1. #1
    Sencha User Kikketer's Avatar
    Join Date
    Apr 2012
    Location
    Wausau, WI
    Posts
    135
    Answers
    6
    Vote Rating
    7
    Kikketer is on a distinguished road

      0  

    Default 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?

    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 store/aStore.js:
    Code:
    Ext.define("Stat.store.AStore", {
      extend : "Ext.data.Store",
      model : "Stat.model.AModel",
      storeId : "astore",
      autoLoad: true
    });
    In OverallChart.js:
    Code:
    Ext.define("Stat.view.OverallChart", {
      extend : "Ext.chart.Chart",
      xtype : "overallchart",
    
    
      config : {
        title : "Test Chart",
        store : "astore",
        animate : true,
        axes : [
    Sencha Touch 2, Charts 2
    Last edited by Kikketer; 10 Apr 2012 at 8:41 AM. Reason: Updated with new error code

  2. 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?

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,619
    Answers
    3450
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    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
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User Kikketer's Avatar
    Join Date
    Apr 2012
    Location
    Wausau, WI
    Posts
    135
    Answers
    6
    Vote Rating
    7
    Kikketer is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    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?
    The me.getChart() returns a chart object, as does this.getChart(). The me.getChart().getStore() returns null.

    Am I using the storeId (store manager) correctly? I assume the chart goes to the manager to find the store with that name.

  5. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,619
    Answers
    3450
    Vote Rating
    817
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Does the chart display data?
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  6. #5
    Sencha User Kikketer's Avatar
    Join Date
    Apr 2012
    Location
    Wausau, WI
    Posts
    135
    Answers
    6
    Vote Rating
    7
    Kikketer is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    Does the chart display data?
    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:
    Code:
    Ext.define("Stat.store.AStore", {
      extend : "Ext.data.Store",
      config : {
        model : "Stat.model.AModel",
        storeId : "astore",
        autoLoad: true
      }
    });
    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.

    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:
    Code:
    {
      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}
        ]
      }]
    }
    The code for the models are almost exactly like the example in Reader: http://docs.sencha.com/touch/2-0/#!/....reader.Reader
    Simplified of course because I only have one layer.

Thread Participants: 1

Tags for this Thread