File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,8 @@ export default class extends Controller {
5
5
view : ObjectConstructor ;
6
6
} ;
7
7
private chart ;
8
- initialize ( ) : void ;
8
+ connect ( ) : void ;
9
+ disconnect ( ) : void ;
9
10
viewValueChanged ( ) : void ;
10
11
private dispatchEvent ;
11
12
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class default_1 extends Controller {
10
10
super ( ...arguments ) ;
11
11
this . chart = null ;
12
12
}
13
- initialize ( ) {
13
+ connect ( ) {
14
14
if ( ! isChartInitialized ) {
15
15
isChartInitialized = true ;
16
16
this . dispatchEvent ( 'init' , {
@@ -35,6 +35,13 @@ class default_1 extends Controller {
35
35
this . chart = new Chart ( canvasContext , payload ) ;
36
36
this . dispatchEvent ( 'connect' , { chart : this . chart } ) ;
37
37
}
38
+ disconnect ( ) {
39
+ if ( this . chart ) {
40
+ this . chart . destroy ( ) ;
41
+ this . chart = null ;
42
+ }
43
+ this . dispatchEvent ( 'disconnect' , { chart : this . chart } ) ;
44
+ }
38
45
viewValueChanged ( ) {
39
46
if ( this . chart ) {
40
47
const viewValue = { data : this . viewValue . data , options : this . viewValue . options } ;
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ export default class extends Controller {
26
26
27
27
private chart : Chart | null = null ;
28
28
29
- initialize ( ) {
29
+ connect ( ) {
30
30
if ( ! isChartInitialized ) {
31
31
isChartInitialized = true ;
32
32
this . dispatchEvent ( 'init' , {
@@ -57,6 +57,15 @@ export default class extends Controller {
57
57
this . dispatchEvent ( 'connect' , { chart : this . chart } ) ;
58
58
}
59
59
60
+ disconnect ( ) {
61
+ if ( this . chart ) {
62
+ this . chart . destroy ( ) ;
63
+ this . chart = null ;
64
+ }
65
+
66
+ this . dispatchEvent ( 'disconnect' , { chart : this . chart } ) ;
67
+ }
68
+
60
69
/**
61
70
* If the underlying data or options change, let's update the chart!
62
71
*/
You can’t perform that action at this time.
0 commit comments