1

I need to generate a line graph based on results within a MySQL database, any ideas?

I must also point out that I do not have administrator rights to install things such as JGraph.

7 Answers 7

3

Google has a pretty comprehensive charting API available via javascript calls or simply image links. http://code.google.com/apis/charttools/index.html

Sign up to request clarification or add additional context in comments.

2 Comments

How does this link too a database?
You'd have to use php to pull the data out and form the image src with the data.
1

You can use the GD library, right?

Should be able to use that to do a line graph as an image. You'd have to determine a scale and all that and figure out how to map that to the X and Y coordinates of the image, and then use that to plot the numeric data to the graph and use imageline() to draw the lines for it.

It would be the most compatible method. Java can be turned off and Flash isn't universally supported.

2 Comments

Yea this is the stage that im at
Why can't you use JPGraph if you have support for GD?
0

I don't want to give you a specific library to use, but if you searched google for "flash graph", you'll find a ton of flash graphic software. See http://www.google.ca/search?q=flash+graph&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Note, these don't require anything to be installed on your server (unlike how jpGraph requires GD).

1 Comment

Good advice there, and flash would be a big help. But requirements state that small devices such as iphones (god help me) should be able to view the graph, if i use flash the number of devices able to view the graph will be too small.
0

Check out PHP/SWF Charts.

Comments

0

To support mobile devices, you can use a JavaScript charting library such as Flot (http://code.google.com/p/flot/).

Example : http://people.iola.dk/olau/flot/examples/basic.html

This would work for desktop (IE / Firefoex /Chrome / Safari) as well as mobile (iOS / Android / Blackberry ).

Comments

0

jqPlot has come on in leaps and bounds recently.

A few stand out features from my point of view:

  • Proper implementation of rotated axis labels/text (Google charts can't do this)
  • Ability to plot many graph types including bubble and candlestick plots (like box and whisker plots)
  • jQuery based so easy to integrate if you are already using jQuery
  • Doesn't require an externally hosted API
  • Free

Features from their site:

  • Numerous chart style options.
  • Date axes with customizable formatting.
  • Up to 9 Y axes.
  • Rotated axis text.
  • Automatic trend line computation.
  • Tooltips and data point highlighting.
  • Sensible defaults for ease of use.

I am using jqPlot in a large project at the moment after trialling the following "competitors":

And for fun here is a fully working ASCII pie chart written in pure SQL: http://code.openark.org/blog/mysql/sql-pie-chart

Comments

0

You can make an bar-graph relatively easy with php, html and css.

HTML/CSS part: As pointed out by Col. Shrapnel above:

It's as easy as elementary school math and basic HTML just a couple divs of this kind

<div style="background-color:black;width:50%;">&nbsp;</div>
<div style="background-color:black;width:30%;">&nbsp;</div>
<div style="background-color:black;width:20%;">&nbsp;</div>

Custom bar images: If you would like a slightly fancier bars, you can use your own customs images, manipulated trough the width: CSS property of the < img /> tag.

The search query bellow contains at least 2 comprehensible and easy tutorials, on how to make your own bar graph with PHP/ google search for detailed tutorials

This approach should be less resource consuming on the end-user's computer, compared to JavaScript APIs.

2 Comments

good point, Phoenix, my bad. Here is quite interesting piece of code regarding how to generate a line graph with GD library in PHP. link
You know, it might be possible to do a line graph with just HTML and CSS. Would be a bit of a pain though. You'd need to use the little used rotation CSS options, and you'd have to calculate the angle from the last point to the next one, and the distance between the two. It would be possible, just not very feasible compared to a bar graph.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.