Flutter charts PanAndZoomBehavior does not zoom on the center of the gesture

雨燕双飞 提交于 2020-05-14 13:14:52

问题


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:


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()],

good lock happy coding



来源:https://stackoverflow.com/questions/53223438/flutter-charts-panandzoombehavior-does-not-zoom-on-the-center-of-the-gesture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!