diff --git a/docs/getting-started/v3-migration.md b/docs/getting-started/v3-migration.md index cf838818339..d84054d9d9c 100644 --- a/docs/getting-started/v3-migration.md +++ b/docs/getting-started/v3-migration.md @@ -156,6 +156,7 @@ Animation system was completely rewritten in Chart.js v3. Each property can now #### Scales +* Linear/Radial linear `beginAtZero` now defaults to `true` instead of `false`. * `Scale.getLabelForIndex` was replaced by `scale.getLabelForValue` * `Scale.getPixelForValue` now has only one parameter. For the `TimeScale` that parameter must be millis since the epoch diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index bf287f1276e..93db36cc0ee 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -22,7 +22,6 @@ defaults._set('polarArea', { angleLines: { display: false }, - beginAtZero: true, gridLines: { circular: true }, diff --git a/src/scales/scale.linear.js b/src/scales/scale.linear.js index 27a67a76f65..0b15876e96c 100644 --- a/src/scales/scale.linear.js +++ b/src/scales/scale.linear.js @@ -6,6 +6,7 @@ import LinearScaleBase from './scale.linearbase'; import Ticks from '../core/core.ticks'; const defaultConfig = { + beginAtZero: true, ticks: { callback: Ticks.formatters.linear } diff --git a/src/scales/scale.radialLinear.js b/src/scales/scale.radialLinear.js index 433088b0f8e..f6ab91f0d7b 100644 --- a/src/scales/scale.radialLinear.js +++ b/src/scales/scale.radialLinear.js @@ -15,6 +15,7 @@ const defaultConfig = { // Boolean - Whether to animate scaling the chart from the centre animate: true, + beginAtZero: true, position: 'chartArea', angleLines: { diff --git a/test/fixtures/controller.bubble/radius-scriptable.js b/test/fixtures/controller.bubble/radius-scriptable.js index 021b678215d..1437a30d9e1 100644 --- a/test/fixtures/controller.bubble/radius-scriptable.js +++ b/test/fixtures/controller.bubble/radius-scriptable.js @@ -21,7 +21,7 @@ module.exports = { title: false, scales: { x: {display: false}, - y: {display: false} + y: {beginAtZero: false, display: false} }, elements: { point: { diff --git a/test/fixtures/controller.line/borderCapStyle/value.js b/test/fixtures/controller.line/borderCapStyle/value.js index 16393fed502..9f02b975814 100644 --- a/test/fixtures/controller.line/borderCapStyle/value.js +++ b/test/fixtures/controller.line/borderCapStyle/value.js @@ -39,7 +39,7 @@ module.exports = { }, scales: { x: {display: false}, - y: {display: false} + y: {beginAtZero: false, display: false} } } }, diff --git a/test/fixtures/controller.line/clip/default-x-max.json b/test/fixtures/controller.line/clip/default-x-max.json index ea8f541a3b4..8cc2f62d2ca 100644 --- a/test/fixtures/controller.line/clip/default-x-max.json +++ b/test/fixtures/controller.line/clip/default-x-max.json @@ -22,7 +22,10 @@ "display": false } }, - "y": {"ticks": {"display": false}} + "y": { + "beginAtZero": false, + "ticks": {"display": false} + } }, "layout": { "padding": 24 diff --git a/test/fixtures/controller.line/clip/default-x-min.json b/test/fixtures/controller.line/clip/default-x-min.json index 65d85cc88c1..c5c37172a5f 100644 --- a/test/fixtures/controller.line/clip/default-x-min.json +++ b/test/fixtures/controller.line/clip/default-x-min.json @@ -22,7 +22,10 @@ "display": false } }, - "y": {"ticks": {"display": false}} + "y": { + "beginAtZero": false, + "ticks": {"display": false} + } }, "layout": { "padding": 24 diff --git a/test/fixtures/controller.line/clip/default-x.json b/test/fixtures/controller.line/clip/default-x.json index 5a8e2c16ae0..7a6fc95224a 100644 --- a/test/fixtures/controller.line/clip/default-x.json +++ b/test/fixtures/controller.line/clip/default-x.json @@ -23,7 +23,10 @@ "display": false } }, - "y": {"ticks": {"display": false}} + "y": { + "beginAtZero": false, + "ticks": {"display": false} + } }, "layout": { "padding": 24 diff --git a/test/fixtures/controller.line/clip/default-y-max.json b/test/fixtures/controller.line/clip/default-y-max.json index 8fe92a4d61c..04c04b79af4 100644 --- a/test/fixtures/controller.line/clip/default-y-max.json +++ b/test/fixtures/controller.line/clip/default-y-max.json @@ -18,6 +18,7 @@ "scales": { "x": {"ticks": {"display": false}}, "y": { + "beginAtZero": false, "max": 6, "ticks": { "display": false diff --git a/test/fixtures/element.point/point-style-circle.json b/test/fixtures/element.point/point-style-circle.json index ba84c4c7bcc..bb74799f471 100644 --- a/test/fixtures/element.point/point-style-circle.json +++ b/test/fixtures/element.point/point-style-circle.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-cross-rot.json b/test/fixtures/element.point/point-style-cross-rot.json index c5add4a30e2..bf30ccedd84 100644 --- a/test/fixtures/element.point/point-style-cross-rot.json +++ b/test/fixtures/element.point/point-style-cross-rot.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-cross.json b/test/fixtures/element.point/point-style-cross.json index 5cce6483fa2..24aed354d5a 100644 --- a/test/fixtures/element.point/point-style-cross.json +++ b/test/fixtures/element.point/point-style-cross.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-dash.json b/test/fixtures/element.point/point-style-dash.json index 0b08ef5925c..29903576364 100644 --- a/test/fixtures/element.point/point-style-dash.json +++ b/test/fixtures/element.point/point-style-dash.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-image.js b/test/fixtures/element.point/point-style-image.js index 6ac2f1f8a8c..74ec545d3f6 100644 --- a/test/fixtures/element.point/point-style-image.js +++ b/test/fixtures/element.point/point-style-image.js @@ -45,7 +45,7 @@ module.exports = { }, scales: { x: {display: false}, - y: {display: false} + y: {display: false, beginAtZero: false} } } }, diff --git a/test/fixtures/element.point/point-style-line.json b/test/fixtures/element.point/point-style-line.json index 7260455dfbc..b14f5d198ed 100644 --- a/test/fixtures/element.point/point-style-line.json +++ b/test/fixtures/element.point/point-style-line.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-rect-rot.json b/test/fixtures/element.point/point-style-rect-rot.json index 642b400e416..4fc560d4a91 100644 --- a/test/fixtures/element.point/point-style-rect-rot.json +++ b/test/fixtures/element.point/point-style-rect-rot.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-rect-rounded.json b/test/fixtures/element.point/point-style-rect-rounded.json index d99d03c44cc..c1977d5d164 100644 --- a/test/fixtures/element.point/point-style-rect-rounded.json +++ b/test/fixtures/element.point/point-style-rect-rounded.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-rect.json b/test/fixtures/element.point/point-style-rect.json index 1d0c361f986..b6ff981a1bf 100644 --- a/test/fixtures/element.point/point-style-rect.json +++ b/test/fixtures/element.point/point-style-rect.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-star.json b/test/fixtures/element.point/point-style-star.json index 62808cca0e2..32ae190cf94 100644 --- a/test/fixtures/element.point/point-style-star.json +++ b/test/fixtures/element.point/point-style-star.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/point-style-triangle.json b/test/fixtures/element.point/point-style-triangle.json index 46c510ede0f..8cbdd58c81f 100644 --- a/test/fixtures/element.point/point-style-triangle.json +++ b/test/fixtures/element.point/point-style-triangle.json @@ -54,7 +54,7 @@ }, "scales": { "x": {"display": false}, - "y": {"display": false} + "y": {"display": false, "beginAtZero": false} } } }, diff --git a/test/fixtures/element.point/rotation.js b/test/fixtures/element.point/rotation.js index 12087d88fcf..27047e5b6e1 100644 --- a/test/fixtures/element.point/rotation.js +++ b/test/fixtures/element.point/rotation.js @@ -43,7 +43,7 @@ module.exports = { }, scales: { x: {display: false}, - y: {display: false} + y: {display: false, beginAtZero: false} } } }, diff --git a/test/fixtures/scale.radialLinear/gridlines-no-z.json b/test/fixtures/scale.radialLinear/gridlines-no-z.json index 362c519048d..b38ae2776ab 100644 --- a/test/fixtures/scale.radialLinear/gridlines-no-z.json +++ b/test/fixtures/scale.radialLinear/gridlines-no-z.json @@ -13,6 +13,7 @@ "legend": false, "title": false, "scale": { + "beginAtZero": false, "gridLines": { "color": "rgba(0, 0, 0, 1)", "lineWidth": 1 diff --git a/test/fixtures/scale.radialLinear/gridlines-z.json b/test/fixtures/scale.radialLinear/gridlines-z.json index add497b9a13..a99f547e595 100644 --- a/test/fixtures/scale.radialLinear/gridlines-z.json +++ b/test/fixtures/scale.radialLinear/gridlines-z.json @@ -13,6 +13,7 @@ "legend": false, "title": false, "scale": { + "beginAtZero": false, "gridLines": { "color": "rgba(0, 0, 0, 1)", "lineWidth": 1, diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 317dc946f37..5dd0b4d563e 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -708,6 +708,7 @@ describe('Chart.controllers.bar', function() { }, y: { type: 'linear', + beginAtZero: false, display: false } } @@ -773,6 +774,7 @@ describe('Chart.controllers.bar', function() { }, y: { type: 'linear', + beginAtZero: false, display: false } } diff --git a/test/specs/controller.line.tests.js b/test/specs/controller.line.tests.js index 383a0443a63..8d4a429cbf4 100644 --- a/test/specs/controller.line.tests.js +++ b/test/specs/controller.line.tests.js @@ -183,6 +183,7 @@ describe('Chart.controllers.line', function() { display: false }, y: { + beginAtZero: false, display: false } } diff --git a/test/specs/core.tooltip.tests.js b/test/specs/core.tooltip.tests.js index 01c5b303c38..0ea323b895a 100644 --- a/test/specs/core.tooltip.tests.js +++ b/test/specs/core.tooltip.tests.js @@ -47,6 +47,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'index', intersect: false, @@ -227,6 +232,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'nearest', intersect: true @@ -345,6 +355,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'index', callbacks: { @@ -506,6 +521,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'index', itemSort: function(a, b) { @@ -587,6 +607,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'index', reverse: true @@ -668,6 +693,11 @@ describe('Core.Tooltip', function() { labels: ['Point 1', 'Point 2', 'Point 3'] }, options: { + scales: { + y: { + beginAtZero: false, + } + }, tooltips: { mode: 'index' } diff --git a/test/specs/scale.linear.tests.js b/test/specs/scale.linear.tests.js index cad0e51819f..ed9f9fcb40a 100644 --- a/test/specs/scale.linear.tests.js +++ b/test/specs/scale.linear.tests.js @@ -27,7 +27,7 @@ describe('Linear Scale', function() { }, offset: false, reverse: false, - beginAtZero: false, + beginAtZero: true, scaleLabel: Chart.defaults.scale.scaleLabel, ticks: { minRotation: 0, @@ -210,7 +210,8 @@ describe('Linear Scale', function() { options: { scales: { y: { - type: 'linear' + type: 'linear', + beginAtZero: false, } } } @@ -673,6 +674,7 @@ describe('Linear Scale', function() { scales: { y: { type: 'linear', + beginAtZero: false, } } } @@ -751,7 +753,9 @@ describe('Linear Scale', function() { }, options: { scales: { - y: {} + y: { + beginAtZero: false, + } } } }); diff --git a/test/specs/scale.radialLinear.tests.js b/test/specs/scale.radialLinear.tests.js index a64157a7e69..32a31a9c107 100644 --- a/test/specs/scale.radialLinear.tests.js +++ b/test/specs/scale.radialLinear.tests.js @@ -45,7 +45,7 @@ describe('Test the radial linear scale', function() { position: 'chartArea', offset: false, reverse: false, - beginAtZero: false, + beginAtZero: true, scaleLabel: Chart.defaults.scale.scaleLabel, ticks: { backdropColor: 'rgba(255,255,255,0.75)', @@ -144,7 +144,11 @@ describe('Test the radial linear scale', function() { labels: ['label1', 'label2', 'label3', 'label4', 'label5', 'label6', 'label7', 'label8'] }, options: { - scales: {} + scales: { + r: { + beginAtZero: false, + } + } } }); @@ -161,7 +165,9 @@ describe('Test the radial linear scale', function() { }, options: { scales: { - rScale: {} + rScale: { + beginAtZero: false, + } } } }); @@ -281,6 +287,7 @@ describe('Test the radial linear scale', function() { }, options: { scale: { + beginAtZero: false, pointLabels: { display: false }