Example #1
4
function drawChart($title, $DataSet, $names, $colors, $legend = false)
{
    // Initialise the graph
    $Chart = new pChart(1300, 750);
    $Chart->setFontProperties("Fonts/tahoma.ttf", 8);
    $Chart->setGraphArea(50, 25, 1200, 725);
    $Chart->drawGraphArea(255, 255, 255, TRUE);
    $Chart->drawXYScale($DataSet->GetData(), $DataSet->GetDataDescription(), "ally", "allx", 150, 150, 150, TRUE, 45);
    $Chart->setLineStyle(4);
    // Draw the 0 line
    $Chart->setFontProperties("Fonts/tahoma.ttf", 6);
    $Chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
    foreach ($colors as $idx => $color) {
        $Chart->setColorPalette($idx, $color[0], $color[1], $color[2]);
    }
    $i = 0;
    foreach ($names as $name) {
        $Chart->drawXYGraph($DataSet->GetData(), $DataSet->GetDataDescription(), $name . "y", $name . "x", $i);
        $i++;
    }
    if ($legend) {
        $Chart->drawLegend(465, 40, $DataSet->GetDataDescription(), 255, 255, 255);
    }
    // Finish the graph
    $Chart->setFontProperties("Fonts/tahoma.ttf", 10);
    //  $Chart->drawTitle(60,22,$title,50,50,50,530);
    $Chart->Stroke();
}
Example #2
2
 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");
 }
$Test->setFontProperties("../pChart/Fonts/tahoma.ttf", 14);
$Test->drawTitle(100, 32, "Sales By Zip Code", 50, 50, 50, 585);
$Test->Render("../temp/bar.png");
// Build Line Chart for dates
$DataSet = new pData();
foreach ($days as $_day) {
    $DataSet->AddPoint($_day["quantity"], "Series1");
    $DataSet->AddPoint($_day["display"], "Series2");
    $DataSet->AddAllSeries();
    $DataSet->SetAbsciseLabelSerie("Series2");
    $DataSet->SetSerieName("Sales By Date", "Series1");
    //$DataSet->RemoveSerie("Series2");
}
// Initialise the graph
$Test = new pChart(1200, 430);
$Test->setColorPalette(0, 38, 33, 204);
$Test->setFontProperties("../pChart/Fonts/tahoma.ttf", 14);
$Test->setGraphArea(50, 50, 1180, 400);
$Test->drawFilledRoundedRectangle(7, 7, 1193, 423, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 1195, 425, 5, 230, 230, 230);
$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("../pChart/Fonts/tahoma.ttf", 10);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
// Finish the graph
$Test->setFontProperties("../pChart/Fonts/tahoma.ttf", 22);
$Test->drawTitle(550, 36, "Sales By Date", 50, 50, 50, 585);
Example #4
2
}
if ($fail) {
    $point2[] = "Fail";
    $point1[] = $fail;
}
$DataSet->AddPoint($point1, "Serie1");
$DataSet->AddPoint($point2, "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test = new pChart(345, 200);
$Test->drawFilledRoundedRectangle(7, 7, 413, 243, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 415, 245, 5, 230, 230, 230);
$Test->createColorGradientPalette(1, 6);
// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
if ($pass == 0 && $fail > 0) {
    $Test->setColorPalette(0, 243, 134, 48);
}
$Test->AntialiasQuality = 0;
$Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 150, 90, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5);
$Test->drawPieLegend(280, 5, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
// Write the title
$Test->setFontProperties("Fonts/MankSans.ttf", 10);
//$Test->drawTitle(10,20,"Covidien",100,100,100);
//$Test->Render("example10.png");
$Test->stroke();
/*   header('Content-type: image/png');
    imagepng($Test);
    imagedestroy($Test);*/
//<img src="Example10.png">
Example #5
1
function drawChart($title, $DataSet, $type, $colors, $legend = false)
{
    // Initialise the graph
    $Chart = new pChart(1300, 700);
    $Chart->setFontProperties("Fonts/tahoma.ttf", 8);
    $Chart->setGraphArea(50, 50, 1200, 600);
    $Chart->drawGraphArea(255, 255, 255, TRUE);
    $Chart->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 0, TRUE);
    // Draw the 0 line
    $Chart->setFontProperties("Fonts/tahoma.ttf", 6);
    $Chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
    foreach ($colors as $idx => $color) {
        $Chart->setColorPalette($idx, $color[0], $color[1], $color[2]);
    }
    if ($type == "bar") {
        $Chart->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription());
    } else {
        if ($type == "line") {
            $Chart->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
        }
    }
    if ($legend) {
        $Chart->drawLegend(465, 40, $DataSet->GetDataDescription(), 255, 255, 255);
    }
    // Finish the graph
    $Chart->setFontProperties("Fonts/tahoma.ttf", 10);
    $Chart->drawTitle(60, 22, $title, 50, 50, 50, 530);
    $Chart->Stroke();
}
Example #6
1
 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;
 }
Example #7
0
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("Used");
$DataSet->SetXAxisName("Hour");
$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(450, 225);
$Test->setColorPalette(0, 69, 252, 69);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 440, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 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(), 0.1, 0);
// Finish the graph
Example #8
0
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("1 Min Average");
$DataSet->SetXAxisName("Hour");
#$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(450, 225);
$Test->setColorPalette(0, 255, 184, 55);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 440, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 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(), 0.1, 0);
// Finish the graph
Example #9
0
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("Used");
$DataSet->SetXAxisName("Hour");
$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(450, 225);
$Test->setColorPalette(0, 201, 127, 246);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 440, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 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(), 0.1, 0);
// Finish the graph
Example #10
0
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();
}
$Test = new pChart($width, $height);
$Test->setFontPropertiesDir("{$pChart_dir}/Fonts");
// Add an image
$Test->drawFromPNG($background, 0, 0);
$Test->reportWarnings("GD");
$Test->setFixedScale($min_y_value, $max_y_value, 5);
$Test->setFontProperties("{$pChart_dir}/Fonts/tahoma.ttf", 14);
$Test->setGraphArea($area_margin_left, 20, $width - 30, $height - 55);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 255, 255, 255, TRUE, 0, 2, TRUE, 1);
$Test->drawGrid(4, TRUE, 233, 218, 213, 0);
//画网格
// Draw the area
$Test->drawArea($DataSet->GetData(), "Serie3", "Serie4", 239, 238, 227, 40);
$DataSet->RemoveSerie("Serie4");
// Draw the line graph
$Test->setColorPalette(0, 255, 237, 237);
$Test->setLineStyle(2, 0);
//设置虚线的宽度
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->setColorPalette(0, 243, 247, 252);
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 5, 3, 255, 255, 255);
// $Test->setFontProperties("{$pChart_dir}/Fonts/simfang.ttf",14);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie3");
// $Test->Render("example15.png");
$Test->Stroke();
function dump($data)
{
    echo "<pre>";
    print_r($data);
    echo "</pre>";
    exit;
Example #12
0
}
if ($p9 != '') {
    $DataSet->SetSerieName($n9, "Serie9");
}
//---------------------------- Set X & Y axis units
if ($unit) {
    $DataSet->SetYAxisUnit($unit);
} else {
    $DataSet->SetYAxisUnit("");
}
$DataSet->SetXAxisUnit("");
//---------------------------- Create Object of pChart
$Test = new pChart($w, $h);
//---------------------------- Set generic colors for one (first) channel
if ($_GET['gcolor'] == 'red') {
    $Test->setColorPalette(0, 220, 50, 50);
} elseif ($_GET['gcolor'] == 'brown') {
    $Test->setColorPalette(0, 220, 140, 100);
} elseif ($_GET['gcolor'] == 'blue') {
    $Test->setColorPalette(0, 100, 140, 220);
} elseif ($_GET['gcolor'] == 'green') {
    $Test->setColorPalette(0, 100, 200, 100);
} elseif ($_GET['gcolor'] == 'orange') {
    $Test->setColorPalette(0, 220, 190, 50);
} else {
    $Test->setColorPalette(0, 150, 150, 150);
}
//---------------------------- Set generic colors for channels 1-9
if ($_GET['g1color'] == 'red') {
    $Test->setColorPalette(0, 220, 50, 50);
} elseif ($_GET['g1color'] == 'brown') {
Example #13
0
 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);
     }
 }
