]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Added experimental graphapplet plugin.
authoreldy <>
Mon, 17 Nov 2003 20:56:44 +0000 (20:56 +0000)
committereldy <>
Mon, 17 Nov 2003 20:56:44 +0000 (20:56 +0000)
wwwroot/cgi-bin/awstats.pl
wwwroot/cgi-bin/plugins/graphapplet.pm
wwwroot/classes/awgraphapplet.jar
wwwroot/classes/src/AWGraphApplet.java

index d07d6745d488dd7c8ca1981ae6902d7af6a9769f..6d33037209b9a42fb9a3aa5ce64ec72a014d91bf 100644 (file)
@@ -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;
index 63c8f71c9134b023306de1965ca6717822eccc47..9d036021c669a36a97c84b5cf0750ce1065cb6e7 100644 (file)
@@ -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";
 # ----->
 
index 4fe84f742c72b4037d0643fa3c25465faf2bf309..26b25060de6805fb4f8168597a2029ca09346cb4 100644 (file)
Binary files a/wwwroot/classes/awgraphapplet.jar and b/wwwroot/classes/awgraphapplet.jar differ
index 8d7966462ff98e50bdb08817959d0bc6d11664b9..78d61a052c50d2f278339f450f877892d82647b6 100644 (file)
@@ -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<ss.length; i++) {
-                               //Trace.debug(2,"ss="+ss[i],getClass().getName());
+//                             Log("ss="+ss[i]);
                    values[j][i] = Float.parseFloat(ss[i]);
-                               //Trace.debug(2,"values["+j+"]["+i+"]="+values[j][i],getClass().getName());
+//                             Log("values["+j+"]["+i+"]="+values[j][i]);
                        }
            }
     }
@@ -192,7 +196,7 @@ public class AWGraphApplet extends java.applet.Applet {
                Polygon p = new Polygon();
                int width=new Float(w).intValue();
                int height=new Float(h).intValue();
-               //Trace.debug(2,"draw3DBar "+x+","+y+","+w+"=>"+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<ss.length; i++) {
                    int cxoffset=((nbvalues*(valWidth+valSpacing))-metrics.stringWidth(ss[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;
     }