2011-03-30 14:34:25 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
|
|
|
|
// Please see http://pandorafms.org for full contribution list
|
|
|
|
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation for version 2.
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2011-04-01 14:28:50 +02:00
|
|
|
include_once('functions_utils.php');
|
2011-06-13 13:12:32 +02:00
|
|
|
include_once('../functions_io.php');
|
2011-04-01 14:28:50 +02:00
|
|
|
include_once('../functions.php');
|
|
|
|
include_once('../functions_html.php');
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* pChart library inclusions */
|
|
|
|
include_once("pChart/pData.class.php");
|
|
|
|
include_once("pChart/pDraw.class.php");
|
|
|
|
include_once("pChart/pImage.class.php");
|
|
|
|
include_once("pChart/pPie.class.php");
|
|
|
|
include_once("pChart/pScatter.class.php");
|
|
|
|
include_once("pChart/pRadar.class.php");
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
// Define default fine colors
|
|
|
|
|
|
|
|
$default_fine_colors = array();
|
|
|
|
$default_fine_colors[] = "#2222FF";
|
|
|
|
$default_fine_colors[] = "#00DD00";
|
|
|
|
$default_fine_colors[] = "#CC0033";
|
|
|
|
$default_fine_colors[] = "#9900CC";
|
|
|
|
$default_fine_colors[] = "#FFCC66";
|
|
|
|
$default_fine_colors[] = "#999999";
|
|
|
|
|
2011-04-14 18:22:22 +02:00
|
|
|
// Default values
|
|
|
|
|
|
|
|
$antialiasing = true;
|
2011-04-20 17:54:31 +02:00
|
|
|
$font = '../fonts/unicode.ttf';
|
2011-04-14 18:22:22 +02:00
|
|
|
$xaxisname = '';
|
|
|
|
$yaxisname = '';
|
|
|
|
$legend = null;
|
|
|
|
$colors = null;
|
2011-04-20 17:54:31 +02:00
|
|
|
$font_size = 8;
|
2011-05-03 13:23:24 +02:00
|
|
|
$force_steps = true;
|
2011-04-14 18:22:22 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
$graph_type = get_parameter('graph_type', '');
|
|
|
|
|
|
|
|
$id_graph = get_parameter('id_graph', false);
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
if (!$id_graph) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2011-06-13 18:55:19 +02:00
|
|
|
$ttl = get_parameter('ttl', 1);
|
|
|
|
|
|
|
|
$graph = unserialize_in_temp($id_graph, true, $ttl);
|
2011-04-08 10:56:43 +02:00
|
|
|
|
|
|
|
if (!isset($graph)) {
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data = $graph['data'];
|
|
|
|
$width = $graph['width'];
|
|
|
|
$height = $graph['height'];
|
2011-05-03 13:23:24 +02:00
|
|
|
|
|
|
|
if (isset($graph['color'])) {
|
2011-04-12 18:30:24 +02:00
|
|
|
$colors = $graph['color'];
|
2011-05-03 13:23:24 +02:00
|
|
|
}
|
|
|
|
if (isset($graph['legend'])) {
|
2011-04-12 18:30:24 +02:00
|
|
|
$legend = $graph['legend'];
|
2011-05-03 13:23:24 +02:00
|
|
|
}
|
2011-04-08 10:56:43 +02:00
|
|
|
if(isset($graph['xaxisname'])) {
|
|
|
|
$xaxisname = $graph['xaxisname'];
|
|
|
|
}
|
|
|
|
if(isset($graph['yaxisname'])) {
|
|
|
|
$yaxisname = $graph['yaxisname'];
|
|
|
|
}
|
2011-04-14 18:22:22 +02:00
|
|
|
if(isset($graph['round_corner'])) {
|
|
|
|
$round_corner = $graph['round_corner'];
|
|
|
|
}
|
2011-04-20 16:22:40 +02:00
|
|
|
if(isset($graph['font'])) {
|
|
|
|
if (!empty($graph['font'])) {
|
|
|
|
$font = $graph['font'];
|
|
|
|
}
|
2011-04-13 15:01:37 +02:00
|
|
|
}
|
2011-04-20 17:54:31 +02:00
|
|
|
if(isset($graph['font_size'])) {
|
|
|
|
if (!empty($graph['font_size'])) {
|
|
|
|
$font_size = $graph['font_size'];
|
|
|
|
}
|
|
|
|
}
|
2011-04-14 18:22:22 +02:00
|
|
|
if(isset($graph['antialiasing'])) {
|
|
|
|
$antialiasing = $graph['antialiasing'];
|
2011-04-13 15:01:37 +02:00
|
|
|
}
|
2011-04-14 15:53:46 +02:00
|
|
|
$force_height = true;
|
|
|
|
if(isset($graph['force_height'])) {
|
|
|
|
$force_height = $graph['force_height'];
|
|
|
|
}
|
2011-05-09 17:20:58 +02:00
|
|
|
if(isset($graph['period'])) {
|
|
|
|
$period = $graph['period'];
|
|
|
|
}
|
2011-04-14 15:53:46 +02:00
|
|
|
|
|
|
|
if (!$force_height) {
|
|
|
|
if ($height < (count($graph['data']) * 14)) {
|
|
|
|
$height = (count($graph['data']) * 14);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
$water_mark = '';
|
|
|
|
if(isset($graph['water_mark'])) {
|
|
|
|
$water_mark = $graph['water_mark']; //"/var/www/pandora_console/images/logo_vertical_water.png";
|
|
|
|
}
|
2011-03-30 17:34:49 +02:00
|
|
|
|
2011-04-25 13:48:27 +02:00
|
|
|
if (isset($graph['force_steps'])) {
|
|
|
|
$force_steps = $graph['force_steps'];
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
/*
|
2011-04-08 10:56:43 +02:00
|
|
|
$colors = array();
|
|
|
|
$colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 50);
|
|
|
|
$colors['pep2'] = array('border' => '#ff7f00', 'color' => '#ff0000', 'alpha' => 50);
|
|
|
|
$colors['pep3'] = array('border' => '#ff0000', 'color' => '#00ff00', 'alpha' => 50);
|
|
|
|
$colors['pep4'] = array('border' => '#000000', 'color' => '#0000ff', 'alpha' => 50);
|
2011-03-30 17:34:49 +02:00
|
|
|
*/
|
2011-04-08 10:56:43 +02:00
|
|
|
|
2011-04-25 13:48:27 +02:00
|
|
|
$step = 1;
|
|
|
|
if ($force_steps) {
|
2011-12-22 19:42:50 +01:00
|
|
|
$pixels_between_xdata = 50;
|
2011-04-25 13:48:27 +02:00
|
|
|
$max_xdata_display = round($width / $pixels_between_xdata);
|
|
|
|
$ndata = count($data);
|
|
|
|
if($max_xdata_display > $ndata) {
|
|
|
|
$xdata_display = $ndata;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$xdata_display = $max_xdata_display;
|
|
|
|
}
|
|
|
|
|
|
|
|
$step = round($ndata/$xdata_display);
|
2011-04-14 15:53:46 +02:00
|
|
|
}
|
|
|
|
|
2011-12-22 19:42:50 +01:00
|
|
|
$c = 1;
|
2011-04-08 10:56:43 +02:00
|
|
|
|
|
|
|
switch($graph_type) {
|
|
|
|
case 'hbar':
|
|
|
|
case 'vbar':
|
|
|
|
foreach($data as $i => $values) {
|
|
|
|
foreach($values as $name => $val) {
|
|
|
|
$data_values[$name][] = $val;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($c % $step) == 0) {
|
|
|
|
$data_keys[] = $i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$data_keys[] = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$c++;
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
2011-04-08 10:56:43 +02:00
|
|
|
$fine_colors = array();
|
|
|
|
|
|
|
|
// If is set fine colors we store it or set default
|
|
|
|
if(isset($colors[reset(array_keys($data_values))]['fine'])) {
|
|
|
|
$fine = $colors[reset(array_keys($data_values))]['fine'];
|
|
|
|
if($fine === true) {
|
|
|
|
$fine = $default_fine_colors;
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach($fine as $i => $fine_color) {
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb_fine = html_html2rgb($fine_color);
|
2011-04-08 10:56:43 +02:00
|
|
|
$fine_colors[$i]['R'] = $rgb_fine[0];
|
|
|
|
$fine_colors[$i]['G'] = $rgb_fine[1];
|
|
|
|
$fine_colors[$i]['B'] = $rgb_fine[2];
|
|
|
|
$fine_colors[$i]['Alpha'] = 100;
|
|
|
|
}
|
2011-04-14 15:53:46 +02:00
|
|
|
$colors = array();
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
break;
|
|
|
|
case 'progress':
|
|
|
|
case 'area':
|
2011-04-12 18:30:24 +02:00
|
|
|
case 'stacked_area':
|
|
|
|
case 'stacked_line':
|
2011-04-11 18:45:03 +02:00
|
|
|
case 'line':
|
2011-04-08 10:56:43 +02:00
|
|
|
case 'threshold':
|
|
|
|
case 'scatter':
|
|
|
|
foreach($data as $i => $d) {
|
|
|
|
$data_values[] = $d;
|
|
|
|
|
|
|
|
|
|
|
|
if (($c % $step) == 0) {
|
|
|
|
$data_keys[] = $i;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$data_keys[] = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
$c++;
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
2011-04-08 10:56:43 +02:00
|
|
|
|
|
|
|
break;
|
2011-04-13 15:01:37 +02:00
|
|
|
case 'slicebar':
|
2011-04-13 10:49:18 +02:00
|
|
|
case 'polar':
|
|
|
|
case 'radar':
|
2011-04-08 10:56:43 +02:00
|
|
|
case 'pie3d':
|
|
|
|
case 'pie2d':
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-13 15:01:37 +02:00
|
|
|
switch($graph_type) {
|
|
|
|
case 'slicebar':
|
|
|
|
case 'polar':
|
|
|
|
case 'radar':
|
|
|
|
case 'pie3d':
|
|
|
|
case 'pie2d':
|
|
|
|
break;
|
|
|
|
case 'default':
|
|
|
|
if(!is_array(reset($data_values))) {
|
|
|
|
$data_values = array($data_values);
|
|
|
|
if(is_array($colors) && !empty($colors)) {
|
|
|
|
$colors = array($colors);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-03-30 14:34:25 +02:00
|
|
|
}
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
$rgb_color = array();
|
|
|
|
|
|
|
|
if (!isset($colors))
|
|
|
|
$colors = array();
|
2011-03-30 14:34:25 +02:00
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
foreach($colors as $i => $color) {
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb['border'] = html_html2rgb($color['border']);
|
2011-04-08 10:56:43 +02:00
|
|
|
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
|
|
|
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
|
|
|
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
2011-03-31 10:26:48 +02:00
|
|
|
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb['color'] = html_html2rgb($color['color']);
|
2011-04-08 10:56:43 +02:00
|
|
|
$rgb_color[$i]['color']['R'] = $rgb['color'][0];
|
|
|
|
$rgb_color[$i]['color']['G'] = $rgb['color'][1];
|
|
|
|
$rgb_color[$i]['color']['B'] = $rgb['color'][2];
|
|
|
|
|
|
|
|
$rgb_color[$i]['alpha'] = $color['alpha'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*foreach($colors as $i => $color) {
|
|
|
|
if (isset($color['border'])) {
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb['border'] = html_html2rgb($color['border']);
|
2011-04-08 10:56:43 +02:00
|
|
|
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
|
|
|
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
|
|
|
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
2011-03-31 10:26:48 +02:00
|
|
|
}
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
if (isset($color['color'])) {
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb['color'] = html_html2rgb($color['color']);
|
2011-04-08 10:56:43 +02:00
|
|
|
$rgb_color[$i]['color']['R'] = $rgb['color'][0];
|
|
|
|
$rgb_color[$i]['color']['G'] = $rgb['color'][1];
|
|
|
|
$rgb_color[$i]['color']['B'] = $rgb['color'][2];
|
|
|
|
}
|
2011-03-31 19:07:00 +02:00
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
if (isset($color['color'])) {
|
|
|
|
$rgb_color[$i]['alpha'] = $color['alpha'];
|
2011-03-30 14:34:25 +02:00
|
|
|
}
|
2011-04-08 10:56:43 +02:00
|
|
|
}*/
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
switch($graph_type) {
|
|
|
|
case 'pie3d':
|
|
|
|
case 'pie2d':
|
2011-04-20 17:54:31 +02:00
|
|
|
pch_pie_graph($graph_type, array_values($data), array_keys($data),
|
|
|
|
$width, $height, $font, $water_mark, $font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
2011-04-13 15:01:37 +02:00
|
|
|
case 'slicebar':
|
2011-05-09 17:20:58 +02:00
|
|
|
pch_slicebar_graph($graph_type, $data, $period, $width, $height, $colors, $font, $round_corner, $font_size);
|
2011-04-13 15:01:37 +02:00
|
|
|
break;
|
2011-03-30 14:34:25 +02:00
|
|
|
case 'polar':
|
|
|
|
case 'radar':
|
2011-04-20 17:54:31 +02:00
|
|
|
pch_kiviat_graph($graph_type, array_values($data), array_keys($data),
|
|
|
|
$width, $height, $font, $font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
2011-04-08 10:56:43 +02:00
|
|
|
case 'hbar':
|
2011-03-30 14:34:25 +02:00
|
|
|
case 'vbar':
|
2011-04-20 11:23:54 +02:00
|
|
|
pch_bar_graph($graph_type, $data_keys, $data_values, $width, $height,
|
|
|
|
$font, $antialiasing, $rgb_color, $xaxisname, $yaxisname, false,
|
2011-04-20 17:54:31 +02:00
|
|
|
$legend, $fine_colors, $water_mark, $font_size);
|
2011-03-30 17:34:49 +02:00
|
|
|
break;
|
2011-04-07 19:36:08 +02:00
|
|
|
case 'stacked_area':
|
2011-03-30 14:34:25 +02:00
|
|
|
case 'area':
|
2011-04-07 19:36:08 +02:00
|
|
|
case 'line':
|
2011-04-20 11:23:54 +02:00
|
|
|
pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
|
|
|
|
$height, $rgb_color, $xaxisname, $yaxisname, false, $legend,
|
2011-04-20 17:54:31 +02:00
|
|
|
$font, $antialiasing, $water_mark, $font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
|
|
|
case 'threshold':
|
2011-04-20 17:54:31 +02:00
|
|
|
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
|
|
|
$height, $font, $antialiasing, $xaxisname, $yaxisname, $title,
|
|
|
|
$font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-05-09 17:20:58 +02:00
|
|
|
function pch_slicebar_graph ($graph_type, $data, $period, $width, $height, $colors, $font, $round_corner, $font_size) {
|
2011-04-13 15:01:37 +02:00
|
|
|
/* CAT:Slicebar charts */
|
|
|
|
|
|
|
|
set_time_limit (0);
|
|
|
|
|
|
|
|
// Dataset definition
|
|
|
|
$myPicture = new pImage($width,$height);
|
|
|
|
|
2011-04-14 18:22:22 +02:00
|
|
|
/* Turn of Antialiasing */
|
|
|
|
$myPicture->Antialias = $antialiasing;
|
|
|
|
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=> $font, "FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
|
2011-04-13 15:01:37 +02:00
|
|
|
|
|
|
|
// Round corners defined in global setup
|
|
|
|
if ($round_corner != 0)
|
|
|
|
$radius = ($height > 18) ? 8 : 0;
|
|
|
|
else
|
|
|
|
$radius = 0;
|
2011-05-09 17:20:58 +02:00
|
|
|
|
|
|
|
$thinest_slice = $width / $period;
|
2011-04-13 15:01:37 +02:00
|
|
|
|
|
|
|
/* Color stuff */
|
|
|
|
$colorsrgb = array();
|
|
|
|
foreach($colors as $key => $col) {
|
2011-04-27 15:43:31 +02:00
|
|
|
$rgb = html_html2rgb($col);
|
2011-04-13 15:01:37 +02:00
|
|
|
$colorsrgb[$key]['R'] = $rgb[0];
|
|
|
|
$colorsrgb[$key]['G'] = $rgb[1];
|
|
|
|
$colorsrgb[$key]['B'] = $rgb[2];
|
|
|
|
}
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
foreach ($data as $d) {
|
2011-05-09 17:20:58 +02:00
|
|
|
$color = $d['data'];
|
|
|
|
$color = $colorsrgb[$color];
|
|
|
|
$ratio = $thinest_slice * $d['utimestamp'];
|
2011-04-13 15:01:37 +02:00
|
|
|
$myPicture->drawRoundedFilledRectangle ($i, 0, $ratio+$i,
|
|
|
|
$height, $radius, array('R' => $color['R'], 'G' => $color['G'], 'B' => $color['B']));
|
|
|
|
$i+=$ratio;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($round_corner) {
|
|
|
|
/* Under this value, the rounded rectangle is painted great */
|
2011-05-09 17:20:58 +02:00
|
|
|
if ($thinest_slice <= 16) {
|
2011-04-13 15:01:37 +02:00
|
|
|
/* Clean a bit of pixels */
|
|
|
|
for ($i = 0; $i < 7; $i++) {
|
|
|
|
$myPicture->drawLine (0, $i, 6 - $i, $i, array('R' => 255, 'G' => 255, 'B' => 255));
|
|
|
|
}
|
|
|
|
$end = $height - 1;
|
|
|
|
for ($i = 0; $i < 7; $i++) {
|
|
|
|
$myPicture->drawLine (0, $end - $i, 5 - $i, $end - $i, array('R' => 255, 'G' => 255, 'B' => 255));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$myPicture->drawRoundedRectangle (0, 0, $width,
|
|
|
|
$height - 1, $radius, array('R' => 157, 'G' => 157, 'B' => 157));
|
|
|
|
|
|
|
|
$myPicture->Stroke ();
|
|
|
|
}
|
|
|
|
|
2011-04-20 17:54:31 +02:00
|
|
|
function pch_pie_graph ($graph_type, $data_values, $legend_values, $width,
|
|
|
|
$height, $font, $water_mark, $font_size) {
|
2011-03-30 14:34:25 +02:00
|
|
|
/* CAT:Pie charts */
|
|
|
|
|
|
|
|
/* Create and populate the pData object */
|
|
|
|
$MyData = new pData();
|
|
|
|
$MyData->addPoints($data_values,"ScoreA");
|
|
|
|
$MyData->setSerieDescription("ScoreA","Application A");
|
|
|
|
|
|
|
|
/* Define the absissa serie */
|
|
|
|
$MyData->addPoints($legend_values,"Labels");
|
|
|
|
$MyData->setAbscissa("Labels");
|
|
|
|
|
|
|
|
/* Create the pChart object */
|
|
|
|
$myPicture = new pImage($width,$height,$MyData,TRUE);
|
2011-04-14 18:22:22 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Set the default font properties */
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
|
2011-04-13 10:49:18 +02:00
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
$water_mark_height = 0;
|
|
|
|
$water_mark_width = 0;
|
|
|
|
if (!empty($water_mark)) {
|
|
|
|
$size_water_mark = getimagesize($water_mark);
|
|
|
|
$water_mark_height = $size_water_mark[1];
|
|
|
|
$water_mark_width = $size_water_mark[0];
|
|
|
|
|
|
|
|
$myPicture->drawFromPNG(($width - $water_mark_width),
|
|
|
|
($height - $water_mark_height) - 50, $water_mark);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Create the pPie object */
|
|
|
|
$PieChart = new pPie($myPicture,$MyData);
|
|
|
|
|
|
|
|
/* Draw an AA pie chart */
|
|
|
|
switch($graph_type) {
|
|
|
|
case "pie2d":
|
2011-04-08 10:56:43 +02:00
|
|
|
$PieChart->draw2DPie($width/4,$height/2,array("DataGapAngle"=>0,"DataGapRadius"=>0, "Border"=>FALSE, "BorderR"=>200, "BorderG"=>200, "BorderB"=>200, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
|
|
|
case "pie3d":
|
2011-04-20 11:23:54 +02:00
|
|
|
$PieChart->draw3DPie($width/4, $height/2,array("DataGapAngle"=>10,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
2011-03-30 14:34:25 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Write down the legend next to the 2nd chart*/
|
2011-04-14 18:22:22 +02:00
|
|
|
//Calculate the bottom margin from the size of string in each index
|
2011-12-22 19:42:50 +01:00
|
|
|
$max_chars = graph_get_max_index($legend_values);
|
|
|
|
$legend_with_aprox = 32 + (7 * $max_chars);
|
2011-04-14 18:22:22 +02:00
|
|
|
|
|
|
|
$PieChart->drawPieLegend($width - $legend_with_aprox, 5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Enable shadow computing */
|
|
|
|
$myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
|
|
|
|
|
|
/* Render the picture */
|
2011-04-20 11:23:54 +02:00
|
|
|
$myPicture->stroke();
|
2011-03-30 14:34:25 +02:00
|
|
|
}
|
|
|
|
|
2011-04-20 17:54:31 +02:00
|
|
|
function pch_kiviat_graph ($graph_type, $data_values, $legend_values, $width,
|
|
|
|
$height, $font, $font_size) {
|
2011-03-30 14:34:25 +02:00
|
|
|
/* CAT:Radar/Polar charts */
|
|
|
|
|
|
|
|
/* Create and populate the pData object */
|
|
|
|
$MyData = new pData();
|
|
|
|
$MyData->addPoints($data_values,"ScoreA");
|
|
|
|
$MyData->setSerieDescription("ScoreA","Application A");
|
|
|
|
|
|
|
|
/* Define the absissa serie */
|
|
|
|
$MyData->addPoints($legend_values,"Labels");
|
|
|
|
$MyData->setAbscissa("Labels");
|
|
|
|
|
|
|
|
/* Create the pChart object */
|
|
|
|
$myPicture = new pImage($width,$height,$MyData,TRUE);
|
|
|
|
|
|
|
|
/* Set the default font properties */
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size,"R"=>80,"G"=>80,"B"=>80));
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Create the pRadar object */
|
|
|
|
$SplitChart = new pRadar();
|
|
|
|
|
|
|
|
/* Draw a radar chart */
|
|
|
|
$myPicture->setGraphArea(20,25,$width-10,$height-10);
|
|
|
|
|
|
|
|
/* Draw an AA pie chart */
|
|
|
|
switch($graph_type) {
|
|
|
|
case "radar":
|
2011-04-20 17:54:31 +02:00
|
|
|
$Options = array("SkipLabels"=>0,"LabelPos"=>RADAR_LABELS_HORIZONTAL,
|
|
|
|
"LabelMiddle"=>FALSE,"Layout"=>RADAR_LAYOUT_STAR,
|
|
|
|
"BackgroundGradient"=>array("StartR"=>255,"StartG"=>255,"StartB"=>255,
|
|
|
|
"StartAlpha"=>100,"EndR"=>207,"EndG"=>227,"EndB"=>125,"EndAlpha"=>50),
|
2011-04-20 18:57:06 +02:00
|
|
|
"FontName"=>$font,"FontSize"=>$font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
$SplitChart->drawRadar($myPicture,$MyData,$Options);
|
|
|
|
break;
|
|
|
|
case "polar":
|
2011-04-20 17:54:31 +02:00
|
|
|
$Options = array("Layout"=>RADAR_LAYOUT_CIRCLE,"BackgroundGradient"=>array("StartR"=>255,"StartG"=>255,"StartB"=>255,"StartAlpha"=>100,"EndR"=>207,"EndG"=>227,"EndB"=>125,"EndAlpha"=>50),
|
2011-04-20 18:57:06 +02:00
|
|
|
"FontName"=>$font,"FontSize"=>$font_size);
|
2011-03-30 14:34:25 +02:00
|
|
|
$SplitChart->drawRadar($myPicture,$MyData,$Options);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Render the picture */
|
|
|
|
$myPicture->stroke();
|
|
|
|
}
|
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
|
|
|
$antialiasing, $rgb_color = false, $xaxisname = "", $yaxisname = "",
|
2011-04-20 17:54:31 +02:00
|
|
|
$show_values = false, $legend = array(), $fine_colors = array(), $water_mark = '', $font_size) {
|
2011-03-30 17:34:49 +02:00
|
|
|
/* CAT: Vertical Bar Chart */
|
2011-04-08 10:56:43 +02:00
|
|
|
if(!is_array($legend) || empty($legend)) {
|
|
|
|
unset($legend);
|
|
|
|
}
|
2011-03-30 17:34:49 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Create and populate the pData object */
|
|
|
|
$MyData = new pData();
|
2011-04-08 10:56:43 +02:00
|
|
|
$overridePalette = array();
|
2011-03-30 14:34:25 +02:00
|
|
|
foreach($data as $i => $values) {
|
2011-04-08 10:56:43 +02:00
|
|
|
$MyData->addPoints($values,$i);
|
2011-04-13 17:58:59 +02:00
|
|
|
|
|
|
|
if(!empty($rgb_color)) {
|
2011-04-01 14:28:50 +02:00
|
|
|
$MyData->setPalette($i,
|
|
|
|
array("R" => $rgb_color[$i]['color']["R"],
|
|
|
|
"G" => $rgb_color[$i]['color']["G"],
|
|
|
|
"B" => $rgb_color[$i]['color']["B"],
|
|
|
|
"BorderR" => $rgb_color[$i]['border']["R"],
|
|
|
|
"BorderG" => $rgb_color[$i]['border']["G"],
|
|
|
|
"BorderB" => $rgb_color[$i]['border']["B"],
|
2011-04-08 10:56:43 +02:00
|
|
|
"Alpha" => $rgb_color[$i]['alpha']));
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign cyclic colors to bars if are setted
|
|
|
|
if($fine_colors) {
|
|
|
|
$c = 0;
|
|
|
|
foreach($values as $ii => $vv) {
|
|
|
|
if(!isset($fine_colors[$c])) {
|
|
|
|
$c = 0;
|
|
|
|
}
|
|
|
|
$overridePalette[$ii] = $fine_colors[$c];
|
|
|
|
$c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$overridePalette = false;
|
2011-04-01 14:28:50 +02:00
|
|
|
}
|
2011-03-30 14:34:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$MyData->setAxisName(0,$yaxisname);
|
|
|
|
$MyData->addPoints($index,"Xaxis");
|
|
|
|
$MyData->setSerieDescription("Xaxis", $xaxisname);
|
|
|
|
$MyData->setAbscissa("Xaxis");
|
|
|
|
|
|
|
|
/* Create the pChart object */
|
|
|
|
$myPicture = new pImage($width,$height,$MyData);
|
2011-04-20 11:23:54 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Turn of Antialiasing */
|
2011-04-14 18:22:22 +02:00
|
|
|
$myPicture->Antialias = $antialiasing;
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Add a border to the picture */
|
|
|
|
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
/* Turn on shadow computing */
|
|
|
|
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Set the default font */
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Draw the scale */
|
2011-04-01 14:28:50 +02:00
|
|
|
// TODO: AvoidTickWhenEmpty = FALSE When the distance between two ticks will be less than 50 px
|
|
|
|
// TODO: AvoidTickWhenEmpty = TRUE When the distance between two ticks will be greater than 50 px
|
2011-04-18 12:30:45 +02:00
|
|
|
|
|
|
|
//Calculate the top margin from the size of string in each index
|
2011-12-22 19:42:50 +01:00
|
|
|
$max_chars = graph_get_max_index($index);
|
2011-04-18 12:30:45 +02:00
|
|
|
$margin_top = 10 * $max_chars;
|
2011-04-20 11:23:54 +02:00
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
switch($graph_type) {
|
|
|
|
case "vbar":
|
2011-04-20 11:23:54 +02:00
|
|
|
$scaleSettings = array("AvoidTickWhenEmpty" => FALSE, "AvoidGridWhenEmpty" => FALSE,
|
|
|
|
"GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,
|
|
|
|
"Mode"=>SCALE_MODE_START0, "LabelRotation" => 60);
|
2011-04-18 12:30:45 +02:00
|
|
|
$margin_left = 40;
|
|
|
|
$margin_top = 10;
|
2011-05-03 13:23:24 +02:00
|
|
|
$margin_bottom = 10 * $max_chars;
|
2011-04-08 10:56:43 +02:00
|
|
|
break;
|
|
|
|
case "hbar":
|
2011-04-20 11:23:54 +02:00
|
|
|
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,
|
|
|
|
"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "Pos"=>SCALE_POS_TOPBOTTOM,
|
|
|
|
"LabelValuesRotation" => 60);
|
|
|
|
$margin_left = 5 * $max_chars;
|
2011-04-18 12:30:45 +02:00
|
|
|
$margin_top = 40;
|
|
|
|
$margin_bottom = 10;
|
2011-04-08 10:56:43 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
$water_mark_height = 0;
|
|
|
|
$water_mark_width = 0;
|
|
|
|
if (!empty($water_mark)) {
|
|
|
|
$size_water_mark = getimagesize($water_mark);
|
|
|
|
$water_mark_height = $size_water_mark[1];
|
|
|
|
$water_mark_width = $size_water_mark[0];
|
|
|
|
|
|
|
|
$myPicture->drawFromPNG(($width - $water_mark_width),
|
|
|
|
($height - $water_mark_height) - $margin_bottom, $water_mark);
|
|
|
|
}
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
/* Define the chart area */
|
2011-04-20 11:23:54 +02:00
|
|
|
$myPicture->setGraphArea($margin_left,$margin_top,$width - $water_mark_width,$height-$margin_bottom);
|
2011-04-08 10:56:43 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
$myPicture->drawScale($scaleSettings);
|
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
if(isset($legend)) {
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Write the chart legend */
|
2011-04-08 10:56:43 +02:00
|
|
|
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
|
|
|
|
$myPicture->drawLegend($width-$size['Width'],0,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL, "BoxWidth"=>10, "BoxHeight"=>10));
|
2011-03-30 14:34:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Turn on shadow computing */
|
|
|
|
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
|
|
|
|
|
|
/* Draw the chart */
|
2011-04-08 10:56:43 +02:00
|
|
|
$settings = array("ForceTransparency"=>"-1", "Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE, "OverrideColors"=>$overridePalette);
|
2011-04-05 11:27:38 +02:00
|
|
|
|
2011-04-08 10:56:43 +02:00
|
|
|
$myPicture->drawBarChart($settings);
|
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
/* Render the picture */
|
|
|
|
$myPicture->stroke();
|
|
|
|
}
|
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
|
|
|
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
|
2011-04-20 17:54:31 +02:00
|
|
|
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size) {
|
2011-03-30 17:34:49 +02:00
|
|
|
/* CAT:Vertical Charts */
|
2011-03-31 10:26:48 +02:00
|
|
|
if(!is_array($legend) || empty($legend)) {
|
|
|
|
unset($legend);
|
|
|
|
}
|
2011-03-31 19:07:00 +02:00
|
|
|
/*$legend=array('pep1' => 'pep1','pep2' => 'pep2','pep3' => 'pep3','pep4' => 'pep4');
|
|
|
|
$data=array(array('pep1' => 1, 'pep2' => 1, 'pep3' => 3, 'pep4' => 3), array('pep1' => 1, 'pep2' => 3, 'pep3' => 1,'pep4' => 4), array('pep1' => 3, 'pep2' => 1, 'pep3' => 1,'pep4' =>1), array('pep1' => 1, 'pep2' =>1, 'pep3' =>1,'pep4' =>0));
|
|
|
|
$index=array(1,2,3,4);
|
|
|
|
*/
|
|
|
|
if(is_array(reset($data))) {
|
2011-03-30 17:34:49 +02:00
|
|
|
$data2 = array();
|
|
|
|
foreach($data as $i =>$values) {
|
|
|
|
$c = 0;
|
2011-03-31 19:07:00 +02:00
|
|
|
foreach($values as $i2 => $value) {
|
|
|
|
$data2[$i2][$i] = $value;
|
2011-03-30 17:34:49 +02:00
|
|
|
$c++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data = $data2;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$data = array($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create and populate the pData object */
|
|
|
|
$MyData = new pData();
|
2011-04-19 14:11:00 +02:00
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
foreach($data as $i => $values) {
|
2011-03-31 19:07:00 +02:00
|
|
|
if(isset($legend)) {
|
2011-03-31 10:26:48 +02:00
|
|
|
$point_id = $legend[$i];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$point_id = $i;
|
|
|
|
}
|
2012-01-24 19:53:18 +01:00
|
|
|
|
2011-03-31 10:26:48 +02:00
|
|
|
$MyData->addPoints($values,$point_id);
|
2011-04-05 18:11:53 +02:00
|
|
|
if (!empty($rgb_color)) {
|
2011-04-01 14:28:50 +02:00
|
|
|
$MyData->setPalette($point_id,
|
2011-04-07 16:34:03 +02:00
|
|
|
array("R" => $rgb_color[$i]['color']["R"],
|
|
|
|
"G" => $rgb_color[$i]['color']["G"],
|
|
|
|
"B" => $rgb_color[$i]['color']["B"],
|
|
|
|
"BorderR" => $rgb_color[$i]['border']["R"],
|
|
|
|
"BorderG" => $rgb_color[$i]['border']["G"],
|
|
|
|
"BorderB" => $rgb_color[$i]['border']["B"],
|
|
|
|
"Alpha" => $rgb_color[$i]['alpha']));
|
|
|
|
|
|
|
|
/*$palette_color = array();
|
|
|
|
if (isset($rgb_color[$i]['color'])) {
|
|
|
|
$palette_color["R"] = $rgb_color[$i]['color']["R"];
|
|
|
|
$palette_color["G"] = $rgb_color[$i]['color']["G"];
|
|
|
|
$palette_color["B"] = $rgb_color[$i]['color']["B"];
|
|
|
|
}
|
|
|
|
if (isset($rgb_color[$i]['color'])) {
|
|
|
|
$palette_color["BorderR"] = $rgb_color[$i]['border']["R"];
|
|
|
|
$palette_color["BorderG"] = $rgb_color[$i]['border']["G"];
|
|
|
|
$palette_color["BorderB"] = $rgb_color[$i]['border']["B"];
|
|
|
|
}
|
|
|
|
if (isset($rgb_color[$i]['color'])) {
|
|
|
|
$palette_color["Alpha"] = $rgb_color[$i]['Alpha'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$MyData->setPalette($point_id, $palette_color);*/
|
2012-01-24 19:53:18 +01:00
|
|
|
}
|
2011-04-14 19:17:12 +02:00
|
|
|
|
2011-12-22 19:42:50 +01:00
|
|
|
$MyData->setSerieWeight($point_id, 0);
|
2011-03-30 17:34:49 +02:00
|
|
|
}
|
2011-04-08 10:56:43 +02:00
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
//$MyData->addPoints($data,"Yaxis");
|
|
|
|
$MyData->setAxisName(0,$yaxisname);
|
|
|
|
$MyData->addPoints($index,"Xaxis");
|
|
|
|
$MyData->setSerieDescription("Xaxis", $xaxisname);
|
|
|
|
$MyData->setAbscissa("Xaxis");
|
|
|
|
|
|
|
|
/* Create the pChart object */
|
|
|
|
$myPicture = new pImage($width,$height,$MyData);
|
|
|
|
|
|
|
|
/* Turn of Antialiasing */
|
2011-04-14 18:22:22 +02:00
|
|
|
$myPicture->Antialias = $antialiasing;
|
2011-03-30 17:34:49 +02:00
|
|
|
|
|
|
|
/* Add a border to the picture */
|
|
|
|
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
|
|
|
|
|
|
|
/* Set the default font */
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font, "FontSize"=>$font_size));
|
2011-03-30 17:34:49 +02:00
|
|
|
|
2011-04-07 16:34:03 +02:00
|
|
|
if(isset($legend)) {
|
2011-04-13 16:41:45 +02:00
|
|
|
/* Set horizontal legend if is posible */
|
|
|
|
$legend_mode = LEGEND_HORIZONTAL;
|
|
|
|
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
|
|
|
if($size['Width'] > ($width - 5)) {
|
|
|
|
$legend_mode = LEGEND_VERTICAL;
|
|
|
|
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
|
|
|
}
|
|
|
|
|
2011-04-07 16:34:03 +02:00
|
|
|
/* Write the chart legend */
|
2011-04-13 16:41:45 +02:00
|
|
|
$myPicture->drawLegend($width-$size['Width'], 8,array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
|
|
|
|
2011-04-12 18:30:24 +02:00
|
|
|
//Calculate the bottom margin from the size of string in each index
|
2011-12-22 19:42:50 +01:00
|
|
|
$max_chars = graph_get_max_index($index);
|
2011-11-03 18:42:43 +01:00
|
|
|
$margin_bottom = $font_size * $max_chars;
|
2011-04-12 18:30:24 +02:00
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
$water_mark_height = 0;
|
|
|
|
$water_mark_width = 0;
|
|
|
|
if (!empty($water_mark)) {
|
|
|
|
$size_water_mark = getimagesize($water_mark);
|
|
|
|
$water_mark_height = $size_water_mark[1];
|
|
|
|
$water_mark_width = $size_water_mark[0];
|
|
|
|
|
|
|
|
$myPicture->drawFromPNG(($width - $water_mark_width),
|
|
|
|
($height - $water_mark_height) - $margin_bottom, $water_mark);
|
|
|
|
}
|
2012-01-24 19:53:18 +01:00
|
|
|
|
|
|
|
/* Area depends on yaxisname */
|
|
|
|
if ($yaxisname != ''){
|
|
|
|
$chart_size = 80;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$chart_size = 40;
|
|
|
|
}
|
2011-04-20 11:23:54 +02:00
|
|
|
|
2011-04-07 16:34:03 +02:00
|
|
|
if (isset($size['Height'])) {
|
|
|
|
/* Define the chart area */
|
2012-01-24 19:53:18 +01:00
|
|
|
//if ($yaxisname != ''){
|
|
|
|
//}
|
|
|
|
$myPicture->setGraphArea($chart_size,$size['Height'],$width - $water_mark_width,$height - $margin_bottom);
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Define the chart area */
|
2012-01-24 19:53:18 +01:00
|
|
|
$myPicture->setGraphArea($chart_size, 5,$width - $water_mark_width,$height - $margin_bottom);
|
2011-04-07 16:34:03 +02:00
|
|
|
}
|
2012-02-07 17:13:03 +01:00
|
|
|
|
|
|
|
/*Get minimun value to draw axis properly*/
|
|
|
|
$min_data = min(min($data));
|
|
|
|
|
|
|
|
$mode = SCALE_MODE_START0;
|
|
|
|
if ($min_data < 0) {
|
|
|
|
$mode = SCALE_MODE_FLOATING;
|
|
|
|
}
|
2011-03-30 17:34:49 +02:00
|
|
|
|
|
|
|
/* Draw the scale */
|
2011-04-07 16:34:03 +02:00
|
|
|
$scaleSettings = array("GridR"=>200,
|
|
|
|
"GridG"=>200,
|
|
|
|
"GridB"=>200,
|
|
|
|
"DrawSubTicks"=>TRUE,
|
2012-02-07 17:13:03 +01:00
|
|
|
"CycleBackground"=>TRUE, "Mode" => $mode, "LabelRotation" => 60, "XMargin" => 0, "MinDivHeight" => 20);
|
2011-03-30 17:34:49 +02:00
|
|
|
$myPicture->drawScale($scaleSettings);
|
|
|
|
|
|
|
|
/* Turn on shadow computing */
|
|
|
|
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
|
|
|
|
2011-04-07 19:36:08 +02:00
|
|
|
switch ($graph_type) {
|
|
|
|
case 'stacked_area':
|
|
|
|
$ForceTransparency = "-1";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$ForceTransparency = "50";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
/* Draw the chart */
|
2011-04-07 19:36:08 +02:00
|
|
|
$settings = array("ForceTransparency"=> $ForceTransparency, //
|
2011-03-31 19:07:00 +02:00
|
|
|
"Gradient"=>TRUE,
|
|
|
|
"GradientMode"=>GRADIENT_EFFECT_CAN,
|
|
|
|
"DisplayValues"=>$show_values,
|
|
|
|
"DisplayZeroValues"=>FALSE,
|
|
|
|
"DisplayR"=>100,
|
|
|
|
"DisplayZeros"=> FALSE,
|
2012-02-07 17:13:03 +01:00
|
|
|
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>TRUE);
|
2011-03-30 17:34:49 +02:00
|
|
|
|
2011-04-20 11:23:54 +02:00
|
|
|
|
2011-03-30 17:34:49 +02:00
|
|
|
switch($graph_type) {
|
2011-04-07 19:36:08 +02:00
|
|
|
case "stacked_area":
|
2011-03-30 14:34:25 +02:00
|
|
|
case "area":
|
|
|
|
$myPicture->drawAreaChart($settings);
|
|
|
|
break;
|
|
|
|
case "line":
|
|
|
|
$myPicture->drawLineChart($settings);
|
|
|
|
break;
|
|
|
|
}
|
2011-03-30 17:34:49 +02:00
|
|
|
|
2011-03-30 14:34:25 +02:00
|
|
|
/* Render the picture */
|
|
|
|
$myPicture->stroke();
|
|
|
|
}
|
|
|
|
|
2011-04-20 17:54:31 +02:00
|
|
|
function pch_threshold_graph ($graph_type, $index, $data, $width, $height, $font,
|
|
|
|
$antialiasing, $xaxisname = "", $yaxisname = "", $title = "",
|
|
|
|
$show_values = false, $show_legend = false, $font_size) {
|
2011-03-30 17:34:49 +02:00
|
|
|
/* CAT:Threshold Chart */
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Create and populate the pData object */
|
|
|
|
$MyData = new pData();
|
|
|
|
$MyData->addPoints($data,"DEFCA");
|
|
|
|
$MyData->setAxisName(0,$yaxisname);
|
|
|
|
$MyData->setAxisDisplay(0,AXIS_FORMAT_CURRENCY);
|
|
|
|
$MyData->addPoints($index,"Labels");
|
|
|
|
$MyData->setSerieDescription("Labels",$xaxisname);
|
|
|
|
$MyData->setAbscissa("Labels");
|
|
|
|
$MyData->setPalette("DEFCA",array("R"=>55,"G"=>91,"B"=>127));
|
|
|
|
|
|
|
|
/* Create the pChart object */
|
|
|
|
$myPicture = new pImage(700,230,$MyData);
|
|
|
|
$myPicture->drawGradientArea(0,0,700,230,DIRECTION_VERTICAL,array("StartR"=>220,"StartG"=>220,"StartB"=>220,"EndR"=>255,"EndG"=>255,"EndB"=>255,"Alpha"=>100));
|
|
|
|
$myPicture->drawRectangle(0,0,699,229,array("R"=>200,"G"=>200,"B"=>200));
|
|
|
|
|
|
|
|
/* Write the picture title */
|
2011-04-20 17:54:31 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
|
2011-04-20 18:57:06 +02:00
|
|
|
$myPicture->drawText(60,35,$title,array("FontSize"=>$font_size,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
|
2011-03-30 14:34:25 +02:00
|
|
|
|
|
|
|
/* Do some cosmetic and draw the chart */
|
|
|
|
$myPicture->setGraphArea(60,40,670,190);
|
|
|
|
$myPicture->drawFilledRectangle(60,40,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
|
|
|
|
$myPicture->drawScale(array("GridR"=>180,"GridG"=>180,"GridB"=>180, "Mode" => SCALE_MODE_START0));
|
|
|
|
$myPicture->setShadow(TRUE,array("X"=>2,"Y"=>2,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
2011-04-20 18:57:06 +02:00
|
|
|
$myPicture->setFontProperties(array("FontName"=>$font,"FontSize"=>$font_size));
|
2011-03-30 14:34:25 +02:00
|
|
|
$settings = array("Gradient"=>TRUE,"GradientMode"=>GRADIENT_EFFECT_CAN,"DisplayValues"=>$show_values,"DisplayZeroValues"=>FALSE,"DisplayR"=>100,"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>FALSE);
|
|
|
|
$myPicture->drawSplineChart($settings);
|
|
|
|
$myPicture->setShadow(FALSE);
|
|
|
|
|
|
|
|
if($show_legend) {
|
|
|
|
/* Write the chart legend */
|
|
|
|
$myPicture->drawLegend(643,210,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Render the picture */
|
|
|
|
$myPicture->stroke();
|
|
|
|
}
|
2011-05-25 11:57:05 +02:00
|
|
|
?>
|