You are here

abstract class ChartsGraphsFlashCanvas in Charts and Graphs 7

Same name and namespace in other branches
  1. 6.2 charts_graphs_flash_canvas.class.inc \ChartsGraphsFlashCanvas

Abstract class to be derived for Flash based charting libraries.

Hierarchy

Expanded class hierarchy of ChartsGraphsFlashCanvas

File

./charts_graphs_flash_canvas.class.inc, line 12
abstract class ChartsGraphsFlashCanvas.

View source
abstract class ChartsGraphsFlashCanvas extends ChartsGraphsCanvas {

  /**
   * Possible values are "window", "opaque" and "transparent".
   */
  var $wmode;
  function get_wmode() {
    $wmodes = self::wmode_values();
    $default = 'window';
    $wmode = strtolower(empty($this->wmode) ? $default : $this->wmode);
    return isset($wmodes[$wmode]) ? $wmode : $default;
  }
  static function wmode_values() {
    return array(
      'window' => 'Window (Default)',
      'opaque' => 'Opaque',
      'transparent' => 'Transparent',
    );
  }

  /**
   * Merges the two arrays.
   *
   * The final array will be a copy of the second array with the values of the
   * first whose IDs are not present in the second.
   *
   * IDs of the second array with a value of NULL are not included but these
   * same IDs are not copied from the first array, so they effectivelly delete
   * settings from the first array.
   *
   * @param <array> $first
   * @param <array> $second
   * @return <array>
   */
  function merge_xml_values($first, $second) {

    //    dpm($first, '$first');
    //    dpm($second, '$second');
    $second_ids = array();
    foreach ($second as $value) {
      $second_ids[$value['#id']] = TRUE;
    }
    $final = array();
    foreach ($first as $value) {
      if (!isset($second_ids[$value['#id']])) {
        $final[] = $value;
      }
    }
    foreach ($second as $value) {
      if (isset($value['#value']) && $value['#value'] === NULL) {
        continue;
      }
      $final[] = $value;
    }
    return $final;
  }
  function get_xml_file_from_array($array) {
    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->formatOutput = TRUE;

    //    var_dump($array);
    foreach ($array as $element) {
      $this
        ->add_dom_element_from_array($dom, $dom, $element);
    }

    //    var_dump($dom->saveXML());
    return $dom
      ->saveXML();
  }
  function add_dom_element_from_array(&$dom, &$father, $element) {
    if (isset($element['#value'])) {
      $new_element = $dom
        ->createElement($element['#id'], (string) $element['#value']);
    }
    else {
      $new_element = $dom
        ->createElement($element['#id']);
      if (isset($element['#cdata'])) {
        $cdata = $dom
          ->createCDATASection((string) $element['#cdata']);
        $new_element
          ->appendChild($cdata);
      }
    }
    if (isset($element['#children'])) {
      foreach ($element['#children'] as $child) {
        $new_child = $this
          ->add_dom_element_from_array($dom, $new_element, $child);
        $new_element
          ->appendChild($new_child);
      }
    }
    if (isset($element['#attributes'])) {
      foreach ($element['#attributes'] as $attribute_name => $attribute_value) {
        $attribute = $dom
          ->createAttribute((string) $attribute_name);
        $new_element
          ->appendChild($attribute);
        $value = $dom
          ->createTextNode((string) $attribute_value);
        $attribute
          ->appendChild($value);
      }
    }
    $father
      ->appendChild($new_element);

    //    var_dump($new_element;
    //    var_dump($dom->saveXML($new_element));
    return $new_element;
  }
  function encode_for_xml($text) {
    return htmlspecialchars($text, ENT_COMPAT, 'UTF-8');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ChartsGraphsCanvas::$height property 2
ChartsGraphsCanvas::$modulename protected property
ChartsGraphsCanvas::$series property An array of series of values. Each element in a series (which is also an array in itself) is a numeric value of "measurement".
ChartsGraphsCanvas::$series_colours property Holds the colours to be used for each data serie.
ChartsGraphsCanvas::$showlegend property If true, shows a legend (if the library supports it).
ChartsGraphsCanvas::$title property 2
ChartsGraphsCanvas::$type property
ChartsGraphsCanvas::$unique_id protected property
ChartsGraphsCanvas::$width property 2
ChartsGraphsCanvas::$x_labels property Identifies each value in a data series. The same identification is used for all data series.
ChartsGraphsCanvas::$x_type property
ChartsGraphsCanvas::$y_legend property Text presented next to the left Y axis.
ChartsGraphsCanvas::$y_max property
ChartsGraphsCanvas::$y_min property
ChartsGraphsCanvas::$y_step property
ChartsGraphsCanvas::$zoom property Allows you to zoom in and out of a graph, if the library (flot does) supports it.
ChartsGraphsCanvas::getModuleName function
ChartsGraphsCanvas::getUnique_ID function
ChartsGraphsCanvas::get_chart abstract function Function that renders data. 4
ChartsGraphsCanvas::series_colours function
ChartsGraphsCanvas::set_data function
ChartsGraphsCanvas::__construct function Constructor function.
ChartsGraphsFlashCanvas::$wmode property Possible values are "window", "opaque" and "transparent".
ChartsGraphsFlashCanvas::add_dom_element_from_array function
ChartsGraphsFlashCanvas::encode_for_xml function
ChartsGraphsFlashCanvas::get_wmode function
ChartsGraphsFlashCanvas::get_xml_file_from_array function
ChartsGraphsFlashCanvas::merge_xml_values function Merges the two arrays.
ChartsGraphsFlashCanvas::wmode_values static function