Vico

8.1. Starter examples

8.1.1. Column chart

<com.patrykandpatrick.vico.views.cartesian.CartesianChartView
    android:id="@+id/cartesian_chart_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layers="column"
    app:showBottomAxis="true"
    app:showStartAxis="true" />

At the top level of the Activity:

val modelProducer = CartesianChartModelProducer()

In onCreate:

cartesianChartView.modelProducer = modelProducer
lifecycleScope.launch {
    modelProducer.runTransaction { columnSeries { series(4, 12, 8, 16) } }
}

8.1.2. Line chart

<com.patrykandpatrick.vico.views.cartesian.CartesianChartView
    android:id="@+id/cartesian_chart_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layers="line"
    app:showBottomAxis="true"
    app:showStartAxis="true" />

At the top level of the Activity:

val modelProducer = CartesianChartModelProducer()

In onCreate:

cartesianChartView.modelProducer = modelProducer
lifecycleScope.launch {
    modelProducer.runTransaction { lineSeries { series(4, 12, 8, 16) } }
}

8.1.3. More

Refer to the sample app—see “Sample app” under “Learning resources” in the preface.