getNeighbors();
The getNeighbors method gets neighbors of the current tree map item.
This method returns an array of PP.Ui.BubbleTreeItem objects.
To execute this example, the page must contain the BubbleTree component named bubbleTree (see Example of Creating the BubbleTree Component). Get an item, move chart to this item, get the list of neighbors and show their names; show size of the current item:
// Get data model var model = bubbleTree.getModel() // Get item by its ID var item = model.getItem("RUS"); // Bring scene to the obtained item bubbleTree.drillTo(item); // Get neighbor items var neighbors = item.getNeighbors(); // Declare variable for the list of neighbors' names var names = ""; // Create the list of neighbors' names for (var i = 0; i < neighbors.length; i++) { names += neighbors[i].getCaption() + " "; } // Show names of neighbor items console.log("Names of neighbor items: " + names); // Show item radius console.log("Item radius: " + item.getRadius());
After the example execution the scene moves to the obtained item:
Also the browser console shows names of neighbors and radius for the obtained item:
Names of neighbor items: Ukraine Romania
Item radius: 8.451542547285166
See also: