x-axis PlotLine value update dynamically without entire chart redraw

In charts 4.0.0 I have not been able to update an x-axis PlotLine value dynamically and have it show unless a drawChart is called afterwards. Even with animation turned off for the DataSeries, it is problematic to call draw on the entire chart each time it is necessary for the PlotLine value to be updated. Is there something I’m missing or is this a known existing limitation?

Hi David,

What implementation of DataSeries are you using?

Have you seen the
“Modify One Point” demo
?

If you check the sources it’s just updating the DataSeriesItem

dataSeriesItem.setY(sliderY.getValue());

And then telling to the series to update that single item

series.update(dataSeriesItem);

Without redrawing the whole chart.

Hi Guillermo,

Yes, I’ve seen the demo. The updating of a data series will work as desired, namely update the data without redrawing the entire chart. However, updating a vertical PlotLine will not. It only updates if the entire chart is redrawn. This is problematic for a few reasons. In the end, I ended up using the flag series feature on the x-axis. It is not as visually pleasing, but works well enough.
Thanks for your help.

Unluckily as you noticed dynamic changes for plotlines do not work out of the box.
I did some tests and it’s possible to remove and add plotlines using javascript, it’s not the best solution but it’s a workaround if you don’t want to redraw the chart:

[code]
Button updatePlotLine = new Button(“Add plotLine”, e → {
PlotLine line = new PlotLine();
line.setColor(SolidColor.RED);
line.setWidth(3);
line.setValue(5);
line.setId(“red-line”);

String scriptRemove = "Highcharts.charts[0]

.xAxis[0]
.removePlotLine(‘"+ line.getId() + "’)";
String scriptAdd = “Highcharts.charts[0]
.xAxis[0]
.addPlotLine(” + ChartSerialization.toJSON(line) + “)”;
JavaScript.getCurrent().execute(scriptRemove);
JavaScript.getCurrent().execute(scriptAdd);
});
[/code]This solution works for the first axis of the first chart (“charts[0]
.xAxis[0]
.”). It could be made more robust by using and id for the axis for instance.

Hope this helps

Hey, Guillermo, that’s terrific! That works very well. Exactly what I was wanting originally. Thanks much for your help.