【Tableau】如何实现嵌入自动刷新

定期在浏览器中自动刷新 Tableau Server 视图

(官方网站,回答客户问题时查看)

问题:无法将 Tableau Server 配置为定期在浏览器中自动刷新视图。

环境:Tableau Server

解决方案:使用以下涉及到在网页中嵌入视图的解决方法之一: 

选项 1:

  1. 选择 :refresh URL 参数
  2. 在网页的 <head> 部分,添加 <meta http-equiv=”refresh” content=”#”>,其中 # 是刷新间隔秒数
URL参数与值: “:refresh=yes
说明:使用 Tableau Server 或 Tableau Online 中的最新数据来呈现视图。有关详细信息,请参见刷新数据或暂停自动更新。
提示:若要不断刷新视图,请在网页的 <head> 部分中添加
<meta http-equiv=”refresh” content=”#”>
其中 # 是刷新的间隔秒数。

选项 2 

  1. Tableau JavaScript APIrefreshDataAsync () 方法与 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.

Embed Code

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 () 方法会清除任何缓存,并从数据源中检索最新信息。

为了表达您对在将来的产品版本中包括此增强功能的支持,请为以下社区理念投下您的一票:自动刷新仪表板。有关本主题的详细信息,请参见:

注意:尽管我们会尽力保持第三方内容引用的正确性,但此处提供的信息可能会进行更改而不另行通知。

广告

发布者:喜乐君

喜乐君 | Tableau Visionary 20202-2023,《数据可视化分析》《业务可视化分析》作者

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s

%d 博主赞过: