Skip to content

RADIAL_EDGE && TREE_EDGE functions fail on missing node._parent (possible fix) #42

Description

@NgMomentum

I had a problem with the RADIAL_EDGE && TREE_EDGE functions failing when the var node was presented without a ['_parent']. This might not be a typical case, as I'm new to using the latest version of ui-router (v1.0.14) and visualizer, and I might be implementing things differently (timing issues, etc). Anyway, the problem seemed to come from the "nodes.filter" part of the _this.nodeForState function returning a node for the value of node.name and state.name both being the undefined string (''). Not sure why I get this and other aren't, but the fix is relatively trivial, so here it is:

function TREE_EDGE(node, renderer) {
    var strokeWidth = renderer.baseStrokeWidth * renderer.zoom;
    var makeLinkPath = function (node) {
        var s = { x: node.animX, y: node.animY }; // statevisnode
        var p = {
			x: node._parent ? node._parent.animX : node.animX,
			y: node._parent ? node._parent.animY : node.animY
		}; // parent
        var yAvg = (s.y + p.y) / 2;
        return "M " + s.x + " " + s.y + " C " + s.x + " " + yAvg + ", " + p.x + " " + yAvg + ", " + p.x + " " + p.y;
    };
    return preact_1.h("path", { d: makeLinkPath(node), "stroke-width": strokeWidth, className: 'link' });
}

I just check for the existance of _parent in node first. My app worked fine thereafter, and the node._parent node seems to be updated in the next iteration anyway. I didin't see any difference in positioning from the demo available on the web. So, this is just a suggestion as I am no expert on ui-router and visualizer. Really like the way visualizer.js presents UI-Router states.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions