Skip to content

Chart Card

custom:lcards-chart

Data visualization using ApexCharts. Plots entity history, real-time sensor data, and processed data source buffers as line, area, bar, pie, and many other chart types.


Quick Start

yaml
# Line chart from a single entity
type: custom:lcards-chart
source: sensor.temperature
chart_type: line
yaml
# Area chart with two sensors
type: custom:lcards-chart
sources:
  - sensor.temperature
  - sensor.humidity
chart_type: area
series_names: [Temperature, Humidity]

Common Properties

The following properties are shared across all LCARdS cards. See Common Card Properties for full details.

CategoryConfig keysReference
Sizingheight, width, min_height, min_width, max_height, max_widthSizing
Overflowoverflow, overflow_x, overflow_yOverflow
Stackingz_indexStacking
Identityid, tagsID & Tags
HA Gridgrid_optionsHA Grid Sizing
Datadata_sources, triggers_updateData Sources
Actionstap_action, hold_action, double_tap_actionActions
AnimationsanimationsAnimations
Rulesvia id / tagsRules Engine

Config Structure

Annotated map of all top-level keys.

yaml
type: custom:lcards-chart

# ── Data source(s) ────────────────────────────────────────────────────────────────
source: sensor.temperature       # simple single-entity mode
attribute: current_temperature   # entity attribute to track (with source)
sources:                         # multi-entity mode
  - sensor.temperature
  - sensor.humidity
data_sources:                    # named data source definitions (for history / processing)
  climate:
    entity: sensor.temperature
    history:
      hours: 24

# ── Chart type & axes ───────────────────────────────────────────────────────────
chart_type: line               # line | area | bar | column | scatter | pie | donut | ...
xaxis_type: datetime           # datetime | category | numeric
series_names: [Temperature, Humidity]
max_points: 0                  # max history points to render (0 = unlimited)

# ── Appearance ─────────────────────────────────────────────────────────────────
style:
  colors:
    series:
      - "var(--lcars-orange)"
  stroke:
    curve: smooth
    width: 2
  legend:
    show: true
  animation:
    preset: lcars_standard

# ── Layout ─────────────────────────────────────────────────────────────────────
height: 200
width: 400
min_height: 100
max_height: 400
overflow: hidden
z_index: 0
grid_options:
  columns: 6
  rows: 4
id: my-chart
tags: [charts]
triggers_update: []

Card Options

OptionTypeDefaultDescription
typestringcustom:lcards-chart (required)
sourcestringSingle entity ID (simple mode)
attributestringEntity attribute to track (with source)
sourceslistMultiple entities or data source references
data_sourcesobjectNamed data source definitions — see Data Sources
chart_typestringlineChart type — see Chart Types
series_nameslistDisplay names for each series (matches sources order)
xaxis_typestringdatetimeX-axis scale: datetime, category, or numeric
max_pointsnumber0Maximum history points to render; 0 = unlimited
show_legendbooleanfalseDeprecated — use style.legend.show instead
styleobjectAll chart appearance config — see style Object

Chart Types

TypeDescription
lineLine chart
areaArea chart (filled under line)
barHorizontal bar chart
columnVertical column chart
scatterScatter plot
piePie chart
donutDonut chart
heatmapHeatmap
radialBarRadial gauge
radarRadar/spider chart
candlestickOHLC candlestick
rangeBarRange bar (for time spans)
rangeAreaRange area (shaded band between two values)
polarAreaPolar area chart
treemapTreemap chart
boxPlotBox plot

Note: candlestick, rangeBar, rangeArea, polarArea, treemap, and boxPlot require datasource data in the ApexCharts-specific format for those types (e.g. OHLC arrays for candlestick). They are advanced chart types — refer to the ApexCharts documentation for data format details.


Data Sources

Three levels of data configuration:

Level 1: Simple entity

yaml
source: sensor.temperature

Auto-creates a data source with 6 hours of history.

Level 2: Multiple entities

yaml
sources:
  - sensor.temperature
  - sensor.humidity
series_names: [Temperature, Humidity]

Level 3: Named Data Sources with processing

yaml
data_sources:
  temp:
    entity: sensor.temperature
    history:
      hours: 24
    processing:
      smoothed:
        type: smooth
        method: exponential
        alpha: 0.3

sources:
  - datasource: temp
    buffer: main          # Raw history
    name: Raw
  - datasource: temp
    buffer: smoothed      # Smoothed values
    name: Smoothed

