You are here

function theme_date_vs_takeup_count in Quiz 7

Same name and namespace in other branches
  1. 8.6 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  2. 8.4 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  3. 8.5 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  4. 6.6 includes/quiz_dashboard/quiz_dashboard.admin.inc \theme_date_vs_takeup_count()
  5. 6.4 includes/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  6. 7.6 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  7. 7.4 includes/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  8. 7.5 modules/quiz_stats/quiz_stats.admin.inc \theme_date_vs_takeup_count()
  9. 6.x 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 includes/quiz_stats/quiz_stats.admin.inc
Generates chart showing how often the quiz has been taken the last days

File

includes/quiz_stats/quiz_stats.admin.inc, line 409
Administration file for Quiz stats Module

Code

function theme_date_vs_takeup_count($variables) {
  $days = $variables['takeup'];
  $days = array_reverse($days);
  $max_count = 0;
  $chart = array(
    '#chart_id' => 'test_chart',
    '#title' => '',
    '#type' => CHART_TYPE_LINE,
    '#size' => chart_size(600, 400),
    //'#chart_fill' => chart_fill('c', 'eeeeee'),
    '#grid_lines' => chart_grid_lines(10, 10, 1, 5),
    '#adjust_resolution' => TRUE,
  );
  $interval = 1;
  foreach ($days as $date => $obj) {
    $count = $obj->value;
    $chart['#data'][] = $count;
    $x_label = '|';
    if ($interval == 7) {
      $x_label = chart_mixed_axis_label(format_date($obj->timestamp, 'custom', 'd M'));
      $interval = 0;
    }
    $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][0][] = $x_label;
    $interval++;
    $max_count = $max_count > $count ? $max_count : $count;
  }
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][0][] = chart_mixed_axis_range_label(0, $max_count);

  // The chart module has some bugs. If we have the time we should provide patches instead of tricking it to work...
  $chart['#mixed_axis_labels'][CHART_AXIS_Y_LEFT][1] = array(
    '|',
    chart_mixed_axis_label(t('Attempts')),
  );
  $chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1] = array(
    '|',
    chart_mixed_axis_label(t('Date')),
    '|',
  );
  return theme('chart', array(
    'chart' => $chart,
  ));
}