我正在尝试用从API加载的数据来显示余烬中的图表。图表中显示的数据是根据API的不同值计算得出的。因此,我要在包含API数据作为模型的路线上显示图表的第一种方法是将示例图表数据添加到现有模型中。以下是该方法的代码:
model(params){
return this.store.findRecord('histogram', params.name).then((result) => {
result.set('chartData',{
labels: ['Value 1', 'Value 2', 'Value 3'],
series: [[71, 46, 59]]});
});
}
所以我的问题是:
当没有现有模型的相同代码(以下示例)正常工作时,为什么上面的示例不起作用?
model: function () {
return {
chartData: {
labels: ['Value 1', 'Value 2', 'Value 3'],
series: [[71, 46, 59]]
}
};
}
提前谢谢了。
您的模型函数应返回结果。但是我不确定您要尝试什么,但是如果您想包含多个模型,请考虑使用Ember.RSVP.hash
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句