You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-50Lines changed: 39 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,24 @@
1
1
# How to synchronize trackball in .NET MAUI SfCartesianChart
2
2
3
-
In this article, we described how to synchronize the trackball in multiple SfCartesian charts.
3
+
In this article, we described how to synchronize the trackball in multiple cartesian charts.
4
4
5
5
The [Trackball](https://help.syncfusion.com/maui/cartesian-charts/trackball) feature in [Syncfusion MAUI Cartesian Chart](https://help.syncfusion.com/maui/cartesian-charts/getting-started) is an interactive functionality that allows users to track and display data points on a chart as they hover over on different areas of the chart. It provides real-time feedback by showing a marker or tooltip with relevant data, such as the value of a specific point on the chart. This enhances the user experience by providing detailed information about specific data points.
6
6
7
7
**Importance of Synchronizing Trackball:**
8
8
9
9
• **Consistency**: Ensures that all charts display data for the same point in time or category, making comparisons easier.
10
+
10
11
• **Interactivity**: Enhances the user experience by allowing synchronized interactions across multiple charts.
11
12
12
13
13
14
**Steps to achieve Synchronized Trackball in .NET MAUI SfCartesianChart**
14
15
15
16
**Step 1: Set Up Multiple Charts**
17
+
16
18
Determine the number of charts you need to create to effectively visualize your data. Initialize a grid with the desired number of rows and columns.
17
19
Let’s configure the Syncfusion .NET MAUI SfCartesian Chart using this [getting started documentation](https://help.syncfusion.com/maui/cartesian-charts/getting-started) in each grid cells. Assign a unique x: Name to each of the charts. Refer to the following code example to create multiple charts in your application.
18
20
19
-
21
+
[XAML]
20
22
```xml
21
23
<Grid>
22
24
<!-- Define 3 rows for the grid layout -->
@@ -72,9 +74,10 @@ Let’s configure the Syncfusion .NET MAUI SfCartesian Chart using this [getting
72
74
73
75
74
76
**Step 2: Initialize TrackballBehavior**
75
-
Initialize TrackballBehavior for each chart and specify a unique x: Name for each of the [ChartTrackballBehavior](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartTrackballBehavior.html?tabs=tabid-3). Refer to the following code to initialize TrackballBehavior.
76
77
77
-
78
+
Initialize TrackballBehavior for each chart and specify a unique x: Name for each of the [ChartTrackballBehavior](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartTrackballBehavior.html). Refer to the following code to initialize TrackballBehavior.
@@ -85,10 +88,12 @@ Initialize TrackballBehavior for each chart and specify a unique x: Name for eac
85
88
Similarly, you have to mention for other charts also.
86
89
87
90
**Step 3: Handle the TrackballCreated events**
88
-
Handling the TrackballCreated events is crucial for synchronizing the trackball across multiple SfCartesianChart controls
89
-
[TrackballCreated Event](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_TrackballCreated): This event is triggered when the trackball is created or updated. By handling this event, you can synchronize the trackball position across multiple charts.
90
-
In your XAML, ensure that the TrackballCreated event is wired up for each chart.
91
-
91
+
92
+
Handling the TrackballCreated events is crucial for synchronizing the trackball across multiple SfCartesianChart controls.
93
+
94
+
[TrackballCreated Event](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_TrackballCreated): This event is triggered when the trackball is created or updated. By handling this event, you can synchronize the trackball position across multiple charts. In your XAML, ensure that the TrackballCreated event is wired up for each chart.
// Show the trackball markers on chart 1 and 2 at the calculated screen positions
164
-
trackBall1.Show(xPoint, yPoint);
165
-
trackBall2.Show(xPoint, yPoint);
166
-
}
147
+
HandleTrackballCreated(sender, e, thirdChart, trackBall1, trackBall2);
167
148
}
168
-
}
149
+
}
169
150
```
170
151
171
-
In the above code, we have used the [ValueToPoint(ChartAxis axis, double value)](https://help.syncfusion.com/maui/cartesian-charts/transform-axis-value-to-pixel-value-and-vice-versa) method to convert the data point value to the screen point, and the ToOADate method is used to convert the DateTime value to a double value here. Then we have to specify those points in the ChartTrackballBehavior class show method to show synchronized trackball for all charts.
152
+
In the above code, we have used the [ValueToPoint](https://help.syncfusion.com/maui/cartesian-charts/transform-axis-value-to-pixel-value-and-vice-versa) method to convert the data point value to the screen point, and the **ToOADate** method is used to convert the DateTime value to a double value here. Then we have to specify those points in the ChartTrackballBehavior class show method to show synchronized trackball for all charts.
172
153
173
154
The following demo illustrates multiple charts in .NET MAUI with synchronized trackball, showing how the trackball positions move together across all charts when interacting with any one chart, following the implemented synchronization steps.
If you are facing a path too long exception when building this example project, close Visual Studio and rename the repository to a shorter name before building the project.
165
+
166
+
For more details, refer to the KB on [How to synchronize trackball in .NET MAUI SfCartesianChart ?](https://support.syncfusion.com/agent/kb/18647)
0 commit comments