The guide is being migrated; some links to the API reference may be missing. Use the search bar in the API reference.

CartesianChartHost

Overview

CartesianChartHost is the entry point for Cartesian charts. It accepts a CartesianChart and a CartesianChartModelProducer, facilitates their communication, and displays the CartesianChart. It also handles scroll and zoom and shows a placeholder when no data is available.

CartesianChartHost(rememberCartesianChart(/* ... */), modelProducer, /* ... */)

Scroll

CartesianChartHost accepts instances of VicoScrollState, enabling scroll customization and programmatic scrolling. Use rememberVicoScrollState to instantiate this class:

val scrollState = rememberVicoScrollState(/* ... */)
CartesianChartHost(scrollState = scrollState, /* ... */)

Scroll, split into Scroll.Absolute and Scroll.Relative, is used to represent scroll values—either absolute (from zero) or relative (from the current value). The following factory functions are available:

  • Scroll.Absolute.pixels

  • Scroll.Absolute.x

  • Scroll.Relative.pixels

  • Scroll.Relative.x

AutoScrollCondition defines when to scroll automatically. There are two singletons:

  • AutoScrollCondition.Never (default)

  • AutoScrollCondition.OnModelGrowth

You can create custom implementations of Scroll and AutoScrollCondition for more specific behavior.

Zoom

CartesianChartHost accepts instances of VicoZoomState, enabling zoom customization. Use rememberVicoZoomState to instantiate this class:

val zoomState = rememberVicoZoomState(/* ... */)
CartesianChartHost(zoomState = zoomState, /* ... */)

Zoom is used to define zoom factors. The following factory functions are available:

  • Zoom.max

  • Zoom.min

  • Zoom.static

  • Zoom.x

You can create custom implementations of Zoom for more specific behavior.