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

Labels poorly formatted on decimal intervals #12

Open
mGallacci opened this issue Aug 30, 2018 · 0 comments
Open

Labels poorly formatted on decimal intervals #12

mGallacci opened this issue Aug 30, 2018 · 0 comments

Comments

@mGallacci
Copy link

First, congratulations for your first open source project. Your comment encouraged me to offer my feedback and help.
I use SimpleGraticule with these intervals:
zoomIntervals:[
{start:0,end:3,interval:20},
{start:4,end:5,interval:10},
{start:6,end:7,interval:5},
{start:8,end:10,interval:1},
{start:11,end:12,interval:0.5},
{start:13,end:18,interval:0.2},
]
When the interval goes below 1, the labels will, sometimes, appear like -4.00000000001 or -3.9999999998.
I've added this to the getMins funcion:
this.dec=0;
if (Math.floor(s)<s){
var sd=s;
while(Math.floor(sd)<sd){
this.dec++;
sd=s*Math.pow(10, this.dec);
}
}
And changed the way x and y values are calculated on the constructLines function to:
var x = Math.round((mins.x + i * this.options.interval) * Math.pow(10, this.dec)) / Math.pow(10, this.dec);

Maybe this is not the optimal way to do it, but it solved the problem. Hope this helps to improve your plugin.

Best,

Marcelo Gallacci

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

1 participant