You are here

protected function Chartjs::buildLegend in Charts 8.4

Same name and namespace in other branches
  1. 5.0.x modules/charts_chartjs/src/Plugin/chart/Library/Chartjs.php \Drupal\charts_chartjs\Plugin\chart\Library\Chartjs::buildLegend()

Builds legend.

Parameters

array $options: The options.

Return value

object The legend object.

File

modules/charts_chartjs/src/Plugin/chart/Library/Chartjs.php, line 124

Class

Chartjs
Define a concrete class for a Chart.

Namespace

Drupal\charts_chartjs\Plugin\chart\Library

Code

protected function buildLegend(array $options) {
  $legend = new \stdClass();
  if (!empty($options['display']['legend_position'])) {
    $legend->display = TRUE;
    $legend->position = $options['display']['legend_position'];
  }
  else {
    $legend->display = FALSE;
  }
  return $legend;
}