alexbruf/elm-daisyui/1.0.0

Daisy.Chart

A closed chart configuration.

Daisy.Render maps these values onto terezka/elm-charts. No elm-charts type appears in this module's API, so chart authors cannot reach the underlying library: the tree stays closed and every chart on a page is drawn the same way.

Colours are daisyUI semantic colours, emitted as CSS custom properties (var(--color-primary)), so a chart follows whatever theme Page.theme selected without the renderer knowing any concrete colour.

Chart kind

= Line
| Bar
| StackedBar
| Donut
| Area

The kind of chart to draw.

Line, Area and Donut read one point per xLabel per series. Bar draws the series side by side in each bin, StackedBar stacks them.

Data

type alias ChartData =
{ series : List Series
, xLabels : List String
}

The data a chart draws.

xLabels labels the bins along the x axis; each Series should have one point per label. Missing points are read as 0, extra points are ignored.

A Donut ignores xLabels: each series becomes one ring segment, sized by the sum of its points and coloured by its own colour.

type alias Series =
{ name : String
, color : SemanticColor
, points : List Float
}

One named, coloured line / bar set / ring.

Colour

= Primary
| Secondary
| Accent
| Info
| Success
| Warning
| Error
| Neutral

The daisyUI semantic palette. These are the only colours a chart can use.

The CSS colour value for a SemanticColor.

semanticColorToCss Primary --> "var(--color-primary)"