如何使用 tableau JavaScript API 将 Tableau 嵌入到网页中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21069424/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 19:58:34  来源:igfitidea点击:

How to embed Tableau into a web page using the tableau JavaScript API?

javascripttableau

提问by ArchieTiger

I'm a beginner trying to embed Tableau visualization into my web page, such that whenever the link is clicked, visualization is rendered on the page. But the browser loads with an error on the tableauSoftware object. How can I initialize this object?

我是一名初学者,试图将 Tableau 可视化嵌入到我的网页中,这样无论何时单击链接,都会在页面上呈现可视化。但是浏览器在 tableauSoftware 对象上加载错误。我怎样才能初始化这个对象?

I'm using the Tableau server trial version

我使用的是 Tableau Server 试用版

<html>
    <head>
        <script type='text/javascript' src='http://localhost:85/javascripts/api/viz_v1.js'></script>
        <script>
            function initializeViz() {
                var placeholderDiv = document.getElementById("tableauViz");
                var url2 = "http://localhost:85/views/test_page/Sheet1?:embed=y&:display_count=no";
                viz = new tableauSoftware.Viz(placeholderDiv, url2);
            }
        </script>
    </head>

    <body>
        <a href="#" onclick="$('#tableauViz').html(''); initializeViz()">visualize</a>

        <div class id ="tableauViz"></div>
    </body>
</html>

I get this error:

我收到此错误:

Enter image description here

在此处输入图片说明

采纳答案by Talvalin

I don't have my laptop to hand to confirm which script should be used on a local Tableau Server installation, but try the Tableau Public script (as per the JavaScript API Tutorial) and see if there's any change:

我手头没有笔记本电脑来确认应该在本地 Tableau Server 安装上使用哪个脚本,但请尝试使用 Tableau Public 脚本(根据JavaScript API 教程),看看是否有任何更改:

<script type="text/javascript" src="http://public.tableausoftware.com/javascripts/api/tableau_v8.js"></script>  

Having now checked my own local Tableau Server installation, the script you need is this one:

现在检查了我自己的本地 Tableau Server 安装后,您需要的脚本是这个:

<script type="text/javascript" src="http://localhost:85/javascripts/api/tableau_v8.js"></script>