Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script>
  // When the onresize event triggers, call vizResize.
  document.body.onresize = vizResize;
  
  // Resize the workbook appropriately without the need for refreshing.
  function vizResize() {
    vizWidth = window.innerWidth - 27;
    vizHeight = window.innerHeight - 27;
    
    // Deal with minimum allowable height.
    if (vizHeight < minHeight) {
      vizHeight = minHeight;
    }
    
    viz.width = vizWidth;
    viz.height = vizHeight;
    
    // Set the div dimensions to that of the viz in case scrolling is needed.
    document.getElementById('tableauViz').style.width = viz.width;
    document.getElementById('tableauViz').style.height = viz.height;
  }
</script>

<script type="module">
  import { TableauViz } from "https://public.tableau.com/javascripts/api/tableau.embedding.3.latest.js";
  
  // Variables for controling the functionality. 
  // Using "window." on some of these essentially makes them global so that they can be used in scripts outside of this module.
  const vizURL = "https://public.tableau.com/views/Regional_16766597857820/GlobalTemperatures"
  const toolbarPosition = "bottom" // Position of the toolbar. Options are bottom, top, hidden. Hidden not available on Tableau Public
  const hideTabs = true; // Hide the tabs?
  window.minHeight = 0; // Minimum height of the viz. Defaulting to 0 since v3 handles this better.
  
  // Create the Tableau viz, making it global so the refresh script can use it.
  window.viz = new TableauViz();
  
  viz.src = vizURL;
  viz.toolbar = toolbarPosition;
  viz.hideTabs = hideTabs;
  var vizWidth = window.innerWidth - 27;
  var vizHeight = window.innerHeight - 27;
  
  // Deal with minimum allowable height.
  if (vizHeight < minHeight) {
    vizHeight = minHeight;
  }
  
  viz.width = vizWidth;
  viz.height = vizHeight;
  
  // Set the div dimensions to that of the viz in case scrolling is needed.
  document.getElementById('tableauViz').style.width = viz.width;
  document.getElementById('tableauViz').style.height = viz.height;
  document.getElementById("tableauViz").appendChild(viz);
</script>

<!-- Don't set div width and height as we've done that above -->
<div>
  <div id="tableauViz" style="margin: 0 auto;"></div>
</div>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console