From: Evert Timberg Date: Sun, 5 Jan 2020 20:50:24 +0000 (-0500) Subject: Bar chart defaults to begin at zero (#6917) X-Git-Tag: v3.0.0-alpha~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b46499985147eae78bd63dea96978008ba8d8912;p=thirdparty%2FChart.js.git Bar chart defaults to begin at zero (#6917) * Bar chart defaults to begin at zero * Add bar beginAtZero test --- diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index 760c80e40..2326d0b94 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -22,6 +22,7 @@ defaults._set('bar', { }, y: { type: 'linear', + beginAtZero: true, } } }); diff --git a/test/fixtures/controller.bar/bar-default-begin-at-zero.js b/test/fixtures/controller.bar/bar-default-begin-at-zero.js new file mode 100644 index 000000000..1f3e21d97 --- /dev/null +++ b/test/fixtures/controller.bar/bar-default-begin-at-zero.js @@ -0,0 +1,29 @@ +module.exports = { + config: { + type: 'bar', + data: { + labels: [0, 1, 3, 4], + datasets: [ + { + data: [5, 20, 1, 10], + backgroundColor: '#00ff00', + borderColor: '#ff0000' + } + ] + }, + options: { + legend: false, + title: false, + scales: { + x: {display: false}, + y: {display: false} + } + } + }, + options: { + canvas: { + height: 256, + width: 512 + } + } +}; diff --git a/test/fixtures/controller.bar/bar-default-begin-at-zero.png b/test/fixtures/controller.bar/bar-default-begin-at-zero.png new file mode 100644 index 000000000..4ec05955c Binary files /dev/null and b/test/fixtures/controller.bar/bar-default-begin-at-zero.png differ diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 317dc946f..e7d36c3fc 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -708,7 +708,8 @@ describe('Chart.controllers.bar', function() { }, y: { type: 'linear', - display: false + display: false, + beginAtZero: false } } } @@ -773,7 +774,8 @@ describe('Chart.controllers.bar', function() { }, y: { type: 'linear', - display: false + display: false, + beginAtZero: false } } } diff --git a/test/specs/scale.linear.tests.js b/test/specs/scale.linear.tests.js index cad0e5181..389235f5f 100644 --- a/test/specs/scale.linear.tests.js +++ b/test/specs/scale.linear.tests.js @@ -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 + } } } });