Skip to content

Commit

Permalink
fix(start_with_last): start_with_last would sometimes throw
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Mar 1, 2021
1 parent 7abc750 commit f5aa2e3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,24 @@ views:
func: first
duration: 10min
start_with_last: true
- type: custom:apexcharts-card
graph_span: 1 week
span:
end: week
all_series_config:
type: column
extend_to_end: false
group_by:
fill: 'null'
series:
- entity: sensor.random0_100
name: last
group_by:
func: last
duration: 10min
- entity: sensor.random0_100
name: first
group_by:
func: first
duration: 10min
start_with_last: true
2 changes: 1 addition & 1 deletion src/graphEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ export default class GraphEntry {
}
if (this._config.group_by.start_with_last) {
if (index > 0) {
if (bucket.data[0][0] !== bucket.timestamp) {
if (bucket.data.length === 0 || bucket.data[0][0] !== bucket.timestamp) {
const prevBucketData = buckets[index - 1].data;
bucket.data.unshift([bucket.timestamp, prevBucketData[prevBucketData.length - 1][1]]);
}
Expand Down

0 comments on commit f5aa2e3

Please sign in to comment.