@@ -106,6 +106,9 @@ export class MetricStripRenderer {
106106 /** Graphics for expand/collapse toggle button. */
107107 private toggleGraphics : Graphics ;
108108
109+ /** All graphics containers. Ordered back to front. */
110+ private graphics : Graphics [ ] ;
111+
109112 /** Current color palette. */
110113 private colors : MetricStripColors ;
111114
@@ -130,15 +133,7 @@ export class MetricStripRenderer {
130133 this . breachGraphics = new Graphics ( ) ;
131134 this . toggleGraphics = new Graphics ( ) ;
132135
133- this . colors = getMetricStripColors ( ) ;
134- }
135-
136- /**
137- * Get all graphics objects for adding to a container.
138- * Returns in correct render order (back to front).
139- */
140- public getGraphics ( ) : Graphics [ ] {
141- return [
136+ this . graphics = [
142137 this . markerGraphics ,
143138 this . dangerZoneGraphics ,
144139 this . areaFillGraphics ,
@@ -147,6 +142,16 @@ export class MetricStripRenderer {
147142 this . breachGraphics ,
148143 this . toggleGraphics , // Toggle rendered on top
149144 ] ;
145+
146+ this . colors = getMetricStripColors ( ) ;
147+ }
148+
149+ /**
150+ * Get all graphics objects for adding to a container.
151+ * Returns in correct render order (back to front).
152+ */
153+ public getGraphics ( ) : Graphics [ ] {
154+ return this . graphics ;
150155 }
151156
152157 /**
@@ -353,26 +358,18 @@ export class MetricStripRenderer {
353358 * Clear all graphics.
354359 */
355360 public clear ( ) : void {
356- this . markerGraphics . clear ( ) ;
357- this . dangerZoneGraphics . clear ( ) ;
358- this . areaFillGraphics . clear ( ) ;
359- this . lineGraphics . clear ( ) ;
360- this . limitLineGraphics . clear ( ) ;
361- this . breachGraphics . clear ( ) ;
362- this . toggleGraphics . clear ( ) ;
361+ for ( const graphics of this . getGraphics ( ) ) {
362+ graphics . clear ( ) ;
363+ }
363364 }
364365
365366 /**
366367 * Destroy all graphics and cleanup.
367368 */
368369 public destroy ( ) : void {
369- this . markerGraphics . destroy ( ) ;
370- this . dangerZoneGraphics . destroy ( ) ;
371- this . areaFillGraphics . destroy ( ) ;
372- this . lineGraphics . destroy ( ) ;
373- this . limitLineGraphics . destroy ( ) ;
374- this . breachGraphics . destroy ( ) ;
375- this . toggleGraphics . destroy ( ) ;
370+ for ( const graphics of this . getGraphics ( ) ) {
371+ graphics . destroy ( ) ;
372+ }
376373 }
377374
378375 // ============================================================================
0 commit comments