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.


<div class="chart"></div>



                html, body {
  overflow-x: hidden;
  position: relative;
  margin: 0;
  padding: 0;
  box-sizing: border-box;

body {
  background-color: #222;

/* the outer beige container */
.chart {
  display: flex;
  margin: 10px;
  width: 600px;
  background-color: #C9BEBC;
  padding: 40px;

/* the blue bar containers */
.container {
  display: flex;
  flex-wrap: wrap-reverse;
  margin: 10px;
  width: 200px;
  height: 500px;
  justify-content: flex-start;
  align-content: flex-start;
  background-color: #364167;

/* the pink boxes we will transition */
.box {
  width: 10px;
  height: 10px;
  margin: 2px;
  z-index: 0;
  background-color: #FF7373;
  position: relative;
  -moz-border-radius: 1px;
  -webkit-border-radius: 1px;
  border-radius: 1px; 
  transform: scale(0);

button {
  margin-top: 20px;
  margin-left: 20px;
  line-height: 60px;
  font-weight: bold;
  padding: 0 40px;
  background: salmon;
  border: none;
  cursor: pointer;
  font-size: 1.5em;



                //set up buttons
let button = document.getElementsByTagName("button")[0];
let button2 = document.getElementsByTagName("button")[1];
const data = [{
        "year": 2015,
        "tour": "The Red Bullet",
        "venue": "Rosemont theatre",
        "capacity": 4400,
        "boxes": 18
        "year": 2017,
        "tour": "Wings",
        "venue": "Allstate arena",
        "capacity": 18500,
        "boxes": 74
        "year": 2018,
        "tour": "Love Yourself",
        "venue": "United center",
        "capacity": 23500,
        "boxes": 94
        "year": 2019,
        "tour": "Love Yourself - Speak Yourself",
        "venue": "Soldier Field",
        "capacity": 61500,
        "boxes": 246

    const colors = ["#FF8E79", "#FF6B5B", "#FF4941", "#DB1D25"];
    scaleColor = d3.scaleOrdinal()
      .domain( => d.year))

    uncount = (data, accessor) =>
      data.reduce((arr, item) => {
        const count = accessor(item)
        for (let i = 0; i < count; i++) {
        return arr
      }, []);

    const boxes = uncount(data, d => d.boxes);

    const nest = d3
      .key(d => d.venue)

    const graph =".chart");
    const group = graph
      .attr("class", "container");

      .data(d => d.values)
      .attr("class", "box")
      .style("background-color", d => scaleColor(d.year));

//intitiate paused animation
let anim = new TimelineLite({paused: true});
anim.staggerTo(".box", 1, {
  scale: 1,
  ease: Back.easeOut,
  stagger: {
    grid: "auto",
    from: "start",
    axis: "y",
    each: 0.08
//play animation 
button.addEventListener ("click", function(e) {
    if(!anim.isActive()) {;
//reverse animation
button2.addEventListener ("click", function(e) {