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

foreignObject support for html #22

Open
flip111 opened this issue Oct 24, 2015 · 5 comments
Open

foreignObject support for html #22

flip111 opened this issue Oct 24, 2015 · 5 comments

Comments

@flip111
Copy link

flip111 commented Oct 24, 2015

It would be nice to allow html in the svg using foreignObject. You can see an example here https://gist.github.com/mbostock/1424037 I'm not sure how the elm-html lib could be pulled into this .. along with event handlers and everything else. Background: trying to display small forms alongside some d3 objects..

seliopou added a commit that referenced this issue Oct 24, 2015
@seliopou
Copy link
Owner

foreignObject is supported right out of the box. elm-d3 lets you manipulate the DOM directly and use any features that it supports. I added an example in the foreignObject branch that's linked to this issue so you can see it in action. Directly translation of the JavaScript example you provided.

@flip111
Copy link
Author

flip111 commented Oct 24, 2015

Sorry maybe i haven't made my question clear enough. It was about how to use elm-html and event handlers to create the html rather than a string. Since it mentions in the readme that elm-d3 provides "an alternative renderer" so it might be hard to mix that with the elm-html renderer?

@seliopou
Copy link
Owner

Ah, I see what you're saying. Probably possible but would take a bit of work. Me and @Drup have been contemplating a similar thing for the OCaml bindings. It's much more straightforward in OCaml/js_of_ocaml because the JavaScript interface pretty well-defined and low-level.

Anyways, I know this isn't what you're talking about but just to be clear, you can create HTML using elm-d3, even within SVG documents. Here's a modified example that does that.

@flip111
Copy link
Author

flip111 commented Oct 24, 2015

I'm new to both d3 and elm i don't think i know enough right now to do the integration of the renderers. Which puts me on a crossroads. Develop everything in D3 and later port the entire thing to elm (when integrated with elm-html). Or start developing in elm and wait with this feature until it's possible in elm. It's quite essential to have this for my project. Can you advice in the choice between those two? I think it's depending on how hard it actually would be (that bit of work) and if there is any chance it will make it into the library.

@seliopou
Copy link
Owner

I'm not sure what to tell you. It seems that you have to make some tradeoffs and you're probably in a better position than anybody else to decide what to do. I may get to embedding arbitrary Elements into elm-d3 soon, or it may be a while.

But to be clear, you can use elm-d3 to manipulate HTML. In fact, you can use it to manipulate any DOM you want to. See the TodoMVC example to see how that works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants