Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Drupal::moduleHandler()->loadInclude('flot_d8', 'inc', 'flot_d8.theme');
  2. function flot_d8_theme(array $existing, $type, $theme, $path) {
  3. return [
  4. 'flot_d8' => [
  5. 'file' => 'flot_d8.theme.inc',
  6. ],
  7. ],
  8. ];
  9. }
  10.  
  11. function template_preprocess_views_view_flot_d8(&$variables) {
  12. $options = $variables['view']->style_plugin->options;
  13. $series = [];
  14.  
  15. foreach ($variables['view']->result as $id => $result) {
  16. $label = $result->labels;
  17. $numbers = $result->numbers;
  18. $series['data'][] = [
  19. 'label' => $label,
  20. 'data' => $numbers,
  21. ];
  22. }
  23.  
  24. $options['series'] = $series;
  25.  
  26. // Update options for twig.
  27. $variables['options'] = $options;
  28. }
  29.  
  30. $output[] = [
  31. '#type' => 'flotd8',
  32. '#theme' => 'flot_examples_series_pie',
  33. '#data' => $variables['options']['series'],
  34. '#options' => ['series' => ['pie' => ['show' => TRUE]]],
  35. ];
  36. return $output;
  37.  
  38. function theme_views_view_flot_d8($variables){
  39. $output[] = [
  40. '#type' => 'flotd8',
  41. '#theme' => 'flot_examples_series_pie',
  42. '#data' => $variables['options']['series'],
  43. '#options' => ['series' => ['pie' => ['show' => TRUE]]],
  44. ];
  45. return theme('flotd8', $output); //This doesn't work
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement