private function show_day_information($type, $date) { $filter = new filter($this->db, $this->output, $this->user); $filter->to_output($this->model->table, $this->model->hostnames); if (($stats = $this->model->get_day_statistics($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $graph = new graph($this->output); $graph->title = $this->graphs[$type] . " for " . date("l j F Y", strtotime($date)); $graph->width = 960; $graph->height = GRAPH_HEIGHT; foreach ($stats as $hour => $count) { $graph->add_bar("Hour " . $hour, $count, "hour"); } $graph->to_output(); if (($stats = $this->model->get_day_information($type, $date, $filter->hostname, $filter->webserver)) === false) { $this->output->add_tag("result", "Database error."); return false; } $this->output->open_tag("day", array("hostnames" => show_boolean($this->model->hostnames), "label" => $this->graphs[$type])); foreach ($stats as $stat) { if ($type == "requests" || $type == "bytes_sent") { $stat["count"] = $this->model->readable_number($stat["count"]); } $this->output->record($stat, "stat"); } $this->output->close_tag(); }
public function execute() { $graph = new graph($this->output); $graph->title = "Demo graph"; $graph->width = 600; $graph->height = 200; $nr = 1; for ($i = 0; $i < 6.3; $i += 0.1) { $graph->add_bar("Bar number: " . $nr++, sprintf("%0.2f", sin($i) + 1.5)); } $graph->to_output(); }