Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profil tool graduation and rounding for displayed labels #624

Closed
sebbelese opened this issue Jun 30, 2021 · 2 comments
Closed

Profil tool graduation and rounding for displayed labels #624

sebbelese opened this issue Jun 30, 2021 · 2 comments

Comments

@sebbelese
Copy link
Contributor

sebbelese commented Jun 30, 2021

Hello,

I use the profil tool in my web-gis application to display raster profiles along polylines. It works quite well, but I have an issue with graduations.

I try to obtain a generic scaling of the y axis, working at any scale:

let zmin = feature.get('zmin');
let zmax = feature.get('zmax');
let graduation = Number(((zmax-zmin)/20).toPrecision(2));

profil.setGeometry(feature, {"graduation":graduation});

where zmin and zmax are features properties defining the z data range.

It works quite well in some cases:
image

But sometimes, the labels are not rounded adequately, leading to unreadable values:
image

Would it be possible to round these labels for readability, for example by using ".toPrecision(...)" with a max number of digits? Or is there any alternative way of doing it?

Another issue: I am not sure why the number of graduations is so different between the two plots with similar ranges. I was expecting ~20 graduations for each plot. A difference between the two situations is that the graduation value is 0.93 (<1) for one plot and 1.1 (>1) for the other one.

Thanks for any help!

Viglino added a commit that referenced this issue Jun 30, 2021
@Viglino
Copy link
Owner

Viglino commented Jun 30, 2021

Hello,
I've added a zDigits option to let you set the number of digit in the profile.

@sebbelese
Copy link
Contributor Author

Waw, it was fast!

Thanks, it works.

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants