ApexCharts card - A highly customizable graph card

Hey all,

Just starting to use HA and have it running on its own OS on a raspberry pi.
I want to install apexcharts, I cannot understand how to add the resources line either to lovelace (not familiar yet either what lovelace is and I can’t find any reference in the GUI, maybe it was incorporated at a certain release and no longer visible) So I wanted to try the steps via the gui

Blockquote>
Else, if you prefer the graphical editor, use the menu to add the resource:

  1. Make sure, advanced mode is enabled in your user profile (click on your user name to get there)
  2. Navigate to Configuration → Lovelace Dashboards → Resources Tab. Hit orange (+) icon
  3. Enter URL /local/apexcharts-card.js and select type “JavaScript Module”.
  4. Restart Home Assistant.

Problem here is step 2: I dont have a “configuration” in my HA just a section called “Settings” There is no lovelace dashboards in their though hence I dont see resources either and cannot complete

Thanks for helping a noob out here and to also include me in being able to use these cool graphs

Thanks :blush:

there are so many options.
Is there maybe an also an Option to hide the Legend completely?

yaxis:
  - id: diesel
    decimals: 2
apex_config:
  legend:
    show: false

Something seemed to have gone wrong during the installation from HACS, however a reinstall fixed it.

Were it not though that I couldnt complete the instructions in the installation description, so not sure if this is due to the HA version or maybe they need an update?

I don’t understand really. Which notifications? Where do I see them?

Sorted out my own challenge here…
image

  • the different energy series are using sensors which return null when their value is zero, and apexcharts ignores them for drawing the series when they are null
  • I have automation which sets the active tariff (off-peak, shoulder, peak) into an input_helper at the correct times, and I have 1 of 3 conditional cards displaying depending on which tariff is active, so it always shows the current tariff’s draw and ignores the others

(Solar panels are zero because we are in the middle of an upgrade and they are disconnected)

Looking for a little help here with an annoying (and probably easy to fix!) issue that I am having with my charts. I will paste the code below… but the problem is that the Gravity line isn’t showing the correct data and updating (I can look at another chart of that variable and it is updating properly - steadily dropping from 1.045 to current 1.039). There is also no chart line for the battery or the thermTemp… can anyone spot what is wrong with this? I’m trying to get the 2 temp sensors using the same y axis, the fridge and heaters are just boolean step charts for on/off
The naming is correct in the code below (including the batterry typo!).
I suspect a very small change could fix this, but I cant work out what!
image


type: custom:apexcharts-card
header:
  show: true
  title: iSpindel Temperature & Battery
apex_config:
  chart:
    zoom:
      enabled: true
    height: 450
  yaxis:
    - id: tTemp
      min: 5
      max: 25
      opposite: true
      seriesName: tTemp
      decimalsInFloat: 1
      forceNiceScale: true
      name: Temp
      title:
        text: Temp
    - id: Battery
      min: 3.2
      max: 4.3
      opposite: false
      seriesName: Battery
      decimalsInFloat: 2
      name: Battery
      title:
        text: Battery
      forceNiceScale: true
    - id: Gravity
      min: 1.010
      max: 1.050
      opposite: false
      seriesName: Gravity
      decimalsInFloat: 3
      forceNiceScale: true
      name: Gravity
      title:
        text: Gravity
    - show: false
  stroke:
    width: 1
series:
  - entity: sensor.ispindle_temp
    name: iTemp
    group_by:
      func: avg
      duration: 8min
    float_precision: 1
    curve: smooth
    yaxis_id: tTemp
  - entity: sensor.brewtherm_temperature
    name: thermTemp
    group_by:
      func: avg
      duration: 8min
    float_precision: 1
    curve: smooth
    yaxis_id: tTemp
  - entity: sensor.ispindle_batterry
    name: Battery
    group_by:
      func: avg
      duration: 12min
    float_precision: 2
    curve: smooth
  - entity: sensor.ispindle_gravity
    name: Gravity
    yaxis_id: Gravity
    group_by:
      func: avg
      duration: 15min
    float_precision: 3
    curve: smooth
  - entity: sensor.brew_fridge_template
    type: area
    curve: stepline
    name: Fridge
  - entity: sensor.brew_heater_template
    type: area
    curve: stepline
    name: Heater
