首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ExtJS3中的图表

ExtJS3中的图表
EN

Stack Overflow用户
提问于 2013-01-07 17:50:32
回答 1查看 624关注 0票数 2

我使用的是ExtJS3,我想把这个图表放到一个带有动态商店http://dev.sencha.com/deploy/ext-3.4.0/examples/chart/pie-chart.html的面板中

我试图将这个图表包含到我的面板代码中,但它不起作用。对于包含在ExtJS3面板中的图表,有人有解决方案或示例吗

谢谢

EN

回答 1

Stack Overflow用户

发布于 2013-02-06 22:35:52

我使用您的示例使用动态存储来生成图表:

代码语言:javascript
复制
Ext.chart.Chart.CHART_URL = 'http://dev.sencha.com/deploy/ext-3.4.0/resources/charts.swf';

Ext.onReady(function(){
    var store = new Ext.data.JsonStore({
    url: "sample_data.php",
    root: 'results',
    fields: [
         {name: 'season'},
         {name: 'total'}
    ]
});

    new Ext.Panel({
        width: 400,
        height: 400,
        title: 'Pie Chart with Legend - Favorite Season',
        renderTo: 'container',
        items: {
            store: store,
            xtype: 'piechart',
            dataField: 'total',
            categoryField: 'season',
            //extra styles get applied to the chart defaults
            extraStyle:
            {
                legend:
                {
                    display: 'bottom',
                    padding: 5,
                    font:
                    {
                        family: 'Tahoma',
                        size: 13
                    }
                }
            }
        }
    });
});

其中http://dev.sencha.com/deploy/ext-3.4.0/resources/charts.swf是可以找到图表的目标,sample_data.php返回以下json:

代码语言:javascript
复制
{"results":[
    {"total":"150","season":"Summer"},
    {"total":"245","season":"Fall"},
    {"total":"117","season":"Winter"},
    {"total":"184","season":"spring"}
]}

注意:这通常应该设置为本地资源。

希望这能有所帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14193416

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档