4 Replies Latest reply on Mar 29, 2010 12:05 AM by 723157

    Refreshing Flash Chart Report based on a Multi-Select List

    Devidas
      I have P13_SYMBOL multiselect list object..

      Set "HTML Form Element Attributes" property of P13_SYMBOL to onchange="javascript:getchart(this);"

      I have written following code at page HTML Header section.

      <script type="text/javascript">
      function getchart(filter)
      {
      var get = new htmldb_Get(null,$v('pFlowId'), 'APPLICATION_PROCESS=GET_CHART',0);
      get.add('G_SYMBOL', filter.value);
      var ret = get.get();
      if(ret)
      {
      var d = document.getElementById('P13_SYMBOL');
      d.innerHTML = ret;
      }

      Created Application Item G_SYMBOL

      Created Application Process GET_CHART as follows.

      DECLARE
      vSymbol VARCHAR2(100);
      BEGIN
      htp.p(:G_SYMBOL);
      EXCEPTION WHEN OTHERS THEN
      htp.p('No such symbol!');
      END;


      Flash chart flash following query.

      select null link, TIMESTAMP label, OPEN value1, HIGH value2, LOW value3, CLOSE value4 from "DCF"."DAILY_STOCK_QUOTE"
      where symbol=:G_SYMBOL
      order by TIMESTAMP

      When I change symbol in multiselect list flash chart doesn't get refresh.
      Any idea what is the wrong with the code?

      Edited by: user8638468 on Mar 3, 2010 12:39 PM

      Edited by: user8638468 on Mar 3, 2010 5:30 PM
        • 1. Re: Refreshing Flash Chart Report based on a Multi-Select List
          Doug A. Gault
          Hey there...

          The reason it's not refreshing is because you actually have to tell the flash chart that it NEEDS to refresh. Unless you have Asynchronous Update turned on, the chart will not refresh itself when the data behind the chart has changed. And even if you DO have Asynchronous Update, on, (Which you don't want to do), you'd likely see some lag between your user's change and the data in the graph changing.

          You can do this by using an APEX JavaScript function called apex_RefreshChart().

          1) Edit the chart and go to the REGION DEFINITION tab.
          2) In the REGION SOURCE, scroll down to the bottom and ad the following code
          <script type="text/javascript">
          function myRefreshChart(){
             var chartName = '#CHART_NAME#';
             chartName = chartName.substring(1);
             apex_RefreshChart(&APP_PAGE_ID., chartName, 'en-us');
          }
          </script>
          3) At the end of your JavaScript function, call the new function myRefreshChart().

          That should force the chart to refresh by re-executing the underlying query and passing back in the data to the chart.

          NOTE: This function is not part of the publicly documented API's so it's likely not supported, but it does work!

          Look for a blog post with more detail sometime tomorrow.

          Hope this helps.

          Doug Gault
          http://www.sumneva.com
          http://douggault.blogspot.com
          1 person found this helpful
          • 3. Re: Refreshing Flash Chart Report based on a Multi-Select List
            Doug A. Gault
            Here's a link to the more detailed blog post for those who are interested.

            http://douggault.blogspot.com/2010/03/refreshing-flash-charts-with-ajax.html

            Can you please mark the question as "answered" so I get credit for it! ;-)
            • 4. Re: Refreshing Flash Chart Report based on a Multi-Select List
              723157
              Doug,

              This helped me immensely. Now I can do all sorts of dynamic chart updating. :)

              That's the second time you've come through for me in a big way.

              -Scott