Bug 720934 - Barcharts with many data points have overlapping x-axis labels

Use jqplot.cursor.js (enanbles zooming) and jqplot.dateAxisRenderer.js instead of jqplot.categoryAxisRenderer.js
This commit is contained in:
Carsten Rinke 2014-06-01 13:44:51 +02:00 committed by Geert Janssens
parent 549ede1168
commit 88bfbb19a0

View File

@ -359,12 +359,12 @@
(push "var d") (push "var d")
(push series-index) (push series-index)
(push " = [];\n"))) (push " = [];\n")))
(series-data-add (lambda (series-index x y) (series-data-add (lambda (series-index date y)
(push (string-append (push (string-append
" d" " d"
(number->string series-index) (number->string series-index)
".push([" ".push(["
(number->string x) "\"" date "\""
", " ", "
(number->string y) (number->string y)
"]);\n")))) "]);\n"))))
@ -385,10 +385,12 @@
(push (gnc:html-js-include "jqplot/jquery.min.js")) (push (gnc:html-js-include "jqplot/jquery.min.js"))
(push (gnc:html-js-include "jqplot/jquery.jqplot.js")) (push (gnc:html-js-include "jqplot/jquery.jqplot.js"))
(push (gnc:html-js-include "jqplot/jqplot.barRenderer.js")) (push (gnc:html-js-include "jqplot/jqplot.barRenderer.js"))
(push (gnc:html-js-include "jqplot/jqplot.categoryAxisRenderer.js")) (push (gnc:html-js-include "jqplot/jqplot.cursor.js"))
(push (gnc:html-js-include "jqplot/jqplot.dateAxisRenderer.js"))
(push (gnc:html-js-include "jqplot/jqplot.highlighter.js")) (push (gnc:html-js-include "jqplot/jqplot.highlighter.js"))
(push (gnc:html-js-include "jqplot/jqplot.canvasTextRenderer.js")) (push (gnc:html-js-include "jqplot/jqplot.canvasTextRenderer.js"))
(push (gnc:html-js-include "jqplot/jqplot.canvasAxisTickRenderer.js")) (push (gnc:html-js-include "jqplot/jqplot.canvasAxisTickRenderer.js"))
(push (gnc:html-css-include "jqplot/jquery.jqplot.css")) (push (gnc:html-css-include "jqplot/jquery.jqplot.css"))
(push "<div id=\"")(push chart-id)(push "\" style=\"width:") (push "<div id=\"")(push chart-id)(push "\" style=\"width:")
@ -404,15 +406,17 @@
(if (and data (list? data)) (if (and data (list? data))
(let ((rows (length data)) (let ((rows (length data))
(cols 0)) (cols 0))
(let loop ((col 0) (rowcnt 1)) (let loop ((col 0) (rowcnt 0))
(series-data-start col) (series-data-start col)
(if (list? (car data)) (if (list? (car data))
(begin (begin
(set! cols (length (car data))))) (set! cols (length (car data)))))
(for-each (for-each
(lambda (row) (lambda (row)
(series-data-add col rowcnt (if (< rowcnt rows)
(series-data-add col (list-ref (gnc:html-barchart-row-labels barchart) rowcnt)
(ensure-numeric (list-ref-safe row col))) (ensure-numeric (list-ref-safe row col)))
)
(set! rowcnt (+ rowcnt 1))) (set! rowcnt (+ rowcnt 1)))
data) data)
(series-data-end col (list-ref-safe (gnc:html-barchart-col-labels barchart) col)) (series-data-end col (list-ref-safe (gnc:html-barchart-col-labels barchart) col))
@ -441,7 +445,7 @@
}, },
axes: { axes: {
xaxis: { xaxis: {
renderer: $.jqplot.CategoryAxisRenderer, renderer:$.jqplot.DateAxisRenderer,
tickRenderer: $.jqplot.CanvasAxisTickRenderer, tickRenderer: $.jqplot.CanvasAxisTickRenderer,
tickOptions: { tickOptions: {
angle: -30, angle: -30,
@ -452,8 +456,9 @@
autoscale: true, autoscale: true,
}, },
}, },
highlighter: { cursor:{
tooltipContentEditor: formatTooltip, show: true,
zoom: true
} }
};\n") };\n")
@ -484,15 +489,6 @@
(push " options.axes.yaxis.label = \"") (push " options.axes.yaxis.label = \"")
(push y-label) (push y-label)
(push "\";\n"))) (push "\";\n")))
(if (and (string? row-labels) (> (string-length row-labels) 0))
(begin
(push " options.axes.xaxis.ticks = [")
(for-each (lambda (val)
(push "\"")
(push val)
(push "\","))
(gnc:html-barchart-row-labels barchart))
(push "];\n")))
(push "$.jqplot.config.enablePlugins = true;") (push "$.jqplot.config.enablePlugins = true;")