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>
|
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
|
* src/scm/html-utilities.scm: display report title
|
||||||
string in gnc:html-no-account-warning and
|
string in gnc:html-no-account-warning and
|
||||||
gnc:html-make-empty-data-warning. API changed.
|
gnc:html-make-empty-data-warning. API changed.
|
||||||
|
@ -293,9 +293,16 @@
|
|||||||
|
|
||||||
(beforebegindate (gnc:timepair-end-day-time
|
(beforebegindate (gnc:timepair-end-day-time
|
||||||
(gnc:timepair-previous-day begindate)))
|
(gnc:timepair-previous-day begindate)))
|
||||||
|
(all-zeros? #t)
|
||||||
;; startbal will be a commodity-collector
|
;; startbal will be a commodity-collector
|
||||||
(startbal '()))
|
(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)
|
(define (monetary->double foreign-monetary date)
|
||||||
(gnc:numeric-to-double
|
(gnc:numeric-to-double
|
||||||
(gnc:gnc-monetary-amount
|
(gnc:gnc-monetary-amount
|
||||||
@ -378,60 +385,86 @@
|
|||||||
(col-labels '())
|
(col-labels '())
|
||||||
(col-colors '()))
|
(col-colors '()))
|
||||||
(if (memq 'AvgBalPlot plot-type)
|
(if (memq 'AvgBalPlot plot-type)
|
||||||
(begin
|
(let
|
||||||
(gnc:html-barchart-append-column!
|
((number-data
|
||||||
barchart
|
(map
|
||||||
(map (lambda (row) (list-ref row 2)) data))
|
(lambda (row) (list-ref row 2)) data)))
|
||||||
(set! col-labels
|
(if (not (list-all-zeros? number-data))
|
||||||
(append col-labels
|
(begin
|
||||||
(list (list-ref columns 2))))
|
(gnc:html-barchart-append-column!
|
||||||
(set! col-colors
|
barchart
|
||||||
(append col-colors (list "blue")))))
|
(map (lambda (row) (list-ref row 2)) data))
|
||||||
|
(set! col-labels
|
||||||
|
(append col-labels
|
||||||
|
(list (list-ref columns 2))))
|
||||||
|
(set! col-colors
|
||||||
|
(append col-colors (list "blue")))
|
||||||
|
(set! all-zeros? #f)))))
|
||||||
|
|
||||||
|
|
||||||
(if (memq 'GainPlot plot-type)
|
(if (memq 'GainPlot plot-type)
|
||||||
(begin
|
(let ((number-data
|
||||||
(gnc:html-barchart-append-column!
|
(map (lambda (row) (list-ref row 7)) data)))
|
||||||
barchart
|
(if (not (list-all-zeros? number-data))
|
||||||
(map (lambda (row) (list-ref row 7)) data))
|
(begin
|
||||||
(set! col-labels
|
(gnc:html-barchart-append-column!
|
||||||
(append col-labels
|
barchart
|
||||||
(list (list-ref columns 7))))
|
(map (lambda (row) (list-ref row 7)) data))
|
||||||
(set! col-colors
|
(set! col-labels
|
||||||
(append col-colors (list "green")))))
|
(append col-labels
|
||||||
|
(list (list-ref columns 7))))
|
||||||
|
(set! col-colors
|
||||||
|
(append col-colors (list "green")))
|
||||||
|
(set! all-zeros? #f)))))
|
||||||
|
|
||||||
(if (memq 'GLPlot plot-type)
|
(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
|
;; debit column
|
||||||
(gnc:html-barchart-append-column!
|
(if (not (and
|
||||||
barchart
|
(list-all-zeros? debit-data)
|
||||||
(map (lambda (row) (list-ref row 5)) data))
|
(list-all-zeros? credit-data)))
|
||||||
(set! col-labels
|
(begin
|
||||||
(append col-labels
|
(gnc:html-barchart-append-column!
|
||||||
(list (list-ref columns 5))))
|
barchart
|
||||||
(set! col-colors
|
number-data)
|
||||||
(append col-colors (list "black")))
|
(set! col-labels
|
||||||
|
(append col-labels
|
||||||
|
(list (list-ref columns 5))))
|
||||||
|
(set! col-colors
|
||||||
|
(append col-colors (list "black")))
|
||||||
|
|
||||||
;; credit
|
;; credit
|
||||||
(gnc:html-barchart-append-column!
|
(gnc:html-barchart-append-column!
|
||||||
barchart
|
barchart
|
||||||
(map (lambda (row) (list-ref row 6)) data))
|
(map (lambda (row) (list-ref row 6)) data))
|
||||||
(set! col-labels
|
(set! col-labels
|
||||||
(append col-labels
|
(append col-labels
|
||||||
(list (list-ref columns 6))))
|
(list (list-ref columns 6))))
|
||||||
(set! col-colors
|
(set! col-colors
|
||||||
(append col-colors (list "red")))))
|
(append col-colors (list "red")))
|
||||||
|
(set all-zeros? #f)))))
|
||||||
|
|
||||||
(gnc:html-barchart-set-col-labels!
|
(if (not all-zeros?)
|
||||||
barchart col-labels)
|
(begin
|
||||||
(gnc:html-barchart-set-col-colors!
|
(gnc:html-barchart-set-col-labels!
|
||||||
barchart col-colors)
|
barchart col-labels)
|
||||||
(gnc:html-barchart-set-row-labels!
|
(gnc:html-barchart-set-col-colors!
|
||||||
barchart (map car data))
|
barchart col-colors)
|
||||||
(gnc:html-barchart-set-row-labels-rotated?! barchart #t)
|
(gnc:html-barchart-set-row-labels!
|
||||||
|
barchart (map car data))
|
||||||
|
(gnc:html-barchart-set-row-labels-rotated?! barchart #t)
|
||||||
|
|
||||||
(gnc:html-barchart-set-width! barchart width)
|
(gnc:html-barchart-set-width! barchart width)
|
||||||
(gnc:html-barchart-set-height! barchart height)
|
(gnc:html-barchart-set-height! barchart height)
|
||||||
(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)
|
;; make a table (optionally)
|
||||||
(if show-table?
|
(if show-table?
|
||||||
|
Loading…
Reference in New Issue
Block a user