leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.51k stars 371 forks source link

How to set y-axis auto scaling with no fractional numbers? #856

Closed ile closed 10 months ago

ile commented 10 months ago

Thanks for the great library. This is just a question, hope it's ok:

Is it possible to set the y axis so that it uses auto scaling, but it wouldn't print fractional numbers?

image

On this chart, it can still print the grids as they are, but it just wouldn't print those 272,5 and 267,5 numbers. So it would look like this:

image

leeoniya commented 10 months ago

what ticks/grid do you want to see when your data range is {min: 264.5, max: 264.9}

ile commented 10 months ago

Well, my data range wouldn't be like that. The data represents "the number of tasks", so it's always integers.

That's why it feels strange to see floating point numbers when "number of tasks" can't be anything like that.

So, if there was a setting like { int: true } that could help.

ile commented 10 months ago

I can also fork the library and do my own change.

leeoniya commented 10 months ago

you can control what tick multiples can be chosen by providing your own via axis.incrs: https://jsfiddle.net/duym25wh/1/