Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Anyone dealed with d3.js and json input ? I'm doing some research using d3.js to build a tree node view. I've found a sample, here,D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing. but reviewing the code it read the data from a json format dataset.
I'm newbie in javascript programing and json, then I suppose I need to create a function to read QV.Data.Rows and converts it to json format. Any clue on how to do it ?
Best Regards,
Pablo Labbe
//Declaring a two-dimensional array (an array of arrays)
var input = new Array(this.Data.Rows.length);
//Getting the data from QlikView
for (var j = 0; j < this.Data.Rows.length; j++) {
input
= this.Data.Rows [0].text; }
//Changing the array into a hierarchical json
var output = [];
for (var i = 0; i < input.length; i++) {
var chain = input.split("/");
var currentNode = output;
for (var j = 0; j < chain.length; j++) {
var wantedNode = chain
; var lastNode = currentNode;
for (var k = 0; k < currentNode.length; k++) {
if (currentNode
.name == wantedNode) { currentNode = currentNode
.children; break;
}
}
// If we couldn't find an item in this list of children
// that has the right name, create one:
if (lastNode == currentNode) {
var temp = wantedNode.split('} ');
var newNode = currentNode
= { id: wantedNode, name: temp[1], children: [] }; currentNode = newNode.children;
}
}
}
var json = output;
Nicole,
Many thanks for this piece of code. A great starting point. I'll test it as soon as possible.
Best Regards,
Pablo
Hello Pablo,
I was also looking for a way to bring this chart into Qlikview and I came across your post
D3.js Drag and Drop, Zoomable, Panning, Collapsible Tree with auto-sizing.
Have you had any success in bringing this chart into Qlikview using the above code as yet? If so, then how did you achieve it? Any help would be greatly appreciated. Thanks
Regards
Mohd
hi Pablo Labbe
does the extension work based on this code? could i get the qar? my email is : chriszhang345@hotmail.com
Thanks
Ani