RomRider / apexcharts-card

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

Line and area chart not working since the version 2.1.0 #799

Open pes001 opened 3 weeks ago

pes001 commented 3 weeks ago

Checklist

Describe the bug Since updating to the verison 2.1.0 line and area chart doesn't work in my dashboard. Column type works as before.

Version of the card Version: 2.1.2

To Reproduce This is the configuration I used: Configuration that doesn't work:

type: custom:apexcharts-card
span:
  start: day
series:
  - entity: sensor.current_spot_electricity_price
    type: line
    color: lightblue
    show:
      legend_value: false
    data_generator: |
      return Object.entries(entity.attributes).map(([date, value], index) => {
        return [new Date(date).getTime(), (value) ];
      });

Configuration that works:

type: custom:apexcharts-card
span:
  start: day
series:
  - entity: sensor.current_spot_electricity_price
    type: column
    color: lightblue
    show:
      legend_value: false
    data_generator: |
      return Object.entries(entity.attributes).map(([date, value], index) => {
        return [new Date(date).getTime(), (value) ];
      });

Screenshots image

image

Expected behavior Graphs of line type should appear as the column type ones

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Everything was correct in version 2.0.4. It appears in both instances of Home assistant I have.

pihiandreas commented 1 week ago

I can confirm this bug, last functioning version is 2.0.4. (over one year old). I found some apexcharts-card: TypeError: this.series is null and Uncaught (in promise) TypeError: this.w.globals.dom.Paper is undefined in the console log. One theory could be that HomeAssistant has changed the availability of sensor-data (on load) and 2.1.x versions of apexcharts-card don't handle these situations. Apexcharts-card probably needs some mechanism to retry reading sensor-data without throwing an exception.