ApexCharts card - A highly customizable graph card

Don’t use stroke_width on column, if you read further up on the linked topic, i shared my code, where you’ll find where and howto use % as width for columns ( edit: “Bars” ) … so they get “centered”

With a column ? Read the documentation.

Thanks. If these charts can’t plot just two days of data without taking over my HA then they are no good to me. Thought they might have been a better alternative to Grafana on a dashboard.

??? , i have never answered you in any regards, so i really have no idea of why you reply to me ?

EDIT: Beside, if i would have answered you in your request for help/assistance, i would have told you to … 1. show what’s wrong :wink: 2. explain “bog down” . 3 INVESTIGATE, bog down , because you most likely have some underlying issues, with 1 of, or both your “suspec_named_sensors”, which might give you a hint, to solve your “bog down” experience

For some reason this doesn’t work for me. Any idea why?

data_generator: |
  return entity.attributes.raw_today.map((entry) => {
    const nu = new Date()
    const series_entry = new Date(entry.start)
    if(nu.getHours() == series_entry.getHours())
      {return [series_entry, entry.value + hass.states['sensor.elpris_paslag'].state]}
    return [series_entry, 0];
    });
- sensor:
  - name: "elpris_paslag"
    state: >
      {% set paslag =  0.82225|float %}
      {{ paslag }}

I don’t get an error but the hass.states['sensor.my_sensor'].state simply seem to return 0.

I didn’t, I responded to OzGav. Don’t know why it appears as responding to you.

But thanks anyway!

I can’t because the chart makes the HA system and browser slows down so much I can’t do anything with it. It takes minutes for one mouse click to respond.

The entire HA interface slows down to a near stop as a result of just adding this one chart, system resources are overwhelmed to the point that Home Assistant dashboard crashes. I had to be very careful and patient, eventually was able to delete the manual card with this chart. Once it was deleted my HA is back to its normal zippy self.

Not sure what to look for or to know what is wrong. The sensors display their data just fine in regular HA dashboards. I can view their history tab quickly and easily, and if i choose a regular inbuilt card they show data just fine, e.g. these are the two sensors I was using, they show here in a jiffy and no system issues:

Yeah I’m not sure if that is the issue just suggested to try it and see if that helps. If it does then you can continue down on the track to work out why

Does hass.states['sensor.elpris_paslag'].state] return text and needs converting to a number?

Maybe, the template sensor code is in my post above and there I (think I) convert it to a float.

Edit:
Working now, me being stupid as always :slight_smile:

Thanks. I think I need to set up a test environment for this, or take a snapshot of my HA VM before trying again. I’m not going to risk putting any Apex Chart in my regular dashboard again. It’s that bad.

Try with first remove 1 of the sensors from this apex-card

ie.

  1. remove solarnet-power-photo
  2. remove

as this seems in conflict with the 8000W that seems to be registered in your native history card

if you still have problems after removing these 2, i would look into / monitoring your system and network resources, as im not familiar with what system you have your HA on, nor which device you trying to view your Graphs from, i can’t say much, but your “bog down” seems related to power/resource whether it’s cpu/ram or network , should be fairly easy to figure out

Lets say your solar_power_prod_sensor , spewing 8000W ( to your limited to 3000 graph ) AND at the same time does this in a constant flow with 1 seconds interval … i mean the graph your showing aint showing a nice thin line, the blue line is very irregular , same goes for the pink for that matter, so there is heavy activity, i don’t know where this info gets trans-coded, or whether it’s raw … and i don’t see any “group_by” in your card … so i think you basically trowing in a homogeneous amount of information, which the card obviously have hard to deal with

Not to mention: … i assume you are aware that the “graphs” you are trying to “create” is COLUMNS , not lines, now that would look interesting in a detailed scale, considering the amount of “points” ( which are not group-ed) , how often does this(these) sensors “update” … spewing out tons of info in “buckets” or ? , small, large buckets ? , does each “bucket” crave a column ?..

PS: sorry for my way of writing, but before you criticize and spew your negative opinions, be sure you know what you are doing

I am sure this “transform” also is a large “bog down” source, you basically let your HA frontend do the math , of a solar-power-production sensor

nobody find?

Hi. I think i found your post, and by setting the width to 200000% made it look ok. But i have another chart too, showing tomorrows price when it’s available, and that one reacts completely different. adding a wider space before the last column and not making them the same size as the other chart


      type: custom:apexcharts-card
      header:
        title: ' '
        show: true
        show_states: true
        colorize_states: true
      graph_span: 10d
      span:
        start: day
        offset: '-9d'
      apex_config:
        legend:
          show: false
        plotOptions:
          bar:
            columnWidth: 200000%
        dataLabels:
          enabled: false
      series:
        - entity: sensor.elpris_idag
          type: column
          color: '#03a9f4'
          group_by:
            func: max
            duration: 1day
          name: Idag
          extend_to: false
          #stroke_width: 12
        - entity: sensor.snittpris_denna_manad
          type: line
          name: Snittpris
          stroke_width: 5
          fill_raw: last
          curve: smooth
          color: lightblue

VS

      type: custom:apexcharts-card
      header:
        title: ' '
        show: true
        show_states: true
        colorize_states: true
      graph_span: 10d
      span:
        start: day
        offset: '-8d'
      apex_config:
        legend:
          show: false
        plotOptions:
          bar:
            columnWidth: 200000%
        dataLabels:
          enabled: false
      series:
        - entity: sensor.elpris_idag
          type: column
          color: '#03a9f4'
          group_by:
            func: max
            duration: 1day
          name: Idag
          extend_to: false
          #stroke_width: 12
        - entity: sensor.elpris_imorgon
          type: column
          color: blue
          group_by:
            func: last
            duration: 1day
          name: Imorgon
          extend_to: false
          #stroke_width: 12
          data_generator: |
            return [[new Date(entity.attributes.datum).getTime(), entity.state]]
        - entity: sensor.snittpris_denna_manad
          type: line
          name: Snittpris
          stroke_width: 5
          fill_raw: last
          curve: smooth
          color: lightblue

VS ???, i have no idea what you are “dealing” with … and it’s definitive first time in any category i’ve heard of 200.000%

seriously you are on your own, don’t refer to me :slight_smile:

PS: i tried to copy/paste your “code” to a view/card here, it absolutely dont work !, NOT even if i remove everthing from VS and donw, so i only should have the first graph, wrong intends !!! , sorry can’t help you on this as it’s not “obvious” what you are doing here

PS: somewhere in your code you have a wrong intend, i can’t find it, thou i can make a similar card, with same sensor, AND without 200000%, as this number is obvious wrong

  1. Whats does this sensor provide ?
sensor.elpris_idag

Is it current pries ( 1 , entry at a given time , during the day ?), or is it ALL prises during “today” ? (i.e like a forecast)

Same goes for

sounds pretty much like a “forecast” :wink:
for these , as i assume is ALL prises during the day / or during tomorrow , it makes no sense in making a graph using “group by max” and then “duration” day

for those 2 sensors, which expose several values, during the day/tomorrow, most likely 1 for each hour, and you can make a graph for that “using raw” ALL data points, im pretty sure neither here in SE, nor DK or NO, have 1 single “elpris_idag”, , so this/these sensors provide you with several , prices, and you can’t uses a card to summarize this, and giving it any sense

I wasn’t looking, but I did see a posted solution for this problem in this year !!

Hi @Kertz1954, please excuse my delay. I have 6 plots and 4 additional values in the header ut not in the chart. I defined three yaxis and referenced them via id. If i hide the first entity of my series with yaxis-id= energy_axis_day the complete yaxis disapperas, otherwise there are 4 other entities with the same yaxis left.

type: custom:apexcharts-card
header:
  show: true
  title: PV-Leistungsübersicht (heute)
  show_states: true
  colorize_states: true
update_interval: 1m
graph_span: 24h
show:
  last_updated: true
apex_config:
  chart:
    height: 300%
span:
  start: day
  offset: '-0d'
