Search code examples
javascriptchartshighchartsextend

Extending highcharts line series to end of chart


I have a Highcharts line chart with multiple series. The X axis is a datetime axis. One series is a step line and the max data point for this can finish before the other series on the x axis, e.g. 5 days before the end.

Is there an easy way of extending this line to the end of the chart automatically without filling in the extra data points before the data is passed to Highcharts? The line should just carry on to the end of the chart at the same y coordinate as the last plotted point.

I have already tried setting minPadding and maxPadding to 0 along with start/endOnTick to false, but this had no effect.

Thanks!


Solution

  • See answer here:

    continue the line drawing on dotnet highchart

    The basic idea is to

    1) retrieve the final y value of your data

    2) retrieve the final x value that you want it to extend until

    3) add a new point to the data with those x and y values.