$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 { 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)); } } } } // 隐藏主坐标轴数据,画副坐标轴数据
/* CAT:Stacked 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->addPoints(array(4, 1, 0, 12, 8, 4, 0, 12, 8), "Frontend #1"); $MyData->addPoints(array(3, 12, 15, 8, VOID, VOID, 12, 15, 8), "Frontend #2"); $MyData->addPoints(array(4, 4, 4, 4, 4, 4, 4, 4, 4), "Frontend #3"); $MyData->setAxisName(0, "Average Usage"); $MyData->addPoints(array("January", "February", "March", "April", "May", "June", "July", "August", "September"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 680, 190); $myPicture->drawScale(array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL_START0)); $myPicture->drawStackedAreaChart(array("DrawPlot" => TRUE, "DrawLine" => TRUE, "LineSurrounding" => -20)); /* Turn on shadow processing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Write the chart legend */ $myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStackedAreaChart.simple.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(); }
public function createCharts($lenght, $width = 1000, $height = 400, $statisticsUncategorized, $params, $options) { //print_r($params); //print_r($options); $year = date('Y'); $month = date('m'); $y = date('Y', strtotime('-' . ($lenght - 1) . ' month')); $m = date('m', strtotime('-' . ($lenght - 1) . ' month')); $user = Zend_Registry::get('User'); $invoicesDb = new Sales_Model_DbTable_Invoice(); $creditnotesDb = new Sales_Model_DbTable_Creditnote(); $turnover = array(); $turnoverCategories = array(); while ($y <= $year) { while ($m) { if ($y < $year || $m <= $month) { //Get invoices $ym = str_pad($m, 2, '0', STR_PAD_LEFT); $query = 'i.state = 105'; $query .= " AND (invoicedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')"; $query .= ' AND i.clientid = ' . $user['clientid']; $query .= ' AND c.clientid = ' . $user['clientid']; if ($params['catid']) { $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c'); } if ($params['country']) { $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i'); } $invoices = $invoicesDb->fetchAll($invoicesDb->select()->from(array('i' => 'invoice'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false)); //Get credit notes $ym = str_pad($m, 2, '0', STR_PAD_LEFT); $query = 'i.state = 105'; $query .= " AND (creditnotedate BETWEEN '" . $y . "-" . $ym . "-" . "01' AND '" . $y . "-" . $ym . "-" . "31')"; $query .= ' AND i.clientid = ' . $user['clientid']; $query .= ' AND c.clientid = ' . $user['clientid']; if ($params['catid']) { $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCategory($query, $params['catid'], $options['categories'], 'c'); } if ($params['country']) { $query = Zend_Controller_Action_HelperBroker::getStaticHelper('Query')->getQueryCountry($query, $params['country'], 'i'); } $creditnotes = $creditnotesDb->fetchAll($creditnotesDb->select()->from(array('i' => 'creditnote'))->join(array('c' => 'contact'), 'i.contactid = c.id', array('catid'))->where($query ? $query : 1)->setIntegrityCheck(false)); $turnover[$y . $ym] = 0; $turnoverCategories[0][$y . $ym] = 0; //Calculate invoices foreach ($invoices as $invoice) { $turnover[$y . $ym] += $invoice->subtotal; if (isset($turnoverCategories[$invoice->catid][$y . $ym])) { $turnoverCategories[$invoice->catid][$y . $ym] += $invoice->subtotal; } else { $turnoverCategories[$invoice->catid][$y . $ym] = $invoice->subtotal; } } //Calculate credit notes foreach ($creditnotes as $creditnote) { $turnover[$y . $ym] -= $creditnote->subtotal; if (isset($turnoverCategories[$creditnote->catid][$y . $ym])) { $turnoverCategories[$creditnote->catid][$y . $ym] += $creditnote->subtotal; } else { $turnoverCategories[$creditnote->catid][$y . $ym] = $creditnote->subtotal; } } //Calculate categories foreach ($options['categories'] as $id => $category) { if (isset($turnoverCategories[$id][$y . $ym])) { $turnoverCategories[$id][$y . $ym] = round($turnoverCategories[$id][$y . $ym]); } else { $turnoverCategories[$id][$y . $ym] = 0; } } $turnover[$y . $ym] = round($turnover[$y . $ym]); $turnoverCategories[0][$y . $ym] = round($turnoverCategories[0][$y . $ym]); $dataDb = 'total:' . $turnover[$y . $ym] . ';'; foreach ($turnoverCategories as $key => $value) { if (isset($value[$y . $ym])) { $dataDb .= $key . ':' . $value[$y . $ym] . ';'; } } //$archiveDb->addArchive($y.$ym, $dataDb, $user['clientid']); $months[$y . $ym] = $y . '/' . $ym; } ++$m; if ($m > 12) { $m = 0; } } ++$y; $m = 1; } //Merge subcategories to main categories foreach ($turnoverCategories as $id => $values) { if (isset($options['categories'][$id]['childs']) && $id != $params['catid']) { foreach ($options['categories'][$id]['childs'] as $childId) { foreach ($values as $month => $value) { $turnoverCategories[$id][$month] += $turnoverCategories[$childId][$month]; } unset($turnoverCategories[$childId]); } } } //Remove empty arrays foreach ($turnoverCategories as $key => $values) { if (!array_sum($values)) { unset($turnoverCategories[$key]); } } require_once BASE_PATH . '/library/pChart/class/pData.class.php'; require_once BASE_PATH . '/library/pChart/class/pDraw.class.php'; require_once BASE_PATH . '/library/pChart/class/pImage.class.php'; //Turnover /* Create your dataset object */ $turnoverData = new pData(); /* Add data in your dataset */ $turnoverData->addPoints($turnover, 'Values'); $turnoverData->setAxisName(0, '€ / Netto'); /* Create the X serie */ $turnoverData->addPoints($months, 'Labels'); $turnoverData->setSerieDescription('Labels', 'Months'); $turnoverData->setAbscissa('Labels'); /* Create a pChart object and associate your dataset */ $turnover = new pImage($width, $height, $turnoverData); /* Turn off AA processing */ $turnover->Antialias = FALSE; /* Choose a nice font */ $turnover->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10)); /* Define the boundaries of the graph area */ $turnover->setGraphArea(75, 20, $width - 30, $height - 60); /* Draw the scale, keep everything automatic */ $turnover->drawScale(array('DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_START0, 'LabelRotation' => 45)); /* Draw the scale, keep everything automatic */ $settings = array('Gradient' => TRUE, 'GradientMode' => GRADIENT_EFFECT_CAN, 'DisplayPos' => LABEL_POS_INSIDE, 'DisplayValues' => TRUE, 'DisplayR' => 0, 'DisplayG' => 0, 'DisplayB' => 0, 'DisplayShadow' => TRUE, 'Surrounding' => 10); $turnover->drawBarChart($settings); /* Build the PNG file and send it to the web browser */ if (!file_exists(BASE_PATH . '/cache/chart/')) { mkdir(BASE_PATH . '/cache/chart/'); chmod(BASE_PATH . '/cache/chart/', 0777); } $turnover->Render(BASE_PATH . '/cache/chart/turnover-' . $width . '-' . $height . '.png'); //Turnover by categories /* Create your dataset object */ $turnoverCategoriesData = new pData(); /* Add data in your dataset */ $turnoverCategoriesTotal = array(); foreach ($turnoverCategories as $key => $value) { $turnoverCategoriesTotal[$key] = array_sum($value); } arsort($turnoverCategoriesTotal); foreach ($turnoverCategoriesTotal as $key => $value) { if ($key && isset($options['categories'][$key])) { $turnoverCategoriesData->addPoints($turnoverCategories[$key], $options['categories'][$key]['title']); } } if (isset($turnoverCategories[0])) { $turnoverCategoriesData->addPoints($turnoverCategories[0], $statisticsUncategorized); } $turnoverCategoriesData->setAxisName(0, '€ / Netto'); /* Create the X serie */ $turnoverCategoriesData->addPoints($months, 'Labels'); $turnoverCategoriesData->setSerieDescription('Labels', 'Months'); $turnoverCategoriesData->setAbscissa('Labels'); /* Create a pChart object and associate your dataset */ $turnoverCategories = new pImage($width, $height, $turnoverCategoriesData); /* Turn off AA processing */ $turnoverCategories->Antialias = FALSE; /* Choose a nice font */ $turnoverCategories->setFontProperties(array('FontName' => BASE_PATH . '/library/pChart/fonts/verdana.ttf', 'FontSize' => 10)); /* Define the boundaries of the graph area */ $turnoverCategories->setGraphArea(75, 20, $width - 30, $height - 60); /* Draw the scale, keep everything automatic */ $turnoverCategories->drawScale(array('XMargin' => 2, 'DrawSubTicks' => TRUE, 'Mode' => SCALE_MODE_ADDALL_START0, 'LabelRotation' => 45)); /* Draw the scale, keep everything automatic */ $settings = array(); $turnoverCategories->drawStackedAreaChart($settings); /* Write the chart legend */ $turnoverCategories->drawLegend(100, 20, array('Style' => LEGEND_NOBORDER, 'Mode' => LEGEND_VERTICAL)); /* Build the PNG file and send it to the web browser */ $turnoverCategories->Render(BASE_PATH . '/cache/chart/turnover-category-' . $width . '-' . $height . '.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" => 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, "drawStackedAreaChart() - draw a stacked area 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, "Mode" => SCALE_MODE_ADDALL)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setShadow(FALSE); $myPicture->drawStackedAreaChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "DrawPlot" => TRUE, "DrawLine" => TRUE, "LineSurrounding" => -250)); /* Draw one static threshold */ $myPicture->drawThreshold(0, array("Alpha" => 70, "Ticks" => 1, "NoMargin" => TRUE)); /* 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, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => TRUE)); $myPicture->setShadow(FALSE); $myPicture->drawStackedAreaChart(array("Surrounding" => 10)); /* Draw one static threshold */ $myPicture->drawThreshold(0, array("Alpha" => 70, "Ticks" => 1, "NoMargin" => TRUE)); /* 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.drawStackedAreaChart.png");
/* 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(4, 0, 0, 12, 8, 3, 0, 12, 8), "Frontend #1"); $MyData->addPoints(array(3, 12, 15, 8, 5, 5, 12, 15, 8), "Frontend #2"); $MyData->addPoints(array(2, 7, 5, 18, 19, 22, 7, 5, 18), "Frontend #3"); $MyData->setAxisName(0, "Average Usage"); $MyData->addPoints(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jui", "Aug", "Sep"), "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Normalize the data series to 100% */ $MyData->normalize(100, "%"); /* Create the pChart object */ $myPicture = new pImage(700, 230, $MyData); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_VERTICAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 100)); $myPicture->drawGradientArea(0, 0, 700, 230, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 20)); /* Set the default font properties */ $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); /* Draw the scale and the chart */ $myPicture->setGraphArea(60, 20, 680, 190); $myPicture->drawScale(array("XMargin" => 2, "DrawSubTicks" => TRUE, "Mode" => SCALE_MODE_ADDALL)); $myPicture->drawStackedAreaChart(array("Surrounding" => 60)); /* Turn on shadow processing */ $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Write the chart legend */ $myPicture->drawLegend(480, 210, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ $myPicture->autoOutput("pictures/example.drawStackedAreaChart.normalized.png");
if ($Mode == "Render") { $myPicture->drawStackedBarChart($Config); } else { echo dumpArray("Config", $Config); echo '$myPicture->drawStackedBarChart($Config);' . "\r\n"; } } if ($c_family == "sarea") { if ($c_forced_transparency == "true") { $Config["ForceTransparency"] = $c_transparency; } if ($c_around_zero2 == "true") { $Config["AroundZero"] = TRUE; } if ($Mode == "Render") { $myPicture->drawStackedAreaChart($Config); } else { echo dumpArray("Config", $Config); echo '$myPicture->drawStackedAreaChart($Config);' . "\r\n"; } } if ($t_enabled == "true") { list($R, $G, $B) = extractColors($t_color); $Config = ""; $Config["R"] = $R; $Config["G"] = $G; $Config["B"] = $B; $Config["Alpha"] = $t_alpha; if (isset($myData->Data["Axis"][$t_axis])) { $Config["AxisID"] = $t_axis; }
$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 picture title */ $myPicture->setFontProperties(array("FontName" => "../fonts/Silkscreen.ttf", "FontSize" => 6)); $myPicture->drawText(10, 13, "drawStackedAreaChart() - draw a stacked area 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, "Mode" => SCALE_MODE_ADDALL)); $myPicture->setFontProperties(array("FontName" => "../fonts/pf_arma_five.ttf", "FontSize" => 6)); $myPicture->setShadow(FALSE); $myPicture->drawStackedAreaChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO, "Surrounding" => 20)); /* 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, "Mode" => SCALE_MODE_ADDALL, "DrawSubTicks" => TRUE)); $myPicture->setShadow(FALSE); $myPicture->drawStackedAreaChart(array("Surrounding" => 10)); /* 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.drawStackedAreaChart.png");
private function drawOverAllImage($date) { $res1 = $this->dataForGraph($date, 0); $res2 = $this->dataForGraph($date, 1); $MyData = new pData(); $MyData->addPoints($res1['percents'], "Load in % for server 1"); $MyData->addPoints($res2['percents'], "Load in % for server 2"); $MyData->setAxisName(0, "Participants"); $MyData->addPoints($res1['times'], "Labels"); // $MyData->addPoints($res2['times'], "Labels"); $MyData->setSerieDescription("Labels", "Months"); $MyData->setAbscissa("Labels"); /* Create the pChart object */ $myPicture = new pImage(1200, 560, $MyData); /* Turn of Antialiasing */ $myPicture->Antialias = TRUE; /* Add a border to the picture */ //$myPicture->drawRectangle(0,0,890,290,array("R"=>0,"G"=>0,"B"=>0)); /* Write the chart title */ $myPicture->setFontProperties(array("FontName" => CORE_REPOSITORY_REAL_PATH . "class/pChart/fonts/Forgotte.ttf", "FontSize" => 11)); $myPicture->drawText(200, 35, "All Servers Resource Usage (" . $date . ")", array("FontSize" => 20, "Align" => TEXT_ALIGN_BOTTOMMIDDLE)); /* Set the default font */ $myPicture->setFontProperties(array("FontName" => CORE_REPOSITORY_REAL_PATH . "class/pChart/fonts/pf_arma_five.ttf", "FontSize" => 8)); /* Define the chart area */ $myPicture->setGraphArea(60, 40, 1100, 500); $AxisBoundaries = array(0 => array("Min" => 0, "Max" => 100)); /* Draw the scale */ $scaleSettings = array("XMargin" => 10, "YMargin" => 10, "Floating" => TRUE, "GridR" => 200, "GridG" => 200, "GridB" => 200, "DrawSubTicks" => TRUE, "CycleBackground" => TRUE, "LabelSkip" => 1, 'Mode' => SCALE_MODE_MANUAL, "ManualScale" => $AxisBoundaries); $myPicture->drawScale($scaleSettings); $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10)); /* Draw the stacked area chart */ $myPicture->drawStackedAreaChart(array("DrawLine" => TRUE, "LineSurrounding" => -20)); /* Turn on Antialiasing */ $myPicture->Antialias = TRUE; /* Draw the line chart */ $myPicture->drawLineChart(); /* Write the chart legend */ $myPicture->drawLegend(800, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL)); /* Render the picture (choose the best way) */ //$myPicture->autoOutput(App::$instance->opt->fizPath."class/pChart/pictures/example.drawLineChart.simple.png"); $myPicture->render(CORE_REPOSITORY_REAL_PATH . "class/pChart/pictures/load_at_" . $date . "_on_overall.png"); $path = CORE_REPOSITORY_HTTP_PATH . "class/pChart/pictures/load_at_" . $date . "_on_overall.png"; if (ST::isAjaxRequest()) { $data = []; print json_encode($data['path'] = $path); } else { return $path; } }