-
Notifications
You must be signed in to change notification settings - Fork 13
/
analytics_portal_types.html
63 lines (54 loc) · 2.1 KB
/
analytics_portal_types.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
title: Portal types
layout: default
permalink: /analytics/portal-types/
---
{% include breadcrumbs.html parent="Analytics" %}
<h2>{{ page.title }}</h2>
<canvas id="chart-portals-by-type" width="400" height="200"></canvas>
<script>
document.addEventListener('DOMContentLoaded', () => {
// loading the datasets data
$.getJSON('/organizations.json', function (orgs) {
// Load charts
chartPortalsByType(orgs);
});
});
function chartPortalsByType(orgs) {
let ctx = document.getElementById('chart-portals-by-type').getContext('2d');
let data = _.chain(orgs)
.filter(org => org.portal_url)
.groupBy('portal_type')
.map((value, key) => ({ label: key == 'null' ? 'Not specified' : key, count: value.length }))
.orderBy('count', 'desc')
.value();
let labels = _.chain(data)
.map('label')
.value();
let values = _.chain(data)
.map('count')
.value();
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: labels,
datasets: [{
label: '# of organisations by portal type',
data: values,
backgroundColor: 'rgba(31, 120, 180, 1)',
borderColor: 'rgba(31, 120, 180, 0.5)',
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
</script>