From f7e46688fc3b891981854d1632c513fa9dac4773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Wiedemann?= Date: Tue, 25 May 2021 13:16:16 +0000 Subject: [PATCH] fix(yaxis): Fixed + unfixed bounds on the same yaxis is now working --- .devcontainer/ui-lovelace.yaml | 16 ++++++++++++++++ src/apexcharts-card.ts | 5 +++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.devcontainer/ui-lovelace.yaml b/.devcontainer/ui-lovelace.yaml index 2b11092..b8c014a 100644 --- a/.devcontainer/ui-lovelace.yaml +++ b/.devcontainer/ui-lovelace.yaml @@ -1016,3 +1016,19 @@ views: show: true apex_config: tickAmount: 4 + - type: custom:apexcharts-card + header: + show: true + title: Soft Bounds + fixed bound + graph_span: 20min + all_series_config: + stroke_width: 2 + series: + - entity: sensor.random0_100 + yaxis_id: first + yaxis: + - id: first + min: 0 + max: ~80 + apex_config: + tickAmount: 4 diff --git a/src/apexcharts-card.ts b/src/apexcharts-card.ts index ba0d12b..d8a338b 100644 --- a/src/apexcharts-card.ts +++ b/src/apexcharts-card.ts @@ -480,6 +480,7 @@ class ChartsCard extends LitElement { if (config.yaxis![idx].apex_config) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion yAxisDup = mergeDeep(JSON.parse(JSON.stringify(config.yaxis![idx])), config.yaxis![idx].apex_config); + delete yAxisDup.apex_config; } if (typeof yAxisDup.min !== 'number') delete yAxisDup.min; if (typeof yAxisDup.max !== 'number') delete yAxisDup.max; @@ -991,7 +992,7 @@ class ChartsCard extends LitElement { } }); yaxis.series_id?.forEach((id) => { - if (min !== null) { + if (min !== null && yaxis.min_type !== minmax_type.FIXED) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this._config!.apex_config!.yaxis![id].min = this._getMinMaxBasedOnType( true, @@ -1001,7 +1002,7 @@ class ChartsCard extends LitElement { yaxis.min_type!, ); } - if (max !== null) { + if (max !== null && yaxis.max_type !== minmax_type.FIXED) { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion this._config!.apex_config!.yaxis![id].max = this._getMinMaxBasedOnType( false,