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


  <script src=""></script>

  <div class="slidecontainer">
    <label class="label" for="myRange">
      Black body temperature: <strong id ='myTemp'>5800K</strong></label>
    <input type="range" step="50" min="3000" max="7000" value="5800" class="slider" id="myRange">
      <p>Radiance on Earth's surface: <strong id="powerValue"></strong></p>

  <div id="graph"></div>



                html, body {
  margin: 0;
  padding: 0;
  font-family: sans-serif;

.slidecontainer {
  padding: 30px; /* Width of the outside container */

/* The slider itself */
.slider {
  -webkit-appearance: none;  /* Override default CSS styles */
  appearance: none;
  width: 100%; /* Full-width */
  height: 25px; /* Specified height */
  background: #d3d3d3; /* Grey background */
  outline: none; /* Remove outline */
  opacity: 0.7; /* Set transparency (for mouse-over effects on hover) */
  -webkit-transition: .2s; /* 0.2 seconds transition on hover */
  transition: opacity .2s;

/* Mouse-over effects */
.slider:hover {
  opacity: 1; /* Fully shown on mouse-over */

/* The slider handle (use -webkit- (Chrome, Opera, Safari, Edge) and -moz- (Firefox) to override default look) */ 
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; /* Override default look */
  appearance: none;
  width: 25px; /* Set a specific slider handle width */
  height: 25px; /* Slider handle height */
  background: #ff0000; /* Green background */
  cursor: pointer; /* Cursor on hover */

.slider::-moz-range-thumb {
  width: 25px; /* Set a specific slider handle width */
  height: 25px; /* Slider handle height */
  background: #4CAF50; /* Green background */
  cursor: pointer; /* Cursor on hover */


                var dl=10; // wavelength intervals in nm
var mx =[];

var slider = document.getElementById("myRange");
var sliderTemp = document.getElementById("myTemp");
var powerValue = document.getElementById("powerValue")

var k=1.3806485279e-23;
var h=6.62607015e-34;
var c=2.99792458e8; //m/s
var Rsol = 0.0046491; //au
var Re = 1.0; //au

function PLANK_RADIANCE(lambda, T) {
  var l = lambda/1000000000.0; //convert from nm to m.
  return ((2.0*h*Math.pow(c, 2.0))/Math.pow(l, 5.0))*(1/(Math.exp((h*c)/(k*T*l))-1.0)); 

function PLANK_IRRADIANCE(lambda,T) {
  var f=Math.PI * Math.pow(Rsol/Re,2.0);
  return f*PLANK_RADIANCE(lambda,T);

function dataUpdate(T){
  var l=0;
  var my= [];
  while (l < 7000){
      l +=dl;
  p= integrate(mx,my).toFixed(0);
  return {radiance:my, power: p};

 var lo = {
    xaxis: {
      title: 'Wavelength-nm',
      range: [000, 4000]
    yaxis: {
      title: 'Radiance-W/m\xB2/nm	'

d = dataUpdate(5800);
powerValue.innerHTML = d.power + ' W/m&sup2;';

    data: [{x: mx,y: d.radiance}],

// Update the current slider value (each time you drag the slider handle)
slider.oninput = function() {
  var temp = this.value;
  sliderTemp.innerHTML = temp + ' K';
  bb_data = dataUpdate(temp);
  powerValue.innerHTML = bb_data.power + ' W/m&sup2;';
  var graphupdate = {
  data: [{x:mx, y: bb_data.radiance}],

function integrate(x,y) {

	// define the variable for area
	area = 0;
	//loop to calculate the area of each trapezoid and sum.
	for (i = 0; i < x.length-1; i++) {
    dx = x[i+1] - x[i];
		// the area of each trapezoid
		ai = dx * (y[i] + y[i+1])/ 2.;
		// cumulatively sum the areas
		area += ai	
	return area;