不与图表 js 一起使用的图表选项
Chart options not used with chart js
我有一个使用图表 js 的 Aurelia 项目。我可以很好地显示图表,但似乎没有使用图表选项。
我有一个执行以下操作的打字稿控制器:
SimpleLineData: LinearChartData;
optionschart: ChartSettings;
activate() {
this.optionschart = this.chartoptions;
this.xx();
setInterval(this.yy.bind(this), 1000);
}
public xx() {
this.SimpleLineData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset 1",
fillColor: '#9b0391',
strokeColor: '#9b0391',
pointColor: '#9b0391',
pointStrokeColor: '#9b0391',
pointHighlightFill: '#9b0391',
pointHighlightStroke: '#9b0391',
borderColor: "#9b0391",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset 2",
fillColor: 'rgba(151,187,205,0.2)',
strokeColor: 'rgba(151,187,205,1)',
pointColor: 'rgba(151,187,205,1)',
pointStrokeColor: '#fff',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(151,187,205,1)',
borderColor: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
}
}
public yy() {
this.SimpleLineData.datasets[0].data[0] = this.x;
this.x++;
}
public chartoptions = {
animation: false
};
在我的 html 中,我这样做:
<chart type="line" style="width: 50%; height: 50%; display: block;" should-update="true" throttle="1000" naive-options="optionschart" data.bind="SimpleLineData"></chart>
当调用 yy()
时,数据会更新,但图表会再次呈现动画。即使我设置了 animation: false
选项。
有人有什么建议吗?
您的 html 中有错字。 naive-options
应更改为 native-options
。它仍然可能不起作用,因为根据 documentation,它应该是 native-options.bind
我有一个使用图表 js 的 Aurelia 项目。我可以很好地显示图表,但似乎没有使用图表选项。
我有一个执行以下操作的打字稿控制器:
SimpleLineData: LinearChartData;
optionschart: ChartSettings;
activate() {
this.optionschart = this.chartoptions;
this.xx();
setInterval(this.yy.bind(this), 1000);
}
public xx() {
this.SimpleLineData = {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [
{
label: "My First dataset 1",
fillColor: '#9b0391',
strokeColor: '#9b0391',
pointColor: '#9b0391',
pointStrokeColor: '#9b0391',
pointHighlightFill: '#9b0391',
pointHighlightStroke: '#9b0391',
borderColor: "#9b0391",
data: [65, 59, 80, 81, 56, 55, 40]
},
{
label: "My Second dataset 2",
fillColor: 'rgba(151,187,205,0.2)',
strokeColor: 'rgba(151,187,205,1)',
pointColor: 'rgba(151,187,205,1)',
pointStrokeColor: '#fff',
pointHighlightFill: '#fff',
pointHighlightStroke: 'rgba(151,187,205,1)',
borderColor: "rgba(151,187,205,1)",
data: [28, 48, 40, 19, 86, 27, 90]
}
]
}
}
public yy() {
this.SimpleLineData.datasets[0].data[0] = this.x;
this.x++;
}
public chartoptions = {
animation: false
};
在我的 html 中,我这样做:
<chart type="line" style="width: 50%; height: 50%; display: block;" should-update="true" throttle="1000" naive-options="optionschart" data.bind="SimpleLineData"></chart>
当调用 yy()
时,数据会更新,但图表会再次呈现动画。即使我设置了 animation: false
选项。
有人有什么建议吗?
您的 html 中有错字。 naive-options
应更改为 native-options
。它仍然可能不起作用,因为根据 documentation,它应该是 native-options.bind