Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacked bar chart radius issue #1888

Open
firstLast98421 opened this issue Oct 12, 2019 · 10 comments
Open

stacked bar chart radius issue #1888

firstLast98421 opened this issue Oct 12, 2019 · 10 comments
Labels
bug General bug label enhancement Enhancement to a current API

Comments

@firstLast98421
Copy link

Do you want to request a feature or report a bug?

Not sure if this is an issue, but maybe an enhancement I would like to request?

Currently, with stacked bar charts, if we give the first bar a radius:
-Ex
Screen Shot 2019-10-12 at 7 42 19 PM
there's the white space gaps at the upper corners of the bars, not filled in with the fill color of the bar stacked above.

I know that with the background prop, we can fill in these corners:
Screen Shot 2019-10-12 at 7 47 19 PM
but I don't think I could get it to have the dynamic value heights.

Any help/alternatives would be appreciated!

@xile611 xile611 added the bug General bug label label Oct 16, 2019
@dauletisataev
Copy link

Can someone give steps to recreate this? And describe desired functionality at the end? @firstLast98421 if it is still relevant

@xile611
Copy link
Member

xile611 commented Mar 16, 2020

@firstLast98421 It's recommend to use that case. Maybe it's not a bug, just wrong used case.

@xile611 xile611 closed this as completed Mar 16, 2020
@nbaleli-w
Copy link

@dauletisataev there's an example here: https://recharts.org/en-US/examples/BarChartHasBackground

@RodriCabrera
Copy link

I'm trying to achieve a similar BarChart. I need a stacked bar chart, whose bars have rounded edges and appear to be on top of each other:

Screenshot 2023-08-04 at 14 49 20

My problem is that when I apply the radius to the Bars, I can't set different backgrounds for each bar.

Here is a reproduction in Code Sandbox:
Screenshot 2023-08-04 at 14 51 24

And an extract of the code:

export default function App() {
  const execution = { inactive: 20, win: 20, loss: 20, hedge: 40 };
  return (
    <BarChart width={120} height={30} data={[execution]} layout="vertical">
      <XAxis type="number" hide />
      <YAxis type="category" hide />
      <Bar
        dataKey="inactive"
        stackId="a"
        fill={"blue"}
        radius={[10, 10, 10, 10]}
        background={{ fill: "red" }}
      />
      <Bar dataKey="hedge" stackId="a" fill={"green"} radius={[0, 10, 10, 0]} />
      <Bar dataKey="win" stackId="a" fill={"pink"} radius={[0, 10, 10, 0]} />
      <Bar dataKey="loss" stackId="a" fill={"yellow"} radius={[0, 10, 10, 0]} />
    </BarChart>
  );
}

@OksanaTyshchenko
Copy link

OksanaTyshchenko commented Aug 7, 2023

@RodriCabrera did you resolve this issue? I have the same problem

@ckifer
Copy link
Member

ckifer commented Aug 7, 2023

Going to re-open this as an enhancement. I don't think its quite possible to get what is wanted at this point. Each bar item in a stack does not have an individual background and therefore one can't be configured. Its all or nothing for everything in the stack. We would need a mask or something for each part of the stack

For understanding purposes though, how do you interpret the graph pictured @RodriCabrera - Is the datapoint at the tip of the rounded bar or is it at the edge where the radius starts? From a usability perspective this confuses me a bit.

@ckifer ckifer reopened this Aug 7, 2023
@ckifer ckifer added the enhancement Enhancement to a current API label Aug 7, 2023
@firstLast98421
Copy link
Author

firstLast98421 commented Aug 7, 2023 via email

@RodriCabrera
Copy link

@RodriCabrera did you resolve this issue? I have the same problem

Hi @OksanaTyshchenko , I couldn't solve it using recharts so I finally created what I needed without libraries (here's a codesandbox with that solution). Because in my case I only needed that small graph, with each overlapping bar representing a percentage.

For understanding purposes though, how do you interpret the graph pictured @RodriCabrera - Is the datapoint at the tip of the rounded bar or is it at the edge where the radius starts? From a usability perspective this might be confuses me a bit.

Hey @ckifer ! Thanks for your attention. I interpret it as the datapoint at the tip of the rounded bar. But I understand what you mean about the usability perspective, because the next bar would start being visible before it's "starting point".
From this perspective, this type of chart would be more "correct" if all the bars would start at the same point...

@Vladimir21500
Copy link

Do you want to request a feature or report a bug?

Not sure if this is an issue, but maybe an enhancement I would like to request?

Currently, with stacked bar charts, if we give the first bar a radius: -Ex Screen Shot 2019-10-12 at 7 42 19 PM there's the white space gaps at the upper corners of the bars, not filled in with the fill color of the bar stacked above.

I know that with the background prop, we can fill in these corners: Screen Shot 2019-10-12 at 7 47 19 PM but I don't think I could get it to have the dynamic value heights.

Any help/alternatives would be appreciated!
FYI: I solved it in this way, just set radius only for last bar element

Here is my example:
{domain.map((group, index) => ( <Bar key={group.toString()} fill={chartColors[index]} dataKey={group as string} onMouseEnter={setTooltipPosition} barSize={56} radius={domain.length - 1 === index ? [6, 6, 0, 0] : [0, 0, 0, 0]} stackId={stack ? 'a' : undefined} /> ))}

@nik-webdevelop
Copy link

nik-webdevelop commented Dec 8, 2023

+1 for this issue/enhancement

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug General bug label enhancement Enhancement to a current API
Projects
None yet
Development

No branches or pull requests

9 participants