$MyData->addPoints(array(6, 10, 14, 10, 14, 6), "Probe2Weight");
$MyData->setSerieDescription("Probe1", "This year");
$MyData->setSerieDescription("Probe2", "Last year");
$MyData->setAxisName(0, "Current stock");
$MyData->addPoints(array("Apple", "Banana", "Orange", "Lemon", "Peach", "Strawberry"), "Product");
$MyData->setAbscissa("Product");
/* 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 Bubble chart object and scale up */
$myPicture->Antialias = TRUE;
$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 bubble chart */
$myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries);
/* Write the chart legend */
$myPicture->drawLegend(570, 13, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBubbleChart.simple.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, "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));
/* 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, "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);
/* Write a label over the chart */
$LabelSettings = array("TitleMode" => LABEL_TITLE_BACKGROUND, "VerticalMargin" => 4, "HorizontalMargin" => 6, "DrawSerieColor" => FALSE, "TitleR" => 255, "TitleG" => 255, "TitleB" => 255);
$myBubbleChart->writeBubbleLabel("Probe1", "Probe1Weight", 3, $LabelSettings);
$myBubbleChart->writeBubbleLabel("Probe2", "Probe2Weight", 4, $LabelSettings);
/* Draw the 2nd scale */
$MyData->setSerieDescription("Probe1", "This year");
$MyData->setSerieDescription("Probe2", "Last year");
$MyData->setAxisName(0, "Current stock");
$MyData->addPoints(array("Apple", "Banana", "Orange", "Lemon", "Peach", "Strawberry"), "Product");
$MyData->setAbscissa("Product");
$MyData->setAbscissaName("Selected Products");
/* 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 Bubble chart object and scale up */
$myPicture->Antialias = TRUE;
$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 bubble chart */
$myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries, array("ForceAlpha" => 50));
/* Write the chart legend */
$myPicture->drawLegend(570, 13, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBubbleChart.simple.png");
$MyData->setSerieDescription("Probe1", "This year");
$MyData->setSerieDescription("Probe2", "Last year");
$MyData->setAxisName(0, "Current stock");
$MyData->addPoints(array("Apple", "Banana", "Orange", "Lemon", "Peach", "Strawberry"), "Product");
$MyData->setAbscissa("Product");
$MyData->setAbscissaName("Selected Products");
/* 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 Bubble chart object and scale up */
$myPicture->Antialias = TRUE;
$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 bubble chart */
$myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries, array("Shape" => BUBBLE_SHAPE_SQUARE, "ForceAlpha" => 50, "BorderWidth" => 4, "BorderAlpha" => 20, "Surrounding" => 20));
/* Write the chart legend */
$myPicture->drawLegend(570, 13, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBubbleChart.square.png");
$MyData->setSerieDescription("Probe1", "This year");
$MyData->setSerieDescription("Probe2", "Last year");
$MyData->setAxisName(0, "Current stock");
$MyData->addPoints(array("Apple", "Banana", "Orange", "Lemon", "Peach", "Strawberry"), "Product");
$MyData->setAbscissa("Product");
$MyData->setAbscissaName("Selected Products");
/* 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 Bubble chart object and scale up */
$myPicture->Antialias = TRUE;
$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 bubble chart */
$myBubbleChart->drawBubbleChart($bubbleDataSeries, $bubbleWeightSeries, array("BorderWidth" => 4, "BorderAlpha" => 50, "Surrounding" => 20));
/* Write the chart legend */
$myPicture->drawLegend(570, 13, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->autoOutput("pictures/example.drawBubbleChart.simple.png");
Example #7
0
 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;
 }