]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix for allowing parsing:false with stacks (#8934)
authorPrateek R Patil <prateek.patil@gmail.com>
Sun, 18 Apr 2021 11:28:56 +0000 (04:28 -0700)
committerGitHub <noreply@github.com>
Sun, 18 Apr 2021 11:28:56 +0000 (07:28 -0400)
* Initial fix for allowing parsing:false with stacks

* Added test from #8935 as requested.

Co-authored-by: tinfoilpancakes <tfm357@gmail.com>
src/core/core.datasetController.js
test/specs/core.datasetController.tests.js

index 8d8e9a95ec9435200ee8223934f83f83c3709d78..a3882e9e66da89d2e7ce13d8762c4a976c0e5023 100644 (file)
@@ -392,6 +392,7 @@ export default class DatasetController {
     if (me._parsing === false) {
       meta._parsed = data;
       meta._sorted = true;
+      parsed = data;
     } else {
       if (isArray(data[start])) {
         parsed = me.parseArrayData(meta, data, start, count);
index d9075754ca4330ab2fcbb843362c4317f8b1d617..ce7d121b6c9b6d71e67f2e16c274409cf7bc94a0 100644 (file)
@@ -699,6 +699,29 @@ describe('Chart.DatasetController', function() {
     Chart.defaults.parsing = originalDefault;
   });
 
+  it('should not fail to produce stacks when parsing is off', function() {
+    var chart = acquireChart({
+      type: 'line',
+      data: {
+        datasets: [{
+          data: [{x: 1, y: 10}]
+        }, {
+          data: [{x: 1, y: 20}]
+        }]
+      },
+      options: {
+        parsing: false,
+        scales: {
+          x: {stacked: true},
+          y: {stacked: true}
+        }
+      }
+    });
+
+    var meta = chart.getDatasetMeta(0);
+    expect(meta._parsed[0]._stacks).toEqual(jasmine.objectContaining({y: {0: 10, 1: 20}}));
+  });
+
   describe('resolveDataElementOptions', function() {
     it('should cache options when possible', function() {
       const chart = acquireChart({