You are here

protected function Highcharts::buildSecondaryYaxis in Charts 8.3

Build the secondary y-axis.

Parameters

array $attachmentDisplayOptions: Attachment display options.

Return value

\Drupal\charts_highcharts\Settings\Highcharts\Yaxis

1 call to Highcharts::buildSecondaryYaxis()
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 268

Class

Highcharts
Defines a concrete class for a Highcharts.

Namespace

Drupal\charts_highcharts\Plugin\chart

Code

protected function buildSecondaryYaxis(array $attachmentDisplayOptions) {
  $chartYaxisSecondary = new Yaxis();
  $yAxisTitleSecondary = new YaxisTitle();
  $yAxisTitleSecondary
    ->setText($attachmentDisplayOptions[0]['style']['options']['yaxis_title']);
  $chartYaxisSecondary
    ->setTitle($yAxisTitleSecondary);
  $yaxisLabelsSecondary = new YaxisLabel();
  if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_suffix'])) {
    $yaxisLabelsSecondary
      ->setYaxisLabelSuffix($attachmentDisplayOptions[0]['style']['options']['yaxis_suffix']);
  }
  if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_prefix'])) {
    $yaxisLabelsSecondary
      ->setYaxisLabelPrefix($attachmentDisplayOptions[0]['style']['options']['yaxis_prefix']);
  }
  $chartYaxisSecondary
    ->setLabels($yaxisLabelsSecondary);
  $chartYaxisSecondary->opposite = 'true';
  if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_min'])) {
    $chartYaxisSecondary
      ->setMin($attachmentDisplayOptions[0]['style']['options']['yaxis_min']);
  }
  if (!empty($attachmentDisplayOptions[0]['style']['options']['yaxis_max'])) {
    $chartYaxisSecondary
      ->setMax($attachmentDisplayOptions[0]['style']['options']['yaxis_max']);
  }
  return $chartYaxisSecondary;
}