ChartStyling

Utility object for chart styling and component creation. Provides reusable styled lines, points, and axes for Vico charts.

Design principles (per design#53):

  • Default to thin lines without point markers to avoid clutter on dense timeseries.

  • Show a single dot only at the marker/cursor position (handled by rememberMarker).

  • Use Interpolator.cubic() for smooth monotone curves that won't overshoot between sparse points.

  • Reserve bold lines for the single most-important series; use subtle/gradient fills for secondary data.

Properties

Link copied to clipboard
const val MEDIUM_LINE_WIDTH_DP: Float = 2.0f
Link copied to clipboard
const val THICK_LINE_WIDTH_DP: Float = 2.5f
Link copied to clipboard
const val THIN_LINE_WIDTH_DP: Float = 1.5f

Functions

Link copied to clipboard
fun createBoldLine(lineColor: Color, interpolator: LineCartesianLayer.Interpolator = LineCartesianLayer.Interpolator.cubic()): LineCartesianLayer.Line

Creates a bold line suitable for highlighting the primary metric in a multi-series chart.

Link copied to clipboard
fun createColoredMarkerValueFormatter(format: (value: Double, color: Color) -> String): DefaultCartesianMarker.ValueFormatter

Creates a DefaultCartesianMarker.ValueFormatter that colors the text to match the series color.

Link copied to clipboard
fun createDashedLine(lineColor: Color, interpolator: LineCartesianLayer.Interpolator = LineCartesianLayer.Interpolator.cubic()): LineCartesianLayer.Line

Creates a dashed secondary line. Useful for distinguishing two metrics that share the same axis without relying on colour alone.

Link copied to clipboard
fun createGradientLine(lineColor: Color, lineWidth: Float = MEDIUM_LINE_WIDTH_DP, interpolator: LineCartesianLayer.Interpolator = LineCartesianLayer.Interpolator.cubic()): LineCartesianLayer.Line

Creates a line with a gradient area fill effect. Ideal for emphasising a single series or showing magnitude. The gradient goes from the line color at ~30% opacity to near-transparent.

Link copied to clipboard
fun createStyledLine(lineColor: Color, lineWidth: Float = MEDIUM_LINE_WIDTH_DP, interpolator: LineCartesianLayer.Interpolator = LineCartesianLayer.Interpolator.cubic()): LineCartesianLayer.Line

Creates a clean timeseries line — thin, smooth, with no point markers. This is the default style recommended by Oscar's UX guidance: "thin lines, and maybe a dot where the cursor is."

Link copied to clipboard
fun createSubtleLine(lineColor: Color): LineCartesianLayer.Line

Creates a subtle line suitable for secondary metrics that should not dominate the chart.

Link copied to clipboard
fun createThemedColor(baseColor: Color, alpha: Float = 1.0f): Color

Gets Material 3 theme-aware colors with opacity. Useful for creating color variants while respecting the current theme.

Link copied to clipboard
fun rememberAxisLabel(color: Color = MaterialTheme.colorScheme.onSurfaceVariant): TextComponent

Creates and remembers a com.patrykandpatrick.vico.compose.common.component.TextComponent styled for axis labels.

Link copied to clipboard
fun rememberMarker(valueFormatter: DefaultCartesianMarker.ValueFormatter = DefaultCartesianMarker.ValueFormatter.default(colorCode = true), showIndicator: Boolean = true): CartesianMarker

Creates and remembers a default CartesianMarker styled for the Meshtastic theme.

Link copied to clipboard
fun rememberThresholdLine(y: Double, color: Color, label: String? = null): Decoration

Creates a HorizontalLine decoration for a reference threshold (e.g. battery low, pressure normal).