Debian Codegraph @

resources/pgbadger.js

raw symbols SCIP
1
2 /* <![CDATA[ */
3
4 function create_download_button (buttonid, cssclass) {
5 if (cssclass == undefined) {
6 cssclass ='btn btn-info';
7 }
8 document.writeln('<button type="button" id="download'+buttonid+'" class="'+cssclass+'">Download</button>');
9 }
10
11 function add_download_button_event (buttonid, divid) {
12
13 jQuery('#download'+buttonid).click( function() {
14 $('#pgbadgerModal img').attr('src', $('#'+divid).jqplotToImageStr({}));
15 $('#pgbadgerModal').modal('toggle');
16 });
17
18 }
19
20 function create_linegraph (divid, charttitle, ylabel, arr_series, lineseries) {
21 return $.jqplot(divid, lineseries, {
22 seriesColors: ['#6e9dc9','#f4ab3a','#ac7fa8','#8dbd0f',"#958c12","#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc"],
23 seriesDefaults: { markerOptions: {show: false}, lineWidth:1 },
24 grid: { borderWidth: 1, background: '#ffffff'},
25 title: charttitle,
26 series: arr_series,
27 axes: {
28 xaxis: {
29 renderer:$.jqplot.DateAxisRenderer,
30 tickOptions:{ angle: -30, textColor: '#333' },
31 },
32 yaxis: {
33 renderer: $.jqplot.LogAxisRenderer,
34 labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
35 tickRenderer: $.jqplot.CanvasAxisTickRenderer,
36 tickOptions: {
37 textColor: '#333',
38 formatter: function(format, value) { return pretty_print_number(value, 0, ylabel); }
39 },
40 }
41 },
42 legend: {
43 show: true,
44 location: 'nw',
45 },
46 cursor:{
47 show: true,
48 zoom: true,
49 showTooltip:false,
50 looseZoom: true,
51 followMouse: true,
52 },
53 highlighter: {
54 show: true,
55 tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) {
56 var dateToDisplay = new Date(plot.data[seriesIndex][pointIndex][0]);
57 var textToShow = '<div>On '+dateToDisplay.toString();
58 for (var i=0; i<plot.data.length;i++) {
59 textToShow += '<br><span class="mfigure">'+pretty_print_number(plot.data[i][pointIndex][1], 2, plot.series[i].label)+' <small>'+plot.series[i].label+'</small></span>';
60 }
61 textToShow += '</div>';
62 return textToShow;
63 }
64 }
65 });
66 }
67
68 function create_piechart(divid, title, data) {
69 return $.jqplot(divid, [data],
70 {
71 seriesColors: ['#6e9dc9','#f4ab3a','#ac7fa8','#8dbd0f',"#958c12","#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc","#4bb2c5", "#c5b47f", "#EAA228", "#579575", "#839557","#498991", "#C08840", "#9F9274", "#546D61", "#646C4A", "#6F6621","#6E3F5F", "#4F64B0", "#A89050", "#C45923", "#187399", "#945381","#959E5C", "#C7AF7B", "#478396", "#907294"],
72 grid: { borderWidth: 1, background: '#ffffff'},
73 title: title,
74 seriesDefaults: {
75 renderer: $.jqplot.PieRenderer,
76 rendererOptions: {
77 showDataLabels: true
78 }
79 },
80 legend: { show:true, location: 'e' },
81 highlighter: {
82 show: true,
83 tooltipLocation:'sw',
84 useAxesFormatters:false,
85 tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) {
86 var textToShow = '<div>';
87 //textToShow += '<span class="mfigure">'+pretty_print_number(plot.data[0][pointIndex][1], 2)+' <small>'+plot.data[0][pointIndex][0]+'</small></span>';
88 textToShow += '<span class="mfigure">'+format_number(plot.data[0][pointIndex][1])+' <small>'+plot.data[0][pointIndex][0]+'</small></span>';
89 textToShow += '</div>';
90 return textToShow;
91 }
92 }
93 }
94 );
95 }
96
97 function create_bargraph (divid, title, ytitle, data, y2title) {
98 return $.jqplot(divid, data, {
99 grid: { borderWidth: 1, background: '#ffffff'},
100 title: title,
101 seriesDefaults: {
102 rendererOptions: {
103 barPadding: 4,
104 barMargin: 5,
105 }
106 },
107 seriesColors: ['#6e9dc9','#8dbd0f','#f4ab3a','#ac7fa8',"#958c12","#953579", "#4b5de4", "#d8b83f", "#ff5800", "#0085cc"],
108 series:[
109 { renderer:$.jqplot.BarRenderer, label: ytitle},
110 { yaxis:'y2axis', label: y2title, markerOptions: {show: false}, lineWidth:1 }
111 ],
112 axes: {
113 xaxis: {
114 renderer: $.jqplot.CategoryAxisRenderer,
115 drawMajorGridlines: false,
116 drawMajorTickMarks: false,
117 tickRenderer: $.jqplot.CanvasAxisTickRenderer,
118 tickOptions: {
119 angle: -30,
120 textColor: '#333',
121 formatString:'%H:%M',
122 fontFamily:'Helvetica',
123 fontSize: '8pt'
124 }
125 },
126 yaxis: {
127 autoscale:true,
128 labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
129 tickOptions:{ textColor: '#333' },
130 tickRenderer: $.jqplot.CanvasAxisTickRenderer,
131 tickOptions: {
132 textColor: '#333',
133 formatter: function(format, value) { return pretty_print_number(value, 1, ytitle); },
134 fontFamily:'Helvetica',
135 fontSize: '8pt'
136 },
137 label: ytitle
138 },
139 y2axis: {
140 autoscale:true,
141 labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
142 tickRenderer: $.jqplot.CanvasAxisTickRenderer,
143 tickOptions: {
144 textColor: '#8dbd0f',
145 formatter: function(format, value) { return pretty_print_number(value, 1, y2title); },
146 fontFamily:'Helvetica',
147 fontSize: '8pt'
148 },
149 rendererOptions: {
150 alignTicks: true,
151 },
152 label: y2title,
153
154 }
155 },
156 highlighter: {
157 show: true,
158 tooltipLocation:'ne',
159 useAxesFormatters:false,
160 tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) {
161 var textToShow = '<div style="z-index: 99;">At '+plot.data[0][pointIndex][0];
162 for (var i=0; i<plot.data.length;i++) {
163 textToShow += '<br><span class="mfigure">'+pretty_print_number(plot.data[i][pointIndex][1], 2, plot.series[i].label)+' <small>'+plot.series[i].label+'</small></span>';
164 }
165 textToShow += '</div>';
166 return textToShow;
167 }
168 }
169 });
170 }
171
172 function pretty_print_number(val, scale, type)
173 {
174
175 if ( (scale == undefined) || ((scale == 0) && (val != 0)) ) {
176 scale = 1;
177 };
178
179 if (type != undefined) {
180 type = type.toLowerCase();
181
182 if (type.search('size') >= 0) {
183 if (Math.abs(val) >= 1125899906842624) {
184 val = (val / 1125899906842624);
185 return val.toFixed(scale) + " PiB";
186 } else if (Math.abs(val) >= 1099511627776) {
187 val = (val / 1099511627776);
188 return val.toFixed(scale) + " TiB";
189 } else if (Math.abs(val) >= 1073741824) {
190 val = (val / 1073741824);
191 return val.toFixed(scale) + " GiB";
192 } else if (Math.abs(val) >= 1048576) {
193 val = (val / 1048576);
194 return val.toFixed(scale) + " MiB";
195 } else if (Math.abs(val) >= 1024) {
196 val = (val / 1024);
197 return val.toFixed(scale) + " KiB";
198 } else {
199 return val + " B";
200 }
201 } else if (type.search('duration') >= 0) {
202 if (Math.abs(val) >= 1000) {
203 val = (val / 1000);
204 return val.toFixed(scale) + " sec";
205 } else {
206 return val.toFixed(scale) + " ms";
207 }
208 } else {
209 if (Math.abs(val) >= 1000000000000000) {
210 val = (val / 1000000000000000);
211 return val.toFixed(scale) + " P";
212 } else if (Math.abs(val) >= 1000000000000) {
213 val = (val / 1000000000000);
214 return val.toFixed(scale) + " T";
215 } else if (Math.abs(val) >= 1000000000) {
216 val = (val / 1000000000);
217 return val.toFixed(scale) + " G";
218 } else if (Math.abs(val) >= 1000000) {
219 val = (val / 1000000);
220 return val.toFixed(scale) + " M";
221 } else if (Math.abs(val) >= 1000) {
222 val = (val / 1000);
223 return val.toFixed(scale) + " K";
224 }
225 }
226 }
227
228 return val.toFixed(scale);
229 }
230
231 function format_number(val) {
232 var decimal = 2;
233 var msep = ',';
234 var deci = Math.round( Math.pow(10,decimal)*(Math.abs(val)-Math.floor(Math.abs(val)))) ;
235 val = Math.floor(Math.abs(val));
236 if ((decimal==0)||(deci==Math.pow(10,decimal))) {deci=0;}
237 var val_format=val+"";
238 var nb=val_format.length;
239 for (var i=1;i<4;i++) {
240 if (val>=Math.pow(10,(3*i))) {
241 val_format=val_format.substring(0,nb-(3*i))+msep+val_format.substring(nb-(3*i));
242 }
243 }
244 if (decimal>0) {
245 var decim="";
246 for (var j=0;j<(decimal-deci.toString().length);j++) {decim+="0";}
247 deci=decim+deci.toString();
248 if (deci > 0) {
249 val_format=val_format+"."+deci;
250 }
251 }
252 if (parseFloat(val)<0) {val_format="-"+val_format;}
253 return val_format;
254 }
255
256
257 function draw_charts() {
258 window.charts = $.grep(window.charts, function(chart) {
259 var chart_copy = chart.slice();
260 var type = chart_copy.shift();
261 var divid = chart[1];
262 if ($('#' + divid).is(':visible')) {
263 window['create_' + type].apply(null, chart_copy);
264 // chart loaded, don't keep it in the list
265 return false;
266 }
267 return true;
268 });
269 };