protected function StatisticsPageTrait::buildCircleIndicator in Opigno statistics 8
Same name and namespace in other branches
- 3.x src/StatisticsPageTrait.php \Drupal\opigno_statistics\StatisticsPageTrait::buildCircleIndicator()
Builds circle indicator for a value.
Parameters
float $value: From 0 to 1.
Return value
array Render array.
1 call to StatisticsPageTrait::buildCircleIndicator()
- StatisticsPageTrait::buildValueWithIndicator in src/
StatisticsPageTrait.php - Builds value with a indicator for the training progress block.
File
- src/
StatisticsPageTrait.php, line 24
Class
- StatisticsPageTrait
- Common helper methods for a statistics pages.
Namespace
Drupal\opigno_statisticsCode
protected function buildCircleIndicator($value) {
$width = 100;
$height = 100;
$cx = $width / 2;
$cy = $height / 2;
$radius = min($width / 2, $height / 2);
$value_rad = $value * 2 * 3.14159 - 3.14159 / 2;
return [
'#theme' => 'opigno_statistics_circle_indicator',
'#width' => $width,
'#height' => $height,
'#cx' => $cx,
'#cy' => $cy,
'#radius' => $radius,
'#x' => round($cx + $radius * cos($value_rad), 2),
'#y' => round($cy + $radius * sin($value_rad), 2),
'#val_rad' => $value_rad < 3.14159 / 2,
];
}