You are here

charts_graphs_open_flash.module in Charts and Graphs 7

Same filename and directory in other branches
  1. 6.2 apis/charts_graphs_open_flash/charts_graphs_open_flash.module

drupal module file implementing Open Flash Chart 2 charting.

File

apis/charts_graphs_open_flash/charts_graphs_open_flash.module
View source
<?php

/**
 * @file drupal module file implementing Open Flash Chart 2 charting.
 */

/**
 * Implements hook_chartgraph_provider().
 **/
function charts_graphs_open_flash_chartgraph_provider() {
  $provider = array(
    'path' => drupal_get_path('module', 'charts_graphs_open_flash  ') . '/charts_graphs_open_flash.class.inc',
    //must be full path
    'clazz' => 'ChartsGraphsOpenFlash',
    //implementation class' name
    'name' => 'open-flash',
    //name used when invoking through a factroy method
    'nice_name' => 'Open Flash Chart 2',
    'chart_types' => array(
      'line' => t('Line'),
      'bar' => t('Bar'),
      'bar_3d' => t('3D Bar'),
      'bar_cylinder' => t('Cylinder Bar'),
      'bar_cylinder_outline' => t('Outlined Cylinder Bar'),
      'bar_dome' => t('Dome Bar'),
      'bar_filled' => t('Filled Bar'),
      'bar_glass' => t('Glass Bar'),
      'bar_round' => t('Glass Bar with rounded tops and bottoms'),
      'bar_round_glass' => t('Glass Bar with rounded tops'),
      'bar_sketch' => t('Sketched Bar'),
      'pie' => t('Pie'),
    ),
    'themes' => array(),
  );
  return (object) $provider;
}

/**
 * Implements hook_menu().
 */
function charts_graphs_open_flash_menu() {
  $items = array();
  $items['charts_graphs_open_flash/data'] = array(
    'page callback' => 'charts_graphs_open_flash_data',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Adds chart data as JSON.
 *
 * @param $cid
 *   cache_id from which cache to retrieve the data
 */
function charts_graphs_open_flash_data($cid = NULL) {
  $cache = cache_get($cid);
  if (!$cache) {
    drupal_not_found();
    exit;
  }
  $canvas = $cache->data;
  $chart = charts_graphs_get_graph('open-flash');
  $chart
    ->get_data_from_cache($cid);
  drupal_json_output($chart);
  exit;
}

Functions

Namesort descending Description
charts_graphs_open_flash_chartgraph_provider Implements hook_chartgraph_provider().
charts_graphs_open_flash_data Adds chart data as JSON.
charts_graphs_open_flash_menu Implements hook_menu().