开发者

Ext JS 4: Generate Chart from nested Data

I have two Models in my Ext JS 4 app:

Storageuse(date, used_storage)

Webspace(name, hasmany: Storageuse)

I also have a store which loads Webspaces with nested Storageuse data from an URL.

What i would like to do is, have a view extending a Window which contains a line chart which has the date as its x-Axis, the webspace name as its y-axis and each Webspace should be a series (line in the chart) and by that way plotting the used_storage over time for each webspace.

Is this somehow possible using the store I described or do开发者_运维问答 i have to send the data another time in a different form as JSON so that it can directly be used by the Chart?

If this is possible can you give me an example on how to do this in the View?


Do you mean this? Than you have to build your json in the following way:

store: new Ext.data.JsonStore({
    fields: [{
        name: 'year',
        type: 'int'
    },
    {
        name: 'x',
        type: 'int'
    },
    {
        name: 'y',
        type: 'int'
    }],
    data: [{
        year: 2010,
        x: 5,
        y: 3
    },
    {
        year: 2009,
        x: 8,
        y: 6
    }]
}),
xField: 'year',
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