//############################################################################## //# piechart.js # //############################################################################## //# YaBB: Yet another Bulletin Board # //# Open-Source Community Software for Webmasters # //# Version: YaBB 2.5 Anniversary Edition # //# Packaged: July 04, 2010 # //# Distributed by: http://www.yabbforum.com # //# ===========================================================================# //# Copyright (c) 2000-2010 YaBB (www.yabbforum.com) - All Rights Reserved. # //# Software by: The YaBB Development Team # //# with assistance from the YaBB community. # //# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com # //# Your source for web hosting, web design, and domains. # //############################################################################## //YaBB 2.5 AE $Revision: 1.3 $ function pieChart() { this.pie_array = new Array(); this.radius = 100; this.start_angle = 90; this.canvas_width = 660; this.color_style = '#000000'; this.use_legends = 0; var htm = ''; var color = '#000000'; var slice_color = new Array(); var itohex = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"]; function tohex(i) { a2 = '' ihex = Math.floor(eval(i +'/16')); idiff = eval(i + '-(' + ihex + '*16)') a2 = itohex[idiff] + a2; while( ihex >= 16) { itmp = Math.floor(eval(ihex +'/16')); idiff = eval(ihex + '-(' + itmp + '*16)'); a2 = itohex[idiff] + a2; ihex = itmp; } a1 = itohex[ihex]; return a1 + a2 ; } for (var tz = 0; tz < 256; tz += 63) for (var ty = 0; ty < 256; ty += 85) for (var tx = 0; tx < 256; tx += 127) slice_color.push('#' + tohex(tx) + tohex(ty) + tohex(tz)); this.sliceAdd = function() { if (this.pie_array.length < 1) return; var label_radius = this.radius + 20; if(this.use_legends == 1) { var canvas_height = (this.radius * 2) + 40; var centerx = label_radius; var label_width = this.canvas_width - (label_radius * 2); var leg_value = new Array(); var leg_label = new Array(); var leg_color = new Array(); for(var i = 0; i < this.pie_array.length; i++) { leg_vallabel = this.pie_array[i].split("|"); if(leg_vallabel[0] > 0) { leg_value.push(parseInt(leg_vallabel[0],10)); leg_label.push(leg_vallabel[1]); leg_color.push(leg_vallabel[2]); } } var legends_top = canvas_height - (leg_label.length * 16); } else { var canvas_height = (this.radius * 2) + 80; var centerx = this.canvas_width / 2; var label_width = (this.canvas_width - (label_radius * 2)) / 2; } var centery = (canvas_height / 2) - 5; var value = new Array(); var label = new Array(); var slicecolor = new Array(); var slicesplit = new Array(); var angle, ang_rads; var votes_tot = 0; this.pie_array.reverse(); for(var i = 0; i < this.pie_array.length; i++) { val_label = this.pie_array[i].split("|"); if(val_label[0] > 0) { value.push(parseInt(val_label[0],10)); votes_tot += parseInt(val_label[0],10); label.push(val_label[1]); slicecolor.push(val_label[2]); slicesplit.push(val_label[3]); } } htm += '