Using series color for legend labels

This is a demo tutorial. While there is no step-by-step commentary available (yet), the live demo below is fully functional. Feel free to open it for full source code.

This demo shows how we can make labels of a legend on an XY chart take the color of their corresponding series.

Code

legend.labels.template.events.on("dataitemchanged", function(ev) {
  const series = ev.target.dataItem.component;
  ev.target.set("fill", series.get("fill"));
});
legend.labels.template.events.on("dataitemchanged", function(ev) {
  var series = ev.target.dataItem.component;
  ev.target.set("fill", series.get("fill"));
});

Example

See the Pen Using series color for legend labels by amCharts team (@amcharts) on CodePen.