Can't get jSon dataStore into ExtJS (Sencha Touch) chart: displays error “cannot read property 'length' of undefined”

前端 未结 2 546
一个人的身影
一个人的身影 2020-12-22 02:53

EDITED I am using Sencha touch charts sample provided for column charts. The code is as below

new Ext.chart.Panel({
    fullscreen: true,
           


        
2条回答
  •  半阙折子戏
    2020-12-22 03:41

    I solved this issue with the help of a Sencha folk. Thanks Dan. Here is the solution:

    1. run the sample on a web server as loading JSON files from the file system can sometimes cause problems.
    2. Structure the json data as below

      {
          "data": [
              {
                  "School": "Dukes",
                  "wins": "3"
              },
              {
                  "School": "Emmaus",
                  "wins": "10"
              },
              {
                  "School": "Maryland",
                  "wins": "5"
              },
              {
                  "School": "Virginia",
                  "wins": "2"
              }
          ]
      }
      
    3. Use the below data store

      window.store1 = new Ext.data.Store({
          model: 'Details',
          proxy: {
              type: 'ajax',
              url: 'GetDataset.json',
              reader: {
                  root: 'data',
                  type: 'json'
              }
          },
          autoLoad: true
      });
      

提交回复
热议问题