views:

137

answers:

7

I want to take data from a table that'll be almost exactly similiar to the one below, but have it in a line graph. The date values would be on the Y-axis, and it would plot the XP values on the X-axis. Since the numbers for each user vary, I'd need a way to make the distance between each point plotted "relative", I guess.

Example table

Any suggestions?

+1  A: 

It's better to get the data from the data source, not from the rendered table. Anyway it's 2 separate questions: how to take data from a table and how to draw a graph.

drawing a chart in PHP is pretty easy. HTML/CSS can be used to draw a bar and PHP to calculate bar length

Col. Shrapnel
The data is generated from a database, and put into a table. I want to give them the option of viewing it in a graph, as well.
Andrew
A: 

I would go for HighCharts.

Roberto Aloi
+1  A: 

If you want to generate a static image of the chart you could use Libchart or pChart for PHP.

wimvds
+1  A: 

Or if you want to go the javascript route, maybe Raphaël? http://raphaeljs.com/

Chad
A: 

I've used the following from PHP: google charts, open flash chart, YUI charts (flash), and amcharts (also flash).

They're all pretty easy to use, and all have their pros and cons. If you want to show more than a single graph on one page, don't use flash-based charts -- turns out browsers have trouble displaying a dozen flash charts all at once. AMCharts is probably the most feature rich, but the options available depend on which of their chart packages you select, and configuration is pretty complex.

Frank Farmer
A: 

If you're using a linux/unix platform, you probably already have Gnuplot installed. Gnuplot can take a plot file and a datafile and generate an image, thus:

History.gnuplot, which needs to be generate first:

set title "Rawr_satch history"
set xlabel "Time"
set ylabel "Ranking"
set output "rawr_satch_graph.png"
set terminal png color
set xdata time
plot "rawr_satch_xphistory.dat" with linespoints

Which assumes a data file rawr_satch_xphistory.dat has already been generated, formatted thus:

2010-03-06 385581123
2010-03-05 384895430
2010-03-04 382983388

People have also written interfaces into Gnuplot for most languages, for example PHP-GNUPlot. Gnuplot scripts can be quite complex, and you could plot multiple variables, etc.

Phil H
A: 

I use and fully recommend the Google Chart Tools API. If you're looking for a simple line-graph, they provide a very simple API that you can call that requires no installation or configuration. Some of the documentation is confusing, but I've been able to figure it out with a little bit of patience.

All that is required is an IMG tag and point the src to the Google URL with the right parameters.

alt text

They also have a more interactive Javascript library if you want to provide more functionality later on.

MattGWagner