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

JavaScript

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

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

              
                <div style="display: grid; grid-template-columns: 1fr 1fr 1fr">
  <div id='plot1' class='plot'></div>
  <div id='plot2' class='plot'></div>
  <div id='plot3' class='plot'></div>
  <div id='plot4' class='plot'></div>
  <div id='plot5' class='plot'></div>
  <div id='plot6' class='plot'></div>
  <div id='plot7' class='plot'></div>
  <div id='plot8' class='plot'></div>
  <div id='plot9' class='plot'></div>
</div>
              
            
!

CSS

              
                .plot {
  height: 250px;
}
              
            
!

JS

              
                let x = [];
let y = [];
let n = 3e3;

for (let i = 0; i < n; i++) {
  let f = Math.random();
  x.push(i);
  y.push(Math.sin(i*f));
}

let traces = [{
  x: x,
  y: y,
  type: 'scatter',
  mode: 'markers'
}];

let layout = {
  margin: {
    l: 25,
    r: 25,
    t: 25,
    b: 25
  }
}

plotGroups(1, 9, 3);

async function plotGroups(plotNum, totalPlots, groupSize) {
  
  //return if done
  if ((plotNum + groupSize) > (totalPlots + 1)) {
    return;
  }
  
  //make array of promises and wait for all to resolve
  let reqs = [];
  for (let i = 0; i < groupSize; i++) {
    reqs.push(Plotly.react('plot' + (plotNum + i).toString(), traces, layout));
  }
  await Promise.all(reqs);
  
  //call recursively with next set
  setTimeout(function() { plotGroups(plotNum + groupSize, totalPlots, groupSize) }, 10);
}
              
            
!
999px

Console