Skip to content

Commit a4472b5

Browse files
Aligned
1 parent e2439ef commit a4472b5

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

GetDataPointsSample/SelectionZoomEvent.xaml.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ private void Chart_SelectionZoomDelta(object sender, ChartSelectionZoomDeltaEven
1919
{
2020
if (series is ScatterSeries scatterSeries)
2121
{
22-
2322
var rect = new Rect(e.ZoomRect.X - cartesianChart.SeriesBounds.Left, e.ZoomRect.Y, e.ZoomRect.Width, e.ZoomRect.Height);
2423
var dataPoints = scatterSeries.GetDataPoints(rect);
2524

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ Initialize the [SelectionZoomDelta](https://help.syncfusion.com/cr/maui/Syncfus
146146
</chart:SfCartesianChart.YAxes>
147147

148148
<chart:SfCartesianChart.Series>
149-
<chart:ScatterSeries ItemsSource="{Binding Data}" XBindingPath="XValue"
149+
<chart:ScatterSeries ItemsSource="{Binding Data}"
150+
XBindingPath="XValue"
150151
YBindingPath="YValue">
151152
<chart:ScatterSeries.SelectionBehavior>
152153
<chart:DataPointSelectionBehavio
@@ -161,7 +162,6 @@ Initialize the [SelectionZoomDelta](https://help.syncfusion.com/cr/maui/Syncfus
161162
**Step 2: Handle the interaction**
162163
The [SelectionZoomDelta](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_SelectionZoomDelta) event is activated during the process of selecting a region in the chart area. Inside the event handler, retrieve the selecting area rectangle values. Then, use the [GetDataPoints](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.CartesianSeries.html#Syncfusion_Maui_Charts_CartesianSeries_GetDataPoints_Microsoft_Maui_Graphics_Rect_) method to retrieve the data points that fall inside the rectangle. Update the indexes of these data points in the [SelectedIndexes](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSelectionBehavior.html#Syncfusion_Maui_Charts_ChartSelectionBehavior_SelectedIndex) property of [ChartSelectionBehavior.](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartSelectionBehavior.html)
163164

164-
165165
```csharp
166166
private void Chart_SelectionZoomDelta(object sender, ChartSelectionZoomDeltaEventArgs e)
167167
{
@@ -173,7 +173,6 @@ private void Chart_SelectionZoomDelta(object sender, ChartSelectionZoomDeltaEven
173173
{
174174
if (series is ScatterSeries scatterSeries)
175175
{
176-
177176
var rect = new Rect(e.ZoomRect.X - cartesianChart.SeriesBounds.Left, e.ZoomRect.Y, e.ZoomRect.Width, e.ZoomRect.Height);
178177
var dataPoints = scatterSeries.GetDataPoints(rect);
179178

@@ -192,11 +191,9 @@ private void Chart_SelectionZoomDelta(object sender, ChartSelectionZoomDeltaEven
192191

193192
}
194193
```
195-
196194
**Step 3: Cancel the zoom**
197195
The [SelectionZoomEnd](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_ZoomEnd) event is invoked when selecting a region from the chart area. Inside the event handler, set the [ZoomFactor](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartAxis.html#Syncfusion_Maui_Charts_ChartAxis_ZoomFactor) to 1 and the [ZoomPosition](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartAxis.html#Syncfusion_Maui_Charts_ChartAxis_ZoomPosition) to 0. This helps cancel the zoom.
198196

199-
200197
```csharp
201198
private void Chart_SelectionZoomEnd(object sender, ChartSelectionZoomEventArgs e)
202199
{
@@ -206,6 +203,4 @@ private void Chart_SelectionZoomEnd(object sender, ChartSelectionZoomEventArgs e
206203
secondaryAxis.ZoomPosition = 0;
207204
}
208205
```
209-
210-
211206
![Selection_zoom.gif](https://support.syncfusion.com/kb/agent/attachment/article/16174/inline?token=eyJhbGciOiJodHRwOi8vd3d3LnczLm9yZy8yMDAxLzA0L3htbGRzaWctbW9yZSNobWFjLXNoYTI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjI0ODUzIiwib3JnaWQiOiIzIiwiaXNzIjoic3VwcG9ydC5zeW5jZnVzaW9uLmNvbSJ9.mcnMg6jPkXsxDZqv152Z1mzVSk-CI-62kO_T0Alylsk)

0 commit comments

Comments
 (0)