You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.2 KiB
80 lines
2.2 KiB
/*!
|
|
* Ext JS Library 3.3.1
|
|
* Copyright(c) 2006-2010 Sencha Inc.
|
|
* licensing@sencha.com
|
|
* http://www.sencha.com/license
|
|
*/
|
|
Ext.onReady(function() {
|
|
var myStore = new Ext.data.ArrayStore({
|
|
autoLoad: true,
|
|
fields: [
|
|
'economy', 'region', 'year',
|
|
{name: 'procedures', type: 'int'},
|
|
{name: 'time', type: 'int'}
|
|
],
|
|
url : 'countries.json'
|
|
});
|
|
|
|
var pivotGrid = new Ext.grid.PivotGrid({
|
|
title : 'Ease of doing business',
|
|
width : 800,
|
|
height : 400,
|
|
renderTo : 'docbody',
|
|
store : myStore,
|
|
aggregator: 'sum',
|
|
measure : 'time',
|
|
|
|
viewConfig: {
|
|
getCellCls: function(value) {
|
|
if (value < 20) {
|
|
return 'expense-low';
|
|
} else if (value < 75) {
|
|
return 'expense-medium';
|
|
} else {
|
|
return 'expense-high';
|
|
}
|
|
}
|
|
},
|
|
|
|
leftAxis: [
|
|
{
|
|
width: 165,
|
|
dataIndex: 'economy'
|
|
}
|
|
],
|
|
|
|
topAxis: [
|
|
{
|
|
dataIndex: 'year'
|
|
}
|
|
],
|
|
|
|
//toggles the Region dimension on and off
|
|
tbar: [
|
|
{
|
|
text: 'Toggle Region',
|
|
enableToggle: true,
|
|
toggleHandler: function() {
|
|
var leftAxis = pivotGrid.leftAxis,
|
|
oldDimensions = leftAxis.dimensions,
|
|
newDimensions = [];
|
|
|
|
if (oldDimensions.length == 1) {
|
|
newDimensions.push({
|
|
width: 100,
|
|
dataIndex: 'region'
|
|
});
|
|
}
|
|
|
|
newDimensions.push({
|
|
width: 165,
|
|
dataIndex: 'economy'
|
|
});
|
|
|
|
leftAxis.setDimensions(newDimensions);
|
|
pivotGrid.view.refresh(true);
|
|
}
|
|
}
|
|
]
|
|
});
|
|
});
|