function visitors_chart in Visitors 8
Same name and namespace in other branches
- 7.2 visitors.chart.inc \visitors_chart()
- 7 visitors.chart.inc \visitors_chart()
- 7.0 visitors.chart.inc \visitors_chart()
Draw chart.
@values int array y-axis values @x_array array x-axis params
4 calls to visitors_chart()
- chart_visitors_days_of_month in reports/
days_of_month.inc - Display days of month chart report.
- chart_visitors_days_of_week in reports/
days_of_week.inc - Display days of week chart report.
- chart_visitors_hours in reports/
hours.inc - Display hours chart report.
- chart_visitors_monthly_history in reports/
monthly_history.inc - Display monthly history chart report.
File
- ./
visitors.chart.inc, line 43
Code
function visitors_chart($values, $x_array = NULL) {
// Dataset definition
$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();
// Initialise the chart
$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);
// Draw the 0 line
$pchart
->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar chart
$pchart
->drawBarGraph($data, $data_description, TRUE);
// Finish the chart
$pchart
->Stroke();
exit;
}