Extra elements

You can add additional elements to charts.

Decoration

Decorations display an additional layer of data. You can create your own implementations of this interface. To add a Decoration to a chart, use the decorations parameters of columnChart and lineChart, or the addDecoration, setDecoration, removeDecoration, and removeDecorations functions of Chart.

ThresholdLine

ThresholdLine, which is a kind of Decoration, displays either a horizontal line highlighting a specific y value or a horizontal box highlighting a range of y values. It has two constructors. For examples, see, in the sample app, rememberThresholdLine in Chart2.kt, rememberThresholdLine in Chart6.kt, and ThresholdLinePreviews.kt.

Marker

A Marker highlights the y value corresponding to a specific value on the x-axis. Markers can be shown when a chart is touched, or you can make them persistent. To create a Marker, use the MarkerComponent class or create your own implementation of the Marker interface. See Marker.kt in the sample app for an example of how a marker can be created.

In Jetpack Compose, use the marker parameter of the Chart composable to add a Marker displayed when the chart is touched, and use the persistentMarkers parameters of columnChart andlineChart to add persistent Markers. In the view system, use the marker field of BaseChartView to add a Marker displayed when the chart is touched, and use the addPersistentMarker, removePersistentMarker, and setPersistentMarkers functions of Chart directly to manage persistent Markers.

MarkerVisibilityChangeListener allows for listening to marker visibility changes. To link an implementation of this interface to a chart, use the markerVisibilityChangeListener parameter of the Chart composable function, or the markerVisibilityChangeListener field of BaseChartView.

Legend

A Legend describes the elements present on a chart. You can create your own implementations of this interface. To add a Legend to a chart, use the legend parameter of the Chart composable function, or the legend field of BaseChartView. Vico includes two default Legend implementations: VerticalLegend and HorizontalLegend. In Jetpack Compose, use verticalLegend and horizontalLegend. For an example, see rememberLegend in Chart7.kt in the sample app.

Last updated