RomRider / apexcharts-card

📈 A Lovelace card to display advanced graphs and charts based on ApexChartsJS for Home Assistant
MIT License
1.16k stars 78 forks source link

"min:" and "max:" in apex_config are not working as expected? #642

Closed redlefloh closed 9 months ago

redlefloh commented 9 months ago

Checklist

Describe the bug "min:" and "max:" in apex_config are not working as expected. If I specify a "min:" or a "max:", I shortly see the correct chart representation drawing while the chart is loading, but then it falls back to the settings that one would expect in "auto" mode?

Version of the card Version: Running 2.0.4 via HACS

To Reproduce This is the configuration I used:

type: custom:apexcharts-card
header:
  show: true
  title: Tibber Electricity Price / SOC
  show_states: true
  colorize_states: true
yaxis:
  - id: price
    apex_config:
      min: 0
      max: 0.2
      forceNiceScale: true
      decimalsInFloat: 2
      labels:
        show: true
series:
  - entity: sensor.electricity_price
    name: ‘ ’ 
    stroke_width: 3
    float_precision: 3
    color: cornflowerblue
    yaxis_id: price
    curve: straight

Screenshots The default yaxis max value i=s 0.15, if I enter a value for max ...

apex_config 1

... for example 0.2, you very briefly see the correct yaxis drawing while the chart is loading:

apex_config 2

but then it falls back again to max 0.15.

apex_config 3

Same again when I change max to 0.3, you very briefly see the correct yaxis drawing at 0.3 while loading:

apex_config 4

and then it falls back again to max 0.15.

apex_config 5

Expected behavior The yaxis always shows what I specify in "min:" and "max:"

Desktop (please complete the following information):

Note: in 2020 there was a bug in apexcharts.js that caused a similar behaviour: https://github.com/apexcharts/apexcharts.js/issues/1578. Not sure if this here is somehow related? Can anyone replicate this behaviour?

RomRider commented 9 months ago

min and max should be defined outside of apex_config. (directly in y_axis)

redlefloh commented 9 months ago

Thanks @RomRider, that was it, the short correct drawing threw me off so it looked like it should work but didn't. Thanks a bunch!