Wijmo 5 flex chart doesn't work with knockout foreach binding

有些话、适合烂在心里 提交于 2019-12-10 17:55:57

问题


I want dynamically update the values(or add extra legend item) on my chart thus I can't use the 'hardcoded' html markup from the flexchart example page. the problem is that foreach binding inside wjFlexChart block doesn't work at all. here's my code:

View:

<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>

ViewModel:

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
     }]
   });
}

Any ideas?

来源:https://stackoverflow.com/questions/30321738/wijmo-5-flex-chart-doesnt-work-with-knockout-foreach-binding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!