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.