CartesianLayer
Implementations
There are three built-in CartesianLayer implementations:
These are discussed individually in the following sections.
CartesianLayerRangeProvider
CartesianLayerRangeProviderWhat x- and y-ranges a layer reports depends on its CartesianLayerRangeProvider instance. A layer passes its intrinsic x- and y-ranges—which depend on CartesianLayerModel—to this instance, which returns the final ranges to report. The available singletons and factory functions are listed below. For more specific behavior, implement the interface.
CartesianLayerRangeProvider.auto(default)
The default implementations of the CartesianLayerRangeProvider functions leave the x-range unchanged but do these two things:
They ensure that the y-range includes zero.
They apply a y-range of [0, 1] if the minimum and maximum intrinsic y-values are both zero.
This also applies to the implementation returned by CartesianLayerRangeProvider.auto. Custom CartesianLayerRangeProvider implementations can override this behavior. With CartesianLayerRangeProvider.fixed, minY and maxY take precedence.
When using CartesianChartModelProducer, set the CartesianLayerRangeProvider instance for each layer only once. There are no restrictions on dynamic behavior, but it should be implemented as part of a single CartesianLayerRangeProvider instance, not by means of a mechanism that switches between CartesianLayerRangeProvider implementations. In particular, for charts powered by CartesianChartModelProducer, CartesianLayerRangeProvider.fixed should be used only for entirely static overrides.
When you need to perform calculations based on a layer’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.Transaction, and a transaction is required for a chart’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).
Axis.Position.Vertical
Axis.Position.VerticalA 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 layer to an Axis.Position.Vertical subclass—either Start or End. The final y-range for either subclass is the narrowest range that includes the y-ranges of all linked layers. Thus, you get two independently scaled groups of layers, and the two y-axes are disconnected.
Sample charts
Last updated