From cec3edef4be6b6af97cc0f5b9badaebb88b20841 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 25 Feb 2013 10:00:22 +0800 Subject: [PATCH] =?UTF-8?q?Dag=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/all.js | 413 ++++++++++++++++++++++-------------------- build/data_mofang.js | 11 +- build/data_shu.js | 11 +- build/datav.js | 413 ++++++++++++++++++++++-------------------- build/deps.js | 402 ++++++++++++++++++++-------------------- build/v5.js | 413 ++++++++++++++++++++++-------------------- deps/raphael.js | 402 ++++++++++++++++++++-------------------- example/dag/dag.html | 63 +++++++ lib/components/dag.js | 316 ++++++++++++++++++++++++++++++++ lib/datav.js | 11 +- 10 files changed, 1464 insertions(+), 991 deletions(-) create mode 100644 example/dag/dag.html create mode 100644 lib/components/dag.js diff --git a/build/all.js b/build/all.js index f2f6905..11d9d0f 100644 --- a/build/all.js +++ b/build/all.js @@ -7735,7 +7735,7 @@ if (!JSON) { current_event, stop, events = {n: {}}, - + eve = function (name, scope) { var e = events, oldstop = stop, @@ -7796,7 +7796,7 @@ if (!JSON) { current_event = ce; return out.length ? out : null; }; - + eve.listeners = function (name) { var names = name.split(separator), e = events, @@ -7828,8 +7828,8 @@ if (!JSON) { } return out; }; - - + + eve.on = function (name, f) { var names = name.split(separator), e = events; @@ -7849,19 +7849,19 @@ if (!JSON) { } }; }; - + eve.stop = function () { stop = 1; }; - + eve.nt = function (subname) { if (subname) { return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); } return current_event; }; - - + + eve.off = eve.unbind = function (name, f) { var names = name.split(separator), e, @@ -7914,7 +7914,7 @@ if (!JSON) { } } }; - + eve.once = function (name, f) { var f2 = function () { var res = f.apply(this, arguments); @@ -7923,7 +7923,7 @@ if (!JSON) { }; return eve.on(name, f2); }; - + eve.version = version; eve.toString = function () { return "You are running Eve " + version; @@ -7940,7 +7940,7 @@ if (!JSON) { // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // └─────────────────────────────────────────────────────────────────────┘ \\ (function () { - + function R(first) { if (R.is(first, "function")) { return loaded ? first() : eve.on("raphael.DOMload", first); @@ -7975,8 +7975,8 @@ if (!JSON) { is: g.win.Raphael }, Paper = function () { - - + + this.ca = this.customAttributes = {}; }, paperproto, @@ -8136,7 +8136,7 @@ if (!JSON) { return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); } }, - + mapPath = R.mapPath = function (path, matrix) { if (!matrix) { return path; @@ -8156,7 +8156,7 @@ if (!JSON) { }; R._g = g; - + R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); if (R.type == "VML") { var d = g.doc.createElement("div"), @@ -8169,15 +8169,15 @@ if (!JSON) { } d = null; } - - + + R.svg = !(R.vml = R.type == "VML"); R._Paper = Paper; - + R.fn = paperproto = Paper.prototype = R.prototype; R._id = 0; R._oid = 0; - + R.is = function (o, type) { type = lowerCase.call(type); if (type == "finite") { @@ -8203,7 +8203,7 @@ if (!JSON) { } return res; } - + R.angle = function (x1, y1, x2, y2, x3, y3) { if (x3 == null) { var x = x1 - x2, @@ -8216,15 +8216,15 @@ if (!JSON) { return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); } }; - + R.rad = function (deg) { return deg % 360 * PI / 180; }; - + R.deg = function (rad) { return rad * 180 / PI % 360; }; - + R.snapTo = function (values, value, tolerance) { tolerance = R.is(tolerance, "finite") ? tolerance : 10; if (R.is(values, array)) { @@ -8244,8 +8244,8 @@ if (!JSON) { } return value; }; - - + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { return function () { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); @@ -8256,7 +8256,7 @@ if (!JSON) { return v.toString(16); }); - + R.setWindow = function (newwin) { eve("raphael.setWindow", R, g.win, newwin); g.win = newwin; @@ -8327,7 +8327,7 @@ if (!JSON) { g /= 255; b /= 255; } - + return [r, g, b]; }, packageRGB = function (r, g, b, o) { @@ -8344,8 +8344,8 @@ if (!JSON) { R.is(o, "finite") && (rgb.opacity = o); return rgb; }; - - + + R.color = function (clr) { var rgb; if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { @@ -8379,7 +8379,7 @@ if (!JSON) { clr.toString = rgbtoString; return clr; }; - + R.hsb2rgb = function (h, s, v, o) { if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { v = h.b; @@ -8400,7 +8400,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.hsl2rgb = function (h, s, l, o) { if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { l = h.l; @@ -8425,7 +8425,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.rgb2hsb = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8444,7 +8444,7 @@ if (!JSON) { S = C == 0 ? 0 : C / V; return {h: H, s: S, b: V, toString: hsbtoString}; }; - + R.rgb2hsl = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8506,12 +8506,12 @@ if (!JSON) { g.doc.body.appendChild(img); img.src = src; }; - + function clrToString() { return this.hex; } - + R.getRGB = cacher(function (colour) { if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; @@ -8583,19 +8583,19 @@ if (!JSON) { } return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; }, R); - + R.hsb = cacher(function (h, s, b) { return R.hsb2rgb(h, s, b).hex; }); - + R.hsl = cacher(function (h, s, l) { return R.hsl2rgb(h, s, l).hex; }); - + R.rgb = cacher(function (r, g, b) { return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); }); - + R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, rgb = this.hsb2rgb(start.h, start.s, start.b); @@ -8607,7 +8607,7 @@ if (!JSON) { } return rgb.hex; }; - + R.getColor.reset = function () { delete this.start; }; @@ -8650,7 +8650,7 @@ if (!JSON) { return d; } - + R.parsePathString = function (pathString) { if (!pathString) { return null; @@ -8659,7 +8659,7 @@ if (!JSON) { if (pth.arr) { return pathClone(pth.arr); } - + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, data = []; if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption @@ -8691,7 +8691,7 @@ if (!JSON) { pth.arr = pathClone(data); return data; }; - + R.parseTransformString = cacher(function (TString) { if (!TString) { return null; @@ -8732,7 +8732,7 @@ if (!JSON) { }); return p[ps]; }; - + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t, t13 = pow(t1, 3), @@ -8761,7 +8761,7 @@ if (!JSON) { alpha: alpha }; }; - + R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!R.is(p1x, "array")) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; @@ -8776,11 +8776,11 @@ if (!JSON) { height: bbox.max.y - bbox.min.y }; }; - + R.isPointInsideBBox = function (bbox, x, y) { return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; }; - + R.isBBoxIntersect = function (bbox1, bbox2) { var i = R.isPointInsideBBox; return i(bbox2, bbox1.x, bbox1.y) @@ -8930,7 +8930,7 @@ if (!JSON) { } return res; } - + R.pathIntersection = function (path1, path2) { return interPathHelper(path1, path2); }; @@ -8990,7 +8990,7 @@ if (!JSON) { } return res; } - + R.isPointInsidePath = function (path, x, y) { var bbox = R.pathBBox(path); return R.isPointInsideBBox(bbox, x, y) && @@ -9001,7 +9001,7 @@ if (!JSON) { eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); }; }; - + var pathDimensions = R.pathBBox = function (path) { var pth = paths(path); if (pth.bbox) { @@ -9011,7 +9011,7 @@ if (!JSON) { return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; } path = path2curve(path); - var x = 0, + var x = 0, y = 0, X = [], Y = [], @@ -9559,7 +9559,7 @@ if (!JSON) { el2.prev = el; el.next = el2; }, - + toMatrix = R.toMatrix = function (path, transform) { var bb = pathDimensions(path), el = { @@ -9573,7 +9573,7 @@ if (!JSON) { extractTransform(el, transform); return el.matrix; }, - + transformPath = R.transformPath = function (path, transform) { return mapPath(path, toMatrix(path, transform)); }, @@ -9653,7 +9653,7 @@ if (!JSON) { } } - + el.matrix = m; _.sx = sx; @@ -9747,12 +9747,12 @@ if (!JSON) { height: h }; }; - + R.pathToRelative = pathToRelative; R._engine = {}; - + R.path2curve = path2curve; - + R.matrix = function (a, b, c, d, e, f) { return new Matrix(a, b, c, d, e, f); }; @@ -9774,7 +9774,7 @@ if (!JSON) { } } (function (matrixproto) { - + matrixproto.add = function (a, b, c, d, e, f) { var out = [[], [], []], m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], @@ -9801,28 +9801,28 @@ if (!JSON) { this.e = out[0][2]; this.f = out[1][2]; }; - + matrixproto.invert = function () { var me = this, x = me.a * me.d - me.b * me.c; return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); }; - + matrixproto.clone = function () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; - + matrixproto.translate = function (x, y) { this.add(1, 0, 0, 1, x, y); }; - + matrixproto.scale = function (x, y, cx, cy) { y == null && (y = x); (cx || cy) && this.add(1, 0, 0, 1, cx, cy); this.add(x, 0, 0, y, 0, 0); (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); }; - + matrixproto.rotate = function (a, x, y) { a = R.rad(a); x = x || 0; @@ -9832,11 +9832,11 @@ if (!JSON) { this.add(cos, sin, -sin, cos, x, y); this.add(1, 0, 0, 1, -x, -y); }; - + matrixproto.x = function (x, y) { return x * this.a + y * this.c + this.e; }; - + matrixproto.y = function (x, y) { return x * this.b + y * this.d + this.f; }; @@ -9864,7 +9864,7 @@ if (!JSON) { a[0] && (a[0] /= mag); a[1] && (a[1] /= mag); } - + matrixproto.split = function () { var out = {}; // translation @@ -9900,14 +9900,14 @@ if (!JSON) { out.noRotation = !+out.shear.toFixed(9) && !out.rotate; return out; }; - + matrixproto.toTransformString = function (shorter) { var s = shorter || this[split](); if (s.isSimple) { s.scalex = +s.scalex.toFixed(4); s.scaley = +s.scaley.toFixed(4); s.rotate = +s.rotate.toFixed(4); - return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + + return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + (s.rotate ? "r" + [s.rotate, 0, 0] : E); } else { @@ -9920,7 +9920,7 @@ if (!JSON) { var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || (navigator.vendor == "Google Inc." && version && version[1] < 8)) { - + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); setTimeout(function () {rect.remove();}); @@ -9928,7 +9928,7 @@ if (!JSON) { } else { paperproto.safari = fun; } - + var preventDefault = function () { this.returnValue = false; }, @@ -10043,40 +10043,40 @@ if (!JSON) { } drag = []; }, - + elproto = R.el = {}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { (function (eventName) { R[eventName] = elproto[eventName] = function (fn, scope) { @@ -10099,8 +10099,8 @@ if (!JSON) { }; })(events[i]); } - - + + elproto.data = function (key, value) { var data = eldata[this.id] = eldata[this.id] || {}; if (arguments.length == 1) { @@ -10117,7 +10117,7 @@ if (!JSON) { eve("raphael.data.set." + this.id, this, value, key); return this; }; - + elproto.removeData = function (key) { if (key == null) { eldata[this.id] = {}; @@ -10126,16 +10126,16 @@ if (!JSON) { } return this; }; - + elproto.hover = function (f_in, f_out, scope_in, scope_out) { return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); }; - + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; var draggable = []; - + elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { function start(e) { (e.originalEvent || e).preventDefault(); @@ -10156,11 +10156,11 @@ if (!JSON) { this.mousedown(start); return this; }; - + elproto.onDragOver = function (f) { f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); }; - + elproto.undrag = function () { var i = draggable.length; while (i--) if (draggable[i].el == this) { @@ -10170,72 +10170,72 @@ if (!JSON) { } !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); }; - + paperproto.circle = function (x, y, r) { var out = R._engine.circle(this, x || 0, y || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.rect = function (x, y, w, h, r) { var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.ellipse = function (x, y, rx, ry) { var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); var out = R._engine.path(R.format[apply](R, arguments), this); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.image = function (src, x, y, w, h) { var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.text = function (x, y, text) { var out = R._engine.text(this, x || 0, y || 0, Str(text)); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.set = function (itemsArray) { !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); var out = new Set(itemsArray); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.setStart = function (set) { this.__set__ = set || this.set(); }; - + paperproto.setFinish = function (set) { var out = this.__set__; delete this.__set__; return out; }; - + paperproto.setSize = function (width, height) { return R._engine.setSize.call(this, width, height); }; - + paperproto.setViewBox = function (x, y, w, h, fit) { return R._engine.setViewBox.call(this, x, y, w, h, fit); }; - - + + paperproto.top = paperproto.bottom = null; - + paperproto.raphael = R; var getOffset = function (elem) { var box = elem.getBoundingClientRect(), @@ -10250,7 +10250,7 @@ if (!JSON) { x: left }; }; - + paperproto.getElementByPoint = function (x, y) { var paper = this, svg = paper.canvas, @@ -10276,7 +10276,7 @@ if (!JSON) { target = target && target.raphael ? paper.getById(target.raphaelid) : null; return target; }; - + paperproto.getById = function (id) { var bot = this.bottom; while (bot) { @@ -10287,7 +10287,7 @@ if (!JSON) { } return null; }; - + paperproto.forEach = function (callback, thisArg) { var bot = this.bottom; while (bot) { @@ -10298,7 +10298,7 @@ if (!JSON) { } return this; }; - + paperproto.getElementsByPoint = function (x, y) { var set = this.set(); this.forEach(function (el) { @@ -10314,12 +10314,20 @@ if (!JSON) { function x_y_w_h() { return this.x + S + this.y + S + this.width + " \xd7 " + this.height; } - + elproto.isPointInside = function (x, y) { var rp = this.realPath = this.realPath || getPath[this.type](this); return R.isPointInsidePath(rp, x, y); }; - + + elproto.getMidpoint = function (isWithoutTransform) { + var bbox = this.getBBox(isWithoutTransform); + return { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + } + }; + elproto.getBBox = function (isWithoutTransform) { if (this.removed) { return {}; @@ -10345,7 +10353,7 @@ if (!JSON) { } return _.bbox; }; - + elproto.clone = function () { if (this.removed) { return null; @@ -10354,7 +10362,7 @@ if (!JSON) { this.__set__ && this.__set__.push(out); return out; }; - + elproto.glow = function (glow) { if (this.type == "text") { return null; @@ -10437,11 +10445,11 @@ if (!JSON) { var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - + R.getTotalLength = getTotalLength; - + R.getPointAtLength = getPointAtLength; - + R.getSubpath = function (path, from, to) { if (this.getTotalLength(path) - to < 1e-6) { return getSubpathsAtLength(path, from).end; @@ -10449,7 +10457,7 @@ if (!JSON) { var a = getSubpathsAtLength(path, to, 1); return from ? getSubpathsAtLength(a, from).end : a; }; - + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { @@ -10457,17 +10465,17 @@ if (!JSON) { } return getTotalLength(this.attrs.path); }; - + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; - + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} return R.getSubpath(this.attrs.path, from, to); }; - + var ef = R.easing_formulas = { linear: function (n) { return n; @@ -10668,7 +10676,7 @@ if (!JSON) { upto255 = function (color) { return color > 255 ? 255 : color < 0 ? 0 : color; }; - + elproto.animateWith = function (el, anim, params, ms, easing, callback) { var element = this; if (element.removed) { @@ -10685,8 +10693,8 @@ if (!JSON) { } } return element; - // - // + // + // // var a = params ? R.animation(params, ms, easing, callback) : anim, // status = element.status(anim); // return this.animate(a).status(a, status * anim.ms / a.ms); @@ -10763,15 +10771,15 @@ if (!JSON) { this.top = percents[percents.length - 1]; this.percents = percents; } - + Animation.prototype.delay = function (delay) { var a = new Animation(this.anim, this.ms); a.times = this.times; a.del = +delay || 0; return a; }; - - Animation.prototype.repeat = function (times) { + + Animation.prototype.repeat = function (times) { var a = new Animation(this.anim, this.ms); a.del = this.del; a.times = math.floor(mmax(times, 0)) || 1; @@ -10983,7 +10991,7 @@ if (!JSON) { } eve("raphael.anim.start." + element.id, element, anim); } - + R.animation = function (params, ms, easing, callback) { if (params instanceof Animation) { return params; @@ -11009,7 +11017,7 @@ if (!JSON) { return new Animation({100: p}, ms); } }; - + elproto.animate = function (params, ms, easing, callback) { var element = this; if (element.removed) { @@ -11020,14 +11028,14 @@ if (!JSON) { runAnimation(anim, element, anim.percents[0], null, element.attr()); return element; }; - + elproto.setTime = function (anim, value) { if (anim && value != null) { this.status(anim, mmin(value, anim.ms) / anim.ms); } return this; }; - + elproto.status = function (anim, value) { var out = [], i = 0, @@ -11056,7 +11064,7 @@ if (!JSON) { return out; } }; - + elproto.pause = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { @@ -11065,7 +11073,7 @@ if (!JSON) { } return this; }; - + elproto.resume = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { var e = animationElements[i]; @@ -11076,7 +11084,7 @@ if (!JSON) { } return this; }; - + elproto.stop = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { @@ -11111,7 +11119,7 @@ if (!JSON) { } }, setproto = Set.prototype; - + setproto.push = function () { var item, len; @@ -11125,12 +11133,12 @@ if (!JSON) { } return this; }; - + setproto.pop = function () { this.length && delete this[this.length--]; return this.items.pop(); }; - + setproto.forEach = function (callback, thisArg) { for (var i = 0, ii = this.items.length; i < ii; i++) { if (callback.call(thisArg, this.items[i], i) === false) { @@ -11161,13 +11169,13 @@ if (!JSON) { } return this; }; - + setproto.clear = function () { while (this.length) { this.pop(); } }; - + setproto.splice = function (index, count, insertion) { index = index < 0 ? mmax(this.length + index, 0) : index; count = mmax(0, mmin(this.length - index, count)); @@ -11194,7 +11202,7 @@ if (!JSON) { } return new Set(todel); }; - + setproto.exclude = function (el) { for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { this.splice(i, 1); @@ -11265,7 +11273,7 @@ if (!JSON) { return "Rapha\xebl\u2018s set"; }; - + R.registerFont = function (font) { if (!font.face) { return font; @@ -11305,7 +11313,7 @@ if (!JSON) { } return font; }; - + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; @@ -11334,7 +11342,7 @@ if (!JSON) { } return thefont; }; - + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); @@ -11374,7 +11382,7 @@ if (!JSON) { }); }; - + paperproto.add = function (json) { if (R.is(json, "array")) { var res = this.set(), @@ -11389,7 +11397,7 @@ if (!JSON) { return res; }; - + R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { @@ -11397,7 +11405,7 @@ if (!JSON) { })); return token || E; }; - + R.fullfill = (function () { var tokenRegex = /\{([^\}]+)\}/g, objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties @@ -11421,12 +11429,12 @@ if (!JSON) { }); }; })(); - + R.ninja = function () { oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - + R.st = setproto; // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html (function (doc, loaded, f) { @@ -11444,7 +11452,7 @@ if (!JSON) { })(document, "DOMContentLoaded"); oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); - + eve.on("raphael.DOMload", function () { loaded = true; }); @@ -11550,7 +11558,7 @@ window.Raphael.svg && function (R) { return null; } id = id.replace(/[\(\)\s,\xb0#]/g, "_"); - + if (element.gradient && id != element.gradient.id) { SVG.defs.removeChild(element.gradient); delete element.gradient; @@ -12047,16 +12055,16 @@ window.Raphael.svg && function (R) { Element = function (node, svg) { var X = 0, Y = 0; - + this[0] = this.node = node; - + node.raphael = true; - + this.id = R._oid++; node.raphaelid = this.id; this.matrix = R.matrix(); this.realPath = null; - + this.paper = svg; this.attrs = this.attrs || {}; this._ = { @@ -12069,11 +12077,11 @@ window.Raphael.svg && function (R) { dirty: 1 }; !svg.bottom && (svg.bottom = this); - + this.prev = svg.top; svg.top && (svg.top.next = this); svg.top = this; - + this.next = null; }, elproto = R.el; @@ -12093,7 +12101,7 @@ window.Raphael.svg && function (R) { }); return p; }; - + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -12113,7 +12121,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["r", deg, cx, cy]])); return this; }; - + elproto.scale = function (sx, sy, cx, cy) { if (this.removed) { return this; @@ -12135,7 +12143,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); return this; }; - + elproto.translate = function (dx, dy) { if (this.removed) { return this; @@ -12149,7 +12157,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["t", dx, dy]])); return this; }; - + elproto.transform = function (tstr) { var _ = this._; if (tstr == null) { @@ -12160,7 +12168,7 @@ window.Raphael.svg && function (R) { this.clip && $(this.clip, {transform: this.matrix.invert()}); this.pattern && updatePosition(this); this.node && $(this.node, {transform: this.matrix}); - + if (_.sx != 1 || _.sy != 1) { var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; this.attr({"stroke-width": sw}); @@ -12168,17 +12176,17 @@ window.Raphael.svg && function (R) { return this; }; - + elproto.hide = function () { !this.removed && this.paper.safari(this.node.style.display = "none"); return this; }; - + elproto.show = function () { !this.removed && this.paper.safari(this.node.style.display = ""); return this; }; - + elproto.remove = function () { if (this.removed || !this.node.parentNode) { return; @@ -12216,7 +12224,7 @@ window.Raphael.svg && function (R) { hide && this.hide(); return bbox; }; - + elproto.attr = function (name, value) { if (this.removed) { return this; @@ -12277,7 +12285,7 @@ window.Raphael.svg && function (R) { setFillAndStroke(this, params); return this; }; - + elproto.toFront = function () { if (this.removed) { return this; @@ -12291,14 +12299,14 @@ window.Raphael.svg && function (R) { svg.top != this && R._tofront(this, svg); return this; }; - + elproto.toBack = function () { if (this.removed) { return this; } var parent = this.node.parentNode; if (parent.tagName.toLowerCase() == "a") { - parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); + parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); } else if (parent.firstChild != this.node) { parent.insertBefore(this.node, this.node.parentNode.firstChild); } @@ -12306,7 +12314,7 @@ window.Raphael.svg && function (R) { var svg = this.paper; return this; }; - + elproto.insertAfter = function (element) { if (this.removed) { return this; @@ -12320,7 +12328,7 @@ window.Raphael.svg && function (R) { R._insertafter(this, element, this.paper); return this; }; - + elproto.insertBefore = function (element) { if (this.removed) { return this; @@ -12492,7 +12500,7 @@ window.Raphael.svg && function (R) { this._viewBox = [x, y, w, h, !!fit]; return this; }; - + R.prototype.renderfix = function () { var cnvs = this.canvas, s = cnvs.style, @@ -12515,7 +12523,7 @@ window.Raphael.svg && function (R) { } } }; - + R.prototype.clear = function () { R.eve("raphael.clear", this); var c = this.canvas; @@ -12527,7 +12535,7 @@ window.Raphael.svg && function (R) { c.appendChild(this.desc); c.appendChild(this.defs = $("defs")); }; - + R.prototype.remove = function () { eve("raphael.remove", this); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); @@ -12771,7 +12779,7 @@ window.Raphael.vml && function (R) { if ("arrow-end" in params) { addArrow(res, params["arrow-end"], 1); } - if (params.opacity != null || + if (params.opacity != null || params["stroke-width"] != null || params.fill != null || params.src != null || @@ -12850,7 +12858,7 @@ window.Raphael.vml && function (R) { params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); stroke.opacity = opacity; - + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); stroke.miterlimit = params["stroke-miterlimit"] || 8; params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); @@ -12897,7 +12905,7 @@ window.Raphael.vml && function (R) { res._.dirty = 1; break; } - + // text-anchor emulation switch (a["text-anchor"]) { case "start": @@ -13025,7 +13033,7 @@ window.Raphael.vml && function (R) { trsfrm = vbt; } R._extractTransform(this, trsfrm); - + var matrix = this.matrix.clone(), skew = this.skew, o = this.node, @@ -13118,7 +13126,7 @@ window.Raphael.vml && function (R) { } cx = cx == null ? bbox.x + bbox.width / 2 : cx; cy = cy == null ? bbox.y + bbox.height / 2 : cy; - + this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); this._.dirtyT = 1; return this; @@ -24684,7 +24692,7 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -25007,6 +25015,15 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */ diff --git a/build/data_mofang.js b/build/data_mofang.js index 6651a86..568789c 100644 --- a/build/data_mofang.js +++ b/build/data_mofang.js @@ -8382,7 +8382,7 @@ if (!JSON) { dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -8705,6 +8705,15 @@ if (!JSON) { return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */ diff --git a/build/data_shu.js b/build/data_shu.js index 9dfbb45..cacce92 100644 --- a/build/data_shu.js +++ b/build/data_shu.js @@ -7941,7 +7941,7 @@ if (!JSON) { dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -8264,6 +8264,15 @@ if (!JSON) { return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */ diff --git a/build/datav.js b/build/datav.js index 7fb4e5f..23ec146 100644 --- a/build/datav.js +++ b/build/datav.js @@ -7735,7 +7735,7 @@ if (!JSON) { current_event, stop, events = {n: {}}, - + eve = function (name, scope) { var e = events, oldstop = stop, @@ -7796,7 +7796,7 @@ if (!JSON) { current_event = ce; return out.length ? out : null; }; - + eve.listeners = function (name) { var names = name.split(separator), e = events, @@ -7828,8 +7828,8 @@ if (!JSON) { } return out; }; - - + + eve.on = function (name, f) { var names = name.split(separator), e = events; @@ -7849,19 +7849,19 @@ if (!JSON) { } }; }; - + eve.stop = function () { stop = 1; }; - + eve.nt = function (subname) { if (subname) { return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); } return current_event; }; - - + + eve.off = eve.unbind = function (name, f) { var names = name.split(separator), e, @@ -7914,7 +7914,7 @@ if (!JSON) { } } }; - + eve.once = function (name, f) { var f2 = function () { var res = f.apply(this, arguments); @@ -7923,7 +7923,7 @@ if (!JSON) { }; return eve.on(name, f2); }; - + eve.version = version; eve.toString = function () { return "You are running Eve " + version; @@ -7940,7 +7940,7 @@ if (!JSON) { // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // └─────────────────────────────────────────────────────────────────────┘ \\ (function () { - + function R(first) { if (R.is(first, "function")) { return loaded ? first() : eve.on("raphael.DOMload", first); @@ -7975,8 +7975,8 @@ if (!JSON) { is: g.win.Raphael }, Paper = function () { - - + + this.ca = this.customAttributes = {}; }, paperproto, @@ -8136,7 +8136,7 @@ if (!JSON) { return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); } }, - + mapPath = R.mapPath = function (path, matrix) { if (!matrix) { return path; @@ -8156,7 +8156,7 @@ if (!JSON) { }; R._g = g; - + R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); if (R.type == "VML") { var d = g.doc.createElement("div"), @@ -8169,15 +8169,15 @@ if (!JSON) { } d = null; } - - + + R.svg = !(R.vml = R.type == "VML"); R._Paper = Paper; - + R.fn = paperproto = Paper.prototype = R.prototype; R._id = 0; R._oid = 0; - + R.is = function (o, type) { type = lowerCase.call(type); if (type == "finite") { @@ -8203,7 +8203,7 @@ if (!JSON) { } return res; } - + R.angle = function (x1, y1, x2, y2, x3, y3) { if (x3 == null) { var x = x1 - x2, @@ -8216,15 +8216,15 @@ if (!JSON) { return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); } }; - + R.rad = function (deg) { return deg % 360 * PI / 180; }; - + R.deg = function (rad) { return rad * 180 / PI % 360; }; - + R.snapTo = function (values, value, tolerance) { tolerance = R.is(tolerance, "finite") ? tolerance : 10; if (R.is(values, array)) { @@ -8244,8 +8244,8 @@ if (!JSON) { } return value; }; - - + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { return function () { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); @@ -8256,7 +8256,7 @@ if (!JSON) { return v.toString(16); }); - + R.setWindow = function (newwin) { eve("raphael.setWindow", R, g.win, newwin); g.win = newwin; @@ -8327,7 +8327,7 @@ if (!JSON) { g /= 255; b /= 255; } - + return [r, g, b]; }, packageRGB = function (r, g, b, o) { @@ -8344,8 +8344,8 @@ if (!JSON) { R.is(o, "finite") && (rgb.opacity = o); return rgb; }; - - + + R.color = function (clr) { var rgb; if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { @@ -8379,7 +8379,7 @@ if (!JSON) { clr.toString = rgbtoString; return clr; }; - + R.hsb2rgb = function (h, s, v, o) { if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { v = h.b; @@ -8400,7 +8400,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.hsl2rgb = function (h, s, l, o) { if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { l = h.l; @@ -8425,7 +8425,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.rgb2hsb = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8444,7 +8444,7 @@ if (!JSON) { S = C == 0 ? 0 : C / V; return {h: H, s: S, b: V, toString: hsbtoString}; }; - + R.rgb2hsl = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8506,12 +8506,12 @@ if (!JSON) { g.doc.body.appendChild(img); img.src = src; }; - + function clrToString() { return this.hex; } - + R.getRGB = cacher(function (colour) { if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; @@ -8583,19 +8583,19 @@ if (!JSON) { } return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; }, R); - + R.hsb = cacher(function (h, s, b) { return R.hsb2rgb(h, s, b).hex; }); - + R.hsl = cacher(function (h, s, l) { return R.hsl2rgb(h, s, l).hex; }); - + R.rgb = cacher(function (r, g, b) { return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); }); - + R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, rgb = this.hsb2rgb(start.h, start.s, start.b); @@ -8607,7 +8607,7 @@ if (!JSON) { } return rgb.hex; }; - + R.getColor.reset = function () { delete this.start; }; @@ -8650,7 +8650,7 @@ if (!JSON) { return d; } - + R.parsePathString = function (pathString) { if (!pathString) { return null; @@ -8659,7 +8659,7 @@ if (!JSON) { if (pth.arr) { return pathClone(pth.arr); } - + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, data = []; if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption @@ -8691,7 +8691,7 @@ if (!JSON) { pth.arr = pathClone(data); return data; }; - + R.parseTransformString = cacher(function (TString) { if (!TString) { return null; @@ -8732,7 +8732,7 @@ if (!JSON) { }); return p[ps]; }; - + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t, t13 = pow(t1, 3), @@ -8761,7 +8761,7 @@ if (!JSON) { alpha: alpha }; }; - + R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!R.is(p1x, "array")) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; @@ -8776,11 +8776,11 @@ if (!JSON) { height: bbox.max.y - bbox.min.y }; }; - + R.isPointInsideBBox = function (bbox, x, y) { return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; }; - + R.isBBoxIntersect = function (bbox1, bbox2) { var i = R.isPointInsideBBox; return i(bbox2, bbox1.x, bbox1.y) @@ -8930,7 +8930,7 @@ if (!JSON) { } return res; } - + R.pathIntersection = function (path1, path2) { return interPathHelper(path1, path2); }; @@ -8990,7 +8990,7 @@ if (!JSON) { } return res; } - + R.isPointInsidePath = function (path, x, y) { var bbox = R.pathBBox(path); return R.isPointInsideBBox(bbox, x, y) && @@ -9001,7 +9001,7 @@ if (!JSON) { eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); }; }; - + var pathDimensions = R.pathBBox = function (path) { var pth = paths(path); if (pth.bbox) { @@ -9011,7 +9011,7 @@ if (!JSON) { return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; } path = path2curve(path); - var x = 0, + var x = 0, y = 0, X = [], Y = [], @@ -9559,7 +9559,7 @@ if (!JSON) { el2.prev = el; el.next = el2; }, - + toMatrix = R.toMatrix = function (path, transform) { var bb = pathDimensions(path), el = { @@ -9573,7 +9573,7 @@ if (!JSON) { extractTransform(el, transform); return el.matrix; }, - + transformPath = R.transformPath = function (path, transform) { return mapPath(path, toMatrix(path, transform)); }, @@ -9653,7 +9653,7 @@ if (!JSON) { } } - + el.matrix = m; _.sx = sx; @@ -9747,12 +9747,12 @@ if (!JSON) { height: h }; }; - + R.pathToRelative = pathToRelative; R._engine = {}; - + R.path2curve = path2curve; - + R.matrix = function (a, b, c, d, e, f) { return new Matrix(a, b, c, d, e, f); }; @@ -9774,7 +9774,7 @@ if (!JSON) { } } (function (matrixproto) { - + matrixproto.add = function (a, b, c, d, e, f) { var out = [[], [], []], m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], @@ -9801,28 +9801,28 @@ if (!JSON) { this.e = out[0][2]; this.f = out[1][2]; }; - + matrixproto.invert = function () { var me = this, x = me.a * me.d - me.b * me.c; return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); }; - + matrixproto.clone = function () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; - + matrixproto.translate = function (x, y) { this.add(1, 0, 0, 1, x, y); }; - + matrixproto.scale = function (x, y, cx, cy) { y == null && (y = x); (cx || cy) && this.add(1, 0, 0, 1, cx, cy); this.add(x, 0, 0, y, 0, 0); (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); }; - + matrixproto.rotate = function (a, x, y) { a = R.rad(a); x = x || 0; @@ -9832,11 +9832,11 @@ if (!JSON) { this.add(cos, sin, -sin, cos, x, y); this.add(1, 0, 0, 1, -x, -y); }; - + matrixproto.x = function (x, y) { return x * this.a + y * this.c + this.e; }; - + matrixproto.y = function (x, y) { return x * this.b + y * this.d + this.f; }; @@ -9864,7 +9864,7 @@ if (!JSON) { a[0] && (a[0] /= mag); a[1] && (a[1] /= mag); } - + matrixproto.split = function () { var out = {}; // translation @@ -9900,14 +9900,14 @@ if (!JSON) { out.noRotation = !+out.shear.toFixed(9) && !out.rotate; return out; }; - + matrixproto.toTransformString = function (shorter) { var s = shorter || this[split](); if (s.isSimple) { s.scalex = +s.scalex.toFixed(4); s.scaley = +s.scaley.toFixed(4); s.rotate = +s.rotate.toFixed(4); - return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + + return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + (s.rotate ? "r" + [s.rotate, 0, 0] : E); } else { @@ -9920,7 +9920,7 @@ if (!JSON) { var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || (navigator.vendor == "Google Inc." && version && version[1] < 8)) { - + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); setTimeout(function () {rect.remove();}); @@ -9928,7 +9928,7 @@ if (!JSON) { } else { paperproto.safari = fun; } - + var preventDefault = function () { this.returnValue = false; }, @@ -10043,40 +10043,40 @@ if (!JSON) { } drag = []; }, - + elproto = R.el = {}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { (function (eventName) { R[eventName] = elproto[eventName] = function (fn, scope) { @@ -10099,8 +10099,8 @@ if (!JSON) { }; })(events[i]); } - - + + elproto.data = function (key, value) { var data = eldata[this.id] = eldata[this.id] || {}; if (arguments.length == 1) { @@ -10117,7 +10117,7 @@ if (!JSON) { eve("raphael.data.set." + this.id, this, value, key); return this; }; - + elproto.removeData = function (key) { if (key == null) { eldata[this.id] = {}; @@ -10126,16 +10126,16 @@ if (!JSON) { } return this; }; - + elproto.hover = function (f_in, f_out, scope_in, scope_out) { return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); }; - + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; var draggable = []; - + elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { function start(e) { (e.originalEvent || e).preventDefault(); @@ -10156,11 +10156,11 @@ if (!JSON) { this.mousedown(start); return this; }; - + elproto.onDragOver = function (f) { f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); }; - + elproto.undrag = function () { var i = draggable.length; while (i--) if (draggable[i].el == this) { @@ -10170,72 +10170,72 @@ if (!JSON) { } !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); }; - + paperproto.circle = function (x, y, r) { var out = R._engine.circle(this, x || 0, y || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.rect = function (x, y, w, h, r) { var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.ellipse = function (x, y, rx, ry) { var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); var out = R._engine.path(R.format[apply](R, arguments), this); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.image = function (src, x, y, w, h) { var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.text = function (x, y, text) { var out = R._engine.text(this, x || 0, y || 0, Str(text)); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.set = function (itemsArray) { !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); var out = new Set(itemsArray); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.setStart = function (set) { this.__set__ = set || this.set(); }; - + paperproto.setFinish = function (set) { var out = this.__set__; delete this.__set__; return out; }; - + paperproto.setSize = function (width, height) { return R._engine.setSize.call(this, width, height); }; - + paperproto.setViewBox = function (x, y, w, h, fit) { return R._engine.setViewBox.call(this, x, y, w, h, fit); }; - - + + paperproto.top = paperproto.bottom = null; - + paperproto.raphael = R; var getOffset = function (elem) { var box = elem.getBoundingClientRect(), @@ -10250,7 +10250,7 @@ if (!JSON) { x: left }; }; - + paperproto.getElementByPoint = function (x, y) { var paper = this, svg = paper.canvas, @@ -10276,7 +10276,7 @@ if (!JSON) { target = target && target.raphael ? paper.getById(target.raphaelid) : null; return target; }; - + paperproto.getById = function (id) { var bot = this.bottom; while (bot) { @@ -10287,7 +10287,7 @@ if (!JSON) { } return null; }; - + paperproto.forEach = function (callback, thisArg) { var bot = this.bottom; while (bot) { @@ -10298,7 +10298,7 @@ if (!JSON) { } return this; }; - + paperproto.getElementsByPoint = function (x, y) { var set = this.set(); this.forEach(function (el) { @@ -10314,12 +10314,20 @@ if (!JSON) { function x_y_w_h() { return this.x + S + this.y + S + this.width + " \xd7 " + this.height; } - + elproto.isPointInside = function (x, y) { var rp = this.realPath = this.realPath || getPath[this.type](this); return R.isPointInsidePath(rp, x, y); }; - + + elproto.getMidpoint = function (isWithoutTransform) { + var bbox = this.getBBox(isWithoutTransform); + return { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + } + }; + elproto.getBBox = function (isWithoutTransform) { if (this.removed) { return {}; @@ -10345,7 +10353,7 @@ if (!JSON) { } return _.bbox; }; - + elproto.clone = function () { if (this.removed) { return null; @@ -10354,7 +10362,7 @@ if (!JSON) { this.__set__ && this.__set__.push(out); return out; }; - + elproto.glow = function (glow) { if (this.type == "text") { return null; @@ -10437,11 +10445,11 @@ if (!JSON) { var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - + R.getTotalLength = getTotalLength; - + R.getPointAtLength = getPointAtLength; - + R.getSubpath = function (path, from, to) { if (this.getTotalLength(path) - to < 1e-6) { return getSubpathsAtLength(path, from).end; @@ -10449,7 +10457,7 @@ if (!JSON) { var a = getSubpathsAtLength(path, to, 1); return from ? getSubpathsAtLength(a, from).end : a; }; - + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { @@ -10457,17 +10465,17 @@ if (!JSON) { } return getTotalLength(this.attrs.path); }; - + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; - + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} return R.getSubpath(this.attrs.path, from, to); }; - + var ef = R.easing_formulas = { linear: function (n) { return n; @@ -10668,7 +10676,7 @@ if (!JSON) { upto255 = function (color) { return color > 255 ? 255 : color < 0 ? 0 : color; }; - + elproto.animateWith = function (el, anim, params, ms, easing, callback) { var element = this; if (element.removed) { @@ -10685,8 +10693,8 @@ if (!JSON) { } } return element; - // - // + // + // // var a = params ? R.animation(params, ms, easing, callback) : anim, // status = element.status(anim); // return this.animate(a).status(a, status * anim.ms / a.ms); @@ -10763,15 +10771,15 @@ if (!JSON) { this.top = percents[percents.length - 1]; this.percents = percents; } - + Animation.prototype.delay = function (delay) { var a = new Animation(this.anim, this.ms); a.times = this.times; a.del = +delay || 0; return a; }; - - Animation.prototype.repeat = function (times) { + + Animation.prototype.repeat = function (times) { var a = new Animation(this.anim, this.ms); a.del = this.del; a.times = math.floor(mmax(times, 0)) || 1; @@ -10983,7 +10991,7 @@ if (!JSON) { } eve("raphael.anim.start." + element.id, element, anim); } - + R.animation = function (params, ms, easing, callback) { if (params instanceof Animation) { return params; @@ -11009,7 +11017,7 @@ if (!JSON) { return new Animation({100: p}, ms); } }; - + elproto.animate = function (params, ms, easing, callback) { var element = this; if (element.removed) { @@ -11020,14 +11028,14 @@ if (!JSON) { runAnimation(anim, element, anim.percents[0], null, element.attr()); return element; }; - + elproto.setTime = function (anim, value) { if (anim && value != null) { this.status(anim, mmin(value, anim.ms) / anim.ms); } return this; }; - + elproto.status = function (anim, value) { var out = [], i = 0, @@ -11056,7 +11064,7 @@ if (!JSON) { return out; } }; - + elproto.pause = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { @@ -11065,7 +11073,7 @@ if (!JSON) { } return this; }; - + elproto.resume = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { var e = animationElements[i]; @@ -11076,7 +11084,7 @@ if (!JSON) { } return this; }; - + elproto.stop = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { @@ -11111,7 +11119,7 @@ if (!JSON) { } }, setproto = Set.prototype; - + setproto.push = function () { var item, len; @@ -11125,12 +11133,12 @@ if (!JSON) { } return this; }; - + setproto.pop = function () { this.length && delete this[this.length--]; return this.items.pop(); }; - + setproto.forEach = function (callback, thisArg) { for (var i = 0, ii = this.items.length; i < ii; i++) { if (callback.call(thisArg, this.items[i], i) === false) { @@ -11161,13 +11169,13 @@ if (!JSON) { } return this; }; - + setproto.clear = function () { while (this.length) { this.pop(); } }; - + setproto.splice = function (index, count, insertion) { index = index < 0 ? mmax(this.length + index, 0) : index; count = mmax(0, mmin(this.length - index, count)); @@ -11194,7 +11202,7 @@ if (!JSON) { } return new Set(todel); }; - + setproto.exclude = function (el) { for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { this.splice(i, 1); @@ -11265,7 +11273,7 @@ if (!JSON) { return "Rapha\xebl\u2018s set"; }; - + R.registerFont = function (font) { if (!font.face) { return font; @@ -11305,7 +11313,7 @@ if (!JSON) { } return font; }; - + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; @@ -11334,7 +11342,7 @@ if (!JSON) { } return thefont; }; - + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); @@ -11374,7 +11382,7 @@ if (!JSON) { }); }; - + paperproto.add = function (json) { if (R.is(json, "array")) { var res = this.set(), @@ -11389,7 +11397,7 @@ if (!JSON) { return res; }; - + R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { @@ -11397,7 +11405,7 @@ if (!JSON) { })); return token || E; }; - + R.fullfill = (function () { var tokenRegex = /\{([^\}]+)\}/g, objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties @@ -11421,12 +11429,12 @@ if (!JSON) { }); }; })(); - + R.ninja = function () { oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - + R.st = setproto; // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html (function (doc, loaded, f) { @@ -11444,7 +11452,7 @@ if (!JSON) { })(document, "DOMContentLoaded"); oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); - + eve.on("raphael.DOMload", function () { loaded = true; }); @@ -11550,7 +11558,7 @@ window.Raphael.svg && function (R) { return null; } id = id.replace(/[\(\)\s,\xb0#]/g, "_"); - + if (element.gradient && id != element.gradient.id) { SVG.defs.removeChild(element.gradient); delete element.gradient; @@ -12047,16 +12055,16 @@ window.Raphael.svg && function (R) { Element = function (node, svg) { var X = 0, Y = 0; - + this[0] = this.node = node; - + node.raphael = true; - + this.id = R._oid++; node.raphaelid = this.id; this.matrix = R.matrix(); this.realPath = null; - + this.paper = svg; this.attrs = this.attrs || {}; this._ = { @@ -12069,11 +12077,11 @@ window.Raphael.svg && function (R) { dirty: 1 }; !svg.bottom && (svg.bottom = this); - + this.prev = svg.top; svg.top && (svg.top.next = this); svg.top = this; - + this.next = null; }, elproto = R.el; @@ -12093,7 +12101,7 @@ window.Raphael.svg && function (R) { }); return p; }; - + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -12113,7 +12121,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["r", deg, cx, cy]])); return this; }; - + elproto.scale = function (sx, sy, cx, cy) { if (this.removed) { return this; @@ -12135,7 +12143,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); return this; }; - + elproto.translate = function (dx, dy) { if (this.removed) { return this; @@ -12149,7 +12157,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["t", dx, dy]])); return this; }; - + elproto.transform = function (tstr) { var _ = this._; if (tstr == null) { @@ -12160,7 +12168,7 @@ window.Raphael.svg && function (R) { this.clip && $(this.clip, {transform: this.matrix.invert()}); this.pattern && updatePosition(this); this.node && $(this.node, {transform: this.matrix}); - + if (_.sx != 1 || _.sy != 1) { var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; this.attr({"stroke-width": sw}); @@ -12168,17 +12176,17 @@ window.Raphael.svg && function (R) { return this; }; - + elproto.hide = function () { !this.removed && this.paper.safari(this.node.style.display = "none"); return this; }; - + elproto.show = function () { !this.removed && this.paper.safari(this.node.style.display = ""); return this; }; - + elproto.remove = function () { if (this.removed || !this.node.parentNode) { return; @@ -12216,7 +12224,7 @@ window.Raphael.svg && function (R) { hide && this.hide(); return bbox; }; - + elproto.attr = function (name, value) { if (this.removed) { return this; @@ -12277,7 +12285,7 @@ window.Raphael.svg && function (R) { setFillAndStroke(this, params); return this; }; - + elproto.toFront = function () { if (this.removed) { return this; @@ -12291,14 +12299,14 @@ window.Raphael.svg && function (R) { svg.top != this && R._tofront(this, svg); return this; }; - + elproto.toBack = function () { if (this.removed) { return this; } var parent = this.node.parentNode; if (parent.tagName.toLowerCase() == "a") { - parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); + parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); } else if (parent.firstChild != this.node) { parent.insertBefore(this.node, this.node.parentNode.firstChild); } @@ -12306,7 +12314,7 @@ window.Raphael.svg && function (R) { var svg = this.paper; return this; }; - + elproto.insertAfter = function (element) { if (this.removed) { return this; @@ -12320,7 +12328,7 @@ window.Raphael.svg && function (R) { R._insertafter(this, element, this.paper); return this; }; - + elproto.insertBefore = function (element) { if (this.removed) { return this; @@ -12492,7 +12500,7 @@ window.Raphael.svg && function (R) { this._viewBox = [x, y, w, h, !!fit]; return this; }; - + R.prototype.renderfix = function () { var cnvs = this.canvas, s = cnvs.style, @@ -12515,7 +12523,7 @@ window.Raphael.svg && function (R) { } } }; - + R.prototype.clear = function () { R.eve("raphael.clear", this); var c = this.canvas; @@ -12527,7 +12535,7 @@ window.Raphael.svg && function (R) { c.appendChild(this.desc); c.appendChild(this.defs = $("defs")); }; - + R.prototype.remove = function () { eve("raphael.remove", this); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); @@ -12771,7 +12779,7 @@ window.Raphael.vml && function (R) { if ("arrow-end" in params) { addArrow(res, params["arrow-end"], 1); } - if (params.opacity != null || + if (params.opacity != null || params["stroke-width"] != null || params.fill != null || params.src != null || @@ -12850,7 +12858,7 @@ window.Raphael.vml && function (R) { params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); stroke.opacity = opacity; - + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); stroke.miterlimit = params["stroke-miterlimit"] || 8; params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); @@ -12897,7 +12905,7 @@ window.Raphael.vml && function (R) { res._.dirty = 1; break; } - + // text-anchor emulation switch (a["text-anchor"]) { case "start": @@ -13025,7 +13033,7 @@ window.Raphael.vml && function (R) { trsfrm = vbt; } R._extractTransform(this, trsfrm); - + var matrix = this.matrix.clone(), skew = this.skew, o = this.node, @@ -13118,7 +13126,7 @@ window.Raphael.vml && function (R) { } cx = cx == null ? bbox.x + bbox.width / 2 : cx; cy = cy == null ? bbox.y + bbox.height / 2 : cy; - + this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); this._.dirtyT = 1; return this; @@ -24684,7 +24692,7 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -25007,6 +25015,15 @@ if ( typeof define === "function" && define.amd && define.amd.jQuery ) { return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */ diff --git a/build/deps.js b/build/deps.js index 8437659..2024368 100644 --- a/build/deps.js +++ b/build/deps.js @@ -7735,7 +7735,7 @@ if (!JSON) { current_event, stop, events = {n: {}}, - + eve = function (name, scope) { var e = events, oldstop = stop, @@ -7796,7 +7796,7 @@ if (!JSON) { current_event = ce; return out.length ? out : null; }; - + eve.listeners = function (name) { var names = name.split(separator), e = events, @@ -7828,8 +7828,8 @@ if (!JSON) { } return out; }; - - + + eve.on = function (name, f) { var names = name.split(separator), e = events; @@ -7849,19 +7849,19 @@ if (!JSON) { } }; }; - + eve.stop = function () { stop = 1; }; - + eve.nt = function (subname) { if (subname) { return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); } return current_event; }; - - + + eve.off = eve.unbind = function (name, f) { var names = name.split(separator), e, @@ -7914,7 +7914,7 @@ if (!JSON) { } } }; - + eve.once = function (name, f) { var f2 = function () { var res = f.apply(this, arguments); @@ -7923,7 +7923,7 @@ if (!JSON) { }; return eve.on(name, f2); }; - + eve.version = version; eve.toString = function () { return "You are running Eve " + version; @@ -7940,7 +7940,7 @@ if (!JSON) { // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // └─────────────────────────────────────────────────────────────────────┘ \\ (function () { - + function R(first) { if (R.is(first, "function")) { return loaded ? first() : eve.on("raphael.DOMload", first); @@ -7975,8 +7975,8 @@ if (!JSON) { is: g.win.Raphael }, Paper = function () { - - + + this.ca = this.customAttributes = {}; }, paperproto, @@ -8136,7 +8136,7 @@ if (!JSON) { return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); } }, - + mapPath = R.mapPath = function (path, matrix) { if (!matrix) { return path; @@ -8156,7 +8156,7 @@ if (!JSON) { }; R._g = g; - + R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); if (R.type == "VML") { var d = g.doc.createElement("div"), @@ -8169,15 +8169,15 @@ if (!JSON) { } d = null; } - - + + R.svg = !(R.vml = R.type == "VML"); R._Paper = Paper; - + R.fn = paperproto = Paper.prototype = R.prototype; R._id = 0; R._oid = 0; - + R.is = function (o, type) { type = lowerCase.call(type); if (type == "finite") { @@ -8203,7 +8203,7 @@ if (!JSON) { } return res; } - + R.angle = function (x1, y1, x2, y2, x3, y3) { if (x3 == null) { var x = x1 - x2, @@ -8216,15 +8216,15 @@ if (!JSON) { return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); } }; - + R.rad = function (deg) { return deg % 360 * PI / 180; }; - + R.deg = function (rad) { return rad * 180 / PI % 360; }; - + R.snapTo = function (values, value, tolerance) { tolerance = R.is(tolerance, "finite") ? tolerance : 10; if (R.is(values, array)) { @@ -8244,8 +8244,8 @@ if (!JSON) { } return value; }; - - + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { return function () { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); @@ -8256,7 +8256,7 @@ if (!JSON) { return v.toString(16); }); - + R.setWindow = function (newwin) { eve("raphael.setWindow", R, g.win, newwin); g.win = newwin; @@ -8327,7 +8327,7 @@ if (!JSON) { g /= 255; b /= 255; } - + return [r, g, b]; }, packageRGB = function (r, g, b, o) { @@ -8344,8 +8344,8 @@ if (!JSON) { R.is(o, "finite") && (rgb.opacity = o); return rgb; }; - - + + R.color = function (clr) { var rgb; if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { @@ -8379,7 +8379,7 @@ if (!JSON) { clr.toString = rgbtoString; return clr; }; - + R.hsb2rgb = function (h, s, v, o) { if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { v = h.b; @@ -8400,7 +8400,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.hsl2rgb = function (h, s, l, o) { if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { l = h.l; @@ -8425,7 +8425,7 @@ if (!JSON) { B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.rgb2hsb = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8444,7 +8444,7 @@ if (!JSON) { S = C == 0 ? 0 : C / V; return {h: H, s: S, b: V, toString: hsbtoString}; }; - + R.rgb2hsl = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -8506,12 +8506,12 @@ if (!JSON) { g.doc.body.appendChild(img); img.src = src; }; - + function clrToString() { return this.hex; } - + R.getRGB = cacher(function (colour) { if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; @@ -8583,19 +8583,19 @@ if (!JSON) { } return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; }, R); - + R.hsb = cacher(function (h, s, b) { return R.hsb2rgb(h, s, b).hex; }); - + R.hsl = cacher(function (h, s, l) { return R.hsl2rgb(h, s, l).hex; }); - + R.rgb = cacher(function (r, g, b) { return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); }); - + R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, rgb = this.hsb2rgb(start.h, start.s, start.b); @@ -8607,7 +8607,7 @@ if (!JSON) { } return rgb.hex; }; - + R.getColor.reset = function () { delete this.start; }; @@ -8650,7 +8650,7 @@ if (!JSON) { return d; } - + R.parsePathString = function (pathString) { if (!pathString) { return null; @@ -8659,7 +8659,7 @@ if (!JSON) { if (pth.arr) { return pathClone(pth.arr); } - + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, data = []; if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption @@ -8691,7 +8691,7 @@ if (!JSON) { pth.arr = pathClone(data); return data; }; - + R.parseTransformString = cacher(function (TString) { if (!TString) { return null; @@ -8732,7 +8732,7 @@ if (!JSON) { }); return p[ps]; }; - + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t, t13 = pow(t1, 3), @@ -8761,7 +8761,7 @@ if (!JSON) { alpha: alpha }; }; - + R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!R.is(p1x, "array")) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; @@ -8776,11 +8776,11 @@ if (!JSON) { height: bbox.max.y - bbox.min.y }; }; - + R.isPointInsideBBox = function (bbox, x, y) { return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; }; - + R.isBBoxIntersect = function (bbox1, bbox2) { var i = R.isPointInsideBBox; return i(bbox2, bbox1.x, bbox1.y) @@ -8930,7 +8930,7 @@ if (!JSON) { } return res; } - + R.pathIntersection = function (path1, path2) { return interPathHelper(path1, path2); }; @@ -8990,7 +8990,7 @@ if (!JSON) { } return res; } - + R.isPointInsidePath = function (path, x, y) { var bbox = R.pathBBox(path); return R.isPointInsideBBox(bbox, x, y) && @@ -9001,7 +9001,7 @@ if (!JSON) { eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); }; }; - + var pathDimensions = R.pathBBox = function (path) { var pth = paths(path); if (pth.bbox) { @@ -9011,7 +9011,7 @@ if (!JSON) { return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; } path = path2curve(path); - var x = 0, + var x = 0, y = 0, X = [], Y = [], @@ -9559,7 +9559,7 @@ if (!JSON) { el2.prev = el; el.next = el2; }, - + toMatrix = R.toMatrix = function (path, transform) { var bb = pathDimensions(path), el = { @@ -9573,7 +9573,7 @@ if (!JSON) { extractTransform(el, transform); return el.matrix; }, - + transformPath = R.transformPath = function (path, transform) { return mapPath(path, toMatrix(path, transform)); }, @@ -9653,7 +9653,7 @@ if (!JSON) { } } - + el.matrix = m; _.sx = sx; @@ -9747,12 +9747,12 @@ if (!JSON) { height: h }; }; - + R.pathToRelative = pathToRelative; R._engine = {}; - + R.path2curve = path2curve; - + R.matrix = function (a, b, c, d, e, f) { return new Matrix(a, b, c, d, e, f); }; @@ -9774,7 +9774,7 @@ if (!JSON) { } } (function (matrixproto) { - + matrixproto.add = function (a, b, c, d, e, f) { var out = [[], [], []], m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], @@ -9801,28 +9801,28 @@ if (!JSON) { this.e = out[0][2]; this.f = out[1][2]; }; - + matrixproto.invert = function () { var me = this, x = me.a * me.d - me.b * me.c; return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); }; - + matrixproto.clone = function () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; - + matrixproto.translate = function (x, y) { this.add(1, 0, 0, 1, x, y); }; - + matrixproto.scale = function (x, y, cx, cy) { y == null && (y = x); (cx || cy) && this.add(1, 0, 0, 1, cx, cy); this.add(x, 0, 0, y, 0, 0); (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); }; - + matrixproto.rotate = function (a, x, y) { a = R.rad(a); x = x || 0; @@ -9832,11 +9832,11 @@ if (!JSON) { this.add(cos, sin, -sin, cos, x, y); this.add(1, 0, 0, 1, -x, -y); }; - + matrixproto.x = function (x, y) { return x * this.a + y * this.c + this.e; }; - + matrixproto.y = function (x, y) { return x * this.b + y * this.d + this.f; }; @@ -9864,7 +9864,7 @@ if (!JSON) { a[0] && (a[0] /= mag); a[1] && (a[1] /= mag); } - + matrixproto.split = function () { var out = {}; // translation @@ -9900,14 +9900,14 @@ if (!JSON) { out.noRotation = !+out.shear.toFixed(9) && !out.rotate; return out; }; - + matrixproto.toTransformString = function (shorter) { var s = shorter || this[split](); if (s.isSimple) { s.scalex = +s.scalex.toFixed(4); s.scaley = +s.scaley.toFixed(4); s.rotate = +s.rotate.toFixed(4); - return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + + return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + (s.rotate ? "r" + [s.rotate, 0, 0] : E); } else { @@ -9920,7 +9920,7 @@ if (!JSON) { var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || (navigator.vendor == "Google Inc." && version && version[1] < 8)) { - + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); setTimeout(function () {rect.remove();}); @@ -9928,7 +9928,7 @@ if (!JSON) { } else { paperproto.safari = fun; } - + var preventDefault = function () { this.returnValue = false; }, @@ -10043,40 +10043,40 @@ if (!JSON) { } drag = []; }, - + elproto = R.el = {}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { (function (eventName) { R[eventName] = elproto[eventName] = function (fn, scope) { @@ -10099,8 +10099,8 @@ if (!JSON) { }; })(events[i]); } - - + + elproto.data = function (key, value) { var data = eldata[this.id] = eldata[this.id] || {}; if (arguments.length == 1) { @@ -10117,7 +10117,7 @@ if (!JSON) { eve("raphael.data.set." + this.id, this, value, key); return this; }; - + elproto.removeData = function (key) { if (key == null) { eldata[this.id] = {}; @@ -10126,16 +10126,16 @@ if (!JSON) { } return this; }; - + elproto.hover = function (f_in, f_out, scope_in, scope_out) { return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); }; - + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; var draggable = []; - + elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { function start(e) { (e.originalEvent || e).preventDefault(); @@ -10156,11 +10156,11 @@ if (!JSON) { this.mousedown(start); return this; }; - + elproto.onDragOver = function (f) { f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); }; - + elproto.undrag = function () { var i = draggable.length; while (i--) if (draggable[i].el == this) { @@ -10170,72 +10170,72 @@ if (!JSON) { } !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); }; - + paperproto.circle = function (x, y, r) { var out = R._engine.circle(this, x || 0, y || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.rect = function (x, y, w, h, r) { var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.ellipse = function (x, y, rx, ry) { var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); var out = R._engine.path(R.format[apply](R, arguments), this); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.image = function (src, x, y, w, h) { var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.text = function (x, y, text) { var out = R._engine.text(this, x || 0, y || 0, Str(text)); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.set = function (itemsArray) { !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); var out = new Set(itemsArray); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.setStart = function (set) { this.__set__ = set || this.set(); }; - + paperproto.setFinish = function (set) { var out = this.__set__; delete this.__set__; return out; }; - + paperproto.setSize = function (width, height) { return R._engine.setSize.call(this, width, height); }; - + paperproto.setViewBox = function (x, y, w, h, fit) { return R._engine.setViewBox.call(this, x, y, w, h, fit); }; - - + + paperproto.top = paperproto.bottom = null; - + paperproto.raphael = R; var getOffset = function (elem) { var box = elem.getBoundingClientRect(), @@ -10250,7 +10250,7 @@ if (!JSON) { x: left }; }; - + paperproto.getElementByPoint = function (x, y) { var paper = this, svg = paper.canvas, @@ -10276,7 +10276,7 @@ if (!JSON) { target = target && target.raphael ? paper.getById(target.raphaelid) : null; return target; }; - + paperproto.getById = function (id) { var bot = this.bottom; while (bot) { @@ -10287,7 +10287,7 @@ if (!JSON) { } return null; }; - + paperproto.forEach = function (callback, thisArg) { var bot = this.bottom; while (bot) { @@ -10298,7 +10298,7 @@ if (!JSON) { } return this; }; - + paperproto.getElementsByPoint = function (x, y) { var set = this.set(); this.forEach(function (el) { @@ -10314,12 +10314,20 @@ if (!JSON) { function x_y_w_h() { return this.x + S + this.y + S + this.width + " \xd7 " + this.height; } - + elproto.isPointInside = function (x, y) { var rp = this.realPath = this.realPath || getPath[this.type](this); return R.isPointInsidePath(rp, x, y); }; - + + elproto.getMidpoint = function (isWithoutTransform) { + var bbox = this.getBBox(isWithoutTransform); + return { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + } + }; + elproto.getBBox = function (isWithoutTransform) { if (this.removed) { return {}; @@ -10345,7 +10353,7 @@ if (!JSON) { } return _.bbox; }; - + elproto.clone = function () { if (this.removed) { return null; @@ -10354,7 +10362,7 @@ if (!JSON) { this.__set__ && this.__set__.push(out); return out; }; - + elproto.glow = function (glow) { if (this.type == "text") { return null; @@ -10437,11 +10445,11 @@ if (!JSON) { var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - + R.getTotalLength = getTotalLength; - + R.getPointAtLength = getPointAtLength; - + R.getSubpath = function (path, from, to) { if (this.getTotalLength(path) - to < 1e-6) { return getSubpathsAtLength(path, from).end; @@ -10449,7 +10457,7 @@ if (!JSON) { var a = getSubpathsAtLength(path, to, 1); return from ? getSubpathsAtLength(a, from).end : a; }; - + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { @@ -10457,17 +10465,17 @@ if (!JSON) { } return getTotalLength(this.attrs.path); }; - + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; - + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} return R.getSubpath(this.attrs.path, from, to); }; - + var ef = R.easing_formulas = { linear: function (n) { return n; @@ -10668,7 +10676,7 @@ if (!JSON) { upto255 = function (color) { return color > 255 ? 255 : color < 0 ? 0 : color; }; - + elproto.animateWith = function (el, anim, params, ms, easing, callback) { var element = this; if (element.removed) { @@ -10685,8 +10693,8 @@ if (!JSON) { } } return element; - // - // + // + // // var a = params ? R.animation(params, ms, easing, callback) : anim, // status = element.status(anim); // return this.animate(a).status(a, status * anim.ms / a.ms); @@ -10763,15 +10771,15 @@ if (!JSON) { this.top = percents[percents.length - 1]; this.percents = percents; } - + Animation.prototype.delay = function (delay) { var a = new Animation(this.anim, this.ms); a.times = this.times; a.del = +delay || 0; return a; }; - - Animation.prototype.repeat = function (times) { + + Animation.prototype.repeat = function (times) { var a = new Animation(this.anim, this.ms); a.del = this.del; a.times = math.floor(mmax(times, 0)) || 1; @@ -10983,7 +10991,7 @@ if (!JSON) { } eve("raphael.anim.start." + element.id, element, anim); } - + R.animation = function (params, ms, easing, callback) { if (params instanceof Animation) { return params; @@ -11009,7 +11017,7 @@ if (!JSON) { return new Animation({100: p}, ms); } }; - + elproto.animate = function (params, ms, easing, callback) { var element = this; if (element.removed) { @@ -11020,14 +11028,14 @@ if (!JSON) { runAnimation(anim, element, anim.percents[0], null, element.attr()); return element; }; - + elproto.setTime = function (anim, value) { if (anim && value != null) { this.status(anim, mmin(value, anim.ms) / anim.ms); } return this; }; - + elproto.status = function (anim, value) { var out = [], i = 0, @@ -11056,7 +11064,7 @@ if (!JSON) { return out; } }; - + elproto.pause = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { @@ -11065,7 +11073,7 @@ if (!JSON) { } return this; }; - + elproto.resume = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { var e = animationElements[i]; @@ -11076,7 +11084,7 @@ if (!JSON) { } return this; }; - + elproto.stop = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { @@ -11111,7 +11119,7 @@ if (!JSON) { } }, setproto = Set.prototype; - + setproto.push = function () { var item, len; @@ -11125,12 +11133,12 @@ if (!JSON) { } return this; }; - + setproto.pop = function () { this.length && delete this[this.length--]; return this.items.pop(); }; - + setproto.forEach = function (callback, thisArg) { for (var i = 0, ii = this.items.length; i < ii; i++) { if (callback.call(thisArg, this.items[i], i) === false) { @@ -11161,13 +11169,13 @@ if (!JSON) { } return this; }; - + setproto.clear = function () { while (this.length) { this.pop(); } }; - + setproto.splice = function (index, count, insertion) { index = index < 0 ? mmax(this.length + index, 0) : index; count = mmax(0, mmin(this.length - index, count)); @@ -11194,7 +11202,7 @@ if (!JSON) { } return new Set(todel); }; - + setproto.exclude = function (el) { for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { this.splice(i, 1); @@ -11265,7 +11273,7 @@ if (!JSON) { return "Rapha\xebl\u2018s set"; }; - + R.registerFont = function (font) { if (!font.face) { return font; @@ -11305,7 +11313,7 @@ if (!JSON) { } return font; }; - + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; @@ -11334,7 +11342,7 @@ if (!JSON) { } return thefont; }; - + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); @@ -11374,7 +11382,7 @@ if (!JSON) { }); }; - + paperproto.add = function (json) { if (R.is(json, "array")) { var res = this.set(), @@ -11389,7 +11397,7 @@ if (!JSON) { return res; }; - + R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { @@ -11397,7 +11405,7 @@ if (!JSON) { })); return token || E; }; - + R.fullfill = (function () { var tokenRegex = /\{([^\}]+)\}/g, objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties @@ -11421,12 +11429,12 @@ if (!JSON) { }); }; })(); - + R.ninja = function () { oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - + R.st = setproto; // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html (function (doc, loaded, f) { @@ -11444,7 +11452,7 @@ if (!JSON) { })(document, "DOMContentLoaded"); oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); - + eve.on("raphael.DOMload", function () { loaded = true; }); @@ -11550,7 +11558,7 @@ window.Raphael.svg && function (R) { return null; } id = id.replace(/[\(\)\s,\xb0#]/g, "_"); - + if (element.gradient && id != element.gradient.id) { SVG.defs.removeChild(element.gradient); delete element.gradient; @@ -12047,16 +12055,16 @@ window.Raphael.svg && function (R) { Element = function (node, svg) { var X = 0, Y = 0; - + this[0] = this.node = node; - + node.raphael = true; - + this.id = R._oid++; node.raphaelid = this.id; this.matrix = R.matrix(); this.realPath = null; - + this.paper = svg; this.attrs = this.attrs || {}; this._ = { @@ -12069,11 +12077,11 @@ window.Raphael.svg && function (R) { dirty: 1 }; !svg.bottom && (svg.bottom = this); - + this.prev = svg.top; svg.top && (svg.top.next = this); svg.top = this; - + this.next = null; }, elproto = R.el; @@ -12093,7 +12101,7 @@ window.Raphael.svg && function (R) { }); return p; }; - + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -12113,7 +12121,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["r", deg, cx, cy]])); return this; }; - + elproto.scale = function (sx, sy, cx, cy) { if (this.removed) { return this; @@ -12135,7 +12143,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); return this; }; - + elproto.translate = function (dx, dy) { if (this.removed) { return this; @@ -12149,7 +12157,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["t", dx, dy]])); return this; }; - + elproto.transform = function (tstr) { var _ = this._; if (tstr == null) { @@ -12160,7 +12168,7 @@ window.Raphael.svg && function (R) { this.clip && $(this.clip, {transform: this.matrix.invert()}); this.pattern && updatePosition(this); this.node && $(this.node, {transform: this.matrix}); - + if (_.sx != 1 || _.sy != 1) { var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; this.attr({"stroke-width": sw}); @@ -12168,17 +12176,17 @@ window.Raphael.svg && function (R) { return this; }; - + elproto.hide = function () { !this.removed && this.paper.safari(this.node.style.display = "none"); return this; }; - + elproto.show = function () { !this.removed && this.paper.safari(this.node.style.display = ""); return this; }; - + elproto.remove = function () { if (this.removed || !this.node.parentNode) { return; @@ -12216,7 +12224,7 @@ window.Raphael.svg && function (R) { hide && this.hide(); return bbox; }; - + elproto.attr = function (name, value) { if (this.removed) { return this; @@ -12277,7 +12285,7 @@ window.Raphael.svg && function (R) { setFillAndStroke(this, params); return this; }; - + elproto.toFront = function () { if (this.removed) { return this; @@ -12291,14 +12299,14 @@ window.Raphael.svg && function (R) { svg.top != this && R._tofront(this, svg); return this; }; - + elproto.toBack = function () { if (this.removed) { return this; } var parent = this.node.parentNode; if (parent.tagName.toLowerCase() == "a") { - parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); + parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); } else if (parent.firstChild != this.node) { parent.insertBefore(this.node, this.node.parentNode.firstChild); } @@ -12306,7 +12314,7 @@ window.Raphael.svg && function (R) { var svg = this.paper; return this; }; - + elproto.insertAfter = function (element) { if (this.removed) { return this; @@ -12320,7 +12328,7 @@ window.Raphael.svg && function (R) { R._insertafter(this, element, this.paper); return this; }; - + elproto.insertBefore = function (element) { if (this.removed) { return this; @@ -12492,7 +12500,7 @@ window.Raphael.svg && function (R) { this._viewBox = [x, y, w, h, !!fit]; return this; }; - + R.prototype.renderfix = function () { var cnvs = this.canvas, s = cnvs.style, @@ -12515,7 +12523,7 @@ window.Raphael.svg && function (R) { } } }; - + R.prototype.clear = function () { R.eve("raphael.clear", this); var c = this.canvas; @@ -12527,7 +12535,7 @@ window.Raphael.svg && function (R) { c.appendChild(this.desc); c.appendChild(this.defs = $("defs")); }; - + R.prototype.remove = function () { eve("raphael.remove", this); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); @@ -12771,7 +12779,7 @@ window.Raphael.vml && function (R) { if ("arrow-end" in params) { addArrow(res, params["arrow-end"], 1); } - if (params.opacity != null || + if (params.opacity != null || params["stroke-width"] != null || params.fill != null || params.src != null || @@ -12850,7 +12858,7 @@ window.Raphael.vml && function (R) { params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); stroke.opacity = opacity; - + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); stroke.miterlimit = params["stroke-miterlimit"] || 8; params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); @@ -12897,7 +12905,7 @@ window.Raphael.vml && function (R) { res._.dirty = 1; break; } - + // text-anchor emulation switch (a["text-anchor"]) { case "start": @@ -13025,7 +13033,7 @@ window.Raphael.vml && function (R) { trsfrm = vbt; } R._extractTransform(this, trsfrm); - + var matrix = this.matrix.clone(), skew = this.skew, o = this.node, @@ -13118,7 +13126,7 @@ window.Raphael.vml && function (R) { } cx = cx == null ? bbox.x + bbox.width / 2 : cx; cy = cy == null ? bbox.y + bbox.height / 2 : cy; - + this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); this._.dirtyT = 1; return this; diff --git a/build/v5.js b/build/v5.js index aecbade..aeffc64 100644 --- a/build/v5.js +++ b/build/v5.js @@ -7078,7 +7078,7 @@ current_event, stop, events = {n: {}}, - + eve = function (name, scope) { var e = events, oldstop = stop, @@ -7139,7 +7139,7 @@ current_event = ce; return out.length ? out : null; }; - + eve.listeners = function (name) { var names = name.split(separator), e = events, @@ -7171,8 +7171,8 @@ } return out; }; - - + + eve.on = function (name, f) { var names = name.split(separator), e = events; @@ -7192,19 +7192,19 @@ } }; }; - + eve.stop = function () { stop = 1; }; - + eve.nt = function (subname) { if (subname) { return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); } return current_event; }; - - + + eve.off = eve.unbind = function (name, f) { var names = name.split(separator), e, @@ -7257,7 +7257,7 @@ } } }; - + eve.once = function (name, f) { var f2 = function () { var res = f.apply(this, arguments); @@ -7266,7 +7266,7 @@ }; return eve.on(name, f2); }; - + eve.version = version; eve.toString = function () { return "You are running Eve " + version; @@ -7283,7 +7283,7 @@ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // └─────────────────────────────────────────────────────────────────────┘ \\ (function () { - + function R(first) { if (R.is(first, "function")) { return loaded ? first() : eve.on("raphael.DOMload", first); @@ -7318,8 +7318,8 @@ is: g.win.Raphael }, Paper = function () { - - + + this.ca = this.customAttributes = {}; }, paperproto, @@ -7479,7 +7479,7 @@ return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); } }, - + mapPath = R.mapPath = function (path, matrix) { if (!matrix) { return path; @@ -7499,7 +7499,7 @@ }; R._g = g; - + R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); if (R.type == "VML") { var d = g.doc.createElement("div"), @@ -7512,15 +7512,15 @@ } d = null; } - - + + R.svg = !(R.vml = R.type == "VML"); R._Paper = Paper; - + R.fn = paperproto = Paper.prototype = R.prototype; R._id = 0; R._oid = 0; - + R.is = function (o, type) { type = lowerCase.call(type); if (type == "finite") { @@ -7546,7 +7546,7 @@ } return res; } - + R.angle = function (x1, y1, x2, y2, x3, y3) { if (x3 == null) { var x = x1 - x2, @@ -7559,15 +7559,15 @@ return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); } }; - + R.rad = function (deg) { return deg % 360 * PI / 180; }; - + R.deg = function (rad) { return rad * 180 / PI % 360; }; - + R.snapTo = function (values, value, tolerance) { tolerance = R.is(tolerance, "finite") ? tolerance : 10; if (R.is(values, array)) { @@ -7587,8 +7587,8 @@ } return value; }; - - + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { return function () { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); @@ -7599,7 +7599,7 @@ return v.toString(16); }); - + R.setWindow = function (newwin) { eve("raphael.setWindow", R, g.win, newwin); g.win = newwin; @@ -7670,7 +7670,7 @@ g /= 255; b /= 255; } - + return [r, g, b]; }, packageRGB = function (r, g, b, o) { @@ -7687,8 +7687,8 @@ R.is(o, "finite") && (rgb.opacity = o); return rgb; }; - - + + R.color = function (clr) { var rgb; if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { @@ -7722,7 +7722,7 @@ clr.toString = rgbtoString; return clr; }; - + R.hsb2rgb = function (h, s, v, o) { if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { v = h.b; @@ -7743,7 +7743,7 @@ B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.hsl2rgb = function (h, s, l, o) { if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { l = h.l; @@ -7768,7 +7768,7 @@ B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.rgb2hsb = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -7787,7 +7787,7 @@ S = C == 0 ? 0 : C / V; return {h: H, s: S, b: V, toString: hsbtoString}; }; - + R.rgb2hsl = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -7849,12 +7849,12 @@ g.doc.body.appendChild(img); img.src = src; }; - + function clrToString() { return this.hex; } - + R.getRGB = cacher(function (colour) { if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; @@ -7926,19 +7926,19 @@ } return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; }, R); - + R.hsb = cacher(function (h, s, b) { return R.hsb2rgb(h, s, b).hex; }); - + R.hsl = cacher(function (h, s, l) { return R.hsl2rgb(h, s, l).hex; }); - + R.rgb = cacher(function (r, g, b) { return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); }); - + R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, rgb = this.hsb2rgb(start.h, start.s, start.b); @@ -7950,7 +7950,7 @@ } return rgb.hex; }; - + R.getColor.reset = function () { delete this.start; }; @@ -7993,7 +7993,7 @@ return d; } - + R.parsePathString = function (pathString) { if (!pathString) { return null; @@ -8002,7 +8002,7 @@ if (pth.arr) { return pathClone(pth.arr); } - + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, data = []; if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption @@ -8034,7 +8034,7 @@ pth.arr = pathClone(data); return data; }; - + R.parseTransformString = cacher(function (TString) { if (!TString) { return null; @@ -8075,7 +8075,7 @@ }); return p[ps]; }; - + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t, t13 = pow(t1, 3), @@ -8104,7 +8104,7 @@ alpha: alpha }; }; - + R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!R.is(p1x, "array")) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; @@ -8119,11 +8119,11 @@ height: bbox.max.y - bbox.min.y }; }; - + R.isPointInsideBBox = function (bbox, x, y) { return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; }; - + R.isBBoxIntersect = function (bbox1, bbox2) { var i = R.isPointInsideBBox; return i(bbox2, bbox1.x, bbox1.y) @@ -8273,7 +8273,7 @@ } return res; } - + R.pathIntersection = function (path1, path2) { return interPathHelper(path1, path2); }; @@ -8333,7 +8333,7 @@ } return res; } - + R.isPointInsidePath = function (path, x, y) { var bbox = R.pathBBox(path); return R.isPointInsideBBox(bbox, x, y) && @@ -8344,7 +8344,7 @@ eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); }; }; - + var pathDimensions = R.pathBBox = function (path) { var pth = paths(path); if (pth.bbox) { @@ -8354,7 +8354,7 @@ return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; } path = path2curve(path); - var x = 0, + var x = 0, y = 0, X = [], Y = [], @@ -8902,7 +8902,7 @@ el2.prev = el; el.next = el2; }, - + toMatrix = R.toMatrix = function (path, transform) { var bb = pathDimensions(path), el = { @@ -8916,7 +8916,7 @@ extractTransform(el, transform); return el.matrix; }, - + transformPath = R.transformPath = function (path, transform) { return mapPath(path, toMatrix(path, transform)); }, @@ -8996,7 +8996,7 @@ } } - + el.matrix = m; _.sx = sx; @@ -9090,12 +9090,12 @@ height: h }; }; - + R.pathToRelative = pathToRelative; R._engine = {}; - + R.path2curve = path2curve; - + R.matrix = function (a, b, c, d, e, f) { return new Matrix(a, b, c, d, e, f); }; @@ -9117,7 +9117,7 @@ } } (function (matrixproto) { - + matrixproto.add = function (a, b, c, d, e, f) { var out = [[], [], []], m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], @@ -9144,28 +9144,28 @@ this.e = out[0][2]; this.f = out[1][2]; }; - + matrixproto.invert = function () { var me = this, x = me.a * me.d - me.b * me.c; return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); }; - + matrixproto.clone = function () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; - + matrixproto.translate = function (x, y) { this.add(1, 0, 0, 1, x, y); }; - + matrixproto.scale = function (x, y, cx, cy) { y == null && (y = x); (cx || cy) && this.add(1, 0, 0, 1, cx, cy); this.add(x, 0, 0, y, 0, 0); (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); }; - + matrixproto.rotate = function (a, x, y) { a = R.rad(a); x = x || 0; @@ -9175,11 +9175,11 @@ this.add(cos, sin, -sin, cos, x, y); this.add(1, 0, 0, 1, -x, -y); }; - + matrixproto.x = function (x, y) { return x * this.a + y * this.c + this.e; }; - + matrixproto.y = function (x, y) { return x * this.b + y * this.d + this.f; }; @@ -9207,7 +9207,7 @@ a[0] && (a[0] /= mag); a[1] && (a[1] /= mag); } - + matrixproto.split = function () { var out = {}; // translation @@ -9243,14 +9243,14 @@ out.noRotation = !+out.shear.toFixed(9) && !out.rotate; return out; }; - + matrixproto.toTransformString = function (shorter) { var s = shorter || this[split](); if (s.isSimple) { s.scalex = +s.scalex.toFixed(4); s.scaley = +s.scaley.toFixed(4); s.rotate = +s.rotate.toFixed(4); - return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + + return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + (s.rotate ? "r" + [s.rotate, 0, 0] : E); } else { @@ -9263,7 +9263,7 @@ var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || (navigator.vendor == "Google Inc." && version && version[1] < 8)) { - + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); setTimeout(function () {rect.remove();}); @@ -9271,7 +9271,7 @@ } else { paperproto.safari = fun; } - + var preventDefault = function () { this.returnValue = false; }, @@ -9386,40 +9386,40 @@ } drag = []; }, - + elproto = R.el = {}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { (function (eventName) { R[eventName] = elproto[eventName] = function (fn, scope) { @@ -9442,8 +9442,8 @@ }; })(events[i]); } - - + + elproto.data = function (key, value) { var data = eldata[this.id] = eldata[this.id] || {}; if (arguments.length == 1) { @@ -9460,7 +9460,7 @@ eve("raphael.data.set." + this.id, this, value, key); return this; }; - + elproto.removeData = function (key) { if (key == null) { eldata[this.id] = {}; @@ -9469,16 +9469,16 @@ } return this; }; - + elproto.hover = function (f_in, f_out, scope_in, scope_out) { return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); }; - + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; var draggable = []; - + elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { function start(e) { (e.originalEvent || e).preventDefault(); @@ -9499,11 +9499,11 @@ this.mousedown(start); return this; }; - + elproto.onDragOver = function (f) { f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); }; - + elproto.undrag = function () { var i = draggable.length; while (i--) if (draggable[i].el == this) { @@ -9513,72 +9513,72 @@ } !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); }; - + paperproto.circle = function (x, y, r) { var out = R._engine.circle(this, x || 0, y || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.rect = function (x, y, w, h, r) { var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.ellipse = function (x, y, rx, ry) { var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); var out = R._engine.path(R.format[apply](R, arguments), this); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.image = function (src, x, y, w, h) { var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.text = function (x, y, text) { var out = R._engine.text(this, x || 0, y || 0, Str(text)); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.set = function (itemsArray) { !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); var out = new Set(itemsArray); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.setStart = function (set) { this.__set__ = set || this.set(); }; - + paperproto.setFinish = function (set) { var out = this.__set__; delete this.__set__; return out; }; - + paperproto.setSize = function (width, height) { return R._engine.setSize.call(this, width, height); }; - + paperproto.setViewBox = function (x, y, w, h, fit) { return R._engine.setViewBox.call(this, x, y, w, h, fit); }; - - + + paperproto.top = paperproto.bottom = null; - + paperproto.raphael = R; var getOffset = function (elem) { var box = elem.getBoundingClientRect(), @@ -9593,7 +9593,7 @@ x: left }; }; - + paperproto.getElementByPoint = function (x, y) { var paper = this, svg = paper.canvas, @@ -9619,7 +9619,7 @@ target = target && target.raphael ? paper.getById(target.raphaelid) : null; return target; }; - + paperproto.getById = function (id) { var bot = this.bottom; while (bot) { @@ -9630,7 +9630,7 @@ } return null; }; - + paperproto.forEach = function (callback, thisArg) { var bot = this.bottom; while (bot) { @@ -9641,7 +9641,7 @@ } return this; }; - + paperproto.getElementsByPoint = function (x, y) { var set = this.set(); this.forEach(function (el) { @@ -9657,12 +9657,20 @@ function x_y_w_h() { return this.x + S + this.y + S + this.width + " \xd7 " + this.height; } - + elproto.isPointInside = function (x, y) { var rp = this.realPath = this.realPath || getPath[this.type](this); return R.isPointInsidePath(rp, x, y); }; - + + elproto.getMidpoint = function (isWithoutTransform) { + var bbox = this.getBBox(isWithoutTransform); + return { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + } + }; + elproto.getBBox = function (isWithoutTransform) { if (this.removed) { return {}; @@ -9688,7 +9696,7 @@ } return _.bbox; }; - + elproto.clone = function () { if (this.removed) { return null; @@ -9697,7 +9705,7 @@ this.__set__ && this.__set__.push(out); return out; }; - + elproto.glow = function (glow) { if (this.type == "text") { return null; @@ -9780,11 +9788,11 @@ var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - + R.getTotalLength = getTotalLength; - + R.getPointAtLength = getPointAtLength; - + R.getSubpath = function (path, from, to) { if (this.getTotalLength(path) - to < 1e-6) { return getSubpathsAtLength(path, from).end; @@ -9792,7 +9800,7 @@ var a = getSubpathsAtLength(path, to, 1); return from ? getSubpathsAtLength(a, from).end : a; }; - + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { @@ -9800,17 +9808,17 @@ } return getTotalLength(this.attrs.path); }; - + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; - + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} return R.getSubpath(this.attrs.path, from, to); }; - + var ef = R.easing_formulas = { linear: function (n) { return n; @@ -10011,7 +10019,7 @@ upto255 = function (color) { return color > 255 ? 255 : color < 0 ? 0 : color; }; - + elproto.animateWith = function (el, anim, params, ms, easing, callback) { var element = this; if (element.removed) { @@ -10028,8 +10036,8 @@ } } return element; - // - // + // + // // var a = params ? R.animation(params, ms, easing, callback) : anim, // status = element.status(anim); // return this.animate(a).status(a, status * anim.ms / a.ms); @@ -10106,15 +10114,15 @@ this.top = percents[percents.length - 1]; this.percents = percents; } - + Animation.prototype.delay = function (delay) { var a = new Animation(this.anim, this.ms); a.times = this.times; a.del = +delay || 0; return a; }; - - Animation.prototype.repeat = function (times) { + + Animation.prototype.repeat = function (times) { var a = new Animation(this.anim, this.ms); a.del = this.del; a.times = math.floor(mmax(times, 0)) || 1; @@ -10326,7 +10334,7 @@ } eve("raphael.anim.start." + element.id, element, anim); } - + R.animation = function (params, ms, easing, callback) { if (params instanceof Animation) { return params; @@ -10352,7 +10360,7 @@ return new Animation({100: p}, ms); } }; - + elproto.animate = function (params, ms, easing, callback) { var element = this; if (element.removed) { @@ -10363,14 +10371,14 @@ runAnimation(anim, element, anim.percents[0], null, element.attr()); return element; }; - + elproto.setTime = function (anim, value) { if (anim && value != null) { this.status(anim, mmin(value, anim.ms) / anim.ms); } return this; }; - + elproto.status = function (anim, value) { var out = [], i = 0, @@ -10399,7 +10407,7 @@ return out; } }; - + elproto.pause = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { @@ -10408,7 +10416,7 @@ } return this; }; - + elproto.resume = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { var e = animationElements[i]; @@ -10419,7 +10427,7 @@ } return this; }; - + elproto.stop = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { @@ -10454,7 +10462,7 @@ } }, setproto = Set.prototype; - + setproto.push = function () { var item, len; @@ -10468,12 +10476,12 @@ } return this; }; - + setproto.pop = function () { this.length && delete this[this.length--]; return this.items.pop(); }; - + setproto.forEach = function (callback, thisArg) { for (var i = 0, ii = this.items.length; i < ii; i++) { if (callback.call(thisArg, this.items[i], i) === false) { @@ -10504,13 +10512,13 @@ } return this; }; - + setproto.clear = function () { while (this.length) { this.pop(); } }; - + setproto.splice = function (index, count, insertion) { index = index < 0 ? mmax(this.length + index, 0) : index; count = mmax(0, mmin(this.length - index, count)); @@ -10537,7 +10545,7 @@ } return new Set(todel); }; - + setproto.exclude = function (el) { for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { this.splice(i, 1); @@ -10608,7 +10616,7 @@ return "Rapha\xebl\u2018s set"; }; - + R.registerFont = function (font) { if (!font.face) { return font; @@ -10648,7 +10656,7 @@ } return font; }; - + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; @@ -10677,7 +10685,7 @@ } return thefont; }; - + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); @@ -10717,7 +10725,7 @@ }); }; - + paperproto.add = function (json) { if (R.is(json, "array")) { var res = this.set(), @@ -10732,7 +10740,7 @@ return res; }; - + R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { @@ -10740,7 +10748,7 @@ })); return token || E; }; - + R.fullfill = (function () { var tokenRegex = /\{([^\}]+)\}/g, objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties @@ -10764,12 +10772,12 @@ }); }; })(); - + R.ninja = function () { oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - + R.st = setproto; // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html (function (doc, loaded, f) { @@ -10787,7 +10795,7 @@ })(document, "DOMContentLoaded"); oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); - + eve.on("raphael.DOMload", function () { loaded = true; }); @@ -10893,7 +10901,7 @@ window.Raphael.svg && function (R) { return null; } id = id.replace(/[\(\)\s,\xb0#]/g, "_"); - + if (element.gradient && id != element.gradient.id) { SVG.defs.removeChild(element.gradient); delete element.gradient; @@ -11390,16 +11398,16 @@ window.Raphael.svg && function (R) { Element = function (node, svg) { var X = 0, Y = 0; - + this[0] = this.node = node; - + node.raphael = true; - + this.id = R._oid++; node.raphaelid = this.id; this.matrix = R.matrix(); this.realPath = null; - + this.paper = svg; this.attrs = this.attrs || {}; this._ = { @@ -11412,11 +11420,11 @@ window.Raphael.svg && function (R) { dirty: 1 }; !svg.bottom && (svg.bottom = this); - + this.prev = svg.top; svg.top && (svg.top.next = this); svg.top = this; - + this.next = null; }, elproto = R.el; @@ -11436,7 +11444,7 @@ window.Raphael.svg && function (R) { }); return p; }; - + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -11456,7 +11464,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["r", deg, cx, cy]])); return this; }; - + elproto.scale = function (sx, sy, cx, cy) { if (this.removed) { return this; @@ -11478,7 +11486,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); return this; }; - + elproto.translate = function (dx, dy) { if (this.removed) { return this; @@ -11492,7 +11500,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["t", dx, dy]])); return this; }; - + elproto.transform = function (tstr) { var _ = this._; if (tstr == null) { @@ -11503,7 +11511,7 @@ window.Raphael.svg && function (R) { this.clip && $(this.clip, {transform: this.matrix.invert()}); this.pattern && updatePosition(this); this.node && $(this.node, {transform: this.matrix}); - + if (_.sx != 1 || _.sy != 1) { var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; this.attr({"stroke-width": sw}); @@ -11511,17 +11519,17 @@ window.Raphael.svg && function (R) { return this; }; - + elproto.hide = function () { !this.removed && this.paper.safari(this.node.style.display = "none"); return this; }; - + elproto.show = function () { !this.removed && this.paper.safari(this.node.style.display = ""); return this; }; - + elproto.remove = function () { if (this.removed || !this.node.parentNode) { return; @@ -11559,7 +11567,7 @@ window.Raphael.svg && function (R) { hide && this.hide(); return bbox; }; - + elproto.attr = function (name, value) { if (this.removed) { return this; @@ -11620,7 +11628,7 @@ window.Raphael.svg && function (R) { setFillAndStroke(this, params); return this; }; - + elproto.toFront = function () { if (this.removed) { return this; @@ -11634,14 +11642,14 @@ window.Raphael.svg && function (R) { svg.top != this && R._tofront(this, svg); return this; }; - + elproto.toBack = function () { if (this.removed) { return this; } var parent = this.node.parentNode; if (parent.tagName.toLowerCase() == "a") { - parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); + parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); } else if (parent.firstChild != this.node) { parent.insertBefore(this.node, this.node.parentNode.firstChild); } @@ -11649,7 +11657,7 @@ window.Raphael.svg && function (R) { var svg = this.paper; return this; }; - + elproto.insertAfter = function (element) { if (this.removed) { return this; @@ -11663,7 +11671,7 @@ window.Raphael.svg && function (R) { R._insertafter(this, element, this.paper); return this; }; - + elproto.insertBefore = function (element) { if (this.removed) { return this; @@ -11835,7 +11843,7 @@ window.Raphael.svg && function (R) { this._viewBox = [x, y, w, h, !!fit]; return this; }; - + R.prototype.renderfix = function () { var cnvs = this.canvas, s = cnvs.style, @@ -11858,7 +11866,7 @@ window.Raphael.svg && function (R) { } } }; - + R.prototype.clear = function () { R.eve("raphael.clear", this); var c = this.canvas; @@ -11870,7 +11878,7 @@ window.Raphael.svg && function (R) { c.appendChild(this.desc); c.appendChild(this.defs = $("defs")); }; - + R.prototype.remove = function () { eve("raphael.remove", this); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); @@ -12114,7 +12122,7 @@ window.Raphael.vml && function (R) { if ("arrow-end" in params) { addArrow(res, params["arrow-end"], 1); } - if (params.opacity != null || + if (params.opacity != null || params["stroke-width"] != null || params.fill != null || params.src != null || @@ -12193,7 +12201,7 @@ window.Raphael.vml && function (R) { params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); stroke.opacity = opacity; - + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); stroke.miterlimit = params["stroke-miterlimit"] || 8; params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); @@ -12240,7 +12248,7 @@ window.Raphael.vml && function (R) { res._.dirty = 1; break; } - + // text-anchor emulation switch (a["text-anchor"]) { case "start": @@ -12368,7 +12376,7 @@ window.Raphael.vml && function (R) { trsfrm = vbt; } R._extractTransform(this, trsfrm); - + var matrix = this.matrix.clone(), skew = this.skew, o = this.node, @@ -12461,7 +12469,7 @@ window.Raphael.vml && function (R) { } cx = cx == null ? bbox.x + bbox.width / 2 : cx; cy = cy == null ? bbox.y + bbox.height / 2 : cy; - + this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); this._.dirtyT = 1; return this; @@ -13115,7 +13123,7 @@ window.Raphael.vml && function (R) { dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -13438,6 +13446,15 @@ window.Raphael.vml && function (R) { return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */ diff --git a/deps/raphael.js b/deps/raphael.js index e5a15b3..2042807 100644 --- a/deps/raphael.js +++ b/deps/raphael.js @@ -29,7 +29,7 @@ current_event, stop, events = {n: {}}, - + eve = function (name, scope) { var e = events, oldstop = stop, @@ -90,7 +90,7 @@ current_event = ce; return out.length ? out : null; }; - + eve.listeners = function (name) { var names = name.split(separator), e = events, @@ -122,8 +122,8 @@ } return out; }; - - + + eve.on = function (name, f) { var names = name.split(separator), e = events; @@ -143,19 +143,19 @@ } }; }; - + eve.stop = function () { stop = 1; }; - + eve.nt = function (subname) { if (subname) { return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); } return current_event; }; - - + + eve.off = eve.unbind = function (name, f) { var names = name.split(separator), e, @@ -208,7 +208,7 @@ } } }; - + eve.once = function (name, f) { var f2 = function () { var res = f.apply(this, arguments); @@ -217,7 +217,7 @@ }; return eve.on(name, f2); }; - + eve.version = version; eve.toString = function () { return "You are running Eve " + version; @@ -234,7 +234,7 @@ // │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ // └─────────────────────────────────────────────────────────────────────┘ \\ (function () { - + function R(first) { if (R.is(first, "function")) { return loaded ? first() : eve.on("raphael.DOMload", first); @@ -269,8 +269,8 @@ is: g.win.Raphael }, Paper = function () { - - + + this.ca = this.customAttributes = {}; }, paperproto, @@ -430,7 +430,7 @@ return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); } }, - + mapPath = R.mapPath = function (path, matrix) { if (!matrix) { return path; @@ -450,7 +450,7 @@ }; R._g = g; - + R.type = (g.win.SVGAngle || g.doc.implementation.hasFeature("http://www.w3.org/TR/SVG11/feature#BasicStructure", "1.1") ? "SVG" : "VML"); if (R.type == "VML") { var d = g.doc.createElement("div"), @@ -463,15 +463,15 @@ } d = null; } - - + + R.svg = !(R.vml = R.type == "VML"); R._Paper = Paper; - + R.fn = paperproto = Paper.prototype = R.prototype; R._id = 0; R._oid = 0; - + R.is = function (o, type) { type = lowerCase.call(type); if (type == "finite") { @@ -497,7 +497,7 @@ } return res; } - + R.angle = function (x1, y1, x2, y2, x3, y3) { if (x3 == null) { var x = x1 - x2, @@ -510,15 +510,15 @@ return R.angle(x1, y1, x3, y3) - R.angle(x2, y2, x3, y3); } }; - + R.rad = function (deg) { return deg % 360 * PI / 180; }; - + R.deg = function (rad) { return rad * 180 / PI % 360; }; - + R.snapTo = function (values, value, tolerance) { tolerance = R.is(tolerance, "finite") ? tolerance : 10; if (R.is(values, array)) { @@ -538,8 +538,8 @@ } return value; }; - - + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { return function () { return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); @@ -550,7 +550,7 @@ return v.toString(16); }); - + R.setWindow = function (newwin) { eve("raphael.setWindow", R, g.win, newwin); g.win = newwin; @@ -621,7 +621,7 @@ g /= 255; b /= 255; } - + return [r, g, b]; }, packageRGB = function (r, g, b, o) { @@ -638,8 +638,8 @@ R.is(o, "finite") && (rgb.opacity = o); return rgb; }; - - + + R.color = function (clr) { var rgb; if (R.is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) { @@ -673,7 +673,7 @@ clr.toString = rgbtoString; return clr; }; - + R.hsb2rgb = function (h, s, v, o) { if (this.is(h, "object") && "h" in h && "s" in h && "b" in h) { v = h.b; @@ -694,7 +694,7 @@ B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.hsl2rgb = function (h, s, l, o) { if (this.is(h, "object") && "h" in h && "s" in h && "l" in h) { l = h.l; @@ -719,7 +719,7 @@ B += [0, 0, X, C, C, X][h]; return packageRGB(R, G, B, o); }; - + R.rgb2hsb = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -738,7 +738,7 @@ S = C == 0 ? 0 : C / V; return {h: H, s: S, b: V, toString: hsbtoString}; }; - + R.rgb2hsl = function (r, g, b) { b = prepareRGB(r, g, b); r = b[0]; @@ -800,12 +800,12 @@ g.doc.body.appendChild(img); img.src = src; }; - + function clrToString() { return this.hex; } - + R.getRGB = cacher(function (colour) { if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) { return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; @@ -877,19 +877,19 @@ } return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: clrToString}; }, R); - + R.hsb = cacher(function (h, s, b) { return R.hsb2rgb(h, s, b).hex; }); - + R.hsl = cacher(function (h, s, l) { return R.hsl2rgb(h, s, l).hex; }); - + R.rgb = cacher(function (r, g, b) { return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1); }); - + R.getColor = function (value) { var start = this.getColor.start = this.getColor.start || {h: 0, s: 1, b: value || .75}, rgb = this.hsb2rgb(start.h, start.s, start.b); @@ -901,7 +901,7 @@ } return rgb.hex; }; - + R.getColor.reset = function () { delete this.start; }; @@ -944,7 +944,7 @@ return d; } - + R.parsePathString = function (pathString) { if (!pathString) { return null; @@ -953,7 +953,7 @@ if (pth.arr) { return pathClone(pth.arr); } - + var paramCounts = {a: 7, c: 6, h: 1, l: 2, m: 2, r: 4, q: 4, s: 4, t: 2, v: 1, z: 0}, data = []; if (R.is(pathString, array) && R.is(pathString[0], array)) { // rough assumption @@ -985,7 +985,7 @@ pth.arr = pathClone(data); return data; }; - + R.parseTransformString = cacher(function (TString) { if (!TString) { return null; @@ -1026,7 +1026,7 @@ }); return p[ps]; }; - + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { var t1 = 1 - t, t13 = pow(t1, 3), @@ -1055,7 +1055,7 @@ alpha: alpha }; }; - + R.bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { if (!R.is(p1x, "array")) { p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y]; @@ -1070,11 +1070,11 @@ height: bbox.max.y - bbox.min.y }; }; - + R.isPointInsideBBox = function (bbox, x, y) { return x >= bbox.x && x <= bbox.x2 && y >= bbox.y && y <= bbox.y2; }; - + R.isBBoxIntersect = function (bbox1, bbox2) { var i = R.isPointInsideBBox; return i(bbox2, bbox1.x, bbox1.y) @@ -1224,7 +1224,7 @@ } return res; } - + R.pathIntersection = function (path1, path2) { return interPathHelper(path1, path2); }; @@ -1284,7 +1284,7 @@ } return res; } - + R.isPointInsidePath = function (path, x, y) { var bbox = R.pathBBox(path); return R.isPointInsideBBox(bbox, x, y) && @@ -1295,7 +1295,7 @@ eve("raphael.log", null, "Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object", methodname); }; }; - + var pathDimensions = R.pathBBox = function (path) { var pth = paths(path); if (pth.bbox) { @@ -1305,7 +1305,7 @@ return {x: 0, y: 0, width: 0, height: 0, x2: 0, y2: 0}; } path = path2curve(path); - var x = 0, + var x = 0, y = 0, X = [], Y = [], @@ -1853,7 +1853,7 @@ el2.prev = el; el.next = el2; }, - + toMatrix = R.toMatrix = function (path, transform) { var bb = pathDimensions(path), el = { @@ -1867,7 +1867,7 @@ extractTransform(el, transform); return el.matrix; }, - + transformPath = R.transformPath = function (path, transform) { return mapPath(path, toMatrix(path, transform)); }, @@ -1947,7 +1947,7 @@ } } - + el.matrix = m; _.sx = sx; @@ -2041,12 +2041,12 @@ height: h }; }; - + R.pathToRelative = pathToRelative; R._engine = {}; - + R.path2curve = path2curve; - + R.matrix = function (a, b, c, d, e, f) { return new Matrix(a, b, c, d, e, f); }; @@ -2068,7 +2068,7 @@ } } (function (matrixproto) { - + matrixproto.add = function (a, b, c, d, e, f) { var out = [[], [], []], m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]], @@ -2095,28 +2095,28 @@ this.e = out[0][2]; this.f = out[1][2]; }; - + matrixproto.invert = function () { var me = this, x = me.a * me.d - me.b * me.c; return new Matrix(me.d / x, -me.b / x, -me.c / x, me.a / x, (me.c * me.f - me.d * me.e) / x, (me.b * me.e - me.a * me.f) / x); }; - + matrixproto.clone = function () { return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f); }; - + matrixproto.translate = function (x, y) { this.add(1, 0, 0, 1, x, y); }; - + matrixproto.scale = function (x, y, cx, cy) { y == null && (y = x); (cx || cy) && this.add(1, 0, 0, 1, cx, cy); this.add(x, 0, 0, y, 0, 0); (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy); }; - + matrixproto.rotate = function (a, x, y) { a = R.rad(a); x = x || 0; @@ -2126,11 +2126,11 @@ this.add(cos, sin, -sin, cos, x, y); this.add(1, 0, 0, 1, -x, -y); }; - + matrixproto.x = function (x, y) { return x * this.a + y * this.c + this.e; }; - + matrixproto.y = function (x, y) { return x * this.b + y * this.d + this.f; }; @@ -2158,7 +2158,7 @@ a[0] && (a[0] /= mag); a[1] && (a[1] /= mag); } - + matrixproto.split = function () { var out = {}; // translation @@ -2194,14 +2194,14 @@ out.noRotation = !+out.shear.toFixed(9) && !out.rotate; return out; }; - + matrixproto.toTransformString = function (shorter) { var s = shorter || this[split](); if (s.isSimple) { s.scalex = +s.scalex.toFixed(4); s.scaley = +s.scaley.toFixed(4); s.rotate = +s.rotate.toFixed(4); - return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + + return (s.dx || s.dy ? "t" + [s.dx, s.dy] : E) + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + (s.rotate ? "r" + [s.rotate, 0, 0] : E); } else { @@ -2214,7 +2214,7 @@ var version = navigator.userAgent.match(/Version\/(.*?)\s/) || navigator.userAgent.match(/Chrome\/(\d+)/); if ((navigator.vendor == "Apple Computer, Inc.") && (version && version[1] < 4 || navigator.platform.slice(0, 2) == "iP") || (navigator.vendor == "Google Inc." && version && version[1] < 8)) { - + paperproto.safari = function () { var rect = this.rect(-99, -99, this.width + 99, this.height + 99).attr({stroke: "none"}); setTimeout(function () {rect.remove();}); @@ -2222,7 +2222,7 @@ } else { paperproto.safari = fun; } - + var preventDefault = function () { this.returnValue = false; }, @@ -2337,40 +2337,40 @@ } drag = []; }, - + elproto = R.el = {}; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { (function (eventName) { R[eventName] = elproto[eventName] = function (fn, scope) { @@ -2393,8 +2393,8 @@ }; })(events[i]); } - - + + elproto.data = function (key, value) { var data = eldata[this.id] = eldata[this.id] || {}; if (arguments.length == 1) { @@ -2411,7 +2411,7 @@ eve("raphael.data.set." + this.id, this, value, key); return this; }; - + elproto.removeData = function (key) { if (key == null) { eldata[this.id] = {}; @@ -2420,16 +2420,16 @@ } return this; }; - + elproto.hover = function (f_in, f_out, scope_in, scope_out) { return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in); }; - + elproto.unhover = function (f_in, f_out) { return this.unmouseover(f_in).unmouseout(f_out); }; var draggable = []; - + elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) { function start(e) { (e.originalEvent || e).preventDefault(); @@ -2450,11 +2450,11 @@ this.mousedown(start); return this; }; - + elproto.onDragOver = function (f) { f ? eve.on("raphael.drag.over." + this.id, f) : eve.unbind("raphael.drag.over." + this.id); }; - + elproto.undrag = function () { var i = draggable.length; while (i--) if (draggable[i].el == this) { @@ -2464,72 +2464,72 @@ } !draggable.length && R.unmousemove(dragMove).unmouseup(dragUp); }; - + paperproto.circle = function (x, y, r) { var out = R._engine.circle(this, x || 0, y || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.rect = function (x, y, w, h, r) { var out = R._engine.rect(this, x || 0, y || 0, w || 0, h || 0, r || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.ellipse = function (x, y, rx, ry) { var out = R._engine.ellipse(this, x || 0, y || 0, rx || 0, ry || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.path = function (pathString) { pathString && !R.is(pathString, string) && !R.is(pathString[0], array) && (pathString += E); var out = R._engine.path(R.format[apply](R, arguments), this); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.image = function (src, x, y, w, h) { var out = R._engine.image(this, src || "about:blank", x || 0, y || 0, w || 0, h || 0); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.text = function (x, y, text) { var out = R._engine.text(this, x || 0, y || 0, Str(text)); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.set = function (itemsArray) { !R.is(itemsArray, "array") && (itemsArray = Array.prototype.splice.call(arguments, 0, arguments.length)); var out = new Set(itemsArray); this.__set__ && this.__set__.push(out); return out; }; - + paperproto.setStart = function (set) { this.__set__ = set || this.set(); }; - + paperproto.setFinish = function (set) { var out = this.__set__; delete this.__set__; return out; }; - + paperproto.setSize = function (width, height) { return R._engine.setSize.call(this, width, height); }; - + paperproto.setViewBox = function (x, y, w, h, fit) { return R._engine.setViewBox.call(this, x, y, w, h, fit); }; - - + + paperproto.top = paperproto.bottom = null; - + paperproto.raphael = R; var getOffset = function (elem) { var box = elem.getBoundingClientRect(), @@ -2544,7 +2544,7 @@ x: left }; }; - + paperproto.getElementByPoint = function (x, y) { var paper = this, svg = paper.canvas, @@ -2570,7 +2570,7 @@ target = target && target.raphael ? paper.getById(target.raphaelid) : null; return target; }; - + paperproto.getById = function (id) { var bot = this.bottom; while (bot) { @@ -2581,7 +2581,7 @@ } return null; }; - + paperproto.forEach = function (callback, thisArg) { var bot = this.bottom; while (bot) { @@ -2592,7 +2592,7 @@ } return this; }; - + paperproto.getElementsByPoint = function (x, y) { var set = this.set(); this.forEach(function (el) { @@ -2608,12 +2608,20 @@ function x_y_w_h() { return this.x + S + this.y + S + this.width + " \xd7 " + this.height; } - + elproto.isPointInside = function (x, y) { var rp = this.realPath = this.realPath || getPath[this.type](this); return R.isPointInsidePath(rp, x, y); }; - + + elproto.getMidpoint = function (isWithoutTransform) { + var bbox = this.getBBox(isWithoutTransform); + return { + x: bbox.x + bbox.width / 2, + y: bbox.y + bbox.height / 2 + } + }; + elproto.getBBox = function (isWithoutTransform) { if (this.removed) { return {}; @@ -2639,7 +2647,7 @@ } return _.bbox; }; - + elproto.clone = function () { if (this.removed) { return null; @@ -2648,7 +2656,7 @@ this.__set__ && this.__set__.push(out); return out; }; - + elproto.glow = function (glow) { if (this.type == "text") { return null; @@ -2731,11 +2739,11 @@ var getTotalLength = getLengthFactory(1), getPointAtLength = getLengthFactory(), getSubpathsAtLength = getLengthFactory(0, 1); - + R.getTotalLength = getTotalLength; - + R.getPointAtLength = getPointAtLength; - + R.getSubpath = function (path, from, to) { if (this.getTotalLength(path) - to < 1e-6) { return getSubpathsAtLength(path, from).end; @@ -2743,7 +2751,7 @@ var a = getSubpathsAtLength(path, to, 1); return from ? getSubpathsAtLength(a, from).end : a; }; - + elproto.getTotalLength = function () { if (this.type != "path") {return;} if (this.node.getTotalLength) { @@ -2751,17 +2759,17 @@ } return getTotalLength(this.attrs.path); }; - + elproto.getPointAtLength = function (length) { if (this.type != "path") {return;} return getPointAtLength(this.attrs.path, length); }; - + elproto.getSubpath = function (from, to) { if (this.type != "path") {return;} return R.getSubpath(this.attrs.path, from, to); }; - + var ef = R.easing_formulas = { linear: function (n) { return n; @@ -2962,7 +2970,7 @@ upto255 = function (color) { return color > 255 ? 255 : color < 0 ? 0 : color; }; - + elproto.animateWith = function (el, anim, params, ms, easing, callback) { var element = this; if (element.removed) { @@ -2979,8 +2987,8 @@ } } return element; - // - // + // + // // var a = params ? R.animation(params, ms, easing, callback) : anim, // status = element.status(anim); // return this.animate(a).status(a, status * anim.ms / a.ms); @@ -3057,15 +3065,15 @@ this.top = percents[percents.length - 1]; this.percents = percents; } - + Animation.prototype.delay = function (delay) { var a = new Animation(this.anim, this.ms); a.times = this.times; a.del = +delay || 0; return a; }; - - Animation.prototype.repeat = function (times) { + + Animation.prototype.repeat = function (times) { var a = new Animation(this.anim, this.ms); a.del = this.del; a.times = math.floor(mmax(times, 0)) || 1; @@ -3277,7 +3285,7 @@ } eve("raphael.anim.start." + element.id, element, anim); } - + R.animation = function (params, ms, easing, callback) { if (params instanceof Animation) { return params; @@ -3303,7 +3311,7 @@ return new Animation({100: p}, ms); } }; - + elproto.animate = function (params, ms, easing, callback) { var element = this; if (element.removed) { @@ -3314,14 +3322,14 @@ runAnimation(anim, element, anim.percents[0], null, element.attr()); return element; }; - + elproto.setTime = function (anim, value) { if (anim && value != null) { this.status(anim, mmin(value, anim.ms) / anim.ms); } return this; }; - + elproto.status = function (anim, value) { var out = [], i = 0, @@ -3350,7 +3358,7 @@ return out; } }; - + elproto.pause = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.pause." + this.id, this, animationElements[i].anim) !== false) { @@ -3359,7 +3367,7 @@ } return this; }; - + elproto.resume = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { var e = animationElements[i]; @@ -3370,7 +3378,7 @@ } return this; }; - + elproto.stop = function (anim) { for (var i = 0; i < animationElements.length; i++) if (animationElements[i].el.id == this.id && (!anim || animationElements[i].anim == anim)) { if (eve("raphael.anim.stop." + this.id, this, animationElements[i].anim) !== false) { @@ -3405,7 +3413,7 @@ } }, setproto = Set.prototype; - + setproto.push = function () { var item, len; @@ -3419,12 +3427,12 @@ } return this; }; - + setproto.pop = function () { this.length && delete this[this.length--]; return this.items.pop(); }; - + setproto.forEach = function (callback, thisArg) { for (var i = 0, ii = this.items.length; i < ii; i++) { if (callback.call(thisArg, this.items[i], i) === false) { @@ -3455,13 +3463,13 @@ } return this; }; - + setproto.clear = function () { while (this.length) { this.pop(); } }; - + setproto.splice = function (index, count, insertion) { index = index < 0 ? mmax(this.length + index, 0) : index; count = mmax(0, mmin(this.length - index, count)); @@ -3488,7 +3496,7 @@ } return new Set(todel); }; - + setproto.exclude = function (el) { for (var i = 0, ii = this.length; i < ii; i++) if (this[i] == el) { this.splice(i, 1); @@ -3559,7 +3567,7 @@ return "Rapha\xebl\u2018s set"; }; - + R.registerFont = function (font) { if (!font.face) { return font; @@ -3599,7 +3607,7 @@ } return font; }; - + paperproto.getFont = function (family, weight, style, stretch) { stretch = stretch || "normal"; style = style || "normal"; @@ -3628,7 +3636,7 @@ } return thefont; }; - + paperproto.print = function (x, y, string, font, size, origin, letter_spacing) { origin = origin || "middle"; // baseline|middle letter_spacing = mmax(mmin(letter_spacing || 0, 1), -1); @@ -3668,7 +3676,7 @@ }); }; - + paperproto.add = function (json) { if (R.is(json, "array")) { var res = this.set(), @@ -3683,7 +3691,7 @@ return res; }; - + R.format = function (token, params) { var args = R.is(params, array) ? [0][concat](params) : arguments; token && R.is(token, string) && args.length - 1 && (token = token.replace(formatrg, function (str, i) { @@ -3691,7 +3699,7 @@ })); return token || E; }; - + R.fullfill = (function () { var tokenRegex = /\{([^\}]+)\}/g, objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties @@ -3715,12 +3723,12 @@ }); }; })(); - + R.ninja = function () { oldRaphael.was ? (g.win.Raphael = oldRaphael.is) : delete Raphael; return R; }; - + R.st = setproto; // Firefox <3.6 fix: http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html (function (doc, loaded, f) { @@ -3738,7 +3746,7 @@ })(document, "DOMContentLoaded"); oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); - + eve.on("raphael.DOMload", function () { loaded = true; }); @@ -3844,7 +3852,7 @@ window.Raphael.svg && function (R) { return null; } id = id.replace(/[\(\)\s,\xb0#]/g, "_"); - + if (element.gradient && id != element.gradient.id) { SVG.defs.removeChild(element.gradient); delete element.gradient; @@ -4341,16 +4349,16 @@ window.Raphael.svg && function (R) { Element = function (node, svg) { var X = 0, Y = 0; - + this[0] = this.node = node; - + node.raphael = true; - + this.id = R._oid++; node.raphaelid = this.id; this.matrix = R.matrix(); this.realPath = null; - + this.paper = svg; this.attrs = this.attrs || {}; this._ = { @@ -4363,11 +4371,11 @@ window.Raphael.svg && function (R) { dirty: 1 }; !svg.bottom && (svg.bottom = this); - + this.prev = svg.top; svg.top && (svg.top.next = this); svg.top = this; - + this.next = null; }, elproto = R.el; @@ -4387,7 +4395,7 @@ window.Raphael.svg && function (R) { }); return p; }; - + elproto.rotate = function (deg, cx, cy) { if (this.removed) { return this; @@ -4407,7 +4415,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["r", deg, cx, cy]])); return this; }; - + elproto.scale = function (sx, sy, cx, cy) { if (this.removed) { return this; @@ -4429,7 +4437,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); return this; }; - + elproto.translate = function (dx, dy) { if (this.removed) { return this; @@ -4443,7 +4451,7 @@ window.Raphael.svg && function (R) { this.transform(this._.transform.concat([["t", dx, dy]])); return this; }; - + elproto.transform = function (tstr) { var _ = this._; if (tstr == null) { @@ -4454,7 +4462,7 @@ window.Raphael.svg && function (R) { this.clip && $(this.clip, {transform: this.matrix.invert()}); this.pattern && updatePosition(this); this.node && $(this.node, {transform: this.matrix}); - + if (_.sx != 1 || _.sy != 1) { var sw = this.attrs[has]("stroke-width") ? this.attrs["stroke-width"] : 1; this.attr({"stroke-width": sw}); @@ -4462,17 +4470,17 @@ window.Raphael.svg && function (R) { return this; }; - + elproto.hide = function () { !this.removed && this.paper.safari(this.node.style.display = "none"); return this; }; - + elproto.show = function () { !this.removed && this.paper.safari(this.node.style.display = ""); return this; }; - + elproto.remove = function () { if (this.removed || !this.node.parentNode) { return; @@ -4510,7 +4518,7 @@ window.Raphael.svg && function (R) { hide && this.hide(); return bbox; }; - + elproto.attr = function (name, value) { if (this.removed) { return this; @@ -4571,7 +4579,7 @@ window.Raphael.svg && function (R) { setFillAndStroke(this, params); return this; }; - + elproto.toFront = function () { if (this.removed) { return this; @@ -4585,14 +4593,14 @@ window.Raphael.svg && function (R) { svg.top != this && R._tofront(this, svg); return this; }; - + elproto.toBack = function () { if (this.removed) { return this; } var parent = this.node.parentNode; if (parent.tagName.toLowerCase() == "a") { - parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); + parent.parentNode.insertBefore(this.node.parentNode, this.node.parentNode.parentNode.firstChild); } else if (parent.firstChild != this.node) { parent.insertBefore(this.node, this.node.parentNode.firstChild); } @@ -4600,7 +4608,7 @@ window.Raphael.svg && function (R) { var svg = this.paper; return this; }; - + elproto.insertAfter = function (element) { if (this.removed) { return this; @@ -4614,7 +4622,7 @@ window.Raphael.svg && function (R) { R._insertafter(this, element, this.paper); return this; }; - + elproto.insertBefore = function (element) { if (this.removed) { return this; @@ -4786,7 +4794,7 @@ window.Raphael.svg && function (R) { this._viewBox = [x, y, w, h, !!fit]; return this; }; - + R.prototype.renderfix = function () { var cnvs = this.canvas, s = cnvs.style, @@ -4809,7 +4817,7 @@ window.Raphael.svg && function (R) { } } }; - + R.prototype.clear = function () { R.eve("raphael.clear", this); var c = this.canvas; @@ -4821,7 +4829,7 @@ window.Raphael.svg && function (R) { c.appendChild(this.desc); c.appendChild(this.defs = $("defs")); }; - + R.prototype.remove = function () { eve("raphael.remove", this); this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); @@ -5065,7 +5073,7 @@ window.Raphael.vml && function (R) { if ("arrow-end" in params) { addArrow(res, params["arrow-end"], 1); } - if (params.opacity != null || + if (params.opacity != null || params["stroke-width"] != null || params.fill != null || params.src != null || @@ -5144,7 +5152,7 @@ window.Raphael.vml && function (R) { params["stroke-width"] && (stroke.weight = width); width && width < 1 && (opacity *= width) && (stroke.weight = 1); stroke.opacity = opacity; - + params["stroke-linejoin"] && (stroke.joinstyle = params["stroke-linejoin"] || "miter"); stroke.miterlimit = params["stroke-miterlimit"] || 8; params["stroke-linecap"] && (stroke.endcap = params["stroke-linecap"] == "butt" ? "flat" : params["stroke-linecap"] == "square" ? "square" : "round"); @@ -5191,7 +5199,7 @@ window.Raphael.vml && function (R) { res._.dirty = 1; break; } - + // text-anchor emulation switch (a["text-anchor"]) { case "start": @@ -5319,7 +5327,7 @@ window.Raphael.vml && function (R) { trsfrm = vbt; } R._extractTransform(this, trsfrm); - + var matrix = this.matrix.clone(), skew = this.skew, o = this.node, @@ -5412,7 +5420,7 @@ window.Raphael.vml && function (R) { } cx = cx == null ? bbox.x + bbox.width / 2 : cx; cy = cy == null ? bbox.y + bbox.height / 2 : cy; - + this.transform(this._.transform.concat([["s", sx, sy, cx, cy]])); this._.dirtyT = 1; return this; diff --git a/example/dag/dag.html b/example/dag/dag.html new file mode 100644 index 0000000..7604c4f --- /dev/null +++ b/example/dag/dag.html @@ -0,0 +1,63 @@ + + + + + Dag Graph + + + + + + + +
+ + + diff --git a/lib/components/dag.js b/lib/components/dag.js new file mode 100644 index 0000000..29d8814 --- /dev/null +++ b/lib/components/dag.js @@ -0,0 +1,316 @@ +/*global $, _, define */ +/*! + * Stream的兼容定义 + */ +;(function (name, definition) { + if (typeof define === 'function') { // Module + define(definition); + } else { // Assign to common namespaces or simply the global object (window) + this[name] = definition(function (id) { return this[id];}); + } +})('Dag', function (require) { + var DataV = require('DataV'); + + var Dag = DataV.extend(DataV.Chart, { + initialize: function (node, options) { + this.type = "Dag"; + this.node = this.checkContainer(node); + this.defaults = {}; + // Properties + this.defaults.width = 500; + this.defaults.height = 500; + + // Data bind + /** + * 柱纬度 + */ + this.dimension.name = { + type: "string", + required: true, + index: 0 + }; + /** + * 横向纬度 + */ + this.dimension.deps = { + type: "string", + required: true, + index: 1 + }; + + /** + * 横向纬度 + */ + this.dimension.status = { + type: "string", + required: true, + index: 2 + }; + // 设置选项 + this.setOptions(options); + // 创建画布 + this.createCanvas(); // this.paper + // 创建菜单 + this.createMenu(); // this.menu + // 绑定右键事件 + this.initEvents(); + this.cache = {}; + this.connector = []; + } + }); + + Dag.prototype.setSource = function (source, map) { + this.source = source; + this.map(map); + }; + + Dag.prototype.createMenu = function () { + var that = this; + var menu = $(''); + menu.css({ + position: 'absolute', + margin: 0, + padding: 0, + listStyleType: 'none' + }).wall(); + var item = $('
  • 查看父节点
  • '); + item.click(function () { + that.showDeps(); + menu.wall(); + }); + var item2 = $('
  • 查看子节点
  • '); + item2.click(function () { + that.showDepents(); + menu.wall(); + }); + var item3 = $('
  • 隐藏节点
  • '); + item3.click(function () { + that.hideNode(); + menu.wall(); + }); + menu.append(item).append(item2).append(item3); + this.menu = menu; + $(this.node).append(menu); + }; + + Dag.prototype.initEvents = function () { + var that = this; + + $(this.paper.canvas).on('contextmenu', function (e) { + var elem = that.paper.getElementByPoint(e.pageX, e.pageY); + if (elem && elem.data('name')) { + that.expand(elem); + } + return false; + }).click(function (e) { + var elem = that.paper.getElementByPoint(e.pageX, e.pageY); + if (elem && elem.data('name')) { + that.toggle(elem); + } + that.menu.wall(); + }).dblclick(function (e) { + // TODO: 双击事件 + }); + }; + + /** + * 找出先前节点 + */ + Dag.prototype.showDeps = function () { + var that = this; + var deps = this.getDeps(this.menu.data('name')); + var node = this.menu.data('node'); + var bbox = node.getBBox(); + var pos = { + x: bbox.x - 50 + }; + var half = (deps.length - 1) / 2; + deps.forEach(function (name, i) { + pos.y = bbox.y + (i - half) * 50; + var from = that.drawNode(name, pos, node); + that.drawLine(from, node); + }); + }; + + /** + * 隐藏节点 + */ + Dag.prototype.hideNode = function () { + var name = this.menu.data('name'); + var froms = _.filter(this.connector, function (line) { + return line[0] === name && line[3]; + }); + var tos = _.filter(this.connector, function (line) { + return line[1] === name && line[3]; + }); + var set = this.cache[name].set; + if (froms.length === 0 && tos.length === 0) { + alert("唯一节点,不能隐藏"); + } else { + if (froms.length === 0) { + set.hide(); + tos.forEach(function (line) { + line[2].hide(); + line[3] = false; + }); + } else if (tos.length === 0) { + set.hide(); + froms.forEach(function (line) { + line[2].hide(); + line[3] = false; + }); + } else { + alert("还有相关节点,不能隐藏"); + } + } + }; + + Dag.prototype.showDepents = function () { + var that = this; + var depents = this.getDependents(this.menu.data('name')); + var node = this.menu.data('node'); + var bbox = node.getBBox(); + var pos = { + x: bbox.x2 + 50 + }; + var half = (depents.length - 1) / 2; + depents.forEach(function (name, i) { + pos.y = bbox.y + (i - half) * 50; + var to = that.drawNode(name, pos, node); + that.drawLine(node, to); + }); + }; + + /** + * 找出节点的依赖 + */ + Dag.prototype.getDeps = function (name) { + var mapping = this.mapping; + var source = this.source; + var item = _.find(source, function (item) { + return item[mapping.name] === name; + }); + var deps = item ? (item[mapping.deps] || []) : []; + return deps; + }; + + /** + * 找出依赖它的节点 + */ + Dag.prototype.getDependents = function (name) { + var mapping = this.mapping; + var source = this.source; + return _.filter(source, function (item) { + return _.indexOf(item[mapping.deps], name) !== -1; + }).map(function (item) { + return item[mapping.name]; + }); + }; + + /** + * 展开右键菜单 + */ + Dag.prototype.expand = function (elem) { + var name = elem.data('name'); + var menu = this.menu; + var bbox = elem.getBBox(); + menu.css({ + left: bbox.x + (bbox.width) / 2, + top: bbox.y + (bbox.height) / 2 + }) + .unwall() + .data('name', name) + .data('node', elem); + }; + + Dag.prototype.toggle = function (elem) { + var name = elem.data('name'); + var mapping = this.mapping; + var node = _.find(this.source, function (item) { + return item[mapping.name] === name; + }); + if (node[mapping.status]) { + node[mapping.status] = false; + this.cache[name].set[1].attr('fill', '#f00'); + } else { + node[mapping.status] = true; + this.cache[name].set[1].attr('fill', '#0f0'); + } + }; + + /** + * 显示已经绘制的节点 + */ + Dag.prototype.showNode = function (name, direction) { + this.cache[name].set.show(); + // 显示连接线 + var line = _.find(this.connector, function (item) { + var index = direction === 'to' ? 0 : 1; + return item[index] === name; + }); + if (line) { + line[2].show(); + line[3] = true; + } + }; + + /** + * 绘制节点 + */ + Dag.prototype.drawNode = function (nodeName, opts, direction) { + var that = this; + var item = _.find(this.source, function (item) { + return item[that.mapping.name] === nodeName; + }); + var name = item ? item[that.mapping.name] : 'unkown'; + + if (this.cache[name]) { + this.showNode(name, direction); + return this.cache[name].set[0]; + } + + var pos = { + x: 250, + y: 250 + }; + + if (opts) { + _.extend(pos, opts); + } + + var paper = this.paper; + var set = paper.set(); + var text = paper.text(pos.x, pos.y, name); + text.data('name', name); + // Creates circle at x = 50, y = 40, with radius 10 + var width = text.getBBox().width; + var radius = width / 2 + (width > 50 ? 2 : 5); + var circle = paper.circle(pos.x, pos.y, radius); + circle.toBack(); + // Sets the stroke attribute of the circle to white + circle.attr("fill", "red").attr("stroke", "#000"); + this.cache[name] = { + pos: pos, + set: set.push(text, circle) + }; + return text; + }; + + Dag.prototype.drawLine = function (from, to) { + var paper = this.paper; + var pos = from.getMidpoint(); + var mid = to.getMidpoint(); + var path = "M" + pos.x + "," + pos.y + "L" + mid.x + "," + mid.y; + var line = paper.path(path).toBack(); + this.connector.push([from.data('name'), to.data('name'), line, true]); + }; + + /** + * 渲染初始节点 + */ + Dag.prototype.render = function (name) { + this.drawNode(name); + }; + + return Dag; +}); diff --git a/lib/datav.js b/lib/datav.js index 21816fe..ade6d8c 100644 --- a/lib/datav.js +++ b/lib/datav.js @@ -235,7 +235,7 @@ dH = endH - startH; dNum = endNum - startNum; } - + var h = (startH + dH * num) / 360; var s = (70 + Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; var b = (100 - Math.abs(4 - (startNum + dNum * num) % 8) * 5) / 100; @@ -558,6 +558,15 @@ return ret; }; + /** + * 创建画布 + */ + Chart.prototype.createCanvas = function () { + var conf = this.defaults; + this.node.style.position = "relative"; + this.paper = new Raphael(this.node, conf.width, conf.height); + }; + /** * 拥有一个组件 */