Wednesday, August 23, 2017

Create stacked bar in APEX 5.1

It seems no "stacked bar" chart in APEX 5.1.

Here is my key steps after few tries.

1. add two series, with same test SQL query.

select * from "EVENT_RT"

2. here is the key setting. Inside Chart > Attribute > choose YES for Stacked. Default is NO, which means two bars side by side displayed.


The other method (should be prior to 5.1) uses one serie data only together with below sample query formed by UNION ALL. I guess it may still work in 5.1

select id,
       project as label,
       NVL((select sum(t.budget) from eba_demo_chart_tasks t where t.project =  p.id and t.budget > t.cost),0) as value,
       'under budget' as series ,
       'green' as color
  from eba_demo_chart_projects p
union all
select id,
       project as label,
       NVL((select sum(t.budget) from eba_demo_chart_tasks t where t.project =  p.id and t.budget <= t.cost),0) as value,
       'over budget' as series ,
       'red' as color
  from eba_demo_chart_projects p