summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/graph/graph_renderer.js
diff options
context:
space:
mode:
authorAdrien Dieudonne <adr@odoo.com>2018-09-26 11:46:41 +0200
committerAdrien Dieudonne <adr@odoo.com>2018-09-26 15:55:12 +0200
commit498c27a6aff896ac02f9784bd776197db9bde604 (patch)
treedaa6e1a18b60c781d1467809a7008f08d52c8cfa /addons/web/static/src/js/views/graph/graph_renderer.js
parentb4bcf86f8ecfbf43c1a703f044af98c6beb471f0 (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/graph_renderer.js')
-rw-r--r--addons/web/static/src/js/views/graph/graph_renderer.js9
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');