Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


<link href="" rel="stylesheet">  
  <div id="title">US Gross Domestic Product (GDP), 1947-2015</div>
<div class="outer">
<div class="graph"></div>
<div id="poweredBy">
Powered by Legna


                $black: #0D0D0D
$lighterblue: #7E88BF

  background-color: $lighterblue

  height: 400px
  width: 925px
  background: white
  margin-top: 25px 
  position: absolute
  left: 50%
  margin-left: -463px
  color: $black
  font-size: 40px
  width: 900px
  height: 50px
  margin: 25px auto 0px auto
  text-align: center
  font-family: 'Inter', sans-serif
  color: $black
  width: 200px
  text-align: center
  position: absolute
  left: 50%
  margin-left: -100px
  top: 525px
  padding-bottom: 25px
  font-size: 16px
  font-family: 'Inter', sans-serif
  fill: $lighterblue
    fill: red
  display: flex
  background-color: red
  height: 40px
  width: 90px
  position: absolute
  opacity: 0
  padding: 5px
  line-height: 20px
  text-align: right
  font-family: "Roboto", sans-serif


                const req = new XMLHttpRequest();"GET", "", true);
req.onload = function(){
const json = JSON.parse(req.responseText);

  .style("width", "925px")
  .style("height", "400px")
  .attr("class", "plot")

const barWidth=(825/

   .attr("id", "tooltip")

const (item){return new Date(item[0])})

const minDate=d3.min(, (d, i)=>[i][0])

const xScale=d3.scaleTime()
.domain([new Date(minDate), new Date("2015-10-01")])
.range([0, 825])

const yMax=d3.max(, (d, i)=>[i][1])

const yAxisScale=d3.scaleLinear()
.domain([0, yMax])
.range([300, 0])

const yScale=d3.scaleLinear()
.domain([0, yMax])
.range([0, 300])

const rect = svg.selectAll("rect")
   .attr("x", (d,i)=>xScale(dates[i]))
   .attr("y", (d,i)=> yAxisScale([i][1]))
   .attr("width", barWidth)
   .attr("height", (d,i)=>yScale([i][1]))
   .attr("data-date", (d,i)=>[i][0])
   .attr("data-gdp", (d,i)=>[i][1])
   .attr("class", "bar")
   .attr("transform", "translate(50, 50)")
   .on("mouseover", function(d,i){     
   .style("opacity", 0.8);"left", 60+i*(barWidth)+"px")
   .style("bottom", 100+"px")  
    .on("mouseout", function(d,i){
      .style("opacity", 0)    
const yAxis=d3.axisLeft(yAxisScale)
     .attr("id", "y-axis")
     .attr("transform", "translate(50, 50)")
const xAxis=d3.axisBottom(xScale)
     .attr("id", "x-axis")
     .attr("transform", "translate(50, 350)")
const label= svg.append("g")
   .text("Gross Domestic Product ($M)")
   .attr("transform", "translate(70,200) rotate(-90)")
   .attr("font-family", "'Roboto', sans-serif")
   .style("text-anchor", "middle")