Search code examples
javascriptangularamchartsamcharts4

How can we add a tooltip on series name of Amcharts?


enter image description here

How to add a tooltip on hover of the series name of Amchart. (Want to add tooltip on hover on selected area in the attached screenshot).

Adding a series name like :

let series = chart.series.push(new am4charts.LineSeries());
series.name = q1.seriesName;

Thank You!


Solution

  • Here is a way. I don't know why one has to use a setTimeout. Without it, the values array is empty when the chart loads.

    chart.legend = new am4charts.Legend();
    setTimeout(function() {
      chart.legend.itemContainers.values[0].tooltipText = 
        "The [bold {color}]{name}[/] series is awesome!";
      chart.legend.itemContainers.values[1].tooltipText = 
        "The [bold {color}]{name}[/] series is cool!";
      chart.legend.itemContainers.values[2].tooltipText = 
        "The [bold {color}]{name}[/] series is nice!";
    }, 500);
    

    enter image description here