} /* 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");
$myPicture->drawGradientArea(0, 0, 700, 220, DIRECTION_VERTICAL, $Settings); $Settings = array("StartR" => 1, "StartG" => 138, "StartB" => 68, "EndR" => 219, "EndG" => 231, "EndB" => 239, "Alpha" => 50); $myPicture->drawGradientArea(0, 222, 700, 350, DIRECTION_VERTICAL, $Settings); /* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 699, 349, 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, 650, 200); /* Draw the scale */ $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "LabelSkip" => 4, "GridR" => 220, "GridG" => 220, "GridB" => 220, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line of best fit */ $myPicture->drawBestFit(array("Ticks" => 4, "Alpha" => 50, "R" => 0, "G" => 0, "B" => 0)); /* Draw the line chart */ $myPicture->drawLineChart(); /* Draw the series derivative graph */ $myPicture->drawDerivative(array("ShadedSlopeBox" => TRUE, "CaptionLine" => TRUE)); /* Write the chart legend */ $myPicture->drawLegend(570, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Set the default font & shadow settings */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(150, 35, "Probability of heart disease", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE, "R" => 255, "G" => 255, "B" => 255)); /* Write a label over the chart */ $LabelSettings = array("DrawVerticalLine" => TRUE, "TitleMode" => LABEL_TITLE_BACKGROUND, "TitleR" => 255, "TitleG" => 255, "TitleB" => 255); $myPicture->writeLabel("Statistical probability", 35, $LabelSettings);