[FIX] web: left margin of graph

The left margin of the graph doesn't take into account the width of the
maximum Y-axis value. In case the values are high (> 10^7), they are
cropped.

The fix is to adapt the left margin as a function of the size of the
maximum value.

opw-676538
This commit is contained in:
Nicolas Martinelli
2016-05-17 16:38:28 +02:00
parent cab2dce0d2
commit 68b127797e
@@ -162,7 +162,9 @@ return Widget.extend({
svg.transition().duration(0);
var chart = nv.models.multiBarChart();
var maxVal = _.max(values, function(v) {return v.y})
chart.options({
margin: {left: 12 * String(maxVal && maxVal.y || 0).length},
delay: 250,
transition: 10,
showLegend: _.size(data) <= MAX_LEGEND_LENGTH,
@@ -292,8 +294,9 @@ return Widget.extend({
svg.transition().duration(0);
var chart = nv.models.lineChart();
var maxVal = _.max(values, function(v) {return v.y})
chart.options({
margin: {left: 50, right: 50},
margin: {left: 12 * String(maxVal && maxVal.y || 0).length, right: 50},
useInteractiveGuideline: true,
showLegend: _.size(data) <= MAX_LEGEND_LENGTH,
showXAxis: true,