xAxis overlapping with chart legend
See original GitHub issueThe issue is very difficult to reproduce in jsfiddle, so instead I will post some snippets and screenshot.
The chart legend is overlapping with the xAxis labels:
And on hovering over the chart, the chart height re-adjusts and corrects itself. I am using Recharts version 1.8.5
Below is the structure of my chart:
<div style={{ width: '100%', height: customHeight }}>
{
config.title
&& (
<Title title={config.title} />
)
}
{
allowZoom
&& (
<ZoomButtons
props={props}
/>
)
}
<ResponsiveContainer>
<LineChart
data={dataToPlot()}
margin={{
right: 25,
left: showYLabel ? 0 : leftMargin,
top: CHART_MARGIN_TOP,
bottom: 10,
}}
onMouseDown={(e) => {
// some logic
}}
onMouseUp={() => {
// some logic
}}
onMouseEnter={() => {
// some logic
}}
onMouseMove={(e) => {
// some logic
}}
onMouseLeave={() => {
// some logic
}}
>
<XAxis
{...commonXAxisConfigs}
/>
<YAxis
{...commonYAxisConfigs}
/>
{renderTooltip()}
{
!config.hideLegends
? (
<Legend
wrapperStyle={{
paddingTop: 20,
}}
content={(
<CustomLegend
props={props}
/>
)}
/>
)
: null
}
{renderLines()}
</LineChart>
</ResponsiveContainer>
</div>
Any idea what could be going wrong? Again sorry for not being able to post a jsfiddle link as it’s only happening while fetching the data from server. Difficult to reproduce with hardcoded data.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Highcharts Legend Overlaps with X-Axis - Stack Overflow
I'm setting up a chart where the legend is located below the line graph. For some reason, the legend seems to overlap with...
Read more >MS Excel axis labels overlap in charts (what can you do ...
Stop Labels overlapping chart. There is a really quick fix for this. As shown below: Right click on the Axis; Choose the Format...
Read more >Overlapping Bar Chart X-Axis Labels - Ignition Early Access
Makes sense. A better way to do this might be to give each column its own color that references the legend, where the...
Read more >Categories overlapping on xAxis legend - Highcharts
I've got an issue with categories and xAxis title. ... Do you have any trick to update chart's height, regarding categories string size...
Read more >Resolve Overlapping Labels in X-Axis and bind to View Model ...
How can i Resolve this? Antoher Problem is that i want to have a Checkbox in the Legend to Show or Hide Specific...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also this worked for me. Setting the legend wrapper style property. I am using recharts version 2.0.6.
wrapperStyle={{ position: 'relative' }}
I’m facing this issue on the latest version v2.1.1.