Highcharts: Displaying Linechart with missing data

2019-04-15 21:45发布

问题:

I am calculating the average-value of properties for each week of the year. And I want to display these information in a line chart (x-Axis is the week of year, y-Axis the average value and the different lines represent different properties).

But for any given property I do not necessarily have a datapoint for each week of the year. If I do not have such a datapoint I want my line for this property to interpolate between the datapoints I have.

Anyone else run into a similiar issue?

回答1:

Highcharts does not really do interpolation. Sure, if your series has a missing point it will draw the line between the adjacent two...but it is not a calculated "value" that you would want to publish. It is just the shortest distance between those two adjacent points. I would pre-process your data to fill in the missing points and then label these points as calculated with either a Note: value or maybe a color: value. Example where the second value is coming from your pre-processing:

data: [{ y: 7.0},
        {y: 6.9,
         Note: 'calculated',
         color: '#BF0B23'},
        {y: 9.5}]