Esempio n. 1
0
 public function testRenderLineChartToOutput()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphRadarChart();
     $chart->palette = new ezcGraphPaletteTango();
     $chart->data['sample'] = new ezcGraphArrayDataSet($this->getRandomData(6));
     ob_start();
     // Suppress header already sent warning
     @$chart->renderToOutput(500, 200);
     file_put_contents($filename, ob_get_clean());
     $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
 }
Esempio n. 2
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);
}