Bugzilla – Attachment 33372 Details for
Bug 13219
Add graphs to guided reports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Added graphs to cataloging report
Added-graphs-to-cataloging-report.patch (text/plain), 6.40 KB, created by
Martin Renvoize (ashimema)
on 2014-11-07 09:36:09 UTC
(
hide
)
Description:
Added graphs to cataloging report
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2014-11-07 09:36:09 UTC
Size:
6.40 KB
patch
obsolete
>From f9857130dc9a20584ae159a89bac16f9a75976e9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 8 Sep 2014 11:25:05 +0000 >Subject: [PATCH] Added graphs to cataloging report > >http://bugs.koha-community.org/show_bug.cgi?id=13219 >--- > .../prog/en/modules/reports/catalogue_stats.tt | 50 ++++++++++++++++- > reports/catalogue_stats.pl | 58 +++++++++++++++++++- > 2 files changed, 105 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt >index 9290ea7..ca72d92 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/catalogue_stats.tt >@@ -2,6 +2,7 @@ > <title>Koha › Reports [% IF ( do_it ) %]› Catalog statistics › Results[% ELSE %]› Catalog statistics[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] > [% INCLUDE 'calendar.inc' %] >+<script src="[% interface %]/lib/charts/Chart.min.js"></script> > <script type="text/javascript"> > //<![CDATA[ > $(document).ready(function() { >@@ -51,7 +52,9 @@ > [% IF ( do_it ) %] > [% FOREACH mainloo IN mainloop %] > <h1>Catalog statistics</h1> >- [% IF ( mainloo.loopfilter ) %] >+ <canvas id="catChart" width="1000" height="400"></canvas> >+ <div id="toolbar" class="btn-toolbar"><div class="btn-group"><a id="updateChart" class="btn" href="#">Click to change to <span id="chartType">Line</span> Chart</a></div></div> >+ [% IF ( mainloo.loopfilter ) %] > <p>Filtered on:</p> > [% FOREACH loopfilte IN mainloo.loopfilter %] > <p>[% loopfilte.crit %] =[% loopfilte.filter %]</p> >@@ -272,4 +275,49 @@ > [% INCLUDE 'reports-menu.inc' %] > </div> > </div> >+[% IF ( do_it ) %] >+<script type="text/javascript"> >+ var ctx = $("#catChart").get(0).getContext("2d"); >+ >+ var chartData = { >+ labels: [[% FOREACH loopco IN mainloo.loopcol %]"[% loopco.coltitle_display |html %]", [% END %]], >+ datasets: [ >+ [% FOREACH loopro IN mainloo.looprow %]{ >+ label: "[% loopro.rowtitle_display or "UNKNOWN VALUE" |html %]", >+ fillColor: "[% loopro.fill %]", >+ strokeColor: "[% loopro.stroke %]", >+ pointColor: "[% loopro.point %]", >+ pointStrokeColor: "#fff", >+ pointHighlightFill: "#fff", >+ pointHighlightStroke: "[% loopro.highlight %]", >+ data: [[% FOREACH loopcel IN loopro.loopcell %]"[% loopcel.value %]", [% END %]] >+ }, [% END %]] >+ }; >+ >+ var chartType = "Bar"; >+ var catChart = new Chart(ctx).Bar( chartData, {}); >+ >+ $("#updateChart").click(function() { >+ console.log("Updating Chart: "); >+ >+ // Replace the chart canvas element >+ $('#catChart').replaceWith('<canvas id="catChart" width="1000" height="400"></canvas>'); >+ >+ // Draw the chart >+ ctx = $('#catChart').get(0).getContext("2d"); >+ >+ if ( chartType == "Bar" ) { >+ new Chart(ctx).Line( chartData, {}); >+ $('#chartType').text('Bar'); >+ chartType = "Line"; >+ } else { >+ new Chart(ctx).Bar( chartData, {}); >+ $('#chartType').text('Line'); >+ chartType = "Bar"; >+ } >+ }); >+ //circChart.update(); >+</script> >+[% END %] >+ > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/reports/catalogue_stats.pl b/reports/catalogue_stats.pl >index a19334a..94b7d52 100755 >--- a/reports/catalogue_stats.pl >+++ b/reports/catalogue_stats.pl >@@ -188,6 +188,7 @@ sub calculate { > my $barcodelike = @$filters[13]; > my $barcodefilter = @$filters[14]; > my $not; >+ my $colors = get_colors(); > > # extract parameters > my $dbh = C4::Context->dbh; >@@ -476,7 +477,8 @@ if($barcodefilter){ > # my %cell; > # %cell = {coltitle => "zzEMPTY"}; > push @loopcol,{coltitle => "NULL"} if ($emptycol); >- >+ >+ my $loopcount = '0'; > foreach my $row ( sort keys %table ) { > my @loopcell; > #@loopcol ensures the order for columns is common with column titles >@@ -488,8 +490,17 @@ if($barcodefilter){ > push @looprow,{ 'rowtitle' => ($row eq "zzEMPTY")?"NULL":$row, > 'loopcell' => \@loopcell, > 'hilighted' => ($hilighted *= -1 > 0), >- 'totalrow' => $table{$row}->{totalrow} >+ 'totalrow' => $table{$row}->{totalrow}, >+ 'fill' => ${$colors}[$loopcount]->{fill}, >+ 'stroke' => ${$colors}[$loopcount]->{stroke}, >+ 'point' => ${$colors}[$loopcount]->{point}, >+ 'highlight' => ${$colors}[$loopcount]->{highlight}, >+ > }; >+ $loopcount++; >+ if ( $loopcount == '6' ) { >+ $loopcount = '0'; >+ } > } > > # warn "footer processing"; >@@ -518,4 +529,47 @@ if($barcodefilter){ > return \@mainloop; > } > >+sub get_colors { >+ my $colors = [ >+ { >+ fill => "rgba(151,187,205,0.2)", >+ stroke => "rgba(151,187,205,1)", >+ point => "rgba(151,187,205,1)", >+ highlight => "rgba(151,187,205,1)", >+ }, >+ { >+ fill => "rgba(216,191,216,0.2)", >+ stroke => "rgba(216,191,216,1)", >+ point => "rgba(216,191,216,1)", >+ highlight => "rgba(216,191,216,1)", >+ }, >+ { >+ fill => "rgba(240,128,128,0.2)", >+ stroke => "rgba(240,128,128,1)", >+ point => "rgba(240,128,128,1)", >+ highlight => "rgba(240,128,128,1)", >+ }, >+ { >+ fill => "rgba(240,230,140,0.2)", >+ stroke => "rgba(240,230,140,1)", >+ point => "rgba(240,230,140,1)", >+ highlight => "rgba(240,230,140,1)", >+ }, >+ { >+ fill => "rgba(152,251,152,0.2)", >+ stroke => "rgba(152,251,152,1)", >+ point => "rgba(152,251,152,1)", >+ highlight => "rgba(152,251,152,1)", >+ }, >+ { >+ fill => "rgba(216,191,216,0.2)", >+ stroke => "rgba(216,191,216,1)", >+ point => "rgba(216,191,216,1)", >+ highlight => "rgba(216,191,216,1)", >+ }, >+ ]; >+ >+ return $colors; >+} >+ > 1; >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 13219
:
33368
|
33369
|
33370
|
33371
|
33372
|
39777
|
39778
|
39779
|
39780
|
39781
|
39782