Skip to content

Instantly share code, notes, and snippets.

@russch
Created November 13, 2013 15:59
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save russch/7451465 to your computer and use it in GitHub Desktop.
Automatically refresh a Tableau viz on Tableau Server
<!DOCTYPE html>
<html>
<title>I'm an HTML file!</title>
<!-- Replace the reference to the JS API on Tableau Public to your server -->
<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/tableau_v8.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<body>
<div id="content"> </div>
<script>
var viz;
function refreshThatSucker(){
viz.refreshDataAsync();
//or do something more obvious and evil
//viz.showShareDialog();
}
function initializeViz() {
var placeholderDiv = document.getElementById("content");
// Replace this URL with your viz
var url = "http://public.tableausoftware.com/views/Iceland_0/IcelandDashboard";
var options = {
width: content.offsetWidth,
height: content.offsetHeight,
hideTabs: true,
hideToolbar: true,
onFirstInteractive: function () {
// Refresh the viz every 5000 milliseconds
window.setInterval("refreshThatSucker()",5000);
}
};
try{
viz = new tableauSoftware.Viz(placeholderDiv, url, options);
}
catch (e){
alert(e);
}
};
</script>
<script type="text/javascript">
// Initialize the app on document ready.
$(initializeViz);
</script>
</body>
</html>
@alexy
Copy link

alexy commented Feb 4, 2014

Tableau 8.1 dashboards have a button "pause refresh"... Aren't they supposed to auto-refresh by themselves?

@alexy
Copy link

alexy commented Feb 4, 2014

Caveat: when pasting as-is you'll see nothing, since the div has the height of 0px. Give it some height, see things!

@delroekid
Copy link

works with Firefox. does not work with chrome Version 35.0.1916.153 m

@Anoopetc07
Copy link

How i can deploy this web page on the tableau server.
Please give the details of the procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment