2.0.0-alpha.7
This release introduces label position customization for MarkerComponent
, dynamic HorizontalAxis
label spacing, and other improvements.
Breaking changes | Addressed | Contributors |
---|---|---|
Minor | #553, #563 | @MessiasLima |
MarkerComponent
In MarkerComponent
, the label position can now be customized. This is achieved via the constructor’s labelPosition
parameter. Three options are available: Top
, AroundPoint
, and AbovePoint
. Top
corresponds to the behavior from previous Vico versions and is the default.
A labelPosition
parameter is also available in rememberMarkerComponent
, which uses remember
and replaces markerComponent
. markerComponent
has been marked as deprecated.
All private MarkerComponent
members are now protected, which simplifies subclassing.
HorizontalAxis
Automatic padding for extreme HorizontalAxis
labels has been improved. Rather than considering only labels for ChartValues#minX
and ChartValues#maxX
, it considers the first label and the last label, whatever their x values are.
We’re also introducing dynamic label spacing, which automatically adjusts the label spacing based on the zoom factor, preventing truncation:
- Compose
- Views
Dynamic label spacing is turned on automatically when you apply HorizontalLayout.FullWidth
and use true
for the addExtremeLabelPadding
parameter of AxisItemPlacer.Horizontal.default
.
Dynamic label spacing is turned on automatically when you use fullWidth
for the horizontalLayout
XML attribute, and true
for the addExtremeHorizontalAxisLabelPadding
attribute.
This required changes to AxisItemPlacer.Horizontal
. (If you don’t have a custom AxisItemPlacer.Horizontal
implementation, skip to “Miscellaneous.”)
2.0.0-alpha.6 | 2.0.0-alpha.7 |
---|---|
getAddFirstLabelPadding | getFirstLabelValue |
getAddLastLabelPadding | getLastLabelValue |
getMeasuredLabelValues | getWidthMeasurementLabelValues , getHeightMeasurementLabelValues |
To keep your existing AxisItemPlacer.Horizontal
implementation’s behavior, do the following:
- If
getAddFirstLabelPadding
returnedtrue
, havegetFirstLabelValue
returncontext.chartValues.minX
. Otherwise, don’t overridegetFirstLabelValue
. - If
getAddLastLabelPadding
returnedtrue
, havegetLastLabelValue
returncontext.chartValues.maxX
. Otherwise, don’t overridegetLastLabelValue
. - Override
getWidthMeasurementLabelValues
and have it returnemptyList()
. - Copy the body of
getMeasuredLabelValues
togetHeightMeasurementLabelValues
.
Miscellaneous
An issue where excessive trailing empty space could appear in charts has been resolved.
AxisRenderer
and Axis
have been renamed to Axis
and BaseAxis
, respectively. This is for consistency with CartesianLayer
and BaseCartesianLayer
. If you’re using Vico with views, you might have as Axis
in a few places. Where this stops working, replace it with as BaseAxis
.
Several utility APIs that Vico shouldn’t expose have been hidden.