我希望通过示例数据加载带有商店和模型的图表。但是当加载数据时出错:无法读取未定义的属性'items' 我在控制器中创建商店和模型并设置图表值:
count
我希望将此图表添加到面板
var chart = Ext.create('Ext.chart.Chart', {
animate: true,
store: Ext.create('Ext.data.Store', {
model: Ext.create('Ext.data.Model', {
fields: ['temperature', 'date']
}
),
data: [
{temperature: 58, date: new Date(2011, 1, 1, 8)},
{temperature: 63, date: new Date(2011, 1, 1, 9)},
{temperature: 73, date: new Date(2011, 1, 1, 10)},
{temperature: 78, date: new Date(2011, 1, 1, 11)},
{temperature: 81, date: new Date(2011, 1, 1, 12)}
]
}),
axes: [{
type: 'numeric',
position: 'left',
title: 'y',
minimum: 0
},
{
type: 'date',
position: 'bottom',
title: 'x',
minimum: 0
}],
series: [{
type: 'column',
axis: 'left',
highlight: true,
tips: {
trackMouse: true,
width: 140,
height: 28
}
},
{
label: {
display: 'insideEnd',
'text-anchor': 'middle',
renderer: Ext.util.Format.numberRenderer('0'),
orientation: 'vertical',
color: '#333'
},
}
],
});
答案 0 :(得分:0)
无法读取未定义的属性'items',因为您直接创建没有定义的模型实例。
这是小提琴http://jsfiddle.net/djaydxnd/66/
store: Ext.create('Ext.data.Store', {
model:Ext.define('chart', {
extend: 'Ext.data.Model',
fields: ['temperature','date']
}),
data: [
{temperature: 58, date: new Date(2011, 1, 1, 8)},
{temperature: 63, date: new Date(2011, 1, 1, 9)},
{temperature: 73, date: new Date(2011, 1, 1, 10)},
{temperature: 78, date: new Date(2011, 1, 1, 11)},
{temperature: 81, date: new Date(2011, 1, 1, 12)}
]
})