2.0.0-alpha.12
This release splits ThresholdLine
into two new Decoration
s, slims down ChartStyle
, improves DefaultMarkerLabelFormatter
, and includes other enhancements.
Breaking changes | Addressed |
---|---|
Moderate | #499, #614 |
HorizontalBox
and HorizontalLine
ThresholdLine
has been marked as deprecated and replaced with two new Decoration
s, HorizontalBox
(for a y range) and HorizontalLine
(for a single y value). For Jetpack Compose, rememberHorizontalBox
and rememberHorizontalLine
functions are available. HorizontalBox
and HorizontalLine
are similar to ThresholdLine
, but a few improvements have been made, and some constructor parameters have new names. The main benefit is that the y
and label
properties are ExtraStore
lambdas, enabling you to update the y values with the chart data. This enables you to easily highlight the average y value, for instance. HorizontalLine
takes a LineComponent
rather than a ShapeComponent
. The LineComponent
constructor and rememberLineComponent
take ShapeComponent
s, so to handle this change, create a LineComponent
that uses your existing ShapeComponent
. The line thickness is defined at the LineComponent
level.
VicoTheme
In the compose
module, ChartStyle
has been slimmed down to house only default colors and renamed to VicoTheme
. We made this change because given the large number of settings, adding copies of each one to ChartStyle
was starting to become inviable. VicoTheme
is simliar to MaterialTheme
in that it contains general styling information but not component-specific settings.
ProvideChartStyle
is now ProvideVicoTheme
. Note that the theme
parameter has no default value—if you need the default theme, you don’t have to use ProvideVicoTheme
at all. m2ChartStyle
and m3ChartStyle
are now rememberM2VicoTheme
and rememberM3VicoTheme
.
ProvideVicoTheme(remember(...) { VicoTheme(...) }) { ... }
ProvideVicoTheme(rememberM2VicoTheme()) { ... }
ProvideVicoTheme(rememberM3VicoTheme()) { ... }
To access the current VicoTheme
, use the vicoTheme
property (e.g., vicoTheme.textColor
).
Component-specific configuration should be done at the component level, as in the Material Design libraries for Jetpack Compose. Beyond VicoTheme
, to reuse a customized version of a component across multiple charts, you can create a wrapper for the function that creates this component and apply your styling there.
Note that unlike ChartStyle
, VicoTheme
has a shared color for axis lines and guidelines. If you need two different colors, make one of them the default, and apply the other one via rememberAxisLineComponent
or rememberAxisGuidelineComponent
.
DefaultMarkerLabelFormatter
DefaultMarkerLabelFormatter
now uses DecimalFormat
. There’s a decimalFormat
constructor parameter, which you can use to provide a custom DecimalFormat
instance and customize the pattern. Also, DefaultMarkerLabelFormatter
subclasses can now be created.
Miscellaneous
For consistency, the default value of LineComponent#thicknessDp
has been changed from 2 to 1, and the default value of rememberLineComponent
’s thickness
parameter has been changed from 8 dp to 1 dp. rememberLineComponent
used the default ColumnCartesianLayer
column width as the default thickness
value, but this was an error—LineComponent
isn’t just for ColumnCartesianLayer
columns. If you were using these defaults, you might have to explicitly specify the desired thickness.
In ColumnCartesianLayer
, the mergeMode
lambda now receives ExtraStore
s, not full ColumnCartesianLayerModel
s. Replace it.extraStore
with it
. In the unlikely event that you were performing a data-based calculation in this lambda, perform it in advance, and save the result as an extra.
rememberMarkerComponent
now has a labelFormatter
parameter.
In TextComponent
, the minimum width can now be customized—see the minWidth
properties and parameters.
We’re continuing the API cleanup. As usual, some duplicate functions have been marked as deprecated, and some APIs that Vico shouldn’t expose have been hidden.
An issue where the sample app could go blank has been resolved.