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 {
55 view : ObjectConstructor ;
66 } ;
77 private chart ;
8- initialize ( ) : void ;
8+ connect ( ) : void ;
9+ disconnect ( ) : void ;
910 viewValueChanged ( ) : void ;
1011 private dispatchEvent ;
1112}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class default_1 extends Controller {
1010 super ( ...arguments ) ;
1111 this . chart = null ;
1212 }
13- initialize ( ) {
13+ connect ( ) {
1414 if ( ! isChartInitialized ) {
1515 isChartInitialized = true ;
1616 this . dispatchEvent ( 'init' , {
@@ -35,6 +35,13 @@ class default_1 extends Controller {
3535 this . chart = new Chart ( canvasContext , payload ) ;
3636 this . dispatchEvent ( 'connect' , { chart : this . chart } ) ;
3737 }
38+ disconnect ( ) {
39+ if ( this . chart ) {
40+ this . chart . destroy ( ) ;
41+ this . chart = null ;
42+ }
43+ this . dispatchEvent ( 'disconnect' , { chart : this . chart } ) ;
44+ }
3845 viewValueChanged ( ) {
3946 if ( this . chart ) {
4047 const viewValue = { data : this . viewValue . data , options : this . viewValue . options } ;
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ export default class extends Controller {
2828
2929 private chart : Chart | null = null ;
3030
31- initialize ( ) {
31+ connect ( ) {
3232 if ( ! isChartInitialized ) {
3333 isChartInitialized = true ;
3434 this . dispatchEvent ( 'init' , {
@@ -59,6 +59,15 @@ export default class extends Controller {
5959 this . dispatchEvent ( 'connect' , { chart : this . chart } ) ;
6060 }
6161
62+ disconnect ( ) {
63+ if ( this . chart ) {
64+ this . chart . destroy ( ) ;
65+ this . chart = null ;
66+ }
67+
68+ this . dispatchEvent ( 'disconnect' , { chart : this . chart } ) ;
69+ }
70+
6271 /**
6372 * If the underlying data or options change, let's update the chart!
6473 */
You can’t perform that action at this time.
0 commit comments