定期在浏览器中自动刷新 Tableau Server 视图
(官方网站,回答客户问题时查看)
问题:无法将 Tableau Server 配置为定期在浏览器中自动刷新视图。
环境:Tableau Server
解决方案:使用以下涉及到在网页中嵌入视图的解决方法之一:
选项 1:
- 选择 :refresh URL 参数
- 在网页的 <head> 部分,添加 <meta http-equiv=”refresh” content=”#”>,其中 # 是刷新间隔秒数
选项 2
- 将 Tableau JavaScript API 的 refreshDataAsync () 方法与 setInterval() 方法结合使用,这相当于单击“刷新数据”工具栏按钮
原因
Tableau Server 中当前未内置定期自动刷新浏览器中显示的 Tableau 视图的功能。
JS API的官方帮助,期待以后有机会认真研究。
https://help.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_samples.htm
Embedding Views & JavaScript API Usage
The easiest method for embedding a Tableau view (dashboard or visualization) is with the copy-paste embed code. Navigate to a view on Tableau Server and copy the Embed Code from the Share toolbar option.
Once acquired, this code can be pasted into HTML. This method is useful for simple embedding, such as embedding into blogs or internal knowledge bases, but only very simple embedding scenarios should use the embed code. Most deployments should instead use the JavaScript API. It is not significantly more work to embed with the JavaScript API and doing so will gain you flexibility and power in your embedded deployment.
Embedding with the JavaScript API
The basic embed code using the JavaScript looks something like:
HTML:
<!-- JS file to enable the JavaScript API. You can point at the
version on public.tableau.com, online.tableau.com, or your on-prem Server -->
<script src="https://www.example.com/javascripts/api/tableau-2.js"></script>
...
<!-- Empty div where the viz will be placed -->
<div id="tableauViz"></div>
JavaScript:
function initializeViz() {
// JS object that points at empty div in the html
var placeholderDiv = document.getElementById("tableauViz");
// URL of the viz to be embedded
var url = "http://public.tableau.com/views/WorldIndicators/GDPpercapita";
// An object that contains options specifying how to embed the viz
var options = {
width: '600px',
height: '600px',
hideTabs: true,
hideToolbar: true,
};
viz = new tableau.Viz(placeholderDiv, url, options);
}
其他信息
:refresh URL 参数和 refreshDataAsync () 方法会清除任何缓存,并从数据源中检索最新信息。
- w3schools.com 上的 HTML <meta> http-equiv 属性
- w3schools.com 上的 Window setInterval() 方法
注意:尽管我们会尽力保持第三方内容引用的正确性,但此处提供的信息可能会进行更改而不另行通知。