繁体   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