Skip to content

BarChart ​

Restrained vertical bar chart. Bars share the available width and rise proportionally to the series max; a single accent marks one bar (the max-value bar by default). No axes or gridlines — use it for at-a-glance comparisons rather than precise reads.

Import ​

kotlin
import io.github.heartcoolman.prism.charts.PrismBarChart
import io.github.heartcoolman.prism.charts.PrismBarDatum

Basic usage ​

kotlin
PrismBarChart(
    data = listOf(
        PrismBarDatum("Mon", 3f),
        PrismBarDatum("Tue", 6f),
        PrismBarDatum("Wed", 4f),
    ),
    showValues = true,
)

Highlight a specific bar ​

By default the max-value bar is accented. Pass highlightIndex to accent another bar instead.

kotlin
PrismBarChart(
    data = listOf(
        PrismBarDatum("Q1", 12f),
        PrismBarDatum("Q2", 18f),
        PrismBarDatum("Q3", 9f),
    ),
    highlightIndex = 0,
    height = 200.dp,
)

API ​

PrismBarChart ​

ParameterTypeDefaultDescription
dataList<PrismBarDatum>—Series to plot, left to right.
modifierModifierModifierModifier applied to the chart row.
highlightIndexInt?nullIndex of the accented bar; defaults to the max-value bar.
heightDp160.dpPlot height (excludes labels and values).
showValuesBooleanfalseRender the value above the highlighted bar.

PrismBarDatum ​

ParameterTypeDefaultDescription
labelString—Caption rendered under the bar.
valueFloat—Magnitude; bar height is proportional to the series max.

Released under the MIT License.