How to disable a trackball for a specific series?

Hi,

I'm looking for a way to show the Track-Ball only on a specific series. 
Actually I have a list of ChartSeries in which I have an AreaSeries and a LineSeries, but I would like to show the trackball of only AreaSeries. How can I do that?

Thank you in advance,
Paolo.

8 Replies

SK Sriram Kiran Senthilkumar Syncfusion Team June 3, 2020 09:37 AM UTC

Hi Paolo, 

Greetings from Syncfusion. We have analyzed your scenario and we have created a simple chart sample which contains an area series and a line series, and the trackball tooltip will be rendered only for the area series in the chart. This scenario can be achieved using the onTrackballPositionChanging event available in the chart. We can customize the trackball based on the requirement, here we have passed the empty string to header and label when the series is area. Please refer the code snippet below for reference. 
SfCartesianChart( 
            onTrackballPositionChanging: (TrackballArgs args) { 
              ChartSeries<dynamic, dynamic> series = args.chartPointInfo.series; 
              if (series.runtimeType.toString().toLowerCase().contains('range')) { 
                args.chartPointInfo.header = ''; 
                args.chartPointInfo.label = ''; 
             
            }, 
            primaryXAxis: CategoryAxis(), 
            trackballBehavior: TrackballBehavior(enable: true), 
            series: <ChartSeries<SalesData, String>> [ 
              AreaSeries<SalesData, String> (// your configuration), 
              LineSeries<SalesData, String>(// your configuration ) 
           

Screenshot 
  
The sample for reference can be found below, 
For further reference on onTrackballPositionChanging event, please refer the user guide below. 

Regards, 
Sriram Kiran 



PA Paolo June 4, 2020 08:53 AM UTC

Amazing solution. Thank you for the fast and exhaustive answer!

Paolo.


SK Sriram Kiran Senthilkumar Syncfusion Team June 5, 2020 03:43 PM UTC

Hi Paolo, 
  
Most welcome. We are always happy in assisting you. Kindly get back to us if you have further queries.. 
  
Regards, 
Sriram Kiran. 



KA Kathiravan March 13, 2021 05:15 PM UTC

I have two line series and two scatter series. i want to hide both the scatter series label but last they are not hiding. Am i doing any mistake?


onTrackballPositionChanging: (TrackballArgs args) {

ChartSeries<dynamic, dynamic> series = args.chartPointInfo.series;
if(series.runtimeType.toString().toLowerCase().contains('line1')){
final double overs = args.chartPointInfo.chartDataPoint.x;
final int run = args.chartPointInfo.chartDataPoint.y.toInt();
// args.chartPointInfo.header = '';
args.chartPointInfo.label = 'Aus - Ov: ' + overs.toString() + " Run: " + run.toString();
print("line 01");
}
if(series.runtimeType.toString().toLowerCase().contains('line')){
           
final double overs = args.chartPointInfo.chartDataPoint.x;
final int run = args.chartPointInfo.chartDataPoint.y.toInt();
// args.chartPointInfo.header = '';
args.chartPointInfo.label = 'Aus - Ov: ' + overs.toString() + " Run: " + run.toString();
print("line");
}
if(series.runtimeType.toString().toLowerCase().contains('bubble1')){
           
args.chartPointInfo.header = '';
args.chartPointInfo.label = '';
print("bubble 01");
}
if(series.runtimeType.toString().toLowerCase().contains('bubble')){
           
args.chartPointInfo.header = '';
args.chartPointInfo.label = '';
print("bubble");
}
String name = args.chartPointInfo.series.name;
// if(series.runtimeType.toString().toLowerCase().contains('line1')){
if (name == "line1"){
final double overs = args.chartPointInfo.chartDataPoint.x;
final int run = args.chartPointInfo.chartDataPoint.y.toInt();
args.chartPointInfo.label = 'Aus - Ov: ' + overs.toString() + " Run: " + run.toString();
print("line 01");
}
// if(series.runtimeType.toString().toLowerCase().contains('line')){
if (name == "line"){
final double overs = args.chartPointInfo.chartDataPoint.x;
final int run = args.chartPointInfo.chartDataPoint.y.toInt();
args.chartPointInfo.label = 'Ind - Ov: ' + overs.toString() + " Run: " + run.toString();
print("line");
}
// if(series.runtimeType.toString().toLowerCase().contains('bubble1')){
if (name == "bubble1"){
args.chartPointInfo.header = '';
args.chartPointInfo.label = '';
print("bubble 01");
}
// if(series.runtimeType.toString().toLowerCase().contains('bubble')){
if (name == "bubble"){
args.chartPointInfo.header = '';
args.chartPointInfo.label = '';
print("bubble");
}
},
series: <CartesianSeries>[
LineSeries<_ChartData, double>(
// markerSettings: MarkerSettings(isVisible: true),
name: "line1",
animationDuration: 2500,
dataSource: chartData,
xValueMapper: (_ChartData sales, _) => sales.x,
yValueMapper: (_ChartData sales, _) => sales.y,

/// The property used to apply the color each data.
pointColorMapper: (_ChartData sales, _) => sales.lineColor,
width: 2),
LineSeries<_ChartData, double>(
name: "line",
animationDuration: 2500,
dataSource: chartData2,
xValueMapper: (_ChartData sales, _) => sales.x,
yValueMapper: (_ChartData sales, _) => sales.y,

/// The property used to apply the color each data.
pointColorMapper: (_ChartData sales, _) => sales.lineColor,
width: 2),
ScatterSeries<_WicketData, double>(
name: "bubble1",
// enableTooltip: true,
dataSource: wicketData,
pointColorMapper:(_WicketData sales, _) => sales.lineColor,
xValueMapper: (_WicketData sales, _) => sales.x,
yValueMapper: (_WicketData sales, _) => sales.y
),
ScatterSeries<_WicketData, double>(
color: Colors.blue,
markerSettings: MarkerSettings(
color: Colors.blue,
height: 10,
width: 10,
// Scatter will render in diamond shape
shape: DataMarkerType.diamond
),
name: "bubble",
// enableTooltip: false,
dataSource: wicketData2,
// pointColorMapper:(_WicketData sales, _) => sales.lineColor,
xValueMapper: (_WicketData sales, _) => sales.x,
yValueMapper: (_WicketData sales, _) => sales.y
)
],
trackballBehavior: TrackballBehavior(
enable: true,
activationMode: ActivationMode.singleTap,
lineType: TrackballLineType.vertical,
tooltipSettings: InteractiveTooltip(format: 'point.x : point.y')
),


DP Dharanitharan Palanisamy Syncfusion Team March 15, 2021 08:37 AM UTC

Hi Kathiravan,

We have analyzed your scenario and the issue is replicated at our end. We regret the inconvenience that occurs, and we will resolve this and include it in our upcoming main release which is expected to be rolled out at the end of March 2021. We appreciate your patience until then.

Thanks,
Dharanitharan. P


KA Kathiravan March 15, 2021 03:29 PM UTC

Thank you for your response.


DP Dharanitharan Palanisamy Syncfusion Team March 16, 2021 05:25 AM UTC

Hi Kathiravan, 
 
Most welcome, we are always happy in assisting you and please revert us if you have any further queries. 
 
Thanks, 
Dharanitharan. P 



DP Dharanitharan Palanisamy Syncfusion Team April 1, 2021 06:39 AM UTC

Hi Kathiravan, 
 
Thanks for being patience and we are glad to inform you that the reported issue got resolved and included in our volume1 main release. Now, the trackball tooltip properly hides. To resolve this, you can upgrade our charts from the below link. 
 
 
Thanks, 
Dharanitharan. P 


Loader.
Up arrow icon