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

              
                <script id="severityGradients" type="text/template">
  <linearGradient id="yellowToLightGreen" x1="0" x2="1" y1="0" y2="0.75">
    <stop stop-color="yellow" offset="0%"></stop>
    <stop stop-color="lightgreen" offset="100%"></stop>
  </linearGradient>
  <linearGradient id="lightGreenToGreen" x1="0.5" x2="0.5" y1="0.4" y2="1">
    <stop stop-color="lightgreen" offset="0%"></stop>
    <stop stop-color="green" offset="98%"></stop>
  </linearGradient>
  <linearGradient id="greenToLightBlue" x1="1" x2="0.3" y1="0.15" y2="0.75">
    <stop stop-color="green" offset="10%"></stop>
    <stop stop-color="lightBlue" offset="100%"></stop>
  </linearGradient>
  <linearGradient id="lightBlueToBlue" x1="1" x2="0.5" y1="0.6" y2="0.5">
    <stop stop-color="lightblue" offset="0%"></stop>
    <stop stop-color="blue" offset="100%"></stop>
  </linearGradient>
  <linearGradient id="blueToOrange" x1="0.75" x2="0.5" y1="0.4" y2="0.25">
    <stop stop-color="blue" offset="0%"></stop>
    <stop stop-color="orange" offset="100%"></stop>
  </linearGradient>
  <linearGradient id="orangeToRed" x1="0" x2="1" y1="0.6" y2="0">
    <stop stop-color="orange" offset="0%"></stop>
    <stop stop-color="red" offset="100%"></stop>
  </linearGradient>
  <linearGradient id="redToYellow" x1="0" x2="1" y1="0.8" y2="0">
    <stop stop-color="red" offset="0%"></stop>
    <stop stop-color="yellow" offset="100%"></stop>
  </linearGradient>
</script>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <span class="nav navbar-nav navbar-right navbar-text">Dial it Up!</span>
  </div>
</nav>
<div>
  <div class="card-config-top">
    <div class="svg-container card-config-top-item">
      <div class="card-stacked-content">
        <div class="severity-arc"></div>
        <svg id="weatherType" version="1.1" class="svg-dial">
                            <circle cx="110" cy="110" r="100" fill="#ffffff" stroke="#666666" style="stroke-width: 2px;"></circle>
                            <circle cx="110" cy="30" r="10" fill="none" stroke="#666666" style="stroke-width: 1px;" ></circle>
                            <circle cx="110" cy="110" r="100" fill="#666666" style="opacity: 0.1;"></circle>
                        </svg>
      </div>
    </div>
    <div class="card-config-top-item">
      <div>
        <img src="https://dankemper.net/t3/examples/images/sunny.svg">
        <img src="https://dankemper.net/t3/examples/images/clouds-1.svg">
        <img src="https://dankemper.net/t3/examples/images/clouds-and-sun.svg">
        <img src="https://dankemper.net/t3/examples/images/windy.svg">
        <img src="https://dankemper.net/t3/examples/images/rainy.svg">
        <img src="https://dankemper.net/t3/examples/images/summer-rain.svg">
        <img src="https://dankemper.net/t3/examples/images/weather.svg">
        <img src="https://dankemper.net/t3/examples/images/storm.svg">
        <img src="https://dankemper.net/t3/examples/images/umbrella-1.svg">
        <img src="https://dankemper.net/t3/examples/images/morning-snow.svg">
        <img src="https://dankemper.net/t3/examples/images/tornado.svg">
        <img src="https://dankemper.net/t3/examples/images/rainbow.svg">
      </div>
    </div>
  </div>
</div>
<div class="container-fluid">
</div>
<footer>
  <div>Icons made by <a href="https://www.flaticon.com/authors/madebyoliver" title="Madebyoliver">Madebyoliver</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> are licensed by <a href="https://creativecommons.org/licenses/by/3.0/"
      title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
</footer>
              
            
!

CSS

              
                footer > div {
  padding: 1em;
  width: 100%;
  text-align: center;
}

.card-config-top {
	display: flex;
	align-items: center;
	justify-content: center;
}

.card-config-top-item > div {
	width: 225px;
	height: 255px;
	margin: 0 auto;
	padding: 5px;
	position: relative;
}

.card-config-top-item > div > img {	
	position: absolute;
	top: 0;
	left: 0;
	padding: 1.0rem;
}

.hidden { 
	visibility: hidden; 
}

.card-stacked-content {
	position: relative;
}

.navbar-brand {
	font-size: 2em;
}

.navbar-brand > span {
	position: absolute;
	top: 8px;
}

.navbar-brand > span > img {
	width: 30%;
	height: auto;
}

.navbar-right {
	margin-right: 0;
	position: relative;
}

.svg-dial {
	width: 220px;
	height: 220px;
	top: 5px;
	position: absolute;
}

.severity-arc {
	height: 100%;
	width: 220px;
}

@media (max-width: 500px) {
  .card-config-top {
    display: block;
  }
	
	.card-config-top-item {
		margin: 0 auto;
	}
}

@media (max-width: 767px) {
	
	.navbar-brand > span {
		position: absolute;
	}
	
}
              
            
!

JS

              
                var WeatherData = WeatherData || {};

