cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


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.

              path {
  stroke: #6cc6af;
  stroke-width: 2px;
  fill: none;
              var data = [
  {x: 0, y:0},
  {x: 1, y:100},
  {x: 2, y:200},
  {x: 3, y:300},
  {x: 4, y:400},
  {x: 5, y:420},
  {x: 6, y:415},
  {x: 7, y:375},
  {x: 8, y:370},
  {x: 9, y:320},

function lineDrawer(state) {
  // graph dimensions
  var svgElem = state.svg[0][0];
  var width = svgElem.offsetWidth;
  var height = svgElem.offsetHeight;
  // graph ranges
  var extentX = d3.extent(state.data, function(d) { return d.x });
  var extentY = d3.extent(state.data, function(d) { return d.y });
  // scale data to graph dimensions
  var scaleX = d3.time.scale()
    .range([state.padding, width - state.padding])
  var scaleY = d3.scale.linear()
    .range([height - state.padding, state.padding])
  // returns a line drawing function with scaled data
  var line = d3.svg.line()
    .x(function(d) { return scaleX(d.x); })
    .y(function(d) { return scaleY(d.y); })
  return {
    draw: function() {
      // specify data and draw a line with the function above
      state.svg.data([state.data]).append('g').append("path").attr("d", line);

function LineGraph(data, className, options) {
  var state = {
    data: data,
    svg: d3.select(className),
    padding: options.padding || 50,
    interpolation: options.interpolation || 'cardinal'
  return Object.assign(

var options = {
  padding: 100,
  interpolation: 'basis'
var lineGraph = LineGraph(data, '.line-graph', options);

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................