From 6e3d47819d6f2cefed18b70656320fc50c790962 Mon Sep 17 00:00:00 2001 From: Jose Marino Date: Thu, 12 Oct 2017 15:39:19 -0600 Subject: [PATCH] report: render linechart with requested line colors 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". --- gnucash/report/report-system/html-linechart.scm | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gnucash/report/report-system/html-linechart.scm b/gnucash/report/report-system/html-linechart.scm index ced16fcbce5..927836fae1a 100644 --- a/gnucash/report/report-system/html-linechart.scm +++ b/gnucash/report/report-system/html-linechart.scm @@ -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") @@ -501,7 +503,8 @@ cursor: { show: true, zoom: true - } + }, + seriesColors: false, };\n") (push " options.stackSeries = ") @@ -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 = '")