在 extjs4 mvc 框架中扩展图表类会导致“配置未定义”
我想扩展图表类以在视图中使用,作为 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);
}
});
I want to extend the chart class to use in a view as part of the extjs4 MVC framework. I get this error in firebug:
config is undefined
[Break On This Error] me.initTheme(config.theme || me.theme);
Chart....8936564 (line 191)
This is the class definition:
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);
}
});
This is the view class the chart is added to:
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);
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这是一个错误,因为默认情况下“主题”应该具有“基本”值,但没有。
来自 Chart.js 的源代码:
因此,只需将以下代码添加到您的新类中:
它对我有用。
I think it's a bug, because 'theme' should be with a 'Base' value by default, but hasn't.
From source code of Chart.js :
So, just add following code into your new class:
It's works for me.
我也有类似的问题,但不是针对配置对象,而是针对基本主题,对于您的问题,首先您可以更正面板的 items 属性,而不是
它应该是
items:[
{ Ext.create('CDR.chart.Daily'),....}
另外,如果您使用的是 MVC 框架,请确保在 app.js 中的 Ext.require 部分中添加了以下行:
I also had similar problem but not for the config object but for the Base Theme , for your issue first you can correct the items property of your panel instead of
it should be
items: [
{ Ext.create('CDR.chart.Daily'),....}
Also if you are using the MVC framework then make sure in your app.js you have added the below lines in the Ext.require section :