1(function(){ 2 window.requestAnimFrame = (function (callback) { 3 return ( 4 window.requestAnimationFrame || 5 window.webkitRequestAnimationFrame || 6 window.mozRequestAnimationFrame || 7 window.oRequestAnimationFrame || 8 window.msRequestAnimationFrame || 9 function (callback) { 10 return window.setTimeout(function () { 11 callback(new Date().getTime()); 12 }, Math.floor(1000 / 60)); 13 } 14 ); 15 })(); 16 17 window.cancelAnimFrame = (function (id) { 18 return ( 19 window.cancelAnimationFrame || 20 window.webkitCancelAnimationFrame || 21 window.mozCancelAnimationFrame || 22 window.oCancelAnimationFrame || 23 window.msCancelAnimationFrame || 24 function (id) { 25 window.clearTimeout(id); 26 } 27 ); 28 })(); 29 window.PieChart = 30 { 31 init: function(elementId,segments) 32 { 33 function renderGraph(values) 34 { 35 var canvas = document.getElementById(elementId); 36 var context = canvas.getContext('2d'); 37 context.clearRect(0, 0, canvas.width, canvas.height); 38 39 var centerX = canvas.width / 2; 40 var centerY = canvas.height / 2; 41 var startAngle = -0.5 * Math.PI; 42 var counterClockwise = false; 43 44 for (var i in values) 45 { 46 if (!values[i]) 47 continue; 48 49 var endAngle = startAngle + ((values[i] / 50) * Math.PI); 50 var x = centerX + segments[i].offsetX; 51 var y = centerY + segments[i].offsetY; 52 53 context.beginPath(); 54 context.moveTo(x,y); 55 context.arc(x, y, segments[i].radius, startAngle, endAngle, counterClockwise); 56 context.closePath(); 57 context.fillStyle = segments[i].color; 58 context.fill(); 59 60 if (values[i] >= 2) 61 { 62 var labelAngle = (startAngle + endAngle) / 2; 63 var labelRadius = segments[i].radius * 0.85; 64 var value = Math.round(values[i]); 65 var fontSize = '14pt'; 66 if (value <= 4) fontSize = '12pt'; 67 if (value <= 3) fontSize = '10pt'; 68 if (value <= 2) fontSize = '6pt'; 69 context.font = '100 ' + fontSize + ' MuseoSans,sans-serif'; 70 context.fillStyle = segments[i].fontColor; 71 context.baseline = 'baseline'; 72 context.textAlign = 'center'; 73 context.fillText(value + '%', x + (Math.cos(labelAngle) * labelRadius), y + (Math.sin(labelAngle) * labelRadius) + 7); 74 } 75 76 startAngle = endAngle; 77 } 78 } 79 80 var graphCurrentValues = []; 81 var graphPrevValues = []; 82 var graphNewValues = []; 83 var graphProgress = 0; 84 var graphAnimating = false; 85 function animateGraph(newValues) 86 { 87 graphNewValues = newValues; 88 while (graphCurrentValues.length < graphNewValues.length) 89 graphCurrentValues.push(0); 90 graphPrevValues = graphCurrentValues; 91 while (graphNewValues.length < graphPrevValues.length) 92 graphNewValues.push(0); 93 graphProgress = 0; 94 95 if (!graphAnimating) 96 { 97 graphAnimating = true; 98 window.requestAnimFrame(animateGraphStep); 99 } 100 } 101 102 function animateGraphStep() 103 { 104 var done = true; 105 graphProgress += (1 - graphProgress) * 0.1; 106 if (graphProgress >= 0.99) 107 graphProgress = 1; 108 else 109 done = false; 110 111 for (var i in graphCurrentValues) 112 { 113 graphCurrentValues[i] = (graphPrevValues[i] * (1 - graphProgress)) + (graphNewValues[i] * graphProgress); 114 } 115 116 renderGraph(graphCurrentValues); 117 118 if (done) 119 graphAnimating = false; 120 else 121 window.requestAnimFrame(animateGraphStep); 122 } 123 124 var interface = 125 { 126 animateGraph:animateGraph 127 } 128 129 return interface; 130 } 131 }; 132})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.