Skip to main content

2.0.0-alpha.24

This release updates the API to use Double for CartesianChart data and continues the API cleanup.

Breaking changesAddressed
Moderate#623

Double migration

For improved precision, we’ve switched from Float to Double for CartesianChart data. Depending on how you’re using API, to migrate, you may have to adapt the signatures of some overridden functions, update some data types, or use conversion methods. Refer to IDE suggestions and the API reference.

Immutability

TextComponent, ShapeComponent, LineComponent, FadingEdges, HorizontalLegend, and VerticalLegend have been made immutable—replace mutation with instance creation.

The corresponding remember functions have been updated accordingly.

DefaultCartesianMarker’s setIndicatorColor—the one API where mutation was expected—has been replaced. Specifically, indicator and setIndicatorColor have been merged into an indicator lambda that receives a color and returns an appropriately styled Component. The color is passed as an integer in the DefaultCartesianMarker constructor, and as a Jetpack Compose Color in rememberDefaultCartesianMarker. Here’s a basic example:

rememberDefaultCartesianMarker(
indicator = remember { { shapeComponent(shape = Shape.Pill, color = it) } },
// ...
)

shapeComponent is a new, non-composable ShapeComponent factory function for Jetpack Compose, intended for use in non-composable lambdas. (rememberShapeComponent remains available for composable contexts.) shadow, described below, is another such function. Other classes lack such non-remember factory functions either because there aren’t yet any lambdas where they could be required, or because their constructors are suitable for Jetpack Compose (meaning that they don’t have any types that must be changed for Jetpack Compose, like Float instead of Dp). LayeredComponent falls into the latter category—in indicator, use the LayeredComponent constructor.

ShapeComponent shadows

The ShapeComponent shadow API has been simplified. PaintComponent has been removed, and ComponentShadow has been renamed to Shadow. Rather than having a setShadow function, ShapeComponent and LineComponent now directly accept Shadow instances.

rememberShapeComponent, rememberLineComponent, and the rememberLineComponent aliases have shadow parameters. Use the rememberShadow and shadow functions to create Shadows.

Miscellaneous

  • The visibility of several APIs intended for internal use has been restricted.
  • BrushShader has been removed—use Brush.toDynamicShader.