[英]How to embed local Tableau report to HTML
I'm trying to use javascript + html to embed one Tableau report into a webpage, and create some buttons/bars to interact with it. 我正在尝试使用javascript + html将一个Tableau报告嵌入到网页中,并创建一些按钮/栏与之交互。
However, I'm stuck in the first step: displaying the report. 但是,我停留在第一步:显示报告。
I've learnt the first example here: http://onlinehelp.tableau.com/samples/en-us/js_api/tutorial.htm
. 我在这里学习了第一个示例:
http://onlinehelp.tableau.com/samples/en-us/js_api/tutorial.htm
: http://onlinehelp.tableau.com/samples/en-us/js_api/tutorial.htm
。
The example works well. 该示例运行良好。 I can see the Tableau report displayed in the webpage and all the buttons/controls work fine.
我可以看到网页中显示的Tableau报告,所有按钮/控件都可以正常工作。
So I made a little change in the javascript function initializeViz()
, in order to display my report in the same way, as below: 因此,我对javascript函数
initializeViz()
进行了一些更改,以便以相同的方式显示我的报告,如下所示:
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url = "file://localhost/C:/reports/Resilience.twb";
var options = {
width: placeholderDiv.offsetWidth,
height: placeholderDiv.offsetHeight * 20,
hideTabs: true,
hideToolbar: true,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableau.Viz(placeholderDiv, url, options);
}
The above function stops displaying anything. 上面的功能停止显示任何内容。 I've checked the local file link
file://localhost/C:/reports/Resilience.twb
in my browser and it works. 我已经在浏览器中检查了本地文件链接
file://localhost/C:/reports/Resilience.twb
,它可以工作。
So I'm really confused, as I've made only the minimum change, and the URL link to local file works, then what could cause the problem? 所以我真的很困惑,因为我只做了最小的更改,并且指向本地文件的URL链接有效,那么什么原因可能导致问题呢? Please help me out, any idea is appreciated.
请帮帮我,任何想法表示赞赏。
are you sure your representation of the path is correct? 您确定路径表示正确吗? You do say C:/reports/Resilience.twb exists but the localhost type paths usually are of the form file:///localhost:port/path/ and the C: seems odd to me to be there.
您确实说过C:/reports/Resilience.twb存在,但是localhost类型的路径通常采用file:/// localhost:port / path /的形式,而C:在我看来似乎很奇怪。 Try using Run from the start menu (on Windows) and typing in '\\localhost\\' and navigate from there to find the full path.
尝试从开始菜单(在Windows上)中使用“运行”,然后输入“ \\ localhost \\”,然后从那里导航以找到完整路径。
EDIT : As far as I can see you cannot display a desktop dashboard file on a webpage . 编辑 :据我所知, 您无法在网页上显示桌面仪表板文件 。 You have to publish it to a tableau server.
您必须将其发布到Tableau Server。 So your URL will have to point to a view rather than a file.
因此,您的URL将必须指向视图而不是文件。 I made a local copy of the training page and amended the var options (height) as you have done above and tested it with the tutorial view and another I have access to and it works in both cases.
我在本地复制了培训页面,并像上面所做的那样修改了var选项(高度),并使用了教程视图对其进行了测试,并且我可以访问另一个视图,并且在两种情况下都可以使用。
Check this doc: http://onlinehelp.tableau.com/current/online/en-us/embed.htm 检查此文档: http : //onlinehelp.tableau.com/current/online/en-us/embed.htm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.