Welcome to the Flutter feedback portal. We’re happy you’re here! If you have feedback on how to improve the Flutter, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
It seem that the onZooming event has some problems.
First, the previousZoomPosition and previousZoomFactor are always null.
Second, the event always fire twice: a correct event and a event always have currentZoomFactor = 1.0.
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
import 'package:intl/intl.dart';
void main() {
runApp(MaterialApp(
home: TestPage(),
));
}
class TestPage extends StatefulWidget {
@override
_TestPageState createState() => _TestPageState();
}
class _TestPageState extends State<TestPage> {
Future future;
@override
void initState() {
super.initState();
future = Future.delayed(Duration(seconds: 1));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: SfCartesianChart(
series: [
LineSeries<Datum, DateTime>(
dataSource: [
Datum(DateTime(2020, 7, 1), 3),
Datum(DateTime(2020, 7, 2), 1),
Datum(DateTime(2020, 7, 3), 4),
Datum(DateTime(2020, 7, 4), 8),
Datum(DateTime(2020, 7, 5), 5),
Datum(DateTime(2020, 7, 6), 1),
Datum(DateTime(2020, 7, 7), 3),
Datum(DateTime(2020, 7, 8), 7),
Datum(DateTime(2020, 7, 9), 2),
],
xValueMapper: (Datum datum, _) => datum.x,
yValueMapper: (Datum datum, _) => datum.y,
markerSettings: MarkerSettings(
isVisible: true,
),
),
],
primaryXAxis: DateTimeAxis(
dateFormat: DateFormat.Md().add_Hm(),
zoomPosition: 1,
zoomFactor: 0.2,
),
primaryYAxis: NumericAxis(
anchorRangeToVisiblePoints: false,
),
zoomPanBehavior: ZoomPanBehavior(
enablePanning: true,
enablePinching: true,
zoomMode: ZoomMode.x,
),
onZooming: (arg) => print('ZoomFactor: ${arg.previousZoomFactor} --> ${arg.currentZoomFactor}, ZoomPosition: ${arg.previousZoomPosition} --> ${arg.currentZoomPosition}'),
),
);
}
}
class Datum {
DateTime x;
num y;
Datum(this.x, this.y);
}
output:
I/flutter ( 9567): ZoomFactor: null --> 0.9030837004407247, ZoomPosition: null --> 0.07291226251672815
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0
I/flutter ( 9567): ZoomFactor: null --> 0.8991228070174323, ZoomPosition: null --> 0.07589212970521715
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0
I/flutter ( 9567): ZoomFactor: null --> 0.8991228070174323, ZoomPosition: null --> 0.07589212970521715
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0
I/flutter ( 9567): ZoomFactor: null --> 0.8951965065500471, ZoomPosition: null --> 0.07884597185240852
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0
I/flutter ( 9567): ZoomFactor: null --> 0.8951965065500471, ZoomPosition: null --> 0.07884597185240852
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0
I/flutter ( 9567): ZoomFactor: null --> 0.8913043478262866, ZoomPosition: null --> 0.08177412841549626
I/flutter ( 9567): ZoomFactor: null --> 1.0, ZoomPosition: null --> 0.0