Probem with datetime

I have file to read some values. When i try to put on chart i have some problem.

Chart show me only date and ignore hours in date. 

my code here:

            chart.Skins = Skins.Metro;

            chart.Indexed = false;

            this.chart.Text = "UCA";

            this.chart.PrimaryYAxis.Title = "CompressiveStrengthMPa";

            this.chart.PrimaryYAxis.ValueType = ChartValueType.Double;

            this.chart.ShowLegend = false;


            this.chart.PrimaryXAxis.ValueType = ChartValueType.DateTime;

            this.chart.PrimaryXAxis.IntervalType = ChartDateTimeIntervalType.Days;

            this.chart.PrimaryXAxis.LabelRotate = true;

            this.chart.PrimaryXAxis.LabelRotateAngle = 90;

            this.chart.PrimaryXAxis.Title = "Time";


            var series = new ChartSeries("Market");

            series.Type = ChartSeriesType.Line;

            Random ran = new Random();


            this.chart.BeginUpdate();


            for (int i = 0; i < reader.Results.Count; i++)

            {

                ERDataDurabilityUltrasonicInstrument data = reader.Results[i]; // Read from file 

                series.Points.Add(data.Time, data.CompressiveStrengthMPa); // Add points where data.Time - is DateTime.  data.CompressiveStrengthMPa - is double

            }


            this.chart.EndUpdate();

            this.chart.Series.Add(series);

            this.chart.Trackball.Visible = true;

zero point: 

next point in 01.01.1753 in 16 hour 32 minut 


next point in 01.01.1753 in 9 hour 04 minut


last point in 02.01.1753 in 00 hour 00 minut



Chart which i need get. Look at green line



4 Replies 1 reply marked as answer

GM Gayathri Manickam Syncfusion Team October 26, 2021 04:58 PM UTC

Hi Kuznetsova, 
 
Greetings from Syncfusion. 
 
This is a general update to let you know that our support team has taken out your query and we are validating the feasibility to achieve your requirement. We will update you the complete validation status in two business days (28th October 2021) before EOD.  
 
Regards, 
Gayathri M. 



GM Gayathri Manickam Syncfusion Team October 28, 2021 11:26 AM UTC

Hi Kuznetsova, 
 
We analyzed your query “Hours ignored in DateTime axis” and we suggest setting IntervalType as Hours for the axis as shown in the below code snippet. 
 
Code Snippet [C#]:  
this.chart.PrimaryXAxis.IntervalType = ChartDateTimeIntervalType.Hours; 
 
For more information, please refer below UG, 
 
Please let us know if you need further assistance on this. 
 
 Regards, 
Gayathri M. 



IK Irina Kuznetsova replied to Gayathri Manickam October 28, 2021 11:52 AM UTC

Hi Gayathri, I have tryed changed interval by hour before write here. That didn't give me nice result. I could send all of my code and file wich i try to read. 




also i try to change line code 170-171 on screenshot. 

Convert DateTime to double like this

{

series.Points.Add(data.Time.ToOADate(), data.CompressiveStrengthMPa);

series1.Points.Add(data.Time.ToOADate(), data.TransitTime);

}


but i gave the same result in first query to you


Regards, 
Ira. 


DD Devakumar Dhanapoosanam Syncfusion Team October 31, 2021 02:11 PM UTC

Hi Kuznetsova, 
 
We have analyzed your query and image, we would like to let you know that range and intervals for an axis are automatically calculated by nice range calculation engine, by default. We can customize the axis Range, IntervalType, DesiredIntervals count and DateTime with specific LabelFormat based on your requirement. Please refer the below code example for customizing the date time with specific range and Interval, 
 
//Set the Interval range, interval and interval type based on your data points 
this.chart.PrimaryXAxis.DateTimeRange = new ChartDateTimeRange(date,  
                                               date.AddMinutes(1000), 2, ChartDateTimeIntervalType.Hours); 
 
 
Output: 
 
 
Please refer the below link for more details 
 
Please let us know if you need any further assistance on this. 
 
Regards, 
Devakumar D 


Marked as answer
Loader.
Up arrow icon