diff --git a/ChangeLog b/ChangeLog index 744ae04cc4..878c213fc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,28 @@ 2003-01-02 David Hampton + * 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. diff --git a/src/report/report-system/options-utilities.scm b/src/report/report-system/options-utilities.scm index fcfa87fd3e..bf917bcf3f 100644 --- a/src/report/report-system/options-utilities.scm +++ b/src/report/report-system/options-utilities.scm @@ -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"))))) + diff --git a/src/report/report-system/report-system.scm b/src/report/report-system/report-system.scm index 0900d52ae7..2f1d84f01f 100644 --- a/src/report/report-system/report-system.scm +++ b/src/report/report-system/report-system.scm @@ -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 diff --git a/src/report/standard-reports/account-piecharts.scm b/src/report/standard-reports/account-piecharts.scm index ea8d0158e4..20d7247032 100644 --- a/src/report/standard-reports/account-piecharts.scm +++ b/src/report/standard-reports/account-piecharts.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 (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,21 +418,23 @@ balance at a given time")) (map (lambda (pair) (string-append - (if (string? (cadr pair)) - (cadr pair) - ((if show-fullname? - gnc:account-get-full-name - gnc:account-get-name) (cadr pair))) - (if show-total? - (string-append - " - " - (gnc:amount->string - (gnc:double-to-gnc-numeric - (car pair) - (gnc:commodity-get-fraction report-currency) - GNC-RND-ROUND) - print-info)) - ""))) + (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 + " - " + (gnc:amount->string + (gnc:double-to-gnc-numeric + (car pair) + (gnc:commodity-get-fraction report-currency) + GNC-RND-ROUND) + print-info)) + ""))) combined))) (gnc:html-piechart-set-labels! chart legend-labels)) diff --git a/src/report/standard-reports/category-barchart.scm b/src/report/standard-reports/category-barchart.scm index bfe56e39ad..343043c205 100644 --- a/src/report/standard-reports/category-barchart.scm +++ b/src/report/standard-reports/category-barchart.scm @@ -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)) - (lambda (a b) - (string (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