Create multi Line chart based on data from MySQL/Pull down

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Bill on 7th March 2013
OK, I have been struggling with this one a bit.

I have the code figured out to create a multi-line chart (3) based on data pulled from a MySQL database. It graphs a Total count(1), a % of success(2) and a % of fail(3) based on Total count. Heck, I even figured out how to change the scale depending on the Maximum Total Uploads. Sometimes the max can be better than 60,000, sometimes the max can be as few as 40, depending on the retailer, that is currently hard coded into the php script.

What I would really like to be able to do, is have a pull down, that allows someone to choose from 1 of 55 Retailers, and then graph that selection.

I have generated the php files that will populate the pull down with the available retailers, and then a query is run to extract the data from MySQL, then I parse the information into "Total Uploads" "% Success" "% Failed" data strings for the graphs, and also the Y Scale for Total Uploads, Labels, etc. I am able to echo that data to the page in a <div> with no page refresh, so I know the code works.

I would like to be able to do is combine all the parts so that when someone comes to the page, they are presented the pull down, where they select the Retailer, the query is run for the data, and then a RGraph is displayed.

Thanks.
Posted by Enter your name... on 7th March 2013
Hi there,

What's the question? To do it you could either generate the data when the page is loaded and store it in JavaScript arrays - and use the onchange event to switch between the data and redraw the chart. Alternatively you could use the onchange event to trigger some AJAX that retrieves the data and draws the chart.

One thing you may need if you use one canvas for multiple charts is to use the RGraph.Reset() function instead of the RGraph.Clear( function.


Richard

Add a reply




« Back to message list