> What's the best way to solve this problem?
Currently there isn't a built-in feature that allows you to
automatically set the nodes' height to the labels' height value.
In order to solve this problem you can create an "invisible" testLabel
where you'll append the text of each node and calculate its
offsetHeight. Then, you can assign this offsetHeight to each node's
$height property.
Somewhere in you init function, before instanciating and plotting your
ST, try appending a test label like this:
//create our test label
var testLabel = document.createElement('div');
testLabel.id = "mytestlabel";
testLabel.style.visibility = "hidden";
testLabel.style.position = "absolute";
//set your fixed with here
testLabel.style.width = "mydesiredwidth";
document.body.appendChild(testLabel);
Then, before loading the JSON into the st call this function:
/* ... some code .... */
nodeDimHelper(json);
st.loadJSON(json);
/* ...some code ... */
Finally, define a nodeDimHelper function that iterates through the
nodes of a JSON tree and adds the proper height by querying the height
of the test label when appending the node's text into it:
//helper function to set the $height parameter. modifies the json data provided
function nodeDimHelper(tree) {
var elem = document.getElementById('mytestlabel');
TreeUtil.each(tree, function(node) {
elem.innerHTML = node.name;
node.data.$height = elem.offsetHeight;
});
}
You can also call this function when implementing the "request"
controller method, right before calling the onComplete callback, so
you can set those nodes' $height property also.
I haven't tested the code, so please contact this group again if you
experience any problems.
Hope it helps,