Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions docs/docs/axes/radial/linear.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ let chart = new Chart(ctx, {
labels: ['January', 'February', 'March', 'April']
},
options: {
scale: {
suggestedMin: 50,
suggestedMax: 100
scales: {
r: {
suggestedMin: 50,
suggestedMax: 100
}
}
}
});
Expand All @@ -83,11 +85,13 @@ This example sets up a chart with a y axis that creates ticks at `0, 0.5, 1, 1.5

```javascript
let options = {
scale: {
max: 5,
min: 0,
ticks: {
stepSize: 0.5
scales: {
r: {
max: 5,
min: 0,
ticks: {
stepSize: 0.5
}
}
}
};
Expand Down
14 changes: 8 additions & 6 deletions docs/docs/charts/radar.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,14 @@ The options for this scale are defined in the `scale` property, which can be ref

```javascript
options = {
scale: {
angleLines: {
display: false
},
suggestedMin: 50,
suggestedMax: 100
scales: {
r: {
angleLines: {
display: false
},
suggestedMin: 50,
suggestedMax: 100
}
}
};
```
Expand Down
1 change: 1 addition & 0 deletions docs/docs/getting-started/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ A number of changes were made to the configuration options passed to the `Chart`
* Polar area `startAngle` option is now consistent with `Radar`, 0 is at top and value is in degrees. Default is changed from `-½π` to `0`.
* Doughnut `rotation` option is now in degrees and 0 is at top. Default is changed from `-½π` to `0`.
* Doughnut `circumference` option is now in degrees. Default is changed from `2π` to `360`.
* `scale` option was removed in favor of `options.scales.r` (or any other scale id, with `axis: 'r'`)
* `scales.[x/y]Axes` arrays were removed. Scales are now configured directly to `options.scales` object with the object key being the scale Id.
* `scales.[x/y]Axes.barPercentage` was moved to dataset option `barPercentage`
* `scales.[x/y]Axes.barThickness` was moved to dataset option `barThickness`
Expand Down
12 changes: 7 additions & 5 deletions samples/charts/polar-area.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
text: 'Chart.js Polar Area Chart'
},
},
scale: {
ticks: {
beginAtZero: true
},
reverse: false
scales: {
r: {
ticks: {
beginAtZero: true
},
reverse: false
}
},
animation: {
animateRotate: false,
Expand Down
6 changes: 4 additions & 2 deletions samples/charts/radar-skip-points.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@
tension: 0.0,
}
},
scale: {
beginAtZero: true,
scales: {
r: {
beginAtZero: true,
},
}
}
};
Expand Down
6 changes: 4 additions & 2 deletions samples/charts/radar.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@
text: 'Chart.js Radar Chart'
},
},
scale: {
beginAtZero: true
scales: {
r: {
beginAtZero: true
}
}
}
};
Expand Down
6 changes: 0 additions & 6 deletions src/core/core.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ function mergeScaleConfig(config, options) {
scales[id] = mergeIf(Object.create(null), [{axis}, scaleConf, defaultScaleOptions[axis], defaultScaleOptions[defaultId]]);
});

// Backward compatibility
if (options.scale) {
scales[options.scale.id || 'r'] = mergeIf(Object.create(null), [{axis: 'r'}, options.scale, chartDefaults.scales.r]);
firstIDs.r = firstIDs.r || options.scale.id || 'r';
}

// Then merge dataset defaults to scale configs
config.data.datasets.forEach(dataset => {
const type = dataset.type || config.type;
Expand Down
7 changes: 0 additions & 7 deletions src/core/core.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,6 @@ class Chart {
}

scale.init(scaleOptions, options);

// TODO(SB): I think we should be able to remove this custom case (options.scale)
// and consider it as a regular scale part of the "scales"" map only! This would
// make the logic easier and remove some useless? custom code.
if (item.isDefault) {
me.scale = scale;
}
});
// clear up discarded scales
each(updated, (hasUpdated, id) => {
Expand Down
58 changes: 30 additions & 28 deletions test/fixtures/controller.polarArea/angle-array.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
{
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}]
},
"options": {
"elements": {
"arc": {
"angle": [
60.5387, 100.6457, 60.5387, 123.5641, 14.7021
]
}
},
"responsive": false,
"scale": {
"display": false
}
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [
{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}
]
},
"options": {
"elements": {
"arc": {
"angle": [60.5387, 100.6457, 60.5387, 123.5641, 14.7021]
}
},
"responsive": false,
"scales": {
"r": {
"display": false
}
}
}
}
}
62 changes: 33 additions & 29 deletions test/fixtures/controller.polarArea/angle-lines.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
{
"threshold": 0.05,
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}]
},
"options": {
"responsive": false,
"scale": {
"display": true,
"angleLines": {
"display": true,
"color": "#000"
},
"ticks": {
"display": false
}
}
"threshold": 0.05,
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [
{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}
]
},
"options": {
"responsive": false,
"scales": {
"r": {
"display": true,
"angleLines": {
"display": true,
"color": "#000"
},
"ticks": {
"display": false
}
}
}
}
}
}
46 changes: 25 additions & 21 deletions test/fixtures/controller.polarArea/angle-undefined.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}]
},
"options": {
"responsive": false,
"scale": {
"display": false
}
"config": {
"type": "polarArea",
"data": {
"labels": ["A", "B", "C", "D", "E"],
"datasets": [
{
"data": [11, 16, 21, 7, 10],
"backgroundColor": [
"rgba(255, 99, 132, 0.8)",
"rgba(54, 162, 235, 0.8)",
"rgba(255, 206, 86, 0.8)",
"rgba(75, 192, 192, 0.8)",
"rgba(153, 102, 255, 0.8)",
"rgba(255, 159, 64, 0.8)"
]
}
]
},
"options": {
"responsive": false,
"scales": {
"r": {
"display": false
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ module.exports = {
]
},
options: {
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ module.exports = {
]
}
},
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ module.exports = {
]
},
options: {
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ module.exports = {
}
}
},
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ module.exports = {
]
},
options: {
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ module.exports = {
backgroundColor: '#00ff00'
}
},
scale: {
display: false
scales: {
r: {
display: false
}
}
}
},
Expand Down
Loading