From b46499985147eae78bd63dea96978008ba8d8912 Mon Sep 17 00:00:00 2001 From: Evert Timberg Date: Sun, 5 Jan 2020 15:50:24 -0500 Subject: [PATCH] Bar chart defaults to begin at zero (#6917) * Bar chart defaults to begin at zero * Add bar beginAtZero test --- src/controllers/controller.bar.js | 1 + .../bar-default-begin-at-zero.js | 29 ++++++++++++++++++ .../bar-default-begin-at-zero.png | Bin 0 -> 5944 bytes test/specs/controller.bar.tests.js | 6 ++-- test/specs/scale.linear.tests.js | 8 +++-- 5 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 test/fixtures/controller.bar/bar-default-begin-at-zero.js create mode 100644 test/fixtures/controller.bar/bar-default-begin-at-zero.png 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 0000000000000000000000000000000000000000..4ec05955cb661f7e9ef53801a46e4e0c1b4473e7 GIT binary patch literal 5944 zcmeAS@N?(olHy`uVBq!ia0y~yU;;83893O0)X@p&(is@U{(HJOhE&A8z3JGOcRJMN zVU_U$M&+bCJseW=8Z(wE=hS>;5=D*v|6r*XQ;2_V)jO z-p>B>uk*nEzkfb{j`!bRAi>BY@FSk(p96Dayl?u*di_H;cdrafbT`G#ObRh&-Ra$A|I90@!{5AI2ds_vJ1{WTGk)NmBNV{kSNQMbX^{qd&Qpd^Bka2ym_D3W`dxo_HG{~N zOeF)C1NDqNGiTbmGHP7VW?(Iy#la&Oz|eN)%)CVmA}>T6nyh?T+Bh^AoYT_$0~xr! za5*^6Rbz5y5ou5~-n?9cfwhWt!2&WRQ~fO@wuU!+NOg4vZ2;#?@U+0Sm$zxL%nEN+>O07sW10}f-fnIBF&d&lokHBE>!;sY%#pPW}@40=;CD703N^Mo`yf-ZS$VQGit1f zzPyEj%iUkh!O-HYA=9ULiK(XxdGrQ-i(3_lqD-LGR%Z~pwBFm@kb#gxb)e{{0~w@xF3KN-2eE$u;4gy0Y54|8Z1cl{b+I+O%9{U zVb{pW2JxT%$Jf=>{d-(kcf8*H!TtJwKYpHmzs};<)<5!%HM^dv{O39#{MldD?k9s^ zTngiygql4q|N9Rd>-$`P=ECvkbAGI6unGEq;Ulnud1A|Tfb-aK?;rm;a^6_{Kh9HI ubFLGpUHL1&tUXZsy~PZp+DQqz|Ge>%89vR4#&*CFaRyIUKbLh*2~7Z^Sn*T< literal 0 HcmV?d00001 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 + } } } });