Search code examples
sqloracleoracle-apexoracle-apex-5

Oracle Apex 5: Using Multiple Columns in a Bar Charts Axix


I'm trying to create a bar chart that shows the values of multiple columns from a table. It's a very simple bar chart, that I can't figure out how to design in APEX 5/SQL.

Chart describing what I mean

Basically, I want the X axis of the bar chart to have bar for each column of my table (that I choose), and the bar will represent the sum of that column, grouped by a column called appname.

I know I will need a:

SELECT SUM(columns) FROM myTable GROUP BY appname

But I can't seem to get the bar chart to represent each column I choose.

Hopefully I've explained this well, my colleagues who don't know how to help say I don't explain things well.


Solution

  • This can be done, but as far as I'm aware only for a fixed number of sets of data. This is what I was able to do with some dummy data: enter image description here

    What you have to do is first create a chart for one of the sets something like:

    select code, sum(value) as total
      from data
     where app_id = 1
     group by code
     order by code
    

    That produces this (with my sample data): enter image description here

    Now when you look at the region definition you will see that the region contains a single "series":enter image description here

    (By default it is named "Series 1" - but I already renamed mine to "App 1").

    Now you can right-click on Series 1 and select "Duplicate" and a new, duplicate series will be created. You can then edit the name and SQL of this new series to refer to application 2. Then when you run that you will see the result I showed at the beginning.