Skip to content

Commit 6ac89cb

Browse files
authored
Rename scale gridLines options to be clearer (#8628)
* Rename `options.gridLines` to `options.grid` * Rename `offsetGridLines` to `offset`
1 parent 9799dbd commit 6ac89cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+137
-135
lines changed

docs/docs/axes/_common.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Namespace: `options.scales[scaleId]`
77
| `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.
88
| `backgroundColor` | [`Color`](../general/colors.md) | | Background color of the scale area.
99
| `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.
10-
| `gridLines` | `object` | | Grid line configuration. [more...](./styling.mdx#grid-line-configuration)
10+
| `grid` | `object` | | Grid line configuration. [more...](./styling.mdx#grid-line-configuration)
1111
| `min` | `number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](./index.mdx#axis-range-settings)
1212
| `max` | `number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](./index.mdx#axis-range-settings)
1313
| `reverse` | `boolean` | `false` | Reverse the scale.

docs/docs/axes/styling.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ There are a number of options to allow styling an axis. There are settings to co
88

99
## Grid Line Configuration
1010

11-
Namespace: `options.scales[scaleId].gridLines`, it defines options for the grid lines that run perpendicular to the axis.
11+
Namespace: `options.scales[scaleId].grid`, it defines options for the grid lines that run perpendicular to the axis.
1212

1313
| Name | Type | Scriptable | Indexable | Default | Description
1414
| ---- | ---- | :-------------------------------: | :-----------------------------: | ------- | -----------
@@ -23,7 +23,7 @@ Namespace: `options.scales[scaleId].gridLines`, it defines options for the grid
2323
| `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.
2424
| `drawTicks` | `boolean` | | | `true` | If true, draw lines beside the ticks in the axis area beside the chart.
2525
| `lineWidth` | `number` | Yes | Yes | `1` | Stroke width of grid lines.
26-
| `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.
26+
| `offset` | `boolean` | | | `false` | If true, grid lines will be shifted to be between labels. This is set to `true` for a bar chart by default.
2727
| `tickBorderDash` | `number[]` | | | | Length and spacing of the tick mark line. If not set, defaults to the grid line `borderDash` value.
2828
| `tickBorderDashOffset` | `number` | Yes | Yes | | Offset for the line dash of the tick mark. If unset, defaults to the grid line `borderDashOffset` value
2929
| `tickColor` | [`Color`](../general/colors.md) | Yes | Yes | | Color of the tick line. If unset, defaults to the grid line color.

docs/docs/charts/bar.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,23 +213,23 @@ The bar chart sets unique default values for the following configuration from th
213213
| Name | Type | Default | Description
214214
| ---- | ---- | ------- | -----------
215215
| `offset` | `boolean` | `true` | If true, extra space is added to both edges and the axis is scaled to fit into the chart area.
216-
| `gridLines.offsetGridLines` | `boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)
216+
| `grid.offset` | `boolean` | `true` | If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval. If false, the grid line will go right down the middle of the bars. [more...](#offsetgridlines)
217217

218218
### Example scale configuration
219219

220220
```javascript
221221
options = {
222222
scales: {
223223
x: {
224-
gridLines: {
225-
offsetGridLines: true
224+
grid: {
225+
offset: true
226226
}
227227
}
228228
}
229229
};
230230
```
231231

232-
### offsetGridLines
232+
### Offset Grid Lines
233233

234234
If true, the bars for a particular data point fall between the grid lines. The grid line will move to the left by one half of the tick interval, which is the space between the grid lines. If false, the grid line will go right down the middle of the bars. This is set to true for a category scale in a bar chart while false for other scales or chart types by default.
235235

docs/docs/getting-started/v3-migration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,9 @@ Animation system was completely rewritten in Chart.js v3. Each property can now
229229

230230
#### Ticks
231231

232-
* `options.gridLines.tickMarkLength` was renamed to `options.gridLines.tickLength`.
232+
* `options.gridLines` was renamed to `options.grid`
233+
* `options.gridLines.offsetGridLines` was renamed to `options.grid.offset`.
234+
* `options.gridLines.tickMarkLength` was renamed to `options.grid.tickLength`.
233235
* `options.ticks.fixedStepSize` is no longer used. Use `options.ticks.stepSize`.
234236
* `options.ticks.major` and `options.ticks.minor` were replaced with scriptable options for tick fonts.
235237
* `Chart.Ticks.formatters.linear` was renamed to `Chart.Ticks.formatters.numeric`.

samples/charts/bar/multi-axis.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
type: 'linear',
8787
display: true,
8888
position: 'right',
89-
gridLines: {
89+
grid: {
9090
drawOnChartArea: false
9191
}
9292
},

samples/charts/line/multi-axis.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
position: 'right',
8585

8686
// grid line settings
87-
gridLines: {
87+
grid: {
8888
drawOnChartArea: false, // only want the grid lines for one axis to show up
8989
},
9090
},

samples/charts/scatter/multi-axis.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
}
126126
},
127127

128-
gridLines: {
128+
grid: {
129129
drawOnChartArea: false, // only want the grid lines for one axis to show up
130130
}
131131
}

samples/scales/financial.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
},
174174
y: {
175175
type: 'linear',
176-
gridLines: {
176+
grid: {
177177
drawBorder: false
178178
},
179179
title: {

samples/scales/gridlines-display.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<body>
3030
<div class="container"></div>
3131
<script>
32-
function createConfig(gridlines, title) {
32+
function createConfig(grid, title) {
3333
return {
3434
type: 'line',
3535
data: {
@@ -58,10 +58,10 @@
5858
},
5959
scales: {
6060
x: {
61-
gridLines: gridlines
61+
grid: grid
6262
},
6363
y: {
64-
gridLines: gridlines,
64+
grid: grid,
6565
min: 0,
6666
max: 100,
6767
ticks: {
@@ -78,30 +78,30 @@
7878

7979
[{
8080
title: 'Display: true',
81-
gridLines: {
81+
grid: {
8282
display: true
8383
}
8484
}, {
8585
title: 'Display: false',
86-
gridLines: {
86+
grid: {
8787
display: false
8888
}
8989
}, {
9090
title: 'Display: false, no border',
91-
gridLines: {
91+
grid: {
9292
display: false,
9393
drawBorder: false
9494
}
9595
}, {
9696
title: 'DrawOnChartArea: false',
97-
gridLines: {
97+
grid: {
9898
display: true,
9999
drawBorder: true,
100100
drawOnChartArea: false,
101101
}
102102
}, {
103103
title: 'DrawTicks: false',
104-
gridLines: {
104+
grid: {
105105
display: true,
106106
drawBorder: true,
107107
drawOnChartArea: true,
@@ -116,7 +116,7 @@
116116
container.appendChild(div);
117117

118118
var ctx = canvas.getContext('2d');
119-
var config = createConfig(details.gridLines, details.title);
119+
var config = createConfig(details.grid, details.title);
120120
new Chart(ctx, config);
121121
});
122122
};

samples/scales/gridlines-scriptable.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
},
4848
scales: {
4949
y: {
50-
gridLines: {
50+
grid: {
5151
drawBorder: false,
5252
color: function(context) {
5353
if (context.tick.value > 0) {

0 commit comments

Comments
 (0)