Navigation Menu

Skip to content

Commit

Permalink
report: render linechart with requested line colors
Browse files Browse the repository at this point in the history
A report can specify the bar colors of a barchart with a call to:
   (gnc:html-linechart-set-col-colors! chart (list "blue" "red"))
However, these colors were ignored when rendering the linechart.

This patch adds the jqplot option "seriesColors" to pass
the requested bar colors to jqplot. If no colors are requested,
we let jqplot use default colors by setting "seriesColors: false".
  • Loading branch information
jmarino committed Oct 12, 2017
1 parent d6d1549 commit 6e3d478
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions gnucash/report/report-system/html-linechart.scm
Expand Up @@ -388,8 +388,10 @@
(gnc:html-linechart-row-labels linechart)))
(col-labels (catenate-escaped-strings
(gnc:html-linechart-col-labels linechart)))
(col-colors (catenate-escaped-strings
(gnc:html-linechart-col-colors linechart)))
;; convert color list to string with valid js array of strings, example: "\"blue\", \"red\""
(colors-str (string-join (map (lambda (color)
(string-append "\"" color "\""))
(gnc:html-linechart-col-colors linechart)) ", "))
(line-width (gnc:html-linechart-line-width linechart))
(series-data-start (lambda (series-index)
(push "var d")
Expand Down Expand Up @@ -501,7 +503,8 @@
cursor: {
show: true,
zoom: true
}
},
seriesColors: false,
};\n")

(push " options.stackSeries = ")
Expand Down Expand Up @@ -546,6 +549,13 @@
(push " options.axes.yaxis.label = \"")
(push y-label)
(push "\";\n")))
(if (not (equal? colors-str ""))
(begin ; example: options.seriesColors= ["blue", "red"];
(push "options.seriesColors = [")
(push colors-str)
(push "];\n")
)
)

;; adjust the date string format to the one given by the preferences
(push " options.axes.xaxis.tickOptions.formatString = '")
Expand Down

0 comments on commit 6e3d478

Please sign in to comment.