我想动态更新图表上的值(或添加额外的图例项),因此我不能使用flexchart 示例页面中的“硬编码”html 标记。问题是 wjFlexChart 块内的 foreach 绑定根本不起作用。这是我的代码:
看法:
<div data-bind="wjFlexChart: { itemsSource: data, bindingX: 'week' }">
<div data-bind="foreach: $data.legend">
<div data-bind="wjFlexChartSeries: { name: name, binding: value}"></div>
</div>
</div>
视图模型:
data = new wijmo.collections.ObservableArray();
weeks = 'wk1,wk2,wk3,wk4,wk5,wk6,wk7,wk8'.split(',');
...
for (var i = 0; i < this.weeks.length; i++) {
this.data.push({
week: this.weeks[i],
legend: [{
name: 'name1_'+i,
value: Math.random() * 10
},{
name: 'name2_'+i,
value: Math.random() * 10
}]
});
}
有任何想法吗?