MCPcopy Create free account
hub / github.com/idank/explainshell / pie

Function pie

explainshell/web/static/js/d3.v3.js:5526–5549  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

5524 d3.layout.pie = function() {
5525 var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = 2 * π;
5526 function pie(data) {
5527 var values = data.map(function(d, i) {
5528 return +value.call(pie, d, i);
5529 });
5530 var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle);
5531 var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values);
5532 var index = d3.range(data.length);
5533 if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
5534 return values[j] - values[i];
5535 } : function(i, j) {
5536 return sort(data[i], data[j]);
5537 });
5538 var arcs = [];
5539 index.forEach(function(i) {
5540 var d;
5541 arcs[i] = {
5542 data: data[i],
5543 value: d = values[i],
5544 startAngle: a,
5545 endAngle: a += d * k
5546 };
5547 });
5548 return arcs;
5549 }
5550 pie.value = function(x) {
5551 if (!arguments.length) return value;
5552 value = x;

Callers

nothing calls this directly

Calls 1

callMethod · 0.45

Tested by

no test coverage detected