ApexCharts card - A highly customizable graph card

Thank you again @RomRider

Unfortunatelly this isn’t working.
This is the setup:

Sensor:

  - platform: template
    sensors:
      xch_farm:
        friendly_name: Farm CHIA
        unit_of_measurement: 'XCH'
        value_template: '1'
        attribute_templates:
          farm: "[ ['2021-05-22T05:30:00.000Z', 0.00499446], ['2021-05-23T05:30:00.000Z', 0.01417467], ['2021-05-24T05:30:00.000Z', 0.01414641], ['2021-05-25T05:30:00.000Z', 0.01311282], ['2021-05-26T05:30:00.000Z', 0.01513299], ['2021-05-27T05:30:00.000Z', 0.01439478] ]"

Dev Tools output:

  - platform: template
    sensors:
      xch_farm:
        friendly_name: Farm CHIA
        unit_of_measurement: 'XCH'
        value_template: '1'
        attribute_templates:
          farm: "[ ['2021-05-22T05:30:00.000Z', 0.00499446], ['2021-05-23T05:30:00.000Z', 0.01417467], ['2021-05-24T05:30:00.000Z', 0.01414641], ['2021-05-25T05:30:00.000Z', 0.01311282], ['2021-05-26T05:30:00.000Z', 0.01513299], ['2021-05-27T05:30:00.000Z', 0.01439478] ]"

Card:

type: 'custom:apexcharts-card'
header:
  show: true
  title: ApexCharts-Card
  show_states: true
  colorize_states: true
graph_span: 2d
span:
  start: week
apex_config:
  dataLabels:
    enabled: true
series:
  - entity: sensor.xch_farm
    type: line
    data_generator: |
      return JSON.parse(entity.attributes.farm).map((entry) => {
        return [new Date(entry[0]).getTime(), parseFloat(entry[1])];
      });

Ok @RomRider , I did a thing.

I used Jinja2 and create a real array in the sensor attributes.

  - platform: template
    sensors:
      xch_farm:
        friendly_name: Farm CHIA
        unit_of_measurement: 'XCH'
        value_template: '1'
        attribute_templates:
          farm: |
            {{ [
              {
                  "date": "2021-05-22T05:30:00+00:00",
                  "value": 0.00499446
              },
              {
                  "date": "2021-05-23T05:30:00+00:00"",
                  "value": 0.01417467
              },
              {
                  "date": "2021-05-24T05:30:00+00:00"",
                  "value": 0.01414641
              },
            ] }}

Now the array is working, BUT with this card setup:

type: 'custom:apexcharts-card'
header:
  show: true
  title: ApexCharts-Card
  show_states: true
  colorize_states: true
graph_span: 2d
span:
  start: week
apex_config:
  dataLabels:
    enabled: true
series:
  - entity: sensor.xch_farm
    type: line
    data_generator: |
      return entity.attributes.farm.map((entry) => {
            return [new Date(entry.date), entry.value];
          });

I finally “see something” in the graph. But no values are showed. Maybe too many decimals?

You need to increase the yaxis definition:

  • in the serie:
  - entity: sensor.xch_farm
    float_precision: 10
    ...
  • on the yaxis:
type: 'custom:apexcharts-card'
y_axis_precision: 10

Try not to burn your hard-drive :stuck_out_tongue:

@RomRider thank you very much for your help. It worked perfectly!

Hahahahha I’ll do my best :grinning:

One more thing @RomRider
On the iOS app I have this kind of glitch on the “now” label.

Is that my fault?

Probably safari’s fault :man_shrugging: nothing I can or you can do about it.

Ok no problem :slightly_smiling_face: Label removed

How do I remove future values from the graph if the X axis is time?

image

I don’t want this horizontal line

type: 'custom:apexcharts-card'
graph_span: 24h
span:
  start: day
header:
  show: true
  title: Napięcie paneli
  show_states: true
  colorize_states: true
series:
  - entity: sensor.pv_voltage_a
    curve: smooth
    fill_raw: 'null'
    group_by:
      duration: 20min
      func: avg
