<?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');
/** * 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> "; } }
public function testRenderCompleteOdometerWithDifferentOptions() { $filename = $this->tempDir . __FUNCTION__ . '.svg'; $chart = new ezcGraphOdometerChart(); $chart->data['data'] = new ezcGraphArrayDataSet(array(1, 7, 18)); $chart->options->borderWidth = 2; $chart->options->borderColor = '#2e3436'; $chart->options->startColor = '#EEEEEC'; $chart->options->endColor = '#A00000'; $chart->options->markerWidth = 5; $chart->options->odometerHeight = 0.7; $chart->render(300, 100, $filename); $this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg'); }