Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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

Save Automatically?

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

              
                <div id='description'>
  <h3><code>theme();</code></h3>
  
  <p>The graph theme can be set using two themes; <code>'light'</code> and <code>'dark'</code>, which changes the background and label to the chosen theme.  By default it is set to <code>'light'</code>.</p>
  <p>The graph below changes the svg container to using the <code>'dark'</code> theme.</p>
  <p><code>.theme('dark');</code></p>
  <div id='chart'></div>
<div><p>The theme can also be applied to the whole page by changing the style.</p></div>  
<div><button onclick="useTheme('light');return false;" class='rs-btn--small rs-btn--selected'>Light Theme</button>
      <button onclick="useTheme('dark');return false;" class ='rs-btn--small'>Dark Theme</button>  
 </div>
 <div><p>The light theme uses the default style and dark theme uses a different library adding <code>ui-rs-core-dark.min.css</code> after <code>css/</code> which just add <code>-dark</code> to the style link.</p></div> 
</div>
              
            
!

CSS

              
                #description{
  margin: 1em;
}



              
            
!

JS

              
                //RedSift
//Setting the graph theme
//Available theme are 'dark' and 'light'.

let chart = d3_rs_lines.html().theme('dark'); //using dark theme

d3.select('#chart').datum([1, 2, 3, 10, 20]).call(chart);

//toggling to different theme
function useTheme(themeName) {
  [].slice.call(document.styleSheets).forEach((style) => {
    if (style.href) {
      if (style.href.startsWith('https://static.redsift.io/reusable/ui-rs-core')) {
        style.disabled = true;
        if (style.href.endsWith('ui-rs-core.min.css') && themeName === 'light') {
          style.disabled = false;
        } else if (style.href.endsWith('ui-rs-core-dark.min.css') && themeName === 'dark') {
          style.disabled = false;
        }
      }
    }
  });
}

// Generic function to toggle selected state of a button
d3.selectAll('button')
  .on('click', function() {
    let selected = this;
    d3.selectAll('button')
      .classed('rs-btn--selected', function() {
        return (selected === this);
      });
  });








              
            
!
999px

Console