Search code examples
javascriptinfovis

call javascript infovis sunburst rotate function outside init


I would like to simulate the click of a sunburst node from a menu outside of the canvas so that the clicked node is rotated until its horizontal, which is what happens when a node is clicked on the canvas.

The function:

sb.rotate(node, method, opt)

see rotate

where node is the value of "ID" in the JSON array, method is either 'animate' or 'replot' and opt is the configuration object

This is the type of error I get when I execute

sb.rotate("mynode", 'animate', "opt");

TypeError: node.getPos is not a function. (In 'node.getPos(opt.property || 'current')', 'node.getPos' is undefined)

Any suggestions on how to get this to work?

jsbin example


Solution

  • In your jsbin, you have to use

    sb.rotate(sb.graph.getNode("Source/Core/Core.js"), animate? 'animate' : 
    'replot', 
    {
        duration: 1000,
        transition: $jit.Trans.Quart.easeInOut
    });
    

    Notice the sb.graph.getNode("Source/Core/Core.js")
    See https://philogb.github.io/jit/static/v20/Docs/files/Graph/Graph-js.html#Graph.getNode

    You also forgot to issue the click in the jsbin. Use

    button.click();
    

    for that. ;)