Esempio n. 1
0
 private function sourceGraph()
 {
     $q = ezcDbInstance::get()->createSelectQuery();
     $q->select('source, count(source)')->from('message')->groupBy('source');
     $s = $q->prepare();
     $s->execute();
     $chart = new ezcGraphPieChart();
     $chart->title = 'Sources';
     $chart->legend = false;
     $chart->palette = new ezcGraphPaletteEz();
     $chart->data['browsers'] = new ezcGraphDatabaseDataSet($s);
     $chart->render(300, 200, '/tmp/graph.png');
     return file_get_contents('/tmp/graph.png');
 }
Esempio n. 2
0
 public function __construct(array $options = array())
 {
     parent::__construct($options);
     $this->driver = new ezcGraphSvgDriver();
     $this->renderer = new ezcGraphRenderer3d();
     $this->palette = new ezcGraphPaletteEzBlue();
     $this->title = 'Test chart';
     $this->data['testdata'] = new ezcGraphArrayDataSet(array('foo' => 123, 'bar' => 43, 'blubb' => 453));
 }
Esempio n. 3
0
 public function testRenderPieChartWithGleamAndShadow()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->data['sample']->highlight['Opera'] = true;
     $chart->renderer->options->legendSymbolGleam = 0.5;
     $chart->renderer->options->pieChartShadowSize = 5;
     $chart->renderer->options->pieChartGleamBorder = 3;
     $chart->renderer->options->pieChartGleam = 0.5;
     $chart->driver = new ezcGraphSvgDriver();
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->title = 'Elections 2005 Germany';
$graph->data['2005'] = new ezcGraphArrayDataSet(array('CDU' => 35.2, 'SPD' => 34.2, 'FDP' => 9.800000000000001, 'Die Gruenen' => 8.1, 'PDS' => 8.699999999999999, 'NDP' => 1.6, 'REP' => 0.6));
$graph->options->label = '%3$.1f%%';
$graph->options->sum = 100;
$graph->options->percentThreshold = 0.02;
$graph->options->summarizeCaption = 'Others';
$graph->render(400, 150, 'tutorial_pie_options.svg');
Esempio n. 5
0
<?php

require 'Base/src/base.php';
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Require custom palette
require dirname(__FILE__) . '/ez_green.php';
// Create the graph
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzGreen();
$graph->legend = false;
// Add the data and hilight norwegian data set
$graph->data['week'] = new ezcGraphArrayDataSet(array('Lukasz Serwatka' => 1805, 'Paul Forsyth' => 1491, 'Paul Borgermans' => 1316, 'Kristof Coomans' => 956, 'Alex Jones' => 942, 'Bard Farstad' => 941, 'Tony Wood' => 900));
// Set graph title
$graph->title = 'Alltime 10 most active users on forum';
// Use 3d renderer, and beautify it
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->pieChartShadowSize = 12;
$graph->renderer->options->pieChartGleam = 0.5;
$graph->renderer->options->dataBorder = false;
$graph->renderer->options->pieChartHeight = 16;
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->renderer->options->pieChartOffset = 100;
$graph->driver = new ezcGraphSvgDriver();
// Output the graph with std SVG driver
$graph->render(500, 200, 'forum_year.svg');
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzGreen();
$graph->title = 'Access statistics';
$graph->driver = new ezcGraphGdDriver();
$graph->options->font = 'tutorial_font.ttf';
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->data['Access statistics']->url = 'http://example.org/';
$graph->data['Access statistics']->url['Mozilla'] = 'http://example.org/mozilla';
$graph->render(400, 200, 'tutorial_reference_gd.png');
?>
<html>
    <head><title>Image map example</title></head>
<body>
<?php 
echo ezcGraphTools::createImageMap($graph, 'GraphPieChartMap');
?>
    <img
        src="tutorial_reference_gd.png"
        width="400" height="200"
        usemap="#GraphPieChartMap" />