Example #14
0
 /**
  * Creates the object and prepares it for rendering.
  * Does all the calculation like borders, margins, paddings ....
  *
  * @return void
  */
 private function preGraphCreation()
 {
     // Initialize the graph
     $this->objChart = new pChart($this->intWidth, $this->intHeight);
     //set the color palette to be used
     foreach ($this->arrDefaultColorPalette as $intKey => $strCurrentColor) {
         $arrCurColor = hex2rgb($strCurrentColor);
         $this->objChart->setColorPalette($intKey, $arrCurColor[0], $arrCurColor[1], $arrCurColor[2]);
     }
     //calculate all needed params, draw that funky shit
     //the outer bounding and pane - rounded and with sharp corners
     $arrBackgroundColor = hex2rgb($this->strBackgroundColor);
     if ($this->bitRoundedCorners) {
         $this->objChart->drawFilledRoundedRectangle(2, 2, $this->intWidth - 3, $this->intHeight - 3, 5, $arrBackgroundColor[0], $arrBackgroundColor[1], $arrBackgroundColor[2]);
         $arrOuterBack = hex2rgb($this->strOuterFrameColor);
         $this->objChart->drawRoundedRectangle(0, 0, $this->intWidth - 1, $this->intHeight - 1, 5, $arrOuterBack[0], $arrOuterBack[1], $arrOuterBack[2]);
     } else {
         $this->objChart->drawFilledRectangle(0, 0, $this->intWidth, $this->intHeight, $arrBackgroundColor[0], $arrBackgroundColor[1], $arrBackgroundColor[2]);
     }
     //the graph area - x and or y-axis label present?
     if ($this->bitRenderLegend) {
         $intRightMargin = 10;
     } else {
         $intRightMargin = 20;
     }
     $intTopMargin = 15;
     $intBottomMargin = 30;
     $intLeftMargin = 40;
     $intLegendWidth = 0;
     if ($this->bitRenderLegend) {
         $intLegendWidth = 120;
     }
     $intWidth = $this->intWidth - $intRightMargin - $intLegendWidth;
     $intHeight = $this->intHeight - $intBottomMargin;
     $intLeftStart = $intLeftMargin;
     $intTopStart = $intTopMargin;
     if ($this->strYAxisTitle != "") {
         $intLeftStart += 15;
         //$intWidth -= 15; //TODO: why not needed?
     }
     if ($this->strXAxisTitle != "") {
         $intHeight -= 15;
     }
     if ($this->strGraphTitle != "") {
         //$intHeight -= 12; //TODO: why not needed???
         $intTopStart += 12;
     }
     if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
         $this->objChart->setGraphArea($intLeftStart, $intTopStart, $intWidth, $intHeight);
         $arrPaneBackground = hex2rgb($this->strGraphBackgroundColor);
         $this->objChart->drawGraphArea($arrPaneBackground[0], $arrPaneBackground[1], $arrPaneBackground[2], true);
     }
     $arrFontColors = hex2rgb($this->strFontColor);
     $this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 8);
     //set up the axis-titles
     if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
         if ($this->strXAxisTitle != "") {
             $this->objDataset->SetXAxisName($this->strXAxisTitle);
         }
         if ($this->strYAxisTitle != "") {
             $this->objDataset->SetYAxisName($this->strYAxisTitle);
         }
     }
     //the x- and y axis, in- / exclusive margins
     if ($this->bitAdditionalDatasetAdded && $this->bitScaleFromAdditionalDataset) {
         $this->objChart->drawScale($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
     } else {
         if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
             $this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
         } else {
             if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR) {
                 $this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_ADDALLSTART0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
             } else {
                 if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
                     $this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_NORMAL, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, false);
                 }
             }
         }
     }
     //the background grid
     if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
         $arrGridColor = hex2rgb($this->strGridColor);
         $this->objChart->drawGrid(4, true, $arrGridColor[0], $arrGridColor[1], $arrGridColor[2], 50);
     }
     if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
         // Draw the line graph
         $this->objChart->drawLineGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription());
         //dots in line
         $this->objChart->drawPlotGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 3, 2, 255, 255, 255);
     } else {
         if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
             //the zero-line
             $this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 6);
             $this->objChart->drawBarGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), TRUE);
             $this->objChart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
             //if given, render the line-plots on top
             if ($this->bitAdditionalDatasetAdded) {
                 //the line itself
                 $this->objChart->drawLineGraph($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription());
                 //the dots
                 $this->objChart->drawPlotGraph($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription(), 3, 2, 255, 255, 255);
             }
         } else {
             if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR) {
                 //the zero-line
                 $this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 6);
                 $this->objChart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
                 $this->objChart->drawStackedBarGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 75);
             } else {
                 if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_PIE) {
                     $this->objChart->drawPieGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), ceil($this->intWidth / 2) - 20, ceil($this->intHeight / 2), ceil($intHeight / 2) + 20, PIE_PERCENTAGE, TRUE, 50, 20, 5);
                 }
             }
         }
     }
     //render values?
     if (count($this->arrValueSeriesToRender) > 0) {
         $this->objChart->writeValues($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), $this->arrValueSeriesToRender);
     }
     // Finish the graph
     $this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 7);
     //set up the legend
     if ($this->bitRenderLegend) {
         if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_PIE) {
             $this->objChart->drawPieLegend($this->intWidth - $intLegendWidth - $intRightMargin + 10 - $this->intLegendAdditionalMargin, $intTopStart, $this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 255, 255, 255);
         } else {
             $arrLegend = $this->objDataset->GetDataDescription();
             //merge legends
             if ($this->bitAdditionalDatasetAdded) {
                 $arrAdditionalLegend = $this->objAdditionalDataset->GetDataDescription();
                 foreach ($arrAdditionalLegend["Description"] as $strKey => $strName) {
                     $arrLegend["Description"][$strKey] = $strName;
                 }
             }
             $this->objChart->drawLegend($this->intWidth - $intLegendWidth - $intRightMargin + 10 - $this->intLegendAdditionalMargin, $intTopStart, $arrLegend, 255, 255, 255);
         }
     }
     //draw the title
     if ($this->strGraphTitle != "") {
         $this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 10);
         $this->objChart->drawTitle(0, $intTopMargin, $this->strGraphTitle, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], $this->intWidth, 10);
     }
 }
