Created
July 4, 2022 13:29
-
-
Save antichaos/bc43bfc5f11d9cae4d550fdb749920ca to your computer and use it in GitHub Desktop.
Tableau embed - gives error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html lang="en"> | |
<head> | |
<script type="module" src="https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.min.js"></script> | |
<title></title> | |
</head> | |
<body> | |
<button onclick="filterState()">filter</button> | |
<button onclick="clearState()">clear</button> | |
<button onclick="unDo()">undo</button> | |
<tableau-viz id="tableauViz" | |
src='https://public.tableau.com/shared/H3DXCNCZH?:display_count=n&:origin=viz_share_link' | |
device="phone" toolbar="bottom" hide-tabs> | |
<viz-filter field="Category" value="Technology"></viz-filter> | |
<viz-filter field="State" value="California,Oregon,Washington"></viz-filter> | |
</tableau-viz> | |
<script> | |
function filterState() { | |
let viz = document.getElementById("tableauViz"); | |
let sheet = viz.workbook.activeSheet; | |
const saleMap = sheet.worksheets.find((ws) => ws.name === "SaleMap"); | |
saleMap.applyFilterAsync("state",["Washington", "Oregon"], FilterUpdateType.Replace) | |
} | |
function clearState() { | |
let viz = document.getElementById("tableauViz"); | |
let sheet = viz.workbook.activeSheet; | |
const saleMap = sheet.worksheets.find((ws) => ws.name === "SaleMap"); | |
saleMap.clearFilterAsync("State"); | |
} | |
function unDo() { | |
let viz = document.getElementById("tableauViz"); | |
viz.undoAsync(); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment