【发布时间】:2017-09-16 04:07:36
【问题描述】:
所以我的印象是,使用 html 中的 JS,您可以在 Tableau 中做一个动态参数。这是我的代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="http://public.tableau.com/javascripts/api/tableau-2.0.0.min.js"></script>
<script>
$(function() {
var url = 'points to dashboard url';
var vizOptions = {
showTabs : true,
hideToolbar : true,
width : "420px",
height : "420px"
};
currentViz = new tableauSoftware.Viz(document.getElementById('viz'), url, vizOptions);
currentViz.addEventListener(tableauSoftware.TableauEventName.FILTER_CHANGE, onFilterChange);
});
function onFilterChange(e)
{
if (e.getFieldName() == 'Department') {
e.getFilterAsync().then(function(filter) {
var values = filter.getAppliedValues();
var value = values[0]['value'];
// Value of the parameter if "All" is selected in the filter.
if (values.length > 1) {
value = 'All';
}
currentViz.getWorkbook().changeParameterValueAsync('Parameter1', value);
});
}
}
我从https://www.interworks.com/blog/daustin/2015/12/17/dynamic-parameters-tableau 获得的这段代码看起来很即插即用。但是,我的参数结果没有改变。注意,可能的原因是参数实际上是整数和列表,与教程不同。
对这个问题有任何见解吗?
【问题讨论】: