日期:2014-05-16  浏览次数:20544 次

Extjs 生成折线图
Extjs 3.2这个版本能否将grid中的数据生成折线图。demo的示例中没有演示图,是不是这个版本不支持此功能。js页面的store应该怎么写?与后台如何传值?后台代码的json应该怎么规范。
Extjs 折线图 grid chart JSON

------解决方案--------------------
你看看这个吧,3.4的,charts.js里面的源码,放到你包里,可以直接运行看效果。


Ext.chart.Chart.CHART_URL = '../../resources/charts.swf';
Ext.onReady(function(){       

 var store = new Ext.data.JsonStore({
        fields:['name', 'visits', 'views'],
        data: [
            {name:'Jul 07', visits: 245000, views: 3000000},
            {name:'Aug 07', visits: 240000, views: 3500000},
            {name:'Sep 07', visits: 355000, views: 4000000},
            {name:'Oct 07', visits: 375000, views: 4200000},
            {name:'Nov 07', visits: 490000, views: 4500000},
            {name:'Dec 07', visits: 495000, views: 5800000},
            {name:'Jan 08', visits: 520000, views: 6000000},
            {name:'Feb 08', visits: 620000, views: 7500000}
        ]
    });

    // extra extra simple
    new Ext.Panel({
        title: 'ExtJS.com Visits Trend, 2007/2008 (No styling)',
        renderTo: Ext.getBody(),
        width:500,
        height:300,
        layout:'fit',
        items: {
            xtype: 'linechart',
            store: store,
            xField: 'name',
            yField: 'visits',
listeners: {
itemclick: function(o){
var rec = store.getAt(o.index);
Ext.example.msg('Item Selected', 'You chose {0}.', rec.get('name'));
}
}
        }
    });
 &nb