Vico

8.2. CartesianChart

8.2.1. Host

The CartesianChart host for views is CartesianChartView.

8.2.2. Creation

CartesianChartView automatically creates a CartesianChart 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 CartesianChartView.chart property to get a reference to this CartesianChart. Also use it to apply a programmatically created CartesianChart:

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

8.2.3. Scroll and zoom

There are XML attributes for toggling scroll and zoom:

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

More advanced customization is performed via ScrollHandler and ZoomHandler:

val scrollHandler = ScrollHandler(/* ... */)
val zoomHandler = ZoomHandler(/* ... */)
cartesianChartView.scrollHandler = scrollHandler
cartesianChartView.zoomHandler = zoomHandler