if (count($date) < 2) {
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 11);
    $Chart->drawTextBox(100, 90, 180, 110, "Not Enough Session Data", 0, 0, 0, 0, ALIGN_LEFT, FALSE, 255, 255, 255, 0);
} else {
    $DataSet = new pData();
    $DataSet->AddPoint($skill, 'SerieSkill');
    $DataSet->AddPoint($skill_change, 'SerieSession');
    $DataSet->AddPoint($date, 'SerieDate');
    $DataSet->AddSerie('SerieSkill');
    $DataSet->SetAbsciseLabelSerie('SerieDate');
    $DataSet->SetSerieName('Skill', 'SerieSkill');
    $DataSet->SetSerieName('Session', 'SerieSession');
    $Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 7);
    $DataSet->SetYAxisName('Skill');
    $DataSet->SetYAxisUnit('K');
    $Chart->setColorPalette(0, 255, 255, 0);
    $Chart->drawRightScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, $color['red'], $color['green'], $color['blue'], TRUE, 0, 0);
    $Chart->drawGrid(1, FALSE, 55, 55, 55, 100);
    $Chart->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
    $Chart->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
    $Chart->clearShadow();
    $Chart->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 30);
    $Chart->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 1, 1, 255, 255, 255);
    $Chart->clearScale();
    $DataSet->RemoveSerie('SerieSkill');
    $DataSet->AddSerie('SerieSession');
    $DataSet->SetYAxisName('Session');
    $DataSet->SetYAxisUnit('');
    $Chart->setColorPalette(1, 255, 0, 0);
    $Chart->setColorPalette(2, 0, 0, 255);
    $Chart->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, $color['red'], $color['green'], $color['blue'], TRUE, 0, 0);
