lenards/elm-patternfly-charts/1.0.0

NOTE: the latest version is 1.0.1

PF6.Charts.Bar

Bar chart — vertical or horizontal bars for categorical comparison.

Supports single-series and grouped multi-series bars with automatic color assignment from the theme's multi-ordered color scale.

Types

An opaque bar chart configuration.

type alias SeriesData =
{ label : String
, values : List Float
}

Multi-series data: each series has a label and a value per category.

= Vertical
| Horizontal

Bar orientation — vertical (default) or horizontal.

Use Horizontal when category labels are long or when you want to show nominal data with more space for labeling (categories on the y-axis).

Constructor

fromData : List String -> List SeriesData -> BarChart

Create a bar chart from category labels and one or more value series.

For a single series, pass a list with one SeriesData.

chart =
    Bar.fromData
        [ "Memory", "CPU", "Disk" ]
        [ { label = "Used", values = [ 70, 45, 82 ] } ]

For grouped bars:

chart =
    Bar.fromData
        [ "Node 1", "Node 2", "Node 3" ]
        [ { label = "Used (GiB)", values = [ 8, 12, 6 ] }
        , { label = "Cached (GiB)", values = [ 3, 4, 2 ] }
        ]

Modifiers

Set chart width in pixels. Default: 500.

Set chart height in pixels. Default: 300.

Apply a Theme.

withColors : List String -> BarChart -> BarChart

Override the color list for bars (one color per series).

Set the x-axis label.

Set the y-axis label.

withTitle : String -> BarChart -> BarChart

Set the chart title.

When True (default), multiple series render as side-by-side grouped bars. When False, series are stacked (use Stack for stacked area).

Set the bar orientation. Default: Vertical (categories on x-axis).

Use Horizontal when category labels are long or for nominal variables — bars extend left-to-right, categories are listed on the y-axis.

Bar.fromData categories series
    |> Bar.withOrientation Bar.Horizontal
    |> Bar.toSvg

Show a skeleton placeholder instead of the chart while data is loading.

Enable SVG <title> tooltips on each bar. Default: False.

When enabled, hovering over a bar shows a browser-native tooltip with the category and value (e.g. "Memory · Used: 70"). No ports or state required.

Renderer

toSvg : BarChart -> Html msg

Render to Html msg.