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!

Dynamically Refresh Pie Chart Color Using JavaScript

Elie Grunhaus-OracleNov 6 2019 — edited Nov 6 2019

Hello All.

I've created an application in my apex.oracle.com workspace (and so, am using version 19.2).

I've created a page number 2 on which I have a pie chart region and a simple select list in this region.

The select list is named P2_PIE_COLOR_SELECTOR and defined as:

select x.color, x.r

from

(

select 'Red' as color, 'red' as r from dual

union

select 'Blue' as color, 'blue' as r from dual

union

select 'Green' as color, 'green' as r from dual

union

select 'Yellow' as color, 'yellow' as r from dual

union

select 'Black' as color, 'black' as r from dual

) x

order by

color

The attribute "Page Action On Selection" is set to "None".

Clicking "Attributes" in the pie chart region, under "Advanced --> Javascript Initialization Code" I have the following code:

function( options ) {

**console.log( "chart initialization options", options );**

**// Setup a callback function which gets called when data is retrieved, to manipulate the series data**

**options.dataFilter = function( data ) {**

**data.series\[3\].color = "&P2\_PIE\_COLOR\_SELECTOR.";**

**return data;**

};

return options;

}

My goal is to dynamically refresh the pie chart region, triggered by selecting a color from the select list, and have a specific slice of the pie chart, identified by data.series[3], have its color changed by the selected color.

And so, if I select, say, the color "Yellow", then I want the pie chart region to automatically refresh with its 4th slice (numbered 3 starting from index zero) also colored yellow.

If I change the select list attribute "Page Action On Selection" to "Submit Page", then this works fine.

But I want this color change to happen without submitting the page.

And so, I created a Dynamic Action called DA_PIE_COLOR_SELECTOR2.
pastedImage_6.png

I then created a "Refresh" action that affects the pie chart region:

pastedImage_16.png

Unfortunately, when I select a color from the select list drop down, I see a rotating gif icon for a couple of seconds. But the pie chart color does not change.

If I then manually refresh the page, then the pie slice color changes to my selected color.

I've looked at several questions and answers on this forum about refreshing a chart region using a Dynamic Action. I've followed the "answers". But none of these are working for my situation.

So ... I would really appreciate it if someone knows how to handle this situation.

Thank you very much.

This post has been answered by fac586 on Nov 6 2019
Jump to Answer
Comments
Post Details
Added on Nov 6 2019
7 comments
1,960 views