You are here

class FrxSVGGraph in Forena Reports 7.2

Same name and namespace in other branches
  1. 6.2 plugins/FrxSVGGraph.inc \FrxSVGGraph
  2. 7.3 renderers/FrxSVGGraph.inc \FrxSVGGraph
  3. 7.4 renderers/FrxSVGGraph.inc \FrxSVGGraph

Hierarchy

Expanded class hierarchy of FrxSVGGraph

2 string references to 'FrxSVGGraph'
forena_forena_controls in ./forena.module
Self register controls with forena.
FrxGraphTemplate::generate in templates/FrxGraphTemplate.inc
* * Enter description here ... *

File

plugins/FrxSVGGraph.inc, line 3

View source
class FrxSVGGraph extends FrxChart {
  private $graph;
  private $links;
  function __construct() {
    $directory = FrxReportGenerator::instance()
      ->configuration('library_path');
    $library = rtrim($directory, '/') . '/SVGGraph/SVGGraph.php';
    require_once $library;
  }
  function renderChart($type, $data, $options, $links) {
    $this->links = $links;
    if ($data) {
      switch ($type) {
        case 'bargraph':
          $output = $this
            ->barGraph($data[0], $options);
          break;
        case 'piechart':
          $output = $this
            ->pieChart($data[0], $options);
          break;
        case 'stackedbargraph':
          $output = $this
            ->stackedBarGraph($data, $options);
          break;
        case 'groupedbargraph':
          $output = $this
            ->groupedBarGraph($data, $options);
          break;
        case 'linegraph':
          $output = $this
            ->lineGraph($data[0], $options);
          break;
        case 'multilinegraph':
          $output = $this
            ->multiLineGraph($data, $options);
          break;
        case 'scatterplot':
          $output = $this
            ->scatterPlot($data, $options);
          break;
        case 'multiscatterplot':
          $output = $this
            ->multiScatterPlot($data, $options);
          break;
      }
    }
    return $output;
  }

  // Generate a bar graph.
  function barGraph($data, $options) {
    if (@$options['style'] == '3D') {
      $type = 'Bar3DGraph';
    }
    elseif (@$options['style'] == 'horizontal') {
      $type = 'HorizontalBarGraph';
    }
    else {
      $type = 'BarGraph';
    }
    return $this
      ->renderGraph($type, $options, $data);
  }
  function stackedBarGraph($data, $options) {
    if (@$options['style'] == 'horizontal') {
      $type = 'HorizontalStackedBarGraph';
    }
    else {
      $type = 'StackedBarGraph';
    }
    return $this
      ->renderGraph($type, $options, $data);
  }
  function groupedBarGraph($data, $options) {
    if (@$options['style'] == 'horizontal') {
      $type = 'HorizontalGroupedBarGraph';
    }
    else {
      $type = 'GroupedBarGraph';
    }
    return $this
      ->renderGraph($type, $options, $data);
  }

  // Generate a pie chart
  function pieChart($data, $options) {
    if (@$options['style'] == '3D') {
      $type = 'Pie3DGraph';
    }
    else {
      $type = 'PieGraph';
    }
    return $this
      ->renderGraph($type, $options, $data);
  }
  function lineGraph($data, $options) {
    return $this
      ->renderGraph('LineGraph', $options, $data);
  }
  function multiLineGraph($data, $options) {
    return $this
      ->renderGraph('MultiLineGraph', $options, $data);
  }

  // Scatter plot
  function scatterPlot($data, $options) {
    return $this
      ->renderGraph('ScatterGraph', $options, $data);
  }

  // Multi scatter plot
  function multiScatterPlot($data, $options) {
    return $this
      ->renderGraph('MultiScatterGraph', $options, $data);
  }
  function renderGraph($type, $options, $data) {
    $links = $this->links;
    $width = @$options['width'] ? @$options['width'] : 600;
    $height = @$options['height'] ? @$options['height'] : 400;
    $graph = new SVGGraph($width, $height, $options);
    $this->graph = $graph;
    $graph
      ->Values($data);
    if (is_array(@$options['colors'])) {
      $graph->colours = $options['colors'];
    }
    if ($links) {
      $graph
        ->Links($links);
    }
    $output = $graph
      ->Fetch($type, FALSE);
    return $output;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxChart::render public function Overrides FrxRenderer::render
FrxChart::xmlToValues public function
FrxRenderer::$dataProvider public property
FrxRenderer::$frxAttributes public property
FrxRenderer::$htmlAttributes public property
FrxRenderer::$id public property
FrxRenderer::$name public property
FrxRenderer::$reportDocDomNode public property
FrxRenderer::$reportDocNode public property
FrxRenderer::$teng public property
FrxRenderer::initReportNode public function
FrxRenderer::mergedAttributes public function * Standard php array containing merged attributes * Enter description here ...
FrxRenderer::replaceTokens public function
FrxSVGGraph::$graph private property
FrxSVGGraph::$links private property
FrxSVGGraph::barGraph function
FrxSVGGraph::groupedBarGraph function
FrxSVGGraph::lineGraph function
FrxSVGGraph::multiLineGraph function
FrxSVGGraph::multiScatterPlot function
FrxSVGGraph::pieChart function
FrxSVGGraph::renderChart function
FrxSVGGraph::renderGraph function
FrxSVGGraph::scatterPlot function
FrxSVGGraph::stackedBarGraph function
FrxSVGGraph::__construct function Overrides FrxRenderer::__construct