【问题标题】:Centering labels in pie. Highcharts在饼图中居中标签。海图
【发布时间】:2013-09-02 20:58:37
【问题描述】:

我有以下饼图:http://jsfiddle.net/wjqrh/76/

    new Highcharts.Chart({
        chart: {
            renderTo: 'f-chart-container',
            type: 'pie',
            backgroundColor: 'rgba(255, 255, 255, 0)'
        },
        title: {
            text: ''
        },
        plotOptions: {
            pie: {
                shadow: true,
                dataLabels: {
                    formatter: function () {
                        return '<span style="color: ' + this.point.color + '; font-weight: bold; font-size: 115%">'
                            + this.point.percentage.toFixed(1)
                            + '%</span>';
                    },
                    distance: 3,
                    connectorWidth: 0,
                    x: 0,
                    y: 0
                }
            }
        },
        tooltip: {
            formatter: function () {
                return '<b>' + this.point.name + '</b>: '
                    + this.point.y
            }
        },
        series: [
            {
                name: '',
                data: data,
                size: '73%',
                innerSize: '50%',
                showInLegend: false
            }
        ],
        colors: colors
    });

紫色扇区的标签放置在正确的位置,但我想将其准确放置在中心,就像显示第三个(绿色)扇区的标签一样。 橙色和青色扇区也发生了相同的标签定位。

如何强制将标签放置在扇区的中心?

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    我想到的只是使用 translate() 函数,它允许移动 SVG 元素。

    http://jsfiddle.net/wjqrh/77/

    chart.series[0].data[5].dataLabel.translate(275,520);
    

    【讨论】:

    • 谢谢,但这是否意味着我无法自动对其他数据集进行更正?
    • 很遗憾没有,因为我们分别计算每个位置。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多