【发布时间】:2020-08-11 07:46:14
【问题描述】:
如何在 Amchart 的系列名称悬停时添加工具提示。 (想要在所附屏幕截图中的选定区域上添加工具提示)。
添加一个系列名称,如:
let series = chart.series.push(new am4charts.LineSeries());
series.name = q1.seriesName;
谢谢!
【问题讨论】:
标签: javascript angular amcharts amcharts4
如何在 Amchart 的系列名称悬停时添加工具提示。 (想要在所附屏幕截图中的选定区域上添加工具提示)。
添加一个系列名称,如:
let series = chart.series.push(new am4charts.LineSeries());
series.name = q1.seriesName;
谢谢!
【问题讨论】:
标签: javascript angular amcharts amcharts4
这是一种方法。我不知道为什么必须使用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);
【讨论】:
chart.legend.itemContainers.template.tooltipText = "[bold {color}]{name}[/] "。如果您在没有超时的情况下设置单个值,请改用就绪事件 (chart.events.on('ready', () => { chart.legend.itemContainers.each((container) => { container.tooltipText = "..." } ) }))。请注意,values 是只读的,不应直接操作 - 使用 each 或 for ... of。