[POLICY-122] Policy GUI Fixes
[policy/engine.git] / ECOMP-SDK-APP / src / main / webapp / static / fusion / sample / html / bar_chart.html
1 <!DOCTYPE html>
2 <html>
3 <meta http-equiv="content-type" content="text/html; charset=UTF8">
4 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5 <link href="../../d3/css/nv.d3.css" rel="stylesheet" type="text/css">
6 <style>
7          body { 
8         overflow-y:scroll; 
9         } 
10  text { 
11         font: 12px sans-serif; 
12  } 
13  svg { 
14   display: block;
15  } 
16  #chart461 svg { 
17  height: 420px; 
18  width:  700px; 
19  min-width: 100px; 
20  min-height: 100px; 
21  } 
22  tr.z-row-over > td.z-row-inner, tr.z-row-over > .z-cell { background-color: rgb(255, 255, 255); } 
23 .nodatadiv {
24         display: table-cell;
25         width: 700px;
26         height:370px;
27         text-align:center;
28         vertical-align: middle;
29 }
30 .nodatainner {
31         padding: 10px;
32 }
33  </style> 
34 <body> 
35 <div align="center"><H3></H3></div><div id="chart461"> <svg></svg> </div> 
36 <script src="../../d3/js/d3.v3.min.js"></script>
37 <script src="../../d3/js/nv.d3.min.js"></script> 
38 <script src="../../d3/js/tooltip.js"></script> 
39 <script src="../../d3/js/utils.js"></script> 
40 <script src="../../d3/js/models/axis.min.js"></script> 
41 <script src="../../d3/js/models/multiChart.js"></script> 
42 <script> 
43 historicalBarChart = [ 
44  { "type":"bar", "key": "AP_CPU", "yAxis": "1", "values": [{ "x":1388552400000 , "y":10}, { "x":1391230800000 , "y":4}, { "x":1393650000000 , "y":4}, { "x":1396324800000 , "y":12}, { "x":1398916800000 , "y":3.27}, { "x":1401595200000 , "y":6.07}, { "x":1404187200000 , "y":8.93}, { "x":1406865600000 , "y":11.61}, { "x":1409544000000 , "y":18.66}, { "x":1412136000000 , "y":19.04}, { "x":1414814400000 , "y":17.5}, { "x":1417410000000 , "y":15.73}, { "x":1420088400000 , "y":9.62333333333333}, { "x":1422766800000 , "y":14.29}, { "x":1425186000000 , "y":16.1166666666667} ] } , 
45  { "type":"bar", "key": "ROUTER_CPU", "yAxis": "1", "values": [{ "x":1388552400000 , "y":7}, { "x":1391230800000 , "y":7}, { "x":1393650000000 , "y":5}, { "x":1396324800000 , "y":6}, { "x":1398916800000 , "y":5}, { "x":1401595200000 , "y":6}, { "x":1404187200000 , "y":7}, { "x":1406865600000 , "y":7}, { "x":1409544000000 , "y":8.03}, { "x":1412136000000 , "y":9}, { "x":1414814400000 , "y":9}, { "x":1417410000000 , "y":8.78}, { "x":1420088400000 , "y":3.01}, { "x":1422766800000 , "y":2}, { "x":1425186000000 , "y":3.63333333333333} ] } , 
46  { "type":"bar", "key": "SCTP_CPU", "yAxis": "1", "values": [{ "x":1388552400000 , "y":8}, { "x":1391230800000 , "y":10}, { "x":1393650000000 , "y":10}, { "x":1396324800000 , "y":9}, { "x":1398916800000 , "y":9.58}, { "x":1401595200000 , "y":11.83}, { "x":1404187200000 , "y":14.36}, { "x":1406865600000 , "y":15.94}, { "x":1409544000000 , "y":24.55}, { "x":1412136000000 , "y":25.35}, { "x":1414814400000 , "y":23.63}, { "x":1417410000000 , "y":21.43}, { "x":1420088400000 , "y":12.5766666666667}, { "x":1422766800000 , "y":24.4}, { "x":1425186000000 , "y":24.5833333333333} ] } , 
47  { "type":"bar", "key": "DP_CPU", "yAxis": "1", "values": [{ "x":1388552400000 , "y":2}, { "x":1391230800000 , "y":9}, { "x":1393650000000 , "y":4}, { "x":1396324800000 , "y":8}, { "x":1398916800000 , "y":2.98}, { "x":1401595200000 , "y":5.84}, { "x":1404187200000 , "y":8.47}, { "x":1406865600000 , "y":10.8}, { "x":1409544000000 , "y":18.33}, { "x":1412136000000 , "y":18.37}, { "x":1414814400000 , "y":16.92}, { "x":1417410000000 , "y":15.18}, { "x":1420088400000 , "y":9.31}, { "x":1422766800000 , "y":13.41}, { "x":1425186000000 , "y":12.4} ] } 
48 ]; 
49 var chart; 
50 nv.addGraph(function() { 
51  chart = nv.models.multiBarChart() 
52            .margin({top: 30, right: 60, bottom: 50, left: 100}) 
53                         .showLegend(true) 
54             .reduceXTicks(false) 
55            .forceY([0, 34.0])
56                         .showControls(true) 
57                         .stacked(false)
58                         .logScale(false)
59                                 .legendPos('top')
60            .color(d3.scale.category10().range()); 
61   chart.xAxis
62         .tickValues([1388552400000,1391230800000,1393650000000,1396324800000,1398916800000,1401595200000,1404187200000,1406865600000,1409544000000,1412136000000,1414814400000,1417410000000,1420088400000,1422766800000])
63              .staggerLabels(false) 
64                         .showMaxMin(false) 
65                         .rotateLabels(90) 
66                .axisLabel('Timestamp')
67         .tickFormat(function(d) { 
68          return d3.time.format('%b %y')(new Date(d)) }); 
69   chart.yAxis
70                         .logScale(false)
71                .axisLabel('') 
72         .tickFormat(d3.format(',.1f')); 
73  d3.select('#chart461 svg') 
74   .datum(historicalBarChart) 
75   .transition().duration(1000) 
76   .call(chart); 
77 nv.utils.windowResize(chart.update); 
78 return chart; 
79 }); 
80 function redraw() { 
81         d3.select('#chart461 svg') 
82                 .datum(historicalBarChart) 
83                 .transition().duration(500) 
84                 .call(chart); 
85
86
87  setInterval(function () { 
88  redraw(); 
89  }, 1500) 
90 if(historicalBarChart.length <= 0 ) {
91         document.getElementById("chart461").innerHTML = "<div id='noData'><b>No Data Available</b></div>";
92         document.getElementById("chart461").className="nodatadiv";
93         document.getElementById("nodata").className="nodatainner";
94 }
95 </script> </body></html>