+var cut = function (parent, color, fraction, z) {
+ var deg = Math.round(360 * fraction);
+ if (deg < 2)
+ deg = 2;
+ parent.append('<div class="xslice" style="' +
+ 'background-color: ' + color + ';' +
+ '-webkit-transform: rotate(' + deg + 'deg);' +
+ 'z-index: ' + z + ';' +
+ '"></div>');
+};
+
+var chart = function (right, left, slices) {
+ var total = 0;
+ for (var i = 0; i != slices.length; ++i) {
+ var slice = slices[i];
+ var z = slices.length - i;
+ if (slice[1] > 0.5)
+ cut(right, slice[0], total + 0.5, z);
+ total += slice[1];
+ cut(total > 0.5 ? left : right, slice[0], total, z);
+ }
+};
+