diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2016-05-17 15:09:23 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2016-05-17 16:38:28 +0200 |
| commit | 68b127797e717ee71b5b0552d69f0f4b4e083f03 (patch) | |
| tree | b34eaf1782c80ba9e0b497401d3e810e1493ea87 /addons/web/static/src/js | |
| parent | cab2dce0d2a05d800027553e2919dfd75dda8b5d (diff) | |
[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
Diffstat (limited to 'addons/web/static/src/js')
| -rw-r--r-- | addons/web/static/src/js/views/graph_widget.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/graph_widget.js b/addons/web/static/src/js/views/graph_widget.js index 048838ad9cd..e458cc483ed 100644 --- a/addons/web/static/src/js/views/graph_widget.js +++ b/addons/web/static/src/js/views/graph_widget.js @@ -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, |
