Change date and time format on mschart axis

I use mschart to display some values ​​over a specific period of time.

It looks something like this:

a busy cat

As you can see, the first value is from 15:11 and the last is from 16:10 But along the X axis it is a display of days. How can i change this?

UPDATE: changing XValueType to ChartValueType.Time results in this:

a busy cat

+8
source share
1 answer

To show the associated DateTime values ​​on XAxis, you can select the XValueType property.

In your case, Series[0].XValueType = ChartValueType.Time will correctly display time-related values.

To format the values, you can use ChartAreas[0].AxisX.LabelStyle.Format , which translates your values ​​into the desired format, for example HH:mm:ss .

 ChartAreas[0].AxisX.LabelStyle.Format ="HH:mm:ss"; 
+17
source

Source: https://habr.com/ru/post/905814/


All Articles