如何用前端代码在浏览器中构建一个Tableau
如何用前端代码在浏览器中构建一个Tableau
Tableau is a powerful data visualization tool that can help you see and understand your data in new ways. But if you want to use Tableau to its full potential, you need to be able to build Tableau visualizations in your web browser.
Fortunately, there are a few different ways to do this. In this article, we'll show you how to use three different methods to build Tableau visualizations in your web browser.
The first method is to use the Tableau JavaScript API. This method is best for developers who are comfortable working with JavaScript.
To use the Tableau JavaScript API, you'll need to include the Tableau JavaScript library in your web page. You can get the library from the Tableau website.
Once you have the library, you can create a Tableau visualization by instantiating a new tableau.Viz object. This object takes two parameters: a URL to the Tableau visualization you want to display, and an HTML element in which to display the visualization.
For example, this code would display a Tableau visualization of sales data in an HTML element with the id "viz":
var viz = new tableau.Viz("https://public.tableau.com/views/WorldIndicators/GDPpercapita", document.getElementById("viz"));
You can find more information about the Tableau JavaScript API on the Tableau website.
The second method is to use the Tableau REST API. This method is best for developers who are comfortable working with web APIs.
To use the Tableau REST API, you'll need to make a series of HTTP requests to the Tableau server. These requests will let you authenticate with the server, get information about the Tableau visualizations that are available, and finally get the data you need to render the visualization.
You can find more information about the Tableau REST API on the Tableau website.
The third method is to use the Tableau Web Data Connector. This method is best for developers who want to connect to data that is not stored on a Tableau server.
To use the Tableau Web Data Connector, you'll need to create a web page that includes the Tableau Web Data Connector library. You can get the library from the Tableau website.
Once you have the library, you can create a Tableau visualization by instantiating a new tableau.Connector object. This object takes two parameters: a URL to the data you want to connect to, and an HTML element in which to display the visualization.
For example, this code would display a Tableau visualization of data from a Google Spreadsheet in an HTML element with the id "viz":
var connector = new tableau.Connector("https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit?usp=sharing", document.getElementById("viz"));
You can find more information about the Tableau Web Data Connector on the Tableau website.
Whichever method you choose, you'll need to have a Tableau server set up and running in order to use Tableau in your web browser. You can find more information about how to set up a Tableau server on the Tableau website.
相关文章