javascript Highcharts 甜甜圈派/图例位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23994836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 01:57:15  来源:igfitidea点击:

Highcharts donut pie/legends position

javascriptjqueryhighcharts

提问by mistenkt

So im having a hard time figuring out how to set up the layout for the pie/legend positions. I want the legend to be aligned to the left, and the pie aligned to the right. 40/60 percentages -ish.

所以我很难弄清楚如何为饼图/图例位置设置布局。我希望图例左对齐,饼图右对齐。40/60 百分比 -ish。

like so:

像这样:

enter image description here

在此处输入图片说明

chart = new Highcharts.Chart({
        chart: {
            renderTo: 'chart',
            type: 'pie',
        },
        credits: {
            enabled: false
        },
        title: {
            text : '',
        },
        plotOptions: {
            pie: {
                shadow: false,
                borderWidth: 0
            }
        },
        tooltip: {
            enabled: false
        },
        series: [{
            data: [
                {
                    name: "first",
                    y: 23
                },
                {
                    name: "second",
                    y: 8
                },
                {
                    name: "third",
                    y: 11
                },
                {
                    name: "fourth",
                    y: 11
                },
                {
                    name: "fifth",
                    y: 47

                }
            ],
            size: '100%',
            innerSize: '67%',
            showInLegend: true,
            dataLabels: {
                enabled: false
            }
        }]
    })

回答by epoch

How about just adding the legendto the chart options, as stated by the API?

legendAPI所述,将仅添加到图表选项如何?

legend: {
    align: 'left',
    layout: 'vertical',
    verticalAlign: 'top',
    x: 40,
    y: 0
}

which renders this:

这使得这个:

enter image description here

在此处输入图片说明

the rest you can do with CSS styling

剩下的你可以用 CSS 样式来做