See Data Sources for full processing options.


style Object

All chart appearance configuration lives under style. Colour values accept all formats supported by Coloursvar(--lcars-*), {theme:...}, hex, and rgba.

style.colors

Controls colours for every visual element. All sub-keys are optional.

FieldTypeDescription
style.colors.serieslistSeries fill/line colours — cycles through array
style.colors.strokelistSeries stroke/outline colours — cycles through array
style.colors.filllistArea fill colours — cycles through array
style.colors.backgroundstringChart background colour
style.colors.foregroundstringDefault text and label colour
style.colors.gridstringGrid line colour
style.colors.marker.filllistData point fill colours — defaults to series colours
style.colors.marker.strokelistData point stroke colours
style.colors.axis.xstringX-axis label colour
style.colors.axis.ystringY-axis label colour
style.colors.axis.borderstringAxis border line colour
style.colors.axis.ticksstringAxis tick mark colour
style.colors.legend.defaultstringLegend text colour
style.colors.legend.itemslistPer-series legend item colours
style.colors.data_labelslistData label colours
yaml
style:
  colors:
    series:
      - "var(--lcars-orange)"
      - "var(--lcars-blue-light)"
    background: "transparent"
    foreground: "var(--lcars-moonlight)"
    grid: "var(--lcars-gray)"

style.stroke

FieldTypeDefaultDescription
style.stroke.widthnumber2Line/border stroke width in px
style.stroke.curvestringsmoothsmooth, straight, stepline, monotoneCubic
style.stroke.dash_arraynumber0Dash gap length; 0 = solid line

style.fill

FieldTypeDefaultDescription
style.fill.typestringsolidsolid, gradient, pattern, image
style.fill.opacitynumber0.7Fill opacity
style.fill.gradient.shadestringlight or dark
style.fill.gradient.typestringhorizontal, vertical, diagonal1, diagonal2
style.fill.gradient.shadeIntensitynumberShade intensity
style.fill.gradient.opacityFromnumberGradient start opacity
style.fill.gradient.opacityTonumberGradient end opacity
yaml
style:
  fill:
    type: gradient
    gradient:
      opacityFrom: 0.5
      opacityTo: 0.05

style.markers

FieldTypeDefaultDescription
style.markers.sizenumber4Marker size in px; 0 = hidden
style.markers.shapestringcirclecircle, square, rect, rhombus
style.markers.stroke.widthnumber2Marker stroke width in px

style.grid

FieldTypeDefaultDescription
style.grid.showbooleantrueShow/hide grid lines
style.grid.opacitynumber0.3Grid line opacity
style.grid.stroke_dash_arraynumber4Grid line dash gap
style.grid.row_colorslistAlternating row background colours
style.grid.column_colorslistAlternating column background colours

style.legend

FieldTypeDefaultDescription
style.legend.showbooleanfalseShow/hide legend
style.legend.positionstringbottomtop, bottom, left, right
style.legend.horizontalAlignstringcenterleft, center, right
style.legend.font_sizenumber14Legend font size in px

style.data_labels

FieldTypeDefaultDescription
style.data_labels.showbooleanfalseShow value labels on data points
style.data_labels.offsetYnumber0Vertical offset in px
style.data_labels.font_sizenumber12Label font size in px

style.xaxis

Controls x-axis display. The x-axis scale type is set by the top-level xaxis_type field, not here.

FieldTypeDefaultDescription
style.xaxis.labels.showbooleantrueShow/hide axis labels
style.xaxis.labels.rotatenumber0Label rotation in degrees
style.xaxis.border.showbooleanfalseShow/hide axis border line
style.xaxis.ticks.showbooleanfalseShow/hide tick marks
yaml
xaxis_type: datetime
style:
  xaxis:
    labels:
      show: true
      rotate: -45

style.yaxis

FieldTypeDefaultDescription
style.yaxis.labels.showbooleantrueShow/hide axis labels
style.yaxis.decimalsnumberRound displayed values to N decimal places (axis labels, tooltips, and data labels)
style.yaxis.border.showbooleanfalseShow/hide axis border line
style.yaxis.ticks.showbooleanfalseShow/hide tick marks

Advanced y-axis config (e.g. min, max, opposite, seriesName for multi-axis charts) can be passed directly to ApexCharts via style.chart_options.


style.display

FieldTypeDefaultDescription
style.display.toolbarbooleanfalseShow ApexCharts toolbar (download/zoom controls)
style.display.tooltip.showbooleantrueShow/hide hover tooltip
style.display.tooltip.themestringdarkdark or light

