ext line chart 性能问题

azdxczbb 2010-09-20 10:13:08
我正用extjs 3.2.1 开发linechart。swf的版本是2.8.
我用的是IE7。
我在显示linechart的时候非常慢,虽然我只是显示4-5个linechart,而且每个linechart也就2-3条line。
一个linechart的数据不过最多只有三十条。
尽管这样轻量级,显示所有的chart还要10秒钟。
我实在不知道怎么调优。希望有经验得朋友们能够帮我一下:)

一下是代码

/*!
* Ext JS Library 3.2.1
* Copyright(c) 2006-2010 Ext JS, Inc.
* licensing@extjs.com
* http://www.extjs.com/license
*/
Ext.chart.Chart.CHART_URL = '../../resources/charts_2.8.swf';

var graphPanelHeight = 220;
var eTradingGridWidth = 1500;
var count = 5;
var width=eTradingGridWidth/(count);
Ext.onReady(function(){
var eTradingGraphPanelLevel1 = new Ext.Panel({
title:"outer",
id: 'eTradingGraphsLevel1',
renderTo: 'level1',
width: eTradingGridWidth,
height: graphPanelHeight+50,
layout: 'column',
footer: true
});
});


function createPanel(){

document.getElementById('level2').innerHTML="<div id=\"container\">";



var eTradingGraphPanel = new Ext.Panel({
id: 'eTradingGraphs',
renderTo: 'container',
width: eTradingGridWidth,
height: graphPanelHeight+50,
layout: 'column',
footer: true
});



function pupolateData(){
var data = [];
for(var i=0;i<8;i++){
//alert(Math.random());
data[i] ={
name:'Jul 0'+(i+1),
visits: Math.random()*10+30,
views: Math.random()*20+10,
sampleData1: Math.random()*10+20,
sampleData2: Math.random()*15+5
};
}
return data;
}
// extra extra simple
for(var i =0;i<count;i++){
var store = new Ext.data.JsonStore({
fields:['name', 'visits', 'views','sampleData1','sampleData2'],
data: pupolateData()
});
if(i==count-1)width=width-5;
var panel = new Ext.Panel({
iconCls:'chart',
title: 'ExtJS.com Visits and Pageviews, 2007/2008 (Full styling)',
frame:true,
//renderTo: 'container',
width:width,
height:graphPanelHeight,
//layout:'fit',

items: {
xtype: 'linechart',
store: store,
url:'../../resources/charts.swf',
xField: 'name',
yAxis: new Ext.chart.NumericAxis({
displayName: 'Visits',
labelRenderer : Ext.util.Format.numberRenderer('0,0')
}),
extraStyle: {
legend: {
display: 'bottom',
font: {
name: 'Tahoma',
color: 0x15428B,
size: 10,
bold: true
}
}
},
tipRenderer : function(chart, record, index, series){
if(series.yField == 'visits'){
return Ext.util.Format.number(record.data.visits, '0,0') + ' visits in ' + record.data.name;
}else{
return Ext.util.Format.number(record.data.views, '0,0') + ' page views in ' + record.data.name;
}
},
chartStyle: {
animationEnabled: true,
font: {
name: 'Tahoma',
color: 0x444444,
size: 11
},
dataTip: {
padding: 5,
border: {
color: 0x99bbe8,
size:1
},
background: {
color: 0xDAE7F6,
alpha: .9
},
font: {
name: 'Tahoma',
color: 0x15428B,
size: 10,
bold: true
}
},
xAxis: {
color: 0x69aBc8,
majorTicks: {color: 0x69aBc8, length: 4},
minorTicks: {color: 0x69aBc8, length: 2},
majorGridLines: {size: 1, color: 0xeeeeee}
},
yAxis: {
color: 0x69aBc8,
majorTicks: {color: 0x69aBc8, length: 4},
minorTicks: {color: 0x69aBc8, length: 2},
majorGridLines: {size: 1, color: 0xdfe8f6}
}
},
series: [{
type: 'line',
displayName: 'Page Views',
yField: 'views',
style: {
image:'bar.gif',
mode: 'stretch',
color:0x99BBE8
}
},{
type:'line',
displayName: 'Visits',
yField: 'visits',
style: {
color: 0x15428B
}
},{
type:'line',
displayName: 'Sample Data',
yField: 'sampleData1',
style: {
color: 0x99B28B
}
},{
type:'line',
displayName: 'Sample Data',
yField: 'sampleData2',
style: {
color: 0x98B9B2
}
}]
}
});

eTradingGraphPanel.add(panel);
}
eTradingGraphPanel.doLayout();
}

...全文
439 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
flash8627 2011-08-02
  • 打赏
  • 举报
回复
常期死firefox啊,ie到正常啊。郁闷死,项目做完了,最后一个功能
flash8627 2011-08-01
  • 打赏
  • 举报
回复
老贴,回一个吧,你已经算不错了,我的更惨,学期死ff,弹出个alert窗口,就把ff死掉了。但上面什么也没写,不知道啥错误。郁闷死了。整个项目做完了,最后一个模块,就一个lineChart,画了三条线,直接copy sample的代码,把store改成动态数据,仅此,不知道就怎么的,找错,没法找。
lihui1172 2011-04-13
  • 打赏
  • 举报
回复
谢谢你的代码
azdxczbb 2010-09-20
  • 打赏
  • 举报
回复
firebug 我有,没有办法找到问题。
同时,IE7是用户的环境,我们不能更改。

这个JS是我从项目里面挪出来的一个简化版的。有EXT环境的话,放进去稍微改一下就能用了。

谢谢楼上的回复~
小d 2010-09-20
  • 打赏
  • 举报
回复
首先,做为一个程序员,做为一个前台的程序员 没有一个好的调试工具怎么能行.你这样贴出来给 也不太好找问题
所以你还是下一个firefox吧 再装上一个firebug
如果一定要用ie的话 见意用ie8 因为 他自带的有调试工具
你就会发现在你的问题很快就可以找出来了.

87,992

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