Settings and activity
2 results found
-
6 votes
See https://github.com/highslide-software/highcharts.com/issues/3499. We have implemented this so that the layout option of the legend decides what side of the chart it should be displayed at.
An error occurred while saving the comment David Coblentz supported this idea · -
232 votesDavid Coblentz supported this idea ·
I'm having the same problem as well. I think it can be fixed with something like this:
horizontal = legendOptions.layout === 'horizontal';
// Adjust for legend
if (legend.display && !legendOptions.floating) {
if (align === 'right' && !horizontal) { // horizontal alignment handled first
if (!defined(margin[1])) {
chart.marginRight = mathMax(
chart.marginRight,
legend.legendWidth - legendX + legendMargin + spacing[1]
);
}
} else if (align === 'left' && !horizontal) {
if (!defined(margin[3])) {
chart.plotLeft = mathMax(
chart.plotLeft,
legend.legendWidth + legendX + legendMargin + spacing[3]
);
}
} else if (verticalAlign === 'top' && (horizontal || align === 'center')) {
if (!defined(margin[0])) {
chart.plotTop = mathMax(
chart.plotTop,
legend.legendHeight + legendY + legendMargin + spacing[0]
);
}
} else if (verticalAlign === 'bottom' && (horizontal || align === 'center')) {
if (!defined(margin[2])) {
chart.marginBottom = mathMax(
chart.marginBottom,
legend.legendHeight - legendY + legendMargin + spacing[2]
);
}
}
}
This shouldn't change the behavior for cases where the legend layout it vertical. For horizontal layouts, it allows verticalAlign of top and bottom with the align set to left, right, or center. If the layout is horizontal, and verticalAlign is middle, the legend will render on top of the chart, similar to the way that it would now for a horizontal layout, with a verticalAlign of middle and align of center.
http://codepen.io/anon/pen/fKsFJ