Skip to content

Commit

Permalink
[html-chart] html-chart-set! don't convert list to vector
Browse files Browse the repository at this point in the history
  • Loading branch information
christopherlam committed Sep 3, 2024
1 parent 4f0862b commit 0d6303e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
10 changes: 5 additions & 5 deletions gnucash/report/html-chart.scm
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
(use-modules (gnucash core-utils))
(use-modules (gnucash json builder)) ;for building JSON options
(use-modules (gnucash report html-utilities))
(use-modules (gnucash report report-utilities))
(use-modules (srfi srfi-9))
(use-modules (ice-9 match))

Expand Down Expand Up @@ -274,10 +275,10 @@
(gnc:html-chart-get chart '(options title text)))

(define (gnc:html-chart-set-title! chart title)
(gnc:html-chart-set! chart '(options title text) title))
(gnc:html-chart-set! chart '(options title text) (list-to-vec title)))

(define (gnc:html-chart-set-data-labels! chart labels)
(gnc:html-chart-set! chart '(data labels) labels))
(gnc:html-chart-set! chart '(data labels) (list-to-vec labels)))

(define (gnc:html-chart-set-axes-display! chart display?)
(gnc:html-chart-set! chart '(options scales xAxes (0) display) display?)
Expand Down Expand Up @@ -337,9 +338,8 @@
(nested-alist-get options path)))

(define (gnc:html-chart-set! chart path val)
(let ((options (gnc:html-chart-get-options-internal chart))
(val-vec (list-to-vec val)))
(nested-alist-set! options path val-vec)
(let ((options (gnc:html-chart-get-options-internal chart)))
(nested-alist-set! options path val)
(gnc:html-chart-set-options-internal! chart options)))

(define JS-Number-to-String "
Expand Down
15 changes: 14 additions & 1 deletion gnucash/report/test/test-html-chart.scm
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

(define (test-html-chart)

(let ((chart (gnc:make-html-chart)))
(let ((chart (gnc:make-html-chart))
(a-list-of-pairs '((unit . day)
(displayFormats (day . "DD-MM-YYYY"))
(tooltipFormat . "DD-MM-YYYY"))))

(gnc:html-chart-add-data-series! chart "label" '(2 3 4) "red")

Expand Down Expand Up @@ -57,6 +60,16 @@
'abc
(gnc:html-chart-get chart '(options maintainAspectRatio)))

(test-equal "path doesn't exist"
#f
(gnc:html-chart-get chart '(options scales xAxes (0) time)))

(gnc:html-chart-set! chart '(options scales xAxes (0) time) a-list-of-pairs)

(test-equal "path exists and the list-of-pairs is intact"
a-list-of-pairs
(gnc:html-chart-get chart '(options scales xAxes (0) time)))

(gnc:html-chart-set! chart '(options legend position) 'de)
(test-equal "1st level option setter & getter"
'de
Expand Down

0 comments on commit 0d6303e

Please sign in to comment.