0

I'm trying to add an chart to my Sencha Touch app.

I have added a view like this and inserted a chart how I saw it on a couple of sites:

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

But now I got in an Error in the Console of the browser: Uncaught Error: [Ext.createByAlias] Cannot create an instance of unrecognized alias: axis.Category.

This is my require-part in the app.js:

requires: [
        'Ext.MessageBox',
        'Ext.dataview.List',
        'Ext.chart.Chart',
        'Ext.chart.axis.Numeric',
        'Ext.chart.axis.Category'
],

Can somebody help me with this?

4

2 回答 2

1

,等是区分大小写的,库中的都是小写的typextype

因此,更改type: 'Category'type: 'category'type: 'Numeric'type: 'numeric'您的代码将运行。

您还应该阅读有关xtype的文档。此选项用于指示要创建的组件类型,而不必自己使用new关键字(允许延迟初始化)。xtype 选项仅在您要实例化的对象的上下文中有意义,而不是您定义的对象。因此,您的代码中的这一行无效:

xtype: 'graph',
于 2013-05-27T18:40:24.003 回答
0

您在此处包含 Sencha Touch 2 Charts 2 Beta 吗?如果是这样,你到底是怎么做到的?下载后请从头开始——我是菜鸟 :)

于 2013-06-18T07:46:48.067 回答