Skip to content

Commit

Permalink
Improve padding in NVD3Vis (apache#6626)
Browse files Browse the repository at this point in the history
* WIP, fixing padding

* Remove testing code

(cherry picked from commit f6ac0da)
  • Loading branch information
betodealmeida authored and youngyjd committed Jan 14, 2019
1 parent b33974c commit c1534d5
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions superset/assets/src/visualizations/nvd3/NVD3Vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,14 @@ function nvd3Vis(element, props) {
.attr('width', width)
.call(chart);

if (xLabelRotation > 0) {
// shift labels to the left so they look better
const xTicks = svg.select('.nv-x.nv-axis > g').selectAll('g');
xTicks
.selectAll('text')
.attr('dx', -6.5);
}

// align yAxis1 and yAxis2 ticks
if (isVizTypes(['dual_line', 'line_multi'])) {
const count = chart.yAxis1.ticks();
Expand Down Expand Up @@ -612,11 +620,15 @@ function nvd3Vis(element, props) {
// If x bounds are shown, we need a right margin
margins.right = Math.max(20, maxXAxisLabelHeight / 2) + marginPad;
}
if (xLabelRotation === 45) {
margins.bottom = maxXAxisLabelHeight + marginPad;
margins.right = maxXAxisLabelHeight + marginPad;
} else if (staggerLabels) {
if (staggerLabels) {
margins.bottom = 40;
} else {
margins.bottom = (
maxXAxisLabelHeight * Math.sin(Math.PI * xLabelRotation / 180)
) + marginPad;
margins.right = (
maxXAxisLabelHeight * Math.cos(Math.PI * xLabelRotation / 180)
) + marginPad;
}

if (isVizTypes(['dual_line', 'line_multi'])) {
Expand Down

0 comments on commit c1534d5

Please sign in to comment.