Home > Web Front-end > JS Tutorial > body text

extjs ColumnChart sets different colors implementation code_extjs

WBOY
Release: 2016-05-16 17:33:40
Original
1469 people have browsed it
Copy code The code is as follows:

Ext.onReady(function(){
//Define store
var chartStore = new Ext.data.JsonStore({
root:'root',
fields:[
{name:'ne',type:'string'},//Network element
{name:'confine',type:'int'},//Threshold
{name:'bill ',type:'string'}//Number of work orders
],
sortInfo:{field: 'bill', direction: 'ASC'}
});
//Test data
var obj={
root:[
{ne:'Network Element One',confine:80,bill:150},
{ne:'Network Element Two',confine:150,bill: 140},
{ne:'Network Element Three',confine:180,bill:160},
{ne:'Network Element Five',confine:120,bill:180},
{ne :'Network element six',confine:165,bill:13},
{ne:'Network element seven',confine:54,bill:12},
{ne:'Network element eight',confine :55,bill:44},
{ne:'Network Element Nine',confine:33,bill:113},
{ne:'Network Element Ten',confine:122,bill:77}
]
}
//Load data
chartStore.loadData(obj);
//pushlet callback function
window.onData = function (event) {
// alert(event.get("data1"));
var obj1 = eval('(' event.get("data1") ')');
//obj=obj1;
// chartStore.loadData(obj);
}
// System property defines column data model
var cm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(),
{header :'network element',dataIndex:'ne'},
{header:'amount of work orders',dataIndex:'bill',renderer:function(value, cellMeta, record, rowIndex, columnIndex, store){
var confine = record.data['confine'];
/*if(value>=confine){
//cellMeta.css='x-grid-back-red';
var row = cm.findColumnIndex(rowIndex);
row.css='x-grid-back-red';
}*/
return value;
}},
{header:' Threshold',dataIndex:'confine'}
//{header:'operation',dataIndex:'state',renderer:renderOperate}
]);
var grid = new Ext.grid.EditorGridPanel ({
title:'Work order backlog monitoring statistics',
cm:cm,
store:chartStore,
sm : new Ext.grid.RowSelectionModel({
singleSelect : true
}),
stripeRows:true,
loadMask:true,
clicksToEdit : 2,//Double-click trigger,
enableColumnMove : false,
trackMouseOver : false,
stripeRows:true ,
frame:true,
loadMask:{
msg: "Data loading..."
},
viewConfig:{
forceFit:true,
columnsText:'Display columns',
scrollOffset:25,
sortAscText:'Ascending',
sortDescText:'Descending'
},
autoExpandColumn:'desc',
bbar: new Ext.PagingToolbar({
pageSize:24,
store:chartStore,
displayInfo:true,
displayMsg:'Display records {0} to {1}, totaling {2 } items',
emptyMsg:'No record'
}),
viewConfig:{forceFit:true,sortAscText:'Forward order',sortDescText:'Descending order',
getRowClass : function(record ,rowIndex,rowParams,store){
if(record.data.bill>=record.data.confine){
return 'x-grid-back-red';
}
}
}
});
var linechart = new Ext.chart.LineChart({
title:'Work Order Backlog Chart',
xtype:'linechart',
url: AIUPP_ROOT '/css/resources/charts.swf',
store:chartStore,
//xField: 'label',
//yField:'alarmCount',
//Define tip content
tipRenderer : function(chart, record){
//alert(record.get('startTime'));
var ne = record.get('ne');
var str = String. format('Network element: {0}n work order quantity: {1}n threshold: {2}',ne,record.get('bill'),record.get('confine'))
return str;
},
//Define two charts, one is a bar chart and the other is a line chart
series: [{
type: 'column',
displayName: 'work single number',
id: "billId",
xField: 'ne',
yField: 'bill',
style: {
color:0x99BBE8,
size: 20
}
},{
type:'column',
displayName: 'threshold',
xField: 'ne',
yField: 'confine',
style : {
color: '#ff0000',
size: 20
}
}],
listeners:{
"show":function(){
var c = linechart.series;
//alert(c[1].store);
//c[1].style.color='#00ff00';
}
},
//Define chart style
chartStyle: {
legend:{
display: "top"
},
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}
}
}
});
var contentPanel = new Ext.TabPanel({
region:'center',
enableTabScroll:true,
activeTab:0,
closable:false,
split : false,
collapsible : false,
layoutOnTabChange:true,
items:[linechart,grid]
});
//Interval time
var interval = new Ext.form.TextField({
name:'interval',
fieldLabel:'interval',
id:"searchInterval"
});
// Grouping method
var groupType = new Ext.form.RadioGroup({
name:'groupType',
fieldLabel:'Grouping method',
id:"searchGroupType",
items :[
new Ext.form.Radio({
name: "groupType",
inputValue: "1",
boxLabel: "Region"
}),
new Ext .form.Radio({
name: "groupType",
inputValue: "2",
boxLabel: "Regional Network Element"
}),
new Ext.form.Radio( {
name: "groupType",
inputValue: "3",
boxLabel: "Regional network element service code"
})
]
});
// 开始按钮
var startBtn = new Ext.Button({
text:'开始',
minWidth:80,
handler:function(){
//store.load();
}
});
// 停止按钮
var stopBtn = new Ext.Button({
text:'停止',
minWidth:80,
handler:function(){
//store.load();
}
});
var searchPanel = new Ext.form.FormPanel({
labelAlign:'left',
labelWidth:60,
frame:true,
layout:'column',
items:[
{columnWidth:.28,layout:'form',items:[interval]},
{columnWidth:.38,layout:'form',items:[groupType]},
{columnWidth:.10,layout:'form',items:[startBtn]},
{columnWidth:.16,layout:'form',items:[stopBtn]}
]
});
var vp = new Ext.Viewport({
layout:'border',
border:false,
hideBorders:true,
bufferResize:100,
items:[
//{region:'north',title:'::监控条件',autoHeight:true,margins:'5 5 10 5',collapsible:true,items:[searchPanel]},
{region:'center',layout:'fit',margins:'5 5 5 5',items:[contentPanel]}
]
});
vp.show();
});
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template