📅  最后修改于: 2023-12-03 15:27:19.449000             🧑  作者: Mango
在使用am4charts库绘制饼图时,默认会生成刻度和标签。但是在某些情况下,我们可能希望禁用这些刻度和标签,以轻松地制作一个更简单的饼图。本文将介绍如何禁用am4charts中饼图的刻度和标签。
为了禁用饼图am4charts中的刻度和标签,我们可以调整相应的参数。
要禁用饼图中的标签,我们可以通过将 labels.template.disabled
设置为 true
来实现:
pieSeries.labels.template.disabled = true;
要禁用饼图中的刻度,我们可以通过将 ticks.template.disabled
设置为 true
来实现:
pieSeries.ticks.template.disabled = true;
// Create chart instance
var chart = am4core.create("chartdiv", am4charts.PieChart);
// Add data
chart.data = [{
"country": "Lithuania",
"litres": 501.9
}, {
"country": "Czech Republic",
"litres": 301.9
}, {
"country": "Ireland",
"litres": 201.1
}, {
"country": "Germany",
"litres": 165.8
}, {
"country": "Australia",
"litres": 139.9
}, {
"country": "Austria",
"litres": 128.3
}, {
"country": "UK",
"litres": 99
}, {
"country": "Belgium",
"litres": 60
}, {
"country": "The Netherlands",
"litres": 50
}];
// Create series
var pieSeries = chart.series.push(new am4charts.PieSeries());
pieSeries.dataFields.value = "litres";
pieSeries.dataFields.category = "country";
// Disable labels
pieSeries.labels.template.disabled = true;
// Disable ticks
pieSeries.ticks.template.disabled = true;
以上是禁用饼图am4charts中的刻度和标签的全部内容,通过上述代码,我们可以轻松地禁用饼图中的刻度和标签。