This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 170
/
dynamicLoad.html
53 lines (42 loc) · 1.76 KB
/
dynamicLoad.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html>
<head>
<title>Dynamic Load</title>
<script type="text/javascript" src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
<script type="text/javascript">
var vizList = ["http://public.tableau.com/views/RegionalSampleWorkbook/Flights",
"http://public.tableau.com/views/RegionalSampleWorkbook/Obesity",
"http://public.tableau.com/views/RegionalSampleWorkbook/College",
"http://public.tableau.com/views/RegionalSampleWorkbook/Stocks",
"http://public.tableau.com/views/RegionalSampleWorkbook/Storms"];
var viz,
vizLen = vizList.length,
vizCount = 0;
function createViz(vizPlusMinus) {
var vizDiv = document.getElementById("vizContainer"),
options = {
hideTabs: true
};
vizCount = vizCount + vizPlusMinus;
if (vizCount >= vizLen) {
// Keep the vizCount in the bounds of the array index.
vizCount = 0;
} else if (vizCount < 0) {
vizCount = vizLen - 1;
}
if (viz) { // If a viz object exists, delete it.
viz.dispose();
}
var vizURL = vizList[vizCount];
viz = new tableau.Viz(vizDiv, vizURL, options);
}
</script>
</head>
<body onload="createViz(0);">
<div id="vizContainer" style="width:800px; height:700px;"></div>
<div id="controls" style="padding:20px;">
<button style="width:100px;" onclick="javascript:createViz(-1);">Previous</button>
<button style="width:100px;" onclick="javascript:createViz(1);">Next</button>
</div>
</body>
</html>