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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.


                <div id="wrapper"></div>


                body {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2em;
  letter-spacing: -0.011em;
  font-family: sans-serif;
  font-size: 16px;
  color: #34495e;
  background: #f8f9fa;

svg {
  fill: #34495e;


                async function drawLineChart() {
  // Checklist 1 of 7 : Access Data
  const dataset = await d3.json("");
  const yAccessor = d => d.temperatureMax;
  const dateParser = d3.timeParse("%Y-%m-%d");
  const xAccessor = d => dateParser(;

  // Checklist 2 of 7 : Create chart dimensions
  let dimensions = {
    height: 400,
    margin: {
      bottom: 40,
      left: 60,
      right: 15,
      top: 15
    width: window.innerWidth * 0.9

  dimensions.boundedWidth =
    dimensions.width - dimensions.margin.left - dimensions.margin.right;
  dimensions.boundedHeight =
    dimensions.height - - dimensions.margin.bottom;

  // Checklist 3 of 7 : Draw canvas
  const wrapper = d3
    .attr("height", dimensions.height)
    .attr("width", dimensions.width);

  const bounds = wrapper
      `translate(${dimensions.margin.left}px, ${}px)`

  // Checklist 4 of 7 : Create scales
  const yScale = d3
    .domain(d3.extent(dataset, yAccessor))
    .range([dimensions.boundedHeight, 0]);

  const freezingTemperaturePlacement = yScale(32);

  // Checklist 5 of 7 : Draw data
  const freezingTemperatures = bounds
    .attr("x", 0)
    .attr("width", dimensions.boundedWidth)
    .attr("y", freezingTemperaturePlacement)
    .attr("height", dimensions.boundedHeight - freezingTemperaturePlacement)
    .attr("fill", "#e0f3f3");

  const xScale = d3
    .domain(d3.extent(dataset, xAccessor))
    .range([0, dimensions.boundedWidth]);

  const lineGenerator = d3
    .x(d => xScale(xAccessor(d)))
    .y(d => yScale(yAccessor(d)));

  const line = bounds
    .attr("d", lineGenerator(dataset))
    .attr("fill", "none")
    .attr("stroke", "#af9358")
    .attr("stroke-width", 2);

  // Checklist 6 of 7 : Draw peripherals
  const yAxisGenerator = d3.axisLeft().scale(yScale);
  const xAxisGenerator = d3.axisBottom().scale(xScale);
  const yAxis = bounds.append("g").call(yAxisGenerator);
  const xAxis = bounds
    .style("transform", `translateY(${dimensions.boundedHeight}px)`);