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

[Label Mark] Index bounding box instead of point #50

Open
atepoorthuis opened this issue Jul 28, 2019 · 0 comments
Open

[Label Mark] Index bounding box instead of point #50

atepoorthuis opened this issue Jul 28, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@atepoorthuis
Copy link
Contributor

Currently, we index only the x/y point of the label/text mark. However, it would be much better to index the bounding box instead. Since we are not relying on native event listener on each element but rather a spatial index, this is the only way to set event listeners on labels.

This isn't trivial since we don't know the height/width of the text until we actually draw it with the correct font/size etc. I did some quick sleuthing and it turns out that there is a performant way using canvas.measureText() (https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/measureText). A reference implementation can be found at: https://github.com/FormidableLabs/measure-text.

@atepoorthuis atepoorthuis added the enhancement New feature or request label Jul 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant