function FrxSVGGraph::renderGraph in Forena Reports 7.5
1 call to FrxSVGGraph::renderGraph()
- FrxSVGGraph::renderChart in src/
Renderer/ FrxSVGGraph.php
File
- src/
Renderer/ FrxSVGGraph.php, line 435 - FrxSVGGraph php SVG Graph generator
Class
Namespace
Drupal\forena\RendererCode
function renderGraph($type) {
$options = $this
->replaceTokens($this->graphOptions);
$data = $this->graphData;
if (!isset($options['scatter_2d']) && ($type == 'ScatterGraph' || $type == 'MultiScatterGraph') && $this->xy_data && !isset($options['scatter_2d'])) {
$options['scatter_2d'] = TRUE;
}
else {
$options['scatter_2d'] = (bool) @$options['scatter_2d'];
}
$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 (isset($options['colour']) && is_array($options['colour'])) {
$graph
->Colours($options['colour']);
}
// Generate the graph
$output = $graph
->Fetch($type, FALSE);
// Add a viewbox to be compatible with Prince PDF generation.
if (!@$options['noviewbox']) {
$options['auto_fit'] = true;
}
if (!@$options['noviewbox'] && !strpos($output, 'viewBox')) {
$output = str_replace('<svg width', "<svg viewBox='0 0 {$width} {$height}' width", $output);
}
if ($this->format == 'web') {
if (@(!$options['no_js'])) {
$js = $graph
->FetchJavascript();
$output .= $js;
}
}
return $output;
}