1

I am new new to D3. I am trying to add input fields inside a svg element(rectangle) using d3.js. Please let me know if there is a way to do so.

1
  • Have a look at this Q&A. It uses checkbox's instead of input fields but they are similar. Ah, I've just read that properly, you might need to use a foreign object for that. Commented Sep 17, 2014 at 4:53

1 Answer 1

2

You can only do this using svg:foreignObject, but you don't really want to use that since it's poorly supported. If you know that you're only going to deploy on browsers that support svg:foreignObject, then you can put any HTML inside of it. Otherwise, you'll need to use traditional DOM elements on a div on a z-index above your SVG and place them using CSS left: and top: in the way that you would place svg:rect elements using x and y.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.