]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix: update chart when attached (#7758)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Fri, 4 Sep 2020 20:47:36 +0000 (23:47 +0300)
committerGitHub <noreply@github.com>
Fri, 4 Sep 2020 20:47:36 +0000 (16:47 -0400)
src/core/core.controller.js
test/specs/core.controller.tests.js

index 58b810b3f7e6b0f957d4c91c2665d7a74d38f0b2..2a932062c4fa11b782909285d40c0e6cdbd57a89 100644 (file)
@@ -1010,8 +1010,8 @@ class Chart {
                        const attached = () => {
                                _remove('attach', attached);
 
-                               me.resize();
                                me.attached = true;
+                               me.resize();
 
                                _add('resize', listener);
                                _add('detach', detached);
index e733d6a6bd3d52c1762caa825968030af5cfb2bd..12045a787151fd7d864c89051055137b785635ef 100644 (file)
@@ -637,6 +637,7 @@ describe('Chart', function() {
                                dw: 0, dh: 0,
                                rw: 0, rh: 0,
                        });
+                       expect(chart.chartArea).toBeUndefined();
 
                        waitForResize(chart, function() {
                                expect(chart).toBeChartOfSize({
@@ -644,6 +645,8 @@ describe('Chart', function() {
                                        rw: 455, rh: 355,
                                });
 
+                               expect(chart.chartArea).not.toBeUndefined();
+
                                body.removeChild(wrapper);
                                chart.destroy();
                                done();