Skip to content

Settings and activity

1 result found

  1. 11 votes
    Vote

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    You have left! (?) (thinking…)
    6 comments  ·  Highcharts Javascript API  ·  Flag idea as inappropriate…  ·  Admin →
    How important is this to you?

    We're glad you're here

    Please sign in to leave feedback

    Signed in as (Sign out)
    An error occurred while saving the comment
    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));