ApexCharts card - A highly customizable graph card

Hey, how do I change the Y axis minimum span? I have a temperature sensor
and I want to the graph to show at least 10 degrees on the Y axis. Right now it shows movement all over the place even though its only in the 0.1 range.

I would like to achieve and effect similar to this:

1 Like

Looking really good, would you like to share the code of your graphs?

Sure!
Here is the code for graph template:

apexcharts_card_templates:
  bandwidth_chart:
    update_interval: 5s
    show:
      loading: false
    apex_config:
      yaxis:
        forceNiceScale: true
        tickAmount: 12
      xaxis:
        type: datetime
        axisBorder:
          show: false
        labels:
          format: 'HH:mm'
        tickAmount: 5
      stroke:
        width: 2
      chart:
        height: 150
      fill:
        type: solid
      plotOptions:
        bar:
          columnWidth: 80%
        stacked: true
      header:
        show: false
      grid:
        show: true
        borderColor: '#222222'
        strokeDashArray: 0
        position: front
      legend:
        show: false
      options:
        type: bar
        stacked: true
    graph_span: 4min
    stacked: true
    all_series_config:
      type: column
      unit: Mb/s

And here for actual card:

type: 'custom:apexcharts-card'
config_templates: bandwidth_chart
y_axis_precision: 0
series:
  - entity: sensor.internet_speed_in1
    color: var(--green1)
    name: IN
    type: column
  - entity: sensor.internet_speed_in2
    color: var(--green3)
    invert: true
    name: IN
    type: column
1 Like

how can I use an entity state instead of a fixed value in max of a radialBar card?

image

You should try with config-template-card.

2 Likes

So to follow up… new frontend with 2021.4.0b0 and it’s fixed…

Good news! Waiting impatiently for coming Wednesday to apply I’m not in beta channel)! Hope this will resolve also issue with my sensor for LTE bandwith :slight_smile:

1 Like

It’s unrelated to the frontend. It’s probably a bug in ApexCharts.
But the way it is displayed: you have 3 intervals between min and max, so if (max - min) / 3 doesn’t generate a round number, you’ll get decimals in the yaxis

But I never configured it like that. I posted the full card config above.

Love this card
I got dsmrreader running which is giving me monthly usage of gas and elec.
Im trying to put this in a graph but it gives wrong results
i think it has to do with the days/duration i mentioned, should i get rid of it?
Herese how it looks now

The code is

type: 'custom:apexcharts-card'
            graph_span: 365d
            update_interval: 1hour
            cache: true
            span:
              end: month
            header:
              show: false
            apex_config:
              xaxis:
                labels:
                  format: MM
                  show: true
                  showAlways: true
              yaxis:
                forceNiceScale: false
                decimalsInFloat: 0
              chart:
                type: area
                height: 300
              stroke:
                show: true
                width: 1
              legend:
                show: true
              dataLabels:
                enabled: false
                distributed: true
              fill:
                type: gradient
                gradient:
                  shadeIntensity: 0.1
                  opacityFrom: 0.25
                  opacityTo: 1
                  inverseColors: true
                  stops:
                    - 0
                    - 90
                    - 100
            series:
              - entity: sensor.stroom_dagtarief_per_maand
                type: column
                name: Stroom dagtarief
                float_precision: 2
                group_by:
                  func: max
                  duration: 31d
              - entity: sensor.stroom_nachttarief_per_maand
                name: Stroom nachttarief
                float_precision: 2
                type: column
                group_by:
                  func: max
                  duration: 31d
              - color: 'rgb(128,128,128)'
                entity: sensor.gas_per_maand
                type: column
                name: Gas
                float_precision: 2
                group_by:
                  func: max
                  duration: 31d
             

That looks very beautiful, how to do activate these numbers? Would you mind sharing this with me?

And set the data labels to True

Looks amazing, could you share the code please?

1 Like

Ah I see what you mean now as I have decimals again…

2021-04-02_10h14_47

I have a card for my gas useage, but if i have low values the y axis is wrong with 2 times the same value, what can be wrong here?

That’s because you have 6 tick lines covering small range of data and/or not enough precision for data labels. Either decrease number of tick lines (to 3) or better, increase number of decimals for y_axis - then you will see something like:

  • 0.00
  • 0.05
  • 0.10
  • 0.15
  • 0.20
  • 0.25

oke thx added y_axis_precision: 3, now it look like:
2021-04-02_12h02_02
Is it possible to have a more logic step in the y-axis, can not find it in the documentation.

Try to add this to your card, this adds ‘low-level’ Apex configuration to the chart. The forceNiceScale is the trick to have more logical steps. Not sure what the entity on the y-axis is but maybe you can add decimalsInFloat and min/max as well and play a bit with those properties.

apex_config:
  yaxis:
    - show: true
      decimalsInFloat: 0
      min: 14
      max: 30
      forceNiceScale: true

Short explanation: yaxis indicates that you will change your axis, this needs an array for every y-axis in the graph, here it is only one but you can define as many as you look. Then, you should set show to true (maybe that can be omitted), indicate the number of decimals in your label (if you want), indicate the range of values (if you want) and set forceNiceScale to true to make it more logical.

I removed y_axis_precision and added:

  yaxis:
    - show: true
      decimalsInFloat: 3
      forceNiceScale: true

but result is the same

Did you add yaxis and the other items to the apex_config or at the same level/indentation as series?

Like:

type: ‘custom:apexcharts-card’
series:
    # all your series
apex_config:
    yaxis:
        - show: true
        - forceNiceScale: true