RomRider / apexcharts-card

πŸ“ˆ A Lovelace card to display advanced graphs and charts based on ApexChartsJS for Home Assistant
MIT License
1.14k stars 78 forks source link

Stacked line charts broken in 2.1.2 #730

Open marcelhoogantink opened 1 month ago

marcelhoogantink commented 1 month ago

Checklist

Describe the bug option stacked: true does not work anymore in 2.1.2, it's OK in 2.0.4

Version of the card Version: 2.1.2

To Reproduce This is the configuration I used:

type: custom:apexcharts-card
experimental:
  color_threshold: true
graph_span: 10d
show:
  last_updated: true
stacked: true
header:
  standard_format: false
  show: true
  show_states: true
  colorize_states: true
  title: test apex graph
all_series_config:
  stroke_width: 1
  type: area
  curve: stepline
  opacity: 1
  statistics:
    type: mean
series:
  - entity: sensor.hass_db_states
  - entity: sensor.hass_db_attributes
  - entity: sensor.hass_db_events
  - entity: sensor.hass_db_statistics
  - entity: sensor.hass_db_size
    type: line
    stroke_width: 2
yaxis:
  - min: 0
    max: 1500

Screenshots Version 2.0.4 is OK: ApexChart_2_0_4_stacked_line_graph

Version 2.1.2 is wrong: ApexChart_2_1_2_stacked_line_graph

Expected behavior Graph should be stacked also in 2.1.2

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context

paulius2k commented 1 month ago

Same for type: column chart:

jarube commented 1 month ago

Same for type: column chart:

Same here!

RomRider commented 1 month ago

Until I fix it in the code, you can fix it with:

apex_config:
  chart:
    stackOnlyBar: false
marcelhoogantink commented 1 month ago

Until I fix it in the code, you can fix it with:

apex_config:
  chart:
    stackOnlyBar: false

Thanks for your reply, I tried it, but it did not work:

image

rolled back to 2.0.4.

jarube commented 1 month ago

Until I fix it in the code, you can fix it with:

apex_config:
  chart:
    stackOnlyBar: false

sorry, this doesn't work me either

del13r commented 1 month ago

Same issue here

2.0.4 image

2.1.0 and 2.1.2 image

Code

card:
  type: custom:apexcharts-card
  stacked: true
  graph_span: 1d
  span:
    offset: ${offset}
  header:
    show: false
    title: Total Power
  series:
    - entity: sensor.power_production
      type: column
      name: Produced
      color: '#01B4DE'
      group_by:
        func: avg
        duration: 5min
    - entity: sensor.power_consumption
      transform: return x *-1 ;
      type: column
      name: Consumed
      color: '#F37320'
      group_by:
        func: avg
        duration: 5min
    - entity: sensor.power_net
      type: column
      name: Imported(+)/Exported(-)
      color: '#545456'
      group_by:
        func: avg
        duration: 5min
  yaxis:
    - min: -7000
      max: 7000
      decimals: 0
paulius2k commented 1 month ago

The strange thing for me is that I can't even make it work again by rolling back to v2.0.4.

wejto commented 1 month ago

As I replied in https://github.com/RomRider/apexcharts-card/issues/728#issuecomment-2222610262, it works in a newer version when you delete the y-axis block in yaml but this workaround is not possible to use every time. At least rolling back to 2.0.4 worked for me well.

del13r commented 1 month ago

The strange thing for me is that I can't even make it work again by rolling back to v2.0.4.

I found that I was being impatient with the download button and had to wait a few seconds before pressing the download button. You can confirm what version you have by doing this in the terminal

cat /homeassistant/www/community/apexcharts-card/apexcharts-card.js | grep -o v2.0.4 v2.0.4

paulius2k commented 1 month ago

I do have 2.0.4 now:

➜  ~ cat /homeassistant/www/community/apexcharts-card/apexcharts-card.js | grep -o v2.0.4
v2.0.4
del13r commented 1 month ago

I found that removing the yaxis: block made the stacking work again with the newer versions 2.1.0 onwards.

Originally posted by @wejto in https://github.com/RomRider/apexcharts-card/issues/728#issuecomment-2222610262

Obviously the yaxis block is desired by me for setting the graph scale and how many decimal points i prefer to display, so removing the yaxis block is a regrettable solution for me.

RichardRamshaw commented 1 month ago

Until I fix it in the code, you can fix it with:

apex_config:
  chart:
    stackOnlyBar: false

This did work for me, added near the top, not sure if it's not working for others as it was added at the bottom?

wejto commented 1 month ago

Until I fix it in the code, you can fix it with:

apex_config:
  chart:
    stackOnlyBar: false

This did work for me, added near the top, not sure if it's not working for others as it was added at the bottom?

Tried this on multiple different rows with no difference unfortunately.

alexeiw123 commented 1 month ago

Ah - I spent ages figuring out the brush feature and was thinking "gee, I've really nailed this view!" - then I saw that my stacked area graph had broken. First up, I thought it must have been some change I'd made when implementing brush.

image

So after finding this issue, I see that there's a bug using stacked. So this is where it gets interesting for me. With the same code, if I roll back to v2.0.4, this is what I get:

image

This actually does seem related to using brush because if I make this change:

  experimental:
    brush: false

Then my stacked graph shows correctly - just no interactivity. (I've also changed the span just to help show detail int he screenshot)

image

So i don't know if these bugs are related. Does brush clash with [stacked](stacked: true)? Will fixing this stacked issue also solve the display issues when brush is enabled?

man010 commented 1 month ago

Removing the yaxis block works as a workaround… but this is not a viable solution in the end

Cellivar commented 1 week ago

I was able to work around this by moving the y-axis config into the apex_charts section..

image

Click here to expand the config ```yaml type: custom:apexcharts-card apex_config: yaxis: - show: true decimalsInFloat: false opposite: true min: 0 stepSize: 100 seriesName: '🏠' - seriesName: '🏠' show: false chart: stackOnlyBar: false height: 600px type: area legend: width: 100% inverseOrder: true position: bottom itemMargin: horizontal: 15 vertical: 5 markers: radius: 1 height: 14 width: 6 offsetY: 4 stacked: true cache: false graph_span: 30m update_interval: 30s header: floating: true show: true show_states: true all_series_config: stroke_width: 1 opacity: 1 type: area float_precision: 0 show: in_header: false fill_raw: last group_by: func: max duration: 1m series: - entity: sensor.eagle_200_meter_power_demand type: line stroke_width: 2 color: '#A55' name: '🏠' yaxis_id: '1' show: legend_value: false in_header: raw extremas: true - entity: sensor.all_standby_power name: 'πŸ’€' - entity: sensor.nelson_energy_power name: 🐁⚑ - entity: sensor.fraser_energy_power name: 🦊⚑ - entity: sensor.rhine_energy_power name: 🌿🐱⚑ - entity: sensor.thelon_energy_power name: πŸ›œ - entity: sensor.shelly_rubicon_power name: πŸ“Ί - entity: sensor.shelly_orinoco_power name: πŸ› οΈ - entity: sensor.all_lights_power name: πŸ’‘ - entity: sensor.yangtzeekiang_energy_power name: πŸ”β„ - entity: sensor.colorado_energy_power name: πŸ’¦πŸ‘• - entity: sensor.riogrande_energy_power name: πŸ’¦πŸ½οΈ - entity: sensor.evse_dryer_total_power name: πŸš“ - entity: sensor.fan_power name: βœ‡β„ ```