Empty data points cause Line chart to go off chart

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 takeflight on 11th April 2013
Using the latest stable rgraph distro, I'm noticing that when I have an empty data point, the point gets drawn off the chart, going into the positive.

I found a bug from late 2012 where someone has the same issue, but with the word 'null' as the data point. Mine end up looking like this:

var line = new RGraph.Line('sensor1graph', [47, 47, , 48, 48, 49, 49, 49, 49, 50, 49, 64, 66, 67, 55, 53, 49, 48, 48, 47]);

Notice the third value is blank. This causes the line to shoot up low orbit.

chart.outofbounds does nothing to fix this it seems.

What am I doing wrong?

BTW, thanks for this product! Great stuff!
Posted by RGraph support on 11th April 2013
Hi there,

Instead of leaving the value undefined, set it to null instead:

var line = new RGraph.Line('sensor1graph', [47, 47, null, 48, 48, 49, 49, 49, 49, 50, 49, 64, 66, 67, 55, 53, 49, 48, 48, 47]);

PS Please remember to link to the RGraph website - cheers!

Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five.developer
Posted by takeflight on 11th April 2013
Just tried this with null values:

var line = new RGraph.Line('sensor1graph', [47, 47, 48, 48, 49, 49, 49, 49, 50, 49, null, null, null, null, null, 64, 66, 67, 55, 53, 49, 48, 48, 47]);

Same thing, the line spikes into the positive.


Here is my whole chart:


var thermometer = new RGraph.Thermometer('greenhouse', 0,120,47);
var line = new RGraph.Line('sensor1graph', [47, 47, 48, 48, 49, 49, 49, 49, 50, 49, null, null, null, null, null, 64, 66, 67, 55, 53, 49, 48, 48, 47]);


  line.Set('chart.labels', ['0','1','2','3','4','5','6', '7', '8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23']);
         line.Set('chart.linewidth', 4);
         line.Set('chart.labels.above', true);
         line.Set('chart.colors', ['black']);
  line.Set('chart.ylabels', 9);
  line.Set('title', 'greenhouse 4.10.2013');
  line.Set('chart.ymin', 0)
  line.Set('chart.ymax', 120)
  line.Set('chart.background.barcolor2', 'rgba(0,0,0,0.1)');
  line.Set('chart.background.barcolor1', 'rgba(0,0,0,0.05)');
  line.Set('chart.filled', true);
  line.Set('chart.fillstyle', 'rgba(0,0,0,0.2)');
         line.Set('chart.shadow', true);
  line.Set('chart.animation.unfold.initial', 0);
  line.Set('chart.spline', true);
  line.Set('chart.ylabels.count', 12);
         line.Draw();
Posted by RGraph support on 11th April 2013
Hi there,

It works if you don't use a spline:

dev.rgraph.net/tests/line/null_values.html

(bottom chart)


Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five.developer
Posted by takeflight on 11th April 2013
Spline gone, now even empty data points, not just 'null' values, do the correct behavior. Thanks for your time!
Posted by Zsolt on 19th April 2013
Hi there,

I am new to RChart and amazed by the long list of features it supplies. However, I run into the same problem - or very similar - and figured out that it was the spline() function which cannot cope with nulls. However, I would still be happy to use the spline curving.

I am drawing a chart which gets filled dynamically over the day. I have to insert nulls in the data array for the "future" part of the day, where I have no chart. And the spline() is very welcome;) However, I cannot use it, because it spikes the line into the positive. It should not draw it.

Any suggestions?

many thanks,

Zsolt
Posted by RGraph support on 19th April 2013
Hi there,

The spline chart doesn't support null values I'm afraid. If you don't use the chart.spline option you should find that null values are fine and that you just get gaps in your data.



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer
Posted by Zsolt on 19th April 2013
Thanks for the answer. If I don't use the chart.spline option I get another chart. My question was if it was possible (in a future release) to draw incomplete curvy charts (which don't cover the full x axis, like any dynamic chart.)

cheers,

Zsolt
Posted by RGraph support on 22nd April 2013
Hi there,

Possibly in a future release - but I don't have any plans to tackle it at the moment.



Richard, RGraph Support

5 developer license with Priority support for £299:
   www.rgraph.net/license#five-developer

Add a reply




« Back to message list