@@ -120,29 +120,31 @@ export class CanvasGaugeCard extends LitElement {
120120
121121 // Here we need to refresh the actual gauge after it has rendered
122122 protected updated ( _ ) {
123- var gauge ;
124- if ( this . _config ?. gauge . type == "linear-gauge" ) {
125- gauge = new Gauge . LinearGauge ( {
126- renderTo : this . _canvasElement ,
127- height : this . _config . gauge [ "height" ] ,
128- width : this . _config . gauge [ "width" ] ,
129- value : 0 ,
130- } ) ;
131- } else if ( this . _config ?. gauge . type == "radial-gauge" ) {
132- gauge = new Gauge . RadialGauge ( {
133- renderTo : this . _canvasElement ,
134- height : this . _config . gauge [ "height" ] ,
135- width : this . _config . gauge [ "width" ] ,
136- value : 0 ,
137- } ) ;
138- }
123+ if ( this . _gauge == null ) {
124+ var gauge ;
125+ if ( this . _config ?. gauge . type == "linear-gauge" ) {
126+ gauge = new Gauge . LinearGauge ( {
127+ renderTo : this . _canvasElement ,
128+ height : this . _config . gauge [ "height" ] ,
129+ width : this . _config . gauge [ "width" ] ,
130+ value : 0 ,
131+ } ) ;
132+ } else if ( this . _config ?. gauge . type == "radial-gauge" ) {
133+ gauge = new Gauge . RadialGauge ( {
134+ renderTo : this . _canvasElement ,
135+ height : this . _config . gauge [ "height" ] ,
136+ width : this . _config . gauge [ "width" ] ,
137+ value : 0 ,
138+ } ) ;
139+ }
139140
140- for ( const key in this . _config ?. gauge ) {
141- if ( this . _config ?. gauge ?. hasOwnProperty ( key ) ) {
142- gauge . options [ key ] = this . _config . gauge [ key ] ;
141+ for ( const key in this . _config ?. gauge ) {
142+ if ( this . _config ?. gauge ?. hasOwnProperty ( key ) ) {
143+ gauge . options [ key ] = this . _config . gauge [ key ] ;
144+ }
143145 }
146+ this . _gauge = gauge ;
144147 }
145- this . _gauge = gauge ;
146148 var entityId = this . _config ?. entity ;
147149 this . _state = this . hass ?. states [ entityId ! ] . state ;
148150 this . _gauge [ "value" ] = this . _state ;
0 commit comments