gnucash master: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Thu Jun 13 07:21:27 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/a552d0d4 (commit)
via https://github.com/Gnucash/gnucash/commit/ddceb547 (commit)
via https://github.com/Gnucash/gnucash/commit/e1228c76 (commit)
via https://github.com/Gnucash/gnucash/commit/0cdb770f (commit)
from https://github.com/Gnucash/gnucash/commit/30ac2cf2 (commit)
commit a552d0d4857f7d612898d57c47ac113ffcca80ad
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Jun 8 23:42:54 2019 +0800
[test-graphing] upgraded
diff --git a/gnucash/report/reports/example/test-graphing.scm b/gnucash/report/reports/example/test-graphing.scm
index e6c3fa439..41463f1c2 100644
--- a/gnucash/report/reports/example/test-graphing.scm
+++ b/gnucash/report/reports/example/test-graphing.scm
@@ -27,58 +27,86 @@
(use-modules (gnucash utilities))
(use-modules (gnucash gnc-module))
-(debug-enable 'backtrace)
-
(gnc:module-load "gnucash/report/report-system" 0)
(gnc:module-load "gnucash/gnome-utils" 0) ;for gnc-build-url
(define (simple-pie-chart)
- (let ((chart (gnc:make-html-piechart)))
- (gnc:html-piechart-set-title! chart "Pie Chart Title")
- (gnc:html-piechart-set-subtitle! chart "Pie Chart SubTitle")
- (gnc:html-piechart-set-width! chart 320)
- (gnc:html-piechart-set-height! chart 240)
- (gnc:html-piechart-set-data! chart '(25 45 30))
- (gnc:html-piechart-set-labels! chart '("foo" "bar" "baz"))
- (gnc:html-piechart-set-colors! chart (gnc:assign-colors 3))
- chart
- )
-)
+ (let ((chart (gnc:make-html-chart)))
+ ;; the minimum chartjs-based html-chart requires the following settings
+ (gnc:html-chart-set-type! chart 'pie)
+
+ ;; title is either a string, or a list of strings
+ (gnc:html-chart-set-title! chart "Pie Chart Title")
+ (gnc:html-chart-set-width! chart '(pixels . 480))
+ (gnc:html-chart-set-height! chart '(pixels . 360))
+
+ ;; data-labels and data-series should be the same length
+ (gnc:html-chart-set-data-labels! chart '("alpha" "beta" "delta"))
+ (gnc:html-chart-add-data-series! chart
+ "series-1" ;series name
+ '(25 45 30) ;pie ratios
+ (gnc:assign-colors 3)) ;colours
+
+ ;; piechart doesn't need axes display:
+ (gnc:html-chart-set-axes-display! chart #f)
+ chart))
(define (simple-bar-chart stacked?)
- (let ((chart (gnc:make-html-barchart))
- (text (gnc:make-html-text (gnc:html-markup-p "[bar goes here]"))))
- (gnc:html-barchart-set-title! chart "Bar Chart Title")
- (gnc:html-barchart-set-subtitle! chart (gnc:html-string-sanitize "Bar Chart SubTitle"))
- (gnc:html-barchart-append-row! chart '(25 45 30))
- (gnc:html-barchart-append-row! chart '(75 55 70))
- (gnc:html-barchart-set-width! chart 320)
- (gnc:html-barchart-set-height! chart 240)
- (gnc:html-barchart-set-row-labels! chart '("date1" "date2"))
- (gnc:html-barchart-set-col-labels! chart '("dataset1" "dataset2" "dataset3"))
- (gnc:html-barchart-set-col-colors! chart (gnc:assign-colors 3))
- (gnc:html-barchart-set-stacked?! chart stacked?)
- (gnc:html-barchart-set-y-axis-label! chart "A Y Axis")
+ (let ((chart (gnc:make-html-chart))
+ (colours (gnc:assign-colors 3)))
+ (gnc:html-chart-set-title!
+ chart (list "Bar Chart Title"
+ (gnc:html-string-sanitize "Bar Chart SubTitle")))
+ (gnc:html-chart-set-type! chart 'bar)
+ (gnc:html-chart-set-width! chart '(pixels . 480))
+ (gnc:html-chart-set-height! chart '(pixels . 360))
+ (gnc:html-chart-set-data-labels! chart '("water" "fire"))
+ (gnc:html-chart-add-data-series! chart
+ "dataset1"
+ '(25 75)
+ (car colours))
+ (gnc:html-chart-add-data-series! chart
+ "dataset2"
+ '(45 55)
+ (cadr colours))
+ (gnc:html-chart-add-data-series! chart
+ "dataset3"
+ '(30 70)
+ (caddr colours))
+
+ (gnc:html-chart-set-stacking?! chart stacked?)
+ (gnc:html-chart-set-y-axis-label! chart "Y Axis")
chart))
(define (simple-scatter-chart)
- (let ((chart (gnc:make-html-scatter))
- (text (gnc:make-html-text (gnc:html-markup-p "[scatter goes here]"))))
- (gnc:html-scatter-set-title! chart "Scatter Title")
- (gnc:html-scatter-set-subtitle! chart "Scatter SubTitle")
- (gnc:html-scatter-add-datapoint! chart '(25 75))
- (gnc:html-scatter-add-datapoint! chart '(45 55))
- (gnc:html-scatter-add-datapoint! chart '(70 30))
- (gnc:html-scatter-set-width! chart 320)
- (gnc:html-scatter-set-height! chart 240)
- (gnc:html-scatter-set-markercolor! chart (car (gnc:assign-colors 1)))
+ (let ((chart (gnc:make-html-chart)))
+ (gnc:html-chart-set-type! chart 'line)
+ (gnc:html-chart-set-title! chart "Scatter Title")
+
+ (gnc:html-chart-set-data-labels! chart '("a" "b" "c" "d" "e"))
+ (gnc:html-chart-set-width! chart '(pixels . 480))
+ (gnc:html-chart-set-height! chart '(pixels . 360))
+
+ ;; scatter plots require x/y coordinates for data points
+ (gnc:html-chart-add-data-series! chart
+ "xy-plot"
+ '(((x . 25) (y . 75))
+ ((x . 45) (y . 55))
+ ((x . 32) (y . 30)))
+ (gnc:assign-colors 3)
+ 'borderWidth 1
+ 'fill #f)
+
+ ;; The following sets xaxis to linear rather than category and
+ ;; also illustrates how to precisely select chartjs options. The
+ ;; second parameter is a list of symbols to target a particular
+ ;; chartJS option. See chartJS documentation.
+ (gnc:html-chart-set! chart '(options scales xAxes (0) type) "linear")
+
chart))
(define (options-generator)
- (let* ((options (gnc:new-options)))
- (gnc:options-set-default-section options "Test Graphing")
- options)
- )
+ (gnc:new-options))
;; This is the rendering function. It accepts a database of options
;; and generates an object of type <html-document>. See the file
@@ -88,9 +116,9 @@
;; defined above.
(define (test-graphing-renderer report-obj)
;; These are some helper functions for looking up option values.
+ (define options (gnc:report-options report-obj))
(define (get-op section name)
- (gnc:lookup-option (gnc:report-options report-obj) section name))
-
+ (gnc:lookup-option options section name))
(define (op-value section name)
(gnc:option-value (get-op section name)))
@@ -124,22 +152,20 @@
document
(gnc:make-html-text (gnc:html-markup-p "Scatter:")))
(gnc:html-document-add-object! document (simple-scatter-chart))
-
- (gnc:html-document-add-object!
- document
- (gnc:make-html-text
+
+ (gnc:html-document-add-object!
+ document
+ (gnc:make-html-text
(gnc:html-markup-p "Done.")))
-
- document
- )
- )
+
+ document))
;; Here we define the actual report with gnc:define-report
(gnc:define-report
-
+
;; The version of this report.
'version 1
-
+
;; The name of this report. This will be used, among other things,
;; for making its menu item in the main menu. You need to use the
;; untranslated value here!
@@ -154,11 +180,11 @@
;; The name in the menu
;; (only necessary if it differs from the name)
- 'menu-name "Sample graphs."
+ 'menu-name "Sample graphs"
;; A tip that is used to provide additional information about the
;; report to the user.
- 'menu-tip "Sample graphs."
+ 'menu-tip "Sample graphs"
;; A path describing where to put the report in the menu system.
;; In this case, it's going under the utility menu.
@@ -166,7 +192,6 @@
;; The options generator function defined above.
'options-generator options-generator
- ;; 'options-generator gnc:new-options
-
+
;; The rendering function defined above.
'renderer test-graphing-renderer)
commit ddceb54736e1ee7d059d60a15da3dff83eb25942
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Jun 9 17:23:55 2019 +0800
[html-chart] ensure yAxis starts at $0.00
Ensuring $0 is included in chart is better.
If beginAtZero is #t, the yAxis will span $0 -> maximum. If
beginAtZero is #f, the chart yAxis will span minimum -> maximum
y-values, which led to bars with minimum amounts being effectively
hidden from view because its height corresponded with the minimum
amount.
diff --git a/gnucash/report/report-system/html-chart.scm b/gnucash/report/report-system/html-chart.scm
index f94e73690..55cfe6229 100644
--- a/gnucash/report/report-system/html-chart.scm
+++ b/gnucash/report/report-system/html-chart.scm
@@ -212,7 +212,7 @@
(cons 'labelString "")))
(cons 'ticks (list
(cons 'fontSize 10)
- (cons 'beginAtZero #f))))
+ (cons 'beginAtZero #t))))
;; the following another yAxis on the right
'((position . right)
(ticks . ((display . #f)))
commit e1228c76a5c301a89a9d80e918c18fa630c9d23f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Thu Jun 13 18:20:26 2019 +0800
[report] refactor gnc:define-report clearer logic
diff --git a/gnucash/report/report-system/report.scm b/gnucash/report/report-system/report.scm
index 41ed9ab7e..a4cab282c 100644
--- a/gnucash/report/report-system/report.scm
+++ b/gnucash/report/report-system/report.scm
@@ -131,14 +131,17 @@ not found.")))
(report-name (gnc:report-template-name report-rec)))
(cond
- (report-guid
- ;; ideal path: report is defined, and has guid
- (if (hash-ref *gnc:_report-templates_* report-guid)
- (gui-error (string-append rpterr-dupe report-guid))
- (hash-set! *gnc:_report-templates_* report-guid report-rec)))
+ ;; missing report-guid: is an error
+ ((not report-guid)
+ (gui-error (string-append rpterr-guid1 report-name rpterr-guid2)))
+
+ ;; dupe: report-guid is a duplicate
+ ((hash-ref *gnc:_report-templates_* report-guid)
+ (gui-error (string-append rpterr-dupe report-guid)))
+
+ ;; good: new report definition, store into report-templates hash
(else
- ;;reports without guid are no longer supported
- (gui-error (string-append rpterr-guid1 report-name rpterr-guid2))))))
+ (hash-set! *gnc:_report-templates_* report-guid report-rec)))))
(define gnc:report-template-version
(record-accessor <report-template> 'version))
commit 0cdb770f5ed0799d7c3d3c6f656e1c24141176c7
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Wed Jun 12 22:22:53 2019 +0800
[taxtxf] fix copy-n-paste error
101f84025551 had copy&paste error, fix function names
diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index 0a9ce8cdc..d34d7afae 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -316,12 +316,12 @@
(case info-type
((form) gnc:txf-get-form)
((desc) gnc:txf-get-description)
- ((pns) gnc:txf-get-payer-name-sourcecategories)
- ((format) gnc:txf-get-formatcategories)
- ((multiple) gnc:txf-get-multiplecategories)
- ((cat-key) gnc:txf-get-category-keycategories)
- ((line) gnc:txf-get-line-datacategories)
- ((last-yr) gnc:txf-get-last-yearcategories)
+ ((pns) gnc:txf-get-payer-name-source)
+ ((format) gnc:txf-get-format)
+ ((multiple) gnc:txf-get-multiple)
+ ((cat-key) gnc:txf-get-category-key)
+ ((line) gnc:txf-get-line-data)
+ ((last-yr) gnc:txf-get-last-year)
(else #f))))
(and categories
get-info-fn
Summary of changes:
gnucash/report/locale-specific/us/taxtxf.scm | 12 +-
gnucash/report/report-system/html-chart.scm | 2 +-
gnucash/report/report-system/report.scm | 17 +--
gnucash/report/reports/example/test-graphing.scm | 137 ++++++++++++++---------
4 files changed, 98 insertions(+), 70 deletions(-)
More information about the gnucash-changes
mailing list