Guest User

HTML SOURCE

a guest
Apr 20th, 2018
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.57 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <title>getData() Basic Example</title>
  5.         <script type="text/javascript" src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
  6.         <script type="text/javascript">
  7.             var viz, sheet, table;
  8.  
  9.             function initViz() {
  10.        
  11.         var containerDiv = document.getElementById("vizContainer"),
  12.                     url = "http://public.tableau.com/views/RegionalSampleWorkbook/Storms",
  13.                     options = {
  14.                         hideTabs: true,
  15.                         hideToolbar: true,
  16.                         onFirstInteractive: function () {
  17.                             document.getElementById('getData').disabled = false; // Enable our button
  18.                         }
  19.                     };
  20.                 viz = new tableau.Viz(containerDiv, url, options);
  21.                 setTimeout(function(){ getUnderlyingData(); }, 3000);
  22.             }
  23.  
  24.        
  25. // <!--
  26. //         window.addEventListener("load", myInit, true);
  27. //         function myInit(){
  28. //             // initViz();
  29. //               getUnderlyingData(); }; -->
  30.  
  31.            
  32.            
  33.             function getUnderlyingData(){
  34.                 //alert('inside');
  35.                 sheet = viz.getWorkbook().getActiveSheet().getWorksheets().get("Storm Map Sheet");
  36.                 //alert(sheet);
  37.          // If the active sheet is not a dashboard, then you can just enter:
  38.          // viz.getWorkbook().getActiveSheet();
  39.                 options = {
  40.                     maxRows: 10, // Max rows to return. Use 0 to return all rows
  41.                     ignoreAliases: false,
  42.                     ignoreSelection: true,
  43.                     includeAllColumns: false
  44.                 };
  45.  
  46.                 sheet.getUnderlyingDataAsync(options).then(function(t){
  47.                        table = t;
  48.             var tgt = document.getElementById("dataTarget");
  49.             tgt.innerHTML = "<h4>Underlying Data:</h4><div>" + JSON.stringify(table.getData()) + "</div>";
  50.                 });
  51.            
  52.             // console.log(JSON.stringify(table.getData()))
  53.             }
  54.         </script>
  55.     </head>
  56.  
  57.     <body onload="initViz()";>
  58.         <div class="page-header">
  59.             <h1>getData() Basic Example</h1>
  60.             <p>Click the "Get Data" button to get underlying data for the viz.</p>
  61.             <button id="getData" onclick="getUnderlyingData()" class="btn">Get Data</button>
  62.         </div>
  63.         <div id="vizContainer" style="width:600px; height:600px;" class:"quote"></div>
  64.         <div id="dataTarget"></div>
  65.     </body>
  66. </html>
Add Comment
Please, Sign In to add comment