Skip to content

Commit

Permalink
Set max width for tooltips (apache#5504)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffreythewang authored and Grace Guo committed Jul 30, 2018
1 parent 8fd8d73 commit b77d6e9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions superset/assets/src/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ function hideTooltips() {
$('.nvtooltip').css({ opacity: 0 });
}

function wrapTooltip(chart, container) {
const tooltipLayer = chart.useInteractiveGuideline && chart.useInteractiveGuideline() ?
chart.interactiveLayer : chart;
const tooltipGeneratorFunc = tooltipLayer.tooltip.contentGenerator();
tooltipLayer.tooltip.contentGenerator((d) => {
let tooltip = `<div style="max-width: ${container.width() * 0.5}px">`;
tooltip += tooltipGeneratorFunc(d);
tooltip += '</div>';
return tooltip;
});
}

function getMaxLabelSize(container, axisClass) {
// axis class = .nv-y2 // second y axis on dual line chart
// axis class = .nv-x // x axis on time series line chart
Expand Down Expand Up @@ -844,6 +856,8 @@ export default function nvd3Vis(slice, payload) {
.call(chart);
}
}

wrapTooltip(chart, slice.container);
return chart;
};

Expand Down

0 comments on commit b77d6e9

Please sign in to comment.