Charts drawn by the package itself, as SVG with the lu-* look (axis labels, grid lines, legend,
tooltips, light and dark).
The look-alike canvas charts are rendered on the server, with the same markup ledger.js
builds, so they show without JavaScript; a small hook only adds the hover guide and tooltip:
line_chart/1(hookLedgerUI.LineChart): lines and areas, with head, legend and tooltip. The server draws the SVG atwidth; the hook then measures the container (ResizeObserver) and lays the same geometry out at the real width, so axis text and strokes stay at their CSS size on any screen. The lines draw in once on mount (no loop; not withprefers-reduced-motion).donut_chart/1(hookLedgerUI.DonutChart): the ring and its plan rows.waterfall_chart/1: floating steps and totals.bar_chart/1: the column strip (lu-bars).cohort_heatmap/1: the retention grid.bar_list/1andheatmap/1: a ranking over tracks and a grid of dots.
chart/1 is the generic, options-driven chart (an ApexCharts-shaped subset: line, area,
bar, donut/pie) drawn by the LedgerUI.Chart hook into an element LiveView leaves alone.
Cards, headers and segmented controls around a chart are separate components; these functions
render only the chart (and, for line_chart/1, its head and legend).
Summary
Functions
Attributes
values(:list) - One number per bar. Defaults to[].data(:list) - The bars as{label, value}tuples or%{label:, value:}maps, in place ofvaluesandlabels. Defaults to[].max(:any) - The value of a full-height bar (the highest value, or 100 when it is lower, by default). Defaults tonil.labels(:list) - Labels in a row under the bars. Defaults to[].titles(:list) -title(hover text) of each bar. Defaults to[].highlight(:any) - Index of the highlighted bar, or its label (:last,nilfor none). Defaults to:last.shape(:string) - Defaults to"round". Must be one of"round", or"square".height(:any) - CSS height of the strip (120px). Defaults tonil.width(:any) - CSS width of the strip. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
label(:string) - The list'saria-label. Defaults tonil.max(:any) - The amount of a full track (the largestamountby default). Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
item(required) - Accepts attributes:label(:string)value(:string)amount(:any)
Attributes
id(:string) (required) - DOM id; also whatpush_eventpayloads target.options(:any) (required) - ApexCharts-shaped options, a map (encoded to JSON) or an encoded JSON string.formatters(:map) - Options path to built-in formatter name, e.g.%{"yaxis.labels.formatter" => "thousands"}. Defaults to%{}.table_toggle(:any) - Reserved: a Chart / Table switch (not drawn yet). Defaults tofalse.summary(:boolean) - Reserved: the cursor summary line (not drawn yet). Defaults tofalse.on_cursor(:string) - LiveView event pushed as the cursor moves. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
columns(:list) (required) - Header labels (M0,M1...).rows(:list) (required) -[%{label: "Jan", values: [100, 94, nil, ...]}];nilis an empty cell.thresholds(:list) - Lower bounds of levels 2 to 5. Defaults to[86, 90, 94, 100].suffix(:string) - Defaults to"%".class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
id(:string) (required)segments(:list) -[%{name: .., value: number, color: css, display: "$96,900"}]. Empty: only the container. Defaults to[].center_label(:string) - Defaults to"TOTAL".center_value(:string) - Defaults tonil.label(:string) - Defaults to"Distribuição".rows(:boolean) - Draw the plan rows (name, value and share) under the ring. Defaults totrue.value_format(:any) - Defaults to&LedgerUI.Components.Chart.money/1.class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
levels(:list) (required) - One level per cell, 0 to 4, row by row.columns(:integer) - Defaults to20.size(:integer) - The cell size in pixels. Defaults to12.shape(:string) - Defaults to"round". Must be one of"round", or"square".label(:string) (required) - What the map shows, for assistive technology.titles(:list) - Atitleper cell. Defaults tonil.less(:string) - Text before the scale; no scale without it. Defaults tonil.more(:string) - Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
id(:string) (required)labels(:list) - X axis labels, one per point. Defaults to[].series(:list) -[%{name: .., values: [..], area: bool, dashed: bool, color: css}]. Without series only the empty container is rendered. Defaults to[].min(:any) - Lowest value of the axis (default: lowest of the data). Defaults tonil.max(:any) - Defaults tonil.ticks(:integer) - Gaps of the Y axis (ticks + 1grid lines). Defaults to4.label_every(:integer) - Draw one X label every N points. Defaults to1.width(:integer) - Width of the server-rendered SVG (first paint). In the browser the hook re-lays the chart to the measured width of its container, so text and strokes keep their CSS size. Defaults to640.height(:integer) - Height of the chart in CSS pixels (the same on the server and after the hook measured). Defaults to250.label(:string) -aria-labelof the SVG. Defaults to"Gráfico".head(:string) - Big figure above the chart (+$70,320). Defaults tonil.sub(:string) - Muted text after the figure (since January). Defaults tonil.legend(:boolean) - Legend of the named series (when there is more than one). Defaults totrue.sub_delta(:string) - A change after the muted text (+12,4%), in bold and colored bysub_delta_tone. Defaults tonil.sub_delta_tone(:string) - Defaults to"pos". Must be one of"pos", or"neg".pin(:integer) - Index whose guide and tooltip stay visible. Defaults tonil.axis_format(:any) - Function of a value for the Y labels. Defaults to&LedgerUI.Components.Chart.kilo/1.value_format(:any) - Function of a value for the tooltip. Defaults to&LedgerUI.Components.Chart.money/1.tip(:any) - Function of an index returning tooltip rows[[name, value, kind]]. Defaults tonil.tip_title(:any) - Function of an index returning the tooltip title. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Attributes
id(:string) - Defaults tonil.steps(:list) -[%{name:, value:, label:, color:, total: bool}]: a step moves the running total,totalstarts from zero. Defaults to[].max(:integer) - Top of the Y axis. Defaults to30000.ticks(:integer) - Gaps of the Y axis. Defaults to3.label(:string) -aria-labelof the SVG. Defaults to"Movimento".axis_format(:any) - Defaults to&LedgerUI.Components.Chart.wf_axis/1.class(:any) - Defaults tonil.- Global attributes are accepted.