2 * g.Raphael 0.5 - Charting library, based on Raphaƫl
4 * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com)
5 * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
7 Raphael = typeof(Raphael) != 'undefined' ? Raphael : (imports ? imports.seed.Raphael.Raphael : {});
8 Roo = typeof(Roo) != 'undefined' ? Roo: (imports ? imports.seed.Roo.Roo: {});
9 //chartinst = typeof(chartinst) != 'undefined' ? chartinst: (imports ? imports.chartinst.chartinst : {});
16 * @param {Raphael} paper to draw on
17 * @param {int} cx - centre X
18 * @param {int} cy - centre Y
19 * @param {int} r - radius
20 * @param {Array} values
21 * @param {Object} opts options
22 * cut : after this meany items - do not show a pie element?
28 function Piecircularchart(paper, width, height, cx, cy, r, values, opts) {
36 opts.linewidth = opts.linewidth || 200;
38 paper.rect(0, 0, width, height).attr({ stroke: "none", fill: (opts.background || "#F0F4F7") });
40 for (var i = 0; i < len; i++) {
44 valueOf: function () { return this.value; }
48 values.sort(function (a, b) {
49 return b.value - a.value;
56 for (i = 0; i < len; i++) {
58 paper.circle(dx, dy, dr).attr({ fill: opts.colors && opts.colors[i] || chartinst.colors[i] || "#3E66BC", stroke: "#fff", "stroke-width": 2 });
67 paper.text(nx, ny, Roo.util.Format.number(values[i], 0)).attr({
69 "font-family": "'Fontin Sans', Fontin-Sans, sans-serif",
70 "font-weight": "bold",
74 paper.path(["M", dx, dy - dr, "l", opts.linewidth, 0]).attr({ stroke: "#fff", "stroke-width": 2 });
75 paper.text(dx + opts.linewidth + 10, dy - dr, opts.legend[values[i].origin]).attr({
77 "font-family": "'Fontin Sans', Fontin-Sans, sans-serif",
78 "text-anchor": "start",
83 dr = Math.round(dr / 4);
94 var F = function() {};
95 F.prototype = Raphael.g;
96 Piecircularchart.prototype = new F;
99 Raphael.fn.piecircularchart = function(width, height, cx, cy, r, values, opts) {
100 return new Piecircularchart(this, width, height, cx, cy, r, values, opts);