ApexCharts card - A highly customizable graph card

did you manage it to hide the zero values ? on an easy way ?

Edit : transform: “return x == 0 ? null : x;”

  - type: custom:apexcharts-card
    span:
      start: day
      offset: -1min
    experimental:
      color_threshold: true
      brush: true
    header:
      show: false
      # title:  Energie
      show_states: true
      colorize_states: true
    apex_config:
      legend:
        show: true
        position: top
      grid:
        strokeDashArray: 0
        borderColor: rgb(52,52,52)
      xaxis:
        axisBorder:
          show: false
          color: rgb(52,52,52)
        tickAmount: 1
        axisTicks:
          show: false
        labels:
          style:
            colors: rgb(128,128,128)
      yaxis:
        decimalsInFloat: 0
        
        labels:
          style:
            colors: rgb(128,128,128)
    all_series_config:
      type: area
      curve: smooth
      stroke_width: 1
      group_by:
        func: avg
        duration: 10min
      color_threshold:
        - value: 0
          opacity: 0.2
        - value: 1000
          opacity: 0.7
        - value: -1000
          opacity: 0.7
         series:
          - entity: sensor.p1_meter_5c2faf04a1f2_active_power
            transform: "return x >= 0 ? x : 0 ;"
            name: Opbrengst
            color: rgb(66,73,241)
            float_precision: 2
            extend_to: now     

          - entity: sensor.p1_meter_5c2faf04a1f2_active_power
            transform: "return x <= 0 ? x : 0 ;"
            name: Verbruik
            color: rgb(11,252,3)
            float_precision: 2
            extend_to: now

this is what I have now… the second chart is in testing mode (I am not sure it will give me a negative chart)

Hi all,

bit of a strange one. i’m trying to replicate a smaller version of the energy dashboard. So far so good apart from the face that my Battery power (%) doesn’t match the secondary axis set to 100.

can anyone advise?

type: custom:apexcharts-card
header:
  show: true
  title: Home Energy
  show_states: true
  colorize_states: true
graph_span: 1day
yaxis:
  - id: watts
    max: 15
    apex_config:
      tickAmount: 4
  - id: percent
    opposite: true
    decimals: 0
    align_to: 1
    apex_config:
      tickAmount: 4
stacked: true
series:
  - entity: sensor.grid_export_power
    type: column
    yaxis_id: watts
    transform: return x / 1000;
    unit: kWh
    group_by:
      func: avg
      duration: 30m
  - entity: sensor.consumption_power
    type: column
    yaxis_id: watts
    transform: return x / 1000;
    unit: kW
    group_by:
      func: avg
      duration: 30m
  - entity: sensor.battery_power
    type: column
    yaxis_id: watts
    transform: return x / 1000;
    unit: kW
    group_by:
      func: avg
      duration: 30m
  - entity: sensor.pv_power
    type: line
    yaxis_id: watts
    transform: return x / 1000;
    unit: kW
    group_by:
      func: avg
      duration: 30m
  - entity: sensor.battery_charge
    type: line
    yaxis_id: percent
    group_by:
      func: avg
      duration: 30m

image

Is it possible to hide a negative value ?

Probably with transform, I donot have data to check but you have to define what else to do as you still have the time component

  - entity: your_entity
    transform: "return x > 0 ? x : 0 ;"

alternative might be to use datagenerator and just get out only positive numbers

the bar chart is negative on purpose, this is energy exported and imported fromthe grid.

The yellow line is my PV Battery charge level in %, but it looks like its starting on the left hand Y axis, and not the Right which is the axis is assigned to…

Is there any way we can plot a graph of the difference between two series?

image

        series:
          - entity: sensor.p1_meter_5c2faf04a1f2_active_power
            transform: "return x >= 0 ? x : 0 ;"
            name: Opbrengst
            color: rgb(66,73,241)
            float_precision: 2
            extend_to: now     

          - entity: sensor.p1_meter_5c2faf04a1f2_active_power
            transform: "return x <= 0 ? x : 0 ;"
            name: Verbruik
            color: rgb(11,252,3)
            float_precision: 0
            extend_to: now

Now you can see that 0 is a green line. Can I remove that zero line ?

Nice color fading :slight_smile: What settings did you use to get that? Gradient or color_threshold?
Willing to share the code?

You can see it in a post from 2 days ago…

1 Like

Hello folks!
I’m trying to graph the wind, and I can’t figure out how to have non-numeric values as the Y axis. I’ve made another thread about it here - if anybody has any insight into how to either graph “weather cardinal” values (n, s, e, w, nnw, ese, wsw, etc) or convert the numeric value (wind direction represented in 360 degrees) into a dot/plot chart like in my thread, I would be very grateful!

Is it possible to combine two entities in a series?
For example in a line graph showing one entity for my PS4 usage, but then one line showing two different TV usages shown as one value, not a separate line for both.

At the moment I have it as a bar graph that has been stacked, which does add them together, but I’d prefer it as a line.

what If I don’t want the 0 value to be seen ?

I use null to remove any graph
transform: "return x >= 0 ? x : null ;"

1 Like

I am trying to visualize what you want but … if you have a x with timeseries on regular distance and filter out the negative/zero value than you graph will probably show gaps …

I have a chart in gradient blue. When it goes below zero I want the chart in gradient green…
It was told that you cannot change color when you want it in gradient.
So I made 2 charts. 1 with values above 0, 1 with values below zero. But it doesnt look nice to have 0 zero value, so I want it removed…

that is what I want ! Top. Thanks

I have red a few questions here about wind plots of some kind, I can’t answers these questions but if you are looking for a way to plot wind speed and direction I have had good luck with this card.

Is it possible to show multiple entities at once in the tooltip when using the line graph?

In the apexchart documentation there is the “shared” keyword für the tooltip. I tried it but no success. I am either doing it wrongly or it is not implemented. I seen to remember seeing it done though.