y_axis_precision: 1

Under “series”:

extend_to_end: false

Similar to some others in this thread, I wanted to make a radial graph for CPU/RAM/Disk usage. The problem so far is the bottom of the graph being cut off:

Adjusting the offset can make the graph visible, but the legends are still cut off with an adorable little scroll bar. It looks like a “foreignobject” container is causing this, but I can’t seem to adjust with the ApexCharts options or card-mod:

Any suggestions to fix this? :slight_smile:

Not much we’ll be able to help with without your config :wink:

type: 'custom:apexcharts-card'
chart_type: radialBar
graph_span: 1s
header:
  show: false
apex_config:
  chart:
    foreColor: 'rgb(148,148,148)'
    offsetY: -50
    height: 350
  legend:
    show: true
    position: left
    floating: true
    offsetX: 200
    offsetY: 200
  plotOptions:
    radialBar:
      inverseOrder: true
      offsetY: 0
      startAngle: -180
      endAngle: 90
      hollow:
        size: 35%
        background: transparent
      dataLabels:
        name:
          show: true
        value:
          show: true
series:
  - entity: sensor.golfquest_pc_cpu_usage
    name: CPU
  - entity: sensor.golfquest_pc_cpu_usage
    name: CPU
  - entity: sensor.golfquest_pc_cpu_usage
    name: CPU

Wow, I made a mental note at least three times to not forget that when I was scanning through this thread. :neutral_face:

Hello everybody.
Is it possible to create a monthly chart (12 months) with the ApexCharts Card?

type: 'custom:apexcharts-card'
span:
  end: day
graph_span: 7d
header:
  show: true
  title: Fatura
  show_states: true
  colorize_states: true
apex_config:
  tooltip:
    enabled: true
  yaxis:
    - show: true
      decimalsInFloat: 0
      axisTicks:
        show: true
      opposite: true
      axisBorder:
        show: false
        color: '#e74c3c'
      labels:
        style:
          colors: '#e74c3c'
          fontSize: 12px
          fontWeight: bold
          fontFamily: Raleway
      forceNiceScale: true
series:
  - entity: sensor.total_pagar_shelly_em_casa
    type: column
    name: ' '
    show:
      extremas: true
    group_by:
      func: last
      duration: 1d
    color: '#e74c3c'

Hello

Anyone know why my charts suddenly wont show up anymore? They do if i create a new one, but not with this exact code. Is there anything in my code that has change that makes it break?

type: 'custom:apexcharts-card'
update_interval: 15min
graph_span: 1d
layout: minimal
header:
  show: true
  show_states: true
  floating: true
  colorize_states: true
now:
  show: false
  label: Stua
  color: white
series:
  - entity: sensor.multi_stua_temp
    color: '#e74c3c'
    type: line
    name: Stua
    group_by:
      func: max
      duration: 30min
    extend_to_end: true
  - entity: sensor.multi_stua_fuktighet
    show:
      datalabels: true
    color: '#3279a8'
    type: line
    name: ' '
    group_by:
      func: max
      duration: 30min
    extend_to_end: true
apex_config:
  chart:
    height: 180px
  xaxis:
    tickAmount: null
    labels:
      format: HH
  stroke:
    width: 3
    curve: smooth
  dataLabels:
    enabled: false
  legend:
    show: false

loving your graphs, but on my side the redering is very bad!

any idea ?
image

Have you figured it out? I’m also looking for this

I tried asking about this 10 days ago but I got no answer .
you want it like this chart right?

It is not possible at the moment because grouping by month doesn’t group by actual months but by some number of days which is fixed.
I have no plan at the moment to introduce that feature, but will think about it for the future.

1 Like


I don’t know what is wrong, but when I try to use the min and max for the y-axis, I cannot get it to work. As soon as I change a min or max value, I see the correct values on the y-axis for 0.1 second, and then it seems some auto-range is performed?

It is said in the documentation that min and max shouldn’t be under apex_config but straight under your yaxis entry.