apexcharts-card: Stacked line charts broken in 2.1.2

Checklist

  • I updated the card to the latest version available
  • I cleared the cache of my browser
  • I verified that I’m really running the lastest version in my browser console
  • I checked if there is another issue opened with the same problem

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):

  • Browser [e.g. chrome, safari] Any
  • Version [e.g. 22] ANy

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6] Any
  • OS: [e.g. iOS8.1] Any
  • Browser [e.g. stock browser, safari] Any
  • Version [e.g. 22] Any

Additional context

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 9
  • Comments: 28 (1 by maintainers)

Most upvoted comments

Same for type: column chart:

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

Same for type: column chart:

Same here!

I found that a workaround that works for me with yaxis present is to add stack_groups to all series that should be stacked. (With no yaxis, no stack_groups needed either.) https://github.com/RomRider/apexcharts-card/issues/827

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.

I do have 2.0.4 now:

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

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.

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

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

apex_config:
  chart:
    stackOnlyBar: false