Vico

2.1. CartesianChart

2.1.1. Anatomy

CartesianChart draws charts based on Cartesian coordinate planes. Any such chart includes one or more CartesianLayers. The CartesianLayers are stacked, and each one has its own data.

For CartesianChart creation, see 5.2.2 (Compose) and 8.2.2 (views).

2.1.2. Hosts

A CartesianChart is used with a host—a composable or view that passes it data, draws it, and handles framework-specific matters, such as gesture detection.

For more, see 5.2.1 (Compose) and 8.2.1 (views).

2.1.3. Ranges

A CartesianChart’s x- and y-ranges depend on those reported by its CartesianLayers. The x-range is the narrowest one that includes all CartesianLayers’ x-ranges. By default, there’s an analogously determined shared y-range, but two separate y-ranges can also be introduced.

x- and y-range customization is discussed in 2.3.3 and 2.3.4.

2.1.4. Scroll and zoom

While scroll and zoom are handled at the framework level, core includes some shared high-level contracts.

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:

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

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

While the built-in implementations cover the majority of use cases, you can create your own for advanced behavior. For more, see 5.2.3 (Compose) and 8.2.3 (views).

2.1.5. Sample charts