1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    susan-emc is on a distinguished road

      0  

    Default Pie Chart within view using MVC

    Pie Chart within view using MVC


    I want to create a pie chart in a view under MVC and follow the Pie chart example. There is one function generateData() which is used to generate data for the store. I need call store.loadData(generateData()) to load data. Here is the store definition

    store: Ext.create('Ext.data.JsonStore', {
    fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data9', 'data9'],
    data: generateData()
    })

    my question: where to put the generateData() definition? I always got one "generateData() is not defined"

    I think the correct way is define store as a property within a chart, and define generateData() within the initComponent() block. also call store.loadData(generateData()) within it. here is the snippet:

    Ext.define('FSSP.view.center.piechart', {
    extend: 'Ext.chart.Chart',
    alias: 'widget.pie',
    ...
    store: Ext.create('Ext.data.JsonStore', {
    fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data9', 'data9'],
    data: generateData()
    }),
    ...
    initComponent: function() {

    generateData = function(n, floor){
    ...
    return data;
    };


    store.loadData(generateData(6, 20));

    }
    thanks

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    14
    Vote Rating
    0
    susan-emc is on a distinguished road

      0  

    Default


    Can anyone help me out? How to define this kind of store in MVC. Following is my code snippet:
    Ext.define('FSSP.store.pie', {
    extend: 'Ext.data.Store',
    generateData : function(n, floor){
    var data = [],
    p = (Math.random() * 11) + 1,
    i;

    floor = (!floor && floor !== 0)? 20 : floor;

    for (i = 0; i < (n || 12); i++) {
    data.push({
    name: Ext.Date.monthNames[i % 12],
    data1: Math.floor(Math.max((Math.random() * 100), floor)),
    data2: Math.floor(Math.max((Math.random() * 100), floor)),
    data3: Math.floor(Math.max((Math.random() * 100), floor)),
    data4: Math.floor(Math.max((Math.random() * 100), floor)),
    data5: Math.floor(Math.max((Math.random() * 100), floor)),
    data6: Math.floor(Math.max((Math.random() * 100), floor)),
    data7: Math.floor(Math.max((Math.random() * 100), floor)),
    data8: Math.floor(Math.max((Math.random() * 100), floor)),
    data9: Math.floor(Math.max((Math.random() * 100), floor))
    });
    }
    return data;
    },
    fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5', 'data6', 'data7', 'data9', 'data9'],
    data: generateData()
    });

    in my view I refer the store
    Ext.define('FSSP.view.center.piechart', {
    ...
    store: 'pie',
    ...
    initComponent: function() {
    this.store = Ext.StoreManager.lookup(this.store);
    this.store.loadData(generateData(6, 20));
    this.callParent(arguments);
    }

    I always get a store is undefined error, and generateData is undefined error.

    Thanks very much.

  3. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    83
    Vote Rating
    0
    alex9311 is on a distinguished road

      0  

    Default


    I am having similar issues if anyone can shed some light on this. Is it possible to have a generator function inside a store declaration like this?

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar