visualization.module in Visualization API 8
File
visualization.module
View source
<?php
function visualization_theme() {
return array(
'visualization' => array(
'variables' => array(
'view' => NULL,
'options' => array(
'title' => NULL,
'xAxis' => array(),
'fields' => array(),
'type' => 'line',
'data' => array(),
),
),
'file' => 'visualization.theme.inc',
'template' => 'visualization',
),
);
}
function visualization_plugin($type = FALSE) {
$config = Drupal::config('visualization.settings');
$preferred_plugin = $config
->get('library');
$plugin_manager = Drupal::service('plugin.manager.visualization.handler');
$plugins = $plugin_manager
->getDefinitions();
if (!empty($plugins[$preferred_plugin])) {
$id = $plugins[$preferred_plugin]['id'];
$instance = $plugin_manager
->createInstance($id);
if ($instance
->available() && (!empty($type) && in_array($type, $instance
->supportedTypes()))) {
return $instance;
}
}
$first_plugin = reset($plugins);
return $plugin_manager
->createInstance($first_plugin['id']);
}