You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert axis options from arrays to objects (#6773)
* Convert axis options from arrays to objects
* Updated all chart type defaults
* Throw errors when axis type or position are not specified
* Avoid raising unnecessary errors when merging options into the default configs
* Fix additional tests
* Ensure scale defaults are set if type is not explicitly defined
* Another step
* Include `scale` as `firstIDs.r`
* update docs
* Update for buildOrUpdateScales
* Update migration guide
* Add test back
Copy file name to clipboardExpand all lines: docs/axes/cartesian/README.md
+8-9
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,8 @@ The following options are common to all cartesian axes but do not apply to other
38
38
| `padding` | `number` | `0` | Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.
39
39
40
40
### Axis ID
41
-
The properties `dataset.xAxisID` or `dataset.yAxisID` have to match the scale properties `scales.xAxes.id` or `scales.yAxes.id`. This is especially needed if multi-axes charts are used.
41
+
42
+
The properties `dataset.xAxisID` or `dataset.yAxisID` have to match to `scales` property. This is especially needed if multi-axes charts are used.
42
43
43
44
```javascript
44
45
var myChart =newChart(ctx, {
@@ -54,11 +55,10 @@ var myChart = new Chart(ctx, {
54
55
},
55
56
options: {
56
57
scales: {
57
-
yAxes: [{
58
-
id:'first-y-axis',
58
+
'first-y-axis': {
59
59
type:'linear'
60
-
}, {
61
-
id:'second-y-axis',
60
+
},
61
+
'second-y-axis': {
62
62
type:'linear'
63
63
}]
64
64
}
@@ -93,12 +93,11 @@ var myChart = new Chart(ctx, {
Copy file name to clipboardExpand all lines: docs/axes/cartesian/time.md
+7-6
Original file line number
Diff line number
Diff line change
@@ -67,18 +67,19 @@ var chart = new Chart(ctx, {
67
67
data: data,
68
68
options: {
69
69
scales: {
70
-
xAxes: [{
70
+
x:{
71
71
type:'time',
72
72
time: {
73
73
unit:'month'
74
74
}
75
-
}]
75
+
}
76
76
}
77
77
}
78
78
});
79
79
```
80
80
81
81
### Display Formats
82
+
82
83
The following display formats are used to configure how different time units are formed into strings for the axis tick marks. See [Moment.js](https://momentjs.com/docs/#/displaying/format/) for the allowable format strings.
83
84
84
85
Name | Default | Example
@@ -101,14 +102,14 @@ var chart = new Chart(ctx, {
101
102
data: data,
102
103
options: {
103
104
scales: {
104
-
xAxes: [{
105
+
x:{
105
106
type:'time',
106
107
time: {
107
108
displayFormats: {
108
109
quarter:'MMM YYYY'
109
110
}
110
111
}
111
-
}]
112
+
}
112
113
}
113
114
}
114
115
});
@@ -127,10 +128,10 @@ var chart = new Chart(ctx, {
Copy file name to clipboardExpand all lines: docs/charts/bar.md
+15-10
Original file line number
Diff line number
Diff line change
@@ -41,9 +41,9 @@ A bar chart provides a way of showing data values represented as vertical bars.
41
41
},
42
42
"options": {
43
43
"scales": {
44
-
"yAxes": [{
44
+
"y": {
45
45
"beginAtZero": true
46
-
}]
46
+
}
47
47
}
48
48
}
49
49
}
@@ -160,14 +160,17 @@ data: {
160
160
}]
161
161
};
162
162
```
163
+
163
164
### barThickness
165
+
164
166
If this value is a number, it is applied to the width of each bar, in pixels. When this is enforced, `barPercentage` and `categoryPercentage` are ignored.
165
167
166
168
If set to `'flex'`, the base sample widths are calculated automatically based on the previous and following samples so that they take the full available widths without overlap. Then, bars are sized using `barPercentage` and `categoryPercentage`. There is no gap when the percentage options are 1. This mode generates bars with different widths when data are not evenly spaced.
167
169
168
170
If not set (default), the base sample widths are calculated using the smallest interval that prevents bar overlapping, and bars are sized using `barPercentage` and `categoryPercentage`. This mode always generates bars equally sized.
169
171
170
172
## Scale Configuration
173
+
171
174
The bar chart sets unique default values for the following configuration from the associated `scale` options:
172
175
173
176
| Name | Type | Default | Description
@@ -180,16 +183,17 @@ The bar chart sets unique default values for the following configuration from th
180
183
```javascript
181
184
options = {
182
185
scales: {
183
-
xAxes: [{
186
+
x:{
184
187
gridLines: {
185
188
offsetGridLines:true
186
189
}
187
-
}]
190
+
}
188
191
}
189
192
};
190
193
```
191
194
192
195
### offsetGridLines
196
+
193
197
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.
194
198
195
199
## Default Options
@@ -249,12 +253,12 @@ var stackedBar = new Chart(ctx, {
249
253
data: data,
250
254
options: {
251
255
scales: {
252
-
xAxes: [{
256
+
x:{
253
257
stacked:true
254
-
}],
255
-
yAxes: [{
258
+
},
259
+
y:{
256
260
stacked:true
257
-
}]
261
+
}
258
262
}
259
263
}
260
264
});
@@ -267,6 +271,7 @@ The following dataset properties are specific to stacked bar charts.
267
271
| `stack` | `string` | The ID of the group to which this dataset belongs to (when stacked, each group will be a separate stack).
268
272
269
273
## Horizontal Bar Chart
274
+
270
275
A horizontal bar chart is a variation on a vertical bar chart. It is sometimes used to show trend data, and the comparison of multiple data sets side by side.
271
276
{% chartjs %}
272
277
{
@@ -300,9 +305,9 @@ A horizontal bar chart is a variation on a vertical bar chart. It is sometimes u
0 commit comments