// 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;this.uid = RGraph.CreateUID();RGraph.OldBrowserCompat(this.context);this.properties = {
'chart.colors':                 ['red', '#ddd', '#0f0', 'blue', 'pink', 'yellow', 'black', 'cyan'],
'chart.strokestyle':            '#999',
'chart.linewidth':              1,
'chart.labels':                 [],
'chart.labels.sticks':          false,
'chart.labels.sticks.length':   7,
'chart.labels.sticks.color':    '#aaa',
'chart.segments':               [],
'chart.gutter.left':            25,
'chart.gutter.right':           25,
'chart.gutter.top':             25,
'chart.gutter.bottom':          25,
'chart.title':                  '',
'chart.title.background':       null,
'chart.title.hpos':             null,
'chart.title.vpos':             0.5,
'chart.title.bold':             true,
'chart.title.font':             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':              'Arial',
'chart.contextmenu':            null,
'chart.tooltips':               null,
'chart.tooltips.event':         'onclick',
'chart.tooltips.effect':        'fade',
'chart.tooltips.css.class':     'RGraph_tooltip',
'chart.tooltips.highlight':     true,
'chart.highlight.style':        'explode',
'chart.highlight.style.2d.fill': 'rgba(255,255,255,0.7)',
'chart.highlight.style.2d.stroke': 'rgba(255,255,255,0.7)',
'chart.centerx':                null,
'chart.centery':                null,
'chart.radius':                 null,
'chart.border':                 false,
'chart.border.color':           'rgba(255,255,255,0.5)',
'chart.key':                    null,
'chart.key.background':         'white',
'chart.key.position':           'graph',
'chart.key.halign':             'right',
'chart.key.shadow':             false,
'chart.key.shadow.color':       '#666',
'chart.key.shadow.blur':        3,
'chart.key.shadow.offsetx':     2,
'chart.key.shadow.offsety':     2,
'chart.key.position.gutter.boxed': true,
'chart.key.position.x':         null,
'chart.key.position.y':         null,
'chart.key.color.shape':        'square',
'chart.key.rounded':            true,
'chart.key.linewidth':          1,
'chart.key.colors':             null,
'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':            25,
'chart.zoom.delay':             16.666,
'chart.zoom.shadow':            true,
'chart.zoom.mode':              'canvas',
'chart.zoom.thumbnail.width':   75,
'chart.zoom.thumbnail.height':  75,
'chart.zoom.thumbnail.fixed':   false,
'chart.zoom.background':        true,
'chart.zoom.action':            'zoom',
'chart.resizable':              false,
'chart.resize.handle.adjust':   [0,0],
'chart.resize.handle.background': null,
'chart.variant':                'pie',
'chart.variant.donut.color':    'white',
'chart.exploded':               [],
'chart.effect.roundrobin.multiplier': 1,
'chart.events.click':             null,
'chart.events.mousemove':         null
}
for (var i=0,len=data.length; i<len; i++){
this.total += data[i];}
this.getShape = this.getSegment;RGraph.Register(this);}
RGraph.Pie.prototype.Set = function (name, value)
{
if(name == 'chart.highlight.style.2d.color'){
name = 'chart.highlight.style.2d.fill';}
this.properties[name] = value;}
RGraph.Pie.prototype.Get = function (name)
{
if(name == 'chart.highlight.style.2d.color'){
name = 'chart.highlight.style.2d.fill';}
return this.properties[name];}
RGraph.Pie.prototype.Draw = function ()
{
RGraph.FireCustomEvent(this, 'onbeforedraw');this.gutterLeft = this.Get('chart.gutter.left');this.gutterRight = this.Get('chart.gutter.right');this.gutterTop = this.Get('chart.gutter.top');this.gutterBottom = this.Get('chart.gutter.bottom');this.radius = this.Get('chart.radius') ? this.Get('chart.radius') : this.getRadius();this.centery = ((this.canvas.height - this.gutterTop - this.gutterBottom) / 2) + this.gutterTop;this.subTotal = 0;this.angles = [];if(typeof(this.Get('chart.centery')) == 'number'){
this.centery = this.Get('chart.centery');}
if(this.Get('chart.align') == 'left'){
this.centerx = this.radius + this.gutterLeft;} else if(this.Get('chart.align') == 'right'){
this.centerx = this.canvas.width - this.radius - this.gutterRight;} else {
this.centerx = this.canvas.width / 2;}
if(typeof(this.Get('chart.centerx')) == 'number'){
this.centerx = this.Get('chart.centerx');}
RGraph.DrawTitle(this.canvas,
this.Get('chart.title'),
(this.canvas.height / 2) - this.radius - 5,
this.centerx,
this.Get('chart.title.size') ? this.Get('chart.title.size') : this.Get('chart.text.size') + 2);if(this.Get('chart.shadow') && 0){
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) * (Math.PI * 2));this.DrawSegment(angle,this.Get('chart.colors')[i],i == (this.data.length - 1), i);}
RGraph.NoShadow(this);this.DrawBorders();for (var i=0; i<this.angles.length; i++){
this.context.beginPath();this.context.strokeStyle = typeof(this.Get('chart.strokestyle')) == 'object' ? this.Get('chart.strokestyle')[i] : this.Get('chart.strokestyle');this.context.fillStyle = this.Get('chart.colors')[i];this.context.arc(this.angles[i][2],
this.angles[i][3],
this.radius,
(this.angles[i][0]),
(this.angles[i][1]),
false);if(this.Get('chart.variant') == 'donut'){
this.context.arc(this.angles[i][2],
this.angles[i][3],
this.radius / 2,
(this.angles[i][1]),
(this.angles[i][0]),
true);} else {
this.context.lineTo(this.angles[i][2], this.angles[i][3]);}
this.context.closePath();this.context.stroke();this.context.fill();}
if(this.Get('chart.labels.sticks')){
this.DrawSticks();var strokeStyle = this.Get('chart.strokestyle');var isWhite = strokeStyle == 'white' || strokeStyle == '#fff' || strokeStyle == '#fffffff' || strokeStyle == 'rgb(255,255,255)' || strokeStyle == 'rgba(255,255,255,0)';if(!isWhite || (isWhite && this.Get('chart.shadow'))){
this.DrawBorders();}
}
this.DrawLabels();if(this.Get('chart.contextmenu')){
RGraph.ShowContext(this);}
RGraph.InstallUserClickListener(this, this.Get('chart.events.click'));RGraph.InstallUserMousemoveListener(this, this.Get('chart.events.mousemove'));RGraph.AllowTooltips(this);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'));}
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 (radians, color, last, index)
{
var context = this.context;var canvas = this.canvas;var subTotal = this.subTotal;radians = radians * this.Get('chart.effect.roundrobin.multiplier');context.beginPath();context.fillStyle = color;context.strokeStyle = this.Get('chart.strokestyle');context.lineWidth = 0;if(this.Get('chart.shadow')){
RGraph.SetShadow(this, this.Get('chart.shadow.color'),this.Get('chart.shadow.offsetx'), this.Get('chart.shadow.offsety'), this.Get('chart.shadow.blur'));}
if( (typeof(this.Get('chart.exploded')) == 'object' && this.Get('chart.exploded')[index] > 0) || typeof(this.Get('chart.exploded')) == 'number'){
var explosion = typeof(this.Get('chart.exploded')) == 'number' ? this.Get('chart.exploded') : this.Get('chart.exploded')[index];var x = 0;var y = 0;var h = explosion;var t = (subTotal + (radians / 2)) - 1.57;var x = (Math.cos(t) * explosion);var y = (Math.sin(t) * explosion);this.context.moveTo(this.centerx + x, this.centery + y);} else {
var x = 0;var y = 0;}
var startAngle = (subTotal) - 1.57;var endAngle = (((subTotal + radians))) - 1.57;context.arc(this.centerx + x,
this.centery + y,
this.radius,
startAngle,
endAngle,
0);if(this.Get('chart.variant') == 'donut'){
context.arc(this.centerx + x,
this.centery + y,
(this.radius / 2),
endAngle,
startAngle,
true);} else {
context.lineTo(this.centerx + x, this.centery + y);}
this.context.closePath();this.angles.push([subTotal - (Math.PI / 2), subTotal + radians - (Math.PI / 2), this.centerx + x, this.centery + y]);this.context.fill();this.Get('chart.segments').push([subTotal, subTotal + radians]);this.subTotal += radians;}
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.angles) == 'undefined'){
continue;}
context.moveTo(this.centerx,this.centery);var a = this.angles[i][0] + ((this.angles[i][1] - this.angles[i][0]) / 2);if(a < 1.57){
hAlignment = 'left';vAlignment = 'center';} else if(a < 3.14){
hAlignment = 'right';vAlignment = 'center';} else if(a < 4.71){
hAlignment = 'right';vAlignment = 'center';} else if(a < 6.28){
hAlignment = 'left';vAlignment = 'center';}
var angle = ((this.angles[i][1] - this.angles[i][0]) / 2) + this.angles[i][0];if(typeof(this.Get('chart.exploded')) == 'object' && this.Get('chart.exploded')[i] || typeof(this.Get('chart.exploded')) == 'number'){
var t = ((this.angles[i][1] - this.angles[i][0]) / 2);var seperation = typeof(this.Get('chart.exploded')) == 'number' ? this.Get('chart.exploded') : this.Get('chart.exploded')[i];var explosion_offsetx = (Math.cos(angle) * seperation);var explosion_offsety = (Math.sin(angle) * seperation);} else {
var explosion_offsetx = 0;var explosion_offsety = 0;}
if(this.Get('chart.labels.sticks')){
explosion_offsetx += (Math.cos(angle) * this.Get('chart.labels.sticks.length'));explosion_offsety += (Math.sin(angle) * this.Get('chart.labels.sticks.length'));}
context.fillStyle = this.Get('chart.text.color');RGraph.Text(context,
this.Get('chart.text.font'),
text_size,
this.centerx + explosion_offsetx + ((this.radius + 10)* Math.cos(a)) + (this.Get('chart.labels.sticks') ? (a < 1.57 || a > 4.71 ? 2 : -2) : 0),
this.centery + explosion_offsety + (((this.radius + 10) * Math.sin(a))),
labels[i],
vAlignment,
hAlignment);}
context.fill();}
}
RGraph.Pie.prototype.DrawSticks = function ()
{
var context = this.context;var offset = this.Get('chart.linewidth') / 2;var exploded = this.Get('chart.exploded');var sticks = this.Get('chart.labels.sticks');for (var i=0; i<this.angles.length; ++i){
if(typeof(sticks) == 'object' && !sticks[i]){
continue;}
var radians = this.angles[i][1] - this.angles[i][0];context.beginPath();context.strokeStyle = this.Get('chart.labels.sticks.color');context.lineWidth = 1;var midpoint = (this.angles[i][0] + (radians / 2));if(typeof(exploded) == 'object' && exploded[i]){
var extra = exploded[i];} else if(typeof(exploded) == 'number'){
var extra = exploded;} else {
var extra = 0;}
context.lineJoin = 'round';context.lineWidth = 1;context.arc(this.centerx,
this.centery,
this.radius + this.Get('chart.labels.sticks.length') + extra,
midpoint,
midpoint + 0.001,
0);context.arc(this.centerx,
this.centery,
this.radius + extra,
midpoint,
midpoint + 0.001,
0);context.stroke();}
}
RGraph.Pie.prototype.getSegment = function (e)
{
RGraph.FixEventObject(e);var accuracy = arguments[1] ? arguments[1] : 0;var canvas = this.canvas;var context = this.context;var mouseCoords = RGraph.getMouseXY(e);var r = this.radius;var angles = this.angles;var ret = [];for (var i=0; i<angles.length; ++i){
var x = mouseCoords[0] - angles[i][2];var y = mouseCoords[1] - angles[i][3];var theta = Math.atan(y / x);var hyp = y / Math.sin(theta);var hyp = (hyp < 0) ? hyp + accuracy : hyp - accuracy;if(x < 0 && y >= 0){
theta += Math.PI;} else if(x < 0 && y < 0){
theta += Math.PI;}
if(theta > (2 * Math.PI)){
theta -= (2 * Math.PI);}
if(theta >= angles[i][0] && theta < angles[i][1]){
hyp = Math.abs(hyp);if(!hyp || (this.radius && hyp > this.radius) ){
return null;}
if(this.type == 'pie' && this.Get('chart.variant') == 'donut' && (hyp > this.radius || hyp < (this.radius / 2) ) ){
return null;}
ret[0] = angles[i][2];ret[1] = angles[i][3];ret[2] = this.radius;ret[3] = angles[i][0] - (2 * Math.PI);ret[4] = angles[i][1];ret[5] = i;if(ret[3] < 0) ret[3] += (2 * Math.PI);if(ret[4] > (2 * Math.PI)) ret[4] -= (2 * Math.PI);ret[3] = ret[3];ret[4] = ret[4];ret['object'] = this;ret['x'] = ret[0];ret['y'] = ret[1];ret['radius'] = ret[2];ret['angle.start'] = ret[3];ret['angle.end'] = ret[4];ret['index'] = ret[5];return ret;}
}
return null;}
RGraph.Pie.prototype.DrawBorders = function ()
{
if(this.Get('chart.linewidth') > 0){
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.beginPath();this.context.arc(this.angles[i][2],
this.angles[i][3],
this.radius,
(this.angles[i][0]),
(this.angles[i][0] + 0.001),
0);this.context.arc(this.angles[i][2],
this.angles[i][3],
this.Get('chart.variant') == 'donut' ? this.radius / 2: this.radius,
this.angles[i][0],
this.angles[i][0],
0);this.context.closePath();this.context.stroke();}
}
}
RGraph.Pie.prototype.getRadius = function ()
{
return Math.min(this.canvas.height - this.Get('chart.gutter.top') - this.Get('chart.gutter.bottom'), this.canvas.width - this.Get('chart.gutter.left') - this.Get('chart.gutter.right')) / 2;}
RGraph.Pie.prototype.Explode = function (index, size)
{
var obj = this;this.Set('chart.exploded', []);this.Get('chart.exploded')[index] = 0;for (var o=0; o<size; ++o){
setTimeout(
function ()
{
obj.Get('chart.exploded')[index] +=1;RGraph.Clear(obj.canvas);RGraph.Redraw()
}, o * (document.all ? 25 : 16.666));}
}
RGraph.Pie.prototype.highlight_segment = function (segment)
{
var context = this.context;context.beginPath();context.strokeStyle = this.Get('chart.highlight.style.2d.stroke');context.fillStyle = this.Get('chart.highlight.style.2d.fill');context.moveTo(segment[0], segment[1]);context.arc(segment[0], segment[1], segment[2], this.angles[segment[5]][0], this.angles[segment[5]][1], 0);context.lineTo(segment[0], segment[1]);context.closePath();context.stroke();context.fill();}
RGraph.Pie.prototype.Highlight = function (shape)
{
if(this.Get('chart.highlight.style') == 'explode'){
this.Explode(shape['index'], 25);var obj = this;setTimeout(function (){obj.Set('chart.exploded', []);}, document.all ? 1000 : 500);} else if(this.Get('chart.highlight.style') == '3d'){
this.context.lineWidth = 1;var extent = 2;this.context.beginPath();RGraph.NoShadow(this);this.context.fillStyle = 'rgba(0,0,0,0)';this.context.arc(shape['x'], shape['y'], shape['radius'], shape['angle.start'], shape['angle.end'], false);this.Get('chart.variant') == 'donut' ? this.context.arc(shape['x'], shape['y'], shape['radius'] / 2, shape['angle.start'], shape['angle.end'], true) : this.context.lineTo(shape['x'], shape['y']);this.context.closePath();this.context.fill();this.context.beginPath();this.context.shadowColor = '#666';this.context.shadowBlur = 3;this.context.shadowOffsetX = 3;this.context.shadowOffsetY = 3;this.context.fillStyle = this.Get('chart.colors')[shape['index']];this.context.strokeStyle = this.Get('chart.strokestyle');this.context.arc(shape['x'] - extent, shape['y'] - extent, shape['radius'], shape['angle.start'], shape['angle.end'], false);this.Get('chart.variant') == 'donut' ? this.context.arc(shape['x'] - extent, shape['y'] - extent, shape['radius'] / 2, shape['angle.start'], shape['angle.end'], true) : this.context.lineTo(shape['x'] - extent, shape['y'] - extent);this.context.closePath();this.context.stroke();this.context.fill();RGraph.NoShadow(this);if(this.Get('chart.border')){
this.context.beginPath();this.context.strokeStyle = obj.Get('chart.border.color');this.context.lineWidth = 5;this.context.arc(shape['x'] - extent, shape['y'] - extent, shape['radius'] - 2, shape['angle.start'], shape['angle.end'], false);this.context.stroke();}
} else {
this.context.beginPath();this.context.strokeStyle = this.Get('chart.highlight.style.2d.stroke');this.context.fillStyle = this.Get('chart.highlight.style.2d.fill');this.context.arc(shape['x'], shape['y'], shape['radius'], shape['angle.start'], shape['angle.end'], false);this.context.lineTo(shape['x'], shape['y']);this.context.closePath();this.context.stroke();this.context.fill();}
}
