Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi everyone,
I wanted to add checkbox and tried this code:
svg.selectAll("foreignObject") .data(nodes) .enter().append("foreignObject") .attr('x' , o.x) .attr('y', o.y) .attr('width', 50) .attr('height', 20) .append("xhtml:body") .html("<form><input type=checkbox id=check></input></form>") .on("click", function(d, i){ console.log(svg.select("#check").node().checked) }) ;
How it can be added using "input"?
Hi @ysapiyev
At first, you should include the second body tag since iframe already has it.
The input tag can be added by using d3.append method.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
You might use something like this code snippet:
d3.select(Your_Root_Element) .append("input") .attr({ type: "checkbox" });
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
I tried something like this:
let input1 = this.svg.append("input") .attr({ type: "checkbox", x: 200, y: 50 });
However, nothing is shown. What can be wrong?
Does this.svg contain an svg element?
Checkbox can be used only in HTML elements such as div, table, footer, etc.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
So, as I understood, I should add div to svg, then add to it checkbox?
let checkbox_d = d3.select("div") .append("input") .attr(type: "checkbox");
Is it correct?
You should add a div container to the root element.
After that you should include input element and svg element into this div container.
SVG element supports the only SVG elements.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
So it will look like that?
let check= d3.select('body') .append('div') .append('input') .type('checkbox') let svg = d3.select(div) .append('svg')
Yes, that's correct.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 |
User | Count |
---|---|
8 | |
6 | |
4 | |
4 | |
4 |