Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing value in highcharts line graph results in no line, just points

please take a look at this:

http://jsfiddle.net/2rNzr/

var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, '', 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

you'll notice that the data has a blank value in it (the second value), which causes the line graph to display incorrectly.

Is this a bug?

What is the correct way of specifying a missing value so there will be a gap in the line graph? i.e. I would NOT want the line graph to simply draw a line between points 1 and 3.

Many thanks for producing an excellent product!

Tony.

like image 535
Tony Avatar asked Feb 27 '13 21:02

Tony


People also ask

How do I show no data available in Highcharts?

Just don't create the highchart and insert text saying "No Data Available". Without any code, this is the most help you're likely to get.

What is point in Highcharts?

The point objects are generated from the series. data configuration objects or raw numbers. They can be accessed from the Series. points array. Other ways to instantiate points are through Highcharts.

What is the default chart type in Highchart?

style: Highcharts. Defaults to {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"} .

How can I tell if Highcharts are loaded?

To determine that chart is fully loaded you can use load event, because load event is invoked when all elements are drown (API reference https://api.highcharts.com/highcharts/chart.events.load). However when you are using series animation this runs in a timeout, then load event is invoked before animation will finish.


2 Answers

You will need to change your missing values to null, and specify that you want a line/spline through the existing values.

var chart = new Highcharts.Chart({

    chart: {
        defaultSeriesType: 'line',
        renderTo: 'container'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, null, 106.4, 129.2, 144.0, 176.0, null, 148.5, 216.4, 194.1, 95.6, 54.4],
    }]

});

see http://jsfiddle.net/xynZT/ with defaultSeriesType: 'spline' as an example.

like image 193
Reality Extractor Avatar answered Nov 10 '22 03:11

Reality Extractor


It's not displaying incorrectly its just plotting a scatter plot. I thinks this is because you don't have a complete series it will be treated like that. I possible, and this depends that your data doesn't use negative number, try to put the collection of no data a 0 such that you have data: [29.9, 0, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4] and this will display a line.

like image 38
LouieV Avatar answered Nov 10 '22 02:11

LouieV