Example #16
0
$pChartDataSet->AddPoint($XAxis, "Serie1");
$pChartDataSet->AddPoint($OLNum, "Serie2");
$pChartDataSet->AddSerie("Serie2");
$pChartDataSet->RemoveSerie("Serie1");
$pChartDataSet->SetAbsciseLabelSerie("Serie1");
$pChartDataSet->SetYAxisName("在\n线\n人\n数\n//\n人");
$pChartDataSet->SetYAxisFormat("floor");
$pChartDataSet->SetXAxisFormat("number");
// 设置作图区域
$pChartGraph = new pChart($imgWidth, 253);
$pChartGraph->drawGraphAreaGradient(90, 90, 90, 90, TARGET_BACKGROUND);
$pChartGraph->setGraphArea(70, 30, $imgWidth + 70 - 90, 253 + 30 - 80);
$pChartGraph->setFontProperties(DRAWFONE_PATH, 8);
$pChartGraph->drawScale($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), SCALE_NORMAL, 250, 250, 250, TRUE, 0, 0, FALSE, 1);
// 开始作图
$pChartGraph->setColorPalette(0, 0, 255, 255);
$pChartGraph->drawGraphAreaGradient(40, 40, 40, -50);
$pChartGraph->drawGrid(1, TRUE, 115, 115, 115, 10);
$pChartGraph->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$pChartGraph->drawFilledLineGraph($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), 25);
$pChartGraph->clearShadow();
$pChartGraph->setFontProperties(DRAWFONE_PATH, 10);
$pChartGraph->drawTitle($imgWidth / 2, 22, "实时在线人数查询(" . $dateTime . ") 峰值( " . $maxNumberIndex . ", " . $maxNumber . "人 )", 255, 255, 255, 585);
$pChartGraph->writeValues($pChartDataSet->GetData(), $pChartDataSet->GetDataDescription(), "Serie2");
// 结束
$pChartGraph->Stroke();
//	$pChartGraph->Render("RealTimeOnLine.png");
//	echo "<img src = 'RealTimeOnLine.png'>";
//	$fileNameTxt = "Cache/XYInfo.".$plat.$server.$dateTime.".txt";
//	$file = fopen($fileNameTxt,"w");
//	$info = $pChartGraph->DivisionWidth.",".$pChartGraph->GArea_Y2.",".$pChartGraph->VMin.",".$pChartGraph->DivisionRatio;
Example #17
0
//$DataSet->SetYAxisName($p);
if ($unit) {
    $DataSet->SetYAxisUnit($unit);
} else {
    $DataSet->SetYAxisUnit("°C");
}
$DataSet->SetXAxisUnit("");
// Initialise the graph
if (!$height) {
    $h = 210;
} else {
    $h = (int) $height;
}
$Test = new pChart($w, $h);
if ($_GET['gcolor'] == 'red') {
    $Test->setColorPalette(0, 220, 50, 50);
} elseif ($_GET['gcolor'] == 'brown') {
    $Test->setColorPalette(0, 220, 140, 100);
} elseif ($_GET['gcolor'] == 'blue') {
    $Test->setColorPalette(0, 100, 140, 220);
} elseif ($_GET['gcolor'] == 'green') {
    $Test->setColorPalette(0, 100, 220, 140);
} elseif ($_GET['gcolor'] == 'orange') {
    $Test->setColorPalette(0, 220, 190, 50);
} else {
    if (SETTINGS_THEME == 'light' || $_GET['bg'] == 'light') {
        $Test->setColorPalette(0, 150, 150, 150);
    } else {
        $Test->setColorPalette(0, 250, 250, 250);
    }
}
Example #18
0
 function main()
 {
     $ThisArea = array('1' => 'Orizaba', '2' => 'Guadalajara', '3' => 'Ramos Arizpe', '4' => 'Tijuana');
     if (!$this->args) {
         $this->help();
         $this->err(__('Usage report <id_area> <id_fraccion> <year> <month> <all_areas> ', true));
         $this->_stop();
     }
     $KeyArea = $this->args[0];
     $Fraccion = $this->args[1];
     $CurrentYear = $this->args[2];
     $CurrentMonth = $this->args[3];
     $all = $this->args[4];
     $args = $this->args;
     $this->out(pr($args));
     $NumDays = date('t', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear));
     if (empty($all) && !empty($KeyArea) && !empty($CurrentMonth)) {
         // CurrentMonth Area
         $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "-" . $CurrentMonth . "%";
         $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea;
         $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion;
     }
     if ($all == true && $KeyArea == false && $CurrentMonth == false) {
         // AllYear
         $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%";
         $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion;
     }
     if ($all == true && $KeyArea > 0 && $CurrentMonth == false) {
         // AllYearArea
         $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%";
         $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea;
         $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion;
     }
     //       $this->out(pr($TonelajeConditions));exit();
     //       $TonelajeConditions['TonelajeCurrent.fecha_guia LIKE'] = "%".$CurrentYear."-".$CurrentMonth."%";
     //       $TonelajeConditions['TonelajeCurrent.id_area'] = $KeyArea;
     //       $TonelajeConditions['TonelajeCurrent.id_fraccion'] = $Fraccion;
     //       $this->out(pr($TonelajeConditions));exit();
     $report = $this->TonelajeCurrent->find('all', array('conditions' => $TonelajeConditions));
     $toneladas = null;
     $report_day = array();
     $report_year = array();
     //     $this->out(pr($report));exit();
     foreach ($report as $key => $data) {
         if ($data['TonelajeCurrent']['status_guia'] == ' B') {
             $canceladas[] = $data;
         }
         $MyMonth = date('M', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear));
         // 	    $this->out(pr($data));
         // 	    $report_day['00'] = '0';
         if ($data['TonelajeCurrent']['status_guia'] !== ' B') {
             $toneladas += $data['TonelajeCurrent']['peso'];
             $counter[] = $data['TonelajeCurrent']['peso'];
             $day = substr($data['TonelajeCurrent']['fecha_guia'], 8, 2);
             $report_day[$day] += $data['TonelajeCurrent']['peso'];
         }
     }
     // End foreach $report
     /** ALERT Save the result for Display in the view
      */
     //       $this->out(pr($report_day));exit();
     //       $this->out($NumDays);
     //       $this->out($MyMonth);
     //       exit();
     //       $this->out(count($counter));exit();
     //2
     $this->autoRender = false;
     //3
     App::import('Vendor', 'pData', array('file' => 'pchart' . DS . 'pData.class'));
     App::import('Vendor', 'pChart', array('file' => 'pchart' . DS . 'pChart.class'));
     //4
     $fontFolder = APP . 'vendors' . DS . 'pchart' . DS . 'Fonts';
     $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pchart' . DS . 'Fonts';
     //          $SchemaFolder = APP.'vendors'.DS.'pchart'.DS.'schema';
     //5
     // Dataset definition
     $DataSet = new pData();
     $MaxTons = max($report_day);
     $MaxTons = $MaxTons + 100;
     foreach ($report_day as $key => $value) {
         $MyDay[] = (int) $key;
     }
     // 	$this->out(pr($MyDay));
     $DataSet->AddPoint($report_day, "Serie1");
     // 	$DataSet->AddPoint('4',"Serie2");
     // 	$DataSet->AddPoint('20',"Serie3");
     // 	$DataSet->AddPoint($MyDay,"Name");
     // exit();
     //         $this->out(pr($DataSet->GetData()));
     // 	$idx=0;
     //         foreach($MyDay as $key => $value){
     // 	  $DataSet->AddPoint($value,"Serie1");
     // 	  $DataSet->AddPoint((int)$key,"Name");
     //         }
     // 	    $this->out(pr($MyDay));
     //         $DataSet->GetData()['0']['Name']=;
     // 	  $DataSet->GetData()['0']['Name']=1;
     $this->out(pr($DataSet->GetData()));
     $DataSet->AddAllSeries();
     $DataSet->SetAbsciseLabelSerie();
     $key = $value = null;
     $DataSet->SetSerieName("Toneladas", "Serie1");
     $DataSet->SetSerieName("Dia", "Serie2");
     $DataSet->SetYAxisName("Toneladas Dias");
     $DataSet->SetYAxisUnit("Ton");
     $DataSet->SetXAxisName("Dias");
     $DataSet->SetXAxisFormat("number");
     // Initialise the graph
     //          pr($SchemaFolder);
     $Test = new pChart(820, 260);
     $Test->setFixedScale(1, $MaxTons, 5, 0, $NumDays, 5);
     $Test->setDateFormat("H:m");
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     $Test->setColorPalette(0, 115, 173, 207);
     $Test->setColorPalette(1, 144, 196, 226);
     $Test->setColorPalette(2, 174, 216, 240);
     $Test->setColorPalette(3, 64, 140, 195);
     $Test->setColorPalette(4, 104, 188, 209);
     $Test->setColorPalette(5, 99, 200, 226);
     $Test->setColorPalette(6, 82, 124, 148);
     $Test->setColorPalette(7, 97, 152, 183);
     $Test->setColorPalette(8, 105, 210, 231);
     $Test->setColorPalette(9, 167, 219, 216);
     $Test->setColorPalette(10, 224, 228, 204);
     $Test->setColorPalette(11, 243, 134, 48);
     // 	$Test->loadColorPalette("/tmp/schema/blue.txt",",");
     $Test->setGraphArea(100, 30, 790, 200);
     //       $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
     $Test->drawRoundedRectangle(5, 5, 810, 225, 5, 230, 230, 230);
     $Test->drawGraphArea(255, 255, 255, TRUE);
     // 	dibujar la grafica
     $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 line graph
     // Draw the 0 line
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     // Draw the bar graph
     $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);
     //  $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription());
     //     $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
     //     $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie3");
     //     $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
     // Finish the graph
     $today = date('Y-m-d');
     // 	$Test->setFontProperties($fontFolder.DS."tahoma.ttf",8);
     //  	$Test->drawLegend(820,150,$DataSet->GetDataDescription(),255,255,255);
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     if (empty($all) && !empty($KeyArea) && !empty($CurrentMonth)) {
         // CurrentMonth Area
         $Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$MyMonth} {$CurrentYear}", 50, 50, 50, 585);
         $Test->Render("../../app/webroot/img/thumbs/graph_" . $today . "_" . $KeyArea . "_" . $Fraccion . ".png");
     }
     if ($all == true && $KeyArea == false && $CurrentMonth == false) {
         // AllYear
         $Test->drawTitle(220, 22, "Toneladas {$CurrentYear}", 50, 50, 50, 585);
         $Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png");
     }
     if ($all == true && $KeyArea > 0 && $CurrentMonth == false) {
         // AllYearArea
         $Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$CurrentYear}", 50, 50, 50, 585);
         $Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png");
     }
     // 	$Test->drawTitle(220,22,"Toneladas $MyMonth $CurrentYear",50,50,50,585);
     // 	$Test->Render("../../app/webroot/img/thumbs/graph_".$today."_".$KeyArea."_".$Fraccion.".png");
 }
