| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 import json | 7 import json |
| 8 import sys | 8 import sys |
| 9 from string import Template | 9 from string import Template |
| 10 | 10 |
| 11 | 11 |
| 12 _HTML_TEMPLATE = """<!DOCTYPE html> | 12 _HTML_TEMPLATE = """<!DOCTYPE html> |
| 13 <script src="https://www.google.com/jsapi"></script> | 13 <script src="https://www.google.com/jsapi"></script> |
| 14 <script> | 14 <script> |
| 15 var all_data = $ALL_DATA; | 15 var all_data = $ALL_DATA; |
| 16 google.load('visualization', '1', {packages:['corechart', 'table']}); | 16 google.load('visualization', '1', {packages:['corechart', 'table']}); |
| 17 google.setOnLoadCallback(drawVisualization); | 17 google.setOnLoadCallback(drawVisualization); |
| 18 function drawVisualization() { | 18 function drawVisualization() { |
| 19 // Apply policy 'l2' by default. | 19 // Apply policy 'l2' by default. |
| 20 var default_policy = 'l2'; | 20 var default_policy = 'l2'; |
| 21 document.getElementById(default_policy).style.fontWeight = 'bold'; | 21 document.getElementById(default_policy).style.fontWeight = 'bold'; |
| 22 turnOn(default_policy); | 22 turnOn(default_policy); |
| 23 } | 23 } |
| 24 | 24 |
| 25 function turnOn(policy) { | 25 function turnOn(policy) { |
| 26 var data = google.visualization.arrayToDataTable(all_data[policy]); | 26 var data = google.visualization.arrayToDataTable(all_data[policy]); |
| 27 var charOptions = { | 27 var charOptions = { |
| 28 title: 'DMP Graph (Policy: ' + policy + ')', | 28 title: 'DMP Graph (Policy: ' + policy + ')', |
| 29 vAxis: {title: 'Timestamp', titleTextStyle: {color: 'red'}}, | 29 hAxis: {title: 'Timestamp', titleTextStyle: {color: 'red'}}, |
| 30 isStacked : true | 30 isStacked : true |
| 31 }; | 31 }; |
| 32 var chart = new google.visualization.AreaChart( | 32 var chart = new google.visualization.AreaChart( |
| 33 document.getElementById('chart_div')); | 33 document.getElementById('chart_div')); |
| 34 chart.draw(data, charOptions); | 34 chart.draw(data, charOptions); |
| 35 var table = new google.visualization.Table( | 35 var table = new google.visualization.Table( |
| 36 document.getElementById('table_div')); | 36 document.getElementById('table_div')); |
| 37 table.draw(data); | 37 table.draw(data); |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 {'POLICIES': policies, | 85 {'POLICIES': policies, |
| 86 'ALL_DATA': json.dumps(all_data)}) | 86 'ALL_DATA': json.dumps(all_data)}) |
| 87 | 87 |
| 88 | 88 |
| 89 def main(argv): | 89 def main(argv): |
| 90 _GenerateGraph(json.load(file(argv[1], 'r'))) | 90 _GenerateGraph(json.load(file(argv[1], 'r'))) |
| 91 | 91 |
| 92 | 92 |
| 93 if __name__ == '__main__': | 93 if __name__ == '__main__': |
| 94 sys.exit(main(sys.argv)) | 94 sys.exit(main(sys.argv)) |
| OLD | NEW |