WeatherData.Drawing = WeatherData.Drawing || {};
WeatherData.Drawing.worker = (function () {

	  var self = this;
	  var spinner = {};
    var tFactor = 2.1;
    var width = 240;
    var height = 240;
    var radius = Math.min(width, height) / 2;
    var color = d3.scaleOrdinal()
        .range(["url(#yellowToLightGreen)", "lightgreen", "url(#lightGreenToGreen)", "green", "url(#greenToLightBlue)", "lightblue",  "url(#lightBlueToBlue)", "blue", "url(#blueToOrange)", "orange", "url(#orangeToRed)", "url(#redToYellow)"]);
	
	  var init = function () {
			TweenMax.set($(".card-config-top-item img:nth-child(n+2)"), {autoAlpha: 0});	
		};

    // A private function which logs any arguments
    var drawWeatherSeverityDonut = function () {
        
			var gradTemplates = d3.select('#severityGradients');
			var arcData = [{slice: 10.1}, {slice: 10.2}, {slice: 10.3}, {slice: 10.4}, {slice: 10.5}, {slice: 10.6}, {slice: 10.7}, {slice: 10.8}, {slice: 10.9}, {slice: 11}, {slice: 11.1}, {slice: 11.2}];
			var arc = d3.arc()
					.outerRadius(radius - 10)
					.innerRadius(radius - 50);

			var pie = d3.pie()
					.sort(null)
					.value(function (d) {
							return d.slice;
					});

			var svg = d3.select(".severity-arc").append("svg");

			svg.html(gradTemplates.html());			

			var outerGroup = svg.attr("width", width)
					.attr("height", height)
					.append("g")
					.attr("transform", "translate(110, 110)");

			var innerGroup = outerGroup.selectAll(".arc")
					.data(pie(arcData))
					.enter().append("g")
					.attr("class", "arc");

			innerGroup.append("path")
					.attr("d", arc)
					.style("fill", function (d) {
							return color(d.data.slice);
					});
    };
	
	  var resolveAngleOfRotation = function() {
			
			var $fadeIn = null;
			var $fadeOut = null;
			var child = ".card-config-top-item img:nth-child({0})";
			var children = ".card-config-top-item img:nth-child({0}), .card-config-top-item img:nth-child({1})"
			var f2 = 2;
			var tl = new TimelineLite();
			var n = ((this.rotation || self.spinner[0].rotation) % 360);	
			
			n = n > 0 ? n :(360 + n);
			tl.add("start", 0);
			
			if (n > 0 && (n <= 30)) {
				
				$fadeOut = $(children.format('2', '12'));
				$fadeIn = $(child.format('1'));
				
			} else if (n > 30 && (n <= 60)) {
				
				$fadeOut = $(children.format('1', '3'));
				$fadeIn = $(child.format('2'));
				
			} else if (n > 60 && (n <= 90)) {
				
				$fadeOut = $(children.format('2', '4'));
				$fadeIn = $(child.format('3'));
				
			} else if (n > 90 && (n <= 120)) {
				
				$fadeOut = $(children.format('3', '5'));
				$fadeIn = $(child.format('4'));
				
			} else if (n > 120 && (n <= 150)) {
				
				$fadeOut = $(children.format('4', '6'));
				$fadeIn = $(child.format('5'));
				
			} else if (n > 150 && (n <= 180)) {
				
				$fadeOut = $(children.format('5', '7'));
				$fadeIn = $(child.format('6'));
				
			} else if (n > 180 && (n <= 210)) {
				
				$fadeOut = $(children.format('6', '8'));
				$fadeIn = $(child.format('7'));
				
			} else if (n > 210 && (n <= 240)) {
				
				$fadeOut = $(children.format('7', '9'));
				$fadeIn = $(child.format('8'));
				
			} else if (n > 240 && (n <= 270)) {
				
				$fadeOut = $(children.format('8', '10'));
				$fadeIn = $(child.format('9'));
				
			} else if (n > 270 && (n <= 300)) {
				
				$fadeOut = $(children.format('9', '11'));
				$fadeIn = $(child.format('10'));
				
			} else if (n > 300 && (n <= 330)) {
				
				$fadeOut = $(children.format('10', '12'));
				$fadeIn = $(child.format('11'));
				
			} else if (n > 330 && (n < 360)) {
				
				$fadeOut = $(children.format('11', '1'));
				$fadeIn = $(child.format('12'));
			}
			
			if ($fadeIn && $fadeOut) {
				tl.to($fadeOut, .50, {autoAlpha: 0}, "start");
				tl.to($fadeIn, .50, {autoAlpha: 1}, "start");
			}

		};
	
	  init();

    return {
        DrawSeverityDonut: drawWeatherSeverityDonut,
				ResolveAngleOfRotation: resolveAngleOfRotation,
			  Spinner: spinner
    };

})();

String.prototype.format = function() {
    var s = this,
        i = arguments.length;

    while (i--) {
        s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
    }
    return s;
};

$(function() {
  
  gsap.registerPlugin(InertiaPlugin);
	var worker = WeatherData.Drawing.worker;

	worker.DrawSeverityDonut();	
	worker.Spinner = Draggable.create($('#weatherType'), {type: "rotation", inertia: false, onDrag: worker.ResolveAngleOfRotation});
	
	$('.svg-container.card-config-top-item > div > div > svg > g > g:nth-child(4) > path').css({"stroke": "green", "stroke-width": 0.5});
})
              
            
!
999px

Console