javascript
4 TopicsMulti parent hierarchy - custom visual D3.js
Hello Guys ! I create hierarchy table and what I want to achieve is something like this below: I know how to build hierarchy level for two categories and draw it, but I have a problem with 3 or more categories. My dataset is flat array of objects. Every object has id and parentId. I'm using d3.stratify() to make hierarchy nodes. It works properly but once I add third category which has two or more parents it crush. I found somewhere that hierarchy where children have many parents is not hierarchy anymore but graph. Is it right ? This is my stratify function: const root = d3 .stratify() .id(function (d: any) { return d.name; }) .parentId(function (d: any) { return d.parentId; })(items); This is my dataset transform when there is 3 categories: yAxis.map((d, i) => { if (yAxis.length === 3) { if (i === 2) { const children = data.filter( (d) => d.name === d.yAxis[d.yAxis.length - 1] ); uniqArray.push(children); } else if (i === 1) { const children = data.filter((d) => d.name === d.yAxis[1]); const filteredChildren = children.filter(function (a) { var key = a.name + "|" + a.parentName; if (!this[key]) { this[key] = true; return true; } }, Object.create(null)); uniqArray.push(filteredChildren); } else { const children = data.filter((d) => !d.parentId); uniqArray.push(_.uniqBy(children, (d) => d.name)); } return [..._.flatten(uniqArray), { name: "root" }]; } }); return yAxis.length > 1 ? [..._.flatten(uniqArray), { name: "root" }] : [...data, { name: "root" }]; Did you ever face that problem ? Or maybe you have some solution. I will be grateful for any advice how to do this. Thanks!Custom visual external Javascript in PowerBi Desktop Issue
Hi, We have custom visual component taht needs to use external javascript loaded using the script tag. The second library can't be embedded via node modules. Here is an extract from our source code : private scriptsUrl: string[] = [ "//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js", "https://api.bimsync.com/1.0/js/viewer.js"]; private loadNext = (resolve, reject) =>{ const scriptsUrlElement = this.scriptsUrl[this.loadCount]; let htmlScriptElement = document.createElement('script'); htmlScriptElement.src=scriptsUrlElement; htmlScriptElement.crossOrigin = "anonymous"; document.body.appendChild(htmlScriptElement); htmlScriptElement.onload = () => { console.info("Viewer scripts loaded"); this.loadCount++; if (this.loadCount >= this.scriptsUrl.length) { resolve(); }else{ this.loadNext(resolve, reject); } }; htmlScriptElement.onerror = (message, url, line, column, error) => { console.info("Viewer scripts error:" + error); reject({message,url,line,column,error}); }; } On web (PowerBi service) it works perfectly but on powerbi desktop we only have an object error (in the onerror) : { trusted:true } Is there a way to debug this on powerBI desktop or anything we should do ?Using D3 for a gauge
Is there a way to put this D3 visual https://c3js.org/samples/chart_gauge.html or this one http://bl.ocks.org/msqr/3202712 into PowerBI? I've just inserted the JS Code inside de D3.JS Visual but it shows just a blank space... Here is the code var chart = c3.generate({ data: { columns: [ ['data', 91.4] ], type: 'gauge', onclick: function (d, i) { console.log("onclick", d, i); }, onmouseover: function (d, i) { console.log("onmouseover", d, i); }, onmouseout: function (d, i) { console.log("onmouseout", d, i); } }, gauge: { // label: { // format: function(value, ratio) { // return value; // }, // show: false // to turn off the min/max labels. // }, // min: 0, // 0 is default, //can handle negative min e.g. vacuum / voltage / current flow / rate of change // max: 100, // 100 is default // units: ' %', // width: 39 // for adjusting arc thickness }, color: { pattern: ['#FF0000', '#F97600', '#F6C600', '#60B044'], // the three color levels for the percentage values. threshold: { // unit: 'value', // percentage is default // max: 200, // 100 is default values: [30, 60, 90, 100] } }, size: { height: 180 } }); setTimeout(function () { chart.load({ columns: [['data', 10]] }); }, 1000); setTimeout(function () { chart.load({ columns: [['data', 50]] }); }, 2000); setTimeout(function () { chart.load({ columns: [['data', 70]] }); }, 3000); setTimeout(function () { chart.load({ columns: [['data', 0]] }); }, 4000); setTimeout(function () { chart.load({ columns: [['data', 100]] }); }, 5000); Any help is much appreciated!Solved