function template_preprocess_charts_blocks in Charts 8.3
Implements template_preprocess_hook().
File
- modules/
charts_blocks/ charts_blocks.module, line 50 - Contains chart_block_example.module.
Code
function template_preprocess_charts_blocks(&$variables) {
// Charts override settings applied at this point.
$chartOverridePluginManager = \Drupal::service('plugin.manager.charts_override');
$plugin_definition = [];
$chartOverrideOptions = [];
try {
$plugin_definition = $chartOverridePluginManager
->getDefinition($variables['library'] . '_overrides');
if (!empty($plugin_definition)) {
$chartOverridePlugin = $chartOverridePluginManager
->createInstance($variables['library'] . '_overrides');
$chartOverrideOptions = $chartOverridePlugin
->chartOverrides($variables['options']);
}
} catch (PluginNotFoundException $e) {
\Drupal::service('messenger')
->addMessage(t('Exception: @error', [
'@error',
$e
->getMessage(),
]));
}
$plugin_manager = \Drupal::service('plugin.manager.charts');
$plugin = $plugin_manager
->createInstance($variables['library']);
$plugin
->buildVariables($variables['options'], $variables['categories'], $variables['seriesData'], $variables['secondaryOptions'], $variables, $variables['id'], $chartOverrideOptions);
}