diff --git a/.devcontainer/ui-lovelace.yaml b/.devcontainer/ui-lovelace.yaml index 9c73b91..9cf4b7b 100644 --- a/.devcontainer/ui-lovelace.yaml +++ b/.devcontainer/ui-lovelace.yaml @@ -427,10 +427,8 @@ views: header: show: true title: radialBar - chart_type: radialBar - header: - show: true show_states: true + chart_type: radialBar series: - entity: sensor.random0_100 - entity: sensor.random_0_1000 diff --git a/src/graphEntry.ts b/src/graphEntry.ts index f0d6f59..51bbcf6 100644 --- a/src/graphEntry.ts +++ b/src/graphEntry.ts @@ -382,9 +382,9 @@ export default class GraphEntry { const now = new Date().getTime(); buckets.forEach((bucket, index) => { if (bucket.data.length === 0) { - if (this._config.group_by.fill === 'last' && bucket.timestamp <= now) { + if (this._config.group_by.fill === 'last' && (bucket.timestamp <= now || this._config.data_generator)) { bucket.data[0] = [bucket.timestamp, lastNonNullBucketValue]; - } else if (this._config.group_by.fill === 'zero' && bucket.timestamp <= now) { + } else if (this._config.group_by.fill === 'zero' && (bucket.timestamp <= now || this._config.data_generator)) { bucket.data[0] = [bucket.timestamp, 0]; } else if (this._config.group_by.fill === 'null') { bucket.data[0] = [bucket.timestamp, null]; @@ -410,6 +410,7 @@ export default class GraphEntry { } }); buckets.pop(); + // Remove nulls at the end while ( buckets.length > 0 && (buckets[buckets.length - 1].data.length === 0 || @@ -417,6 +418,13 @@ export default class GraphEntry { ) { buckets.pop(); } + // Remove nulls at the beginning + while ( + buckets.length > 0 && + (buckets[0].data.length === 0 || (buckets[0].data.length === 1 && buckets[0].data[0][1] === null)) + ) { + buckets.shift(); + } return buckets; }