Skip to content

Axes and Labels ​

Everything on a chart that reads as text or marks a value: reference lines, the legend, value labels, the axes, formatters, the tooltip and the toolbar. Several Y axes are on Series and Time.

Reference lines ​

style.thresholds draws horizontal lines at fixed values, such as a target, a limit or a comfort band, and style.zero_line draws one at 0. A line with a label names itself on the right.

  • The label is drawn in dark text on a tab of the line's colour.
yaml
type: custom:lcards-chart
sources:
  - entity: sensor.outdoor_temperature
    name: Outside
style:
  zero_line: true
  thresholds:
    - value: 18
      label: Warm
      color: var(--lcars-red)
    - value: 8
      label: Cold
      color: var(--lcars-blue)
      dash: true
More about reference lines
  • The zero line is a thin dashed line at half opacity, labelled "Zero".
  • Per series: reference lines belong to the chart, not to a series; with several Y axes they are measured on the first.
KeyTypeDefaultDescription
style.zero_linebooleanfalseDraw a line at 0
style.zero_line_colorcolourvar(--lcars-gray)The zero line's colour
style.thresholdslist-Lines at fixed values, each with the keys below
style.thresholds[].valuenumberrequiredWhere the line goes, on the Y axis
style.thresholds[].labelstring-Text on the line
style.thresholds[].colorcolourvar(--lcars-red)Line and label colour
style.thresholds[].widthnumber2Line width, px
style.thresholds[].dashbooleanfalseDashed line
style.thresholds[].opacitynumber0.7Line opacity, 0 to 1

style.legend ​

style.legend shows the series names and colours, and sets where they go. It is off on most charts and on for pie, donut, polar area and gauge charts, because there it names the slices.

  • A gauge chart's legend also shows each gauge's value.
yaml
type: custom:lcards-chart
sources:
  - entity: sensor.attic_temperature
    name: Attic
  - entity: sensor.kitchen_temperature
    name: Kitchen
  - entity: sensor.office_temperature
    name: Office
style:
  legend:
    show: true
    position: right
    font_size: 13
KeyTypeDefaultDescription
style.legend.showbooleanfalse (true for pie, donut, polarArea and radialBar)Show the legend
style.legend.positionstringbottom (top on scatter)top, bottom, left or right
style.legend.horizontalAlignstringcenterleft, center or right
style.legend.font_sizenumberfont size + 2 (12 on scatter and polar area)Legend font size, px (8 to 24)

The legend's text colours are style.colors.legend.

style.data_labels ​

style.data_labels writes each value on the chart, on its column or point. It suits a chart with few values, such as a week of daily columns.

yaml
type: custom:lcards-chart
chart_type: column
graph_span: 7d
sources:
  - entity: sensor.outdoor_temperature
    name: Daily high
    statistics:
      type: max
      period: day
style:
  data_labels:
    show: true
    font_size: 11
  yaxis:
    decimals: 0
More about value labels
  • Decimals: style.yaxis.decimals rounds the labels too.
  • Treemaps show their labels (the series names) unless show is false.
  • Colours are style.colors.data_labels.
KeyTypeDefaultDescription
style.data_labels.showbooleanfalseShow value labels
style.data_labels.offsetYnumber0Move the labels down (or up, negative), px (-50 to 50)
style.data_labels.font_sizenumberthe base font sizeLabel font size, px (8 to 24)

style.xaxis and style.yaxis ​

style.xaxis and style.yaxis show or hide each axis's labels, line and tick marks, and style.yaxis.decimals rounds the values. The X axis shows time by default.

  • style.yaxis.decimals rounds the Y axis labels, the tooltip and the value labels together. Without it labels show up to two decimal places.
  • Set xaxis_type: category or xaxis_type: numeric at the top level for other kinds of X values. For several Y axes, use yaxis; style.yaxis styles them all.
yaml
type: custom:lcards-chart
graph_span: 48h
sources:
  - entity: sensor.outdoor_temperature
    name: Outside
style:
  xaxis:
    border:
      show: true
    ticks:
      show: true
  yaxis:
    decimals: 1
    border:
      show: true
More about axes
  • Time labels: the X axis picks its own time format to suit the window. Times show in the time zone and clock (12 or 24 hour) set in your Home Assistant profile, the same zone the time window uses; the tooltip time too. Set your own format with style.formatters.xaxis_label.
  • Rotating labels works on category axes only; time axes don't rotate.
  • Colours are style.colors.axis.
KeyTypeDefaultDescription
style.xaxis.labels.showbooleantrueShow the X axis labels
style.xaxis.labels.rotatenumber0Label rotation, degrees (-90 to 90)
style.xaxis.border.showbooleanfalseShow the X axis line
style.xaxis.ticks.showbooleanfalseShow the X axis tick marks
style.yaxis.labels.showbooleantrueShow the Y axis labels
style.yaxis.decimalsnumberup to 2 placesDecimal places for the labels, the tooltip and value labels (0 to 10)
style.yaxis.border.showbooleanfalseShow the Y axis line
style.yaxis.ticks.showbooleanfalseShow the Y axis tick marks

Formatters ​

style.formatters sets the text of the axis labels and the tooltip with short format strings. They use a small chart-only syntax; they are not LCARdS templates.

  • An X axis format without { is a date format: HH:mm, MMM DD, ddd HH:mm. A Y axis format puts the value into text: {value}°C.
  • A tooltip format replaces the whole tooltip: {seriesName}: {y}, or {x|MMM DD HH:mm}: {y}°C to format the time.
  • Units and decimal places usually need no formatter: set unit and float_precision on the series.
yaml
type: custom:lcards-chart
sources:
  - entity: sensor.outdoor_temperature
    name: Outside
style:
  formatters:
    xaxis_label: ddd HH:mm
    yaxis_label: "{value}°"
    tooltip: "{x|ddd [at] HH:mm}: {y}°C"
More about formatters
  • Date tokens: YYYY, YY, MMMM (October), MMM (Oct), MM, M, dddd (Tuesday), ddd (Tue), DD, D, HH, H, hh, h, mm, m, ss, s, A (PM), a (pm). Month and day names follow your Home Assistant language. Put literal text in square brackets: [at] HH:mm.
  • Time zone: date formats show times in the time zone set in your Home Assistant profile, like the axis.
  • Values: {value} in axis labels; {y}, {x}, {x|format} and {seriesName} in tooltips. {value} and {y} show up to one decimal place, and a plain {x} reads like Oct 07 14:30.
  • Quote a format that starts with {, or YAML reads it as a map.
KeyTypeDefaultDescription
style.formatters.xaxis_labelstringa time format to suit the windowX axis labels: a date format, or text with {value}
style.formatters.yaxis_labelstring-Y axis labels: text with {value}. Applies to every axis in yaxis
style.formatters.tooltipstringthe standard tooltipThe tooltip's whole text, with {x}, {x|format}, {y} and {seriesName}

style.display ​

style.display turns the hover tooltip and the ApexCharts toolbar (zoom, pan, download) on or off. The toolbar is off, because most dashboards don't need it.

yaml
type: custom:lcards-chart
graph_span: 6h
sources:
  - entity: sensor.house_power
    name: Power
style:
  display:
    toolbar: true
    tooltip:
      theme: light
KeyTypeDefaultDescription
style.display.toolbarbooleanfalseShow the zoom, pan and download toolbar
style.display.tooltip.showbooleantrueShow the tooltip on hover
style.display.tooltip.themestringdarkdark or light

Released under the MIT License. | About