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 http://img687.imageshack.us/img687/4175/tablel.png
Any suggestions?
If you want to generate a static image of the chart you could use Libchart or pChart for PHP.
It's better to get the data from the data source, not from the rendered table. Anyway it's two 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 the bar length.
Or if you want to go the JavaScript route, maybe Raphaël.
I would go for HighCharts.
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.
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.
They also have a more interactive Javascript library if you want to provide more functionality later on.
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. It 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.
Related
I'm looking for quite a specific technique.
The short of it:
I need HTML which can generate a line chart, as shown below (but without the background image. That is totally irrelevant)
However, I want to make it in HTML, without Javascript or Flash and in a way that the dots can be hovered to show more information.
The long of it:
The image shown above comes from the website jpgraph.net. That is a PHP library for creating charts. The downside of that however, is that it generates images. Since you have no clue of knowing where the dots are going to end up, you can't estimate where the hovers should be made.
Ofcourse there are also loads of javascript ways of doing this, but the graph should also work without javascript.
Flash is out of the question, since it should also work on tablets (read iPads)... And because it is flash...
All the information shown in the graph is generated by an external system. That means that the code should work and change the graph, depending on the information put in there.
EDIT:
I'm aware of the fact that it is easily done with javascript, and my fallback would be to offer a javascript version and as a fallback the php version. However, I'm hoping to find a way which doesn't need a fallback. Using 1 script to do the same task would be better than using two.
You should check out Charts.js by Nick Downie.
It has simple HTML5 Charts using the canvas element -
Charts and Graphs Included:
Bar Chart
Doughnut Chart
Line Graph
Pie Chart
Polar-area Chart
Radar Chart
Read the documentation here: http://www.chartjs.org/docs/
and download on GitHub here: https://github.com/nnnick/Chart.js
Hope I Helped
For those still interested: I fixed this using the jpgraph.net library. It's a php library which allows you to draw graphs on the server using data you get from somewhere else.
As enhzflep pointed out, since you have the data, you can calculate where the points will end up. This is however, quite a tedious job, but it's working in javascript-less browsers.
I want to plot some data into a web graph control(preferably javascript or php). The data is collected regularly from a microcontroller, however the data collection interval is not linear. For instance, I may collect 5 data points in one day, and then 2 data points the next, and at different intervals etc...
Is there a graphing tool that can automatically create a linear datetime axis such that the data is represented properly on the graph.
jquery's jqplot does the trick.
You can use jqplot as James Cotter says, but there are also :
Highcharts.js (apparently the best JS out there, but restrictive license)
Google Charts Tools (generate a graph from an URL, it returns a PNG image)
Depending on your needs, I'd definitely use Google Charts Tools as it'd decrease my bandwidth usage. However, if you need complex manipulation of your datas once the chart is displayed, use Highcharts.js (or jqPlot).
I have a project to draw relationships between different elements determined on a sheet.
When the user has finished making the plan, it can export it to a txt file that contains the links.
A bit like MS Visio but with only three or four elements draguable.
Does anyone have an idea of this project using web languages (php, js) ?
Thank you in advance.
I am not so sure of your question but if you want to draw graphs using php variables with javascript, then the html5 canvas is probably your best bet in terms or proffessionality with design and implementation.
Only downside is it is javascript only, and the user must have a browser that supports canvas.
Take a look at Raphael, you can make your users draw anything you want, export the structure as JSON,for example, and treat it with any language you want
Take a look at this Raphael example to see an interconnected graph
I sampled a small wikipedia collection from 2008 and trying generate a graph similar to this: http://en.wikipedia.org/wiki/File:Wikipedia-n-zipf.png
from the processing I did. I have word frequencies and ranks of words. How can I generate the graph on the fly from the data I collected? Thanks.
If I am understanding your question correctly, you want to generate PNG charts on the fly?
This Page lists a few great chart engines for PHP. If you want to generate graphics using PHP for word frequencies, my personal favorite is PCHART It is a really nice library to generate charts like that.
Google Chart is completely free and doesn't use as much server power, but you have much less control over caching, styling, etc. The key difference here is that the actual image generation is done by Google.
If you want it to look exactly like that, you can use any of them and use the most basic settings to get what you need.
I think you want to use the google chart api / graph tools.
You can find it here
Line charts documentation and examples
I would like to create a stacked bar chart based on data from a text file USING PHP ... ( The file name must be on the x axis ... n based on the data read inside the file, y axis stack bars must be populated )
If you could provide me with code snippets and suggest the best libraries to use for this specific "dynamic stacked bar graph " creation, it'd be really helpful .
Thanks a lot
What format is your data in?
I've used, and like pChart (The site has good examples). There is a new version out but I have yet to use that. They can do stacked bar charts
Fusion charts has both a free and paid version. The paid version has stacked bar charts (Not sure about the free) and they have examples on their site.
Both can be dynamic in generating graphs. It really depends on your needs.
If it does not HAVE to be PHP there are javascript options that can read data from a file as well.
This is kind of a broad question, and it seems like some Googling might be useful here.
That being said, I'd take a look at Highcharts. It's a JavaScript library that draws graphs based on input data, which can easily be generated using PHP.
I currently use it with a Ruby on Rails app, and it works really well.