-
Notifications
You must be signed in to change notification settings - Fork 715
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
feat(annotation): consider using <foreignObject> for text layout #1173
Comments
Add option to pass in an element to render as a label as a child. Uses <foreignObject> to allow user to pass in an HTML element. Related to this discussion: airbnb#1173 This has the benefit of letting the element handle text reflow, with the drawback being that the user need to manage min and max width of the container element they render. This approach seems much better imo, favouring composability over configuration which is much more in line with the philosophy of d3.
One consideration to bear in mind is that most non-browser SVG renderers will not render HTML |
Interesting point @richsilv, perhaps it's worth noting that in the docs for the new label type. I think both svg + html would be supported so users could then make their own decision based on different use cases. |
* Annotation label <foreignobject> render Add option to pass in an element to render as a label as a child. Uses <foreignObject> to allow user to pass in an HTML element. Related to this discussion: #1173 This has the benefit of letting the element handle text reflow, with the drawback being that the user need to manage min and max width of the container element they render. This approach seems much better imo, favouring composability over configuration which is much more in line with the philosophy of d3. * Fix child render for Safari Add witdth and height to <foreignObject>. Worked for Chrome but was not displaying anything for Safari. * Fix test cases Not sure how idomatic all the `dive()`s are, but I've heard complaints about them so I'm guess it's the way to go. * Remove console log * Address PR comments Rename ForeignObjectLabel -> HtmlLabel Split out HtmlLabel and LabelAnchorLine to separate components. Export HtmlLabel as a separate component as it uses a small subset of the shared props.
I used Safari does not support it – at all – while most browsers are quirky. Very poor documentation on how to use this right. This is probably going to be suddenly dumped by all browsers. That besides all that @richsilv already mentioned. Non-browser support is null. |
From #1127 (comment)
The text was updated successfully, but these errors were encountered: