Skip to content

Commit 17ed3ed

Browse files
authored
Merge pull request #34 from mrdnote/master
Add option to draw the line skewed
2 parents 2b1b29b + 18a26ba commit 17ed3ed

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ Vertical or horizontal lines are supported.
4545
// Data value to draw the line at
4646
value: 25,
4747

48+
// Optional value at which the line draw should end
49+
endValue: 26,
50+
4851
// Line color
4952
borderColor: 'red',
5053

src/line.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,22 @@ module.exports = function(Chart) {
3232

3333
var scale = chartInstance.scales[options.scaleID];
3434
var pixel = scale ? scale.getPixelForValue(options.value) : NaN;
35+
var endPixel = scale && isValid(options.endValue) ? scale.getPixelForValue(options.endValue) : NaN;
36+
if (isNaN(endPixel))
37+
endPixel = pixel;
3538
var chartArea = chartInstance.chartArea;
3639

3740
if (!isNaN(pixel)) {
3841
if (options.mode == horizontalKeyword) {
3942
model.x1 = chartArea.left;
4043
model.x2 = chartArea.right;
41-
model.y1 = model.y2 = pixel;
44+
model.y1 = pixel;
45+
model.y2 = endPixel;
4246
} else {
4347
model.y1 = chartArea.top;
4448
model.y2 = chartArea.bottom;
45-
model.x1 = model.x2 = pixel;
49+
model.x1 = pixel;
50+
model.x2 = endPixel;
4651
}
4752
}
4853

0 commit comments

Comments
 (0)