ApexCharts card - A highly customizable graph card

I have a problem with displaying the full history from the last month, the data is always displayed from the last few days as in the screenshot😞

card configuration below:

type: custom:apexcharts-card
graph_span: 1month1s
apex_config:
  xaxis:
    labels:
      style:
        fontSize: 11px
  dataLabels:
    enabled: true
  chart:
    height: 340px
  stroke:
    show: true
    width: 2
    curve: smooth
  legend:
    show: false
header:
  show: true
  title: Parametry zużycia PC w zależnosci od temperatury
  show_states: true
  colorize_states: true
span:
  end: day
series:
  - entity: sensor.tasmota_energy_today
    color: rgb(255, 0, 0)
    type: column
    name: Zużycie Prądu
    group_by:
      func: last
      duration: 1d
      fill: last
  - entity: sensor.temperature_1_2
    color: rgb(10, 82, 191)
    type: line
    name: Temp zewnętrzna
    group_by:
      func: last
      duration: 1d
      fill: last
  - entity: sensor.temperature_4_2
    color: rgb(149, 18, 230)
    type: line
    name: Temp wewnątrz
    group_by:
      func: last
      duration: 1d
      fill: last

I use this to display 13 months

graph_span: 13month

I see you are using this

graph_span: 1month1s

Maybe a typo error or not.

Hello Guys,

I’m bit struggling to populate forecast from entity attributes into graph, and only history or just loading keeps up. Worthy to mention that I’m not that kind of programing guru so coming here for help.

it is also worthy mention that I did my research, where people are trying to resolve the same, but non of that helped me.

Here is Entity:

and here is my latest sample of the sensor, which keeps loading.

May I ask what I’m doing wrong?

series:
  - entity: sensor.current_spot_electricity_price
    data_generator: |
      return entity.attributes.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes[index]["value"]]
      });


Hi all,

I’m trying to visualise the graph of the consumption of a washing machine cycle.
It’s quite easy to identify the start and end time of a cycle, so I wonder if it’s possible to set a precise start and end date and time in the graph?

I’ve experienced the exact same and made a post about it a while ago. I have since found a solution to the problem. You’ll need to group_by the series and use same settings for all of them, for example:

    group_by:
      func: max
      duration: 1h

So now I can mix line, area and column in the same chart without screwing up the look completely:

Great graphs! Could you share the yaml for the setup in your screenshot?

thanks!-
for a second I did see it happen, but on second view, it just falls back to those thins columns…

      - entity: sensor.energyzero_today_energy_average_price
        name: Price this hour
        yaxis_id: price
        data_generator: |
          return entity.attributes.today.map((entry) => {
            return [new Date(entry.timestamp).getTime(), entry.price];
          });
        color_threshold:
          - value: 0.05
            color: lightgreen
          - value: 0.1
            color: green
          - value: 0.2
            color: orange
          - value: 0.3
            color: darkorange
          - value: 0.4
            color: red
          - value: 0.5
            color: maroon
          - value: 0.6
            color: purple
          - value: 0.7
            color: black
        type: column
        show:
          extremas: true
        opacity: 0.8
        float_precision: 2
        group_by:
          func: max
          duration: 1h
      - entity: sensor.netto_verbruik
        yaxis_id: power
        transform: return x /1000;
        unit: kW
        type: line
        name: Verbruik
        stroke_width: 1
        extend_to: now
        color: rgb(0,93,136)
        group_by:
          func: max
          duration: 1h
        show:
          legend_value: true

what’s even more mysterious, is that comparable card stops showing the columns the first series altogether, and only shows the second series.

taking out the group_by reveals the columns…

        series:
          - entity: sensor.entsoe_avg_price
            name: Prijs vandaag
            yaxis_id: price
            color_threshold:
              - value: 0.05
                color: lightgreen
              - value: 0.1
                color: green
              - value: 0.15
                color: orange
              - value: 0.2
                color: darkorange
              - value: 0.25
                color: red
              - value: 0.3
                color: maroon
              - value: 0.35
                color: purple
              - value: 0.4
                color: black
            stroke_width: 5
            float_precision: 4
            type: column
