/* Create the pChart object */
$myPicture = new pImage(700, 230, $MyData);
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 100, "StartG" => 100, "StartB" => 100, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 20));
$myPicture->drawGradientArea(0, 0, 60, 230, DIRECTION_HORIZONTAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100));
/* Do some cosmetics */
$myPicture->drawLine(60, 0, 60, 230, array("R" => 70, "G" => 70, "B" => 70));
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(35, 115, "Recorded cases", array("R" => 255, "G" => 255, "B" => 255, "FontSize" => 20, "Angle" => 90, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Prepare the chart area */
$myPicture->setGraphArea(100, 30, 680, 190);
$myPicture->drawFilledRectangle(100, 30, 680, 190, array("R" => 255, "G" => 255, "B" => 255, "Alpha" => 20));
$myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255, "FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6));
$myPicture->drawScale(array("AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE));
/* Write two thresholds over the chart */
$myPicture->drawThreshold(10, array("WriteCaption" => TRUE, "Caption" => "Agreed SLA", "NoMargin" => TRUE));
$myPicture->drawThreshold(15, array("WriteCaption" => TRUE, "Caption" => "Best effort", "NoMargin" => TRUE));
/* Draw one static X threshold area */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30));
$myPicture->drawXThresholdArea(3, 5, array("AreaName" => "Service closed", "R" => 226, "G" => 194, "B" => 54, "Alpha" => 40));
$myPicture->setShadow(FALSE);
/* Draw the chart */
$myPicture->drawSplineChart();
$myPicture->drawPlotChart(array("PlotSize" => 3, "PlotBorder" => TRUE));
/* Write the data bounds */
$myPicture->writeBounds();
/* Write the chart legend */
$myPicture->drawLegend(630, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawThreshold.labels.png");
$myPicture->drawGradientArea(0, 0, 700, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80));
/* Add a border to the picture */
$myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6));
$myPicture->drawText(10, 13, "drawThresholdArea() - draw treshold areas in the charting area", array("R" => 255, "G" => 255, "B" => 255));
/* Write the chart title */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
$myPicture->drawText(250, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE));
/* Draw the scale and do some cosmetics */
$myPicture->setGraphArea(60, 60, 450, 190);
$myPicture->drawFilledRectangle(70, 70, 440, 180, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "DrawSubTicks" => TRUE));
/* Draw one static threshold area */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1));
$myPicture->setFontProperties(array("FontName" => "../fonts/MankSans.ttf", "FontSize" => 10));
$myPicture->drawXThresholdArea(2, 3, array("AreaName" => "Test Zone", "R" => 226, "G" => 194, "B" => 54, "Alpha" => 40));
$myPicture->setShadow(FALSE);
/* Set the font properties */
$myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11));
/* Draw the scale and do some cosmetics */
$myPicture->setGraphArea(500, 60, 670, 190);
$myPicture->drawFilledRectangle(505, 65, 665, 185, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10));
$myPicture->drawScale(array("XMargin" => 5, "YMargin" => 5, "Floating" => TRUE, "Pos" => SCALE_POS_TOPBOTTOM, "DrawSubTicks" => TRUE));
/* Draw one static threshold area */
$myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1));
$myPicture->setFontProperties(array("FontName" => "../fonts/MankSans.ttf", "FontSize" => 10));
$myPicture->drawXThresholdArea(2, 3, array("NameR" => 0, "NameG" => 0, "NameB" => 0, "AreaName" => "Test Zone", "R" => 206, "G" => 231, "B" => 64, "Alpha" => 20));
$myPicture->setShadow(FALSE);
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawXThresholdArea.png");
Example #3
0
    $scaleSettings = array("Mode" => $scale, "ManualScale" => $AxisBoundaries, "DrawXLines" => FALSE, "DrawYLines" => FALSE, "AxisR" => 240, "AxisG" => 240, "AxisB" => 240, "TickR" => 240, "TickG" => 240, "TickB" => 240, "InnerTickWidth" => 0, "OuterTickWidth" => 5, "LabelSkip" => 0, "GridTicks" => 1, "ScaleSpacing" => 100, "XMargin" => 0, "YMargin" => 0, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => FALSE, "CycleBackground" => TRUE);
    $ThresholdSettings = array("Alpha" => 50, "Ticks" => 0, "R" => 230, "G" => 230, "B" => 230, "CaptionR" => 230, "CaptionG" => 230, "CaptionB" => 230, "WriteCaption" => TRUE, "DrawBox" => FALSE, "CaptionOffset" => -18, "NoMargin" => TRUE, "Border" => FALSE, "CaptionAlign" => CAPTION_RIGHT_BOTTOM);
    /* Choose a nice font */
    $Test->setFontProperties(array("FontName" => $font, "R" => 240, "G" => 240, "B" => 240, "FontSize" => $scale_fontsize));
}
$Test->drawScale($scaleSettings);
//$Test->drawGraphAreaGradient(162,183,202,50);
$Test->setFontProperties(array("FontName" => $font, "FontSize" => $threshold_fontsize));
$drawThreshold = $ThresholdSettings;
$drawThreshold["Alpha"] = 10;
//празрачность вертикальной закраски
$index = 0;
$Alpha = $drawThreshold["Alpha"];
while ($index < sizeof($thresholds)) {
    if ($index == 0) {
        $Test->drawXThresholdArea(0, $thresholds[$index], $drawThreshold);
    } elseif ($index % 2 == 1) {
        if ($index + 1 >= sizeof($thresholds)) {
            $Test->drawXThresholdArea($thresholds[$index], sizeof($hours), $drawThreshold);
        } else {
            $Test->drawXThresholdArea($thresholds[$index], $thresholds[$index + 1], $drawThreshold);
        }
    }
    ++$index;
}
$drawThreshold["Alpha"] = $Alpha;
$Test->drawThreshold(round(max($values), 1), $ThresholdSettings);
//горизонтальная линия по максимальному значению
$Test->drawThreshold(round(min($values), 1), $ThresholdSettings);
//горизонтальная линия по минимальному значению
$Test->drawThreshold(round(array_sum($values) / sizeof($values), 1), $ThresholdSettings);