function theme_date_vs_takeup_count in Quiz 6.x
Same name and namespace in other branches
- 8.6 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 8.4 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 8.5 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \theme_date_vs_takeup_count()
- 6.4 includes/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 7.6 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 7 includes/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 7.4 includes/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
- 7.5 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
Generates date vs takeup count chart.
Parameters
$takeup: Array quiz data structure.
Return value
HTML to render/display chart.
1 theme call to theme_date_vs_takeup_count()
- _get_date_vs_takeup_count_chart in modules/
quiz_stats/ quiz_stats.admin.inc - Generates chart showing how often the quiz has been taken the last days.
File
- modules/
quiz_stats/ quiz_stats.admin.inc, line 429 - Administration file for Quiz stats Module.
Code
function theme_date_vs_takeup_count($variables) {
$chart = [
'#type' => 'chart',
'#title' => t('Activity by date'),
'#chart_type' => 'line',
];
$chart['line_data'] = [
'#type' => 'chart_data',
'#title' => t('Result'),
'#labels' => [
'Something',
],
];
$chart['line_data']['#data'] = [];
$labels = [];
foreach ($variables['takeup'] as $point) {
$chart['line_data']['#data'][] = (int) $point->count;
$labels[] = $point->date;
}
$chart['xaxis'] = [
'#type' => 'chart_xaxis',
'#labels' => $labels,
];
$chart['yaxis'] = [
'#title' => 'Participants',
'#type' => 'chart_yaxis',
];
return \Drupal::service('renderer')
->render($chart);
}