Vico

2.3. CartesianLayer

2.3.1. Implementations

There are three built-in CartesianLayer implementations:

These are discussed individually in 2.4–2.6.

2.3.2. CartesianLayerRangeProvider

What x and y ranges a CartesianLayer reports depends on its CartesianLayerRangeProvider. The CartesianLayer passes its intrinsic x and y ranges—which depend on the CartesianLayerModel—to the CartesianLayerRangeProvider, which returns the final ranges for the CartesianLayer to report. There are two CartesianLayerRangeProvider factory functions, listed below. For more specific behavior, implement the interface.

The default implementations of the CartesianLayerRangeProvider functions leave the x range unchanged but do these two things:

This also applies to the CartesianLayerRangeProvider implementations returned by CartesianLayerRangeProvider.auto and AxisValueOverrider.adaptiveYValues. Custom CartesianLayerRangeProvider implementations can override this behavior. With CartesianLayerRangeProvider.fixed, minY and maxY take precedence.

When using CartesianChartModelProducer, set each CartesianLayer’s CartesianLayerRangeProvider only once. There are no restrictions on dynamic behavior, but it should be implemented as part of a single CartesianLayerRangeProvider, not by means of an CartesianLayerRangeProvider-switching mechanism. In particular, this means that CartesianChartModelProducer-powered charts, CartesianLayerRangeProvider.fixed should be used only for entirely static overrides.

When you need to perform calculations based on the CartesianLayer’s intrinsic x and y ranges, use the values passed to the CartesianLayerRangeProvider functions. Beyond that, use extras if needed. These are important here not only for the usual synchronization reasons, but also because they’re updated via CartesianChartModelProducer.Transactions, and a CartesianChartModelProducer.Transaction is required for a CartesianChart’s x and y ranges to be updated. A common use case for extras is switching between externally defined x and y ranges—both in synchronization with series updates and without series updates (for example, in response to changes in user-accessible range settings).

2.3.3. Axis.Position.Vertical

A CartesianChart can have two separate y ranges, one for the start y-axis and one for the end y-axis. (The presence of two y-axes isn’t strictly necessary, but it’s generally needed for unambiguity.) You can assign each CartesianLayer an Axis.Position.Vertical subclass—either Start or End. The final y range for either Axis.Position.Vertical subclass is the narrowest range that includes the y ranges of all CartesianLayers linked to that subclass. Thus, you get two independently scaled groups of CartesianLayers, and the two y-axes are disconnected.