/**
  * Constructor
  * 
  * @param array $options Default option array
  * @return void
  * @ignore
  */
 public function __construct(array $options = array())
 {
     parent::__construct();
     $this->addElement('xAxis', new ezcGraphChartElementNumericAxis());
     $this->elements['xAxis']->axisLabelRenderer = new ezcGraphAxisCenteredLabelRenderer();
     $this->elements['xAxis']->position = ezcGraph::LEFT;
     $this->addElement('yAxis', new ezcGraphChartElementLabeledAxis());
     $this->elements['yAxis']->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
     $this->elements['yAxis']->position = ezcGraph::BOTTOM;
     $this->renderer = new ezcGraphHorizontalRenderer();
 }
Beispiel #2
0
 public function testReturnFrom3dSvgBarChart()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['moreData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['evenMoreData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['sampleData']->url = 'http://example.com/sampleData';
     $chart->data['sampleData']->symbol = ezcGraph::DIAMOND;
     $chart->data['moreData']->url = 'http://example.com/moreData';
     $chart->data['moreData']->symbol = ezcGraph::CIRCLE;
     $chart->data['evenMoreData']->url = 'http://example.com/evenMoreData';
     $chart->data['evenMoreData']->symbol = ezcGraph::BULLET;
     $chart->render(500, 200, $filename);
     $reference = $chart->renderer->getElementReferences();
     // Check data references
     $this->assertSame(3, count($reference['data']), '3 datasets expected.');
     $this->assertSame(5, count($reference['data']['sampleData']), '[sampleData] 5 datapoints expected.');
     $this->assertSame(3, count($reference['data']['sampleData']['sample 2']), '[sampleData] 3 elements for datapoint expected.');
     $this->assertSame('ezcGraphPolygon_98', $reference['data']['sampleData']['sample 2'][0], '[sampleData] ezcGraph element expected.');
     $this->assertSame('ezcGraphPolygon_99', $reference['data']['sampleData']['sample 2'][1], '[sampleData] ezcGraph element expected.');
     $this->assertSame('ezcGraphPolygon_100', $reference['data']['sampleData']['sample 2'][2], '[sampleData] ezcGraph element expected.');
     // Check data references
     $this->assertSame(5, count($reference['data']['moreData']), '[moreData] 5 datapoints expected.');
     $this->assertSame(2, count($reference['data']['moreData']['sample 2']), '[moreData] 3 elements for datapoint expected.');
     $this->assertSame('ezcGraphCircularArc_102', $reference['data']['moreData']['sample 2'][0], '[moreData] ezcGraph element expected.');
     $this->assertSame('ezcGraphCircle_103', $reference['data']['moreData']['sample 2'][1], '[moreData] ezcGraph element expected.');
     // Check data references
     $this->assertSame(5, count($reference['data']['evenMoreData']), '[evenMoreData] 5 datapoints expected.');
     $this->assertSame(2, count($reference['data']['evenMoreData']['sample 2']), '[evenMoreData] 3 elements for datapoint expected.');
     $this->assertSame('ezcGraphCircularArc_105', $reference['data']['evenMoreData']['sample 2'][0], '[evenMoreData] ezcGraph element expected.');
     $this->assertSame('ezcGraphCircle_106', $reference['data']['evenMoreData']['sample 2'][1], '[evenMoreData] ezcGraph element expected.');
     // Check legend references
     $this->assertSame(3, count($reference['legend']), '3 legend items expected.');
     $this->assertSame(2, count($reference['legend']['sampleData']), '2 elements for legend item expected.');
     $this->assertSame('ezcGraphPolygon_4', $reference['legend']['sampleData']['symbol'], 'ezcGraphCircle expected as legend symbol.');
     $this->assertSame('ezcGraphTextBox_5', $reference['legend']['sampleData']['text'], 'ezcGraphTextBox expected for legend text.');
     // Check legend references
     $this->assertSame(3, count($reference['legend']), '3 legend items expected.');
     $this->assertSame(2, count($reference['legend']['moreData']), '2 elements for legend item expected.');
     $this->assertSame('ezcGraphCircle_6', $reference['legend']['moreData']['symbol'], 'ezcGraphCircle expected as legend symbol.');
     $this->assertSame('ezcGraphTextBox_7', $reference['legend']['moreData']['text'], 'ezcGraphTextBox expected for legend text.');
     // Check legend references
     $this->assertSame(3, count($reference['legend']), '3 legend items expected.');
     $this->assertSame(2, count($reference['legend']['evenMoreData']), '2 elements for legend item expected.');
     $this->assertSame('ezcGraphCircle_8', $reference['legend']['evenMoreData']['symbol'], 'ezcGraphCircle expected as legend symbol.');
     $this->assertSame('ezcGraphTextBox_9', $reference['legend']['evenMoreData']['text'], 'ezcGraphTextBox expected for legend text.');
     // Check for legend URLs
     $this->assertSame(3, count($reference['legend_url']), '3 legend url items expected.');
     $this->assertSame('http://example.com/moreData', $reference['legend_url']['moreData'], 'Link expected for "moreData".');
     $this->assertSame('http://example.com/sampleData', $reference['legend_url']['sampleData'], 'Link expected for "sampleData".');
 }
