Skip to main content

2.0.0-alpha.26

This release includes updates to LineCartesianLayer’s split line styling.

Breaking changesAddressed
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 DynamicShaders 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.

rememberLine’s shader and backgroundShader parameters have been replaced with fill and areaFill parameters. Fills are created via the fill function, which takes a Color 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 DynamicShaders, 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 DynamicShaders, 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:

  • In LineCartesianLayer, bugs affecting split line styling have been resolved.
  • BaseDynamicShader has been removed—use DynamicShader.