View source
<?php
require_once VISITORS_MODULE_CHART_DIR . '/pData.inc';
require_once VISITORS_MODULE_CHART_DIR . '/pChart.inc';
function visitors_get_chart_width() {
$width = (int) variable_get('visitors_chart_width', 700);
return $width <= 0 ? 700 : $width;
}
function visitors_get_chart_height() {
$height = (int) variable_get('visitors_chart_height', 430);
return $height <= 0 ? 430 : $height;
}
function visitors_chart($values, $x_array = NULL) {
$data_set = new pData();
$data_set
->AddPoint($values, 'Serie1');
if ($x_array !== NULL) {
$data_set
->AddPoint($x_array, 'Serie2');
$data_set
->SetAbsciseLabelSerie('Serie2');
}
$data_set
->AddSerie('Serie1');
$data_set
->SetSerieName('', 'Serie1');
$data = $data_set
->GetData();
$data_description = $data_set
->GetDataDescription();
$width = visitors_get_chart_width();
$height = visitors_get_chart_height();
$pchart = new pChart($width, $height);
$pchart
->setFontProperties(dirname(__FILE__) . '/fonts/tahoma.ttf', 8);
$pchart
->setGraphArea(50, 30, $width - 20, $height - 30);
$pchart
->drawFilledRoundedRectangle(7, 7, $width - 7, $height - 7, 5, 240, 240, 240);
$pchart
->drawRoundedRectangle(5, 5, $width - 5, $height - 5, 5, 230, 230, 230);
$pchart
->drawGraphArea(255, 255, 255, TRUE);
$pchart
->setFixedScale(0, 0, 0, 0, 0, 0, 0);
$pchart
->drawScale($data, $data_description, SCALE_ADDALLSTART0, 150, 150, 150, TRUE, 0, 0, TRUE);
$pchart
->drawGrid(4, TRUE, 230, 230, 230, 50);
$pchart
->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
$pchart
->drawBarGraph($data, $data_description, TRUE);
$pchart
->Stroke();
exit;
}