PDA

View Full Version : cannot read property data of null while reading data using json file in extjs4.1



vijayakumar84
13 Feb 2013, 4:44 AM
Hi,
I am reading data from json file in my application.I am getting error cannot read property data of null.Even thoug. i am getting the status 200 in console .can anybody tell what is problem

this is my data contain in file


data : [{
'name' : 'metric one',
'data' :10,
'data1' :20,
'data2' :15
}, {
'name' : 'metric two',
'data' : 7,
'data1' : 30,
'data2':10
}, {
'name' : 'metric three',
'data' : 5,
'data1': 25,
'data2':15
}, {
'name' : 'metric four',
'data' : 2,
'data1' : 26,
'data2':20
}, {
'name' : 'metric five',
'data' : 27,
'data1': 27,
'data2':15
}, {
'name' : 'metric six',
'data' : 15,
'data1' : 10,
'data2':8
}]

}


this is my store code



Ext.define('extcityview.store.Barchart', {
extend:'Ext.data.Store',
storeId : 'barchart',
model : 'extcityview.model.Barchart',
autoLoad : 'true',
proxy : {
type : 'ajax',
url : 'information.json',
reader : {
type : 'json',
rootProperty : 'data'
}
}
});


this is my model code



Ext.define('extcityview.model.Barchart', {
extend: 'Ext.data.Model',
fields: [
{ name: 'name', type: 'string' },
{ name: 'data', type: 'int' },
{name:'data1',type:'int'},
{name:'data2',type:'int'}
]
});


this is my view



var barchart1 = Ext.create('Ext.chart.Chart', {
// renderTo : Ext.getBody(),
width : 1000,
height : 400,
animate : true,
store : 'barchart',
axes : [{
type : 'Numeric',
position : 'left',
fields : ['data', 'data1','data2'],
label : {
renderer : Ext.util.Format.numberRenderer('0,0')
},
grid : false,
minimum : 0
}, {
type : 'Category',
position : 'bottom',
fields : ['name'],


}],


series : [{
type : 'column',
axis : 'left',
highlight : true,
tips : {
trackMouse : true,
width : 20,
height : 28,


/*
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('name') + ': ' + storeItem.get('data') + ' $');
}*/


},



renderer: function(sprite, record, attr, index, store) {

var color = colorpalette[index];
return Ext.apply(attr, { fill: color });

} ,


style : {
//stroke : 'rgb(40,40,40)',
width : 30
},
/*
label : {
display : 'insideEnd',
'text-anchor' : 'middle',
field : ['data', 'data1'],
renderer : Ext.util.Format.numberRenderer('0'),
orientation : 'vertical',
color : ['#0611a0', '#a61120']
},*/


xField : ['name'],
yField : ['data', 'data1','data2']
}]
});





Uncaught TypeError: Cannot read property 'data' of null ext/src/chart/axis/Axis.js:155 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/axis/Axis.js)

