502
if($this->req->srv["reader"] == "VGReader"){
504
$useYAxixMinMax = false;
505
$maskManager = new MaskManagerClass($this->settings);
506
$maskArray = $maskManager->getMaskStructureAsArray($this->req->props['db_name'], "0");
507
$axisManager = new AxisManagerClass($this->settings);
508
$axisArray = $axisManager->getAxisOfUser("0");
509
//print_r($maskArray);
510
$itemIdsAxisIdsArray = array();
511
$numberOfItemsPerAxis = array();
512
foreach($maskArray["postfixes"] as $postfix){
513
$itemsIds = $postfix["itemIds"];
514
for($i=0; $i<sizeof($postfix["itemIds"]); $i++){
515
$itemIdsAxisIdsArray[$postfix["itemIds"][$i]] = $postfix["axisIds"][$i];
516
$itemIdToAxisArray[$postfix["itemIds"][$i]] = $axisArray[$postfix["axisIds"][$i]];
517
if(isset($axisArray[$postfix["axisIds"][$i]]["RangeBegin"]) || isset($axisArray[$postfix["axisIds"][$i]]["RangeEnd"])){
518
$useYAxixMinMax = true;
520
if(isset($numberOfItemsPerAxis[$postfix["itemIds"][$i]])){
521
$numberOfItemsPerAxis[$postfix["axisIds"][$i]] = 1;
523
$numberOfItemsPerAxis[$postfix["axisIds"][$i]]++;
526
$axisIdsUniq = array_unique($postfix["axisIds"]);
527
$axisIdsUniq = array_values($axisIdsUniq);
529
//print_r($maskArray);
530
//print_r($axisArray);
531
//print_r($itemIdToAxisArray);
532
//print_r($itemsIds);
533
//print_r($axisIdsUniq);
535
foreach($points as $t => $v) {
484
foreach($points as $t => $v) {
486
538
if ($this->show_gaps) {
487
539
$gapinfo = $points->missing_data();
488
540
if ($gapinfo) array_push($mvalue, 1);
489
541
else array_push($mvalue, 0);
495
545
/* if ($time_on_addon) {
496
546
if ($this->show_gaps) {
971
1028
$no_data = true;
972
for ($i = 0; $i < $size; $i++) {
974
$f = fopen("/tmp/xxx.7", "a+");
975
fwrite($f, print_r($iv, true) . "\n");
976
fwrite($f, $i . " of " . $size . "\n");
977
fwrite($f, date("r", ceil($iv->window_start)) . " - " . date("r", floor($iv->window_start + $iv->window_size)) . "\n");
978
fwrite($f, print_r($time, true));
979
fwrite($f, print_r($values[$i], true));
982
if (sizeof($time) > 0) {
985
foreach ($values[$i] as $val) {
992
if ($empty_data) continue;
995
$plot = new LinePlot($values[$i], $time);
996
if (sizeof($GRAPH_COLORS)) {
997
$color = $GRAPH_COLORS[$i%sizeof($GRAPH_COLORS)];
998
$plot->SetColor($color);
999
if ($GRAPH_LINE_WEIGHT) {
1000
$plot->SetWeight($GRAPH_LINE_WEIGHT);
1006
$plot->mark->SetType($mtype);
1007
if ($GRAPH_ACCURACY_MARKS_SIZE) $plot->mark->SetSize($GRAPH_ACCURACY_MARKS_SIZE);
1008
$plot->mark->SetFillColor(($color&&($size>1))?$color:$marks);
1011
$this->graph->Add($plot);
1031
$plot = new LinePlot(array($values[0][0]), array($time[0]));
1032
$this->graph->Add($plot);
1033
$this->graph->yaxis->Hide();
1034
if($this->req->srv["reader"] == "VGReader"){
1036
$maskManager = new MaskManagerClass($this->settings);
1037
$maskArray = $maskManager->getMaskStructureAsArray($this->req->props['db_name'], "0");
1038
$axisManager = new AxisManagerClass($this->settings);
1039
$axisArray = $axisManager->getAxisOfUser("0");
1040
//print_r($maskArray);
1041
$itemIdsAxisIdsArray = array();
1042
$numberOfItemsPerAxis = array();
1043
foreach($maskArray["postfixes"] as $postfix){
1044
$itemsIds = $postfix["itemIds"];
1045
for($i=0; $i<sizeof($postfix["itemIds"]); $i++){
1046
$itemIdsAxisIdsArray[$postfix["itemIds"][$i]] = $postfix["axisIds"][$i];
1047
if(isset($numberOfItemsPerAxis[$postfix["itemIds"][$i]])){
1048
$numberOfItemsPerAxis[$postfix["axisIds"][$i]] = 1;
1050
$numberOfItemsPerAxis[$postfix["axisIds"][$i]]++;
1053
$axisIdsUniq = array_unique($postfix["axisIds"]);
1054
$axisIdsUniq = array_values($axisIdsUniq);
1056
//print_r($itemsIds);
1057
//print_r($itemIdsAxisIdsArray);
1058
//print_r($numberOfItemsPerAxis);
1059
$counterNumberOfItemsPerAxis = $numberOfItemsPerAxis;
1060
// Inicialization of the axis
1061
$myType = array("lin", "log");
1062
for($i=0; $i<sizeof($axisIdsUniq); $i++){
1063
$this->graph->SetYScale($i,'lin', $axisArray[$i]["RangeBegin"]*1.1, $axisArray[$i]["RangeEnd"]*1.1);
1065
//print_r($axisIdsUniq);
1067
for ($i = 0; $i < $size; $i++){
1068
if (sizeof($time) > 0) {
1070
foreach ($values[$i] as $val) {
1071
if ($val !== NULL) {
1072
$empty_data = false;
1079
$idOfAxisOnPlot = array_search($itemIdsAxisIdsArray[$itemsIds[$i]], $axisIdsUniq);
1080
$plot = new LinePlot($values[$i], $time);
1081
if (sizeof($GRAPH_COLORS)){
1082
$baseColor = $GRAPH_COLORS[$idOfAxisOnPlot];
1083
$color = $baseColor;
1084
$plot->SetColor($color);
1085
if ($GRAPH_LINE_WEIGHT){
1086
$plot->SetWeight($GRAPH_LINE_WEIGHT);
1090
$plot->mark->SetType($mtype);
1091
if ($GRAPH_ACCURACY_MARKS_SIZE) $plot->mark->SetSize($GRAPH_ACCURACY_MARKS_SIZE);
1092
$plot->mark->SetFillColor(($color&&($size>1))?$color:$marks);
1094
//echo "ID:".$idOfAxisOnPlot."\n";
1095
$this->graph->AddY($idOfAxisOnPlot, $plot);
1096
$this->graph->ynaxis[$idOfAxisOnPlot]->SetColor($baseColor);
1097
$this->graph->ynaxis[$idOfAxisOnPlot]->title->Set($axisArray[$idOfAxisOnPlot]["Name"]." ".$axisArray[$idOfAxisOnPlot]["RangeBegin"]."-".$axisArray[$idOfAxisOnPlot]["RangeEnd"]);
1098
$this->graph->ynaxis[$idOfAxisOnPlot]->title->SetColor($baseColor);
1103
//$this->graph->SetYDeltaDist(50);
1104
//$this->graph->SetMargin($GRAPH_MARGINS['left'], $GRAPH_MARGINS['right'] + sizeof($axisIdsUniq)*20,$GRAPH_MARGINS['top'],$GRAPH_MARGINS['bottom']);
1105
$this->graph->SetMargin($GRAPH_MARGINS['left'], 50*sizeof($axisIdsUniq),$GRAPH_MARGINS['top'],$GRAPH_MARGINS['bottom']);
1106
$GRAPH_MARGINS['right'] = 50*sizeof($axisIdsUniq);
1109
// NOT VGREADER CASE
1110
for ($i = 0; $i < $size; $i++) {
1111
if (sizeof($time) > 0) {
1114
foreach ($values[$i] as $val) {
1115
if ($val !== NULL) {
1116
$empty_data = false;
1120
if ($empty_data) continue;
1121
$plot = new LinePlot($values[$i], $time);
1122
if (sizeof($GRAPH_COLORS)) {
1123
$color = $GRAPH_COLORS[$i%sizeof($GRAPH_COLORS)];
1124
$plot->SetColor($color);
1125
if ($GRAPH_LINE_WEIGHT) {
1126
$plot->SetWeight($GRAPH_LINE_WEIGHT);
1130
$plot->mark->SetType($mtype);
1131
if ($GRAPH_ACCURACY_MARKS_SIZE) $plot->mark->SetSize($GRAPH_ACCURACY_MARKS_SIZE);
1132
$plot->mark->SetFillColor(($color&&($size>1))?$color:$marks);
1134
$this->graph->SetYScale($i,'lin');
1135
$this->graph->AddY($i, $plot);
1136
$this->graph->ynaxis[$i]->title->Set("N".$i);
1016
1141
if ($no_data) {
1017
1142
$range = date("c", ceil($iv->window_start)) . " and " . date("c", floor($iv->window_start + $iv->window_size));
1018
1143
throw new ADEIException(translate("No data between: %s", $range), ADEIException::NO_DATA);
1076
1200
$this->graph_interval = $iv;
1077
1201
$this->precision = $precision;
1079
// print_r($mvalue);
1080
// echo $realmin . "\n";
1084
/* $graph->img->SetMargin(40,110,20,40);
1085
//$graph ->xaxis->scale-> SetDateFormat( 'Y-m-d');
1086
$graph->xaxis->SetFont(FF_ARIAL,FS_NORMAL,6);
1087
$graph->xaxis->SetLabelAngle(45);
1088
$graph->SetShadow();
1090
$graph->ygrid->Show(true,true);
1091
$Size = sizeof($Data->TimeSeries);
1092
for($i=3; $i<6;$i++){
1093
$lineplot[$i]=new LinePlot($Data->TimeSeries[$i]["Value"], $Data->TimeSeries[$i]["Time"]);
1094
$lineplot[$i]->SetColor($Data->TimeSeries[$i]["Color"]);
1095
$lineplot[$i]->SetLegend($Data->TimeSeries[$i]["Name"]);
1096
$graph->Add($lineplot[$i]);
1098
$graph->Stroke($TempDir."Lin-".$FileName.".png");
1104
// $graph = new Graph($this->width, $this->heigh /*, "auto"*/);
1105
// $graph->SetScale('intlin'/* ymin, ymax, xmin, xmax */);
1108
// $lineplot = new LinePlot($dataarray);
1196
1289
"margins" => array($GRAPH_MARGINS['left'],$GRAPH_MARGINS['top'],$GRAPH_MARGINS['right'],$GRAPH_MARGINS['bottom'])
1292
function getGradient($beginColor, $endColor, $numberOfSteps, $stepId){
1293
$beginColor = array(
1294
hexdec(substr($beginColor, 1, 2)),
1295
hexdec(substr($beginColor, 3, 2)),
1296
hexdec(substr($beginColor, 5, 2))
1299
hexdec(substr($endColor, 1, 2)),
1300
hexdec(substr($endColor, 3, 2)),
1301
hexdec(substr($endColor, 5, 2))
1303
for($i=0; $i<3; $i++){
1304
$step[$i] = ($endColor[$i] - $beginColor[$i])/$numberOfSteps;
1307
for($j=0; $j<3; $j++){
1308
$decColor = $beginColor[$j] + $stepId*$step[$j];
1309
$decColor < 15?$element = "0".dechex($decColor): $element = dechex($decColor);
1200
1314
static function Display($file = false) {
1201
1315
global $TMP_PATH;