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

Commit 87d92f4

Browse files
committed
add simple examples
1 parent e1afb1a commit 87d92f4

3 files changed

Lines changed: 152 additions & 5 deletions

File tree

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,19 @@ Find more [Samples](https://github.com/datavisyn/chartjs-plugin-error-bars/tree/
6565
* stroke color
6666
* @default: derived from borderColor
6767
*/
68-
color: '#666'
68+
color: '#666',
6969

7070
/**
71-
* bar width in pixel as number or string or bar width in percent based on the barchart bars width (max 100%)
72-
* @default 10
73-
*/
74-
width: 10 | '10px' | '60%'
71+
* bar width in pixel as number or string or bar width in percent based on the barchart bars width (max 100%)
72+
* @default 10
73+
*/
74+
width: 10 | '10px' | '60%',
75+
76+
/**
77+
* whether to interpet the plus/minus values, relative to the value itself (default) or absolute
78+
* @default false
79+
*/
80+
absoluteValues: false
7581
}
7682
}
7783

samples/absolute.html

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<title>Vertical Bar</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: 75%;">
19+
<canvas id="canvas"></canvas>
20+
</div>
21+
<script>
22+
var color = Chart.helpers.color;
23+
var barChartData = {
24+
labels: ['Value', 'Value 2', 'Value 3', 'Value 4'],
25+
datasets: [{
26+
label: 'Dataset 1',
27+
//backgroundColor: '#d95f02',
28+
borderColor: '#d95f02',
29+
borderWidth: 1,
30+
data: [
31+
50,
32+
100,
33+
130,
34+
0
35+
],
36+
errorBars: {
37+
'Value': {plus: 80, minus: 20},
38+
'Value 2': {plus: 120, minus: 80}
39+
}
40+
}]
41+
42+
};
43+
44+
window.onload = function () {
45+
var ctx = document.getElementById("canvas").getContext("2d");
46+
window.myBar = new Chart(ctx, {
47+
type: 'bar',
48+
data: barChartData,
49+
options: {
50+
responsive: true,
51+
legend: {
52+
position: 'top',
53+
},
54+
title: {
55+
display: true,
56+
text: 'Chart.js Error Bars Plugin'
57+
},
58+
plugins: {
59+
chartJsPluginErrorBars: {
60+
width: '60%',
61+
absoluteValues: true
62+
//color: 'darkgray'
63+
}
64+
}
65+
},
66+
});
67+
};
68+
</script>
69+
</body>
70+
71+
</html>

samples/horizontal-simple.html

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<!doctype html>
2+
<html>
3+
4+
<head>
5+
<title>Vertical Bar</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: 75%;">
19+
<canvas id="canvas"></canvas>
20+
</div>
21+
<script>
22+
var color = Chart.helpers.color;
23+
var barChartData = {
24+
labels: ['Value', 'Value 2', 'Value 3', 'Value 4'],
25+
datasets: [{
26+
label: 'Dataset 1',
27+
//backgroundColor: '#d95f02',
28+
borderColor: '#d95f02',
29+
borderWidth: 1,
30+
data: [
31+
50,
32+
100,
33+
130,
34+
0
35+
],
36+
errorBars: {
37+
'Value': {plus: 20, minus: -30},
38+
'Value 2': {plus: 20, minus: -30}
39+
}
40+
}]
41+
42+
};
43+
44+
window.onload = function () {
45+
var ctx = document.getElementById("canvas").getContext("2d");
46+
window.myBar = new Chart(ctx, {
47+
type: 'horizontalBar',
48+
data: barChartData,
49+
options: {
50+
responsive: true,
51+
legend: {
52+
position: 'top',
53+
},
54+
title: {
55+
display: true,
56+
text: 'Chart.js Error Bars Plugin'
57+
},
58+
plugins: {
59+
chartJsPluginErrorBars: {
60+
width: '60%',
61+
//color: 'darkgray'
62+
}
63+
}
64+
},
65+
});
66+
};
67+
</script>
68+
</body>
69+
70+
</html>

0 commit comments

Comments
 (0)