Skip to content

point selection index is wrong in Spline series #2377

Open
@amjad-haffar

Description

@amjad-haffar

Bug description

there is a bug in onPointTap function , it get the wrong index of the point im clicking only in spline series as i tested

Steps to reproduce

when i use the line series there is function inside of it called onPointTap()
this is working perfectly , you click the point you want to select and then print(details.pointIndex)
you get the right index printed
but when you do this in SplineSeries you get wrong index its kind of shifting back with 1 index
I'm using the latest version of the package

Code sample

Code sample
SfCartesianChart(
          tooltipBehavior: tooltipBehavior,
          enableAxisAnimation: true,
          primaryYAxis: NumericAxis(
            labelFormat: '{value}',
            axisLine: AxisLine(width: 1, color: ColorManager.grey),
            majorGridLines: MajorGridLines(width: 1, color: ColorManager.grey),
            labelStyle: Utils(context).primarySmallText,
          ),
          primaryXAxis: CategoryAxis(
            rangePadding: ChartRangePadding.none,
            majorGridLines: MajorGridLines(width: 1, color: ColorManager.grey),
            axisLine: AxisLine(width: 1, color: ColorManager.grey),
          ),
          series: <CartesianSeries<dynamic, String>>[
            SplineSeries<dynamic, String>(
              splineType: SplineType.monotonic,
              onPointTap: (ChartPointDetails details) {
                setState(() {
                  if (isDaysChart) {
                    selectedIndexDays = details.pointIndex!;
                  } else {
                    selectedIndexHours = details.pointIndex!;
                  }
                });
                WidgetsBinding.instance.addPostFrameCallback((_) {
                  tooltipBehavior.showByIndex(
                    details.seriesIndex!,
                    details.pointIndex!,
                  );
                });
              },
              markerSettings:
                  MarkerSettings(isVisible: true, color: Utils(context).white),
              dataSource: filteredData,
              xValueMapper: (value, _) => value.label,
              yValueMapper: (value, _) => value.percentage,
              pointColorMapper: (d, index) {
                final isSelected = isDaysChart
                    ? selectedIndexDays == index
                    : selectedIndexHours == index;
                return isSelected
                    ? Utils(context).secondary
                    : Utils(context).primary;
              },
              dataLabelSettings: const DataLabelSettings(isVisible: false),
              animationDelay: 0.0,
              animationDuration: 2000,
            ),
          ],
        ),

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Stack Traces

Stack Traces
[Add the Stack Traces here]

On which target platforms have you observed this bug?

Android

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.29.3, on Microsoft Windows [Version 10.0.26100.2894], locale en-US)
[√] Windows Version (11 Pro 64-bit, 24H2, 2009)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.36)
[√] Android Studio (version 2023.3)
[√] VS Code (version 1.101.0)
[√] Connected device (4 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchartsCharts componentfollow-up scheduledFollow-up scheduled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions