diff --git a/ChangeLog b/ChangeLog index aefa4cfb7a..2435b56715 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2001-04-04 Christian Stimming + + * src/gnome/gnc-html-guppi.c, src/scm/html-barchart.scm: Added new + option for barchart: legend-reversed. + 2001-04-04 Robert Graham Merkel * src/scm/report/balance-sheet.scm: calculate retained profits diff --git a/src/gnome/gnc-html-guppi.c b/src/gnome/gnc-html-guppi.c index c461479cf2..7295f4056c 100644 --- a/src/gnome/gnc-html-guppi.c +++ b/src/gnome/gnc-html-guppi.c @@ -513,6 +513,7 @@ gnc_html_embedded_barchart(gnc_html * parent, char * param; int datarows=0; int datacols=0; + int legend_reversed=0; int rotate=0; int stacked=0; int normalize_stacks=0; @@ -590,6 +591,13 @@ gnc_html_embedded_barchart(gnc_html * parent, GTK_VALUE_BOOL(arglist[argind]) = rotate; argind++; } + if((param = g_hash_table_lookup(params, "legend_reversed")) != NULL) { + sscanf(param, "%d", &rotate); + arglist[argind].name = "legend_reversed"; + arglist[argind].type = GTK_TYPE_BOOL; + GTK_VALUE_BOOL(arglist[argind]) = rotate; + argind++; + } if((param = g_hash_table_lookup(params, "stacked")) != NULL) { sscanf(param, "%d", &stacked); arglist[argind].name = "stacked"; diff --git a/src/scm/html-barchart.scm b/src/scm/html-barchart.scm index 75df6e5cb4..d6b4c1393c 100644 --- a/src/scm/html-barchart.scm +++ b/src/scm/html-barchart.scm @@ -34,6 +34,7 @@ col-labels row-labels col-colors + legend-reversed? row-labels-rotated? stacked? data @@ -55,7 +56,7 @@ (define (gnc:make-html-barchart) (gnc:make-html-barchart-internal -1 -1 #f #f #f #f '() '() '() - #f #f '() #f #f #f #f #f #f)) + #f #f #f '() #f #f #f #f #f #f)) (define gnc:html-barchart-data (record-accessor 'data)) @@ -117,6 +118,12 @@ (define gnc:html-barchart-set-col-colors! (record-modifier 'col-colors)) +(define gnc:html-barchart-legend-reversed? + (record-accessor 'legend-reversed?)) + +(define gnc:html-barchart-set-legend-reversed?! + (record-modifier 'legend-reversed?)) + (define gnc:html-barchart-title (record-accessor 'title)) @@ -396,13 +403,18 @@ (push " \n"))) - (let ((rot? (gnc:html-barchart-row-labels-rotated? barchart))) - (push " \n") - (push "0\">\n"))) - (if (gnc:html-barchart-stacked? barchart) - (push " \n")) + (push " \n" + "0\">\n")) + (push " \n" + "0\">\n")) + (push " \n" + "0\">\n")) (push "Unable to push bar chart\n") (push "  \n")) " ") diff --git a/src/scm/html-utilities.scm b/src/scm/html-utilities.scm index 0d3c950bfe..7eedd461a3 100644 --- a/src/scm/html-utilities.scm +++ b/src/scm/html-utilities.scm @@ -89,10 +89,23 @@ ;; Builds and returns a tree-(hierarchy-)shaped table as a html-table ;; object. ;; +;; Arguments by topic: +;; +;; Reporting period -- start-date, end-date +;; +;; Selected accounts -- tree-depth, show-subaccts?, accounts, +;; do-subtot? +;; +;; Foreign currency -- show-other-curr?, report-commodity, +;; exchange-fn +;; +;; Output fine-tuning -- show-col-headers?, show-total? (with +;; total-name, get-total-fn), group-types? +;; ;; Note: The returned table object will have 2*tree-depth columns if ;; show-other-curr?==#f, else it will have 3*tree-depth columns. ;; -;; Arguments: +;; Arguments in detail: ;; ;; start-date: Start date of reporting period. If #f, ;; everything till end-date will be considered. @@ -106,7 +119,10 @@ ;; are totally independent from the calculated balance and vice ;; versa. ;; -;; show-total? If #f, no total sum is shown. +;; show-col-headers?: show column headings "Account" and +;; "Balance" +;; +;; show-total?: If #f, no total sum is shown. ;; ;; # get-total-fn: The function to calculate the total ;; sum, e.g. gnc:accounts-get-comm-total-{profit,assets}. @@ -119,8 +135,6 @@ ;; do-subtot?: Specify whether to include sub-account balances ;; in each account's balance. ;; -;; col-headers? : show column headings "Account" and "Balance" -;; ;; show-other-curr?, report-commodity, ;; # exchange-fn: The rightmost column always shows ;; balances in the currency report-commodity. If those balances happen @@ -443,15 +457,15 @@ ;; set some column headers (if show-col-headers? - (gnc:html-table-set-col-headers! + (gnc:html-table-set-col-headers! table - (list (gnc:make-html-table-header-cell/size - 1 tree-depth (_ "Account name")) - (gnc:make-html-table-header-cell/size - 1 (if show-other-curr? - (* 2 tree-depth) - tree-depth) - (_ "Balance"))))) + (list (gnc:make-html-table-header-cell/size + 1 tree-depth (_ "Account name")) + (gnc:make-html-table-header-cell/size + 1 (if show-other-curr? + (* 2 tree-depth) + tree-depth) + (_ "Balance"))))) ;; there are tree-depth account name columns. (let loop ((col 0)) diff --git a/src/scm/report/category-barchart.scm b/src/scm/report/category-barchart.scm index 03ef1eb610..f63d9946fd 100644 --- a/src/scm/report/category-barchart.scm +++ b/src/scm/report/category-barchart.scm @@ -27,11 +27,11 @@ (gnc:depend "date-utilities.scm") ;; The option names are defined here to a) save typing and b) avoid -;; spelling errors. The reportnames are defined here (and not only +;; spelling errors. The *reportnames* are defined here (and not only ;; once at the very end) because I need them to define the "other" ;; report, thus needing them twice. -(let ((reportname-income (N_ "Income Category Barchart")) - (reportname-expense (N_ "Expense Category Barchart")) +(let ((reportname-income (N_ "Income Barchart")) + (reportname-expense (N_ "Expense Barchart")) (pagename-general (N_ "General")) (optname-from-date (N_ "From")) @@ -295,6 +295,8 @@ chart (gnc:commodity-get-mnemonic report-currency)) (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?) ;; If we have too many categories, we sum them into a new ;; 'other' category and add a link to a new report with just