Dirk Vogt | 1accb67 | 2017-05-10 14:07:42 +0200 | [diff] [blame] | 1 | <div id = "{{element_name}}" class="panel line_chart"> </div> |
| 2 | <script> |
| 3 | google.charts.setOnLoadCallback(drawChartReportPerDay); |
| 4 | |
| 5 | function drawChartReportPerDay(element) { |
| 6 | element = "heartbeats" |
| 7 | var chart = new google.visualization.PieChart(document.getElementById("{{element_name}}")); |
| 8 | var data = new google.visualization.DataTable(); |
| 9 | var options = { |
| 10 | title: "{{ title }}", |
| 11 | pieHole: 0.4, |
| 12 | sliceVisibilityThreshold: .01, |
| 13 | legend: { |
| 14 | position: "labeled", |
| 15 | }, |
| 16 | chartArea: { |
| 17 | left:0, |
| 18 | right:0, |
| 19 | top:50, |
| 20 | bottom:0, |
| 21 | }, |
| 22 | }; |
| 23 | $.getJSON( "{% url 'hiccup_stats_api_v1_version_daily' %}", |
| 24 | { |
| 25 | date: new Date(new Date().setDate(new Date().getDate()-1)).toISOString().split('T')[0], |
| 26 | version__is_official_release: "{{ is_official_release }}", |
| 27 | version__is_beta_release: "{{ is_beta_release }}", |
| 28 | }, function( json_response ) { |
| 29 | res = []; |
| 30 | if (json_response.results) |
| 31 | res = json_response.results; |
| 32 | else |
| 33 | res = json_response; |
| 34 | reformated_array = res.map(function(obj) { |
| 35 | ret = [obj.build_fingerprint.split('/')[4], obj.heartbeats]; |
| 36 | return ret; |
| 37 | }); |
| 38 | data.addColumn('string', 'Version'); |
| 39 | data.addColumn('number', 'Heartbeats'); |
| 40 | data.addRows(reformated_array); |
| 41 | chart.draw(data, options); |
| 42 | }); |
| 43 | } |
| 44 | </script> |