The distanceProperty on the Dendrogram layout is supposed to "determine the height values of dendrogram branches." However, I can't figure out how to use it properly. Leaving it as "null" means there's about 170 pixels of space between each level in my tree.
Can anyone tell me the proper usage of the distanceProperty, or does anyone have any demos adjusting the space between levels?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
N.B: here distance is between 0 (leafNodes of the dendrogram) and 1(root of the dendrogram).
Make sure, the first node, with id=1 in the graphml is the rootNode of the Dendrogram.
Once the xml used to generate the Data instance on the flare side, each:
node.data.distance should be multiplied by the DendrogramLayout.layoutBounds.width (or height) depending on the orientation of the dendrogram.
2) Instantiate the DendrogramLayout such as:
new DendrogramLayout("data.distance",Orientation.LEFT_TO_RIGHT) or any other orientation.
3)It took me hours, and maybe I do not understand something else, but the only way I managed to represent the distances on the dendrogram is by adding the following code line, just after the
Data generation:
private function visualize(data:Data):void
{
trace(d.tree.root.data.id);//here
var dendroBounds:Rectangle = new Rectangle(20, 4, 0.8*(stage.stageWidth-20), 0.8*(stage.stageHeight-4));
var dendroWidth:Number = dendroBounds.width;
data.nodes.setProperties(opt[idx].nodes);
data.edges.setProperties(opt[idx].edges);
var rootNode:NodeSprite;
for (var j:int=0; j<data.nodes.length; ++j) {
data.nodes[j].data.label = String(j);
data.nodes[j].buttonMode = true;
var dist:Number = data.nodes[j].data.distance;
data.nodes[j].data.distance = dist*dendroWidth*0.8;
if(data.nodes[j].data.id == 1){
rootNode = data.nodes[j];
}
}.....
Good Luck,
Philippe
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The distanceProperty on the Dendrogram layout is supposed to "determine the height values of dendrogram branches." However, I can't figure out how to use it properly. Leaving it as "null" means there's about 170 pixels of space between each level in my tree.
Can anyone tell me the proper usage of the distanceProperty, or does anyone have any demos adjusting the space between levels?
Hi tslatt,
To make it works you should:
1) generate graphml (or any other data format) including a node property with the distance of the node from the root node of the dendrogram.
e.G:
<graph edgedefault="undirected">
<key id="name" for="node" attr.name="name" attr.type="string"/>
<key id="distance" for="node" attr.name="distance" attr.type="string"/>
−
<node id="1">
<data key="name"/>
<data key="distance">1.0</data>
</node>
−
<node id="2">
<data key="name"/>
<data key="distance">1.0</data>
</node>
−
<node id="3">
<data key="name"/>
<data key="distance">1.0</data>
</node>
−
<node id="4">
<data key="name"/>
<data key="distance">0.6729828850855746</data>
</node>
N.B: here distance is between 0 (leafNodes of the dendrogram) and 1(root of the dendrogram).
Make sure, the first node, with id=1 in the graphml is the rootNode of the Dendrogram.
Once the xml used to generate the Data instance on the flare side, each:
node.data.distance should be multiplied by the DendrogramLayout.layoutBounds.width (or height) depending on the orientation of the dendrogram.
2) Instantiate the DendrogramLayout such as:
new DendrogramLayout("data.distance",Orientation.LEFT_TO_RIGHT) or any other orientation.
3)It took me hours, and maybe I do not understand something else, but the only way I managed to represent the distances on the dendrogram is by adding the following code line, just after the
Data generation:
private function visualize(data:Data):void
{
trace(d.tree.root.data.id);//here
var dendroBounds:Rectangle = new Rectangle(20, 4, 0.8*(stage.stageWidth-20), 0.8*(stage.stageHeight-4));
var dendroWidth:Number = dendroBounds.width;
data.nodes.setProperties(opt[idx].nodes);
data.edges.setProperties(opt[idx].edges);
var rootNode:NodeSprite;
for (var j:int=0; j<data.nodes.length; ++j) {
data.nodes[j].data.label = String(j);
data.nodes[j].buttonMode = true;
var dist:Number = data.nodes[j].data.distance;
data.nodes[j].data.distance = dist*dendroWidth*0.8;
if(data.nodes[j].data.id == 1){
rootNode = data.nodes[j];
}
}.....
Good Luck,
Philippe