Skip to content

Commit ad2a69f

Browse files
committed
Undo scale changes
1 parent e2f0648 commit ad2a69f

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/core/core.scale.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ export default class Scale extends Element {
999999

10001000
const borderOpts = grid.setContext(me.getContext(0));
10011001
const axisWidth = borderOpts.drawBorder ? borderOpts.borderWidth : 0;
1002+
const axisHalfWidth = axisWidth / 2;
10021003
const alignBorderValue = function(pixel) {
10031004
return _alignPixel(chart, pixel, axisWidth);
10041005
};
@@ -1008,26 +1009,26 @@ export default class Scale extends Element {
10081009
if (position === 'top') {
10091010
borderValue = alignBorderValue(me.bottom);
10101011
ty1 = me.bottom - tl;
1011-
ty2 = borderValue;
1012-
y1 = alignBorderValue(chartArea.top);
1012+
ty2 = borderValue - axisHalfWidth;
1013+
y1 = alignBorderValue(chartArea.top) + axisHalfWidth;
10131014
y2 = chartArea.bottom;
10141015
} else if (position === 'bottom') {
10151016
borderValue = alignBorderValue(me.top);
10161017
y1 = chartArea.top;
1017-
y2 = alignBorderValue(chartArea.bottom);
1018-
ty1 = borderValue;
1018+
y2 = alignBorderValue(chartArea.bottom) - axisHalfWidth;
1019+
ty1 = borderValue + axisHalfWidth;
10191020
ty2 = me.top + tl;
10201021
} else if (position === 'left') {
10211022
borderValue = alignBorderValue(me.right);
10221023
tx1 = me.right - tl;
1023-
tx2 = borderValue;
1024-
x1 = alignBorderValue(chartArea.left);
1024+
tx2 = borderValue - axisHalfWidth;
1025+
x1 = alignBorderValue(chartArea.left) + axisHalfWidth;
10251026
x2 = chartArea.right;
10261027
} else if (position === 'right') {
10271028
borderValue = alignBorderValue(me.left);
10281029
x1 = chartArea.left;
1029-
x2 = alignBorderValue(chartArea.right);
1030-
tx1 = borderValue;
1030+
x2 = alignBorderValue(chartArea.right) - axisHalfWidth;
1031+
tx1 = borderValue + axisHalfWidth;
10311032
tx2 = me.left + tl;
10321033
} else if (axis === 'x') {
10331034
if (position === 'center') {
@@ -1040,7 +1041,7 @@ export default class Scale extends Element {
10401041

10411042
y1 = chartArea.top;
10421043
y2 = chartArea.bottom;
1043-
ty1 = borderValue;
1044+
ty1 = borderValue + axisHalfWidth;
10441045
ty2 = ty1 + tl;
10451046
} else if (axis === 'y') {
10461047
if (position === 'center') {
@@ -1051,7 +1052,7 @@ export default class Scale extends Element {
10511052
borderValue = alignBorderValue(me.chart.scales[positionAxisID].getPixelForValue(value));
10521053
}
10531054

1054-
tx1 = borderValue;
1055+
tx1 = borderValue - axisHalfWidth;
10551056
tx2 = tx1 - tl;
10561057
x1 = chartArea.left;
10571058
x2 = chartArea.right;
@@ -1412,12 +1413,12 @@ export default class Scale extends Element {
14121413
let x1, x2, y1, y2;
14131414

14141415
if (me.isHorizontal()) {
1415-
x1 = _alignPixel(chart, me.left, axisWidth);
1416-
x2 = _alignPixel(chart, me.right, lastLineWidth);
1416+
x1 = _alignPixel(chart, me.left, axisWidth) - axisWidth / 2;
1417+
x2 = _alignPixel(chart, me.right, lastLineWidth) + lastLineWidth / 2;
14171418
y1 = y2 = borderValue;
14181419
} else {
1419-
y1 = _alignPixel(chart, me.top, axisWidth);
1420-
y2 = _alignPixel(chart, me.bottom, lastLineWidth);
1420+
y1 = _alignPixel(chart, me.top, axisWidth) - axisWidth / 2;
1421+
y2 = _alignPixel(chart, me.bottom, lastLineWidth) + lastLineWidth / 2;
14211422
x1 = x2 = borderValue;
14221423
}
14231424
drawLine(

0 commit comments

Comments
 (0)