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
+93-3Lines changed: 93 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# How to create and dynamically update target line for .NET MAUI Cartesian Chart
2
-
This article provides a detailed walkthrough on how to add arrows to the axis using Annotations in [.NET MAUI Cartesian Chart](https://www.syncfusion.com/maui-controls/maui-cartesian-charts).
2
+
This article provides a detailed walkthrough on how to add and dynamically update a target line using annotations in [.NET MAUI Cartesian Chart](https://www.syncfusion.com/maui-controls/maui-cartesian-charts).
3
3
4
4
The [SfCartesianChart](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html) includes support for [Annotations](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.SfCartesianChart.html#Syncfusion_Maui_Charts_SfCartesianChart_Annotations), enabling the addition of various types of annotations to enhance chart visualization. Using [HorizontalLineAnnotation](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.Charts.HorizontalLineAnnotation.html), you can create and dynamically adjust the target line.
5
5
@@ -115,7 +115,7 @@ internal class ViewModel : INotifyPropertyChanged
115
115
}
116
116
```
117
117
118
-
**Step 4:** The second column of the grid layout contains a VerticalStackLayout with a Slider and an Entry box, allowing the user to change the annotation value dynamically.
118
+
**Step 4:** The second column of the grid layout contains a VerticalStackLayout with a Slider and an Entry box, allowing the user to change the annotation value dynamically. The Entry_TextChanged event validates input, ensuring values stay within the bounds defined by the Y_Axis.
119
119
120
120
**XAML**
121
121
@@ -129,6 +129,96 @@ internal class ViewModel : INotifyPropertyChanged
if (double.TryParse(e.NewTextValue, outdoublenewValue))
150
+
{
151
+
if (newValue>maxValue)
152
+
{
153
+
entry.Text=e.OldTextValue;
154
+
}
155
+
}
156
+
else
157
+
{
158
+
entry.Text=e.OldTextValue;
159
+
}
160
+
}
161
+
}
162
+
}
163
+
```
164
+
165
+
**Step 5:** This XAML code defines a grid layout with a [SfCartesianChart](https://help.syncfusion.com/maui/cartesian-charts/getting-started) for displaying revenue data and a vertical control panel for adjusting a dynamic target line. The chart includes a horizontal annotation line bound to Y1, adjustable via an Entry and a Slider in the adjacent VerticalStackLayout.
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.
142
232
143
-
For more details, refer to the KB on [how to create and dynamically update target line for .NET MAUI Cartesian Chart?](https://support.syncfusion.com/agent/kb/18517).
233
+
For more details, refer to the KB on [how to create and dynamically update target line for .NET MAUI Cartesian Chart](https://support.syncfusion.com/agent/kb/18517).
0 commit comments