Skip to content

Instantly share code, notes, and snippets.

@antichaos
Created July 4, 2022 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antichaos/bc43bfc5f11d9cae4d550fdb749920ca to your computer and use it in GitHub Desktop.
Save antichaos/bc43bfc5f11d9cae4d550fdb749920ca to your computer and use it in GitHub Desktop.
Tableau embed - gives error
<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