You are here

protected function Highcharts::buildChartTitle in Charts 8.3

Build the chart title.

Parameters

array $options: Options.

Return value

\Drupal\charts_highcharts\Settings\Highcharts\ChartTitle

1 call to Highcharts::buildChartTitle()
Highcharts::buildVariables in modules/charts_highcharts/src/Plugin/chart/Highcharts.php
Creates a JSON Object formatted for Highcharts JavaScript to use.

File

modules/charts_highcharts/src/Plugin/chart/Highcharts.php, line 450

Class

Highcharts
Defines a concrete class for a Highcharts.

Namespace

Drupal\charts_highcharts\Plugin\chart

Code

protected function buildChartTitle(array $options) {
  $chartTitle = new ChartTitle();
  if (isset($options['title'])) {
    $chartTitle
      ->setText($options['title']);
  }

  // Set title position.
  if (isset($options['title_position'])) {
    if ($options['title_position'] == 'in') {
      $chartTitle
        ->setVerticalAlign('middle');
    }
    else {
      $chartTitle
        ->setVerticalOffset(20);
    }
  }
  return $chartTitle;
}