Changing datetime format on mschart axis

19,529

To show DateTime related values on the XAxis you can choose to set the XValueType property.

In your case Series[0].XValueType = ChartValueType.Time would be the right thing to display time related values.

To format the values you can use ChartAreas[0].AxisX.LabelStyle.Format which would translate your values into the required format say like HH:mm:ss.

ChartAreas[0].AxisX.LabelStyle.Format ="HH:mm:ss";
Share:
19,529
Kingpin
Author by

Kingpin

I'm a software engineer at ise gmbh in Oldenburg

Updated on July 17, 2022

Comments

  • Kingpin
    Kingpin almost 2 years

    I'm using mschart to display some values over a timeperiod.

    It looks something like this:

    a busy cat

    As you can see the first value is from 15:11 and the last from 16:10 But on the x-axis it's on displaying the days. How can I change this?

    EDIT: Changing XValueType to ChartValueType.Time leads to this:

    a busy cat

  • VJOY
    VJOY about 12 years
    How to display AM/PM values ?
  • 27k1
    27k1 over 10 years
    A little tip! Use Keywords such as #VALY{HH:mm:ss} if seconds are not displaying.
  • Adam Garner
    Adam Garner about 6 years
    I found that I had to put chartArea1.AxisX.LabelStyle.Format ="HH:mm:ss"; in my designer file before this would work.