我从事的项目使用Angular 4 + Highcharts 5.0.14
我想使图表响应。为此,我想使用API和定义的responsive
属性。但是以下代码会引发错误:
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
错误:
[ts] Argument of type '{ title: { text: string; }; subtitle: { text: string; }; yAxis: { title: { text: string; }; }; le...' is not assignable to parameter of type 'Options'. Types of property 'responsive' are incompatible.
Type '{ rules: { condition: { maxWidth: number; }; chartOptions: { legend: { layout: string; align: str...' is not assignable to type 'ResponsiveOptions[]'.
Object literal may only specify known properties, and 'rules' does not exist in type 'ResponsiveOptions[]'.
似乎为responsive
属性使用数组而不是对象不会产生错误,但不能在chartOptions
内设置任何其他属性:
responsive: [{
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
}
}]
}]
由于我是Angular和Highcharts的新手,所以我不明白为什么会发生错误。