1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
|
function Stat_menu()
{
Ext.onReady(function(){
var tb = new Ext.Toolbar();
tb.render('toolbar');
var menu = new Ext.menu.Menu({
id: 'mainMenu',
style: { overflow: 'visible' },
items: [{
text: '1 - Nb paliers / PRT',
checked: false,
group: 'theme',
checkHandler: onItemCheck
}, {
text: '2 - Nb de Connexions par jour',
checked: false,
group: 'theme',
//checkHandler:
}, {
text: "3 - Classes de Nb paliers / PRT",
checked: false,
group: 'theme',
checkHandler: onItemCheck
}, {
text: '4 - Nb de risques par projet',
checked: false,
group: 'theme',
//checkHandler:
}
]
})
tb.add({
text:'Liste des graphes',
iconCls: 'bmenu', // <-- icon
menu: menu
})
})
function onItemCheck(item, checked){
switch(item.text.charAt(0)) {
case ("1"):if (checked) {Baton()};
break;
case ("3"):if (checked) {Camenbert()};
break
}
}
}
function Baton()
{
Ext.Ajax.request({
url: 'Ajax_compte_paliers.php',
method:"POST",
success: function(result,request) {
var myData = {
records : Ext.JSON.decode(result.responseText) };
var datastore = new Ext.data.JsonStore({
fields: [
{name: 'Code_PRT'},
{name: 'Nb', type: 'int'}],
data: myData.records
});
var panel1 = new Ext.Panel({
frame:true,
renderTo: 'panel',
width:1000,
height:400,
layout:'fit',
title: 'Liste en ordre décroissant des 25 Projets',
items : {
id: 'chartCmp',
xtype: 'chart',
style: 'background:#fff',
animate: true,
shadow: true,
store: datastore,
axes: [{
type: 'Numeric',
position: 'left',
fields: ['Nb'],
label: {
renderer: Ext.util.Format.numberRenderer('0,0')
},
title: 'Nombre de paliers',
grid: false,
minimum: 0
}, {
type: 'Category',
position: 'bottom',
fields: ['Code_PRT'],
title: 'Projets'
}],
series: [{
type: 'column',
axis: 'left',
highlight: true,
tips: {
trackMouse: true,
width: 70,
height: 28,
renderer: function(storeItem, item) {
this.setTitle(storeItem.get('Code_PRT') + ': ' + storeItem.get('Nb'))
}
},
xField: 'Nb_pal',
yField: 'Nb',
style: {fill: '#FFA800' }
}]
}
})
},
failure: function (result, request) {
Ext.MessageBox.alert('Problème de récupération des nombres de paliers', result.responseText) }
})
}
function Camenbert()
{
Ext.Ajax.request({
url: 'Classe_nb_paliers.php',
method:"POST",
success: function(result,request) {
var myData = {
records : Ext.JSON.decode(result.responseText) };
var datastore = new Ext.data.JsonStore({
fields: [
{name: 'Classe'},
{name: 'Nb2', type: 'int'}],
data: myData.records
});
var panel1 = new Ext.Panel({
title : 'Typologie de projets par nombre de paliers',
frame:true,
renderTo: 'panel',
width:1000,
height:400,
layout:'fit',
items: {
xtype: 'chart',
id: 'chartCmp',
animate: true,
store: datastore,
shadow: true,
legend: {position: 'right'},
insetPadding: 60,
theme: 'Base:gradients',
series: [{
type: 'pie',
field: 'Nb2',
showInLegend: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function(storeItem, item) {
//calculate percentage.
var total = 0;
datastore.each(function(rec) {
total += rec.get('Nb2');
});
this.setTitle(storeItem.get('Classe') + ': ' + Math.round(storeItem.get('Nb2') / total * 100) + '%') }
},
highlight: { segment: {
margin: 20}
},
label: {
field: 'Classe',
display: 'rotate',
contrast: true,
font: '16px Arial' }
}]
}
})
},
failure: function (result, request) {
Ext.MessageBox.alert('Problème de récupération des classes de paliers', result.responseText) }
})
} |
Partager