</body>
</html>
Esempio n. 7
0
 /**
  * Creates and prints the pie chart in the statistic
  *
  * @param String $type
  *
  * @static
  *
  */
 static function printPieChart($type = 'tech')
 {
     global $CFG_GLPI;
     // Definition of Chart Labels
     $label = array('tech' => __('Rating by the user', 'helpdeskrating'), 'user' => __('Rating by the technician', 'helpdeskrating'));
     $uid = PluginHelpdeskratingStatistic::getUserID();
     if ($uid) {
         // Get Graph Data
         $data = PluginHelpdeskratingStatistic::getSpreadingData($type);
         if ($data[__('in progress', 'helpdeskrating')] == 0 && $data[__('closed', 'helpdeskrating')] == 0 && $data[__('rated', 'helpdeskrating')] == 0) {
             echo "<h1>{$label[$type]}</h1>";
             echo __('no data available', 'helpdeskrating');
         } else {
             // Create Graph
             $graph = new ezcGraphPieChart();
             $graph->title = $label[$type];
             // Set Graph Data
             $graph->data['data'] = new ezcGraphArrayDataSet($data);
             // Graph Legend
             $graph->legend->position = ezcGraph::BOTTOM;
             $graph->data['data']->color[__('in progress', 'helpdeskrating')] = '#55575388';
             $graph->data['data']->highlight[__('in progress', 'helpdeskrating')] = true;
             $graph->data['data']->color[__('closed', 'helpdeskrating')] = '#F5900080';
             $graph->data['data']->color[__('rated', 'helpdeskrating')] = '#4E9A0680';
             // Graph Output
             $filename = $uid . '_' . mt_rand() . '.svg';
             $graph->render(400, 300, GLPI_GRAPH_DIR . '/' . $filename);
             echo "<object data='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$filename}'\n                        type='image/svg+xml' width='400' height='300'>\n                        <param name='src' value='" . $CFG_GLPI['root_doc'] . "/front/graph.send.php?file={$filename}'>\n                        You need a browser capeable of SVG to display this image.\n                        </object> ";
         }
     }
 }
Esempio n. 8
0
function graph_pie($p_metrics, $p_title = '', $p_graph_width = 500, $p_graph_height = 350, $p_center = 0.4, $p_poshorizontal = 0.1, $p_posvertical = 0.09)
{
    $t_graph_font = graph_get_font();
    error_check(is_array($p_metrics) ? array_sum($p_metrics) : 0, $p_title);
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphPieChart();
        $graph->title = $p_title;
        $graph->background->color = '#FFFFFF';
        $graph->options->font = $t_graph_font;
        $graph->options->font->maxFontSize = 12;
        $graph->legend = false;
        $graph->data[0] = new ezcGraphArrayDataSet($p_metrics);
        $graph->data[0]->color = '#FFFF00';
        $graph->renderer = new ezcGraphRenderer3d();
        $graph->renderer->options->dataBorder = false;
        $graph->renderer->options->pieChartShadowSize = 10;
        $graph->renderer->options->pieChartGleam = 0.5;
        $graph->renderer->options->pieChartHeight = 16;
        $graph->renderer->options->legendSymbolGleam = 0.5;
        $graph->driver = new ezcGraphGdDriver();
        //$graph->driver->options->supersampling = 1;
        $graph->driver->options->jpegQuality = 100;
        $graph->driver->options->imageFormat = IMG_JPEG;
        $graph->renderer->options->syncAxisFonts = false;
        $graph->renderToOutput($p_graph_width, $p_graph_height);
    } else {
        $graph = new PieGraph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(40, 40, 40, 100);
        $graph->title->Set($p_title);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->legend->Pos($p_poshorizontal, $p_posvertical);
        $graph->legend->SetFont($t_graph_font);
        $p1 = new PiePlot3d(array_values($p_metrics));
        // should be reversed?
        $p1->SetTheme('earth');
        # $p1->SetTheme("sand");
        $p1->SetCenter($p_center);
        $p1->SetAngle(60);
        $p1->SetLegends(array_keys($p_metrics));
        # Label format
        $p1->value->SetFormat('%2.0f');
        $p1->value->Show();
        $p1->value->SetFont($t_graph_font);
        $graph->Add($p1);
        if (helper_show_query_count()) {
            $graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)');
            $graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
        }
        $graph->Stroke();
    }
}
Esempio n. 9
0
 public function testSvgWithDifferentLocales()
 {
     $this->setLocale(LC_NUMERIC, 'de_DE', 'de_DE.UTF-8', 'de_DE.UTF8', 'deu_deu', 'de', 'ge', 'deutsch', 'de_DE@euro');
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->palette = new ezcGraphPaletteEz();
     $chart->options->font = $this->basePath . 'font.svg';
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->data['sample']->highlight['Safari'] = true;
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->renderer->options->pieChartShadowSize = 10;
     $chart->renderer->options->pieChartGleam = 0.5;
     $chart->renderer->options->dataBorder = false;
     $chart->renderer->options->pieChartHeight = 16;
     $chart->renderer->options->legendSymbolGleam = 0.5;
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Esempio n. 10
0
 public function testRenderLabeledFlashPieChart()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.swf';
     $chart = new ezcGraphPieChart();
     $chart->options->font->path = dirname(__FILE__) . '/data/fdb_font.fdb';
     $chart->palette = new ezcGraphPaletteEz();
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->data['sample']->highlight['Safari'] = true;
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->renderer->options->pieChartShadowSize = 10;
     $chart->renderer->options->pieChartGleam = 0.5;
     $chart->renderer->options->dataBorder = false;
     $chart->renderer->options->pieChartHeight = 16;
     $chart->renderer->options->legendSymbolGleam = 0.5;
     $chart->driver = new ezcGraphFlashDriver();
     $chart->render(500, 200, $filename);
     $this->swfCompare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.swf');
 }
