2.0.0-alpha.26
This release includes updates to LineCartesianLayer
’s split line styling.
Breaking changes | Addressed |
---|---|
Minor | #259, #405, #483, #784, #809 |
LineCartesianLayer
has new fill APIs: LineFill
(for line fills) and AreaFill
(for area fills, previously referred
to as line backgrounds). These replace the direct use of DynamicShader
s and offer greater flexibility. They accept
instances of Fill
, which is a generic class that stores fill properties (either a color or a DynamicShader
). Fill
will soon also be used by ShapeComponent
and LineComponent
.
Both LineFill
and AreaFill
have two factory functions: single
and double
. These let you apply a single style or
split a line’s style at a y value of your choosing, respectively. The ability to customize the split y is
new—previously, only y = 0 could be used. You can create your own LineFill
and AreaFill
implementations for more
advanced styling.
With these APIs, ColorShader
and TopBottomShader
are no longer needed, so they’ve been removed.
- Compose
- Views
rememberLine
’s shader
and backgroundShader
parameters have been replaced with fill
and areaFill
parameters. Fill
s are created via the fill
function, which takes a Color
or a DynamicShader
.
Use LineFill
as follows:
-
For a single
Color
orDynamicShader
, use the following:fill = LineCartesianLayer.LineFill.single(fill(...))
For example, this produces a solid blue line:
fill = LineCartesianLayer.LineFill.single(fill(Color.Blue))
-
For two
Color
s orDynamicShader
s, use the following:fill =
LineCartesianLayer.LineFill.double(
topFill = fill(...),
bottomFill = fill(...),
)For example, this produces a line that’s green for positive y values and red for negative y values:
fill =
LineCartesianLayer.LineFill.double(
topFill = fill(Color.Green),
bottomFill = fill(Color.Red),
)You can use the
splitY
lambda to split the line style elsewhere than at y = 0. Here, y = 10 is used:fill = LineCartesianLayer.LineFill.double(...) { 10 }
This is an
ExtraStore
lambda:fill = LineCartesianLayer.LineFill.double(...) { it[splitYKey] }
Use AreaFill
as follows:
-
For a single
Color
orDynamicShader
, use the following:areaFill = LineCartesianLayer.AreaFill.single(fill(...))
-
For two
Color
s orDynamicShader
s, use the following:areaFill =
LineCartesianLayer.AreaFill.double(
topFill = fill(...),
bottomFill = fill(...),
)You can use the
splitY
lambda to split the fill elsewhere than at y = 0. Here, y = 10 is used:areaFill = LineCartesianLayer.AreaFill.double(...) { 10 }
This is an
ExtraStore
lambda:areaFill = LineCartesianLayer.AreaFill.double(...) { it[splitYKey] }
The LineCartesianLayer.Line
constructor’s shader
and backgroundShader
parameters have been replaced with
fill
and areaFill
parameters. Fill
s are created via the constructor, which takes a color integer or a
DynamicShader
.
Use LineFill
as follows:
-
For a single color or
DynamicShader
, use the following:fill = LineCartesianLayer.LineFill.single(Fill(...))
For example, this produces a solid blue line:
fill = LineCartesianLayer.LineFill.single(Fill(Color.BLUE))
-
For two colors or
DynamicShader
s, use the following:fill =
LineCartesianLayer.LineFill.double(
topFill = Fill(...),
bottomFill = Fill(...),
)For example, this produces a line that’s green for positive y values and red for negative y values:
fill =
LineCartesianLayer.LineFill.double(
topFill = Fill(Color.GREEN),
bottomFill = Fill(Color.RED),
)You can use the
splitY
lambda to split the line style elsewhere than at y = 0. Here, y = 10 is used:fill = LineCartesianLayer.LineFill.double(...) { 10 }
This is an
ExtraStore
lambda:fill = LineCartesianLayer.LineFill.double(...) { it[splitYKey] }
Use AreaFill
as follows:
-
For a single color or
DynamicShader
, use the following:areaFill = LineCartesianLayer.AreaFill.single(Fill(...))
-
For two colors or
DynamicShader
s, use the following:areaFill =
LineCartesianLayer.AreaFill.double(
topFill = Fill(...),
bottomFill = Fill(...),
)You can use the
splitY
lambda to split the fill elsewhere than at y = 0. Here, y = 10 is used:areaFill = LineCartesianLayer.AreaFill.double(...) { 10 }
This is an
ExtraStore
lambda:areaFill = LineCartesianLayer.AreaFill.double(...) { it[splitYKey] }
Additionally, the following changes have been made:
- Compose
- Views
- In
LineCartesianLayer
, bugs affecting split line styling have been resolved. BaseDynamicShader
has been removed—useDynamicShader
.
- In
LineCartesianLayer
, bugs affecting split line styling have been resolved. BaseDynamicShader
has been removed—useDynamicShader
.StaticShader
andShader.dynamic
have been removed—useShader.toDynamicShader
.