Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plotly legend overlaps plot on small screens #3882

Merged
merged 1 commit into from
Jun 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions client/app/visualizations/chart/plotly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,14 +747,6 @@ export function updateLayout(plotlyElement, layout, updatePlot) {
layout.width = Math.floor(plotlyElement.offsetWidth);
layout.height = Math.floor(plotlyElement.offsetHeight);

const transformName = find([
'transform',
'webkitTransform',
'mozTransform',
'msTransform',
'oTransform',
], prop => has(plotlyElement.style, prop));

if (layout.width <= 600) {
// change legend orientation to horizontal; plotly has a bug with this
// legend alignment - it does not preserve enough space under the plot;
Expand Down Expand Up @@ -802,9 +794,9 @@ export function updateLayout(plotlyElement, layout, updatePlot) {
layout.height / 2,
layout.height - (bounds.bottom - bounds.top),
));
// offset the legend
legend.style[transformName] = 'translate(0, ' + layout.height + 'px)';
updatePlot(plotlyElement, pick(layout, ['height']));
// offset the legend
legend.setAttribute('transform', 'translate(0, ' + layout.height + ')');
}
});
} else {
Expand All @@ -817,12 +809,6 @@ export function updateLayout(plotlyElement, layout, updatePlot) {
xanchor: 'left',
yanchor: 'top',
};

const legend = plotlyElement.querySelector('.legend');
if (legend) {
legend.style[transformName] = null;
}

updatePlot(plotlyElement, pick(layout, ['width', 'height', 'legend']));
}
}