[FIX] web: several columns in line chart tooltips for large data

Currently tooltip goes out off the screen when the
graph view (in line mode) presents a large number
of groups.
The present commit splits the tooltip content in
three columns when the number of groups exceeds
20. This split is not done in mobile mode because
it is not an appropriate in that situation.

Co-authored-by: Mohammed Shekha <msh@openerp.com>

Related to Task: 1917958

closes odoo/odoo#30288
This commit is contained in:
Hiral Bhavsar
2019-02-21 13:03:22 +00:00
committed by Mathieu Duckerts-Antoine
co-authored by Mohammed Shekha
parent 4b652ebe8a
commit bb6aec1ac3
2 changed files with 27 additions and 1 deletions
@@ -21,6 +21,7 @@ var CHART_TYPES = ['pie', 'bar', 'line'];
// hide top legend when too many items for device size
var MAX_LEGEND_LENGTH = 25 * (Math.max(1, config.device.size_class));
var SPLIT_THRESHOLD = config.device.isMobile ? Infinity : 20;
return AbstractRenderer.extend({
className: "o_graph_container",
@@ -412,7 +413,11 @@ return AbstractRenderer.extend({
}
}
var $svgContainer = $('<div/>', {class: 'o_graph_svg_container'});
var $svgContainer = $('<div/>', { class: 'o_graph_svg_container'});
// Split the tooltip into columns for large data because some portion goes out off the screen.
if (data.length >= SPLIT_THRESHOLD) {
$svgContainer.addClass('o_tooltip_split_in_columns');
}
this.$el.append($svgContainer);
var svg = d3.select($svgContainer[0]).append('svg');
svg.datum(data);
@@ -33,6 +33,27 @@
}
}
}
/* Use less than 50% of the screen area for tooltip and show legends in 3 column of 33% each */
&.o_tooltip_split_in_columns .nvtooltip {
max-width: 48%;
tbody {
display: flex;
flex-flow: wrap;
tr {
width: 33%;
td {
display: inline-block;
&.key {
min-width: 160px;
max-width: 70%;
overflow-x: hidden;
text-overflow: ellipsis;
}
}
}
}
}
}
}
}