PDA

View Full Version : Cannot read property 'theme' - MVC



romerve
2 Nov 2011, 11:38 AM
Hello,

I am trying to get a chart to render, but i am having issues. I keep getting "Uncaught TypeError: Cannot read property 'theme' of undefined ext-all-debug.js:41482"

My store works fine as this error only happens when initializing the view.

app.js:

Ext.Loader.setConfig({enabled:true});

var siteAppPath = 'http://localhost/analytics/public/js/analytics/app';


Ext.application({
name: 'Analytics',
appFolder: siteAppPath,
controllers: ['Reporter'],

launch: function() {
console.log('app');



}

});




controller/Reporter.js:

Ext.define('Analytics.controller.Reporter', { extend: 'Ext.app.Controller',
views: ['charts.AssemInOut'] ,
stores: ['dsAssemInOut'],
models: ['AssemInOut'],

init: function() {

console.log('contro');

var ch = Ext.create('ch.asio');
ch.show();
}
});

view/charts/AssemInOut:

Ext.define('Analytics.view.charts.AssemInOut', { extend: 'Ext.chart.Chart',
alias: 'ch.asio',
store: 'dsAssemInOut',
renderTo: Ext.getBody(),

initComponent: function() {
this.title = 'Assemblies In and Out grouped by Work Centers.';
this.autoHeight = true,
this.autoWidth = true,

this.axes = [
{
type: 'Numeric',
position: 'bottom',
fields: ['qtyIn', 'qtyOut'],
minimum: 0,
title: 'Ins and Outs'
},{
type: 'Category',
position: 'left',
fields: ['sequence_name'],
title: 'Work Centers'
}
],

this.series = [
{
type: 'bar',
axis: 'bottom',
xField: 'sequence_name',
yField: ['qtyIn', 'qtyOut']
}
]

}
});

The store and model are working just fine so i ll omit them from now as it seems that the problem is with the view.

I cant find the error anywhere.

Any help is appreciated.

Thanks

mitchellsimoens
16 Nov 2011, 11:57 AM
You need to include the themes for the chart.

Try adding this line to your Analytics.view.charts.AssemInOut class:


requires : ['Ext.chart.theme.Base'],

Or in the file with your Ext.application you can do this:


Ext.require('Ext.chart.*');

And that will load all the chart classes.