ApexCharts card - A highly customizable graph card

@tormagj, @NeoID, this feature is available in the latest beta already, you can check the dev documentation for in_header: before_now or in_header: after_now

2 Likes

I’ll need to check that, please open a bug on github

yes:

apex_config:
  legend:
    show: false

Not at the moment, could you please open a feature request?

What you want is extend_to_end: false

That is not possible yet, please open a feature request :slight_smile:

1 Like

THanks for the quick replies. Feature requests done.

One more thing came up. Is it possible to fix the scale for the y-ticks. I can use apex_config.yaxis.tickAmount to set the number of ticks, but I would rather fix the separation (e.g. 25%) and minimum for chart and let the maximum be data dependent.

A much requested feature in HA is easy output of graph images to a notification service like Telegram. Now, with these few lines on the card:

  chart:
    toolbar:
      show: true

Getting a visual in form of .PNG is just two clicks away! I tried to get a url to fetch the .PNG file but I can’t seem to get it. Anyone ideas on getting that .PNG file? An auto local save of the .PNG would also be fine for me.

A lovelace card only runs in your browser. There’s no way to access it from anywhere else or through a URL.
This card won’t help you with what you are trying to achieve unfortunately.

Thanks! My idea was on the legend in the bottom, but I guess it works just as well hiding them and showing in the header. Great stuff.

image

I do however have a problem with the extremas. The funny thing is that if I delete the data_generator field, the extremas are shown as expected, but when I put back the data_generator it disappears again. Could this be a bug, or is it something I am doing wrong?

Code below (reduced to one curve et.c. for clarity, but still produces the problem in my case). I updated to v1.8.0-dev.6.

type: 'custom:apexcharts-card'
graph_span: 2d
span:
  start: day
now:
  show: true
  label: Now
header:
  show: true
  title: Tidewater
  show_states: true
series:
  - entity: sensor.syrevagen_tide_main
    show:
      in_header: before_now
      legend_value: false
      extremas: time
    name: Prediction
    data_generator: |
      return entity.attributes.data.map((entry) => {
        return [new Date(entry.datetime), entry.prediction];
      });

This is wrong, it should be:

    data_generator: |
      return entity.attributes.data.map((entry) => {
        return [new Date(entry.datetime).getTime(), entry.prediction];
      });

With that, the extremas should work, hopefully :slight_smile:

Ahh! You are perfectly right, it works when adding the getTime(). Thank you!

Great card!
Trying to show data from a sensor like this:

data: 
- datetime: '2021-03-02T16:00:00.000Z'
  value: 3420
- datetime: '2021-03-02T17:00:00.000Z'
  value: 2400
- datetime: '2021-03-02T18:00:00.000Z'
  value: 0

This code gives me a working x-axis (dates are correct) and correct units in the legend, but no data points (the chart ist empty) :frowning:

series:
  - entity: sensor.sun_irradiance
    type: line
    data_generator: |
      return entity.attributes.data.map(
      (item) => {     
        return [new Date(item.datetime).getTime(), item.value];
      });

What am I missing?

Show us the complete config of your card.

type: 'custom:apexcharts-card'
graph_span: 7d
span:
  start: hour
header:
  show: true
  title: Irradiance
  show_states: true
  colorize_states: true
series:
  - entity: sensor.sun_irradiance
    type: line
    data_generator: |
      return entity.attributes.data.map(
      (item) => {     
        return [new Date(item.datetime).getTime(), item.value];
      });


I don’t see anything wrong with that config. Do you mind sharing the complete state of your entity?

would it be too much to ask to give me basic setup for this, I have no idea how to begin to build this…

using:

  - type: custom:apexcharts-card
    graph_span: 7d
    series:
      - entity: sensor.wind_bft

results in an error btw:

Schermafbeelding 2021-03-03 om 11.53.41

besides never showing any graphthat was a user error, had not enabled recorder on the entity. Maybe it should have said so, like the core cards: ‘No state history found’ ?

have a look at the x-axis legend…

small progress in the default card config:

  - type: custom:apexcharts-card
    graph_span: 5d
    span:
      end: day
    y_axis_precision: 1
    update_interval: 15min
    now:
      show: true
    header:
      show: true
      title: Windkracht
      show_states: true
    series:
      - entity: sensor.wind_bft
        stroke_width: 2
    apex_config:
      y-axis:
        max: 12
      dataLabels:
        enabled: true

now, for starters, how will the Y-axis show the number 0-12, and not all decimals out now shows?

Hi,
Thanks for the great card!
Here my card to compare the temperature for 3 days.
The problem is that on the header and in the legend the values for d-1 and d-2 are those for the end of the day (23:59) and not at the same time as the today’s one.
Is it possible to change that? I didn’t found how.
Other thing is that today’s graph shows the line from now on until the end of the day. How to remove it?
Thanks in advance for the help.
image

graph_span: 1d
span:
  start: day
header:
  show: true
  title: Temperature Ext. sur 3 jours
  show_states: true
  colorize_states: true
series:
  - entity: sensor.0x158d000678e709_temperature
    name: Aujourd'hui
  - entity: sensor.0x158d000678e709_temperature
    offset: '-1d'
    name: Hier
  - entity: sensor.0x158d000678e709_temperature
    offset: '-2d'
    name: Avant-hier
now:
  show: true
  color: '#ff0000'
  label: Now

I can’t help you with your main question. I am wondering about the same myself.
Regarding today continuing to the end of the graph you could modify your entity as following:

  - entity: sensor.0x158d000678e709_temperature
    name: Aujourd'hui   
    extend_to_end: false

@ThoStaKa, @akunia, this feature is available in the latest beta: ApexCharts card - A highly customizable graph card

Been trying to create a 7 day graph of my power production and consumption. I now have a problem with my consumption graph. I use the following:

-  type: custom:apexcharts-card
       graph_span: 7d1s
       span:
         end: day
       header:
         show: true
         title: Production\Consumption of Power in kWh
       apex_config:
         chart:
           type: area
           height: 250
         stroke:
           show: true
           width: 1
           curve: smooth
         legend:
           show: true
         fill:
           type: gradient
           gradient:
             shadeIntensity: 0.1
             opacityFrom: 0.25
             opacityTo: 1
             inverseColors: true
             stops:
               - 0
               - 90
               - 100
       series:
         - color: 'rgb(0,235,78)'
           entity: sensor.production_today
           type: column
           group_by:
             func: max
             duration: 24h
         - color: 'rgb(235,168,0)'
           entity: sensor.consumption_today
           type: column
           group_by:
             func: max
             duration: 24h

The problem I have is with the consumption part. The sensor.consumption_today just counts the total consumption that day and resets at midnight. When I put in the option under group_by and then duration: 24h, it will take the consumption from the last 24 hours and not the consumption from midnight, so my numbers are higher than they really are. Any idea what I need to do to have the correct numbers from midnight to midnight?

That makes group_by work from midnight to 23:59:59.999, you already have it.
Don’t use graph_span: 7d1s but just graph_span: 7d.

Unless your server is not using the right timezone, I can’t see why this would be happening.

Great, thank you @ThoStaKa :+1: