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!

Dynamic Colors for Pie Chart Slices in Oracle APEX

Rabia BibiApr 6 2026 — edited Apr 6 2026

I am working on a Pie Chart in Oracle APEX and using the following SQL query to display the top 10 items based on sales value:

SELECT * 
FROM (
   SELECT 
       LABEL,
       VALUE 
   FROM (
       SELECT 
           I.ITEM_NAME AS LABEL,
           SUM(NVL(D.QUANTITY, 0) * NVL(D.PRICE, 0)) 
             - SUM((NVL(D.QUANTITY, 0) * NVL(D.PRICE, 0)) * NVL(D.DISCOUNT_PCT, 0) / 100) AS VALUE,
           ROW_NUMBER() OVER (
               ORDER BY 
                   SUM(NVL(D.QUANTITY, 0) * NVL(D.PRICE, 0)) 
                   - SUM((NVL(D.QUANTITY, 0) * NVL(D.PRICE, 0)) * NVL(D.DISCOUNT_PCT, 0) / 100) DESC
           ) AS RN
       FROM 
           PRM_SALE_HEAD H, 
           PRM_SALE_DETAIL D, 
           PRM_ITEMS I
       WHERE 
           H.SALE_HEAD_PK = D.SALE_HEAD_FK
           AND D.ITEM_FK = I.ITEM_PK
           AND H.BRANCH_FK = NVL(:P1_BRANCH_FK, H.BRANCH_FK)
       GROUP BY 
           I.ITEM_NAME
   )
   ORDER BY VALUE DESC
) 
WHERE ROWNUM <= 10;

The chart is working fine and displaying correct values. However, when I set a color in the chart attributes, all slices appear in the same color.

I want each slice of the Pie Chart to have a different color dynamically, preferably based on:

  • A color column from the query (e.g., HEX color code), OR

  • Automatically assigned distinct colors per slice

    I tried:

  • Changed the chart color property → applies the same color to all slices

  • Did not find a clear way to bind colors dynamically from SQL

    Any guidance or example would be highly appreciated.

This post has been answered by Muhammad Khaleeq on Apr 6 2026
Jump to Answer
Comments
Post Details
Added on Apr 6 2026
2 comments
211 views