我有一个带有highcharts的角度项目,使用的是官方的highcharts-angular包装器。我想将数据显示为项目图或实体表。用户应该能够在两者之间切换。当我更改图表的“选项”时,我得到
ERROR TypeError: Cannot read property '0' of undefined
at q.getExtremes (highcharts.src.js:30138)
at q.getExtremes (bullet.src.js:279)
我也尝试按照建议的here使用Series.update方法,但是得到相同的错误。您可以在此stackblitz中重现它。该代码基本上是这样做的:
// initial options
this.chartOptions =
{
series: [{
"type": "solidgauge",
"data": [{ "y": 380.2 }]
}]
};
// after some delay, or when user clicks a button
this.chartOptions =
{
series: [ {
"type": "bullet",
"data": [{ "y": 80.2 }]
} ]
};
答案 0 :(得分:0)
Highcharts中存在一个与更新solidgauge
系列类型:https://github.com/highcharts/highcharts/issues/7746
作为解决方法,您可以更新chart.type
:
setBullet() {
const component = this;
this.chartOptions =
{
chart: {
type: 'bullet',
...
},
series: [...]
};
}
setSolidGauge() {
const component = this;
this.chartOptions =
{
chart: {
"type": "solidgauge",
...
},
series: [...]
};
}
实时示例: https://stackblitz.com/edit/angular-iktja5?file=src/app/chart.component.ts