Ext.define.getRangeext/src/chart/axis/Axis.js:155 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/axis/Axis.js)
Ext.define.calcEndsext/src/chart/axis/Axis.js:319 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/axis/Axis.js)
Ext.define.applyDataext/src/chart/axis/Numeric.js:232 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/axis/Numeric.js)
Ext.define.drawAxisext/src/chart/axis/Axis.js:372 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/axis/Axis.js)
Ext.define.redrawext/src/chart/Chart.js:477 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/Chart.js)
Ext.define.afterComponentLayoutext/src/chart/Chart.js:436 (http://www.sencha.com/forum/chrome-devtools://devtools/ext/src/chart/Chart.js)
Ext.define.notifyOwnerComponent.js:170 (http://127.0.0.1:8020/extcityview/ext/src/layout/component/Component.js?_dc=1360759988979)
Ext.define.callLayoutContext.js:349 (http://127.0.0.1:8020/extcityview/ext/src/layout/Context.js?_dc=1360759989313)
Ext.define.flushLayoutsContext.js:520 (http://127.0.0.1:8020/extcityview/ext/src/layout/Context.js?_dc=1360759989313)
Ext.define.runCompleteContext.js:1096 (http://127.0.0.1:8020/extcityview/ext/src/layout/Context.js?_dc=1360759989313)
callOverrideParentext-dev.js:56 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Base.implement.callParentext-dev.js:6271 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.override.runCompleteAbstractComponent.js:80 (http://127.0.0.1:8020/extcityview/ext/src/AbstractComponent.js?_dc=1360759988506)
Ext.define.runContext.js:1077 (http://127.0.0.1:8020/extcityview/ext/src/layout/Context.js?_dc=1360759989313)
Ext.define.statics.flushLayoutsAbstractComponent.js:84 (http://127.0.0.1:8020/extcityview/ext/src/AbstractComponent.js?_dc=1360759988506)
Ext.define.statics.resumeLayoutsAbstractComponent.js:100 (http://127.0.0.1:8020/extcityview/ext/src/AbstractComponent.js?_dc=1360759988506)
Ext.resumeLayoutsAbstractComponent.js:3437 (http://127.0.0.1:8020/extcityview/ext/src/AbstractComponent.js?_dc=1360759988506)
Ext.define.renderRenderable.js:809 (http://127.0.0.1:8020/extcityview/ext/src/util/Renderable.js?_dc=1360759988566)
Ext.define.constructorAbstractComponent.js:1126 (http://127.0.0.1:8020/extcityview/ext/src/AbstractComponent.js?_dc=1360759988506)
Base.implement.callParentext-dev.js:6271 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.define.constructorComponent.js:336 (http://127.0.0.1:8020/extcityview/ext/src/Component.js?_dc=1360759988449)
constructorext-dev.js:7459 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
(anonymous function)
Ext.ClassManager.instantiateext-dev.js:8199 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
(anonymous function)ext-dev.js:3015 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.application.launchapp.js:14 (http://127.0.0.1:8020/extcityview/app/app.js)
Ext.define.onBeforeLaunchApplication.js:208 (http://127.0.0.1:8020/extcityview/ext/src/app/Application.js?_dc=1360759988359)
(anonymous function)Application.js:174 (http://127.0.0.1:8020/extcityview/ext/src/app/Application.js?_dc=1360759988359)
(anonymous function)ext-dev.js:14498 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
fireext-dev.js:14658 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.readyEvent.event.fireext-dev.js:14901 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.fireReadyEventext-dev.js:14999 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.onDocumentReadyext-dev.js:15023 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.onReady.fnext-dev.js:10056 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.triggerReadyext-dev.js:10042 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.refreshQueueext-dev.js:9540 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.refreshQueueext-dev.js:9541 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.refreshQueueext-dev.js:9541 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.onFileLoadedext-dev.js:9947 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
(anonymous function)ext-dev.js:3001 (http://127.0.0.1:8020/extcityview/ext/ext-dev.js)
Ext.apply.injectScriptElement.onLoadFn

Dev@QLP
13 Feb 2013, 7:36 AM
Its hard to tell because of your code not being formatted but the data portion seems to look correct. Can you use Chrome debugger/console to see if your store has actually loaded the data? I'm not familiar with Charting at all so I can't comment on that part.

scottmartin
14 Feb 2013, 10:12 AM
How about if you use root: 'data' instead of rootProperty: 'data' (treeStore::rootProperty)?

Scott.

moxinyu1221
7 Aug 2014, 11:02 PM
coordinate: function (direction, directionOffset, directionCount) {
var me = this,
store = me.getStore(),
hidden = me.getHidden(),

items = store.getData().items,----->question

axis = me['get' + direction + 'Axis'](),
range = {min: Infinity, max: -Infinity},
fieldCategory = me['fieldCategory' + direction] || [direction],
fields = me.getFields(fieldCategory),
i, field, data, style = {},
sprites = me.getSprites();

how to solve ,please.

scottmartin
8 Aug 2014, 6:52 AM
What is the value of 'store'? Is getStore evaluating correctly?