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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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>
<svg width="400" height="400"></svg>


                svg {
  transform: rotateY(180deg);
text {
  transform: rotateY(180deg);
.percent-score {
  font-size: 50px;
  font-style: italic;
  font-weight: bold;
  color: red;


                const innerRadius = 40;
const colorSmooth = 300; //smooth transition of colors (resolution)
const innerText = "Chart";

// values in perсents
var percentsGreat  = 50;
var percentsGood   = 20;
var percentsNormal = 20;
var percentsBad    = 10;

// "start", "end" arcs colors pair per value
var greatStartColor  = "#FFE39C";
var greatEndColor    = "#FFBA9C";
var goodStartColor   = "#6FCF97";
var goodEndColor     = "#66D2EA";
var normalStartColor = "#BC9CFF";
var normalEndColor   = "#8BA4F9";
var badStartColor    = "#919191";
var badEndColor      = "#3D4975";

//indent between arcs
var indent = 1;

// define the workspace and set the origin to its center
var svg = d3 .select("svg"),
  width = svg.attr  ("width"),
 height = svg.attr  ("height"),
      g = svg.append("g")
             .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");

var radius = d3.min([width, height]) / 2;

var arc = d3.arc()
  .innerRadius(radius - innerRadius)
  .padAngle   ((_, i) => color2(i) === color2(i + indent) ? 0 : 1)
  .startAngle (function(d) {
    return d;
  .endAngle(function(d) {
    return d + dblpi / colorSmooth * 1.2;
  }); // 1.2 to block artifacts on the transitions

var great  = colorSmooth / 100 * percentsGreat;
var good   = colorSmooth / 100 * percentsGood   + great;
var normal = colorSmooth / 100 * percentsNormal + good;
var bad    = colorSmooth / 100 * percentsBad    + normal;

var dblpi = 2 * Math.PI;

var color = d3.scaleLinear()
  .domain([0,      great,
           great,  good,
           good,   normal,
           normal, bad
  .range([greatStartColor,  greatEndColor,
          goodStartColor,   goodEndColor,
          normalStartColor, normalEndColor,
          badStartColor,    badEndColor

const color2 = 
     .domain([great, good, normal, bad])

  .data  (d3.range(0, dblpi, dblpi / colorSmooth))
  .enter ()
  .attr  ("d", arc)
  .style ("fill", function(d, i) {
    return color(i);

 .attr  ("class", "percent-score")
 .attr  ("dy", ".35em") // align the text to the center of the chart
 .attr  ("text-anchor", "middle")
 .text  (innerText);