Example #19
0
$DataSet = new pData();
if ($time > 0) {
    $DataSet->AddPoint(array($f0, $f1, $f2, $f3, $f4, $f5, $f6, $f7, $f8), "Serie1");
    $DataSet->AddPoint(array("Lying", "Sitting", "Sit Fidgeting", "Standing", "Stand Fidgeting", "Playing Wii", "Slow Walking", "Brisk Walking", "Running"), "Serie2");
}
/*
$DataSet->AddPoint(array(1,1,1,1,1,1,1,1,1),"Serie1");
$DataSet->AddPoint(array("Lying","Sitting","Sit Fidgeting","Standing","Stand Fidgeting","Paying Wii","Slow Walking","Brisk Walking","Running"),"Serie2");
*/
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test = new pChart(460, 350);
$Test->drawGraphAreaGradient(250, 250, 250, 50, TARGET_BACKGROUND);
//$Test->setColorPalette(8,170,100,50);
$Test->setColorPalette(0, 224, 175, 243);
$Test->setColorPalette(1, 216, 153, 240);
$Test->setColorPalette(2, 209, 135, 237);
$Test->setColorPalette(3, 197, 101, 233);
$Test->setColorPalette(4, 176, 46, 224);
$Test->setColorPalette(5, 188, 224, 46);
$Test->setColorPalette(6, 224, 100, 46);
$Test->setColorPalette(7, 224, 214, 46);
/* $Test->setColorPalette(5,155,206,240); 
 $Test->setColorPalette(6,107,183,233); 
 $Test->setColorPalette(7,81,170,230); 
*/
$Test->setColorPalette(8, 46, 151, 224);
//$Test->drawFilledRoundedRectangle(7,7,453,343,5,240,240,240);
// $Test->drawRoundedRectangle(5,5,455,345,5,230,230,230);
// $Test->createColorGradientPalette(205,194,251,103,50,251,9);
Example #20
0
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("Usage");
$DataSet->SetXAxisName("Hour");
$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(900, 225);
$Test->setColorPalette(0, 126, 185, 245);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 890, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 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(), 0.1, 0);
// Finish the graph
Example #21
0
 function main()
 {
     $ThisArea = array('1' => 'Orizaba', '2' => 'Guadalajara', '3' => 'Ramos Arizpe', '4' => 'Tijuana');
     if (!$this->args) {
         $this->help();
         $this->err(__('Usage report <year> <area> <month> <fraction> <all_areas> ', true));
         $this->_stop();
     }
     $KmsConditions = null;
     if (isset($this->args[0]) && !isset($this->args[3])) {
         $CurrentYear = $this->args[0];
         $KmsConditions['KmsCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "%";
     }
     if (isset($this->args[1])) {
         $KeyArea = $this->args[1];
         $KmsConditions['KmsCurrent.id_area'] = $KeyArea;
     } else {
         $KeyArea = null;
     }
     if (isset($this->args[2])) {
         $CurrentMonth = $this->args[2];
         $CurrentYear = $this->args[0];
         $KmsConditions['KmsCurrent.fecha_guia LIKE'] = "%" . $CurrentYear . "-" . $CurrentMonth . "%";
     } else {
         $CurrentMonth = null;
     }
     if (isset($this->args[3])) {
         $Fraccion = $this->args[3];
         $KmsConditions['KmsCurrent.id_fraccion'] = $Fraccion;
     } else {
         $Fraccion = null;
     }
     if (isset($this->args[4])) {
         $all = $this->args[4];
     } else {
         $all = null;
     }
     $args = $this->args;
     /** ALERT Like in the ancient times Define the vars firts
      **/
     //       $KmsConditions = null;
     //       $this->out(pr($KmsConditions));
     //       $this->out(pr($args));exit();
     $NumDays = date('t', mktime('0', '0', '0', $CurrentMonth, '01', $CurrentYear));
     /** TODO => Firts we need all areas => all fractions => CurrentYear
     **	 => Second Detail By Four Areas => CurrentYear
     **	 => Third Graphics by Area => Month => Fraction => CurrentYear
     **/
     $kms_full = $full = $kms_all = null;
     $kms_search = $this->KmsCurrent->find('all', array('conditions' => $KmsConditions));
     //       $this->out(pr($KmsConditions));
     //       $this->out(pr($kms_search));
     //       exit();
     if (!empty($kms_search)) {
         foreach ($kms_search as $key => $value) {
             if ($value['KmsCurrent']['id_configuracionviaje'] == '3') {
                 $kms_full[$value['KmsCurrent']['no_viaje']][] = $value['KmsCurrent']['kms_viaje'];
                 $kms_full[$value['KmsCurrent']['no_viaje']]['day'] = substr($value['KmsCurrent']['fecha_guia'], 8, 2);
             } elseif ($value['KmsCurrent']['id_configuracionviaje'] == '2' or $value['KmsCurrent']['id_configuracionviaje'] == '1') {
                 $kms_all += $value['KmsCurrent']['kms_viaje'];
                 $kms_senc[substr($value['KmsCurrent']['fecha_guia'], 8, 2)] = $value['KmsCurrent']['kms_viaje'];
             }
         }
         foreach ($kms_full as $k => $data) {
             $full += $data['0'];
             $full_days[$data['day']] += $data['0'];
         }
         $AreaCorp['kms_all'] = ($kms_all + $full) * 2;
         $all_days = ($kms_all + array_sum($full_days)) * 2;
     } else {
         $AreaCorp['kms_all'] = null;
     }
     //       $this->out(pr($full));
     $this->out(pr($full_days));
     //       $this->out(array_sum($full_days));
     $this->out(pr($kms_senc));
     $this->out(pr($AreaCorp));
     $this->out(pr($all_days));
     //       exit();
     $report_day = $kms_senc;
     $report_year = array();
     /** ALERT Save the result for Display in the view
      */
     //2
     $this->autoRender = false;
     //3
     App::import('Vendor', 'pData', array('file' => 'pchart' . DS . 'pData.class'));
     App::import('Vendor', 'pChart', array('file' => 'pchart' . DS . 'pChart.class'));
     //4
     $fontFolder = APP . 'vendors' . DS . 'pchart' . DS . 'Fonts';
     $fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pchart' . DS . 'Fonts';
     //5
     // Dataset definition
     $DataSet = new pData();
     $MaxKms = max($report_day);
     $MaxKms = $MaxKms + 100;
     foreach ($report_day as $key => $value) {
         $MyDay[] = (int) $key;
     }
     // 	$this->out(pr($MyDay));
     $DataSet->AddPoint($report_day, "Serie1");
     // 	$DataSet->AddPoint('4',"Serie2");
     // 	$DataSet->AddPoint('20',"Serie3");
     // 	$DataSet->AddPoint($MyDay,"Name");
     // exit();
     //         $this->out(pr($DataSet->GetData()));
     // 	$idx=0;
     //         foreach($MyDay as $key => $value){
     // 	  $DataSet->AddPoint($value,"Serie1");
     // 	  $DataSet->AddPoint((int)$key,"Name");
     //         }
     // 	    $this->out(pr($MyDay));
     //         $DataSet->GetData()['0']['Name']=;
     // 	  $DataSet->GetData()['0']['Name']=1;
     $this->out(pr($DataSet->GetData()));
     $DataSet->AddAllSeries();
     $DataSet->SetAbsciseLabelSerie();
     $key = $value = null;
     $DataSet->SetSerieName("Kilometros", "Serie1");
     $DataSet->SetSerieName("Dia", "Serie2");
     $DataSet->SetYAxisName("Kilometros Dias");
     $DataSet->SetYAxisUnit("Kms");
     $DataSet->SetXAxisName("Dias");
     $DataSet->SetXAxisFormat("number");
     // Initialise the graph
     //          pr($SchemaFolder);
     $Test = new pChart(820, 260);
     $Test->setFixedScale(1, $MaxKms, 5, 0, $NumDays, 5);
     $Test->setDateFormat("H:m");
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     // 	$Test->setColorPalette(0,115,173,207);
     // 	$Test->setColorPalette(1,144,196,226);
     $Test->setColorPalette(2, 174, 216, 240);
     $Test->setColorPalette(3, 64, 140, 195);
     $Test->setColorPalette(4, 104, 188, 209);
     $Test->setColorPalette(5, 99, 200, 226);
     $Test->setColorPalette(6, 82, 124, 148);
     $Test->setColorPalette(7, 97, 152, 183);
     $Test->setColorPalette(8, 105, 210, 231);
     $Test->setColorPalette(9, 167, 219, 216);
     $Test->setColorPalette(10, 224, 228, 204);
     $Test->setColorPalette(11, 243, 134, 48);
     // 	$Test->loadColorPalette("/tmp/schema/blue.txt",",");
     $Test->setGraphArea(100, 30, 790, 200);
     //       $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
     $Test->drawRoundedRectangle(5, 5, 810, 225, 5, 230, 230, 230);
     $Test->drawGraphArea(255, 255, 255, TRUE);
     // 	dibujar la grafica
     $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 line graph
     // Draw the 0 line
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     $Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
     // Draw the bar graph
     $Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);
     //  $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription());
     //     $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
     //     $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie3");
     //     $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
     // Finish the graph
     $today = date('Y-m-d');
     // 	$Test->setFontProperties($fontFolder.DS."tahoma.ttf",8);
     //  	$Test->drawLegend(820,150,$DataSet->GetDataDescription(),255,255,255);
     $Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
     // 	$_today =
     if (isset($KeyArea)) {
         $area = "_" . $KeyArea;
     } else {
         $area = "_0";
     }
     if (isset($Fraccion)) {
         $fraction = "_" . $Fraccion;
     } else {
         $fraction = "_0";
     }
     $Test->drawTitle(220, 22, "Kilometros {$ThisArea[$KeyArea]} {$MyMonth} {$CurrentYear}", 50, 50, 50, 585);
     $Test->Render("../../app/webroot/img/thumbs/graph_kms_" . $today . $area . $fraction . ".png");
 }
if (!empty($passthru_persist)) {
    $persist = 1;
}
$num_sections = count($palette);
//make sure we actually have a numerical value
if ($value === '') {
    exit;
} else {
    $value = (double) $value;
}
$font = $CFG->dirroot . "/lib/pChart.1.27d/Fonts/tahoma.ttf";
//creat our main chart
$chart = new pChart(2 * $radius, $radius);
$chart->setGraphArea(0, 0, 2 * $radius, $radius);
//set the RPG color palette from the parameter
foreach ($palette as $i => $rgb) {
    $chart->setColorPalette($i, $rgb[0], $rgb[1], $rgb[2]);
}
//draw pie slices
php_report_gas_gauge_create_pie($chart, $radius, $num_sections);
//label pie slices
php_report_gas_gauge_draw_labels($chart, $radius, $total, $num_sections, $font);
//arrow that measures progress
php_report_gas_gauge_draw_arrow($chart, $radius, $value, $total);
if ($persist == 0) {
    //render the chart to the screen
    $chart->Stroke();
} else {
    //store the chart in a PNG file
    imagepng($chart->Picture, $passthru_filename);
}
Example #23
0
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();
}
 public function componentPieChart()
 {
     $DataSet = new pData();
     if (count($this->values) > 0) {
         $DataSet->AddPoint($this->values, "Serie1");
         $DataSet->AddPoint($this->labels, "Serie2");
         $DataSet->AddAllSeries();
         $DataSet->SetAbsciseLabelSerie("Serie2");
     }
     // Draw the pie chart
     // Initialise the graph
     $Test = new pChart($this->width, $this->height);
     $Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'OpenSans-Regular.ttf', 8);
     $Test->drawFilledRoundedRectangle(2, 2, $this->width - 3, $this->height - 3, 5, 240, 240, 240);
     $Test->drawRoundedRectangle(0, 0, $this->width - 1, $this->height - 1, 5, 230, 230, 230);
     foreach ($this->colors as $id => $color) {
         $Test->setColorPalette($id, $color['r'], $color['g'], $color['b']);
     }
     if ($this->height > 200 && $this->width > 250) {
         if (count($this->values) > 0) {
             $Test->drawPieLegend($this->width / 3 + $this->width / 3, 40, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
         }
         $title_font_size = 10;
         $left = $this->width / 3;
         $pie_labels = PIE_PERCENTAGE_AND_VALUES;
     } else {
         $title_font_size = 7;
         $left = $this->width / 2;
         $pie_labels = PIE_NOLABEL;
     }
     if (isset($this->style) && $this->style == '3d' && count($this->values) > 0) {
         $Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), floor($left), floor($this->height / 2), floor(($this->width + $this->height) / 6), $pie_labels, TRUE, 40, 10, 3);
     }
     $Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'OpenSans-Bold.ttf', $title_font_size);
     $Test->drawTitle(50, 22, $this->title, 50, 50, 50, $this->width - 30);
     $Test->Stroke();
     //("example2.png");
 }