#             group_by:
#               func: max
#               duration: 1h
            opacity: 1
            data_generator: |
              return entity.attributes.prices.map((record, index) => {
                return [record.time, record.price];
              });
          - entity: sensor.netto_verbruik
            yaxis_id: power
            transform: return x /1000;
            unit: kW
            type: line
            name: Verbruik
            stroke_width: 1
            extend_to: now
            color: rgb(0,93,136)
            group_by:
              func: max
              duration: 1h
            show:
              legend_value: true

@Mariusthvdb I have below (screenshot) with added code. In my case the group_by was the key to make this work.

Code:

type: custom:stack-in-card
cards:
  - type: horizontal-stack
    cards:
      - type: custom:mushroom-template-card
        entity: sensor.dailygas
        secondary: Daily Gas
        primary: |
          {{ states('sensor.dailygas') | round(1) }} M3
        icon: mdi:gas-burner
        icon_color: orange
        tap_action:
          action: more-info
      - type: custom:mushroom-template-card
        entity: sensor.waterverbruik_vandaag
        secondary: Daily Water
        primary: |
          {{ states('sensor.waterverbruik_vandaag') | round(0) }} L
        icon: mdi:water
        icon_color: blue
        tap_action:
          action: more-info
      - type: custom:mushroom-template-card
        entity: sensor.aeon_labs_zw100_multisensor_6_temperature_2
        secondary: Outside
        primary: >
          {{ states('sensor.aeon_labs_zw100_multisensor_6_temperature_2') |
          round(1) }} C
        name: Grid
        icon: mdi:thermometer
        icon_color: green
        tap_action:
          action: more-info
  - type: custom:apexcharts-card
    graph_span: 24h
    update_interval: 10min
    span:
      start: day
    apex_config:
      chart:
        height: 150px
        fontFamily: Raleway,sans-serif
      xaxis:
        labels:
          format: HH
      legend:
        show: false
      stroke:
        width: 2
      plotOptions:
        bar:
          columnWidth: 100%
      grid:
        show: true
        borderColor: '#00000030'
        strokeDashArray: 4
        position: back
    experimental:
      color_threshold: true
    header:
      show: false
      show_states: false
      colorize_states: true
    yaxis:
      - id: first
        decimals: 1
        apex_config:
          tickAmount: 2
      - id: second
        opposite: true
        decimals: 1
        apex_config:
          tickAmount: 2
    series:
      - entity: sensor.hourlygas
        name: Gas
        yaxis_id: first
        show:
          legend_value: false
        type: column
        group_by:
          func: max
        color_threshold:
          - value: 0
            color: '#228B22'
          - value: 0.1
            color: '#d35400'
          - value: 1.5
            color: '#c0392b'
      - entity: sensor.aeon_labs_zw100_multisensor_6_temperature_2
        name: Temp
        yaxis_id: second
        type: line
        curve: smooth
        extend_to: false
        opacity: 0.6
        color: '#00bb33'
        show:
          legend_value: false
        group_by:
          func: avg
          duration: 60min

1 Like

@Reflex How did you get the datalabels on top of the columns combined with the line chart? Can you share the code pls?

thx. still not working unfortunately

  - type: custom:apexcharts-card
    graph_span: 23h
    header:
      show: true
      title: EnergyZero prijzen Vandaag (€/kwh)
#    experimental:
#      color_threshold: true
    span:
      start: day
    now:
      show: true
      label: Now
    yaxis:
      - id: price
        decimals: 2
      - id: power
        show: true
        opposite: true
    apex_config:
      plotOptions:
        bar:
          columnWidth: 100%
      stroke:
        width: 2
    series:
      - entity: sensor.energyzero_today_energy_average_price
        name: Price this hour
        yaxis_id: price
        data_generator: |
          return entity.attributes.today.map((entry) => {
            return [new Date(entry.timestamp).getTime(), entry.price];
          });
        type: column
        show:
          extremas: true
        opacity: 0.8
#         float_precision: 2
        group_by:
          func: max
#           duration: 60m

      - entity: sensor.netto_verbruik
        yaxis_id: power
        transform: return x /1000;
        unit: kW
        type: line
        name: Verbruik
#         stroke_width: 1
        extend_to: now
        color: red
        group_by:
          func: max
          duration: 60m
        show:
          legend_value: true

results in

Believe Ive tried all combinations of settings…

none of which bring

which is shown when taking out the 2nd series…
as y9ou can see I also played with the various durations, but they only increase the white gap, instead of widening the bars.

