Skip to content

Commit

Permalink
fix(series): extremas would be wrong in some cases with `in_header: f…
Browse files Browse the repository at this point in the history
…alse`

Fixes #725
  • Loading branch information
RomRider committed Jul 10, 2024
1 parent eb84693 commit 019b4ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 9 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,15 @@ views:
}
title: Synology NAS
series:
- entity: sensor.random_0_1000
name: Test Index
float_precision: 0
show:
extremas: min
in_chart: false
group_by:
duration: 2min
func: avg
- entity: sensor.random_0_1000
name: Min
float_precision: 0
Expand Down
14 changes: 8 additions & 6 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1024,11 +1024,13 @@ class ChartsCard extends LitElement {
points: this._config?.series_in_graph.flatMap((serie, index) => {
if (serie.show.extremas) {
const { min, max } = this._graphs?.[serie.index]?.minMaxWithTimestamp(
this._seriesOffset[index]
? new Date(start.getTime() + this._seriesOffset[index]).getTime()
this._seriesOffset[serie.index]
? new Date(start.getTime() + this._seriesOffset[serie.index]).getTime()
: start.getTime(),
this._seriesOffset[index] ? new Date(end.getTime() + this._seriesOffset[index]).getTime() : end.getTime(),
this._serverTimeOffset - (this._seriesTimeDelta[index] || 0),
this._seriesOffset[serie.index]
? new Date(end.getTime() + this._seriesOffset[serie.index]).getTime()
: end.getTime(),
this._serverTimeOffset - (this._seriesTimeDelta[serie.index] || 0),
) || {
min: [0, null],
max: [0, null],
Expand All @@ -1042,7 +1044,7 @@ class ChartsCard extends LitElement {
extremas.push(
...this._getPointAnnotationStyle(
min,
this._seriesOffset[index],
this._seriesOffset[serie.index],
bgColor,
txtColor,
serie,
Expand All @@ -1058,7 +1060,7 @@ class ChartsCard extends LitElement {
extremas.push(
...this._getPointAnnotationStyle(
max,
this._seriesOffset[index],
this._seriesOffset[serie.index],
bgColor,
txtColor,
serie,
Expand Down

0 comments on commit 019b4ee

Please sign in to comment.