Skip to content

Chart Card

custom:lcards-chart

Data visualization using ApexCharts. Plots entity history, real-time sensor data, and processed DataSource 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]

Top-Level Options

OptionTypeDescription
typestringcustom:lcards-chart (required)
sourcestringSingle entity ID (simple mode)
attributestringEntity attribute to track
sourceslistMultiple entities or DataSource references
data_sourcesobjectNamed DataSource definitions — see DataSources
chart_typestringChart type (see table below)
series_nameslistDisplay names for each series
idstringCard ID for rule targeting
tagslistTags for rule targeting
titleobjectChart title config — see below
colorslistArray of series colours
strokeobjectLine stroke options
fillobjectArea fill options
markersobjectData point markers
legendobjectLegend config
gridobjectGrid lines config
xaxisobjectX-axis config — see below
yaxisobject / listY-axis config (list for multiple axes) — see below
tooltipobjectTooltip config
animationobjectChart render animation — see below

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)
polarAreaPolar area chart
treemapTreemap chart
boxPlotBox plot

Note: candlestick, rangeBar, 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 DataSource with 6 hours of history.

Level 2: Multiple entities

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

Level 3: Named DataSources 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 DataSources for full processing options.


title Object

FieldTypeDescription
textstringTitle text
alignstringleft, center, right
style.fontSizestringCSS font size, e.g. "14px"
style.colorstringTitle colour
style.fontFamilystringCSS font family
offsetYnumberVertical offset in px
yaml
title:
  text: "Outdoor Temperature"
  align: left
  style:
    fontSize: "14px"
    color: "var(--lcards-moonlight)"
    fontFamily: "Antonio, sans-serif"

Colours and Styling

yaml
colors:
  - "var(--lcards-blue-light)"
  - "var(--lcards-orange)"
  - "var(--lcards-moonlight)"

stroke:
  curve: smooth          # smooth, straight, stepline, monotoneCubic
  width: 2

fill:
  type: gradient         # solid, gradient, pattern
  gradient:
    shadeIntensity: 0.5
    opacityFrom: 0.6
    opacityTo: 0.1

markers:
  size: 0                # 0 = no markers

Colour values accept all formats supported by Coloursvar(--lcards-*), {theme:...}, hex, and rgba.


xaxis Object

FieldTypeDefaultDescription
typestringcategorydatetime, category, or numeric
labels.showbooleantrueShow/hide axis labels
labels.rotatenumber0Label rotation in degrees
border.showbooleantrueShow/hide axis border line
ticks.showbooleantrueShow/hide tick marks
yaml
xaxis:
  type: datetime
  labels:
    show: true
    rotate: -45

yaxis Object (single)

FieldTypeDescription
minnumberAxis minimum value
maxnumberAxis maximum value
decimalsInFloatnumberDecimal places on labels
labels.showbooleanShow/hide labels
labels.formatterstringLabel format string: "{value}°C"
oppositebooleanPlace axis on the right side
seriesNamestringTie this axis to a series by name

Multiple Y-axes

yaml
yaxis:
  - seriesName: Temperature
    min: -10
    max: 40
    decimalsInFloat: 1
    labels:
      formatter: "{value}°C"
  - seriesName: Humidity
    min: 0
    max: 100
    opposite: true        # Second axis on right side
    labels:
      formatter: "{value}%"

Legend and Tooltip

yaml
legend:
  show: true
  position: bottom       # top, bottom, left, right

tooltip:
  x:
    format: "dd MMM HH:mm"
  y:
    formatter: "{value}°C"

Chart Animation

yaml
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

Annotated Example

24-hour dual-series chart with named DataSource, custom colours, dual Y-axes, gradient fill, and animation preset:

yaml
type: custom:lcards-chart
title:
  text: "Living Room Climate"
  align: left
  style:
    color: "var(--lcards-moonlight)"
    fontSize: "13px"

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

colors:
  - "var(--lcards-orange)"
  - "var(--lcards-blue-light)"

stroke:
  curve: smooth
  width: 2

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

markers:
  size: 0

xaxis:
  type: datetime
  labels:
    show: true

yaxis:
  - seriesName: Temperature
    min: 15
    max: 30
    decimalsInFloat: 1
    labels:
      formatter: "{value}°C"
  - seriesName: Humidity
    min: 0
    max: 100
    opposite: true
    labels:
      formatter: "{value}%"

legend:
  show: true
  position: bottom

animation:
  preset: lcars_standard