File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,18 @@ import { parseTimeDuration } from "./duration/duration";
3030
3131const componentName = isProduction ? "plotly-graph" : "plotly-graph-dev" ;
3232
33+ function patchLonelyDatapoints ( xs : Datum [ ] , ys : Datum [ ] ) {
34+ /* Ghost traces when data has single non-unavailable states sandwiched between unavailable ones
35+ see: https://github.com/dbuezas/lovelace-plotly-graph-card/issues/103
36+ */
37+ for ( let i = 1 ; i < xs . length - 1 ; i ++ ) {
38+ if ( ys [ i - 1 ] === null && ys [ i ] !== null && ys [ i + 1 ] === null ) {
39+ ys . splice ( i , 0 , ys [ i ] ) ;
40+ xs . splice ( i , 0 , xs [ i ] ) ;
41+ }
42+ }
43+ }
44+
3345console . info (
3446 `%c ${ componentName . toUpperCase ( ) } %c ${ version } ${ process . env . NODE_ENV } ` ,
3547 "color: orange; font-weight: bold; background: black" ,
@@ -429,6 +441,7 @@ export class PlotlyGraph extends HTMLElement {
429441 console . error ( e ) ;
430442 }
431443 }
444+ patchLonelyDatapoints ( xs , ys ) ;
432445 const customdatum = { unit_of_measurement : unit , name, attributes } ;
433446 const customdata = xs . map ( ( ) => customdatum ) ;
434447 const mergedTrace = merge (
You can’t perform that action at this time.
0 commit comments