Esempio n. 11
0
 public function testPieChartWithoutData()
 {
     try {
         $pieChart = new ezcGraphPieChart();
         $pieChart->render(400, 200);
     } catch (ezcGraphNoDataException $e) {
         return true;
     }
     $this->fail('Expected ezcGraphNoDataException.');
 }
Esempio n. 12
0
 public function testBottomLegend()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->legend->position = ezcGraph::BOTTOM;
     $chart->legend->padding = 2;
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->title = 'Access statistics';
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->data['Access statistics']->highlight['Opera'] = true;
$graph->render(400, 150, 'tutorial_simple_pie.svg');
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->title = 'Access statistics';
$graph->options->font->name = 'serif';
$graph->title->background = '#EEEEEC';
$graph->title->font->name = 'sans-serif';
$graph->options->font->maxFontSize = 8;
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->render(400, 150, 'tutorial_chart_title.svg');
Esempio n. 15
0
<?php

/* -*- mode: php; c-basic-offset: 4; indent-tabs-mode: nil; -*-
 * vim:expandtab:shiftwidth=4:tabstop=4:
 */
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->legend = false;
$graph->data['File number per ' . $index] = new ezcGraphArrayDataSet($count);
$graph->data['File number per ' . $index]->highlight['Others'] = true;
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->moveOut = 0.2;
$graph->renderer->options->pieChartOffset = 63;
$graph->renderer->options->pieChartGleam = 0.3;
$graph->renderer->options->pieChartGleamColor = '#FFFFFF';
$graph->renderer->options->pieChartGleamBorder = 2;
$graph->renderer->options->pieChartShadowSize = 5;
$graph->renderer->options->pieChartShadowColor = '#BABDB6';
$graph->renderer->options->pieChartHeight = 5;
$graph->renderer->options->pieChartRotation = 0.8;
$graph->driver = new ezcGraphGdDriver();
$graph->options->font = 'app/img/arial.ttf';
$graph->driver->options->imageFormat = IMG_PNG;
$graph->render(532, 195, 'app/img/graph/countPieGraph.png');
echo '<h2>File number per ' . $index . '</h2>';
?>

<img src="app/img/graph/countPieGraph.png"/>
<table class="simple">
     <thead>
        <tr>
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzRed();
$graph->title = 'Access statistics';
$graph->options->label = '%2$d (%3$.1f%%)';
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->data['Access statistics']->highlight['Explorer'] = true;
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->moveOut = 0.2;
$graph->renderer->options->pieChartOffset = 63;
$graph->renderer->options->pieChartGleam = 0.3;
$graph->renderer->options->pieChartGleamColor = '#FFFFFF';
$graph->renderer->options->pieChartShadowSize = 5;
$graph->renderer->options->pieChartShadowColor = '#000000';
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->renderer->options->legendSymbolGleamSize = 0.9;
$graph->renderer->options->legendSymbolGleamColor = '#FFFFFF';
$graph->renderer->options->pieChartSymbolColor = '#55575388';
$graph->renderer->options->pieChartHeight = 5;
$graph->renderer->options->pieChartRotation = 0.8;
$graph->render(400, 150, 'tutorial_pie_chart_3d.svg');
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEz();
$graph->title = 'Access statistics';
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->data['Access statistics']->url = 'http://example.org/';
$graph->data['Access statistics']->url['Mozilla'] = 'http://example.org/mozilla';
$graph->render(400, 200, 'tutorial_reference_svg.svg');
$graph->driver->options->linkCursor = 'crosshair';
ezcGraphTools::linkSvgElements($graph);
<?php

require_once 'tutorial_insert_data.php';
// Receive data from database
$db = ezcDbInstance::get();
$query = $db->createSelectQuery();
$query->select('browser', 'hits')->from('browser_hits');
$statement = $query->prepare();
$statement->execute();
// Create chart from data
$chart = new ezcGraphPieChart();
$chart->title = 'Browser statistics';
$chart->data['browsers'] = new ezcGraphDatabaseDataSet($statement);
$chart->render(400, 200, 'tutorial_simple.svg');
Esempio n. 19
0
 public function testPieChartSvgLinkingCustomCursor()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->data['sample']->url = 'http://example.org/browsers';
     $chart->data['sample']->url['Mozilla'] = 'http://example.org/browsers/mozilla';
     $chart->data['sample']->highlight['Opera'] = true;
     $chart->driver->options->linkCursor = 'crosshair';
     $chart->render(500, 200, $filename);
     ezcGraphTools::linkSvgElements($chart);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphPieChart();
