簡體   English   中英

AmCharts4:如何在餅圖中隱藏圖例 label 中的百分比

[英]AmCharts4: How to hide percentage in legend label in Pie chart

我不想在餅圖中顯示圖例中的百分比。 我怎樣才能禁用它? 以下是代碼-

 /** * --------------------------------------- * This demo was created using amCharts 4. * * For more information visit: * https://www.amcharts.com/ * * Documentation is available at: * https://www.amcharts.com/docs/v4/ * --------------------------------------- */ // Create chart instance var chart = am4core.create("chartdiv", am4charts.PieChart); // Add data chart.data = [{ "country": "Lithuania", "litres": 501.9 }, { "country": "Czechia", "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 }]; chart.legend = new am4charts.Legend(); chart.legend.labels.template.text = "[bold {color}]{name}: {value} [/]"; // Add and configure Series var pieSeries = chart.series.push(new am4charts.PieSeries()); pieSeries.dataFields.value = "litres"; pieSeries.dataFields.category = "country";
 body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; } #chartdiv { width: 100%; height: 400px; }
 <script src="https://cdn.amcharts.com/lib/4/core.js"></script> <script src="https://cdn.amcharts.com/lib/4/charts.js"></script> <div id="chartdiv"></div>

在下面的代碼中,我只想將圖例顯示為Name: Value但它會在其旁邊附加百分比值。 我怎樣才能刪除它? 附上下面的截圖,

圖片

   chart.legend.valueLabels.template.disabled = true;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM