Formatting axis values ​​for a chart

In my WinForms project, I am using a standard Chart control (from VS Toolbox) to display pressure and time. It should be possible to scale the graph. This works great, but the X-axis values ​​in the zoomed graph show the values ​​in decimal places:

enter image description here

Does anyone have an idea that I can show the values ​​in a more convenient format? For example, in the above chart, I would see labels like: 8.00, 10.00, 12.00? I can also live with values ​​like: 7.98, 9.98, 11.98, so with a limited number of decimal places.

I looked in the control constructors for the Chart control where I can specify a format string or number of decimal places, but I couldn't find it.

There is nothing special about this chart. It shows 2 episodes (not easy to see, but you will probably see a blue and green line). I use the FastLine chart type for both series. I have enabled scaling by setting IsUserEnabled and IsUSerSelection to true for CursorX and CursorY in the graphic designer. As said it works, but I was unable to define a property to customize the format of the values.

+3


source to share


1 answer


Set the property LabelStyle.Format

:

chart1.ChartAreas[0].AxisX.LabelStyle.Format = "0.00";

      



or

chart1.ChartAreas[0].AxisX.LabelStyle.Format = "{0:0.00}";

      

+5


source







All Articles