Skip to content

Commit

Permalink
fix: extremas was not working with invert: true
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Feb 18, 2021
1 parent d95f7e1 commit 4d06ef6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 10 additions & 3 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,17 @@ views:
show:
extremas: true
- entity: sensor.random_0_1000
name: Sensor 2
type: area
offset: -1d
name: Sensor 1
invert: true
type: area
curve: straight
show:
extremas: true
# - entity: sensor.random_0_1000
# name: Sensor 2
# type: area
# offset: -1d
# invert: true
graph_span: 15min
cache: true
layout: minimal
Expand Down
7 changes: 4 additions & 3 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,8 @@ class ChartsCard extends LitElement {
const txtColor = computeTextColor(bgColor);
if (!min[0] || !max[0]) return [];
return [
this._getPointAnnotationStyle(min, bgColor, txtColor, serie, index),
this._getPointAnnotationStyle(max, bgColor, txtColor, serie, index),
this._getPointAnnotationStyle(min, bgColor, txtColor, serie, index, serie.invert),
this._getPointAnnotationStyle(max, bgColor, txtColor, serie, index, serie.invert),
];
} else {
return [];
Expand All @@ -646,10 +646,11 @@ class ChartsCard extends LitElement {
txtColor: string,
serie: ChartCardSeriesConfig,
index: number,
invert = false,
) {
return {
x: value[0],
y: value[1],
y: invert && value[1] ? -value[1] : value[1],
seriesIndex: index,
marker: {
strokeColor: bgColor,
Expand Down

0 comments on commit 4d06ef6

Please sign in to comment.