]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove zeroLineIndex functionality (#6697)
authorEvert Timberg <evert.timberg+github@gmail.com>
Thu, 7 Nov 2019 11:27:49 +0000 (06:27 -0500)
committerGitHub <noreply@github.com>
Thu, 7 Nov 2019 11:27:49 +0000 (06:27 -0500)
* Remove zeroLineIndex functionality

* Remove docs

* Code review updates

docs/axes/styling.md
docs/getting-started/v3-migration.md
src/core/core.scale.js
src/scales/scale.linearbase.js
test/fixtures/core.scale/tick-drawing.json
test/specs/scale.category.tests.js
test/specs/scale.linear.tests.js
test/specs/scale.logarithmic.tests.js
test/specs/scale.radialLinear.tests.js
test/specs/scale.time.tests.js

index e7ca3371412aff8f2cc0d49d90017e4d8b520d45..311b962e177b411bf633b9e3eeeecae859270cc3 100644 (file)
@@ -18,10 +18,6 @@ The grid line configuration is nested under the scale configuration in the `grid
 | `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.
 | `drawTicks` | `boolean` | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
 | `tickMarkLength` | `number` | `10` | Length in pixels that the grid lines will draw into the axis area.
-| `zeroLineWidth` | `number` | `1` | Stroke width of the grid line for the first index (index 0).
-| `zeroLineColor` | `Color` | `'rgba(0, 0, 0, 0.25)'` | Stroke color of the grid line for the first index (index 0).
-| `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).
-| `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).
 | `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.
 | `z` | `number` | `0` | z-index of gridline layer. Values &lt;= 0 are drawn under datasets, &gt; 0 on top.
 
index 74faeb5cd00c4a8aeb476ca4dc11e5115de0e388..2d27abdb0743252614090554190dedac0444ea2b 100644 (file)
@@ -26,6 +26,7 @@ Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`.
 ### Customizability
 
 * `custom` attribute of elements was removed. Please use scriptable options
+* The `zeroLine*` options of axes were removed.
 
 ### Options
 
