Posted

in

, ,

by


Nice stacked bar charts

: stacked bar charts in

I wanted nice stacked charts to show my energy consumption in Home Assistant.

After combining code from several sources (1), the result looks like this:

screenshot of stacked bar chart

The code:

I’ve inserted ‘manual card‘ to the dashboardand inserted the yaml code:

header:
  show: true
  show_states: true
  colorize_states: true
  title: ***INSERT YOUR CHART TITLE***
  
type: custom:apexcharts-card
apex_config:
  chart:
    stacked: true
  xaxis:
    labels:
      format: dd.MM
  legend:
    show: true
    
graph_span: 7d

span:
  end: day
  
show:
  last_updated: true
  

series:
  - entity: sensor.tuya_smart_plug_01_energy
    type: column
    group_by:
      func: diff
      duration: 1d
      start_with_last: true
      
  - entity: sensor.***INSERT YOUR SENSOR 1 NAME***
    type: column
    group_by:
      func: diff
      duration: 1d
      start_with_last: true
      
  - entity: sensor.***INSERT YOUR SENSOR 2 NAME***
    type: column
    group_by:
      func: diff
      duration: 1d
      start_with_last: true
      
...

Before using Apex charts in Home Assistant, install them via HACS or manually (search for apexcharts-card repository in HACS, frontend section):

screenshot of HACS - install apexchart


Comments

2 responses to “Nice stacked bar charts”

  1. Andrej Uduč Avatar

    Thanks for bringing my attention at apex charts. And I see you’re from my country. Have you tried making a nice dashboard using Moj Elektro data?
    There’a nice HA integration project at
    https://frlequ.github.io/

    1. Tomi Avatar
      Tomi

      Thanks!
      Yes, I’m using Elektro and network tariff integrations.
      Didn’t use them as the input to apex charts yet, but thanks for the idea!

Leave a Reply

Your email address will not be published. Required fields are marked *