Example #25
0
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("IOwait %");
$DataSet->SetXAxisName("Hour");
$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(450, 225);
$Test->setColorPalette(0, 255, 44, 44);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 440, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 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(), 0.1, 0);
// Finish the graph
Example #26
0
// Initialise the graph
$pChartCfg = new stdClass();
$pChartCfg->XSize = 400;
$pChartCfg->YSize = 400;
$pChartCfg->centerX = intval($pChartCfg->XSize / 2);
$pChartCfg->centerY = intval($pChartCfg->YSize / 2);
$pChartCfg->radius = 150;
$pChartCfg->legendX = 10;
$pChartCfg->legendY = 15;
$graph = new stdClass();
$graph->data = $DataSet->GetData();
$graph->description = $DataSet->GetDataDescription();
$Test = new pChart($pChartCfg->XSize, $pChartCfg->YSize);
foreach ($series_color as $key => $hexrgb) {
    $rgb = str_split($hexrgb, 2);
    $Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// Draw the pie chart
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->AntialiasQuality = 0;
$Test->drawBasicPieGraph($graph->data, $graph->description, $pChartCfg->centerX, $pChartCfg->centerY, $pChartCfg->radius, PIE_PERCENTAGE, 255, 255, 218);
$Test->drawPieLegend($pChartCfg->legendX, $pChartCfg->legendY, $graph->data, $graph->description, 250, 250, 250);
$Test->Stroke();
function checkRights(&$db, &$user)
{
    return $user->hasRight($db, 'testplan_metrics');
}
/**
 * 
 *
 */
Example #27
0
 /**
  * Build The Bar Gharph image with given params 
  * and store in upload/pChart directory.
  *
  * @param  array  $params    an assoc array of name/value pairs          
  * @return array  $filesPath created image files Path.
  *
  * @static
  */
 static function barGraph($params, $divisionWidth = 44)
 {
     if (empty($params)) {
         return;
     }
     //get the required directory path.
     $config =& CRM_Core_Config::singleton();
     //get the default currency.
     $currency = $config->defaultCurrency;
     $pChartPath = str_replace('templates', 'packages', $config->templateDir);
     $pChartPath .= 'pChart/Fonts/';
     $uploadDirURL = str_replace('persist/contribute/', 'upload/pChart/', $config->imageUploadURL);
     $uploadDirPath = $config->uploadDir . 'pChart/';
     //create pchart directory, if exist clean and then create again.
     if (is_dir($uploadDirPath)) {
         CRM_Utils_File::cleanDir($uploadDirPath);
         CRM_Utils_File::createDir($uploadDirPath);
     } else {
         CRM_Utils_File::createDir($uploadDirPath);
     }
     require_once 'packages/pChart/pData.class.php';
     require_once 'packages/pChart/pChart.class.php';
     $chartCount = 0;
     $filesValues = array();
     foreach ($params as $chartIndex => $chartValues) {
         $chartCount++;
         $shades = 0;
         $names = $values = array();
         foreach ($chartValues['values'] as $indexName => $indexValue) {
             $names[] = $indexName;
             $values[] = $indexValue;
             $shades++;
         }
         $legend = CRM_Utils_Array::value('legend', $chartValues);
         $xname = CRM_Utils_Array::value('xname', $chartValues);
         $yname = CRM_Utils_Array::value('yname', $chartValues);
         //calculate max scale for graph.
         $maxScale = ceil(max($values) * 1.1);
         $fontSize = 8;
         $angleOfIncline = 45;
         $monetaryformatting = true;
         require_once 'CRM/Utils/Money.php';
         $formatedMoney = CRM_Utils_Money::format(max($values));
         $positions = imageftbbox($fontSize, 0, $pChartPath . "tahoma.ttf", $formatedMoney);
         $scaleTextWidth = $positions[2] - $positions[0];
         //need to increase Ysize if we incline money value.
         $increaseYBy = 0;
         $inclinePositions = imageftbbox($fontSize, $angleOfIncline, $pChartPath . "tahoma.ttf", $formatedMoney);
         $inclineTextWidth = $inclinePositions[2] - $inclinePositions[0];
         if ($inclineTextWidth > $divisionWidth) {
             $increaseYBy = $inclineTextWidth / 2;
         }
         //Initialise the co-ordinates.
         $xComponent = 20;
         $yComponent = 35;
         $ySize = 300;
         //calculate coords.
         $x1 = $xComponent + $scaleTextWidth;
         $y1 = $yComponent + $increaseYBy;
         $ySize += $increaseYBy;
         $y2 = $ySize - $yComponent;
         //calculate x axis size as per number of months.
         $x2 = $xComponent + $divisionWidth + $scaleTextWidth + (count($chartValues['values']) - 1) * $divisionWidth;
         $xSize = $x2 + $xComponent;
         $dataSet = new pData();
         $dataSet->AddPoint($values, "Serie1");
         $dataSet->AddPoint($names, "Serie2");
         $dataSet->AddSerie("Serie1");
         $dataSet->SetAbsciseLabelSerie("Serie2");
         //Initialise the graph
         $chart = new pChart($xSize, $ySize);
         $chart->setFontProperties($pChartPath . "tahoma.ttf", $fontSize);
         $chart->setGraphArea($x1, $y1, $x2, $y2);
         //set the y axis scale.
         $chart->setFixedScale(0, $maxScale, 1);
         $chart->drawFilledRoundedRectangle(0, 0, $xSize, $ySize, 5, 240, 240, 240);
         $chart->drawRoundedRectangle(0, 0, $xSize, $ySize, 5, 230, 230, 230);
         $chart->drawGraphArea(255, 255, 255, TRUE);
         $chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE, 1, FALSE, $divisionWidth, $monetaryformatting);
         $chart->drawGrid(4, TRUE, 230, 230, 230, 50);
         //set colors.
         $chart->setColorShades($shades, self::$_colors);
         //Draw the bar chart
         $chart->drawBarGraph($dataSet->GetData(), $dataSet->GetDataDescription(), TRUE, 80, true);
         //get the series values and write at top.
         $chart->setColorPalette(0, 0, 0, 255);
         $dataDesc = $dataSet->GetDataDescription();
         $chart->writeValues($dataSet->GetData(), $dataSet->GetDataDescription(), $dataDesc['Values'], $monetaryformatting, $angleOfIncline);
         //Write the title
         if ($legend) {
             $chart->setFontProperties($pChartPath . "tahoma.ttf", 10);
             $chart->drawTitle(10, 20, $legend, 50, 50, 50);
         }
         if ($xname) {
             $chart->setFontProperties($pChartPath . "tahoma.ttf", 8);
             $chart->drawTitle(0, 90, $xname, 2, 0, 2);
         }
         if ($yname) {
             $chart->setFontProperties($pChartPath . "tahoma.ttf", 8);
             $chart->drawTitle(40, 290, $yname, 2, 0, 20);
         }
         $fileName = "pChartByMonth{$chartCount}" . time() . '.png';
         $chart->Render($uploadDirPath . $fileName);
         //get the file path.
         $filesValues[$chartIndex]['file_name'] = $uploadDirURL . $fileName;
         //get the co-ordinates
         $coords = $chart->coordinates();
         //format the coordinates to make graph clickable.
         $position = 0;
         $chartCoords = array();
         foreach ($chartValues['values'] as $name => $value) {
             $chartCoords[$name] = implode(',', array($coords['xCoords'][$position], $coords['yCoords'][$position], $coords['xCoords'][$position] + $divisionWidth / 2, $y2));
             $position++;
         }
         $filesValues[$chartIndex]['coords'] = $chartCoords;
         //free the chart and data objects.
         unset($chart);
         unset($dataSet);
     }
     return $filesValues;
 }
	/**
 	 * This method return a graph containing information about evaluations
     * inside courses in sessions, it's used inside get_block method for
     * showing it inside dashboard interface
 	 * @return string  img html
 	 */
    public function get_evaluations_courses_in_sessions_graph()
    {
		$graphs = array();
		if (!empty($this->sessions)) {
			$session_ids = array_keys($this->sessions);
			foreach ($session_ids as $session_id) {
				$courses_code = array_keys(Tracking::get_courses_list_from_session($session_id));
				$courses_graph = array();
				foreach ($courses_code as $course_code) {
					$cats = Category::load(null, null, $course_code, null, null, $session_id);
					if (isset($cats) && isset($cats[0])) {
						$alleval = $cats[0]->get_evaluations(null, true, $course_code);
						$alllinks = $cats[0]->get_links(null, true);
						$users = get_all_users($alleval, $alllinks);
						$datagen = new FlatViewDataGenerator ($users, $alleval, $alllinks);
						$evaluation_sumary = $datagen->get_evaluation_sumary_results();
						if (!empty($evaluation_sumary)) {
							$items = array_keys($evaluation_sumary);
							$max = $min = $avg = array();
							foreach ($evaluation_sumary as $evaluation) {
								$max[] = $evaluation['max'];
								$min[] = $evaluation['min'];
								$avg[] = $evaluation['avg'];
							}
							// Dataset definition
						    $data_set = new pData;
						    $data_set->AddPoint($max, "Max");
						    $data_set->AddPoint($avg, "Avg");
						    $data_set->AddPoint($min, "Min");
						    $data_set->AddPoint($items, "Items");
						    $data_set->SetXAxisName(get_lang('EvaluationName'));
							$data_set->SetYAxisName(get_lang('Percentage'));
							$data_set->AddAllSeries();
						   	$data_set->RemoveSerie("Items");
						   	$data_set->SetAbsciseLabelSerie("Items");
						    $graph_id = $this->user_id.'StudentEvaluationGraph';
							$cache = new pCache();
							// the graph id
							$data = $data_set->GetData();
							if ($cache->IsInCache($graph_id, $data)) {
								//if we already created the img
								$img_file = $cache->GetHash($graph_id, $data);
							} else {
								// Initialise the graph
                                $angle = -30;
							    $test = new pChart($this->bg_width, $this->bg_height);
							    $test->setFontProperties(api_get_path(LIBRARY_PATH) . 'pchart/fonts/tahoma.ttf', 8);
                                $test->fixHeightByRotation(
                                    $data_set->GetData(),
                                    $data_set->GetDataDescription(),
                                    $angle
                                );
                                $test->setGraphArea(50, 30, $this->bg_width - 75, $this->bg_height - 75);
                                $test->drawFilledRoundedRectangle(
                                    7,
                                    7,
                                    $this->bg_width - 20,
                                    $test->YSize - 20,
                                    5,
                                    240,
                                    240,
                                    240
                                );
                                $test->drawRoundedRectangle(
                                    5,
                                    5,
                                    $this->bg_width - 18,
                                    $test->YSize - 18,
                                    5,
                                    230,
                                    230,
                                    230
                                );
							    $test->drawGraphArea(255,255,255,TRUE);
							    $test->setFixedScale(0,100,5);
                                $test->drawScale(
                                    $data_set->GetData(),
                                    $data_set->GetDataDescription(),
                                    SCALE_ADDALL,
                                    150,
                                    150,
                                    150,
                                    TRUE,
                                    $angle,
                                    2,
                                    TRUE
                                );
							    $test->setColorPalette(0,105,221,34);
								$test->setColorPalette(1,255,135,30);
								$test->setColorPalette(2,255,0,0);
							    $test->drawGrid(4,TRUE,230,230,230,50);
							    // Draw the 0 line
							    $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6);
							    $test->drawTreshold(0,143,55,72,TRUE,TRUE);
							    // Draw the bar graph
							    $test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100);
							    // Finish the graph
							    $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
							    $test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
							    $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
							    $test->setColorPalette(0,50,50,50);
								$test->setColorPalette(1,50,50,50);
								$test->setColorPalette(2,50,50,50);
							    $test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
							    $cache->WriteToCache($graph_id, $data_set->GetData(), $test);
								ob_start();
								$test->Stroke();
								ob_end_clean();
								$img_file = $cache->GetHash($graph_id, $data_set->GetData());
							}
							if (!empty($img_file)) {
								$courses_graph[$course_code] = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">';
							}
						}
					}
				}
				if (!empty($courses_graph)) {
					$graphs[$session_id] = $courses_graph;
				}
			}
		}
    	return $graphs;
 	}
