簡體   English   中英

HighCharts中如何將餅圖中的圖例作為數據標簽

[英]How to have legends in Pie charts as data labels in HighCharts

在處理高圖表中的餅圖時,我有幾個問題。

  1. 除了圓形之外,如何改變圖例的形狀。
  2. 我想在百分比值之前顯示數據標簽中的圖例。 樣本圖像
  3. 而且隨着數據的增加,數據標簽對餅圖來說並不激進。 如何解決這個問題。

我的圖表選項:

Highcharts.chart('container', {
    chart: {
        plotBackgroundColor: null,
        plotBorderWidth: null,
        plotShadow: false,
        type: 'pie'
    },
   
    tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
    },
    accessibility: {
        point: {
            valueSuffix: '%'
        }
    },
    plotOptions: {
        pie: {
            allowPointSelect: true,
            cursor: 'pointer',
            dataLabels: {
                enabled: true,
                format: '{point.percentage:.1f} %'
            },
            showInLegend: true
        },
    },
    series: [{
        name: 'Brands',
        colorByPoint: true,
        dataLabels: {
        connectorWidth : 0
        },
        showLegends: true,
        data: [{
            name: 'Chrome',
            y: 61.41,
           
        }, {
            name: 'Internet Explorer',
            y: 11.84
        }, {
            name: 'Firefox',
            y: 10.85
        }]
    }]
});

我的密碼筆

如果我得到任何問題的答案,我將不勝感激。

  1. API 允許通過設置symbolRadiussymbolHeight等選項來自定義圖例符號。

演示: https://jsfiddle.net/BlackLabel/1m98xgvr/

API: https://api.highcharts.com/highcharts/legend.symbolHeight

如果您想將圖例符號更改為自定義 png,請嘗試使用此解決方案:

自定義Highcharts圖例符號


  1. 您可以將dataLabels.useHTML標志設置為 true 並使用dataLabes.formatter回調來自定義 output,這將是一個出色的 HTML 元素。

演示: https://jsfiddle.net/BlackLabel/2sog3znq/


  1. 在這里我不確定你的想法是什么 - 你能更准確地解釋一下嗎?

暫無
暫無

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

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