RomRider / apexcharts-card

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

forceNiceScale not working since V2.1.0 #738

Open DevoliaEsp opened 4 months ago

DevoliaEsp commented 4 months ago

Checklist

Describe the bug Since apex V2.1.0 and later, it seems that "forceNiceScale", an yaxis motion listed in apex_config, simply doesn't work anymore

Version of the card Version: 2.1.2

To Reproduce This is the configuration I used: `type: custom:apexcharts-card update_interval: 15min apex_config: xaxis: axisBorder: show: false yaxis:

Screenshots image image Before (V2.0.4) and after (2.1.0/2.1.2)

Desktop (please complete the following information):

mikeynp commented 4 months ago

+1 same for me. Reverted back to 2.0.4 and everything works ok again. For me, forceNiceScale: true seems to not work when I have multiple series (assigned to different y-axes), e.g. (truncated example):

series:
  - entity: sensor.thing
    name: Thing
    yaxis_id: first
  - entity: sensor.thing2
    name: Thing2
    yaxis_id: second
yaxis:
  - id: first
    apex_config:
      forceNiceScale: true
  - id: second
    opposite: true
    apex_config:
      forceNiceScale: true
ausfas commented 4 months ago

Same here , it's fine in 2.04

rotgier commented 3 months ago

Same for he. I had to revert to 2.0.4 to have forceNiceScale work as expected. I also have multiple series (assigned to different y-axes).

My config (works on 2.0.4 and stops working since 2.1.0).

type: custom:apexcharts-card
graph_span: 2h
header:
  show: true
  title: Power RAW last 1h
  show_states: true
  colorize_states: true
apex_config:
  chart:
    height: 250px
  legend:
    show: false
  yaxis:
    forceNiceScale: true
yaxis:
  - id: power
    apex_config:
      forceNiceScale: true
  - id: percent
    opposite: true
    decimals: 0
    min: 0
    max: 100
    apex_config:
      tickAmount: 5    
series:
  - entity: sensor.house_consumption
    curve: smooth
    type: line
    stroke_width: 1
    yaxis_id: power
    extend_to: false
  - entity: sensor.pv_power
    curve: smooth
    type: line
    stroke_width: 1
    yaxis_id: power
    extend_to: false
  - entity: sensor.meter_active_power_total
    curve: smooth
    type: line
    stroke_width: 1
    yaxis_id: power
    extend_to: false
  - entity: sensor.battery_power
    curve: smooth
    type: line
    stroke_width: 1
    yaxis_id: power
    extend_to: false
  - entity: sensor.energy_monitoring_smartplug_moc
    curve: stepline
    type: line
    stroke_width: 1
    yaxis_id: power
    extend_to: false
  - entity: sensor.battery_state_of_charge
    curve: stepline
    type: line
    stroke_width: 1
    yaxis_id: percent
    extend_to: false

I've looked into the source code changes and the only thing that could have impact was update to "apexcharts": "^3.49.2" 🤔

I've quickly checked and this also does not work:

type: custom:apexcharts-card
graph_span: 2h
yaxis:
  - id: power
    apex_config:
      forceNiceScale: true 
series:
  - entity: sensor.house_consumption
    yaxis_id: power

image

On 2.0.4 it works just fine:

image

ausfas commented 3 months ago

Still no update on this big 😔

Triple-S commented 2 months ago

I'm afraid this is not a bug but a feature in the underlying apexcharts library, so it probably cannot be fixed in this repository. Here it is stated that this behaviour is probably intended although I don't understand the reason for it: https://github.com/apexcharts/apexcharts.js/issues/4283#issuecomment-1971274210 If you still want this to be fixed you probably need to open an issue here: https://github.com/apexcharts/apexcharts.js/issues

ausfas commented 1 month ago

not sure why its as intended where 2.04 the logic works but now it doesn't... sorry I disagree.

Triple-S commented 1 month ago

@ausfas It is not a bug because the logic behind forceNiceScale was changed intentionally in the apexcharts library. Whether thats good or bad is another question, but as I stated this repository is the wrong place to discuss this, because this repository will never be able to solve the problem. That is because this repository serves as a bridge between Home Assistant and Apexcharts, so anything related directly to Apexcharts, like this problem, has nothing to do with this repository.