]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Bar chart defaults to begin at zero (#6917)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 5 Jan 2020 20:50:24 +0000 (15:50 -0500)
committerGitHub <noreply@github.com>
Sun, 5 Jan 2020 20:50:24 +0000 (15:50 -0500)
* Bar chart defaults to begin at zero

* Add bar beginAtZero test

src/controllers/controller.bar.js
test/fixtures/controller.bar/bar-default-begin-at-zero.js [new file with mode: 0644]
test/fixtures/controller.bar/bar-default-begin-at-zero.png [new file with mode: 0644]
test/specs/controller.bar.tests.js
test/specs/scale.linear.tests.js

index 760c80e40d7578bd9e99b16b17547a2bbfc743c3..2326d0b94673a7a88e54763064d8f32d88d2bfda 100644 (file)
@@ -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 (file)
index 0000000..1f3e21d
--- /dev/null
@@ -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 (file)
index 0000000..4ec0595
Binary files /dev/null and b/test/fixtures/controller.bar/bar-default-begin-at-zero.png differ
index 317dc946f376d6fa25b747dfc866008eaf239934..e7d36c3fc27a81d56afeccc02918ad8767000b63 100644 (file)
@@ -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
                                        }
                                }
                        }
index cad0e51819f0a50e22e2fbffc58849c65815e4f2..389235f5f8e2893e2ee6909c573cf2972ad58d97 100644 (file)
@@ -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
+                                       }
                                }
                        }
                });