yaxis:
  - id: percent
    min: 0
    max: 100
    decimals: 0
    apex_config:
      tickAmount: 5
  - id: energy_axis_day
    decimals: 0
    min: 0
    max: ~10000
    opposite: true
    align_to: 1000
    apex_config:
      tickAmount: 5
  - id: none
    show: false
now:
  show: true
  color: red
series:
  - entity: sensor.e3dc_battery_soc
    yaxis_id: percent
    type: area
    opacity: 0.3
    name: Batterie
    color: rgb(209, 226, 175)
    stroke_width: 2
    group_by:
      func: last
      duration: 30m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.e3dc_power_consumption
    yaxis_id: energy_axis_day
    type: line
    name: Hausverbrauch
    color: rgb(204, 51, 51)
    stroke_width: 2
    extend_to: false
    group_by:
      func: last
      duration: 12m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.e3dc_grid_power_in
    yaxis_id: energy_axis_day
    type: line
    name: Netzbezug
    color: rgb(0, 102, 128)
    stroke_width: 2
    extend_to: false
    group_by:
      func: last
      duration: 12m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.e3dc_wallbox_power
    yaxis_id: energy_axis_day
    type: line
    name: Wallbox
    color: grey
    stroke_width: 2
    extend_to: false
    group_by:
      func: last
      duration: 12m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.e3dc_grid_power_out
    yaxis_id: energy_axis_day
    type: line
    name: Netzeinspeisung
    color: rgb(0, 164, 206)
    stroke_width: 2
    extend_to: false
    group_by:
      func: last
      duration: 12m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.solar_power_overall
    yaxis_id: energy_axis_day
    type: line
    name: PV (gesamt)
    color: rgb(255, 194, 56)
    stroke_width: 2
    group_by:
      func: last
      duration: 12m
    show:
      in_header: false
      in_chart: true
      extremas: false
  - entity: sensor.total_energy_yield_day
    yaxis_id: none
    name: PV (Tag)
    color: rgb(255, 194, 56)
    group_by:
      func: last
      duration: 12m
    show:
      in_header: true
      in_chart: false
      extremas: false
  - entity: sensor.netzbezug_tag
    yaxis_id: none
    name: Netzbezug (Tag)
    color: rgb(0, 102, 128)
    group_by:
      func: last
      duration: 12m
    show:
      in_header: true
      in_chart: false
      extremas: false
  - entity: sensor.netzeinspeisung_tag
    yaxis_id: none
    name: Netzeinspeisung (Tag)
    color: rgb(0, 164, 206)
    group_by:
      func: last
      duration: 12m
    show:
      in_header: true
      in_chart: false
      extremas: false
  - entity: sensor.hausverbrauch_tag
    yaxis_id: none
    name: Hausverbrauch (Tag)
    color: rgb(204, 51, 51)
    stroke_width: 2
    group_by:
      func: last
      duration: 12m
    show:
      in_header: true
      in_chart: false
      extremas: false

If you have any idea please give me a hint.

Best regards,
Chrclaus

Hi there, yet another question: I want to groupBy data on a monthly basis. As i noticed

group_by:
  duration: 4w

does not work for months. Does anybody has a workaround for example on a weekly-basis like i did to keep the monthly-interval?

type: custom:apexcharts-card
apex_config:
  chart:
    stacked: true
update_interval: 1d
graph_span: 4w
span:
  end: month
show:
  last_updated: true
header:
  show: true
  title: Energie-Übersicht (Monat)
  show_states: true
  colorize_states: true
series:
  - entity: sensor.energy_e3dc_wallbox
    type: column
    name: Wallbox
    color: grey
    group_by:
      func: delta
      duration: 4w
      fill: zero
  - entity: [...continiuos...]

Best regards,
Chrclaus

the VS was a way to show it is two separate charts. I have them in conditional cards in a vertical stack card, maybe thats why the intendention is wrong. The sensors are template sensors that show the average price today and the average price tomorrow. the today sensor gets it’s value at 00:00:00 and the tomorrow sensor gets its value when nordpool releases the new prices

1 Like