Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit 405c941

Browse files
author
sluger
committed
added simple example
1 parent 62c68cb commit 405c941

1 file changed

Lines changed: 91 additions & 0 deletions

File tree

samples/simple-bar.html

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<title>Chart.js Error Bars Plugin</title>
6+
<script src="../node_modules/chart.js/dist/Chart.bundle.js" type></script>
7+
<script src="../build/Plugin.Errorbars.js"></script>
8+
<style>
9+
canvas {
10+
-moz-user-select: none;
11+
-webkit-user-select: none;
12+
-ms-user-select: none;
13+
}
14+
</style>
15+
</head>
16+
17+
<body>
18+
<div id="container" style="width: 50%;">
19+
<canvas id="canvas"></canvas>
20+
</div>
21+
22+
<script>
23+
var color = Chart.helpers.color;
24+
var barChartData = {
25+
labels: ["January", "February", "March", "April"],
26+
datasets: [{
27+
label: 'Dataset 1',
28+
//backgroundColor: '#d95f02',
29+
borderColor: '#d95f02',
30+
borderWidth: 1,
31+
data: [
32+
56,
33+
33,
34+
78,
35+
54
36+
],
37+
errorBars: {
38+
'January': {plus: 15, minus: -34},
39+
'February': {plus: 15, minus: -3},
40+
'March': {plus: 35, minus: -14},
41+
'April': {plus: 45, minus: -4}
42+
}
43+
}, {
44+
label: 'Dataset 2',
45+
//backgroundColor: '#1b9e77',
46+
borderColor: '#1b9e77',
47+
borderWidth: 1,
48+
data: [
49+
100,
50+
77,
51+
33,
52+
45
53+
],
54+
errorBars: {
55+
'January': {plus: 15, minus: -34},
56+
'February': {plus: 5, minus: -24},
57+
'March': {plus: 20, minus: -4},
58+
'April': {plus: 45, minus: -20}
59+
}
60+
}]
61+
62+
};
63+
64+
window.onload = function () {
65+
var ctx = document.getElementById("canvas").getContext("2d");
66+
window.myBar = new Chart(ctx, {
67+
type: 'bar',
68+
data: barChartData,
69+
options: {
70+
responsive: true,
71+
legend: {
72+
position: 'top',
73+
},
74+
title: {
75+
display: true,
76+
text: 'Chart.js Error Bars Plugin'
77+
},
78+
plugins: {
79+
chartJsPluginErrorBars: {
80+
width: '60%',
81+
//color: 'darkgray'
82+
}
83+
}
84+
},
85+
});
86+
87+
};
88+
89+
</script>
90+
</body>
91+
</html>

0 commit comments

Comments
 (0)