-
10 Apr 2012 8:06 AM #1
Answered: Cannot call method 'each' of null, Debug line 12192
Answered: Cannot call method 'each' of null, Debug line 12192
This bit of code is called I assume to place labels on an axis. I am currently getting an error (the title) when it hits the "store.each" portion.
Through some debugging I discovered that the .getStore() returns nothing. How does the chart get it's store populated?
in store/aStore.js:Code:deduceLabels: function() { var me = this, chart = me.getChart(), store = chart.getStore(), fields = Ext.Array.from(me.getFields()), ln = fields.length, labels = [], i; store.each(function(record) { for (i = 0; i < ln; i++) { labels.push(record.get(fields[i])); } }, this); this.setLabels(labels); },
In OverallChart.js:Code:Ext.define("Stat.store.AStore", { extend : "Ext.data.Store", model : "Stat.model.AModel", storeId : "astore", autoLoad: true });
Sencha Touch 2, Charts 2Code:Ext.define("Stat.view.OverallChart", { extend : "Ext.chart.Chart", xtype : "overallchart", config : { title : "Test Chart", store : "astore", animate : true, axes : [Last edited by Kikketer; 10 Apr 2012 at 8:41 AM. Reason: Updated with new error code
-
Best Answer Posted by mitchellsimoens
That would tell me chart.getStore() is returning null. Is this correct? I don't see why that would be, what does me.getChart() return?
-
10 Apr 2012 8:40 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3157
That would tell me chart.getStore() is returning null. Is this correct? I don't see why that would be, what does me.getChart() return?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Apr 2012 9:46 AM #3
-
10 Apr 2012 10:29 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
- Answers
- 3157
Does the chart display data?
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
10 Apr 2012 12:00 PM #5
No, but I've made some progress.
I was initially using a static text document as the JSONP data (hacking in the callback function it was expecting). I noticed after some messing around that it was calling this service twice, and changing the function name.
So I created a mock JSONP server that simply returns the same data and changes the function call name based on what's in the GET.
The error vanished using the following code in the store:
I don't believe I had the proper things in the config object before. The chart is able to access this store by just using the storeId, which I was very happy to see.Code:Ext.define("Stat.store.AStore", { extend : "Ext.data.Store", config : { model : "Stat.model.AModel", storeId : "astore", autoLoad: true } });
Now no data is appearing in the chart, but I have a feeling I just have to mess with the chart parameters to get things figured out (I'm still new to this and I basically grabbed the charts 1 example).
Would you be able to tell my why perhaps it would be calling the service twice? My model has a "hasMany" relationship, but all the data is within the same JSON block:
The code for the models are almost exactly like the example in Reader: http://docs.sencha.com/touch/2-0/#!/....reader.ReaderCode:{ lmig : [{ "Name" : "Drive", "Data" : [ {'date':'10-14-2010', 'A':0, 'B':0}, {'date':'10-21-2010', 'A':426, 'B':0}, {'date':'10-28-2010', 'A':722, 'B':0}, {'date':'11-04-2010', 'A':1267, 'B':0}, {'date':'11-11-2010', 'A':1553, 'B':0}, {'date':'11-18-2010', 'A':1796, 'B':0}, {'date':'11-25-2010', 'A':2018, 'B':0}, {'date':'12-02-2010', 'A':2250, 'B':0}, {'date':'12-09-2010', 'A':2406, 'B':0} ] }] }
Simplified of course because I only have one layer.


Reply With Quote