Forum Stats

  • 3,851,490 Users
  • 2,263,988 Discussions
  • 7,904,740 Comments

Discussions

How to refresh report data after selecting a part in 3d pie flash chart

CERW
CERW Member Posts: 4
edited Aug 28, 2013 4:00AM in APEX Discussions

I have created a Flash Chart (3D Pie)  and would like to show a report with the details, below that chart... but without a complete refresh of the page

(I now use the link in the chart query,.. but that refreshes the whole page)

Is there any way to refresh a report region based on the chosen value from the Flash 3D Pie Chart ?

Tagged:

Answers

  • Tom Petrus
    Tom Petrus Member Posts: 1,151 Gold Trophy

    1/ Give your chart region a static ID. (eg I used "chart2" in my sample code)

    2/ Create a dynamic action to fire on Page Load with true action execute javascript. Use this code2

    AnyChart.getChartById($("#chart2_chart object").attr("id"))
    .addEventListener("pointClick", function(e){
      alert("Value of selected datapoint: " + e.data.YValue);
    
      $s("P2_SELECTED_VALUE", e.data.YValue);
    });
    

    You will need to change 2 things in this code:

    2.1:  the chart selector: "#chart2_chart object" . Since I gave my chart region a static ID of chart2 you will need to change that portion of the selector to the id you gave yours.

    Eg if you call it

    emp_chart 
    

    this selector would become

    "#emp_chart_chart object"
    

    2.2: the affected item: I am storing the selected datapoint value into an item called P2_SELECTED_VALUE. Change this to an item's name on your page (remember that if this item is hidden you may want to set the "Protect Value" property to "No" if the page is being submitted at all).

    Basically, this code attaches an event listener to the chart throug the AnyChart javascript API to the pointClick event. This event occurs when you selected a datapoint on the chart. In the function I first show an alert which will show you the selected value (not label!) and then set this value in a page item. Because the $s function from apex is used this will also trigger a change event on the item.

    3/ Next, edit your to-be-affected report region and add the item you are storing the value in to the "Page Items To Submit" item. This will ensure that the correct value is used to filter the report data when it is refreshed.

    4/ Then finally, create another dynamic action to fire "On Change" of the item which will hold the selected value. As a true action set it to refresh the report region.

    Alternatively, you could skip creating this extra dynamic action and just refresh the report region by doing this from the pointclick event handler by doing

    $("#report_region_id").trigger("apexrefresh");
    

    But you may like using a dynamic action for this better because you'll have less javascript to worry about or you might like how the dynamic action exposes more of what happens. Whichever you fancy more!

This discussion has been closed.