我正在尝试将图表添加到我的Sencha Touch应用程序中。用Sencha Touch 2创建图表?
我加入了这样的观点,并插入图表我怎么看见它的一对夫妇的网站:
Ext.define('dergraph.view.Graph', {
extend: 'Ext.Container',
xtype: 'graph',
requires: [
'Ext.TitleBar'
],
config: {
tabBarPosition: 'bottom',
layout: 'fit',
items: [
{
xtype: 'chart',
animate: true,
store: 'dergraph.store.PhoneBook',
legend: {
position: 'right'
},
axes: [{
type: 'Category',
fields: ['firstName'],
position: 'bottom', //x-axis
title: 'Category'
}, {
type: 'Numeric',
fields: ['value'],
position: 'left', //y-axis
title: 'Value'
}]
}
]
}
});
但现在我在浏览器的控制台中的错误有:未捕获的错误: Ext.createByAlias]无法创建无法识别别名的实例:axis.Category。
这是app.js我需要部分:
requires: [
'Ext.MessageBox',
'Ext.dataview.List',
'Ext.chart.Chart',
'Ext.chart.axis.Numeric',
'Ext.chart.axis.Category'
],
有人可以帮我吗?
谢谢,它现在可以工作! 我以前在main.js中的xtype查看该网站是这样的: { 的xtype: '曲线' 标题: '图表', iconCls: '撰写' } 是不是错了? – torhoehn
要在Ext4或Touch中创建新的xtype,您应该在定义中使用[别名](http://docs.sencha.com/touch/2.2.1/#!/api/Ext.Class-cfg-alias) :'别名:widget.graph'。然后,你可以使用例如'Ext.widget({title:'Graph',xtype:'graph'})'或者作为item,'Ext.widget({xtype:'panel',items:[{xtype :'graph'}]})'。不过,不确定这对主视图非常有用。 – rixo