Moving icons of a StockLegend to left
This demo shows how we can use events to re-arrange items within a StockLegend. Specifically, it moves settings and close icon buttons to the left - before the actual legend label.
Related code
Section titled “Related code”valueLegend.settingsButtons.template.events.on("dataitemchanged", function(e) { e.target.set("marginRight", 5); root.events.once("frameended", function() { e.target.toBack() });});
valueLegend.closeButtons.template.events.on("dataitemchanged", function(e) { root.events.once("frameended", function() { e.target.toBack() });});valueLegend.settingsButtons.template.events.on("dataitemchanged", function(e) { e.target.set("marginRight", 5); root.events.once("frameended", function() { e.target.toBack() });});
valueLegend.closeButtons.template.events.on("dataitemchanged", function(e) { root.events.once("frameended", function() { e.target.toBack() });});Alternative option: custom theme
Section titled “Alternative option: custom theme”It’s also possible to achieve the same result with a custom theme:
const myTheme = am5.Theme.new(root);
myTheme.rule("Button", ["stocklegend", "control"]).setup = function(target) { target.toBack();}
root.setThemes([ am5themes_Animated.new(root), myTheme]);var myTheme = am5.Theme.new(root);
myTheme.rule("Button", ["stocklegend", "control"]).setup = function(target) { target.toBack();}
root.setThemes([ am5themes_Animated.new(root), myTheme]);