diff options
| author | Adrien Dieudonne <adr@odoo.com> | 2018-09-26 11:46:41 +0200 |
|---|---|---|
| committer | Adrien Dieudonne <adr@odoo.com> | 2018-09-26 15:55:12 +0200 |
| commit | 498c27a6aff896ac02f9784bd776197db9bde604 (patch) | |
| tree | daa6e1a18b60c781d1467809a7008f08d52c8cfa /addons/web/static/src/js/views/graph | |
| parent | b4bcf86f8ecfbf43c1a703f044af98c6beb471f0 (diff) | |
[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.
Diffstat (limited to 'addons/web/static/src/js/views/graph')
| -rw-r--r-- | addons/web/static/src/js/views/graph/graph_renderer.js | 9 |
1 files changed, 8 insertions, 1 deletions
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 = $('<div/>', {class: 'o_graph_svg_container'}); this.$el.append($svgContainer); var svg = d3.select($svgContainer[0]).append('svg'); |
