charty

MosaicBarChart#

Best for comparing the composition of several categories: each BarGroup becomes one vertical column, and its values are stacked as percentages so every column fills the full plot height.

MosaicBarChart

Kotlin
MosaicBarChart(    data = {        listOf(            BarGroup(label = "Q1", values = listOf(10f, 50f, 30f, 90f)),            BarGroup(label = "Q2", values = listOf(70f, 20f, 80f, 40f)),        )    },    modifier = Modifier.fillMaxWidth().height(200.dp),    config = MosaicBarChartConfig(        barWidthFraction = 0.9f,        animation = Animation.Default,    ),    onSegmentClick = { segment ->        println("${segment.barGroup.label}[${segment.segmentIndex}] = ${segment.segmentPercentage}%")    },)

Each BarGroup.values list is one column, not one row. Values of 0f or less are skipped. A group whose positive values sum to zero draws nothing.

MosaicBarChart has no chart-level colour parameter. Segments use BarGroup.colors when supplied, and otherwise cycle through a built-in three-colour palette.

Click data: MosaicBarSegment(barGroup, segmentIndex, segmentValue, segmentPercentage)

Fixed 0–100% axis#

The value axis is always 0%–100%, because every column is normalised to fill the plot height. Column totals are therefore not comparable across columns — only the internal proportions are. Use StackedBarChart when the absolute totals matter.

Rolling window#

Kotlin
config = MosaicBarChartConfig(visibleWindow = 12, animation = Animation.Fast)

Keeps only the last N columns on screen; null or at least 2.

Persistent markers#

Kotlin
config = MosaicBarChartConfig(    visibleWindow = 12,    markers = listOf(PersistentMarker(dataIndex = -1, label = "Latest")),)

A negative dataIndex counts back from the end of the drawn data, so -1 marks the newest column.

Animating value changes#

Kotlin
config = MosaicBarChartConfig(animateValueChanges = true, animation = Animation.Fast)

Tooltip#

Kotlin
MosaicBarChart(    data = { groups },    modifier = Modifier.fillMaxWidth().height(200.dp),    tooltip = ChartTooltip.canvas(),    config = MosaicBarChartConfig(        tooltipFormatter = { segment -> "${segment.barGroup.label}: ${segment.segmentPercentage.toInt()}%" },    ),)

Accessibility#

A generated summary plus one focusable node per column.

Kotlin
interactionConfig = ChartInteractionConfig(accessibilityDescription = "Traffic source mix by quarter")

MosaicBarChartConfig#

PropertyTypeDefaultDescription
barWidthFractionFloat0.9fColumn width as a fraction of its slot; 0f..1f
animationAnimationAnimation.DefaultGrow-from-bottom entry animation
animateValueChangesBooleanfalseTween segment values on data change
markersList<PersistentMarker>emptyList()Persistent pinned labels
tooltipConfigTooltipConfig?null (the theme's)Canvas tooltip appearance
tooltipPositionTooltipPositionAUTOABOVE, BELOW, or AUTO
tooltipFormatter(MosaicBarSegment) -> String"label [i]: n%"Tooltip text
visibleWindowInt?nullRolling "show last N" window; null or >= 2

Limitations#