@@ -118,6 +118,12 @@ export class PlotlyGraph extends HTMLElement {
118118 // The user supplied configuration. Throw an exception and Lovelace will
119119 // render an error card.
120120 async setConfig ( config ) {
121+ if ( typeof config . entities [ 0 ] === "string" ) {
122+ config = {
123+ ...config ,
124+ entities : config . entities . map ( ( name ) => ( { entity : name } ) ) ,
125+ } ;
126+ }
121127 const was = this . config ;
122128 this . config = JSON . parse ( JSON . stringify ( config ) ) ;
123129 const is = this . config ;
@@ -135,7 +141,7 @@ export class PlotlyGraph extends HTMLElement {
135141 const { histories, attributes } = this . cache ;
136142
137143 const units = Array . from (
138- new Set ( Object . values ( attributes ) . map ( ( a ) => a . unit_of_measurement ) )
144+ new Set ( Object . values ( attributes ) . map ( ( a ) => a . unit_of_measurement || "" ) )
139145 ) ;
140146
141147 this . data = entities . map ( ( trace ) => {
@@ -145,7 +151,11 @@ export class PlotlyGraph extends HTMLElement {
145151 const yaxis_idx = units . indexOf ( attribute . unit_of_measurement ) ;
146152 return {
147153 name : trace . name || attribute . friendly_name || entity_id ,
148- hovertemplate : `%{y} ${ attribute . unit_of_measurement || "" } ` ,
154+ hovertemplate : `<b>%{x} ${ attribute . unit_of_measurement } </b><br>%{y}` ,
155+ line : {
156+ width : 1 ,
157+ shape : "hv" ,
158+ } ,
149159 ...trace ,
150160 x : history . map ( ( { last_changed } ) => new Date ( last_changed ) ) ,
151161 y : history . map ( ( { state } ) => state ) ,
@@ -197,7 +207,6 @@ export class PlotlyGraph extends HTMLElement {
197207 modeBarButtonsToRemove : [ "resetScale2d" , "toImage" ] ,
198208 ...config . config ,
199209 } ;
200- console . log ( this . data , layout ) ;
201210 this . isInternalRelayout = true ;
202211 await Plotly . react ( contentEl , data , layout , plotlyConfig ) ;
203212 this . isInternalRelayout = false ;
0 commit comments