假设 XY 图表是这样创建的:
let charts = [];
function createChart() {
am4core.useTheme(am4themes_animated);
// Create chart instance
let chart = am4core.create("chartdiv", am4charts.XYChart);
// Add data
chart.data = [{
"date": new Date(2018, 0, 1),
"value": 450,
"showTooltip": "always"
}, ...,
{
"date": new Date(2018, 0, 5),
"value": 500,
"showTooltip": "always",
"orientation": "up",
"offset": 5
}];
// Create axes
let dateAxis = chart.xAxes.push(new am4charts.DateAxis());
...
let valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
// Create series
let series = chart.series.push(new am4charts.LineSeries());
...
let bullet = series.bullets.push(new am4charts.CircleBullet());
...
charts.push(chart);
}
function modifyTooltip() {
let chart = charts[0];
// How to get the first bullet, second bullet, third bullet of the XY chart?
let bullets = chart.series.bullet; // <- undefined
}
目标是修改第一个、第二个和第三个项目符号工具提示显示,在
function modifyTooltip()
:
bullets.propertyFields.showTooltipOn = "showTooltip";
图表和第一、第二和第三个项目符号如下所示:
参考资料:Codepen - amcharts v4 XYchart 示例
是否有任何方法可以遍历系列中的所有项目符号,以便可以使用
propertyFields
修改特定项目符号的工具提示属性?
提前致谢