2.0.0-alpha.24
This release updates the API to use Double
for CartesianChart
data and continues the API cleanup.
Breaking changes | Addressed |
---|---|
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.
- Compose
- Views
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.
If you’re indirectly instantiating TextComponent
, ShapeComponent
, or LineComponent
via XML and then
performing further customization programmatically, do the following:
- For
TextComponent
,ShapeComponent
, andLineComponent
, use theircopy
functions. - Use
FadingEdges
either entirely via XML or entirely programmatically.
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
. Here’s a basic example:
indicator = { ShapeComponent(shape = Shape.Pill, color = it) }
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.
- Compose
- Views
rememberShapeComponent
, rememberLineComponent
, and the rememberLineComponent
aliases have shadow
parameters. Use the rememberShadow
and shadow
functions to create Shadow
s.
ShapeComponent
and LineComponent
have shadow
properties. Instantiate Shadow
via its constructor.
Miscellaneous
- Compose
- Views
- The visibility of several APIs intended for internal use has been restricted.
BrushShader
has been removed—useBrush.toDynamicShader
.
- The visibility of several APIs intended for internal use has been restricted.
ShapeDrawable
has been removed—useShape.toDrawable
.