// THIS FILE HAS BEEN MINIFIED

if(typeof(RGraph) == 'undefined') RGraph = {};RGraph.Pie = function (id, data)
{
this.id = id;this.canvas = document.getElementById(id);this.context = this.canvas.getContext("2d");this.canvas.__object__ = this;this.total = 0;this.subTotal = 0;this.angles = [];this.data = data;this.properties = [];this.type = 'pie';this.isRGraph = true;RGraph.OldBrowserCompat(this.context);this.properties = {
'chart.colors':                 ['rgb(255,0,0)', '#ddd', 'rgb(0,255,0)', 'rgb(0,0,255)', 'pink', 'yellow', 'red', 'rgb(0,255,255)', 'black', 'white'],
'chart.strokestyle':            '#999',
'chart.linewidth':              1,
'chart.labels':                 [],
'chart.labels.sticks':          false,
'chart.labels.sticks.color':    '#aaa',
'chart.segments':               [],
'chart.gutter':                 25,
'chart.title':                  '',
'chart.title.vpos':             null,
'chart.shadow':                 false,
'chart.shadow.color':           'rgba(0,0,0,0.5)',
'chart.shadow.offsetx':         3,
'chart.shadow.offsety':         3,
'chart.shadow.blur':            3,
'chart.text.size':              10,
'chart.text.color':             'black',
'chart.text.font':              'Verdana',
'chart.contextmenu':            null,
'chart.tooltips':               [],
'chart.tooltips.effect':         'fade',
'chart.tooltips.css.class':      'RGraph_tooltip',
'chart.radius':                 null,
'chart.highlight.style':        '3d',
'chart.border':                 false,
'chart.border.color':           'rgba(255,255,255,0.5)',
'chart.key.background':         'white',
'chart.key.position':           'graph',
'chart.annotatable':            false,
'chart.annotate.color':         'black',
'chart.align':                  'center',
'chart.zoom.factor':            1.5,
'chart.zoom.fade.in':           true,
'chart.zoom.fade.out':          true,
'chart.zoom.hdir':              'right',
'chart.zoom.vdir':              'down',
'chart.zoom.frames':            10,
'chart.zoom.delay':             50,
'chart.zoom.shadow':            true,
'chart.zoom.mode':              'canvas',
'chart.zoom.thumbnail.width':   75,
'chart.zoom.thumbnail.height':  75,
'chart.zoom.background':        true,
'chart.zoom.action':            'zoom',
'chart.resizable':              false,
'chart.variant':                'pie'
}
for (var i=0,len=data.length; i<len; i++){
this.total += data[i];}
if(typeof(RGraph) == 'undefined'){
alert('[PIE] Fatal error: The common library does not appear to have been included');}
}
RGraph.Pie.prototype.Set = function (name, value)
{
this.properties[name] = value;}
RGraph.Pie.prototype.Get = function (name)
{
return this.properties[name];}
RGraph.Pie.prototype.Draw = function ()
{
RGraph.FireCustomEvent(this, 'onbeforedraw');this.diameter = Math.min(this.canvas.height, this.canvas.width) - (2 * this.Get('chart.gutter'));this.radius = this.Get('chart.radius') ? this.Get('chart.radius') : this.diameter / 2;this.centery = this.canvas.height / 2;this.subTotal = 0;this.angles = [];if(this.Get('chart.align') == 'left'){
this.centerx = this.radius + this.Get('chart.gutter');} else if(this.Get('chart.align') == 'right'){
this.centerx = this.canvas.width - (this.radius + this.Get('chart.gutter'));} else {
this.centerx = this.canvas.width / 2;}
if(this.Get('chart.shadow')){
var offsetx = document.all ? this.Get('chart.shadow.offsetx') : 0;var offsety = document.all ? this.Get('chart.shadow.offsety') : 0;this.context.beginPath();this.context.fillStyle = this.Get('chart.shadow.color');this.context.shadowColor = this.Get('chart.shadow.color');this.context.shadowBlur = this.Get('chart.shadow.blur');this.context.shadowOffsetX = this.Get('chart.shadow.offsetx');this.context.shadowOffsetY = this.Get('chart.shadow.offsety');this.context.arc(this.centerx + offsetx, this.centery + offsety, this.radius, 0, 6.28, 0);this.context.fill();RGraph.NoShadow(this);}
this.total = RGraph.array_sum(this.data);for (var i=0,len=this.data.length; i<len; i++){
var angle = (this.data[i] / this.total) * 360;this.DrawSegment(angle,
this.Get('chart.colors')[i],
i == (this.data.length - 1));}
if(this.Get('chart.linewidth') > 0){
this.context.beginPath();this.context.lineWidth = this.Get('chart.linewidth');this.context.strokeStyle = this.Get('chart.strokestyle');for (var i=0,len=this.angles.length; i<len; ++i){
this.context.moveTo(this.centerx, this.centery);this.context.arc(this.centerx, this.centery, this.radius, this.angles[i][0] / 57.3, this.angles[i][0] / 57.3, 0);}
this.context.stroke();this.context.beginPath();this.context.moveTo(this.centerx, this.centery);this.context.arc(this.centerx, this.centery, this.radius, 0, 6.28, 0);this.context.stroke();}
if(this.Get('chart.labels.sticks')){
this.DrawSticks();if(
this.Get('chart.strokestyle') != 'white'
&& this.Get('chart.strokestyle') != '#fff'
&& this.Get('chart.strokestyle') != '#fffffff'
&& this.Get('chart.strokestyle') != 'rgb(255,255,255)'
&& this.Get('chart.strokestyle') != 'rgba(255,255,255,0)'
){
this.context.beginPath();this.context.strokeStyle = this.Get('chart.strokestyle');this.context.lineWidth = this.Get('chart.linewidth');this.context.arc(this.centerx, this.centery, this.radius, 0, 6.28, false);this.context.stroke();}
}
this.DrawLabels();if(this.Get('chart.align') == 'left'){
var centerx = this.radius + this.Get('chart.gutter');} else if(this.Get('chart.align') == 'right'){
var centerx = this.canvas.width - (this.radius + this.Get('chart.gutter'));} else {
var centerx = null;}
RGraph.DrawTitle(this.canvas, this.Get('chart.title'), this.Get('chart.gutter'), centerx, this.Get('chart.text.size') + 2);if(this.Get('chart.contextmenu')){
RGraph.ShowContext(this);}
if(this.Get('chart.tooltips').length){
RGraph.Register(this);this.canvas.onclick = function (e)
{
RGraph.HideZoomedCanvas();e = RGraph.FixEventObject(e);var mouseCoords = RGraph.getMouseXY(e);var canvas = e.target;var context = canvas.getContext('2d');var obj = e.target.__object__;var x = mouseCoords[0] - obj.centerx;var y = mouseCoords[1] - obj.centery;var theta = Math.atan(y / x);var hyp = y / Math.sin(theta);RGraph.Redraw();if(obj.Get('chart.variant') == 'donut' && Math.abs(hyp) < (obj.radius / 2)){
return;}
var isDonut = obj.Get('chart.variant') == 'donut';var hStyle = obj.Get('chart.highlight.style');var segment = RGraph.getSegment(e);if(segment){
if(isDonut || hStyle == '2d'){
context.beginPath();context.fillStyle = 'rgba(255,255,255,0.5)';context.moveTo(obj.centerx, obj.centery);context.arc(obj.centerx, obj.centery, obj.radius, RGraph.degrees2Radians(obj.angles[segment[5]][0]), RGraph.degrees2Radians(obj.angles[segment[5]][1]), 0);context.lineTo(obj.centerx, obj.centery);context.closePath();context.fill();context.stroke();} else {
context.lineWidth = 2;context.fillStyle = 'white';context.strokeStyle = 'white';context.beginPath();context.moveTo(obj.centerx, obj.centery);context.arc(obj.centerx, obj.centery, obj.radius, obj.angles[segment[5]][0] / 57.3, obj.angles[segment[5]][1] / 57.3, 0);context.stroke();context.fill();context.lineWidth = 1;context.shadowColor = '#666';context.shadowBlur = 3;context.shadowOffsetX = 3;context.shadowOffsetY = 3;context.beginPath();context.fillStyle = obj.Get('chart.colors')[segment[5]];context.strokeStyle = 'rgba(0,0,0,0)';context.moveTo(obj.centerx - 3, obj.centery - 3);context.arc(obj.centerx - 3, obj.centery - 3, obj.radius, RGraph.degrees2Radians(obj.angles[segment[5]][0]), RGraph.degrees2Radians(obj.angles[segment[5]][1]), 0);context.lineTo(obj.centerx - 3, obj.centery - 3);context.closePath();context.stroke();context.fill();RGraph.NoShadow(obj);if(obj.Get('chart.border')){
context.beginPath();context.strokeStyle = obj.Get('chart.border.color');context.lineWidth = 5;context.arc(obj.centerx - 3, obj.centery - 3, obj.radius - 2, RGraph.degrees2Radians(obj.angles[i][0]), RGraph.degrees2Radians(obj.angles[i][1]), 0);context.stroke();}
}
if(typeof(obj.Get('chart.tooltips')) == 'function'){
var text = String(obj.Get('chart.tooltips')(segment[5]));} else if(typeof(obj.Get('chart.tooltips')) == 'object' && typeof(obj.Get('chart.tooltips')[segment[5]]) == 'function'){
var text = String(obj.Get('chart.tooltips')[segment[5]](segment[5]));} else if(typeof(obj.Get('chart.tooltips')) == 'object'){
var text = String(obj.Get('chart.tooltips')[segment[5]]);} else {
var text = '';}
if(text){
RGraph.Tooltip(canvas, text, e.pageX, e.pageY, segment[5]);}
if(obj.Get('chart.key') && obj.Get('chart.key').length && obj.Get('chart.key.position') == 'graph'){
RGraph.DrawKey(obj, obj.Get('chart.key'), obj.Get('chart.colors'));}
e.stopPropagation();e.cancelBubble = true;return;}
}
this.canvas.onmousemove = function (e)
{
RGraph.HideZoomedCanvas();e = RGraph.FixEventObject(e);var segment = RGraph.getSegment(e);if(segment){
e.target.style.cursor = document.all ? 'hand' : 'pointer';return;}
e.target.style.cursor = 'default';}
} else {
this.canvas.onclick = null;this.canvas.onmousemove = null;}
if(this.Get('chart.border')){
this.context.beginPath();this.context.lineWidth = 5;this.context.strokeStyle = this.Get('chart.border.color');this.context.arc(this.centerx,
this.centery,
this.radius - 2,
0,
6.28,
0);this.context.stroke();}
if(this.Get('chart.key') != null){
RGraph.DrawKey(this, this.Get('chart.key'), this.Get('chart.colors'));}
if(this.Get('chart.variant') == 'donut'){
this.context.beginPath();this.context.strokeStyle = this.Get('chart.strokestyle');this.context.fillStyle = 'white';this.context.arc(this.centerx, this.centery, this.radius / 2, 0, 6.28, 0);this.context.stroke();this.context.fill();}
RGraph.NoShadow(this);if(this.Get('chart.annotatable')){
RGraph.Annotate(this);}
if(this.Get('chart.zoom.mode') == 'thumbnail' || this.Get('chart.zoom.mode') == 'area'){
RGraph.ShowZoomWindow(this);}
if(this.Get('chart.resizable')){
RGraph.AllowResizing(this);}
RGraph.FireCustomEvent(this, 'ondraw');}
RGraph.Pie.prototype.DrawSegment = function (degrees, color, last)
{
var context = this.context;var canvas = this.canvas;var subTotal = this.subTotal;context.beginPath();context.fillStyle = color;context.strokeStyle = this.Get('chart.strokestyle');context.lineWidth = 0;context.arc(this.centerx,
this.centery,
this.radius,
subTotal / 57.3,
(last ? 360 : subTotal + degrees) / 57.3,
0);context.lineTo(this.centerx, this.centery);this.angles.push([subTotal, subTotal + degrees])
this.context.closePath();this.context.fill();this.Get('chart.segments').push([subTotal, subTotal + degrees]);this.subTotal += degrees;}
RGraph.Pie.prototype.DrawLabels = function ()
{
var hAlignment = 'left';var vAlignment = 'center';var labels = this.Get('chart.labels');var context = this.context;RGraph.NoShadow(this);context.fillStyle = 'black';context.beginPath();if(labels && labels.length){
var text_size = this.Get('chart.text.size');for (i=0; i<labels.length; ++i){
if(typeof(this.Get('chart.segments')[i]) == 'undefined'){
continue;}
context.moveTo(this.centerx,this.centery);var a = this.Get('chart.segments')[i][0] + ((this.Get('chart.segments')[i][1] - this.Get('chart.segments')[i][0]) / 2);if(a < 90){
hAlignment = 'left';vAlignment = 'center';} else if(a < 180){
hAlignment = 'right';vAlignment = 'center';} else if(a < 270){
hAlignment = 'right';vAlignment = 'center';} else if(a < 360){
hAlignment = 'left';vAlignment = 'center';}
context.fillStyle = this.Get('chart.text.color');RGraph.Text(context,
this.Get('chart.text.font'),
text_size,
this.centerx + ((this.radius + 10)* Math.cos(a / 57.3)) + (this.Get('chart.labels.sticks') ? (a < 90 || a > 270 ? 2 : -2) : 0),
this.centery + (((this.radius + 10) * Math.sin(a / 57.3))),
labels[i],
vAlignment,
hAlignment);}
context.fill();}
}
RGraph.Pie.prototype.DrawSticks = function ()
{
var context = this.context;var segments = this.Get('chart.segments');var offset = this.Get('chart.linewidth') / 2;for (var i=0; i<segments.length; ++i){
var degrees = segments[i][1] - segments[i][0];context.beginPath();context.strokeStyle = this.Get('chart.labels.sticks.color');context.lineWidth = 1;var midpoint = (segments[i][0] + (degrees / 2)) / 57.3;context.arc(this.centerx,
this.centery,
this.radius + 7,
midpoint,
midpoint,
0);context.arc(this.centerx,
this.centery,
this.radius - offset,
midpoint,
midpoint,
0);context.stroke();}
}