using:

        group_by:
          func: max
          duration: 60m

      - entity: sensor.netto_verbruik
        yaxis_id: power
        transform: return x /1000;
        unit: kW
        type: line
        name: Verbruik
#         stroke_width: 1
        extend_to: now
        color: red
        group_by:
          func: max
#           duration: 20m

seems to be the closest I can get:

and that is also the result of:

        type: column
        show:
          extremas: true
        opacity: 0.8
#         float_precision: 2
#         group_by:
#           func: max
#           duration: 60m

      - entity: sensor.netto_verbruik
        yaxis_id: power
        transform: return x /1000;
        unit: kW
        type: line
        name: Verbruik
#         stroke_width: 1
        extend_to: now
        color: red
        group_by:
          func: max
#           duration: 20m
        show:
          legend_value: true

… so, not required to set a group_by on the first series (it is an hourly function after all, so maybe thats expected :wink: )
and only set that on the 2nd series, to align the frequencies

finally, Taking out the experimental color_threshold reveals something interesting:

not sure what that indicates, but at least its of importance to the issue at hand…

and a revisit t that same page does this:

all in all, I do believe this seems to indicate an apexcharts issue. Its rather unreliable.at best

grr. nw I see this

If enabled, it might:

  • display the wrong serie color in the tooltip in some cases (series with datapoints not aligned mostly)
  • display thin columns instead of the standard size
  • completely render apex_config.fill options unusable, and if you do, it will break the card

but, even without the experimental, this is an unreliable config

this says it all

Dec-19-2022 10-20-18

Hi, I have a strange problem with the color threshold function (line should be red above 1 degree C and blue below -1 degree C). Sometimes the temperature line gets a weird look. Currently for example, if i put the span to 20 hours everything works fine but if I do a span of 2 days it gets all messed up:

Is there something obvious I have missed in the code or could there be a problem with my signal?

My code:

type: custom:apexcharts-card
graph_span: 2d
series:
  - entity: sensor.utomhustemperatur
    curve: smooth
    type: line
    stroke_width: 2
    name: Utomhus
    color_threshold:
      - value: 1
        color: '#932037'
      - value: -1
        color: '#104a8e'
  - entity: sensor.kallare_temp
    curve: smooth
    type: line
    color: '#2a694d'
    stroke_width: 2
    name: Källaren
apex_config:
  legend:
    position: top
  yaxis:
    show: true
    title:
      text: °C
    axisBorder:
      show: false
  xaxis:
    show: true
    axisBorder:
      show: false
  grid:
    show: false
experimental:
  color_threshold: true

Thanks in advance!

BR,
Andreas

1 Like

Has anyone experienced that the last hours aren’t shown in the graph? Below the last three hours are missing. If I click the three dotsd → Edit dashboard → Save then it looks perfectly fine. Happens randomly.

type: custom:apexcharts-card
header:
  title: ''
  show: false
  show_states: true
  colorize_states: false
graph_span: 2d
now:
  show: true
  color: orange
  label: nu
span:
  start: day
stacked: true
apex_config:
  forceNiceScale: true
  tooltip:
    enabled: true
    x:
      format: hh:mm
    'y':
      show: true
  label: Now
  grid:
    show: true
    borderColor: '#EDEDED'
    strokeDashArray: 3
    position: back
  xaxis:
    tooltip:
      enabled: false
    axisBorder:
      show: false
    labels:
      style:
        fontSize: 10px
        fontFamily: Segoe UI Light
  chart:
    height: 225
  legend:
    show: false
  dataLabels:
    enabled: false
  stroke:
    width: 0
  fill:
    type: gradient
    gradient:
      type: vertical
      shadeIntensity: 0
      inverseColors: false
      opacityFrom: 0.9
      opacityTo: 0.7
      stops:
        - 10
yaxis:
  - min: 0
    max: ~5
    apex_config:
      forceNiceScale: true
      decimalsInFloat: 1
      labels:
        style:
          fontSize: 10px
          fontFamily: Segoe UI Light
