Skip to content

Commit 94afa63

Browse files
authored
Remove zeroLineIndex functionality (#6697)
* Remove zeroLineIndex functionality * Remove docs * Code review updates
1 parent aff7d41 commit 94afa63

File tree

10 files changed

+8
-50
lines changed

10 files changed

+8
-50
lines changed

docs/axes/styling.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ The grid line configuration is nested under the scale configuration in the `grid
1818
| `drawOnChartArea` | `boolean` | `true` | If true, draw lines on the chart area inside the axis lines. This is useful when there are multiple axes and you need to control which grid lines are drawn.
1919
| `drawTicks` | `boolean` | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
2020
| `tickMarkLength` | `number` | `10` | Length in pixels that the grid lines will draw into the axis area.
21-
| `zeroLineWidth` | `number` | `1` | Stroke width of the grid line for the first index (index 0).
22-
| `zeroLineColor` | `Color` | `'rgba(0, 0, 0, 0.25)'` | Stroke color of the grid line for the first index (index 0).
23-
| `zeroLineBorderDash` | `number[]` | `[]` | Length and spacing of dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
24-
| `zeroLineBorderDashOffset` | `number` | `0.0` | Offset for line dashes of the grid line for the first index (index 0). See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
2521
| `offsetGridLines` | `boolean` | `false` | If true, grid lines will be shifted to be between labels. This is set to `true` for a bar chart by default.
2622
| `z` | `number` | `0` | z-index of gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
2723

docs/getting-started/v3-migration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`.
2626
### Customizability
2727

2828
* `custom` attribute of elements was removed. Please use scriptable options
29+
* The `zeroLine*` options of axes were removed.
2930

3031
### Options
3132

src/core/core.scale.js

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ defaults._set('scale', {
2424
drawOnChartArea: true,
2525
drawTicks: true,
2626
tickMarkLength: 10,
27-
zeroLineWidth: 1,
28-
zeroLineColor: 'rgba(0,0,0,0.25)',
29-
zeroLineBorderDash: [],
30-
zeroLineBorderDashOffset: 0.0,
3127
offsetGridLines: false,
3228
borderDash: [],
3329
borderDashOffset: 0.0
@@ -324,9 +320,6 @@ function skip(ticks, spacing, majorStart, majorEnd) {
324320
}
325321

326322
var Scale = Element.extend({
327-
328-
zeroLineIndex: 0,
329-
330323
/**
331324
* Parse a supported input value to internal representation.
332325
* @param {*} raw
@@ -981,7 +974,7 @@ var Scale = Element.extend({
981974
return alignPixel(chart, pixel, axisWidth);
982975
};
983976
var borderValue, i, tick, lineValue, alignedLineValue;
984-
var tx1, ty1, tx2, ty2, x1, y1, x2, y2, lineWidth, lineColor, borderDash, borderDashOffset;
977+
var tx1, ty1, tx2, ty2, x1, y1, x2, y2;
985978

986979
if (position === 'top') {
987980
borderValue = alignBorderValue(me.bottom);
@@ -1012,18 +1005,10 @@ var Scale = Element.extend({
10121005
for (i = 0; i < ticksLength; ++i) {
10131006
tick = ticks[i] || {};
10141007

1015-
if (i === me.zeroLineIndex && options.offset === offsetGridLines) {
1016-
// Draw the first index specially
1017-
lineWidth = gridLines.zeroLineWidth;
1018-
lineColor = gridLines.zeroLineColor;
1019-
borderDash = gridLines.zeroLineBorderDash || [];
1020-
borderDashOffset = gridLines.zeroLineBorderDashOffset || 0.0;
1021-
} else {
1022-
lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
1023-
lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
1024-
borderDash = gridLines.borderDash || [];
1025-
borderDashOffset = gridLines.borderDashOffset || 0.0;
1026-
}
1008+
const lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
1009+
const lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
1010+
const borderDash = gridLines.borderDash || [];
1011+
const borderDashOffset = gridLines.borderDashOffset || 0.0;
10271012

10281013
lineValue = getPixelForGridLine(me, tick._index || i, offsetGridLines);
10291014

src/scales/scale.linearbase.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,6 @@ module.exports = Scale.extend({
234234
generateTickLabels: function(ticks) {
235235
var me = this;
236236
me._tickValues = ticks.map(t => t.value);
237-
me.zeroLineIndex = me._tickValues.indexOf(0);
238-
239237
Scale.prototype.generateTickLabels.call(me, ticks);
240238
},
241239

test/fixtures/core.scale/tick-drawing.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@
1919
"gridLines":{
2020
"drawOnChartArea": false,
2121
"drawBorder": false,
22-
"color": "rgba(0, 0, 0, 1)",
23-
"zeroLineColor": "rgba(0, 0, 0, 1)"
22+
"color": "rgba(0, 0, 0, 1)"
2423
}
2524
}, {
2625
"type": "category",
@@ -32,8 +31,7 @@
3231
"gridLines":{
3332
"drawOnChartArea": false,
3433
"drawBorder": false,
35-
"color": "rgba(0, 0, 0, 1)",
36-
"zeroLineColor": "rgba(0, 0, 0, 1)"
34+
"color": "rgba(0, 0, 0, 1)"
3735
}
3836
}],
3937
"yAxes": [{

test/specs/scale.category.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ describe('Category scale tests', function() {
2929
lineWidth: 1,
3030
offsetGridLines: false,
3131
display: true,
32-
zeroLineColor: 'rgba(0,0,0,0.25)',
33-
zeroLineWidth: 1,
34-
zeroLineBorderDash: [],
35-
zeroLineBorderDashOffset: 0.0,
3632
borderDash: [],
3733
borderDashOffset: 0.0
3834
},

test/specs/scale.linear.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ describe('Linear Scale', function() {
2323
lineWidth: 1,
2424
offsetGridLines: false,
2525
display: true,
26-
zeroLineColor: 'rgba(0,0,0,0.25)',
27-
zeroLineWidth: 1,
28-
zeroLineBorderDash: [],
29-
zeroLineBorderDashOffset: 0.0,
3026
borderDash: [],
3127
borderDashOffset: 0.0
3228
},

test/specs/scale.logarithmic.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ describe('Logarithmic Scale tests', function() {
2222
lineWidth: 1,
2323
offsetGridLines: false,
2424
display: true,
25-
zeroLineColor: 'rgba(0,0,0,0.25)',
26-
zeroLineWidth: 1,
27-
zeroLineBorderDash: [],
28-
zeroLineBorderDashOffset: 0.0,
2925
borderDash: [],
3026
borderDashOffset: 0.0
3127
},

test/specs/scale.radialLinear.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ describe('Test the radial linear scale', function() {
3434
lineWidth: 1,
3535
offsetGridLines: false,
3636
display: true,
37-
zeroLineColor: 'rgba(0,0,0,0.25)',
38-
zeroLineWidth: 1,
39-
zeroLineBorderDash: [],
40-
zeroLineBorderDashOffset: 0.0,
4137
borderDash: [],
4238
borderDashOffset: 0.0
4339
},

test/specs/scale.time.tests.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ describe('Time scale tests', function() {
6969
lineWidth: 1,
7070
offsetGridLines: false,
7171
display: true,
72-
zeroLineColor: 'rgba(0,0,0,0.25)',
73-
zeroLineWidth: 1,
74-
zeroLineBorderDash: [],
75-
zeroLineBorderDashOffset: 0.0,
7672
borderDash: [],
7773
borderDashOffset: 0.0
7874
},

0 commit comments

Comments
 (0)