You are here

charts_graphs_amcharts.module in Charts and Graphs 6.2

Same filename and directory in other branches
  1. 7 apis/charts_graphs_amcharts/charts_graphs_amcharts.module

drupal module file implementing amcharts.

File

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

/**
 * @file drupal module file implementing amcharts.
 */

/**
 * Implementation of hook_chartgraph_provider().
 **/
function charts_graphs_amcharts_chartgraph_provider() {
  $provider = array(
    'path' => dirname(__FILE__) . '/charts_graphs_amcharts.class.inc',
    // must be full path
    'clazz' => 'ChartsGraphsAmcharts',
    // implementation class' name
    'name' => 'amcharts',
    // name used when invoking through a factory method
    'nice_name' => 'amCharts',
    'chart_types' => array(
      'line' => t('Line'),
      'area' => t('Area'),
      'donut' => t('Donut'),
      'donut_3d' => t('3D Donut'),
      'side_bar' => t('Side Bar'),
      'bar' => t('Bar'),
      'pie' => t('Pie'),
      'pie_3d' => t('3D Pie'),
      'stacked_area' => t('Stacked Area'),
      'stacker_bar' => t('Stacked Bar'),
      'stacked_side_bar' => t('Stacked Side Bar'),
      '100_stacked_bar' => t('100% Stacked Bar'),
      'bar_3d' => t('3D Bar'),
      '100_stacked_side_bar' => t('100% Stacked Side Bar'),
      'side_bar_3d' => t('3D Side Bar'),
    ),
    'themes' => array(),
  );
  return (object) $provider;
}
function charts_graphs_amcharts_menu() {
  $items = array();
  $items['charts_graphs_amcharts/getdata'] = array(
    'page callback' => 'charts_graphs_amcharts_get_data',
    'access arguments' => array(
      'access content',
    ),
    'type' => MENU_CALLBACK,
  );
  return $items;
}
function charts_graphs_amcharts_get_data() {
  $cid = check_plain($_GET['cid']);
  $op = check_plain(arg(2));
  if ($op != 'settings' && $op != 'data') {
    drupal_not_found();
    exit;
  }
  $cache = cache_get($cid);
  if (!$cache || empty($cache->data)) {
    drupal_not_found();
    exit;
  }
  $obj = $cache->data;
  $ret = $obj->{$op};
  drupal_set_header('Content-Type: text/xml; charset=utf-8');
  print $ret;
  exit;
}

Functions