/*
 * Display
 */
$timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime')));
$graph = new CPie($db_data['graphtype']);
$graph->setPeriod($timeline['period']);
$graph->setSTime($timeline['stime']);
if (isset($_REQUEST['border'])) {
    $graph->setBorder(0);
}
$width = get_request('width', 0);
if ($width <= 0) {
    $width = $db_data['width'];
}
$height = get_request('height', 0);
if ($height <= 0) {
    $height = $db_data['height'];
}
$graph->setWidth($width);
$graph->setHeight($height);
$graph->setHeader($host['host'] . ': ' . $db_data['name']);
if ($db_data['show_3d']) {
    $graph->switchPie3D();
}
$graph->showLegend($db_data['show_legend']);
$result = DBselect('SELECT gi.*' . ' FROM graphs_items gi' . ' WHERE gi.graphid=' . $db_data['graphid'] . ' ORDER BY gi.sortorder,gi.itemid DESC');
while ($db_data = DBfetch($result)) {
    $graph->addItem($db_data['itemid'], $db_data['calc_fnc'], $db_data['color'], $db_data['type']);
}
$graph->draw();
require_once dirname(__FILE__) . '/include/page_footer.php';