Now the boolean charts is showed as digital signal charts (added in the pchart engine)
This commit is contained in:
parent
0d2f905e8a
commit
ef85096922
|
@ -268,11 +268,18 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
|
||||||
$graph['font_size'] = $font_size;
|
$graph['font_size'] = $font_size;
|
||||||
$graph['backgroundColor'] = $backgroundColor;
|
$graph['backgroundColor'] = $backgroundColor;
|
||||||
$graph['unit'] = $unit;
|
$graph['unit'] = $unit;
|
||||||
|
$graph['series_type'] = $series_type;
|
||||||
|
|
||||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||||
|
|
||||||
|
|
||||||
return "<img src='" . ui_get_full_url (false, false, false, false) . "include/graphs/functions_pchart.php?static_graph=1&graph_type=area&ttl=".$ttl."&id_graph=" . $id_graph . "'>";
|
return "<img src='" .
|
||||||
|
ui_get_full_url (false, false, false, false) .
|
||||||
|
"include/graphs/functions_pchart.php?" .
|
||||||
|
"static_graph=1&" .
|
||||||
|
"graph_type=area&" .
|
||||||
|
"ttl=" . $ttl . "&" .
|
||||||
|
"id_graph=" . $id_graph . "'>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ $colors = null;
|
||||||
$font_size = 8;
|
$font_size = 8;
|
||||||
$force_steps = true;
|
$force_steps = true;
|
||||||
$legend_position = null;
|
$legend_position = null;
|
||||||
|
$series_type = null;
|
||||||
|
|
||||||
|
|
||||||
$graph_type = get_parameter('graph_type', '');
|
$graph_type = get_parameter('graph_type', '');
|
||||||
|
|
||||||
|
@ -131,6 +133,12 @@ if (isset($graph['force_steps'])) {
|
||||||
$force_steps = $graph['force_steps'];
|
$force_steps = $graph['force_steps'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($graph['series_type'])) {
|
||||||
|
$series_type = $graph['series_type'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$colors = array();
|
$colors = array();
|
||||||
$colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 50);
|
$colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 50);
|
||||||
|
@ -156,7 +164,7 @@ if ($force_steps) {
|
||||||
|
|
||||||
$c = 1;
|
$c = 1;
|
||||||
|
|
||||||
switch($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'hbar':
|
case 'hbar':
|
||||||
case 'vbar':
|
case 'vbar':
|
||||||
foreach ($data as $i => $values) {
|
foreach ($data as $i => $values) {
|
||||||
|
@ -285,7 +293,7 @@ foreach ($colors as $i => $color) {
|
||||||
|
|
||||||
ob_get_clean(); //HACK TO EAT ANYTHING THAT CORRUPS THE IMAGE FILE
|
ob_get_clean(); //HACK TO EAT ANYTHING THAT CORRUPS THE IMAGE FILE
|
||||||
|
|
||||||
switch($graph_type) {
|
switch ($graph_type) {
|
||||||
case 'pie3d':
|
case 'pie3d':
|
||||||
case 'pie2d':
|
case 'pie2d':
|
||||||
pch_pie_graph($graph_type, array_values($data), array_keys($data),
|
pch_pie_graph($graph_type, array_values($data), array_keys($data),
|
||||||
|
@ -310,7 +318,8 @@ switch($graph_type) {
|
||||||
case 'line':
|
case 'line':
|
||||||
pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
|
pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
|
||||||
$height, $rgb_color, $xaxisname, $yaxisname, false, $legend,
|
$height, $rgb_color, $xaxisname, $yaxisname, false, $legend,
|
||||||
$font, $antialiasing, $water_mark, $font_size, $backgroundColor, $unit);
|
$font, $antialiasing, $water_mark, $font_size,
|
||||||
|
$backgroundColor, $unit, $series_type);
|
||||||
break;
|
break;
|
||||||
case 'threshold':
|
case 'threshold':
|
||||||
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
||||||
|
@ -628,8 +637,8 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
||||||
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
|
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
|
||||||
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size,
|
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size,
|
||||||
$backgroundColor = 'white', $unit = '') {
|
$backgroundColor = 'white', $unit = '', $series_type = array()) {
|
||||||
|
|
||||||
/* CAT:Vertical Charts */
|
/* CAT:Vertical Charts */
|
||||||
if (!is_array($legend) || empty($legend)) {
|
if (!is_array($legend) || empty($legend)) {
|
||||||
unset($legend);
|
unset($legend);
|
||||||
|
@ -640,9 +649,9 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
*/
|
*/
|
||||||
if (is_array(reset($data))) {
|
if (is_array(reset($data))) {
|
||||||
$data2 = array();
|
$data2 = array();
|
||||||
foreach($data as $i =>$values) {
|
foreach ($data as $i =>$values) {
|
||||||
$c = 0;
|
$c = 0;
|
||||||
foreach($values as $i2 => $value) {
|
foreach ($values as $i2 => $value) {
|
||||||
$data2[$i2][$i] = $value;
|
$data2[$i2][$i] = $value;
|
||||||
$c++;
|
$c++;
|
||||||
}
|
}
|
||||||
|
@ -659,15 +668,26 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
foreach ($data as $i => $values) {
|
foreach ($data as $i => $values) {
|
||||||
if (isset($legend)) {
|
if (isset($legend)) {
|
||||||
$point_id = $legend[$i];
|
$point_id = $legend[$i];
|
||||||
|
|
||||||
|
// Translate the id of serie to legend of id
|
||||||
|
if (!empty($series_type)) {
|
||||||
|
if (!isset($series_type[$point_id])) {
|
||||||
|
$series_type[$point_id] = $series_type[$i];
|
||||||
|
unset($series_type[$i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$point_id = $i;
|
$point_id = $i;
|
||||||
}
|
}
|
||||||
|
|
||||||
$MyData->addPoints($values,$point_id);
|
$MyData->addPoints($values, $point_id);
|
||||||
|
|
||||||
|
|
||||||
if (!empty($rgb_color)) {
|
if (!empty($rgb_color)) {
|
||||||
$MyData->setPalette($point_id,
|
$MyData->setPalette($point_id,
|
||||||
array("R" => $rgb_color[$i]['color']["R"],
|
array(
|
||||||
|
"R" => $rgb_color[$i]['color']["R"],
|
||||||
"G" => $rgb_color[$i]['color']["G"],
|
"G" => $rgb_color[$i]['color']["G"],
|
||||||
"B" => $rgb_color[$i]['color']["B"],
|
"B" => $rgb_color[$i]['color']["B"],
|
||||||
"BorderR" => $rgb_color[$i]['border']["R"],
|
"BorderR" => $rgb_color[$i]['border']["R"],
|
||||||
|
@ -702,7 +722,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
$MyData->setAbscissa("Xaxis");
|
$MyData->setAbscissa("Xaxis");
|
||||||
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC);
|
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC);
|
||||||
|
|
||||||
switch($backgroundColor) {
|
switch ($backgroundColor) {
|
||||||
case 'white':
|
case 'white':
|
||||||
$transparent = false;
|
$transparent = false;
|
||||||
$fontColor = array('R' => 0, 'G' => 0, 'B' => 0);
|
$fontColor = array('R' => 0, 'G' => 0, 'B' => 0);
|
||||||
|
@ -718,7 +738,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Create the pChart object */
|
/* Create the pChart object */
|
||||||
$myPicture = new pImage($width,$height,$MyData,$transparent,$backgroundColor,$fontColor);
|
$myPicture = new pImage($width, $height, $MyData, $transparent,
|
||||||
|
$backgroundColor, $fontColor);
|
||||||
|
|
||||||
/* Turn of Antialiasing */
|
/* Turn of Antialiasing */
|
||||||
$myPicture->Antialias = $antialiasing;
|
$myPicture->Antialias = $antialiasing;
|
||||||
|
@ -727,19 +748,22 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
||||||
|
|
||||||
/* Set the default font */
|
/* Set the default font */
|
||||||
$myPicture->setFontProperties(array("FontName"=>$font, "FontSize"=>$font_size));
|
$myPicture->setFontProperties(
|
||||||
|
array("FontName" =>$font, "FontSize" => $font_size));
|
||||||
|
|
||||||
if (isset($legend)) {
|
if (isset($legend)) {
|
||||||
/* Set horizontal legend if is posible */
|
/* Set horizontal legend if is posible */
|
||||||
$legend_mode = LEGEND_HORIZONTAL;
|
$legend_mode = LEGEND_HORIZONTAL;
|
||||||
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
$size = $myPicture->getLegendSize(
|
||||||
|
array("Style" => LEGEND_NOBORDER,"Mode" => $legend_mode));
|
||||||
if ($size['Width'] > ($width - 5)) {
|
if ($size['Width'] > ($width - 5)) {
|
||||||
$legend_mode = LEGEND_VERTICAL;
|
$legend_mode = LEGEND_VERTICAL;
|
||||||
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the chart legend */
|
/* Write the chart legend */
|
||||||
$myPicture->drawLegend($width-$size['Width'], 8,array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
$myPicture->drawLegend($width - $size['Width'], 8,
|
||||||
|
array("Style" => LEGEND_NOBORDER, "Mode" => $legend_mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate the bottom margin from the size of string in each index
|
//Calculate the bottom margin from the size of string in each index
|
||||||
|
@ -753,8 +777,10 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
$water_mark_height = $size_water_mark[1];
|
$water_mark_height = $size_water_mark[1];
|
||||||
$water_mark_width = $size_water_mark[0];
|
$water_mark_width = $size_water_mark[0];
|
||||||
|
|
||||||
$myPicture->drawFromPNG(($width - $water_mark_width),
|
$myPicture->drawFromPNG(
|
||||||
($height - $water_mark_height) - $margin_bottom, $water_mark);
|
($width - $water_mark_width),
|
||||||
|
($height - $water_mark_height) - $margin_bottom,
|
||||||
|
$water_mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the max number of scale
|
// Get the max number of scale
|
||||||
|
@ -808,11 +834,15 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
/* Define the chart area */
|
/* Define the chart area */
|
||||||
//if ($yaxisname != ''){
|
//if ($yaxisname != ''){
|
||||||
//}
|
//}
|
||||||
$myPicture->setGraphArea($chart_size,$size['Height'],$width - $water_mark_width,$height - $margin_bottom);
|
$myPicture->setGraphArea($chart_size, $size['Height'],
|
||||||
|
($width - $water_mark_width),
|
||||||
|
($height - $margin_bottom));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Define the chart area */
|
/* Define the chart area */
|
||||||
$myPicture->setGraphArea($chart_size, 5,$width - $water_mark_width,$height - $margin_bottom);
|
$myPicture->setGraphArea($chart_size, 5,
|
||||||
|
($width - $water_mark_width),
|
||||||
|
($height - $margin_bottom));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*Get minimun value to draw axis properly*/
|
/*Get minimun value to draw axis properly*/
|
||||||
|
@ -830,11 +860,12 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the scale */
|
/* Draw the scale */
|
||||||
$scaleSettings = array("GridR"=>200,
|
$scaleSettings = array(
|
||||||
"GridG"=>200,
|
"GridR" => 200,
|
||||||
"GridB"=>200,
|
"GridG" => 200,
|
||||||
"DrawSubTicks"=>TRUE,
|
"GridB" => 200,
|
||||||
"CycleBackground"=>TRUE,
|
"DrawSubTicks" => TRUE,
|
||||||
|
"CycleBackground" => TRUE,
|
||||||
"Mode" => $mode,
|
"Mode" => $mode,
|
||||||
"ManualScale" => $ManualScale,
|
"ManualScale" => $ManualScale,
|
||||||
"LabelRotation" => 40,
|
"LabelRotation" => 40,
|
||||||
|
@ -865,25 +896,66 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the chart */
|
/* Draw the chart */
|
||||||
$settings = array("ForceTransparency"=> $ForceTransparency, //
|
$settings = array(
|
||||||
"Gradient"=>TRUE,
|
"ForceTransparency" => $ForceTransparency,
|
||||||
"GradientMode"=>GRADIENT_EFFECT_CAN,
|
"Gradient" => TRUE,
|
||||||
"DisplayValues"=>$show_values,
|
"GradientMode" => GRADIENT_EFFECT_CAN,
|
||||||
"DisplayZeroValues"=>FALSE,
|
"DisplayValues" => $show_values,
|
||||||
"DisplayR"=>100,
|
"DisplayZeroValues" => FALSE,
|
||||||
"DisplayZeros"=> FALSE,
|
"DisplayR" => 100,
|
||||||
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>TRUE);
|
"DisplayZeros" => FALSE,
|
||||||
|
"DisplayG" => 100,
|
||||||
|
"DisplayB" => 100,
|
||||||
|
"DisplayShadow" => TRUE,
|
||||||
|
"Surrounding" => 5,
|
||||||
|
"AroundZero" => TRUE);
|
||||||
|
|
||||||
|
|
||||||
switch($graph_type) {
|
if (empty($series_type)) {
|
||||||
case "stacked_area":
|
switch($graph_type) {
|
||||||
case "area":
|
case "stacked_area":
|
||||||
$myPicture->drawAreaChart($settings);
|
case "area":
|
||||||
break;
|
$myPicture->drawAreaChart($settings);
|
||||||
case "line":
|
break;
|
||||||
$myPicture->drawLineChart($settings);
|
case "line":
|
||||||
break;
|
$myPicture->drawLineChart($settings);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// Hiden all series for to show each serie as type
|
||||||
|
foreach ($series_type as $id => $type) {
|
||||||
|
$MyData->setSerieDrawable($id, false);
|
||||||
|
}
|
||||||
|
foreach ($series_type as $id => $type) {
|
||||||
|
$MyData->setSerieDrawable($id, true); //Enable the serie to paint
|
||||||
|
switch ($type) {
|
||||||
|
default:
|
||||||
|
case 'area':
|
||||||
|
$myPicture->drawAreaChart($settings);
|
||||||
|
break;
|
||||||
|
//~ case "points":
|
||||||
|
//~ $myPicture->drawPlotChart($settings);
|
||||||
|
//~ break;
|
||||||
|
case "line":
|
||||||
|
$myPicture->drawLineChart($settings);
|
||||||
|
break;
|
||||||
|
case 'boolean':
|
||||||
|
switch($graph_type) {
|
||||||
|
case "stacked_area":
|
||||||
|
case "area":
|
||||||
|
$myPicture->drawFilledStepChart($settings);
|
||||||
|
break;
|
||||||
|
case "line":
|
||||||
|
$myPicture->drawStepChart($settings);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$MyData->setSerieDrawable($id, false); //Disable the serie to paint the rest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Render the picture */
|
/* Render the picture */
|
||||||
$myPicture->stroke();
|
$myPicture->stroke();
|
||||||
|
|
Loading…
Reference in New Issue