Skip to content

Commit

Permalink
fix(extremas): Multi y-axis support (RomRider#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider authored Feb 18, 2021
1 parent d127b37 commit 5c7d742
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ views:
header:
show: true
title: Weather Forecast
all_series_config:
show:
extremas: time
series:
- entity: weather.home
type: area
Expand Down Expand Up @@ -800,7 +803,7 @@ views:
stroke_width: 0
data_generator: |
return entity.attributes.forecast.map((entry) => {
return [new Date(entry.datetime).getTime(), entry.snow];
return [new Date(entry.datetime).getTime(), entry.temperature];
});
- entity: weather.home
type: column
Expand All @@ -811,5 +814,5 @@ views:
stroke_width: 0
data_generator: |
return entity.attributes.forecast.map((entry) => {
return [new Date(entry.datetime).getTime(), entry.precipitation];
return [new Date(entry.datetime).getTime(), entry.templow];
});
6 changes: 6 additions & 0 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,10 +655,15 @@ class ChartsCard extends LitElement {
) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const points: any = [];
const multiYAxis =
this._config?.apex_config?.yaxis &&
Array.isArray(this._config.apex_config.yaxis) &&
this._config.apex_config.yaxis.length > 1;
points.push({
x: value[0],
y: invert && value[1] ? -value[1] : value[1],
seriesIndex: index,
yAxisIndex: multiYAxis ? index : 0,
marker: {
strokeColor: bgColor,
fillColor: 'var(--card-background-color)',
Expand Down Expand Up @@ -687,6 +692,7 @@ class ChartsCard extends LitElement {
x: value[0],
y: invert && value[1] ? -value[1] : value[1],
seriesIndex: index,
yAxisIndex: multiYAxis ? index : 0,
marker: {
size: 0,
},
Expand Down

0 comments on commit 5c7d742

Please sign in to comment.