Page 1 of 1

Axis labels with consistent decimals

Posted: Mon Jul 12, 2010 6:54 pm
by 15654674
Is there a way to get an axis to display tick labels with a consistent number of decimal places without having to examine the data range of the data and guess at what the code might do to lay things out?

We're plotting values on custom Axes with Automatic set to true. The problem we have currently is that while axes with a wide range of values look reasonably good, axes whose series have a small range of values (e.g. values fall between 1 and 3) have tick labels which go e.g. "1.1", "1.35", "1.5", "1.65", etc. The inconsistent number of decimal places staggers the labels and makes them look very bad. The format codes offered for AxisLabels.ValueFormat force you to choose between always presenting two decimal places (terrible for cases where we don't need them) or the above setting where trailing zeros are removed, and there doesn't seem to be a reasonable way to examine axis ranges or the difference between successive tick values to apply an appropriate ValueFormat before the labels are drawn. Am I missing something that would allow me to do this?

Re: Axis labels with consistent decimals

Posted: Tue Jul 13, 2010 8:49 am
by 10050769
Hello Charles Cruden,

I suggest that instead of use two decimals you can use one decimal using Labels.ValueFormat with next lines of code:

Code: Select all

               tChart1.Axes.Bottom.Ticks.Visible = true;
               tChart1.Axes.Bottom.Labels.ValueFormat = "0.0";
Could you say us, if previous lines of code do as you want?
If these lines don't work like for you, Could you say exactly how you want the labels are?

I hope will helps.

Thanks,