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

Commit 659d285

Browse files
authored
Merge pull request #5 from jeredmasters/master
added lineWidth option
2 parents 7cbd30e + 313b15e commit 659d285

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ Find more [Samples](https://github.com/datavisyn/chartjs-plugin-error-bars/tree/
7272
* @default 10
7373
*/
7474
width: 10 | '10px' | '60%',
75+
76+
/**
77+
* lineWidth as number, or as string with pixel (px) ending
78+
*/
79+
lineWidth: 2 | '2px',
7580

7681
/**
7782
* whether to interpet the plus/minus values, relative to the value itself (default) or absolute

src/plugin.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ const defaultOptions = {
88
* @default: derived from borderColor
99
*/
1010
color: undefined,
11+
1112
/**
12-
* with as number, or as string with pixel (px) ending, or as string with percentage (%) ending
13+
* width as number, or as string with pixel (px) ending, or as string with percentage (%) ending
1314
*/
1415
width: 10,
1516

17+
/**
18+
* lineWidth as number, or as string with pixel (px) ending
19+
*/
20+
lineWidth: 2,
21+
1622
/**
1723
* whether the error values are given in absolute values or relative (default)
1824
*/
@@ -116,11 +122,13 @@ const ErrorBarsPlugin = {
116122
* @param minus negative error bar position
117123
* @param color error bar stroke color
118124
* @param width error bar width in pixel
125+
* @param lineWidth error ber line width
119126
* @param horizontal orientation
120127
* @private
121128
*/
122-
_drawErrorBar(ctx, model, plus, minus, color, width, horizontal) {
129+
_drawErrorBar(ctx, model, plus, minus, color, width, lineWidth, horizontal) {
123130
ctx.save();
131+
ctx.lineWidth=lineWidth;
124132
ctx.strokeStyle = color;
125133
ctx.beginPath();
126134
if (horizontal) {
@@ -204,7 +212,7 @@ const ErrorBarsPlugin = {
204212
const plus = vScale.getPixelForValue(plusValue);
205213
const minus = vScale.getPixelForValue(minusValue);
206214

207-
this._drawErrorBar(ctx, bar, plus, minus, errorBarColor, errorBarWidth, horizontal);
215+
this._drawErrorBar(ctx, bar, plus, minus, errorBarColor, errorBarWidth, options.lineWidth, horizontal);
208216
}
209217
});
210218
});

0 commit comments

Comments
 (0)