Extjs - 在添加图表时获取'TypeError:name is undefined'

时间:2013-08-27 12:05:58

标签: javascript extjs extjs4

当替换图表时,其他一些这样的网格都很好。 也许宣言图中有一些错误? 我的图表页面(projecttaskstatistics):

Ext.define('yTrack.view.project.Task.Statistics' , {
    extended: 'Ext.chart.Chart',
    alias: 'widget.projecttaskstatistics',
    width: 500,
    height: 300,
    animate: true,
    store: 'Tasks.Timehistory',
    axes: [{
        type: 'Time',
        position: 'bottom',
        fields: ['time'],
        dateFormat: 'G',
        title: 'Use of time',
        grid: true
    }, {
        type: 'Category',
        position: 'left',
        fields: ['user_name'],
        title: 'Users'
    }],
    series: [{
        type: 'bar',
        axis: 'bottom',
        highlight: true,
        tips: {
            trackMouse: true,
            width: 140,
            height: 28
            renderer: function(storeItem, item) {
                this.setTitle(storeItem.get('user_name') + ': ' + storeItem.get('time') + ' views');
            }
        },
        label: {
            display: 'insideEnd',
            field: 'time',
            renderer: Ext.util.Format.dateRenderer('G:i'),
            orientation: 'horizontal',
            color: '#333',
            'text-anchor': 'middle'
        },
        xField: 'user_name',
        yField: 'time'
    }]
});

我可以找到错误。帮助我。

3 个答案:

答案 0 :(得分:1)

有错误,不确定。

正如德鲁所指出的,有一个缺失的结肠。

此外,你应该修改这一行:

extended: 'Ext.chart.Chart',

到此:

extend: 'Ext.chart.Chart',

但是,您不需要扩展课程。

答案 1 :(得分:0)

你的代码中缺少逗号(在你的提示配置中高度:28之后),尝试这个并让我知道它是否有效:

Ext.define('yTrack.view.project.Task.Statistics' , { extend: 'Ext.chart.Chart', alias: 'widget.projecttaskstatistics', width: 500, height: 300, animate: true, store: 'Tasks.Timehistory', axes: [{
        type: 'Time',
        position: 'bottom',
        fields: ['time'],
        dateFormat: 'G',
        title: 'Use of time',
        grid: true
    }, {
        type: 'Category',
        position: 'left',
        fields: ['user_name'],
        title: 'Users' }], series: [{
    type: 'bar',
    axis: 'bottom',
    highlight: true,
    tips: {
        trackMouse: true,
        width: 140,
        height: 28,
        renderer: function(storeItem, item) {
            this.setTitle(storeItem.get('user_name') + ': ' + storeItem.get('time') + ' views');
        }
    },
    label: {
        display: 'insideEnd',
        field: 'time',
        renderer: Ext.util.Format.dateRenderer('G:i'),
        orientation: 'horizontal',
        color: '#333',
        'text-anchor': 'middle'
    },
    xField: 'user_name',
    yField: 'time' }] });

答案 2 :(得分:0)

我遇到了同样的问题,并通过以下更改得到了解决

删除 ext-all-debug.js

<script src="ext-4.2.0.663/ext-all-debug.js"></script>

添加 ext-all.js

<script src="ext-4.2.0.663/ext-all.js"></script> 

似乎它是ExtJs Debugger .js文件中的一个错误。

试试吧。它会得到解决。