Extent reports with diagrams by tables
Joachim Herb
Joachim.Herb at gmx.de
Sat Apr 5 13:09:37 EDT 2008
Hello,
I have extended net-barchart.scm with an option to display a table below the chart. I had also to
patch the file scm/html-table.scm because there was a crash whenever I added a second column to a
html table. I have no idea if this is the correct fix, but a least it works for me.
Here is the patch:
diff -ruBbw gnucash/guile-modules/gnucash/report/net-barchart.scm
gnucash-new/guile-modules/gnucash/report/net-barchart.scm
--- gnucash/guile-modules/gnucash/report/net-barchart.scm 2008-04-05 18:48:54.000000000 +0200
+++ gnucash-new/guile-modules/gnucash/report/net-barchart.scm 2008-04-05 18:56:45.000000000 +0200
@@ -120,9 +120,16 @@
(N_ "Show a Net Worth bar?"))
#t))
+ (add-option
+ (gnc:make-simple-boolean-option
+ gnc:pagename-display
+ (N_ "Show table")
+ "c" (N_ "Display a table of the selected data.")
+ #f))
+
(gnc:options-add-plot-size!
options gnc:pagename-display
- optname-plot-width optname-plot-height "c" 500 400)
+ optname-plot-width optname-plot-height "d" 500 400)
(gnc:options-set-default-section options gnc:pagename-general)
@@ -179,6 +186,7 @@
(report-title (get-option gnc:pagename-general
gnc:optname-reportname))
(classified-accounts (gnc:decompose-accountlist accounts))
+ (show-table? (get-option gnc:pagename-display (N_ "Show table")))
(document (gnc:make-html-document))
(chart (gnc:make-html-barchart))
(non-zeros #f))
@@ -356,7 +364,45 @@
;; Test for all-zero data here.
(if non-zeros
+ (begin
(gnc:html-document-add-object! document chart)
+ (if show-table?
+ (let ((table (gnc:make-html-table)))
+ (gnc:html-table-set-col-headers!
+ table
+ (append
+ (list (_ "Date"))
+ (if show-sep?
+ (if inc-exp?
+ (list (_ "Income") (_ "Expense"))
+ (list (_ "Assets") (_ "Liabilities")))
+ '())
+ (if show-net?
+ (if inc-exp?
+ (list (_ "Net Profit"))
+ (list (_ "Net Worth")))
+ '()))
+ )
+ (gnc:html-table-append-column! table date-string-list)
+ (if show-sep?
+ (begin
+ (gnc:html-table-append-column! table assets-list)
+ (gnc:html-table-append-column! table liability-list)
+ )
+ )
+ (if show-net?
+ (gnc:html-table-append-column! table net-list)
+ )
+ ;; set numeric columns to align right
+ (for-each
+ (lambda (col)
+ (gnc:html-table-set-col-style!
+ table col "td"
+ 'attribute (list "align" "right")))
+ '(1 2 3))
+
+ (gnc:html-document-add-object! document table))
+ ))
(gnc:html-document-add-object!
document
(gnc:html-make-empty-data-warning
diff -ruBbw gnucash/scm/html-table.scm gnucash-new/scm/html-table.scm
--- gnucash/scm/html-table.scm 2008-04-05 18:48:52.000000000 +0200
+++ gnucash-new/scm/html-table.scm 2008-04-05 16:08:56.000000000 +0200
@@ -484,7 +484,7 @@
(rest-new (cdr newcol))
(rest-existing (cdr existing-data))
(rest-result (append-to-element rest-new rest-existing
- (- length-to-append 1))))
+ (- length-to-append 1) width-to-make)))
(cons (cons (widen-and-append
current-existing
current-new
------- patch end
Joachim
More information about the gnucash-user
mailing list