Jenga Bar Chart
A vertical bar chart: one bar per entry, growing from a shared baseline, with its label underneath. Bar heights are relative to maxValue and animate when the data changes. With onSelect each bar's whole slot is a tap target and the chart reads as a group of selectable bars; without it the chart is static. There are no axes; put the figure the selection refers to next to the chart, or add a valueLabel at each bar's tip.
Parameters
the bars, in display order; values must not be negative.
accessibility label for a bar (e.g. "May, 12,000").
the Modifier for the chart.
the selected bar, or null for none.
called with a tapped bar's index; null makes the chart static.
the value of a full-height bar; the largest entry by default.
how bars are laid out; see JengaBarChartArrangement.
the height of a full-height bar.
the height of a zero-value bar.
the widest a bar may be.
the gap between bar slots.
the bar shape.
the gap between a bar and its label.
padding around the chart.
the label text style.
the label text style under the selected bar.
the color set; defaults to JengaBarChartDefaults.colors.
how bar heights animate.
optional content above each bar's tip, given the entry and whether it is selected.
the content under each bar, given the entry and whether it is selected.
Samples
var selected by remember {
mutableStateOf<Int?>(
value = null,
)
}
val months = listOf(
JengaBarChartEntry(
label = "May",
value = 8200f,
),
JengaBarChartEntry(
label = "Jun",
value = 12400f,
),
JengaBarChartEntry(
label = "Jul",
value = 9100f,
),
)
JengaBarChart(
entries = months,
barContentDescription = { "${it.label}, ${it.value}" },
selectedIndex = selected,
onSelect = { selected = it },
)