-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (38 loc) · 1022 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
$(window).load(function() {
let json = api.boa.run('critical-dev.boa');
$('#loading').hide();
$('#content').show();
let count = 0;
let labels = [];
let dataset = [];
let mapData = {};
for(let key in json.out){
for(let name in json.out[key]){
mapData[key] = mapData[key] || [];
mapData[key].push(json.out[key][name]);
}
}
for(let index in mapData) {
count++;
let label =
$('#table-output-body').append(`<tr><td> ${count} </td> <td> ${index} </td> <td> ${mapData[index].length} </td> </tr>`)
labels.push(index);
dataset.push(mapData[index].length);
}
let chartData = {
labels: labels,
datasets: [{
fillColor: '#ff8080',
strokeColor: '#bf6060',
data: dataset
}]
}
let canvas = document.createElement('canvas');
canvas.setAttribute('width', '400px');
canvas.setAttribute('height', '300px');
canvas.id = "chart-output";
$('#content').prepend(canvas);
let ctx = canvas.getContext('2d');
new Chart(ctx).Bar(chartData, { 'responsive': true, });
});