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

+ 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

              
                <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<div id="title">
  <h1>Doping in Professional Bicycle Racing</h1>
  <h3>35 Fastest times up Alpe d'Huez</h3>
</div>

              
            
!

CSS

              
                body{
  border: 1px lightgrey solid;
  width: 900px;
  margin: 40px;
  padding-left: 50px;
}
#title {
  margin: 100px;
  position: relative;
}
h1{
  position: absolute;
  right: 50px;
  font-weight: lighter;  
}

h3{
  position: absolute;
  top: 40px;
  right: 50px;
  font-weight: lighter;
}

.dot:hover{
  fill: lightblue;
}

#tooltip {
  position: absolute;
  display: none;
  min-width: 50px;
  height: auto;
  background: none repeat scroll 0 0 #ffffff;
  border: 1px solid grey;
  padding: 10px;
  text-align: center;
}
              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', function(){
const req = new XMLHttpRequest();
req.open("GET","https://raw.githubusercontent.com/freeCodeCamp/ProjectReferenceData/master/cyclist-data.json", true);
req.send();
req.onload=function(){
  const w = 800; const h =600; const padding = 60;
   const dataset = JSON.parse(req.responseText);
  
  const xScale = d3.scaleLinear()
  .domain([d3.min(dataset, (d) => d.Year-1), d3.max(dataset, (d)=> d.Year+1)])
  .range([padding, w-padding])
  
  const yScale = d3.scaleTime()
  .domain([new Date(d3.max(dataset, (d)=>(d.Seconds)*1000)), new Date(d3.min(dataset, (d)=>(d.Seconds)*1000))]) //1000 곱하기 왜냐면 여기서 시간 단위 1은 밀리세컨즈이기떄문
  .range([h-padding, padding])

  
  const xAxis = d3.axisBottom(xScale).tickFormat(d3.format("d"))
  const yAxis = d3.axisLeft(yScale).tickFormat(d3.timeFormat("%M:%S"))
  
  const tooltip = d3.select("body")
  .data(dataset)
  .append("div")
  .attr("id", "tooltip")

  
  const svg = d3.select("body")
  .append("svg")
  .attr("width", w).attr("height", h)
  
  svg.append("g")
  .attr("id", "x-axis")
  .attr("transform", "translate(0," + (h - padding) + ")")
  .call(xAxis)
  
  svg.append("g")
  .attr("id", "y-axis")
  .attr("transform", "translate(" + padding + ", 0)")
  .call(yAxis)

 
  svg
  .select("body")
  .append("svg")
  .attr("height", h)
  .attr("width", w)
  
  svg
    .selectAll("circle")
    .data(dataset)
    .enter()
    .append("circle")
    .attr("cx", (d)=> xScale(d.Year))
    .attr("cy", (d) => yScale(new Date(d.Seconds*1000)))
    .attr("r", 9)
    .attr("fill", function(d){if (d.Doping === "") {return "orange"} else {return "green"}})
    .attr("opacity", "0.6")
    .attr("data-xvalue", (d) => d.Year)
    .attr("data-yvalue", (d) => (new Date(d.Seconds*1000)))
    .attr("class", "dot")
    .attr("id", "legend")
    .on("mousemove", function(d){
            tooltip
              .style("left", xScale(d.Year) + 10 + "px")
              .style("top", (yScale(d.Seconds*1000)) + "px")
              .style("display", "inline-block")
              .html("Name: " + d.Name + "<br/>" +"Time: " +d.Time+ "<br/>"+"Year: "+d.Year+ "<br/> Country: " + d.Nationality + "<br />"+ d.Doping)
              .attr("data-year", d.Year)
        })
    .on("mouseout", function(d){ tooltip.style("display", "none");});
  
   
}})
              
            
!
999px

Console