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";
2929
3030const componentName = isProduction ? "plotly-graph" : "plotly-graph-dev" ;
3131
32- const isDefined = ( y : any ) => y !== null && y !== undefined ;
32+ const isNumber = ( y : any ) => ! Number . isNaN ( parseFloat ( y ) ) ;
3333
3434function 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
3636 see: https://github.com/dbuezas/lovelace-plotly-graph-card/issues/103
37+ and: https://github.com/dbuezas/lovelace-plotly-graph-card/issues/124
3738 */
3839 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 ] ) ) {
4041 ys . splice ( i , 0 , ys [ i ] ) ;
4142 xs . splice ( i , 0 , xs [ i ] ) ;
4243 }
@@ -567,9 +568,7 @@ export class PlotlyGraph extends HTMLElement {
567568 if ( isEntityIdAttrConfig ( trace ) ) name += ` (${ trace . attribute } ) ` ;
568569 if ( isEntityIdStatisticsConfig ( trace ) ) name += ` (${ trace . statistic } ) ` ;
569570 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 ) ;
573572
574573 let xs : Datum [ ] = xsIn ;
575574 let ys = ysIn ;
You can’t perform that action at this time.
0 commit comments