Skip to content

Commit

Permalink
fix(yaxis): Fixed + unfixed bounds on the same yaxis is now working
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed May 25, 2021
1 parent 76e5ba6 commit f7e4668
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .devcontainer/ui-lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit f7e4668

Please sign in to comment.