ApexCharts card - A highly customizable graph card

What am I doing wrong? Y axis on the right

sorry I didnt receive a notification.

not sure what to say, if I select, it immediately re-calculates and updates the graph. can only help if you post your config…

What is the easiest way to use the value of a sensor as the name of a series? The sensor may be frequently updated.

Hi! :slight_smile: Is update_interval still broken? It seems so…

can you average 2 different sensors together into 1 line?

It isn’t for me, I can’t reproduce that issue. Please chime in here with a config

Hello everyone,

is there a way to make the y-axis values automatically adjust the number of decimal places depending on the range/max value?

E.g.

- >=10: 0 decimal places
- <10: 1 decimal place
- <1: 2 decimal places
yaxis:
  - decimals: >-
          {% if maximum value >= 10 %}
             0
          {% else if maximum value < 10 && maximum value >= 1 %}
             1
          {% else if maximum value < 1 %}
             2
          {% endif %}

Sorry, I am really bad at JavaScript, so maybe this has multiple errors. But for sure I would need to know how to find the “maximum value”. “Maximum value” of course being the highest value displayed in the current date range.

Right now I have a graph showing no decimal places because all values in the selected date range are below 1. So I only see lots of “1” on the y-axis. So no information there.
If I change the date range, then values larger than 1000 watts appear and it makes sense to not have decimal places.

P.S.: @fokcuk , your problem looks related. Wrong amount of decimals defined. Maybe you can define manually, or use this approach once the people smarter than me have helped me fix my approach. :slight_smile:

As a beginner to HA I had a bit of trouble installing this, so I’ve written up a blog post on how to install ApexCharts Card to Home Assistant Core to make it easier for others.

I’ll put the key parts in here, the blog post has screenshots as well.

In Linux

sudo su
cd /home/homeassistant/.homeassistant
mkdir www
cd www
wget https://github.com/RomRider/apexcharts-card/releases/download/v1.10.0/apexcharts-card.js
cd ..
chown -R homeassistant:homeassistant www

In the UI ensure Advanced Mode is enabled. Click on your user profile (the little icon bottom left of the screen) and enable it.

Next click Configuration → Dashboards → Resources. Hit the + (plus) button, enter “/local/apexcharts-card.js” (without the speech marks), and click “JavaScript Module”.

In your Linux command prompt restart HA

sudo systemctl restart home-assistant@homeassistant

ApexCharts is now installed. To use it go into a dashboard and choose edit from the top right. Choose “Add Card”. Scroll to the bottom of the available cards and find “Custom: ApexCharts Card”. From there follow the user guide.

If I’ve done anything against forum rules someone please let me know - I did look around for rules for a minute but didn’t find any.

Hi @RomRider
Just noticed in the latest dev builds that long term statistics are supported (that’s how I understood it). Is that correct?

Tried to set it up to display my power consumption for the last 20 days but still just display the last 10 days. I used the same sensor as in my Energy dashboard.

span:
  end: day
series:
  - entity: sensor.accumulated_consumption_my_street
    yaxis_id: kwh
    name: Förbrukning per dag
    type: column
    color: fc7703
    float_precision: 1
    group_by:
      func: last
      duration: 1d
    show:
      datalabels: true

Please check the dev documentation of the card, there’s an option to enable statistics instead of history.
You don’t need to use group_by with statistics also, it’s done for you by Homeassistant.

1 Like

Nice, missed that part.

Config looks like this now:

series:
  - entity: sensor.last_meter_consumption_my_streety
    yaxis_id: kwh
    name: Förbrukning idag
    type: column
    color: fc7703
    float_precision: 1
    show:
      datalabels: true
    statistics:
      type: mean
      period: day
      align: end

But gives this error, any idea why? Looks like statistics isn’t recognized? I’m on version v2.0.0-dev.7.

It tells you the currently running version in the error and it’s not the lastest version but an old cached version.

