Example #1
0
 public function testLogarithmicalRotationAxis()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphRadarChart();
     $chart->palette = new ezcGraphPaletteEzBlue();
     $chart->legend = false;
     $chart->data['sample'] = new ezcGraphArrayDataSet(array(1 => 12, 5 => 7, 10 => 234, 132 => 34, 1125 => 12, 12346 => 6, 140596 => 1));
     $chart->rotationAxis = new ezcGraphChartElementLogarithmicalAxis();
     $chart->render(400, 200, $filename);
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
 public function testRenderTextBoxes()
 {
     $chart = new ezcGraphRadarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
     $mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawText'));
     $mockedRenderer->expects($this->at(0))->method('drawText')->with($this->equalTo(new ezcGraphBoundings(142.0, 182.0, 202.0, 198.0), 1.0), $this->equalTo('sample 1'), $this->equalTo(ezcGraph::TOP | ezcGraph::CENTER));
     $mockedRenderer->expects($this->at(4))->method('drawText')->with($this->equalTo(new ezcGraphBoundings(398.0, 182.0, 458.0, 198.0), 1.0), $this->equalTo('sample 5'), $this->equalTo(ezcGraph::TOP | ezcGraph::CENTER));
     $chart->renderer = $mockedRenderer;
     $chart->render(500, 200);
 }
Example #3
0
 public function testRadarLogarithmicalAxis()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphRadarChart();
     $chart->palette = new ezcGraphPaletteBlack();
     $chart->axis = new ezcGraphChartElementLogarithmicalAxis();
     $chart->options->fillLines = 210;
     $chart->data['sample 1'] = new ezcGraphArrayDataSet($this->getRandomData(8, 1, 1000000));
     $chart->data['sample 2'] = new ezcGraphArrayDataSet($this->getRandomData(8, 1, 1000000, 42));
     $chart->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 ezcGraphRadarChart();
$graph->title = 'Wikipedia articles';
$graph->options->fillLines = 220;
// Add data
foreach ($wikidata as $language => $data) {
    $graph->data[$language] = new ezcGraphArrayDataSet($data);
    $graph->data[$language][] = reset($data);
}
$graph->render(400, 150, 'tutorial_radar_chart.svg');
<?php

require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphRadarChart();
$graph->palette = new ezcGraphPaletteEzBlue();
$graph->options->fillLines = 220;
$graph->legend->position = ezcGraph::BOTTOM;
$graph->rotationAxis = new ezcGraphChartElementNumericAxis();
$graph->rotationAxis->majorStep = 2;
$graph->rotationAxis->minorStep = 0.5;
mt_srand(5);
$data = array();
for ($i = 0; $i <= 10; $i++) {
    $data[$i] = mt_rand(-5, 5);
}
$data[$i - 1] = reset($data);
$graph->data['random data'] = $dataset = new ezcGraphArrayDataSet($data);
$average = new ezcGraphDataSetAveragePolynom($dataset, 4);
$graph->data[(string) $average->getPolynom()] = $average;
$graph->data[(string) $average->getPolynom()]->symbol = ezcGraph::NO_SYMBOL;
$graph->data[(string) $average->getPolynom()]->color = '#9CAE86';
$graph->render(500, 250, 'tutorial_complex_radar_chart.svg');
Example #6
0
function draw_radar_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 ezcGraphRadarChart();
    $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 = false;
    $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;
    $graph->options->fillLines = 128;
    // Alpha (0 <= Alpha <= 255)
    /*
    switch ($CONFIG['labeltype']) {
    	case 'labelonly':   $label = '%1$s'; break;
    	case 'valueonly':   $label = '%2$d'; break;
    	case 'value':       $label = '%1$s: %2$d'; break;
    	case 'percentonly': $label = '%3$.1f%%'; break;
    	case 'percent':     $label = '%1$s: %3$.1f%%'; break;
    	default:            $label = '%1$s: %2$d (%3$.1f%%)';
    }
    $graph->options->label = $label;
    */
    // 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->axis->min = 0; // ???
    //$graph->axis->max = 4; // ???
    $graph->axis->majorStep = 5;
    //$graph->axis->minorStep = 1;
    $EZCDATA = array();
    foreach ($DATA as $value) {
        $EZCDATA = array_merge($EZCDATA, array($value['key'] => $value['value']));
        /*
        if ($LEGEND == 'key') { $EZCDATA = array_merge($EZCDATA, array($value['key'] => $value['value'])); }
        if ($LEGEND == 'label') { $EZCDATA = array_merge($EZCDATA, array($value['label'] => $value['value'])); }
        */
    }
    $graph->data[$CONFIG['title']] = new ezcGraphArrayDataSet($EZCDATA);
    $graph->data[$CONFIG['title']][] = reset($EZCDATA);
    /*
    if (strtolower($CONFIG['chartspace']) == '3d') {
    	$graph->renderer = new ezcGraphRenderer3d();
    	$graph->renderer->options->pieChartOffset = 60;
    	$graph->renderer->options->pieChartShadowSize = 8;
    	$graph->renderer->options->pieChartShadowColor = '#000000'; //#BABDB6
    	$graph->renderer->options->pieChartHeight = 20;
    }
    */
    /* Build the PNG file and send it to the web browser */
    $graph->renderToOutput($WIDTH, $HEIGHT);
}