Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to sort a Stacked Bar Chart?

TinkerBoyOct 28 2020

Hi.
I am trying to make a Likert Diverging Bar Chart.
I wanted to post links to how they look but the forum wont allow me
How do I sort the stacked bars and Legend to show up the correct way ? Or is there a Diverging Bar Chart?

I have the bar chart up to this point

image.pngSo the data is kept in a table and each question can have a value from 1 - 5. I wrote this query that will union together 3 questions as they form a section. If the answer is 1 or 2 it has to be converted to a - count as they fall in the negative side of the chart. I removed 3 that is Neutral as I am not able to plot it as it sits in the middle

Strongly Disagree = 1
Disagree = 2
Neutral = 3
Agree = 4
Strongly Agree = 4

In the query i order by the label and the the series but the chart still orders it the way it wants

select *
from (
select 'RESPONSIBILITY' as label ,
responsibility1 as series ,
(case when responsibility1 = 'Strongly Disagree' then count1 * -1
when responsibility1 = 'Disagree' then count1 * -1
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then count1
when responsibility1 = 'Strongly Agree' then count1
end ) as value ,
1 as order_value,
(case when responsibility1 = 'Strongly Disagree' then 1
when responsibility1 = 'Disagree' then 2
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then 4
when responsibility1 = 'Strongly Agree' then 5
end ) as order_series
from (
select (case when responsibility = 1 then 'Strongly Disagree'
when responsibility = 2 then 'Disagree'
-- when responsibility = 3 then 'Neutral'
when responsibility = 4 then 'Agree'
when responsibility = 5 then 'Strongly Agree'
end ) as responsibility1 ,
count(*) as count1
from wfd0045_360_review_req
where responsibility is not null
and responsibility <> 3
group by responsibility)
union
select 'FAIRLY' as label ,
responsibility1 as series ,
(case when responsibility1 = 'Strongly Disagree' then count1 * -1
when responsibility1 = 'Disagree' then count1 * -1
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then count1
when responsibility1 = 'Strongly Agree' then count1
end ) as value ,
2 as order_value ,
(case when responsibility1 = 'Strongly Disagree' then 1
when responsibility1 = 'Disagree' then 2
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then 4
when responsibility1 = 'Strongly Agree' then 5
end ) as order_series
from (
select (case when FAIRLY = 1 then 'Strongly Disagree'
when FAIRLY = 2 then 'Disagree'
-- when FAIRLY = 3 then 'Neutral'
when FAIRLY = 4 then 'Agree'
when FAIRLY = 5 then 'Strongly Agree'
end ) as responsibility1 ,
count(*) as count1
from wfd0045_360_review_req
where FAIRLY is not null
and FAIRLY <> 3
group by FAIRLY)
union
select 'FEEDBACK' as label ,
responsibility1 as series ,
(case when responsibility1 = 'Strongly Disagree' then count1 * -1
when responsibility1 = 'Disagree' then count1 * -1
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then count1
when responsibility1 = 'Strongly Agree' then count1
end ) as value ,
3 as order_value ,
(case when responsibility1 = 'Strongly Disagree' then 1
when responsibility1 = 'Disagree' then 2
-- when responsibility1 = 'Neutral' then count1
when responsibility1 = 'Agree' then 4
when responsibility1 = 'Strongly Agree' then 5
end ) as order_series
from (
select (case when FEEDBACK = 1 then 'Strongly Disagree'
when FEEDBACK = 2 then 'Disagree'
-- when FEEDBACK = 3 then 'Neutral'
when FEEDBACK = 4 then 'Agree'
when FEEDBACK = 5 then 'Strongly Agree'
end ) as responsibility1 ,
count(*) as count1
from wfd0045_360_review_req
where FEEDBACK is not null
and FEEDBACK <> 3
group by FEEDBACK)
)
order by order_value , order_series

This post has been answered by Oleh Tyshchenko on Oct 29 2020
Jump to Answer
Comments
Post Details
Added on Oct 28 2020
19 comments
1,422 views