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

Bars order in stacked bar chart #7625

Closed
Duitel opened this issue May 11, 2018 · 1 comment
Closed

Bars order in stacked bar chart #7625

Duitel opened this issue May 11, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@Duitel
Copy link

Duitel commented May 11, 2018

Hi,

Is it possible to sort stacked bars based on the total bar height? Right now it defaults to first all the bars of the first subcategory, then all the bars of the 2nd subcategory which are not in there yet, following by all the bars of the 3rd subcategory which are not in there yet, and so on (figure 1).

I tried sorting the output on the total number of reviews (the total bar height) beforehand (figure 2), but without the desired effect: this only orders the bars relative to their subcategory.

Objective: Make a stacked bar chart with first all bars with total height 3, than with total height 2 and finally with height 1.

See below for the used SQL .

Figures

image
Figure 1: Stacked bar chart without ordering query output

image
Figure 2: Stacked bar chart with query output ordered on total bar height

SQL

SELECT *
FROM
(
Select reviews.reviewer, COUNT() AS NumberReviewsPerPerson
FROM reviews
WHERE reviews.reviewer IN ('delbert', 'deangelo', 'darren', 'genesis', 'rhea', 'herta', 'malcolm', 'timmy', 'adalberto')
GROUP BY reviews.reviewer
) t1
LEFT JOIN (
Select reviews.reviewer, products.category, COUNT(
) as NumberReviewsPerPersonPerCategory
FROM reviews
LEFT JOIN products ON (products.id = reviews.product_id)
GROUP BY reviews.reviewer, products.category
) t2
ON (t1.reviewer = t2.reviewer)

Related #2339

⬇️ Please click the 👍 reaction instead of leaving a +1 or update? comment

@alxnddr
Copy link
Member

alxnddr commented Oct 28, 2022

Closed by #24840

@alxnddr alxnddr closed this as completed Oct 28, 2022
@alxnddr alxnddr added this to the 0.45 milestone Oct 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants