From: eldy <> Date: Mon, 17 Nov 2003 20:56:44 +0000 (+0000) Subject: Added experimental graphapplet plugin. X-Git-Tag: AWSTATS_6_0_BETA~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca2bdac13fbc7689455eb46c43c2aa8d35f163c1;p=thirdparty%2FAWStats.git Added experimental graphapplet plugin. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index d07d6745..6d330372 100644 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -8350,7 +8350,9 @@ if (scalar keys %HTMLOutput) { $daycursor =~ /^(\d\d\d\d)(\d\d)(\d\d)/; my $year=$1; my $month=$2; my $day=$3; if (! DateIsValid($day,$month,$year)) { next; } # If not an existing day, go to next - push @blocklabel,"$day§$MonthNumLib{$month}"; + my $bold=($day==$nowday && $month==$nowmonth && $year==$nowyear?':':''); + my $weekend=(DayOfWeek($day,$month,$year)=~/[06]/?'!':''); + push @blocklabel,"$day§$MonthNumLib{$month}$weekend$bold"; } my @vallabel=("$Message[10]","$Message[56]","$Message[57]","$Message[75]"); my @valcolor=("$color_v","$color_p","$color_h","$color_k"); @@ -8517,11 +8519,14 @@ if (scalar keys %HTMLOutput) { # Show bars for days of week if ($PluginsLoaded{'ShowGraph'}{'graphapplet'}) { my @blocklabel=(); - for (@DOWIndex) { push @blocklabel,$Message[$_+84]; } + for (@DOWIndex) { push @blocklabel,($Message[$_+84].($_=~/[06]/?"!":"")); } my @vallabel=("$Message[56]","$Message[57]","$Message[75]"); my @valcolor=("$color_p","$color_h","$color_k"); my @valmax=(int($max_h),int($max_h),int($max_k)); my @valtotal=($total_p,$total_h,$total_k); + $average_p=sprintf("%.2f",$average_p); + $average_h=sprintf("%.2f",$average_h); + $average_k=(int($average_k)?Format_Bytes(sprintf("%.2f",$average_k)):"0.00"); my @valaverage=($average_p,$average_h,$average_k); my @valdata=(); my $xx=0; diff --git a/wwwroot/cgi-bin/plugins/graphapplet.pm b/wwwroot/cgi-bin/plugins/graphapplet.pm index 63c8f71c..9d036021 100644 --- a/wwwroot/cgi-bin/plugins/graphapplet.pm +++ b/wwwroot/cgi-bin/plugins/graphapplet.pm @@ -22,7 +22,7 @@ use strict;no strict "refs"; # <----- # ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN # AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE. -my $PluginNeedAWStatsVersion="5.91"; +my $PluginNeedAWStatsVersion="6.0"; my $PluginHooksFunctions="ShowGraph"; # -----> diff --git a/wwwroot/classes/awgraphapplet.jar b/wwwroot/classes/awgraphapplet.jar index 4fe84f74..26b25060 100644 Binary files a/wwwroot/classes/awgraphapplet.jar and b/wwwroot/classes/awgraphapplet.jar differ diff --git a/wwwroot/classes/src/AWGraphApplet.java b/wwwroot/classes/src/AWGraphApplet.java index 8d796646..78d61a05 100644 --- a/wwwroot/classes/src/AWGraphApplet.java +++ b/wwwroot/classes/src/AWGraphApplet.java @@ -49,8 +49,7 @@ public class AWGraphApplet extends java.applet.Applet { // public synchronized void init() { public synchronized void start() { -// Trace.init(DEBUG,""); -// Trace.debug(0,"Applet init",getClass().getName()); + Log("Applet init"); String temp = getParameter("b_fontsize"); if (temp != null) { b_fontsize = Integer.parseInt(temp); } @@ -83,13 +82,13 @@ public class AWGraphApplet extends java.applet.Applet { temp = getParameter("border_color"); if (temp != null) { border_color = Color.decode("#"+temp); } + Log("bblocks "+nbblocks); + Log("nbvalues "+nbvalues); + Log("barsize "+barsize); + font = new java.awt.Font("Verdana", 0, b_fontsize); metrics = getFontMetrics(font); -// Trace.debug(1,"nbblocks "+nbblocks,getClass().getName()); -// Trace.debug(1,"nbvalues "+nbvalues,getClass().getName()); -// Trace.debug(1,"barsize "+barsize,getClass().getName()); - blabels = new String[nbblocks]; vlabels = new String[nbvalues]; styles = new int[nbvalues]; @@ -109,10 +108,15 @@ public class AWGraphApplet extends java.applet.Applet { } for (int i=0; i < nbvalues; i++) { if (max[i]<=0) { max[i]=1; } -// Trace.debug(2,"max["+i+"]="+max[i],getClass().getName()); + Log("max["+i+"]="+max[i]); } } + private synchronized void Log(String s) { +// Trace.debug(1,s); + System.out.println(s); + } + private synchronized void parsebLabel(int i) { String temp = getParameter("b" + (i+1) + "_label"); if (temp==null) { @@ -166,9 +170,9 @@ public class AWGraphApplet extends java.applet.Applet { if (temp != null) { String[] ss=temp.split(" ",0); for (int i=0; i"+width+","+h+"=>"+height,getClass().getName()); +// Log("draw3DBar "+x+","+y+","+w+"=>"+width+","+h+"=>"+height); p.addPoint(x,y);p.addPoint(x+width,y); p.addPoint(x+width,y-height);p.addPoint(x,y-height); @@ -252,10 +256,16 @@ public class AWGraphApplet extends java.applet.Applet { // Loop on each block for (int j = 0; j < nbblocks; j++) { + // Draw the block label - //Trace.debug("Write block j="+j+" with cx="+cx,""); +// Log("Write block j="+j+" with cx="+cx); cy = getSize().height - metrics.getHeight() - metrics.getDescent(); g.setColor(Color.black); + // Check if bold or highlight + int bold=0; int highlight=0; + if (blabels[j].indexOf(":")>0) { bold=1; blabels[j]=blabels[j].replaceAll(":",""); } + if (blabels[j].indexOf("!")>0) { highlight=1; blabels[j]=blabels[j].replaceAll("!",""); } + String[] ss=blabels[j].split("§",0); for (int i=0; i>1; @@ -287,13 +297,7 @@ public class AWGraphApplet extends java.applet.Applet { public synchronized String[][] getParameterInfo() { String[][] info = { - {"title", "string", "The title of bar graph. Default is 'Chart'"}, - {"nbvalues", "int", "The number of nbvalues/rows. Default is 5."}, - {"orientation", "{VERTICAL, HORIZONTAL}", "The orienation of the bar graph. Default is VERTICAL."}, - {"c#", "int", "Subsitute a number for #. " + "The value/size of bar #. Default is 0."}, - {"c#_label", "string", "The label for bar #. " + "Default is an empty label."}, - {"c#_style", "{SOLID, STRIPED}", "The style of bar #. " + "Default is SOLID."}, - {"c#_color", "{RED, GREEN, BLUE, PINK, ORANGE, MAGENTA, CYAN, " + "WHITE, YELLOW, GRAY, DARKGRAY}", "The color of bar #. Default is GRAY."} + {"title", "string", "The title of bar graph."} }; return info; }