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!

  • Check out the features or bugs others have reported and vote on your favorites. Feedback will be prioritized based on popularity.
  • If you have feedback that’s not listed yet, submit your own.

Thanks for joining our community and helping improve Syncfusion products!

0
Votes

If you touch the line in this sample, an exception will be thrown, because
pixelToPoint
looks for discrete DateTime values, but you most probably click between them.

import 'package:flutter/material.dart';
import 'package:syncfusion_flutter_charts/charts.dart';

void main() {
return runApp(_ChartApp());
}

class _ChartApp extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return _ChartAppState();
}
}

class _ChartAppState extends State<_ChartApp> {
ChartSeriesController? chartSeriesController;

@override
Widget build(BuildContext context) {
final List<SalesData> chartData1 = [
SalesData(DateTime(2024, 1, 1), 35),
SalesData(DateTime(2024, 1, 2), 28),
SalesData(DateTime(2024, 1, 3), 34),
SalesData(DateTime(2024, 1, 4), 32),
SalesData(DateTime(2024, 1, 5), 40)
];

return MaterialApp(
home: SfCartesianChart(
primaryXAxis: const DateTimeAxis(),
legend: const Legend(isVisible: true),
onChartTouchInteractionMove: (args) {
final Offset value = Offset(args.position.dx, args.position.dy);
final pixelToPoint = chartSeriesController?.pixelToPoint(value);
debugPrint('pixelToPoint: ${pixelToPoint?.x}, ${pixelToPoint?.y}');
},
series: <CartesianSeries>[
// Renders line chart
SplineSeries<SalesData, DateTime>(
name: 'Line 1',
animationDuration: 0,
dataSource: chartData1,
xValueMapper: (SalesData sales, _) => sales.year,
yValueMapper: (SalesData sales, _) => sales.sales,
onRendererCreated: (controller) => chartSeriesController = controller,
),
],
),
);
}
}

class SalesData {
SalesData(this.year, this.sales);

final DateTime year;
final double sales;
}