[FIX] web: first and last line chart x label shown

The graph view displaying a line chart has had some recent changes in
b23a981320. Now it is of the full width of container but when there is
less than 4 labels (thanks to c4937132a3) the first and last labels may
be cut because they are by default aligned on the middle with its tick
(so for the first label, the half left may be missing, and the last the
half right may be missing).

With this change, we align labels as expected. This could be done in CSS
sheet (with `.nv-axisMin-x > text { text-transform: start!important; }`)
but here it is done only in the given instance.

opw-1917560
closes #31116
This commit is contained in:
Nicolas Lempereur
2019-02-14 14:40:13 +00:00
parent 014bab1076
commit e2e0135a75
@@ -451,6 +451,10 @@ return AbstractRenderer.extend({
// of the tiny margins.
if (ticksLabels.length > 3) {
$svgContainer.find('svg .nv-x g.nv-axisMaxMin-x > text').hide();
} else {
// Since the graph is on full container have first and last label in the container
$svgContainer.find('svg .nv-x g.nv-axisMin-x > text').css({'text-anchor': 'start'});
$svgContainer.find('svg .nv-x g.nv-axisMax-x > text').css({'text-anchor': 'end'});
}
return chart;