Title position in highcharts

Created on 7 September 2023, about 1 year ago
Updated 28 September 2023, about 1 year ago

Currently using highcharts, only the "in" title positon option has an effect. All other options are ignored and a default "top" position is used for title and subtile.
Also for "in" only the title itself is affected - but not the subtitle.

For now I fix the problem in a custom module using

function mymodule_chart_definition_alter(array &$definition, array $element, $chart_id) {
  if (isset($element["#title_position"])) {
    // option "in" is handled by Highcharts.php setting verticalAlign to top and "y" ti 24
    //  null, left, right, in, out, top, bottom
    $titlePosition = $element["#title_position"];
    if ($titlePosition == 'left') {
      $definition["title"]["align"] = 'left';
      $definition["subtitle"]["align"] = 'left';
    } elseif ($titlePosition == 'right') {
      $definition["title"]["align"] = 'right';
      $definition["subtitle"]["align"] = 'right';
    } elseif ($titlePosition == 'in') {
      $definition["title"]["verticalAlign"] = 'middle';
      $definition["subtitle"]["verticalAlign"] = 'middle';
      $definition["title"]["y"] = 50;
      $definition["subtitle"]["y"] = 74;
    } elseif ($titlePosition == 'bottom') {
      $definition["title"]["verticalAlign"] = 'bottom';
      $definition["subtitle"]["verticalAlign"] = 'bottom';
      $definition["subtitle"]["y"] = 34;
    }
}

And use the default for "no" value selected, top and out, as I can't define a negative Y-value for title/subtile (as they are displayed outside the chart then).
I think those changes should be part of the Highcharts.php file

✨ Feature request
Status

Fixed

Version

5.0

Component

Highcharts integration

Created by

πŸ‡©πŸ‡ͺGermany vistree

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024