You are here

function FrxSVGGraph::renderChart in Forena Reports 7.3

Same name and namespace in other branches
  1. 6.2 plugins/FrxSVGGraph.inc \FrxSVGGraph::renderChart()
  2. 7.2 plugins/FrxSVGGraph.inc \FrxSVGGraph::renderChart()
  3. 7.4 renderers/FrxSVGGraph.inc \FrxSVGGraph::renderChart()

File

renderers/FrxSVGGraph.inc, line 49

Class

FrxSVGGraph

Code

function renderChart($type, $data, $options, $links) {
  $options['width'] = @$options['width'] ? $options['width'] : 600;
  $options['height'] = @$options['height'] ? $options['height'] : 400;
  $this->links = $links;
  $type = strtolower($type);

  // Legacy sustitions for backcward compatibility.
  if ($type == 'piechart') {
    $type = 'piegraph';
  }
  if ($type == 'scatterplot') {
    $type = 'scattergraph';
  }
  if ($type == 'multiscatterplot') {
    $type = 'multiscattergraph';
  }

  // Newly defined types
  $graph_types = FrxSVGGraph::graphTypes();

  // Build map for array types.
  $lower_graphs_types = array_change_key_case($graph_types);
  $graph_classes = array_combine(array_keys($lower_graphs_types), array_keys($graph_types));
  if ($data && isset($graph_classes[$type])) {
    $class = $graph_classes[$type];
    if (@$graph_types[$class]['series'] == 1) {
      $output = $this
        ->renderGraph($class, $options, $data[0]);
    }
    else {
      $output = $this
        ->renderGraph($class, $options, $data);
    }
  }
  return $output;
}