Merge branch '8784-dir-listings'
[arvados.git] / tools / crunchstat-summary / crunchstat_summary / chartjs.js
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 window.onload = function() {
6     var charts = {};
7     sections.forEach(function(section, section_idx) {
8         var h1 = document.createElement('h1');
9         h1.appendChild(document.createTextNode(section.label));
10         document.body.appendChild(h1);
11         section.charts.forEach(function(data, chart_idx) {
12             // Skip chart if every series has zero data points
13             if (0 == data.data.reduce(function(len, series) {
14                 return len + series.dataPoints.length;
15             }, 0)) {
16                 return;
17             }
18             var id = 'chart-'+section_idx+'-'+chart_idx;
19             var div = document.createElement('div');
20             div.setAttribute('id', id);
21             div.setAttribute('style', 'width: 100%; height: 150px');
22             document.body.appendChild(div);
23             charts[id] = new CanvasJS.Chart(id, data);
24             charts[id].render();
25         });
26     });
27
28     if (typeof window.debug === 'undefined')
29         window.debug = {};
30     window.debug.charts = charts;
31 };