Is it possible to use milliseconds in date/time values for Scatter plots?


« 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 Jim on 2nd November 2016
Dear Richard,

RGraph is awesome (not a word I normally use...) - thank you.

I'm supplying time values as X data to a Scatter plot. Does the code support millisecond values please?

I've tried two formats: "12:30:44.123" and "12:30:44 123" so far, and both give 'NaN' values on the X axis.

Many thanks,
Jim
Posted by Richard on 2nd November 2016
Hi there,

I looked at the spec for the Date.parse() function and it may or may not support it (it was a brief look), my quick test in Chrome said no.

However you can bypass it by specifying raw millisecond values instead (RGraph converts the dates to millisecond values internally).

So you could do something like this (still using the RGraph date parsing for the main bit of the date):

var date = RGraph.parseDate('2016-12-25 00:00:00');
var ms = 485;

alert(date + ms);

You can either use dates for the ymin/ymax values and let RGraph parse them or use millisecond values here too.




Richard
Posted by Jim on 2nd November 2016
Many thanks Richard, now I can see the data!

So I'm now using something like:

    var line1 = new RGraph.Scatter({
     id: 'canvas1',
     data: [ [ [36670,1.000],[36673,2.000],[36675,1.000],[36681,3.000],[36692,2.000],[36694,1.000] ], [ [36670,2.000],[36673,3.000],[36675,2.000],[36681,5.000],[36692,3.000],[36694,2.000] ] ],
     options: { ...

The time values have come from extracting seconds and milliseconds from full DateTime values (I'm working in C#, generating HTML and js). It's not a complete solution, as although the time range is only a few seconds, it might cross minute or hour boundaries.

But the time values are too big for the X axis and overwrite each other - can I get more control over the axis labelling?

Also, is there an equivalent to 'xscaleDecimal' for the Y axis please?

Thanks again,
Jim
Posted by Richard on 2nd November 2016
Hi there,

You could use the xscaleFormatter option that allows you to give a function that returns the "formated" label.

And yes there's also an xscaleDecimals property - though if you're using the xscaleFormatter option you might not need it.

www.rgraph.net/docs/scatter.html#axis%20properties



Richard
Posted by Jim on 2nd November 2016
Many thanks Richard.

I was wondering about a possible 'yscaleDecimals' property, for the Y axis?
Posted by Jim on 2nd November 2016
Sorry, got it now. It's just 'scaleDecimals'.

Add a reply

 




« Back to message list
RGraph on social media