Forum Discussion
Change view of visual when a selection has been made.
Sure. We're happy to review the code when it's ready.
Have you applied fill or stroke to svg elements? What kind of SVG elements you use?
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
At this stage I'm just trying to draw any SVG element to the canvas (circle, rect or text).
Even taking a copy of the barchart sample doesn't work. I can see the SVG elements using F12, and that the d3 javascript has loaded but it's a blank white canvas
There seem to be quite a variety of suggestions on how to set the environment up in terms of what commands and switches to run.
I'll start again from scratch tonight and use a clean Windows 10 Azure VM. Do you have a current list of how to configure a clean environment from scratch and can I email you directly? I will be using this in a number of presentations so will be sharing the knowledge widely.
- v-viig8 years ago
Community Champion
We'd recommend to follow official documentation that describe how to isntall and work with pbiviz tools.
If you have any issues feel free to email us.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
- Phil_Seamark8 years ago
Microsoft Employee
Hi again,
I'm repeating the environment setup on a clean Azure Windows 10 VM.
I have some questions about the https://github.com/Microsoft/PowerBI-visuals/blob/master/Tutorial/ExternalLibraries.md page
The link I have highlighted with text of "this" goes to a 404 page. Is this important?
Then, once I have run
npm install [email protected] --save
I don't have the "node_modules/d3/d3.min.js" in the "node_mindules/d3" folder. There is one in a sub folder called build. This this the correct file to use?
- Phil_Seamark8 years ago
Microsoft Employee
Further to this, now I am set up with a clean environment (following the install instructions closely) and I still can't draw a d3 object to the canvas.
Here is my code which based on the started "Update Count" visual that works.
I'm just trying to see if I can draw a simply D3 graphic to the page. I wonder if I'm creating the svg object ok, and adding a g and rect object to it, but missing the correct command to add it to the DOM.
module powerbi.extensibility.visual { "use strict"; export class Visual implements IVisual { private target: HTMLElement; private updateCount: number; private settings: VisualSettings; private textNode: Text; private svg: d3.Selection<SVGElement>; private g: d3.Selection<SVGElement>; private myrect: d3.Selection<SVGElement>; constructor(options: VisualConstructorOptions) { console.log('Visual constructor', options); this.target = options.element; this.updateCount = 0; if (typeof document !== "undefined") { const new_p: HTMLElement = document.createElement("p"); new_p.appendChild(document.createTextNode("Update -- count:")); const new_em: HTMLElement = document.createElement("em"); this.textNode = document.createTextNode(this.updateCount.toString()); new_em.appendChild(this.textNode); new_p.appendChild(new_em); this.target.appendChild(new_p); } this.svg = d3.select(options.element).append('svg'); this.g = this.svg.append('g'); this.myrect = this.g.append('rect'); this.myrect.attr("x", 10); this.myrect.attr("y", 10); this.myrect.attr("height", 50); this.myrect.attr("width", 50); this.myrect.attr("fill", "red"); }