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

Group bars, but don't stack them #3849

Closed
ilgiz-badamshin opened this issue Feb 1, 2017 · 10 comments
Closed

Group bars, but don't stack them #3849

ilgiz-badamshin opened this issue Feb 1, 2017 · 10 comments

Comments

@ilgiz-badamshin
Copy link

It's possible to group bars, but don't stack them?
This work with xAxes.stacked = true and yAxes.stacked = false in version 2.4.0: https://jsfiddle.net/tcc6bLdn/
But in master another behavior : https://jsfiddle.net/5xo8rp9f/1/

@etimberg
Copy link
Member

etimberg commented Feb 1, 2017

This is likely caused by #3563

@potatopeelings
Copy link
Contributor

potatopeelings commented Feb 3, 2017

@etimberg - you're right.

Specifically, the removal of this line

return xScale.options.stacked ? ruler.categoryWidth * xScale.options.barPercentage : ruler.barWidth;
and this block
if (xScale.options.stacked) {
return leftTick + (ruler.categoryWidth / 2) + ruler.categorySpacing;
}
(and their horizontal equivalents) is what caused this.

I had removed it assuming it was a bug because this use case was not immediately obvious and also since the reverse (vertical stacking without stacking x) didn't seem valid. That said, is this a common use case? In the absence of a 3rd dimension, it causes a few problems (the smaller bar being hidden if it's behind the larger one, bar level tooltips not working, being mistaken for a stacked chart). On a related note, the last chart at http://peltiertech.com/overlapped-bar-chart-longer-bars-in-back/ does something similar but without the associate problems by controlling the individual bar widths.

ilgiz-badamshin's chart works around the 1st and 3rd problems by using transparency (the 3rd color that is not in the legend, indicates the areas of overlap)

@etimberg
Copy link
Member

etimberg commented Feb 3, 2017

Hmmm, I think that both of those cases (stacking X but not Y and vice versa) have been used. I do know that the stacked Y only does make something that sort of looks like a waterfall chart.

I agree that it causes problems. The overlapped bar chart is almost a new chart type because it would need to sort the draw order to put largest bar at the back.

@potatopeelings
Copy link
Contributor

Ah ok! I'll add that back then. I recall there was some thread where the waterfall was going to be implemented as a plug in, but now that you mention it, doing it here is better. I'll add back the lines I removed so that we have this functionality (waterfall) back.

I don't see any code in the original to put the largest bar in the back - if it's easy enough I'll add it, otherwise (and I'm guessing its otherwise - because I don't see a nice place to sort elements in the bar controller) we'll probably need a separate issue for these layered bars (to push the taller ones to the back).

@etimberg
Copy link
Member

etimberg commented Feb 5, 2017

Awesome 😄 Thanks so much for looking at this. I know you've done a couple of great features now (horizontal bars, group stacked bars) would you be interested in helping maintain?

I don't think it's easy to sort the bars because that would involve changing how datasets draw (right now the datasets draw in order) so it's definitely a separate issue.

@potatopeelings
Copy link
Contributor

PR submitted (just added the lines back and add a new test).

@ilgiz-badamshin - sorry about that!

@etimberg - there's a couple of plugins I'm working on right now - I'll probably have a bit more time after I'm done with those. I just pick up Issues and sort them out / fix them, yes?

@etimberg
Copy link
Member

Yup, that's the idea :)

@etimberg
Copy link
Member

Pr in #3899

@samy2k01
Copy link

Great, grouping bars without stacking is an excellent feature. Looking forward to the fix. Cheers guys.

@etimberg
Copy link
Member

Fixed in #3899

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants