ApexCharts card - A highly customizable graph card

Thank you for this wonderful card!

I have five two challenges with this card showing our TV consumption over the past week:

  • The x-axis doesn’t show a label for the first column. This is independent of the data range, so if I only pick 6 days instead of 7, the first column is still without label. Am I doing something wrong or should I report this as a bug?

  • I would like to change the color of the data labels to the normal text color used in the rest of the chart, e.g. for the annotation of the x-axis

  • I would like the data labels to not show hours in decimals, but show hours and minutes like the tooltip data does

  • I would like to change the tooltip data formatting to only show hours and minutes, not seconds.

  • The tooltip somehow seems to be offset. In the example, when I hover over the 3.9h column, it highlights that column but puts a vertical line on the 0.4h column and shows the 21m data from Aug 8 in the tooltip. Something is wrong here.

Any help is appreciated! Here is my configuration (updated):

type: custom:apexcharts-card
graph_span: 1w
span:
  end: day
yaxis:
  - id: tv
    show: false
series:
  - entity: sensor.watched_tv_today
    type: column
    group_by:
      func: max
      duration: 1d
    show:
      as_duration: hour
      datalabels: true
    yaxis_id: tv
apex_config:
  grid:
    show: false
  dataLabels:
    formatter: |
      EVAL:function(value, opts) {
        h = Math.floor(value);
        m = Math.floor((value - h) * 60);
        result = "";
        if (h > 0)
          result = h + "h ";
        if (m > 0)
          result += m + "m";
        return result;
      }
    offsetY: -10
    background:
      enabled: false
    style:
      colors: ['var(--primary-text-color)']
  tooltip:
    enabled: false

New chart with updated config. I’ve disabled the tooltip but this isn’t fixed.

3 Likes

I just learnt that this is a bug of the Apex library itself: First date is missing from graph · Issue #198 · RomRider/apexcharts-card · GitHub

I also just learnt that this is another bug in the underlying library. Too bad: Hovering offset in minimal layout · Issue #147 · RomRider/apexcharts-card · GitHub

Is it possible to dynamically set the tickAmount for the yaxis depending on the data?

Same problem. You solve it?
Thanks

Yup, I used a group_by option to make the datapoints exist at same instances of time:

group_by:
    func: avg
    duration: 1min
    fill: last

form me not working. only one value on tooltip.

Incredible! Works very well - thank you.

1 Like

Another question on your code/implementation. It appears the Apex Charts omits some data compared to the standard history graph. See attached picture. The only thing I see tell visually is that the filled in areas below (when the HVAC action is ‘cooling’) appear thinner on the Apex Charts and maybe that’s why the shorter time-spans are getting cut out? Rounding error or something?

I don’t seem to be able to replicate that unfortunately. Try experimenting with the group_by: settings or remove that section altogether and see how you go.

Is there a way to only show the hours or minutes below the card? Also in the circle itself it shows % instead of hours, any way to change this? Thx

Hey guys, is there a way to overlay a single big number (Say current value of one of the series?). Would want to tinker with transparency etc.

I had a look through the thread but couldn’t spot anything? Ta.

image

1 Like

A little question that should probably be simple but I can’t seem to figure it out – if I have a pie/donut chart with a single entity source using percentage (in this case a battery sensor), how do I get the chart to render so the pie/donut shape reflects that percentage value?

For example, below I have a battery sensor entity with 75%, and the 75% value is displayed correctly in some text places on the chart, but the pie itself always shows a complete 100% chart.

Thanks.

image

I haven’t gone in to how you would actually do this but a pie chart by design will show various values as a percentage of the total. If you only give it one value that value will always be 100% of the total no matter what the absolute reading is. I am assuming that you would have to provide two values eg, amount_full=75, amount_empty=25 or amount_empty=100 - amount_full.

Probably best to ask this on GitHub.

What do you mean? Are you suggesting I should raise a feature request?

I’ve skimmed the documentation a few times and can’t see anything that seems to match?

Dunno if there is a better way but this should work.

type: custom:apexcharts-card
header:
  show: true
  title: ApexCharts-Card
  show_states: true
  colorize_states: true
apex_config:
  plotOptions:
    pie:
      donut:
        total:
          show: true
          showAlways: true
chart_type: pie
series:
  - entity: sensor.esp_humidity_bathroom
    name: fake %full  
  - entity: sensor.esp_humidity_bathroom
    name:  fake  %empty
    transform: "return 100 - x ;"

1 Like

Anyone who knows if it’s possible to make the dashed “Now-line” wider? Have tried with stroke_width but obviously it’s not working.

Probably wouldn’t hurt.

So you can kind of fake it like this.

Can’t figure out how to send the big number to the background or set it’s transparency though.

type: custom:apexcharts-card
graph_span: 48hr
apex_config:
  chart:
    height: 250px
  legend:
    show: false
  grid:
    show: false
  dataLabels:
    enabled: true
    offsetX: -100
    offsetY: 23
    opacity: 0.5
    style:
      fontSize: 180px
      colors:
        - '#7a7a7a'
    background:
      enabled: false
  yaxis:
    - show: true
      decimalsInFloat: 0
      forceNiceScale: true
      min: 0
series:
  - entity: sensor.senseair_co2_value
    color: white
    curve: stepline
    show:
      datalabels: true
    opacity: 0
    name: latest
    group_by:
      func: last
      duration: 48hr
    transform: return x ;
  - entity: sensor.senseair_co2_value
    color: white
    curve: stepline
    show:
      in_header: false
      extremas: true
    stroke_width: 1.5
    opacity: 0.8
    float_precision: 0
    name: CO2
    group_by:
      func: median
      duration: 30min

image

1 Like