Skip to content

Commit

Permalink
Make margin width based on container width instead of slice width (#4487
Browse files Browse the repository at this point in the history
)

* Make width based on container width instead of slice width

* fix const var name and add comment

* Actually 30 looks good too
  • Loading branch information
jeffreythewang authored and Grace Guo committed Feb 28, 2018
1 parent 764a92c commit 3a58dc7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion superset/assets/visualizations/nvd3_vis.js
Expand Up @@ -18,6 +18,8 @@ import './nvd3_vis.css';
import { VIZ_TYPES } from './main';

const minBarWidth = 15;
// Limit on how large axes margins can grow as the chart window is resized
const maxMarginPad = 30;
const animationTime = 1000;

const BREAKPOINTS = {
Expand Down Expand Up @@ -463,7 +465,9 @@ function nvd3Vis(slice, payload) {

if (chart.yAxis !== undefined || chart.yAxis2 !== undefined) {
// Hack to adjust y axis left margin to accommodate long numbers
const marginPad = isExplore ? width * 0.01 : width * 0.03;
const containerWidth = slice.container.width();
const marginPad = Math.min(isExplore ? containerWidth * 0.01 : containerWidth * 0.03,
maxMarginPad);
const maxYAxisLabelWidth = chart.yAxis2 ? getMaxLabelSize(slice.container, 'nv-y1')
: getMaxLabelSize(slice.container, 'nv-y');
const maxXAxisLabelHeight = getMaxLabelSize(slice.container, 'nv-x');
Expand Down

0 comments on commit 3a58dc7

Please sign in to comment.