Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onTrackballPositionChanging #65

Closed
anisalibegic opened this issue Dec 18, 2019 · 4 comments
Closed

onTrackballPositionChanging #65

anisalibegic opened this issue Dec 18, 2019 · 4 comments

Comments

@anisalibegic
Copy link

Every time I click on a point using trackball the onTrackballPositionChanging callback is fired for every other point. After that I have no idea on which point I clicked...

Is there a way to find out the index of the point I clicked on using trackball?

@dharanidharandharmasivam
Copy link
Contributor

Hi @anisalibegic ,

Greetings from Syncfusion. Yes, we can find the point index when you click on a point with trackball enabled. This can be achieved using the onTrackballPositionChanging event. In this event, we can get the point index on which we have tapped. We have printed the index value, and this can be changed based on your scenario. Find the code snippet below.

SfCartesianChart(
onTrackballPositionChanging: (TrackballArgs args) {
print(args.chartPointInfo.dataPointIndex.toString());
},
)

Sample for reference can be found from the below link.
https://www.syncfusion.com/downloads/support/directtrac/general/ze/sample683015834

Hope this helps.

Thanks,
Dharani.

@anisalibegic
Copy link
Author

Hi @dharanidharandharmasivam!

I think I found an issue with onTrackballPositionChanging. Open your sample and hide the primaryXAxis like this:

primaryXAxis: NumericAxis(
    isVisible: false,
),
primaryYAxis: NumericAxis(
   isVisible: true,
),

After that whenever you click on a point I get the following output:

I/flutter (18909): 0
I/flutter (18909): 0
I/flutter (18909): 1
I/flutter (18909): 0
I/flutter (18909): 1
I/flutter (18909): 2
I/flutter (18909): 0
I/flutter (18909): 1
I/flutter (18909): 2
I/flutter (18909): 3
I/flutter (18909): 0
I/flutter (18909): 1
I/flutter (18909): 2
I/flutter (18909): 3
I/flutter (18909): 4

If you change the visibility of primaryXAxis to true then it prints the correct output:

I/flutter (18909): 2

Complete code:

SfCartesianChart(
  trackballBehavior: TrackballBehavior(enable: true, activationMode: ActivationMode.singleTap),
  onTrackballPositionChanging: (TrackballArgs args) {
    print(args.chartPointInfo.dataPointIndex.toString());
  },
  primaryXAxis: NumericAxis(
    isVisible: false,
  ),
  primaryYAxis: NumericAxis(
    isVisible: true,
  ),
  series: <ChartSeries<ChartData, num>>[
    LineSeries<ChartData, num>(
      dataSource: [
        ChartData(1, 16),
        ChartData(2, 23),
        ChartData(3, 19),
        ChartData(4, 29),
        ChartData(5, 24),
      ],
      xValueMapper: (ChartData tendencias, _) => tendencias.mes,
      yValueMapper: (ChartData tendencias, _) => tendencias.vendas,
    )
  ],
)

@dharanidharandharmasivam
Copy link
Contributor

Hi @anisalibegic ,

We have analyzed your query and we can replicate the reported scenario when the axis visibility is disabled. We will fix the reported scenario and include in our vol 4 sp1 release which is expected to be out at the end of January 2020.

As a workaround, if you wish to hide the axis elements like axis line, ticks, and labels, specify the color to transparent and the space for the axis labels and ticks remains the same. You can find the code snippet for the workaround from below to hide the axis elements.

 SfCartesianChart(
      primaryXAxis: NumericAxis(
        axisLine: AxisLine(color: Colors.transparent),
        majorTickLines: MajorTickLines(color: Colors.transparent),
        labelStyle: ChartTextStyle(color: Colors.transparent)
      ),
      // Other configuration
    )

Hope this helps.

Thanks,
Dharani.

@dharanidharandharmasivam
Copy link
Contributor

Hi @anisalibegic ,

Thanks for being patience. The trackball issue has been fixed, now trackball event will be triggered for the tapped point when the axis visibility is hidden. To resolve the reported issue kindly upgrade the chart widget package to v17.4.43 from below.

https://pub.dev/packages/syncfusion_flutter_charts/versions/17.4.43

Thanks,
Dharani.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants