]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Options need to include dataset level defaults from main chart type (#8534)
authorEvert Timberg <evert.timberg+github@gmail.com>
Sun, 28 Feb 2021 06:58:07 +0000 (01:58 -0500)
committerGitHub <noreply@github.com>
Sun, 28 Feb 2021 06:58:07 +0000 (08:58 +0200)
src/core/core.config.js
test/specs/core.controller.tests.js

index f93a8ba9ef89b2107d2740be6477efa81e21b747..32b70dded58b84e6a034128361561bf35beef6ea 100644 (file)
@@ -276,9 +276,11 @@ export default class Config {
    * @return {object[]}
    */
   chartOptionScopes() {
+    const controllerDefaults = defaults.controllers[this.type] || {};
     return [
       this.options,
-      defaults.controllers[this.type] || {},
+      controllerDefaults,
+      controllerDefaults.datasets || {},
       {type: this.type},
       defaults,
       defaults.descriptors
index e618e9c1f52f86195c922559c16ff1abbb8565a4..2fb13eb4bae2040339d7d5416a6b5ca2a7943d48 100644 (file)
@@ -171,6 +171,17 @@ describe('Chart', function() {
       defaults.controllers.line.spanGaps = false;
     });
 
+    it('should initialize config with default dataset options', function() {
+      var defaults = Chart.defaults.controllers.pie.datasets;
+
+      var chart = acquireChart({
+        type: 'pie'
+      });
+
+      var options = chart.options;
+      expect(options.circumference).toBe(defaults.circumference);
+    });
+
     it('should override axis positions that are incorrect', function() {
       var chart = acquireChart({
         type: 'line',