BarLegendLabels

data class BarLegendLabels<UnitType : Dimension>(var values: BarLegendLabels.Values<UnitType>? = null, val placement: BarLegendLabels.Placement = Placement.MIDDLE, val textStroke: BarLegendLabels.TextStroke = TextStroke(), val textShadow: Shadow = BarLegendDefaults.textShadow, var normalized: Boolean = BarLegendDefaults.normalized, var currentUnits: UnitType?, val formatter: (measurement: Measurement<UnitType>, index: Int) -> String = { measurement, idx -> // Use the property directly to avoid capturing an old value val targetUnit = currentUnits val displayMeasurement = if (targetUnit != null && measurement.unit != targetUnit) { measurement.converted(to = targetUnit) } else { measurement } val intValue = displayMeasurement.value.toInt() // FIX: Resolve the symbol from the converted unit (targetUnit) val symbol = targetUnit?.symbol ?: measurement.unit.symbol if (idx == 0) "$intValue$symbol" else "$intValue" })

Configures value annotations drawn on a BarLegend.

Constructors

Link copied to clipboard
constructor(values: BarLegendLabels.Values<UnitType>? = null, placement: BarLegendLabels.Placement = Placement.MIDDLE, textStroke: BarLegendLabels.TextStroke = TextStroke(), textShadow: Shadow = BarLegendDefaults.textShadow, normalized: Boolean = BarLegendDefaults.normalized, currentUnits: UnitType?, formatter: (measurement: Measurement<UnitType>, index: Int) -> String = { measurement, idx -> // Use the property directly to avoid capturing an old value val targetUnit = currentUnits val displayMeasurement = if (targetUnit != null && measurement.unit != targetUnit) { measurement.converted(to = targetUnit) } else { measurement } val intValue = displayMeasurement.value.toInt() // FIX: Resolve the symbol from the converted unit (targetUnit) val symbol = targetUnit?.symbol ?: measurement.unit.symbol if (idx == 0) "$intValue$symbol" else "$intValue" })

Types

Link copied to clipboard
Link copied to clipboard
data class TextStroke(val color: Color = BarLegendDefaults.textStrokeColor, val width: Float = BarLegendDefaults.textStrokeWidth)
Link copied to clipboard
sealed class Values<UnitType : Dimension>

Properties

Link copied to clipboard

Whether a label that collides with one already placed is still drawn.

Link copied to clipboard

Whether each label is centred on its colour cell rather than on its own tick position.

Link copied to clipboard
Link copied to clipboard
val formatter: (measurement: Measurement<UnitType>, index: Int) -> String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun format(measurement: Measurement<UnitType>, index: Int): String