2 Likes

Now I’m running the new version (was extremey hard to refresh cache…) but was hoping to get one bar per day with the energy consumed for that day, now it is an increasing graph. Can that be done? I guess that is what group_by: day did before?

series:
  - entity: sensor.last_meter_consumption_my_street
    name: Förbrukning per dag
    type: column
    color: fc7703
    statistics:
      type: sum
      period: day
      align: end

Is it possible to achieve something along the lines of the following in a radialBar chart:

Household energy is the sensor reading the total energy use of the house, so I am wanting to use it as the denominator in the % calculation for entities in the chart

series:
  - entity: sensor.mvhr_daily_energy_kwh_utility
    min: 0
    max: sensor.household_energy_usage

:tada: :tada: (Long awaited) NEW RELEASE :tada: :tada:

2.0.0 (2022-04-23)

:warning: BREAKING CHANGES

  • extend_to_end has been removed and replaced by extend_to with support for now, end and false

Features

  • extend_to replaces extend_to_end with new options (4bb1dd2), closes #318
  • add state type to long term statistics (#329) (3fad4f0)
  • Apply a time_delta to all the datapoints of your serie (435e381), closes #277
  • display only the min or max extrema (3db982b), closes #319
  • follow Home Assistant number format (9204de2), closes #307
  • support actions on the title with title_actions (a9f406e), closes #323
  • Support for HA long-term statistics (#208) (29aaa7c), closes #308

Bug Fixes

  • last_updated date format was not following the configuration (3dd4904)
  • update_interval was broken (31d2fb7)
  • annotations with time were not following the time format configuration (5d08853)
  • another caching issue with statistics (b93ee75)
  • caching issue for statistics (8daff2f)
  • hidden by default would not work without a name (9c75ce8), closes #280
  • last caching issue with statistics (2e528f7)
  • median function fails if it receives an empty table (#316) (12f8d2e)
  • Support for fire-dom-event with browser-mod (3dc9625), closes #196
  • Update apexcharts.js to the the latest version (dd0bf6f)
5 Likes

Don’t use sum but maybe max instead?

Been trying a few mixes of configurations but max instead of sum gives me an empty graph. But it sounds to you that what I want should be doable so then I know at least that it should work :slight_smile:

Long term statistics is the last piece missing in my dashboards so really happing you spent time implementing it.

have a chart:

type: custom:apexcharts-card
header:
  show: true
  title: Nordpool spot-hinnat + alv + siirto + vero
  show_states: false
  colorize_states: true
graph_span: 2d
span:
  start: day
now:
  show: true
  label: Now
  color: '#ff0000'
series:
  - entity: sensor.nordpool_kwh_fi_eur_4_095_024
    name: Tänään
    data_generator: |
      return entity.attributes.raw_today.map((entry) => {
        return [new Date(entry.start), entry.value];
      });
    type: column
    show:
      legend_value: false
      in_header: false
    extend_to_end: false
  - entity: sensor.nordpool_kwh_fi_eur_4_095_024
    name: Huomenna
    data_generator: |
      return entity.attributes.raw_tomorrow.map((entry) => {
        return [new Date(entry.start), entry.value];
      });
    type: column
    show:
      legend_value: false
      in_header: false

…which is not working anymore with a new release 2.0, which is a pity, because I just got it working. It gives me:

/// apexcharts-card version 2.0.0 /// value.series[0] is not a ChartCardSeriesExternalConfig value.series[0].extend_to_end is extraneous value.series[0].extend_to_end is extraneous
  1. What/how to change to get it working again?
  2. OR, how to revert back to older version?

EDIT: NEVER MIND!!
I did not realize, it had this deprecated extend_to_end: line, so I removed it. I think it should be OK now(?)

Is it possible to make a dynamic Y axis? If I don’t specify the “min”, the resolution is too high. I wanted to have a “min” of currentvalue-200

1 Like