howdy/ui/chart
Charts: bar, line and area charts drawn as SVG on the server, in the theme’s chart colours.
chart.bar(
title: "Revenue by month",
labels: ["Jan", "Feb", "Mar"],
series: [
chart.Series("Online", [4200.0, 5100.0, 6100.0]),
chart.Series("In store", [3100.0, 2900.0, 3300.0]),
],
)
|> chart.view
Every series is one entry per label. Series take the theme’s chart
colours in order, so a series keeps its colour as long as it keeps its
place: when a filter removes some, pass the survivors in the same order
with colours rather than letting them shift. There are five colours;
past five series, fold the rest into an “Other” series or draw several
charts. A sixth and later series is drawn in the muted text colour.
Hovering over or focusing a label’s column shows every series’ value there; with Tab a keyboard reaches each column, and a screen reader reads the same values. Under the chart, “Show data” opens the numbers as a table. None of it needs a script.
The value axis always includes zero, so bars grow from a baseline and a line’s height is honest. Two measures on different scales belong in two charts, never on two axes of one.
Types
pub type Kind {
Bar
Line
Area
Pie(hole: Float)
Radial(max: Float)
Radar
}
Constructors
-
Bar -
Line -
Area -
Pie(hole: Float)Parts of a whole, as slices;
holeis the inner radius as a share of the outer, so0.0is a pie and about0.6a donut. -
Radial(max: Float)Values out of
max, as concentric rings. -
RadarSeveral measures around a circle, one polygon per series.
Values
pub fn area(
title title: String,
labels labels: List(String),
series series: List(Series),
) -> Chart
Lines with a light wash beneath, for volumes over time.
pub fn bar(
title title: String,
labels labels: List(String),
series series: List(Series),
) -> Chart
Columns, grouped by label when there are several series.
pub fn bar_down_class() -> css.Class
pub fn bar_group_class() -> css.Class
pub fn bar_slot_class() -> css.Class
pub fn bar_up_class() -> css.Class
pub fn baseline_class() -> css.Class
pub fn caption_class() -> css.Class
pub fn centre_label_class() -> css.Class
pub fn centre_value_class() -> css.Class
pub fn chart_class() -> css.Class
pub fn colours(chart: Chart, colours: List(Int)) -> Chart
Which chart colour, from 1 to 5, each series takes. Use it to keep a series’ colour when others are filtered out.
pub fn column_class() -> css.Class
pub fn crosshair_class() -> css.Class
pub fn details_class() -> css.Class
pub fn donut(
title title: String,
labels labels: List(String),
values values: List(Float),
) -> Chart
A pie with a hole, showing the total in the middle.
pub fn end_label_class() -> css.Class
pub fn figure_class() -> css.Class
pub fn format(chart: Chart, format: fn(Float) -> String) -> Chart
How values are written on the axis, in readouts and in the table. The
default is the words’ decimal: whole numbers with thousands separators
and at most two decimal places.
pub fn format_number(value: Float) -> String
Thousands separators and at most two decimal places: 12,500 or 3.25.
pub fn grid_class() -> css.Class
pub fn gutter_class() -> css.Class
pub fn highlight_class() -> css.Class
pub fn key_box_class() -> css.Class
pub fn key_line_class() -> css.Class
pub fn legend_class() -> css.Class
pub fn line(
title title: String,
labels labels: List(String),
series series: List(Series),
) -> Chart
Lines, for change over an ordered range such as time.
pub fn line_class() -> css.Class
pub fn part_class() -> css.Class
pub fn part_legend_class() -> css.Class
pub fn part_name_class() -> css.Class
pub fn pie(
title title: String,
labels labels: List(String),
values values: List(Float),
) -> Chart
Parts of a whole as slices, with each part’s value and share in the legend. Use it for a few parts, six at most; to compare values, a bar chart reads better.
pub fn plot_class() -> css.Class
pub fn polar_class() -> css.Class
pub fn polar_svg_class() -> css.Class
pub fn radar(
title title: String,
axes axes: List(String),
series series: List(Series),
) -> Chart
Several measures, one per axis around the circle, for comparing the
shape of a few series. axes name the measures; each series has one
value per axis.
pub fn radar_grid_class() -> css.Class
pub fn radar_label_class() -> css.Class
pub fn radar_shape_class() -> css.Class
pub fn radial(
title title: String,
labels labels: List(String),
values values: List(Float),
max max: Float,
) -> Chart
Each value out of max as a ring, such as goals reached.
pub fn ring_track_class() -> css.Class
pub fn summary_class() -> css.Class
pub fn table_class() -> css.Class
pub fn table_scroll_class() -> css.Class
pub fn tick_class() -> css.Class
pub fn tip_label_class() -> css.Class
pub fn tip_left_class() -> css.Class
pub fn tip_name_class() -> css.Class
pub fn tip_right_class() -> css.Class
pub fn tip_row_class() -> css.Class
pub fn view(chart: Chart) -> element.Element(msg)
pub fn words(chart: Chart, words: words.Words) -> Chart
Speak another language: “Show data”, “Total”, shares and, unless
format says otherwise, numbers. English by default.
pub fn x_label_class() -> css.Class