Pie Title
Introduce a pie title that displays the series name. There should be option for placement: 'above', 'below' and 'inside'.
Pie titles are necessary when you use charts with 2 or more pies is them.
See these 3 mockups I made:
Above: http://jsfiddle.net/kzoon/Nw2cC/
Below: http://jsfiddle.net/kzoon/qMvc9/
Inside: http://jsfiddle.net/kzoon/8SdqV/
I created this small plugin that allows a pie plugin to be aligned using the regular Highcharts alignment options (align, verticalAlign, x, y).
-
Kaka commented
How can use it in Angular 5? I am not able to use the plugin.
-
You still need the plugin.
-
Anonymous commented
Is this plugin still necessary or has it been integrated into the main API? Using Highcharts 4.2.4.
-
@jxd Dynamic updating capabilities are now added, plese see the updated jsFiddle.
-
jxd commented
This plugin works great for static title. How can I dynamically update the title? Each time the title or data changes, it puts the new title on top of the existing one instead of removing and adding new title. I would really appreciate if anyone can let me know how to remove existing title and re-add the new title. I am using Highcharts JS v4.1.3.
-
jcoleman commented
I made a couple of changes that display the title correctly for center and right alignment:
/**
* Pie title plugin
* Last revision: 2012-12-21
*/
(function (Highcharts) {
Highcharts.wrap(Highcharts.seriesTypes.pie.prototype, 'render', function (proceed) {var chart = this.chart,
center = this.center || (this.yAxis && this.yAxis.center),
titleOption = this.options.title,
box;proceed.call(this);
if (center && titleOption) {
box = {
x: chart.plotLeft + center[0] - 0.5 * center[2],
y: chart.plotTop + center[1] - 0.5 * center[2],
width: center[2],
height: center[2]
};
if (!this.title) {
this.title = this.chart.renderer.label(titleOption.text)
.css(titleOption.style)
.add()
}
var labelBBox = this.title.getBBox();
if (titleOption.align == "center")
box.x -= labelBBox.width/2;
else if (titleOption.align == "right")
box.x -= labelBBox.width;
this.title.align(titleOption, null, box);
}
});} (Highcharts));