function FrxSVGGraph::renderGraph in Forena Reports 7.3
Same name and namespace in other branches
- 6.2 plugins/FrxSVGGraph.inc \FrxSVGGraph::renderGraph()
- 7.2 plugins/FrxSVGGraph.inc \FrxSVGGraph::renderGraph()
- 7.4 renderers/FrxSVGGraph.inc \FrxSVGGraph::renderGraph()
1 call to FrxSVGGraph::renderGraph()
- FrxSVGGraph::renderChart in renderers/
FrxSVGGraph.inc
File
- renderers/
FrxSVGGraph.inc, line 80
Class
Code
function renderGraph($type, $options, $data) {
static $jsinc = FALSE;
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'];
}
$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);
// Add a viewbox to be compatible with Prince PDF generation.
$output = str_replace('<svg width', "<svg viewBox='0 0 {$width} {$height}' width", $output);
$javascript = '/<script[^>]*?>.*?<\\/script>/si';
$noscript = '';
if (!$jsinc && $this->format == 'web') {
$output .= $graph
->FetchJavascript();
}
else {
$output = preg_replace($javascript, $noscript, $output);
}
return $output;
}