Skip to content

Commit

Permalink
fix(legacy-plugin-chart-histogram): fixes legend overflow (apache#863)
Browse files Browse the repository at this point in the history
* fix(legacy-plugin-chart-histogram): fixes legend onverflow

* Update plugins/legacy-plugin-chart-histogram/src/WithLegend.jsx

Co-authored-by: Ville Brofeldt <[email protected]>

Co-authored-by: Ville Brofeldt <[email protected]>
  • Loading branch information
2 people authored and zhaoyongjie committed Nov 17, 2021
1 parent afe0942 commit 535dcd1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class CustomHistogram extends React.PureComponent {
width={width}
height={height}
position="top"
renderLegend={({ direction }) => (
renderLegend={({ direction, style }) => (
<LegendOrdinal
style={style}
scale={colorScale}
direction={direction}
shape="rect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ class WithLegend extends React.Component {
flexDirection: legendDirection,
justifyContent: this.getLegendJustifyContent(),
};

const legendContainerStyle = {
flexWrap: 'wrap',
display: 'flex',
flexDirection: legendDirection,
};
return (
<div className={`with-legend ${className}`} style={style}>
<div className="legend-container" style={legendStyle}>
{renderLegend({
// Pass flexDirection for @vx/legend to arrange legend items
direction: legendDirection,
style: legendContainerStyle,
})}
</div>
<div className="main-container" style={chartStyle}>
Expand Down

0 comments on commit 535dcd1

Please sign in to comment.