forked from NickStees/jekyll-cms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
data.html
66 lines (56 loc) · 1.5 KB
/
data.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
64
65
66
---
layout: page
title: Data
permalink: /data/
headerTitle: data
headerSubCopy: Maintain Charts with Netlify CMS
---
{% include global-header.html %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.6.0/Chart.bundle.js"></script>
<!-- Portfolio Start -->
<section id="portfolio-work">
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>Chart Data</h1>
<p>Use the Netlify CMS to maintain a chartdata.yaml file which is used to build this chart.</p>
<canvas id="canvas"></canvas>
</div>
</div>
</div>
</section>
<script>
var chartData = {
labels: [
{% for item in site.data.chartdata.sales %}
"{{item.label}}",
{% endfor %}
],
datasets: [{
label: 'Sales',
borderWidth: 1,
data: [
{% for item in site.data.chartdata.sales %}
"{{item.value}}",
{% endfor %}
]
}]
};
window.onload = function() {
var ctx = document.getElementById("canvas").getContext("2d");
window.myBar = new Chart(ctx, {
type: 'line',
data: chartData,
options: {
responsive: true,
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Example'
}
}
});
};
</script>