Aligning a legend with plot container

This demo shows how we can use axis' events to monitor its width, and automatically adjust position of the legend, so it is aligned perfectly with the plot area.

Code

yAxis.events.on("boundschanged", function() {
  legend.set("dx", yAxis.width());
});
yAxis.events.on("boundschanged", function() {
  legend.set("dx", yAxis.width());
});

Demo

See the Pen
Aligning a legend with plot container
by amCharts team (@amcharts)
on CodePen.0

Posted in Uncategorized