}
# Call to plugins' function ShowPagesAddField
- foreach my $pluginname (
- keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
+ foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowPagesAddField'} } )
{
-
- # my $function="ShowPagesAddField_$pluginname('')";
- # eval("$function");
my $function = "ShowPagesAddField_$pluginname";
&$function('');
}
# TODO
# Show bars for month
- if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
+ my $graphdone=0;
+ foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowGraph'} } )
+ {
my @blocklabel = ();
for ( my $ix = 1 ; $ix <= 12 ; $ix++ ) {
my $monthix = sprintf( "%02s", $ix );
push @blocklabel,
- "$MonthNumLib{$monthix}\�$YearRequired";
+ "$MonthNumLib{$monthix}\n$YearRequired";
}
my @vallabel = (
"$Message[11]", "$Message[10]",
$valdata[ $xx++ ] = $MonthBytes{ $YearRequired . $monthix }
|| 0;
}
- ShowGraph_graphapplet(
+
+ my $function = "ShowGraph_$pluginname";
+ &$function(
"$title", "month",
$ShowMonthStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
+ $graphdone=1;
}
- else {
+ if (! $graphdone)
+ {
print "<table>\n";
print "<tr valign=\"bottom\">";
print "<td> </td>\n";
}
# Show bars for day
- if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
+ my $graphdone=0;
+ foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowGraph'} } )
+ {
my @blocklabel = ();
foreach
my $daycursor ( $firstdaytoshowtime .. $lastdaytoshowtime )
my $weekend =
( DayOfWeek( $day, $month, $year ) =~ /[06]/ ? '!' : '' );
push @blocklabel,
- "$day�$MonthNumLib{$month}$weekend$bold";
+ "$day\n$MonthNumLib{$month}$weekend$bold";
}
my @vallabel = (
"$Message[10]", "$Message[56]",
$valdata[ $xx++ ] = $DayHits{ $year . $month . $day } || 0;
$valdata[ $xx++ ] = $DayBytes{ $year . $month . $day } || 0;
}
- ShowGraph_graphapplet(
+ my $function = "ShowGraph_$pluginname";
+ &$function(
"$title", "daysofmonth",
$ShowDaysOfMonthStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
+ $graphdone=1;
}
- else {
+ if (! $graphdone) {
print "<table>\n";
print "<tr valign=\"bottom\">\n";
foreach
}
# Show bars for days of week
- if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
+ my $graphdone=0;
+ foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowGraph'} } )
+ {
my @blocklabel = ();
for (@DOWIndex) {
push @blocklabel,
$avg_dayofweek_h[$_] = int( $avg_dayofweek_h[$_] );
}
}
- ShowGraph_graphapplet(
+ my $function = "ShowGraph_$pluginname";
+ &$function(
"$title", "daysofweek",
$ShowDaysOfWeekStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
+ $graphdone=1;
}
- else {
+ if (! $graphdone)
+ {
print "<table>\n";
print "<tr valign=\"bottom\">\n";
for (@DOWIndex) {
}
# Show bars for hour
- if ( $PluginsLoaded{'ShowGraph'}{'graphapplet'} ) {
+ my $graphdone=0;
+ foreach my $pluginname ( keys %{ $PluginsLoaded{'ShowGraph'} } )
+ {
my @blocklabel = ( 0 .. 23 );
my @vallabel =
( "$Message[56]", "$Message[57]", "$Message[75]" );
$valdata[ $xx++ ] = $_time_h[$_] || 0;
$valdata[ $xx++ ] = $_time_k[$_] || 0;
}
- ShowGraph_graphapplet(
+ my $function = "ShowGraph_$pluginname";
+ &$function(
"$title", "hours",
$ShowHoursStats, \@blocklabel,
\@vallabel, \@valcolor,
\@valmax, \@valtotal,
\@valaverage, \@valdata
);
+ $graphdone=1;
}
- else {
+ if (! $graphdone)
+ {
print "<table>\n";
print "<tr valign=\"bottom\">\n";
for ( my $ix = 0 ; $ix <= 23 ; $ix++ ) {
--- /dev/null
+#!/usr/bin/perl
+#-----------------------------------------------------------------------------
+# GraphGoogleChartApi AWStats plugin
+# Allow AWStats to replace bar graphs with a Google Graph image
+#-----------------------------------------------------------------------------
+# Perl Required Modules: None
+#-----------------------------------------------------------------------------
+# $Revision$ - $Author$ - $Date$
+#
+# Changelog
+#
+# 1.0 - Initial release
+# 1.1 - Changed scaling: making it independent of chart series
+
+
+# <-----
+# ENTER HERE THE USE COMMAND FOR ALL REQUIRED PERL MODULES
+# ----->
+#use strict;
+no strict "refs";
+
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN VARIABLES
+#-----------------------------------------------------------------------------
+# <-----
+# ENTER HERE THE MINIMUM AWSTATS VERSION REQUIRED BY YOUR PLUGIN
+# AND THE NAME OF ALL FUNCTIONS THE PLUGIN MANAGE.
+my $PluginNeedAWStatsVersion = "6.0";
+my $PluginHooksFunctions = "ShowGraph";
+# ----->
+
+# <-----
+# IF YOUR PLUGIN NEED GLOBAL VARIABLES, THEY MUST BE DECLARED HERE.
+use vars qw/
+$DirClasses
+/;
+# ----->
+
+
+#-----------------------------------------------------------------------------
+# PLUGIN FUNCTION: Init_pluginname
+#-----------------------------------------------------------------------------
+sub Init_graphgooglechartapi {
+ my $InitParams = shift;
+ my $checkversion = &Check_Plugin_Version($PluginNeedAWStatsVersion);
+
+ # <-----
+ # ENTER HERE CODE TO DO INIT PLUGIN ACTIONS
+ $DirClasses = $InitParams;
+ # ----->
+
+ return ($checkversion?$checkversion:"$PluginHooksFunctions");
+}
+
+
+#-------------------------------------------------------
+# PLUGIN FUNCTION: ShowGraph_pluginname
+# UNIQUE: YES (Only one plugin using this function can be loaded)
+# Add the code for call to applet awgraphapplet
+# Parameters: $title $type $showmonthstats \@blocklabel,\@vallabel,\@valcolor,\@valmax,\@valtotal
+# Input: None
+# Output: HTML code for awgraphapplet insertion
+# Return: 0 OK, 1 Error
+#-------------------------------------------------------
+sub ShowGraph_graphgooglechartapi() {
+ my $title = shift;
+ my $type = shift;
+ my $showmonthstats = shift;
+ my $blocklabel = shift;
+ my $vallabel = shift;
+ my $valcolor = shift;
+ my $valmax = shift;
+ my $valtotal = shift;
+ my $valaverage = shift;
+ my $valdata = shift;
+
+ my $graphwidth = 780;
+ my $graphheight = 400;
+
+ my $color1 = "4477dd";
+ my $color2 = "66f0ff";
+ my $maxlabellen = 3;
+
+ if ($type eq 'month') {
+ $graphwidth = 540;
+ $graphheight = 160;
+ $color1 = "ffb055";
+ $color2 = "f8e880";
+ }
+ elsif ($type eq 'daysofmonth') {
+ $graphwidth = 640;
+ $graphheight = 160;
+ $color1 = "f8e880";
+ $color2 = "4477DD";
+ $maxlabellen = 2;
+ }
+ elsif ($type eq 'daysofweek') {
+ $graphwidth = 300;
+ $graphheight = 160;
+ }
+ elsif ($type eq 'hours') {
+ $graphwidth = 600;
+ $graphheight = 160;
+ }
+ else {
+ error("Unknown type parameter in ShowGraph_graphgooglechartapi function");
+ }
+
+ print "<img src = \"http://chart.apis.google.com/chart?cht=bvg&chd=t:";
+ $s = "";
+
+ # initialise array for 2 data series
+ @max = (0,0);
+
+ # display only x series
+ $x=1;
+ for ($serie = 0; $serie <= $x; $serie++) {
+ foreach my $j (1..(scalar @$blocklabel)) {
+ if ($j > 1) { $s .= ","; }
+ $val = @$valdata[($j-1)*(scalar @$vallabel)+$serie];
+ $s .= "$val";
+ if ($val > $max[$serie]) {
+ $max[$serie] = $val;
+ }
+ }
+ if ($serie < $x) {
+ $s .= "|";
+ }
+ }
+ print $s."&chds=0,$max[0],0,$max[1]&chbh=a&chl=";
+
+ # display labels
+ foreach my $i (1..(scalar @$blocklabel)) {
+ $b = "".@$blocklabel[$i-1];
+ $b = substr($b,0,$maxlabellen);
+ print $b ."|";
+ }
+ print "&chs=$graphwidth"; print "x$graphheight&chco=$color1,$color2\" alt=\"\" /><br />\n";
+
+ return 0;
+}
+
+
+
+1; # Do not remove this line