Kendo ui 奥雷利亚+;剑道-更改数据后如何重新加载剑道饼图?
我试图使用Aurelia和在饼图中显示数据。由于项目需求,我在一个文件中加载了饼图小部件。如果我的数据在页面加载之前可用,则一切正常 查看模型Kendo ui 奥雷利亚+;剑道-更改数据后如何重新加载剑道饼图?,kendo-ui,aurelia,Kendo Ui,Aurelia,我试图使用Aurelia和在饼图中显示数据。由于项目需求,我在一个文件中加载了饼图小部件。如果我的数据在页面加载之前可用,则一切正常 查看模型 export class PieChartCustomElement { chartData = []; chartSeries = [{ type: 'pie', startAngle: 150, field: 'percent', categoryField: 'lang
export class PieChartCustomElement {
chartData = [];
chartSeries = [{
type: 'pie',
startAngle: 150,
field: 'percent',
categoryField: 'languageName'
}];
// other variables
constructor() {
//if I hard-code the data here, all works fine
this.chartData = [
{ languageName: 'English', percent: 62.5 },
{ languageName: 'Spanish', percent: 35 },
{ languageName: 'Esperanto', percent: 2.5 }
];
}
}
查看
<template>
<require from="aurelia-kendoui-bridge/chart/chart"></require>
<h4>pie chart custom element</h4>
<ak-chart k-title.bind="title"
k-legend.bind="legend"
k-series-defaults.bind="chartDefaults"
k-series.bind="chartSeries"
k-data-source.bind="chartData"
k-tooltip.bind="tooltip"
k-widget.bind="pieChart"></ak-chart>
</template>
我很确定这是因为饼图小部件已经加载,并且在其备份数据更改时不会自动重新加载。如果确实是这样,当我更改饼图的数据集时,如何重新加载饼图?如果不是,我做错了什么
-注释/取消注释构造函数/激活事件中的代码,以查看行为。我相信您正在寻找的方法是 在
piechart.js中的attached()
方法中尝试更改
this.chartData = languageData;
到
this.chartData = languageData;
this.pieChart.setDataSource(this.chartData);