Skip to content

Commit 07e2eb2

Browse files
committed
2 parents e842825 + 8f636bc commit 07e2eb2

File tree

2 files changed

+24
-33
lines changed

2 files changed

+24
-33
lines changed

DateTimeY/DateTimeY/DateTimeY.csproj.user

Lines changed: 0 additions & 31 deletions
This file was deleted.

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
1-
# How-to-use-DateTime-values-in-the-Y-Axis-in-.NET-MAUI-Cartesian-Chart
2-
This Knowledge base article explains how to use DateTime values on the Y-Axis in .NET MAUI Cartesian Chart.
1+
# How to use DateTime values in the Y Axis in .NET MAUI Cartesian Chart
2+
3+
This repository contains a sample project showcasing how to use DateTime values on the Y-Axis in a .NET MAUI Cartesian Chart.
4+
Since the Cartesian Chart does not natively support DateTimeAxis for the Y-Axis, this project demonstrates an alternative approach for plotting DateTime values and formatting them for display on NumericalAxis labels.
5+
6+
**Step 1:** Initialize the SfCartesianChart with Primary and Secondary Axes and populate it with data as follows. For more detailed guidance, refer to the MAUI Cartesian Charts getting started documentation.
7+
8+
**Step 2:** Define the DataModel and convert the DateTime values into total minutes and store it in a separate property for using them in the numerical Y-Axis.
9+
10+
**Step 3:** Declare an event handler for the LabelCreated event of the numerical Y-Axis.
11+
12+
**Step 4:** Handle duration values and format the labels of the NumericalAxis within the LabelCreated event.
13+
14+
**Step 5:** Run the sample, the chart will be displayed with the DateTime values formatted on the Numerical Y-Axis labels as shown in the below output.
15+
16+
![Output screenshot](https://github.com/user-attachments/assets/0ef206f2-0735-4f22-9fbd-aa7b90aa0baa)
17+
18+
## Troubleshooting
19+
20+
### Path Too Long Exception
21+
22+
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.
23+
24+
Refer to the KB article on [How to use DateTime values in the Y Axis in .NET MAUI Cartesian Chart]() for better understanding along with relevant code snippets.

0 commit comments

Comments
 (0)