我已经查阅了amcharts版本4的文档(https://www.amcharts.com/javascript-charts/),但似乎无法找到如何将y轴格式化为货币的方法。虽然有其他方式来格式化y轴,但貌似没有货币格式化的说明。是否有人知道如何开始或在哪里寻找相关信息?
到目前为止,我已经有了上面的图表,只需要知道如何或在哪里将y轴格式化为货币形式。当你悬停在线条上时,我目前已经成功地将标签格式化为货币形式,因为这是非常简单的。这是我的创建轴的函数:
function createAxisAndSeries(field, name, opposite) {
const valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
const series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = field;
series.dataFields.dateX = 'date';
series.strokeWidth = 2;
series.yAxis = valueAxis;
series.name = name;
series.tooltipText = '{name}: [bold]${valueY}[/]';
series.tensionX = 0.8;
const interfaceColors = new am4core.InterfaceColorSet();
valueAxis.renderer.line.strokeOpacity = 1;
valueAxis.renderer.line.strokeWidth = 2;
valueAxis.renderer.line.stroke = series.stroke;
valueAxis.renderer.labels.template.fill = series.stroke;
valueAxis.renderer.opposite = opposite;
valueAxis.renderer.grid.template.disabled = true;
}