Search code examples
eventsnetwork-programminganychart

Adding point listener to Network Graph AnyChart


I am trying to use AnyChart to open specific url's based on the node that is clicked in the graph. However, pointClick doesn't seem to work;

JavaScript;

anychart.data.loadJsonFile("levels.json", function (data) {

        var chart = anychart.graph(data);

...

chart.listen("pointClick", function(e){
            open_level(e);
});

...

function open_level(e){
    var level = e.iterator.get("url")
    window.open(level);
}

A node is given in .JSON by;

"id": "Earth",
      "height": 60,
      "url": "Earth.html" (local HTML file)
    },

How should I do this?


Solution

  • The Network graph implements a different event system as it includes nodes and edges simultaneously. So, you can achieve the desired interactivity like is described in the sample we prepared.