code.php (1.4 kb) added by Gregory Sitnin
Description: running code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bar char test</title>
<style>img {display: block;}</style>
</head>
<body>
<?php
require_once "ezc/Base/src/base.php";
function __autoload($className) {
ezcBase::autoload($className);
}
function buildBarChart($title, $filename, $width, $height, array $data) {
$graph = new ezcGraphBarChart();
$graph->title = $title;
$graph->legend = false;
foreach ($data as $key => $value) {
$remains[$key] = 100 - $value;
}
$graph->data['values'] = new ezcGraphArrayDataSet($data);
$graph->data['remains'] = new ezcGraphArrayDataSet($remains);
$graph->driver = new ezcGraphGdDriver();
$graph->driver->options->supersampling = 1;
$graph->driver->options->jpegQuality = 100;
$graph->driver->options->imageFormat = IMG_PNG;
$graph->options->font = 'fonts/verdana.ttf';
$graph->palette = new ezcGraphPaletteEzRed();
$graph->options->stackBars = true;
$graph->render($width, $height, $filename);
return "<img src=\"$filename\" width=\"$width\" height=\"$height\">";
}
echo buildBarChart('Horizontal bars sample', 'test_bar_hor.png', 600, 400, array(
'string 1' => 55,
'string 2' => 25,
'string 3' => 10,
'string 4' => 10,
'string 5' => 5,
));
?>
</body>
</html>