1 Reply Latest reply: Aug 1, 2014 9:14 AM by user3861177 RSS

    OBIEE / Javascript function calling Google API - Visualization does not appear until browser refreshed

    user3861177

      I have started playing around with the google visualization API's (https://developers.google.com/chart/interactive/docs/index).  I am using javascript within the narrative view of an analysis to call the google api.  My problem is that the visualization never appears on the first attempt.  If I refresh the browser or switch dashboard pages and then come back, then the visualization will appear.  Also, when the visualization does not appear, I cannot see my javascript at all when I view the page source in firefox, IE, or chrome.  When the visualization does appear, the javascript obviously shows up under page source.  As a short term counter measure, I have set up the dashboard page to automatically refresh once but that is far from ideal from a user experience perspective. Any ideas on how to make the visualization appear right away without refreshing the browser?

       

      In case it helps, here is an example of my javascript within the narrative view:

      Prefix

      <script type='text/javascript' src='https://www.google.com/jsapi'></script>

      <script type='text/javascript'>

      google.load('visualization', '1', {'packages': ['geochart']})    ;

        function drawRegionsMap() {

        var data = google.visualization.arrayToDataTable([

         ['Country', 'Number of Service Calls'],

       

      Narrative:

      ['@1', @2]

       

      Postfix:

      ]

      );

      var options = {

                 colorAxis: {colors: ['orange', 'blue']}

      };

      var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));

      chart.draw(data, options);

      };

      </script>

      <body onload = "javascript: drawRegionsMap();">

      <div id="chart_div" style="width: 1200px; height: 800px;"></div>

      </body>