/* 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, "drawBubbleChart() - draw a linear bubble chart", array("R" => 255, "G" => 255, "B" => 255)); /* Write the title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(40, 55, "Current Stock / Needs chart", array("FontSize" => 14, "Align" => TEXT_ALIGN_BOTTOMLEFT)); /* Change the default font */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Create the Bubble chart object and scale up */ $myBubbleChart = new pBubble($myPicture, $MyData); /* Scale up for the bubble chart */ $bubbleDataSeries = array("Probe1", "Probe2"); $bubbleWeightSeries = array("Probe1Weight", "Probe2Weight"); $myBubbleChart->bubbleScale($bubbleDataSeries, $bubbleWeightSeries); /* Draw the 1st chart */ $myPicture->setGraphArea(40, 60, 430, 190); $myPicture->drawFilledRectangle(40, 60, 430, 190, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -50, "Alpha" => 10)); $myPicture->drawScale(array("DrawSubTicks" => TRUE, "CycleBackground" => TRUE)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30)); $myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries); /* Draw the 2nd scale */ $myPicture->setShadow(FALSE); $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 the 2nd stock chart */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 30)); $myBubbleChart->drawbubbleChart($bubbleDataSeries, $bubbleWeightSeries, array("DrawBorder" => TRUE, "Surrounding" => 60, "BorderAlpha" => 100)); /* Write the chart legend */
static function makeChartArticle($type, $data, $events, $colors, $lang = "en") { global $wt, $I18N; $font = PCHART_FONTS_PATH . "/LiberationSans-Regular.ttf"; if (in_array($wt->uselang, array("zh", "ja", "jp", "ko"))) { $font = PCHART_FONTS_PATH . "/wqy-microhei.ttf"; } if (in_array($wt->uselang, array("he", "bn", "vi", "fa", "ar", "th", "ta", "ka", "hi", "hy", "ml"))) { $font = PCHART_FONTS_PATH . "/unifont.ttf"; } $maxsizeTotal = 0; $maxeditTotal = 0; $u = 0; foreach ($data as $year => $values) { $years[] = $year; $all[] = $values["all"]; $minor[] = $values["minor"]; $anon[] = $values["anon"]; $maxsize = 0; //get the max size of each month foreach ($values["months"] as $i => $mdetails) { if ($mdetails["size"] > $maxsize) { $maxsize = $mdetails["size"]; } } $tmpssize[] = $maxsize ? $maxsize : $tmpssize[$u - 1]; $linemarker[] = 1; $eventmarker[] = isset($events[$year]["protect"]) ? 10 + $events[$year]["protect"] * 3 : 0; $u++; } $msgAll = $I18N->msg('all'); $msgMinor = $I18N->msg('minor'); $msgPagesize = $I18N->msg('pagesize'); $MyData = new pData(); $MyData->addPoints($all, "all"); $MyData->addPoints($minor, "minor"); $MyData->addPoints($anon, "anon"); $MyData->addPoints($tmpssize, "size"); $MyData->addPoints($eventmarker, "protect"); $MyData->setSerieOnAxis("all", 0); $MyData->setSerieOnAxis("minor", 0); $MyData->setSerieOnAxis("anon", 0); $MyData->setSerieOnAxis("size", 1); $MyData->setSerieOnAxis("protect", 1); $MyData->setAxisPosition(1, AXIS_POSITION_RIGHT); $MyData->setAxisName(0, "Edits"); $MyData->setAxisName(1, "Size (kb)"); $MyData->Data["Series"]["all"]["Color"] = self::hex2rgb($colors["all"], 200, true); $MyData->Data["Series"]["minor"]["Color"] = self::hex2rgb($colors["minor"], 200, true); $MyData->Data["Series"]["anon"]["Color"] = self::hex2rgb($colors["anon"], 200, true); $MyData->Data["Series"]["size"]["Color"] = self::hex2rgb($colors["size"], 200, true); $MyData->Data["Series"]["protect"]["Color"] = self::hex2rgb($colors["protect"], 200, true); $MyData->addPoints($years, "Labels"); $MyData->setAbscissa("Labels"); $myPicture = new pImage(1000, 300, $MyData, TRUE); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => 12, "R" => 34, "G" => 34, "B" => 34)); $myPicture->setGraphArea(50, 30, 820, 270); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => 8)); $scaleSettings = array("AxisR" => 134, "AxisG" => 134, "AxisB" => 134, "AxisAplha" => 40, "DrawSubTicks" => TRUE, "CycleBackground" => false, "LabelRotation" => 0, "LabelSkip" => 0, "Mode" => SCALE_MODE_START0); $myPicture->drawScale($scaleSettings); $settings = array("Surrounding" => -30, "InnerSurrounding" => 10, "RecordImageMap" => false, "DisplayValues" => false); $MyData->setSerieDrawable('size', false); $MyData->setSerieDrawable('protect', false); $myPicture->drawBarChart($settings); $MyData->setSerieDrawable('size', true); $MyData->setSerieDrawable('all', false); $MyData->setSerieDrawable('minor', false); $MyData->setSerieDrawable('anon', false); $MyData->setSerieDrawable('protect', false); $myPicture->drawLineChart(); $MyData->setSerieDrawable('protect', true); $MyData->setSerieDrawable('size', true); $myBubbleChart = new pBubble($myPicture, $MyData); $bubbleDataSeries = array("size"); $bubbleWeightSeries = array("protect"); $myBubbleChart->bubbleScale($bubbleDataSeries, $bubbleWeightSeries); $myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries, array("ForceAlpha" => true)); $myPicture->setFontProperties(array("FontName" => $font, "FontSize" => 11, "R" => 34, "G" => 34, "B" => 34)); $MyData->setSerieDrawable('size', true); $MyData->setSerieDrawable('all', true); $MyData->setSerieDrawable('minor', true); $MyData->setSerieDrawable('anon', true); $MyData->setSerieDrawable('protect', true); $myPicture->drawLegend(900, 55, array("Style" => LEGEND_NOBORDER, "BoxWidth" => 10, "BoxHeight" => 10, "Mode" => LEGEND_VERTICAL)); ob_start(); imagepng($myPicture->Picture); $imgdata = ob_get_contents(); ob_end_clean(); $rimg = "data:image/png;base64," . base64_encode($imgdata); return $rimg; }