Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>getData() Basic Example</title>
- <script type="text/javascript" src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
- <script type="text/javascript">
- var viz, sheet, table;
- function initViz() {
- var containerDiv = document.getElementById("vizContainer"),
- url = "http://public.tableau.com/views/RegionalSampleWorkbook/Storms",
- options = {
- hideTabs: true,
- hideToolbar: true,
- onFirstInteractive: function () {
- document.getElementById('getData').disabled = false; // Enable our button
- }
- };
- viz = new tableau.Viz(containerDiv, url, options);
- setTimeout(function(){ getUnderlyingData(); }, 3000);
- }
- // <!--
- // window.addEventListener("load", myInit, true);
- // function myInit(){
- // // initViz();
- // getUnderlyingData(); }; -->
- function getUnderlyingData(){
- //alert('inside');
- sheet = viz.getWorkbook().getActiveSheet().getWorksheets().get("Storm Map Sheet");
- //alert(sheet);
- // If the active sheet is not a dashboard, then you can just enter:
- // viz.getWorkbook().getActiveSheet();
- options = {
- maxRows: 10, // Max rows to return. Use 0 to return all rows
- ignoreAliases: false,
- ignoreSelection: true,
- includeAllColumns: false
- };
- sheet.getUnderlyingDataAsync(options).then(function(t){
- table = t;
- var tgt = document.getElementById("dataTarget");
- tgt.innerHTML = "<h4>Underlying Data:</h4><div>" + JSON.stringify(table.getData()) + "</div>";
- });
- // console.log(JSON.stringify(table.getData()))
- }
- </script>
- </head>
- <body onload="initViz()";>
- <div class="page-header">
- <h1>getData() Basic Example</h1>
- <p>Click the "Get Data" button to get underlying data for the viz.</p>
- <button id="getData" onclick="getUnderlyingData()" class="btn">Get Data</button>
- </div>
- <div id="vizContainer" style="width:600px; height:600px;" class:"quote"></div>
- <div id="dataTarget"></div>
- </body>
- </html>
Add Comment
Please, Sign In to add comment