index d5529aa006a7a00b9474988e33fc2d9b71f1bae7..df0b7bf4028935e14ce3ab40098e927dbecbcbd0 100644 (file)
@@ -24,10 +24,6 @@ defaults._set('scale', {
                drawOnChartArea: true,
                drawTicks: true,
                tickMarkLength: 10,
-               zeroLineWidth: 1,
-               zeroLineColor: 'rgba(0,0,0,0.25)',
-               zeroLineBorderDash: [],
-               zeroLineBorderDashOffset: 0.0,
                offsetGridLines: false,
                borderDash: [],
                borderDashOffset: 0.0
@@ -324,9 +320,6 @@ function skip(ticks, spacing, majorStart, majorEnd) {
 }
 
 var Scale = Element.extend({
-
-       zeroLineIndex: 0,
-
        /**
         * Parse a supported input value to internal representation.
         * @param {*} raw
@@ -981,7 +974,7 @@ var Scale = Element.extend({
                        return alignPixel(chart, pixel, axisWidth);
                };
                var borderValue, i, tick, lineValue, alignedLineValue;
-               var tx1, ty1, tx2, ty2, x1, y1, x2, y2, lineWidth, lineColor, borderDash, borderDashOffset;
+               var tx1, ty1, tx2, ty2, x1, y1, x2, y2;
 
                if (position === 'top') {
                        borderValue = alignBorderValue(me.bottom);
@@ -1012,18 +1005,10 @@ var Scale = Element.extend({
                for (i = 0; i < ticksLength; ++i) {
                        tick = ticks[i] || {};
 
-                       if (i === me.zeroLineIndex && options.offset === offsetGridLines) {
-                               // Draw the first index specially
-                               lineWidth = gridLines.zeroLineWidth;
-                               lineColor = gridLines.zeroLineColor;
-                               borderDash = gridLines.zeroLineBorderDash || [];
-                               borderDashOffset = gridLines.zeroLineBorderDashOffset || 0.0;
-                       } else {
-                               lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
-                               lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
-                               borderDash = gridLines.borderDash || [];
-                               borderDashOffset = gridLines.borderDashOffset || 0.0;
-                       }
+                       const lineWidth = valueAtIndexOrDefault(gridLines.lineWidth, i, 1);
+                       const lineColor = valueAtIndexOrDefault(gridLines.color, i, 'rgba(0,0,0,0.1)');
+                       const borderDash = gridLines.borderDash || [];
+                       const borderDashOffset = gridLines.borderDashOffset || 0.0;
 
                        lineValue = getPixelForGridLine(me, tick._index || i, offsetGridLines);
 
index c420b601957219be917d826a94a4770bdd4f94c7..2401801aeb9d694ebf8610802655f4f5df942d1b 100644 (file)
@@ -234,8 +234,6 @@ module.exports = Scale.extend({
        generateTickLabels: function(ticks) {
                var me = this;
                me._tickValues = ticks.map(t => t.value);
-               me.zeroLineIndex = me._tickValues.indexOf(0);
-
                Scale.prototype.generateTickLabels.call(me, ticks);
        },
 
index 7c9d6da7abe6dfdbf37c4c921768b1ea58b81c0e..c3bb0a8250cc1e6ca18cf71e21fa787528ff3ad5 100644 (file)
@@ -19,8 +19,7 @@
                     "gridLines":{
                         "drawOnChartArea": false,
                         "drawBorder": false,
-                        "color": "rgba(0, 0, 0, 1)",
-                        "zeroLineColor": "rgba(0, 0, 0, 1)"
+                        "color": "rgba(0, 0, 0, 1)"
                     }
                 }, {
                     "type": "category",
@@ -32,8 +31,7 @@
                     "gridLines":{
                         "drawOnChartArea": false,
                         "drawBorder": false,
-                        "color": "rgba(0, 0, 0, 1)",
-                        "zeroLineColor": "rgba(0, 0, 0, 1)"
+                        "color": "rgba(0, 0, 0, 1)"
                     }
                 }],
                 "yAxes": [{
index c8b5957cd3117c99e4f7d930d5c9dfd04898d245..99a7636e21eaa9ce00aeeb35d043a3423fcbdde7 100644 (file)
@@ -29,10 +29,6 @@ describe('Category scale tests', function() {
                                lineWidth: 1,
                                offsetGridLines: false,
                                display: true,
-                               zeroLineColor: 'rgba(0,0,0,0.25)',
-                               zeroLineWidth: 1,
-                               zeroLineBorderDash: [],
-                               zeroLineBorderDashOffset: 0.0,
                                borderDash: [],
                                borderDashOffset: 0.0
                        },
index 2c185178360e01f2c6e251736c554040ed53bd7a..4e8a7c83795edf34091851c521b1d0b0b24587e6 100644 (file)
@@ -23,10 +23,6 @@ describe('Linear Scale', function() {
                                lineWidth: 1,
                                offsetGridLines: false,
                                display: true,
-                               zeroLineColor: 'rgba(0,0,0,0.25)',
-                               zeroLineWidth: 1,
-                               zeroLineBorderDash: [],
-                               zeroLineBorderDashOffset: 0.0,
                                borderDash: [],
                                borderDashOffset: 0.0
                        },
index fa0dc3caeeb932f879523f7e2c066f2097b0e858..58ff809b33d94103e2eeec8750cf214b47889eac 100644 (file)
@@ -22,10 +22,6 @@ describe('Logarithmic Scale tests', function() {
                                lineWidth: 1,
                                offsetGridLines: false,
                                display: true,
-                               zeroLineColor: 'rgba(0,0,0,0.25)',
-                               zeroLineWidth: 1,
-                               zeroLineBorderDash: [],
-                               zeroLineBorderDashOffset: 0.0,
                                borderDash: [],
                                borderDashOffset: 0.0
                        },
index a474a5f22b34b8935f287fb3c6d7896c046fc4dd..b8ae7c8d825ceb5f3977a9a937334782c1640676 100644 (file)
@@ -34,10 +34,6 @@ describe('Test the radial linear scale', function() {
                                lineWidth: 1,
                                offsetGridLines: false,
                                display: true,
-                               zeroLineColor: 'rgba(0,0,0,0.25)',
-                               zeroLineWidth: 1,
-                               zeroLineBorderDash: [],
-                               zeroLineBorderDashOffset: 0.0,
                                borderDash: [],
                                borderDashOffset: 0.0
                        },
index 8f84ad0f55498dee2b69cd12dcf11aa354469ac0..97ef82a1bacfc4a23f3f0c80288b5afaca8a66be 100755 (executable)
@@ -69,10 +69,6 @@ describe('Time scale tests', function() {
                                lineWidth: 1,
                                offsetGridLines: false,
                                display: true,
-                               zeroLineColor: 'rgba(0,0,0,0.25)',
-                               zeroLineWidth: 1,
-                               zeroLineBorderDash: [],
-                               zeroLineBorderDashOffset: 0.0,
                                borderDash: [],
                                borderDashOffset: 0.0
                        },