We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

X Axis converts the datetime value into double precision value in WPF SFChart

In my WPF project, we have a sf chart control whose x axis is shown below :

<chart:SfChart.PrimaryAxis>

                <chart:DateTimeCategoryAxis Header="XAxis" LabelRotationAngle="90" EnableTouchMode="True"                                  ThumbLabelVisibility="Visible" EnableScrollBar="True"                      LabelsIntersectAction="Auto" TickLineSize="10"  Interval="1" IntervalType="Milliseconds" LabelFormat="MM/dd/yyyy hh:mm:ss.fff tt">

                </chart:DateTimeCategoryAxis>

            </chart:SfChart.PrimaryAxis>


And in the code behind, I am using the lineseries in the .cs file of the usercontrol -  as shown below :

               LineSeries lineSeries = new LineSeries();

                lineSeries.ItemsSource = viewModel.GraphData;

                lineSeries.XBindingPath = "Date";

                lineSeries.YBindingPath = Columns

                lineSeries.IsSeriesVisible = true;

                lineSeries.ShowTooltip = true;

               chart.Series.Add(lineSeries);

And graph is shown below :

             


when the graph is displaying like this, what is the exact data on x axis ? Datetime or double values ??when we assign a datetime value with milliseconds (eg. 5/3/2022 3:34:55 PM), the graph is converting that datetime value into a double value (like 44680.67). This double value is NOT displaying anywhere in the Graph. Our wpf app receives an exact time value from another external source and want to match with the datetime values shown in the x axis here - it is not happening.

Why can't we get exact datetime value shown in the x axis ?? [it is used for displaying only ???].





1 Reply

MD Moneeshram Dhanabal Syncfusion Team October 17, 2022 07:47 AM

Hi Jassim Sharaf,


We have validated your query, and we would like to inform you that for DataTimeCatagoryAxis the XAxis values are converted to double since it is plotted based on Index value. And if you want to receive exact time value from another external source and match with the datetime values, then you need to change the Primary axis to DataTimeAxis as mentioned in the below code snippet.


Code:

<chart:SfChart.PrimaryAxis>

            <chart:DateTimeAxis Header="XAxis" LabelRotationAngle="90"

             . . .

             LabelFormat="MM/dd/yyyy hh:mm:ss.fff tt">

            </chart:DateTimeAxis>

</chart:SfChart.PrimaryAxis>


Please refer this below link for further reference:

https://help.syncfusion.com/wpf/charts/axis#types-of-axis
https://help.syncfusion.com/wpf/charts/annotations#annotation-based-on-axis


Regards,

Moneeshram D


Loader.
Live Chat Icon For mobile
Up arrow icon