function writeData($data, $graph) { if ($data != "") { echo "Plottong " . $graph . "\n"; $dataset1 = array(); $dataset2 = array(); foreach ($data as $key => $value) { array_push($dataset1, $key); array_push($dataset2, $value); } $DataSet = new pData(); $DataSet->AddPoint($dataset2, "Serie1"); $DataSet->AddPoint($dataset1, "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); $Test = new pChart(380, 200); $Test->drawFilledRoundedRectangle(7, 7, 373, 193, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 375, 195, 5, 230, 230, 230); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 150, 90, 110, TRUE, TRUE, 50, 20, 5); $Test->drawPieLegend(310, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); $Test->Render("{$graph}-pie.png"); } }
/** * Does the magic. Creates all necessary stuff and finally * saves the graph to the specified filename * */ public function saveGraph($strFilename) { $this->preGraphCreation(); if (strpos($strFilename, _realpath_) === false) { $strFilename = _realpath_ . $strFilename; } if (strtolower(substr($strFilename, -3) != "png")) { throw new class_exception("Filename must be a png-file", class_exception::$level_ERROR); } $this->objChart->Render($strFilename); }
public function _showGraph_pChart($buscarBarra) { // Dataset definition $DataSet = new pData(); if ($buscarBarra == "semana") { $semana = array("1era Semana", "2da Semana", "3era Semana", "4ta Semana"); $cantidadSemanal = array(2, 4, 5, 6); $DataSet->AddPoint($semana, "Serie1"); $DataSet->AddPoint($cantidadSemanal, "Serie2"); // Initialise the graph define("WIDTH", 500); define("HEIGHT", 500); $Test = new pChart(WIDTH, HEIGHT); $Test->setFontProperties("../font/arial.ttf", 7); $Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30); $Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230); } elseif ($buscarBarra == "mes") { $mensual = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre"); $cantidadMensual = array(4, 6, 11, 23, 9, 2, 30, 20, 12, 45); $DataSet->AddPoint($mensual, "Serie1"); $DataSet->AddPoint($cantidadMensual, "Serie2"); // Initialise the graph define("WIDTH", 700); define("HEIGHT", 500); $Test = new pChart(WIDTH, HEIGHT); $Test->setFontProperties("../font/arial.ttf", 7); $Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30); $Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230); $Test->setColorPalette(0, 224, 100, 46); } $DataSet->AddAllSeries(); $DataSet->RemoveSerie("Serie1"); $DataSet->SetAbsciseLabelSerie("Serie1"); $DataSet->SetSerieName("Productos Comprados", "Serie2"); // Initialise the graph $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("../font/arial.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70); // Set labels $Test->setFontProperties("../font/arial.ttf", 7); $Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie2"); // Finish the graph $Test->setFontProperties("../font/arial.ttf", 8); $Test->drawLegend(WIDTH / 5, 25, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("../font/arial.ttf", 10); $Test->drawTitle(WIDTH - 200, 22, "Estadistica de Barra de Grafico", 50, 50, 50, 185); $Test->Render("../img/imagenBarra_pChart.png"); }
function generateGraph($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to) { $myarr = graphTests($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to); $myarr1 = graphErrs($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to); $myarr2 = graphLbls($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to); // Standard inclusions include "pChart/pChart/pData.class"; include "pChart/pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint($myarr, "Serie1"); $DataSet->AddPoint($myarr1, "Serie2"); $DataSet->AddPoint($myarr2, "Serie3"); $DataSet->AddSerie("Serie1"); $DataSet->AddSerie("Serie2"); $DataSet->SetAbsciseLabelSerie("Serie3"); $DataSet->SetSerieName("Test Resulting trends", "Serie1"); $DataSet->SetSerieName("Errors in tests", "Serie2"); $DataSet->SetYAxisName("Tests"); // $DataSet->SetYAxisFormat("time"); $DataSet->SetXAxisName("months"); // Initialise the graph $Test = new pChart(750, 330); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(85, 30, 650, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 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, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph $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(90, 35, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->drawTitle(60, 22, "Test Summary", 50, 50, 50, 585); $Test->Render("mpdf.png"); }
public function make($working_path) { // This will import the file http://my.domain.com/myData.csv using each column as a serie if (!$this->plot->valid()) { $file = $this->plot->name(); $error = $this->plot->error(); $this->log($working_path, "Plot file {$file} is invalid: {$error}"); return 1; } $data = new pData(); $columns = array(); $all_columns = array(); $x_column = $this->plot->property('x_column') - 1; if ($x_column === NULL) { $x_column = 0; } $data_file = $this->plot->data_property('name'); $deliminator = $this->plot->data_property('deliminator'); $has_header = $this->plot->data_property('header') == 'yes'; foreach ($this->plot->columns() as $column => $name) { if ($column != $x_column + 1) { $columns[] = $column - 1; } $all_columns[] = $column - 1; } $data->ImportFromCSV($working_path . $data_file, $deliminator, $all_columns, $has_header); foreach ($columns as $column) { $name = $this->plot->column($column + 1); $data->AddSerie('Serie' . $column); $data->SetSerieName($name, "Serie" . $column); } $max_col = -1; $max_val = NULL; foreach ($data->GetData() as $record) { foreach ($columns as $column) { $point = $record['Serie' . $column]; if ($max_val === NULL || $point > $max_val) { $max_val = $point; $max_col = $column; } } } $x_label = $this->plot->axis_property('x', 'label'); if ($x_label) { $data->SetXAxisName($x_label); } else { $data->SetXAxisName($this->plot->column($x_column + 1)); } $x_unit = $this->plot->axis_property('x', 'unit'); if ($x_unit) { $data->SetXAxisUnit($x_unit); } $y_label = $this->plot->axis_property('y', 'label'); reset($columns); if ($y_label) { $data->SetYAxisName($y_label); } else { $data->SetYAxisName($this->plot->column(current($columns) + 1)); } $y_unit = $this->plot->axis_property('y', 'unit'); if ($y_unit) { $data->SetyAxisUnit($y_unit); } $width = $this->plot->property('width'); if (!$width) { $width = 640; } $height = $this->plot->property('height'); if (!$height) { $height = 480; } $plot = new pChart($width, $height); $font_name = $this->plot->property('font-name'); if (!$font_name) { $font_name = 'tahoma.ttf'; } $font_name = 'lib/plugins/projects/pchart/fonts/' . $font_name; $font_size = $this->plot->property('font_size'); if (!$font_size) { $font_size = 12; } $plot->setFontProperties($font_name, $font_size); $h = $font_size + 10; $left_margin = 0; foreach ($data->GetData() as $record) { $position = imageftbbox($font_size, 0, $font_name, $record['Serie' . $max_col]); $text_width = $position[2] - $position[0]; if ($text_width > $left_margin) { $left_margin = $text_width; } } $left_margin += 2 * $h; $plot->setGraphArea($left_margin, 2 * $h, $width - $h, $height - 2 * $h); $background = $this->plot->property('background'); if (!$background) { $background = array('R' => 255, 'G' => 255, 'B' => 255); } else { $background = html_color_to_RGB($background); } $plot->drawGraphArea($background['R'], $background['G'], $background['B']); // pick the largest scale $plot->drawXYScale($data->GetData(), $data->GetDataDescription(), 'Serie' . $max_col, 'Serie' . $x_column, 0, 0, 0, TRUE, 0, 0); $line_no = 0; $colors = array(); foreach ($columns as $column) { $name = $this->plot->column($column + 1); $style = $this->plot->line_style($name, 'style'); $line_color = $this->plot->line_style($name, 'color'); if (!$line_color) { $colors[$name] = array('R' => 0, 'G' => 0, 'B' => 0); } else { $colors[$name] = html_color_to_RGB($line_color); } $plot->setColorPalette($line_no, $colors[$name]['R'], $colors[$name]['G'], $colors[$name]['B']); if (!$style || $style == 'line' || $style == 'both') { $line_width = $this->plot->line_style($name, 'width'); if (!$line_width) { $line_width = 1; } $dot_size = $this->plot->line_style($name, 'dot-size'); if (!$dot_size) { $dot_size = 0; } $plot->setLineStyle($line_width, $dot_size); $plot->drawXYGraph($data->GetData(), $data->GetDataDescription(), 'Serie' . $column, 'Serie' . $x_column, $line_no); } if ($style == 'point' || $style == 'both') { $radius = $this->plot->line_style($name, 'radius'); if (!$radius) { $radius = 5; } $plot->drawXYPlotGraph($data->GetData(), $data->GetDataDescription(), 'Serie' . $column, 'Serie' . $x_column, $line_no, $radius, $radius - 2); } $line_no++; } $title = $this->plot->property('title'); foreach ($columns as $column) { $data->removeSerie('Serie' . $column); } $in_legend = array(); $description = $data->GetDataDescription(); $description['Description'] = array(); $palette_id = 0; foreach ($columns as $column) { $name = $this->plot->column($column + 1); if (in_array($name, $in_legend)) { continue; } $in_legend[] = $name; $description['Description']['Serie' . $column] = $name; $plot->setColorPalette($palette_id, $colors[$name]['R'], $colors[$name]['G'], $colors[$name]['B']); ++$palette_id; } $legend_box_size = $plot->getLegendBoxSize($description); $legend_position = $this->plot->property('legend-position'); if (!$legend_position) { $legend_position = 'top-left'; } switch ($legend_position) { case 'top-left': $legend_left = 0; $legend_top = 0; break; case 'top': $legend_left = ($width - $h - $left_margin - $legend_box_size[0]) / 2; $legend_top = 0; break; case 'top-right': $legend_left = $width - $left_margin - $h - $legend_box_size[0]; $legend_top = 0; break; case 'left': $legend_left = 0; $legend_top = ($height - 4 * $h - $legend_box_size[1]) / 2; break; case 'center': $legend_left = ($width - $h - $left_margin - $legend_box_size[0]) / 2; $legend_top = ($height - 4 * $h - $legend_box_size[1]) / 2; break; case 'right': $legend_left = $width - $left_margin - $h - $legend_box_size[0]; $legend_top = ($height - 4 * $h - $legend_box_size[1]) / 2; break; case 'bottom-left': $legend_left = 0; $legend_top = $height - 4 * $h - $legend_box_size[1]; break; case 'bottom': $legend_left = ($width - $h - $left_margin - $legend_box_size[0]) / 2; $legend_top = $height - 4 * $h - $legend_box_size[1]; break; case 'bottom-right': $legend_left = $width - $left_margin - $h - $legend_box_size[0]; $legend_top = $height - 4 * $h - $legend_box_size[1]; break; } $plot->drawLegend($left_margin + $legend_left, 2 * $h + $legend_top, $description, 255, 255, 255, 100, 100, 100, 0, 0, 0, true); $plot->drawTitle($h, 0, $title, 0, 0, 0, $width - $h, $h * 2, 100); $plot->Render($this->path($working_path)); $file_name = $this->plot->name(); $plot_name = $this->name(); $this->log($working_path, "Successfully plotted {$file_name} as {$plot_name}\ntitle: {$title}\n"); return 0; }
function index() { $this->load->model('charge_model'); $revenue = $this->charge_model->GetRevenueByDay($this->user->Get('client_id')); $data = array(); if ($this->config->item('show_dashboard_chart') !== 'no' and !empty($revenue) and count($revenue) > 1) { $series = array(); foreach ($revenue as $day) { $series[] = $day['revenue']; $series2[] = date("M j", strtotime($day['day'])); } include APPPATH . 'libraries/pchart/pData.class'; include APPPATH . 'libraries/pchart/pChart.class'; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint($series, "Revenue"); $DataSet->AddPoint($series2, "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->RemoveSerie("Serie2"); $DataSet->SetXAxisName('Date'); $DataSet->SetYAxisName('Revenue'); //$DataSet->SetXAxisFormat('date'); // Initialise the graph $Test = new pChart(1000, 260); $Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 10); $Test->setGraphArea(90, 30, 960, 200); $Test->drawGraphArea(252, 252, 252); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 255); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255); // Finish the graph $Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 8); $Test->drawLegend(45, 35, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 10); //$Test->drawTitle(60,22,"Last 30 Days",50,50,50,585); $Test->Render(BASEPATH . '../writeable/rev_chart_' . $this->user->Get('client_id') . '.png'); } else { $data['no_chart'] = 'true'; } // get log $this->load->model('log_model'); $log = $this->log_model->GetClientLog($this->user->Get('client_id')); $data['log'] = $log; $this->load->view(branded_view('cp/dashboard'), $data); }
function generate_image($site_name, $visits) { $font = APP_PATH . "libs/pchart/Fonts/tahoma.ttf"; //$font = APP_PATH."includes/pchart/Fonts/DejaVuSans.ttf"; global $lang; // Dataset definition $DataSet = new pData(); $names = array(); $points = array(); foreach ($visits as $date => $visit) { $points[] = $visit; $text = $lang['days'][date('N', strtotime($date))]; $names[] = $text; } $DataSet->AddPoint($points, "Lankytojai"); $DataSet->AddPoint($names, "days"); $DataSet->AddAllSeries(); $DataSet->RemoveSerie("days"); $DataSet->SetAbsciseLabelSerie('days'); // Initialise the graph $Test = new pChart(700, 230); $Test->setFontProperties($font, 8); $Test->setGraphArea(50, 30, 680, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 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, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties($font, 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80); // Finish the graph $Test->setFontProperties($font, 8); // $Test->drawLegend(100,20,$DataSet->GetDataDescription(),255,255,255); $Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82); $Test->setFontProperties($font, 10); $Test->drawTitle(50, 22, $site_name, 50, 50, 50, 585); $path = IMAGE_PATH . "{$site_name}.png"; if (file_exists($path)) { unlink($path); } $Test->Render($path); return $path; }
/** * Create graph (a .png file) * * @param string $file */ public function generateGraph($file) { $patientValues = Storage::getInstance()->getPatientsData($file); /* * pGraph work */ $dataSet = new pData(); if (!empty($patientValues)) { $dataSet->AddPoint(array_keys($patientValues[$file]), 'label'); $dataSet->SetAbsciseLabelSerie('label'); $serie1 = array_values($patientValues[$file]); $average = round(array_sum($serie1) / count($serie1), 2); $dataSet->AddPoint($serie1, "Serie1"); $dataSet->AddSerie("Serie1"); // Initialise the graph $graph = new MyHorBar(450, 600); $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 8); $graph->setGraphArea(120, 60, 410, 550); $graph->drawFilledRoundedRectangle(7, 7, 443, 593, 5, 240, 240, 240); $graph->drawRoundedRectangle(5, 5, 443, 595, 5, 230, 230, 230); $graph->drawGraphArea(255, 255, 255, true); $graph->drawHorScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, true, 0, 2, true); $graph->drawHorGrid(10, true, 230, 230, 230, 50); // Draw the 0 line $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 6); $graph->drawTreshold($average, 143, 55, 72, true, false, 2, null, 90); // Draw the bar graph $graph->drawHorBarGraph($dataSet->GetData(), $dataSet->GetDataDescription(), false); // Finish the graph $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10); $graph->drawLegend(15, 15, $dataSet->GetDataDescription(), 255, 255, 255); $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10); $graph->drawTitle(170, 27, $file, 50, 50, 50, -1); } else { $graph = new pChart(450, 150); $graph->setGraphArea(120, 60, 410, 100); $graph->drawFilledRoundedRectangle(7, 7, 443, 143, 5, 240, 240, 240); $graph->drawRoundedRectangle(5, 5, 443, 145, 5, 230, 230, 230); $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10); $graph->drawTitle(170, 27, $file, 50, 50, 50, -1); $graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 36); $graph->drawTitle(125, 90, 'No data!', 245, 50, 50, -1); } $graph->Render(WWW_DIR . '/images/graphs/' . $file . '.png'); }
protected function _createSourcesGraph() { // load pChart graphic library $this->_loadLibs(); // définition des données à afficher $dataSet = new pData(); // need config, to know which data user wants to display : visits, unique visitors, pageviews $sefConfig = Sh404sefFactory::getConfig(); // Google does not allow combining dimension=ga:medium with metric = unique visitors $dataType = $sefConfig->analyticsDashboardDataType == 'ga:visitors' ? 'ga:visits' : $sefConfig->analyticsDashboardDataType; $dataTypeString = str_replace('ga:', '', $dataType); // sort data for proper display usort($this->_rawData['sources'], array($this, '_sortSourcesDataCompareFunction')); // we walk the array, pulling out alternatively // the first and last items // making the new array having the largest item // followed by the smallest, then second largest // then second smallest, ... // which makes drawing labels much easier $tmpArray = array(); $even = false; $max = count($this->_rawData['sources']); for ($i = 0; $i < $max; $i++) { if ($even) { // pull last item in sorted array $tmpArray[] = array_pop($this->_rawData['sources']); } else { // pull array first item $tmpArray[] = array_shift($this->_rawData['sources']); } // flag inversion $even = !$even; } // get data from response $data = array(); $types = array(); foreach ($tmpArray as $entry) { $value = $entry->{$dataTypeString}; // do not add empty values, as pChart would choke on that and display a warning if (!empty($value)) { $data[] = $value; $types[] = Sh404sefHelperAnalytics::getReferralLabel($entry->dimension['medium']); } } $dataSet->AddPoint($data, "visits"); $dataSet->AddPoint($types, "types"); $dataSet->addSerie('visits'); $dataSet->SetAbsciseLabelSerie("types"); $label = JText::_('COM_SH404SEF_ANALYTICS_REPORT_SOURCES') . JText::_('COM_SH404SEF_ANALYTICS_REPORT_BY_LABEL') . Sh404sefHelperAnalytics::getDataTypeTitle(); $dataSet->SetSerieName($label, "visits"); // Initialise the graph $w = intval(0.45 * $this->_options['cpWidth']); $w = empty($w) ? 160 : $w; $radius = intval($w * 0.22); $margin = 5; $h = intval($w * 0.8); $centreX = intval(0.5 * $w); $centreY = intval(0.5 * $h); $chart = new pChart($w, $h); $fontSize = 8; // prepare graph $chart->setFontProperties($this->_baseChartPath . DS . 'Fonts/arial.ttf', $fontSize); $chart->loadColorPalette($this->_baseChartPath . DS . 'palettes' . DS . 'tones-2-green-soft.php'); $chart->setGraphArea($margin, $margin, $w - $margin, $h - $margin); // This will draw a shadow under the pie chart $chart->drawFilledCircle($centreX + 4, $centreY + 4, $radius, 200, 200, 200); // Draw the pie chart $d = $dataSet->GetData(); if (!empty($d)) { $chart->drawBasicPieGraph($d, $dataSet->GetDataDescription(), $centreX, $centreY, $radius, PIE_PERCENTAGE_LABEL_VALUE, 255, 255, 218); } // create a temporary file for $user =& JFactory::getUser(); // make sure the root tmp dir exists $rootDir = 'tmp' . DS . 'sh404sef_analytics'; Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $rootDir); // file name is variable to avoid browser cache $basePath = $rootDir . DS . md5('useless_' . $user->id . '_hashing') . DS; // create path and make sure there's an index.html file in it Sh404sefHelperFiles::createDirAndIndex(JPATH_ROOT . DS . $basePath); $imageFileName = Sh404sefHelperAnalytics::createTempFile($basePath, $this->_options['report'] . '.' . $this->_options['accountId'] . '.sources.' . $dataTypeString); $chart->Render(JPATH_ROOT . DS . $imageFileName); // need cleaning up, so let's remove all report files for that user older than an hour or so Sh404sefHelperAnalytics::cleanReportsImageFiles(JPATH_ROOT . DS . $basePath, $age = 4000); return JURI::root() . $imageFileName; }
/* Example10 : A 3D exploded pie graph */ // Standard inclusions require_once "../pChart/pData.class"; require_once "../pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $data = array(10, 2, 3, 5, 3, 11, 13, 12, 11, 15, 5, 16); $sum = array_sum($data); $DataSet->AddPoint($data, "Serie1"); $DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $Test = new pChart(420, 250); $Test->drawFilledRoundedRectangle(7, 7, 413, 243, 5, 210, 200, 240); $Test->drawRoundedRectangle(5, 5, 415, 245, 5, 0, 230, 230); $Test->createColorGradientPalette(195, 204, 56, 223, 110, 41, 5); // Draw the pie chart $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->AntialiasQuality = 0; $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 180, 130, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5); $Test->drawPieLegend(330, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); // Write the title $Test->setFontProperties("../Fonts/tahoma.ttf", 13); $Test->drawTitle(10, 20, "Firewood Usage in 2015", 114, 16, 46); $Test->drawTitle(320, 220, 'Total :' . $sum . 'kg', 224, 46, 147); $Test->Render("firewood.png");
public function pchartAction() { // $this->_helper->layout->disableLayout(); $this->_helper->layout->setLayout("layout_admin"); include "pData.class"; include "pChart.class"; $this->view->showArray = $this->testdemoAction(); $showdate = array(); $showreport = array(); foreach ($this->view->showArray as $show) { array_push($showdate, substr($show['date'], strlen($show['date']) - 4, 4)); array_push($showreport, $show['count']); } // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array_slice($showreport, 0, 26), "Serie1"); $DataSet->AddPoint(array_slice($showdate, 0, 26), "Serie2"); $DataSet->AddSerie("Serie1"); $DataSet->SetAbsciseLabelSerie("Serie2"); $DataSet->SetSerieName("Reports", "Serie1"); $DataSet->SetYAxisName('Report Count'); $DataSet->SetXAxisName('Date'); // Initialise the graph $Test = new pChart(900, 250); $Test->setFontProperties("xihei.ttf", 8); $Test->setGraphArea(50, 30, 780, 200); $Test->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255); $Test->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("xihei.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE); // Finish the graph $Test->setFontProperties("xihei.ttf", 8); $Test->drawLegend(596, 50, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("xihei.ttf", 10); $Test->drawTitle(200, 22, "Reports by Day in Jue.", 50, 50, 50, 585); $Test->Render("Naked1.png"); //===================================================================================== // Dataset definition $DataSet2 = new pData(); $DataSet2->AddPoint(array(38, 22, 606), "Serie1"); $DataSet2->AddPoint(array("Male", "Female", "Unkown"), "Serie2"); $DataSet2->AddAllSeries(); $DataSet2->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $Test2 = new pChart(300, 200); $Test2->loadColorPalette("softtones.txt"); $Test2->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 255, 255, 255); $Test2->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230); // This will draw a shadow under the pie chart $Test2->drawFilledCircle(122, 102, 70, 200, 200, 200); // Draw the pie chart $Test2->setFontProperties("tahoma.ttf", 8); $Test2->drawBasicPieGraph($DataSet2->GetData(), $DataSet2->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218); $Test2->drawPieLegend(230, 15, $DataSet2->GetData(), $DataSet2->GetDataDescription(), 250, 250, 250); $Test2->Render("Naked2.png"); //===================================================================================== // select province $db = Zend_Registry::get('db'); $selectprovince = $db->select(); $selectprovince->from('consumer', array("province", "count(*) as count"))->where("pest is null")->group("consumer.province")->order("count desc"); $provinceArray = $db->fetchAll($selectprovince); $this->view->showprovince = ''; $this->view->showprovincecount = ''; $showprovince = array(); $showprovincecount = array(); foreach ($provinceArray as $province) { if ($province['province'] == null || $province['province'] == '') { array_push($showprovince, 'Unkown'); } else { array_push($showprovince, $province['province']); } array_push($showprovincecount, $province['count']); } // Dataset definition $DataSet3 = new pData(); $DataSet3->AddPoint(array_slice($showprovincecount, 0, 20), "Serie1"); $DataSet3->AddPoint(array_slice($showprovince, 0, 20), "Serie2"); $DataSet3->AddSerie("Serie1"); $DataSet3->SetAbsciseLabelSerie("Serie2"); $DataSet3->SetSerieName("Spark Count", "Serie1"); $DataSet3->SetYAxisName('Spark Count'); $DataSet3->SetXAxisName('Province'); Zend_Debug::dump($DataSet3->GetDataDescription()); // Initialise the graph $Test3 = new pChart(900, 250); $Test3->setFontProperties("xihei.ttf", 8); $Test3->setGraphArea(50, 30, 780, 200); $Test3->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255); $Test3->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230); $Test3->drawGraphArea(255, 255, 255, TRUE); $Test3->drawScale($DataSet3->GetData(), $DataSet3->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test3->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test3->setFontProperties("xihei.ttf", 6); $Test3->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test3->drawBarGraph($DataSet3->GetData(), $DataSet3->GetDataDescription(), TRUE); // Finish the graph $Test3->setFontProperties("xihei.ttf", 8); $Test3->drawLegend(596, 50, $DataSet3->GetDataDescription(), 255, 255, 255); $Test3->setFontProperties("xihei.ttf", 10); $Test3->drawTitle(200, 22, "Reports by Day in Jue.", 50, 50, 50, 585); $Test3->Render("Naked3.png"); }
<?php /* SmallGraph: Let's go fast, draw small! */ // Standard inclusions include "src/pData.php"; include "src/pChart.php"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(1, 4, -3, 2, -3, 3, 2, 1, 0, 7, 4, -3, 2, -3, 3, 5, 1, 0, 7), "Serie1"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $DataSet->SetSerieName("January", "Serie1"); // Initialise the graph $Test = new pChart(100, 30); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawFilledRoundedRectangle(2, 2, 98, 28, 2, 230, 230, 230); $Test->setGraphArea(5, 5, 95, 25); $Test->drawGraphArea(255, 255, 255); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 220, 220, 220, FALSE); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); // Finish the graph $Test->Render("SmallGraph.png");
$Test->drawFilledRoundedRectangle(7, 7, 693, 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, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the bar graph $Test->drawOverlayBarGraph($DataSet->GetData(), $DataSet->GetDataDescription()); // Finish the graph $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->drawTitle(50, 22, $res['treinador'], 50, 50, 50, 585); $Test->Render("example" . $res['id_treinador'] . ".png"); ?> <img src="example<?php echo $res['id_treinador']; ?> .png" alt="<?php echo $res['id_treinador']; ?> " width="670"/> <b>Média: </b> <?php echo number_format($questao, 2); ?> <br><br><b>Questões</b><br> <label style="color:#0000FF">Pergunta 1: O Treinamento foi eficiente?</label> <?php echo number_format($questao1, 2); ?>
$Test->drawGrid(4, TRUE, 230, 230, 230, 10); $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $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); // Clear the scale $Test->clearScale(); // Draw the 2nd graph /*$DataSet->RemoveSerie("Serie1"); $DataSet->AddSerie("Serie2"); $DataSet->SetYAxisName("Web Hits"); $Test->drawRightScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,213,217,221,TRUE,0,0); $Test->drawGrid(4,TRUE,230,230,230,10); $Test->setShadowProperties(3,3,0,0,0,30,4); $Test->drawCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription()); $Test->clearShadow(); $Test->drawFilledCubicCurve($DataSet->GetData(),$DataSet->GetDataDescription(),.1,30); $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),3,2,255,255,255); */ // Write the legend (box less) $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->drawLegend(530, 5, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 255, 255, 255, FALSE); // Write the title $Test->setFontProperties("../Fonts/tahoma.ttf", 18); $Test->setShadowProperties(1, 1, 0, 0, 0); $Test->drawTitle(0, 0, "Comparison of Fuel usage in 2015", 255, 255, 255, 660, 30, TRUE); $Test->clearShadow(); // Render the picture $Test->Render("clientsGraph.png"); ?>
$DataSet = new pData(); $canvas = new GDCanvas(700, 230); $Chart = new pChart(700, 230, $canvas); // Dataset definition CSVImporter::ImportFromCSV($DataSet, "../sample/datawithtitle.csv", ",", array(1, 2, 3), TRUE, 0); $DataSet->AddAllSeries(); $DataSet->setAbscissaLabelSeries(); // Initialise the graph $Chart->setFontProperties("../Fonts/tahoma.ttf", 8); $Chart->setGraphArea(60, 30, 680, 200); $canvas->drawFilledRoundedRectangle(new Point(7, 7), new Point(693, 223), 5, new Color(240), 1, 0, ShadowProperties::NoShadow()); $canvas->drawRoundedRectangle(new Point(5, 5), new Point(695, 225), 5, new Color(230), 1, 0, ShadowProperties::NoShadow()); $Chart->drawGraphBackground(new BackgroundStyle(new Color(255), TRUE)); $Chart->drawScale($DataSet, ScaleStyle::DefaultStyle(), 0, 2); $Chart->drawGrid(new GridStyle(4, TRUE, new Color(230, 230, 230), TRUE)); // Draw the 0 line $Chart->setFontProperties("../Fonts/tahoma.ttf", 6); $Chart->drawTreshold(0, new Color(143, 55, 72), TRUE, TRUE); // Draw the area $Chart->drawArea($DataSet, "Serie 1", "Serie 3", new Color(239, 238, 227)); // Draw the line graph $Chart->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Chart->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, new Color(255)); // Finish the graph $Chart->setFontProperties("../Fonts/tahoma.ttf", 8); $Chart->drawLegend(65, 35, $DataSet->GetDataDescription(), new Color(250)); $Chart->setFontProperties("../Fonts/tahoma.ttf", 10); $Chart->drawTitle(60, 22, "Example 4", new Color(50), 585); $Chart->Render("Example4.png"); header("Content-Type:image/png"); readfile("Example4.png");
public function dashboardwiki() { $hours = $this->from == $this->to; $result = $this->hlp->Query()->dashboardwiki($this->tlimit, $hours); $data1 = array(); $data2 = array(); $data3 = array(); $times = array(); foreach ($result as $time => $row) { $data1[] = (int) $row['E']; $data2[] = (int) $row['C']; $data3[] = (int) $row['D']; $times[] = $time . ($hours ? 'h' : ''); } $DataSet = new pData(); $DataSet->AddPoints($data1, 'Serie1'); $DataSet->AddPoints($data2, 'Serie2'); $DataSet->AddPoints($data3, 'Serie3'); $DataSet->AddPoints($times, 'Times'); $DataSet->AddAllSeries(); $DataSet->SetAbscissaLabelSeries('Times'); $DataSet->SetSeriesName($this->hlp->getLang('graph_edits'), 'Serie1'); $DataSet->SetSeriesName($this->hlp->getLang('graph_creates'), 'Serie2'); $DataSet->SetSeriesName($this->hlp->getLang('graph_deletions'), 'Serie3'); $Canvas = new GDCanvas(700, 280, false); $Chart = new pChart(700, 280, $Canvas); $Chart->setFontProperties(dirname(__FILE__) . '/pchart/Fonts/DroidSans.ttf', 8); $Chart->setGraphArea(50, 10, 680, 200); $Chart->drawScale($DataSet, new ScaleStyle(SCALE_NORMAL, new Color(127)), $hours ? 0 : 45, 1, false, ceil(count($times) / 12)); $Chart->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $DataSet->removeSeries('Times'); $DataSet->removeSeriesName('Times'); $Chart->drawLegend(550, 15, $DataSet->GetDataDescription(), new Color(250)); header('Content-Type: image/png'); $Chart->Render(''); }
function line($valores, $titulo, $label = array()) { $nombre = tempnam('/tmp', 'g') . '.png'; $DataSet = new pData(); $ind = 1; $DataSet->AddPoint($valores, 'Serie' . $ind); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $DataSet->SetSerieName($titulo, 'Serie' . $ind); if (count($label) > 0) { $ID = 0; foreach ($label as $val) { $DataSet->Data[$ID]["Name"] = $val; $ID++; } } $Test = new pChart(300, 200); $Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8); $Test->setGraphArea(70, 30, 280, 170); $Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, true, 0, 0); $Test->drawGrid(4, TRUE, 200, 200, 200, 50); $Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8); $Test->drawLegend(200, 9, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 10); //$Test->drawTitle(10,22,$titulo,50,50,50,300); $Test->Render($nombre); return $nombre; }
$Test->drawGraphAreaGradient(40, 40, 40, -50); $Test->drawGrid(4, TRUE, 230, 230, 230, 10); $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $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); // Clear the scale $Test->clearScale(); // Draw the 2nd graph $DataSet->RemoveSerie("Serie1"); $DataSet->AddSerie("Serie2"); $DataSet->SetYAxisName("Web Hits"); $Test->drawRightScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 0); $Test->drawGrid(4, TRUE, 230, 230, 230, 10); $Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4); $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); // Write the legend (box less) $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->drawLegend(530, 5, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 255, 255, 255, FALSE); // Write the title $Test->setFontProperties("../Fonts/MankSans.ttf", 18); $Test->setShadowProperties(1, 1, 0, 0, 0); $Test->drawTitle(0, 0, "SourceForge ranking summary", 255, 255, 255, 660, 30, TRUE); $Test->clearShadow(); // Render the picture $Test->Render("Example26.png");
$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");
function grafico2($dados, $eixo, $grafico) { 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->SetAbsciseLabelSerie("Serie2"); $Test = new pChart(700, 400); $Test->drawFilledRoundedRectangle(7, 7, 700, 430, 5, 180, 216, 216); $Test->setFontProperties("pChart/Fonts/tahoma.ttf", 10); $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 270, 210, 210, PIE_PERCENTAGE, TRUE, 50, 20, 5); $Test->drawPieLegend(520, 70, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); $Test->Render("images/" . $grafico); }
private function createClosuresGraph($queries) { $qb = new QueryBrowser(); $imagehashes = array(); foreach ($queries as $q) { $DataSet = new pData(); $qResult = $qb->executeQueryToArray($q['query']); if (sizeof($qResult) > 0) { foreach ($qResult as $row) { $DataSet->AddPoint($row['y'], $q['series'], $row['x']); } $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $chartname = $this->createPathFromHash(md5(serialize($DataSet))); $imagehashes[] = array($chartname, $q['series']); if (!file_exists($chartname)) { $Test = new pChart(700, 280); $Test->setFontProperties("graph/Fonts/tahoma.ttf", 8); $Test->setGraphArea(50, 30, 680, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 273, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 695, 275, 5, 230, 230, 230); $Test->drawGraphArea(255, 255, 255, true); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, true, 45, 2); $Test->drawGrid(4, true, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("graph/Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, true, true); // Draw the cubic curve graph $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 50); // Finish the graph $Test->setFontProperties("graph/Fonts/tahoma.ttf", 10); $Test->drawTitle(50, 22, $q['series'], 50, 50, 50, 585); $Test->Render("render/" . $chartname); } } } return $imagehashes; }
function drawChart($tittel, $what, $people = true, $childrenonly = false, $rotate = false) { global $time, $dataset, $filename, $chart_path; // Initialise the graph if (!$rotate) { $Test = new pChart(700, 230); } else { $Test = new pChart(700, 330); } $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(70, 30, 680, 200); if (!$rotate) { $Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230); } else { $Test->drawFilledRoundedRectangle(7, 7, 693, 223 + 100, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 695, 225 + 100, 5, 230, 230, 230); } $Test->drawGraphArea(255, 255, 255, TRUE); if (!$rotate) { $Test->drawScale($dataset->GetData(), $dataset->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); } else { $Test->drawScale($dataset->GetData(), $dataset->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 90, 2, TRUE); } $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the line graph //$Test->drawLineGraph($dataset->GetData(),$dataset->GetDataDescription()); //$Test->drawPlotGraph($dataset->GetData(),$dataset->GetDataDescription(),3,2,255,255,255); $Test->drawBarGraph($dataset->GetData(), $dataset->GetDataDescription(), TRUE); // Finish the graph $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawLegend(75, 35, $dataset->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->drawTitle(60, 22, $tittel, 50, 50, 50, 585); if ($people && $childrenonly) { $what2 = 'children'; } elseif ($people) { $what2 = 'people'; } else { $what2 = 'entries'; } $filename = $chart_path . '/' . $time . '-' . $what . '-' . $what2 . '.png'; $Test->Render($filename); }
<?php /* Naked: Naked and easy! */ // Standard inclusions include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(1, 4, 3, 2, 3, 3, 2, 1, 0, 7, 4, 3, 2, 3, 3, 5, 1, 0, 7)); $DataSet->AddSerie(); $DataSet->SetSerieName("Sample data", "Serie1"); // Initialise the graph $Test = new pChart(700, 230); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->setGraphArea(40, 30, 680, 200); $Test->drawGraphArea(252, 252, 252, TRUE); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 70); // Draw the line graph $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(45, 35, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->drawTitle(60, 22, "My pretty graph", 50, 50, 50, 585); $Test->Render("Naked.png");
$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");
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); $Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie1"); // Draw the title $Test->setFontProperties("../simantz/class/pchart/Fonts/pf_arma_five.ttf", 8); $Title = "QUotation Amount Vs Time For {$defaultorganization_name}"; $Test->drawTextBox(65, 10, 550, 25, $Title, 0, 255, 255, 255, ALIGN_CENTER, TRUE, 0, 0, 0, 30); // Draw the line graph $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 254, 254, 254); // Draw the legend $Test->setFontProperties("../simantz/class/pchart/Fonts/tahoma.ttf", 8); $Test->drawLegend(10, 150, $DataSet->GetDataDescription(), 254, 254, 254); // Render the chart $photofile = $uploadpath . "chartsalequoteamt_6month.png"; $Test->Render($photofile); // $chart->setTitle("Sales Vs Expenses For $defaultorganization_name"); // $chart->getPlot()->setGraphCaptionRatio(0.62); // $chart->render("chart/generated/salesexpenses_6month.png"); if ($action != "create") { header('Content-type: image/png'); //$photofile="chartcache/chart0.png>"; $image = ImageCreateFromPNG($photofile); imagepng($image); imagedestroy($image); unlink($photofile); } else { //header('Content-type: text/png'); if (!file_exists($photofile)) { echo "cannot create chart!"; } else {
// Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(10, 4, 3, 2, 3, 3, 2, 1, 0, 7, 4, 3, 2, 3, 3, 5, 1, 0, 7), "Serie1"); $DataSet->AddPoint(array(1, 4, 2, 6, 2, 3, 0, 1, -5, 1, 2, 4, 5, 2, 1, 0, 6, 4, 30), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $DataSet->SetXAxisName("Samples"); $DataSet->SetYAxisName("Temperature"); $DataSet->SetSerieName("January", "Serie1"); // Initialise the graph $Test = new pChart(700, 230); $Test->reportWarnings("GD"); $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->setGraphArea(60, 30, 585, 185); $Test->drawFilledRoundedRectangle(7, 7, 693, 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, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("../Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the cubic curve graph $Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription()); // Finish the graph $Test->setFontProperties("../Fonts/tahoma.ttf", 8); $Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("../Fonts/tahoma.ttf", 10); $Test->drawTitle(50, 22, "Example 19", 50, 50, 50, 585); $Test->Render("Example19.png");
echo $data2 = 0; echo $data3 = 0; echo $data4 = 0; echo $data5 = 400; echo $data6 = 0; $val = ""; for ($i = 1; $i < 7; $i++) { } // Standard inclusions include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array($data1, $data2, $data3, $data4, $data5, $data6), "Serie1"); $DataSet->AddPoint(array("January", "February", "March", "April", "May", "June"), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie("Serie2"); // Initialise the graph $Test = new pChart(300, 200); $Test->loadColorPalette("Sample/softtones.txt"); $Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240); $Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230); // This will draw a shadow under the pie chart $Test->drawFilledCircle(122, 102, 70, 200, 200, 200); // Draw the pie chart $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->AntialiasQuality = 0; $Test->drawBasicPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218); $Test->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250); $Test->Render("example14.png");
protected function generateGraphImage($finalData, $hourflag, $title = 'Sticky Charts', $x_axis_format = 'date') { $path = $this->config->item('csv_upload_path'); if (!empty($finalData['data'])) { $DataSet = new pData(); $in = 0; foreach ($finalData['data'] as $seriesData) { $in++; $seriesIndex = 'Serie' . $in; $DataSet->AddPoint($seriesData['data'], $seriesIndex); $DataSet->SetSerieName($seriesData['name'], $seriesIndex); $DataSet->AddSerie($seriesIndex); } $xAxisArray = array(); $in++; $seriesIndex = 'Serie' . $in; $catCount = count($finalData['cat']); if ($catCount <= 10) { $DataSet->SetXAxisFormat($x_axis_format); } foreach ($finalData['cat'] as $catD) { if ($catCount > 10) { $xAxisArray[] = ''; } else { $xAxisArray[] = strtotime($catD); } } $DataSet->SetYAxisFormat("number"); $DataSet->AddPoint($xAxisArray, $seriesIndex); $DataSet->SetAbsciseLabelSerie($seriesIndex); $DataSet->SetYAxisName($finalData['y_title']); $DataSet->SetXAxisName($finalData['x_title']); // Initialise the graph $Test = new pChart(985, 458); $Test->drawBackground(247, 226, 180); $Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 8); $Test->setGraphArea(40, 30, 950, 400); $Test->drawGraphArea(109, 110, 114, false); $Test->drawGrid(4, false, 0, 0, 0, 50); $Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 6); // Draw the line graph if ($title == 'Violation Report') { //!$hourflag && $sCount = count($finalData['data']); if ($sCount > 0) { for ($m = 0; $m < $sCount; $m++) { $color = Color_handler::get_next($m); $rgb = $color->get_rgb(); $Test->setColorPalette($m, $rgb['r'], $rgb['g'], $rgb['b']); } } $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, TRUE, 0, 0, TRUE); $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription()); } else { $sCount = count($finalData['data']); if ($sCount > 0) { for ($m = 0; $m < $sCount; $m++) { $color = Color_handler::get_next($m % 3); $rgb = $color->get_rgb(); $Test->setColorPalette($m, $rgb['r'], $rgb['g'], $rgb['b']); } } $Test->setLineStyle(2); $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 0, 0, 0, TRUE, 0, 2); $Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription()); $Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 2); } // Finish the graph $Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 8); $Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 10); $imgName = uniqid('graph_') . '.png'; $Test->Render($path . $imgName); return upload_to_amazon_graphImage($imgName, $path); } }
include "pChart/pData.class"; include "pChart/pChart.class"; // Dataset definition $DataSet = new pData(); $DataSet->AddPoint(array(1, 4, 3, 2, 3, 3, 2, 1, 0, 7, 4, 3, 2, 3, 3, 5, 1, 0, 7), "Serie1"); $DataSet->AddPoint(array(1, 4, 2, 6, 2, 3, 0, 1, 5, 1, 2, 4, 5, 2, 1, 0, 6, 4, 2), "Serie2"); $DataSet->AddAllSeries(); $DataSet->SetAbsciseLabelSerie(); $DataSet->SetSerieName("January", "Serie1"); $DataSet->SetSerieName("February", "Serie2"); // Initialise the graph $Test = new pChart(700, 230); $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->setGraphArea(50, 30, 585, 200); $Test->drawFilledRoundedRectangle(7, 7, 693, 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, 150, 150, 150, TRUE, 0, 2); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties("Fonts/tahoma.ttf", 6); $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE); // Draw the cubic curve graph $Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 50); // Finish the graph $Test->setFontProperties("Fonts/tahoma.ttf", 8); $Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255); $Test->setFontProperties("Fonts/tahoma.ttf", 10); $Test->drawTitle(50, 22, "Example 7", 50, 50, 50, 585); $Test->Render("example7.png");
/** * Render graph * *@return nothing **/ function render($p_stack = FALSE) { // declare the graph $Test = new pChart(800, 250); $Test->tmpFolder = $this->tmpPath; $fileId = time() . '_' . rand(1, 1000); $fontFile = "tahoma.ttf"; // prepare the map echo '<SCRIPT TYPE="text/javascript" SRC="' . $this->pChartPath . 'overlib.js"></SCRIPT> <SCRIPT TYPE="text/javascript" SRC="' . $this->pChartPath . 'pMap.js"></SCRIPT>'; $MapID = "map_" . $fileId . ".map"; $Test->setImageMap(TRUE, $MapID); $Map = new pChart(800, 250); $Map->tmpFolder = $this->tmpPath; $imgName = "img_" . $fileId . ".png"; $img = $this->tmpPath . $imgName; $imgLink = GLPI_ROOT . "/plugins/fusioninventory/front/send.php?file=" . urlencode("tmp/" . $imgName); $mapLink = GLPI_ROOT . "/plugins/fusioninventory/front/send.php?file=" . urlencode("tmp/" . $MapID); echo '<DIV ID="overDiv" STYLE="position:absolute; visibility:hidden; z-index:1000;"></DIV>'; echo "<IMG ID='fusioninventory_graph_{$fileId}' SRC='{$imgLink}' WIDTH=800 HEIGHT=250 BORDER=0 OnMouseMove='fusioninventory_graph(event);' OnMouseOut='nd();'>"; echo '<SCRIPT> function fusioninventory_graph(event) { LoadImageMap("fusioninventory_graph_' . $fileId . '","' . $mapLink . '"); getMousePosition(event); } </SCRIPT>'; // configure the graph $Test->setFontProperties($this->fontsPath . $fontFile, 8); $Test->setGraphArea(80, 30, 580, 185); // graph size : keep place for titles on X and Y axes $Test->drawFilledRoundedRectangle(7, 7, 793, 243, 5, 240, 240, 240); // background rectangle $Test->drawRoundedRectangle(5, 5, 795, 245, 5, 230, 230, 230); // 3D effect $Test->drawGraphArea(255, 255, 255, TRUE); $Test->setFixedScale(0, $this->getMaxY($this->maxValue), $this->divisionsY); // to see values from 0 $Test->drawScale($this->pData->GetData(), $this->pData->GetDataDescription(), SCALE_ADDALL, 150, 150, 150, TRUE, 0, 2, TRUE); $Test->drawGrid(4, TRUE, 230, 230, 230, 50); // Draw the 0 line $Test->setFontProperties($this->fontsPath . $fontFile, 6); // Draw the bar graph if ($p_stack) { $Test->drawStackedBarGraph($this->pData->GetData(), $this->pData->GetDataDescription(), 100); } else { $Test->drawBarGraph($this->pData->GetData(), $this->pData->GetDataDescription(), FALSE, 100); } // Finish the graph $Test->setFontProperties($this->fontsPath . $fontFile, 8); $Test->drawLegend(590, 30, $this->pData->GetDataDescription(), 255, 255, 255); // take care of legend text size $Test->setFontProperties($this->fontsPath . $fontFile, 10); $Test->drawTitle(50, 22, $this->title . ' (/ ' . $this->timeUnitName . ')', 50, 50, 50, 585); $Test->Render($img); }