Creating TreeLayout with Legend, Tree nodes overlapping legend, legend should have a max z-index always

Hi i have created a TreeLayout, with legend but tree nodes are overlapping on legend check the screen shot below.

I have also tried to give layers to Tree Nodes and Legend but whenever i give layername other than “Grid” to treenodes or legend then treelayout and legend stacking vertically can not overlap at all. Starting the treelayout after the legend height. Even if i grad it comes back to the same position after legend check the second screen.

If you want the legend to be in front of your tree nodes and links, you should put it in a Layer that will always be in front of your nodes and links. Maybe something like:

    layer = new Layer();
    layer.name = 'Legend';
    layer.allowSelect = false;
    layer.pickable = false;
    layer.isTemporary = true;
    myDiagram.addLayerAfter(layer, myDiagram.findLayer('Foreground'));

Hi Thank you for replying,

I created this small legend as a separated tree but it is not starting from top-left. Check the link below.

How and when did you determine the position?
It needs to be done in an “InitialLayoutCompleted” DiagramEvent listener.

Thank you Walter, working fine now.