javascript

位置:IT落伍者 >> javascript >> 浏览文章

extjs ColumnChart设置不同的颜色实现代码


发布日期:2022年09月24日
 
extjs ColumnChart设置不同的颜色实现代码

ExtonReady(function(){

//定义store

var chartStore = new ExtdataJsonStore({

root:root

fields:[

{name:netype:string}//网元

{name:confinetype:int}//阀值

{name:billtype:string}//工单数

]

sortInfo:{field: bill direction: ASC}

});

//测试数据

var obj={

root:[

{ne:网元一confine:bill:}

{ne:网元二confine:bill:}

{ne:网元三confine:bill:}

{ne:网元五confine:bill:}

{ne:网元六confine:bill:}

{ne:网元七confine:bill:}

{ne:网元八confine:bill:}

{ne:网元九confine:bill:}

{ne:网元十confine:bill:}

]

}

//载入数据

chartStoreloadData(obj);

//pushlet 回调函数

windowonData = function (event) {

//alert(eventget("data"));

var obj = eval((+eventget("data")+));

//obj=obj;

//chartStoreloadData(obj);

}

// 系统属性定义列数据模型

var cm = new ExtgridColumnModel([new ExtgridRowNumberer()

{header:网元dataIndex:ne}

{header:工单量dataIndex:billrenderer:function(value cellMeta record  rowIndex columnIndex store){

var confine = recorddata[confine];

/*if(value>=confine){

//cellMetacss=xgridbackred;

var row = cmfindColumnIndex(rowIndex);

rowcss=xgridbackred;

}*/

return value;

}}

{header:阀值dataIndex:confine}

//{header:操作dataIndex:staterenderer:renderOperate}

]);

var grid = new ExtgridEditorGridPanel({

title:工单积压监控统计

cm:cm

store:chartStore

sm : new ExtgridRowSelectionModel({

singleSelect : true

})

stripeRows:true

loadMask:true

clicksToEdit : //双击触发

enableColumnMove : false

trackMouseOver : false

stripeRows:true

frame:true

loadMask:{

msg:"数据加载中"

}

viewConfig:{

forceFit:true

columnsText:显示列

scrollOffset:

sortAscText:升序

sortDescText:降序

}

autoExpandColumn:desc

bbar:new ExtPagingToolbar({

pageSize:

store:chartStore

displayInfo:true

displayMsg:显示第 {} 条到第 {} 条记录总共 {} 条

emptyMsg:无记录

})

viewConfig:{forceFit:truesortAscText:正序sortDescText:降序

getRowClass : function(recordrowIndexrowParamsstore){

if(recorddatabill>=recorddataconfine){

return xgridbackred;

}

}

}

});

var linechart = new ExtchartLineChart({

title:工单积压图表

xtype:linechart

url: AIUPP_ROOT+/css/resources/chartsswf

store:chartStore

//xField: label

//yField:alarmCount

//定义tip内容

tipRenderer : function(chart record){

//alert(recordget(startTime));

var ne = recordget(ne);

var str =  Stringformat(网元:{}n工单量:{}n阀值:{}nerecordget(bill)recordget(confine))

return str;

}

//定义两个图表一个是柱状图一个是折线图

series: [{

type: column

displayName: 工单个数

id:"billId"

xField: ne

yField: bill

style: {

color:xBBE

size:

}

}{

type:column

displayName: 阀值

xField: ne

yField: confine

style: {

color: #ff

size:

}

}]

listeners:{

"show":function(){

var c = linechartseries;

//alert(c[]store);

//c[]stylecolor=#ff;

}

}

//定义图表样式

chartStyle: {

legend:{

display: "top"

}

xAxis: {

color: xaBc

majorTicks: {color: xaBc length:}

minorTicks: {color: xaBc length: }

majorGridLines:{size: color: xeeeeee}

}

yAxis: {

color: xaBc

majorTicks: {color: xaBc length: }

minorTicks: {color: xaBc length: }

majorGridLines: {size: color: xdfef}

}

}

});

var contentPanel = new ExtTabPanel({

region:center

enableTabScroll:true

activeTab:

closable:false

split : false

collapsible : false

layoutOnTabChange:true

items:[linechartgrid]

});

// 间隔时间

var interval = new ExtformTextField({

name:interval

fieldLabel:间隔时间

id:"searchInterval"

});

// 分组方式

var groupType = new ExtformRadioGroup({

name:groupType

fieldLabel:分组方式

id:"searchGroupType"

items:[

new ExtformRadio({

name:"groupType"

inputValue:""

boxLabel:"地区"

})

new ExtformRadio({

name:"groupType"

inputValue:""

boxLabel:"地区+网元"

})

new ExtformRadio({

name:"groupType"

inputValue:""

boxLabel:"地区+网元+业务代码"

})

]

});

// 开始按钮

var startBtn = new ExtButton({

text:开始

minWidth:

handler:function(){

//storeload();

}

});

// 停止按钮

var stopBtn = new ExtButton({

text:停止

minWidth:

handler:function(){

//storeload();

}

});

var searchPanel = new ExtformFormPanel({

labelAlign:left

labelWidth:

frame:true

layout:column

items:[

{columnWidth:layout:formitems:[interval]}

{columnWidth:layout:formitems:[groupType]}

{columnWidth:layout:formitems:[startBtn]}

{columnWidth:layout:formitems:[stopBtn]}

]

});

var vp = new ExtViewport({

layout:border

border:false

hideBorders:true

bufferResize:

items:[

//{region:northtitle:::监控条件autoHeight:truemargins:   collapsible:trueitems:[searchPanel]}

{region:centerlayout:fitmargins: items:[contentPanel]}

]

});

vpshow();

});

               

上一篇:js正文内容高亮效果的实现方法

下一篇:js函数排序的实例代码