You are here

public function ChartTrait::setChartType in Dashboards with Layout Builder 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Dashboard/ChartTrait.php \Drupal\dashboards\Plugin\Dashboard\ChartTrait::setChartType()

Add a label.

Parameters

string $chart: Label to add.

2 calls to ChartTrait::setChartType()
NodeStatistics::buildRenderArray in src/Plugin/Dashboard/NodeStatistics.php
Build render array.
Submissions::buildRenderArray in modules/dashboards_webform/src/Plugin/Dashboard/Submissions.php
Build render array.

File

src/Plugin/Dashboard/ChartTrait.php, line 47

Class

ChartTrait
Trait for build a chart.

Namespace

Drupal\dashboards\Plugin\Dashboard

Code

public function setChartType($chart) : void {
  if (!in_array($chart, array_keys($this
    ->getAllowedStyles()))) {
    throw new \InvalidArgumentException($this
      ->t('Chart type @chart not allowed', [
      '@chart' => $chart,
    ]));
  }
  $this->type = $chart;
}