-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathresize.html
44 lines (36 loc) · 1.53 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Resize</title>
<script type="module">
// TableauEventType represents the type of Tableau embedding event that can be listened for.
import { TableauEventType } from "https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.js";
function handleFirstInteractive(e) {
const resizeButton = document.getElementById("resizeViz");
// Resize the visualization.
resizeButton.onclick = () => {
viz.width = document.getElementById("resizeWidth").value;
viz.height = document.getElementById("resizeHeight").value;
}
}
let viz = document.getElementById("tableauViz");
// Event fired when a viz first becomes interactive.
viz.addEventListener(TableauEventType.FirstInteractive, handleFirstInteractive);
</script>
</head>
<body>
<div style="width:800px; height:700px;overflow:auto;">
<!-- Initialization of the Tableau visualization. -->
<tableau-viz id="tableauViz" src="https://public.tableau.com/views/RegionalSampleWorkbook/Stocks"
hide-tabs>
</tableau-viz>
</div>
<!-- User can input a new width and height to resize the visualization. -->
<div style="padding:20px;">
<input type="text" id="resizeWidth" placeholder="Width">
<input type="text" id="resizeHeight" placeholder="Height">
<button id="resizeViz">Resize</button>
</div>
</body>
</html>