mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add sorting options for barcharts and piecharts. Work around Guppi
problem by replacing the character "&" with the word "and". git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7760 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
2c0b8dae96
commit
c1b10d5299
23
ChangeLog
23
ChangeLog
@ -1,5 +1,28 @@
|
||||
2003-01-02 David Hampton <hampton@employees.org>
|
||||
|
||||
* src/report/report-system/options-utilities.scm:
|
||||
* src/report/report-system/report-system.scm: Add new option for
|
||||
specifying sort critera for piecharts and barcharts.
|
||||
|
||||
* src/report/standard-reports/account-piecharts.scm: Add various
|
||||
sorting options. Work around Guppi problem by replacing the
|
||||
character "&" with the word "and".
|
||||
|
||||
* src/report/standard-reports/category-barchart.scm: Add various
|
||||
sorting options. The default is now by ammount instead of by
|
||||
account-code, which is a much more interesting report. #102342
|
||||
Work around Guppi problem by replacing the character "&" with the
|
||||
word "and". Don't "reverse" the barchart legend. Double-clicking
|
||||
on the legend now opend the right child report.
|
||||
|
||||
* src/report/standard-reports/net-barchart.scm: The report title
|
||||
should change when the report name field is changed in the
|
||||
options. #102266
|
||||
|
||||
* src/report/standard-reports/pnl.scm: The report title should
|
||||
change when the report name field is changed in the
|
||||
options. #102267
|
||||
|
||||
* src/gnome-utils/window-help.c (helpWindow): Correctly pass on
|
||||
the label when first opening a help window.
|
||||
|
||||
|
@ -273,3 +273,18 @@
|
||||
(vector 'filledcircle "filled circle" "filled circle")
|
||||
(vector 'filledsquare "filled square" "filled square")))))
|
||||
|
||||
|
||||
(define (gnc:options-add-sort-method!
|
||||
options pagename optname sort-tag default)
|
||||
(gnc:register-option
|
||||
options
|
||||
(gnc:make-multichoice-option
|
||||
pagename optname
|
||||
sort-tag
|
||||
(N_ "Choose the method for sorting accounts.")
|
||||
default
|
||||
(list
|
||||
(vector 'acct-code "Account Code" "Alphabetical by account code")
|
||||
(vector 'alphabetical "Alphabetical" "Alphabetical by account name")
|
||||
(vector 'amount "Amount" "By amount, largest to smallest")))))
|
||||
|
||||
|
@ -67,6 +67,7 @@
|
||||
(export gnc:options-add-price-source!)
|
||||
(export gnc:options-add-plot-size!)
|
||||
(export gnc:options-add-marker-choice!)
|
||||
(export gnc:options-add-sort-method!)
|
||||
|
||||
;; html-utilities.scm
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
|
||||
(use-modules (srfi srfi-1))
|
||||
(use-modules (ice-9 slib))
|
||||
(use-modules (ice-9 regex))
|
||||
(use-modules (gnucash gnc-module))
|
||||
|
||||
(require 'printf)
|
||||
@ -72,6 +73,7 @@ balance at a given time"))
|
||||
(define optname-slices (N_ "Maximum Slices"))
|
||||
(define optname-plot-width (N_ "Plot Width"))
|
||||
(define optname-plot-height (N_ "Plot Height"))
|
||||
(define optname-sort-method (N_ "Sort Method"))
|
||||
|
||||
;; The option-generator. The only dependance on the type of piechart
|
||||
;; is the list of account types that the account selection option
|
||||
@ -138,6 +140,10 @@ balance at a given time"))
|
||||
options gnc:pagename-display
|
||||
optname-plot-width optname-plot-height "d" 500 350)
|
||||
|
||||
(gnc:options-add-sort-method!
|
||||
options gnc:pagename-display
|
||||
optname-sort-method "e" 'amount)
|
||||
|
||||
(gnc:options-set-default-section options gnc:pagename-general)
|
||||
|
||||
options))
|
||||
@ -182,6 +188,7 @@ balance at a given time"))
|
||||
(max-slices (get-option gnc:pagename-display optname-slices))
|
||||
(height (get-option gnc:pagename-display optname-plot-height))
|
||||
(width (get-option gnc:pagename-display optname-plot-width))
|
||||
(sort-method (get-option gnc:pagename-display optname-sort-method))
|
||||
|
||||
(work-done 0)
|
||||
(work-to-do 0)
|
||||
@ -297,7 +304,21 @@ balance at a given time"))
|
||||
(sort (filter (lambda (pair) (not (>= 0.0 (car pair))))
|
||||
(fix-signs
|
||||
(traverse-accounts 1 topl-accounts)))
|
||||
(lambda (a b) (> (car a) (car b)))))
|
||||
(cond
|
||||
((eq? sort-method 'acct-code)
|
||||
(lambda (a b)
|
||||
(string<? (gnc:account-get-code (cadr a))
|
||||
(gnc:account-get-code (cadr b)))))
|
||||
((eq? sort-method 'alphabetical)
|
||||
(lambda (a b)
|
||||
(string<? ((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (cadr a))
|
||||
((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (cadr b)))))
|
||||
(else
|
||||
(lambda (a b) (> (car a) (car b)))))))
|
||||
|
||||
;; if too many slices, condense them to an 'other' slice
|
||||
;; and add a link to a new pie report with just those
|
||||
@ -397,11 +418,13 @@ balance at a given time"))
|
||||
(map
|
||||
(lambda (pair)
|
||||
(string-append
|
||||
(regexp-substitute/global #f "&"
|
||||
(if (string? (cadr pair))
|
||||
(cadr pair)
|
||||
((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (cadr pair)))
|
||||
'pre " " (_ "and") " " 'post)
|
||||
(if show-total?
|
||||
(string-append
|
||||
" - "
|
||||
|
@ -27,6 +27,7 @@
|
||||
(use-modules (srfi srfi-1))
|
||||
(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
|
||||
(use-modules (ice-9 slib))
|
||||
(use-modules (ice-9 regex))
|
||||
(use-modules (gnucash gnc-module))
|
||||
|
||||
(require 'printf)
|
||||
@ -79,6 +80,7 @@ developing over time"))
|
||||
(define optname-slices (N_ "Maximum Bars"))
|
||||
(define optname-plot-width (N_ "Plot Width"))
|
||||
(define optname-plot-height (N_ "Plot Height"))
|
||||
(define optname-sort-method (N_ "Sort Method"))
|
||||
|
||||
(define (options-generator account-types)
|
||||
(let* ((options (gnc:new-options))
|
||||
@ -142,7 +144,11 @@ developing over time"))
|
||||
|
||||
(gnc:options-add-plot-size!
|
||||
options gnc:pagename-display
|
||||
optname-plot-width optname-plot-height "c" 400 400)
|
||||
optname-plot-width optname-plot-height "d" 400 400)
|
||||
|
||||
(gnc:options-add-sort-method!
|
||||
options gnc:pagename-display
|
||||
optname-sort-method "e" 'amount)
|
||||
|
||||
(gnc:options-set-default-section options gnc:pagename-general)
|
||||
|
||||
@ -193,6 +199,7 @@ developing over time"))
|
||||
(max-slices (get-option gnc:pagename-display optname-slices))
|
||||
(height (get-option gnc:pagename-display optname-plot-height))
|
||||
(width (get-option gnc:pagename-display optname-plot-width))
|
||||
(sort-method (get-option gnc:pagename-display optname-sort-method))
|
||||
|
||||
(work-done 0)
|
||||
(work-to-do 0)
|
||||
@ -355,9 +362,23 @@ developing over time"))
|
||||
(filter (lambda (l)
|
||||
(not (= 0.0 (apply + (cadr l)))))
|
||||
(traverse-accounts 1 topl-accounts))
|
||||
(cond
|
||||
((eq? sort-method 'acct-code)
|
||||
(lambda (a b)
|
||||
(string<? (gnc:account-get-code (car a))
|
||||
(gnc:account-get-code (car b))))))
|
||||
(gnc:account-get-code (car b)))))
|
||||
((eq? sort-method 'alphabetical)
|
||||
(lambda (a b)
|
||||
(string<? ((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (car a))
|
||||
((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (car b)))))
|
||||
(else
|
||||
(lambda (a b)
|
||||
(> (apply + (cadr a))
|
||||
(apply + (cadr b))))))))
|
||||
;; Or rather sort by total amount?
|
||||
;;(< (apply + (cadr a))
|
||||
;; (apply + (cadr b))))))
|
||||
@ -394,7 +415,8 @@ developing over time"))
|
||||
(gnc:html-barchart-set-row-labels-rotated?! chart #t)
|
||||
(gnc:html-barchart-set-stacked?! chart stacked?)
|
||||
;; If this is a stacked barchart, then reverse the legend.
|
||||
(gnc:html-barchart-set-legend-reversed?! chart stacked?)
|
||||
;; Doesn't do what you'd expect. - DRH
|
||||
;;(gnc:html-barchart-set-legend-reversed?! chart stacked?)
|
||||
|
||||
;; If we have too many categories, we sum them into a new
|
||||
;; 'other' category and add a link to a new report with just
|
||||
@ -436,11 +458,13 @@ developing over time"))
|
||||
(gnc:report-percent-done 94)
|
||||
(gnc:html-barchart-set-col-labels!
|
||||
chart (map (lambda (pair)
|
||||
(regexp-substitute/global #f "&"
|
||||
(if (string? (car pair))
|
||||
(car pair)
|
||||
((if show-fullname?
|
||||
gnc:account-get-full-name
|
||||
gnc:account-get-name) (car pair))))
|
||||
gnc:account-get-name) (car pair)))
|
||||
'pre " " (_ "and") " " 'post))
|
||||
all-data))
|
||||
(gnc:html-barchart-set-col-colors!
|
||||
chart
|
||||
|
Loading…
Reference in New Issue
Block a user