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:

<com.patrykandpatrick.vico.views.chart.CartesianChartView
    android:id="@+id/cartesian_chart_view"
    app:layers="..."
    <!-- ... --> />

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

CartesianChartView has XML attributes for toggling scroll and zoom:

<com.patrykandpatrick.vico.views.chart.CartesianChartView
    android:id="@+id/cartesian_chart_view"
    app:scrollEnabled="..."
    app:zoomEnabled="..."
    <!-- ... --> />

More advanced customization is performed via ScrollHandler and ZoomHandler:

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