-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (38 loc) · 3.23 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 = "<div class='tableauPlaceholder' id='viz1708264586715' style='position: relative'><noscript><a href='#'><img alt=' ' src='https://public.tableau.com/static/images/CA/CALICO_Massachusetts/Dashboard1/1_rss.png' style='border: none' /></a></noscript><object class='tableauViz' style='display:none;'><param name='host_url' value='https%3A%2F%2Fpublic.tableau.com%2F' /> <param name='embed_code_version' value='3' /> <param name='site_root' value='' /><param name='name' value='CALICO_Massachusetts/Dashboard1' /><param name='tabs' value='yes' /><param name='toolbar' value='yes' /><param name='static_image' value='https://public.tableau.com/static/images/CA/CALICO_Massachusetts/Dashboard1/1.png' /> <param name='animate_transition' value='yes' /><param name='display_static_image' value='yes' /><param name='display_spinner' value='yes' /><param name='display_overlay' value='yes' /><param name='display_count' value='yes' /><param name='language' value='en-GB' /></object></div> <script type='text/javascript'> var divElement = document.getElementById('viz1708264586715'); var vizElement = divElement.getElementsByTagName('object')[0]; if ( divElement.offsetWidth > 800 ) { vizElement.style.minWidth='1000px';vizElement.style.maxWidth='100%';vizElement.style.minHeight='850px';vizElement.style.maxHeight=(divElement.offsetWidth*0.75)+'px';} else if ( divElement.offsetWidth > 500 ) { vizElement.style.minWidth='1000px';vizElement.style.maxWidth='100%';vizElement.style.minHeight='850px';vizElement.style.maxHeight=(divElement.offsetWidth*0.75)+'px';} else { vizElement.style.width='100%';vizElement.style.minHeight='1450px';vizElement.style.maxHeight=(divElement.offsetWidth*1.77)+'px';} var scriptElement = document.createElement('script'); scriptElement.src = 'https://public.tableau.com/javascripts/api/viz_v1.js'; vizElement.parentNode.insertBefore(scriptElement, vizElement); </script>";
const vizContainer = document.getElementById('vizContainer');
const options = {
hideTabs: true,
height: 1000,
width: 1200,
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();
});