CartesianChartView

CartesianChartViewarrow-up-right is the entry point for Cartesian charts in the view system. It accepts CartesianChartarrow-up-right and CartesianChartModelProducerarrow-up-right instances, facilitates communication between them, and displays the chart. It also handles scroll and zoom and shows a placeholder when no data is available.

CartesianChartView automatically creates a chart when the layers attribute is used:

<style name="ChartStyle">
    <item name="layers"><!-- ... --></item>
    <!-- ... -->
</style>
<com.patrykandpatrick.vico.views.cartesian.CartesianChartView
    app:chartStyle="@style/ChartStyle"
    <!-- ... --> />

Use the CartesianChartView.chartarrow-up-right property to get a reference to this chart. Also use it to apply a chart created programmatically:

cartesianChartView.chart = CartesianChart(/* ... */)

You can add multiple layers by separating their names with pipes:

<style name="ChartStyle">
    <item name="layers">column|line</item>
    <!-- ... -->
</style>
<com.patrykandpatrick.vico.views.cartesian.CartesianChartView
    app:chartStyle="@style/ChartStyle"
    <!-- ... --> />

Scroll and zoom

There are XML attributes for toggling scroll and zoom:

More advanced customization uses ScrollHandlerarrow-up-right and ZoomHandlerarrow-up-right:

Scrollarrow-up-right represents scroll values—either absolute (from zero) or relative (from the current value). Scroll.Absolutearrow-up-right and Scroll.Relativearrow-up-right cover the two cases. The following factory functions are available:

AutoScrollConditionarrow-up-right defines when to scroll automatically. There are two singletons:

Zoomarrow-up-right defines zoom factors. The following singletons and factory functions are available:

While the built-in implementations cover the majority of use cases, you can create custom implementations of Scroll, AutoScrollCondition, and Zoom for more advanced behavior.

Sample charts

Last updated