I have series of data (temperature vs time) and I want to plot it using Chart
object of .NET 4.0.
The problem is that if I choose DateTime
Solution 1:
Try This:
DateTime myDateValue = DateTime.Now;
String XValueType = myDateValue.ToString("HH:mm:ss");
Solution 2:
if you are using windows chart control then
Try This:
chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "HH:mm:ss";
Solution 3: as you said in your below comments if you are showing only DateTime as a string it would be difficult while comparing.
Yes it would be difficult if you only show the Time
part (HH:mm:ss)
as string.
but if you display the Date and Time then you can again convert back the string to DateTime and perform conversion.
Try This:
DateTime date=DateTime.Now;
axisLabel=date.ToString("dd.MM.yyyy HH:mm:ss");
you can convert the datetime string back to DateTime as below:
DateTime date = DateTime.ParseExact(axisLabel,"dd.MM.yyyy
HH:mm:ss",CultureInfo.InvariantCulture);