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.


                <div id="container" class="fill center"></div>


                body {
  position: relative;
.fill {
  height: 100vh;
  width: 100vw;
.center {
  display: flex;
  justify-content: center;
  align-items: center;

.svg {
  background-color: #b3d0ff;

.dot {
  fill: steelblue;

.dot:hover {
  opacity: 0.5;

.title {
  font-size: 20px;

.tooltip {
  position: absolute;
  height: max-content;
  width: max-content;
  padding: 0.5rem;
  background-color: #bfbfbf;
  border: 1px solid grey;
  border-radius: 7px;

.legend {
  margin: 1rem;
  width: 150px;
  height: max-content;
  padding: 0.2rem;
  background-color: #bdbdbd;
  border: 1px solid black;
  left: 1200;
  top: 250;



                const graph = function (arr) {
  const w = 1200;
  const h = 600;
  const pad = 80;

  const svg = d3
    .attr("width", w)
    .attr("height", h)
    .attr("class", "svg");

    .text("Doping in road bicycle racing")
    .attr("class", "title")
    .attr("id", "title")
    .attr("x", w / 2 - 100)
    .attr("text-align", "center")
    .attr("y", pad / 2);"#container")
    .attr("class", "legend")
    .attr("id", "legend")
      "X-Axis represents years, Y-Axis represents time in Minutes and Seconds"

  const xScale = d3
    .domain([d3.min(arr, (d) => d.Year), d3.max(arr, (d) => d.Year)])
    .range([pad, w - pad])

  var formatTime = d3.timeFormat("%M:%S");

  const minTime = d3.min(arr, (d) => new Date(d.Seconds * 1000));
  const maxTime = d3.max(arr, (d) => new Date(d.Seconds * 1000));

  const yScale = d3
    .domain([minTime, maxTime])
    .range([pad, h - pad])

  const tooltip = d3
    .attr("id", "tooltip")
    .style("opacity", 0)
    .attr("class", "tooltip center");

    .attr("data-xvalue", (d) => d.Year)
    .attr("data-yvalue", (d) => {
      return new Date(d.Seconds * 1000);
    .attr("cx", (d) => xScale(d.Year))
    .attr("cy", (d) => {
      return yScale(new Date(d.Seconds * 1000));
    .attr("r", 5)
    .attr("class", "dot")
    .on("mouseover", (e, d) => {
      tooltip.transition().duration(200).style("opacity", 0.9);"left", e.pageX + "px").style("top", e.pageY + "px");
      tooltip.attr("data-year", d.Year);
    .on("mouseout", () => {
      tooltip.transition().duration(200).style("opacity", 0);

  const xAxis = d3.axisBottom(xScale).tickFormat(d3.format("d"));

  const yAxis = d3
    .tickFormat((d) => formatTime(d));

    .attr("transform", `translate(0,${h - pad})`)
    .attr("id", "x-axis");

    .attr("transform", `translate(${pad},0)`)
    .attr("id", "y-axis");

const getData = function (url) {
  const xhr = new XMLHttpRequest();"GET", url, true);
  xhr.onload = function () {
    const response = JSON.parse(xhr.responseText);


document.addEventListener("DOMContentLoaded", function () {