series:
  - entity: sensor.nordpool_kwh_se3_sek_2_10_025
    name: Elpris exkl påslag
    time_delta: +0m
    type: column
    color: 3ca358
    float_precision: 2
    unit: kr/kWh
    extend_to: now
    data_generator: |
      return (entity.attributes.raw_today.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"]];
      })).concat(entity.attributes.raw_tomorrow.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"]];
      }));
  - entity: sensor.nordpool_kwh_se3_sek_2_10_025
    name: Påslag
    time_delta: +0m
    type: column
    color: rgb(230, 230, 230)
    float_precision: 2
    unit: kr/kWh
    extend_to: now
    data_generator: |
      return (entity.attributes.raw_today.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_today[index]["value"] - entity.attributes.raw_today[index]["value"] + 0.0862*1.25 + 0.2425 + 0.45];
      })).concat(entity.attributes.raw_tomorrow.map((start, index) => {
        return [new Date(start["start"]).getTime(), entity.attributes.raw_tomorrow[index]["value"] - entity.attributes.raw_tomorrow[index]["value"] + 0.0862*1.25 + 0.2425 + 0.45];
      }));
style: |
  ha-card {
     --ha-card-background: rgba(0, 0, 0, 0);
     box-shadow: none;
     margin: -30px 12px 0px 8px;
     font-size: 15px;
     font-family: 'Segoe UI Light";
     text-align: center
   }
  div#header__title {
    font-size: 20px;
    font-weight: 300;
    font-family: 'Segoe UI Light";
    font-color: #ff0000
  }

1 Like

I have the same issue and spent most of last night trying to fix it to no avail. When using extend_to: now, when the hour changes columns disappear and then get progressively thicker as time goes by until we get to the next hour, then they disappear again on the top of the hour.

If I set columnWidth to 90%, it seems they really are 90% only just before the hour changes, like for example at 03:58. At 04:00 the columns disappear again.

However, extend_to: false fixes that issue. The line doesn’t extend all the way, but it’s close.

right! so its a different issue altogether indeed. thanks!

is ofc much better, although the flat liner after now is really ugly… maybe there’s a hidden setting somewhere to fix that too :wink:

Lastly: the legend show Price this our is not correct as you can clearly see. Not sure why it defaults to the 0.2 continuously. Unless it is truncated/rounded somehow

edit

didnt read your post closely enough, sorry for that. extend_to: false indeed fixes that flatliner

setting the float precision reveals what’s happening, instead of showing the current (now), it is showing the last value in the data:

Here is the code for the screenshot below as requested. You will have to replace my sensors with your own. And, also, you need to have mushroom, stack-in-card etc. installed.

