On Sun, Apr 13, 2008 at 10:38 AM, Joachim Herb <[EMAIL PROTECTED]> wrote:
> Hello, > > a feature I missed for a long time is the ability to extend the bar chart > graphs with tables > containing the same information as the graph. > > I added this to the standard reports net-barchart.scm and > category-barchart.scm. As I expect that > other people might also be interested in this, here are the patches. > > As these are my first scheme programs (and hopefully the last) feel free to > suggest improvements. > I couldn't get this to work. Try opening the attached GnuCash file, running the expense barchart, then going into the options and checking "Show table". I got a crashed report and a Scheme backtrace (shown below). Can you figure out what's wrong? Cheers, Charles In c:/soft/gnucash/inst/share/gnucash/scm/report.scm: 543: 27* (if template (let* # # # ...) #f) 544: 28 (let* (# # # ...) (gnc:html-document-set-style-sheet! doc stylesheet) ...) 546: 29* [#<procedure #f #> #] In c:/soft/gnucash/inst/share/gnucash/guile-modules/gnucash/report/category-barc hart.scm: 633: 30 [category-barchart-renderer # "Expense Over Time" ...] In unknown file: ... ?: 31 (letrec ((show-acct? #)) (if (not #) (let* # #) ...) ...) In c:/soft/gnucash/inst/share/gnucash/guile-modules/gnucash/report/category-barc hart.scm: 234: 32* (if (not (null? accounts)) (let* (# # # ...) (letrec # # ...)) ...) 237: 33 (let* (# # # # ...) (letrec # # # ...)) ... 532: 34 (begin # # # ...) 535: 35* (letrec ((addcol (lambda # #))) (addcol (map cadr all-data))) 546: 36 [addcol ((0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...))] ... 539: 37 (begin (gnc:html-table-append-column! table (car col)) (addcol (cdr co l))) 540: 38* [gnc:html-table-append-column! # #] In unknown file: ?: 39 (letrec (# # #) (let* # #)) In c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm: ... 500: 40 [gnc:html-table-set-data! # ... 502: 41* [reverse ... 502: 42* [car ... 502: 43* [append-to-element (# # # # ...) (# # # # ...) 13 ...] 479: 44 (if (= length-to-append 0) (cons (quote ()) newcol) ...) 481: 45 (let* (# # # # ...) (cons # #)) 486: 46* (append-to-element rest-new rest-existing (- length-to-append 1)) c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm:486:27: In expression (app end-to-element rest-new rest-existing ...): c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm:486:27: Wrong number of ar guments to #<procedure append-to-element (newcol existing-data length-to-append width-to-make)> In c:/soft/gnucash/inst/share/gnucash/scm/report.scm: 543: 24* (if template (let* # # # ...) #f) 544: 25 (let* (# # # ...) (gnc:html-document-set-style-sheet! doc stylesheet) ...) 546: 26* [#<procedure #f #> #] In c:/soft/gnucash/inst/share/gnucash/guile-modules/gnucash/report/category-barc hart.scm: 633: 27 [category-barchart-renderer # "Expense Over Time" ...] In unknown file: ... ?: 28 (letrec ((show-acct? #)) (if (not #) (let* # #) ...) ...) In c:/soft/gnucash/inst/share/gnucash/guile-modules/gnucash/report/category-barc hart.scm: 234: 29* (if (not (null? accounts)) (let* (# # # ...) (letrec # # ...)) ...) 237: 30 (let* (# # # # ...) (letrec # # # ...)) ... 532: 31 (begin # # # ...) 535: 32* (letrec ((addcol (lambda # #))) (addcol (map cadr all-data))) 546: 33 [addcol ((0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 ...))] ... 539: 34 (begin (gnc:html-table-append-column! table (car col)) (addcol (cdr co l))) 540: 35* [gnc:html-table-append-column! # #] In unknown file: ?: 36 (letrec (# # #) (let* # #)) In c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm: ... 500: 37 [gnc:html-table-set-data! # ... 502: 38* [reverse ... 502: 39* [car ... 502: 40* [append-to-element (# # # # ...) (# # # # ...) 13 ...] 479: 41 (if (= length-to-append 0) (cons (quote ()) newcol) ...) 481: 42 (let* (# # # # ...) (cons # #)) 486: 43* (append-to-element rest-new rest-existing (- length-to-append 1)) c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm:486:27: In expression (app end-to-element rest-new rest-existing ...): c:/soft/gnucash/inst/share/gnucash/scm/html-table.scm:486:27: Wrong number of ar guments to #<procedure append-to-element (newcol existing-data length-to-append width-to-make)> > Joachim > > > --- category-barchart.scm 2008-03-02 14:24:56.000000000 +0100 > +++ /home/joachim/workspace/gnucash/category-barchart.scm 2008-04-13 > 18:57:05.000000000 +0200 > @@ -146,13 +146,20 @@ > "c" (N_ "Maximum number of bars in the chart") 8 > 2 24 0 1)) > > + (add-option > + (gnc:make-simple-boolean-option > + gnc:pagename-display > + (N_ "Show table") > + "d" (N_ "Display a table of the selected data.") > + #f)) > + > (gnc:options-add-plot-size! > options gnc:pagename-display > - optname-plot-width optname-plot-height "d" 400 400) > + optname-plot-width optname-plot-height "e" 400 400) > > (gnc:options-add-sort-method! > options gnc:pagename-display > - optname-sort-method "e" 'amount) > + optname-sort-method "f" 'amount) > > (gnc:options-set-default-section options gnc:pagename-general) > > @@ -209,8 +216,10 @@ > > (work-done 0) > (work-to-do 0) > + (show-table? (get-option gnc:pagename-display (N_ "Show table"))) > (document (gnc:make-html-document)) > (chart (gnc:make-html-barchart)) > + (table (gnc:make-html-table)) > (topl-accounts (gnc:filter-accountlist-type > account-types > (gnc-account-get-children-sorted > @@ -518,7 +528,79 @@ > chart (append urls urls))) > > (gnc:report-percent-done 98) > - (gnc:html-document-add-object! document chart)) > + (gnc:html-document-add-object! document chart) > + (if show-table? > + (begin > + (gnc:html-table-append-column! table date-string-list) > + > + (letrec > + ((addcol > + (lambda (col) > + (if (not (null? col)) > + (begin > + (gnc:html-table-append-column! > + table (car col)) > + (addcol (cdr col)) > + ) > + )) > + )) > + (addcol (map cadr all-data)) > + ) > + > + (gnc:html-table-set-col-headers! > + table > + (append > + (list (_ "Date")) > + (map (lambda (pair) > + (regexp-substitute/global #f "&" > + (if (string? (car > pair)) > + (car pair) > + ((if > show-fullname? > + > gnc-account-get-full-name > + > xaccAccountGetName) (car pair))) > + 'pre " " (_ "and") " > " 'post)) > + all-data) > + (if (> (gnc:html-table-num-columns table) 2) > + (list (_ "Grand Total")) > + (list nil) > + ) > + )) > + > + (if (> (gnc:html-table-num-columns table) 2) > + (letrec > + ((sumtot > + (lambda (row) > + (if (null? row) > + '() > + (cons (sumrow (car row)) (sumtot (cdr > row))) > + ) > + ) > + ) > + (sumrow > + (lambda (row) > + (if (not (null? row)) > + (+ (car row) (sumrow (cdr row))) > + 0 > + ) > + ) > + )) > + (gnc:html-table-append-column! > + table > + (sumtot (apply zip (map cadr all-data))) > + ) > + ) > + ) > + ;; 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 4 5 6 7 8 9 10 11 12 13 14)) > + (gnc:html-document-add-object! document table) > + ) ;; begin if > + ) > + ) > > ;; else if empty data > (gnc:html-document-add-object! > > > --- end diff category-barchart.scm > > > --- net-barchart.scm 2008-03-02 14:24:56.000000000 +0100 > +++ /home/joachim/workspace/gnucash/net-barchart.scm 2008-04-13 > 19:23:46.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 > _______________________________________________ > gnucash-devel mailing list > gnucash-devel@gnucash.org > https://lists.gnucash.org/mailman/listinfo/gnucash-devel >
expbarchart
Description: Binary data
_______________________________________________ gnucash-devel mailing list gnucash-devel@gnucash.org https://lists.gnucash.org/mailman/listinfo/gnucash-devel