1) 修改此漏斗图中右侧以黄色突出显示的标签值。
2) 更改百分比的计算方式:通常,我的每个类别的数据中都有一个“百分比”字段,我希望将其显示为已突出显示的标签中的百分比。例如,类别“秒”的 data.percentage 为 10%。因此,需要显示 10%,如图所示。
代码:
var chart = am4core.create("chartdiv", am4charts.SlicedChart);
chart.hiddenState.properties.opacity = 0;
chart.data = [{
"name": "The first",
"value": 600,
"percentage": "100%"
}, {
"name": "The second",
"value": 300,
"percentage": "10%"
}, {
"name": "The third",
"value": 200,
"percentage": "10%"
}, {
"name": "The fourth",
"value": 180,
"percentage": "35%"
}, {
"name": "The fifth",
"value": 50,
"percentage": "20%"
}];
var series = chart.series.push(new am4charts.FunnelSeries());
series.colors.step = 2;
series.dataFields.value = "value";
series.dataFields.category = "name";
series.alignLabels = true;
series.labelsContainer.paddingLeft = 15;
series.labelsContainer.width = 200;
我发现系列对象有一个名为标签的成员,其中包含标签值,但我不知道如何在代码本身中修改它们。我该怎么做?