首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

新手!extjs4 chart的有关问题

2012-07-24 
新手求助!extjs4 chart的问题在学习extjs的chart,用他给的demo都没问题。尝试数据是这样的格式的[{speed1

新手求助!extjs4 chart的问题
在学习extjs的chart,用他给的demo都没问题。尝试
数据是这样的格式的[{"speed1" : "71","num" : "10"}]



甚至点击点的时候,都可以读出speed1来。

但是为什么显示不正常呢?

代码如下:

JScript code
Ext.require('Ext.chart.*');Ext.require(['Ext.Window', 'Ext.fx.target.Sprite', 'Ext.layout.container.Fit', 'Ext.window.MessageBox']);Ext.onReady(function () {    window.store1 = Ext.create('Ext.data.JsonStore', {                    fields : ['speed1', 'num'],                    data : [{                                    "speed1" : "71",                                    "num" : "10"                            }, {                                    "speed1" : "63",                                    "num" : "11"                            }, {                                    "speed1" : "77",                                    "num" : "12"                            }, {                                    "speed1" : "85",                                    "num" : "13"                            }, {                                    "speed1" : "79",                                    "num" : "14"                            }                    ]    });    var chart = Ext.create('Ext.chart.Chart', {            xtype: 'chart',            style: 'background:#fff',            animate: true,            store: store1,            shadow: true,            theme: 'Category1',            legend: {                position: 'right'            },            axes: [{                type: 'Numeric',                minimum: 0,                position: 'left',                fields: ['speed1'],                title: 'Number of Hits',             //  minorTickSteps: 1,                grid: {                    odd: {                        opacity: 1,                        fill: '#ddd',                        stroke: '#bbb',                        'stroke-width': 0.5                    }                }            }, {                type: 'Category',                position: 'bottom',                fields: ['num'],                title: 'Month of the Year'            }],            series: [{                type: 'line',                highlight: {                    size: 20,                    radius: 7                },                                tips: {                    trackMouse: true,                    width: 80,                    height: 40,                    renderer: function(storeItem, item) {                        this.setTitle(storeItem.get('num'));                        this.update(storeItem.get('speed1'));                    }                },                axis: 'left',             //   smooth: true,//平滑线条                fill: true,//填充面积                xField: ['num'],                yField: ['speed1'],                markerConfig: {                    type: 'circle',//cross是叉叉,这个是圆圈                    size: 4,                    radius: 4,                    'stroke-width': 0                }            }]        });    var win = Ext.create('Ext.Window', {        width: 800,        height: 600,        minHeight: 400,        minWidth: 550,        hidden: false,        maximizable: true,        title: 'Line Chart',        renderTo: Ext.getBody(),        layout: 'fit',        tbar: [{            text: 'Save Chart',            handler: function() {                Ext.MessageBox.confirm('Confirm Download', 'Would you like to download the chart as an image?', function(choice){                    if(choice == 'yes'){                        chart.save({                            type: 'image/png'                        });                    }                });            }        }],        items: chart    });}); 




[解决办法]
type: 'Numeric',

所以, "speed1" 的值要是数字


data : [{
"speed1" : 71,
"num" : "10"
}, {
"speed1" : 63,
"num" : "11"
}, {
"speed1" : 77,
"num" : "12"
}, {
"speed1" : 85,
"num" : "13"
}, {
"speed1" : 79,
"num" : "14"
}
]

热点排行