简体   繁体   English

Tableau JS过滤器:使用javascript API,将过滤器从一个仪表板移动到另一个仪表板

[英]Tableau JS filter: Using javascript API, move filters from one dashboard to another

I am using Javascript API to embed tableau reports in my website. 我正在使用Javascript API将Tableau报表嵌入到我的网站中。 I want the default Tableau behaviour of it saving the filters of one dashboard in a workbook, while moving to another dashboard in the similar workbook. 我想要它的默认Tableau行为,将一个仪表板的筛选器保存在工作簿中,同时移到相似工作簿中的另一个仪表板。

For example: 例如:

If default date in a workbook is Jan-1 and I change it to Jan-2 in one of the dashboards, it should reflect in other dashboards in the same workbook. 如果工作簿中的默认日期是1月1日,而我在其中一个仪表板中将其更改为1月2日,则该日期应反映在同一工作簿中的其他仪表板中。 (In my embedded Tableau workbook!) (在我的嵌入式Tableau工作簿中!)

My code: 我的代码:

function initializeViz(url){
    var placeholderDiv = document.getElementById("tableauViz");
    var options = {
        width: placeholderDiv.offsetWidth,
        height: placeholderDiv.offsetHeight,
        hideTabs: true,
        hideToolbar: true,
        onFirstInteractive: function () {
            workbook = viz.getWorkbook();
            activeSheet = workbook.getActiveSheet();
        }
    };
    var x=url;
    if(viz!=null){
    viz.dispose();}
    viz = new tableauSoftware.Viz(placeholderDiv, url, options);
}

PS 聚苯乙烯

This is closest thing I could find: Saving and restoring current view state of a Tableau graph through javascript API 这是我能找到的最接近的东西: 通过javascript API保存和还原Tableau图形的当前视图状态

I tried to find to find solution/documentation here: http://documents.tips/documents/javascript-api.html 我试图在此处找到解决方案/文档: http : //documents.tips/documents/javascript-api.html

I think you have two options here: 我认为您有两种选择:

  1. If the user is changing a filter in the dashboard you can make the filter apply to all worksheets using the same data source (does not require the JS API and is very simple to do). 如果用户正在仪表板中更改过滤器,则可以使该过滤器使用相同的数据源应用于所有工作表(不需要JS API,并且操作非常简单)。 在此处输入图片说明

  2. If you want to read the filters from the view and then apply them somewhere else you can use Worksheet.getFiltersAsync() which returns a collection of Filter classes . 如果要从视图中读取过滤器,然后将其应用到其他位置,则可以使用Worksheet.getFiltersAsync() ,它返回Filter类的集合

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM