Highcharts Angular update chart with new options - including linked series

本小妞迷上赌 提交于 2020-11-29 19:48:47

问题


Please see my edited demo that uses the official highcharts-angular wrapper.

Initially the chart has a blue series with type:arearange and dataGrouping, as well as a red overplotted series. Note the tooltips refer to the points of the red series. More info in the demo.

The first button will add another such pair of series. The code uses addSeries to do so. It works.

The second button should do the same, but by changing the chart options instead of addSeries. It does not work. The new series appears, but all the red series and tooltips disappear. The desire is to make this method work!

I have studied the (nice) highcharts-angular demos and instructions, but I cannot make it work in my case.


回答1:


If you would like to update the chartOptions, please don't use any API methods like update, addSeries or redraw.
Instead, focus on the options which are declared in the state- chartOptions. This basically means that you have to convert the addAllDummySeries method in order to use that approach.

Please look a the simple example below. We are not using any reverence to the chart, only we are changing the options declared above, not that one generated by Highcharts. By changing the state we are telling Angular to make a redraw.
Demo: https://stackblitz.com/edit/highcharts-angular-optimal-way-to-update-hktwwr

Also in my opinion using the oneToOne flag set to true is not a good idea. Please see the difference in the demo below.
Demo: https://stackblitz.com/edit/highcharts-angular-optimal-way-to-update-w5pnwd



来源:https://stackoverflow.com/questions/64614656/highcharts-angular-update-chart-with-new-options-including-linked-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!