You are here

public function WebformAnalysisChart::buildPieChart in Webform Analysis 8

Build Pie Chart.

Parameters

\Drupal\webform_analysis\WebformAnalysisInterface $analysis: Analysis.

string $component: Component.

array $header: Header.

Return value

array Pie Chart.

Overrides WebformAnalysisChartInterface::buildPieChart

1 call to WebformAnalysisChart::buildPieChart()
WebformAnalysisChart::build in src/WebformAnalysisChart.php
Build.

File

src/WebformAnalysisChart.php, line 142

Class

WebformAnalysisChart
Webform Analysis Chart.

Namespace

Drupal\webform_analysis

Code

public function buildPieChart(WebformAnalysisInterface $analysis, $component = '', array $header = []) {
  $data = $analysis
    ->getComponentRows($component, $header, TRUE);
  $options = count($data) > 2 ? [
    'pieHole' => 0.2,
  ] : [];
  return [
    'options' => $options,
    'data' => $data,
  ];
}