mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 09:15:15 +02:00
Now the boolean charts is showed as digital signal charts (added in the pchart engine)
(cherry picked from commit ef8509692201ce2218afe386ff5645afb2f33242) Conflicts: pandora_console/include/graphs/fgraph.php
This commit is contained in:
parent
fdf65ad5da
commit
3cdf73e1ca
@ -266,11 +266,22 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
|
||||
$graph['font_size'] = $font_size;
|
||||
$graph['backgroundColor'] = $backgroundColor;
|
||||
$graph['unit'] = $unit;
|
||||
$graph['series_type'] = $series_type;
|
||||
|
||||
$id_graph = serialize_in_temp($graph, null, $ttl);
|
||||
|
||||
// Warning: This string is used in the function "api_get_module_graph" from 'functions_api.php' with the regec patern "/<img src='(.+)'>/"
|
||||
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;
|
||||
$force_steps = true;
|
||||
$legend_position = null;
|
||||
$series_type = null;
|
||||
|
||||
|
||||
$graph_type = get_parameter('graph_type', '');
|
||||
|
||||
@ -131,6 +133,12 @@ if (isset($graph['force_steps'])) {
|
||||
$force_steps = $graph['force_steps'];
|
||||
}
|
||||
|
||||
if (isset($graph['series_type'])) {
|
||||
$series_type = $graph['series_type'];
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
$colors = array();
|
||||
$colors['pep1'] = array('border' => '#000000', 'color' => '#000000', 'alpha' => 50);
|
||||
@ -304,7 +312,8 @@ switch($graph_type) {
|
||||
case 'line':
|
||||
pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
|
||||
$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;
|
||||
case 'threshold':
|
||||
pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
|
||||
@ -622,7 +631,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
|
||||
function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
|
||||
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size,
|
||||
$backgroundColor = 'white', $unit = '') {
|
||||
$backgroundColor = 'white', $unit = '', $series_type = array()) {
|
||||
|
||||
/* CAT:Vertical Charts */
|
||||
if (!is_array($legend) || empty($legend)) {
|
||||
@ -653,15 +662,26 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
foreach ($data as $i => $values) {
|
||||
if (isset($legend)) {
|
||||
$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 {
|
||||
$point_id = $i;
|
||||
}
|
||||
|
||||
$MyData->addPoints($values, $point_id);
|
||||
|
||||
|
||||
if (!empty($rgb_color)) {
|
||||
$MyData->setPalette($point_id,
|
||||
array("R" => $rgb_color[$i]['color']["R"],
|
||||
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"],
|
||||
@ -713,7 +733,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
|
||||
}
|
||||
/* 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 */
|
||||
$myPicture->Antialias = $antialiasing;
|
||||
@ -722,19 +743,22 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
//$myPicture->drawRectangle(0,0,$width,$height,array("R"=>0,"G"=>0,"B"=>0));
|
||||
|
||||
/* Set the default font */
|
||||
$myPicture->setFontProperties(array("FontName"=>$font, "FontSize"=>$font_size));
|
||||
$myPicture->setFontProperties(
|
||||
array("FontName" =>$font, "FontSize" => $font_size));
|
||||
|
||||
if (isset($legend)) {
|
||||
/* Set horizontal legend if is posible */
|
||||
$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)) {
|
||||
$legend_mode = LEGEND_VERTICAL;
|
||||
$size = $myPicture->getLegendSize(array("Style"=>LEGEND_NOBORDER,"Mode"=>$legend_mode));
|
||||
}
|
||||
|
||||
/* 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
|
||||
@ -748,8 +772,10 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
$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);
|
||||
$myPicture->drawFromPNG(
|
||||
($width - $water_mark_width),
|
||||
($height - $water_mark_height) - $margin_bottom,
|
||||
$water_mark);
|
||||
}
|
||||
|
||||
// Get the max number of scale
|
||||
@ -803,11 +829,15 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
/* Define the chart area */
|
||||
//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 {
|
||||
/* 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*/
|
||||
@ -825,7 +855,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
}
|
||||
|
||||
/* Draw the scale */
|
||||
$scaleSettings = array("GridR"=>200,
|
||||
$scaleSettings = array(
|
||||
"GridR" => 200,
|
||||
"GridG" => 200,
|
||||
"GridB" => 200,
|
||||
"DrawSubTicks" => TRUE,
|
||||
@ -860,16 +891,22 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
}
|
||||
|
||||
/* Draw the chart */
|
||||
$settings = array("ForceTransparency"=> $ForceTransparency, //
|
||||
$settings = array(
|
||||
"ForceTransparency" => $ForceTransparency,
|
||||
"Gradient" => TRUE,
|
||||
"GradientMode" => GRADIENT_EFFECT_CAN,
|
||||
"DisplayValues" => $show_values,
|
||||
"DisplayZeroValues" => FALSE,
|
||||
"DisplayR" => 100,
|
||||
"DisplayZeros" => FALSE,
|
||||
"DisplayG"=>100,"DisplayB"=>100,"DisplayShadow"=>TRUE,"Surrounding"=>5,"AroundZero"=>TRUE);
|
||||
"DisplayG" => 100,
|
||||
"DisplayB" => 100,
|
||||
"DisplayShadow" => TRUE,
|
||||
"Surrounding" => 5,
|
||||
"AroundZero" => TRUE);
|
||||
|
||||
|
||||
if (empty($series_type)) {
|
||||
switch($graph_type) {
|
||||
case "stacked_area":
|
||||
case "area":
|
||||
@ -879,6 +916,41 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
|
||||
$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 */
|
||||
$myPicture->stroke();
|
||||
|
Loading…
x
Reference in New Issue
Block a user