ApexCharts card - A highly customizable graph card

Must have to do something with the following configuration:

apex_config:
  plotOptions:
    bar:
      columnWidth: 20%

Changed it to 20% and now it looks like this:

2022-05-02 11_04_41-Window

Can some one help me out here? I can’t make the option : Display the graph from start of day, week, month, … with support for “up to now” or until the “end of the period”

I would like to see my graph from the begin of the day till the actual hour i’m look at the graph. But if i enter end: up to now it’s not working.

Can anyone help me get this color temperature line chart in my code? I posted above but this is for my Fireboard temperature probe with an ambient temperature from local METAR.

type: custom:apexcharts-card
graph_span: 1.5h
now:
  show: true
  color: red
  label: Now
header:
  show: true
  title: Fireboard History .!|!.
  show_states: true
  colorize_states: true
series:
  - entity: sensor.kxx_temperature
    name: Ambient (Outside)
  - entity: sensor.fireboard.temp.channel.1
    type: area
  - entity: sensor.fireboard.temp.channel.2
    type: line

I’ve tried posting all of the
let options = {

But it doesn’t like it.

Thank you!

Ive got an issue with an apexcharts card after upgrading

The error i am getting is

// apexcharts-card version 2.0.1 /// value.series[0] is not a ChartCardSeriesExternalConfig value.series[0].extend_to_end is extraneous value.series[0].extend_to_end is extraneous

Here is my card config

type: custom:apexcharts-card
graph_span: 36h
span:
  start: day
  offset: '-6h'
header:
  show: true
  title: Solar Production vs. forecast
  show_states: true
now:
  show: true
  label: now
apex_config:
  legend:
    show: false
series:
  - entity: sensor.solaredge_current_power
    name: Actual
    unit: W
    fill_raw: last
    extend_to_end: false
    group_by:
      func: avg
      duration: 30min
  - entity: sensor.solcast_forecast_average_30min
    transform: return x * 1000;
    name: Forecast
    unit: W
    fill_raw: last
    extend_to_end: false
  - entity: sensor.solcast_forecast_data
    type: line
    extend_to_end: false
    unit: W
    show:
      in_header: false
    data_generator: |
      return entity.attributes.forecasts.map((entry) => {
         return [new Date(entry.period_end), entry.pv_estimate*1000];
       });

As far as I know this is now deprecated. You would need

extend_to: end

See: series options

I would like to change a few things in my graph but I cannot find the matching options (if they even exist)

  • Add the unit to the y-axis.
    I do not mean manually overriding the unit. I mean automatically displaying the unit next to the axis
  • Define the major tick mark multiples.
    Right now the tick marks are e.g. multiples of 213. So 213, 426 etc.
    This is automatically created, I assume based on the max value. I would like it to be multiples of 100.
    I tried “forceNiceScale” as an intermediate fix, but I would prefer to define the actual value.
  • Define an amount between max value and chart area border ( e.g. max value + 5%).
    So if the max value is 999, I do not want the max tick mark to be 1000. I would like to always have e.g. max value + 5% or something like that. It looks weird, when the max value is right at the top of the chart.
  • Convert state to number.
    I found pairing, so pair a string on x to a value in y. But that I do not want.
    I would like the x-axis to remain time and I would like to have “1” if a sensor is “on” and “0” if a sensor is “off”

Anybody have an idea how to do any of these?

Maybe a minor bonus thing, but is there a way to change the span of the x-axis without creating input_select?
I am currently using it, but this changes the span of every chart and not just one. It changes the span across all dashboards (obviously). But I don’t really want to create one input_select per chart.

Ahh, i missed that.

Working now, thanks!

Have you had any luck with this?

Hi all! I tried to use the radial bar function to represent a Watt sensor. I set min/max value like the docs but this is I obtained. The screen “01” is the result, the screen “02” is a gauge I used before with the same sensor in it

This is the result of the chart:
01

This one is a gauge with the same sensor in it:
02

This is the config I use:

- type: custom:apexcharts-card
   cache: false
   layout: minimal
   chart_type: radialBar
   yaxis:
     - min: 0
       max: 3000
   graph_span: 2s
   stacked: false
   show:
     last_updated: false
   series:
     - entity: sensor.home_energy_meter_gen5_electric_consumed_w
       name: W
       type: line
       unit: W
       color: "#75ecff"
       show:
         legend_value: false

There’s something I miss or it’s a bug? Thanks in advice.

Hi,

I’ve got an MQTT sensor (image from states page below) configured in yaml like so:

  • platform: mqtt
    device_class: “power”
    force_update: “true”
    icon: “mdi:transmission-tower”
    name: “SOFAR Load”
    unique_id: “sofar_consumption”
    unit_of_measurement: “W”
    state_topic: “sofar/consumption”

And it just returns integers. I’ve done a chart which is based on
graph_span: 24hr
span:
start: day

And the series is configured as so

  • entity: sensor.sofar_load
    name: Load
    transform: ‘return x > 15000 ? null : x / 1000;’
    yaxis_id: power
    type: area
    color: ‘#6FB6C6
    unit: kW
    extend_to: now
    curve: straight
    fill_raw: last
    opacity: 0.1
    group_by:
    func: avg
    duration: 5min
    show:
    legend_value: false

This is working great, because in the first instance I just wanted the chart to plot values for today, starting at midnight. I want to get a bit more advanced. I’ve created a helper entity, a date, which goes by the name of input_datetime.power_diagram_date and I want to be able to select a date in the entity and then display the values for that date only on the graph. At first I thought try and use some javascript on offset to derive a “-1 day” value based on difference between today and date in the helper, however offset does not support javascript.

As such, I’m trying to fall back to data_generator to in effect select values from the sensor based on whether the date matches.

For now though, keeping it simple if anyone could explain at least how to manually load the data in data_generator in the most basic sense, I’d appreciate it. I’ve tried lots of attempts but without knowing the data model for a basic single value sensor I’m struggling to know what properties my sensor exposes.

As you can imagine, this pitiful attempt does nothing - but it is based on some other examples I’d seen online, for more complex sensors.

data_generator: |
          return entity.states.map((entry) => {
            return [new Date(entry.datetime), entry.value];
          });

You can see what I am essentially trying to do in a test dashboard, select a date, and have the chart plot for that date. Obviously no ‘load’ figures are being displayed because my data_generator is failing.

Is there any debug mechanism or is it a case of just fundamentally understanding the properties and trial/error also?

Thanks a lot
Dan

Hi all,

Who can help me out with this issue.
I would like my card to be showed zoomed in all the time and not always have to zoom in again.

This is the config of my card:

type: custom:apexcharts-card
experimental:
color_threshold: true
header:
show: true
show_states: true
colorize_states: true
title: Verbruik
graph_span: 1d
span:
start: day
apex_config:
chart:
type: area
zoom:
enabled: true
toolbar:
show: true
tools:
zoom: true
zoomin: true
zoomout: true
pan: true
reset: true
stroke:
show: true
dataLabels:
enabled: true
legend:
show: false
fill:
type: gradient
gradient:
inverseColors: true
type: vertical
shadeIntensity: 0.7
opacityFrom: 0.7
opacityTo: 0.3
grid:
show: false
all_series_config:
stroke_width: 1
group_by:
func: last
duration: 1m
curve: smooth
type: area
series:

  • entity: sensor.koelkast_power
    extend_to: now
    name: Koelkast
    transform: return x / 1;
    unit: W
    float_precision: 2
    color_threshold:
    • value: 0
      color: blue
    • value: 80
      color: e07614
    • value: 100
      color: f44336
      wrong
      correct

Hey guys,

I’ve made a graph that supposed to monitor and display in- and outgoing traffic from my server. However, it doesnt seem to reset after 24h, instead of that it just adds data to the next day.

type: custom:apexcharts-card
graph_span: 15d
header:
  show: true
  title: Traffic
series:
  - entity: sensor.sensor_network_out_enp0s31f6_gb
    name: Out
    curve: smooth
    type: column
    color: '#e85d04'
    stroke_width: 1
    opacity: 0.3
    group_by:
      duration: 24h
      func: max
  - entity: sensor.sensor_network_in_enp0s31f6_gb
    name: In
    curve: smooth
    type: column
    color: '#ae2012'
    stroke_width: 1
    opacity: 0.3
    group_by:
      duration: 24h
      func: max

image

Can somone help me figure this out?

Give this a go (you’ll need to make a few changes to suit your sensors, but the gradient should show)

  - type: custom:apexcharts-card
    graph_span: 7d
    apex_config:
      chart: {
              height: 380,
              type: "line",
              foreColor: '#6D6D6D'
          }
      fill: {
          type: "gradient",
          gradient: {
              type: 'vertical',
              shadeIntensity: 1,
              opacityFrom: 1,
              opacityTo: 1,
              colorStops: [
                  {
                      offset: 10,
                      color: "#fc440b",
                      opacity: 1
                  },
                  {
                      offset: 55,
                      color: "#ffce63",
                      opacity: 1
                  },
                  {
                      offset: 90,
                      color: "#0a95f9",
                      opacity: 1
                  }
              ]
          }
      }
      grid: {
          borderColor: '#6D6D6D'
      }
      stroke: {
          curve: 'smooth'
      }
    series:
      - entity: sensor.tempest_st_00056115_temperature
        stroke_width: 4
        group_by:
          func: last
          duration: 15min
1 Like

Would you mind sharing the config for this card? I would love a stacked card, with the nordpool price as well, but haven’t figured out how. Thanks!

Provide the config for the card please, using </>

Shorter graph span perhaps?
When posting config please use </>

Can anyone help me with this?

Is it possible to make the legend show the first value in stead of the last value as default?

why would there be a constant loading icon top right of my card:

May-16-2022 11-50-26

    - type: custom:apexcharts-card
      header:
        show: true
        title: Kitchen appliances
        show_states: true
      graph_span: 2d
      series:
        - entity: sensor.espresso_keuken_actueel
          stroke_width: 1
          curve: stepline
        - entity: sensor.quooker_keuken_actueel
          stroke_width: 1
          curve: stepline

wouldn’t this indicate a huge impact this custom card has on the system? The sensor for Quooker is changing frequently, but not constantly…also, as you can see in the graph, the icon is spinning while the state of the sensor doesnt change at that time. So must be something else going on?

things calm down if I add update_interval: 20sec but that would possibly miss out on a state change during that period… somehow I dont understand why the card updates, when no state change occurs.
heck, it even updates when both are off, and show 0watt:

May-16-2022 12-02-46

and when I take out the Quooker completely… only leaving a sensor that has been 0 for some time now.

and yet the card updates…been over an hour since this sensor changed last exactly now.

Hi,

I’m trying to use the new long term statistics feature. Basically, I need to display hourly yield of my PV. The sensor’s state is daily yield. I’m trying the following code:

            graph_span: 15h
            span:
              start: day
              offset: +5h
            all_series_config:
              type: column
              show:
                legend_value: false
            series:
              - entity: sensor.daily_yield
                name: 6 days ago
                offset: -6d
                statistics:
                  type: state
                  period: hour
                  align: start
                group_by:
                  func: diff
                  start_with_last: true
              - entity: sensor.daily_yield
                name: Today
                group_by:
                  func: diff
                  duration: 1h

The value shown for each hour is zero for some reason (in the first series obviously, the second one draws correctly). I have checked that the WS call returns correct values. What am I missing?