最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts donut pielegends position - Stack Overflow

programmeradmin8浏览0评论

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.

like so:

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
            }
        }]
    })

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.

like so:

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
            }
        }]
    })
Share Improve this question edited Jun 2, 2014 at 12:53 mistenkt asked Jun 2, 2014 at 12:42 mistenktmistenkt 2,3923 gold badges16 silver badges19 bronze badges 2
  • 1 share your code that you have tried – Bhushan Kawadkar Commented Jun 2, 2014 at 12:43
  • Its just a basic init of a donut pie.. – mistenkt Commented Jun 2, 2014 at 12:51
Add a ment  | 

1 Answer 1

Reset to default 15

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

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

which renders this:

the rest you can do with CSS styling

发布评论

评论列表(0)

  1. 暂无评论