Skip to content

Allow dynamic Y‑axis min/max and tickAmount (templates or functions) #1052

Description

@petr314

Problem

In Home Assistant, the apexcharts-card currently does not allow dynamic values for:

  • yaxis.min
  • yaxis.max
  • apex_config.yaxis.tickAmount

When using templates such as:

max: "{{ states('sensor.max_cena_elektriny_dnes') | float }}"

…the card throws:

Bad yaxis min/max format

Even when the template sensor exists and returns a valid number.

When using native ApexCharts functions such as:

max: |
function (max) { return Math.ceil(max); }

…the function is ignored.

The card also rejects stepSize as “extraneous”, even though ApexCharts supports it.

Why this matters

For sensors with variable ranges (e.g., electricity spot prices), the Y-axis becomes unreadable:

  • 0.81
  • 1.62
  • 2.43

Instead of clean values like:

  • 0
  • 1
  • 2
  • 3

Without dynamic min/max or tickAmount, charts cannot adapt to real-world data.

Feature request

Please allow one of the following:

  1. Support for templates in yaxis.min, yaxis.max, and tickAmount
  2. Support for ApexCharts native functions in these fields
  3. Support for stepSize
  4. Or any mechanism to allow dynamic scaling of the Y-axis

This would greatly improve readability and usability of charts in Home Assistant.

Thanks for considering this improvement!

Additional context

Here is a screenshot showing the issue with the Y‑axis scaling:

Image

Here is the English version of the chart configuration used for the screenshot:

type: custom:apexcharts-card
header:
  show: true
  title: Electricity Prices – Final vs. Buyback
graph_span: 24h
span:
  start: hour
now:
  show: true
  label: Now
yaxis:
  - id: prices
    decimals: 2
    min: ~0
series:
  - entity: sensor.finalni_cena_elektriny
    name: Final Price
    type: line
    stroke_width: 2
    color: "#ff9800"
    yaxis_id: prices

  - entity: sensor.vykupni_cena_elektriny
    name: Buyback Price
    type: line
    stroke_width: 2
    color: "#4caf50"
    yaxis_id: prices

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions