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]

Top-Level 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
heightstring/numberCard height — see Sizing
widthstring/numberCard width — see Sizing
min_heightstring/numberMinimum card height — see Sizing
min_widthstring/numberMinimum card width — see Sizing
idstringCard ID for rule targeting — see Rules Engine
tagslistTags for rule targeting — see Rules Engine
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.decimalsnumberDecimal places on 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

Template strings evaluated by LCARdS' Template Engine to format axis labels and tooltip values.

FieldTypeDescription
style.formatters.xaxis_labelstringTemplate for x-axis label text
style.formatters.yaxis_labelstringTemplate for y-axis label text
style.formatters.tooltipstringTemplate for tooltip value text

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
        labels:
          formatter: "{value}°C"
      - seriesName: Humidity
        min: 0
        max: 100
        opposite: true
        labels:
          formatter: "{value}%"