File tree Expand file tree Collapse file tree 2 files changed +18
-17
lines changed
Expand file tree Collapse file tree 2 files changed +18
-17
lines changed Original file line number Diff line number Diff line change @@ -38,19 +38,23 @@ export default class EventTimeline extends LightningElement {
3838 xAxis ;
3939 yAxis ;
4040
41- async renderedCallback ( ) {
42- if ( this . isD3Initialized ) {
43- this . drawTimeline ( ) ;
44- return ;
45- }
41+ async connectedCallback ( ) {
4642 await loadScript ( this , D3 ) ;
4743 this . isD3Initialized = true ;
4844 this . initializeTimeline ( ) ;
49- this . drawTimeline ( ) ;
45+ }
46+
47+ async renderedCallback ( ) {
48+ this . initializeTimeline ( ) ;
5049 }
5150
5251 initializeTimeline ( ) {
52+ if ( ! this . isD3Initialized ) {
53+ return ;
54+ }
55+
5356 const rootElement = this . template . querySelector ( '.timeline' ) ;
57+ rootElement . childNodes . forEach ( ( childNode ) => childNode . remove ( ) ) ;
5458
5559 // Add SVG element
5660 const svgElement = d3
Original file line number Diff line number Diff line change @@ -17,7 +17,11 @@ export default class OrgLimits extends LightningElement {
1717
1818 async connectedCallback ( ) {
1919 try {
20- const limits = await getOrgLimits ( ) ;
20+ const [ limits ] = await Promise . all ( [
21+ getOrgLimits ( ) ,
22+ loadScript ( this , D3 )
23+ ] ) ;
24+ this . isD3Initialized = true ;
2125 this . limits = limits
2226 . map ( ( limit ) => {
2327 const l = { ...limit } ;
@@ -33,23 +37,16 @@ export default class OrgLimits extends LightningElement {
3337 }
3438
3539 async renderedCallback ( ) {
36- try {
37- if ( ! this . isD3Initialized ) {
38- await loadScript ( this , D3 ) ;
39- this . isD3Initialized = true ;
40- }
41- this . drawChart ( ) ;
42- } catch ( error ) {
43- this . error = JSON . stringify ( error ) ;
44- }
40+ this . drawChart ( ) ;
4541 }
4642
4743 drawChart ( ) {
48- if ( ! this . isD3Initialized || ! this . limits ) {
44+ if ( ! this . isD3Initialized ) {
4945 return ;
5046 }
5147
5248 const rootElement = this . template . querySelector ( '.chart' ) ;
49+ rootElement . childNodes . forEach ( ( childNode ) => childNode . remove ( ) ) ;
5350
5451 // Add SVG element
5552 const svg = d3
You can’t perform that action at this time.
0 commit comments