BarLegend

data class BarLegend<UnitType : Dimension>(val id: String, var items: List<BarLegendItem<UnitType>> = emptyList(), val resample: EasingCurve? = null, var title: String? = null, var titleFontSize: TextUnit = LegendDefaults.titleFontSize, val titleFontWeight: FontWeight = FontWeight.Bold, var titleColorValue: Color = LegendDefaults().titleColor, val labelFontSize: TextUnit = BarLegendDefaults.labelFontSize, var labelColor: Color = BarLegendDefaults.labelColor, val labelFont: Typeface = BarLegendDefaults.labelFont, val measurement: MeasurementUnits.MeasurementType? = null, val units: MeasurementUnits = MeasurementUnits.IMPERIAL, var currentUnits: UnitType? = units.dimensions(measurement)) : Legend, ColorScaleUpdatable

A Legend type that renders a color bar with optional measurement-aware labels. It's a data class to promote immutability, common in Compose.

Parameters

UnitType

A type representing the unit of measurement (e.g., Temperature, Speed).

Constructors

Link copied to clipboard
constructor(id: String, items: List<BarLegendItem<UnitType>> = emptyList(), resample: EasingCurve? = null, title: String? = null, titleFontSize: TextUnit = LegendDefaults.titleFontSize, titleFontWeight: FontWeight = FontWeight.Bold, titleColorValue: Color = LegendDefaults().titleColor, labelFontSize: TextUnit = BarLegendDefaults.labelFontSize, labelColor: Color = BarLegendDefaults.labelColor, labelFont: Typeface = BarLegendDefaults.labelFont, measurement: MeasurementUnits.MeasurementType? = null, units: MeasurementUnits = MeasurementUnits.IMPERIAL, currentUnits: UnitType? = units.dimensions(measurement))

Properties

Link copied to clipboard
Link copied to clipboard
open override val id: String

Unique identifier used to register and manage the legend instance.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val resample: EasingCurve? = null
Link copied to clipboard
open override var title: String?

Display title rendered above the legend content.

Link copied to clipboard
open override var titleColorValue: Color
Link copied to clipboard
open override var titleFontSize: TextUnit

The size of the Title Text

Link copied to clipboard
Link copied to clipboard
open override val units: MeasurementUnits

Units used when formatting any measurement values displayed by the legend.

Functions

Link copied to clipboard
open override fun apply(colorScale: ColorScaleSpecification): BarLegend<UnitType>

open override fun apply(colorScale: ColorScaleOptions): Any

Applies the provided color-scale specification to the implementing legend.

Link copied to clipboard
Link copied to clipboard
open override fun items(newItems: List<PointLegendItem>): PointLegend
open override fun items(newItems: List<BarLegendItem<Dimension>>): BarLegend<UnitType>
Link copied to clipboard
open override fun title(newValue: String?): BarLegend<UnitType>

Allows an implementing class to create a new version of itself with an updated title.

Link copied to clipboard
open fun titleColor(color: Color): Legend
Link copied to clipboard
open override fun units(newValue: MeasurementUnits): BarLegend<UnitType>

Allows an implementing class to create a new version of itself with updated units.

Link copied to clipboard
open override fun updateFromPaint(paint: LayerPaint): Legend