This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new f6ac0da Improve padding in NVD3Vis (#6626)
f6ac0da is described below
commit f6ac0daf7e2a0f46542a5d6d5015de71e1f19ede
Author: Beto Dealmeida <[email protected]>
AuthorDate: Wed Jan 9 15:43:57 2019 -0800
Improve padding in NVD3Vis (#6626)
* WIP, fixing padding
* Remove testing code
---
superset/assets/src/visualizations/nvd3/NVD3Vis.js | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/superset/assets/src/visualizations/nvd3/NVD3Vis.js
b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
index a31c67e..9377604 100644
--- a/superset/assets/src/visualizations/nvd3/NVD3Vis.js
+++ b/superset/assets/src/visualizations/nvd3/NVD3Vis.js
@@ -549,6 +549,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();
@@ -615,11 +623,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'])) {