Avail feature updated
[ninja.git] / modules / reports / views / trends / new_report.php
blob9f069e7631989329765f0f5f4699061408702b02
1 <div id="trends_graphs" style="margin: 20px auto 0 auto;">
2 <div id='tgraph'>Trend graphs loading...</div>
3 <script>
4 <?php
6 $rawdata = array();
7 $labels = array();
8 $state_names = array();
9 $outputs = array();
10 $outputs_r = array();
12 foreach ($graph_pure_data as $service => $statechanges) {
14 $labels[] = $service;
16 $servicerow = array();
18 for ($i = 0; $i < count($statechanges); $i++) {
20 $cur_out = $statechanges[$i]['output'];
21 if( isset( $outputs_r[$cur_out] ) ) {
22 $output_id = $outputs_r[$cur_out];
23 } else {
24 $output_id = count($outputs);
25 $outputs[] = $cur_out;
26 $outputs_r[$cur_out] = $output_id;
29 $servicerow[] = array(
30 $statechanges[$i]['duration'], /* 0: duration */
31 $statechanges[$i]['state'], /* 1: state */
32 $output_id /* 2: short */
35 $state_names[$statechanges[$i]['state']] = ucfirst($this->_state_string_name($obj_type, $statechanges[$i]['state']));
38 $rawdata[] = $servicerow;
41 $colors = reports::_state_color_table($obj_type);
46 var rawdata = <?php echo json_encode($rawdata); ?>,
47 short_names = <?php echo json_encode($outputs); ?>,
48 labels = <?php echo json_encode($labels); ?>,
49 state_names = <?php echo json_encode($state_names); ?>,
50 colors = <?php echo json_encode($colors); ?>;
53 var data = [];
54 for( var i=0; i<rawdata.length; i++ ) {
55 data[i] = [];
56 for( var j=0; j<rawdata[i].length; j++ ) {
57 data[i][j] = {
58 'duration': rawdata[i][j][0],
59 'label': state_names[rawdata[i][j][1]],
60 'short': short_names[rawdata[i][j][2]],
61 'color': colors[rawdata[i][j][1]]
66 $(window).load(function () {
67 new TGraph(
68 data, 'timeline',
69 labels,
70 <?php echo $graph_start_date ?>,
71 <?php echo ($use_scaling) ? 'true':'false'; ?>
73 });
75 </script>
76 <?php if ($included && $skipped) {
77 printf(_("<p>Not showing %d graphs due to being 100%% OK</p>"), $skipped);
78 } ?>
79 </div>