/** * Gera um gráfico de linha * @param array $dados Array no formato array('Label' => array(pontos)) * @param string $tipo linha ou barra */ function grafico($dados, $tipo = 'linha') { require_once 'exemplos/graficos/pChart/class/pDraw.class.php'; require_once 'exemplos/graficos/pChart/class/pImage.class.php'; require_once 'exemplos/graficos/pChart/class/pData.class.php'; // precisamos ter dados para montar os gráficos $DataSet = new pData(); // Adicionando os pontos de um gráfico de linha // horas de trabalho na semana foreach ($dados as $label => $pontos) { $DataSet->addPoints($pontos, $label); } $DataSet->setAxisName(0, 'Horas'); // unidade $DataSet->setAxisUnit(0, 'h'); $settings = array("R" => 229, "G" => 11, "B" => 11, "Alpha" => 80); $DataSet->setPalette("Joao", $settings); // Labels $DataSet->addPoints(array('Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'), 'Dias'); $DataSet->setSerieDescription('Dias', 'Dias da Semana'); $DataSet->setAbscissa('Dias'); $Graph = new pImage(700, 230, $DataSet); $Graph->setFontProperties(array('FontName' => 'exemplos/graficos/pChart/fonts/verdana.ttf', 'FontSize' => 8)); $Graph->setGraphArea(50, 40, 670, 190); $scale = array('GridR' => 150, 'GridG' => 150, 'GridB' => 150, 'DrawSubTicks' => true, 'CycleBackground' => true); $Graph->drawScale($scale); if ($tipo == 'linha') { $Graph->drawLineChart(); } else { $Graph->drawBarChart(); } $Graph->drawLegend(540, 25, array('Style' => LEGEND_ROUND, 'Mode' => LEGEND_VERTICAL)); $Graph->drawText(60, 20, "Horas Trabalhadas"); $Graph->autoOutput(); }
function ring2d($x, $y, $name) { $MyData = new pData(); $MyData->addPoints($x, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($y, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(500, 250, $MyData); /* Draw a solid background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 500, 500, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 500, 30, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 500, 250, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12)); $myPicture->drawText(15, 20, $name, array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "mod/pchart/fonts/verdana.ttf", "FontSize" => 12, "R" => 80, "G" => 80, "B" => 80)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 50)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw an AA pie chart */ $PieChart->draw2DRing(390, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE)); /* Write the legend box */ $myPicture->setShadow(FALSE); $PieChart->drawPieLegend(10, 50, array("Alpha" => 20)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("2dring.png"); }
$myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawLabel() - Write labels over your charts", array("R" => 255, "G" => 255, "B" => 255)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(155, 55, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw the scale and the 1st chart */ $myPicture->setGraphArea(60, 60, 670, 190); $myPicture->drawFilledRectangle(60, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->drawScale(array("DrawSubTicks" => TRUE)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawSplineChart(); $myPicture->setShadow(FALSE); /* Write the chart legend */ $myPicture->drawLegend(600, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Write a label over the chart */ $LabelSettings = array("TitleR" => 255, "TitleG" => 255, "TitleB" => 255, "DrawSerieColor" => FALSE, "TitleMode" => LABEL_TITLE_BACKGROUND, "OverrideTitle" => "Information", "ForceLabels" => array("Issue with the recording device", "New recording device"), "GradientEndR" => 220, "GradientEndG" => 255, "GradientEndB" => 220, "TitleBackgroundG" => 155); $myPicture->writeLabel(array("Probe 2"), array(1, 3), $LabelSettings); /* Write a label over the chart */ $LabelSettings = array("NoTitle" => TRUE, "GradientEndR" => 255, "GradientEndG" => 200, "GradientEndB" => 200); $myPicture->writeLabel(array("Probe 1"), 5, $LabelSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawLabel.caption.png");
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawRectangle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Draw a rectangle */ $RectangleSettings = array("R" => 181, "G" => 209, "B" => 27, "Alpha" => 100); $myPicture->drawRectangle(20, 60, 400, 170, $RectangleSettings); /* Draw a rectangle */ $RectangleSettings = array("R" => 209, "G" => 134, "B" => 27, "Alpha" => 30); $myPicture->drawRectangle(30, 30, 200, 200, $RectangleSettings); /* Draw a rectangle */ $RectangleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100); $myPicture->drawRectangle(480, 50, 650, 80, $RectangleSettings); /* Draw a rectangle */ $RectangleSettings = array("R" => 209, "G" => 125, "B" => 27, "Alpha" => 100); $myPicture->drawRectangle(480, 90, 650, 120, $RectangleSettings); /* Draw a rectangle */ $RectangleSettings = array("R" => 209, "G" => 198, "B" => 27, "Alpha" => 100, "Ticks" => 2); $myPicture->drawRectangle(480, 130, 650, 160, $RectangleSettings); /* Draw a rectangle */ $RectangleSettings = array("R" => 134, "G" => 209, "B" => 27, "Alpha" => 100, "Ticks" => 2); $myPicture->drawRectangle(480, 170, 650, 200, $RectangleSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawRectangle.png");
/* CAT:Stacked chart */ /* pChart library inclusions */ include "class/pData.class.php"; include "class/pDraw.class.php"; include "class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(4, 1, 0, 12, 8, 4, 0, 12, 8), "Frontend #1"); $MyData->addPoints(array(3, 12, 15, 8, VOID, VOID, 12, 15, 8), "Frontend #2"); $MyData->addPoints(array(4, 4, 4, 4, 4, 4, 4, 4, 4), "Frontend #3"); $MyData->setAxisName(0, "Average Usage"); $MyData->addPoints(array("January", "February", "March", "April", "May", "June", "July", "August", "September"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 680, 190); $myPicture->drawScale(array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0)); $myPicture->drawStackedAreaChart(array("DrawPlot" => TRUE, "DrawLine" => TRUE, "LineSurrounding" => -20)); /* Turn on shadow processing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Write the chart legend */ $myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStackedAreaChart.simple.png");
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC); /* Create the abscissa serie */ $MyData->addPoints(array(1230768000, 1233446400, 1235865600, 1238544000, 1241136000, 1243814400), "Timestamp"); $MyData->setSerieDescription("Timestamp", "Sampled Dates"); $MyData->setAbscissa("Timestamp"); $MyData->setXAxisDisplay(AXIS_FORMAT_DATE); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawScale() - draw the X-Y scales", array("R" => 255, "G" => 255, "B" => 255)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); /* Write the chart title */ $myPicture->setGraphArea(60, 60, 660, 190); $myPicture->drawText(350, 55, "My chart title", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); $myPicture->drawFilledRectangle(60, 60, 660, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); /* Draw the scale */ $myPicture->drawScale(); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawScale.dates.png");
/** * 绘制图表并生成图片 * @method drawChart * @return [type] [description] */ protected function drawChart($data_arr, $lab_arr, $pic_name) { /* pChart library inclusions */ include "libs/pChart2.1.4/class/pData.class.php"; include "libs/pChart2.1.4/class/pDraw.class.php"; include "libs/pChart2.1.4/class/pPie.class.php"; include "libs/pChart2.1.4/class/pImage.class.php"; /* pData object creation */ $MyData = new \pData(); /* Data definition */ $MyData->addPoints($data_arr, "Value"); /* Labels definition */ $MyData->addPoints($lab_arr, "Legend"); $MyData->setAbscissa("Legend"); /* Create the pChart object */ $myPicture = new \pImage(500, 150, $MyData); /* Draw a gradient background */ $myPicture->drawGradientArea(0, 0, 500, 150, DIRECTION_HORIZONTAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); /* Add a border to the picture */ // $myPicture->drawRectangle(0,0,399,149,array("R"=>0,"G"=>0,"B"=>0)); /* Create the pPie object */ $PieChart = new \pPie($myPicture, $MyData); /* Enable shadow computing */ $myPicture->setShadow(FALSE); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => __DIR__ . "/libs/pChart2.1.4/fonts/msyh.ttf", "FontSize" => 10, "R" => 80, "G" => 80, "B" => 80)); /* Draw a splitted pie chart */ $PieChart->draw3DPie(250, 100, array("Radius" => 80, "DrawLabels" => TRUE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => FALSE)); /* Render the picture (choose the best way) */ $myPicture->autoOutput(public_path() . '/pictures/' . $pic_name); }
/* Draw a rectangle */ $myPicture->drawFilledRectangle(58, 27, 816, 228, array("R" => 0, "G" => 0, "B" => 0, "Dash" => TRUE, "DashR" => 0, "DashG" => 51, "DashB" => 51, "BorderR" => 0, "BorderG" => 0, "BorderB" => 0)); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Draw the scale */ $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255)); $ScaleSettings = array("XMargin" => 4, "DrawSubTicks" => TRUE, "GridR" => 255, "GridG" => 255, "GridB" => 255, "AxisR" => 255, "AxisG" => 255, "AxisB" => 255, "GridAlpha" => 30, "CycleBackground" => TRUE); $myPicture->drawScale($ScaleSettings); /* Draw the spline chart */ $myPicture->drawFilledSplineChart(); /* Write the chart boundaries */ $BoundsSettings = array("MaxDisplayR" => 237, "MaxDisplayG" => 23, "MaxDisplayB" => 48, "MinDisplayR" => 23, "MinDisplayG" => 144, "MinDisplayB" => 237); $myPicture->writeBounds(BOUND_BOTH, $BoundsSettings); /* Write the 0 line */ $myPicture->drawThreshold(0, array("WriteCaption" => TRUE)); /* Write the chart legend */ $myPicture->setFontProperties(array("R" => 255, "G" => 255, "B" => 255)); $myPicture->drawLegend(560, 266, array("Style" => LEGEND_NOBORDER)); /* Write the 1st data series statistics */ $Settings = array("R" => 188, "G" => 224, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT); $myPicture->drawText(620, 270, "Max : " . ceil($MyData->getMax("Probe 1")), $Settings); $myPicture->drawText(680, 270, "Min : " . ceil($MyData->getMin("Probe 1")), $Settings); $myPicture->drawText(740, 270, "Avg : " . ceil($MyData->getSerieAverage("Probe 1")), $Settings); /* Write the 2nd data series statistics */ $Settings = array("R" => 224, "G" => 100, "B" => 46, "Align" => TEXT_ALIGN_BOTTOMLEFT); $myPicture->drawText(620, 283, "Max : " . ceil($MyData->getMax("Probe 2")), $Settings); $myPicture->drawText(680, 283, "Min : " . ceil($MyData->getMin("Probe 2")), $Settings); $myPicture->drawText(740, 283, "Avg : " . ceil($MyData->getSerieAverage("Probe 2")), $Settings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawFilledSplineChart.png");
$Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawText() - add some text to your charts", array("R" => 255, "G" => 255, "B" => 255)); /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Write some text */ $myPicture->setFontProperties(array("FontName" => "../fonts/advent_light.ttf", "FontSize" => 20)); $TextSettings = array("R" => 255, "G" => 255, "B" => 255, "Angle" => 10); $myPicture->drawText(60, 115, "10 degree text", $TextSettings); /* Write some text */ $TextSettings = array("R" => 0, "G" => 0, "B" => 0, "Angle" => 0, "FontSize" => 40); $myPicture->drawText(220, 130, "Simple text", $TextSettings); /* Write some text */ $TextSettings = array("R" => 200, "G" => 100, "B" => 0, "Angle" => 90, "FontSize" => 14); $myPicture->drawText(500, 170, "Vertical Text", $TextSettings); /* Write some text */ $myPicture->setFontProperties(array("FontName" => "../fonts/Bedizen.ttf", "FontSize" => 6)); $TextSettings = array("DrawBox" => TRUE, "BoxRounded" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Angle" => 0, "FontSize" => 10); $myPicture->drawText(220, 160, "Encapsulated text", $TextSettings); /* Write some text */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 6)); $TextSettings = array("DrawBox" => TRUE, "R" => 0, "G" => 0, "B" => 0, "Angle" => 0, "FontSize" => 10); $myPicture->drawText(220, 195, "Text in a box", $TextSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawText.png");
$myPicture = new pImage(700, 230, $MyData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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(60, 60, 450, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("DrawSubTicks" => TRUE)); /* Draw one static threshold area */ $myPicture->drawThresholdArea(5, 15, array("R" => 226, "G" => 194, "B" => 54, "Alpha" => 40)); /* Draw the scale and do some cosmetics */ $myPicture->setGraphArea(500, 60, 670, 190); $myPicture->drawFilledRectangle(500, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("Pos" => SCALE_POS_TOPBOTTOM, "DrawSubTicks" => TRUE)); /* Draw one static threshold area */ $myPicture->drawThresholdArea(5, 15, array("R" => 206, "G" => 231, "B" => 64, "Alpha" => 20)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawThresholdArea.png");
include "../class/pImage.class.php"; /* Create the pChart object */ $myPicture = new pImage(700, 230); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawFromGIF() - add pictures to your charts", array("R" => 255, "G" => 255, "B" => 255)); /* Turn off shadow computing */ $myPicture->setShadow(FALSE); /* Draw a GIF object */ $myPicture->drawFromGIF(180, 50, "resources/computer.gif"); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Draw a GIF object */ $myPicture->drawFromGIF(400, 50, "resources/computer.gif"); /* Write the legend */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); $TextSettings = array("R" => 255, "G" => 255, "B" => 255, "FontSize" => 10, "FontName" => "../fonts/calibri.ttf", "Align" => TEXT_ALIGN_BOTTOMMIDDLE); $myPicture->drawText(240, 200, "Without shadow", $TextSettings); $myPicture->drawText(460, 200, "With enhanced shadow", $TextSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawFromGIF.png");
$myPicture->drawPolygon($Plots, $PolygonSettings); $myPicture->addToImageMap("POLY", "402,62,460,80,420,190,360,168", $myPicture->toHTMLColor(71, 87, 145), "Polygon", "My Message"); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 150, "G" => 200, "B" => 170, "Dash" => TRUE, "DashR" => 170, "DashG" => 220, "DashB" => 190, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255); $myPicture->drawFilledRectangle(20, 60, 210, 170, $RectangleSettings); $myPicture->addToImageMap("RECT", "20,60,210,170", $myPicture->toHTMLColor(150, 200, 170), "Box 1", "Message 1"); /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 209, "G" => 134, "B" => 27, "Alpha" => 30); $myPicture->drawFilledRectangle(30, 30, 200, 200, $RectangleSettings); $myPicture->addToImageMap("RECT", "30,30,200,200", $myPicture->toHTMLColor(209, 134, 27), "Box 2", "Message 2"); /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100, "Surrounding" => 30); $myPicture->drawFilledRectangle(480, 50, 650, 80, $RectangleSettings); $myPicture->addToImageMap("RECT", "480,50,650,80", $myPicture->toHTMLColor(209, 31, 27), "Box 3", "Message 3"); /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 209, "G" => 125, "B" => 27, "Alpha" => 100, "Surrounding" => 30); $myPicture->drawFilledRectangle(480, 90, 650, 120, $RectangleSettings); $myPicture->addToImageMap("RECT", "480,90,650,120", $myPicture->toHTMLColor(209, 125, 27), "Box 4", "Message 4"); /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 209, "G" => 198, "B" => 27, "Alpha" => 100, "Surrounding" => 30, "Ticks" => 2); $myPicture->drawFilledRectangle(480, 130, 650, 160, $RectangleSettings); $myPicture->addToImageMap("RECT", "480,130,650,160", $myPicture->toHTMLColor(209, 198, 27), "Box 5", "Message 5"); /* Draw a customized filled rectangle */ $RectangleSettings = array("R" => 134, "G" => 209, "B" => 27, "Alpha" => 100, "Surrounding" => 30, "Ticks" => 2); $myPicture->drawFilledRectangle(480, 170, 650, 200, $RectangleSettings); $myPicture->addToImageMap("RECT", "480,170,650,200", $myPicture->toHTMLColor(134, 209, 27), "Box 6", "Message 6"); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/Shapes.png");
/* Give a name to the Y axis */ $MyData->setAxisName(0, "Temperatures"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 650, 200); /* Draw the scale */ $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line of best fit */ $myPicture->drawBestFit(); /* Turn on shadows */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the line chart */ $myPicture->drawPlotChart(); /* Write the chart legend */ $myPicture->drawLegend(580, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawBestFit.png");
/* Do a gradient overlay */ $Settings = array("StartR" => 194, "StartG" => 231, "StartB" => 44, "EndR" => 43, "EndG" => 107, "EndB" => 58, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 210, 100, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 210, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 100)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 209, 99, array("R" => 0, "G" => 0, "B" => 0)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "pSurface() :: Surface charts", array("R" => 255, "G" => 255, "B" => 255)); /* Define the charting area */ $myPicture->setGraphArea(50, 60, 180, 80); $myPicture->drawFilledRectangle(50, 60, 180, 80, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 20)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1)); /* Create the surface object */ $mySurface = new pSurface($myPicture); /* Set the grid size */ $mySurface->setGrid(9, 1); /* Write the axis labels */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setFontProperties(array("FontName" => "../fonts/Bedizen.ttf", "FontSize" => 7)); $mySurface->writeXLabels(array("Angle" => 45, "Labels" => array("Run 1", "Run 2", "Run 3", "Run 4", "Run 5", "Run 6", "Run 7", "Run 8", "Run 9", "Run 10"))); $mySurface->writeYLabels(array("Labels" => array("Probe 1", "Probe 2"))); /* Add random values */ for ($i = 0; $i <= 10; $i++) { $mySurface->addPoint($i, rand(0, 1), rand(0, 100)); } /* Draw the surface chart */ $mySurface->drawSurface(array("Border" => TRUE, "Surrounding" => 40)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.surface.simple.png");
$myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 650, 200); /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Write the chart legend */ $myPicture->drawLegend(580, 12, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the chart */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $Settings = array("RecordImageMap" => TRUE); $myPicture->drawBarChart($Settings); /* Replace the labels of the image map */ $Labels = array("Jan: 140", "Feb: 0", "Mar: 340", "Apr: 300", "May: 320", "Jun: 300", "Jul: 200", "Aug: 100", "Sep: 50"); $myPicture->replaceImageMapValues("Server B", $Labels); /* Repalce the titles of the image map */ $Titles = array("Jan 2k11", "Feb 2k11", "Mar 2k11", "Apr 2k11", "May 2k11", "Jun 2k11", "Jul 2k11", "Aug 2k11", "Sep 2k11"); $myPicture->replaceImageMapTitle("Server A", "Second server"); $myPicture->replaceImageMapTitle("Server B", $Titles); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/BarChart.labels.png");
/* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 650, 200); /* Draw the scale */ $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line chart */ $Settings = array("RecordImageMap" => TRUE); $myPicture->drawSplineChart($Settings); $myPicture->drawPlotChart(array("PlotBorder" => TRUE, "PlotSize" => 3, "BorderSize" => 1, "Surrounding" => -60, "BorderAlpha" => 80)); /* Write the chart legend */ $myPicture->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/SplineChart.png");
include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(4, 1, 0, 12, 8, 4, 0, 12, 8), "Frontend #1"); $MyData->addPoints(array(3, 12, 15, 8, VOID, VOID, 12, 15, 8), "Frontend #2"); $MyData->addPoints(array(4, 4, 4, 4, 4, 4, 4, 4, 4), "Frontend #3"); $MyData->setAxisName(0, "Average Usage"); $MyData->addPoints(array("January", "February", "March", "April", "May", "June", "July", "August", "September"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 680, 190); $myPicture->drawScale(array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0)); $myPicture->drawStackedAreaChart(array("DrawPlot" => TRUE, "DrawLine" => TRUE, "LineSurrounding" => -20)); /* Turn on shadow processing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Write a label */ $myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE)); /* Write the chart legend */ $myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawLabel.stacked.png");
/* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(35, 28, 17, 27, 12, 12, 20, 15, 20, 28), "Open"); $MyData->addPoints(array(20, 17, 25, 20, 25, 23, 16, 29, 26, 17), "Close"); $MyData->addPoints(array(10, 11, 14, 11, 9, 4, 3, 7, 9, 5), "Min"); $MyData->addPoints(array(37, 32, 33, 29, 29, 25, 22, 34, 29, 31), "Max"); $MyData->addPoints(array(30, 20, 21, 24, 22, 18, 18, 24, 22, 24), "Median"); $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "\$"); $MyData->addPoints(array("Dec 13", "Dec 14", "Dec 15", "Dec 16", "Dec 17", "Dec 20", "Dec 21", "Dec 22", "Dec 23", "Dec 24"), "Time"); $MyData->setAbscissa("Time"); $MyData->setAbscissaName("Time"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of AAliasing */ $myPicture->Antialias = FALSE; /* Draw the border */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 30, 650, 190); /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Create the pStock object */ $mystockChart = new pStock($myPicture, $MyData); /* Draw the stock chart */ $stockSettings = array("BoxUpR" => 255, "BoxUpG" => 255, "BoxUpB" => 255, "BoxDownR" => 0, "BoxDownG" => 0, "BoxDownB" => 0, "SerieMedian" => "Median"); $mystockChart->drawStockChart($stockSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStockChart.median.png");
$MyData->addPoints(array(30, 20, 21, 24, 22, 18, 18, 24, 22, 24), "Median"); $MyData->setAxisDisplay(0, AXIS_FORMAT_CURRENCY, "\$"); $MyData->addPoints(array("Dec 13", "Dec 14", "Dec 15", "Dec 16", "Dec 17", "Dec 20", "Dec 21", "Dec 22", "Dec 23", "Dec 24"), "Time"); $MyData->setAbscissa("Time"); $MyData->setAbscissaName("Time"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Retrieve the image map */ if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"])) { $myPicture->dumpImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp"); } /* Set the image map name */ $myPicture->initialiseImageMap("ImageMapStockChart", IMAGE_MAP_STORAGE_FILE, "StockChart", "../tmp"); /* Turn of AAliasing */ $myPicture->Antialias = FALSE; /* Draw the border */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setFontProperties(array("FontName" => FONT_PATH . "/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 30, 650, 190); /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Create the pStock object */ $mystockChart = new pStock($myPicture, $MyData); /* Draw the stock chart */ $stockSettings = array("RecordImageMap" => TRUE, "BoxUpR" => 255, "BoxUpG" => 255, "BoxUpB" => 255, "BoxDownR" => 0, "BoxDownG" => 0, "BoxDownB" => 0, "SerieMedian" => "Median"); $mystockChart->drawStockChart($stockSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/StockChart.png");
$MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw a background */ $Settings = array("R" => 190, "G" => 213, "B" => 107, "Dash" => 1, "DashR" => 210, "DashG" => 223, "DashB" => 127); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 650, 200); /* Draw the scale */ $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line chart */ $myPicture->drawSplineChart(); $myPicture->drawPlotChart(array("PlotBorder" => TRUE, "BorderSize" => 1, "Surrounding" => -60, "BorderAlpha" => 80)); /* Write the chart legend */ $myPicture->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawSplineChart.simple.png");
/* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = FALSE; /* Draw the background and the border */ $myPicture->drawFilledRectangle(0, 0, 699, 229, array("R" => 200, "G" => 200, "B" => 200)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 220, "StartG" => 220, "StartB" => 220, "EndR" => 100, "EndG" => 100, "EndB" => 100, "Alpha" => 30)); $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Size by time generations", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Define the chart area */ $myPicture->setGraphArea(40, 40, 680, 200); /* Draw the scale */ $scaleSettings = array("LabelSkip" => 4, "XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridAlpha" => 30, "GridR" => 140, "GridG" => 140, "GridB" => 140, "DrawSubTicks" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line chart */ $myPicture->drawZoneChart("Bounds 1", "Bounds 2", array("LineAlpha" => 100, "AreaR" => 230, "AreaG" => 230, "AreaB" => 230, "AreaAlpha" => 20, "LineTicks" => 3)); $MyData->setSerieDrawable(array("Bounds 1", "Bounds 2"), FALSE); /* Draw the line chart */ $myPicture->drawLineChart(); $myPicture->drawPlotChart(array("PlotBorder" => TRUE, "PlotSize" => 2, "BorderSize" => 3, "Surrounding" => 60, "BorderAlpha" => 50)); /* Write the chart legend */ $myPicture->drawLegend(640, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawZoneChart.png");
/* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $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, "drawCircle() - Transparency & colors", array("R" => 255, "G" => 255, "B" => 255)); /* Draw some circles */ $myPicture->drawCircle(100, 125, 50, 50, array("R" => 213, "G" => 226, "B" => 0, "Alpha" => 100)); $myPicture->drawCircle(140, 125, 50, 50, array("R" => 213, "G" => 226, "B" => 0, "Alpha" => 70)); $myPicture->drawCircle(180, 125, 50, 50, array("R" => 213, "G" => 226, "B" => 0, "Alpha" => 40)); $myPicture->drawCircle(220, 125, 50, 50, array("R" => 213, "G" => 226, "B" => 0, "Alpha" => 20)); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Draw a customized circles */ $CircleSettings = array("R" => 209, "G" => 31, "B" => 27, "Alpha" => 100); $myPicture->drawCircle(480, 60, 20, 20, $CircleSettings); /* Draw a customized circles */ $CircleSettings = array("R" => 209, "G" => 125, "B" => 27, "Alpha" => 100); $myPicture->drawCircle(480, 100, 30, 20, $CircleSettings); /* Draw a customized circles */ $CircleSettings = array("R" => 209, "G" => 198, "B" => 27, "Alpha" => 100, "Ticks" => 4); $myPicture->drawCircle(480, 140, 40, 20, $CircleSettings); /* Draw a customized circles */ $CircleSettings = array("R" => 134, "G" => 209, "B" => 27, "Alpha" => 100, "Ticks" => 4); $myPicture->drawCircle(480, 180, 50, 20, $CircleSettings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawCircle.png");
protected function drawBarChart(ChartDataset $CDs) { if (!extension_loaded("gd") && !extension_loaded("gd2")) { /* Extension not loaded */ // NO BARCHARTS AND ERRORS FOR YOU! return; } /* Create and populate the pData object */ $MyData = new pData(); if (empty($CDs->data)) { return; } //print_r($CDs->data); foreach ($CDs->data as $points) { //print_r($points); $MyData->addPoints($points["points"], $points["label"]); } $MyData->setAxisName(0, "Amount Sold"); $MyData->setSerieDescription($points["label"], $points["label"]); $MyData->setAbscissa($points["label"]); /* Create the pChart object */ $myPicture = new pImage(1000, 230, $MyData); // the horrible way to add fonts is just one bunch of f****d up shit, not making sense. bullshit parameters and paths. //$myPicture->setFontProperties(array("FontName"=>"Bedizen")); $myPicture->setFontProperties(array("FontName" => "pChart2.1.4//fonts/calibri.ttf", "FontSize" => 11)); //print_r(is_file("C:/xampp_jan2015/htdocs/hackerbar/web/fonts/GeosansLight.ttf")); /* Turn of Antialiasing */ $myPicture->Antialias = false; /* Add a border to the picture */ $myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 1000, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); $myPicture->drawRectangle(0, 0, 999, 229, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ //$myPicture->setFontProperties(array("FontName"=>"../fonts/pf_arma_five.ttf","FontSize"=>6)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 850, 200); /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Write the chart legend */ $myPicture->drawLegend(860, 25, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the chart */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $settings = array("Surrounding" => -30, "InnerSurrounding" => 30); $myPicture->drawBarChart($settings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("images/barcharts/" . $points["label"] . ".png"); //$myPicture->auto $myPicture->render("myfile.png"); }
/* Define the chart area */ $myPicture->setGraphArea(60, 50, 670, 200); /* Draw the scale */ $scaleSettings = array("LabelSkip" => 9, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the line chart */ $myPicture->drawPlotChart(array("PlotSize" => 2)); /* Compute the serie average and standard deviation */ $Average = $MyData->getSerieAverage("Probe 1"); /* Compute the serie standard deviation */ $StandardDeviation = $MyData->getStandardDeviation("Probe 1"); /* Draw a threshold area */ $myPicture->setShadow(FALSE); $myPicture->drawThresholdArea($Average - $StandardDeviation, $Average + $StandardDeviation, array("R" => 100, "G" => 100, "B" => 200, "Alpha" => 10)); $myPicture->setShadow(TRUE); /* Draw the serie average */ $myPicture->drawThreshold($Average, array("WriteCaption" => TRUE, "Caption" => "Average value", "AxisID" => 0)); /* Draw the standard deviation boundaries */ $ThresholdSettings = array("WriteCaption" => TRUE, "CaptionAlign" => CAPTION_RIGHT_BOTTOM, "Caption" => "SD", "AxisID" => 0, "R" => 0, "G" => 0, "B" => 0); $myPicture->drawThreshold($Average + $StandardDeviation, $ThresholdSettings); $myPicture->drawThreshold($Average - $StandardDeviation, $ThresholdSettings); /* Write the coefficient of variation */ $CoefficientOfVariation = round($MyData->getCoefficientOfVariation("Probe 1"), 1); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->drawText(610, 46, "coefficient of variation : " . $CoefficientOfVariation, array("Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStandardDeviation.png");
/* Create the pChart object */ $myPicture = new pImage(400, 400, $myData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 400, 400, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 400, 400, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 400, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawScatterLineChart() - Draw a scatter line chart", array("R" => 255, "G" => 255, "B" => 255)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 399, 399, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Set the graph area */ $myPicture->setGraphArea(50, 50, 350, 350); /* Create the Scatter chart object */ $myScatter = new pScatter($myPicture, $myData); /* Draw the scale */ $myScatter->drawScatterScale(); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw a scatter plot chart */ $myScatter->drawScatterLineChart(); /* Draw the legend */ $myScatter->drawScatterLegend(270, 375, array("Mode" => LEGEND_HORIZONTAL, "Style" => LEGEND_NOBORDER)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawScatterLineChart.trigo.png");
function PlotPie($rowA, $rowB, $name, $cch) { include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pData.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pDraw.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pImage.class.php"; include $_SERVER['DOCUMENT_ROOT'] . "/TBSIM/Lib/class/pPie.class.php"; $MyData = new pData(); $MyData->addPoints($rowA, "ScoreA"); $MyData->setSerieDescription("ScoreA", "Application A"); /* Define the absissa serie */ $MyData->addPoints($rowB, "Labels"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 630, $MyData); $myPicture->setFontProperties(array("FontName" => "fonts/Forgotte.ttf", "FontSize" => 14)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 252, "G" => 252, "B" => 252, "DrawBox" => 1, "BoxAlpha" => 30); //$myPicture->drawText(350,25,$name,$TextSettings); $myPicture->setShadow(FALSE); $myPicture->setGraphArea(50, 50, 675, 690); //$myPicture->setFontProperties(array("R"=>0,"G"=>0,"B"=>0,"FontName"=>"fonts/pf_arma_five.ttf","FontSize"=>6)); $Settings = array("Pos" => SCALE_POS_LEFTRIGHT, "Mode" => SCALE_MODE_FLOATING, "LabelingMethod" => LABELING_ALL, "GridR" => 255, "GridG" => 255, "GridB" => 255, "GridAlpha" => 50, "TickR" => 0, "TickG" => 0, "TickB" => 0, "TickAlpha" => 50, "LabelRotation" => 0, "CycleBackground" => 1, "DrawXLines" => 1, "DrawSubTicks" => 1, "SubTickR" => 255, "SubTickG" => 0, "SubTickB" => 0, "SubTickAlpha" => 50, "DrawYLines" => ALL); //$myPicture->drawScale($Settings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 10)); /* Create the pPie object */ $PieChart = new pPie($myPicture, $MyData); /* Draw an AA pie chart */ if ($cch == 11) { $PieChart->draw2DPie(160, 140, array("DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); } if ($cch == 12) { $PieChart->draw2DRing(160, 140, array("WriteValues" => TRUE, "ValueR" => 255, "ValueG" => 255, "ValueB" => 255, "Border" => TRUE)); } if ($cch == 13) { $PieChart->draw3DPie(160, 140, array("Radius" => 70, "DrawLabels" => TRUE, "LabelStacked" => TRUE, "Border" => TRUE)); } /* Write the legend box */ $myPicture->setShadow(FALSE); $PieChart->drawPieLegend(15, 40, array("Alpha" => 20)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.draw2DPie.labels.png"); }
/* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(4, VOID, VOID, 12, 8, 3), "Frontend #1"); $MyData->addPoints(array(3, 12, 15, 8, 5, 5), "Frontend #2"); $MyData->addPoints(array(2, 7, 5, 18, 19, 22), "Frontend #3"); $MyData->setAxisName(0, "Average Usage"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 680, 190); $myPicture->drawScale(array("DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0)); $myPicture->setShadow(FALSE); $myPicture->drawStackedBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15)); /* Write a label */ $myPicture->writeLabel(array("Frontend #1", "Frontend #2", "Frontend #3"), 1, array("DrawVerticalLine" => TRUE)); /* Write the chart legend */ $myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStackedBarChart.shaded.png");
/* Create the pChart object */ $myPicture = new pImage(400, 400, $myData); /* Draw the background */ $Settings = array("R" => 170, "G" => 183, "B" => 87, "Dash" => 1, "DashR" => 190, "DashG" => 203, "DashB" => 107); $myPicture->drawFilledRectangle(0, 0, 400, 400, $Settings); /* Overlay with a gradient */ $Settings = array("StartR" => 219, "StartG" => 231, "StartB" => 139, "EndR" => 1, "EndG" => 138, "EndB" => 68, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 400, 400, DIRECTION_VERTICAL, $Settings); $myPicture->drawGradientArea(0, 0, 400, 20, DIRECTION_VERTICAL, array("StartR" => 0, "StartG" => 0, "StartB" => 0, "EndR" => 50, "EndG" => 50, "EndB" => 50, "Alpha" => 80)); /* Write the picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawScatterPlotChart() - Draw a scatter plot chart", array("R" => 255, "G" => 255, "B" => 255)); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 399, 399, array("R" => 0, "G" => 0, "B" => 0)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Set the graph area */ $myPicture->setGraphArea(50, 50, 350, 350); /* Create the Scatter chart object */ $myScatter = new pScatter($myPicture, $myData); /* Draw the scale */ $myScatter->drawScatterScale(); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw a scatter plot chart */ $myScatter->drawScatterPlotChart(); /* Draw the legend */ $myScatter->drawScatterLegend(260, 375, array("Mode" => LEGEND_HORIZONTAL, "Style" => LEGEND_NOBORDER)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawScatterPlotChart.png");
include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->loadPalette("../palettes/blind.color", TRUE); $MyData->addPoints(array(150, 220, 300, 250, 420, 200, 300, 200, 110), "Server A"); $MyData->addPoints(array("January", "February", "March", "April", "May", "Juin", "July", "August", "September"), "Months"); $MyData->setSerieDescription("Months", "Month"); $MyData->setAbscissa("Months"); /* Create the floating 0 data serie */ $MyData->addPoints(array(60, 80, 20, 40, 40, 50, 90, 30, 100), "Floating 0"); $MyData->setSerieDrawable("Floating 0", FALSE); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 10, "R" => 110, "G" => 110, "B" => 110)); /* Write the title */ $myPicture->drawText(10, 13, "Net Income 2k8"); /* Set the graphical area */ $myPicture->setGraphArea(50, 30, 680, 180); /* Draw the scale */ $AxisBoundaries = array(0 => array("Min" => 0, "Max" => 500)); $myPicture->drawScale(array("InnerTickWidth" => 0, "OuterTickWidth" => 0, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries, "LabelRotation" => 45, "DrawXLines" => FALSE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridTicks" => 0, "GridAlpha" => 30, "AxisAlpha" => 0)); /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the chart */ $settings = array("Floating0Serie" => "Floating 0", "Surrounding" => 10); $myPicture->drawBarChart($settings); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawBarChart.span.png");
/* pChart library inclusions */ include "../class/pData.class.php"; include "../class/pDraw.class.php"; include "../class/pImage.class.php"; /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints(array(13251, 4118, 3087, 1460, 1248, 156, 26, 9, 8), "Hits"); $MyData->setAxisName(0, "Hits"); $MyData->addPoints(array("Firefox", "Chrome", "Internet Explorer", "Opera", "Safari", "Mozilla", "SeaMonkey", "Camino", "Lunascape"), "Browsers"); $MyData->setSerieDescription("Browsers", "Browsers"); $MyData->setAbscissa("Browsers"); $MyData->setAbscissaName("Browsers"); $MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC, 1); /* Create the pChart object */ $myPicture = new pImage(500, 500, $MyData); $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the chart scale */ $myPicture->setGraphArea(100, 30, 480, 480); $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM)); // /* Turn on shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the chart */ $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30)); /* Write the legend */ $myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawBarChart.vertical.png");