Scatter/MySQL/date

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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 Bruce on 28th March 2013
I'm hoping someone can point me to an example of a scatter chart, using time ( I'm using hourly data, showing 1 day at a time) pulling from mysql. I have part of it but I'm stuck. Oh and there is negative data..

So using the line graph/mysql example I'm getting the data I want. Example:
[0.00, -2.00, -2.58, -3.90, -5.53, -7.58, -6.26, -3.63, -4.78, -4.29, -3.69, -3.27, -4.23, -5.02, -4.50, -5.43, -5.12, -5.42, -5.16, -5.11]
['2013-03-28 00:05', '2013-03-28 01:05', '2013-03-28 02:05', '2013-03-28 03:05', '2013-03-28 04:05', '2013-03-28 05:05', '2013-03-28 06:05', '2013-03-28 07:05', '2013-03-28 08:05', '2013-03-28 09:05', '2013-03-28 10:05', '2013-03-28 11:05', '2013-03-28 12:05', '2013-03-28 13:05', '2013-03-28 14:05', '2013-03-28 15:05', '2013-03-28 16:05', '2013-03-28 17:05', '2013-03-28 18:05', '2013-03-28 19:05']

I can't just feed those two strings to a scatter can I? Scatter wants [ [x, y, color] ] correct?

Thanks in advance for any direction here.
Bruce
Posted by RGraph support on 29th March 2013
Hi there,

If the values are Y values you'll need to put the X axis in the center so that you can show negative values. And you can pass date/time values as X values - RGraph uses Date.parse() to convert them to numbers - there's an example of a Date/time chart here:

dev.rgraph.net/demos/scatter-date-time-values.html

Eg you could have:

['2012/01/05 12:45:45', 6, 'green']

instead of:

[45, 6, 'green']

Alternatively if you data is quite linear (ie you halways have 24 1 hour values) you could use the Line chart.


Richard, RGraph Support

1 Year Priority Support now reduced to £299:
   www.rgraph.net/support

Add a reply




« Back to message list