答案 0 :(得分:0)
要更改漏斗图切片上的标签,请将labelText
更改为所需的值。默认情况下,它设置为[[title]]: [[value]]
,但如果您只想要百分比值,则可以将其更改为[[percents]]%
。
对于图例,您必须设置图例valueText
。默认设置为[[value]]
,因此您也可以向其添加[[percents]]%
:
AmCharts.makeChart("chartdiv", {
// ...
labelText: "[[percents]]%",
legend: {
valueText: "[[value]] ([[percents]]%)",
valueWidth: 75, //you might also need to increase the valueWidth to add more space
// ...
},
// ...
});
演示如下:
var chart = AmCharts.makeChart("chartdiv", {
"type": "funnel",
"theme": "light",
"labelText": "[[percents]]%",
"legend": {
"valueText": "[[value]] ([[percents]]%)",
"valueWidth": 75
},
"dataProvider": [{
"title": "Website visits",
"value": 300
}, {
"title": "Downloads",
"value": 123
}, {
"title": "Requested prices",
"value": 98
}, {
"title": "Contacted",
"value": 72
}],
"titleField": "title",
"marginRight": 160,
"marginLeft": 15,
"labelPosition": "right",
"funnelAlpha": 0.9,
"valueField": "value",
"startX": 0,
"neckWidth": "40%",
"startAlpha": 0,
"labelPosition": "center",
"outlineThickness": 1,
"neckHeight": "30%",
"balloonText": "[[title]]:<b>[[value]]</b>",
"export": {
"enabled": true
}
});
&#13;
#chartdiv {
width: 100%;
height: 500px;
}
&#13;
<script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
<script src="https://www.amcharts.com/lib/3/funnel.js"></script>
<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>
<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />
<script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
<div id="chartdiv"></div>
&#13;