$MyData->setAbscissaName("Time (years)"); /* 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");
function PlotLine($rowX, $rowY, $name, $ch) { 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($rowX, "Serie1"); $myData->setSerieDescription("Serie1", $name); //$myData->setSerieOnAxis("Serie1",0); $myData->addPoints($rowY, "Absissa"); $myData->setAbscissa("Absissa"); //$myData->addPoints(array("January","February","March","April","May","June","July","August"),"Absissa"); //$myData->setAbscissa("Absissa"); $myData->setAxisPosition(0, AXIS_POSITION_LEFT); //$myData->setAxisName(0,"1st axis"); $myData->setAxisUnit(0, ""); $myPicture = new pImage(700, 230, $myData); $Settings = array("R" => 240, "G" => 242, "B" => 241, "Dash" => 1, "DashR" => 260, "DashG" => 262, "DashB" => 261); $myPicture->drawFilledRectangle(0, 0, 700, 230, $Settings); $Settings = array("StartR" => 252, "StartG" => 255, "StartB" => 254, "EndR" => 252, "EndG" => 255, "EndB" => 254, "Alpha" => 50); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, $Settings); $myPicture->drawRectangle(0, 0, 699, 229, array("R" => 0, "G" => 0, "B" => 0)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 50, "G" => 50, "B" => 50, "Alpha" => 20)); $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, 190); //$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)); $Config = ""; if ($ch == 1) { $myPicture->drawSplineChart($Config); } if ($ch == 2) { $myPicture->drawBarChart($Config); } if ($ch == 3) { $myPicture->drawLineChart($Config); } if ($ch == 4) { $myPicture->drawPlotChart($Config); } if ($ch == 5) { $myPicture->drawStepChart($Config); } if ($ch == 6) { $myPicture->drawAreaChart($Config); } if ($ch == 7) { $myPicture->drawFilledSplineChart($Config); } if ($ch == 8) { $myPicture->drawFilledStepChart($Config); } if ($ch == 9) { $myPicture->drawStackedAreaChart($Config); } $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => "fonts/pf_arma_five.ttf", "FontSize" => 6, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL); $myPicture->drawLegend(563, 16, $Config); $myPicture->stroke(); }
} /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the stacked area chart */ if ($chartType == 'area2') { $myPicture->drawStackedAreaChart(); } else { if ($chartType == 'bar') { $myPicture->drawBarChart(array("Surrounding" => -15, "InnerSurrounding" => 15) + $arrDisplayValues); } else { if ($chartType == 'bar2') { $myPicture->drawStackedBarChart(); } else { $myPicture->drawLineChart(); if ($plot > 0) { $myPicture->drawPlotChart($arrDisplayValues + array("PlotSize" => $weight * 1.5 + 3, "PlotBorder" => TRUE, "BorderSize" => 0.8, "BorderAlpha" => 75, "Surrounding" => -30)); } } } } // 隐藏主坐标轴数据,画副坐标轴数据 if (isset($arrSeriesY2)) { foreach ($arrSeries as $serie) { if (in_array($serie, $arrSeriesY2)) { $myData->setSerieDrawable($serie, TRUE); } else { $myData->setSerieDrawable($serie, FALSE); } } $myPicture->drawLineChart(); if ($plot == 1) {
$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); /* 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");
/* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(160, 35, "Measured temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); $myPicture->drawText(340, 30, "(and associated standard deviation)", array("FontSize" => 10, "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, 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 */
} /* 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");
/* 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, "drawPlotChart() - draw a plot chart", array("R" => 255, "G" => 255, "B" => 255)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(250, 55, "Average temperature", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw the scale and the 1st chart */ $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)); $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)); $myPicture->drawPlotChart(array("BorderSize" => 1, "Surrounding" => 40, "BorderAlpha" => 100, "PlotSize" => 2, "PlotBorder" => TRUE, "DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO)); $myPicture->setShadow(FALSE); /* Draw the scale and the 2nd chart */ $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)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawPlotChart(array("PlotSize" => 1, "PlotBorder" => TRUE, "BorderSize" => 1)); $myPicture->setShadow(FALSE); /* Write the chart legend */ $myPicture->drawLegend(510, 205, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawPlotChart.png");
/* 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->drawScale($Settings); $Config = array("DisplayValues" => 0, "AroundZero" => 0, "BreakVoid" => 1, "RecordImageMap" => FALSE); $GraphType = 'SplineChart'; switch ($GraphType) { case 'AreaChart': $myPicture->drawAreaChart($Config); break; case 'FilledSplineChart': $myPicture->drawFilledSplineChart($Config); break; case 'SplineChart': $myPicture->drawSplineChart($Config); break; case 'BarChart': $myPicture->drawBarChart($Config, 'tetimes'); break; case 'StackedBarChart': $myPicture->drawStackedBarChart($Config); break; case 'PlotChart': $myPicture->drawPlotChart($Config); break; default: break; } $Config = array("FontR" => 0, "FontG" => 0, "FontB" => 0, "FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 8, "Margin" => 6, "Alpha" => 30, "BoxSize" => 5, "Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL); $myPicture->drawLegend($Graphwidth - 65, 40, $Config); $myPicture->setFontProperties(array("FontName" => $LibPath . "fonts/verdana.ttf", "FontSize" => 10)); $TextSettings = array("Align" => TEXT_ALIGN_MIDDLEMIDDLE, "R" => 0, "G" => 0, "B" => 0); $myPicture->drawText(200, 15, $GraphLabel, $TextSettings); $myPicture->render(__DIR__ . '/temp/' . $Type . '_' . $SensorID . '.png');
$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); $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 chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 8, "R" => 255, "G" => 255, "B" => 255)); $myPicture->drawText(10, 16, "Average recorded temperature", array("FontSize" => 11, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6, "R" => 0, "G" => 0, "B" => 0)); /* Define the chart area */ $myPicture->setGraphArea(60, 50, 650, 220); /* 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; /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the line chart */ $myPicture->drawLineChart(); $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotBorder" => TRUE, "BorderSize" => 2, "Surrounding" => -60, "BorderAlpha" => 80)); /* Write the chart legend */ $myPicture->drawLegend(590, 9, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL, "FontR" => 255, "FontG" => 255, "FontB" => 255)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawLineChart.reversed.png");
/* Set the image map name */ $myPicture->initialiseImageMap("ImageMap1", IMAGE_MAP_STORAGE_FILE, "PlotChart", "../tmp"); /* 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; $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the line chart */ $myPicture->drawPlotChart(array("RecordImageMap" => TRUE)); /* Write the chart legend */ $myPicture->drawLegend(580, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("../tmp/PlotChart.png");
$myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "Chart title", array("R" => 255, "G" => 255, "B" => 255)); /* Draw the scale */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setGraphArea(50, 60, 670, 190); $myPicture->drawFilledRectangle(50, 60, 670, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $myPicture->drawScale(array("CycleBackground" => TRUE)); /* Graph title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawText(50, 52, "Chart subtitle", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Draw the bar chart chart */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $MyData->setSerieDrawable("Last year", FALSE); $myPicture->drawBarChart(); /* Turn on antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line and plot chart */ $MyData->setSerieDrawable("Last year", TRUE); $MyData->setSerieDrawable("This year", FALSE); $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawSplineChart(); $myPicture->setShadow(FALSE); $myPicture->drawPlotChart(array("PlotSize" => 3, "PlotBorder" => TRUE, "BorderSize" => 3, "BorderAlpha" => 20)); /* Make sure all series are drawable before writing the scale */ $MyData->drawAll(); /* Write the legend */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawLegend(580, 35, array("Style" => LEGEND_ROUND, "Alpha" => 20, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.combo.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, "drawPlotChart() - draw a plot chart", array("R" => 255, "G" => 255, "B" => 255)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(250, 55, "Average time spent on projects", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Draw the scale and the 1st chart */ $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)); $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)); $myPicture->drawSplineChart(); $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO)); $myPicture->setShadow(FALSE); /* Draw the scale and the 2nd chart */ $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)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawPlotChart(); $myPicture->setShadow(FALSE); /* Write the chart legend */ $myPicture->drawLegend(590, 205, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawPlotChart.icon.png");
public function reportday($projectID) { /* pChart library inclusions */ include "../p_chart/class/pData.class.php"; include "../p_chart/class/pDraw.class.php"; include "../p_chart/class/pImage.class.php"; //每日剩余 $where = "project = {$projectID} AND deleted = '0' AND status NOT IN ( 'cancel','closed') "; $tasks_all = $this->task->getTasksByCondition($where); $tasks_all_count = count($tasks_all); $this->view->tasks_all_count = $tasks_all_count; $where = "project = {$projectID} AND deleted = '0'"; $allFinishedDate = $this->task->getAllFinishedDate($where); $tasks_un_finished_x = array(); $tasks_un_finished_y = array(); foreach (array_reverse($allFinishedDate) as $v) { $where = "project = {$projectID} AND deleted = '0' AND status NOT IN ( 'cancel','closed') AND finishedDate <= '{$v->date} 23:59:59' AND finishedDate != '0000-00-00 00:00:00'"; $count = $this->task->getUnFinishedTasksPerDay($where, $tasks_all_count); $tasks_un_finished_x[] = date('m-d', strtotime($v->date)); $tasks_un_finished_y[] = $count; } /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($tasks_un_finished_y, "Probe 1"); $MyData->setSerieWeight("Probe 1", 2); $MyData->setAxisName(0, ""); $MyData->addPoints($tasks_un_finished_x, "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); /* 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); $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 chart title */ $myPicture->setFontProperties(array("FontName" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8, "R" => 255, "G" => 255, "B" => 255)); $myPicture->drawText(10, 16, "每日剩余任务数", array("FontSize" => 10, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0)); /* 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; /* Enable shadow computing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the line chart */ $myPicture->drawLineChart(); $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotBorder" => TRUE, "BorderSize" => 2, "Surrounding" => -60, "BorderAlpha" => 80)); /* Write the chart legend */ $myPicture->drawLegend(590, 9, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL, "FontR" => 255, "FontG" => 255, "FontB" => 255)); /* Render the picture (choose the best way) */ $myPicture->autoOutput(); $img = $myPicture->base64("output.png"); $this->view->src_line = $img; //每位成员剩余 $where = "project = {$projectID} AND deleted = '0' AND (status = 'wait' OR status = 'doing') AND assignedTo !='' "; $tasks_un_finished_per_member = $this->task->getUnFinishedTasksPerAssignedTo($where); $tasks_un_finished_member_x = array(); $tasks_un_finished_member_y = array(); foreach ($tasks_un_finished_per_member as $v) { $tasks_un_finished_member_x[] = $v->value; $tasks_un_finished_member_y[] = $v->name; } /* Create and populate the pData object */ $MyData = new pData(); $MyData->addPoints($tasks_un_finished_member_x, "Hits"); $MyData->setAxisName(0, "剩余任务数"); $MyData->addPoints($tasks_un_finished_member_y, "Browsers"); $MyData->setSerieDescription("Browsers", "Browsers"); $MyData->setAbscissa("Browsers"); //$MyData->setAbscissaName("Browsers"); /* 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" => "../p_chart/fonts/msyh.ttf", "FontSize" => 8)); /* 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)); /* Create the per bar palette */ $Palette = array("0" => array("R" => 188, "G" => 224, "B" => 46, "Alpha" => 100), "1" => array("R" => 224, "G" => 100, "B" => 46, "Alpha" => 100), "2" => array("R" => 224, "G" => 214, "B" => 46, "Alpha" => 100), "3" => array("R" => 46, "G" => 151, "B" => 224, "Alpha" => 100), "4" => array("R" => 176, "G" => 46, "B" => 224, "Alpha" => 100), "5" => array("R" => 224, "G" => 46, "B" => 117, "Alpha" => 100), "6" => array("R" => 92, "G" => 224, "B" => 46, "Alpha" => 100), "7" => array("R" => 224, "G" => 176, "B" => 46, "Alpha" => 100)); /* Draw the chart */ $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette)); /* Write the legend */ $myPicture->drawLegend(570, 215, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput(); $img = $myPicture->base64("output.png"); $this->view->src_bar = $img; $project_info = $this->loadModel('project')->getById($projectID); $this->view->project_info = $project_info; //今日完成 $where = "project = {$projectID} AND deleted = '0' AND status = 'done' AND DATE_FORMAT(finishedDate,'%Y-%m-%d') = '" . date('Y-m-d') . "'"; $tasks_done_today = $this->task->getTasksByCondition($where); $this->view->tasks_done_today = $tasks_done_today; //今日新增 $where = "project = {$projectID} AND deleted = '0' AND DATE_FORMAT(openedDate,'%Y-%m-%d') = '" . date('Y-m-d') . "'"; $tasks_opened_today = $this->task->getTasksByCondition($where); $this->view->tasks_opened_today = $tasks_opened_today; //未完成(迭代期) $where = "project = {$projectID} AND deleted = '0' AND (status = 'wait' OR status = 'doing')"; $tasks_un_finished = $this->task->getTasksByCondition($where); $this->view->tasks_un_finished = $tasks_un_finished; $this->display($this->moduleName, 'reportday'); }