Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Drupal::moduleHandler()->loadInclude('flot_d8', 'inc', 'flot_d8.theme');
- function flot_d8_theme(array $existing, $type, $theme, $path) {
- return [
- 'flot_d8' => [
- 'file' => 'flot_d8.theme.inc',
- ],
- ],
- ];
- }
- function template_preprocess_views_view_flot_d8(&$variables) {
- $options = $variables['view']->style_plugin->options;
- $series = [];
- foreach ($variables['view']->result as $id => $result) {
- $label = $result->labels;
- $numbers = $result->numbers;
- $series['data'][] = [
- 'label' => $label,
- 'data' => $numbers,
- ];
- }
- $options['series'] = $series;
- // Update options for twig.
- $variables['options'] = $options;
- }
- $output[] = [
- '#type' => 'flotd8',
- '#theme' => 'flot_examples_series_pie',
- '#data' => $variables['options']['series'],
- '#options' => ['series' => ['pie' => ['show' => TRUE]]],
- ];
- return $output;
- function theme_views_view_flot_d8($variables){
- $output[] = [
- '#type' => 'flotd8',
- '#theme' => 'flot_examples_series_pie',
- '#data' => $variables['options']['series'],
- '#options' => ['series' => ['pie' => ['show' => TRUE]]],
- ];
- return theme('flotd8', $output); //This doesn't work
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement