mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Catch case with empty or zero data lists before handing off to graph code.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4281 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3c1c2a1a5f
commit
29678f8a6f
@ -17,6 +17,10 @@
|
||||
|
||||
2001-05-25 Robert Graham Merkel <rgmerk@mira.net>
|
||||
|
||||
* src/scm/report/average-balance.scm: catch all-zero-data
|
||||
case, display warning message rather than let the graphing
|
||||
code catch it.
|
||||
|
||||
* src/scm/html-utilities.scm: display report title
|
||||
string in gnc:html-no-account-warning and
|
||||
gnc:html-make-empty-data-warning. API changed.
|
||||
|
@ -293,9 +293,16 @@
|
||||
|
||||
(beforebegindate (gnc:timepair-end-day-time
|
||||
(gnc:timepair-previous-day begindate)))
|
||||
(all-zeros? #t)
|
||||
;; startbal will be a commodity-collector
|
||||
(startbal '()))
|
||||
|
||||
(define (list-all-zeros? alist)
|
||||
(if (null? alist) #t
|
||||
(if (not (= 0.0 (car alist)))
|
||||
#f
|
||||
(list-all-zeros? (cdr alist)))))
|
||||
|
||||
(define (monetary->double foreign-monetary date)
|
||||
(gnc:numeric-to-double
|
||||
(gnc:gnc-monetary-amount
|
||||
@ -378,6 +385,11 @@
|
||||
(col-labels '())
|
||||
(col-colors '()))
|
||||
(if (memq 'AvgBalPlot plot-type)
|
||||
(let
|
||||
((number-data
|
||||
(map
|
||||
(lambda (row) (list-ref row 2)) data)))
|
||||
(if (not (list-all-zeros? number-data))
|
||||
(begin
|
||||
(gnc:html-barchart-append-column!
|
||||
barchart
|
||||
@ -386,9 +398,14 @@
|
||||
(append col-labels
|
||||
(list (list-ref columns 2))))
|
||||
(set! col-colors
|
||||
(append col-colors (list "blue")))))
|
||||
(append col-colors (list "blue")))
|
||||
(set! all-zeros? #f)))))
|
||||
|
||||
|
||||
(if (memq 'GainPlot plot-type)
|
||||
(let ((number-data
|
||||
(map (lambda (row) (list-ref row 7)) data)))
|
||||
(if (not (list-all-zeros? number-data))
|
||||
(begin
|
||||
(gnc:html-barchart-append-column!
|
||||
barchart
|
||||
@ -397,13 +414,22 @@
|
||||
(append col-labels
|
||||
(list (list-ref columns 7))))
|
||||
(set! col-colors
|
||||
(append col-colors (list "green")))))
|
||||
(append col-colors (list "green")))
|
||||
(set! all-zeros? #f)))))
|
||||
|
||||
(if (memq 'GLPlot plot-type)
|
||||
(begin
|
||||
(let ((debit-data
|
||||
(map (lambda (row) list-ref row 5) data))
|
||||
(credit-data
|
||||
(map (lambda (row) list-ref row 6) data)))
|
||||
;; debit column
|
||||
(if (not (and
|
||||
(list-all-zeros? debit-data)
|
||||
(list-all-zeros? credit-data)))
|
||||
(begin
|
||||
(gnc:html-barchart-append-column!
|
||||
barchart
|
||||
(map (lambda (row) (list-ref row 5)) data))
|
||||
number-data)
|
||||
(set! col-labels
|
||||
(append col-labels
|
||||
(list (list-ref columns 5))))
|
||||
@ -418,8 +444,11 @@
|
||||
(append col-labels
|
||||
(list (list-ref columns 6))))
|
||||
(set! col-colors
|
||||
(append col-colors (list "red")))))
|
||||
(append col-colors (list "red")))
|
||||
(set all-zeros? #f)))))
|
||||
|
||||
(if (not all-zeros?)
|
||||
(begin
|
||||
(gnc:html-barchart-set-col-labels!
|
||||
barchart col-labels)
|
||||
(gnc:html-barchart-set-col-colors!
|
||||
@ -431,7 +460,11 @@
|
||||
(gnc:html-barchart-set-width! barchart width)
|
||||
(gnc:html-barchart-set-height! barchart height)
|
||||
(gnc:html-barchart-set-height! barchart height)
|
||||
(gnc:html-document-add-object! document barchart)))
|
||||
(gnc:html-document-add-object! document barchart))
|
||||
(gnc:html-document-add-object!
|
||||
document
|
||||
(gnc:html-make-empty-data-warning
|
||||
(_ "Average Balance"))))))
|
||||
|
||||
;; make a table (optionally)
|
||||
(if show-table?
|
||||
|
Loading…
Reference in New Issue
Block a user