-
Notifications
You must be signed in to change notification settings - Fork 13
/
analytics_licensing.html
63 lines (54 loc) · 2.26 KB
/
analytics_licensing.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: Licensing
layout: default
permalink: /analytics/licensing/
---
{% include breadcrumbs.html parent="Analytics" %}
<!--Chart: number of data files by license-->
<h2>Dataset Licensing</h2>
<canvas id="chart-datasets-by-license" width="400" height="200"></canvas>
<script>
document.addEventListener('DOMContentLoaded', () => {
// loading the datasets data
$.getJSON('/datasets.json', function (datasets) {
// Load charts
chartDatasetsByLicense(datasets);
});
});
function chartDatasetsByLicense(datasets) {
let ctx = document.getElementById('chart-datasets-by-license').getContext('2d');
let data = _.chain(datasets)
.groupBy('licence')
.map((value, key) => ({ label: key === '' ? "Other" : 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 datasets by license',
data: values,
backgroundColor: 'rgba(31, 120, 180, 1)',
borderColor: 'rgba(31, 120, 180, 0.5)',
borderWidth: 1
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
});
}
</script>