Skip to content

Commit 0b887db

Browse files
commit
1 parent 757ebfb commit 0b887db

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

DisplayTrackballValues/DisplayTrackballValues/MainPage.xaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,25 @@
3535

3636
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
3737
x:Name="series1"
38-
StrokeWidth="3"
3938
XBindingPath="Date"
4039
YBindingPath="ProductASales"
40+
StrokeWidth="3"
4141
ShowTrackballLabel="True"
4242
Label="Product A"
4343
Fill="RoyalBlue"/>
4444
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
4545
x:Name="series2"
46-
StrokeWidth="3"
4746
XBindingPath="Date"
4847
YBindingPath="ProductBSales"
48+
StrokeWidth="3"
4949
ShowTrackballLabel="True"
5050
Label="Product B"
5151
Fill="HotPink"/>
5252
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
5353
x:Name="series3"
54-
StrokeWidth="3"
5554
XBindingPath="Date"
5655
YBindingPath="ProductCSales"
56+
StrokeWidth="3"
5757
ShowTrackballLabel="True"
5858
Label="Product C"
5959
Fill="Green"/>

DisplayTrackballValues/DisplayTrackballValues/MainPage.xaml.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
2828
StrokeWidth = 3,
2929
Type = ShapeType.InvertedTriangle
3030
};
31+
3132
dateLabel1.SetBinding(Label.TextProperty, new Binding("Date") { Source = item.DataItem, StringFormat = "{0:dd/MM/yyyy}" });
3233
valueLabel1.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
3334
}
@@ -43,6 +44,7 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
4344
StrokeWidth = 3,
4445
Type = ShapeType.Cross
4546
};
47+
4648
dateLabel2.SetBinding(Label.TextProperty, new Binding("Date") { Source = item.DataItem, StringFormat = "{0:dd/MM/yyyy}" });
4749
valueLabel2.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
4850
}
@@ -58,6 +60,7 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
5860
StrokeWidth = 3,
5961
Type = ShapeType.Diamond
6062
};
63+
6164
dateLabel3.SetBinding(Label.TextProperty, new Binding("Date") { Source = item.DataItem, StringFormat = "{0:dd/MM/yyyy}" });
6265
valueLabel3.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
6366
}

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# How to display X and Y values of trackball moving trace in layout in .NET MAUI Cartesian Chart
1+
# How to display X and Y values of trackball moving trace in Labels in .NET MAUI Cartesian Chart
22

3-
The [.NET MAUI Cartesian Chart](https://www.syncfusion.com/maui-controls/maui-charts) allows you to display X and Y values of trackball moving trace in layout. This can be achieved using the [TrackballCreated](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_TrackballCreated) event provided by the [SfCartesianChart](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html).
3+
The [.NET MAUI Cartesian Chart](https://www.syncfusion.com/maui-controls/maui-charts) allows you to display X and Y values of trackball moving trace in Labels. This can be achieved using the [TrackballCreated](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_TrackballCreated) event provided by the [SfCartesianChart](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html).
44

55
**Step 1 :** Initialize the SfCartesianChart with [Trackball Behavior](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.ChartTrackballBehavior.html), Create the [TrackballCreated](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_TrackballCreated) event, which is triggered when the trackball moves from one data point to another. Refer to the [documentation](https://help.syncfusion.com/maui/cartesian-charts/getting-started) for detailed steps on initializing the SfCartesianChart.
66

@@ -32,25 +32,25 @@ The [.NET MAUI Cartesian Chart](https://www.syncfusion.com/maui-controls/maui-c
3232
3333
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
3434
x:Name="series1"
35-
StrokeWidth="3"
3635
XBindingPath="Date"
3736
YBindingPath="ProductASales"
37+
StrokeWidth="3"
3838
ShowTrackballLabel="True"
3939
Label="Product A"
4040
Fill="RoyalBlue"/>
4141
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
4242
x:Name="series2"
43-
StrokeWidth="3"
4443
XBindingPath="Date"
4544
YBindingPath="ProductBSales"
45+
StrokeWidth="3"
4646
ShowTrackballLabel="True"
4747
Label="Product B"
4848
Fill="HotPink"/>
4949
<chart:LineSeries ItemsSource="{Binding ProductSalesDetails}"
5050
x:Name="series3"
51-
StrokeWidth="3"
5251
XBindingPath="Date"
5352
YBindingPath="ProductCSales"
53+
StrokeWidth="3"
5454
ShowTrackballLabel="True"
5555
Label="Product C"
5656
Fill="Green"/>
@@ -175,12 +175,14 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
175175
StrokeWidth = 3,
176176
Type = ShapeType.InvertedTriangle
177177
};
178+
178179
// Bind the date label to the date from the data item with a specific format
179180
dateLabel1.SetBinding(Label.TextProperty, new Binding("Date")
180181
{
181182
Source = item.DataItem,
182183
StringFormat = "{0:dd/MM/yyyy}"
183184
});
185+
184186
// Bind the value to the label from the item
185187
valueLabel1.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
186188
}
@@ -197,12 +199,14 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
197199
StrokeWidth = 3,
198200
Type = ShapeType.Cross
199201
};
202+
200203
// Bind the date label to the date from the data item with a specific format
201204
dateLabel2.SetBinding(Label.TextProperty, new Binding("Date")
202205
{
203206
Source = item.DataItem,
204207
StringFormat = "{0:dd/MM/yyyy}"
205208
});
209+
206210
// Bind the value to the label from the item
207211
valueLabel2.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
208212
}
@@ -219,12 +223,14 @@ private void chart_TrackballCreated(object sender, TrackballEventArgs e)
219223
StrokeWidth = 3,
220224
Type = ShapeType.Diamond
221225
};
226+
222227
// Bind the date label to the date from the data item with a specific format
223228
dateLabel3.SetBinding(Label.TextProperty, new Binding("Date")
224229
{
225230
Source = item.DataItem,
226231
StringFormat = "{0:dd/MM/yyyy}"
227232
});
233+
228234
// Bind the value to the label from the item
229235
valueLabel3.SetBinding(Label.TextProperty, new Binding("Label") { Source = item });
230236
}

0 commit comments

Comments
 (0)