<?php

require 'Base/src/base.php';
function __autoload($className)
{
    ezcBase::autoload($className);
}
// Create the graph
$graph = new ezcGraphBarChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->xAxis->majorGrid = '#888888';
$graph->yAxis->majorGrid = '#888888';
// Add the data and hilight norwegian data set
$graph->data['Posts'] = new ezcGraphArrayDataSet(array('May 2006' => 1164, 'Jun 2006' => 965, 'Jul 2006' => 1014, 'Aug 2006' => 1269, 'Sep 2006' => 1269, 'Oct 2006' => 771));
$graph->data['per day'] = new ezcGraphArrayDataSet(array('May 2006' => 38, 'Jun 2006' => 32, 'Jul 2006' => 33, 'Aug 2006' => 41, 'Sep 2006' => 34, 'Oct 2006' => 25));
// Set graph title
$graph->title = 'Forum posts in last months';
// Use 3d renderer, and beautify it
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->barChartGleam = 0.5;
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->driver = new ezcGraphSvgDriver();
// Output the graph with std SVG driver
$graph->render(500, 200, 'forum_evolution.svg');
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->palette = new ezcGraphPaletteEz();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['English']->symbol = ezcGraph::NO_SYMBOL;
$graph->data['German']->symbol = ezcGraph::BULLET;
$graph->data['Norwegian']->symbol = ezcGraph::DIAMOND;
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->legendSymbolGleam = 0.5;
$graph->renderer->options->barChartGleam = 0.5;
$graph->render(400, 150, 'tutorial_bar_chart_3d.svg');
Beispiel #5
0
 public function test3dBarChartSvgLinking()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->options->fillLines = 200;
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['moreData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['evenMoreData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $chart->data['sampleData']->url = 'http://example.com/sampleData';
     $chart->data['sampleData']->symbol = ezcGraph::DIAMOND;
     $chart->data['moreData']->url = 'http://example.com/moreData';
     $chart->data['moreData']->symbol = ezcGraph::CIRCLE;
     $chart->data['evenMoreData']->url = 'http://example.com/evenMoreData';
     $chart->data['evenMoreData']->symbol = ezcGraph::BULLET;
     $chart->render(500, 200, $filename);
     ezcGraphTools::linkSvgElements($chart);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Beispiel #6
0
 public function testStackedBarChartBug13253()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $graph = new ezcGraphBarChart();
     $graph->data['values'] = new ezcGraphArrayDataSet(array('string 1' => 55, 'string 2' => 25, 'string 3' => 10, 'string 4' => 10, 'string 5' => 5));
     $graph->data['remains'] = new ezcGraphArrayDataSet(array('string 1' => 45, 'string 2' => 75, 'string 3' => 90, 'string 4' => 90, 'string 5' => 95));
     $graph->palette = new ezcGraphPaletteEzRed();
     $graph->options->stackBars = true;
     $graph->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->palette = new ezcGraphPaletteBlack();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['German']->displayType = ezcGraph::LINE;
$graph->options->fillLines = 210;
$graph->render(400, 150, 'tutorial_user_palette.svg');
Beispiel #8
0
 public function testBarChartWithSingleDataPointNumericAxis()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $barChart = new ezcGraphBarChart();
     $barChart->xAxis = new ezcGraphChartElementNumericAxis();
     $barChart->data['test'] = new ezcGraphArrayDataSet(array(23));
     $barChart->render(400, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Beispiel #9
0
 /**
  * create graph via ezc/gd2
  * @todo verify availability of gd2?
  * @todo improve layout: col. width, x axis labels, etc...
  * @todo if zetacomponent graph is not there, create an error image using gd
  */
 static function graph($data, $dataname, $scale = 60)
 {
     $content = false;
     self::$lastError = '';
     $times = array_keys($data);
     $min = $times[0];
     $max = end($times);
     if (!class_exists('ezcGraphBarChart')) {
         $errormsg = "Error while rendering graph: missing Zetacomponents Graph library";
         self::$lastError = $errormsg;
         eZDebug::writeError($errormsg);
         return false;
     }
     $graph = new ezcGraphBarChart();
     $locale = eZLocale::instance();
     $graph->title = "From " . $locale->formatShortDateTime($min) . " to " . $locale->formatShortDateTime($max);
     //$graph->xAxis->label = "From " . $locale->formatShortDateTime( $min ) . " to " . $locale->formatShortDateTime( $max );
     $graph->options->font->maxFontSize = 10;
     $graph->palette = new ezcGraphPaletteEzBlue();
     $graph->yAxis->label = $dataname;
     $graph->yAxis->min = 0;
     $graph->legend = false;
     // width of bar charts is not calculated correctly by DateAxis
     //$graph->xAxis = new ezcGraphChartElementDateAxis();
     //$graph->xAxis->interval = $scale;
     $graph->xAxis = new ezcGraphChartElementNumericAxis();
     $graph->xAxis->min = $min - $scale / 2;
     $graph->xAxis->max = $max + $scale / 2;
     $graph->xAxis->labelCallback = 'calcChurnLabel';
     $graph->data[$dataname] = new ezcGraphArrayDataSet($data);
     $graph->driver = new ezcGraphGdDriver2();
     $graph->driver->options->imageFormat = IMG_JPEG;
     // pick a font that is delivered along with ezp
     $graph->options->font = 'design/standard/fonts/arial.ttf';
     try {
         $ok = ob_start();
         $graph->render(600, 400, 'php://stdout');
         $content = ob_get_clean();
         //$clusterfile->fileStoreContents( $cachefile, $content );
     } catch (exception $e) {
         $errormsg = "Error while rendering graph: " . $e->getMessage();
         self::$lastError = $errormsg;
         eZDebug::writeError($errormsg);
     }
     return $content;
 }
Beispiel #10
0
<?php

require_once '../tutorial_autoload.php';
$wikidata = (include '../tutorial_wikipedia_data.php');
// Create a bar chart
$graph = new ezcGraphBarChart();
$graph->data['German articles'] = new ezcGraphArrayDataSet($wikidata['German']);
$graph->render(400, 150, 'example_02.svg');
<?php

require_once 'tutorial_autoload.php';
require_once 'tutorial_custom_palette.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->palette = new tutorialCustomPalette();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['German']->displayType = ezcGraph::LINE;
$graph->options->fillLines = 210;
$graph->render(400, 150, 'tutorial_modified_palette.svg');
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['German']->displayType = ezcGraph::LINE;
$graph->options->fillLines = 210;
$graph->render(400, 150, 'tutorial_bar_line_chart.svg');
 public function testRenderWithZeroAxisSpace()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $labelCount = 20;
     $data = $this->getRandomData($labelCount, 500, 2000, 23);
     $chart = new ezcGraphBarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->data['sample'] = new ezcGraphArrayDataSet($data);
     // Set manual label count
     $chart->xAxis->labelCount = 21;
     $chart->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedBoxedLabelRenderer();
     $chart->xAxis->axisLabelRenderer->angle = 45;
     $chart->xAxis->axisSpace = 0.1;
     $chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
     $chart->yAxis->axisSpace = 0;
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
 protected function generateCharts(InputInterface $input, OutputInterface $output, $destination, array $results)
 {
     $gd_info = gd_info();
     if (!$gd_info['FreeType Support']) {
         throw new \RuntimeException('gd extension must be compiled with FreeType support');
     }
     $font = $this->getChartFont($input);
     list($width, $height) = $this->getChartDimensions($input);
     $chart_data = $this->getChartData($results);
     foreach ($chart_data as $measure => $benchmarks) {
         foreach ($benchmarks as $benchmark => $subbenchmarks) {
             $file = $destination . '/' . $benchmark . '_' . $measure . '.png';
             $output->writeln('<comment>Writing ' . $file . '</comment>');
             $driver = new \ezcGraphGdDriver();
             $driver->options->supersampling = 1;
             $driver->options->imageFormat = IMG_PNG;
             $graph = new \ezcGraphBarChart();
             $graph->driver = $driver;
             $graph->options->font = $font;
             $graph->xAxis->label = 'Elements';
             $graph->yAxis->label = $measure == 'memory' ? 'Memory (KB)' : 'Executions / Second';
             $graph->title = $benchmark . ' - ' . $measure;
             foreach ($subbenchmarks as $subbenchmark => $elements) {
                 $graph->data[$subbenchmark] = new \ezcGraphArrayDataSet($elements);
             }
             $graph->render($width, $height, $file);
         }
     }
 }
<?php

require_once 'tutorial_autoload.php';
require_once 'tutorial_custom_palette_palette.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->palette = new tutorialCustomPalette();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['German']->displayType = ezcGraph::LINE;
$graph->options->fillLines = 210;
$graph->render(400, 150, 'tutorial_custom_palette.svg');
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->data['German']->displayType = ezcGraph::LINE;
$graph->data['German']->highlight = true;
$graph->data['German']->highlight['Mar 2006'] = false;
$graph->options->fillLines = 210;
$graph->options->highlightSize = 12;
$graph->options->highlightFont->background = '#EEEEEC88';
$graph->options->highlightFont->border = '#000000';
$graph->options->highlightFont->borderWidth = 1;
// $graph->renderer = new ezcGraphRenderer2d();
$graph->renderer->options->barMargin = 0.2;
$graph->renderer->options->barPadding = 0.2;
$graph->renderer->options->dataBorder = 0;
$graph->render(400, 150, 'tutorial_bar_chart_options.svg');
 /**
  * Build Networth Graphic for balance sheet
  * @param array $financialData
  */
 public function buildNetWorthGraphic($netWorthData)
 {
     $graphic = 'nw' . time() . '.png';
     $nwGraphicFile = APPLICATION_PATH . '/../pdf/images/' . $graphic;
     $graph = new ezcGraphBarChart();
     $graph->palette = new ezcGraphPaletteEzBlue();
     $graph->title = 'Net Worth';
     $graph->legend = false;
     $graph->driver = new ezcGraphGdDriver();
     $graph->options->font = APPLICATION_PATH . '/../pdf/fonts/font.ttf';
     $graph->driver->options->imageFormat = IMG_PNG;
     $graph->data['Net Worth'] = new ezcGraphArrayDataSet(array('Today' => str_replace(',', '', $netWorthData['net_worth']), 'Future' => str_replace(',', '', $netWorthData['net_worth_f']), 'FFR Plan A' => str_replace(',', '', $netWorthData['net_worth_a']), 'FFR Plan B' => str_replace(',', '', $netWorthData['net_worth_b']), 'FFR Plan C' => str_replace(',', '', $netWorthData['net_worth_c'])));
     $graph->render(400, 200, $nwGraphicFile);
     $netWorthGraphic = array('nwGraphicFile' => $nwGraphicFile, 'graphic' => $graphic);
     return $netWorthGraphic;
 }
Beispiel #18
0
 public function testRenderBarChartWithHighlightedData()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->data['Line 1'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => -21, 'sample 3' => 324, 'sample 4' => -120, 'sample 5' => 1));
     $chart->data['Line 2'] = new ezcGraphArrayDataSet(array('sample 1' => 543, 'sample 2' => 234, 'sample 3' => 298, 'sample 4' => 5, 'sample 5' => 613));
     $chart->data['Line 1']->highlight = true;
     $chart->data['Line 2']->highlight['sample 5'] = true;
     $chart->data['Line 1']->displayType = ezcGraph::BAR;
     $chart->options->highlightSize = 12;
     $chart->options->highlightFont->color = ezcGraphColor::fromHex('#3465A4');
     $chart->options->highlightFont->background = ezcGraphColor::fromHex('#D3D7CF');
     $chart->options->highlightFont->border = ezcGraphColor::fromHex('#888A85');
     $chart->xAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Beispiel #19
0
 public function testStackedBarChart3d()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->options->stackBars = true;
     $chart->data['sample'] = new ezcGraphArrayDataSet(array('Mozilla' => 4375, 'IE' => 345, 'Opera' => 1204, 'wget' => 231, 'Safari' => 987));
     $chart->data['sample 2'] = new ezcGraphArrayDataSet(array('Mozilla' => 4352, 'IE' => 745, 'Opera' => 204, 'wget' => 2231, 'Safari' => 487));
     $chart->data['sample 3'] = new ezcGraphArrayDataSet(array('Mozilla' => 234, 'IE' => 100, 'Opera' => 0, 'wget' => -934, 'Safari' => 2043));
     $chart->renderer = new ezcGraphRenderer3d();
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Beispiel #20
0
 public function __construct()
 {
     parent::__construct();
     $this->init();
 }
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphBarChart();
$graph->title = 'Wikipedia articles';
// Stack bars
$graph->options->stackBars = true;
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->yAxis->label = 'Thousand articles';
$graph->render(400, 150, 'tutorial_stacked_bar_chart.svg');
Beispiel #22
0
function graph_group($p_metrics, $p_title = '', $p_graph_width = 350, $p_graph_height = 400, $p_baseline = 100)
{
    # $p_metrics is an array of three arrays
    #   $p_metrics['open'] = array( 'enum' => value, ...)
    #   $p_metrics['resolved']
    #   $p_metrics['closed']
    $t_graph_font = graph_get_font();
    # count up array portions that are set
    $t_count = 0;
    foreach (array('open', 'resolved', 'closed') as $t_label) {
        if (isset($p_metrics[$t_label]) && is_array($p_metrics[$t_label])) {
            $t_count += array_sum($p_metrics[$t_label]);
        }
    }
    error_check($t_count, $p_title);
    # calculate totals
    $total = graph_total_metrics($p_metrics);
    if (plugin_config_get('eczlibrary') == ON) {
        $graph = new ezcGraphBarChart();
        $graph->title = $p_title;
        $graph->background->color = '#FFFFFF';
        $graph->options->font = $t_graph_font;
        $graph->options->font->maxFontSize = 12;
        $graph->legend = false;
        foreach (array('open', 'resolved', 'closed') as $t_label) {
            $graph->data[$t_label] = new ezcGraphArrayDataSet($p_metrics[$t_label]);
        }
        $graph->data['total'] = new ezcGraphArrayDataSet($total);
        //$graph->data['total']->displayType = ezcGraph::LINE;
        //$graph->data['total']->barMargin = -20;
        $graph->options->fillLines = 210;
        $graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
        $graph->xAxis->axisLabelRenderer->angle = 45;
        $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 {
        # defines margin according to height
        $graph = new Graph($p_graph_width, $p_graph_height);
        $graph->img->SetMargin(45, 35, 35, $p_baseline);
        if (ON == plugin_config_get('jpgraph_antialias')) {
            $graph->img->SetAntiAliasing();
        }
        $graph->SetScale('textlin');
        $graph->SetMarginColor('white');
        $graph->SetFrame(false);
        $graph->title->SetFont($t_graph_font, FS_BOLD);
        $graph->title->Set($p_title);
        $graph->xaxis->SetTickLabels(array_keys($p_metrics['open']));
        if (FF_FONT2 <= $t_graph_font) {
            $graph->xaxis->SetLabelAngle(60);
        } else {
            $graph->xaxis->SetLabelAngle(90);
            # can't rotate non truetype fonts
        }
        $graph->xaxis->SetFont($t_graph_font);
        $graph->legend->Pos(0.05, 0.08);
        $graph->legend->SetFont($t_graph_font);
        $graph->yaxis->scale->ticks->SetDirection(-1);
        $graph->yaxis->SetFont($t_graph_font);
        $graph->yscale->SetGrace(10);
        # adds on the same graph
        $tot = new BarPlot(array_values($total));
        $tot->SetFillColor('lightblue');
        $tot->SetWidth(0.7);
        $tot->SetLegend(plugin_lang_get('legend_total'));
        $graph->Add($tot);
        $p1 = new BarPlot(array_values($p_metrics['open']));
        $p1->SetFillColor('yellow');
        $p1->SetWidth(1);
        $p1->SetLegend(plugin_lang_get('legend_opened'));
        $p2 = new BarPlot(array_values($p_metrics['closed']));
        $p2->SetFillColor('blue');
        $p2->SetWidth(1);
        $p2->SetLegend(plugin_lang_get('legend_closed'));
        $p3 = new BarPlot(array_values($p_metrics['resolved']));
        $p3->SetFillColor('red');
        $p3->SetWidth(1);
        $p3->SetLegend(plugin_lang_get('legend_resolved'));
        $gbplot = new GroupBarPlot(array($p1, $p3, $p2));
        $graph->Add($gbplot);
        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();
    }
}
Beispiel #23
0
$header = $header . "</tr> </thead>";
$i = 0;
foreach ($user_info as $g => $vals) {
    for ($j = 0; $j < count($sz_range_fields); $j++) {
        $tab[$i][] = $vals[$sz_range_fields[$j]];
        if (isset($sz_ranges[$sz_range_name[$j]])) {
            $sz_ranges[$sz_range_name[$j]] += $vals[$sz_range_fields[$j]];
        } else {
            $sz_ranges[$sz_range_name[$j]] = $vals[$sz_range_fields[$j]];
        }
    }
    $i++;
}
echo '<h2 style="line-height:1;">File count per size range</h2>';
generateMergedTable($tab, $header);
// build profile chart
$graph = new ezcGraphBarChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->legend = false;
$graph->data['File size profile'] = new ezcGraphArrayDataSet($sz_ranges);
$graph->xAxis->label = 'Size range';
$graph->yAxis->label = 'File count';
$graph->driver = new ezcGraphGdDriver();
$graph->options->font = 'app/img/KhmerOSclassic.ttf';
$graph->driver->options->imageFormat = IMG_PNG;
$graph->render(532, 300, 'app/img/graph/sizeCountBarGraph-' . $user . '.png');
echo '<br><img src="app/img/graph/sizeCountBarGraph-' . $user . '.png" />';
echo '<br><i>Size repartition for user ' . $user . '</i>';
?>

Beispiel #24
0
 public function testRenderBarChartWithUnregularStepSizes()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->legend = false;
     $chart->data['dataset'] = new ezcGraphArrayDataSet(array(12, 43, 324, 12, 43, 125, 120, 123, 543, 12, 45, 76, 87, 99));
     $chart->data['dataset']->color = '#3465A47F';
     $chart->renderer = new ezcGraphRenderer3d();
     try {
         $chart->render(500, 200, $filename);
     } catch (ezcGraphUnregularStepsException $e) {
         return true;
     }
     $this->fail('Expected ezcGraphUnregularStepsException.');
 }
Beispiel #25
0
function draw_stacked_chart($WIDTH, $HEIGHT, $DATA, $CONFIG, $LEGEND, $FONT, $PALETTE = 'default')
{
    $palettename = return_palette_name($PALETTE);
    require dirname(__FILE__) . '/lib/ezc/Graph/mahara/palettes/' . $palettename . '.php';
    $graph = new ezcGraphBarChart();
    $paletteclass = generate_palette_class_name($palettename);
    $graph->palette = new $paletteclass();
    $graph->title = $CONFIG['title'];
    $graph->subtitle = 'Created: ' . $CONFIG['ctime'] . ', modified: ' . $CONFIG['mtime'];
    $graph->subtitle->position = ezcGraph::BOTTOM;
    $graph->legend = true;
    $graph->legend->position = ezcGraph::BOTTOM;
    $graph->legend->symbolSize = $FONT['size'];
    $graph->background->padding = 10;
    $graph->driver = new ezcGraphGdDriver();
    $graph->driver->options->imageFormat = IMG_PNG;
    switch ($FONT['type']) {
        case 'serif':
            $fontname = 'lib/ezc/Graph/mahara/fonts/LiberationSerif-Regular.ttf';
            break;
        case 'sans':
            $fontname = 'lib/ezc/Graph/mahara/fonts/LiberationSans-Regular.ttf';
            break;
    }
    $graph->options->font = $fontname;
    // Stack bars
    $graph->options->stackBars = true;
    $graph->options->fillLines = 128;
    // Alpha (0 <= Alpha <= 255)
    // Set the maximum font size for all chart elements
    $graph->options->font->maxFontSize = $FONT['size'];
    // Set the font size for the title independently to 14
    $graph->title->font->maxFontSize = $FONT['titlesize'];
    $graph->yAxis->min = 0;
    $graph->yAxis->max = 100;
    $graph->yAxis->majorStep = 50;
    $graph->yAxis->minorStep = 10;
    if ($CONFIG['type'] == 'percent') {
        $graph->yAxis->formatString = '%d%%';
    }
    if (isset($DATA['marker']) && !empty($DATA['marker'])) {
        $graph->additionalAxis['border'] = $marker = new ezcGraphChartElementNumericAxis();
        $marker->position = ezcGraph::LEFT;
        //$marker->border = $graph->palette->majorGridColor;
        $marker->chartPosition = $DATA['marker'];
        $marker->label = $DATA['percent'] . '% ';
    }
    //$EZCDATA = array();
    foreach ($DATA['data'] as $key => $value) {
        $graph->data[$key] = new ezcGraphArrayDataSet($value);
    }
    //$CONFIG['charttype'] = 'bar3d';
    if (strtolower($CONFIG['chartspace']) == '3d') {
        $graph->renderer = new ezcGraphRenderer3d();
    }
    //$graph->renderer->options->barMargin = .2;
    $graph->renderer->options->barPadding = 0.2;
    /* Build the PNG file and send it to the web browser */
    $graph->renderToOutput($WIDTH, $HEIGHT);
}
Beispiel #26
0
 public function testRenderBarChartWithMoreBarsThenMajorSteps()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphBarChart();
     $chart->legend = false;
     $chart->xAxis = new ezcGraphChartElementNumericAxis();
     $chart->xAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
     $chart->data['dataset'] = new ezcGraphArrayDataSet(array(12, 43, 324, 12, 43, 125, 120, 123, 543, 12, 45, 76, 87, 99, 834, 34, 453));
     $chart->data['dataset']->color = '#3465A47F';
     $chart->render(500, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Beispiel #27
0
                break;
            case "10":
                $matches[$curTimestamp]['month'] = 'O';
                break;
            case "11":
                $matches[$curTimestamp]['month'] = 'N';
                break;
            case "12":
                $matches[$curTimestamp]['month'] = 'D';
                break;
        }
    }
    // done with this month
    $oldTimestamp = $curTimestamp;
}
$graph = new ezcGraphBarChart();
$graph->title = 'GU Matches 01/2005 -11/2010';
// disable legend
$graph->legend = false;
$graph->driver = new ezcGraphGdDriver();
$graph->options->font = '../CMS/libchart-1.2.1/libchart/fonts/DejaVuSansCondensed.ttf';
/*	
echo '<pre>';
print_r($matches);
echo '</pre>';
*/
$dataset = array();
foreach ($matches as $matchesPerMonth) {
    //$dataset[$matchesPerMonth['timestamp']] = $matchesPerMonth['month'] = $matchesPerMonth['matches'];
    $dataset[$matchesPerMonth['timestamp']] = $matchesPerMonth['month'] = $matchesPerMonth['matches'];
}