Discontinuous line with zero or null values


« 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 Brandon on 26th January 2016
Hi,

I tried to generate a linechart using the same dataset with rgraph. When comparing it with another chart generated by another library, I found some parts of the graph are not drawn and appear to be missing.

These are the comparison graphs:
1. From rgraph: imgur.com/DlSlfTn
2. From another program : imgur.com/Se1GqPh

Is there a way to make the generated charts from rgraph to not ignore 0 values or plot continuously no matter the values? Would appreciate the help. Thanks
Posted by Richard on 26th January 2016
Hi there,

If they are indeed 0 (as opposed to null) then they're probably not being plotted because 0 is off the chart (you have a minimum set). So you could the outorbounds property to true.

...
outofbounds: true,
...

Richard
Posted by Brandon on 26th January 2016
Thanks a lot for the help!

The solution works but the lines are drawn outside the boundaries and look rather messy. Is there a method to draw a layer of rectangle before the axis labels are drawn? The purpose is to clip those out-of-bounds lines.
Posted by Richard on 26th January 2016
Hi there,

The best way would be to pre-process your data first. Eg say your data is:

var data = [1,2,4,3,6,7,8,4,1,9,6,5];

But you only have a minimum of two. Then simply loop through the data first and set anything below two to two. Like this:

for (var i=0; i<data.length; i++) {
     if (data[i] < 2) {
         data[i] = 2;
     }
}

Richard
Posted by Brandon on 27th January 2016
This solution works perfectly. Thanks a lot!
Posted by Richard on 27th January 2016
Hi there,

It works, but I was thinking last night that it does result in different angles for the line. Consider the simple dataset: [2, 2,-10,2, 2] Now if the minimum is 1 then the dataset becomes: [2,2,1,2,2] And the dip in the line is less steep than it was before. So I'll be looking into adding an outofboundsClip option that matches your use case and doesn't involve changing the data.

Richard

Add a reply

 




« Back to message list
RGraph on social media