style.typography

FieldTypeDefaultDescription
style.typography.font_familystring"Antonio, Helvetica Neue, sans-serif"Font family for all chart text
style.typography.font_sizenumber12Base font size in px

style.theme

Controls ApexCharts' built-in theme/palette engine. Takes lower precedence than explicit colour settings.

FieldTypeDefaultDescription
style.theme.modestringdarkdark or light
style.theme.palettestringApexCharts palette name (e.g. palette1-palette10)
style.theme.monochrome.enabledbooleanfalseUse a single-hue monochrome palette
style.theme.monochrome.colorstringBase colour for monochrome palette
style.theme.monochrome.shade_tostringdarkdark or light
style.theme.monochrome.shade_intensitynumber0.65Shade spread

style.formatters

Custom format strings for axis labels and tooltips. These use a lightweight chart-specific syntax — they are not evaluated by the LCARdS template engine.

Axis label format strings (xaxis_label, yaxis_label) work in two modes:

  • Date format (no { in string): formats x-axis timestamps using tokens — HH:mm, MMM DD, YYYY-MM-DD, ddd, etc. Only meaningful for xaxis_label on datetime axes.
  • Value template (contains {value}): replaces {value} with the axis value — e.g. {value}°C, {value}%.

Tooltip format strings (tooltip) support:

  • {x|format} — x value formatted as a date using the given tokens (e.g. {x|MMM DD HH:mm})
  • {x} — x value formatted as a date with the default format (MMM DD HH:mm)
  • {y} — y value
FieldTypeExamples
style.formatters.xaxis_labelstringHH:mm · MMM DD · {value}°C
style.formatters.yaxis_labelstring{value}°C · {value}% · {value} kWh
style.formatters.tooltipstring{x|MMM DD HH:mm}: {y}°C · {x}: {y}

Note: style.formatters.yaxis_label sets a single formatter for all y-axes. For per-axis formatting on multi-axis charts, use style.chart_options (see below) — but be aware that formatter must be a JavaScript function and cannot be expressed in YAML. Use decimalsInFloat in chart_options.yaxis[*] for decimal precision per axis instead.


style.animation

FieldTypeDescription
style.animation.presetstringAnimation preset name — see table below
yaml
style:
  animation:
    preset: lcars_standard
PresetDescription
lcars_standardSmooth LCARS entrance with slight elastic ease
lcars_dramaticLonger, more theatrical entrance
lcars_minimalQuick, subtle fade-in
lcars_realtimeOptimised for frequently updating real-time data
lcars_alertRapid entrance for alert/status displays
noneDisable animation

style.chart_options

Raw ApexCharts options object, merged on top of all other style settings. Use this for advanced ApexCharts configuration that has no LCARdS-level equivalent — such as multi-axis yaxis arrays, plotOptions, annotations, etc.

yaml
style:
  chart_options:
    yaxis:
      - seriesName: Temperature
        min: 15
        max: 30
        decimalsInFloat: 1
      - seriesName: Humidity
        min: 0
        max: 100
        opposite: true
    plotOptions:
      bar:
        borderRadius: 4

Refer to the ApexCharts documentation for all available keys.


Annotated Example

24-hour dual-series chart with named data source, custom colours, dual Y-axes (via style.chart_options), gradient fill, and animation preset:

yaml
type: custom:lcards-chart
xaxis_type: datetime

data_sources:
  climate:
    entity: sensor.living_room_temperature
    history:
      hours: 24
    processing:
      smooth:
        type: smooth
        method: exponential
        alpha: 0.2

sources:
  - datasource: climate
    buffer: main
    name: Temperature
  - sensor.living_room_humidity
series_names: [Temperature, Humidity]

chart_type: area

style:
  colors:
    series:
      - "var(--lcars-orange)"
      - "var(--lcars-blue-light)"

  stroke:
    curve: smooth
    width: 2

  fill:
    type: gradient
    gradient:
      opacityFrom: 0.5
      opacityTo: 0.05

  markers:
    size: 0

  xaxis:
    labels:
      show: true

  legend:
    show: true
    position: bottom

  animation:
    preset: lcars_standard

  chart_options:
    yaxis:
      - seriesName: Temperature
        min: 15
        max: 30
        decimalsInFloat: 1
      - seriesName: Humidity
        min: 0
        max: 100
        opposite: true
        decimalsInFloat: 0