From 498c27a6aff896ac02f9784bd776197db9bde604 Mon Sep 17 00:00:00 2001 From: Adrien Dieudonne Date: Wed, 26 Sep 2018 11:46:41 +0200 Subject: [FIX] line chart: show tick labels on x axes Before this commit all x axis labels were not displayed because ticksLabels was empty. Now, we show all labels except the first one and the last one because they are truncate. We need at least two intermediate labels to know the scale and the direction. So, we only remove labels when there is more than 3 data points. --- addons/web/static/src/js/views/graph/graph_renderer.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/graph/graph_renderer.js') diff --git a/addons/web/static/src/js/views/graph/graph_renderer.js b/addons/web/static/src/js/views/graph/graph_renderer.js index b18e508d420..05852722083 100644 --- a/addons/web/static/src/js/views/graph/graph_renderer.js +++ b/addons/web/static/src/js/views/graph/graph_renderer.js @@ -365,7 +365,7 @@ return AbstractRenderer.extend({ } } - if (!tickValues) { + if (!tickValues.length) { tickValues = graphData.map(function (d, i) { return i; }); @@ -415,6 +415,13 @@ return AbstractRenderer.extend({ } } + // Delete first and last label because there is no enough space because + // of the tiny margins. + if (ticksLabels.length > 3) { + ticksLabels[0] = []; + ticksLabels[ticksLabels.length - 1] = []; + } + var $svgContainer = $('
', {class: 'o_graph_svg_container'}); this.$el.append($svgContainer); var svg = d3.select($svgContainer[0]).append('svg'); -- cgit v1.2.3