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

Coordinate precision controls? #139

Closed
veltman opened this issue Dec 20, 2018 · 1 comment
Closed

Coordinate precision controls? #139

veltman opened this issue Dec 20, 2018 · 1 comment

Comments

@veltman
Copy link

veltman commented Dec 20, 2018

What are your thoughts on allowing user control over the precision of generated coordinates from methods like line() and area()?

I'm thinking of two reasons why this is potentially useful:

  1. Any kind of non-browser static rendering where file size is a consideration.
  2. I've run into a few browser-specific SVG rendering bugs that are precision-dependent, where coordinates with many significant digits can lead to weird problems (e.g. https://bugzilla.mozilla.org/show_bug.cgi?id=1507603).

2 has only come up on rare occasions for me, but 1 has come up more often.

I could imagine two versions:

Specify a number to round each coordinate to:

d3.line()
  .precision(1e-3);

Or instead update d3-path directly to take an optional precision argument that gets applied in the toString() method, and then someone could pass one as a custom context.

d3.line()
  .context(d3.path(1e-3));

// or...

d3.line()
  .context(d3.path().precision(1e-3));

Any thoughts on the merit of incorporating this? The latter approach would avoid cluttering the main API but still provide a low-level outlet for interested users.

@veltman
Copy link
Author

veltman commented Dec 20, 2018

Oops, I just realized this has already been discussed over at d3/d3-path#10, I'll chime in there.

@veltman veltman closed this as completed Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant