2011-04-08 Sergio Martin <sergio.martin@artica.es>
* include/graphs/functions_pchart.php include/graphs/functions_fsgraph.php include/graphs/functions_utils.php: Improved the entry point of the graphics abstraction and merged bar and pie configurations from integria git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4179 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
985b94ca1e
commit
52e5cdcf61
|
@ -1,3 +1,11 @@
|
|||
2011-04-08 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/graphs/functions_pchart.php
|
||||
include/graphs/functions_fsgraph.php
|
||||
include/graphs/functions_utils.php: Improved the entry point
|
||||
of the graphics abstraction and merged bar and pie configurations
|
||||
from integria
|
||||
|
||||
2011-04-07 Miguel de Dios <miguel.dedios@artica.es>
|
||||
|
||||
* include/functions_graph.php: added call to paint the other graphs.
|
||||
|
|
|
@ -33,7 +33,6 @@ function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_i
|
|||
|
||||
$chart = new FusionCharts($graph_type, $width, $height);
|
||||
|
||||
|
||||
$pixels_between_xdata = 25;
|
||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||
$ndata = count($chart_data);
|
||||
|
@ -341,8 +340,7 @@ function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_inde
|
|||
$graph_type = "MSArea2D"; //MSLine is possible also
|
||||
|
||||
$chart = new FusionCharts($graph_type, $width, $height);
|
||||
|
||||
|
||||
|
||||
$pixels_between_xdata = 25;
|
||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||
$ndata = count($chart_data);
|
||||
|
@ -591,30 +589,72 @@ function fs_2d_column_chart ($data, $width, $height) {
|
|||
// Generate the XML
|
||||
$chart = new FusionCharts('Column2D', $width, $height);
|
||||
|
||||
$pixels_between_xdata = 25;
|
||||
$max_xdata_display = round($width / $pixels_between_xdata);
|
||||
$ndata = count($chart_data);
|
||||
if($max_xdata_display > $ndata) {
|
||||
$xdata_display = $ndata;
|
||||
}
|
||||
else {
|
||||
$xdata_display = $max_xdata_display;
|
||||
}
|
||||
|
||||
$step = round($ndata/$xdata_display);
|
||||
|
||||
|
||||
if(is_array(reset($data))) {
|
||||
$data2 = array();
|
||||
$count = 0;
|
||||
foreach($data as $i =>$values) {
|
||||
$count++;
|
||||
$show_name = '0';
|
||||
if (($count % $step) == 0) {
|
||||
$show_name = '1';
|
||||
}
|
||||
debugPrint($i, '/tmp/logo');
|
||||
|
||||
$chart->addCategory($i."2", //'');
|
||||
'hoverText=' . $i .
|
||||
';showName=' . $show_name);
|
||||
|
||||
$c = 0;
|
||||
foreach($values as $i2 => $value) {
|
||||
$data2[$i2][$i] = $value;
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
$data = $data2;
|
||||
}
|
||||
else {
|
||||
$data = array($data);
|
||||
}
|
||||
|
||||
$empty = 0;
|
||||
$num_vlines = 0;
|
||||
$count = 0;
|
||||
$step = 3;
|
||||
|
||||
foreach ($data as $name => $value) {
|
||||
if ($count++ % $step == 0) {
|
||||
$show_name = '1';
|
||||
$num_vlines++;
|
||||
} else {
|
||||
$show_name = '0';
|
||||
foreach ($data as $legend_value => $values) {
|
||||
|
||||
foreach($values as $name => $value) {
|
||||
if ($count++ % $step == 0) {
|
||||
$show_name = '1';
|
||||
$num_vlines++;
|
||||
} else {
|
||||
$show_name = '0';
|
||||
}
|
||||
if ($value > 0) {
|
||||
$empty = 0;
|
||||
}
|
||||
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
|
||||
}
|
||||
if ($value > 0) {
|
||||
$empty = 0;
|
||||
}
|
||||
$chart->addChartData($value, 'name=' . clean_flash_string($name) . ';showName=' . $show_name . ';color=95BB04');
|
||||
}
|
||||
|
||||
$chart->setChartParams('decimalPrecision=0;showAlternateVGridColor=1; numVDivLines='.$num_vlines.';showNames=1;rotateNames=1;showValues=0;showPercentageValues=0;showLimits=0;baseFontSize=9;'
|
||||
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
|
||||
|
||||
// Return the code
|
||||
return get_chart_code2 ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Column2D.swf');
|
||||
return get_chart_code ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Column2D.swf');
|
||||
}
|
||||
|
||||
// Returns a 3D column chart
|
||||
|
@ -649,7 +689,7 @@ function fs_3d_column_chart ($data, $width, $height) {
|
|||
. ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
|
||||
|
||||
// Return the code
|
||||
return get_chart_code2 ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Column3D.swf');
|
||||
return get_chart_code2 ($chart, $width, $height, 'include/graphs/FusionCharts/FCF_Column2D.swf');
|
||||
}
|
||||
|
||||
// Prints a Gantt chart
|
||||
|
|
|
@ -25,107 +25,173 @@ include_once("pChart/pPie.class.php");
|
|||
include_once("pChart/pScatter.class.php");
|
||||
include_once("pChart/pRadar.class.php");
|
||||
|
||||
// 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";
|
||||
|
||||
$graph_type = get_parameter('graph_type', '');
|
||||
$width = get_parameter('width', 700);
|
||||
$height = get_parameter('height', 300);
|
||||
$xaxisname = get_parameter('xaxisname', '');
|
||||
$yaxisname = get_parameter('yaxisname', '');
|
||||
$title = get_parameter('title', '');
|
||||
$data = json_decode(safe_output(get_parameter('data')), true);
|
||||
$legend = json_decode(safe_output(get_parameter('legend')), true);
|
||||
|
||||
$id_graph = get_parameter('id_graph', false);
|
||||
|
||||
if ($id_graph) {
|
||||
$graph = unserialize_in_temp($id_graph, false);
|
||||
if (!$id_graph) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$graph = unserialize_in_temp($id_graph, false);
|
||||
|
||||
if (!isset($graph)) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = $graph['data'];
|
||||
$width = $graph['width'];
|
||||
$height = $graph['height'];
|
||||
$colors = $graph['color'];
|
||||
$legend = $graph['legend'];
|
||||
if(isset($graph['xaxisname'])) {
|
||||
$xaxisname = $graph['xaxisname'];
|
||||
}
|
||||
if(isset($graph['yaxisname'])) {
|
||||
$yaxisname = $graph['yaxisname'];
|
||||
}
|
||||
|
||||
if (isset($graph)) {
|
||||
$data = $graph['data'];
|
||||
$width = $graph['width'];
|
||||
$height = $graph['height'];
|
||||
$colors = $graph['color'];
|
||||
$legend = $graph['legend'];
|
||||
|
||||
//debugPrint($graph, true);
|
||||
/*
|
||||
$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);
|
||||
$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);
|
||||
*/
|
||||
$rgb_color = array();
|
||||
|
||||
if (!isset($colors))
|
||||
$colors = array();
|
||||
|
||||
foreach($colors as $i => $color) {
|
||||
$rgb['border'] = html2rgb($color['border']);
|
||||
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
||||
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
||||
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
||||
|
||||
$rgb['color'] = html2rgb($color['color']);
|
||||
$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'])) {
|
||||
$rgb['border'] = html2rgb($color['border']);
|
||||
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
||||
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
||||
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
||||
|
||||
$pixels_between_xdata = 40;
|
||||
$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);
|
||||
$c = 0;
|
||||
|
||||
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++;
|
||||
}
|
||||
$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) {
|
||||
$rgb_fine = html2rgb($fine_color);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($color['color'])) {
|
||||
$rgb['color'] = html2rgb($color['color']);
|
||||
$rgb_color[$i]['color']['R'] = $rgb['color'][0];
|
||||
$rgb_color[$i]['color']['G'] = $rgb['color'][1];
|
||||
$rgb_color[$i]['color']['B'] = $rgb['color'][2];
|
||||
break;
|
||||
case 'polar':
|
||||
case 'radar':
|
||||
case 'progress':
|
||||
case 'area':
|
||||
case 'spline':
|
||||
case 'threshold':
|
||||
case 'scatter':
|
||||
foreach($data as $i => $d) {
|
||||
$data_values[] = $d;
|
||||
|
||||
|
||||
if (($c % $step) == 0) {
|
||||
$data_keys[] = $i;
|
||||
}
|
||||
else {
|
||||
$data_keys[] = "";
|
||||
}
|
||||
|
||||
$c++;
|
||||
}
|
||||
|
||||
if (isset($color['color'])) {
|
||||
$rgb_color[$i]['alpha'] = $color['alpha'];
|
||||
}
|
||||
}*/
|
||||
}
|
||||
break;
|
||||
case 'pie3d':
|
||||
case 'pie2d':
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if($graph_type != 'pie3d' && $graph_type != 'pie2d') {
|
||||
|
||||
$pixels_between_xdata = 25;
|
||||
$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);
|
||||
$c = 0;
|
||||
|
||||
foreach($data as $i => $d) {
|
||||
$data_values[] = $d;
|
||||
|
||||
|
||||
if (($c % $step) == 0) {
|
||||
$data_keys[] = $i;
|
||||
}
|
||||
else {
|
||||
$data_keys[] = "";
|
||||
}
|
||||
|
||||
$c++;
|
||||
if(!is_array(reset($data_values))) {
|
||||
$data_values = array($data_values);
|
||||
if(is_array($colors) && !empty($colors)) {
|
||||
$colors = array($colors);
|
||||
}
|
||||
}
|
||||
|
||||
$rgb_color = array();
|
||||
|
||||
if (!isset($colors))
|
||||
$colors = array();
|
||||
|
||||
foreach($colors as $i => $color) {
|
||||
$rgb['border'] = html2rgb($color['border']);
|
||||
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
||||
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
||||
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
||||
|
||||
$rgb['color'] = html2rgb($color['color']);
|
||||
$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'])) {
|
||||
$rgb['border'] = html2rgb($color['border']);
|
||||
$rgb_color[$i]['border']['R'] = $rgb['border'][0];
|
||||
$rgb_color[$i]['border']['G'] = $rgb['border'][1];
|
||||
$rgb_color[$i]['border']['B'] = $rgb['border'][2];
|
||||
}
|
||||
|
||||
if (isset($color['color'])) {
|
||||
$rgb['color'] = html2rgb($color['color']);
|
||||
$rgb_color[$i]['color']['R'] = $rgb['color'][0];
|
||||
$rgb_color[$i]['color']['G'] = $rgb['color'][1];
|
||||
$rgb_color[$i]['color']['B'] = $rgb['color'][2];
|
||||
}
|
||||
|
||||
if (isset($color['color'])) {
|
||||
$rgb_color[$i]['alpha'] = $color['alpha'];
|
||||
}
|
||||
}*/
|
||||
|
||||
switch($graph_type) {
|
||||
case 'pie3d':
|
||||
case 'pie2d':
|
||||
|
@ -135,14 +201,12 @@ switch($graph_type) {
|
|||
case 'radar':
|
||||
pch_radar_graph($graph_type, $data_values, $data_keys, $width, $height);
|
||||
break;
|
||||
case 'hbar':
|
||||
pch_horizontal_graph($graph_type, $data_keys, $data_values, $width, $height, $xaxisname, $yaxisname);
|
||||
break;
|
||||
case 'progress':
|
||||
pch_progress_graph($graph_type, $data_keys, $data_values, $width, $height, $xaxisname, $yaxisname);
|
||||
break;
|
||||
case 'hbar':
|
||||
case 'vbar':
|
||||
pch_bar_graph($graph_type, $data_keys, $data_values, $width, $height, $rgb_color, $xaxisname, $yaxisname);
|
||||
pch_bar_graph($graph_type, $data_keys, $data_values, $width, $height, $rgb_color, $xaxisname, $yaxisname, false, $legend, $fine_colors);
|
||||
break;
|
||||
case 'stacked_area':
|
||||
case 'area':
|
||||
|
@ -165,7 +229,6 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $heig
|
|||
$MyData->addPoints($data_values,"ScoreA");
|
||||
$MyData->setSerieDescription("ScoreA","Application A");
|
||||
|
||||
$legend_values = array('日本語', '九州', '訓読み', '北海道');
|
||||
/* Define the absissa serie */
|
||||
$MyData->addPoints($legend_values,"Labels");
|
||||
$MyData->setAbscissa("Labels");
|
||||
|
@ -174,7 +237,7 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $heig
|
|||
$myPicture = new pImage($width,$height,$MyData,TRUE);
|
||||
|
||||
/* Set the default font properties */
|
||||
$myPicture->setFontProperties(array("FontName"=>"../fonts/code.ttf","FontSize"=>8,"R"=>80,"G"=>80,"B"=>80));
|
||||
$myPicture->setFontProperties(array("FontName"=>"../fonts/code.ttf","FontSize"=>10,"R"=>80,"G"=>80,"B"=>80));
|
||||
|
||||
/* Create the pPie object */
|
||||
$PieChart = new pPie($myPicture,$MyData);
|
||||
|
@ -182,15 +245,16 @@ function pch_pie_graph ($graph_type, $data_values, $legend_values, $width, $heig
|
|||
/* Draw an AA pie chart */
|
||||
switch($graph_type) {
|
||||
case "pie2d":
|
||||
$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));
|
||||
$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));
|
||||
break;
|
||||
case "pie3d":
|
||||
$PieChart->draw3DPie($width/4,$height/2,array("DataGapAngle"=>10,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>FALSE));
|
||||
$PieChart->draw3DPie($width/4,$height/2,array("DataGapAngle"=>10,"DataGapRadius"=>6, "Border"=>TRUE, "Radius"=>$width/4, "ValueR"=>0, "ValueG"=>0, "ValueB"=>0, "WriteValues"=>TRUE));
|
||||
break;
|
||||
}
|
||||
|
||||
/* Write down the legend next to the 2nd chart*/
|
||||
$PieChart->drawPieLegend($width/1.5,$height/4, array("R"=>255,"G"=>255,"B"=>255));
|
||||
$legend_size = $myPicture->getLegendSize(array("BoxSize"=>10));
|
||||
$PieChart->drawPieLegend($legend_size['Width'],5, array("R"=>255,"G"=>255,"B"=>255, "BoxSize"=>10));
|
||||
|
||||
/* Enable shadow computing */
|
||||
$myPicture->setShadow(TRUE,array("X"=>3,"Y"=>3,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
||||
|
@ -239,28 +303,17 @@ function pch_radar_graph ($graph_type, $data_values, $legend_values, $width, $he
|
|||
$myPicture->stroke();
|
||||
}
|
||||
|
||||
/* TOFIX */
|
||||
function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false, $show_legend = true) {
|
||||
function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false, $legend = array(), $fine_colors = array()) {
|
||||
/* CAT: Vertical Bar Chart */
|
||||
if(is_array($data[0])) {
|
||||
$data2 = array();
|
||||
foreach($data as $i =>$values) {
|
||||
$c = 0;
|
||||
foreach($values as $value) {
|
||||
$data2[$index[$c]][$i] = $value;
|
||||
$c++;
|
||||
}
|
||||
}
|
||||
$data = $data2;
|
||||
}
|
||||
else {
|
||||
$data = array($data);
|
||||
}
|
||||
if(!is_array($legend) || empty($legend)) {
|
||||
unset($legend);
|
||||
}
|
||||
|
||||
/* Create and populate the pData object */
|
||||
$MyData = new pData();
|
||||
$overridePalette = array();
|
||||
foreach($data as $i => $values) {
|
||||
$MyData->addPoints($values,"bar");
|
||||
$MyData->addPoints($values,$i);
|
||||
if($rgb_color !== false) {
|
||||
$MyData->setPalette($i,
|
||||
array("R" => $rgb_color[$i]['color']["R"],
|
||||
|
@ -269,7 +322,22 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color
|
|||
"BorderR" => $rgb_color[$i]['border']["R"],
|
||||
"BorderG" => $rgb_color[$i]['border']["G"],
|
||||
"BorderB" => $rgb_color[$i]['border']["B"],
|
||||
"Alpha" => $rgb_color[$i]['alpha']));
|
||||
"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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,35 +355,45 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $rgb_color
|
|||
/* Add a border to the picture */
|
||||
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(array("FontName"=>"../fonts/code.ttf","FontSize"=>10));
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea(30,20,$width,$height-100);
|
||||
|
||||
/* Draw the scale */
|
||||
// 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
|
||||
$scaleSettings = array("AvoidTickWhenEmpty" => FALSE, "AvoidGridWhenEmpty" => FALSE, "GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "XMargin" => 40, "LabelRotation" => 90);
|
||||
switch($graph_type) {
|
||||
case "vbar":
|
||||
$scaleSettings = array("AvoidTickWhenEmpty" => FALSE, "AvoidGridWhenEmpty" => FALSE, "GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "LabelRotation" => 60);
|
||||
$leftmargin = 40;
|
||||
break;
|
||||
case "hbar":
|
||||
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "Pos"=>SCALE_POS_TOPBOTTOM);
|
||||
$leftmargin = 100;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Define the chart area */
|
||||
$myPicture->setGraphArea($leftmargin,20,$width,$height-80);
|
||||
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
if($show_legend) {
|
||||
if(isset($legend)) {
|
||||
/* Write the chart legend */
|
||||
$myPicture->drawLegend($height/2,$width/1.8,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
|
||||
$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));
|
||||
}
|
||||
|
||||
/* Turn on shadow computing */
|
||||
$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
||||
|
||||
/* Draw the chart */
|
||||
$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);
|
||||
|
||||
switch($graph_type) {
|
||||
case "vbar":
|
||||
$myPicture->drawBarChart($settings);
|
||||
break;
|
||||
}
|
||||
$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);
|
||||
|
||||
$myPicture->drawBarChart($settings);
|
||||
|
||||
/* Render the picture */
|
||||
$myPicture->stroke();
|
||||
}
|
||||
|
@ -346,7 +424,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
|
|||
|
||||
/* Create and populate the pData object */
|
||||
$MyData = new pData();
|
||||
|
||||
|
||||
foreach($data as $i => $values) {
|
||||
if(isset($legend)) {
|
||||
$point_id = $legend[$i];
|
||||
|
@ -384,15 +462,13 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
|
|||
$MyData->setPalette($point_id, $palette_color);*/
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//$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);
|
||||
|
||||
|
@ -427,8 +503,6 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $rgb_c
|
|||
"DrawSubTicks"=>TRUE,
|
||||
"CycleBackground"=>TRUE, "Mode"=>SCALE_MODE_START0, "LabelRotation" => 60);
|
||||
$myPicture->drawScale($scaleSettings);
|
||||
|
||||
|
||||
|
||||
/* Turn on shadow computing */
|
||||
//$myPicture->setShadow(TRUE,array("X"=>0,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
|
||||
|
|
|
@ -57,4 +57,15 @@ function delete_unserialize_in_temp($serial_id = null) {
|
|||
|
||||
return unlink($file_path);
|
||||
}
|
||||
|
||||
function reverse_data($array) {
|
||||
$array2 = array();
|
||||
foreach($array as $index => $values) {
|
||||
foreach($values as $index2 => $value) {
|
||||
$array2[$index2][$index] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return $array2;
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue