在HighStock中尝试添加切换按钮以查看绝对值和百分比变化。但是,this.chart.update似乎没有更新图表。
saveInstance(chartInstance) {
this.chart = chartInstance;
}
prcentchg(){
if(this.chart.options.plotOptions.series.compare !== 'percent'){
this.chart.options.title.text = '====> Percent <===='
this.chart.options.plotOptions.series.compare = 'percent';
this.chart.options.tooltip.pointFormat = '<span style="color:
{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>'
this.chart.update(this.chart.options)
console.log(this.chart.series[0])
}else {
this.chart.options.title.text = '====> Absolute Value <===='
this.chart.options.plotOptions.series.compare = 'value';
this.chart.options.tooltip.pointFormat = '<span style="color:{series.color}">{point.y}</span>'
this.chart.update(this.chart.options)
console.log(this.chart)
}
请参阅Plunker链接:PLUNKER LINK