Place text in center of pie chart - Highcharts

后端 未结 7 669
-上瘾入骨i
-上瘾入骨i 2020-12-08 00:57

I would like to place a title in the center of a pie/donut chart in HighCharts.

I don\'t see anything in the chart options that would directly enable this, so I\'m t

7条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-08 01:26

    I found this works when there is a legend and you set the text you want in the centre of the chart as the title:

    events: {
        load: function() {
            const titleHeight = this.title.getBBox().height;
            this.title.attr({
                y: this.plotHeight / 2 + titleHeight / 2,
            });
        },
        redraw: function() {
            const titleHeight = this.title.getBBox().height;
            this.title.attr({
                y: this.plotHeight / 2 + titleHeight / 2,
            });
        },
    },
    

提交回复
热议问题