How does RGraph handle epoch timestamps?
« Back to message list
How does RGraph work with epoch timestamps? I trying to scatter graph where the X axis is date stamps.
var set1 = [
[ 1396411199, 10 ],
[ 1396497599, 11 ],
[ 1396583999, 12 ],
];
How do I get RGraph to show proper dates?
Posted by Richard on 30th April 2014var set1 = [
[ 1396411199, 10 ],
[ 1396497599, 11 ],
[ 1396583999, 12 ],
];
How do I get RGraph to show proper dates?
Hi there,
You set the xmin to the minimum value - eg 951170461, set the xmax to the maximum value - eg 1398844493 and then you scale will effective ly be (in this case) from 2000 - 2014. You can then decide what you want shown on the X axis - could be as many or as few labels as you wish.
There's a demo of a date/time chart here:
view-source:www.rgraph.net/demos/scatter-date-time-values.html
And a note in the docs here about using date/time values instead of numbers for the xmin/xmax values:
www.rgraph.net/canvas/docs/scatter.html#date-time-charts
eg:
obj.set('xmin', '2000-01-01 00:00:00');
obj.set('xmax', '2014-01-01 00:00:00');
Richard
Posted by Neil Watson on 30th April 2014You set the xmin to the minimum value - eg 951170461, set the xmax to the maximum value - eg 1398844493 and then you scale will effective ly be (in this case) from 2000 - 2014. You can then decide what you want shown on the X axis - could be as many or as few labels as you wish.
There's a demo of a date/time chart here:
view-source:www.rgraph.net/demos/scatter-date-time-values.html
And a note in the docs here about using date/time values instead of numbers for the xmin/xmax values:
www.rgraph.net/canvas/docs/scatter.html#date-time-charts
eg:
obj.set('xmin', '2000-01-01 00:00:00');
obj.set('xmax', '2014-01-01 00:00:00');
Richard
It seems very static. Can the range and labels on the x-axis not be determined automatically?
Posted by Richard on 30th April 2014Hi there,
The range is calculated from the difference between the min and max - but the labels are given by you.
Richard
The range is calculated from the difference between the min and max - but the labels are given by you.
Richard
Add a reply
« Back to message list