File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -29,14 +29,15 @@ import { parseTimeDuration } from "./duration/duration";
29
29
30
30
const componentName = isProduction ? "plotly-graph" : "plotly-graph-dev" ;
31
31
32
- const isDefined = ( y : any ) => y !== null && y !== undefined ;
32
+ const isNumber = ( y : any ) => ! Number . isNaN ( parseFloat ( y ) ) ;
33
33
34
34
function patchLonelyDatapoints ( xs : Datum [ ] , ys : Datum [ ] ) {
35
- /* Ghost traces when data has single non-unavailable states sandwiched between unavailable ones
35
+ /* Ghost traces when data has single numeric value sandwiched between unavailable, unknown, etc ones
36
36
see: https://github.com/dbuezas/lovelace-plotly-graph-card/issues/103
37
+ and: https://github.com/dbuezas/lovelace-plotly-graph-card/issues/124
37
38
*/
38
39
for ( let i = 0 ; i < xs . length ; i ++ ) {
39
- if ( ! isDefined ( ys [ i - 1 ] ) && isDefined ( ys [ i ] ) && ! isDefined ( ys [ i + 1 ] ) ) {
40
+ if ( ! isNumber ( ys [ i - 1 ] ) && isNumber ( ys [ i ] ) && ! isNumber ( ys [ i + 1 ] ) ) {
40
41
ys . splice ( i , 0 , ys [ i ] ) ;
41
42
xs . splice ( i , 0 , xs [ i ] ) ;
42
43
}
@@ -567,9 +568,7 @@ export class PlotlyGraph extends HTMLElement {
567
568
if ( isEntityIdAttrConfig ( trace ) ) name += ` (${ trace . attribute } ) ` ;
568
569
if ( isEntityIdStatisticsConfig ( trace ) ) name += ` (${ trace . statistic } ) ` ;
569
570
const xsIn = history . map ( ( { timestamp } ) => new Date ( timestamp ) ) ;
570
- const ysIn : Datum [ ] = history . map ( ( { value } ) =>
571
- value === "unavailable" ? null : value
572
- ) ;
571
+ const ysIn : Datum [ ] = history . map ( ( { value } ) => value ) ;
573
572
574
573
let xs : Datum [ ] = xsIn ;
575
574
let ys = ysIn ;
You can’t perform that action at this time.
0 commit comments