波动图PanAndZoomBehavior不会放大手势的中心 [英] Flutter charts PanAndZoomBehavior does not zoom on the center of the gesture
问题描述
我在Flutter应用程序中使用了 https://github.com/google/charts 。效果很好。但是,当我放大图表时,放大发生在错误的地方!它开始扩展并保持左静态。效果是手指缩放下的图表幻灯片不在缩放点上。有没有办法像放大图库中的图片一样进行缩放?
我的图表代码
小部件build(BuildContext context){
返回新图表。LineChart(
_chartSeriesFromChartData(seriesList),
动画:false,
defaultRenderer:chart.LineRendererConfig(includeArea:true,includePoints:true),
primaryMeasureAxis:charts.NumericAxisSpec(tickProviderSpec:charts.BasicNumericTickProviderSpec(desiredTickCount:8)),
行为:[ZoomBehaviour()] $ p>
解决方案您可以在代码中使用以下代码:
行为:[新图表。PanAndZoomBehavior()],
,或者如果您想按图表中的项目进行选择您可以使用:
行为:[new chart.SeriesLegend()],
,如果要使用其中两个,则可以使用:
行为:[new chart.SeriesLegend (),新图表。PanAndZoomBehavior()],
祝你好运编码
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()],
)
解决方案 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 luck happy coding
这篇关于波动图PanAndZoomBehavior不会放大手势的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!