$graph->title = 'Access statistics';
$graph->legend = false;
$graph->driver = new ezcGraphFlashDriver();
$graph->options->font = 'tutorial_font.fdb';
$graph->driver->options->compression = 7;
$graph->data['Access statistics'] = new ezcGraphArrayDataSet(array('Mozilla' => 19113, 'Explorer' => 10917, 'Opera' => 1464, 'Safari' => 652, 'Konqueror' => 474));
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->pieChartShadowSize = 10;
$graph->renderer->options->pieChartGleam = 0.5;
$graph->renderer->options->dataBorder = false;
$graph->renderer->options->pieChartHeight = 16;
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->render(400, 200, 'tutorial_driver_flash.swf');
Esempio n. 21
0
 public function testRender3dPieChartWithOneDataPoint()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['Skien'] = new ezcGraphArrayDataSet(array('Norwegian' => 10));
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->renderer->options->dataBorder = false;
     $chart->render(500, 300, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Esempio n. 22
0
 /**
  * Generates a crash report OS version distribution graph for currently 
  * selected project and dumps it to stdout.
  * @param type $w Desired image width.
  * @param type $h Desired image height.
  * @throws CHttpException
  * @return void
  */
 public static function generateOSVersionDistributionGraph($w, $h, $file = null)
 {
     if (!is_numeric($w) || $w <= 0 || $w > 1024) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     if (!is_numeric($h) || $h <= 0 || $h > 960) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Get current project info
     $curProjectId = Yii::app()->user->getCurProjectId();
     if ($curProjectId == false) {
         throw new CHttpException(403, 'Invalid parameter');
     }
     // Prepare data
     $criteria = new CDbCriteria();
     $criteria->select = 'os_name_reg, COUNT(*) as cnt';
     $criteria->order = 'cnt DESC';
     $criteria->group = 'os_name_reg';
     $criteria->compare('t.project_id', $curProjectId);
     $curVer = '(not set)';
     $versions = Yii::app()->user->getCurProjectVersions($curVer);
     if ($curVer != -1) {
         $criteria->compare('appversion_id', $curVer == 0 ? null : $curVer);
     }
     $data = array();
     $models = CrashReport::model()->findAll($criteria);
     $totalCount = 0;
     foreach ($models as $model) {
         $totalCount += $model->cnt;
     }
     $itemCount = 0;
     $others = 0;
     foreach ($models as $model) {
         $itemCount++;
         if ($itemCount > 10) {
             $others += $model->cnt;
             continue;
         }
         $osName = strlen($model->os_name_reg) != 0 ? $model->os_name_reg : "(not set)";
         $percent = 100 * $model->cnt / $totalCount;
         $label = sprintf('(%0.1f%%) %s', $percent, $osName);
         $label = MiscHelpers::addEllipsis($label, 60);
         if (array_key_exists($label, $data)) {
             $data[$label] += $model->cnt;
         } else {
             $data[$label] = $model->cnt;
         }
     }
     if ($others > 0) {
         // Add 'Others'
         $percent = 100 * $others / $totalCount;
         $label = sprintf('(%0.1f%%) Others', $percent);
         $data[$label] = $others;
     }
     // Check the case when $data is empty.
     if (count($data) == 0) {
         // Open out file
         if ($file != null) {
             $fout = @fopen($file, 'w');
             if ($fout == false) {
                 @unlink($tmpfile);
                 throw new CHttpException(403, 'Invalid file.');
             }
         }
         // No data available
         $fileName = Yii::app()->basePath . '/../images/no_data_available.png';
         if ($fd = @fopen($fileName, "r")) {
             $fsize = filesize($fileName);
             // Write HTTP headers
             header("Content-type: image/png");
             //header("Content-Disposition: filename=\"".$fileName."\"");
             header("Content-length: {$fsize}");
             header("Cache-control: private");
             //use this to open files directly
             // Write file content
             while (!feof($fd)) {
                 $buffer = fread($fd, 2048);
                 if ($file == null) {
                     echo $buffer;
                 } else {
                     fwrite($fout, $buffer);
                 }
             }
             if ($file != null) {
                 fclose($fout);
             }
             fclose($fd);
         }
         return;
     }
     $graph = new ezcGraphPieChart();
     $graph->palette = new ezcGraphPaletteEzGreen();
     $graph->data['Versions'] = new ezcGraphArrayDataSet($data);
     $graph->legend = true;
     $graph->legend->position = ezcGraph::RIGHT;
     $graph->legend->landscapeSize = 0.5;
     $graph->legend->portraitSize = 0.5;
     $graph->options->sum = $totalCount;
     //$graph->options->summarizeCaption = 'Others';
     $graph->options->label = '%3$.1f%%';
     $graph->options->font->name = 'Tahoma';
     $graph->options->font->maxFontSize = 14;
     $graph->options->font->minFontSize = 1;
     $graph->renderer = new ezcGraphRenderer3d();
     $graph->renderer->options->pieChartRotation = 0.8;
     $graph->renderer->options->pieChartShadowSize = 10;
     //$graph->renderer->options->pieChartGleam = .3;
     //$graph->renderer->options->pieChartGleamColor = '#FFFFFF';
     //$graph->renderer->options->pieChartGleamBorder = 2;
     if ($file === null) {
         $graph->renderToOutput($w, $h);
     } else {
         $graph->render($w, $h, $file);
     }
 }
Esempio n. 23
0
 public function testRenderer3dPieChartMissingLabels()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['TestCase'] = new ezcGraphArrayDataSet(array('Big' => 2.9, 'Small 1' => 0.03, 'Small 2' => 0.04, 'Small 3' => 0.03, 'Last' => 1));
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->renderer->options->dataBorder = false;
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Esempio n. 24
0
 /**
  *  Obtiene los necesarios para ver la asistencias de alumnos
  *
  **/
 protected function obtenerDatos()
 {
     Misc::use_helper('Misc');
     //Iniciando Variables
     $alumno_id = -1;
     $cuenta_id = -1;
     $vista_id = 1;
     // default para vista DIARIO
     $division_id = 0;
     $carrera_id = 0;
     $datos = array();
     $idxAlumno = array();
     $aFeriado = array();
     $aIntervalo = array();
     $optionsDivision = array();
     $optionsCarrera = array();
     $aTemp = array();
     $aFechaTemp = array();
     $aTipoasistencias = array();
     $aPorcentajeAsistencia = array();
     $flag_error = 0;
     $nombre_completo_archivo = "";
     $bool_gd = array_search("gd", get_loaded_extensions());
     // Tomando los datos del formulario y completando variable
     $ciclolectivo_id = $this->getUser()->getAttribute('fk_ciclolectivo_id');
     $ciclolectivo = CiclolectivoPeer::retrieveByPK($ciclolectivo_id);
     $ciclolectivo_fecha_inicio = strtotime($ciclolectivo->getFechaInicio());
     $ciclolectivo_fecha_fin = strtotime($ciclolectivo->getFechaFin());
     // Asigno la fecha de inicio del ciclo lectivo por defecto
     $aFechaActual = getdate($ciclolectivo_fecha_inicio);
     // Tomo el año de la fecha de inicio y de fin del ciclo lectivo
     $anio_desde = date("Y", $ciclolectivo_fecha_inicio);
     $anio_hasta = date("Y", $ciclolectivo_fecha_fin);
     if ($this->getRequestParameter('dia')) {
         $d = $this->getRequestParameter('dia');
     } else {
         $d = $aFechaActual['mday'];
     }
     if ($this->getRequestParameter('mes')) {
         $m = $this->getRequestParameter('mes');
     } else {
         $m = $aFechaActual['mon'];
     }
     if ($this->getRequestParameter('ano')) {
         $y = $this->getRequestParameter('ano');
     } else {
         $y = $aFechaActual['year'];
     }
     if ($this->getRequestParameter('alumno_id')) {
         $alumno_id = $this->getRequestParameter('alumno_id');
         $a = AlumnoPeer::retrieveByPK($alumno_id);
         $cuenta_id = $a->getFkCuentaId();
     }
     if ($this->getRequestParameter('carrera_id')) {
         $carrera_id = $this->getRequestParameter('carrera_id');
     }
     if ($this->getRequestParameter('vistas')) {
         $vista_id = $this->getRequestParameter('vistas');
     }
     $establecimiento_id = $this->getUser()->getAttribute('fk_establecimiento_id');
     $criteria = new Criteria();
     $criteria->add(AnioPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id);
     if ($this->getRequestParameter('alumno_id')) {
         $criteria->add(RelAlumnoDivisionPeer::FK_ALUMNO_ID, $alumno_id);
         $criteria->addJoin(RelAlumnoDivisionPeer::FK_DIVISION_ID, DivisionPeer::ID);
     }
     if ($this->getRequestParameter('carrera_id')) {
         $criteria->add(AnioPeer::FK_CARRERA_ID, $carrera_id);
     }
     $criteria->addAscendingOrderByColumn(AnioPeer::DESCRIPCION);
     $criteria->addAscendingOrderByColumn(DivisionPeer::ORDEN);
     $criteria->addAscendingOrderByColumn(DivisionPeer::DESCRIPCION);
     $divisiones = DivisionPeer::doSelectJoinAnio($criteria);
     // divisiones a mostrar
     foreach ($divisiones as $division) {
         $optionsDivision[$division->getId()] = $division->__toString();
     }
     if ($this->getRequestParameter('division_id')) {
         $division_id = $this->getRequestParameter('division_id');
     } else {
         if (count($optionsDivision) > 0) {
             $aTemp = array_keys($optionsDivision);
             $division_id = $aTemp[0];
         } else {
             // Ver si se puede hacer desde el validate
             $this->getRequest()->setError('Division', 'No hay Ninguna División cargada');
             $flag_error = 1;
         }
     }
     $cCarrera = new Criteria();
     $cCarrera->add(CarreraPeer::FK_ESTABLECIMIENTO_ID, $establecimiento_id);
     $carreras = CarreraPeer::doSelect($cCarrera);
     foreach ($carreras as $carrera) {
         $optionsCarrera[$carrera->getId()] = $carrera->getDescripcion();
     }
     if (!checkdate($m, $d, $y)) {
         // Ver si se puede hacer desde el validate
         $this->getRequest()->setError('Fecha', 'La fecha ingresada es erronea');
         $flag_error = 1;
     }
     if ($flag_error == 0) {
         // devuelve un intervalo de dias según vista y fecha seleccionada
         $aIntervalo = diasxintervalo($d, $m, $y, $vista_id);
         // chequeo si el intervalo de fechas generados esta o no dentro de las fechas validas del ciclo lectivo
         foreach ($aIntervalo as $fecha) {
             $fecha_intervalo = strtotime($fecha);
             if ($fecha_intervalo >= $ciclolectivo_fecha_inicio and $fecha_intervalo <= $ciclolectivo_fecha_fin) {
                 $aFechaTemp[] = $fecha;
             }
         }
         $aIntervalo = $aFechaTemp;
     }
     // obteniendo los feriados actuales
     $criteria = new Criteria();
     $feriados = FeriadoPeer::doSelect($criteria);
     foreach ($feriados as $feriado) {
         $aFeriado[$feriado->getFecha()] = $feriado->getNombre();
     }
     // esto deberia estar hecho muy diferente guardar en un /tmp con archivo aleatorio
     if (file_exists(sfConfig::get('sf_upload_dir_name') . '/grafico_asistencias.png')) {
         unlink(sfConfig::get('sf_upload_dir_name') . '/grafico_asistencias.png');
     }
     if (count($aIntervalo) > 0) {
         //Obtener los alumnos de la division y asistencias en el rango de fecha
         //$con = sfContext::getInstance()->getDatabaseConnection($connection='propel');
         $con = Propel::getConnection();
         $s = "SELECT alumno.id, alumno.nombre, alumno.apellido, alumno.apellido_materno,";
         $s .= "tipoasistencia.descripcion, tipoasistencia.nombre AS asistencia, asistencia.fecha,";
         $s .= "asistencia.fk_tipoasistencia_id ";
         $s .= "FROM alumno, rel_alumno_division ";
         $s .= "LEFT JOIN asistencia ON ( rel_alumno_division.FK_ALUMNO_ID = asistencia.FK_ALUMNO_ID ";
         $s .= "AND asistencia.FECHA ";
         $s .= "IN (";
         for ($i = 0, $max = count($aIntervalo); $i < $max; $i++) {
             $s .= "'" . $aIntervalo[$i] . " 00:00:00'";
             if ($i < count($aIntervalo) - 1) {
                 $s .= ",";
             }
         }
         $s .= ") ) ";
         $s .= "LEFT JOIN tipoasistencia ON ( asistencia.FK_TIPOASISTENCIA_ID = tipoasistencia.ID ) ";
         $s .= "WHERE ";
         if ($alumno_id >= 0) {
             $s .= "alumno.ID =" . $alumno_id;
         } else {
             $s .= "rel_alumno_division.FK_DIVISION_ID =" . $division_id;
         }
         $s .= " AND rel_alumno_division.FK_ALUMNO_ID = alumno.ID";
         $s .= " ORDER BY alumno.apellido,alumno.apellido_materno,alumno.nombre,asistencia.FECHA";
         $stmt = $con->prepare($s);
         $alumnos = $stmt->execute();
         $totales = array();
         $tot = 0;
         while ($alumno = $stmt->fetch(PDO::FETCH_ASSOC)) {
             $idxAlumno[$alumno['id']] = $alumno['apellido'] . " " . $alumno['apellido_materno'] . " " . $alumno['nombre'];
             if ($alumno['fecha']) {
                 $datos[$alumno['id']][$alumno['fecha']] = $alumno['asistencia'];
                 @$totales[$alumno['asistencia']]++;
             }
         }
         $aTipoasistencias = $this->getTiposasistencias();
         $aPorcentajeAsistencia = array();
         $flag = 0;
         // cantidad de fechas sin fines de semana
         $cantFechas = 0;
         foreach ($aIntervalo as $fecha) {
             if (!(date("w", strtotime($fecha)) == 6) and !(date("w", strtotime($fecha)) == 0)) {
                 $cantFechas++;
             }
         }
         $dias = $cantFechas * count($idxAlumno);
         foreach ($aTipoasistencias as $idx => $Tipoasistencia) {
             $aPorcentajeAsistencia[$idx] = isset($totales[$idx]) ? number_format($totales[$idx] * 100 / $dias, 2) : number_format(0, 2);
             $tot += isset($totales[$idx]) ? number_format($totales[$idx], 2) : number_format(0, 2);
             if ($aPorcentajeAsistencia[$idx] != 0) {
                 $flag = 1;
             }
         }
         if ($flag == 1) {
             $aTitulo = array_keys($aTipoasistencias);
             $aTitulo[] = "No Cargado";
             if ($bool_gd) {
                 // Si no tiene cargado la GD no muestra el grafico
                 // Genera nombre de archivo único
                 $nombre_archivo = uniqid();
                 $nombre_completo_archivo = $nombre_archivo . '.jpg';
                 // nueva clase para grafico de tortas
                 $graph = new ezcGraphPieChart();
                 // uso driver GD pero podria ser SVG o Ming
                 $graph->driver = new ezcGraphGdDriver();
                 $graph->driver->options->supersampling = 1;
                 $graph->driver->options->jpegQuality = 100;
                 $graph->driver->options->imageFormat = IMG_JPEG;
                 // Color de fondo del grafico
                 $graph->background->color = '#FFFFFF';
                 // De donde sacar la letra
                 $graph->options->font = realpath(sfConfig::get('sf_lib_dir') . "/font/FreeSerifBold.ttf");
                 $graph->options->font->maxFontSize = 9;
                 //     $graph->title = "Asistencia";
                 // Cargo datos de la asistencia
                 $graph->data['Asistencia'] = new ezcGraphArrayDataSet($aPorcentajeAsistencia);
                 // tamaño del symbolo de la lista
                 $graph->legend->symbolSize = 10;
                 // se selecciona las opciones graficas
                 $graph->renderer = new ezcGraphRenderer3d();
                 $graph->renderer->options->moveOut = 0.01;
                 $graph->renderer->options->pieChartShadowSize = 10;
                 // $graph->renderer->options->pieChartGleam = .5;
                 $graph->renderer->options->dataBorder = false;
                 $graph->renderer->options->pieChartHeight = 16;
                 $graph->renderer->options->legendSymbolGleam = 0.5;
                 //graba archivo de imagen
                 $graph->render(400, 250, sfConfig::get('app_alba_tmpdir') . DIRECTORY_SEPARATOR . $nombre_completo_archivo);
             }
         }
     }
     //Asignacion de variables para el template
     $this->bool_tmp = is_writable(sfConfig::get('app_alba_tmpdir'));
     $this->bool_gd = $bool_gd;
     $this->nombre_completo_archivo = $nombre_completo_archivo;
     $this->d = $d;
     $this->m = $m;
     $this->y = $y;
     $this->aTipoasistencias = $aTipoasistencias;
     $this->aAlumnos = $idxAlumno;
     $this->aDatos = $datos;
     $this->optionsDivision = $optionsDivision;
     $this->optionsCarrera = $optionsCarrera;
     $this->aVistas = repeticiones();
     $this->aMeses = Meses();
     $this->aIntervalo = $aIntervalo;
     $this->aPorcentajeAsistencia = $aPorcentajeAsistencia;
     $this->aFeriado = $aFeriado;
     $this->alumno_id = $alumno_id;
     $this->cuenta_id = $cuenta_id;
     $this->vista_id = $vista_id;
     $this->division_id = $division_id;
     $this->carrera_id = $carrera_id;
     $this->anio_desde = $anio_desde;
     $this->anio_hasta = $anio_hasta;
 }
Esempio n. 25
0
<?php

require 'Base/src/base.php';
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Require custom palette
require dirname(__FILE__) . '/ez_red.php';
// Create the graph
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzRed();
$graph->legend = false;
// Add the data and hilight norwegian data set
$graph->data['week'] = new ezcGraphArrayDataSet(array('Claudia Kosny' => 128, 'Kristof Coomans' => 70, 'Xavier Dutoit' => 64, 'David Jones' => 58, 'Lukasz Serwatka' => 45, 'Norman Leutner' => 22, 'Marko Zmak' => 20, 'sangib das' => 20, 'Nabil Alimi' => 19));
// Set graph title
$graph->title = '10 most active users on forum in last month';
// Use 3d renderer, and beautify it
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->pieChartShadowSize = 12;
$graph->renderer->options->pieChartGleam = 0.5;
$graph->renderer->options->dataBorder = false;
$graph->renderer->options->pieChartHeight = 16;
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->renderer->options->pieChartOffset = 100;
$graph->driver = new ezcGraphSvgDriver();
// Output the graph with std SVG driver
$graph->render(500, 200, 'forum_month.svg');
Esempio n. 26
0
<?php

require 'Base/src/base.php';
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Create the graph
$graph = new ezcGraphPieChart();
// Add the data and hilight norwegian data set
$graph->data['articles'] = new ezcGraphArrayDataSet(array('English' => 1300000, 'Germany' => 452000, 'Netherlands' => 217000, 'Norway' => 70000));
$graph->data['articles']->highlight['Norway'] = true;
// Set graph title
$graph->title = 'Articles by country';
// Modify pie chart label to only show amount and percent
$graph->options->label = '%2$d (%3$.1f%%)';
// Use 3d renderer, and beautify it
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->pieChartShadowSize = 12;
$graph->renderer->options->pieChartGleam = 0.5;
$graph->renderer->options->dataBorder = false;
$graph->renderer->options->pieChartHeight = 16;
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->renderer->options->pieChartOffset = 100;
// Output the graph with std SVG driver
$graph->render(500, 200, 'wiki_graph.svg');
Esempio n. 27
0
if (array_key_exists(TYPE, $acct_schema)) {
    $header = $header . "<th>Type</th>";
}
if (array_key_exists(STATUS, $acct_schema)) {
    $header = $header . "<th>Status</th>";
}
$header = $header . "<th>Blocks</th>";
$header = $header . "<th>Size</th>";
$header = $header . "<th>Count</th>";
$header = $header . "</tr> </thead>";
// display the table
generateMergedTable($tab, $header);
if (isset($user_status)) {
    // build status chart
    /*TODO Generalize pie chart generation*/
    $graph = new ezcGraphPieChart();
    $graph->palette = new ezcGraphPaletteEzBlue();
    $graph->legend = false;
    $title = 'Status repartition for user ' . $user . ' (count)';
    $graph->data[$title] = new ezcGraphArrayDataSet($user_status);
    $graph->renderer = new ezcGraphRenderer3d();
    $graph->renderer->options->moveOut = 0.2;
    $graph->renderer->options->pieChartOffset = 63;
    $graph->renderer->options->pieChartGleam = 0.3;
    $graph->renderer->options->pieChartGleamColor = '#FFFFFF';
    $graph->renderer->options->pieChartGleamBorder = 2;
    $graph->renderer->options->pieChartShadowSize = 5;
    $graph->renderer->options->pieChartShadowColor = '#BABDB6';
    $graph->renderer->options->pieChartHeight = 5;
    $graph->renderer->options->pieChartRotation = 0.8;
    $graph->driver = new ezcGraphGdDriver();
Esempio n. 28
0
 public function testRenderPieChartBackgroundColorShortcut()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphPieChart();
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->background = '#2e3436';
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Esempio n. 29
0
 /**
  * Constructs a new pie chart instance.
  */
 public function __construct()
 {
     parent::__construct();
     $this->init();
 }
Esempio n. 30
0
<?php

/* -*- mode: php; c-basic-offset: 4; indent-tabs-mode: nil; -*-
 * vim:expandtab:shiftwidth=4:tabstop=4:
 */
$graph = new ezcGraphPieChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->legend = false;
$graph->data['Volume per group'] = new ezcGraphArrayDataSet($top_size);
$graph->data['Volume per group']->highlight['Others'] = true;
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->moveOut = 0.2;
$graph->renderer->options->pieChartOffset = 63;
$graph->renderer->options->pieChartGleam = 0.3;
$graph->renderer->options->pieChartGleamColor = '#FFFFFF';
$graph->renderer->options->pieChartGleamBorder = 2;
$graph->renderer->options->pieChartShadowSize = 5;
$graph->renderer->options->pieChartShadowColor = '#BABDB6';
$graph->renderer->options->pieChartHeight = 5;
$graph->renderer->options->pieChartRotation = 0.8;
$graph->driver = new ezcGraphGdDriver();
$graph->options->font = 'app/img/KhmerOSclassic.ttf';
$graph->driver->options->imageFormat = IMG_PNG;
$graph->render(532, 195, 'app/img/graph/groupVolumePieGraph.png');
echo '<h2>Space used per group </h2>';
?>

<img src="app/img/graph/groupVolumePieGraph.png"/>
<table class="simple">
     <thead>
        <tr>