type: custom:stack-in-card
mode: vertical
cards:
  - type: custom:stack-in-card
    mode: horizontal
    style: |
      ha-card  {
        margin: 0px -6px -25px -10px  !important;
        box-shadow: 0px 0px;
          }
    cards:
      - type: gauge
        entity: sensor.sek_kwh
        needle: true
        segments:
          - from: 0
            color: rgb(0,180,0)
          - from: 3
            color: rgb(200,140,0)
          - from: 5
            color: rgb(180,0,0)
          - from: 7
            color: rgb(255,0,0)
        max: 10
        min: 1
        unit: kr
        name: Timpris
      - type: gauge
        entity: sensor.total_power_heltal
        name: Näteffekt
        needle: true
        segments:
          - from: 0
            color: rgb(0,180,0)
          - from: 3000
            color: rgb(200,140,0)
          - from: 5000
            color: rgb(180,0,0)
          - from: 7000
            color: rgb(255,0,0)
        min: 0
        max: 10000
      - type: gauge
        entity: sensor.energy_d_heltal
        name: Förbrukat idag
        needle: true
        segments:
          - from: 0
            color: rgb(0,180,0)
          - from: 60
            color: rgb(200,140,0)
          - from: 90
            color: rgb(180,0,0)
          - from: 120
            color: rgb(255,0,0)
        min: 0
        max: 150
        unit: kWh
  - type: custom:apexcharts-card
    config_templates: grid_chart
    stacked: true
    experimental:
      color_threshold: true
    header:
      show: true
      show_states: false
    graph_span: 48h
    span:
      start: day
    now:
      show: true
      color: rgb(220,150,0)
    series:
      - entity: sensor.nordpool_kwh_se3_sek_3_08_025
        yaxis_id: first
        time_delta: +30m
        name: Timpris el
        color: rgb(180,120,0)
        data_generator: >
          var output =
          entity.attributes.raw_today.concat(entity.attributes.raw_tomorrow);
          return output.map((entry) => { return [new Date(entry.start),
          entry.value]});
        type: column
        stroke_width: 0
        show:
          legend_value: false
          in_header: false
          in_chart: true
        color_threshold:
          - value: 0
            color: '#009500'
            opacity: 1
          - value: 2
            color: rgb(200,140,0)
          - value: 4
            color: rgb(180,0,0)
          - value: 6
            color: rgb(255,0,0)
      - entity: sensor.nordpool_kwh_se3_sek_3_08_025
        yaxis_id: first
        time_delta: +30m
        name: Fasta avgifter
        data_generator: >
          var output =
          entity.attributes.raw_today.concat(entity.attributes.raw_tomorrow);
          return output.map((entry) => { return [new Date(entry.start),
          entry.value - entry.value + 0.0175 + 0.305 + 0.45]});
        color: rgb(85,75,55)
        type: column
        stroke_width: 0
        group_by:
          func: max
          duration: 1h
        show:
          legend_value: false
          in_header: false
          in_chart: true
      - entity: sensor.energy_h
        curve: stepline
        yaxis_id: second
        color: '#CF7524'
        name: Förbrukning
        type: line
        stroke_width: 2
        extend_to: false
        group_by:
          func: max
          duration: 1h
    yaxis:
      - id: first
        min: 0
        max: 9
        apex_config:
          decimalsInFloat: 0
          forceNiceScale: true
          labels:
            style:
              fontSize: 9px
              fontWeight: normal
              colors: rgb(170,170,170)
            formatter: |
              EVAL:v => `${v.toFixed(0)} kr`
      - id: second
        min: 0
        max: 8
        opposite: true
        show: true
        apex_config:
          decimalsInFloat: 0
          forceNiceScale: true
          labels:
            style:
              fontSize: 9px
              fontWeight: normal
              colors: rgb(215,170,40)
            formatter: |
              EVAL:v => `${v.toFixed(0)} kWh`
          fill:
            type: gradient
            gradient:
              shadeIntensity: 0.5
              inverseColors: true
              opacityFrom: 0.4
              opacityTo: 0
              stops:
                - 2
    apex_config:
      legend:
        show: false
      plotOptions:
        bar:
          columnWidth: 90%
      chart:
        type: area
        height: 180
        offsetY: -10
        parentHeightOffset: -5
      xaxis:
        axisBorder:
          show: false
        axisTicks:
          show: true
        tooltip:
          enabled: false
        tickPlacement: between
        crosshairs:
          show: true
        labels:
          style:
            fontSize: 11px
            fontWeight: 1400
          offsetX: -1
  - type: custom:mushroom-chips-card
    chips:
      - type: template
        double_tap_action:
          action: none
        content: 'idag: {{ states.sensor.timpris_avg_idag.state }}'
        tap_action:
          action: none
        hold_action:
          action: none
        style: |
          ha-card  {
            --text-color: rgb(var(--rgb-grey));
            margin: -18px 0px -2px 3px  !important;
            box-shadow: 0px 0px;
              }
      - type: template
        double_tap_action:
          action: none
        content: 'imorgon: {{ states.sensor.timpris_avg_imorgon.state }}'
        tap_action:
          action: none
        hold_action:
          action: none
        style: |
          ha-card  {
            --text-color: rgb(var(--rgb-blue-grey));
            margin: -18px 0px -2px -10px  !important;
            box-shadow: 0px 0px;
              }
      - type: template
        entity: sensor.electricity_cheapest_hours
        icon: mdi:flash
        icon_color: green
        content: |-

          {{ states("sensor.electricity_cheapest_hours") }}
        card_mod:
          style: |
            ha-card {
            --text-color: rgb(var(--rgb-green));
            margin: -18px 0px -2px -10px  !important;
            box-shadow: 0px 0px;
            }
            .content {
              white-space: pre-wrap;
            }
      - type: template
        entity: sensor.electricity_cheapest_hours
        icon: mdi:flash
        icon_color: red
        content: |-

          {{ states("sensor.electricity_expensive_hours") }}
        card_mod:
          style: |
            ha-card {
            --text-color: rgb(var(--rgb-red));
            margin: -18px 0px -2px -10px  !important;
            box-shadow: 0px 0px;
            }
            .content {
              white-space: pre-wrap;
            }
  - type: custom:stack-in-card
    mode: horizontal
    style: |
      ha-card  {
        margin: 0px 0px 0px 0px !important;
        box-shadow: 0px 0px;
          }
    cards:
      - type: custom:apexcharts-card
        config_templates: grid_chart
        experimental:
          color_threshold: true
        header:
          show: false
          show_states: false
        graph_span: 12h
        span:
          end: hour
        series:
          - entity: sensor.sek_kwh_spent_h
            yaxis_id: first
            name: Denna timme
            type: column
            group_by:
              func: max
              duration: 1h
            show:
              datalabels: true
              legend_value: false
              in_header: false
              in_chart: true
            color: '#c0c0c0'
            color_threshold:
              - value: 0
                color: green
                opacity: 1
              - value: 7.49
                color: rgb(200,140,0)
              - value: 14.49
                color: rgb(170,0,0)
              - value: 24.49
                color: rgb(255,0,0)
        yaxis:
          - id: first
            show: false
            min: 0
            max: 60
        apex_config:
          legend:
            show: false
          grid:
            show: false
          xaxis:
            axisBorder:
              show: false
            axisTicks:
              show: false
            tooltip:
              enabled: false
            tickPlacement: between
            crosshairs:
              show: false
            labels:
              style:
                fontSize: 9px
              format: HH
              hideOverlappingLabels: false
          plotOptions:
            bar:
              columnWidth: 90%
          dataLabels:
            offsetY: -7
            background:
              opacity: 0.001
              enabled: true
              foreColor: rgb(110,110,110)
              borderRadius: 0
              borderWidth: 0
            style:
              fontSize: 8px
              color: rgb(210,210,210)
              fontWeight: 600
            formatter: |
              EVAL:v => `${v.toFixed(0)}`
          chart:
            height: 110
            offsetY: -20
            parentHeightOffset: -10
      - type: custom:apexcharts-card
        config_templates: grid_chart
        experimental:
          color_threshold: true
        header:
          show: false
          show_states: false
          colorize_states: true
        graph_span: 8d
        span:
          end: day
        series:
          - entity: sensor.sek_kwh_spent_d
            yaxis_id: first
            type: column
            group_by:
              func: max
              duration: 1d
            show:
              datalabels: true
              legend_value: false
              in_header: false
              in_chart: true
            color: '#c0c0c0'
            color_threshold:
              - value: 0
                color: green
                opacity: 1
              - value: 7.49
                color: rgb(200,140,0)
              - value: 14.49
                color: rgb(170,0,0)
              - value: 24.49
                color: rgb(255,0,0)
        yaxis:
          - id: first
            show: false
            min: 0
            max: '|+200|'
        apex_config:
          xaxis:
            axisBorder:
              show: false
            axisTicks:
              show: false
            tooltip:
              enabled: false
            tickPlacement: between
            crosshairs:
              show: false
            labels:
              style:
                fontSize: 9px
              datetimeFormatter:
                day: D
              format: ddd
              hideOverlappingLabels: false
          legend:
            show: false
          grid:
            show: false
          plotOptions:
            bar:
              columnWidth: 94%
          dataLabels:
            offsetY: -7
            background:
              opacity: 0.001
              enabled: true
              foreColor: rgb(110,110,110)
              borderRadius: 0
              borderWidth: 0
            style:
              fontSize: 8px
              color: rgb(210,210,210)
              fontWeight: 600
            formatter: |
              EVAL:v => `${v.toFixed(0)}`
          chart:
            height: 110
            offsetY: -20
            parentHeightOffset: -10
  - type: custom:stack-in-card
    mode: vertical
    style: |
      ha-card  {
        margin: -30px 0px 0px 0px !important;
        box-shadow: 0px 0px;
          }
    cards:
      - type: custom:apexcharts-card
        config_templates: grid_chart
        header:
          show: false
          show_states: false
        graph_span: 10h
        span:
          end: hour
        series:
          - entity: sensor.energy_h
            color: '#CF7524'
            yaxis_id: first
            name: Förbrukning
            type: column
            group_by:
              func: max
              duration: 1h
              start_with_last: false
            show:
              datalabels: true
              legend_value: true
              in_chart: true
          - entity: sensor.average_inside_temperature_current
            yaxis_id: second
            name: Inomhus
            type: line
            stroke_width: 1.2
            color: rgb(220,80,80)
            group_by:
              func: avg
              duration: 1h
          - entity: sensor.temperature_2
            yaxis_id: third
            name: Utomhus
            type: line
            stroke_width: 1.2
            color: rgb(80,150,230)
            group_by:
              func: avg
              duration: 1h
        yaxis:
          - id: first
            min: 0
            max: 10
            apex_config:
              tickAmount: 7
              decimalsInFloat: 0
              forceNiceScale: true
              labels:
                style:
                  fontSize: 9px
                  fontWeight: normal
                  colors: '#CF7524'
          - id: second
            min: '|-0.5|'
            max: '|+0.5|'
            opposite: true
            apex_config:
              decimalsInFloat: 0
              forceNiceScale: true
              labels:
                style:
                  fontSize: 9px
                  fontWeight: normal
                  colors: rgb(220,80,80)
          - id: third
            min: '|-1|'
            max: '|+6|'
            opposite: true
            apex_config:
              decimalsInFloat: 0
              forceNiceScale: true
              labels:
                style:
                  fontSize: 9px
                  fontWeight: normal
                  colors: rgb(80,150,230)
        apex_config:
          legend:
            show: true
          grid:
            show: false
          plotOptions:
            area:
              fillTo: origin
          chart:
            height: 160
            offsetY: -10
            parentHeightOffset: -10
          dataLabels:
            offsetY: -8
            background:
              opacity: 0.01
              enabled: true
              foreColor: '#CF7524'
              padding: 2
              borderRadius: 4
              borderWidth: 0
            style:
              fontSize: 10px
              color: rgb(200,200,200)
            formatter: |
              EVAL:function(value) {
                let v = value.toFixed(1) + "";
                return v.replace('.',',');
              }
          tooltip:
            enabled: true
          xaxis:
            axisBorder:
              show: false
            axisTicks:
              show: true
            tooltip:
              enabled: false
            tickPlacement: between
            crosshairs:
              show: false
            labels:
              style:
                fontSize: 9px
              datetimeFormatter:
                day: HH
              format: H:mm
              hideOverlappingLabels: false
