$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1"); $DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2"); $DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie3"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetSerieName("January", "Serie1"); $DataSet->SetSerieName("February", "Serie2"); $DataSet->SetYAxisName("Temperature"); $DataSet->SetYAxisUnit("°C"); $DataSet->SetXAxisUnit("h"); // Initialise the graph $Test = new pChart(700, 230); $Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND); $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->setGraphArea(120, 20, 675, 190); $Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE); $Test->drawGraphAreaGradient(163, 203, 167, 50); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); // Draw the bar chart $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); // Draw the title $Title = " Average Temperatures during\r\n the first months of 2008 "; $Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30); // Draw the legend $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82); // Render the picture $Test->addBorder(2); $Test->Render("example23.png");
$Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 213, 217, 221, TRUE, 0, 2, TRUE); $Test->drawGraphAreaGradient(40, 40, 40, -50); $Test->drawGrid(4, TRUE, 230, 230, 230, 5); // Draw the title $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Title = " Average growth size for selected\r\n DNA samples "; $Test->setLineStyle(2); $Test->drawLine(51, -2, 51, 402, 0, 0, 0); $Test->setLineStyle(1); $Test->drawTextBox(0, 0, 50, 400, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30); $Test->setFontProperties("Fonts/pf_arma_five.ttf", 6); // Draw the bar graph $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); // Second chart $DataSet->SetXAxisName(""); $Test->clearScale(); $Test->setGraphArea(110, 20, 350, 140); $Test->drawGraphArea(213, 217, 221, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 213, 217, 221, TRUE, 0, 2); $Test->drawGraphAreaGradient(40, 40, 40, -50); $Test->drawGrid(4, TRUE, 230, 230, 230, 5); // Draw the line chart $Test->setShadowProperties(0, 3, 0, 0, 0, 30, 4); $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 40); $Test->clearShadow(); // Write the legend $Test->drawLegend(-2, 3, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 255, 255, 255, FALSE); // Finish the graph $Test->addBorder(1); $Test->Render("HomePage2.png");
function createChart(&$info, &$cfg) { $backgndColor = array('R' => 255, 'G' => 255, 'B' => 254); $chartCfg = new stdClass(); $chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600; $chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50; $chartCfg->border = new stdClass(); $chartCfg->border->width = 1; $chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0); $chartCfg->graphArea = new stdClass(); $chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221); $chartCfg->graphArea->beginX = property_exists($cfg, 'beginX') ? $cfg->beginX : 40; $chartCfg->graphArea->beginY = property_exists($cfg, 'beginY') ? $cfg->beginY : 100; $chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX; $chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY; $chartCfg->scale = new stdClass(); // 20100914 - franciscom // After reading documentation // drawScale // Today there is four way of computing scales : // // - Getting Max & Min values per serie : ScaleMode = SCALE_NORMAL // - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_START0 // - Getting the series cumulative Max & Min values : ScaleMode = SCALE_ADDALL // - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_ADDALLSTART0 // // This will depends on the kind of graph you are drawing, today only the stacked bar chart // can use the SCALE_ADDALL mode. // Drawing graphs were you want to fix the min value to 0 you must use the SCALE_START0 option. // $chartCfg->scale->mode = SCALE_ADDALLSTART0; $chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0); $chartCfg->scale->drawTicks = TRUE; $chartCfg->scale->angle = $cfg->scale->legendXAngle; $chartCfg->scale->decimals = 1; $chartCfg->scale->withMargin = TRUE; $chartCfg->legend = new stdClass(); $chartCfg->legend->X = $chartCfg->XSize - 80; $chartCfg->legend->Y = 15; $chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240); $chartCfg->title = new stdClass(); $chartCfg->title->value = $cfg->chartTitle; $chartCfg->title->X = 2 * $chartCfg->graphArea->beginX; $chartCfg->title->Y = $chartCfg->legend->Y; $chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255); $Test = new pChart($chartCfg->XSize, $chartCfg->YSize); $Test->reportWarnings("GD"); $Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']); $Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']); $Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY); $Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size')); if ($info->canDraw) { $DataSet = new pData(); foreach ($info->chart_data as $key => $values) { $id = $key + 1; $DataSet->AddPoint($values, "Serie{$id}"); $DataSet->SetSerieName($info->series_label[$key], "Serie{$id}"); } $DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName); $DataSet->AddAllSeries(); $DataSet->RemoveSerie($info->xAxis->serieName); $DataSet->SetAbsciseLabelSerie($info->xAxis->serieName); $chartData = $DataSet->GetData(); $chartLegend = $DataSet->GetDataDescription(); foreach ($info->series_color as $key => $hexrgb) { $rgb = str_split($hexrgb, 2); $Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2])); } // $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions); $Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin); $Test->drawStackedBarGraph($chartData, $chartLegend, 70); // Draw the legend $Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size')); $Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']); $Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']); } else { $chartCfg->title->value .= '/' . lang_get('no_data_available'); } $Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']); $Test->Stroke(); }
$Test->setFontProperties("../Fonts/tahoma.ttf", 8); //$Test->setGraphArea(65, 30, 570, 185); //$Test->drawFilledRoundedRectangle(7, 7, 800, 223, 5, 240, 240, 240); //$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); //$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, TRUE, 0, 2, TRUE, 1); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 0); //$Test->drawGraphAreaGradient(162, 183, 202, 50); $Test->drawGraphAreaGradient(40, 40, 40, -50); //$Test->drawGrid(4, TRUE, 230, 230, 230, 20); $Test->drawGrid(4, TRUE, 230, 230, 230, 10); $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->clearShadow(); $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30); //$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); // Draw the 0 line $Test->setFontProperties("../Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); //$DataSet->RemoveSerie("Serie4"); $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); //$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); // Finish the graph $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->drawLegend(590, 90, $DataSet->GetDataDescription(), 0, 255, 255); $Test->setFontProperties("../Fonts/tahoma.ttf", 10); // Draw the title $Title = "Comparison of Household fuel usage in 2015"; $Test->drawTextBox(7, 225, 693, 245, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30); //$Test->drawTitle(60,22,"Comparison Graph",50,50,50,585); $Test->addBorder(0.5); $Test->Render("clientsGraph.png");
public function build() { require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pData.php'; require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pChart.php'; $dataSet = new pData(); foreach ($this->lines as $name => $ordinateValues) { if (count($ordinateValues) != count($this->absciseValues)) { throw new Exception('Count of line "' . $name . '" ordinate points "' . count($ordinateValues) . '" mismatch to abscise points "' . count($this->absciseValues) . '"'); } $dataSet->AddPoint($ordinateValues, $name); } $dataSet->AddPoint($this->absciseValues, 'Abscise'); $dataSet->AddAllSeries(); $dataSet->RemoveSerie('Abscise'); $dataSet->SetAbsciseLabelSerie('Abscise'); foreach ($this->lines as $name => $ordinateValues) { $dataSet->SetSerieName($name, $name); } $dataSet->SetYAxisUnit($this->ordinateStepTitle); $dataSet->SetXAxisUnit($this->absciseStepTitle); $chart = new pChart($this->maxWidth, $this->maxHeight); $chart->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND); // Graph area setup $chart->setFontProperties(PCHART_FONTS_DIR . DIRECTORY_SEPARATOR . 'tahoma.ttf', 10); $chart->setGraphArea($this->graphMargins[0], $this->graphMargins[1], $this->maxWidth - $this->graphMargins[2], $this->maxHeight - $this->graphMargins[3]); $chart->drawGraphArea(213, 217, 221, FALSE); $ordinateScaleMargin = ($this->getMaxOrdinateValue() - $this->getMinOrdinateValue()) / $this->ordinateDevisions; $chart->setFixedScale($this->getMinOrdinateValue() - $ordinateScaleMargin, $this->getMaxOrdinateValue() + $ordinateScaleMargin, $this->ordinateDevisions); $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2); $chart->drawGraphAreaGradient(162, 183, 202, 50); $chart->drawGrid(4, TRUE, 230, 230, 230, 20); // Draw the line chart // $chart->setShadowProperties(1, 1, 0, 0, 0, 30, 4); $chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription()); $chart->clearShadow(); $chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 5, 3, -1, -1, -1, TRUE); // Draw the legend $chart->drawLegend($this->maxWidth - $this->graphMargins[2] + 10, $this->graphMargins[1], $dataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82); // Draw chart title if ($this->chartTitle) { $chart->drawTextBox(0, $this->maxHeight - 20, $this->maxWidth, $this->maxHeight, $this->chartTitle, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30); } // Render the picture $chart->addBorder(2); $chart->Render($this->outputFilepath); }
function createChart(&$info, &$cfg) { $backgndColor = array('R' => 255, 'G' => 255, 'B' => 254); $chartCfg = new stdClass(); $chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600; $chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50; $chartCfg->border = new stdClass(); $chartCfg->border->width = 1; $chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0); $chartCfg->graphArea = new stdClass(); $chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221); $chartCfg->graphArea->beginX = 40; $chartCfg->graphArea->beginY = 40; $chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX; $chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY; $chartCfg->scale = new stdClass(); $chartCfg->scale->mode = SCALE_ADDALL; $chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0); $chartCfg->scale->drawTicks = TRUE; $chartCfg->scale->angle = $cfg->scale->legendXAngle; $chartCfg->scale->decimals = 1; $chartCfg->scale->withMargin = TRUE; $chartCfg->legend = new stdClass(); $chartCfg->legend->X = $chartCfg->XSize - 80; $chartCfg->legend->Y = 15; $chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240); $chartCfg->title = new stdClass(); $chartCfg->title->value = $cfg->chartTitle; $chartCfg->title->X = 2 * $chartCfg->graphArea->beginX; $chartCfg->title->Y = $chartCfg->legend->Y; $chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255); $Test = new pChart($chartCfg->XSize, $chartCfg->YSize); $Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']); $Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']); $Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY); $Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size')); if ($info->canDraw) { $DataSet = new pData(); foreach ($info->chart_data as $key => $values) { $id = $key + 1; $DataSet->AddPoint($values, "Serie{$id}"); $DataSet->SetSerieName($info->series_label[$key], "Serie{$id}"); } $DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName); $DataSet->AddAllSeries(); $DataSet->RemoveSerie($info->xAxis->serieName); $DataSet->SetAbsciseLabelSerie($info->xAxis->serieName); $chartData = $DataSet->GetData(); $chartLegend = $DataSet->GetDataDescription(); foreach ($info->series_color as $key => $hexrgb) { $rgb = str_split($hexrgb, 2); $Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2])); } // $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions); $Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin); $Test->drawStackedBarGraph($chartData, $chartLegend, 70); // Draw the legend $Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size')); $Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']); $Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']); } else { $chartCfg->title->value .= '/' . lang_get('no_data_available'); } $Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']); $Test->Stroke(); }
function grafico($dados, $eixo, $cor1, $grafico, $situacao, $legenda) { include_once "pChart/pChart/pData.class"; include_once "pChart/pChart/pChart.class"; $DataSet = new pData(); $DataSet->AddPoint($dados, "Serie1"); $DataSet->AddPoint($eixo, "Serie2"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie2"); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName($legenda, "Serie1"); $Test = new pChart(720, 430); $Test->drawGraphAreaGradient($cor1, 173, 131, 50, TARGET_BACKGROUND); $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 8); $Test->setGraphArea(50, 80, 675, 390); $Test->drawGraphArea(217, 217, 211, FALSE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE); $Test->drawGraphAreaGradient(163, 203, 167, 50); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); $Title = "{$situacao}"; $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 14); $Test->drawTextBox(0, 0, 700, 60, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 30, 0, 0, 30); $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 9); $Test->drawLegend(520, 70, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82); $Test->addBorder(2); $Test->Render("images/" . $grafico); }
function cartesianChart($type, $x, $y, $w, $h, $imgname = '', $config = array()) { $w -= 4; $h -= 4; $settings = array('FontName' => 'tahoma.ttf', 'FontSize' => 8, 'LegendFontSize' => 8, 'LegendFontName' => 'tahoma.ttf', 'Logo' => '', 'LogoTransparency' => 20, 'XAxisFormat' => 'number', 'XAxisUnit' => '', 'YAxisFormat' => 'number', 'YAxisUnit' => '', 'XLogo' => 0, 'YLogo' => 0, 'Xlabel' => 'x label', 'XAngle' => 0, 'Ylabel' => 'y label', 'Legend' => '', 'Textbox' => '', 'TextboxFontSize' => 8, 'TextboxFontName' => 'tahoma.ttf', 'ImgR' => 132, 'ImgG' => 173, 'ImgB' => 131, 'Decay' => 80, 'BGR' => 163, 'BGG' => 203, 'BGB' => 167, 'Decay2' => 80, 'Filled' => '', 'DataR' => 191, 'DataG' => 120, 'DataB' => 71, 'LBR' => 226, 'LBG' => 228, 'LBB' => 230, 'LR' => 0, 'LG' => 0, 'LB' => 0); // Get the custom settings if (is_array($config)) { foreach ($config as $key => $val) { $settings[$key] = $val; } } $DataSet = new pData(); $DataSet->AddPoint($y, "Serie1"); $DataSet->AddPoint($x, "Serie2"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie2"); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName($settings['Legend'], "Serie1"); $DataSet->SetYAxisName($settings['Ylabel']); $DataSet->SetXAxisName($settings['Xlabel']); $DataSet->SetXAxisFormat($settings['XAxisFormat']); if (strlen($settings['XAxisUnit'])) { $DataSet->SetXAxisUnit($settings['XAxisUnit']); } if (strlen($settings['YAxisUnit'])) { $DataSet->SetYAxisUnit($settings['YAxisUnit']); } $DataSet->SetYAxisFormat($settings['YAxisFormat']); // Initialise the graph $Test = new pChart($w, $h); $Test->drawGraphAreaGradient($settings['ImgR'], $settings['ImgG'], $settings['ImgB'], $settings['Decay'], TARGET_BACKGROUND); $FontSize = $settings['FontSize']; $FontName = $this->_ext_path . "/fonts/" . $settings['FontName']; $Test->setFontProperties($FontName, $FontSize); //Calc Textbox Height if (strlen($settings['Textbox'])) { $TextboxFontSize = $settings['TextboxFontSize']; $TextboxFontName = $this->_ext_path . "/fonts/" . $settings['TextboxFontName']; $Position = imageftbbox($TextboxFontSize, 0, $TextboxFontName, $settings['Textbox']); $TextboxHeight = $Position[1] - $Position[7] + 8; } else { $TextboxHeight = 0; } // Maximize The graph area //on Y axis if ($settings['XAxisFormat'] == 'time') { $xdata = "99:99:99"; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $WXmax = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; } elseif ($settings['XAxisFormat'] == 'date') { $xdata = "99/99/9999"; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $WXmax = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; } else { $WXmax = 0; foreach ($x as $xdata) { $xdata .= $settings['XAxisUnit']; $Position = imageftbbox($FontSize, 0, $FontName, $xdata); $TextWidth = $Position[2] - $Position[0]; $TextHeightX = $Position[1] - $Position[7]; $WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax; } } if ($settings['XAngle'] > 0) { $sin = abs(sin(deg2rad($settings['XAngle']))); $cos = abs(cos(deg2rad($settings['XAngle']))); $HXmax = $WXmax * $sin + $TextHeightX * $cos; } else { $HXmax = $TextHeightX; } //on Y axis... if ($settings['YAxisFormat'] == 'time') { $ydata = "99:99:99"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $WYmax = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; } elseif ($settings['YAxisFormat'] == 'date') { $ydata = "99/99/9999"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $WYmax = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; } else { $WYmax = 0; foreach ($y as $ydata) { $ydata .= $settings['YAxisUnit']; //echo $ydata."<br>"; $Position = imageftbbox($FontSize, 0, $FontName, $ydata); $TextWidth = $Position[2] - $Position[0]; $TextHeightY = $Position[1] - $Position[7]; $WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax; } } $Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20); //$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE); $Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']); $Test->drawGrid(4, TRUE, 230, 230, 230, 20); // This will put the picture "logo.png" with transparency if (strlen($settings['Logo'])) { $XLogo = $WYmax + $TextHeightY + 35 + $settings['XLogo']; $YLogo = 20 + $settings['XLogo']; $logo = $settings['Logo']; //Fing extension of logo : png,gif or jpg if ($this->_findexts($logo) == "png") { echo "png!"; $Test->drawFromPNG($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } elseif ($this->_findexts($logo) == "gif") { echo "gif!"; $Test->drawFromGIF($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } elseif ($this->_findexts($logo) == "jpg") { echo "jpg"; $Test->drawFromJPG($logo, $XLogo, $YLogo, $settings['LogoTransparency']); } } $Test->setColorPalette(0, $settings['DataR'], $settings['DataG'], $settings['DataB']); if ($type == "bar") { // Draw the bar chart $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); } elseif ($type == "line") { $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE); } elseif ($type == "cubic") { $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->clearShadow(); if ($settings['Filled'] == 'yes') { $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30); } $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE); } // Draw the textbox if (strlen($settings['Textbox'])) { $Test->setFontProperties($TextboxFontName, $TextboxFontSize); $Test->drawTextBox(0, $h - $TextboxHeight, $w, $h, $settings['Textbox'], 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30); } // Draw the legend if (strlen($settings['Legend'])) { $LegendFontSize = $settings['LegendFontSize']; $LegendFontName = $this->_ext_path . "/fonts/" . $settings['LegendFontName']; $Position = imageftbbox($LegendFontSize, 0, $LegendFontName, $settings['Legend']); $LegendW = $Position[2] - $Position[0] + 40; $Test->setFontProperties($LegendFontName, $LegendFontSize); $Test->drawLegend($w - $LegendW, 10, $DataSet->GetDataDescription(), $settings['LBR'], $settings['LBG'], $settings['LBB'], 52, 58, 82, $settings['LR'], $settings['LG'], $settings['LB'], TRUE); } // Render the picture $Test->addBorder(2); if (strlen($imgname)) { //custom image name $imgname = $this->_img_path . "/" . $imgname; } else { $this->obj->load->helper('string'); $imgname = $this->_img_path . "/{$type}-" . random_string('alnum', 16) . ".png"; } $Test->Render($imgname); return array("name" => '/' . $imgname, "w" => $w + 4, "h" => $h + 4); }