2
votes

I used https://github.com/google/charts inside my flutter app. It works great. But when i zoom on chart, the zoom happens but in the wrong place! It starts expanding keeping the left static. The effect is the chart slide under your finger zooming not in the point you are zooming to. Is there a way to zoom like you zoom on a picture on gallery?

code of my chart

Widget build(BuildContext context) {
    return new charts.LineChart(
      _chartSeriesFromChartData(seriesList),
      animate: false,
      defaultRenderer: charts.LineRendererConfig(includeArea: true, includePoints: true),
      primaryMeasureAxis: charts.NumericAxisSpec(tickProviderSpec: charts.BasicNumericTickProviderSpec(desiredTickCount: 8)),
      behaviors: [ZoomBehaviour()],
    )
1
did you find a solution? also, I wanted to zoom also the vertical axis...Karlooie

1 Answers

11
votes

You can use code like this in your code:

behaviors: [new charts.PanAndZoomBehavior()],

or if you want selection by item in our charts you can use:

behaviors: [new charts.SeriesLegend()],

and if you want use two of them maybe you can use:

behaviors: [new charts.SeriesLegend(), new charts.PanAndZoomBehavior()],