recharts icon indicating copy to clipboard operation
recharts copied to clipboard

ComposedCharts - Area + Bar causes white gap around edges of area graph.

Open ro-savage opened this issue 5 years ago • 9 comments

In all examples of composed charts with area/line and bar, there is a white space around the area/line chart on the edges of the graph.

See: https://jsfiddle.net/alidingling/9xopwa9v/

Is there a way to move this gap, so that the line will come out of the 'edge' of the graph, the same as if a normal line/area chart was being used?

With ComposedChart + Bar Graph image

Without ComposedChart image

I do require the bars as well, I realise you can use type="point" on the XAxis but then it breaks the bars.

ro-savage avatar Mar 18 '19 14:03 ro-savage

@ro-savage - Use <XAxis dataKey="name" scale="point"/> and this will solve the probem. Please refer solution https://jsfiddle.net/yntoefxv/

Durgaprasad-Budhwani avatar Mar 20 '19 12:03 Durgaprasad-Budhwani

Thanks for the response @Durgaprasad-Budhwani

However, I'd this reserves the issue that now the bar are over the edge of the graph.

image

Ideally there would be a way to have the line/area graph start at the beginning of the 'grid' rather than the center. The area/line would then take up a whole grid each, basically moving

ro-savage avatar Mar 20 '19 20:03 ro-savage

I am facing a similar issue... Have you come across any optimal way of dealing it..? @ro-savage If yes, please share it!

VinayakRugvedi avatar Nov 05 '19 14:11 VinayakRugvedi

We just accepted it as 'the way it is'. I think to change it would require a PR to recharts with an option to position is differently.

ro-savage avatar Nov 06 '19 03:11 ro-savage

But, there should some workaround with which we can handle it Is there a way we can take control over those svgs to position them..? Can we atleast extend the area and line chart to the Y-Axis, preserving the position of the bars..?

VinayakRugvedi avatar Nov 06 '19 07:11 VinayakRugvedi

Bump because this is still very much an issue as more complicated charts have to get created mixing the area and bar components.

ckifer avatar Aug 20 '20 17:08 ckifer

Bump too, I am trying to have an area element start at the y-axis and end at the end of the graph rather than having random space between the area graph and left and right axies Thanks!!

samofwise avatar Aug 31 '21 14:08 samofwise

last commented on this before I was a maintainer 😅. Re-opened

ckifer avatar Feb 28 '24 23:02 ckifer

This is pretty ugly but Edit elegant-nash-tlpfxr

image

ckifer avatar Mar 04 '24 19:03 ckifer