From d8f4dd3a174fbc72f57240bebeefbda4093fae11 Mon Sep 17 00:00:00 2001 From: wout Date: Sat, 12 Jan 2013 16:25:24 +0100 Subject: Ensuring polygons and polylines are at position 0,0 within their wrapper --- src/poly.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/poly.js b/src/poly.js index 8867604..978111c 100644 --- a/src/poly.js +++ b/src/poly.js @@ -2,7 +2,17 @@ SVG.Poly = { // Set polygon data with default zero point if no data is passed plot: function(points) { - return this.attr('points', points || '0,0'); + this.attr('points', points || '0,0'); + + var box = this.bbox(); + + if (box.x != 0 || box.y != 0) + this.transform({ + x: -box.x, + y: -box.y + }); + + return this; }, // Move path using translate move: function(x, y) { -- cgit v1.2.3