graph_span: 12h```

First, you are using the yaxis within the ‘apex_config:’. This does not support id’s. link

You need to format your yaxis as per the HA ApexCharts documentation. This should correct some of your problems.

Ah, thanks. Think I have now sorted it… removed the id and made sure I have a y-axis section for each series.

try - 'y': 0

OK, I am struggling with what I should use to even attempt to display this. As I have some experience with Apex I was thinking maybe, but I am not sure.

Goal: Displaying Pokemon Stats for the standard categories. Here’s a picture of what would be “nice” from Pokedex:

Since this data is driven in something I have built for randomly selecting a Pokemon, the data of course changes. All the values and categories are loaded into a sensor already. In fact I can display this data with a simple Markdown like this:

type: markdown
content: |-
  ## Stats
  {% for st in state_attr("sensor.random_pokemon","stats") -%}
    {{ st.stat.name }} {{ st.base_stat }}
  {% endfor %}

Which looks like this:

image

SO I have no issues getting the name and value to plot. Apex seem though to be more of a time-based plot and not a simple one time value. I have no care about “time” as this randomly changes during the day as Pokemon are changed. There is no “history” only a single point in time and a value and that single point has names not time (i.e. 6 series … or 7 if you count the sum). Note that the sensor has many, many things only one of which is the “stats” as an attribute and those vakue are buring deeper as you can see in the Markdown template to get to the values/names. It is not a simple single attribute for each nor would I want to create more sensors based on the master sensor as the data is there.

So is Apex charts good for this? Or something else? Does anyone have a starting point for me that can help me?

You can see the discussion here about creating the original sensor:

I would also note that I am not tied to a “bar” view, maybe a circular chart is better.

1 Like

The docs say only line, area and column are supported at the moment.

I would assume your answer then is “no”. Is there any other mini-graph card or something that could display this?

Hmmm…actually have a look here https://smarthomescene.com/guides/apexcharts-card-advanced-graphs-for-your-home-assistant-ui/ (I was looking at the series type options before not the chart type so radial bar is supported)

Understood and you are closer to what I was thinking EXCEPT … If you look at the example it is this:

type: custom:apexcharts-card
header:
  show: true
  title: Temperature Levels
  show_states: true
  colorize_states: true
chart_type: radialBar
series:
  - entity: sensor.bathroom_battery_level
    name: Bathroom
  - entity: sensor.bedroom_battery_level
    name: Bedroom
  - entity: sensor.kitchen_battery_level
    name: Kitchen

Simple entities. I need those to be an attribute hanging off a sensor that needs jinja or JS to get the value and name. But maybe it is a decent stating point

Maybe I can attempt to wrap it in a custom templatable entry or? Is “series” in that case templatable is the question.

** Update ***

Closer … still too much is canned but …

OK. See if you can come up with a solution with this card. If not, ha-floorplan will have this ability in maybe a month as a new feature.

Ultimately, this should not be this way but if I can wite it canned, I would think it could be better:

type: custom:apexcharts-card
header:
  show: false
  show_states: true
  colorize_states: true
chart_type: radialBar
all_series_config:
  max: 200
  show:
    legend_value: false
series:
  - entity: sensor.random_pokemon
    name: HP
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[0].base_stat]]
  - entity: sensor.random_pokemon
    name: Attack
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[1].base_stat]]
  - entity: sensor.random_pokemon
    name: Defense
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[2].base_stat]]
  - entity: sensor.random_pokemon
    name: Special Attack
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[3].base_stat]]
  - entity: sensor.random_pokemon
    name: Special Defense
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[4].base_stat]]
  - entity: sensor.random_pokemon
    name: Speed
    data_generator: >
      return [[new Date(entity.state).getTime(),
      entity.attributes.stats[5].base_stat]]

What does it need?
!) no one should assume that those stats are in the order, it should be able to be written as “for each stat” (maybe I use multiple entity card??"
2) The max should probably be like 110% greater than the largest value (maybe I use jinja custom template card?)
3) The display when mousing over the series should NOT display the percent, it should display the value (can’t believe this does not exist, I just must be missing something)

1 Like

Hello together,

I use mutliple yaxis (2) and use 6 series. The first one uses the first yaxis and the other 5 series uses the second yaxis.
Everything fine, but if hide the first series of the five ones, the yaxis is hidden also. The reminaing 4 series don´t have a yaxis:
grafik

grafik

Is it possible to show the yaxis all the time?

I expect its because the radial bar card expects values from 0-100%. This is from the Apex Charts docs:

Keep in mind that the value of these charts must be in percentage (between 0 and 100). You can still display the original value in labels, but the data presented in series must always be in a percentage.

What you really need is the bar chart I think but it isn’t currently available. Edit: here is the actual Apex Charts code that will drop the %. You will have to work out how to put it into the card syntax:

  plotOptions: {
    radialBar: {
      dataLabels: {
        total: {
          show: true,
          label: 'TOTAL',
          formatter: function (w) {
            return w.globals.seriesTotals.reduce((a, b) => {
                      return a + b
                    }, 0) / w.globals.series.length
          },
        },
        value: {
          show: true,
          fontSize: '14px',
          formatter: function (val) {
            return val
          },
        },
      }
    }
  },

I’ve searched for a quite a while and couldn’t find a solution for this, so wondering if it isn’t possible…

I’d like to use an entity state as a label in the chart. Basically using what’s below, but this doesn’t work (it doesn’t render the template).

now:
  show: true
  label: {{ states('sensor.mysensor')|float(0) }}