/* CAT:Bar 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->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);
protected function buildCostPieChartData() { $data = parent::buildCostPieChartData(); if (!$data) { return $data; } $this->setOption('title', $data['title']); $myData = new pData(); $y_series = $data['y']['series']; // building chart data for each vehicle foreach ($y_series as $key => $y) { $values = $this->filterNulls($y['values']); if (!$values) { continue; } $myData->addPoints($values, $y['id']); $myData->setSerieDescription($y['id'], $y['label']); $myData->setSerieDrawable($y['id'], false); // series will be activated in plotPieChart } $x = $data['x']; // adding labels $myData->addPoints($x['values'], $x['id']); $myData->setAbscissa($x['id']); return $myData; }
$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 generate_graph_image($outputfile) { // Create Graph Dataset and set axis attributes $graphData = new pData(); $graphData->setAxisName(0, $this->ytitle_actual); $graphData->addPoints($this->xlabels, "xaxis"); $graphData->setSerieDescription("xaxis", "xaxis"); $graphData->setAbscissa("xaxis"); $graphData->setXAxisName("ooo"); // Add each series of plot values to dataset, but Reportico will // duplicate series were the same data are displayed in different forms // so only add each unique series once $seriesadded = array(); foreach ($this->plot as $k => $v) { $series = $v["name"] . $k; $graphData->addPoints($v["data"], $series); $graphData->setSerieDescription($series, $v["legend"]); } /* $graph->xgrid->SetColor($this->xgridcolor); $graph->ygrid->SetColor($this->ygridcolor); */ /* switch ( $this->xgriddisplay ) { case "all": $graph->xgrid->Show(true,true); break; case "major": $graph->xgrid->Show(true,false); break; case "minor": $graph->xgrid->Show(false,true); break; case "none": default: $graph->xgrid->Show(false,false); break; } switch ( $this->ygriddisplay ) { case "all": $graph->ygrid->Show(true,true); break; case "major": $graph->ygrid->Show(true,false); break; case "minor": $graph->ygrid->Show(false,true); break; case "none": default: $graph->ygrid->Show(false,false); break; } */ /* $graph->xaxis->SetFont($fontfamilies[$xaxisfont],$fontstyles[$xaxisfontstyle], $xaxisfontsize); $graph->xaxis->SetColor($xaxiscolor,$xaxisfontcolor); $graph->yaxis->SetFont($fontfamilies[$yaxisfont],$fontstyles[$yaxisfontstyle], $yaxisfontsize); $graph->yaxis->SetColor($yaxiscolor,$yaxisfontcolor); $graph->xaxis->title->SetFont($fontfamilies[$xtitlefont],$fontstyles[$xtitlefontstyle], $xtitlefontsize); $graph->xaxis->title->SetColor($xtitlecolor); $graph->yaxis->title->SetFont($fontfamilies[$ytitlefont],$fontstyles[$ytitlefontstyle], $ytitlefontsize); $graph->yaxis->title->SetColor($ytitlecolor); $graph->xaxis->SetLabelAngle(90); $graph->xaxis->SetLabelMargin(15); $graph->yaxis->SetLabelMargin(15); $graph->xaxis->SetTickLabels($xlabels); $graph->xaxis->SetTextLabelInterval($xticklabint); $graph->yaxis->SetTextLabelInterval($yticklabint); $graph->xaxis->SetTextTickInterval($xtickinterval); $graph->yaxis->SetTextTickInterval($ytickinterval); */ /* if ( $gridpos == "front" ) $graph->SetGridDepth(DEPTH_FRONT); */ // Display the graph /*?$graph->Stroke();*/ $this->apply_defaults_internal(); //echo "oo<BR>"; //echo "<PRE>"; //var_dump($graphData); //echo $this->width."<BR>"; //echo $this->height_actual."<BR>"; $graphImage = new pImage($this->width_actual, $this->height_actual, $graphData); /* Turn of Antialiasing */ $graphImage->Antialias = TRUE; // Add gradient fill from chosen background color to white $startgradient = $this->htmltorgb("#ffffff"); $color = $this->htmltorgb($this->graphcolor); $graphImage->drawGradientArea(0, 0, $this->width_actual, $this->height_actual, DIRECTION_VERTICAL, array("StartR" => $startgradient[0], "StartG" => $startgradient[1], "StartB" => $startgradient[2], "EndR" => $color[0], "EndG" => $color[1], "EndB" => $color[2], "Alpha" => 100)); /* Add a border to the picture */ $graphImage->drawRectangle(0, 0, $this->width_actual - 1, $this->height_actual - 1, array("R" => 200, "G" => 200, "B" => 200)); /* Set the title font and draw it */ $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->titlefont, "FontSize" => $this->titlefontsize)); $this->titlecolor = $this->htmltorgb($this->titlecolor); $graphImage->drawText(20, 30, $this->title_actual, array("R" => $this->titlecolor[0], "G" => $this->titlecolor[1], "B" => $this->titlecolor[2])); /* Set the default font from the X title font */ $graphImage->setFontProperties(array("FontName" => PCHARTFONTS_DIR . $this->xtitlefont, "FontSize" => $this->xtitlefontsize)); /* Define the chart area */ $graphImage->setGraphArea($this->marginleft, $this->margintop, $this->width_actual - $this->marginright, $this->height_actual - $this->marginbottom); //$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE,"LabelRotation"=>30); //$graphImage->drawScale($scaleSettings); //$settings = array("Surrounding"=>-30,"InnerSurrounding"=>30); //$graphImage->drawBarChart($settings); //$graphImage->autoOutput("pictures/example.drawBarChart.simple.png"); //return; // Before plotting a series ensure they are all not drawable. /// Plot the chart data $stackeddrawn = false; $stackedexists = false; $barexists = false; foreach ($this->plot as $k => $v) { if ($v["type"] == "STACKEDBAR") { $stackedexists = true; } if ($v["type"] == "STACKEDBAR" || $v["type"] == "BAR") { $barexists = true; } } /* Draw the scale */ $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelRotation" => 30); // For stacked charts fix up the Max and Min values; if ($stackedexists) { $scaleMin = "Unknown"; $scaleMax = 0; foreach ($this->plot as $k => $v) { if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") { $series = $v["name"] . $k; $min = $graphData->getMin($series); if ($scaleMin == "Unknown" || $min < $scaleMin) { $scaleMin = $min; } $scaleMax = $scaleMax + $graphData->getMax($series); } } if ($scaleMin > 0) { $scaleMin = 0; } $range = $scaleMax - $scaleMin; // Make scales based on 5% of the range of values $scaleMax = round($range * 0.05 + $scaleMax); if ($scaleMin < 0) { $scaleMin = $scaleMin - round($range * 0.05); } $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax)); $scaleSettings["Mode"] = SCALE_MODE_MANUAL; $scaleSettings["ManualScale"] = $AxisBoundaries; } else { if ($barexists) { $scaleMin = "Unknown"; $scaleMax = 0; foreach ($this->plot as $k => $v) { if ($v["type"] == "BAR" || $v["type"] == "STACKEDBAR") { $series = $v["name"] . $k; $min = $graphData->getMin($series); if ($scaleMin == "Unknown" || $min < $scaleMin) { $scaleMin = $min; } $max = $graphData->getMax($series); if ($scaleMax == "Unknown" || $max > $scaleMax) { $scaleMax = $max; } } } if ($scaleMin > 0) { $scaleMin = 0; } $range = $scaleMax - $scaleMin; // Make scales based on 5% of the range of values $scaleMax = round($range * 0.05 + $scaleMax); if ($scaleMin < 0) { $scaleMin = $scaleMin - round($range * 0.05); } $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax)); $scaleSettings["Mode"] = SCALE_MODE_MANUAL; $scaleSettings["ManualScale"] = $AxisBoundaries; } } $graphImage->drawScale($scaleSettings); // If there's a Pie chart we want to draw different legends $piechart = false; foreach ($this->plot as $k => $v) { foreach ($this->plot as $k1 => $v1) { $series = $v1["name"] . $k1; $graphData->setSerieDrawable($series, FALSE); } $series = $v["name"] . $k; $graphData->setSerieDrawable($series, TRUE); switch ($v["type"]) { case "PIE": $piechart = true; $pie = new pPie($graphImage, $graphData); //$pie->draw2DPie($width_actual / 2,$height_actual / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE)); $pie->draw2DPie($width_actual / 2, $height_actual / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); break; case "PIE3D": $piechart = true; $pie = new pPie($graphImage, $graphData); $pie->draw3DPie($this->width_actual / 2, $this->height_actual / 2, 80, array("SecondPass" => FALSE)); break; case "STACKEDBAR": case "BAR": if ($stackeddrawn) { break; } if ($barexists) { foreach ($this->plot as $k1 => $v1) { if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR") { $graphData->setSerieDrawable($v1["name"] . $k1, TRUE); } } } $stackeddrawn = true; $settings = array("Surrounding" => -30, "InnerSurrounding" => 30); if ($stackedexists) { $graphImage->drawStackedBarChart($settings); } else { $graphImage->drawBarChart($settings); } break; case "LINE": default: if (count($v["data"]) == 1) { $v["data"][] = 0; } $graphImage->drawLineChart($settings); break; } } $graphData->drawAll(); if ($piechart) { $pie->drawPieLegend($this->width_actual - 100, 30, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); } else { $graphImage->drawLegend($this->width_actual - 180, 22, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_VERTICAL)); } $graphImage->setShadow(TRUE, array("X" => 0, "Y" => 0, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $graphImage->render($outputfile); return true; }
$myPicture->setGraphArea(28 + $font * 3, 11 + $font_t * 3, $width - 15 - $width_offset, $height - 23 - $font * 3); #$myPicture->setGraphArea(28+$font*3,3+$font_t*3,$width-15-$width_offset,$height-23-$font*3); /* Draw the scale */ $scaleMode = ($chartType == 'bar2' or $chartType == 'area2') ? SCALE_MODE_ADDALL_START0 : SCALE_MODE_START0; if ($labelSkip == -1) { $labelSkip = round($myData->getSerieCount($abscissa) / (($width - 15 - $width_offset) / 30)); } $scaleSettings = $scaleRGB + array("FLOATING" => TRUE, "DrawSubTicks" => TRUE, "Mode" => $scaleMode, "CycleBackground" => TRUE, "LabelRotation" => 30, "LabelSkip" => $labelSkip); if ($chartRotation == 1) { $scaleSettings = array("Pos" => SCALE_POS_TOPBOTTOM, "LabelRotation" => 0) + $scaleSettings; } $myPicture->drawScale($scaleSettings); // 隐藏副坐标轴数据 if (isset($arrSeriesY2)) { foreach ($arrSeriesY2 as $serie) { $myData->setSerieDrawable($serie, FALSE); } } $arrDisplayValues = array("DisplayValues" => FALSE); if ($plot == 2) { $arrDisplayValues["DisplayValues"] = TRUE; } /* 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 {
$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" => "../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" => 255, "GridG" => 255, "GridB" => 255, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); /* Write the chart legend */ $myPicture->drawLegend(540, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the area chart */ $MyData->setSerieDrawable("Probe 1", TRUE); $MyData->setSerieDrawable("Probe 2", FALSE); $myPicture->drawAreaChart(); /* Draw a line and a plot chart on top */ $MyData->setSerieDrawable("Probe 2", TRUE); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawLineChart(); $myPicture->drawPlotChart(array("PlotBorder" => TRUE, "PlotSize" => 3, "BorderSize" => 1, "Surrounding" => -60, "BorderAlpha" => 80)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.Combo.area.lines.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" => 100)); /* 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, "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(); /* Draw the line and plot chart */ $MyData->setSerieDrawable("Last year", TRUE); $MyData->setSerieDrawable("This year", FALSE); $myPicture->drawSplineChart(); $myPicture->drawPlotChart(); /* Make sure all series are drawable before writing the scale */ $MyData->drawAll(); /* Write the legend */ $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");
//rgb(69,43,135) /* Draw the scale */ $myPicture->setFontProperties(array("FontName" => "../pChart/fonts/verdana.ttf", "FontSize" => 8)); $myPicture->setGraphArea(50, 60, 670, 340); $myPicture->drawFilledRectangle(50, 60, 670, 340, array("R" => 255, "G" => 255, "B" => 255, "Surrounding" => -200, "Alpha" => 10)); $axisBoundaries = array(0 => array("Min" => 0, "Max" => $yaxis - 1)); $scaleSettings = array("GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawXLines" => FALSE, "MinDivHeight" => 50, "DrawSubTicks" => FALSE, "CycleBackground" => TRUE, "Mode" => SCALE_MODE_MANUAL, "ManualScale" => $axisBoundaries); $myPicture->drawScale($scaleSettings); /* Graph title */ //$myPicture->setFontProperties(array("FontName"=>"../pChart/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)); $Palette = array("0" => array("R" => 32, "G" => 74, "B" => 140, "Alpha" => 100), "1" => array("R" => 32, "G" => 74, "B" => 140, "Alpha" => 100), "2" => array("R" => 69, "G" => 43, "B" => 135, "Alpha" => 100), "3" => array("R" => 69, "G" => 43, "B" => 135, "Alpha" => 100)); /* Draw the bar chart chart */ $myPicture->setFontProperties(array("FontName" => "../pChart/fonts/verdana.ttf", "FontSize" => 10)); $data->setSerieDrawable("Last year", FALSE); $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "DisplayOrientation" => ORIENTATION_HORIZONTAL, "Surrounding" => 30, "OverrideColors" => $Palette, "DisplayColor" => DISPLAY_MANUAL, "DisplayR" => 255, "DisplayG" => 255, "DisplayB" => 255)); $myPicture->drawThresholdArea($result->Benchmark_Low, $result->Benchmark_High, array("R" => 177, "G" => 221, "B" => 207, "Alpha" => 40)); /* Make sure all series are drawable before writing the scale */ $data->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"); $myPicture->Stroke(); } else { $entries = $tc->getEntries(); $metrics = $tc->getScored(); $option_values = ''; foreach ($entries as $entry) {
<?php /* CAT:Scaling */ /* 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(8, 10, 24, 25, 25, 24, 23, 22, 20, 12, 10, 4), "Temperature"); $MyData->addPoints(array(2, 4, 6, 4, 5, 3, 6, 4, 5, 8, 6, 1), "Pressure"); $MyData->setSerieDrawable("Pressure", FALSE); $MyData->setAxisName(0, "Temperatures"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 390, $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, 390, $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, 390, 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, 389, 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)); /* Write the chart title */
include "pChart/class/pData.class.php"; include "pChart/class/pDraw.class.php"; include "pChart/class/pImage.class.php"; include "statistics_description_text.php"; $width = 760; $height = 500; $pChart = new pData(); $chart_tile_colours = array("0" => array("R" => 246, "G" => 113, "B" => 53, "Alpha" => 100), "1" => array("R" => 211, "G" => 60, "B" => 29, "Alpha" => 100), "2" => array("R" => 80, "G" => 94, "B" => 97, "Alpha" => 100), "3" => array("R" => 131, "G" => 137, "B" => 129, "Alpha" => 100), "4" => array("R" => 42, "G" => 43, "B" => 45, "Alpha" => 100), "5" => array("R" => 116, "G" => 82, "B" => 73, "Alpha" => 100), "6" => array("R" => 190, "G" => 93, "B" => 72, "Alpha" => 100), "7" => array("R" => 95, "G" => 83, "B" => 84, "Alpha" => 100), "8" => array("R" => 220, "G" => 220, "B" => 220, "Alpha" => 100)); for ($i = 0; $i < count($colours); $i++) { $pChart->addPoints(array($tile_colour_results[0][$i], $tile_colour_results[1][$i], $tile_colour_results[2][$i], $tile_colour_results[3][$i], $tile_colour_results[4][$i], $tile_colour_results[5][$i], $tile_colour_results[6][$i], $tile_colour_results[7][$i], $tile_colour_results[8][$i], $tile_colour_results[9][$i], $tile_colour_results[10][$i], $tile_colour_results[11][$i], $tile_colour_results[12][$i]), "Serie{$i}"); $pChart->setSerieDescription("Serie{$i}", $colours[$i][0]); $pChart->setSerieOnAxis("Serie{$i}", 0); $pChart->setPalette("Serie{$i}", $chart_tile_colours[$i]); } $pChart->addPoints(array(get_tile_total_count($tile_colour_results, 0), get_tile_total_count($tile_colour_results, 1), get_tile_total_count($tile_colour_results, 2), get_tile_total_count($tile_colour_results, 3), get_tile_total_count($tile_colour_results, 4), get_tile_total_count($tile_colour_results, 5), get_tile_total_count($tile_colour_results, 6), get_tile_total_count($tile_colour_results, 7), get_tile_total_count($tile_colour_results, 8), get_tile_total_count($tile_colour_results, 9), get_tile_total_count($tile_colour_results, 10), get_tile_total_count($tile_colour_results, 11), get_tile_total_count($tile_colour_results, 12)), "Serie10"); $pChart->setSerieDrawable("Serie10", FALSE); $pChart->setPalette("Serie10", array("Alpha" => 0)); $pChart->addPoints(array("Ormax", "Protector", "Polar", "Minster", "Turmalin", "Granat", "E13", "T11", "Nova", "Rubin", "Nortegl", "Hollander", "KDN"), "Absissa"); $pChart->setAbscissa("Absissa"); $pChart->setAxisPosition(0, AXIS_POSITION_LEFT); $pChart->setAxisName(0, "Laskentamäärät kpl"); $pChart->setAxisUnit(0, ""); $pChartPicture = new pImage($width, $height, $pChart); $Settings = array("R" => 255, "G" => 255, "B" => 255); $pChartPicture->drawFilledRectangle(0, 0, $width, $height, $Settings); $pChartPicture->setFontProperties(array("FontName" => "pChart/fonts/arial.ttf", "FontSize" => 14)); $TextSettings = array("Align" => TEXT_ALIGN_BOTTOMMIDDLE, "R" => 0, "G" => 0, "B" => 0); $pChartPicture->drawText($width / 2, 25, ucfirst($table) . " - Tiilet / Värit", $TextSettings); $description .= GetYearsDescription($years); $description .= " - (" . GetSeriesTotalSum($pChart, "Half") . "kpl)"; if (strlen($description) > 120) {
/* Add a border to the picture */ $myPicture->drawRectangle(0, 0, 65 * $nbr_room + 64, 329, array("R" => 0, "G" => 0, "B" => 0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Silkscreen.ttf", "FontSize" => 6, "R" => 255, "G" => 255, "B" => 255)); $myPicture->drawText(10, 13, "Consomation moyenne des baies avec objectif a 3,5 kW", array("R" => 255, "G" => 255, "B" => 255)); /* Define the default font */ $myPicture->setFontProperties(array("FontName" => "pChart/fonts/verdana.ttf", "FontSize" => 10)); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20)); /* Set the graph area */ $myPicture->setGraphArea(50, 40, 65 * $nbr_room + 35, 290); $myPicture->drawGradientArea(50, 40, 65 * $nbr_room + 35, 290, DIRECTION_VERTICAL, array("StartR" => 200, "StartG" => 200, "StartB" => 200, "EndR" => 255, "EndG" => 255, "EndB" => 255, "Alpha" => 30)); /* Draw the chart scale */ $scaleSettings = array("AxisAlpha" => 10, "TickAlpha" => 10, "DrawXLines" => FALSE, "Mode" => SCALE_MODE_START0, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10); $myPicture->drawScale($scaleSettings); /* Draw the chart */ $MyData->setSerieDrawable("Objectif", FALSE); $myPicture->drawBarChart(array("DisplayValues" => TRUE, "DisplayPos" => LABEL_POS_INSIDE, "Surrounding" => 30)); $MyData->setSerieDrawable("Objectif", TRUE); $MyData->setSerieDrawable("Consomation moyenne des baies (kW)", FALSE); $MyData->setSerieDrawable("Salles", FALSE); $serieSettings = array("R" => 229, "G" => 11, "B" => 11); $MyData->setPalette("Objectif", $serieSettings); $myPicture->setShadow(TRUE, array("X" => 2, "Y" => 2, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); $myPicture->drawSplineChart(); if ($consult_date != "Donnée actuelle") { $myPicture->Render("images/consoe_graph_render_{$consult_date}.png"); } else { $myPicture->Render("images/consoe_graph_render.png"); } } else { $error = 1;
$scaleMax = round($range * 0.05 + $scaleMax); if ($scaleMin < 0) { $scaleMin = $scaleMin - round($range * 0.05); } $AxisBoundaries = array(0 => array("Min" => $scaleMin, "Max" => $scaleMax)); $scaleSettings["Mode"] = SCALE_MODE_MANUAL; $scaleSettings["ManualScale"] = $AxisBoundaries; } } $graphImage->drawScale($scaleSettings); // If there's a Pie chart we want to draw different legends $piechart = false; foreach ($plot as $k => $v) { foreach ($plot as $k1 => $v1) { $series = $v1["name"] . $k1; $graphData->setSerieDrawable($series, FALSE); } $series = $v["name"] . $k; $graphData->setSerieDrawable($series, TRUE); switch ($v["type"]) { case "PIE": $piechart = true; $pie = new pPie($graphImage, $graphData); //$pie->draw2DPie($width / 2,$height / 2,80,array("DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE)); $pie->draw2DPie($width / 2, $height / 2, 80, array("WriteValues" => PIE_VALUE_PERCENTAGE, "DataGapAngle" => 10, "DataGapRadius" => 6, "Border" => TRUE, "BorderR" => 255, "BorderG" => 255, "BorderB" => 255)); break; case "PIE3D": $piechart = true; $pie = new pPie($graphImage, $graphData); $pie->draw3DPie($width / 2, $height / 2, 80, array("SecondPass" => FALSE)); break;
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; }
$MyData->addPoints($data["times"], "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); $myPicture = new pImage(1400, 460, $MyData); $myPicture->Antialias = FALSE; $myPicture->setFontProperties(array("FontName" => "pChart/fonts/Forgotte.ttf", "FontSize" => 8, "R" => 0, "G" => 0, "B" => 0)); $myPicture->drawText(15, 22, "HAL10K by intrd", array("FontSize" => 15, "Align" => TEXT_ALIGN_BOTTOMLEFT)); //$myPicture->drawText(15,22,"HAL10K by intrd",array("FontSize"=>15,"Align"=>TEXT_ALIGN_BOTTOMLEFT)); $myPicture->drawText(450, 20, "Período: " . $startdate . " - " . $enddate . "", array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT)); $myPicture->drawText(651, 23, $nextmov, array("FontSize" => 13, "Align" => TEXT_ALIGN_BOTTOMLEFT)); $myPicture->setFontProperties(array("FontName" => "pChart/fonts/pf_arma_five.ttf", "FontSize" => 10, "R" => 0, "G" => 0, "B" => 0)); $myPicture->setGraphArea(20 * 2, 20, 650 * 2, 200 * 2); $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 500, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE); $myPicture->drawScale($scaleSettings); $myPicture->Antialias = TRUE; $MyData->setSerieDrawable("BTC/USD", TRUE); $MyData->setSerieDrawable("EMAshort", TRUE); $MyData->setSerieDrawable("EMAlong", TRUE); $MyData->setSerieDrawable("Buy", FALSE); $MyData->setSerieDrawable("Sell", FALSE); $myPicture->drawLineChart(array("DisplayValues" => FALSE)); $MyData->setSerieDrawable("BTC/USD", FALSE); $MyData->setSerieDrawable("EMAshort", FALSE); $MyData->setSerieDrawable("EMAlong", FALSE); $MyData->setSerieDrawable("Buy", TRUE); $MyData->setSerieDrawable("Sell", TRUE); $myPicture->drawPlotChart(array("DisplayValues" => TRUE, "PlotBorder" => FALSE, "BorderSize" => 2, "Surrounding" => -60, "BorderAlpha" => 80)); $MyData->setSerieDrawable("BTC/USD", TRUE); $MyData->setSerieDrawable("EMAshort", TRUE); $MyData->setSerieDrawable("EMAlong", TRUE); $MyData->setSerieDrawable("Buy", TRUE);