]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Put the border opts in own object (#10571)
authorJacco van den Berg <jaccoberg2281@gmail.com>
Thu, 18 Aug 2022 13:07:46 +0000 (15:07 +0200)
committerGitHub <noreply@github.com>
Thu, 18 Aug 2022 13:07:46 +0000 (15:07 +0200)
* put borderOpts in own object

* document z option

* remove todo and change scaleId to id

* update some tests

* clean bit, remove console log

* fix failing test

* lint

* Remove comment

27 files changed:
docs/axes/_common.md
docs/axes/styling.md
docs/migration/v4-migration.md
docs/samples/scale-options/grid.md
src/core/core.scale.defaults.js
src/core/core.scale.js
src/scales/scale.radialLinear.js
test/fixtures/core.layouts/stacked-boxes-with-weight.js
test/fixtures/core.layouts/stacked-boxes.js
test/fixtures/core.scale/border-behind-elements.js
test/fixtures/core.scale/cartesian-axis-border-settings.json
test/fixtures/core.scale/grid/border-over-grid.js
test/fixtures/core.scale/grid/colors.js
test/fixtures/core.scale/grid/scriptable-borderDash.js
test/fixtures/core.scale/label-offset-vertical-axes.json
test/fixtures/core.scale/tick-drawing.json
test/fixtures/core.scale/tick-override-styles.json
test/fixtures/core.scale/x-axis-position-center.json
test/fixtures/core.scale/x-axis-position-dynamic.json
test/fixtures/core.scale/y-axis-position-center.json
test/fixtures/core.scale/y-axis-position-dynamic.json
test/fixtures/scale.radialLinear/border-dash.json
test/fixtures/scale.radialLinear/circular-border-dash.json
test/fixtures/scale.timeseries/financial-daily.js
test/specs/scale.linear.tests.js
test/specs/scale.time.tests.js
types/index.d.ts

index 6a66bc38b09b67b6403508ea5b1fedcc45418ec5..e6e3d4c876a1e1fd85915160e788cbb0e9328f0d 100644 (file)
@@ -7,6 +7,7 @@ Namespace: `options.scales[scaleId]`
 | `type` | `string` | | Type of scale being employed. Custom scales can be created and registered with a string key. This allows changing the type of an axis for a chart.
 | `alignToPixels` | `boolean` | `false` | Align pixel values to device pixels.
 | `backgroundColor` | [`Color`](/general/colors.md) | | Background color of the scale area.
+| `border` | `object` | | Border configuration. [more...](/axes/styling.md#border-configuration)
 | `display` | `boolean`\|`string` | `true` | Controls the axis global visibility (visible when `true`, hidden when `false`). When `display: 'auto'`, the axis is visible only if at least one associated dataset is visible.
 | `grid` | `object` | | Grid line configuration. [more...](/axes/styling.md#grid-line-configuration)
 | `min` | `number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](/axes/index.md#axis-range-settings)
index 19cd93b384ad6fb7e67a8de31e214b2932d757e4..4eb9bf0b428126f9c69aacc42ee175caf6ceb9ec 100644 (file)
@@ -8,14 +8,9 @@ Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines
 
 | Name | Type | Scriptable | Indexable | Default | Description
 | ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
-| `borderColor` | [`Color`](../general/colors.md) | | | `Chart.defaults.borderColor` | The color of the border line.
-| `borderWidth` | `number` | | | `1` | The width of the border line.
-| `borderDash` | `number[]` | Yes | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
-| `borderDashOffset` | `number` | Yes | | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
 | `circular` | `boolean` | | | `false` | If true, gridlines are circular (on radar and polar area charts only).
 | `color` | [`Color`](../general/colors.md)  | Yes | Yes | `Chart.defaults.borderColor` | The color of the grid lines. If specified as an array, the first color applies to the first grid line, the second to the second grid line, and so on.
 | `display` | `boolean` | | | `true` | If false, do not display grid lines for this axis.
-| `drawBorder` | `boolean` | | | `true` | If true, draw a border at the edge between the axis and the chart area.
 | `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.
 | `lineWidth` | `number` | Yes | Yes | `1` | Stroke width of grid lines.
@@ -25,7 +20,7 @@ Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines
 | `tickColor` | [`Color`](../general/colors.md) | Yes | Yes | | Color of the tick line. If unset, defaults to the grid line color.
 | `tickLength` | `number` | | | `8` | Length in pixels that the grid lines will draw into the axis area.
 | `tickWidth` | `number` | Yes | Yes | | Width of the tick mark in pixels. If unset, defaults to the grid line width.
-| `z` | `number` | | | `0` | z-index of gridline layer. Values &lt;= 0 are drawn under datasets, &gt; 0 on top.
+| `z` | `number` | | | `-1` | z-index of the gridline layer. Values &lt;= 0 are drawn under datasets, &gt; 0 on top.
 
 The scriptable context is described in [Options](../general/options.md#tick) section.
 
@@ -42,3 +37,16 @@ Namespace: `options.scales[scaleId].ticks.major`, it defines options for the maj
 | Name | Type | Default | Description
 | ---- | ---- | ------- | -----------
 | `enabled` | `boolean` | `false` | If true, major ticks are generated. A major tick will affect autoskipping and `major` will be defined on ticks in the scriptable options context.
+
+## Border Configuration
+
+Namespace: `options.scales[scaleId].border`, it defines options for the border that run perpendicular to the axis.
+
+| Name | Type | Scriptable | Indexable | Default | Description
+| ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
+| `display` | `boolean` | | | `true` | If true, draw a border at the edge between the axis and the chart area.
+| `color` | [`Color`](../general/colors.md) | | | `Chart.defaults.borderColor` | The color of the border line.
+| `width` | `number` | | | `1` | The width of the border line.
+| `dash` | `number[]` | Yes | | `[]` | Length and spacing of dashes on grid lines. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash).
+| `dashOffset` | `number` | Yes | | `0.0` | Offset for line dashes. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/lineDashOffset).
+| `z` | `number` | | | `0` | z-index of the border layer. Values &lt;= 0 are drawn under datasets, &gt; 0 on top.
index 743c6bc14dab64eea755a4caa34fad924129e2c6..bfbaaa9f0fccae39bff2378b58bf68405e9204d3 100644 (file)
@@ -17,6 +17,12 @@ A number of changes were made to the configuration options passed to the `Chart`
 * The radialLinear grid indexable and scriptable options don't decrease the index of the specified grid line anymore.
 * The `destroy` plugin hook has been removed and replaced with `afterDestroy`.
 * Ticks callback on time scale now receives timestamp instead of a formatted label.
+* `scales[id].grid.drawBorder` has been renamed to `scales[id].border.display`.
+* `scales[id].grid.borderWidth` has been renamed to `scales[id].border.width`.
+* `scales[id].grid.borderColor` has been renamed to `scales[id].border.color`.
+* `scales[id].grid.borderDash` has been renamed to `scales[id].border.dash`.
+* `scales[id].grid.borderDashOffset` has been renamed to `scales[id].border.dashOffset`.
+* The z index for the border of a scale is now configurable instead of being 1 higher as the grid z index.
 * Linear scales now add and subtracts `5%` of the max value to the range if the min and max are the same instead of `1`.
 * If the tooltip callback returns `undefined`, then the default callback will be used.
 
index e22b01e5e144cf77edf39fed43f980206ab25cc8..ff56f2cc8c82849d201f2a52e96bae818c638001 100644 (file)
@@ -61,16 +61,20 @@ const config = {
     },
     scales: {
       x: {
+        border: {
+          display: BORDER
+        },
         grid: {
           display: DISPLAY,
-          drawBorder: BORDER,
           drawOnChartArea: CHART_AREA,
           drawTicks: TICKS,
         }
       },
       y: {
+        border: {
+          display: false
+        },
         grid: {
-          drawBorder: false,
           color: function(context) {
             if (context.tick.value > 0) {
               return Utils.CHART_COLORS.green;
index d73ae84ef18ea9d688c9406877c2c9270c6d7faa..9a8556e3920dfe87f51871067ef5d1c82a0a642d 100644 (file)
@@ -26,16 +26,19 @@ export function applyScaleDefaults(defaults) {
     grid: {
       display: true,
       lineWidth: 1,
-      drawBorder: true,
       drawOnChartArea: true,
       drawTicks: true,
       tickLength: 8,
       tickWidth: (_ctx, options) => options.lineWidth,
       tickColor: (_ctx, options) => options.color,
       offset: false,
-      borderDash: [],
-      borderDashOffset: 0.0,
-      borderWidth: 1
+    },
+
+    border: {
+      display: true,
+      dash: [],
+      dashOffset: 0.0,
+      width: 1
     },
 
     // scale title
@@ -80,13 +83,13 @@ export function applyScaleDefaults(defaults) {
 
   defaults.route('scale.ticks', 'color', '', 'color');
   defaults.route('scale.grid', 'color', '', 'borderColor');
-  defaults.route('scale.grid', 'borderColor', '', 'borderColor');
+  defaults.route('scale.border', 'color', '', 'borderColor');
   defaults.route('scale.title', 'color', '', 'color');
 
   defaults.describe('scale', {
     _fallback: false,
     _scriptable: (name) => !name.startsWith('before') && !name.startsWith('after') && name !== 'callback' && name !== 'parser',
-    _indexable: (name) => name !== 'borderDash' && name !== 'tickBorderDash',
+    _indexable: (name) => name !== 'borderDash' && name !== 'tickBorderDash' && name !== 'dash',
   });
 
   defaults.describe('scales', {
index 5d20d8216a6f9f5c97386064330197318b2ff8a5..4ad607903fdd15f231cebd842e7dc8afe906dd2c 100644 (file)
@@ -1004,7 +1004,7 @@ export default class Scale extends Element {
     const axis = this.axis;
     const chart = this.chart;
     const options = this.options;
-    const {grid, position} = options;
+    const {grid, position, border} = options;
     const offset = grid.offset;
     const isHorizontal = this.isHorizontal();
     const ticks = this.ticks;
@@ -1012,8 +1012,8 @@ export default class Scale extends Element {
     const tl = getTickMarkLength(grid);
     const items = [];
 
-    const borderOpts = grid.setContext(this.getContext());
-    const axisWidth = borderOpts.drawBorder ? borderOpts.borderWidth : 0;
+    const borderOpts = border.setContext(this.getContext());
+    const axisWidth = borderOpts.display ? borderOpts.width : 0;
     const axisHalfWidth = axisWidth / 2;
     const alignBorderValue = function(pixel) {
       return _alignPixel(chart, pixel, axisWidth);
@@ -1076,12 +1076,14 @@ export default class Scale extends Element {
     const limit = valueOrDefault(options.ticks.maxTicksLimit, ticksLength);
     const step = Math.max(1, Math.ceil(ticksLength / limit));
     for (i = 0; i < ticksLength; i += step) {
-      const optsAtIndex = grid.setContext(this.getContext(i));
+      const context = this.getContext(i);
+      const optsAtIndex = grid.setContext(context);
+      const optsAtIndexBorder = border.setContext(context);
 
       const lineWidth = optsAtIndex.lineWidth;
       const lineColor = optsAtIndex.color;
-      const borderDash = optsAtIndex.borderDash || [];
-      const borderDashOffset = optsAtIndex.borderDashOffset;
+      const borderDash = optsAtIndexBorder.dash || [];
+      const borderDashOffset = optsAtIndexBorder.dashOffset;
 
       const tickWidth = optsAtIndex.tickWidth;
       const tickColor = optsAtIndex.tickColor;
@@ -1496,9 +1498,9 @@ export default class Scale extends Element {
         * @protected
         */
   drawBorder() {
-    const {chart, ctx, options: {grid}} = this;
-    const borderOpts = grid.setContext(this.getContext());
-    const axisWidth = grid.drawBorder ? borderOpts.borderWidth : 0;
+    const {chart, ctx, options: {border, grid}} = this;
+    const borderOpts = border.setContext(this.getContext());
+    const axisWidth = border.display ? borderOpts.width : 0;
     if (!axisWidth) {
       return;
     }
@@ -1516,8 +1518,8 @@ export default class Scale extends Element {
       x1 = x2 = borderValue;
     }
     ctx.save();
-    ctx.lineWidth = borderOpts.borderWidth;
-    ctx.strokeStyle = borderOpts.borderColor;
+    ctx.lineWidth = borderOpts.width;
+    ctx.strokeStyle = borderOpts.color;
 
     ctx.beginPath();
     ctx.moveTo(x1, y1);
@@ -1622,6 +1624,7 @@ export default class Scale extends Element {
     const opts = this.options;
     const tz = opts.ticks && opts.ticks.z || 0;
     const gz = valueOrDefault(opts.grid && opts.grid.z, -1);
+    const bz = valueOrDefault(opts.border && opts.border.z, 0);
 
     if (!this._isVisible() || this.draw !== Scale.prototype.draw) {
       // backward compatibility: draw has been overridden by custom scale
@@ -1641,7 +1644,7 @@ export default class Scale extends Element {
         this.drawTitle();
       }
     }, {
-      z: gz + 1, // TODO, v4 move border options to its own object and add z
+      z: bz,
       draw: () => {
         this.drawBorder();
       }
index 7d323cdc173307fac32c9aa9cdec4b126e3f6fbd..1c9fb938c72d75ed19c0d7428ad62a4c55780040 100644 (file)
@@ -264,7 +264,7 @@ function pathRadiusLine(scale, radius, circular, labelCount) {
   }
 }
 
-function drawRadiusLine(scale, gridLineOpts, radius, labelCount) {
+function drawRadiusLine(scale, gridLineOpts, radius, labelCount, borderOpts) {
   const ctx = scale.ctx;
   const circular = gridLineOpts.circular;
 
@@ -277,8 +277,8 @@ function drawRadiusLine(scale, gridLineOpts, radius, labelCount) {
   ctx.save();
   ctx.strokeStyle = color;
   ctx.lineWidth = lineWidth;
-  ctx.setLineDash(gridLineOpts.borderDash);
-  ctx.lineDashOffset = gridLineOpts.borderDashOffset;
+  ctx.setLineDash(borderOpts.dash);
+  ctx.lineDashOffset = borderOpts.dashOffset;
 
   ctx.beginPath();
   pathRadiusLine(scale, radius, circular, labelCount);
@@ -527,7 +527,7 @@ export default class RadialLinearScale extends LinearScaleBase {
   drawGrid() {
     const ctx = this.ctx;
     const opts = this.options;
-    const {angleLines, grid} = opts;
+    const {angleLines, grid, border} = opts;
     const labelCount = this._pointLabels.length;
 
     let i, offset, position;
@@ -540,8 +540,11 @@ export default class RadialLinearScale extends LinearScaleBase {
       this.ticks.forEach((tick, index) => {
         if (index !== 0) {
           offset = this.getDistanceFromCenterForValue(tick.value);
-          const optsAtIndex = grid.setContext(this.getContext(index));
-          drawRadiusLine(this, optsAtIndex, offset, labelCount);
+          const context = this.getContext(index);
+          const optsAtIndex = grid.setContext(context);
+          const optsAtIndexBorder = border.setContext(context);
+
+          drawRadiusLine(this, optsAtIndex, offset, labelCount, optsAtIndexBorder);
         }
       });
     }
index cbbb8754572b8398aaf83fe3bdcaf6e73c7117c6..0c5d993d67a9e828ee70a38c786312bf37054174 100644 (file)
@@ -19,8 +19,8 @@ module.exports = {
           stackWeight: 2,
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'red'
+          border: {
+            color: 'red'
           },
           ticks: {
             autoSkip: false,
@@ -35,8 +35,8 @@ module.exports = {
           stackWeight: 2,
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'green'
+          border: {
+            color: 'green'
           },
           ticks: {
             autoSkip: false,
@@ -51,8 +51,8 @@ module.exports = {
           stackWeight: 6,
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'blue'
+          border: {
+            color: 'blue'
           },
           ticks: {
             autoSkip: false,
@@ -66,8 +66,8 @@ module.exports = {
           stack: '1',
           stackWeight: 2,
           offset: true,
-          grid: {
-            borderColor: 'red'
+          border: {
+            color: 'red'
           },
           ticks: {
             precision: 0
@@ -79,8 +79,8 @@ module.exports = {
           stack: '1',
           offset: true,
           stackWeight: 2,
-          grid: {
-            borderColor: 'green'
+          border: {
+            color: 'green'
           },
           ticks: {
             precision: 0
@@ -92,8 +92,8 @@ module.exports = {
           stack: '1',
           stackWeight: 3,
           offset: true,
-          grid: {
-            borderColor: 'blue'
+          border: {
+            color: 'blue'
           },
           ticks: {
             precision: 0
index e4fb345c5fb58b6e2414b3c74a798356323f60ad..7655c90188bd61e0cc2bd9f3bbd6fa7f33cd9dba 100644 (file)
@@ -18,8 +18,8 @@ module.exports = {
           stack: '1',
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'red'
+          border: {
+            color: 'red'
           },
           ticks: {
             autoSkip: false,
@@ -33,8 +33,8 @@ module.exports = {
           stack: '1',
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'green'
+          border: {
+            color: 'green'
           },
           ticks: {
             autoSkip: false,
@@ -48,8 +48,8 @@ module.exports = {
           stack: '1',
           offset: true,
           bounds: 'data',
-          grid: {
-            borderColor: 'blue'
+          border: {
+            color: 'blue'
           },
           ticks: {
             autoSkip: false,
@@ -62,8 +62,8 @@ module.exports = {
           position: 'left',
           stack: '1',
           offset: true,
-          grid: {
-            borderColor: 'red'
+          border: {
+            color: 'red'
           },
           ticks: {
             precision: 0
@@ -74,8 +74,8 @@ module.exports = {
           position: 'left',
           stack: '1',
           offset: true,
-          grid: {
-            borderColor: 'green'
+          border: {
+            color: 'green'
           },
           ticks: {
             precision: 0
@@ -86,8 +86,8 @@ module.exports = {
           position: 'left',
           stack: '1',
           offset: true,
-          grid: {
-            borderColor: 'blue'
+          border: {
+            color: 'blue',
           },
           ticks: {
             precision: 0
index c5d17182383f4b3539389cf9a76439ff49dcf147..980e730a19729a158d75516a28f52f0371d84a3d 100644 (file)
@@ -22,18 +22,18 @@ module.exports = {
           ticks: {
             display: false
           },
-          grid: {
-            borderColor: 'red',
-            borderWidth: 5
+          border: {
+            color: 'red',
+            width: 5
           }
         },
         x: {
           ticks: {
             display: false
           },
-          grid: {
-            borderColor: 'red',
-            borderWidth: 5
+          border: {
+            color: 'red',
+            width: 5
           }
         }
       }
index e71e8fd7a03870a87005dd663b79a8a7c6e3f2d2..3543eaf72802f9d590800975e05d1112e390304f 100644 (file)
                     "min": -100,
                     "max": 100,
                     "grid": {
-                        "borderColor": "blue",
-                        "borderWidth": 5,
                         "color": "red",
-                        "drawBorder": true,
                         "drawOnChartArea": false
                     },
+                    "border": {
+                        "display": true,
+                        "color": "blue",
+                        "width": 5
+                    },
                     "ticks": {
                         "display": false
                     }
                     "axis": "y",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
index 785a40456bc8f5acb7308a4e5922148b620ea3f4..cbe0acde40d272c78bc718773e02b423765664d5 100644 (file)
@@ -7,9 +7,11 @@ module.exports = {
           position: {y: 0},
           min: -10,
           max: 10,
+          border: {
+            color: 'black',
+            width: 5
+          },
           grid: {
-            borderColor: 'black',
-            borderWidth: 5,
             color: 'lightGray',
             lineWidth: 3,
           },
@@ -21,9 +23,11 @@ module.exports = {
           position: {x: 0},
           min: -10,
           max: 10,
+          border: {
+            color: 'black',
+            width: 5
+          },
           grid: {
-            borderColor: 'black',
-            borderWidth: 5,
             color: 'lightGray',
             lineWidth: 3,
           },
index e5765a170c216c6fa438ad3c1599bd6966d17ad4..017ec042e3d0b6603f0fec96689697b0fced8000 100644 (file)
@@ -14,9 +14,11 @@ module.exports = {
           ticks: {
             display: false
           },
+          border: {
+            color: 'blue',
+            width: 2,
+          },
           grid: {
-            borderColor: 'blue',
-            borderWidth: 2,
             color: 'green',
             drawTicks: false,
           }
@@ -25,9 +27,11 @@ module.exports = {
           ticks: {
             display: false
           },
+          border: {
+            color: 'black',
+            width: 2,
+          },
           grid: {
-            borderColor: 'black',
-            borderWidth: 2,
             color: 'red',
             drawTicks: false,
           }
index 8fabb498c4c1e3db6b94a6fb4fe8bcc9bfd7cd30..2471e64304bee8763c74f8a2f386c0243d0edb3a 100644 (file)
@@ -7,8 +7,10 @@ module.exports = {
           position: {y: 0},
           min: -10,
           max: 10,
+          border: {
+            dash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
+          },
           grid: {
-            borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
             color: 'lightGray',
             lineWidth: 3,
           },
@@ -20,8 +22,10 @@ module.exports = {
           position: {x: 0},
           min: -10,
           max: 10,
+          border: {
+            dash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
+          },
           grid: {
-            borderDash: (ctx) => ctx.index % 2 === 0 ? [6, 3] : [],
             color: 'lightGray',
             lineWidth: 3,
           },
index 381955acea733b01ffcda7d4b2e61bfaceed16f0..ea182d4d5d5df56e21b16402e1169b684fe87b09 100644 (file)
                         "display": false
                     },
                     "grid":{
-                        "display": false,
-                        "drawBorder": false
+                        "display": false
+                    },
+                    "border": {
+                        "display": false
                     }
                 },
                 "y": {
                     "ticks": {
                         "labelOffset": 25
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
-                        "display": false,
-                        "drawBorder": false
+                        "display": false
                     }
                 }
             }
index 369bf88cd6792549326ee3a6e40ce35c24ac71e2..9327a2b296ae494f749f738c31970a784a97f21d 100644 (file)
                     "ticks": {
                         "display": false
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)"
                     }
                 },
                     "ticks": {
                         "display": false
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)"
                     }
                 },
                     "ticks": {
                         "display": false
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "offset": false,
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)"
                     }
                 },
                     "ticks": {
                         "display": false
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "offset": false,
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)"
                     }
                 }
index c793190117b477f079c8d5ea65ec46bfe3a80738..23d8e81993de428cfb064754b7483adb71a5ee79 100644 (file)
                     "ticks": {
                         "display": false
                     },
+                    
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)",
                         "width": 1,
                         "tickColor": "rgba(255, 0, 0, 1)",
                     "ticks": {
                         "display": false
                     },
+                    "border": {
+                        "display": false
+                    },
                     "grid":{
                         "offset": false,
                         "drawOnChartArea": false,
-                        "drawBorder": false,
                         "color": "rgba(0, 0, 0, 1)",
                         "tickColor": "rgba(255, 0, 0, 1)",
                         "tickWidth": 5
index 57124da11a8a790e742ea785a84450a6ce73d584..98dda96fca073a4c1da59bdcfba6fa39a1002a72 100644 (file)
                     "axis": "x",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": true
+                        "display": true,
+                        "color": "red"
                     }
                 },
                 "y": {
                     "axis": "y",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
index 074cd9eea6381c9825e11c8635fd4c5b69df2177..7fbe9aed2f94211a7b96e05d41e44b99217be2f4 100644 (file)
                     "axis": "x",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
                     "axis": "y",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
index a43b0ebb850f8845a088e03a2baab05adfcbb21f..a4e92a5db986c4a2277f171dc003aac055b8cf98 100644 (file)
                     "axis": "x",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
                     "axis": "y",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
index 10d3b930a4af4f6ec3ab06c75d5bd194ec6b196d..6d8b3fcf9335f24cc74c3573a3e6ec1340cce98f 100644 (file)
                     "axis": "x",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
                     "axis": "y",
                     "min": -100,
                     "max": 100,
+                    "border": {
+                        "color": "red"
+                    },
                     "grid": {
                         "color": "red",
-                        "borderColor": "red",
                         "drawOnChartArea": false
                     },
                     "ticks": {
index 5aac486374acb703c58a9779460e1d256bd3d2b8..356f4e508b8904ecd82d383731142bcaa8c10b44 100644 (file)
         "r": {
           "grid": {
             "color": "rgba(0, 0, 255, 0.5)",
-            "lineWidth": 1,
-            "borderDash": [4, 2],
-            "borderDashOffset": 2
+            "lineWidth": 1
+          },
+          "border": {
+            "dash": [4, 2],
+            "dashOffset": 2
           },
           "angleLines": {
             "color": "rgba(0, 0, 255, 0.5)",
index 844b526627bfdf0fe1fbd79274d6837ebec5bdf8..3425e0e7b963f09746a11595322bd27d888a11ad 100644 (file)
@@ -8,12 +8,14 @@
       "responsive": false,
       "scales": {
         "r": {
+          "border": {
+            "dash": [4, 2],
+            "dashOffset": 2
+          },
           "grid": {
             "circular": true,
             "color": "rgba(0, 0, 255, 0.5)",
-            "lineWidth": 1,
-            "borderDash": [4, 2],
-            "borderDashOffset": 2
+            "lineWidth": 1
           },
           "angleLines": {
             "color": "rgba(0, 0, 255, 0.5)",
index 52dcb9614d3d1beabaa096816fcc33772c1e9a87..9f13f02d1953fa262fb97b99715bdef3f267a65e 100644 (file)
@@ -46,8 +46,8 @@ module.exports = {
         },
         y: {
           type: 'linear',
-          grid: {
-            drawBorder: false
+          border: {
+            display: false
           }
         }
       }
index 77a6dd5e4dd1212c778c985d2d2de53f93eb58bb..9fbe5467a2d2484d22525107b6b2db2fb3778330 100644 (file)
@@ -1119,7 +1119,9 @@ describe('Linear Scale', function() {
             type: 'linear',
             grid: {
               drawTicks: false,
-              drawBorder: false
+            },
+            border: {
+              display: false
             },
             title: {
               display: false,
index 3629dc2508a301b686203b20a079c6ab11753f4d..abae7359cf39dc3494c8ba9ad0f89cbac38fa660 100644 (file)
@@ -1102,8 +1102,8 @@ describe('Time scale tests', function() {
           },
           y: {
             type: 'linear',
-            grid: {
-              drawBorder: false
+            border: {
+              display: false
             }
           }
         }
index e40319e12d42a3fd86a28748c4880460a1024a91..430d5890421813a5d7df8d117c71eac5e7fc01b1 100644 (file)
@@ -2831,13 +2831,28 @@ export interface PluginChartOptions<TType extends ChartType> {
   plugins: PluginOptionsByType<TType>;
 }
 
+export interface BorderOptions {
+  /**
+   * @default true
+   */
+  display: boolean
+  /**
+   * @default []
+   */
+  dash: Scriptable<number[], ScriptableScaleContext>;
+  /**
+   * @default 0
+   */
+  dashOffset: Scriptable<number, ScriptableScaleContext>;
+  color: Color;
+  width: number;
+}
+
 export interface GridLineOptions {
   /**
    * @default true
    */
   display: boolean;
-  borderColor: Color;
-  borderWidth: number;
   /**
    * @default false
    */
@@ -2846,23 +2861,10 @@ export interface GridLineOptions {
    * @default 'rgba(0, 0, 0, 0.1)'
    */
   color: ScriptableAndArray<Color, ScriptableScaleContext>;
-  /**
-   * @default []
-   */
-  borderDash: Scriptable<number[], ScriptableScaleContext>;
-  /**
-   * @default 0
-   */
-  borderDashOffset: Scriptable<number, ScriptableScaleContext>;
   /**
    * @default 1
    */
   lineWidth: ScriptableAndArray<number, ScriptableScaleContext>;
-
-  /**
-   * @default true
-   */
-  drawBorder: boolean;
   /**
    * @default true
    */
@@ -3092,6 +3094,8 @@ export interface CartesianScaleOptions extends CoreScaleOptions {
 
   grid: GridLineOptions;
 
+  border: BorderOptions;
+
   /** Options for the scale title. */
   title: {
     /** If true, displays the axis title. */