Skip to main content

2.0.0-alpha.7

This release introduces label position customization for MarkerComponent, dynamic HorizontalAxis label spacing, and other improvements.

Breaking changesAddressedContributors
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:

Dynamic label spacing is turned on automatically when you apply HorizontalLayout.FullWidth and use true for the addExtremeLabelPadding parameter of AxisItemPlacer.Horizontal.default.

This required changes to AxisItemPlacer.Horizontal. (If you don’t have a custom AxisItemPlacer.Horizontal implementation, skip to “Miscellaneous.”)

2.0.0-alpha.62.0.0-alpha.7
getAddFirstLabelPaddinggetFirstLabelValue
getAddLastLabelPaddinggetLastLabelValue
getMeasuredLabelValuesgetWidthMeasurementLabelValues, getHeightMeasurementLabelValues

To keep your existing AxisItemPlacer.Horizontal implementation’s behavior, do the following:

  • If getAddFirstLabelPadding returned true, have getFirstLabelValue return context.chartValues.minX. Otherwise, don’t override getFirstLabelValue.
  • If getAddLastLabelPadding returned true, have getLastLabelValue return context.chartValues.maxX. Otherwise, don’t override getLastLabelValue.
  • Override getWidthMeasurementLabelValues and have it return emptyList().
  • Copy the body of getMeasuredLabelValues to getHeightMeasurementLabelValues.

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.