我们如何在Amcharts的系列名称上添加工具提示?

时间:2020-08-11 07:46:14

标签: javascript angular amcharts amcharts4

enter image description here

如何将鼠标悬停在Amchart系列名称的提示上。 (想在所附屏幕截图中的选定区域的悬停上添加工具提示。

添加系列名称,例如:

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

谢谢!

1 个答案:

答案 0 :(得分:1)

这是一种方法。我不知道为什么必须使用setTimeout。没有它,图表加载时values数组为空。

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