/**
  * Creates and prints the odometer chart in the statistic
  *
  * @param String $type
  *
  * @static
  *
  */
 static function printOdometerChart($type = 'overall')
 {
     global $CFG_GLPI;
     // Definition of ChartLabels
     $label = array('overall' => __('Overall satisfaction', 'helpdeskrating'), 'solution' => __('Satisfaction with the solution', 'helpdeskrating'), 'tech' => __('Satisfaction with the technician', 'helpdeskrating'), 'time' => __('Satisfaction with the chronological sequence', 'helpdeskrating'));
     $uid = PluginHelpdeskratingStatistic::getUserID();
     if ($uid) {
         $graph = new ezcGraphOdometerChart();
         $graph->title = $label[$type];
         // Graph Data
         $data = PluginHelpdeskratingStatistic::getAlltimeData($type);
         $graph->data['data'] = new ezcGraphArrayDataSet(array($data));
         $graph->data['data']->color[0] = '#00000000';
         // Graph Display Options
         $graph->options->startColor = '#00FF00';
         $graph->options->endColor = '#FF0000';
         $graph->options->borderWidth = 1;
         $graph->options->borderColor = '#BABDB6';
         $graph->options->markerWidth = 5;
         $graph->options->odometerHeight = 0.5;
         $graph->axis->min = 1;
         $graph->axis->max = 6;
         $graph->axis->label = $label[$type] . ": " . number_format($data, 2, '.', '');
         // Graph Output
         $filename = $uid . '_' . mt_rand() . '.svg';
         $graph->render(400, 150, 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='150'>\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> ";
     }
 }
Exemple #2
0
function draw_odometer_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 ezcGraphOdometerChart();
    $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;
    // 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'];
    // Set colors for the background gradient
    //$graph->options->startColor = '#808080';
    //$graph->options->endColor = '#C0C0C0';
    /*
    $graph->options->startColor = '#2E3436';
    $graph->options->endColor = '#EEEEEC';
    */
    // Set marker width
    $graph->options->markerWidth = 3;
    // Set axis span
    $graph->axis->min = 0;
    $graph->axis->max = 100;
    $graph->axis->label = $DATA['label'];
    /*
    $graph->yAxis->majorStep = 20;
    $graph->yAxis->minorStep = 10;
    if ($CONFIG['type'] == 'percent') {
    	$graph->yAxis->formatString = '%d%%';
    }
    */
    if ($CONFIG['type'] == 'percent') {
        $EZCDATA = array($DATA['percent']);
    } else {
        $EZCDATA = array($DATA['value']);
    }
    $graph->data[$CONFIG['title']] = new ezcGraphArrayDataSet($EZCDATA);
    /* Build the PNG file and send it to the web browser */
    $graph->renderToOutput($WIDTH, $HEIGHT);
}
<?php

require_once 'tutorial_autoload.php';
$graph = new ezcGraphOdometerChart();
$graph->title = 'Custom odometer';
$graph->data['data'] = new ezcGraphArrayDataSet(array(87));
// Set the marker color
$graph->data['data']->color[0] = '#A0000055';
// Set colors for the background gradient
$graph->options->startColor = '#2E3436';
$graph->options->endColor = '#EEEEEC';
// Define a border for the odometer
$graph->options->borderWidth = 2;
$graph->options->borderColor = '#BABDB6';
// Set marker width
$graph->options->markerWidth = 5;
// Set space, which the odometer may consume
$graph->options->odometerHeight = 0.7;
// Set axis span and label
$graph->axis->min = 0;
$graph->axis->max = 100;
$graph->axis->label = 'Coverage  ';
$graph->render(400, 150, 'tutorial_custom_odometer_chart.svg');
Exemple #4
0
 public function testRenderCompleteOdometerToOutput()
 {
     $filename = $this->tempDir . __FUNCTION__ . '.svg';
     $chart = new ezcGraphOdometerChart();
     $chart->data['data'] = new ezcGraphArrayDataSet(array(1, 7, 18));
     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');
 }