-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
49 lines (38 loc) · 1.31 KB
/
app.js
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
console.log('Is this working?');
let viz;
//Add Share Link to Tableau Public in here
const url = "https://public.tableau.com/views/Sales_Dashboard_16430474006180/Sales_Dashboard?:language=en-US&:display_count=n&:origin=viz_share_link";
const vizContainer = document.getElementById('vizContainer');
const options = {
hideTabs: true,
height: 800,
width: 1000,
onFirstInteraction: function() {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
console.log("My dashboard is interactive");
}
};
//create a function to generate the viz element
function initViz() {
console.log('Executing the initViz function!');
viz = new tableau.Viz(vizContainer, url, options);
}
// run the initViz function when the page loads
document.addEventListener("DOMContentLoaded", initViz);
const exportPDF = document.getElementById('exportPDF');
const exportImage = document.getElementById('exportImage');
//click on the pdf button to generate pdf of dashboard
function generatePDF() {
viz.showExportPDFDialog()
}
exportPDF.addEventListener("click", function () {
generatePDF();
});
//click on image to generate image of dashboard
function generateImage() {
viz.showExportImageDialog()
}
exportImage.addEventListener("click", function () {
generateImage();
});