LiveCharts - How to prevent the Y-Axis from showing double values?

2.3k views Asked by At

I have a Columndiagram. This diagram may have Y values from 0 to very larg numbers.

My problem:

When the Y values are small (from my observation smaller than 7), the chart shows double values. (for example: 0, 0.01, 0.02 ... , 0.1), which is in my case not correct.

What I want:

force the Y Axis to use integers.

What I cannot do:

I cannot define a seperator for the Y axis and set its Step to 1. Becuase if I do it, I'll have Step= 1 even if the values are very large, which is not desirable.

Is there any workaround for it?

1

There are 1 answers

1
bto.rdz On BEST ANSWER

By default, the library decides the step (when you don't force it) with the CalculateSeparator() method (for more info see this), since the library should also allow you to plot decimal values, it can not be forced to display only integers.

A simple work around I can think of, is to force the Axis.MaxValue property.

In your case, when your values are less than 7, I would force the Axis.MaxValue to 10 (or any other value that works fine for you), then when the data in your chart is greater than 7, you can set Axis.MaxValue back to double.NaN and the library will calculate this limit by it self.

I hope it helps you.