You are here

public function HighchartsHandler::postRender in Visualization API 8

Includes global Javascript required by Highcharts.

Overrides VisualizationHandlerInterface::postRender

File

src/Plugin/visualization/handler/HighchartsHandler.php, line 142
Drupal\visualization\Plugin\visualization\handler\HighchartsHandler.

Class

HighchartsHandler
Library plugin for Visualization implementing support for Highcharts.

Namespace

Drupal\visualization\Plugin\visualization\handler

Code

public function postRender() {
  if (!$this->addedJavascript) {
    module_load_include('module', 'libraries', 'libraries');
    $path = libraries_get_path('highcharts');
    $js_libs['#attached']['js'] = array(
      array(
        'type' => 'file',
        'data' => $path . '/js/highcharts.js',
      ),
      array(
        'type' => 'file',
        'scope' => 'footer',
        'data' => drupal_get_path('module', 'visualization') . '/js/visualization.js',
      ),
      array(
        'type' => 'file',
        'scope' => 'footer',
        'data' => drupal_get_path('module', 'visualization') . '/js/highcharts.js',
      ),
    );
    drupal_render($js_libs);
    $this->addedJavascript = TRUE;
  }
}