Example #29
-1
function pie($data, $title, $filename, $colors = null)
{
    $keys = array();
    foreach ($data['keys'] as $k) {
        array_push($keys, wordwrap($k, 20, "\r\n"));
    }
    // Dataset definition
    $DataSet = new pData();
    $DataSet->AddPoint($data['values'], "Serie1");
    $DataSet->AddPoint($keys, "Serie2");
    $DataSet->AddAllSeries();
    $DataSet->SetAbsciseLabelSerie("Serie2");
    // Initialise the graph
    $maxlen = 20;
    $w = 400 + $maxlen * 6;
    $pie = new pChart($w, 250);
    $pie->drawFilledRoundedRectangle(2, 2, $w - 3, 247, 5, 240, 240, 240);
    $pie->drawRoundedRectangle(0, 0, $w - 1, 249, 5, 230, 230, 230);
    if ($colors == null) {
        $pie->loadColorPalette('chartcolors.txt', ',');
    } else {
        for ($i = 0; $i < count($colors); $i++) {
            $a = $colors[$i];
            $pie->setColorPalette($i, $a[0], $a[1], $a[2]);
        }
    }
    // Draw the pie chart
    $pie->setFontProperties("Fonts/consola.ttf", 8);
    $pie->AntialiasQuality = 0;
    $pie->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 200, 110, 110, PIE_PERCENTAGE_LABEL, FALSE, 50, 20, 5);
    $pie->drawPieLegend(350, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
    // Write the title
    $pie->setFontProperties("Fonts/MankSans.ttf", 10);
    $pie->drawTitle(10, 20, $title, 100, 100, 100);
    $pie->Render($filename);
}
Example #30
-1
 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);
 }