Kategorie: JpGraph RSS-Feed für diese Kategorie
JpGraph: Klassenerweiterung „ErrorPlotValues“

Die Klasse „Plot“ bzw. „ErrorPlots“ von JpGraph bot nicht die Möglichkeit, die entsprechenden Werte darzustellen, die den Balken bestimmen. Der Entwickelr von JpGraph konnte sich leider auf meine Anfrage nicht melden. Daher gebe ich die Klassenerweiterung (recht spezifisch) hier bekannt: <?PHP /* * a small class extension for displaying percentage or absolute values * inside ErrorPlots * by Hofmann R. Julian // 16. Januar 2009 * # new ErrorPlotValues( # [array like for normal ErrorPlot], # [xValues array like for normal ErrorPlot], # [FALSE = percentage, TRUE = absolute values], # [width of the upper and lower line] # );
JpGraph: Beispiel: RadarPlot: Hits nach Stunde

<?PHP function gProzent($alle, $anteil, $stellen = 2) { if ($anteil > 0) return (round(($anteil / ($alle / 100 )), $stellen)); else return 0; } for ($z = 12; $z > 0; $z–) { if ($z < 10) $z = "0{$z}"; $legende[] = "{$z}\n".((int) $z + 12); } $handle = fopen("access_log", "r"); while (!feof($handle)) { $zeile = fgets($handle, 4096); $gValidHit = explode("\"", $zeile); if (strstr($gValidHit[1], "?")) { $p = explode(" ", $zeile); $aHits[(int) substr($p[3], 13, 2)]++; } } fclose ($handle); for ($z = 0; $z <= 11; $z++) $aHitsPM[$z] = $aHits[(11 – $z)]; for ($z = 0; $z <= 11;
JpGraph: Beispiel: LinePlot: Statistik des entstandenen Traffics

<?PHP function sBrowser($stext) { if (strpos($stext, "Googlebot") > 0) return (2); if (strpos($stext, "oogle-Sitemaps") > 0) return (2); if (strpos($stext, "Yahoo!") > 0) return (2); if (strpos($stext, "snbot") > 0) return (2); if (strpos($stext, "Safari") > 0) return (1); if (strpos($stext, "Firefox") > 0) return (1); if (strpos($stext, "MSIE") > 0) return (1); if (strpos($stext, "pera/") > 0) return (1); if (strpos($stext, "BonEcho") > 0) return (1); if (strpos($stext, "ozilla") > 0) return (1); return (NULL); } $Monat = "Nov/2008"; $lMonat = "Oct/2008"; $monate = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $WochenTage =
JpGraph: Beispiel: ScatterPlot: Statistik über die Abweichung der Besucher nach Tagen

<?PHP /* * Suchmaschinen sind inbegriffen. */ $Monat = "Nov/2008"; $Anzahl = date("t", strtotime("01. ".(str_replace("/", " ", $Monat)))); $WochenTage = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"); for ($z = 1; $z <= $Anzahl; $z++) { $aBesucher[] = 0; $xAchse[] = $z; } $handle = fopen("access_log", "r"); while (!feof($handle)) { $zeile = fgets($handle, 4096); $gURL = explode("\"", $zeile); if (strstr($gURL[1], "?")) { if (strstr($gURL[0], $Monat)) { $p = explode(" ", $zeile); $ts = strtotime((substr($p[3], 8, 4))."-" .(date("m", strtotime("01. ".(str_replace("/", " ", $Monat))))) ."-{$p[3][1]}{$p[3][2]} ".(substr($p[3], 13, 8))); $Besucher[$p[0]][0] = $ts; if ( (!($Besucher[$p[0]][1])) || (($oBrowser <> $fBrowser) && ($p[0] ==
JpGraph: Beispiel: PiePlotC: Statistik der Besucher nach Land bzw. Domain

<?PHP function gDomain($sDomain, &$vDomains) { $c = geoip_country_code_by_name($sDomain); if (in_array($c, $vDomains)) return (array_search($c, $vDomains)); return (count($vDomains) – 1); } /* * Die hier dargestellte Ermittlung der Domains spiegelt nicht die * tatsaechliche Verteilung der Domains der Besucher da, da mehrfache * Besuche gleicher IP-Adressen nicht beruecksichtig werden. */ $Domains = array("Deutschland", "Oesterreich", "Schweiz", "andere"); $vDomains = array("DE", "AT", "CH", "%"); for ($z = 0; $z < count($Domains); $z++) $aDomains[$z] = 0; $handle = fopen("access_log", "r"); while (!feof($handle)) { $zeile = fgets($handle, 4096); $iDomain = explode("\"", $zeile); if (strstr($iDomain[1], "?")) { $p = explode(" ", $zeile); if (!$bDomains[$p[0]]) $bDomains[$p[0]] =