CartesianChart
Host
The CartesianChart host for views is CartesianChartView.
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(/* ... */)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 = zoomHandlerLast updated