D3 Planet Orbits Merged with radial
by Andy Jones
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<svg width="900" height="900">
</svg>
CSS
body {
background-color:#383838;
}
.outerElement {
stroke : #4B6130;
fill : #262626;
}
.outerElement {
stroke : #4B6130;
fill : #262626;
}
.mainElement {
stroke: #3BAF4A;
stroke-width: 8px;
fill : #1C1C1C;
}
#donut {
width: 29rem;
height: 29rem;
margin: 0 auto;
}
path.color0 {
fill: #1072b8;
}
path.color1 {
fill: #35526b;
}
text {
fill:#fff;
text-anchor: middle;
font-size:11px;
font-family: 'Open Sans', Arial, sans-serif;
text-align: center;
}
.menu {
width:45px;
cursor:pointer;
}
.menu-segment {
fill: #282828;
}
JavaScript
var menu = function() {
// Protect against missing new keyword
if (!(this instanceof menu)) {
return new menu();
}
// The following variables have getter/setter functions exposed so are configurable
var data = [{}],
padding = 1,
width = 600,
height = 600,
outerCircleOrbit = 150,
outerCircleRadius = 30,
radius = 50,
numberOfElements = 14,
thickness = 25,
iconSize = 16;
var offsetAngleDeg = -180 / data.length, // Initial rotation angle designed to put centre the first segment at the top
rotation = 2 * Math.PI / numberOfElements, //Amount of rotation ofr each element
rotationDeg = 360 / numberOfElements, //Degrees of rotation for max number of elements
control = {}, // The control that will be augmented and returned
pie, // The pie layout
arc, // The arc generator
segmentLayer,
animationDuration = 1000;
/**
* Adds an additional function to the string prototype to allow
* C# like string based formatting with placeholders
*/
if (!String.prototype.format) {
/**
* Format a string using placeholders by using "{0} {1}".format(arg0, arg1)
* @param {params} The parameters to replace
* @returns {string} The formatted string
*/
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
/**
* Calculates...