1 Reply Latest reply on Aug 24, 2017 1:17 PM by patrick.byrne.0

    question re: refreshDataAsync() and the API

    Gary H-S

      I read summary data from a viz through leveraging the onFirstInteractive property. However, when I choose to refresh the data in the viz via the refreshDataAsync() function how do I know when the refresh is complete so I can again read its summary data (e.g. run the getSummaryData() function again)?

       

      window.onload = function () {

      var vizOptions = {

      hideToolbar: true,

      hideTabs: true,

      onFirstInteractive: function () {

      getSummaryData();

      }

      }

       

      var divId = "viz";

      var vizUrl = "https://.../views/IEMTProject-SeniorManagement/AverageWaitTime?:embed=y&:display_count=no&:showVizHome=no&:refresh";

      viz = initViz(divId, vizUrl, vizOptions);

       

       

      function getSummaryData() {

      var awt;

       

      // sheet = viz.getWorkbook().getActiveSheet().getWorksheets().get("Storm Map Sheet");

      // If the active sheet is not a dashboard, then you can just enter:

      worksheet = viz2.getWorkbook().getActiveSheet();

       

      options = {

      maxRows: 0, // Max rows to return. Use 0 to return all rows

      ignoreAliases: false,

      ignoreSelection: true

      };

       

      worksheet.getSummaryDataAsync(options).then(function (t) {

      myArray = t.getData();

      myObjects = myArray[0];

      //console.log(myObjects);

      for (var i = 0; i < myObjects.length; i++) {

      if (myObjects[i].value != 1 && myObjects[i].value != 10 && myObjects[i].value != 24) {

      var floatie = myObjects[i].value;

      awt = Math.round(floatie * 10) / 10;

      document.getElementById("awt_value").innerHTML = awt;

      colorTheCircle(awt);

      }

      }

      });

      }