1

extjs4 MVC フレームワークの一部としてビューで使用するチャート クラスを拡張したいと考えています。firebug で次のエラーが発生します。

config is undefined 
[Break On This Error] me.initTheme(config.theme || me.theme);
Chart....8936564 (line 191)

これはクラス定義です:

Ext.define('CDR.chart.Daily', {
alias: 'widget.dailychart',
extend: 'Ext.chart.Chart',    
initComponent: function() {
    Ext.apply(this, {
        id: 'daily',
        insetPadding: 30,

     ... irrelevant code cut .......

    });          
    this.callParent(arguments);
  }
});

これは、グラフが追加されるビュー クラスです。

Ext.define('CDR.view.trunk.View', {
alias: 'widget.trunkview',
extend: 'Ext.panel.Panel',    
requires: [
    'CDR.chart.Daily'
],        
initComponent: function() {
    Ext.apply(this, {
        id        : 'itemCt',
        border    : false,
        autoScroll: true,
        layout: {
            type : 'hbox',
        },            
        items: [
            Ext.create('CDR.chart.Daily'),
            {
                id    : 'contentCt',
                width : 500,
                border: false
            }
        ]
    });                
    this.callParent(arguments);
  }    
});
4

2 に答える 2

2

「テーマ」にはデフォルトで「ベース」値が必要ですが、そうでないため、バグだと思います。Chart.js のソース コードから:

/**
 * @cfg {String} theme (optional) The name of the theme to be used. A theme defines the colors and
 * other visual displays of tick marks on axis, text, title text, line colors, marker colors and styles, etc.
 * Possible theme values are 'Base', 'Green', 'Sky', 'Red', 'Purple', 'Blue', 'Yellow' and also six category themes
 * 'Category1' to 'Category6'. Default value is 'Base'.
 */

したがって、次のコードを新しいクラスに追加するだけです。

constructor: function() {
    this.callParent([{theme: 'Category1'}]);
},

それは私にとってはうまくいきます。

于 2011-07-28T16:29:13.827 に答える
0

私も同様の問題を抱えていましたが、 config オブジェクトではなく Base Theme でした。問題については、最初に、代わりにパネルの項目プロパティを修正できます

 items: [
        Ext.create('CDR.chart.Daily'),

そのはず

items: [ { Ext.create('CDR.chart.Daily'),....}

また、MVC フレームワークを使用している場合は、app.js で Ext.require セクションに以下の行を追加したことを確認してください。

'Ext.chart.theme.Base',
'Ext.chart.theme.Theme',
于 2011-06-24T11:34:24.277 に答える