Skip to content

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

@atepoorthuis

Description

@atepoorthuis

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions