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>curve();</code></h3>
  <p>Customize the curve to follow different interpolation between the points.</p>
  <p>
    <button class='rs-btn--small' onclick='linearCurve()'>Linear curve</button>
    <button class='rs-btn--small' onclick='stepCurve()'>Step curve</button>
    <button class='rs-btn--small rs-btn--selected' onclick='_default()'>Default curve</button>
  </p>
  <div id='chartInfo'></div>
</div>

<div id='chart'></div>
<div id='moreInfo'>More info about curve interpolation can be found <a href='https://github.com/d3/d3-shape#curves' target="_blank">here.</a></div>
              
            
!

CSS

              
                #description , #moreInfo{
  margin: 1em;
}
              
            
!

JS

              
                //Redsift
//curve();
//customize interpolation between the points
//example below shows ways it can be done

//default chart
let chart = d3_rs_lines.html();

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

d3.select('#chartInfo')
  .html('<p>By default the curve is set to <code>curveCatmullRom</code>.</p>');

//linear curve
function linearCurve() {
  let chart = d3_rs_lines.html()
    .curve('curveLinear'); //curve interpolate linearly

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

  d3.select('#chartInfo')
    .html('<p>The curve below is interpolated linearly using  <code>.curve("curveLinear");</code></p>');
}

function stepCurve() {
  let chart = d3_rs_lines.html()
    .curve('curveStep'); //curve interpolate using alternating horizontal and vertical lines

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

  d3.select('#chartInfo')
    .html('<p>The curve below is interpolated using alternating horizontal and vertical lines <code>.curve("curveStep");</code></p>');
}

//default chart
function _default() {

  let chart = d3_rs_lines.html();

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

  d3.select('#chartInfo')
    .html('<p>By default the curve is set to <code>curveCatmullRom</code>.</p>');

}

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