通过修改图表的标记模板,可以将amchart5标签从百分比更改为数字。以下是一种示例方法:
// 创建图表
let chart = am5xy.create("chartdiv", am5xy.XYChart);
// 创建值轴
let valueAxis = chart.yAxes.push(new am5xy.ValueAxis());
// 将标记模板更改为数字标记
let series = chart.series.push(new am5xy.LineSeries());
series.dataFields.valueY = "value";
let bullet = series.bullets.push(new am5.Bullet());
let label = bullet.createChild(am5.Label);
label.text = "{value}";
// 设置数据
series.data = [{
"value": 100
}, {
"value": 200
}, {
"value": 300
}];
在以上示例代码中,我们将标记模板更改为使用数字标记,而不是百分比标记。这是通过创建一个包含数字值的am5.Label对象来实现的,并将其添加到标记模板中。
下一篇:AmChart5需要帮助?