Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <div id="container"></div>
              
            
!

CSS

              
                html, body {
  background: #eaeaea;
}

#container {
  background: white;
  max-width: 1200px;
  max-height: 600px;
  border: 1px solid gray;
  padding: 20px;
  box-shadow: 2px 2px 2px #ccc;
}
              
            
!

JS

              
                // Copy-paste this from:
// - https://adventofcode.com/2018/leaderboard/self
// - https://adventofcode.com/2017/leaderboard/self
// - etc.
// Prefix with each year
const data = `
2018
Day       Time  Rank  Score       Time  Rank  Score
 13   00:54:22   418      0   02:45:59  1072      0
 12   01:58:59  1883      0   03:07:04  1668      0
 11   00:35:28  1490      0   01:34:41  1638      0
 10   00:59:00  1129      0   01:06:23  1228      0
  9   00:58:46  1105      0   01:27:19   775      0
  8   00:25:34   794      0   00:30:36   584      0
  7   00:20:10   468      0   01:51:39  1254      0
  6   02:10:54  2207      0   02:39:06  2188      0
  5   00:33:53  1874      0   00:47:42  1651      0
  4   00:40:19   755      0   00:43:02   620      0
  3   00:23:23  1116      0   00:28:28   882      0
  2   00:29:43  2167      0   00:35:29  1479      0
  1   00:05:53   861      0   00:13:58   514      0

2017
Day       Time  Rank  Score       Time  Rank  Score
 25   00:43:47   655      0   00:44:46   581      0
 24   00:31:37   269      0   00:37:27   254      0
 23   00:26:44   645      0   14:53:28  2132      0
 22   00:44:20   562      0   00:59:10   545      0
 21       >24h  2957      0       >24h  2890      0
 20   00:32:38   548      0   11:16:45  2654      0
 19   00:29:47   345      0   00:32:59   339      0
 18   00:51:08   777      0   01:48:31   523      0
 17   00:49:59  1015      0   00:59:29   784      0
 16   00:33:18   711      0   01:29:47   660      0
 15   00:24:12   787      0   00:42:58   861      0
 14   00:32:42   691      0   02:26:00  1040      0
 13   07:24:40  3722      0   13:47:19  4295      0
 12   00:23:44   788      0   00:31:01   698      0
 11   01:04:34  1168      0   01:07:02  1069      0
 10   01:20:29  1132      0   02:26:26  1128      0
  9   01:37:35  1396      0   01:45:41  1361      0
  8   00:30:42  1037      0   00:33:27  1037      0
  7   00:49:49  1549      0   02:22:52  1339      0
  6   00:30:17  1117      0   00:40:01  1189      0
  5   00:12:36   945      0   00:14:52   834      0
  4   00:05:13   473      0   00:16:12   755      0
  3   15:04:39  8836      0   15:41:16  6092      0
  2   04:03:37  3912      0   04:11:25  3258      0
  1   00:06:53   250      0   00:21:28   446      0
`;

const lines = data
  .split(/\r?\n/)
  .filter(l => !!l.trim());

const datasets = [];
const colors1 = ["#3dd", "#33d", "#d33", "#3d3", "#3dd", "#ddd"];
const colors2 = ["rgba(30, 220, 220, 0.15)", "rgba(30, 30, 220, 0.15)", "rgba(220, 30, 30, 0.15)", "rgba(30, 220, 30, 0.15)", "rgba(30, 220, 220, 0.15)", "rgba(220, 220, 220, 0.15)"];

for (var i = 0; i < lines.length; i++) {

  if (lines[i].length === 4) {
    datasets.push({ 
      label: lines[i] + ' rank for star 2',
      borderColor: colors1[Number(lines[i]) - 2015],
      pointBackgroundColor: colors1[Number(lines[i]) - 2015],
      borderWidth: 2,
      backgroundColor: colors2[Number(lines[i]) - 2015],
      showLine: true,
      lineTension: 0,
      data: [],
    });
  } else if (lines[i].match(/\d+/)) {
    const cols = lines[i].match(/\S+/g);
    datasets[datasets.length-1].data.push({ x: Number(cols[0]), y: Number(cols[5]) });
  }
}

const canvas = document.getElementById('container').appendChild(document.createElement("canvas"));
const chart = new Chart(canvas.getContext("2d"), {
  type: 'scatter',
  data: {
    datasets: datasets
  },
  options: {
    responsive: true,
    scales: { yAxes: [{ type: 'logarithmic' }] }
  }
});

console.log('Done!');
              
            
!
999px

Console