2 Likes

I really like Apex Chars, it’ve been using it for pretty much all my graphing and visualization. I thought folks might like this visualization of HVAC set points, temp, and mode that use some of the cool features.

It uses the second y-axis to create the stripes that show heating or cooling active. It does this by using transform: 'return x === ''heating'' ? 1 : 0;' to change the state into a 1 or 0, and showing it as an area on the second y-axis which is scaled 0 … 1.

type: custom:apexcharts-card
graph_span: 24h
update_interval: 1min
apex_config:
  chart:
    height: 200px
  grid:
    show: false
  xaxis:
    axisBorder:
      show: false
    axisTicks:
      show: false
experimental:
  color_threshold: true
header:
  show: true
  show_states: true
  colorize_states: true
  title: Heating / Cooling
series:
  - entity: sensor.hvac_current_temperature
    color: orange
    opacity: 1
    stroke_width: 4
    transform: 'return x < 0 ? null : x;'
    name: Hall
    type: line
    show:
      legend_value: false
    fill_raw: last
    yaxis_id: Temperature
  - entity: sensor.cooling_setpoint
    color: rgb(66,133,244)
    stroke_width: 2
    opacity: 1
    name: Cool Set
    type: line
    show:
      legend_value: false
    fill_raw: last
    curve: stepline
    yaxis_id: Temperature
  - entity: sensor.heating_setpoint
    color: rgb(219,68,55)
    opacity: 1
    stroke_width: 2
    name: Heat Set
    type: line
    show:
      legend_value: false
    fill_raw: last
    curve: stepline
    yaxis_id: Temperature
  - entity: sensor.hvac_state
    transform: 'return x === ''cooling'' ? 1 : 0;'
    color: '#add8e6'
    opacity: 0.5
    stroke_width: 0
    name: Cooling
    type: area
    show:
      legend_value: false
      in_header: false
    fill_raw: last
    curve: stepline
    yaxis_id: State
  - entity: sensor.hvac_state
    transform: 'return x === ''heating'' ? 1 : 0;'
    color: orange
    opacity: 0.3
    stroke_width: 0
    name: Heating
    type: area
    show:
      legend_value: false
      in_header: false
    fill_raw: last
    curve: stepline
    yaxis_id: State
yaxis:
  - id: Temperature
    show: true
    min: ~65
    max: ~75
    align_to: 5
    decimals: 0
  - id: State
    show: false


When I use the card in Browser mod, the text ends up next to the boxes.

Is there any solution to that?

Thanks, works perfect :slight_smile:

Can anyone help me?