getLegends();
The getLegends method returns object that contains tree map legends.
The method returns a JSON object whose properties (Legend0, Legend1 and so on) contain tree map legends.
Executing the example requires that the HTML page contains the TreeMapBox component named treeMapBox (see Example of Creating the TreeMapBox Component). Show size legend if settings of data mapping with tree elements' sizes are defined:
// Get size legend var sizeLegend = treeMapBox.getLegends()["Legend1"]; if (treeMapBox.getSizeVisual()) { // Show the size legend sizeLegend.setIsVisible(True); // Set legend size sizeLegend.setSize(180, 75); } else { sizeLegend.getIsVisible() ? console.log("Legend is shown.") : console.log("Legend is hidden.") console.log("Settings of data mappings with tree elements' sizes are not defined."); };
If tree map size legend is unavailable, or settings for data mapping with tree elements' sizes are not defined, after the example execution the browser console displays appropriate warnings. If these settings are defined the size legend is shown.
See also: