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
/
resize.html
63 lines (52 loc) · 2.31 KB
/
resize.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
53
54
55
56
57
58
59
60
61
62
<!DOCTYPE html>
<html>
<head>
<title>Resizing</title>
<script type="text/javascript" src="https://public.tableau.com/javascripts/api/tableau-2.min.js"></script>
<script type="text/javascript">
var viz;
function initViz() {
var containerDiv = document.getElementById("vizContainer"),
url = "http://public.tableau.com/views/RegionalSampleWorkbook/Stocks",
options = {
hideTabs: true
};
viz = new tableau.Viz(containerDiv, url, options);
}
function vizResize() {
var width = document.getElementById("resizeWidth").value;
var height = document.getElementById("resizeHeight").value;
viz.setFrameSize(parseInt(width, 10), parseInt(height, 10));
}
/* Important: Worksheets automatically resize to fill the div container for
* the visualization. However, dashboards and stories do not resize automatically
* unless you create them with the automatic size option in Tableau Desktop.
* Scroll down to see how to change the size of a visualization that contains
* a dashboard or story.
*
* To change the size of a visualization that contains a dashboard or story,
* use the following function instead:
*
* function vizResize() {
* var width = document.getElementById("resizeWidth").value;
* var height = document.getElementById("resizeHeight").value;
* var sheet = viz.getWorkbook().getActiveSheet();
*
* sheet.changeSizeAsync(
* {"behavior": "EXACTLY", "maxSize": { "height": height, "width": width }})
* .then(viz.setFrameSize(parseInt(width, 10), parseInt(height, 10)));
* }
*/
</script>
</head>
<body onload="initViz();">
<div id="vizContainer" style="width:800px; height:700px; overflow:auto;"></div>
<div id="controls" style="padding:20px;">
<form id="resizeForm">
<input type="text" id="resizeWidth" placeholder="Width">
<input type="text" id="resizeHeight" placeholder="Height">
<button type="button" onClick="vizResize();">Resize</button>
</form>
</div>
</body>
</html>