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

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='info'>
<h3><code>barSize();</code></h3>
<p>Change the size of the bar elements. Positive value set the absolute value in pixels. Negative values specify the scale relative to space between ticks. i.e. -0.5 will set the bar size to 50% of the width between the ticks.</p>
<p>Change the bars size:</p>  
<p><code>.barSize(<button class="rs-btn--small rs-btn--selected" onclick='size_10()'>10</button> 
    <button class="rs-btn--small" onclick='size_n05()'>-0.5</button>); 
  </code></p>
<div id='chart'></div>
</div>


              
            
!

CSS

              
                #info{
  margin: 1em;
}
              
            
!

JS

              
                //Redsift
//barSize();
//Set the size the bar elements

//barSize set to 10
let chart = d3_rs_bars.html()
                      .barSize(10); //positive bar size element
                                         
d3.select('#chart').datum([1,2,3,10,20]).call(chart);

//on toggle set barSize to 10
function size_10(){
let chart = d3_rs_bars.html()
                      .barSize(10); //positive bar size element
                                         
d3.select('#chart').datum([1,2,3,10,20]).call(chart);
}

//on toggle set barSize to -0.5
function size_n05(){
let chart = d3_rs_bars.html()
                      .barSize(-0.5); //negetive bar size element
                                         
d3.select('#chart').datum([1,2,3,10,20]).call(chart);
}

// 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