0

I am trying to draw a line graph with multiple lines on it. Some of the lines have null values at the start (do not have measurements for all early values). When the lines are set to be splines, the splines extrapolate the null values to be very high. I want the splines to start where the values start and not to extrapolate.

var data = [[0.775,1.460,2.218,2.800,3.522,5.056,8.500,14.012,17.341,19.059,15.038,8.888,],
[,0.727,2.057,4.225,5.677,7.842,10.930,14.824,18.418,19.248,14.138,9.666,],
[,0.627,2.530,5.134,8.312,12.452,17.047,20.548,22.542,22.016,15.315,9.525,],
[,,0.556,4.679,9.442,13.284,19.225,23.606,26.523,23.362,15.818,9.385,],
[,,0.506,2.998,7.891,12.243,18.559,25.529,24.443,23.574,16.200,9.291,],
[,,0.444,3.082,6.877,12.420,17.558,23.496,26.848,26.281,15.746,9.332,],
[,,0.382,2.948,6.935,11.296,17.782,23.572,23.354,24.772,16.563,9.593,],
];
var line = new RGraph.Line({
            id: 'cvs2',
            data: data,
            options: {
                textFont: 'Yantramanav',
                textSize: '8',
                textColor: '#444',
                BackgroundBarcolor1: 'white',
                BackgroundBarcolor2: 'red',
                BackgroundGridColor: 'rgba(238,238,238,1)',
                linewidth: 1,
                filled: false,
                fillstyle: ['red','blue','#0f0'],
                hmargin: 5,
                shadow: false,
                tickmarks: 'circle',
                spline: true,
                gutterLeft: 40,
                labels: ['2','4','8','16','32','64','128','256','512','1024','2048','4096',],
colors: ['hsl(172,50%,50%)','hsl(35,50%,50%)','hsl(257,50%,50%)','hsl(120,50%,50%)','hsl(342,50%,50%)','hsl(204,50%,50%)','hsl(67,50%,50%)',],
} }).draw();

You can see that the null values all start high up the y-axis. If the line is set to spline: false, the lines start where they have values and do not interpolate some random wrong value.

enter image description here

I have tried setting spline to false, and lines start where I expect them to - once they have non null data.

1 Answers1

0

Spline Line charts don't support null values I'm afraid. You'll have to go with non-spline charts in order to allow null values in your dataset

Richard
  • 4,809
  • 3
  • 27
  • 46
  • Thank you. I have now looked at the code for drawing curvy lines in RGraph, and I can see it has no features for this. – Matt Palmer Apr 01 '23 at 12:18
  • 1
    I managed to hack the code a bit so that it only starts drawing when it has non null values, and stops if there are null values at the end. It doesn't interpolate any null values in the middle, but this works for me as my data can have null values in the start or end, but not in the middle. – Matt Palmer Apr 01 '23 at 12:19
  • Did you have much trouble finding the relevant place in the code (ie the drawSpline() function)? – Richard Apr 01 '23 at 16:37