Socket
Socket
Sign inDemoInstall

gitbook-plugin-tableau

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 2.0.0

assets/jsonfn.js

25

assets/plugin.js
require(["gitbook", "jQuery"], function(gitbook, $) {
gitbook.events.bind("page.change", function(e, config) {
$('.tableau-container').each(function(){
function setupTableau($container){
let opts = null;
let optsContainer = $container.find('.tableau-container-options');
var url = $(this).attr('data-url')+'?';
url += $(this).attr('data-parameters') ? $(this).attr('data-parameters') : 'showVizHome=no&display_spinner=no&animate_transition=yes&tabs=no&embed=y';
try{
opts = JSONfn.parse(optsContainer.text());
}catch (e){
console.error("Could not parse these Tableau options: "+$container[0]);
}
var options = $(this).attr('data-options') != undefined ? JSON.parse($(this).attr('data-options')) : {"hideTabs":true,"hideToolbar":true};
options.width = $(this).attr('width') || "100%"
options.height = $(this).attr('height') || "100%",
$(optsContainer).remove();
viz = new tableauSoftware.Viz(this, url, options);
let defaults = {hideTabs:true, hideToolbar:true, width: "100%", height: "100%"};
viz = new tableauSoftware.Viz($container[0], $container.attr('data-url'), $.extend(defaults, opts));
}
gitbook.events.bind("page.change", function(e, config) {
gitbook.state.$book.find('.tableau-container').each(function(){
setupTableau($(this));
});
});
});
module.exports = {
book: {
assets: "./assets",
js: ["tableau-2.js", "tableau-2.2.0.js", "plugin.js"]
js: ["tableau-2.js", "tableau-2.2.0.js", "plugin.js", "jsonfn.js"]
},

@@ -10,12 +10,18 @@ blocks: {

if(blk.body.trim()==''){
throw Error('Required Tableau URL inside tag body');
if(blk.args.length != 1) throw Error('Tableau plugin requires only one parameter. A URL to a Tableau workbook');
let opts = {};
try{
opts = JSON.parse(blk.body.trim());
}catch (e){
console.warn("No options for Tableau URL: "+blk.args[0]);
}
var u = 'data-url="'+blk.body.trim()+'" ';
var w = blk.kwargs.width || '100%';
var h = blk.kwargs.height || '100%';
var o = blk.kwargs.options ? "data-options='"+blk.kwargs.options+"' " : ' ';
var p = blk.kwargs.parameters ? 'data-parameters="'+blk.kwargs.parameters+'"' : '';
return '<div class="tableau-container" width="'+w+'" height="'+h+'" '+u+o+p+'><div>';
var w = opts.width || '100%';
var h = opts.height || '100%';
return '<div class="tableau-container" width="'+w+'" height="'+h+'" data-url="'+blk.args[0]
+'"><div class="tableau-container-options" style="display:none;">'+JSON.stringify(opts)+'</div><div>';
}

@@ -22,0 +28,0 @@ }

{
"name": "gitbook-plugin-tableau",
"version": "1.0.0",
"version": "2.0.0",
"description": "A Gitbook plugin for embedding public Tableau visualizations using the Tableau Javascript API",

@@ -5,0 +5,0 @@ "main": "index.js",

# Embedded Tableau Views
A Gitbook plugin for embedding Tableau visualizations using the [Tableau Javascript API](https://onlinehelp.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api.htm).
# Supported features
##### URL Parameters
Defaults:
```
parameters='showVizHome=no&display_spinner=no&animate_transition=yes&tabs=no&embed=y'
```
##### Options
See the [full list](https://onlinehelp.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_ref.htm) of available options
Defaults:
```JSON
options='{"hideTabs":true,"hideToolbar":true}'
```
##### Width and Height
Default: `width="100%"` `height="100%"`
# Install

@@ -33,13 +15,27 @@ Modify your book.json by adding `tableau` to plugins

```
{% tableau width='700px', height='750px', parameters='showVizHome=no&embed=y', options='{"hideTabs":true,"hideToolbar":true}' %}
https://public.tableau.com/views/Visual/Principles
{% tableau "https://public.tableau.com/views/Visual/Principles" %}
{"hideTabs":true,
"hideToolbar":true,
"width": "100%",
"height": "100%",
"onFirstInteractive": "function(){console.log('Run this code when the viz has finished loading.');}"}
{% endtableau %}
```
##### Default Options
See the [full list](https://onlinehelp.tableau.com/current/api/js_api/en-us/JavaScriptAPI/js_api_ref.htm) of available options
# Caveats
* Make sure the string you pass to options is valid JSON
```JSON
{"hideTabs":true,
"hideToolbar":true,
"width": "100%",
"height": "100%"}
```
# TODO
##### Caveats
* Make sure the body of the block is valid JSON
##### TODO
* Make the defaults configurable
* Allow passing an account token to the tableau api
* Allow passing an account token to the Tableau api
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc