Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
@stoddabr/react-tableau-embed-live
Advanced tools
Embed your Tableau dashboards with confidence!
Embed your Tableau dashboards in React with confidence!
Other features:
any
-holes and should refer to the Tableau official type reference (i.e., if you're using vizRef.current
you're advanced). I have asked several times for full Tableau Embed API types and Tableau keeps saying they're "coming soon".Install via npm @stoddabr/react-tableau-embed-live:
npm install @stoddabr/react-tableau-embed-live
Then import, pass a source url and then badda-bing you're in bussiness.
Simple example using a public tableau embedding:
import * as React from "react";
import "./App.css";
import { TableauEmbed } from "@stoddabr/react-tableau-embed-live";
function App() {
return (
<div
className="App"
style={{
alignItems: "center",
display: "flex",
justifyContent: "center",
flexDirection: "column",
}}
>
<h1>The Tableau Embedded API v3</h1>
<h3>Now more lightweight, and backwards compatible!</h3>
<TableauEmbed sourceUrl="https://public.tableau.com/views/WorldIndicators/GDPpercapita" />
</div>
);
}
export default App;
An example site lives in the folder example/react-tableau-embed-live-examples
with useful wrapper components inside of example/react-tableau-embed-live-examples/src/tableau_examples
.
To run demo on your machine:
# run once:
# clone the repo
git clone https://github.com/stoddabr/react-tableau-embed-live.git
# navigate to example folder
cd example/react-tableau-embed-live-examples
# install example dependencies
npm i
# run every time:
# run project in hot-reloading dev-mode
npm run dev
Used internally by this library.
Prop Name | Type | What do | Min. Library Version |
---|---|---|---|
sourceUrl | string | The URL of the Tableau dashboard. Can be a share or direct link. The host of this url will be used to fetch the Tableau API. | 0.3.X |
version | string | The version of the Tableau Embedding API to use. Defaults to "latest" which may change if you use Tableau Server or Cloud. Will always minify. If using a custom version, ensure the feature is available as per the changelog. Example: "3.1.0". | 0.3.X |
loadingSpinner | React.ReactElement | Custom loading spinner. By default this library uses a fork of lds-ripple | 0.3.19 |
ref | TableauVizRef (React.Ref) | Forwarded reference to underlying <tableau-viz/> WebComponent used in the Tableau Embed API. To be used with a useRef hook. Useful for advanced callbacks. See the "Add/Remove Filter Buttons" example. | 0.3.18 |
Props drilled directly into the Tableau Embed API's <tableau-viz>
WebComponent. See documentation for full explination. This table simply explains how they are exposed. Because of Tableau Embed API idiosyncrasies, some of these may not work.
Prop Name | Type | What do | Min. Library Version |
---|---|---|---|
height | React.CSSProperties["height"] (number or string) | Height of the Tableau Dashboard. Will default to the container (but may be glitchy). It's recommended to fix with same as authored Tableau dashboard. | 0.3.X |
width | React.CSSProperties["width"] (number or string) | Width of the Tableau Dashboard. Will default to the container (but may be glitchy). It's recommended to fix with same as authored Tableau dashboard. | 0.3.X |
["hide-tabs"] | boolean | Will hide toolbars on the Tableau Dashboard. Note: to set to false (and show tabs), pass undefined not false . Tableau's API appears to cast this prop to a string which makes false -> "false" -> which is truthy (i.e., boolean("false") === true is true). See example below. | 0.3.X |
toolbar | "top" | "bottom" | "hidden" | Location of the toolbars. | 0.3.X |
device | "default" | "desktop" | "tablet" | "phone" | Device layout to use. Defaults to "default" | 0.3.X |
token | See Tableau docs | See Tableau docs | 0.3.22 |
["instance-id-to-clone"] | See Tableau docs | See Tableau docs | 0.3.X |
["disable-url-actions"] | See Tableau docs | See Tableau docs | 0.3.X |
SupportedEvent* | (event: any) => void | Callback function to be mounted directly on WebComponent. See list of supported events in the Tableau docs. For example onCustomViewLoaded={()=>console.log("hola world")} | 0.3.X |
onEventListener** SupportedEvent* ** | (event: any) => void | Callback function to be mounted using an event listener. This may result in a different behavior. Similar name to props in row above only with "onEventListener" instead of "on" prefix. Callback function to be mounted directly on WebComponent. See list of supported events in the Tableau docs. For example OnEventListenerCustomViewLoaded={()=>console.log("hola world")} | 0.3.X |
Note: some props in require odd syntax to pass due to how tableau has hyphenated fields which JS is allergic to. To sidestep future compatibility issues, this library recommends using an odd syntax which involes spreading a temporary object. An example of this syntax can be seen in the simple example below with hide-tabs
.
<TableauEmbed
sourceUrl="https://public.tableau.com/views/WorldIndicators/GDPpercapita"
{...{ "hide-tabs": showTab ? undefined : true }}
/>
The styles of the parent component of TableauEmbed
is important and tricky to get correct.
By default, without any height/width props passed, it will take up the height/width in the parent container.
However, this will only happen if the tableau dashboard being embedded is NOT set to fixed mode or the size it's attempting is larger than it's range (tableau docs).
Fixed dashboards should always be set to their exact dimensions and then scaled using JS/CSS transforms (for example, "the react way" in this article).
Prior updates of the Tableau Embedded API have broken this styling (specifically v3.2 -> v3.4).
It's recommended for any project using this library to implement integration-level snapshot tests that check to ensure the TableauEmbed
component is styled correctly.
When using this library ensure you are following Tableau's licensing agreement.
If you discover anything other limitations please create an issue, and/or ping me on Twitter: @sliceofbrett
Contributions welcome!!
To contribute, please fork, then create an atomic PR that describes the fix or feature. If you're not sure what to contribute, see the above list of limitations, or any open issues without an active dev branch.
This project is setup with some CICD github actions to make this process easier. Every push request will trigger actions to increment the npm patch version, build the project, publish the project to npm, build the examples site, and then publishes the example site to a dedicated branch.
FAQs
Embed your Tableau dashboards with confidence!
The npm package @stoddabr/react-tableau-embed-live receives a total of 0 weekly downloads. As such, @stoddabr/react-tableau-embed-live popularity was classified as not popular.
We found that @stoddabr/react-tableau-embed-live demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.