构建应用程序后呈现图表饼图期间的初始化错误

时间:2016-03-15 15:16:35

标签: extjs extjs4.2 sencha-cmd

构建我的应用程序后,异常" TypeError:j.initialize不是函数"发生。仅当我构建应用程序而不是调试模式时才会发生此错误。

在ext-all.js的这一行:

j.initialize();

我资助extjs代码中出现的情况,但我不明白为什么。

使用的extjs版本:4.2.2 - build 1444 使用的CMD版本:4.0.2.67

我的图表饼图代码:

                           {
                                xtype:'chart',
                                renderTo: Ext.getBody(),
                                legend:false,
                                width:120,
                                height:120,
                                animate: true,
                                store: 'PagesCountDetailsPieStore',
                                itemId:'pieChartProjectDetailsDashboard',
                                shadow:false,
                                series: [{
                                    type: 'pie',
                                    donut:60,
                                    angleField: 'data'
                                }]
                            }

使用的商店:

Ext.define('Saas.store.PagesCountDetailsPieStore',{
extend:'Ext.data.JsonStore',
storeId:'pageCountDetailsPieStoreItemId',
autoLoad:true,
fields:['name','data'],
data: [
    { 'name': 'metric one',   'data': 10 },
    { 'name': 'metric two',   'data':  7 },
    { 'name': 'metric three', 'data':  5 },
    { 'name': 'metric four',  'data':  2 },
    { 'name': 'metric five',  'data': 27 }]

});

文件ext-all.js中出现错误:

initializeSeries: function(j, m, a) {
var k = this,
    g = k.themeAttrs,
    d, h, o, q, p, n = [],
    e = (j instanceof Ext.chart.series.Series).i = 0,
    c, b;
if (!j.initialized) {
    b = {
        chart: k,
        seriesId: j.seriesId
    };
    if (g) {
        o = g.seriesThemes;
        p = g.markerThemes;
        d = Ext.apply({}, g.series);
        h = Ext.apply({}, g.marker);
        b.seriesStyle = Ext.apply(d, o[a % o.length]);
        b.seriesLabelStyle = Ext.apply({}, g.seriesLabel);
        b.markerStyle = Ext.apply(h, p[a % p.length]);
        if (g.colors) {
            b.colorArrayStyle = g.colors
        } else {
            n = [];
            for (c = o.length; i < c; i++) {
                q = o[i];
                if (q.fill || q.stroke) {
                    n.push(q.fill || q.stroke)
                }
            }
            if (n.length) {
                b.colorArrayStyle = n
            }
        }
        b.seriesIdx = m;
        b.themeIdx = a
    }
    if (e) {
        Ext.applyIf(j, b)
    } else {
        Ext.applyIf(b, j);
        j = k.series.replace(Ext.createByAlias("series." + j.type.toLowerCase(), b))
    }
}
j.initialize();
j.initialized = true;
return j

},

1 个答案:

答案 0 :(得分:0)

这似乎是编译器问题。

您只需在视图顶部手动添加一个需求条件,即可获得图表所需的全部功能。

    requires:[
       'Ext.chart.series.Pie',
       'Ext.chart.series.Series',
       'Ext.chart.Chart',
       'Ext.data.Store'
    ]