From 7523fb951aabc24bf290028c348cbe46bd846f86 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 23 Jan 2012 22:22:02 +0000 Subject: graphing with raphael --- test/ import mapinfo_files/41o-vK6-8wL._SL70_.jpg | Bin 0 -> 815 bytes ...0_PI13-percent,BottomRight,0,0_CR0,0,57,70_.jpg | Bin 0 -> 2238 bytes ...0_PI16-percent,BottomRight,0,0_CR0,0,56,70_.jpg | Bin 0 -> 2149 bytes test/ import mapinfo_files/ads-common.js | 538 ++ test/ import mapinfo_files/asw.js | 4 + test/ import mapinfo_files/basic.css | 299 + test/ import mapinfo_files/basic070802.css | 297 + test/ import mapinfo_files/blinklistsm.gif | Bin 0 -> 260 bytes test/ import mapinfo_files/cm.html | 3 + test/ import mapinfo_files/delicioussm.gif | Bin 0 -> 96 bytes test/ import mapinfo_files/diggsm.gif | Bin 0 -> 245 bytes test/ import mapinfo_files/furlsm.gif | Bin 0 -> 954 bytes test/ import mapinfo_files/ga.js | 51 + test/ import mapinfo_files/iu3.html | 4 + test/ import mapinfo_files/jeditcode.css | 158 + test/ import mapinfo_files/mapserver_logo.gif | Bin 0 -> 2603 bytes .../postgisinaction_small.jpg | Bin 0 -> 5282 bytes test/ import mapinfo_files/postgresql95x51_4.gif | Bin 0 -> 2534 bytes test/ import mapinfo_files/printer.css | 1 + test/ import mapinfo_files/redditsm.gif | Bin 0 -> 1052 bytes test/ import mapinfo_files/rss.png | Bin 0 -> 407 bytes .../stock_elephant_060_rev.gif | Bin 0 -> 4641 bytes test/CousinMarriageWorld.svgz | Bin 424803 -> 0 bytes test/Ireland_complete.svg | 811 --- test/Ireland_trad_counties_named.svg | 1481 ---- "test/Rapha\303\253l \302\267 Australia.html" | 162 - test/Republic_of_Ireland_counties_and_cities.svg | 7494 -------------------- test/World_map_-_low_resolution.svgz | Bin 23948 -> 0 bytes test/analytics/analytics.html | 96 + test/analytics/analytics.js | 141 + test/analytics/demo-print.css | 20 + test/analytics/demo.css | 23 + test/analytics/popup.js | 121 + test/demo-print.css | 20 - test/demo.css | 23 - test/g.raphael-min.js | 7 - test/g.raphael/README.md | 17 + test/g.raphael/docs/bar.markdown | 104 + test/g.raphael/docs/dot.markdown | 135 + test/g.raphael/docs/g.markdown | 7 + test/g.raphael/docs/line.markdown | 159 + test/g.raphael/docs/pie.markdown | 150 + .../examples/barchart/barchart_basic.html | 20 + .../examples/barchart/barchart_custom_axis.html | 23 + .../examples/barchart/barchart_custom_spacing.html | 21 + .../examples/barchart/barchart_horizontal.html | 20 + .../examples/barchart/barchart_hover.html | 27 + .../examples/barchart/barchart_hoverCol.html | 29 + .../examples/barchart/barchart_stacked.html | 28 + .../examples/barchart/barchart_text_axis.html | 25 + test/g.raphael/examples/dot/dotchart_basic.html | 22 + test/g.raphael/examples/dot/dotchart_href.html | 28 + test/g.raphael/examples/dot/dotchart_labels.html | 23 + test/g.raphael/examples/dot/dotchart_symbols.html | 22 + .../examples/linechart/linechart_basic.html | 21 + .../examples/linechart/linechart_interactive.html | 27 + .../examples/linechart/linechart_opts.html | 22 + .../examples/linechart/linechart_shading.html | 28 + .../examples/piechart/piechart_basic.html | 24 + .../g.raphael/examples/piechart/piechart_each.html | 28 + .../examples/piechart/piechart_hover.html | 28 + .../examples/piechart/piechart_hover_adv.html | 41 + .../examples/piechart/piechart_rotate.html | 28 + .../examples/piechart/piechart_with_legend.html | 20 + test/g.raphael/examples/raphael-min.js | 116 + test/g.raphael/g.bar-min.js | 7 + test/g.raphael/g.bar.js | 386 + test/g.raphael/g.dot-min.js | 7 + test/g.raphael/g.dot.js | 110 + test/g.raphael/g.line-min.js | 7 + test/g.raphael/g.line.js | 254 + test/g.raphael/g.pie-min.js | 1 + test/g.raphael/g.pie.js | 205 + test/g.raphael/g.raphael-min.js | 7 + test/g.raphael/g.raphael.js | 475 ++ test/g.raphael/test.html | 58 + test/g.raphael/test2.html | 55 + test/index.html | 50 - test/main.js | 36 - test/raphael-svg-import | 1 + test/raphael.js | 5462 ++++++++++++++ test/when/demo-print.css | 13 + test/when/demo.css | 21 + test/when/index.html | 36 + test/when/raphael-utils.js | 33 + test/when/when.js | 187 + test/where/ import mapinfo.html | 367 + test/where/CousinMarriageWorld.svgz | Bin 0 -> 424803 bytes test/where/Ireland_complete.svg | 291 + test/where/Ireland_inks.svg | 312 + test/where/Ireland_just_counties.svg | 316 + test/where/Ireland_trad_counties_inks.svg | 1600 +++++ test/where/Ireland_trad_counties_named.svg | 1481 ++++ test/where/Ireland_trad_counties_named_RU.svg | 1611 +++++ .../where/Rapha\303\253l \302\267 Australia.html" | 162 + .../Republic_of_Ireland_counties_and_cities.svg | 7494 ++++++++++++++++++++ test/where/World_map_-_low_resolution.svgz | Bin 0 -> 23948 bytes test/where/demo-print.css | 20 + test/where/demo.css | 23 + test/where/g.raphael-min.js | 7 + test/where/importdemo.html | 813 +++ test/where/index.html | 50 + test/where/main.js | 42 + test/where/raphael-svg-import.js | 878 +++ thoughts | 0 thoughts.schoolties.odt | Bin 0 -> 13343 bytes 106 files changed, 25791 insertions(+), 10084 deletions(-) create mode 100644 test/ import mapinfo_files/41o-vK6-8wL._SL70_.jpg create mode 100644 test/ import mapinfo_files/51+ADVi+EdL._OU01_SL70_PI13-percent,BottomRight,0,0_CR0,0,57,70_.jpg create mode 100644 test/ import mapinfo_files/51EL0wD7xHL._OU01_SL70_PI16-percent,BottomRight,0,0_CR0,0,56,70_.jpg create mode 100644 test/ import mapinfo_files/ads-common.js create mode 100644 test/ import mapinfo_files/asw.js create mode 100644 test/ import mapinfo_files/basic.css create mode 100644 test/ import mapinfo_files/basic070802.css create mode 100644 test/ import mapinfo_files/blinklistsm.gif create mode 100644 test/ import mapinfo_files/cm.html create mode 100644 test/ import mapinfo_files/delicioussm.gif create mode 100644 test/ import mapinfo_files/diggsm.gif create mode 100644 test/ import mapinfo_files/furlsm.gif create mode 100644 test/ import mapinfo_files/ga.js create mode 100644 test/ import mapinfo_files/iu3.html create mode 100644 test/ import mapinfo_files/jeditcode.css create mode 100644 test/ import mapinfo_files/mapserver_logo.gif create mode 100644 test/ import mapinfo_files/postgisinaction_small.jpg create mode 100644 test/ import mapinfo_files/postgresql95x51_4.gif create mode 100644 test/ import mapinfo_files/printer.css create mode 100644 test/ import mapinfo_files/redditsm.gif create mode 100644 test/ import mapinfo_files/rss.png create mode 100644 test/ import mapinfo_files/stock_elephant_060_rev.gif delete mode 100644 test/CousinMarriageWorld.svgz delete mode 100644 test/Ireland_complete.svg delete mode 100644 test/Ireland_trad_counties_named.svg delete mode 100644 "test/Rapha\303\253l \302\267 Australia.html" delete mode 100644 test/Republic_of_Ireland_counties_and_cities.svg delete mode 100644 test/World_map_-_low_resolution.svgz create mode 100644 test/analytics/analytics.html create mode 100644 test/analytics/analytics.js create mode 100644 test/analytics/demo-print.css create mode 100644 test/analytics/demo.css create mode 100644 test/analytics/popup.js delete mode 100644 test/demo-print.css delete mode 100644 test/demo.css delete mode 100644 test/g.raphael-min.js create mode 100644 test/g.raphael/README.md create mode 100644 test/g.raphael/docs/bar.markdown create mode 100644 test/g.raphael/docs/dot.markdown create mode 100644 test/g.raphael/docs/g.markdown create mode 100644 test/g.raphael/docs/line.markdown create mode 100644 test/g.raphael/docs/pie.markdown create mode 100644 test/g.raphael/examples/barchart/barchart_basic.html create mode 100644 test/g.raphael/examples/barchart/barchart_custom_axis.html create mode 100644 test/g.raphael/examples/barchart/barchart_custom_spacing.html create mode 100644 test/g.raphael/examples/barchart/barchart_horizontal.html create mode 100644 test/g.raphael/examples/barchart/barchart_hover.html create mode 100644 test/g.raphael/examples/barchart/barchart_hoverCol.html create mode 100644 test/g.raphael/examples/barchart/barchart_stacked.html create mode 100644 test/g.raphael/examples/barchart/barchart_text_axis.html create mode 100644 test/g.raphael/examples/dot/dotchart_basic.html create mode 100644 test/g.raphael/examples/dot/dotchart_href.html create mode 100644 test/g.raphael/examples/dot/dotchart_labels.html create mode 100644 test/g.raphael/examples/dot/dotchart_symbols.html create mode 100644 test/g.raphael/examples/linechart/linechart_basic.html create mode 100644 test/g.raphael/examples/linechart/linechart_interactive.html create mode 100644 test/g.raphael/examples/linechart/linechart_opts.html create mode 100644 test/g.raphael/examples/linechart/linechart_shading.html create mode 100644 test/g.raphael/examples/piechart/piechart_basic.html create mode 100644 test/g.raphael/examples/piechart/piechart_each.html create mode 100644 test/g.raphael/examples/piechart/piechart_hover.html create mode 100644 test/g.raphael/examples/piechart/piechart_hover_adv.html create mode 100644 test/g.raphael/examples/piechart/piechart_rotate.html create mode 100644 test/g.raphael/examples/piechart/piechart_with_legend.html create mode 100644 test/g.raphael/examples/raphael-min.js create mode 100644 test/g.raphael/g.bar-min.js create mode 100644 test/g.raphael/g.bar.js create mode 100644 test/g.raphael/g.dot-min.js create mode 100644 test/g.raphael/g.dot.js create mode 100644 test/g.raphael/g.line-min.js create mode 100644 test/g.raphael/g.line.js create mode 100644 test/g.raphael/g.pie-min.js create mode 100644 test/g.raphael/g.pie.js create mode 100644 test/g.raphael/g.raphael-min.js create mode 100644 test/g.raphael/g.raphael.js create mode 100644 test/g.raphael/test.html create mode 100644 test/g.raphael/test2.html delete mode 100644 test/index.html delete mode 100644 test/main.js create mode 160000 test/raphael-svg-import create mode 100644 test/raphael.js create mode 100644 test/when/demo-print.css create mode 100644 test/when/demo.css create mode 100644 test/when/index.html create mode 100644 test/when/raphael-utils.js create mode 100644 test/when/when.js create mode 100644 test/where/ import mapinfo.html create mode 100644 test/where/CousinMarriageWorld.svgz create mode 100644 test/where/Ireland_complete.svg create mode 100644 test/where/Ireland_inks.svg create mode 100644 test/where/Ireland_just_counties.svg create mode 100644 test/where/Ireland_trad_counties_inks.svg create mode 100644 test/where/Ireland_trad_counties_named.svg create mode 100644 test/where/Ireland_trad_counties_named_RU.svg create mode 100644 "test/where/Rapha\303\253l \302\267 Australia.html" create mode 100644 test/where/Republic_of_Ireland_counties_and_cities.svg create mode 100644 test/where/World_map_-_low_resolution.svgz create mode 100644 test/where/demo-print.css create mode 100644 test/where/demo.css create mode 100644 test/where/g.raphael-min.js create mode 100644 test/where/importdemo.html create mode 100644 test/where/index.html create mode 100644 test/where/main.js create mode 100644 test/where/raphael-svg-import.js create mode 100644 thoughts create mode 100644 thoughts.schoolties.odt diff --git a/test/ import mapinfo_files/41o-vK6-8wL._SL70_.jpg b/test/ import mapinfo_files/41o-vK6-8wL._SL70_.jpg new file mode 100644 index 0000000..53b462d Binary files /dev/null and b/test/ import mapinfo_files/41o-vK6-8wL._SL70_.jpg differ diff --git a/test/ import mapinfo_files/51+ADVi+EdL._OU01_SL70_PI13-percent,BottomRight,0,0_CR0,0,57,70_.jpg b/test/ import mapinfo_files/51+ADVi+EdL._OU01_SL70_PI13-percent,BottomRight,0,0_CR0,0,57,70_.jpg new file mode 100644 index 0000000..7c9e020 Binary files /dev/null and b/test/ import mapinfo_files/51+ADVi+EdL._OU01_SL70_PI13-percent,BottomRight,0,0_CR0,0,57,70_.jpg differ diff --git a/test/ import mapinfo_files/51EL0wD7xHL._OU01_SL70_PI16-percent,BottomRight,0,0_CR0,0,56,70_.jpg b/test/ import mapinfo_files/51EL0wD7xHL._OU01_SL70_PI16-percent,BottomRight,0,0_CR0,0,56,70_.jpg new file mode 100644 index 0000000..ccd6e0b Binary files /dev/null and b/test/ import mapinfo_files/51EL0wD7xHL._OU01_SL70_PI16-percent,BottomRight,0,0_CR0,0,56,70_.jpg differ diff --git a/test/ import mapinfo_files/ads-common.js b/test/ import mapinfo_files/ads-common.js new file mode 100644 index 0000000..b065450 --- /dev/null +++ b/test/ import mapinfo_files/ads-common.js @@ -0,0 +1,538 @@ +// Color library + +// RGB object +function AmazonRGB(red, green, blue) +{ + // These are integers between 0 and 255 inclusive. + this.r = red; + this.g = green; + this.b = blue; +} + +// Accessor methods for the RGB components. +AmazonRGB.prototype.getR = function() { return this.r; }; +AmazonRGB.prototype.getG = function() { return this.g; }; +AmazonRGB.prototype.getB = function() { return this.b; }; + +// Defines and returns the 6-digit hex representation +// of this RGB color. +AmazonRGB.prototype.getHex = function() { + if (!this.hex) + { + var map = '0123456789ABCDEF'; + this.hex = '' + + map.substr(Math.floor(this.r / 16), 1) + + map.substr((this.r % 16), 1) + + map.substr(Math.floor(this.g / 16), 1) + + map.substr((this.g % 16), 1) + + map.substr(Math.floor(this.b / 16), 1) + + map.substr((this.b % 16), 1); + } + return this.hex; +}; + +// Returns the equivalent HSV object. +AmazonRGB.prototype.toHSV = function() { + // Normalize RGB values for color space transform. + var r = this.r / 255; + var g = this.g / 255; + var b = this.b / 255; + + // Helper values for color space transform. + var max = (r > g) ? r : g; + max = (max > b) ? max : b; + var min = (r < g) ? r : g; + min = (min < b) ? min : b; + + var delta = max - min; + + // Color space transform. + var v = max; + var s = 0; + + if (max > 0) { s = delta / max; } + + var h = 0; + + if (delta > 0) + { + if ((max == r) && (max != g)) + { + h += (g - b) / delta; + } + if ((max == g) && (max != b)) + { + h += (2 + (b - r) / delta); + } + if ((max == b) && (max != r)) + { + h += (4 + (r - g) / delta); + } + h = h * 60; + if (h < 0) { h += 360; } + } + + var result = new AmazonHSV(h, s, v); + return result; +}; + + +// HSV object +function AmazonHSV(hue, saturation, value) +{ + // These are real numbers between 0 and 1 inclusive. + this.h = hue; + this.s = saturation; + this.v = value; +} + +// Accessor methods for the HSV components. +AmazonHSV.prototype.getH = function() { return this.h; }; +AmazonHSV.prototype.getS = function() { return this.s; }; +AmazonHSV.prototype.getV = function() { return this.v; }; + +// Returns the equivalent RGB object. +AmazonHSV.prototype.toRGB = function() { + var sat_r; + var sat_g; + var sat_b; + + // Color space transform + if (this.h < 120) + { + sat_r = (120 - this.h) / 60; + sat_g = this.h / 60; + sat_b = 0; + } + else if (this.h < 240) + { + sat_r = 0; + sat_g = (240 - this.h) / 60; + sat_b = (this.h - 120) / 60; + } + else + { + sat_r = (this.h - 240) / 60; + sat_g = 0; + sat_b = (360 - this.h) / 60; + } + + if (sat_r > 1) { sat_r = 1; } + if (sat_g > 1) { sat_g = 1; } + if (sat_b > 1) { sat_b = 1; } + + var result = new AmazonRGB( + Math.round((1 - this.s + this.s * sat_r) * this.v * 255), + Math.round((1 - this.s + this.s * sat_g) * this.v * 255), + Math.round((1 - this.s + this.s * sat_b) * this.v * 255) + ); + + return result; +}; + + +/* Container object that holds an RGB object and an HSV object. + This is the catch-all type that gives you everything + you will need up front. With this object, you can create + a color from RGB values, HSV values, or a hex string. + + Upon object creation, you are not guaranteed that any of the + private properties exist yet (they are created as needed). + Therefore, you must use accessor methods to get each property + of this object. +*/ +function AmazonColor(type, a, b, c) +{ + if (type == 'rgb') + { + this.rgb = new AmazonRGB(a,b,c); + this.r = a; + this.g = b; + this.b = c; + } + else if (type == 'hsv') + { + this.hsv = new AmazonHSV(a,b,c); + this.h = a; + this.s = b; + this.v = c; + } + else if (type.match(/[0-9a-f]{6}/i)) + { + // 'type' argument was a hex color value + var map = '0123456789ABCDEF'; + this.r = map.indexOf(type.substr(0,1)) * 16 + map.indexOf(type.substr(1,1)); + this.g = map.indexOf(type.substr(2,1)) * 16 + map.indexOf(type.substr(3,1)); + this.b = map.indexOf(type.substr(4,1)) * 16 + map.indexOf(type.substr(5,1)); + this.rgb = new AmazonRGB(this.r, this.g, this.b); + this.hex = type; + } + else + { + // nothing to work with + return null; + } +} + +// Accessor methods for properties. +// Requested properties are calculated when first requested if necessary, +// then stored for later. +AmazonColor.prototype.getR = function() { + if (!this.r) + { + if (!this.rgb) { this.rgb = this.hsv.toRGB(); } + this.r = this.rgb.getR(); + } + return this.r; +}; + +AmazonColor.prototype.getG = function() { + if (!this.g) + { + if (!this.rgb) { this.rgb = this.hsv.toRGB(); } + this.g = this.rgb.getG(); + } + return this.g; +}; + +AmazonColor.prototype.getB = function() { + if (!this.b) + { + if (!this.rgb) { this.rgb = this.hsv.toRGB(); } + this.b = this.rgb.getB(); + } + return this.b; +}; + +AmazonColor.prototype.getH = function() { + if (!this.h) + { + if (!this.hsv) { this.hsv = this.rgb.toHSV(); } + this.h = this.hsv.getH(); + } + return this.h; +}; + +AmazonColor.prototype.getS = function() { + if (!this.s) + { + if (!this.hsv) { this.hsv = this.rgb.toHSV(); } + this.s = this.hsv.getS(); + } + return this.s; +}; + +AmazonColor.prototype.getV = function() { + if (!this.v) + { + if (!this.hsv) { this.hsv = this.rgb.toHSV(); } + this.v = this.hsv.getV(); + } + return this.v; +}; + +AmazonColor.prototype.getHex = function() { + if (!this.hex) + { + if (!this.rgb) { this.rgb = this.hsv.toRGB(); } + this.hex = this.rgb.getHex(); + } + return this.hex; +}; + +// Return a contrasting color of the same hue. +AmazonColor.prototype.getContrasting = function() { + var newH = this.getH(); + var newS = this.getS(); + var newV = this.getV(); + + if (newS == 0) + { + // Grayscale; don't change saturation + newV = (newV + 0.5) % 1; + } + else + { + newS = (newS + 0.5) % 1; + newV = (newV + 0.5) % 1; + + // Adjust color for better contrast if it's in the deep blue range. + if ((newH > 200) && (newH < 275)) + { + if ((newS >= 0.5) && (newV >= 0.5)) + { + // High saturation and value, decrease saturation + newS = newS / 2; + } + else if ((newS <= 0.5) && (newV <= 0.5)) + { + // Low saturation and value, increase value + newV = newV + 0.5; + } + } + } + + return new AmazonColor('hsv', newH, newS, newV); +}; + +// Return a similar color of the same hue. +AmazonColor.prototype.getSimilar = function() { + var newH = this.getH(); + var newS = this.getS(); + var newV = this.getV(); + + // Change it more for highly-saturated colors. + var tweak = (newS > 0.8) ? 0.1 : 0; + + if (newV > 0.6) { newV = newV - 0.2 - tweak; } + else if (newV < 0.4) { newV = newV + 0.2 + tweak; } + else { newV = newV - 0.3; } + + // Adjust color for better contrast if it's in the deep blue range. + if ((newH > 200) && (newH < 275)) + { + if (newS > 0.8) { newS = newS - 0.4; } + } + + return new AmazonColor('hsv', newH, newS, newV); +}; + +// Simple test to see if a color is "dark" or not. +AmazonColor.prototype.isDark = function() { + var rval = false; + var v = this.getV(); + + if (v < 0.6) + { + // Low value...it's dark. + rval = true; + } + else + { + var h = this.getH(); + var s = this.getS(); + + // A strongly-saturated blue or purple is considered "dark". + if ((h > 200) && (h < 275)) + { + if (s > 0.5) { rval = true; } + } + } + + return rval; +}; + + + +var oldErrorHandler = window.onerror; +window.onerror = amazon_error_handler; + +// Set our defaults. +if(!window.amazon_ad_width) { amazon_ad_width = 728; } +if(!window.amazon_ad_height) { amazon_ad_height = 90; } +if(!window.amazon_ad_tag) { amazon_ad_tag = ""; } +if(!window.amazon_ad_price) { amazon_ad_price = "all"; } +if(!window.amazon_ad_border) { amazon_ad_border = 'show'; } +if(!window.amazon_ad_logo) { amazon_ad_logo = 'show'; } +if(!window.amazon_ad_product_images) { amazon_ad_product_images = 'show'; } +if(!window.amazon_ad_link_target) { amazon_ad_link_target = "same"; } +if(!window.amazon_ad_referrer) { amazon_ad_referrer = "current"; } +if(!window.amazon_ad_discount) { amazon_ad_discount = "add"; } +if(!window.amazon_ad_linkcode) { amazon_ad_linkcode = "op1"; } + +amazon_pvid(); + +// Write the iframe +document.write(''); + +// Flush parameters after render to restore defaults. +amazon_ad_width = null; +amazon_ad_height = null; +amazon_ad_price = null; +amazon_ad_border = null; +amazon_ad_logo = null; +amazon_ad_product_images = null; +amazon_ad_link_target = null; +amazon_ad_referrer = null; +amazon_ad_exclude = null; +amazon_ad_include = null; +amazon_ad_categories = null; +amazon_ad_discount = null; +amazon_ad_linkcode = null; +amazon_ad_title = null; + +window.onerror = oldErrorHandler; + +//------------- +// HELPER FUNCTIONS +//------------- +function amazon_generate_url() +{ + // Common stuff + var amazon_q = window.location.protocol + "//" + amazon_ad_rcm + "/e/cm?"; + amazon_q += "t=" + amazon_ad_tag; + amazon_q += "&o=" + amazon_ad_o; + amazon_q += "&p=" + amazon_p(amazon_ad_width,amazon_ad_height); + amazon_q += "&l=" + amazon_ad_linkcode; + amazon_q += "&pvid=" + amazon_ad_pvid; + + // Referring URL should be the parent location if the ad page is within an iframe. + amazon_q += "&ref-url=" + escape((amazon_iframe() || (amazon_ad_referrer == 'parent')) ? document.referrer : document.location); + amazon_q = amazon_q.replace(/\+/g,'%2B'); + + amazon_q += "&ref-title=" + escape(document.title); + + // get referrer of the page serving these ads, if we can + try{ + var referrer = top.document.referrer; + amazon_q += "&ref-ref=" + escape(referrer); + } + catch(e) + {} + + // Colors + amazon_q+="&bgc="+amazon_fix_color(window.amazon_color_background, "FFFFFF"); + amazon_q+="&bdc="+amazon_fix_color(window.amazon_color_border, "000000"); + amazon_q+="&pcc="+amazon_fix_color(window.amazon_color_price, "990000"); + amazon_q+="&tec="+amazon_fix_color(window.amazon_color_text, "000000"); + amazon_q+="&tic="+amazon_fix_color(window.amazon_color_link, "3399FF"); + amazon_q+="&ac=" +amazon_fix_color(window.amazon_color_logo, "CC6600"); + + var bgc = new AmazonColor(amazon_fix_color(window.amazon_color_background, "A1A1A1")); + var pvc = bgc.getSimilar(); + amazon_q+="&pvc="+pvc.getHex(); + + var bdc = new AmazonColor(amazon_fix_color(window.amazon_color_border, "000000")); + if (bdc.isDark()) { amazon_q+="&lgl=1"; } + + // Display options + if(amazon_ad_price=="all") {amazon_q+="&mp=1";} + if(amazon_ad_border=='hide') {amazon_q+="&hb=1";} + if(amazon_ad_logo=='hide') {amazon_q+="&hl=1";} + if(amazon_ad_product_images=='hide') {amazon_q+="&hp=1";} + if(amazon_ad_link_target=="new") {amazon_q+="&tg=_blank";} + if(amazon_ad_discount=="add") {amazon_q+="&dsc=1";} + + // Advanced options + if(window.amazon_ad_exclude) + { + amazon_q += '&exwords=' + filterKeywords(amazon_ad_exclude); + } + + if(window.amazon_ad_include) + { + amazon_q += '&inwords=' + filterKeywords(amazon_ad_include); + } + + if(window.amazon_ad_categories) {amazon_q+='&incats='+amazon_ad_categories;} + + if(window.amazon_ad_title) + { + // Change all characters to their numerical forms for inclusion in a URI + var codes = new Array; + for (var i = 0; i < amazon_ad_title.length; ++i) { codes.push(amazon_ad_title.charCodeAt(i)); } + var url_amazon_ad_title = codes.toString(); + amazon_q+='&title='+url_amazon_ad_title; + } + + amazon_q += '&f=ifr'; + var e = (document.characterSet) ? document.characterSet : document.charset; + if (e) { amazon_q += '&e='+e.toLowerCase(); } + + return amazon_q; +} + +//takes a string keywords argument and makes sure it only contains +//the allowed number of phrases +function filterKeywords(keywords) +{ + var keyword_limit = 5; + + var rtn_keywords; + if(keywords) + { + var items = keywords.split(/;/); + if (items.length > keyword_limit) + { + items = items.slice(0,keyword_limit); + rtn_keywords = items.join(';'); + } + else + { + rtn_keywords = keywords; + } + } + + return rtn_keywords; +} + +function amazon_p(w, h) +{ + var p = new Array(); + p["120x150"] = 6; + p["120x240"] = 8; + p["180x150"] = 9; + p["120x450"] = 10; + p["120x600"] = 11; + p["300x250"] = 12; + p["468x60"] = 13; + p["160x600"] = 14; + p["468x240"] = 15; + p["468x336"] = 16; + p["600x520"] = 36; + p["728x90"] = 48; + + return p[w + "x" + h]; +} + +function amazon_iframe() +{ + var rval = false; + if (document.body) + { + rval = ((document.referrer != '') && ((document.body.clientWidth < (1.5 * amazon_ad_width)) && (document.body.clientHeight < (1.5 * amazon_ad_height)))); + } + else if (document.documentElement) + { + rval = ((document.referrer != '') && ((document.documentElement.clientWidth < (1.5 * amazon_ad_width)) && (document.documentElement.clientHeight < (1.5 * amazon_ad_height)))); + } + return rval; +} + +function amazon_fix_color($color, $dflt) +{ + if(!$color) { return $dflt; } + if($color.length != 6) { return $dflt; } + $color = $color.toUpperCase(); + var $h2d = "0123456789ABCDEF"; + for(i = 0; i < 6; i++) + { + var $x = $color.charAt(i); + if($h2d.indexOf($x) == -1 ) + { + return $dflt; + } + } + return $color; +} + +function amazon_pvid() +{ + if(window.amazon_ad_pvid) + { + return amazon_ad_pvid; + } + + amazon_ad_pvid = ""; + + var $h2d = "0123456789ABCDEF"; + for(i = 0; i < 16; i++) + { + amazon_ad_pvid += $h2d.charAt(Math.floor( 16 * Math.random() )); + } +} + +function amazon_error_handler() +{ + return true; +} diff --git a/test/ import mapinfo_files/asw.js b/test/ import mapinfo_files/asw.js new file mode 100644 index 0000000..db94510 --- /dev/null +++ b/test/ import mapinfo_files/asw.js @@ -0,0 +1,4 @@ +amazon_ad_o = 1; +amazon_ad_linkcode = 'sb3'; +amazon_ad_rcm = "rcm.amazon.com"; +document.write(""); diff --git a/test/ import mapinfo_files/basic.css b/test/ import mapinfo_files/basic.css new file mode 100644 index 0000000..5ad10a7 --- /dev/null +++ b/test/ import mapinfo_files/basic.css @@ -0,0 +1,299 @@ +/* Presentation Stylesheet */ + +/**#lselect h3, #lresources h3, #larchives h3 { + height: 23px; + width: 150px; + margin: 0; +} **/ + +@page { + size: 7.5in 9.5in; + margin: 16mm 16mm 16mm 16mm; + } + + div.chapter, div.appendix { + page-break-after: always; + } + +.select{ + z-index: 7; +} + +.head { + color: #cdba91; + font: caption; + font-family: 'Georgia'; + font-size: large; + font-style: normal; + font-variant: small-caps; + font-weight: bold; +} + +.header_title { color:white;background-color:#003333;font-family: Georgia} + + +#linkList{ + position:absolute; + top:10px; + left:10px; + z-index:5; + width:150px; + /*background-image:url(images/zbg.gif); + background-position:0 -401px;*/ + overflow:hidden; + padding-bottom:0px; +} + + +#linkList h3{ + height:60px; + width:150px; + background-position:0 0; +} + +/* --// lists --// */ + +#linkList li { + background: #fefefe; + padding: 5px 7px; + border-bottom: 1px solid #DCD5B8; + text-transform: uppercase; + font-size: 9px; +} +#linkList li:hover { background: #DCD5B8; } + +/*#linkList2 { font: 10px Tahoma, Verdana, Arial, sans-serif; width: 220px;} +#linkList p, #linkList li{ font: x-small/1.6em tahoma, verdana, sans-serif; text-indent: 0;} + +#linkList ul { list-style: none; margin: 0; padding: 0; } +#linkList li { color: #fff; padding: 2px 0 0 17px; } +#linkList li a { display: block; border: none; color: #98B974; text-decoration:none; font-weight: bold; margin-left: -12px; padding-left: 12px; background: url(images/nav_arrow.gif) no-repeat 0 2px;} +#linkList li a:hover { color: #f4f0e6; background-position: 0 -48px; text-decoration:underline; } +#linkList li a.c { display: inline; padding: 0; margin: 0; background: none; color: #4C4E39; font-weight: normal; } +#linkList li a.c:hover { color: #f4f0e6; } */ + + +a { + color: maroon; + text-decoration: none; + border-bottom: 1px dotted maroon; + } + + #more { + color: blue; + text-decoration: none; + } + +a:hover { + color: red; + text-decoration: none; + border-bottom: 1px solid red; + } + +a:visited { + color: dimgray; + text-decoration: none; + border-bottom:1px solid dimgray; + } + + p { + margin:0; + padding:15px; + font-family: verdana, arial, helvetica; + line-height: 110%; + font-size: small; + } + +h4 { + margin:0; + padding: 5px 0; + } + +p:first-letter { + font-weight: bold; + color: maroon; + font-family: Georgia; + } + +#l-col { + margin: 0; + padding: 15px; + font-family: georgia, verdana, arial, helvetica; + line-height: 150%; + font-size: small; + text-align: left; + } + +#l-col h4 { + font-weight: bold; + font-size: small; + } + +#l-col a { + height: 25px; + } + +#cont { + margin: 0; + padding: 15px; + font-family: verdana, arial, helvetica; + } + +#cont h3 { + font-size: large; + color: maroon; + } + +#cont h4 { + font-size: small; + } + +#cont h6 { + color: silver; + font-weight: normal; + margin: 0px; + margin-bottom: 16px; + } + +#cont ul { + font-family: verdana, arial, helvetica; + line-height: 150%; + font-size: small; + } + +#cont ul li{ + padding-bottom: 8px; + } + +#cont ol { + font-family: verdana, arial, helvetica; + line-height: 150%; + font-size: small; + } + +#cont ol li{ + padding-bottom: 8px; + } + +#cont td { + font-family: verdana, arial, helvetica; + font-size: small; + } + +blockquote { + font-family: courier new, courier, fixed; + font-size: small; + color: darkblue; + background-color: gainsboro; + padding: 16px; + } + +#bar { + text-align: center; + font-family: verdana, arial, helvetica; + font-size: x-small; + } + +#ftr { + text-align: center; + font-family: verdana, arial, helvetica; + font-size: x-small; + } + +body { + color: #333333; + text-align:center; + font-family: verdana, arial, helvetica; + padding:0; + } + +.content { + color: #333333; + text-align:left; + font-size: small; + font-family: verdana, arial, helvetica; + padding:0; + } + +#outer { + text-align:center; + margin:auto; + } +/**#5a7b9c #398EB5**/ +#hdr { + background-color: #333333; + color: #FFFFFF; + } + +#bar { + height:20px; + background: #660000; + color: white; + border:solid #000000; + border-width:0 0 0 0; + } + +#bar a{color: white} +h1 { + font: bold large georgia; + letter-spacing: 1px; + margin-bottom: 0px; + color: #154349; + } + +h2 { + font: bold 110% verdana; + letter-spacing: 1px; + margin-bottom: 0px; + color: #006699; + } + +h3 { + font: italic normal 12pt georgia; + letter-spacing: 1px; + margin-bottom: 0px; + color: #154349; + } + +#bodyblock { + position:relative; + background: white; + color: white; + width:720px; + padding:0; + } + +body#forumbody #l-col { + width:0px; + } + +#l-col { + float:left; + background:white; + color: #333333; + width:165px; + text-align: left; + } + +#cont { + width:475px; + background:white; + color: #333333; + border:solid #000000; + border-width:0 0 0 0; + text-align:left; + } + +#ftr { + height:25px; + font-family: Georgia,Arial,Helvetica; + background:black; + color: white; + border:solid black; + border-width:1px 0 0 0; + margin:0; + } + + table.comparison { font-family: arial ; font-size: 0.75em} + ul {font-family: arial ; font-size: 0.75em} + diff --git a/test/ import mapinfo_files/basic070802.css b/test/ import mapinfo_files/basic070802.css new file mode 100644 index 0000000..1688fa4 --- /dev/null +++ b/test/ import mapinfo_files/basic070802.css @@ -0,0 +1,297 @@ +/* Presentation Stylesheet */ + +/**#lselect h3, #lresources h3, #larchives h3 { + height: 23px; + width: 150px; + margin: 0; +} **/ + +@page { + size: 7.5in 9.5in; + margin: 16mm 16mm 16mm 16mm; + } + + div.chapter, div.appendix { + page-break-after: always; + } + +.select{ + z-index: 7; +} + +.head { + color: #cdba91; + font: caption; + font-family: 'Georgia'; + font-size: large; + font-style: normal; + font-variant: small-caps; + font-weight: bold; +} + +.header_title { color:white;background-color:#003333;font-family: Georgia} + + +#linkList{ + position:absolute; + top:10px; + left:10px; + z-index:5; + width:150px; + /*background-image:url(images/zbg.gif); + background-position:0 -401px;*/ + overflow:hidden; + padding-bottom:0px; +} + + +#linkList h3{ + height:60px; + width:150px; + background-position:0 0; +} + +/* --// lists --// */ + +#linkList li { + background: #fefefe; + padding: 5px 7px; + border-bottom: 1px solid #DCD5B8; + text-transform: uppercase; + font-size: 9px; +} +#linkList li:hover { background: #DCD5B8; } + +/*#linkList2 { font: 10px Tahoma, Verdana, Arial, sans-serif; width: 220px;} +#linkList p, #linkList li{ font: x-small/1.6em tahoma, verdana, sans-serif; text-indent: 0;} + +#linkList ul { list-style: none; margin: 0; padding: 0; } +#linkList li { color: #fff; padding: 2px 0 0 17px; } +#linkList li a { display: block; border: none; color: #98B974; text-decoration:none; font-weight: bold; margin-left: -12px; padding-left: 12px; background: url(images/nav_arrow.gif) no-repeat 0 2px;} +#linkList li a:hover { color: #f4f0e6; background-position: 0 -48px; text-decoration:underline; } +#linkList li a.c { display: inline; padding: 0; margin: 0; background: none; color: #4C4E39; font-weight: normal; } +#linkList li a.c:hover { color: #f4f0e6; } */ + + +a { + color: maroon; + text-decoration: none; + border-bottom: 1px dotted maroon; + } + + #more { + color: blue; + text-decoration: none; + } + +a:hover { + color: red; + text-decoration: none; + border-bottom: 1px solid red; + } + +a:visited { + color: dimgray; + text-decoration: none; + border-bottom:1px solid dimgray; + } + + p { + margin:0; + padding:15px; + font-family: verdana, arial, helvetica; + line-height: 110%; + font-size: small; + } + +h4 { + margin:0; + padding: 5px 0; + } + +p:first-letter { + font-weight: bold; + color: maroon; + font-family: Georgia; + } + +#l-col { + margin: 0; + padding: 15px; + font-family: georgia, verdana, arial, helvetica; + line-height: 150%; + font-size: small; + text-align: left; + } + +#l-col h4 { + font-weight: bold; + font-size: small; + } + +#l-col a { + height: 25px; + } + +#cont { + margin: 0; + padding: 15px; + font-family: verdana, arial, helvetica; + } + +#cont h3 { + font-size: large; + color: maroon; + } + +#cont h4 { + font-size: small; + } + +#cont h6 { + color: silver; + font-weight: normal; + margin: 0px; + margin-bottom: 16px; + } + +#cont ul { + font-family: verdana, arial, helvetica; + line-height: 150%; + font-size: small; + } + +#cont ul li{ + padding-bottom: 8px; + } + +#cont ol { + font-family: verdana, arial, helvetica; + line-height: 150%; + font-size: small; + } + +#cont ol li{ + padding-bottom: 8px; + } + +#cont td { + font-family: verdana, arial, helvetica; + font-size: small; + } + +blockquote { + font-family: courier new, courier, fixed; + font-size: small; + color: darkblue; + background-color: gainsboro; + padding: 16px; + } + +#bar { + text-align: center; + font-family: verdana, arial, helvetica; + font-size: x-small; + } + +#ftr { + text-align: center; + font-family: verdana, arial, helvetica; + font-size: x-small; + } + +body { + color: #333333; + text-align:center; + font-family: verdana, arial, helvetica; + padding:0; + } + +.content { + color: #333333; + text-align:left; + font-size: small; + font-family: verdana, arial, helvetica; + padding:0; + } + +#outer { + text-align:center; + margin:auto; + } +/**#5a7b9c #398EB5**/ +#hdr { + background-color: #333333; + color: #FFFFFF; + } + +#bar { + height:20px; + background: #660000; + color: white; + border:solid #000000; + border-width:0 0 0 0; + } + +#bar a{color: white} +h1 { + font: bold large georgia; + letter-spacing: 1px; + margin-bottom: 0px; + color: #154349; + } + +h2 { + font: bold 110% verdana; + letter-spacing: 1px; + margin-bottom: 0px; + color: #006699; + } + +h3 { + font: italic normal 12pt georgia; + letter-spacing: 1px; + margin-bottom: 0px; + color: #154349; + } + +#bodyblock { + position:relative; + background: white; + color: white; + width:720px; + padding:0; + } + +body#forumbody #l-col { + width:0px; + } + +#l-col { + float:left; + background:white; + color: #333333; + width:165px; + text-align: left; + } + +#cont { + width:475px; + background:white; + color: #333333; + border:solid #000000; + border-width:0 0 0 0; + text-align:left; + } + +#ftr { + height:25px; + font-family: Georgia,Arial,Helvetica; + background:black; + color: white; + border:solid black; + border-width:1px 0 0 0; + margin:0; + } + + diff --git a/test/ import mapinfo_files/blinklistsm.gif b/test/ import mapinfo_files/blinklistsm.gif new file mode 100644 index 0000000..6c53ce8 Binary files /dev/null and b/test/ import mapinfo_files/blinklistsm.gif differ diff --git a/test/ import mapinfo_files/cm.html b/test/ import mapinfo_files/cm.html new file mode 100644 index 0000000..08b9a71 --- /dev/null +++ b/test/ import mapinfo_files/cm.html @@ -0,0 +1,3 @@ + + + Amazon.com
\ No newline at end of file diff --git a/test/ import mapinfo_files/delicioussm.gif b/test/ import mapinfo_files/delicioussm.gif new file mode 100644 index 0000000..4ec034f Binary files /dev/null and b/test/ import mapinfo_files/delicioussm.gif differ diff --git a/test/ import mapinfo_files/diggsm.gif b/test/ import mapinfo_files/diggsm.gif new file mode 100644 index 0000000..3dbc394 Binary files /dev/null and b/test/ import mapinfo_files/diggsm.gif differ diff --git a/test/ import mapinfo_files/furlsm.gif b/test/ import mapinfo_files/furlsm.gif new file mode 100644 index 0000000..4acabe5 Binary files /dev/null and b/test/ import mapinfo_files/furlsm.gif differ diff --git a/test/ import mapinfo_files/ga.js b/test/ import mapinfo_files/ga.js new file mode 100644 index 0000000..e092564 --- /dev/null +++ b/test/ import mapinfo_files/ga.js @@ -0,0 +1,51 @@ +(function(){var g=void 0,h=true,i=null,j=false,ba=encodeURIComponent,ca=Infinity,da=setTimeout,ea=decodeURIComponent,k=Math;function fa(a,b){return a.onload=b}function ga(a,b){return a.name=b}var m="push",ha="slice",ia="replace",ja="load",ka="floor",n="charAt",la="value",p="indexOf",ma="match",r="name",oa="host",t="toString",u="length",v="prototype",w="split",pa="stopPropagation",qa="scope",x="location",y="getString",z="substring",ra="navigator",A="join",C="toLowerCase",D;function sa(a,b){switch(b){case 0:return""+a;case 1:return a*1;case 2:return!!a;case 3:return a*1E3}return a}function E(a,b){return g==a||"-"==a&&!b||""==a}function ta(a){if(!a||""==a)return"";for(;a&&" \n\r\t"[p](a[n](0))>-1;)a=a[z](1);for(;a&&" \n\r\t"[p](a[n](a[u]-1))>-1;)a=a[z](0,a[u]-1);return a}function ua(a){var b=1,c=0,d;if(!E(a)){b=0;for(d=a[u]-1;d>=0;d--)c=a.charCodeAt(d),b=(b<<6&268435455)+c+(c<<14),c=b&266338304,b=c!=0?b^c>>21:b}return b} +function va(){return k.round(k.random()*2147483647)}function wa(){}function F(a,b){return ba instanceof Function?b?encodeURI(a):ba(a):(G(68),escape(a))}function H(a){a=a[w]("+")[A](" ");if(ea instanceof Function)try{return ea(a)}catch(b){G(17)}else G(68);return unescape(a)}var xa=function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,!!d):a.attachEvent&&a.attachEvent("on"+b,c)},ya=function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,!!d):a.detachEvent&&a.detachEvent("on"+b,c)}; +function I(a){return a&&a[u]>0?a[0]:""}function za(a){var b=a?a[u]:0;return b>0?a[b-1]:""}var Aa=function(){this.prefix="ga.";this.I={}};Aa[v].set=function(a,b){this.I[this.prefix+a]=b};Aa[v].get=function(a){return this.I[this.prefix+a]};Aa[v].contains=function(a){return this.get(a)!==g};function Ba(a){a[p]("www.")==0&&(a=a[z](4));return a[C]()}function Ca(a,b){var c,d={url:a,protocol:"http",host:"",path:"",c:new Aa,anchor:""};if(!a)return d;c=a[p]("://");if(c>=0)d.protocol=a[z](0,c),a=a[z](c+3);c=a.search("/|\\?|#");if(c>=0)d.host=a[z](0,c)[C](),a=a[z](c);else return d.host=a[C](),d;c=a[p]("#");if(c>=0)d.anchor=a[z](c+1),a=a[z](0,c);c=a[p]("?");c>=0&&(Da(d.c,a[z](c+1)),a=a[z](0,c));d.anchor&&b&&Da(d.c,d.anchor);a&&a[n](0)=="/"&&(a=a[z](1));d.path=a;return d} +function Da(a,b){function c(b,c){a.contains(b)||a.set(b,[]);a.get(b)[m](c)}for(var d=ta(b)[w]("&"),e=0;e=1||(a=["utmt=error","utmerr="+a,"utmwv=5.2.2","utmn="+va(),"utmsp=1"],b&&a[m]("api="+b),c&&a[m]("msg="+F(c[z](0,100))),K.q&&a[m]("aip=1"),Ga(a[A]("&")))};var Ha=0;function L(a){return(a?"_":"")+Ha++} +var Ia=L(),Ja=L(),Ka=L(),La=L(),Ma=L(),M=L(),N=L(),Na=L(),Oa=L(),Pa=L(),Qa=L(),Ra=L(),Sa=L(),Ta=L(),Ua=L(),Va=L(),Wa=L(),Xa=L(),Ya=L(),Za=L(),$a=L(),ab=L(),bb=L(),cb=L(),db=L(),eb=L(),fb=L(),gb=L(),hb=L(),ib=L(),jb=L(),kb=L(),lb=L(),mb=L(),nb=L(),O=L(h),ob=L(),pb=L(),qb=L(),rb=L(),sb=L(),tb=L(),ub=L(),vb=L(),wb=L(),xb=L(),P=L(h),yb=L(h),zb=L(h),Bb=L(h),Cb=L(h),Db=L(h),Eb=L(h),Fb=L(h),Gb=L(h),Hb=L(h),Ib=L(h),Q=L(h),Jb=L(h),Kb=L(h),Lb=L(h),Mb=L(h),Nb=L(h),Ob=L(h),Pb=L(h),Qb=L(h),Rb=L(h),Sb=L(h),Tb= +L(h),Ub=L(h),Vb=L(h),Wb=L(),Xb=L(),Yb=L();L();var Zb=L(),$b=L(),ac=L(),bc=L(),cc=L(),dc=L(),ec=L(),hc=L(),ic=L(),jc=L();L();var kc=L(),lc=L();var mc=function(){function a(a,c,d){R(S[v],a,c,d)}T("_getName",Ka,58);T("_getAccount",Ia,64);T("_visitCode",P,54);T("_getClientInfo",Ta,53,1);T("_getDetectTitle",Wa,56,1);T("_getDetectFlash",Ua,65,1);T("_getLocalGifPath",fb,57);T("_getServiceMode",gb,59);U("_setClientInfo",Ta,66,2);U("_setAccount",Ia,3);U("_setNamespace",Ja,48);U("_setAllowLinker",Qa,11,2);U("_setDetectFlash",Ua,61,2);U("_setDetectTitle",Wa,62,2);U("_setLocalGifPath",fb,46,0);U("_setLocalServerMode",gb,92,g,0);U("_setRemoteServerMode", +gb,63,g,1);U("_setLocalRemoteServerMode",gb,47,g,2);U("_setSampleRate",eb,45,1);U("_setCampaignTrack",Va,36,2);U("_setAllowAnchor",Ra,7,2);U("_setCampNameKey",Ya,41);U("_setCampContentKey",cb,38);U("_setCampIdKey",Xa,39);U("_setCampMediumKey",ab,40);U("_setCampNOKey",db,42);U("_setCampSourceKey",$a,43);U("_setCampTermKey",bb,44);U("_setCampCIdKey",Za,37);U("_setCookiePath",N,9,0);U("_setMaxCustomVariables",hb,0,1);U("_setVisitorCookieTimeout",Na,28,1);U("_setSessionCookieTimeout",Oa,26,1);U("_setCampaignCookieTimeout", +Pa,29,1);U("_setReferrerOverride",qb,49);U("_setSiteSpeedSampleRate",ic,132);a("_trackPageview",S[v].na,1);a("_trackEvent",S[v].v,4);a("_trackPageLoadTime",S[v].ma,100);a("_trackSocial",S[v].oa,104);a("_trackTrans",S[v].pa,18);a("_sendXEvent",S[v].u,78);a("_createEventTracker",S[v].V,74);a("_getVersion",S[v].$,60);a("_setDomainName",S[v].t,6);a("_setAllowHash",S[v].ea,8);a("_getLinkerUrl",S[v].Z,52);a("_link",S[v].link,101);a("_linkByPost",S[v].da,102);a("_setTrans",S[v].ha,20);a("_addTrans",S[v].O, +21);a("_addItem",S[v].M,19);a("_setTransactionDelim",S[v].ia,82);a("_setCustomVar",S[v].fa,10);a("_deleteCustomVar",S[v].X,35);a("_getVisitorCustomVar",S[v].aa,50);a("_setXKey",S[v].ka,83);a("_setXValue",S[v].la,84);a("_getXKey",S[v].ba,76);a("_getXValue",S[v].ca,77);a("_clearXKey",S[v].S,72);a("_clearXValue",S[v].T,73);a("_createXObj",S[v].W,75);a("_addIgnoredOrganic",S[v].K,15);a("_clearIgnoredOrganic",S[v].P,97);a("_addIgnoredRef",S[v].L,31);a("_clearIgnoredRef",S[v].Q,32);a("_addOrganic",S[v].N, +14);a("_clearOrganic",S[v].R,70);a("_cookiePathCopy",S[v].U,30);a("_get",S[v].Y,106);a("_set",S[v].ga,107);a("_addEventListener",S[v].addEventListener,108);a("_removeEventListener",S[v].removeEventListener,109);a("_initData",S[v].m,2);a("_setVar",S[v].ja,22);U("_setSessionTimeout",Oa,27,3);U("_setCookieTimeout",Pa,25,3);U("_setCookiePersistence",Na,24,1);a("_setAutoTrackOutbound",wa,79);a("_setTrackOutboundSubdomains",wa,81);a("_setHrefExamineLimit",wa,80)},R=function(a,b,c,d){a[b]=function(){try{return G(d), +c.apply(this,arguments)}catch(a){throw Fa("exc",b,a&&a[r]),a;}}},T=function(a,b,c,d){S[v][a]=function(){try{return G(c),sa(this.a.get(b),d)}catch(e){throw Fa("exc",a,e&&e[r]),e;}}},U=function(a,b,c,d,e){S[v][a]=function(f){try{G(c),e==g?this.a.set(b,sa(f,d)):this.a.set(b,e)}catch(l){throw Fa("exc",a,l&&l[r]),l;}}},nc=function(a,b){return{type:b,target:a,stopPropagation:function(){throw"aborted";}}};var oc=function(a,b){return b!=="/"?j:(a[p]("www.google.")==0||a[p](".google.")==0||a[p]("google.")==0)&&!(a[p]("google.org")>-1)?h:j},pc=function(a){var b=a.get(Ma),c=a[y](N,"/");oc(b,c)&&a[pa]()};var uc=function(){var a={},b={},c=new qc;this.g=function(a,b){c.add(a,b)};var d=new qc;this.d=function(a,b){d.add(a,b)};var e=j,f=j,l=h;this.J=function(){e=h};this.f=function(a){this[ja]();this.set(Wb,a,h);a=new rc(this);e=j;d.execute(this);e=h;b={};this.i();a.qa()};this.load=function(){e&&(e=j,this.sa(),sc(this),f||(f=h,c.execute(this),tc(this),sc(this)),e=h)};this.i=function(){if(e)if(f)e=j,tc(this),e=h;else this[ja]()};this.get=function(c){c&&c[n](0)=="_"&&this[ja]();return b[c]!==g?b[c]:a[c]}; +this.set=function(c,d,e){c&&c[n](0)=="_"&&this[ja]();e?b[c]=d:a[c]=d;c&&c[n](0)=="_"&&this.i()};this.n=function(b){a[b]=this.b(b,0)+1};this.b=function(a,b){var c=this.get(a);return c==g||c===""?b:c*1};this.getString=function(a,b){var c=this.get(a);return c==g?b:c+""};this.sa=function(){if(l){var b=this[y](Ma,""),c=this[y](N,"/");oc(b,c)||(a[M]=a[Sa]&&b!=""?ua(b):1,l=j)}}};uc[v].stopPropagation=function(){throw"aborted";}; +var rc=function(a){var b=this;this.j=0;var c=a.get(Xb);this.Aa=function(){b.j>0&&c&&(b.j--,b.j||c())};this.qa=function(){!b.j&&c&&da(c,0)};a.set(Yb,b,h)};function vc(a,b){for(var b=b||[],c=0;c=0&&d>0&&e>0&&f>0&&b>=0))return G(110),j;a.set(P,c);a.set(Cb,d);a.set(Db,e);a.set(Eb,f);a.set(Fb,b);return h},yc=function(a){var b=a.get(P),c=a.get(Cb),d=a.get(Db),e=a.get(Eb),f=a.b(Fb,1);b==g?G(113):b==NaN&&G(114);b>=0&&c>0&&d>0&&e>0&&f>=0||G(115);return[a.b(M,1),b!=g?b:"-",c||"-",d||"-",e||"-",f][A](".")},zc=function(a){return[a.b(M,1),a.b(Ib,0),a.b(Q,1), +a.b(Jb,0)][A](".")},Ac=function(a,b,c){var c=c?"":a[y](M,"1"),d=b[w](".");if(d[u]!==4||wc(d[0],c))d=i;a.set(Ib,d?d[1]*1:0);a.set(Q,d?d[2]*1:10);a.set(Jb,d?d[3]*1:a.get(La));return d!=i||!wc(b,c)},Bc=function(a,b){var c=F(a[y](zb,"")),d=[],e=a.get(O);if(!b&&e){for(var f=0;f0&&(c+="|"+d[A](","))}return c?a.b(M,1)+"."+c:i},Cc=function(a,b,c){c=c?"":a[y](M,"1");b=b[w](".");if(b[u]<2||wc(b[0],c))return j;b=b[ha](1)[A](".")[w]("|"); +b[u]>0&&a.set(zb,H(b[0]));if(b[u]<=1)return h;for(var c=b[1][w](b[1][p](",")==-1?"^":","),d=0;d=0&&G(125);return h},Ec=function(a,b){var c=Dc(a,b);return c?[a.b(M,1),a.b(Kb,0),a.b(Lb,1),a.b(Mb,1),c][A]("."):""},Dc=function(a){function b(b,e){if(!E(a.get(b))){var f=a[y](b,""),f=f[w](" ")[A]("%20"),f=f[w]("+")[A]("%20");c[m](e+"="+f)}}var c=[];b(Ob,"utmcid");b(Sb,"utmcsr");b(Qb, +"utmgclid");b(Rb,"utmdclid");b(Pb,"utmccn");b(Tb,"utmcmd");b(Ub,"utmctr");b(Vb,"utmcct");return c[A]("|")},Gc=function(a,b,c){c=c?"":a[y](M,"1");b=b[w](".");if(b[u]<5||wc(b[0],c))return a.set(Kb,g),a.set(Lb,g),a.set(Mb,g),a.set(Ob,g),a.set(Pb,g),a.set(Sb,g),a.set(Tb,g),a.set(Ub,g),a.set(Vb,g),a.set(Qb,g),a.set(Rb,g),j;a.set(Kb,b[1]*1);a.set(Lb,b[2]*1);a.set(Mb,b[3]*1);Fc(a,b[ha](4)[A]("."));return h},Fc=function(a,b){function c(a){return(a=b[ma](a+"=(.*?)(?:\\|utm|$)"))&&a[u]==2?a[1]:g}function d(b, +c){c&&(c=e?H(c):c[w]("%20")[A](" "),a.set(b,c))}b[p]("=")==-1&&(b=H(b));var e=c("utmcvr")=="2";d(Ob,c("utmcid"));d(Pb,c("utmccn"));d(Sb,c("utmcsr"));d(Tb,c("utmcmd"));d(Ub,c("utmctr"));d(Vb,c("utmcct"));d(Qb,c("utmgclid"));d(Rb,c("utmdclid"))},wc=function(a,b){return b?a!=b:!/^\d+$/.test(a)};var qc=function(){this.s=[]};qc[v].add=function(a,b){this.s[m]({name:a,Da:b})};qc[v].execute=function(a){try{for(var b=0;b=a.get(eb)*100&&a[pa]()}function Ic(a){Jc()&&a[pa]()}function Kc(a){J[x].protocol=="file:"&&a[pa]()}function Lc(a){a.get(pb)||a.set(pb,J.title,h);a.get(ob)||a.set(ob,J[x].pathname+J[x].search,h)};var Mc=new function(){var a=[];this.set=function(b){a[b]=h};this.Ea=function(){for(var b=[],c=0;c=0){b=b[ia](/\n|\r/g," ");f=0;for(var l=b[u];f2E3&&(b=b[z](0,2E3),G(69)); +a=a+"="+b+"; path="+c+"; ";e&&(a+="expires="+(new Date((new Date).getTime()+e)).toGMTString()+"; ");d&&(a+="domain="+d+";");J.cookie=a}};var Oc,Pc,Qc=function(){if(!Oc){var a={},b=V[ra],c=V.screen;a.H=c?c.width+"x"+c.height:"-";a.G=c?c.colorDepth+"-bit":"-";a.language=(b&&(b.language||b.browserLanguage)||"-")[C]();a.javaEnabled=b&&b.javaEnabled()?1:0;a.characterSet=J.characterSet||J.charset||"-";Oc=a}},Rc=function(){Qc();for(var a=Oc,b=V[ra],a=b.appName+b.version+a.language+b.platform+b.userAgent+a.javaEnabled+a.H+a.G+(J.cookie?J.cookie:"")+(J.referrer?J.referrer:""),b=a[u],c=V.history[u];c>0;)a+=c--^b++;return ua(a)},Sc=function(a){Qc(); +var b=Oc;a.set(sb,b.H);a.set(tb,b.G);a.set(wb,b.language);a.set(xb,b.characterSet);a.set(ub,b.javaEnabled);if(a.get(Ta)&&a.get(Ua)){if(!(b=Pc)){var c,d,e;d="ShockwaveFlash";if((b=(b=V[ra])?b.plugins:g)&&b[u]>0)for(c=0;c-1&&(e=d.description[w]("Shockwave Flash ")[1]);else{d=d+"."+d;try{c=new ActiveXObject(d+".7"),e=c.GetVariable("$version")}catch(f){}if(!e)try{c=new ActiveXObject(d+".6"),e="WIN 6,0,21,0",c.AllowScriptAccess="always",e=c.GetVariable("$version")}catch(l){}if(!e)try{c= +new ActiveXObject(d),e=c.GetVariable("$version")}catch(o){}e&&(e=e[w](" ")[1][w](","),e=e[0]+"."+e[1]+" r"+e[2])}b=e?e:"-"}Pc=b;a.set(vb,Pc)}else a.set(vb,"-")};var Y=function(){R(Y[v],"push",Y[v][m],5);R(Y[v],"_createAsyncTracker",Y[v].Ba,33);R(Y[v],"_getAsyncTracker",Y[v].Ca,34);this.r=0};Y[v].Ba=function(a,b){return K.l(a,b||"")};Y[v].Ca=function(a){return K.p(a)};Y[v].push=function(a){this.r>0&&G(105);this.r++;for(var b=arguments,c=0,d=0;d0&&(e=f[z](0,l),f=f[z](l+1));var o=e=="_gat"?K:e=="_gaq"?Tc:K.p(e);o[f].apply(o,b[d][ha](1))}}catch(q){c++}this.r--;return c};var Yc=function(){function a(a,b,c,d){g==f[a]&&(f[a]={});g==f[a][b]&&(f[a][b]=[]);f[a][b][c]=d}function b(a,b,c){if(g!=f[a]&&g!=f[a][b])return f[a][b][c]}function c(a,b){if(g!=f[a]&&g!=f[a][b]){f[a][b]=g;var c=h,d;for(d=0;d0)&&(X("__utmd","1",a[y](N,"/"),a[y](Ma,""),1E4),W("__utmd")[u]==0&&a[pa]())};var gd=function(a){a.get(P)==g?ed(a):a.get(Bb)&&!a.get(kc)?ed(a):a.get(Hb)&&fd(a)},hd=function(a){a.get(Nb)&&!a.get(Gb)&&(fd(a),a.set(Lb,a.get(Fb)))},ed=function(a){var b=a.get(La);a.set(yb,h);a.set(P,va()^Rc(a)&2147483647);a.set(zb,"");a.set(Cb,b);a.set(Db,b);a.set(Eb,b);a.set(Fb,1);a.set(Gb,h);a.set(Ib,0);a.set(Q,10);a.set(Jb,b);a.set(O,[]);a.set(Bb,j);a.set(Hb,j)},fd=function(a){a.set(Db,a.get(Eb));a.set(Eb,a.get(La));a.n(Fb);a.set(Gb,h);a.set(Ib,0);a.set(Q,10);a.set(Jb,a.get(La));a.set(Hb,j)};var id="daum:q,eniro:search_word,naver:query,pchome:q,images.google:q,google:q,yahoo:p,yahoo:q,msn:q,bing:q,aol:query,aol:q,lycos:query,ask:q,netscape:query,cnn:query,about:terms,mamma:q,voila:rdata,virgilio:qs,live:q,baidu:wd,alice:qs,yandex:text,najdi:q,seznam:q,search:q,wp:szukaj,onet:qt,szukacz:q,yam:k,kvasir:q,ozu:q,terra:query,rambler:query".split(","),od=function(a){if(a.get(Va)&&!a.get(kc)){for(var b=!E(a.get(Ob))||!E(a.get(Sb))||!E(a.get(Qb))||!E(a.get(Rb)),c={},d=0;d=0)||c&&c[oa][p]("google")>-1&&c.c.contains("q")&&c.path=="cse")return j;if((b=pd(a,c))&&!b[2])return md(a,g,b[0],g,g,"(organic)","organic",b[1],g),h;else if(b)return j; +if(a.get(Gb))a:{for(var b=a.get(kb),d=Ba(c[oa]),e=0;e-1){a=j;break a}md(a,g,d,g,g,"(referral)","referral",g,"/"+c.path);a=h}else a=j;return a},pd=function(a,b){for(var c=a.get(ib),d=0;d-1){var f=b.c.get(e[1]);if(f&&(f=I(f),!f&&b[oa][p]("google.")>-1&&(f="(not provided)"),!e[3]||b.url[p](e[3])>-1)){a:{for(var c=f,d=a.get(jb),c=H(c)[C](),l=0;l0&&d==c}if(d(Qb)||d(Rb))return G(131),j;for(var e=0;e0&&(c=b[z](e),b=b[z](0,e)),f<0?b+"?"+d+c:b+"&"+d+c)};var vd="|",xd=function(a,b,c,d,e,f,l,o,q){var s=wd(a,b);s||(s={},a.get(lb)[m](s));s.id_=b;s.affiliation_=c;s.total_=d;s.tax_=e;s.shipping_=f;s.city_=l;s.state_=o;s.country_=q;s.items_=s.items_||[];return s},yd=function(a,b,c,d,e,f,l){var a=wd(a,b)||xd(a,b,"",0,0,0,"","",""),o;a:{if(a&&a.items_){o=a.items_;for(var q=0;q=c)return j;c=Bd()||Cd();if(c==g)return j;var d=c[0];if(d==g||d==ca||isNaN(d))return j;d>0?Dd(c)?b(Ed(c)):b(Ed(c[ha](0,1))):xa(V,"load",function(){Fd(a,b)},j);return h},Dd=function(a){for(var b=1;b2147483648&&(b=g);b>0&&a.setPageReadyTime();return b==g?g:[b]}};var S=function(a,b,c){function d(a){return function(b){if((b=b.get(lc)[a])&&b[u])for(var c=nc(e,a),d=0;d-1?(G(13),this.set(ob,a,h)):typeof a==="object"&&a!==i&&this.ta(a);this.w=a=this.get(ob);this.a.f("page");this.z(a)}; +D.v=function(a,b,c,d,e){if(a==""||!Uc(a)||b==""||!Uc(b))return j;if(c!=g&&!Uc(c))return j;if(d!=g&&!Vc(d))return j;this.set($b,a,h);this.set(ac,b,h);this.set(bc,c,h);this.set(cc,d,h);this.set(Zb,!!e,h);this.a.f("event");return h};D.oa=function(a,b,c,d){if(!a||!b)return j;this.set(dc,a,h);this.set(ec,b,h);this.set(hc,c||J[x].href,h);d&&this.set(ob,d,h);this.a.f("social");return h};D.ma=function(){this.set(ic,10);this.z(this.w)};D.pa=function(){this.a.f("trans")};D.u=function(a){this.set(nb,a,h);this.a.f("event")}; +D.V=function(a){this.m();var b=this;return{_trackEvent:function(c,d,e){G(91);b.v(a,c,d,e)}}};D.Y=function(a){return this.get(a)};D.ga=function(a,b){if(a)if(a!=g&&(a.constructor+"")[p]("String")>-1)this.set(a,b);else if(typeof a=="object")for(var c in a)a.hasOwnProperty(c)&&this.set(c,a[c])};D.addEventListener=function(a,b){var c=this.get(lc)[a];c&&c[m](b)};D.removeEventListener=function(a,b){for(var c=this.get(lc)[a],d=0;c&&de.get(hb))a=j;else if(!b||!c||F(b)[u]+F(c)[u]>64)a=j;else{d!=1&&d!=2&&(d=3);var f={};ga(f,b);f.value=c;f.scope=d;e.get(O)[a]=f;a=h}a&&this.a.i();return a};D.X=function(a){this.a.get(O)[a]=g;this.a.i()};D.aa=function(a){return(a=this.a.get(O)[a])&&a[qa]==1?a[la]:g};D.ka=function(a,b,c){this.h().e(a,b,c)};D.la=function(a,b,c){this.h().k(a,b,c)};D.ba=function(a,b){return this.h().getKey(a,b)}; +D.ca=function(a,b){return this.h().C(a,b)};D.S=function(a){this.h().A(a)};D.T=function(a){this.h().B(a)};D.W=function(){return new Yc};D.K=function(a){a&&this.get(jb)[m](a[C]())};D.P=function(){this.set(jb,[])};D.L=function(a){a&&this.get(kb)[m](a[C]())};D.Q=function(){this.set(kb,[])};D.N=function(a,b,c,d,e){if(a&&b){a=[a,b[C]()][A](":");if(d||e)a=[a,d,e][A](":");d=this.get(ib);d.splice(c?0:d[u],0,a)}};D.R=function(){this.set(ib,[])}; +D.U=function(a){this.a[ja]();var b=this.get(N),c=td(this.a);this.set(N,a);this.a.i();sd(this.a,c);this.set(N,b)};D.ra=function(){return J.referrer};D.m=function(){this.a[ja]()};D.ja=function(a){a&&a!=""&&(this.set(zb,a),this.a.f("var"))};var Gd=function(a){a.get(Wb)!=="trans"&&a.b(Ib,0)>=500&&a[pa]();if(a.get(Wb)==="event"){var b=(new Date).getTime(),c=a.b(Jb,0),d=a.b(Eb,0),c=k[ka](0.2*((b-(c!=d?c:c*1E3))/1E3));c>0&&(a.set(Jb,b),a.set(Q,k.min(10,a.b(Q,0)+c)));a.b(Q,0)<=0&&a[pa]()}},Id=function(a){a.get(Wb)==="event"&&a.set(Q,k.max(0,a.b(Q,10)-1))};var Jd=function(){var a=[];this.add=function(b,c,d){d&&(c=F(""+c));a[m](b+"="+c)};this.toString=function(){return a[A]("&")}},Kd=function(a,b){(b||a.get(gb)!=2)&&a.n(Ib)},Ld=function(a,b){b.add("utmwv","5.2.2");b.add("utms",a.get(Ib));b.add("utmn",va());var c=J[x].hostname;E(c)||b.add("utmhn",c,h);c=a.get(eb);c!=100&&b.add("utmsp",c,h)},Nd=function(a,b){b.add("utmac",a.get(Ia));a.get(Zb)&&b.add("utmni",1);Md(a,b);K.q&&b.add("aip",1);b.add("utmu",Mc.Ea())},Md=function(a,b){function c(a,b){b&&d[m](a+ +"="+b+";")}var d=[];c("__utma",yc(a));c("__utmz",Ec(a,j));c("__utmv",Bc(a,h));c("__utmx",td(a));b.add("utmcc",d[A]("+"),h)},Od=function(a,b){a.get(Ta)&&(b.add("utmcs",a.get(xb),h),b.add("utmsr",a.get(sb)),b.add("utmsc",a.get(tb)),b.add("utmul",a.get(wb)),b.add("utmje",a.get(ub)),b.add("utmfl",a.get(vb),h))},Pd=function(a,b){a.get(Wa)&&a.get(pb)&&b.add("utmdt",a.get(pb),h);b.add("utmhid",a.get(rb));b.add("utmr",Ea(a.get(qb),a.get(N)),h);b.add("utmp",F(a.get(ob),h),h)},Qd=function(a,b){for(var c=a.get(mb), +d=a.get(nb),e=a.get(O)||[],f=0;f=0&&![].reduce)throw new Wd(a[u]);Yd(a,b)||Zd(a,b)}else throw new Vd(a[u]);},Xd=function(a,b,c){var c=c||Ud+"/__utm.gif?",d=new Image(1,1);d.src=c+a;fa(d,function(){fa(d,i);d.onerror= +i;b()});d.onerror=function(){fa(d,i);d.onerror=i;b()}},Yd=function(a,b){var c,d=Ud+"/p/__utm.gif",e=V.XDomainRequest;if(e)c=new e,c.open("POST",d);else if(e=V.XMLHttpRequest)e=new e,"withCredentials"in e&&(c=e,c.open("POST",d,h),c.setRequestHeader("Content-Type","text/plain"));if(c)return c.onreadystatechange=function(){c.readyState==4&&(b(),c=i)},c.send(a),h},Zd=function(a,b){if(J.body){a=ba(a);try{var c=J.createElement('')}catch(d){c=J.createElement("iframe"),ga(c, +a)}c.height="0";c.width="0";c.style.display="none";c.style.visibility="hidden";var e=J[x],e=Ud+"/u/post_iframe.html#"+ba(e.protocol+"//"+e[oa]+"/favicon.ico"),f=function(){c.src="";c.parentNode&&c.parentNode.removeChild(c)};xa(V,"beforeunload",f);var l=j,o=0,q=function(){if(!l){try{if(o>9||c.contentWindow[x][oa]==J[x][oa]){l=h;f();ya(V,"beforeunload",f);b();return}}catch(a){}o++;da(q,200)}};xa(c,"load",q);J.body.appendChild(c);c.src=e}else Nc(function(){Zd(a,b)},100)};var Z=function(){this.q=j;this.D={};this.F=[];this.wa=0;this._gasoCPath=this._gasoDomain=g;R(Z[v],"_createTracker",Z[v].l,55);R(Z[v],"_getTracker",Z[v].ya,0);R(Z[v],"_getTrackerByName",Z[v].p,51);R(Z[v],"_getTrackers",Z[v].za,130);R(Z[v],"_anonymizeIp",Z[v].xa,16);mc()};D=Z[v];D.ya=function(a,b){return this.l(a,g,b)};D.l=function(a,b,c){b&&G(23);c&&G(67);b==g&&(b="~"+K.wa++);a=new S(b,a,c);K.D[b]=a;K.F[m](a);return a};D.p=function(a){a=a||"";return K.D[a]||K.l(g,a)};D.za=function(){return K.F[ha](0)}; +D.xa=function(){this.q=h};var $d=function(a){if(J.webkitVisibilityState=="prerender")return j;a();return h};var K=new Z;var ae=V._gat;ae&&typeof ae._getTracker=="function"?K=ae:V._gat=K;var Tc=new Y;(function(a){if(!$d(a)){G(123);var b=j,c=function(){!b&&$d(a)&&(G(124),b=h,ya(J,"webkitvisibilitychange",c))};xa(J,"webkitvisibilitychange",c)}})(function(){var a=V._gaq,b=j;if(a&&typeof a[m]=="function"&&(b=Object[v][t].call(Object(a))=="[object Array]",!b)){Tc=a;return}V._gaq=Tc;b&&Tc[m].apply(Tc,a)});})(); diff --git a/test/ import mapinfo_files/iu3.html b/test/ import mapinfo_files/iu3.html new file mode 100644 index 0000000..e1f51b9 --- /dev/null +++ b/test/ import mapinfo_files/iu3.html @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/ import mapinfo_files/jeditcode.css b/test/ import mapinfo_files/jeditcode.css new file mode 100644 index 0000000..7d8abe2 --- /dev/null +++ b/test/ import mapinfo_files/jeditcode.css @@ -0,0 +1,158 @@ +code { + background-color: #EFEFEF; + border-color: #003333; + display: block; + font-family: courier; + font-size: normal; + width:700px; +} +div.code { + width: 700px;overflow: auto; + background-color: #EFEFEF; + border-style: dotted; + border-width: thin; +} + +@print div.code { + width: 700px; + background-color: #EFEFEF; + border-style: dotted; + border-width: thin; +} + +.syntax0 { +color: #000000; +} +.syntax1 { +color: #009900; +font-style: italic; +} +.syntax2 { +color: #cccccc; +font-style: italic; +} +.syntax3 { +color: #6600cc; +} +.syntax4 { +color: #cc6600; +} +.syntax5 { +color: #009191; +} +.syntax6 { +color: #000099; +} +.syntax7 { +color: #ff0000; +font-weight: bold; +} +.syntax8 { +color: #0000ba; +} +.syntax9 { +color: #990000; +font-weight: bold; +} +.syntax10 { +color: #0b5174; +font-weight: bold; +} +.syntax11 { +color: #006699; +font-weight: bold; +} +.syntax12 { +color: #990033; +font-weight: bold; +font-style: italic; +} +.syntax13 { +color: #ee0009; +font-style: italic; +} +.syntax14 { +color: #ff6666; +} +.syntax15 { +color: #9900cc; +} +.syntax16 { +color: #6600cc; +} +.syntax17 { +color: #990033; +} +.syntax18 { +color: #000000; +font-weight: bold; +} + + +.syntax-NULL { + color: #000000; +} +.syntax-COMMENT1 { + color: #009900; + font-style: italic; +} +.syntax-COMMENT2 { + color: #cccccc; + font-style: italic; +} +.syntax-COMMENT3 { + color: #3a6a60; +} +.syntax-COMMENT4 { + color: #3a6a60; +} +.syntax-DIGIT { + color: #009191; +} +.syntax-FUNCTION { + color: #000099; +} +.syntax-INVALID { + color: #ff0000; + font-weight: bold; +} +.syntax-KEYWORD1 { + color: #0000ba; +} +.syntax-KEYWORD2 { + color: #990000; + font-weight: bold; +} +.syntax-KEYWORD3 { + color: #0b5174; + font-weight: bold; +} +.syntax-KEYWORD4 { + color: #8b677f; + font-weight: bold; +} +.syntax-LABEL { + color: #990033; + font-weight: bold; + font-style: italic; +} +.syntax-LITERAL1 { + color: #ee0009; + font-style: italic; +} +.syntax-LITERAL2 { + color: #ff6666; +} +.syntax-LITERAL3 { + color: #af5992; +} +.syntax-LITERAL4 { + color: #000000; +} +.syntax-MARKUP { + color: #990033; +} +.syntax-OPERATOR { + color: #000000; + font-weight: bold; +} \ No newline at end of file diff --git a/test/ import mapinfo_files/mapserver_logo.gif b/test/ import mapinfo_files/mapserver_logo.gif new file mode 100644 index 0000000..7a24576 Binary files /dev/null and b/test/ import mapinfo_files/mapserver_logo.gif differ diff --git a/test/ import mapinfo_files/postgisinaction_small.jpg b/test/ import mapinfo_files/postgisinaction_small.jpg new file mode 100644 index 0000000..fb1740c Binary files /dev/null and b/test/ import mapinfo_files/postgisinaction_small.jpg differ diff --git a/test/ import mapinfo_files/postgresql95x51_4.gif b/test/ import mapinfo_files/postgresql95x51_4.gif new file mode 100644 index 0000000..cec74d9 Binary files /dev/null and b/test/ import mapinfo_files/postgresql95x51_4.gif differ diff --git a/test/ import mapinfo_files/printer.css b/test/ import mapinfo_files/printer.css new file mode 100644 index 0000000..5c16d43 --- /dev/null +++ b/test/ import mapinfo_files/printer.css @@ -0,0 +1 @@ +@media print { .screen_only {display:none}} diff --git a/test/ import mapinfo_files/redditsm.gif b/test/ import mapinfo_files/redditsm.gif new file mode 100644 index 0000000..37d87c5 Binary files /dev/null and b/test/ import mapinfo_files/redditsm.gif differ diff --git a/test/ import mapinfo_files/rss.png b/test/ import mapinfo_files/rss.png new file mode 100644 index 0000000..31e15b1 Binary files /dev/null and b/test/ import mapinfo_files/rss.png differ diff --git a/test/ import mapinfo_files/stock_elephant_060_rev.gif b/test/ import mapinfo_files/stock_elephant_060_rev.gif new file mode 100644 index 0000000..70a8c43 Binary files /dev/null and b/test/ import mapinfo_files/stock_elephant_060_rev.gif differ diff --git a/test/CousinMarriageWorld.svgz b/test/CousinMarriageWorld.svgz deleted file mode 100644 index c815dda..0000000 Binary files a/test/CousinMarriageWorld.svgz and /dev/null differ diff --git a/test/Ireland_complete.svg b/test/Ireland_complete.svg deleted file mode 100644 index ca29153..0000000 --- a/test/Ireland_complete.svg +++ /dev/null @@ -1,811 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - Ireland-Counties - 22 June 2007 - - - Fut.Perf. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Mayo - Sligo - Donegal - Londonderry - Antrim - Down - Tyrone - Fermanagh - Armagh - Monaghan - Cavan - Leitrim - Louth - Meath - Roscommon - Galway - Clare - Limerick - Longford - Westmeath - Offaly (King’s) - Laois (Queen’s) - Kildare - Dublin - Wicklow - Wexford - Carlow - Kilkenny - Tipperary - Waterford - Cork - Kerry - - - ULSTER - CONNACHT - LEINSTER - MUNSTER - - - - - - - - - - diff --git a/test/Ireland_trad_counties_named.svg b/test/Ireland_trad_counties_named.svg deleted file mode 100644 index 5c24e51..0000000 --- a/test/Ireland_trad_counties_named.svg +++ /dev/null @@ -1,1481 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - 22 June 2007 - - - Fut.Perf. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git "a/test/Rapha\303\253l \302\267 Australia.html" "b/test/Rapha\303\253l \302\267 Australia.html" deleted file mode 100644 index 00aa196..0000000 --- "a/test/Rapha\303\253l \302\267 Australia.html" +++ /dev/null @@ -1,162 +0,0 @@ - - - - - Raphaël · Australia - - - - - - - -
-
Created with Raphaël 2.0.0
-
-

New South Wales

-

- New South Wales (abbreviated as NSW) is Australia’s oldest and most populous state, located in the south-east of the - country, north of Victoria and south of Queensland. It was founded in 1788 and originally comprised much of the - Australian mainland, as well as Lord Howe Island and Norfolk Island. New Zealand was not initially part of the colony, - although when Britain annexed New Zealand in 1840 it was briefly a part of New South Wales. During the 19th century - large areas were successively separated to form the British colonies of Tasmania, South Australia, Victoria, - Queensland, and New Zealand. -

-
-
-

Victoria

-

- Victoria is a state located in the south-eastern corner of Australia. It is the smallest mainland state in area but - the most densely populated and urbanised. Prior to European settlement, some 30,000 Indigenous Australians lived in - the area now occupied by the state. By contrast, over five million people now inhabit the region. European settlement - in Victoria began in the 1830s as a farming community. Victoria is the second most populous Australian state, after New South Wales, with - an estimated population of 5,205,200 as of June 2007. Melbourne is Victoria’s capital and largest city, with more - than 70% of all Victorians living there. -

-
-
-

Western Australia

-

- Western Australia is a state occupying the entire western third of the Australian continent. The nation’s largest - state and the second largest sub-national entity in the world, it has 2.1 million inhabitants (10% of the national - total), 85% of whom live in the south-west corner of the state. The people of Western Australia are often - colloquially referred to as sand-gropers, the common name of an insect found on sand dunes around Perth. -

-
-
-

South Australia

-

- South Australia is a state of Australia in the southern central part of the country. It covers some of the most arid - parts of the continent; with a total land area of 983,482 square kilometres, it is the fourth largest - of Australia’s six states and two territories. It is bordered to the west by Western Australia, to the north by the - Northern Territory and Queensland, to the east by Queensland, New South Wales and Victoria, and along the south by - the Great Australian Bight and the Southern Ocean. With nearly 1.6 million people, the state comprises less than - 10% of the Australian population and ranks fifth in population among the states and territories. -

-
-
-

Northern Territory

-

- The Northern Territory is a federal territory of Australia, occupying much of the center of the mainland continent, - as well as the central northern regions. It shares borders with Western Australia to the west, South Australia to the - south, and Queensland to the east. To the north, the territory is bordered by the Timor Sea, the Arafura Sea and the - Gulf of Carpentaria. Despite its large area — over 1,349,129 square kilometres, making it the third - largest Australian federal division — it is sparsely populated. With a population of 218,380 it is the least populous - division in the country. -

-
-
-

Queensland

-

- Queensland is a state of Australia, occupying the north-eastern corner of the mainland continent. It is bordered by - the Northern Territory to the west, South Australia to the south-west and New South Wales to the south. To the east, - Queensland is bordered by the Coral Sea and Pacific Ocean. The state is Australia’s second largest by area, following - Western Australia, and the country's third most populous after New South Wales and Victoria. -

-
-
-

Tasmania

-

- Tasmania is an Australian island and state of the same name. It is located 240 kilometres south of the - eastern side of the continent, being separated from it by Bass Strait. The state of Tasmania includes the island of - Tasmania and other surrounding islands. Tasmania has an estimated population of 494,520 (March 2008) and an area - of 68,401 square kilometres. - Tasmania is promoted as the Natural State and the "Island of Inspiration" owing to its large and relatively - unspoiled natural environment. The island is 364 kilometres long from the northernmost point to the southernmost point and 306 - kilometres from west to east. -

-
-
-

Demo of Raphaël—JavaScript Vector Library

- - - \ No newline at end of file diff --git a/test/Republic_of_Ireland_counties_and_cities.svg b/test/Republic_of_Ireland_counties_and_cities.svg deleted file mode 100644 index 165a110..0000000 --- a/test/Republic_of_Ireland_counties_and_cities.svg +++ /dev/null @@ -1,7494 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/World_map_-_low_resolution.svgz b/test/World_map_-_low_resolution.svgz deleted file mode 100644 index 35ba55d..0000000 Binary files a/test/World_map_-_low_resolution.svgz and /dev/null differ diff --git a/test/analytics/analytics.html b/test/analytics/analytics.html new file mode 100644 index 0000000..416d154 --- /dev/null +++ b/test/analytics/analytics.html @@ -0,0 +1,96 @@ + + + + + Raphaël · Analytics + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
12345678910111213141516171819192022232425262728293031
825272554597947274444515683129152124086029733562517870682
+
+

Demo of Raphaël—JavaScript Vector Library

+ + diff --git a/test/analytics/analytics.js b/test/analytics/analytics.js new file mode 100644 index 0000000..461a036 --- /dev/null +++ b/test/analytics/analytics.js @@ -0,0 +1,141 @@ +Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) { + color = color || "#000"; + var path = ["M", Math.round(x) + .5, Math.round(y) + .5, "L", Math.round(x + w) + .5, Math.round(y) + .5, Math.round(x + w) + .5, Math.round(y + h) + .5, Math.round(x) + .5, Math.round(y + h) + .5, Math.round(x) + .5, Math.round(y) + .5], + rowHeight = h / hv, + columnWidth = w / wv; + for (var i = 1; i < hv; i++) { + path = path.concat(["M", Math.round(x) + .5, Math.round(y + i * rowHeight) + .5, "H", Math.round(x + w) + .5]); + } + for (i = 1; i < wv; i++) { + path = path.concat(["M", Math.round(x + i * columnWidth) + .5, Math.round(y) + .5, "V", Math.round(y + h) + .5]); + } + return this.path(path.join(",")).attr({stroke: color}); +}; + +$(function () { + $("#data").css({ + position: "absolute", + left: "-9999em", + top: "-9999em" + }); +}); + +window.onload = function () { + function getAnchors(p1x, p1y, p2x, p2y, p3x, p3y) { + var l1 = (p2x - p1x) / 2, + l2 = (p3x - p2x) / 2, + a = Math.atan((p2x - p1x) / Math.abs(p2y - p1y)), + b = Math.atan((p3x - p2x) / Math.abs(p2y - p3y)); + a = p1y < p2y ? Math.PI - a : a; + b = p3y < p2y ? Math.PI - b : b; + var alpha = Math.PI / 2 - ((a + b) % (Math.PI * 2)) / 2, + dx1 = l1 * Math.sin(alpha + a), + dy1 = l1 * Math.cos(alpha + a), + dx2 = l2 * Math.sin(alpha + b), + dy2 = l2 * Math.cos(alpha + b); + return { + x1: p2x - dx1, + y1: p2y + dy1, + x2: p2x + dx2, + y2: p2y + dy2 + }; + } + // Grab the data + var labels = [], + data = []; + $("#data tfoot th").each(function () { + labels.push($(this).html()); + }); + $("#data tbody td").each(function () { + data.push($(this).html()); + }); + + // Draw + var width = 800, + height = 250, + leftgutter = 30, + bottomgutter = 20, + topgutter = 20, + colorhue = .6 || Math.random(), + color = "hsl(" + [colorhue, .5, .5] + ")", + r = Raphael("holder", width, height), + txt = {font: '12px Helvetica, Arial', fill: "#fff"}, + txt1 = {font: '10px Helvetica, Arial', fill: "#fff"}, + txt2 = {font: '12px Helvetica, Arial', fill: "#000"}, + X = (width - leftgutter) / labels.length, + max = Math.max.apply(Math, data), + Y = (height - bottomgutter - topgutter) / max; + r.drawGrid(leftgutter + X * .5 + .5, topgutter + .5, width - leftgutter - X, height - topgutter - bottomgutter, 10, 10, "#000"); + var path = r.path().attr({stroke: color, "stroke-width": 4, "stroke-linejoin": "round"}), + bgp = r.path().attr({stroke: "none", opacity: .3, fill: color}), + label = r.set(), + lx = 0, ly = 0, + is_label_visible = false, + leave_timer, + blanket = r.set(); + label.push(r.text(60, 12, "24 hits").attr(txt)); + label.push(r.text(60, 27, "22 September 2008").attr(txt1).attr({fill: color})); + label.hide(); + var frame = r.popup(100, 100, label, "right").attr({fill: "#000", stroke: "#666", "stroke-width": 2, "fill-opacity": .7}).hide(); + + var p, bgpp; + for (var i = 0, ii = labels.length; i < ii; i++) { + var y = Math.round(height - bottomgutter - Y * data[i]), + x = Math.round(leftgutter + X * (i + .5)), + t = r.text(x, height - 6, labels[i]).attr(txt).toBack(); + if (!i) { + p = ["M", x, y, "C", x, y]; + bgpp = ["M", leftgutter + X * .5, height - bottomgutter, "L", x, y, "C", x, y]; + } + if (i && i < ii - 1) { + var Y0 = Math.round(height - bottomgutter - Y * data[i - 1]), + X0 = Math.round(leftgutter + X * (i - .5)), + Y2 = Math.round(height - bottomgutter - Y * data[i + 1]), + X2 = Math.round(leftgutter + X * (i + 1.5)); + var a = getAnchors(X0, Y0, x, y, X2, Y2); + p = p.concat([a.x1, a.y1, x, y, a.x2, a.y2]); + bgpp = bgpp.concat([a.x1, a.y1, x, y, a.x2, a.y2]); + } + var dot = r.circle(x, y, 4).attr({fill: "#333", stroke: color, "stroke-width": 2}); + blanket.push(r.rect(leftgutter + X * i, 0, X, height - bottomgutter).attr({stroke: "none", fill: "#fff", opacity: 0})); + var rect = blanket[blanket.length - 1]; + (function (x, y, data, lbl, dot) { + var timer, i = 0; + rect.hover(function () { + clearTimeout(leave_timer); + var side = "right"; + if (x + frame.getBBox().width > width) { + side = "left"; + } + var ppp = r.popup(x, y, label, side, 1), + anim = Raphael.animation({ + path: ppp.path, + transform: ["t", ppp.dx, ppp.dy] + }, 200 * is_label_visible); + lx = label[0].transform()[0][1] + ppp.dx; + ly = label[0].transform()[0][2] + ppp.dy; + frame.show().stop().animate(anim); + label[0].attr({text: data + " hit" + (data == 1 ? "" : "s")}).show().stop().animateWith(frame, anim, {transform: ["t", lx, ly]}, 200 * is_label_visible); + label[1].attr({text: lbl + " September 2008"}).show().stop().animateWith(frame, anim, {transform: ["t", lx, ly]}, 200 * is_label_visible); + dot.attr("r", 6); + is_label_visible = true; + }, function () { + dot.attr("r", 4); + leave_timer = setTimeout(function () { + frame.hide(); + label[0].hide(); + label[1].hide(); + is_label_visible = false; + }, 1); + }); + })(x, y, data[i], labels[i], dot); + } + p = p.concat([x, y, x, y]); + bgpp = bgpp.concat([x, y, x, y, "L", x, height - bottomgutter, "z"]); + path.attr({path: p}); + bgp.attr({path: bgpp}); + frame.toFront(); + label[0].toFront(); + label[1].toFront(); + blanket.toFront(); +}; \ No newline at end of file diff --git a/test/analytics/demo-print.css b/test/analytics/demo-print.css new file mode 100644 index 0000000..04c724b --- /dev/null +++ b/test/analytics/demo-print.css @@ -0,0 +1,20 @@ +body { + background: #fff; + color: #000; + font: 100.1% "Lucida Grande", Lucida, Verdana, sans-serif; +} +#holder { + height: 480px; + left: 50%; + margin: 0 0 0 -320px; + position: absolute; + top: 0; + width: 640px; +} +#copy { + bottom: 0; + font-size: .7em; + position: absolute; + right: 1em; + text-align: right; +} diff --git a/test/analytics/demo.css b/test/analytics/demo.css new file mode 100644 index 0000000..a7940af --- /dev/null +++ b/test/analytics/demo.css @@ -0,0 +1,23 @@ +body { + background: #333; + color: #fff; + font: 300 100.1% "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; +} +#holder { + height: 480px; + left: 50%; + margin: -240px 0 0 -320px; + position: absolute; + top: 50%; + width: 640px; +} +#copy { + bottom: 0; + font: 300 .7em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; + position: absolute; + right: 1em; + text-align: right; +} +#copy a { + color: #fff; +} diff --git a/test/analytics/popup.js b/test/analytics/popup.js new file mode 100644 index 0000000..5fd722a --- /dev/null +++ b/test/analytics/popup.js @@ -0,0 +1,121 @@ +(function () { +var tokenRegex = /\{([^\}]+)\}/g, + objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties + replacer = function (all, key, obj) { + var res = obj; + key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) { + name = name || quotedName; + if (res) { + if (name in res) { + res = res[name]; + } + typeof res == "function" && isFunc && (res = res()); + } + }); + res = (res == null || res == obj ? all : res) + ""; + return res; + }, + fill = function (str, obj) { + return String(str).replace(tokenRegex, function (all, key) { + return replacer(all, key, obj); + }); + }; + Raphael.fn.popup = function (X, Y, set, pos, ret) { + pos = String(pos || "top-middle").split("-"); + pos[1] = pos[1] || "middle"; + var r = 5, + bb = set.getBBox(), + w = Math.round(bb.width), + h = Math.round(bb.height), + x = Math.round(bb.x) - r, + y = Math.round(bb.y) - r, + gap = Math.min(h / 2, w / 2, 10), + shapes = { + top: "M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}l-{right},0-{gap},{gap}-{gap}-{gap}-{left},0a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z", + bottom: "M{x},{y}l{left},0,{gap}-{gap},{gap},{gap},{right},0a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z", + right: "M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}v{h4},{h4},{h4},{h4}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}l0-{bottom}-{gap}-{gap},{gap}-{gap},0-{top}a{r},{r},0,0,1,{r}-{r}z", + left: "M{x},{y}h{w4},{w4},{w4},{w4}a{r},{r},0,0,1,{r},{r}l0,{top},{gap},{gap}-{gap},{gap},0,{bottom}a{r},{r},0,0,1,-{r},{r}h-{w4}-{w4}-{w4}-{w4}a{r},{r},0,0,1-{r}-{r}v-{h4}-{h4}-{h4}-{h4}a{r},{r},0,0,1,{r}-{r}z" + }, + offset = { + hx0: X - (x + r + w - gap * 2), + hx1: X - (x + r + w / 2 - gap), + hx2: X - (x + r + gap), + vhy: Y - (y + r + h + r + gap), + "^hy": Y - (y - gap) + + }, + mask = [{ + x: x + r, + y: y, + w: w, + w4: w / 4, + h4: h / 4, + right: 0, + left: w - gap * 2, + bottom: 0, + top: h - gap * 2, + r: r, + h: h, + gap: gap + }, { + x: x + r, + y: y, + w: w, + w4: w / 4, + h4: h / 4, + left: w / 2 - gap, + right: w / 2 - gap, + top: h / 2 - gap, + bottom: h / 2 - gap, + r: r, + h: h, + gap: gap + }, { + x: x + r, + y: y, + w: w, + w4: w / 4, + h4: h / 4, + left: 0, + right: w - gap * 2, + top: 0, + bottom: h - gap * 2, + r: r, + h: h, + gap: gap + }][pos[1] == "middle" ? 1 : (pos[1] == "top" || pos[1] == "left") * 2]; + var dx = 0, + dy = 0, + out = this.path(fill(shapes[pos[0]], mask)).insertBefore(set); + switch (pos[0]) { + case "top": + dx = X - (x + r + mask.left + gap); + dy = Y - (y + r + h + r + gap); + break; + case "bottom": + dx = X - (x + r + mask.left + gap); + dy = Y - (y - gap); + break; + case "left": + dx = X - (x + r + w + r + gap); + dy = Y - (y + r + mask.top + gap); + break; + case "right": + dx = X - (x - gap); + dy = Y - (y + r + mask.top + gap); + break; + } + out.translate(dx, dy); + if (ret) { + ret = out.attr("path"); + out.remove(); + return { + path: ret, + dx: dx, + dy: dy + }; + } + set.translate(dx, dy); + return out; + }; +})(); \ No newline at end of file diff --git a/test/demo-print.css b/test/demo-print.css deleted file mode 100644 index 04c724b..0000000 --- a/test/demo-print.css +++ /dev/null @@ -1,20 +0,0 @@ -body { - background: #fff; - color: #000; - font: 100.1% "Lucida Grande", Lucida, Verdana, sans-serif; -} -#holder { - height: 480px; - left: 50%; - margin: 0 0 0 -320px; - position: absolute; - top: 0; - width: 640px; -} -#copy { - bottom: 0; - font-size: .7em; - position: absolute; - right: 1em; - text-align: right; -} diff --git a/test/demo.css b/test/demo.css deleted file mode 100644 index a7940af..0000000 --- a/test/demo.css +++ /dev/null @@ -1,23 +0,0 @@ -body { - background: #333; - color: #fff; - font: 300 100.1% "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; -} -#holder { - height: 480px; - left: 50%; - margin: -240px 0 0 -320px; - position: absolute; - top: 50%; - width: 640px; -} -#copy { - bottom: 0; - font: 300 .7em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; - position: absolute; - right: 1em; - text-align: right; -} -#copy a { - color: #fff; -} diff --git a/test/g.raphael-min.js b/test/g.raphael-min.js deleted file mode 100644 index ec0ce1f..0000000 --- a/test/g.raphael-min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * g.Raphael 0.5 - Charting library, based on Raphaël - * - * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com) - * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. - */ -Raphael.el.popup=function(d,k,h,g){var c=this.paper||this[0].paper,f,j,b,e,a;if(!c){return}switch(this.type){case"text":case"circle":case"ellipse":b=true;break;default:b=false}d=d==null?"up":d;k=k||5;f=this.getBBox();h=typeof h=="number"?h:(b?f.x+f.width/2:f.x);g=typeof g=="number"?g:(b?f.y+f.height/2:f.y);e=Math.max(f.width/2-k,0);a=Math.max(f.height/2-k,0);this.translate(h-f.x-(b?f.width/2:0),g-f.y-(b?f.height/2:0));f=this.getBBox();var i={up:["M",h,g,"l",-k,-k,-e,0,"a",k,k,0,0,1,-k,-k,"l",0,-f.height,"a",k,k,0,0,1,k,-k,"l",k*2+e*2,0,"a",k,k,0,0,1,k,k,"l",0,f.height,"a",k,k,0,0,1,-k,k,"l",-e,0,"z"].join(","),down:["M",h,g,"l",k,k,e,0,"a",k,k,0,0,1,k,k,"l",0,f.height,"a",k,k,0,0,1,-k,k,"l",-(k*2+e*2),0,"a",k,k,0,0,1,-k,-k,"l",0,-f.height,"a",k,k,0,0,1,k,-k,"l",e,0,"z"].join(","),left:["M",h,g,"l",-k,k,0,a,"a",k,k,0,0,1,-k,k,"l",-f.width,0,"a",k,k,0,0,1,-k,-k,"l",0,-(k*2+a*2),"a",k,k,0,0,1,k,-k,"l",f.width,0,"a",k,k,0,0,1,k,k,"l",0,a,"z"].join(","),right:["M",h,g,"l",k,-k,0,-a,"a",k,k,0,0,1,k,-k,"l",f.width,0,"a",k,k,0,0,1,k,k,"l",0,k*2+a*2,"a",k,k,0,0,1,-k,k,"l",-f.width,0,"a",k,k,0,0,1,-k,-k,"l",0,-a,"z"].join(",")};j={up:{x:-!b*(f.width/2),y:-k*2-(b?f.height/2:f.height)},down:{x:-!b*(f.width/2),y:k*2+(b?f.height/2:f.height)},left:{x:-k*2-(b?f.width/2:f.width),y:-!b*(f.height/2)},right:{x:k*2+(b?f.width/2:f.width),y:-!b*(f.height/2)}}[d];this.translate(j.x,j.y);return c.path(i[d]).attr({fill:"#000",stroke:"none"}).insertBefore(this.node?this:this[0])};Raphael.el.tag=function(f,b,l,k){var i=3,e=this.paper||this[0].paper;if(!e){return}var c=e.path().attr({fill:"#000",stroke:"#000"}),j=this.getBBox(),m,h,a,g;switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}f=f||0;l=typeof l=="number"?l:(a?j.x+j.width/2:j.x);k=typeof k=="number"?k:(a?j.y+j.height/2:j.y);b=b==null?5:b;h=0.5522*b;if(j.height>=b*2){c.attr({path:["M",l,k+b,"a",b,b,0,1,1,0,-b*2,b,b,0,1,1,0,b*2,"m",0,-b*2-i,"a",b+i,b+i,0,1,0,0,(b+i)*2,"L",l+b+i,k+j.height/2+i,"l",j.width+2*i,0,0,-j.height-2*i,-j.width-2*i,0,"L",l,k-b-i].join(",")})}else{m=Math.sqrt(Math.pow(b+i,2)-Math.pow(j.height/2+i,2));c.attr({path:["M",l,k+b,"c",-h,0,-b,h-b,-b,-b,0,-h,b-h,-b,b,-b,h,0,b,b-h,b,b,0,h,h-b,b,-b,b,"M",l+m,k-j.height/2-i,"a",b+i,b+i,0,1,0,0,j.height+2*i,"l",b+i-m+j.width+2*i,0,0,-j.height-2*i,"L",l+m,k-j.height/2-i].join(",")})}f=360-f;c.rotate(f,l,k);if(this.attrs){this.attr(this.attrs.x?"x":"cx",l+b+i+(!a?this.type=="text"?j.width:0:j.width/2)).attr("y",a?k:k-j.height/2);this.rotate(f,l,k);f>90&&f<270&&this.attr(this.attrs.x?"x":"cx",l-b-i-(!a?j.width:j.width/2)).rotate(180,l,k)}else{if(f>90&&f<270){this.translate(l-j.x-j.width-b-i,k-j.y-j.height/2);this.rotate(f-180,j.x+j.width+b+i,j.y+j.height/2)}else{this.translate(l-j.x+b+i,k-j.y-j.height/2);this.rotate(f,j.x-b-i,j.y+j.height/2)}}return c.insertBefore(this.node?this:this[0])};Raphael.el.drop=function(d,g,f){var e=this.getBBox(),c=this.paper||this[0].paper,a,j,b,i,h;if(!c){return}switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}d=d||0;g=typeof g=="number"?g:(a?e.x+e.width/2:e.x);f=typeof f=="number"?f:(a?e.y+e.height/2:e.y);j=Math.max(e.width,e.height)+Math.min(e.width,e.height);b=c.path(["M",g,f,"l",j,0,"A",j*0.4,j*0.4,0,1,0,g+j*0.7,f-j*0.7,"z"]).attr({fill:"#000",stroke:"none"}).rotate(22.5-d,g,f);d=(d+90)*Math.PI/180;i=(g+j*Math.sin(d))-(a?0:e.width/2);h=(f+j*Math.cos(d))-(a?0:e.height/2);this.attrs?this.attr(this.attrs.x?"x":"cx",i).attr(this.attrs.y?"y":"cy",h):this.translate(i-e.x,h-e.y);return b.insertBefore(this.node?this:this[0])};Raphael.el.flag=function(e,k,j){var g=3,c=this.paper||this[0].paper;if(!c){return}var b=c.path().attr({fill:"#000",stroke:"#000"}),i=this.getBBox(),f=i.height/2,a;switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}e=e||0;k=typeof k=="number"?k:(a?i.x+i.width/2:i.x);j=typeof j=="number"?j:(a?i.y+i.height/2:i.y);b.attr({path:["M",k,j,"l",f+g,-f-g,i.width+2*g,0,0,i.height+2*g,-i.width-2*g,0,"z"].join(",")});e=360-e;b.rotate(e,k,j);if(this.attrs){this.attr(this.attrs.x?"x":"cx",k+f+g+(!a?this.type=="text"?i.width:0:i.width/2)).attr("y",a?j:j-i.height/2);this.rotate(e,k,j);e>90&&e<270&&this.attr(this.attrs.x?"x":"cx",k-f-g-(!a?i.width:i.width/2)).rotate(180,k,j)}else{if(e>90&&e<270){this.translate(k-i.x-i.width-f-g,j-i.y-i.height/2);this.rotate(e-180,i.x+i.width+f+g,i.y+i.height/2)}else{this.translate(k-i.x+f+g,j-i.y-i.height/2);this.rotate(e,i.x-f-g,i.y+i.height/2)}}return b.insertBefore(this.node?this:this[0])};Raphael.el.label=function(){var c=this.getBBox(),b=this.paper||this[0].paper,a=Math.min(20,c.width+10,c.height+10)/2;if(!b){return}return b.rect(c.x-a/2,c.y-a/2,c.width+a,c.height+a,a).attr({stroke:"none",fill:"#000"}).insertBefore(this.node?this:this[0])};Raphael.el.blob=function(z,j,i){var g=this.getBBox(),B=Math.PI/180,n=this.paper||this[0].paper,r,A,q;if(!n){return}switch(this.type){case"text":case"circle":case"ellipse":A=true;break;default:A=false}r=n.path().attr({fill:"#000",stroke:"none"});z=(+z+1?z:45)+90;q=Math.min(g.height,g.width);j=typeof j=="number"?j:(A?g.x+g.width/2:g.x);i=typeof i=="number"?i:(A?g.y+g.height/2:g.y);var m=Math.max(g.width+q,q*25/12),t=Math.max(g.height+q,q*25/12),u=j+q*Math.sin((z-22.5)*B),b=i+q*Math.cos((z-22.5)*B),v=j+q*Math.sin((z+22.5)*B),d=i+q*Math.cos((z+22.5)*B),o=(v-u)/2,l=(d-b)/2,f=m/2,e=t/2,s=-Math.sqrt(Math.abs(f*f*e*e-f*f*l*l-e*e*o*o)/(f*f*l*l+e*e*o*o)),c=s*f*l/e+(v+u)/2,a=s*-e*o/f+(d+b)/2;r.attr({x:c,y:a,path:["M",j,i,"L",v,d,"A",f,e,0,1,1,u,b,"z"].join(",")});this.translate(c-g.x-g.width/2,a-g.y-g.height/2);return r.insertBefore(this.node?this:this[0])};Raphael.fn.label=function(a,d,b){var c=this.set();b=this.text(a,d,b).attr(Raphael.g.txtattr);return c.push(b.label(),b)};Raphael.fn.popup=function(a,f,d,b,c){var e=this.set();d=this.text(a,f,d).attr(Raphael.g.txtattr);return e.push(d.popup(b,c),d)};Raphael.fn.tag=function(a,f,d,c,b){var e=this.set();d=this.text(a,f,d).attr(Raphael.g.txtattr);return e.push(d.tag(c,b),d)};Raphael.fn.flag=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.flag(b),c)};Raphael.fn.drop=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.drop(b),c)};Raphael.fn.blob=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.blob(b),c)};Raphael.el.lighter=function(b){b=b||2;var a=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[a[0],a[1]];a[0]=Raphael.rgb2hsb(Raphael.getRGB(a[0]).hex);a[1]=Raphael.rgb2hsb(Raphael.getRGB(a[1]).hex);a[0].b=Math.min(a[0].b*b,1);a[0].s=a[0].s/b;a[1].b=Math.min(a[1].b*b,1);a[1].s=a[1].s/b;this.attr({fill:"hsb("+[a[0].h,a[0].s,a[0].b]+")",stroke:"hsb("+[a[1].h,a[1].s,a[1].b]+")"});return this};Raphael.el.darker=function(b){b=b||2;var a=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[a[0],a[1]];a[0]=Raphael.rgb2hsb(Raphael.getRGB(a[0]).hex);a[1]=Raphael.rgb2hsb(Raphael.getRGB(a[1]).hex);a[0].s=Math.min(a[0].s*b,1);a[0].b=a[0].b/b;a[1].s=Math.min(a[1].s*b,1);a[1].b=a[1].b/b;this.attr({fill:"hsb("+[a[0].h,a[0].s,a[0].b]+")",stroke:"hsb("+[a[1].h,a[1].s,a[1].b]+")"});return this};Raphael.el.resetBrightness=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs}return this};(function(){var c=["lighter","darker","resetBrightness"],a=["popup","tag","flag","label","drop","blob"];for(var b in a){(function(d){Raphael.st[d]=function(){return Raphael.el[d].apply(this,arguments)}})(a[b])}for(var b in c){(function(d){Raphael.st[d]=function(){for(var e=0;e0?0:0.5))*Math.pow(10,b))/Math.pow(10,b);return{from:e,to:l,power:b}},axis:function(p,o,k,D,e,G,g,J,h,a,q){a=a==null?2:a;h=h||"t";G=G||10;q=arguments[arguments.length-1];var C=h=="|"||h==" "?["M",p+0.5,o,"l",0,0.001]:g==1||g==3?["M",p+0.5,o,"l",0,-k]:["M",p,o+0.5,"l",k,0],s=this.snapEnds(D,e,G),H=s.from,z=s.to,F=s.power,E=0,w={font:"11px 'Fontin Sans', Fontin-Sans, sans-serif"},v=q.set(),I;I=(z-H)/G;var n=H,m=F>0?F:0;r=k/G;if(+g==1||+g==3){var b=o,u=(g-1?1:-1)*(a+3+!!(g-1));while(b>=o-k){h!="-"&&h!=" "&&(C=C.concat(["M",p-(h=="+"||h=="|"?a:!(g-1)*a*2),b+0.5,"l",a*2+1,0]));v.push(q.text(p+u,b,(J&&J[E++])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w).attr({"text-anchor":g-1?"start":"end"}));n+=I;b-=r}if(Math.round(b+r-(o-k))){h!="-"&&h!=" "&&(C=C.concat(["M",p-(h=="+"||h=="|"?a:!(g-1)*a*2),o-k+0.5,"l",a*2+1,0]));v.push(q.text(p+u,o-k,(J&&J[E])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w).attr({"text-anchor":g-1?"start":"end"}))}}else{n=H;m=(F>0)*F;u=(g?-1:1)*(a+9+!g);var c=p,r=k/G,A=0,B=0;while(c<=p+k){h!="-"&&h!=" "&&(C=C.concat(["M",c+0.5,o-(h=="+"?a:!!g*a*2),"l",0,a*2+1]));v.push(A=q.text(c,o+u,(J&&J[E++])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w));var l=A.getBBox();if(B>=l.x-5){v.pop(v.length-1).remove()}else{B=l.x+l.width}n+=I;c+=r}if(Math.round(c-r-p-k)){h!="-"&&h!=" "&&(C=C.concat(["M",p+k+0.5,o-(h=="+"?a:!!g*a*2),"l",0,a*2+1]));v.push(q.text(p+k,o+u,(J&&J[E])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w))}}var K=q.path(C);K.text=v;K.all=q.set([K,v]);K.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this)};return K},labelise:function(a,c,b){if(a){return(a+"").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g,function(d,f,e){if(f){return(+c).toFixed(f.replace(/^#+\.?/g,"").length)}if(e){return(c*100/b).toFixed(e.replace(/^%+\.?/g,"").length)+"%"}})}else{return(+c).toFixed(0)}}}; \ No newline at end of file diff --git a/test/g.raphael/README.md b/test/g.raphael/README.md new file mode 100644 index 0000000..34092b9 --- /dev/null +++ b/test/g.raphael/README.md @@ -0,0 +1,17 @@ +# unofficial documentation fork of g.raphael # + +I started this fork while learning about g.raphael and decided to record down what I know from my noobish studying of the source code. This is *NOT* an official documentation, you should keep a lookout on the [official gRaphael website](http://example.net/) for the real deal. + +In the meantime, I hope this continue to serve as a easy to understand resource. + +## docs folder ## + +contains the various breakdown of the different g.raphael charts written in markdown. + +## examples folder ## + +contains examples. Often I get emails or Twitter messages asking me how to do X in gRaphael and I prefer to just make an example and post it here for other people to reference. + +## I could be wrong ## + +If you spot any mistake or wish to expound on the current stuff here, please let me know. \ No newline at end of file diff --git a/test/g.raphael/docs/bar.markdown b/test/g.raphael/docs/bar.markdown new file mode 100644 index 0000000..150e7dc --- /dev/null +++ b/test/g.raphael/docs/bar.markdown @@ -0,0 +1,104 @@ +# g.bar.js # + +## Requirements ## + + + raphael.js + + g.raphael.js + + g.bar.js + +## Overview ## + +Creates a bar chart. + +## Parameters ## + +**1. x** number **X coordinate of the centre** + +**2. y** number **Y coordinate of the centre** + +**3. width** number **width** + +**4. height** number **height** + +**5. values** array of numbers **Values for your bars.** + +**5. opts** object **Options (more info soon.)** + +_opts_ + +**type** + +Values are, + + + "round" + + "sharp" + + "soft" + + "square" + +Defaults to "square" if type is not specified. + +**stacked** + +Values are, + + + true + + false + +Defaults to false. Use this to stack your bars instead of displaying them side by side. + +**gutter** + +Values given as a string, denoting %. E.g. "40%" + +Defaults to "20%". For horizontal barcharts, this is calculated as, + + bargutter = Math.floor(barheight * gutter / 100) + +e.g. if my height was 220, and I had 4 bars, then my barheight is calculated as, + + Math.floor(height / (len * (100 + gutter) + gutter) * 100); // where len is 4 and height is 220, and if not specified, gutter is 20 + +then according to the above, my bargutter = 8px. + + +## Methods ## + +**1. .hover(fin, fout)** - fin/fout: **callbacks to trigger when mouse hovers in and out respectively over the bars.** + +## Usage ## + +Create a bar chart, + + + // bare bones + var barchart = r.g.barchart(_params); + // example + var barchart = r.g.barchart(10, 10, 300, 220, [[30, 20, 10]]); + // horizontal barchart + var hbarchart = r.g.hbarchart(10, 10, 300, 220, [[30, 20, 10]]); + + +Create a stacked bar chart, + + + // example + var barchart = r.g.barchart(10, 10, 300, 220, [[30, 20, 10], [44, 66, 88]], {stacked:true}); + + +Attach hover event to piechart, + + + // example + r.g.barchart.hover(function() { + this.bar.attr({fill: "#333"}); + }, function() { + this.bar.attr({fill: "#666"}); + }); + +## Others ## + +N/A + +## Written by ## + +Kenny Shen, www.northpole.sg. \ No newline at end of file diff --git a/test/g.raphael/docs/dot.markdown b/test/g.raphael/docs/dot.markdown new file mode 100644 index 0000000..03fa76f --- /dev/null +++ b/test/g.raphael/docs/dot.markdown @@ -0,0 +1,135 @@ +# g.dot.js # + +## Requirements ## + + + raphael.js + + g.raphael.js + + g.dot.js + +## Overview ## + +Creates a dot chart. + +## Parameters ## + +**1. x** number **X coordinate of the centre** + +**2. y** number **Y coordinate of the centre** + +**3. width** number **width** + +**4. height** number **height** + +**5. valuesx** array of numbers **Values for x-axis.** + +**6. valuesy** array of numbers **Values for y-axis.** + +**7. size** array of numbers **Values for dot data.** + +**8. opts** object **Options (more info soon.)** + +_opts_ + +**symbol** + +Values are, + +_(shorthand: full name)_ + + + o: "disc" + + f: "flower" + + d: "diamond" + + s: "square" + + t: "triangle" + + *: "star" + + x: "cross" + + +: "plus" + + ->: "arrow" + +If omitted, an empty "" is assigned to indicate no symbols. + +**max** + +Value - number. If omitted, this defaults to 100. This sets the max radius for the maximum value of your dot. + +**href** + +Value - array of links(string). This is positional and will be mapped from left to right. For example, if you supply 'href:["http://www.google.com","http://www.yahoo.com"]' and you have 4 dots, the links will be applied to the first two. + +**axis** + +Value - "_top_ _right_ _bottom_ _left_". If omitted, no axis will be rendered for the line chart. For example, if you wanted axis rendered for the left and bottom, (as in a typical x-y chart), you'll add 'axis:"0 0 1 1"' to opts. The axis is created using g.axis (for more information, see the g documentation). + +**axisxlabels** + +Value - array of labels. + +**axisylabels** + +Value - array of labels(string). + +**axisxstep** + +Value - number. Sets the stepping for the x-axis. + +**axisystep** + +Value - number. Sets the stepping for the y-axis. + +**heat** + +Value - boolean. If omitted, defaults to false. Sets a spectrum of color based on your values evenly across the dots. + +## Methods ## + +**1. .hover(fin, fout)** - fin/fout: **callbacks to trigger when mouse hovers in and out respectively over the dots.** + +**2. .click(f)** - f: **callback to trigger on click event.** + +**3. .each(f)** - f: **callback applied to each iteration.** + +## Usage ## + +Create a Raphael instance, + + + // bare bones + var r = Raphael(); + // create at top left corner of #element + var r = Raphael('dot-chart'); + + +Create a dot chart, + + + // bare bones + var dotchart = r.g.dotchart(_params); + // example + var dotchart = r.g.dotchart(10,10,300,220,[5,10,15,20,25],[220,220,220,220,220],[1,2,3,4,5], {max:10}); + + +Create labels, + + + // example + var axisx = ["dot1","dot2","dot3","dot4","dot5"] + r.g.dotchart(10,10,300,220,[5,10,15,20,25],[220,220,220,220,220],[1,2,3,4,5], {max:10, axis: "0 0 1 0", axisxlabels: axisx, axisxstep: 4, heat: true}); + + +Attach click event to dotchart, + + + // example + var dots = r.g.dotchart(10,10,300,220,[5,10,15,20,25],[220,220,220,220,220],[1,2,3,4,5], {max:10, href: ["http://www.google.com","http://www.yahoo.com",,,"http://www.raphaeljs.com"]}); + dots.each(function() { + this.click(function() { + // alerts href, if defined + alert(this.attrs.href); + }); + }); + +## Others ## + +## Written by ## + +Kenny Shen, www.northpole.sg. \ No newline at end of file diff --git a/test/g.raphael/docs/g.markdown b/test/g.raphael/docs/g.markdown new file mode 100644 index 0000000..10faea2 --- /dev/null +++ b/test/g.raphael/docs/g.markdown @@ -0,0 +1,7 @@ +# g.raphael.js # + +_in progress_ + +## Written by ## + +Kenny Shen, www.northpole.sg. \ No newline at end of file diff --git a/test/g.raphael/docs/line.markdown b/test/g.raphael/docs/line.markdown new file mode 100644 index 0000000..9ee4c96 --- /dev/null +++ b/test/g.raphael/docs/line.markdown @@ -0,0 +1,159 @@ +# g.line.js # + +## Requirements ## + + + raphael.js + + g.raphael.js + + g.line.js + +## Overview ## + +Creates a line chart. + +## Parameters ## + +**1. x** number **X coordinate of the centre** + +**2. y** number **Y coordinate of the centre** + +**3. width** number **width** + +**4. height** number **height** + +**5. valuesx** array of numbers **Values for x-axis.** + +**6. valuesy** array of numbers **Values for y-axis.** + +**7. opts** object **Options (more info soon.)** + +_opts_ + +**colors** + +Value - an array of color values, such as ["#444","#666"...]. If omitted, random colors will be used. (actually, Raphael.fn.g.colors. More info on this in the g.raphael.js documentation) For more information, refer to the [supported color formats](http://raphaeljs.com/reference.html#colour) section of the Raphaeljs documention. + +**symbol** + +Values are, + +_(shorthand: full name)_ + + + o: "disc" + + f: "flower" + + d: "diamond" + + s: "square" + + t: "triangle" + + *: "star" + + x: "cross" + + +: "plus" + + ->: "arrow" + +If omitted, an empty "" is assigned to indicate no symbols. + +**shade** + +Value - boolean. If omitted, false is assumed. If true, the area underneath the line will be shaded with the same color as the line, with opacity set to .3. You can affect this by setting nostroke (see below) option to true. + +**nostroke** + +Value - boolean. If omitted, false is assumed. + +**axis** + +Value - "_top_ _right_ _bottom_ _left_". If omitted, no axis will be rendered for the line chart. For example, if you wanted axis rendered for the left and bottom, (as in a typical x-y chart), you'll add 'axis:"0 0 1 1"' to opts. The axis is created using g.axis (for more information, see the g documentation). + +**smooth** + +Value - boolean. If omitted, false is assumed. If true, smoothing/rounding is applied to the path between data points. + +**gutter** + +Value - number. If omitted, value of '10' is assigned. Think of this as a general padding value between the chart and the bounding box/container. + + +## Methods ## + +**1. .hover(fin, fout)** - fin/fout: **callbacks to trigger when mouse hovers in and out respectively over the data points.** + +**2. .click(f)** - f: **callback to trigger on click event.** + +**3. .each(f)** - f: **callback applied to each iteration.** + +.each(f) works by iterating through each of the data points and returning each as a 'dot' object to the callback f(). Within the callback, you can access the object returned on each iteration in the context of 'this', for example + + + var f = function() { + + console.log(this.symbol); // the symbol used to represent the data point on the line chart + + } + +**4. .hoverColumn(fin, fout)** - fin/fout: **callbacks to trigger when mouse hovers in and out respectively over the data columns.** + +**5. .clickColumn(f)** - f: **callback to trigger on click event.** + +**6. .hrefColumn(cols)** - _coming soon_ + +**7. .eachColumn(f)** - f: **callback applied to each iteration.** + + +## Usage ## + +Create a Raphael instance, + + + // bare bones + var r = Raphael(); + // create at top left corner of #element + var r = Raphael('line-chart'); + + +Create a line chart, + + + // bare bones + var linechart = r.g.linechart(_params); + // example + var linechart = r.g.linechart(10,10,300,220,[1,2,3,4,5],[10,20,15,35,30], {"colors":["#444"], "symbol":"s", axis:"0 0 1 1"}); + + +Attach hover event to linechart, + + + // example + r.g.linechart.hover(function() { + this.symbol.attr({'fill':'#CCC'}); + }, function() { + this.symbol.attr({'fill':'#444'}); + }); + + +Attach click event to linechart, + + + // example + r.g.linechart.click(function() { + alert("You clicked on the line chart!"); + }); + + +## Others ## + +There's two important internal methods that are used to create and return the objects for interaction with a gRaphael line chart, based on what methods you call. + +.hover(), .click(), .each() create and return representations ('dots') of the data points used to plot the line. The dots have the following properties when they're returned in the context of 'this' to the methods you call, + + + x + + y + + value + + line + + shade + + symbol + + symbols + + axis + +.hoverColumn(), .clickColumn(), .eachColumn() create and return groupings of data 'dots'. Columns have similar properties to their atomic counterparts but are usually array of values. + +## Written by ## + +Kenny Shen, www.northpole.sg. \ No newline at end of file diff --git a/test/g.raphael/docs/pie.markdown b/test/g.raphael/docs/pie.markdown new file mode 100644 index 0000000..3dbc6d3 --- /dev/null +++ b/test/g.raphael/docs/pie.markdown @@ -0,0 +1,150 @@ +# g.pie.js # + +## Requirements ## + + + raphael.js + + g.raphael.js + + g.pie.js + +## Overview ## + +Creates a pie chart. + +## Parameters ## + +**1. x** number **X coordinate of the centre** + +**2. y** number **Y coordinate of the centre** + +**3. r** number **radius** + +**4. values** array of numbers **Values for your slices.** + +**5. opts** object **Options (more info soon.)** + +_opts_ + +**legend** + +Values are, + + + legend - e.g. ["apples", "oranges"] + + legendothers + + legendmark + + legendpos - e.g. "west" + +legend is required. If legendpos is omitted, 'east' is assumed. If legendmark is omitted, 'disc' is assumed. The current possible options for legendmark and legendpos are, + +**legendmark** + +Values are, + +_(shorthand: full name)_ + + + o: "disc" + + f: "flower" + + d: "diamond" + + s: "square" + + t: "triangle" + + *: "star" + + x: "cross" + + +: "plus" + + ->: "arrow" + +**legendpos** + +Values are, + + + "north" + + "south" + + "east" + + "west" + +## Methods ## + +**1. .hover(fin, fout)** - fin/fout: **callbacks to trigger when mouse hovers in and out respectively over the pie sectors.** + +**2. .click(f)** - f: **callback to trigger on click event.** + +**3. .each(f)** - f: **callback applied to each iteration.** + +.each(f) works by iterating through each of the slices and returning each as an object to the callback f(). Within the callback, you can access the object returned on each iteration in the context of 'this', for example + + + var f = function() { + + console.log(this.r); // the radius of the slice + + } + +## Usage ## + +Create a Raphael instance, + + + // bare bones + var r = Raphael(); + // create at top left corner of #element + var r = Raphael('pie-chart'); + + +Create a pie chart, + + + // bare bones + var pie = r.g.piechart(_params); + // example + var pie = r.g.piechart(10, 10, 90, [10,20,30]); + + +Create legends, + + + // example + r.g.piechart(320, 240, 100, [10,20,30,40], {legend:['%% apples', '%% bananas', '%% cherries', '%% durians'], legendmark:"*", legendpos: "south"}); + +Attach hover event to piechart, + + + // example + r.g.piechart(10, 10, 90, [10,20,30]).hover(function() { + // when mouse hovers over slice, change color + this.sector.attr({fill:"#FAA"}); + }, function() { + // when mouse hovers out, restore color + this.sector.attr({fill:"#666"}); + }); + +Attach click event to piechart, + + + // example + r.g.piechart.click(function() { + alert("You clicked on the pie chart!"); + }); + +## Others ## + +Each pie chart in g.raphael.js is composed of a 'series', or a collection of slices/sectors. Each slice has its own 'sector' property which carries information like the value, the color and other attributes, as well as its own 'cover' which can be thought of as a layer (really set to opacity 0) to which you attach events like click or hover. + +When you iterate through each slice of the pie chart using .each(), the returned slice has the following properties: + + + sector + + cover + + cx + + cy + + x (middle x coordinate of the sector) + + y (middle y coordinate of the sector) + + mangle + + r (radius) + + value + + total + + label + +When you attach a hover event for example, using .hover(), g.raphael.js is essentially iterating through each slice, as it does in .each(), and passing the returned slice to the callbacks to be called, and setting the events to happen by binding mouseover and mouseout events to the covers. + +All of this is container within the 'chart' object, which is initialized and returned to you when you first call g.piechart. + +## Written by ## + +Kenny Shen, www.northpole.sg. \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_basic.html b/test/g.raphael/examples/barchart/barchart_basic.html new file mode 100644 index 0000000..8956e9f --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_basic.html @@ -0,0 +1,20 @@ + + + gRaphaël Bar Chart - a simple barchart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_custom_axis.html b/test/g.raphael/examples/barchart/barchart_custom_axis.html new file mode 100644 index 0000000..5cf8e74 --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_custom_axis.html @@ -0,0 +1,23 @@ + + + gRaphaël Bar Chart - a barchart with customised axis + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_custom_spacing.html b/test/g.raphael/examples/barchart/barchart_custom_spacing.html new file mode 100644 index 0000000..f7a51e7 --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_custom_spacing.html @@ -0,0 +1,21 @@ + + + gRaphaël Bar Chart - a horizontal barchart with gutters + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_horizontal.html b/test/g.raphael/examples/barchart/barchart_horizontal.html new file mode 100644 index 0000000..87f422f --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_horizontal.html @@ -0,0 +1,20 @@ + + + gRaphaël Bar Chart - a simple barchart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_hover.html b/test/g.raphael/examples/barchart/barchart_hover.html new file mode 100644 index 0000000..4366857 --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_hover.html @@ -0,0 +1,27 @@ + + + gRaphaël Bar Chart - a .hover() example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_hoverCol.html b/test/g.raphael/examples/barchart/barchart_hoverCol.html new file mode 100644 index 0000000..0c61574 --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_hoverCol.html @@ -0,0 +1,29 @@ + + + gRaphaël Bar Chart - a .hoverColumn() example + + + + + + + + diff --git a/test/g.raphael/examples/barchart/barchart_stacked.html b/test/g.raphael/examples/barchart/barchart_stacked.html new file mode 100644 index 0000000..6bfd9de --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_stacked.html @@ -0,0 +1,28 @@ + + + gRaphaël Bar Chart - a stacked vs unstacked barchart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/barchart/barchart_text_axis.html b/test/g.raphael/examples/barchart/barchart_text_axis.html new file mode 100644 index 0000000..e3036f7 --- /dev/null +++ b/test/g.raphael/examples/barchart/barchart_text_axis.html @@ -0,0 +1,25 @@ + + + gRaphaël Bar Chart - a barchart with text x-axis + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/dot/dotchart_basic.html b/test/g.raphael/examples/dot/dotchart_basic.html new file mode 100644 index 0000000..3cb74ed --- /dev/null +++ b/test/g.raphael/examples/dot/dotchart_basic.html @@ -0,0 +1,22 @@ + + + gRaphaël Line Chart - a simple dot chart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/dot/dotchart_href.html b/test/g.raphael/examples/dot/dotchart_href.html new file mode 100644 index 0000000..575d8ab --- /dev/null +++ b/test/g.raphael/examples/dot/dotchart_href.html @@ -0,0 +1,28 @@ + + + gRaphaël Line Chart - a simple dot chart example with hyperlinks + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/dot/dotchart_labels.html b/test/g.raphael/examples/dot/dotchart_labels.html new file mode 100644 index 0000000..3d61097 --- /dev/null +++ b/test/g.raphael/examples/dot/dotchart_labels.html @@ -0,0 +1,23 @@ + + + gRaphaël Line Chart - a labelled dot chart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/dot/dotchart_symbols.html b/test/g.raphael/examples/dot/dotchart_symbols.html new file mode 100644 index 0000000..60a6f21 --- /dev/null +++ b/test/g.raphael/examples/dot/dotchart_symbols.html @@ -0,0 +1,22 @@ + + + gRaphaël Line Chart - customised symbol dot chart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/linechart/linechart_basic.html b/test/g.raphael/examples/linechart/linechart_basic.html new file mode 100644 index 0000000..4527f12 --- /dev/null +++ b/test/g.raphael/examples/linechart/linechart_basic.html @@ -0,0 +1,21 @@ + + + gRaphaël Line Chart - a simple line chart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/linechart/linechart_interactive.html b/test/g.raphael/examples/linechart/linechart_interactive.html new file mode 100644 index 0000000..824d969 --- /dev/null +++ b/test/g.raphael/examples/linechart/linechart_interactive.html @@ -0,0 +1,27 @@ + + + gRaphaël Line Chart - line chart interaction example + + + + + + +
+ + diff --git a/test/g.raphael/examples/linechart/linechart_opts.html b/test/g.raphael/examples/linechart/linechart_opts.html new file mode 100644 index 0000000..ac14e24 --- /dev/null +++ b/test/g.raphael/examples/linechart/linechart_opts.html @@ -0,0 +1,22 @@ + + + gRaphaël Line Chart - line chart interaction example + + + + + + +
+ + diff --git a/test/g.raphael/examples/linechart/linechart_shading.html b/test/g.raphael/examples/linechart/linechart_shading.html new file mode 100644 index 0000000..c429d8c --- /dev/null +++ b/test/g.raphael/examples/linechart/linechart_shading.html @@ -0,0 +1,28 @@ + + + gRaphaël Line Chart - a line chart with shading example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/piechart/piechart_basic.html b/test/g.raphael/examples/piechart/piechart_basic.html new file mode 100644 index 0000000..54cc4bb --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_basic.html @@ -0,0 +1,24 @@ + + + gRaphaël Pie Chart - a simple piechart example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/piechart/piechart_each.html b/test/g.raphael/examples/piechart/piechart_each.html new file mode 100644 index 0000000..e66be8d --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_each.html @@ -0,0 +1,28 @@ + + + gRaphaël Pie Chart - iterating through sectors using .each() + + + + + + + + diff --git a/test/g.raphael/examples/piechart/piechart_hover.html b/test/g.raphael/examples/piechart/piechart_hover.html new file mode 100644 index 0000000..f3a62a8 --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_hover.html @@ -0,0 +1,28 @@ + + + gRaphaël Pie Chart - a .hover() example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/piechart/piechart_hover_adv.html b/test/g.raphael/examples/piechart/piechart_hover_adv.html new file mode 100644 index 0000000..ce41d3a --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_hover_adv.html @@ -0,0 +1,41 @@ + + + gRaphaël Pie Chart - a more complex .hover() example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/piechart/piechart_rotate.html b/test/g.raphael/examples/piechart/piechart_rotate.html new file mode 100644 index 0000000..1ee3a24 --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_rotate.html @@ -0,0 +1,28 @@ + + + gRaphaël Pie Chart - rotate your piechart + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/piechart/piechart_with_legend.html b/test/g.raphael/examples/piechart/piechart_with_legend.html new file mode 100644 index 0000000..721656a --- /dev/null +++ b/test/g.raphael/examples/piechart/piechart_with_legend.html @@ -0,0 +1,20 @@ + + + gRaphaël Pie Chart - a piechart with legend example + + + + + + + + \ No newline at end of file diff --git a/test/g.raphael/examples/raphael-min.js b/test/g.raphael/examples/raphael-min.js new file mode 100644 index 0000000..33e620e --- /dev/null +++ b/test/g.raphael/examples/raphael-min.js @@ -0,0 +1,116 @@ +/* + * Raphael 1.4.7 - JavaScript Vector Library + * + * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com) + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + */ +Raphael=function(){function l(){if(l.is(arguments[0],U)){for(var a=arguments[0],b=Ca[K](l,a.splice(0,3+l.is(a[0],P))),c=b.set(),d=0,f=a[o];d';da=da.firstChild;da.style.behavior="url(#default#VML)";if(!(da&&typeof da.adj=="object"))return l.type=null;da=null}l.svg=!(l.vml=l.type=="VML");H[p]=l[p];l._id=0;l._oid=0;l.fn={};l.is=function(a,b){b=fa.call(b);return b=="object"&&a===Object(a)||b=="undefined"&&typeof a==b||b=="null"&&a==null||b=="array"&&Array.isArray&&Array.isArray(a)||fa.call(tb.call(a).slice(8,-1))==b};l.setWindow=function(a){aa= +a;C=aa.document};function ua(a){if(l.vml){var b=/^\s+|\s+$/g;ua=Z(function(d){var f;d=D(d)[I](b,A);try{var e=new aa.ActiveXObject("htmlfile");e.write("");e.close();f=e.body}catch(g){f=aa.createPopup().document.body}e=f.createTextRange();try{f.style.color=d;var h=e.queryCommandValue("ForeColor");h=(h&255)<<16|h&65280|(h&16711680)>>>16;return"#"+("000000"+h[O](16)).slice(-6)}catch(i){return"none"}})}else{var c=C.createElement("i");c.title="Rapha\u00ebl Colour Picker";c.style.display="none";C.body[x](c); +ua=Z(function(d){c.style.color=d;return C.defaultView.getComputedStyle(c,A).getPropertyValue("color")})}return ua(a)}function Ta(){return"hsb("+[this.h,this.s,this.b]+")"}function vb(){return"hsl("+[this.h,this.s,this.l]+")"}function wb(){return this.hex}l.hsb2rgb=function(a,b,c){if(l.is(a,"object")&&"h"in a&&"s"in a&&"b"in a){c=a.b;b=a.s;a=a.h}return l.hsl2rgb(a,b,c/2)};l.hsl2rgb=function(a,b,c){if(l.is(a,"object")&&"h"in a&&"s"in a&&"l"in a){c=a.l;b=a.s;a=a.h}if(a>1||b>1||c>1){a/=255;b/=255;c/= +255}var d={},f=["r","g","b"],e;if(b){b=c<0.5?c*(1+b):c+b-c*b;c=2*c-b;for(var g=0,h=f.length;g1&&e--;d[f[g]]=e*6<1?c+(b-c)*6*e:e*2<1?b:e*3<2?c+(b-c)*(2/3-e)*6:c}}else d={r:c,g:c,b:c};d.r*=255;d.g*=255;d.b*=255;a=(~~d.r)[O](16);f=(~~d.g)[O](16);b=(~~d.b)[O](16);a=a[I](ja,"0");f=f[I](ja,"0");b=b[I](ja,"0");d.hex="#"+a+f+b;d.toString=wb;return d};l.rgb2hsb=function(a,b,c){if(b==null&&l.is(a,"object")&&"r"in a&&"g"in a&&"b"in a){c=a.b;b=a.g;a=a.r}if(b==null&&l.is(a,ga)){var d= +l.getRGB(a);a=d.r;b=d.g;c=d.b}if(a>1||b>1||c>1){a/=255;b/=255;c/=255}var f=Y(a,b,c),e=ba(a,b,c);d=f;if(e==f)return{h:0,s:0,b:f,toString:Ta};else{var g=f-e;e=g/f;a=a==f?(b-c)/g:b==f?2+(c-a)/g:4+(a-b)/g;a/=6;a<0&&a++;a>1&&a--}return{h:a,s:e,b:d,toString:Ta}};l.rgb2hsl=function(a,b,c){if(b==null&&l.is(a,"object")&&"r"in a&&"g"in a&&"b"in a){c=a.b;b=a.g;a=a.r}if(b==null&&l.is(a,ga)){var d=l.getRGB(a);a=d.r;b=d.g;c=d.b}if(a>1||b>1||c>1){a/=255;b/=255;c/=255}var f=Y(a,b,c),e=ba(a,b,c);d=(f+e)/2;if(e==f)a= +{h:0,s:0,l:d};else{var g=f-e;e=d<0.5?g/(f+e):g/(2-f-e);a=a==f?(b-c)/g:b==f?2+(c-a)/g:4+(a-b)/g;a/=6;a<0&&a++;a>1&&a--;a={h:a,s:e,l:d}}a.toString=vb;return a};var xb=/,?([achlmqrstvxz]),?/gi,ka=/\s*,\s*/,yb={hs:1,rg:1};l._path2string=function(){return this.join(",")[I](xb,"$1")};function Z(a,b,c){function d(){var f=Array[p].slice.call(arguments,0),e=f[R]("\u25ba"),g=d.cache=d.cache||{},h=d.count=d.count||[];if(g[z](e))return c?c(g[e]):g[e];h[o]>=1000&&delete g[h.shift()];h[F](e);g[e]=a[K](b,f);return c? +c(g[e]):g[e]}return d}l.getRGB=Z(function(a){if(!a||(a=D(a)).indexOf("-")+1)return{r:-1,g:-1,b:-1,hex:"none",error:1};if(a=="none")return{r:-1,g:-1,b:-1,hex:"none"};!(yb[z](a.substring(0,2))||a.charAt()=="#")&&(a=ua(a));var b,c,d,f,e;if(a=a.match(ub)){if(a[2]){d=ha(a[2].substring(5),16);c=ha(a[2].substring(3,5),16);b=ha(a[2].substring(1,3),16)}if(a[3]){d=ha((e=a[3].charAt(3))+e,16);c=ha((e=a[3].charAt(2))+e,16);b=ha((e=a[3].charAt(1))+e,16)}if(a[4]){a=a[4][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);f=y(a[3])}if(a[5]){a= +a[5][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;f=y(a[3])}if(a[6]){a=a[6][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360);return l.hsb2rgb(b,c,d)}if(a[7]){a=a[7][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360*2.55);return l.hsb2rgb(b,c,d)}if(a[8]){a=a[8][G](ka);b=y(a[0]);c=y(a[1]);d=y(a[2]);(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360);return l.hsl2rgb(b,c,d)}if(a[9]){a= +a[9][G](ka);b=y(a[0])*2.55;c=y(a[1])*2.55;d=y(a[2])*2.55;(a[0].slice(-3)=="deg"||a[0].slice(-1)=="\u00b0")&&(b/=360*2.55);return l.hsl2rgb(b,c,d)}a={r:b,g:c,b:d};b=(~~b)[O](16);c=(~~c)[O](16);d=(~~d)[O](16);b=b[I](ja,"0");c=c[I](ja,"0");d=d[I](ja,"0");a.hex="#"+b+c+d;isFinite(y(f))&&(a.o=f);return a}return{r:-1,g:-1,b:-1,hex:"none",error:1}},l);l.getColor=function(a){a=this.getColor.start=this.getColor.start||{h:0,s:1,b:a||0.75};var b=this.hsb2rgb(a.h,a.s,a.b);a.h+=0.075;if(a.h>1){a.h=0;a.s-=0.2; +a.s<=0&&(this.getColor.start={h:0,s:1,b:a.b})}return b.hex};l.getColor.reset=function(){delete this.start};var zb=/([achlmqstvz])[\s,]*((-?\d*\.?\d*(?:e[-+]?\d+)?\s*,?\s*)+)/ig,Ab=/(-?\d*\.?\d*(?:e[-+]?\d+)?)\s*,?\s*/ig;l.parsePathString=Z(function(a){if(!a)return null;var b={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0},c=[];if(l.is(a,U)&&l.is(a[0],U))c=va(a);c[o]||D(a)[I](zb,function(d,f,e){var g=[];d=fa.call(f);e[I](Ab,function(h,i){i&&g[F](+i)});if(d=="m"&&g[o]>2){c[F]([f][M](g.splice(0,2)));d="l"; +f=f=="m"?"l":"L"}for(;g[o]>=b[d];){c[F]([f][M](g.splice(0,b[d])));if(!b[d])break}});c[O]=l._path2string;return c});l.findDotsAtSegment=function(a,b,c,d,f,e,g,h,i){var j=1-i,m=E(j,3)*a+E(j,2)*3*i*c+j*3*i*i*f+E(i,3)*g;j=E(j,3)*b+E(j,2)*3*i*d+j*3*i*i*e+E(i,3)*h;var n=a+2*i*(c-a)+i*i*(f-2*c+a),r=b+2*i*(d-b)+i*i*(e-2*d+b),q=c+2*i*(f-c)+i*i*(g-2*f+c),k=d+2*i*(e-d)+i*i*(h-2*e+d);a=(1-i)*a+i*c;b=(1-i)*b+i*d;f=(1-i)*f+i*g;e=(1-i)*e+i*h;h=90-v.atan((n-q)/(r-k))*180/v.PI;(n>q||r1){B=v.sqrt(B);c=B*c;d=B*d}B=c*c;var L=d*d;B=(e==g?-1:1)*v.sqrt(v.abs((B*L-B*w*w-L*k*k)/(B*w*w+L*k*k)));e=B*c*w/d+(a+h)/2;var B=B*-d*k/c+(b+i)/2,w=v.asin(((b-B)/d).toFixed(7));k=v.asin(((i-B)/d).toFixed(7));w=ak)w-=m*2;if(!g&&k>w)k-=m*2}m=k-w;if(v.abs(m)>n){q=k;m=h;L=i;k=w+n*(g&&k>w?1:-1);h=e+c*v.cos(k);i=B+d*v.sin(k);q=Va(h,i,c,d,f,0,g,m, +L,[k,q,e,B])}m=k-w;f=v.cos(w);e=v.sin(w);g=v.cos(k);k=v.sin(k);m=v.tan(m/4);c=4/3*c*m;m=4/3*d*m;d=[a,b];a=[a+c*e,b-m*f];b=[h+c*k,i-m*g];h=[h,i];a[0]=2*d[0]-a[0];a[1]=2*d[1]-a[1];if(j)return[a,b,h][M](q);else{q=[a,b,h][M](q)[R]()[G](",");j=[];h=0;for(i=q[o];h1000000000000&&(n=0.5);v.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[F](n.x);r[F](n.y)}if(i>0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[F](n.x);r[F](n.y)}i=e-2*d+b-(h-2*e+d);j=2*(d-b)-2*(e-d);m=b-d;n=(-j+v.sqrt(j*j-4*i*m))/2/i;i=(-j-v.sqrt(j*j-4*i*m))/2/i;v.abs(n)>1000000000000&&(n=0.5);v.abs(i)>1000000000000&&(i=0.5);if(n>0&&n<1){n=la(a,b,c,d,f,e,g,h,n);q[F](n.x); +r[F](n.y)}if(i>0&&i<1){n=la(a,b,c,d,f,e,g,h,i);q[F](n.x);r[F](n.y)}return{min:{x:ba[K](0,q),y:ba[K](0,r)},max:{x:Y[K](0,q),y:Y[K](0,r)}}}),wa=Z(function(a,b){var c=oa(a),d=b&&oa(b);a={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};b={x:0,y:0,bx:0,by:0,X:0,Y:0,qx:null,qy:null};function f(q,k){var t;if(!q)return["C",k.x,k.y,k.x,k.y,k.x,k.y];!(q[0]in{T:1,Q:1})&&(k.qx=k.qy=null);switch(q[0]){case "M":k.X=q[1];k.Y=q[2];break;case "A":q=["C"][M](Va[K](0,[k.x,k.y][M](q.slice(1))));break;case "S":t=k.x+(k.x- +(k.bx||k.x));k=k.y+(k.y-(k.by||k.y));q=["C",t,k][M](q.slice(1));break;case "T":k.qx=k.x+(k.x-(k.qx||k.x));k.qy=k.y+(k.y-(k.qy||k.y));q=["C"][M](Ua(k.x,k.y,k.qx,k.qy,q[1],q[2]));break;case "Q":k.qx=q[1];k.qy=q[2];q=["C"][M](Ua(k.x,k.y,q[1],q[2],q[3],q[4]));break;case "L":q=["C"][M](ya(k.x,k.y,q[1],q[2]));break;case "H":q=["C"][M](ya(k.x,k.y,q[1],k.y));break;case "V":q=["C"][M](ya(k.x,k.y,k.x,q[1]));break;case "Z":q=["C"][M](ya(k.x,k.y,k.X,k.Y));break}return q}function e(q,k){if(q[k][o]>7){q[k].shift(); +for(var t=q[k];t[o];)q.splice(k++,0,["C"][M](t.splice(0,6)));q.splice(k,1);i=Y(c[o],d&&d[o]||0)}}function g(q,k,t,L,B){if(q&&k&&q[B][0]=="M"&&k[B][0]!="M"){k.splice(B,0,["M",L.x,L.y]);t.bx=0;t.by=0;t.x=q[B][1];t.y=q[B][2];i=Y(c[o],d&&d[o]||0)}}for(var h=0,i=Y(c[o],d&&d[o]||0);h0.5)*2-1;E(f-0.5,2)+E(e-0.5,2)>0.25&&(e=v.sqrt(0.25-E(f-0.5,2))*m+0.5)&&e!=0.5&&(e=e.toFixed(5)-1.0E-5*m)}return A});b=b[G](/\s*\-\s*/); +if(d=="linear"){var h=b.shift();h=-y(h);if(isNaN(h))return null;h=[0,0,v.cos(h*v.PI/180),v.sin(h*v.PI/180)];var i=1/(Y(v.abs(h[2]),v.abs(h[3]))||1);h[2]*=i;h[3]*=i;if(h[2]<0){h[0]=-h[2];h[2]=0}if(h[3]<0){h[1]=-h[3];h[3]=0}}b=Wa(b);if(!b)return null;i=a.getAttribute(ca);(i=i.match(/^url\(#(.*)\)$/))&&c.defs.removeChild(C.getElementById(i[1]));i=u(d+"Gradient");i.id="r"+(l._id++)[O](36);u(i,d=="radial"?{fx:f,fy:e}:{x1:h[0],y1:h[1],x2:h[2],y2:h[3]});c.defs[x](i);c=0;for(h=b[o];c1?m.o/100:m.o});case "stroke":m=l.getRGB(j);d[W](i,m.hex);i=="stroke"&&m[z]("o")&&u(d,{"stroke-opacity":m.o>1?m.o/100:m.o});break;case "gradient":(({circle:1,ellipse:1})[z](a.type)||D(j).charAt()!="r")&&pa(d,j,a.paper);break;case "opacity":case "fill-opacity":if(f.gradient){if(m=C.getElementById(d.getAttribute(ca)[I](/^url\(#|\)$/g,A))){m=m.getElementsByTagName("stop");m[m[o]- +1][W]("stop-opacity",j)}break}default:i=="font-size"&&(j=ha(j,10)+"px");m=i[I](/(\-.)/g,function(k){return sa.call(k.substring(1))});d.style[m]=j;d[W](i,j);break}}Db(a,b);if(h)a.rotate(h.join(N));else y(e)&&a.rotate(e,true)},eb=1.2,Db=function(a,b){if(!(a.type!="text"||!(b[z]("text")||b[z]("font")||b[z]("font-size")||b[z]("x")||b[z]("y")))){var c=a.attrs,d=a.node,f=d.firstChild?ha(C.defaultView.getComputedStyle(d.firstChild,A).getPropertyValue("font-size"),10):10;if(b[z]("text")){for(c.text=b.text;d.firstChild;)d.removeChild(d.firstChild); +b=D(b.text)[G]("\n");for(var e=0,g=b[o];eb.height&&(b.height=e.y+e.height-b.y);e.x+e.width- +b.x>b.width&&(b.width=e.x+e.width-b.x)}}a&&this.hide();return b};s[p].attr=function(a,b){if(this.removed)return this;if(a==null){a={};for(var c in this.attrs)if(this.attrs[z](c))a[c]=this.attrs[c];this._.rt.deg&&(a.rotation=this.rotate());(this._.sx!=1||this._.sy!=1)&&(a.scale=this.scale());a.gradient&&a.fill=="none"&&(a.fill=a.gradient)&&delete a.gradient;return a}if(b==null&&l.is(a,ga)){if(a=="translation")return Aa.call(this);if(a=="rotation")return this.rotate();if(a=="scale")return this.scale(); +if(a==ca&&this.attrs.fill=="none"&&this.attrs.gradient)return this.attrs.gradient;return this.attrs[a]}if(b==null&&l.is(a,U)){b={};c=0;for(var d=a.length;c1&&(a=1);f.opacity=a}b.fill&&(f.on=true);if(f.on==null||b.fill=="none")f.on=false;if(f.on&&b.fill)if(a=b.fill.match(Sa)){f.src=a[1];f.type="tile"}else{f.color=l.getRGB(b.fill).hex;f.src=A;f.type="solid";if(l.getRGB(b.fill).error&&(g.type in{circle:1,ellipse:1}||D(b.fill).charAt()!="r")&&pa(g,b.fill)){d.fill="none";d.gradient=b.fill}}e&&c[x](f);f=c.getElementsByTagName("stroke")&&c.getElementsByTagName("stroke")[0];e=false;!f&&(e=f=S("stroke"));if(b.stroke&&b.stroke!="none"|| +b["stroke-width"]||b["stroke-opacity"]!=null||b["stroke-dasharray"]||b["stroke-miterlimit"]||b["stroke-linejoin"]||b["stroke-linecap"])f.on=true;(b.stroke=="none"||f.on==null||b.stroke==0||b["stroke-width"]==0)&&(f.on=false);a=l.getRGB(b.stroke);f.on&&b.stroke&&(f.color=a.hex);a=((+d["stroke-opacity"]+1||2)-1)*((+d.opacity+1||2)-1)*((+a.o+1||2)-1);h=(y(b["stroke-width"])||1)*0.75;a<0&&(a=0);a>1&&(a=1);b["stroke-width"]==null&&(h=d["stroke-width"]);b["stroke-width"]&&(f.weight=h);h&&h<1&&(a*=h)&&(f.weight= +1);f.opacity=a;b["stroke-linejoin"]&&(f.joinstyle=b["stroke-linejoin"]||"miter");f.miterlimit=b["stroke-miterlimit"]||8;b["stroke-linecap"]&&(f.endcap=b["stroke-linecap"]=="butt"?"flat":b["stroke-linecap"]=="square"?"square":"round");if(b["stroke-dasharray"]){a={"-":"shortdash",".":"shortdot","-.":"shortdashdot","-..":"shortdashdotdot",". ":"dot","- ":"dash","--":"longdash","- .":"dashdot","--.":"longdashdot","--..":"longdashdotdot"};f.dashstyle=a[z](b["stroke-dasharray"])?a[b["stroke-dasharray"]]: +A}e&&c[x](f)}if(g.type=="text"){f=g.paper.span.style;d.font&&(f.font=d.font);d["font-family"]&&(f.fontFamily=d["font-family"]);d["font-size"]&&(f.fontSize=d["font-size"]);d["font-weight"]&&(f.fontWeight=d["font-weight"]);d["font-style"]&&(f.fontStyle=d["font-style"]);g.node.string&&(g.paper.span.innerHTML=D(g.node.string)[I](/"));g.W=d.w=g.paper.span.offsetWidth;g.H=d.h=g.paper.span.offsetHeight;g.X=d.x;g.Y=d.y+Q(g.H/2);switch(d["text-anchor"]){case "start":g.node.style["v-text-align"]= +"left";g.bbx=Q(g.W/2);break;case "end":g.node.style["v-text-align"]="right";g.bbx=-Q(g.W/2);break;default:g.node.style["v-text-align"]="center";break}}};pa=function(a,b){a.attrs=a.attrs||{};var c="linear",d=".5 .5";a.attrs.gradient=b;b=D(b)[I](cb,function(i,j,m){c="radial";if(j&&m){j=y(j);m=y(m);E(j-0.5,2)+E(m-0.5,2)>0.25&&(m=v.sqrt(0.25-E(j-0.5,2))*((m>0.5)*2-1)+0.5);d=j+N+m}return A});b=b[G](/\s*\-\s*/);if(c=="linear"){var f=b.shift();f=-y(f);if(isNaN(f))return null}var e=Wa(b);if(!e)return null; +a=a.shape||a.node;b=a.getElementsByTagName(ca)[0]||S(ca);!b.parentNode&&a.appendChild(b);if(e[o]){b.on=true;b.method="none";b.color=e[0].color;b.color2=e[e[o]-1].color;a=[];for(var g=0,h=e[o];g')}}catch(Pb){S=function(a){return C.createElement("<"+a+' xmlns="urn:schemas-microsoft.com:vml" class="rvml">')}}Ca= +function(){var a=Xa[K](0,arguments),b=a.container,c=a.height,d=a.width,f=a.x;a=a.y;if(!b)throw new Error("VML container not found.");var e=new H,g=e.canvas=C.createElement("div"),h=g.style;f=f||0;a=a||0;d=d||512;c=c||342;d==+d&&(d+="px");c==+c&&(c+="px");e.width=1000;e.height=1000;e.coordsize=na*1000+N+na*1000;e.coordorigin="0 0";e.span=C.createElement("span");e.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";g[x](e.span);h.cssText= +l.format("width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden",d,c);if(b==1){C.body[x](g);h.left=f+"px";h.top=a+"px";h.position="absolute"}else b.firstChild?b.insertBefore(g,b.firstChild):b[x](g);Ia.call(e,e,l.fn);return e};H[p].clear=function(){this.canvas.innerHTML=A;this.span=C.createElement("span");this.span.style.cssText="position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;";this.canvas[x](this.span);this.bottom= +this.top=null};H[p].remove=function(){this.canvas.parentNode.removeChild(this.canvas);for(var a in this)this[a]=bb(a);return true}}H[p].safari=navigator.vendor=="Apple Computer, Inc."&&(navigator.userAgent.match(/Version\/(.*?)\s/)[1]<4||aa.navigator.platform.slice(0,2)=="iP")?function(){var a=this.rect(-99,-99,this.width+99,this.height+99).attr({stroke:"none"});aa.setTimeout(function(){a.remove()})}:function(){};function Ib(){this.returnValue=false}function Jb(){return this.originalEvent.preventDefault()} +function Kb(){this.cancelBubble=true}function Lb(){return this.originalEvent.stopPropagation()}var Mb=function(){if(C.addEventListener)return function(a,b,c,d){var f=Da&&Ea[b]?Ea[b]:b;function e(g){if(Da&&Ea[z](b))for(var h=0,i=g.targetTouches&&g.targetTouches.length;h1&&(a=Array[p].splice.call(arguments,0,arguments[o]));return new X(a)};H[p].setSize=kb;H[p].top=H[p].bottom=null;H[p].raphael=l;function nb(){return this.x+N+this.y}s[p].resetScale=function(){if(this.removed)return this;this._.sx=1;this._.sy=1;this.attrs.scale="1 1"};s[p].scale=function(a,b,c,d){if(this.removed)return this;if(a==null&&b==null)return{x:this._.sx, +y:this._.sy,toString:nb};b=b||a;!+b&&(b=a);var f,e,g=this.attrs;if(a!=0){var h=this.getBBox(),i=h.x+h.width/2,j=h.y+h.height/2;f=a/this._.sx;e=b/this._.sy;c=+c||c==0?c:i;d=+d||d==0?d:j;h=~~(a/v.abs(a));var m=~~(b/v.abs(b)),n=this.node.style,r=c+(i-c)*f;j=d+(j-d)*e;switch(this.type){case "rect":case "image":var q=g.width*h*f,k=g.height*m*e;this.attr({height:k,r:g.r*ba(h*f,m*e),width:q,x:r-q/2,y:j-k/2});break;case "circle":case "ellipse":this.attr({rx:g.rx*h*f,ry:g.ry*m*e,r:g.r*ba(h*f,m*e),cx:r,cy:j}); +break;case "text":this.attr({x:r,y:j});break;case "path":i=Ha(g.path);for(var t=true,L=0,B=i[o];L=i)return r;m=r}});function Ma(a,b){return function(c,d,f){c=wa(c);for(var e,g,h,i,j="",m={},n=0,r=0,q=c.length;rd){if(b&&!m.start){e=ob(e,g,h[1],h[2],h[3],h[4],h[5],h[6],d-n);j+=["C",e.start.x,e.start.y,e.m.x,e.m.y,e.x,e.y];if(f)return j;m.start=j;j=["M",e.x,e.y+"C",e.n.x,e.n.y,e.end.x,e.end.y,h[5],h[6]][R]();n+=i;e=+h[5];g=+h[6];continue}if(!a&&!b){e=ob(e,g,h[1],h[2],h[3],h[4],h[5],h[6], +d-n);return{x:e.x,y:e.y,alpha:e.alpha}}}n+=i;e=+h[5];g=+h[6]}j+=h}m.end=j;e=a?n:b?m:l.findDotsAtSegment(e,g,h[1],h[2],h[3],h[4],h[5],h[6],1);e.alpha&&(e={x:e.x,y:e.y,alpha:e.alpha});return e}}var Nb=Z(function(a,b,c,d,f,e,g,h){for(var i={x:0,y:0},j=0,m=0;m<1.01;m+=0.01){var n=la(a,b,c,d,f,e,g,h,m);m&&(j+=E(E(i.x-n.x,2)+E(i.y-n.y,2),0.5));i=n}return j}),pb=Ma(1),Ba=Ma(),Na=Ma(0,1);s[p].getTotalLength=function(){if(this.type=="path"){if(this.node.getTotalLength)return this.node.getTotalLength();return pb(this.attrs.path)}}; +s[p].getPointAtLength=function(a){if(this.type=="path"){if(this.node.getPointAtLength)return this.node.getPointAtLength(a);return Ba(this.attrs.path,a)}};s[p].getSubpath=function(a,b){if(this.type=="path"){if(v.abs(this.getTotalLength()-b)<1.0E-6)return Na(this.attrs.path,a).end;b=Na(this.attrs.path,b,1);return a?Na(b,a).end:b}};l.easing_formulas={linear:function(a){return a},"<":function(a){return E(a,3)},">":function(a){return E(a-1,3)+1},"<>":function(a){a*=2;if(a<1)return E(a,3)/2;a-=2;return(E(a, +3)+2)/2},backIn:function(a){var b=1.70158;return a*a*((b+1)*a-b)},backOut:function(a){a-=1;var b=1.70158;return a*a*((b+1)*a+b)+1},elastic:function(a){if(a==0||a==1)return a;var b=0.3,c=b/4;return E(2,-10*a)*v.sin((a-c)*2*v.PI/b)+1},bounce:function(a){var b=7.5625,c=2.75;if(a<1/c)a=b*a*a;else if(a<2/c){a-=1.5/c;a=b*a*a+0.75}else if(a<2.5/c){a-=2.25/c;a=b*a*a+0.9375}else{a-=2.625/c;a=b*a*a+0.984375}return a}};var T={length:0};function qb(){var a=+new Date;for(var b in T)if(b!="length"&&T[z](b)){var c= +T[b];if(c.stop||c.el.removed){delete T[b];T[o]--}else{var d=a-c.start,f=c.ms,e=c.easing,g=c.from,h=c.diff,i=c.to,j=c.t,m=c.prev||0,n=c.el,r=c.callback,q={},k;if(db-2*m){s[aa]=E(s[aa],b-2*m);u=b-2*m}if(t[aa]&&t[aa].length>b-2*m){t[aa]=E(t[aa],b-2*m)}}var U=Array.prototype.concat.apply([],t),S=Array.prototype.concat.apply([],s),p=this.g.snapEnds(Math.min.apply(Math,U),Math.max.apply(Math,U),t[0].length-1),z=p.from,k=p.to,J=this.g.snapEnds(Math.min.apply(Math,S),Math.max.apply(Math,S),s[0].length-1),v=J.from,h=J.to,V=(b-m*2)/((k-z)||1),T=(d-m*2)/((h-v)||1);var B=this.set();if(F.axis){var g=(F.axis+"").split(/[,\s]+/);+g[0]&&B.push(this.g.axis(M+m,L+m,b-2*m,z,k,F.axisxstep||Math.floor((b-2*m)/20),2));+g[1]&&B.push(this.g.axis(M+b-m,L+d-m,d-2*m,v,h,F.axisystep||Math.floor((d-2*m)/20),3));+g[2]&&B.push(this.g.axis(M+m,L+d-m,b-2*m,z,k,F.axisxstep||Math.floor((b-2*m)/20),0));+g[3]&&B.push(this.g.axis(M+m,L+d-m,d-2*m,v,h,F.axisystep||Math.floor((d-2*m)/20),1))}var I=this.set(),W=this.set(),n;for(aa=0,H=s.length;aa width - 2 * gutter) { + valuesy[i] = shrink(valuesy[i], width - 2 * gutter); + len = width - 2 * gutter; + } + if (valuesx[i] && valuesx[i].length > width - 2 * gutter) { + valuesx[i] = shrink(valuesx[i], width - 2 * gutter); + } + } + var allx = Array.prototype.concat.apply([], valuesx), + ally = Array.prototype.concat.apply([], valuesy), + xdim = this.g.snapEnds(Math.min.apply(Math, allx), Math.max.apply(Math, allx), valuesx[0].length - 1), + minx = xdim.from, + maxx = xdim.to, + ydim = this.g.snapEnds(Math.min.apply(Math, ally), Math.max.apply(Math, ally), valuesy[0].length - 1), + miny = ydim.from, + maxy = ydim.to, + kx = (width - gutter * 2) / ((maxx - minx) || 1), + ky = (height - gutter * 2) / ((maxy - miny) || 1); + + var axis = this.set(); + if (opts.axis) { + var ax = (opts.axis + "").split(/[,\s]+/); + +ax[0] && axis.push(this.g.axis(x + gutter, y + gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 2)); + +ax[1] && axis.push(this.g.axis(x + width - gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 3)); + +ax[2] && axis.push(this.g.axis(x + gutter, y + height - gutter, width - 2 * gutter, minx, maxx, opts.axisxstep || Math.floor((width - 2 * gutter) / 20), 0)); + +ax[3] && axis.push(this.g.axis(x + gutter, y + height - gutter, height - 2 * gutter, miny, maxy, opts.axisystep || Math.floor((height - 2 * gutter) / 20), 1)); + } + var lines = this.set(), + symbols = this.set(), + line; + for (i = 0, ii = valuesy.length; i < ii; i++) { + if (!opts.nostroke) { + lines.push(line = this.path().attr({ + stroke: colors[i], + "stroke-width": opts.width || 2, + "stroke-linejoin": "round", + "stroke-linecap": "round", + "stroke-dasharray": opts.dash || "" + })); + } + var sym = this.raphael.is(symbol, "array") ? symbol[i] : symbol, + symset = this.set(); + path = []; + for (var j = 0, jj = valuesy[i].length; j < jj; j++) { + var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx, + Y = y + height - gutter - (valuesy[i][j] - miny) * ky; + (Raphael.is(sym, "array") ? sym[j] : sym) && symset.push(this.g[Raphael.fn.g.markers[this.raphael.is(sym, "array") ? sym[j] : sym]](X, Y, (opts.width || 2) * 3).attr({fill: colors[i], stroke: "none"})); + if (opts.smooth) { + if (j && j != jj - 1) { + var X0 = x + gutter + ((valuesx[i] || valuesx[0])[j - 1] - minx) * kx, + Y0 = y + height - gutter - (valuesy[i][j - 1] - miny) * ky, + X2 = x + gutter + ((valuesx[i] || valuesx[0])[j + 1] - minx) * kx, + Y2 = y + height - gutter - (valuesy[i][j + 1] - miny) * ky; + var a = getAnchors(X0, Y0, X, Y, X2, Y2); + path = path.concat([a.x1, a.y1, X, Y, a.x2, a.y2]); + } + if (!j) { + path = ["M", X, Y, "C", X, Y]; + } + } else { + path = path.concat([j ? "L" : "M", X, Y]); + } + } + if (opts.smooth) { + path = path.concat([X, Y, X, Y]); + } + symbols.push(symset); + if (opts.shade) { + shades[i].attr({path: path.concat(["L", X, y + height - gutter, "L", x + gutter + ((valuesx[i] || valuesx[0])[0] - minx) * kx, y + height - gutter, "z"]).join(",")}); + } + !opts.nostroke && line.attr({path: path.join(",")}); + } + function createColumns(f) { + // unite Xs together + var Xs = []; + for (var i = 0, ii = valuesx.length; i < ii; i++) { + Xs = Xs.concat(valuesx[i]); + } + Xs.sort(); + // remove duplicates + var Xs2 = [], + xs = []; + for (i = 0, ii = Xs.length; i < ii; i++) { + Xs[i] != Xs[i - 1] && Xs2.push(Xs[i]) && xs.push(x + gutter + (Xs[i] - minx) * kx); + } + Xs = Xs2; + ii = Xs.length; + var cvrs = f || that.set(); + for (i = 0; i < ii; i++) { + var X = xs[i] - (xs[i] - (xs[i - 1] || x)) / 2, + w = ((xs[i + 1] || x + width) - xs[i]) / 2 + (xs[i] - (xs[i - 1] || x)) / 2, + C; + f ? (C = {}) : cvrs.push(C = that.rect(X - 1, y, Math.max(w + 1, 1), height).attr({stroke: "none", fill: "#000", opacity: 0})); + C.values = []; + C.symbols = that.set(); + C.y = []; + C.x = xs[i]; + C.axis = Xs[i]; + for (var j = 0, jj = valuesy.length; j < jj; j++) { + Xs2 = valuesx[j] || valuesx[0]; + for (var k = 0, kk = Xs2.length; k < kk; k++) { + if (Xs2[k] == Xs[i]) { + C.values.push(valuesy[j][k]); + C.y.push(y + height - gutter - (valuesy[j][k] - miny) * ky); + C.symbols.push(chart.symbols[j][k]); + } + } + } + f && f.call(C); + } + !f && (columns = cvrs); + } + function createDots(f) { + var cvrs = f || that.set(), + C; + for (var i = 0, ii = valuesy.length; i < ii; i++) { + for (var j = 0, jj = valuesy[i].length; j < jj; j++) { + var X = x + gutter + ((valuesx[i] || valuesx[0])[j] - minx) * kx, + nearX = x + gutter + ((valuesx[i] || valuesx[0])[j ? j - 1 : 1] - minx) * kx, + Y = y + height - gutter - (valuesy[i][j] - miny) * ky; + f ? (C = {}) : cvrs.push(C = that.circle(X, Y, Math.abs(nearX - X) / 2).attr({stroke: "none", fill: "#000", opacity: 0})); + C.x = X; + C.y = Y; + C.value = valuesy[i][j]; + C.line = chart.lines[i]; + C.shade = chart.shades[i]; + C.symbol = chart.symbols[i][j]; + C.symbols = chart.symbols[i]; + C.axis = (valuesx[i] || valuesx[0])[j]; + f && f.call(C); + } + } + !f && (dots = cvrs); + } + chart.push(lines, shades, symbols, axis, columns, dots); + chart.lines = lines; + chart.shades = shades; + chart.symbols = symbols; + chart.axis = axis; + chart.hoverColumn = function (fin, fout) { + !columns && createColumns(); + columns.mouseover(fin).mouseout(fout); + return this; + }; + chart.clickColumn = function (f) { + !columns && createColumns(); + columns.click(f); + return this; + }; + chart.hrefColumn = function (cols) { + var hrefs = that.raphael.is(arguments[0], "array") ? arguments[0] : arguments; + if (!(arguments.length - 1) && typeof cols == "object") { + for (var x in cols) { + for (var i = 0, ii = columns.length; i < ii; i++) if (columns[i].axis == x) { + columns[i].attr("href", cols[x]); + } + } + } + !columns && createColumns(); + for (i = 0, ii = hrefs.length; i < ii; i++) { + columns[i] && columns[i].attr("href", hrefs[i]); + } + return this; + }; + chart.hover = function (fin, fout) { + !dots && createDots(); + dots.mouseover(fin).mouseout(fout); + return this; + }; + chart.click = function (f) { + !dots && createDots(); + dots.click(f); + return this; + }; + chart.each = function (f) { + createDots(f); + return this; + }; + chart.eachColumn = function (f) { + createColumns(f); + return this; + }; + return chart; +}; diff --git a/test/g.raphael/g.pie-min.js b/test/g.raphael/g.pie-min.js new file mode 100644 index 0000000..55eafc0 --- /dev/null +++ b/test/g.raphael/g.pie-min.js @@ -0,0 +1 @@ +Raphael.fn.g.piechart=function(e,d,o,b,l){l=l||{};var k=this,m=[],g=this.set(),n=this.set(),j=this.set(),u=[],w=b.length,x=0,A=0,z=0,c=9,y=true;n.covers=g;if(w==1){j.push(this.circle(e,d,o).attr({fill:this.g.colors[0],stroke:l.stroke||"#fff","stroke-width":l.strokewidth==null?1:l.strokewidth}));g.push(this.circle(e,d,o).attr(this.g.shim));A=b[0];b[0]={value:b[0],order:0,valueOf:function(){return this.value;}};j[0].middle={x:e,y:d};j[0].mangle=180;}else{function t(F,E,i,H,D,M){var J=Math.PI/180,B=F+i*Math.cos(-H*J),p=F+i*Math.cos(-D*J),G=F+i/2*Math.cos(-(H+(D-H)/2)*J),L=E+i*Math.sin(-H*J),K=E+i*Math.sin(-D*J),C=E+i/2*Math.sin(-(H+(D-H)/2)*J),I=["M",F,E,"L",B,L,"A",i,i,0,+(Math.abs(D-H)>180),1,p,K,"z"];I.middle={x:G,y:C};return I;}for(var v=0;vc){y=false;b[c].value+=b[v];b[c].others=true;z=b[c].value;}}w=Math.min(c+1,b.length);z&&b.splice(w)&&(b[c].others=true);for(v=0;v");}for(v=0;v 180), 1, x2, y2, "z"]; + res.middle = {x: xm, y: ym}; + return res; + } + for (var i = 0; i < len; i++) { + total += values[i]; + values[i] = {value: values[i], order: i, valueOf: function () { return this.value; }}; + } + values.sort(function (a, b) { + return b.value - a.value; + }); + for (i = 0; i < len; i++) { + if (defcut && values[i] * 360 / total <= 1.5) { + cut = i; + defcut = false; + } + if (i > cut) { + defcut = false; + values[cut].value += values[i]; + values[cut].others = true; + others = values[cut].value; + } + } + len = Math.min(cut + 1, values.length); + others && values.splice(len) && (values[cut].others = true); + for (i = 0; i < len; i++) { + var mangle = angle - 360 * values[i] / total / 2; + if (!i) { + angle = 90 - mangle; + mangle = angle - 360 * values[i] / total / 2; + } + if (opts.init) { + var ipath = sector(cx, cy, 1, angle, angle - 360 * values[i] / total).join(","); + } + var path = sector(cx, cy, r, angle, angle -= 360 * values[i] / total); + var p = this.path(opts.init ? ipath : path).attr({fill: opts.colors && opts.colors[i] || this.g.colors[i] || "#666", stroke: opts.stroke || "#fff", "stroke-width": (opts.strokewidth == null ? 1 : opts.strokewidth), "stroke-linejoin": "round"}); + p.value = values[i]; + p.middle = path.middle; + p.mangle = mangle; + sectors.push(p); + series.push(p); + opts.init && p.animate({path: path.join(",")}, (+opts.init - 1) || 1000, ">"); + } + for (i = 0; i < len; i++) { + p = paper.path(sectors[i].attr("path")).attr(this.g.shim); + opts.href && opts.href[i] && p.attr({href: opts.href[i]}); + p.attr = function () {}; + covers.push(p); + series.push(p); + } + } + + chart.hover = function (fin, fout) { + fout = fout || function () {}; + var that = this; + for (var i = 0; i < len; i++) { + (function (sector, cover, j) { + var o = { + sector: sector, + cover: cover, + cx: cx, + cy: cy, + mx: sector.middle.x, + my: sector.middle.y, + mangle: sector.mangle, + r: r, + value: values[j], + total: total, + label: that.labels && that.labels[j] + }; + cover.mouseover(function () { + fin.call(o); + }).mouseout(function () { + fout.call(o); + }); + })(series[i], covers[i], i); + } + return this; + }; + // x: where label could be put + // y: where label could be put + // value: value to show + // total: total number to count % + chart.each = function (f) { + var that = this; + for (var i = 0; i < len; i++) { + (function (sector, cover, j) { + var o = { + sector: sector, + cover: cover, + cx: cx, + cy: cy, + x: sector.middle.x, + y: sector.middle.y, + mangle: sector.mangle, + r: r, + value: values[j], + total: total, + label: that.labels && that.labels[j] + }; + f.call(o); + })(series[i], covers[i], i); + } + return this; + }; + chart.click = function (f) { + var that = this; + for (var i = 0; i < len; i++) { + (function (sector, cover, j) { + var o = { + sector: sector, + cover: cover, + cx: cx, + cy: cy, + mx: sector.middle.x, + my: sector.middle.y, + mangle: sector.mangle, + r: r, + value: values[j], + total: total, + label: that.labels && that.labels[j] + }; + cover.click(function () { f.call(o); }); + })(series[i], covers[i], i); + } + return this; + }; + chart.inject = function (element) { + element.insertBefore(covers[0]); + }; + var legend = function (labels, otherslabel, mark, dir) { + var x = cx + r + r / 5, + y = cy, + h = y + 10; + labels = labels || []; + dir = (dir && dir.toLowerCase && dir.toLowerCase()) || "east"; + mark = paper.g.markers[mark && mark.toLowerCase()] || "disc"; + chart.labels = paper.set(); + for (var i = 0; i < len; i++) { + var clr = series[i].attr("fill"), + j = values[i].order, + txt; + values[i].others && (labels[j] = otherslabel || "Others"); + labels[j] = paper.g.labelise(labels[j], values[i], total); + chart.labels.push(paper.set()); + chart.labels[i].push(paper.g[mark](x + 5, h, 5).attr({fill: clr, stroke: "none"})); + chart.labels[i].push(txt = paper.text(x + 20, h, labels[j] || values[j]).attr(paper.g.txtattr).attr({fill: opts.legendcolor || "#000", "text-anchor": "start"})); + covers[i].label = chart.labels[i]; + h += txt.getBBox().height * 1.2; + } + var bb = chart.labels.getBBox(), + tr = { + east: [0, -bb.height / 2], + west: [-bb.width - 2 * r - 20, -bb.height / 2], + north: [-r - bb.width / 2, -r - bb.height - 10], + south: [-r - bb.width / 2, r + 10] + }[dir]; + chart.labels.translate.apply(chart.labels, tr); + chart.push(chart.labels); + }; + if (opts.legend) { + legend(opts.legend, opts.legendothers, opts.legendmark, opts.legendpos); + } + chart.push(series, covers); + chart.series = series; + chart.covers = covers; + return chart; +}; diff --git a/test/g.raphael/g.raphael-min.js b/test/g.raphael/g.raphael-min.js new file mode 100644 index 0000000..1dba168 --- /dev/null +++ b/test/g.raphael/g.raphael-min.js @@ -0,0 +1,7 @@ +/* + * g.Raphael 0.4.1 - Charting library, based on Raphaël + * + * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com) + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + */ +(function(){var a=Math.max,c=Math.min;Raphael.fn.g=Raphael.fn.g||{};Raphael.fn.g.markers={disc:"disc",o:"disc",flower:"flower",f:"flower",diamond:"diamond",d:"diamond",square:"square",s:"square",triangle:"triangle",t:"triangle",star:"star","*":"star",cross:"cross",x:"cross",plus:"plus","+":"plus",arrow:"arrow","->":"arrow"};Raphael.fn.g.shim={stroke:"none",fill:"#000","fill-opacity":0};Raphael.fn.g.txtattr={font:"12px Arial, sans-serif"};Raphael.fn.g.colors=[];var e=[0.6,0.2,0.05,0.1333,0.75,0];for(var b=0;b<10;b++){if(b=i*2){this[0].attr({path:["M",f,m+i,"a",i,i,0,1,1,0,-i*2,i,i,0,1,1,0,i*2,"m",0,-i*2-j,"a",i+j,i+j,0,1,0,0,(i+j)*2,"L",f+i+j,m+o.height/2+j,"l",o.width+2*j,0,0,-o.height-2*j,-o.width-2*j,0,"L",f,m-i-j].join(",")});}else{var n=Math.sqrt(Math.pow(i+j,2)-Math.pow(o.height/2+j,2));this[0].attr({path:["M",f,m+i,"c",-h,0,-i,h-i,-i,-i,0,-h,i-h,-i,i,-i,h,0,i,i-h,i,i,0,h,h-i,i,-i,i,"M",f+n,m-o.height/2-j,"a",i+j,i+j,0,1,0,0,o.height+2*j,"l",i+j-n+o.width+2*j,0,0,-o.height-2*j,"L",f+n,m-o.height/2-j].join(",")});}this[1].attr({x:f+i+j+o.width/2,y:m});k=(360-k)%360;this.rotate(k,f,m);k>90&&k<270&&this[1].attr({x:f-i-j-o.width/2,y:m,rotation:[180+k,f,m]});return this;};g.update();return g;};Raphael.fn.g.popupit=function(l,k,m,g,t){g=g==null?2:g;t=t||5;l=Math.round(l);k=Math.round(k);var j=m.getBBox(),n=Math.round(j.width/2),i=Math.round(j.height/2),s=[0,n+t*2,0,-n-t*2],o=[-i*2-t*3,-i-t,0,-i-t],f=["M",l-s[g],k-o[g],"l",-t,(g==2)*-t,-a(n-t,0),0,"a",t,t,0,0,1,-t,-t,"l",0,-a(i-t,0),(g==3)*-t,-t,(g==3)*t,-t,0,-a(i-t,0),"a",t,t,0,0,1,t,-t,"l",a(n-t,0),0,t,!g*-t,t,!g*t,a(n-t,0),0,"a",t,t,0,0,1,t,t,"l",0,a(i-t,0),(g==1)*t,t,(g==1)*-t,t,0,a(i-t,0),"a",t,t,0,0,1,-t,t,"l",-a(n-t,0),0,"z"].join(","),q=[{x:l,y:k+t*2+i},{x:l-t*2-n,y:k},{x:l,y:k-t*2-i},{x:l+t*2+n,y:k}][g];m.translate(q.x-n-j.x,q.y-i-j.y);return this.path(f).attr({fill:"#000",stroke:"none"}).insertBefore(m.node?m:m[0]);};Raphael.fn.g.popup=function(f,l,k,g,i){g=g==null?2:g>3?3:g;i=i||5;k=k||"$9.99";var h=this.set(),j=3;h.push(this.path().attr({fill:"#000",stroke:"#000"}));h.push(this.text(f,l,k).attr(this.g.txtattr).attr({fill:"#fff","font-family":"Helvetica, Arial"}));h.update=function(o,n,q){o=o||f;n=n||l;var t=this[1].getBBox(),u=t.width/2,s=t.height/2,y=[0,u+i*2,0,-u-i*2],v=[-s*2-i*3,-s-i,0,-s-i],m=["M",o-y[g],n-v[g],"l",-i,(g==2)*-i,-a(u-i,0),0,"a",i,i,0,0,1,-i,-i,"l",0,-a(s-i,0),(g==3)*-i,-i,(g==3)*i,-i,0,-a(s-i,0),"a",i,i,0,0,1,i,-i,"l",a(u-i,0),0,i,!g*-i,i,!g*i,a(u-i,0),0,"a",i,i,0,0,1,i,i,"l",0,a(s-i,0),(g==1)*i,i,(g==1)*-i,i,0,a(s-i,0),"a",i,i,0,0,1,-i,i,"l",-a(u-i,0),0,"z"].join(","),x=[{x:o,y:n+i*2+s},{x:o-i*2-u,y:n},{x:o,y:n-i*2-s},{x:o+i*2+u,y:n}][g];x.path=m;if(q){this.animate(x,500,">");}else{this.attr(x);}return this;};return h.update(f,l);};Raphael.fn.g.flag=function(f,k,j,i){i=i||0;j=j||"$9.99";var g=this.set(),h=3;g.push(this.path().attr({fill:"#000",stroke:"#000"}));g.push(this.text(f,k,j).attr(this.g.txtattr).attr({fill:"#fff","font-family":"Helvetica, Arial"}));g.update=function(l,o){this.rotate(0,l,o);var n=this[1].getBBox(),m=n.height/2;this[0].attr({path:["M",l,o,"l",m+h,-m-h,n.width+2*h,0,0,n.height+2*h,-n.width-2*h,0,"z"].join(",")});this[1].attr({x:l+m+h+n.width/2,y:o});i=360-i;this.rotate(i,l,o);i>90&&i<270&&this[1].attr({x:l-r-h-n.width/2,y:o,rotation:[180+i,l,o]});return this;};return g.update(f,k);};Raphael.fn.g.label=function(f,i,h){var g=this.set();g.push(this.rect(f,i,10,10).attr({stroke:"none",fill:"#000"}));g.push(this.text(f,i,h).attr(this.g.txtattr).attr({fill:"#fff"}));g.update=function(){var k=this[1].getBBox(),j=c(k.width+10,k.height+10)/2;this[0].attr({x:k.x-j/2,y:k.y-j/2,width:k.width+j,height:k.height+j,r:j});};g.update();return g;};Raphael.fn.g.labelit=function(h){var g=h.getBBox(),f=c(20,g.width+10,g.height+10)/2;return this.rect(g.x-f/2,g.y-f/2,g.width+f,g.height+f,f).attr({stroke:"none",fill:"#000"}).insertBefore(h.node?h:h[0]);};Raphael.fn.g.drop=function(f,k,j,h,i){h=h||30;i=i||0;var g=this.set();g.push(this.path(["M",f,k,"l",h,0,"A",h*0.4,h*0.4,0,1,0,f+h*0.7,k-h*0.7,"z"]).attr({fill:"#000",stroke:"none",rotation:[22.5-i,f,k]}));i=(i+90)*Math.PI/180;g.push(this.text(f+h*Math.sin(i),k+h*Math.cos(i),j).attr(this.g.txtattr).attr({"font-size":h*12/30,fill:"#fff"}));g.drop=g[0];g.text=g[1];return g;};Raphael.fn.g.blob=function(g,m,l,k,i){k=(+k+1?k:45)+90;i=i||12;var f=Math.PI/180,j=i*12/12;var h=this.set();h.push(this.path().attr({fill:"#000",stroke:"none"}));h.push(this.text(g+i*Math.sin((k)*f),m+i*Math.cos((k)*f)-j/2,l).attr(this.g.txtattr).attr({"font-size":j,fill:"#fff"}));h.update=function(t,s,y){t=t||g;s=s||m;var A=this[1].getBBox(),D=a(A.width+j,i*25/12),z=a(A.height+j,i*25/12),o=t+i*Math.sin((k-22.5)*f),B=s+i*Math.cos((k-22.5)*f),q=t+i*Math.sin((k+22.5)*f),C=s+i*Math.cos((k+22.5)*f),F=(q-o)/2,E=(C-B)/2,p=D/2,n=z/2,x=-Math.sqrt(Math.abs(p*p*n*n-p*p*E*E-n*n*F*F)/(p*p*E*E+n*n*F*F)),v=x*p*E/n+(q+o)/2,u=x*-n*F/p+(C+B)/2;if(y){this.animate({x:v,y:u,path:["M",g,m,"L",q,C,"A",p,n,0,1,1,o,B,"z"].join(",")},500,">");}else{this.attr({x:v,y:u,path:["M",g,m,"L",q,C,"A",p,n,0,1,1,o,B,"z"].join(",")});}return this;};h.update(g,m);return h;};Raphael.fn.g.colorValue=function(i,h,g,f){return"hsb("+[c((1-i/h)*0.4,1),g||0.75,f||0.75]+")";};Raphael.fn.g.snapEnds=function(n,o,m){var k=n,p=o;if(k==p){return{from:k,to:p,power:0};}function q(f){return Math.abs(f-0.5)<0.25?~~(f)+0.5:Math.round(f);}var l=(p-k)/m,g=~~(l),j=g,h=0;if(g){while(j){h--;j=~~(l*Math.pow(10,h))/Math.pow(10,h);}h++;}else{while(!g){h=h||1;g=~~(l*Math.pow(10,h))/Math.pow(10,h);h++;}h&&h--;}p=q(o*Math.pow(10,h))/Math.pow(10,h);if(p0?0:0.5))*Math.pow(10,h))/Math.pow(10,h);return{from:k,to:p,power:h};};Raphael.fn.g.axis=function(v,u,o,G,l,J,m,L,n,g){g=g==null?2:g;n=n||"t";J=J||10;var F=n=="|"||n==" "?["M",v+0.5,u,"l",0,0.001]:m==1||m==3?["M",v+0.5,u,"l",0,-o]:["M",v,u+0.5,"l",o,0],z=this.g.snapEnds(G,l,J),K=z.from,B=z.to,I=z.power,H=0,C=this.set();d=(B-K)/J;var s=K,q=I>0?I:0;w=o/J;if(+m==1||+m==3){var h=u,A=(m-1?1:-1)*(g+3+!!(m-1));while(h>=u-o){n!="-"&&n!=" "&&(F=F.concat(["M",v-(n=="+"||n=="|"?g:!(m-1)*g*2),h+0.5,"l",g*2+1,0]));C.push(this.text(v+A,h,(L&&L[H++])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr).attr({"text-anchor":m-1?"start":"end"}));s+=d;h-=w;}if(Math.round(h+w-(u-o))){n!="-"&&n!=" "&&(F=F.concat(["M",v-(n=="+"||n=="|"?g:!(m-1)*g*2),u-o+0.5,"l",g*2+1,0]));C.push(this.text(v+A,u-o,(L&&L[H])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr).attr({"text-anchor":m-1?"start":"end"}));}}else{s=K;q=(I>0)*I;A=(m?-1:1)*(g+9+!m);var k=v,w=o/J,D=0,E=0;while(k<=v+o){n!="-"&&n!=" "&&(F=F.concat(["M",k+0.5,u-(n=="+"?g:!!m*g*2),"l",0,g*2+1]));C.push(D=this.text(k,u+A,(L&&L[H++])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr));var p=D.getBBox();if(E>=p.x-5){C.pop(C.length-1).remove();}else{E=p.x+p.width;}s+=d;k+=w;}if(Math.round(k-w-v-o)){n!="-"&&n!=" "&&(F=F.concat(["M",v+o+0.5,u-(n=="+"?g:!!m*g*2),"l",0,g*2+1]));C.push(this.text(v+o,u+A,(L&&L[H])||(Math.round(s)==s?s:+s.toFixed(q))).attr(this.g.txtattr));}}var M=this.path(F);M.text=C;M.all=this.set([M,C]);M.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this);};return M;};Raphael.el.lighter=function(g){g=g||2;var f=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[f[0],f[1]];f[0]=Raphael.rgb2hsb(Raphael.getRGB(f[0]).hex);f[1]=Raphael.rgb2hsb(Raphael.getRGB(f[1]).hex);f[0].b=c(f[0].b*g,1);f[0].s=f[0].s/g;f[1].b=c(f[1].b*g,1);f[1].s=f[1].s/g;this.attr({fill:"hsb("+[f[0].h,f[0].s,f[0].b]+")",stroke:"hsb("+[f[1].h,f[1].s,f[1].b]+")"});};Raphael.el.darker=function(g){g=g||2;var f=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[f[0],f[1]];f[0]=Raphael.rgb2hsb(Raphael.getRGB(f[0]).hex);f[1]=Raphael.rgb2hsb(Raphael.getRGB(f[1]).hex);f[0].s=c(f[0].s*g,1);f[0].b=f[0].b/g;f[1].s=c(f[1].s*g,1);f[1].b=f[1].b/g;this.attr({fill:"hsb("+[f[0].h,f[0].s,f[0].b]+")",stroke:"hsb("+[f[1].h,f[1].s,f[1].b]+")"});};Raphael.el.original=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs;}};})(); \ No newline at end of file diff --git a/test/g.raphael/g.raphael.js b/test/g.raphael/g.raphael.js new file mode 100644 index 0000000..e9c74cd --- /dev/null +++ b/test/g.raphael/g.raphael.js @@ -0,0 +1,475 @@ +/*! + * g.Raphael 0.4.1 - Charting library, based on Raphaël + * + * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com) + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + */ + + +(function () { + var mmax = Math.max, + mmin = Math.min; + Raphael.fn.g = Raphael.fn.g || {}; + Raphael.fn.g.markers = { + disc: "disc", + o: "disc", + flower: "flower", + f: "flower", + diamond: "diamond", + d: "diamond", + square: "square", + s: "square", + triangle: "triangle", + t: "triangle", + star: "star", + "*": "star", + cross: "cross", + x: "cross", + plus: "plus", + "+": "plus", + arrow: "arrow", + "->": "arrow" + }; + Raphael.fn.g.shim = {stroke: "none", fill: "#000", "fill-opacity": 0}; + Raphael.fn.g.txtattr = {font: "12px Arial, sans-serif"}; + Raphael.fn.g.colors = []; + var hues = [.6, .2, .05, .1333, .75, 0]; + for (var i = 0; i < 10; i++) { + if (i < hues.length) { + Raphael.fn.g.colors.push("hsb(" + hues[i] + ", .75, .75)"); + } else { + Raphael.fn.g.colors.push("hsb(" + hues[i - hues.length] + ", 1, .5)"); + } + } + Raphael.fn.g.text = function (x, y, text) { + return this.text(x, y, text).attr(this.g.txtattr); + }; + Raphael.fn.g.labelise = function (label, val, total) { + if (label) { + return (label + "").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g, function (all, value, percent) { + if (value) { + return (+val).toFixed(value.replace(/^#+\.?/g, "").length); + } + if (percent) { + return (val * 100 / total).toFixed(percent.replace(/^%+\.?/g, "").length) + "%"; + } + }); + } else { + return (+val).toFixed(0); + } + }; + + Raphael.fn.g.finger = function (x, y, width, height, dir, ending, isPath) { + // dir 0 for horisontal and 1 for vertical + if ((dir && !height) || (!dir && !width)) { + return isPath ? "" : this.path(); + } + ending = {square: "square", sharp: "sharp", soft: "soft"}[ending] || "round"; + var path; + height = Math.round(height); + width = Math.round(width); + x = Math.round(x); + y = Math.round(y); + switch (ending) { + case "round": + if (!dir) { + var r = ~~(height / 2); + if (width < r) { + r = width; + path = ["M", x + .5, y + .5 - ~~(height / 2), "l", 0, 0, "a", r, ~~(height / 2), 0, 0, 1, 0, height, "l", 0, 0, "z"]; + } else { + path = ["M", x + .5, y + .5 - r, "l", width - r, 0, "a", r, r, 0, 1, 1, 0, height, "l", r - width, 0, "z"]; + } + } else { + r = ~~(width / 2); + if (height < r) { + r = height; + path = ["M", x - ~~(width / 2), y, "l", 0, 0, "a", ~~(width / 2), r, 0, 0, 1, width, 0, "l", 0, 0, "z"]; + } else { + path = ["M", x - r, y, "l", 0, r - height, "a", r, r, 0, 1, 1, width, 0, "l", 0, height - r, "z"]; + } + } + break; + case "sharp": + if (!dir) { + var half = ~~(height / 2); + path = ["M", x, y + half, "l", 0, -height, mmax(width - half, 0), 0, mmin(half, width), half, -mmin(half, width), half + (half * 2 < height), "z"]; + } else { + half = ~~(width / 2); + path = ["M", x + half, y, "l", -width, 0, 0, -mmax(height - half, 0), half, -mmin(half, height), half, mmin(half, height), half, "z"]; + } + break; + case "square": + if (!dir) { + path = ["M", x, y + ~~(height / 2), "l", 0, -height, width, 0, 0, height, "z"]; + } else { + path = ["M", x + ~~(width / 2), y, "l", 1 - width, 0, 0, -height, width - 1, 0, "z"]; + } + break; + case "soft": + if (!dir) { + r = mmin(width, Math.round(height / 5)); + path = ["M", x + .5, y + .5 - ~~(height / 2), "l", width - r, 0, "a", r, r, 0, 0, 1, r, r, "l", 0, height - r * 2, "a", r, r, 0, 0, 1, -r, r, "l", r - width, 0, "z"]; + } else { + r = mmin(Math.round(width / 5), height); + path = ["M", x - ~~(width / 2), y, "l", 0, r - height, "a", r, r, 0, 0, 1, r, -r, "l", width - 2 * r, 0, "a", r, r, 0, 0, 1, r, r, "l", 0, height - r, "z"]; + } + } + if (isPath) { + return path.join(","); + } else { + return this.path(path); + } + }; + + // Symbols + Raphael.fn.g.disc = function (cx, cy, r) { + return this.circle(cx, cy, r); + }; + Raphael.fn.g.line = function (cx, cy, r) { + return this.rect(cx - r, cy - r / 5, 2 * r, 2 * r / 5); + }; + Raphael.fn.g.square = function (cx, cy, r) { + r = r * .7; + return this.rect(cx - r, cy - r, 2 * r, 2 * r); + }; + Raphael.fn.g.triangle = function (cx, cy, r) { + r *= 1.75; + return this.path("M".concat(cx, ",", cy, "m0-", r * .58, "l", r * .5, ",", r * .87, "-", r, ",0z")); + }; + Raphael.fn.g.diamond = function (cx, cy, r) { + return this.path(["M", cx, cy - r, "l", r, r, -r, r, -r, -r, r, -r, "z"]); + }; + Raphael.fn.g.flower = function (cx, cy, r, n) { + r = r * 1.25; + var rout = r, + rin = rout * .5; + n = +n < 3 || !n ? 5 : n; + var points = ["M", cx, cy + rin, "Q"], + R; + for (var i = 1; i < n * 2 + 1; i++) { + R = i % 2 ? rout : rin; + points = points.concat([+(cx + R * Math.sin(i * Math.PI / n)).toFixed(3), +(cy + R * Math.cos(i * Math.PI / n)).toFixed(3)]); + } + points.push("z"); + return this.path(points.join(",")); + }; + Raphael.fn.g.star = function (cx, cy, r, r2, rays) { + r2 = r2 || r * .382; + rays = rays || 5; + var points = ["M", cx, cy + r2, "L"], + R; + for (var i = 1; i < rays * 2; i++) { + R = i % 2 ? r : r2; + points = points.concat([(cx + R * Math.sin(i * Math.PI / rays)), (cy + R * Math.cos(i * Math.PI / rays))]); + } + points.push("z"); + return this.path(points.join(",")); + }; + Raphael.fn.g.cross = function (cx, cy, r) { + r = r / 2.5; + return this.path("M".concat(cx - r, ",", cy, "l", [-r, -r, r, -r, r, r, r, -r, r, r, -r, r, r, r, -r, r, -r, -r, -r, r, -r, -r, "z"])); + }; + Raphael.fn.g.plus = function (cx, cy, r) { + r = r / 2; + return this.path("M".concat(cx - r / 2, ",", cy - r / 2, "l", [0, -r, r, 0, 0, r, r, 0, 0, r, -r, 0, 0, r, -r, 0, 0, -r, -r, 0, 0, -r, "z"])); + }; + Raphael.fn.g.arrow = function (cx, cy, r) { + return this.path("M".concat(cx - r * .7, ",", cy - r * .4, "l", [r * .6, 0, 0, -r * .4, r, r * .8, -r, r * .8, 0, -r * .4, -r * .6, 0], "z")); + }; + + // Tooltips + Raphael.fn.g.tag = function (x, y, text, angle, r) { + angle = angle || 0; + r = r == null ? 5 : r; + text = text == null ? "$9.99" : text; + var R = .5522 * r, + res = this.set(), + d = 3; + res.push(this.path().attr({fill: "#000", stroke: "#000"})); + res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"})); + res.update = function () { + this.rotate(0, x, y); + var bb = this[1].getBBox(); + if (bb.height >= r * 2) { + this[0].attr({path: ["M", x, y + r, "a", r, r, 0, 1, 1, 0, -r * 2, r, r, 0, 1, 1, 0, r * 2, "m", 0, -r * 2 -d, "a", r + d, r + d, 0, 1, 0, 0, (r + d) * 2, "L", x + r + d, y + bb.height / 2 + d, "l", bb.width + 2 * d, 0, 0, -bb.height - 2 * d, -bb.width - 2 * d, 0, "L", x, y - r - d].join(",")}); + } else { + var dx = Math.sqrt(Math.pow(r + d, 2) - Math.pow(bb.height / 2 + d, 2)); + this[0].attr({path: ["M", x, y + r, "c", -R, 0, -r, R - r, -r, -r, 0, -R, r - R, -r, r, -r, R, 0, r, r - R, r, r, 0, R, R - r, r, -r, r, "M", x + dx, y - bb.height / 2 - d, "a", r + d, r + d, 0, 1, 0, 0, bb.height + 2 * d, "l", r + d - dx + bb.width + 2 * d, 0, 0, -bb.height - 2 * d, "L", x + dx, y - bb.height / 2 - d].join(",")}); + } + this[1].attr({x: x + r + d + bb.width / 2, y: y}); + angle = (360 - angle) % 360; + this.rotate(angle, x, y); + angle > 90 && angle < 270 && this[1].attr({x: x - r - d - bb.width / 2, y: y, rotation: [180 + angle, x, y]}); + return this; + }; + res.update(); + return res; + }; + Raphael.fn.g.popupit = function (x, y, set, dir, size) { + dir = dir == null ? 2 : dir; + size = size || 5; + x = Math.round(x); + y = Math.round(y); + var bb = set.getBBox(), + w = Math.round(bb.width / 2), + h = Math.round(bb.height / 2), + dx = [0, w + size * 2, 0, -w - size * 2], + dy = [-h * 2 - size * 3, -h - size, 0, -h - size], + p = ["M", x - dx[dir], y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size, + "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, + "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, size, size, + "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, + "l", -mmax(w - size, 0), 0, "z"].join(","), + xy = [{x: x, y: y + size * 2 + h}, {x: x - size * 2 - w, y: y}, {x: x, y: y - size * 2 - h}, {x: x + size * 2 + w, y: y}][dir]; + set.translate(xy.x - w - bb.x, xy.y - h - bb.y); + return this.path(p).attr({fill: "#000", stroke: "none"}).insertBefore(set.node ? set : set[0]); + }; + Raphael.fn.g.popup = function (x, y, text, dir, size) { + dir = dir == null ? 2 : dir > 3 ? 3 : dir; + size = size || 5; + text = text || "$9.99"; + var res = this.set(), + d = 3; + res.push(this.path().attr({fill: "#000", stroke: "#000"})); + res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"})); + res.update = function (X, Y, withAnimation) { + X = X || x; + Y = Y || y; + var bb = this[1].getBBox(), + w = bb.width / 2, + h = bb.height / 2, + dx = [0, w + size * 2, 0, -w - size * 2], + dy = [-h * 2 - size * 3, -h - size, 0, -h - size], + p = ["M", X - dx[dir], Y - dy[dir], "l", -size, (dir == 2) * -size, -mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, -size, -size, + "l", 0, -mmax(h - size, 0), (dir == 3) * -size, -size, (dir == 3) * size, -size, 0, -mmax(h - size, 0), "a", size, size, 0, 0, 1, size, -size, + "l", mmax(w - size, 0), 0, size, !dir * -size, size, !dir * size, mmax(w - size, 0), 0, "a", size, size, 0, 0, 1, size, size, + "l", 0, mmax(h - size, 0), (dir == 1) * size, size, (dir == 1) * -size, size, 0, mmax(h - size, 0), "a", size, size, 0, 0, 1, -size, size, + "l", -mmax(w - size, 0), 0, "z"].join(","), + xy = [{x: X, y: Y + size * 2 + h}, {x: X - size * 2 - w, y: Y}, {x: X, y: Y - size * 2 - h}, {x: X + size * 2 + w, y: Y}][dir]; + xy.path = p; + if (withAnimation) { + this.animate(xy, 500, ">"); + } else { + this.attr(xy); + } + return this; + }; + return res.update(x, y); + }; + Raphael.fn.g.flag = function (x, y, text, angle) { + angle = angle || 0; + text = text || "$9.99"; + var res = this.set(), + d = 3; + res.push(this.path().attr({fill: "#000", stroke: "#000"})); + res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff", "font-family": "Helvetica, Arial"})); + res.update = function (x, y) { + this.rotate(0, x, y); + var bb = this[1].getBBox(), + h = bb.height / 2; + this[0].attr({path: ["M", x, y, "l", h + d, -h - d, bb.width + 2 * d, 0, 0, bb.height + 2 * d, -bb.width - 2 * d, 0, "z"].join(",")}); + this[1].attr({x: x + h + d + bb.width / 2, y: y}); + angle = 360 - angle; + this.rotate(angle, x, y); + angle > 90 && angle < 270 && this[1].attr({x: x - r - d - bb.width / 2, y: y, rotation: [180 + angle, x, y]}); + return this; + }; + return res.update(x, y); + }; + Raphael.fn.g.label = function (x, y, text) { + var res = this.set(); + res.push(this.rect(x, y, 10, 10).attr({stroke: "none", fill: "#000"})); + res.push(this.text(x, y, text).attr(this.g.txtattr).attr({fill: "#fff"})); + res.update = function () { + var bb = this[1].getBBox(), + r = mmin(bb.width + 10, bb.height + 10) / 2; + this[0].attr({x: bb.x - r / 2, y: bb.y - r / 2, width: bb.width + r, height: bb.height + r, r: r}); + }; + res.update(); + return res; + }; + Raphael.fn.g.labelit = function (set) { + var bb = set.getBBox(), + r = mmin(20, bb.width + 10, bb.height + 10) / 2; + return this.rect(bb.x - r / 2, bb.y - r / 2, bb.width + r, bb.height + r, r).attr({stroke: "none", fill: "#000"}).insertBefore(set.node ? set : set[0]); + }; + Raphael.fn.g.drop = function (x, y, text, size, angle) { + size = size || 30; + angle = angle || 0; + var res = this.set(); + res.push(this.path(["M", x, y, "l", size, 0, "A", size * .4, size * .4, 0, 1, 0, x + size * .7, y - size * .7, "z"]).attr({fill: "#000", stroke: "none", rotation: [22.5 - angle, x, y]})); + angle = (angle + 90) * Math.PI / 180; + res.push(this.text(x + size * Math.sin(angle), y + size * Math.cos(angle), text).attr(this.g.txtattr).attr({"font-size": size * 12 / 30, fill: "#fff"})); + res.drop = res[0]; + res.text = res[1]; + return res; + }; + Raphael.fn.g.blob = function (x, y, text, angle, size) { + angle = (+angle + 1 ? angle : 45) + 90; + size = size || 12; + var rad = Math.PI / 180, + fontSize = size * 12 / 12; + var res = this.set(); + res.push(this.path().attr({fill: "#000", stroke: "none"})); + res.push(this.text(x + size * Math.sin((angle) * rad), y + size * Math.cos((angle) * rad) - fontSize / 2, text).attr(this.g.txtattr).attr({"font-size": fontSize, fill: "#fff"})); + res.update = function (X, Y, withAnimation) { + X = X || x; + Y = Y || y; + var bb = this[1].getBBox(), + w = mmax(bb.width + fontSize, size * 25 / 12), + h = mmax(bb.height + fontSize, size * 25 / 12), + x2 = X + size * Math.sin((angle - 22.5) * rad), + y2 = Y + size * Math.cos((angle - 22.5) * rad), + x1 = X + size * Math.sin((angle + 22.5) * rad), + y1 = Y + size * Math.cos((angle + 22.5) * rad), + dx = (x1 - x2) / 2, + dy = (y1 - y2) / 2, + rx = w / 2, + ry = h / 2, + k = -Math.sqrt(Math.abs(rx * rx * ry * ry - rx * rx * dy * dy - ry * ry * dx * dx) / (rx * rx * dy * dy + ry * ry * dx * dx)), + cx = k * rx * dy / ry + (x1 + x2) / 2, + cy = k * -ry * dx / rx + (y1 + y2) / 2; + if (withAnimation) { + this.animate({x: cx, y: cy, path: ["M", x, y, "L", x1, y1, "A", rx, ry, 0, 1, 1, x2, y2, "z"].join(",")}, 500, ">"); + } else { + this.attr({x: cx, y: cy, path: ["M", x, y, "L", x1, y1, "A", rx, ry, 0, 1, 1, x2, y2, "z"].join(",")}); + } + return this; + }; + res.update(x, y); + return res; + }; + + Raphael.fn.g.colorValue = function (value, total, s, b) { + return "hsb(" + [mmin((1 - value / total) * .4, 1), s || .75, b || .75] + ")"; + }; + + Raphael.fn.g.snapEnds = function (from, to, steps) { + var f = from, + t = to; + if (f == t) { + return {from: f, to: t, power: 0}; + } + function round(a) { + return Math.abs(a - .5) < .25 ? ~~(a) + .5 : Math.round(a); + } + var d = (t - f) / steps, + r = ~~(d), + R = r, + i = 0; + if (r) { + while (R) { + i--; + R = ~~(d * Math.pow(10, i)) / Math.pow(10, i); + } + i ++; + } else { + while (!r) { + i = i || 1; + r = ~~(d * Math.pow(10, i)) / Math.pow(10, i); + i++; + } + i && i--; + } + t = round(to * Math.pow(10, i)) / Math.pow(10, i); + if (t < to) { + t = round((to + .5) * Math.pow(10, i)) / Math.pow(10, i); + } + f = round((from - (i > 0 ? 0 : .5)) * Math.pow(10, i)) / Math.pow(10, i); + return {from: f, to: t, power: i}; + }; + Raphael.fn.g.axis = function (x, y, length, from, to, steps, orientation, labels, type, dashsize) { + dashsize = dashsize == null ? 2 : dashsize; + type = type || "t"; + steps = steps || 10; + var path = type == "|" || type == " " ? ["M", x + .5, y, "l", 0, .001] : orientation == 1 || orientation == 3 ? ["M", x + .5, y, "l", 0, -length] : ["M", x, y + .5, "l", length, 0], + ends = this.g.snapEnds(from, to, steps), + f = ends.from, + t = ends.to, + i = ends.power, + j = 0, + text = this.set(); + d = (t - f) / steps; + var label = f, + rnd = i > 0 ? i : 0; + dx = length / steps; + if (+orientation == 1 || +orientation == 3) { + var Y = y, + addon = (orientation - 1 ? 1 : -1) * (dashsize + 3 + !!(orientation - 1)); + while (Y >= y - length) { + type != "-" && type != " " && (path = path.concat(["M", x - (type == "+" || type == "|" ? dashsize : !(orientation - 1) * dashsize * 2), Y + .5, "l", dashsize * 2 + 1, 0])); + text.push(this.text(x + addon, Y, (labels && labels[j++]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr).attr({"text-anchor": orientation - 1 ? "start" : "end"})); + label += d; + Y -= dx; + } + if (Math.round(Y + dx - (y - length))) { + type != "-" && type != " " && (path = path.concat(["M", x - (type == "+" || type == "|" ? dashsize : !(orientation - 1) * dashsize * 2), y - length + .5, "l", dashsize * 2 + 1, 0])); + text.push(this.text(x + addon, y - length, (labels && labels[j]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr).attr({"text-anchor": orientation - 1 ? "start" : "end"})); + } + } else { + label = f; + rnd = (i > 0) * i; + addon = (orientation ? -1 : 1) * (dashsize + 9 + !orientation); + var X = x, + dx = length / steps, + txt = 0, + prev = 0; + while (X <= x + length) { + type != "-" && type != " " && (path = path.concat(["M", X + .5, y - (type == "+" ? dashsize : !!orientation * dashsize * 2), "l", 0, dashsize * 2 + 1])); + text.push(txt = this.text(X, y + addon, (labels && labels[j++]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr)); + var bb = txt.getBBox(); + if (prev >= bb.x - 5) { + text.pop(text.length - 1).remove(); + } else { + prev = bb.x + bb.width; + } + label += d; + X += dx; + } + if (Math.round(X - dx - x - length)) { + type != "-" && type != " " && (path = path.concat(["M", x + length + .5, y - (type == "+" ? dashsize : !!orientation * dashsize * 2), "l", 0, dashsize * 2 + 1])); + text.push(this.text(x + length, y + addon, (labels && labels[j]) || (Math.round(label) == label ? label : +label.toFixed(rnd))).attr(this.g.txtattr)); + } + } + var res = this.path(path); + res.text = text; + res.all = this.set([res, text]); + res.remove = function () { + this.text.remove(); + this.constructor.prototype.remove.call(this); + }; + return res; + }; + + Raphael.el.lighter = function (times) { + times = times || 2; + var fs = [this.attrs.fill, this.attrs.stroke]; + this.fs = this.fs || [fs[0], fs[1]]; + fs[0] = Raphael.rgb2hsb(Raphael.getRGB(fs[0]).hex); + fs[1] = Raphael.rgb2hsb(Raphael.getRGB(fs[1]).hex); + fs[0].b = mmin(fs[0].b * times, 1); + fs[0].s = fs[0].s / times; + fs[1].b = mmin(fs[1].b * times, 1); + fs[1].s = fs[1].s / times; + this.attr({fill: "hsb(" + [fs[0].h, fs[0].s, fs[0].b] + ")", stroke: "hsb(" + [fs[1].h, fs[1].s, fs[1].b] + ")"}); + }; + Raphael.el.darker = function (times) { + times = times || 2; + var fs = [this.attrs.fill, this.attrs.stroke]; + this.fs = this.fs || [fs[0], fs[1]]; + fs[0] = Raphael.rgb2hsb(Raphael.getRGB(fs[0]).hex); + fs[1] = Raphael.rgb2hsb(Raphael.getRGB(fs[1]).hex); + fs[0].s = mmin(fs[0].s * times, 1); + fs[0].b = fs[0].b / times; + fs[1].s = mmin(fs[1].s * times, 1); + fs[1].b = fs[1].b / times; + this.attr({fill: "hsb(" + [fs[0].h, fs[0].s, fs[0].b] + ")", stroke: "hsb(" + [fs[1].h, fs[1].s, fs[1].b] + ")"}); + }; + Raphael.el.original = function () { + if (this.fs) { + this.attr({fill: this.fs[0], stroke: this.fs[1]}); + delete this.fs; + } + }; +})(); \ No newline at end of file diff --git a/test/g.raphael/test.html b/test/g.raphael/test.html new file mode 100644 index 0000000..01e8d85 --- /dev/null +++ b/test/g.raphael/test.html @@ -0,0 +1,58 @@ + + + + gRaphaël Dynamic Bar Chart + + + + + + + + + + + +
+

+ Demo of gRaphaël JavaScript library. +

+ + diff --git a/test/g.raphael/test2.html b/test/g.raphael/test2.html new file mode 100644 index 0000000..f5ded7b --- /dev/null +++ b/test/g.raphael/test2.html @@ -0,0 +1,55 @@ + + + + gRaphaël Static Line Charts + + + + + + + + + + + +
+

+ Demo of gRaphaël JavaScript library. +

+ + diff --git a/test/index.html b/test/index.html deleted file mode 100644 index fcb95ba..0000000 --- a/test/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - Raphaël · Australia - - - - - - - -
-
-
-
-
-
-
-

Demo of Raphaël—JavaScript Vector Library

- - \ No newline at end of file diff --git a/test/main.js b/test/main.js deleted file mode 100644 index b6fae23..0000000 --- a/test/main.js +++ /dev/null @@ -1,36 +0,0 @@ -window.onload = function () { - var R = Raphael("paper", 300, 300); - var attr = { - fill: "#333", - stroke: "#666", - "stroke-width": 1, - "stroke-linejoin": "round" - }; - var eire = {}; - eire.kerry = R.path("m 106.0225,848.20339 c -0.306,10e-4 -0.53263,0.0705 -0.63191,0.23774 -1.41569,2.38404 -3.0829,3.18648 -5.05527,2.42748 -0.702485,-0.27028 -2.198339,-2.73104 -2.627742,-1.0135 -0.236592,0.94633 -2.869687,3.13447 -3.441093,1.42028 -0.428767,-1.28639 -2.428612,-2.20425 -2.827949,-0.60698 -0.08231,0.32934 -1.569962,4.01148 -1.620429,4.04176 -2.527956,1.51678 -1.566308,2.39064 -2.62774,4.24818 -1.264954,2.21366 -2.786796,2.02621 -5.055271,3.03446 -0.606733,0.26963 -1.2895,0.40863 -1.820654,0.80704 -0.7627,0.572 -2.602979,-0.51819 -2.8342,0.40668 -0.266543,1.06616 -1.991021,3.20849 -3.84151,1.82065 -1.066988,-0.80024 -5.261736,-2.49776 -5.261736,0 0,1.48329 -0.0499,4.8488 2.027113,4.8488 2.572878,0 1.931134,1.31943 3.434832,1.8207 3.342845,1.11421 -0.141133,3.29369 1.620439,5.05527 0.976629,0.97662 2.364761,3.06445 0.406674,3.84766 -1.125889,0.45042 -4.231627,1.7216 -0.606883,2.62779 1.028513,0.25717 2.55558,-0.60688 4.241918,-0.60688 0.984732,0 4.014706,-0.52725 4.248185,0.40668 0.610116,2.44049 -3.286812,3.28137 -5.055271,3.63509 -1.053388,0.21062 -9.039305,0.52604 -9.103247,0.20646 -0.456296,-2.28158 -3.944878,-1.14299 -4.041709,-1.8207 -0.216065,-1.51247 -2.227322,-2.05879 -2.227322,-3.44104 0,-1.54401 1.553414,-2.90688 -0.400418,-2.62779 -0.969135,0.13845 -4.071791,0.75319 -3.234618,2.42759 0.410058,0.8201 0.807087,1.10385 0.807087,2.0208 0,3.21335 -0.751734,1.41398 -2.8342,1.41398 -2.930971,0 -3.609023,0.39366 -6.062582,1.62049 -1.109757,0.55483 -1.9475,0.14099 -1.320116,-1.11371 0.01977,-0.0396 1.749479,-3.80727 1.420221,-3.74136 -2.975868,0.59508 -2.998006,2.11291 -5.161627,2.83416 -0.741969,0.31798 -1.654751,1.22518 -2.221071,1.41392 -1.448686,0.48291 -3.884495,0.24726 -3.441083,2.02091 0.255426,1.02172 0.606883,1.77265 0.606883,3.03437 0,2.2574 -2.002823,-0.018 -3.234623,1.21386 -1.55342,1.55337 -3.569947,-0.0575 -4.248179,-1.41407 -0.200434,-0.40082 -2.427531,-2.3501 -2.427531,-0.40663 0,1.21347 0,2.42788 0,3.6413 0,0.87902 -2.673293,0.66029 -2.221071,1.41397 1.192518,1.98758 1.413979,1.54121 1.413979,3.44109 0,1.50742 -0.432401,2.81509 0.807092,3.43488 0.269656,0.13474 0.537845,0.2842 0.813353,0.40663 0.606717,0.26968 1.097824,0.2466 1.714282,0 0.917522,-0.36699 1.698356,-1.36147 2.734096,-1.62049 1.268933,-0.31718 1.185296,-1.99093 2.62774,-1.41393 1.579016,0.63161 1.938366,-0.11772 3.034424,-1.21376 1.984809,-1.98477 0.669328,0.33365 2.827948,0.81335 0.606718,0.13484 1.199121,0.40041 1.820639,0.40041 0.938974,0 2.406269,-1.91825 2.634006,-1.0073 0.274291,1.09715 0.919013,2.8279 2.421265,2.828 1.514324,0 2.090039,-1.01361 2.634006,-1.01361 1.443305,0 2.351977,-0.99473 3.841501,-1.2075 1.614528,-0.23065 6.449149,1.12557 7.68301,0.2002 1.679697,-1.25981 2.604741,-0.79868 4.24818,-1.62044 1.614428,-0.80724 2.248594,-1.61413 4.248184,-1.61413 0.393025,0 5.25548,0.12348 5.25548,1.41393 0,2.23778 -0.641519,2.27302 -1.820653,4.04176 -0.80547,1.20811 -2.200965,2.7375 -4.241928,2.22727 -1.383713,-0.34596 -2.498891,-1.48154 -4.24817,-0.60688 -1.466939,0.73351 0.01427,2.94452 -0.813353,3.44114 -1.963722,1.17818 -3.868203,1.73075 -6.062571,2.8279 -1.744459,0.87226 -4.358625,0.51879 -6.875919,1.62049 -1.744214,0.76324 -4.278256,2.47683 -6.068823,2.22101 -0.943794,-0.13484 -2.094019,0.85685 -3.034424,1.01356 -1.714738,0.2858 -0.775814,2.33018 -1.213761,2.42758 -1.795297,0.39887 -4.468504,0.31993 -3.84151,2.8279 0.286444,1.14574 1.824287,3.23097 0.807101,4.24818 -1.909175,1.90919 -0.576741,3.44109 -4.648602,3.44109 -0.981368,0 -4.269131,1.60632 -4.248179,1.61418 0.790009,0.29621 3.84151,1.22673 3.84151,2.62779 0,0.6243 -0.341981,4.48377 0,4.65485 0.548187,0.27404 3.411012,1.21367 4.047961,1.21372 0.292725,0 2.597694,-1.59046 2.62774,-1.62049 0.282975,-0.2829 0.62335,-1.64362 1.213771,-2.62769 0.261227,-0.43541 3.039143,-3.62553 3.8415,-2.02081 0.941281,1.88251 0.338993,3.43398 -1.013552,4.44829 -1.84631,1.38474 -0.05184,2.57589 1.013552,3.64135 0.895624,0.89563 3.434841,0.34756 3.434841,1.61413 0,3.33848 -0.0482,4.06193 3.034409,3.03446 1.147512,-0.38255 2.048416,-2.0208 3.847767,-2.0208 3.071568,0 1.801604,-1.83472 3.434827,-3.23468 0.471902,-0.40452 0.792451,-1.21381 1.413969,-1.21376 2.401224,0 1.736751,-0.93873 3.441093,-1.62049 2.544678,-1.01786 5.461945,1.3459 5.461945,1.01366 0,-2.40131 3.370099,-0.27729 4.241928,-2.02091 1.057383,-2.11481 1.442439,-2.02712 4.24817,-2.02712 2.051414,0 2.789613,-2.0209 4.855062,-2.0209 1.640225,0 3.015819,-0.40042 4.654853,-0.40042 1.497517,0 1.586875,1.31057 1.207519,2.828 -0.572527,2.29009 -2.351061,2.22727 -4.84881,2.22727 -1.733127,0 -4.157741,-0.5744 -4.654854,1.41408 -0.293386,1.17352 -4.331001,1.08262 -4.248179,1.41392 0.33152,1.32613 1.117089,3.31521 -0.807092,2.83425 -0.539307,-0.13489 -1.081127,-0.27188 -1.62044,-0.40677 -0.510797,-0.12763 -0.607538,-1.55632 -1.0073,-1.21372 -0.899803,0.77126 -0.775824,2.91439 -1.783104,3.20334 0.490957,1.47384 0.337847,5.26605 0.337847,6.97608 0,2.60356 2.53176,0.45152 3.434827,0 0.87272,-0.43641 2.860672,-1.99939 5.149124,-2.57148 1.324451,-0.3311 3.248066,-1.84312 3.71638,-3.71638 0.706096,-2.82439 3.500144,-2.00209 6.575596,-2.00209 1.623543,0 3.246845,-0.19245 4.86758,-0.2878 1.029459,-0.0606 1.540201,-1.71428 2.57144,-1.71428 2.99763,0 3.19943,-3.19939 4.86131,-4.86132 1.02639,-1.02642 6.34535,-0.4349 8.00835,-1.43275 1.13584,-0.68151 0.5756,-5.10547 0.5756,-6.29411 0,-1.8255 0.35426,-3.71948 1.42649,-5.14902 1.79392,-2.39194 7.15121,-1.97481 7.15121,-5.43071 0,-2.41266 -4.14879,-0.84954 -2.57144,-4.00417 1.01499,-2.02997 2.28499,-2.28854 0.28155,-4.29198 -1.28803,-1.28809 -0.28155,-3.89226 -0.28155,-5.43066 0,-1.01871 -1.23229,-3.57753 -1.43274,-4.57978 -0.52268,-2.61337 -2.03221,-3.84836 -3.43484,-5.71846 -1.8508,-2.46777 1.45476,-3.08251 2.57769,-4.57972 0.58952,-0.78612 2.10161,-3.53264 2.28989,-4.28577 0.0219,-0.0878 -0.17183,-0.50268 -0.31908,-0.93223 -0.37455,-0.25887 -0.74527,-0.52529 -1.11366,-0.78827 2.17612,0 -3.55915,-2.87094 -5.71846,-3.14082 -2.89514,-0.36188 -2.81216,-1.69742 -2.00209,-3.72268 0.95169,-2.37918 1.08249,-2.12067 0,-4.28567 -0.80173,-1.60347 1.64877,-3.58099 2.28363,-4.00418 0.32839,-0.21893 -0.44112,-5.48852 0.2878,-6.58186 1.12033,-1.6805 -1.17194,-4.0312 -2.00209,-4.86132 -0.72764,-0.72766 -0.60286,-4.16009 -0.5756,-5.56831 -0.18064,-0.0392 -0.38935,-0.0948 -0.61939,-0.16261 -0.52966,0.18689 -0.66219,0.0535 -0.68822,-0.21283 -1.13918,-0.36292 -2.48908,-0.8173 -3.29093,-0.81329 z").attr(attr); - eire.antrim = R.path("m 347.15165,611.21733 c -3.57829,-1.93341 1.11861,-7.31262 2.45256,-9.85407 3.01338,-1.5821 6.81839,-1.51958 8.13344,-5.39938 2.31025,-3.81042 1.03748,-9.30495 0.65925,-13.6165 -1.66502,-2.10709 -1.08954,3.85432 -2.52519,4.76928 -2.67295,3.82814 -2.50197,-3.83335 -2.99537,-5.45519 -0.43165,-3.94787 -5.42654,-4.34854 -6.35663,-8.08338 -2.03692,-2.51622 -8.26381,-3.53008 -6.60688,-7.75809 0.61103,-2.40806 1.31865,-8.81529 -2.77794,-6.50058 -1.31201,-2.46056 -1.24194,-6.79353 -0.68191,-9.30971 2.05983,-1.06165 0.81557,-4.52486 -1.51406,-3.6538 -0.86698,-4.45845 -5.24635,-4.82854 -9.01716,-4.17035 -3.15689,0.31988 -5.72421,-0.40583 -7.78788,-2.44911 -4.69738,1.72936 -8.59392,-2.68214 -13.10118,-1.10114 -2.24554,1.14704 -3.97391,2.08907 -4.49845,4.69864 -1.5352,1.64612 -5.88374,0.92267 -2.5324,3.2534 2.52767,3.06099 1.37799,7.07442 1.44654,10.72418 0.0679,3.88945 -2.40346,10.05468 1.86283,12.1863 -1.07368,2.16761 -0.8633,4.43052 1.53376,6.07304 1.00016,3.89496 1.56146,7.92091 3.69184,11.52511 1.14976,2.64671 -1.56899,8.87175 1.99953,9.23078 1.29711,1.55327 0.77953,5.41489 4.31554,4.25989 3.49228,0.35157 8.79549,-3.27592 10.96287,0.67651 1.53969,4.46785 -5.03133,6.49181 -4.40459,10.42962 3.65365,2.03637 -0.22408,7.39316 -0.89341,10.5965 -2.42806,2.00069 3.37415,0.12753 2.25739,3.41186 2.96085,-0.10371 6.39106,-0.40282 9.07522,2.04388 3.76393,0.73812 6.68914,-3.80051 8.68962,-6.53071 0.4757,-4.34894 4.72101,-3.66257 7.38186,-2.19724 1.79659,-2.12016 1.06399,-5.2245 1.2308,-7.79974 z").attr(attr); - //eire.kerry = R.path().attr(attr); - var current = null; - for (var state in eire) { - eire[state].color = Raphael.getColor(); - (function (st, state) { - st[0].style.cursor = "pointer"; - st[0].onmouseover = function () { - current && eire[current].animate({fill: "#333", stroke: "#666"}, 500) && (document.getElementById(current).style.display = ""); - st.animate({fill: st.color, stroke: "#ccc"}, 500); - st.toFront(); - R.safari(); - document.getElementById(state).style.display = "block"; - current = state; - }; - st[0].onmouseout = function () { - st.animate({fill: "#333", stroke: "#666"}, 500); - st.toFront(); - R.safari(); - }; - if (state == "nsw") { - st[0].onmouseover(); - } - })(eire[state], state); - } - }; \ No newline at end of file diff --git a/test/raphael-svg-import b/test/raphael-svg-import new file mode 160000 index 0000000..9d59748 --- /dev/null +++ b/test/raphael-svg-import @@ -0,0 +1 @@ +Subproject commit 9d59748129c14f571c76752d44c9403b5d83052d diff --git a/test/raphael.js b/test/raphael.js new file mode 100644 index 0000000..bf6e741 --- /dev/null +++ b/test/raphael.js @@ -0,0 +1,5462 @@ +// ┌─────────────────────────────────────────────────────────────────────┐ \\ +// │ Raphaël 2.0.1 - JavaScript Vector Library │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ +// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ +// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ +// └─────────────────────────────────────────────────────────────────────┘ \\ + +// ┌──────────────────────────────────────────────────────────────────────────────────────┐ \\ +// │ Eve 0.4.0 - JavaScript Events Library │ \\ +// ├──────────────────────────────────────────────────────────────────────────────────────┤ \\ +// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\ +// │ Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. │ \\ +// └──────────────────────────────────────────────────────────────────────────────────────┘ \\ + +(function (glob) { + var version = "0.4.0", + has = "hasOwnProperty", + separator = /[\.\/]/, + wildcard = "*", + fun = function () {}, + numsort = function (a, b) { + return a - b; + }, + current_event, + stop, + events = {n: {}}, + + eve = function (name, scope) { + var e = events, + oldstop = stop, + args = Array.prototype.slice.call(arguments, 2), + listeners = eve.listeners(name), + z = 0, + f = false, + l, + indexed = [], + queue = {}, + out = [], + errors = []; + current_event = name; + stop = 0; + for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) { + indexed.push(listeners[i].zIndex); + if (listeners[i].zIndex < 0) { + queue[listeners[i].zIndex] = listeners[i]; + } + } + indexed.sort(numsort); + while (indexed[z] < 0) { + l = queue[indexed[z++]]; + out.push(l.apply(scope, args)); + if (stop) { + stop = oldstop; + return out; + } + } + for (i = 0; i < ii; i++) { + l = listeners[i]; + if ("zIndex" in l) { + if (l.zIndex == indexed[z]) { + out.push(l.apply(scope, args)); + if (stop) { + stop = oldstop; + return out; + } + do { + z++; + l = queue[indexed[z]]; + l && out.push(l.apply(scope, args)); + if (stop) { + stop = oldstop; + return out; + } + } while (l) + } else { + queue[l.zIndex] = l; + } + } else { + out.push(l.apply(scope, args)); + if (stop) { + stop = oldstop; + return out; + } + } + } + stop = oldstop; + return out.length ? out : null; + }; + + eve.listeners = function (name) { + var names = name.split(separator), + e = events, + item, + items, + k, + i, + ii, + j, + jj, + nes, + es = [e], + out = []; + for (i = 0, ii = names.length; i < ii; i++) { + nes = []; + for (j = 0, jj = es.length; j < jj; j++) { + e = es[j].n; + items = [e[names[i]], e[wildcard]]; + k = 2; + while (k--) { + item = items[k]; + if (item) { + nes.push(item); + out = out.concat(item.f || []); + } + } + } + es = nes; + } + return out; + }; + + + eve.on = function (name, f) { + var names = name.split(separator), + e = events; + for (var i = 0, ii = names.length; i < ii; i++) { + e = e.n; + !e[names[i]] && (e[names[i]] = {n: {}}); + e = e[names[i]]; + } + e.f = e.f || []; + for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) { + return fun; + } + e.f.push(f); + return function (zIndex) { + if (+zIndex == +zIndex) { + f.zIndex = +zIndex; + } + }; + }; + + eve.stop = function () { + stop = 1; + }; + + eve.nt = function (subname) { + if (subname) { + return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event); + } + return current_event; + }; + + eve.unbind = function (name, f) { + var names = name.split(separator), + e, + key, + splice, + i, ii, j, jj, + cur = [events]; + for (i = 0, ii = names.length; i < ii; i++) { + for (j = 0; j < cur.length; j += splice.length - 2) { + splice = [j, 1]; + e = cur[j].n; + if (names[i] != wildcard) { + if (e[names[i]]) { + splice.push(e[names[i]]); + } + } else { + for (key in e) if (e[has](key)) { + splice.push(e[key]); + } + } + cur.splice.apply(cur, splice); + } + } + for (i = 0, ii = cur.length; i < ii; i++) { + e = cur[i]; + while (e.n) { + if (f) { + if (e.f) { + for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) { + e.f.splice(j, 1); + break; + } + !e.f.length && delete e.f; + } + for (key in e.n) if (e.n[has](key) && e.n[key].f) { + var funcs = e.n[key].f; + for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) { + funcs.splice(j, 1); + break; + } + !funcs.length && delete e.n[key].f; + } + } else { + delete e.f; + for (key in e.n) if (e.n[has](key) && e.n[key].f) { + delete e.n[key].f; + } + } + e = e.n; + } + } + }; + + eve.once = function (name, f) { + var f2 = function () { + f.apply(this, arguments); + eve.unbind(name, f2); + }; + return eve.on(name, f2); + }; + + eve.version = version; + eve.toString = function () { + return "You are running Eve " + version; + }; + (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (glob.eve = eve); +})(this); + +// ┌─────────────────────────────────────────────────────────────────────┐ \\ +// │ "Raphaël 2.0.1" - JavaScript Vector Library │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ +// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ +// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ +// └─────────────────────────────────────────────────────────────────────┘ \\ +(function () { + + function R(first) { + if (R.is(first, "function")) { + return loaded ? first() : eve.on("DOMload", first); + } else if (R.is(first, array)) { + return R._engine.create[apply](R, first.splice(0, 3 + R.is(first[0], nu))).add(first); + } else { + var args = Array.prototype.slice.call(arguments, 0); + if (R.is(args[args.length - 1], "function")) { + var f = args.pop(); + return loaded ? f.call(R._engine.create[apply](R, args)) : eve.on("DOMload", function () { + f.call(R._engine.create[apply](R, args)); + }); + } else { + return R._engine.create[apply](R, arguments); + } + } + } + R.version = "2.0.1"; + R.eve = eve; + var loaded, + separator = /[, ]+/, + elements = {circle: 1, rect: 1, path: 1, ellipse: 1, text: 1, image: 1}, + formatrg = /\{(\d+)\}/g, + proto = "prototype", + has = "hasOwnProperty", + g = { + doc: document, + win: window + }, + oldRaphael = { + was: Object.prototype[has].call(g.win, "Raphael"), + is: g.win.Raphael + }, + Paper = function () { + + + this.ca = this.customAttributes = {}; + }, + paperproto, + appendChild = "appendChild", + apply = "apply", + concat = "concat", + supportsTouch = "createTouch" in g.doc, + E = "", + S = " ", + Str = String, + split = "split", + events = "click dblclick mousedown mousemove mouseout mouseover mouseup touchstart touchmove touchend touchcancel"[split](S), + touchMap = { + mousedown: "touchstart", + mousemove: "touchmove", + mouseup: "touchend" + }, + lowerCase = Str.prototype.toLowerCase, + math = Math, + mmax = math.max, + mmin = math.min, + abs = math.abs, + pow = math.pow, + PI = math.PI, + nu = "number", + string = "string", + array = "array", + toString = "toString", + fillString = "fill", + objectToString = Object.prototype.toString, + paper = {}, + push = "push", + ISURL = R._ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i, + colourRegExp = /^\s*((#[a-f\d]{6})|(#[a-f\d]{3})|rgba?\(\s*([\d\.]+%?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+%?(?:\s*,\s*[\d\.]+%?)?)\s*\)|hsba?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\)|hsla?\(\s*([\d\.]+(?:deg|\xb0|%)?\s*,\s*[\d\.]+%?\s*,\s*[\d\.]+(?:%?\s*,\s*[\d\.]+)?)%?\s*\))\s*$/i, + isnan = {"NaN": 1, "Infinity": 1, "-Infinity": 1}, + bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/, + round = math.round, + setAttribute = "setAttribute", + toFloat = parseFloat, + toInt = parseInt, + upperCase = Str.prototype.toUpperCase, + availableAttrs = R._availableAttrs = { + "arrow-end": "none", + "arrow-start": "none", + blur: 0, + "clip-rect": "0 0 1e9 1e9", + cursor: "default", + cx: 0, + cy: 0, + fill: "#fff", + "fill-opacity": 1, + font: '10px "Arial"', + "font-family": '"Arial"', + "font-size": "10", + "font-style": "normal", + "font-weight": 400, + gradient: 0, + height: 0, + href: "http://raphaeljs.com/", + "letter-spacing": 0, + opacity: 1, + path: "M0,0", + r: 0, + rx: 0, + ry: 0, + src: "", + stroke: "#000", + "stroke-dasharray": "", + "stroke-linecap": "butt", + "stroke-linejoin": "butt", + "stroke-miterlimit": 0, + "stroke-opacity": 1, + "stroke-width": 1, + target: "_blank", + "text-anchor": "middle", + title: "Raphael", + transform: "", + width: 0, + x: 0, + y: 0 + }, + availableAnimAttrs = R._availableAnimAttrs = { + blur: nu, + "clip-rect": "csv", + cx: nu, + cy: nu, + fill: "colour", + "fill-opacity": nu, + "font-size": nu, + height: nu, + opacity: nu, + path: "path", + r: nu, + rx: nu, + ry: nu, + stroke: "colour", + "stroke-opacity": nu, + "stroke-width": nu, + transform: "transform", + width: nu, + x: nu, + y: nu + }, + commaSpaces = /\s*,\s*/, + hsrg = {hs: 1, rg: 1}, + p2s = /,?([achlmqrstvxz]),?/gi, + pathCommand = /([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig, + tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?\s*,?\s*)+)/ig, + pathValues = /(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/ig, + radial_gradient = R._radial_gradient = /^r(?:\(([^,]+?)\s*,\s*([^\)]+?)\))?/, + eldata = {}, + sortByKey = function (a, b) { + return a.key - b.key; + }, + sortByNumber = function (a, b) { + return toFloat(a) - toFloat(b); + }, + fun = function () {}, + pipe = function (x) { + return x; + }, + rectPath = R._rectPath = function (x, y, w, h, r) { + if (r) { + return [["M", x + r, y], ["l", w - r * 2, 0], ["a", r, r, 0, 0, 1, r, r], ["l", 0, h - r * 2], ["a", r, r, 0, 0, 1, -r, r], ["l", r * 2 - w, 0], ["a", r, r, 0, 0, 1, -r, -r], ["l", 0, r * 2 - h], ["a", r, r, 0, 0, 1, r, -r], ["z"]]; + } + return [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]]; + }, + ellipsePath = function (x, y, rx, ry) { + if (ry == null) { + ry = rx; + } + return [["M", x, y], ["m", 0, -ry], ["a", rx, ry, 0, 1, 1, 0, 2 * ry], ["a", rx, ry, 0, 1, 1, 0, -2 * ry], ["z"]]; + }, + getPath = R._getPath = { + path: function (el) { + return el.attr("path"); + }, + circle: function (el) { + var a = el.attrs; + return ellipsePath(a.cx, a.cy, a.r); + }, + ellipse: function (el) { + var a = el.attrs; + return ellipsePath(a.cx, a.cy, a.rx, a.ry); + }, + rect: function (el) { + var a = el.attrs; + return rectPath(a.x, a.y, a.width, a.height, a.r); + }, + image: function (el) { + var a = el.attrs; + return rectPath(a.x, a.y, a.width, a.height); + }, + text: function (el) { + var bbox = el._getBBox(); + return rectPath(bbox.x, bbox.y, bbox.width, bbox.height); + } + }, + mapPath = R.mapPath = function (path, matrix) { + if (!matrix) { + return path; + } + var x, y, i, j, ii, jj, pathi; + path = path2curve(path); + for (i = 0, ii = path.length; i < ii; i++) { + pathi = path[i]; + for (j = 1, jj = pathi.length; j < jj; j += 2) { + x = matrix.x(pathi[j], pathi[j + 1]); + y = matrix.y(pathi[j], pathi[j + 1]); + pathi[j] = x; + pathi[j + 1] = y; + } + } + return path; + }; + + 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"), + b; + d.innerHTML = ''; + b = d.firstChild; + b.style.behavior = "url(#default#VML)"; + if (!(b && typeof b.adj == "object")) { + return (R.type = E); + } + 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") { + return !isnan[has](+o); + } + if (type == "array") { + return o instanceof Array; + } + return (type == "null" && o === null) || + (type == typeof o && o !== null) || + (type == "object" && o === Object(o)) || + (type == "array" && Array.isArray && Array.isArray(o)) || + objectToString.call(o).slice(8, -1).toLowerCase() == type; + }; + + R.angle = function (x1, y1, x2, y2, x3, y3) { + if (x3 == null) { + var x = x1 - x2, + y = y1 - y2; + if (!x && !y) { + return 0; + } + return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360; + } else { + 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)) { + var i = values.length; + while (i--) if (abs(values[i] - value) <= tolerance) { + return values[i]; + } + } else { + values = +values; + var rem = value % values; + if (rem < tolerance) { + return value - rem; + } + if (rem > values - tolerance) { + return value - rem + values; + } + } + return value; + }; + + + var createUUID = R.createUUID = (function (uuidRegEx, uuidReplacer) { + return function () { + return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(uuidRegEx, uuidReplacer).toUpperCase(); + }; + })(/[xy]/g, function (c) { + var r = math.random() * 16 | 0, + v = c == "x" ? r : (r & 3 | 8); + return v.toString(16); + }); + + + R.setWindow = function (newwin) { + eve("setWindow", R, g.win, newwin); + g.win = newwin; + g.doc = g.win.document; + if (R._engine.initWin) { + R._engine.initWin(g.win); + } + }; + var toHex = function (color) { + if (R.vml) { + // http://dean.edwards.name/weblog/2009/10/convert-any-colour-value-to-hex-in-msie/ + var trim = /^\s+|\s+$/g; + var bod; + try { + var docum = new ActiveXObject("htmlfile"); + docum.write(""); + docum.close(); + bod = docum.body; + } catch(e) { + bod = createPopup().document.body; + } + var range = bod.createTextRange(); + toHex = cacher(function (color) { + try { + bod.style.color = Str(color).replace(trim, E); + var value = range.queryCommandValue("ForeColor"); + value = ((value & 255) << 16) | (value & 65280) | ((value & 16711680) >>> 16); + return "#" + ("000000" + value.toString(16)).slice(-6); + } catch(e) { + return "none"; + } + }); + } else { + var i = g.doc.createElement("i"); + i.title = "Rapha\xebl Colour Picker"; + i.style.display = "none"; + g.doc.body.appendChild(i); + toHex = cacher(function (color) { + i.style.color = color; + return g.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color"); + }); + } + return toHex(color); + }, + hsbtoString = function () { + return "hsb(" + [this.h, this.s, this.b] + ")"; + }, + hsltoString = function () { + return "hsl(" + [this.h, this.s, this.l] + ")"; + }, + rgbtoString = function () { + return this.hex; + }, + prepareRGB = function (r, g, b) { + if (g == null && R.is(r, "object") && "r" in r && "g" in r && "b" in r) { + b = r.b; + g = r.g; + r = r.r; + } + if (g == null && R.is(r, string)) { + var clr = R.getRGB(r); + r = clr.r; + g = clr.g; + b = clr.b; + } + if (r > 1 || g > 1 || b > 1) { + r /= 255; + g /= 255; + b /= 255; + } + + return [r, g, b]; + }, + packageRGB = function (r, g, b, o) { + r *= 255; + g *= 255; + b *= 255; + var rgb = { + r: r, + g: g, + b: b, + hex: R.rgb(r, g, b), + toString: rgbtoString + }; + 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) { + rgb = R.hsb2rgb(clr); + clr.r = rgb.r; + clr.g = rgb.g; + clr.b = rgb.b; + clr.hex = rgb.hex; + } else if (R.is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) { + rgb = R.hsl2rgb(clr); + clr.r = rgb.r; + clr.g = rgb.g; + clr.b = rgb.b; + clr.hex = rgb.hex; + } else { + if (R.is(clr, "string")) { + clr = R.getRGB(clr); + } + if (R.is(clr, "object") && "r" in clr && "g" in clr && "b" in clr) { + rgb = R.rgb2hsl(clr); + clr.h = rgb.h; + clr.s = rgb.s; + clr.l = rgb.l; + rgb = R.rgb2hsb(clr); + clr.v = rgb.b; + } else { + clr = {hex: "none"}; + clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1; + } + } + 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; + s = h.s; + h = h.h; + o = h.o; + } + h *= 360; + var R, G, B, X, C; + h = (h % 360) / 60; + C = v * s; + X = C * (1 - abs(h % 2 - 1)); + R = G = B = v - C; + + h = ~~h; + R += [C, X, 0, 0, X, C][h]; + G += [X, C, C, X, 0, 0][h]; + 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; + s = h.s; + h = h.h; + } + if (h > 1 || s > 1 || l > 1) { + h /= 360; + s /= 100; + l /= 100; + } + h *= 360; + var R, G, B, X, C; + h = (h % 360) / 60; + C = 2 * s * (l < .5 ? l : 1 - l); + X = C * (1 - abs(h % 2 - 1)); + R = G = B = l - C / 2; + + h = ~~h; + R += [C, X, 0, 0, X, C][h]; + G += [X, C, C, X, 0, 0][h]; + 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]; + g = b[1]; + b = b[2]; + + var H, S, V, C; + V = mmax(r, g, b); + C = V - mmin(r, g, b); + H = (C == 0 ? null : + V == r ? (g - b) / C : + V == g ? (b - r) / C + 2 : + (r - g) / C + 4 + ); + H = ((H + 360) % 6) * 60 / 360; + 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]; + g = b[1]; + b = b[2]; + + var H, S, L, M, m, C; + M = mmax(r, g, b); + m = mmin(r, g, b); + C = M - m; + H = (C == 0 ? null : + M == r ? (g - b) / C : + M == g ? (b - r) / C + 2 : + (r - g) / C + 4); + H = ((H + 360) % 6) * 60 / 360; + L = (M + m) / 2; + S = (C == 0 ? 0 : + L < .5 ? C / (2 * L) : + C / (2 - 2 * L)); + return {h: H, s: S, l: L, toString: hsltoString}; + }; + R._path2string = function () { + return this.join(",").replace(p2s, "$1"); + }; + function repush(array, item) { + for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) { + return array.push(array.splice(i, 1)[0]); + } + } + function cacher(f, scope, postprocessor) { + function newf() { + var arg = Array.prototype.slice.call(arguments, 0), + args = arg.join("\u2400"), + cache = newf.cache = newf.cache || {}, + count = newf.count = newf.count || []; + if (cache[has](args)) { + repush(count, args); + return postprocessor ? postprocessor(cache[args]) : cache[args]; + } + count.length >= 1e3 && delete cache[count.shift()]; + count.push(args); + cache[args] = f[apply](scope, arg); + return postprocessor ? postprocessor(cache[args]) : cache[args]; + } + return newf; + } + + var preload = R._preload = function (src, f) { + var img = g.doc.createElement("img"); + img.style.cssText = "position:absolute;left:-9999em;top:-9999em"; + img.onload = function () { + f.call(this); + this.onload = null; + g.doc.body.removeChild(this); + }; + img.onerror = function () { + g.doc.body.removeChild(this); + }; + 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}; + } + if (colour == "none") { + return {r: -1, g: -1, b: -1, hex: "none", toString: clrToString}; + } + !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour)); + var res, + red, + green, + blue, + opacity, + t, + values, + rgb = colour.match(colourRegExp); + if (rgb) { + if (rgb[2]) { + blue = toInt(rgb[2].substring(5), 16); + green = toInt(rgb[2].substring(3, 5), 16); + red = toInt(rgb[2].substring(1, 3), 16); + } + if (rgb[3]) { + blue = toInt((t = rgb[3].charAt(3)) + t, 16); + green = toInt((t = rgb[3].charAt(2)) + t, 16); + red = toInt((t = rgb[3].charAt(1)) + t, 16); + } + if (rgb[4]) { + values = rgb[4][split](commaSpaces); + red = toFloat(values[0]); + values[0].slice(-1) == "%" && (red *= 2.55); + green = toFloat(values[1]); + values[1].slice(-1) == "%" && (green *= 2.55); + blue = toFloat(values[2]); + values[2].slice(-1) == "%" && (blue *= 2.55); + rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3])); + values[3] && values[3].slice(-1) == "%" && (opacity /= 100); + } + if (rgb[5]) { + values = rgb[5][split](commaSpaces); + red = toFloat(values[0]); + values[0].slice(-1) == "%" && (red *= 2.55); + green = toFloat(values[1]); + values[1].slice(-1) == "%" && (green *= 2.55); + blue = toFloat(values[2]); + values[2].slice(-1) == "%" && (blue *= 2.55); + (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360); + rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3])); + values[3] && values[3].slice(-1) == "%" && (opacity /= 100); + return R.hsb2rgb(red, green, blue, opacity); + } + if (rgb[6]) { + values = rgb[6][split](commaSpaces); + red = toFloat(values[0]); + values[0].slice(-1) == "%" && (red *= 2.55); + green = toFloat(values[1]); + values[1].slice(-1) == "%" && (green *= 2.55); + blue = toFloat(values[2]); + values[2].slice(-1) == "%" && (blue *= 2.55); + (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360); + rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3])); + values[3] && values[3].slice(-1) == "%" && (opacity /= 100); + return R.hsl2rgb(red, green, blue, opacity); + } + rgb = {r: red, g: green, b: blue, toString: clrToString}; + rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1); + R.is(opacity, "finite") && (rgb.opacity = opacity); + return rgb; + } + 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); + start.h += .075; + if (start.h > 1) { + start.h = 0; + start.s -= .2; + start.s <= 0 && (this.getColor.start = {h: 0, s: 1, b: start.b}); + } + return rgb.hex; + }; + + R.getColor.reset = function () { + delete this.start; + }; + + // http://schepers.cc/getting-to-the-point + function catmullRom2bezier(crp) { + var d = []; + for (var i = 0, iLen = crp.length; iLen - 2 > i; i += 2) { + var p = [{x: +crp[i], y: +crp[i + 1]}, + {x: +crp[i], y: +crp[i + 1]}, + {x: +crp[i + 2], y: +crp[i + 3]}, + {x: +crp[i + 4], y: +crp[i + 5]}]; + if (iLen - 4 == i) { + p[0] = {x: +crp[i - 2], y: +crp[i - 1]}; + p[3] = p[2]; + } else if (i) { + p[0] = {x: +crp[i - 2], y: +crp[i - 1]}; + } + d.push(["C", + (-p[0].x + 6 * p[1].x + p[2].x) / 6, + (-p[0].y + 6 * p[1].y + p[2].y) / 6, + (p[1].x + 6 * p[2].x - p[3].x) / 6, + (p[1].y + 6*p[2].y - p[3].y) / 6, + p[2].x, + p[2].y + ]); + } + + return d; + } + + R.parsePathString = cacher(function (pathString) { + if (!pathString) { + return null; + } + 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 + data = pathClone(pathString); + } + if (!data.length) { + Str(pathString).replace(pathCommand, function (a, b, c) { + var params = [], + name = b.toLowerCase(); + c.replace(pathValues, function (a, b) { + b && params.push(+b); + }); + if (name == "m" && params.length > 2) { + data.push([b][concat](params.splice(0, 2))); + name = "l"; + b = b == "m" ? "l" : "L"; + } + if (name == "r") { + data.push([b][concat](params)); + } else while (params.length >= paramCounts[name]) { + data.push([b][concat](params.splice(0, paramCounts[name]))); + if (!paramCounts[name]) { + break; + } + } + }); + } + data.toString = R._path2string; + return data; + }); + + R.parseTransformString = cacher(function (TString) { + if (!TString) { + return null; + } + var paramCounts = {r: 3, s: 4, t: 2, m: 6}, + data = []; + if (R.is(TString, array) && R.is(TString[0], array)) { // rough assumption + data = pathClone(TString); + } + if (!data.length) { + Str(TString).replace(tCommand, function (a, b, c) { + var params = [], + name = lowerCase.call(b); + c.replace(pathValues, function (a, b) { + b && params.push(+b); + }); + data.push([b][concat](params)); + }); + } + data.toString = R._path2string; + return data; + }); + + R.findDotsAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { + var t1 = 1 - t, + t13 = pow(t1, 3), + t12 = pow(t1, 2), + t2 = t * t, + t3 = t2 * t, + x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x, + y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y, + mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x), + my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y), + nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x), + ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y), + ax = t1 * p1x + t * c1x, + ay = t1 * p1y + t * c1y, + cx = t1 * c2x + t * p2x, + cy = t1 * c2y + t * p2y, + alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI); + (mx > nx || my < ny) && (alpha += 180); + return { + x: x, + y: y, + m: {x: mx, y: my}, + n: {x: nx, y: ny}, + start: {x: ax, y: ay}, + end: {x: cx, y: cy}, + alpha: alpha + }; + }; + R._removedFactory = function (methodname) { + return function () { + throw new Error("Rapha\xebl: you are calling to method \u201c" + methodname + "\u201d of removed object"); + }; + }; + var pathDimensions = cacher(function (path) { + if (!path) { + return {x: 0, y: 0, width: 0, height: 0}; + } + path = path2curve(path); + var x = 0, + y = 0, + X = [], + Y = [], + p; + for (var i = 0, ii = path.length; i < ii; i++) { + p = path[i]; + if (p[0] == "M") { + x = p[1]; + y = p[2]; + X.push(x); + Y.push(y); + } else { + var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); + X = X[concat](dim.min.x, dim.max.x); + Y = Y[concat](dim.min.y, dim.max.y); + x = p[5]; + y = p[6]; + } + } + var xmin = mmin[apply](0, X), + ymin = mmin[apply](0, Y); + return { + x: xmin, + y: ymin, + width: mmax[apply](0, X) - xmin, + height: mmax[apply](0, Y) - ymin + }; + }, null, function (o) { + return { + x: o.x, + y: o.y, + width: o.width, + height: o.height + }; + }), + pathClone = function (pathArray) { + var res = []; + if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption + pathArray = R.parsePathString(pathArray); + } + for (var i = 0, ii = pathArray.length; i < ii; i++) { + res[i] = []; + for (var j = 0, jj = pathArray[i].length; j < jj; j++) { + res[i][j] = pathArray[i][j]; + } + } + res.toString = R._path2string; + return res; + }, + pathToRelative = R._pathToRelative = cacher(function (pathArray) { + if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption + pathArray = R.parsePathString(pathArray); + } + var res = [], + x = 0, + y = 0, + mx = 0, + my = 0, + start = 0; + if (pathArray[0][0] == "M") { + x = pathArray[0][1]; + y = pathArray[0][2]; + mx = x; + my = y; + start++; + res.push(["M", x, y]); + } + for (var i = start, ii = pathArray.length; i < ii; i++) { + var r = res[i] = [], + pa = pathArray[i]; + if (pa[0] != lowerCase.call(pa[0])) { + r[0] = lowerCase.call(pa[0]); + switch (r[0]) { + case "a": + r[1] = pa[1]; + r[2] = pa[2]; + r[3] = pa[3]; + r[4] = pa[4]; + r[5] = pa[5]; + r[6] = +(pa[6] - x).toFixed(3); + r[7] = +(pa[7] - y).toFixed(3); + break; + case "v": + r[1] = +(pa[1] - y).toFixed(3); + break; + case "m": + mx = pa[1]; + my = pa[2]; + default: + for (var j = 1, jj = pa.length; j < jj; j++) { + r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3); + } + } + } else { + r = res[i] = []; + if (pa[0] == "m") { + mx = pa[1] + x; + my = pa[2] + y; + } + for (var k = 0, kk = pa.length; k < kk; k++) { + res[i][k] = pa[k]; + } + } + var len = res[i].length; + switch (res[i][0]) { + case "z": + x = mx; + y = my; + break; + case "h": + x += +res[i][len - 1]; + break; + case "v": + y += +res[i][len - 1]; + break; + default: + x += +res[i][len - 2]; + y += +res[i][len - 1]; + } + } + res.toString = R._path2string; + return res; + }, 0, pathClone), + pathToAbsolute = R._pathToAbsolute = cacher(function (pathArray) { + if (!R.is(pathArray, array) || !R.is(pathArray && pathArray[0], array)) { // rough assumption + pathArray = R.parsePathString(pathArray); + } + if (!pathArray || !pathArray.length) { + return [["M", 0, 0]]; + } + var res = [], + x = 0, + y = 0, + mx = 0, + my = 0, + start = 0; + if (pathArray[0][0] == "M") { + x = +pathArray[0][1]; + y = +pathArray[0][2]; + mx = x; + my = y; + start++; + res[0] = ["M", x, y]; + } + for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) { + res.push(r = []); + pa = pathArray[i]; + if (pa[0] != upperCase.call(pa[0])) { + r[0] = upperCase.call(pa[0]); + switch (r[0]) { + case "A": + r[1] = pa[1]; + r[2] = pa[2]; + r[3] = pa[3]; + r[4] = pa[4]; + r[5] = pa[5]; + r[6] = +(pa[6] + x); + r[7] = +(pa[7] + y); + break; + case "V": + r[1] = +pa[1] + y; + break; + case "H": + r[1] = +pa[1] + x; + break; + case "R": + var dots = [x, y][concat](pa.slice(1)); + for (var j = 2, jj = dots.length; j < jj; j++) { + dots[j] = +dots[j] + x; + dots[++j] = +dots[j] + y; + } + res.pop(); + res = res[concat](catmullRom2bezier(dots)); + break; + case "M": + mx = +pa[1] + x; + my = +pa[2] + y; + default: + for (j = 1, jj = pa.length; j < jj; j++) { + r[j] = +pa[j] + ((j % 2) ? x : y); + } + } + } else if (pa[0] == "R") { + dots = [x, y][concat](pa.slice(1)); + res.pop(); + res = res[concat](catmullRom2bezier(dots)); + r = ["R"][concat](pa.slice(-2)); + } else { + for (var k = 0, kk = pa.length; k < kk; k++) { + r[k] = pa[k]; + } + } + switch (r[0]) { + case "Z": + x = mx; + y = my; + break; + case "H": + x = r[1]; + break; + case "V": + y = r[1]; + break; + case "M": + mx = r[r.length - 2]; + my = r[r.length - 1]; + default: + x = r[r.length - 2]; + y = r[r.length - 1]; + } + } + res.toString = R._path2string; + return res; + }, null, pathClone), + l2c = function (x1, y1, x2, y2) { + return [x1, y1, x2, y2, x2, y2]; + }, + q2c = function (x1, y1, ax, ay, x2, y2) { + var _13 = 1 / 3, + _23 = 2 / 3; + return [ + _13 * x1 + _23 * ax, + _13 * y1 + _23 * ay, + _13 * x2 + _23 * ax, + _13 * y2 + _23 * ay, + x2, + y2 + ]; + }, + a2c = function (x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) { + // for more information of where this math came from visit: + // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes + var _120 = PI * 120 / 180, + rad = PI / 180 * (+angle || 0), + res = [], + xy, + rotate = cacher(function (x, y, rad) { + var X = x * math.cos(rad) - y * math.sin(rad), + Y = x * math.sin(rad) + y * math.cos(rad); + return {x: X, y: Y}; + }); + if (!recursive) { + xy = rotate(x1, y1, -rad); + x1 = xy.x; + y1 = xy.y; + xy = rotate(x2, y2, -rad); + x2 = xy.x; + y2 = xy.y; + var cos = math.cos(PI / 180 * angle), + sin = math.sin(PI / 180 * angle), + x = (x1 - x2) / 2, + y = (y1 - y2) / 2; + var h = (x * x) / (rx * rx) + (y * y) / (ry * ry); + if (h > 1) { + h = math.sqrt(h); + rx = h * rx; + ry = h * ry; + } + var rx2 = rx * rx, + ry2 = ry * ry, + k = (large_arc_flag == sweep_flag ? -1 : 1) * + math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))), + cx = k * rx * y / ry + (x1 + x2) / 2, + cy = k * -ry * x / rx + (y1 + y2) / 2, + f1 = math.asin(((y1 - cy) / ry).toFixed(9)), + f2 = math.asin(((y2 - cy) / ry).toFixed(9)); + + f1 = x1 < cx ? PI - f1 : f1; + f2 = x2 < cx ? PI - f2 : f2; + f1 < 0 && (f1 = PI * 2 + f1); + f2 < 0 && (f2 = PI * 2 + f2); + if (sweep_flag && f1 > f2) { + f1 = f1 - PI * 2; + } + if (!sweep_flag && f2 > f1) { + f2 = f2 - PI * 2; + } + } else { + f1 = recursive[0]; + f2 = recursive[1]; + cx = recursive[2]; + cy = recursive[3]; + } + var df = f2 - f1; + if (abs(df) > _120) { + var f2old = f2, + x2old = x2, + y2old = y2; + f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1); + x2 = cx + rx * math.cos(f2); + y2 = cy + ry * math.sin(f2); + res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]); + } + df = f2 - f1; + var c1 = math.cos(f1), + s1 = math.sin(f1), + c2 = math.cos(f2), + s2 = math.sin(f2), + t = math.tan(df / 4), + hx = 4 / 3 * rx * t, + hy = 4 / 3 * ry * t, + m1 = [x1, y1], + m2 = [x1 + hx * s1, y1 - hy * c1], + m3 = [x2 + hx * s2, y2 - hy * c2], + m4 = [x2, y2]; + m2[0] = 2 * m1[0] - m2[0]; + m2[1] = 2 * m1[1] - m2[1]; + if (recursive) { + return [m2, m3, m4][concat](res); + } else { + res = [m2, m3, m4][concat](res).join()[split](","); + var newres = []; + for (var i = 0, ii = res.length; i < ii; i++) { + newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x; + } + return newres; + } + }, + findDotAtSegment = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) { + var t1 = 1 - t; + return { + x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x, + y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y + }; + }, + curveDim = cacher(function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) { + var a = (c2x - 2 * c1x + p1x) - (p2x - 2 * c2x + c1x), + b = 2 * (c1x - p1x) - 2 * (c2x - c1x), + c = p1x - c1x, + t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a, + t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a, + y = [p1y, p2y], + x = [p1x, p2x], + dot; + abs(t1) > "1e12" && (t1 = .5); + abs(t2) > "1e12" && (t2 = .5); + if (t1 > 0 && t1 < 1) { + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); + x.push(dot.x); + y.push(dot.y); + } + if (t2 > 0 && t2 < 1) { + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); + x.push(dot.x); + y.push(dot.y); + } + a = (c2y - 2 * c1y + p1y) - (p2y - 2 * c2y + c1y); + b = 2 * (c1y - p1y) - 2 * (c2y - c1y); + c = p1y - c1y; + t1 = (-b + math.sqrt(b * b - 4 * a * c)) / 2 / a; + t2 = (-b - math.sqrt(b * b - 4 * a * c)) / 2 / a; + abs(t1) > "1e12" && (t1 = .5); + abs(t2) > "1e12" && (t2 = .5); + if (t1 > 0 && t1 < 1) { + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t1); + x.push(dot.x); + y.push(dot.y); + } + if (t2 > 0 && t2 < 1) { + dot = findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t2); + x.push(dot.x); + y.push(dot.y); + } + return { + min: {x: mmin[apply](0, x), y: mmin[apply](0, y)}, + max: {x: mmax[apply](0, x), y: mmax[apply](0, y)} + }; + }), + path2curve = R._path2curve = cacher(function (path, path2) { + var p = pathToAbsolute(path), + p2 = path2 && pathToAbsolute(path2), + attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, + attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null}, + processPath = function (path, d) { + var nx, ny; + if (!path) { + return ["C", d.x, d.y, d.x, d.y, d.x, d.y]; + } + !(path[0] in {T:1, Q:1}) && (d.qx = d.qy = null); + switch (path[0]) { + case "M": + d.X = path[1]; + d.Y = path[2]; + break; + case "A": + path = ["C"][concat](a2c[apply](0, [d.x, d.y][concat](path.slice(1)))); + break; + case "S": + nx = d.x + (d.x - (d.bx || d.x)); + ny = d.y + (d.y - (d.by || d.y)); + path = ["C", nx, ny][concat](path.slice(1)); + break; + case "T": + d.qx = d.x + (d.x - (d.qx || d.x)); + d.qy = d.y + (d.y - (d.qy || d.y)); + path = ["C"][concat](q2c(d.x, d.y, d.qx, d.qy, path[1], path[2])); + break; + case "Q": + d.qx = path[1]; + d.qy = path[2]; + path = ["C"][concat](q2c(d.x, d.y, path[1], path[2], path[3], path[4])); + break; + case "L": + path = ["C"][concat](l2c(d.x, d.y, path[1], path[2])); + break; + case "H": + path = ["C"][concat](l2c(d.x, d.y, path[1], d.y)); + break; + case "V": + path = ["C"][concat](l2c(d.x, d.y, d.x, path[1])); + break; + case "Z": + path = ["C"][concat](l2c(d.x, d.y, d.X, d.Y)); + break; + } + return path; + }, + fixArc = function (pp, i) { + if (pp[i].length > 7) { + pp[i].shift(); + var pi = pp[i]; + while (pi.length) { + pp.splice(i++, 0, ["C"][concat](pi.splice(0, 6))); + } + pp.splice(i, 1); + ii = mmax(p.length, p2 && p2.length || 0); + } + }, + fixM = function (path1, path2, a1, a2, i) { + if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") { + path2.splice(i, 0, ["M", a2.x, a2.y]); + a1.bx = 0; + a1.by = 0; + a1.x = path1[i][1]; + a1.y = path1[i][2]; + ii = mmax(p.length, p2 && p2.length || 0); + } + }; + for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) { + p[i] = processPath(p[i], attrs); + fixArc(p, i); + p2 && (p2[i] = processPath(p2[i], attrs2)); + p2 && fixArc(p2, i); + fixM(p, p2, attrs, attrs2, i); + fixM(p2, p, attrs2, attrs, i); + var seg = p[i], + seg2 = p2 && p2[i], + seglen = seg.length, + seg2len = p2 && seg2.length; + attrs.x = seg[seglen - 2]; + attrs.y = seg[seglen - 1]; + attrs.bx = toFloat(seg[seglen - 4]) || attrs.x; + attrs.by = toFloat(seg[seglen - 3]) || attrs.y; + attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x); + attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y); + attrs2.x = p2 && seg2[seg2len - 2]; + attrs2.y = p2 && seg2[seg2len - 1]; + } + return p2 ? [p, p2] : p; + }, null, pathClone), + parseDots = R._parseDots = cacher(function (gradient) { + var dots = []; + for (var i = 0, ii = gradient.length; i < ii; i++) { + var dot = {}, + par = gradient[i].match(/^([^:]*):?([\d\.]*)/); + dot.color = R.getRGB(par[1]); + if (dot.color.error) { + return null; + } + dot.color = dot.color.hex; + par[2] && (dot.offset = par[2] + "%"); + dots.push(dot); + } + for (i = 1, ii = dots.length - 1; i < ii; i++) { + if (!dots[i].offset) { + var start = toFloat(dots[i - 1].offset || 0), + end = 0; + for (var j = i + 1; j < ii; j++) { + if (dots[j].offset) { + end = dots[j].offset; + break; + } + } + if (!end) { + end = 100; + j = ii; + } + end = toFloat(end); + var d = (end - start) / (j - i + 1); + for (; i < j; i++) { + start += d; + dots[i].offset = start + "%"; + } + } + } + return dots; + }), + tear = R._tear = function (el, paper) { + el == paper.top && (paper.top = el.prev); + el == paper.bottom && (paper.bottom = el.next); + el.next && (el.next.prev = el.prev); + el.prev && (el.prev.next = el.next); + }, + tofront = R._tofront = function (el, paper) { + if (paper.top === el) { + return; + } + tear(el, paper); + el.next = null; + el.prev = paper.top; + paper.top.next = el; + paper.top = el; + }, + toback = R._toback = function (el, paper) { + if (paper.bottom === el) { + return; + } + tear(el, paper); + el.next = paper.bottom; + el.prev = null; + paper.bottom.prev = el; + paper.bottom = el; + }, + insertafter = R._insertafter = function (el, el2, paper) { + tear(el, paper); + el2 == paper.top && (paper.top = el); + el2.next && (el2.next.prev = el); + el.next = el2.next; + el.prev = el2; + el2.next = el; + }, + insertbefore = R._insertbefore = function (el, el2, paper) { + tear(el, paper); + el2 == paper.bottom && (paper.bottom = el); + el2.prev && (el2.prev.next = el); + el.prev = el2.prev; + el2.prev = el; + el.next = el2; + }, + extractTransform = R._extractTransform = function (el, tstr) { + if (tstr == null) { + return el._.transform; + } + tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E); + var tdata = R.parseTransformString(tstr), + deg = 0, + dx = 0, + dy = 0, + sx = 1, + sy = 1, + _ = el._, + m = new Matrix; + _.transform = tdata || []; + if (tdata) { + for (var i = 0, ii = tdata.length; i < ii; i++) { + var t = tdata[i], + tlen = t.length, + command = Str(t[0]).toLowerCase(), + absolute = t[0] != command, + inver = absolute ? m.invert() : 0, + x1, + y1, + x2, + y2, + bb; + if (command == "t" && tlen == 3) { + if (absolute) { + x1 = inver.x(0, 0); + y1 = inver.y(0, 0); + x2 = inver.x(t[1], t[2]); + y2 = inver.y(t[1], t[2]); + m.translate(x2 - x1, y2 - y1); + } else { + m.translate(t[1], t[2]); + } + } else if (command == "r") { + if (tlen == 2) { + bb = bb || el.getBBox(1); + m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2); + deg += t[1]; + } else if (tlen == 4) { + if (absolute) { + x2 = inver.x(t[2], t[3]); + y2 = inver.y(t[2], t[3]); + m.rotate(t[1], x2, y2); + } else { + m.rotate(t[1], t[2], t[3]); + } + deg += t[1]; + } + } else if (command == "s") { + if (tlen == 2 || tlen == 3) { + bb = bb || el.getBBox(1); + m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2); + sx *= t[1]; + sy *= t[tlen - 1]; + } else if (tlen == 5) { + if (absolute) { + x2 = inver.x(t[3], t[4]); + y2 = inver.y(t[3], t[4]); + m.scale(t[1], t[2], x2, y2); + } else { + m.scale(t[1], t[2], t[3], t[4]); + } + sx *= t[1]; + sy *= t[2]; + } + } else if (command == "m" && tlen == 7) { + m.add(t[1], t[2], t[3], t[4], t[5], t[6]); + } + _.dirtyT = 1; + el.matrix = m; + } + } + + el.matrix = m; + + _.sx = sx; + _.sy = sy; + _.deg = deg; + _.dx = dx = m.e; + _.dy = dy = m.f; + + if (sx == 1 && sy == 1 && !deg && _.bbox) { + _.bbox.x += +dx; + _.bbox.y += +dy; + } else { + _.dirtyT = 1; + } + }, + getEmpty = function (item) { + var l = item[0]; + switch (l.toLowerCase()) { + case "t": return [l, 0, 0]; + case "m": return [l, 1, 0, 0, 1, 0, 0]; + case "r": if (item.length == 4) { + return [l, 0, item[2], item[3]]; + } else { + return [l, 0]; + } + case "s": if (item.length == 5) { + return [l, 1, 1, item[3], item[4]]; + } else if (item.length == 3) { + return [l, 1, 1]; + } else { + return [l, 1]; + } + } + }, + equaliseTransform = R._equaliseTransform = function (t1, t2) { + t2 = Str(t2).replace(/\.{3}|\u2026/g, t1); + t1 = R.parseTransformString(t1) || []; + t2 = R.parseTransformString(t2) || []; + var maxlength = mmax(t1.length, t2.length), + from = [], + to = [], + i = 0, j, jj, + tt1, tt2; + for (; i < maxlength; i++) { + tt1 = t1[i] || getEmpty(t2[i]); + tt2 = t2[i] || getEmpty(tt1); + if ((tt1[0] != tt2[0]) || + (tt1[0].toLowerCase() == "r" && (tt1[2] != tt2[2] || tt1[3] != tt2[3])) || + (tt1[0].toLowerCase() == "s" && (tt1[3] != tt2[3] || tt1[4] != tt2[4])) + ) { + return; + } + from[i] = []; + to[i] = []; + for (j = 0, jj = mmax(tt1.length, tt2.length); j < jj; j++) { + j in tt1 && (from[i][j] = tt1[j]); + j in tt2 && (to[i][j] = tt2[j]); + } + } + return { + from: from, + to: to + }; + }; + R._getContainer = function (x, y, w, h) { + var container; + container = h == null && !R.is(x, "object") ? g.doc.getElementById(x) : x; + if (container == null) { + return; + } + if (container.tagName) { + if (y == null) { + return { + container: container, + width: container.style.pixelWidth || container.offsetWidth, + height: container.style.pixelHeight || container.offsetHeight + }; + } else { + return { + container: container, + width: y, + height: w + }; + } + } + return { + container: 1, + x: x, + y: y, + width: w, + 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); + }; + function Matrix(a, b, c, d, e, f) { + if (a != null) { + this.a = +a; + this.b = +b; + this.c = +c; + this.d = +d; + this.e = +e; + this.f = +f; + } else { + this.a = 1; + this.b = 0; + this.c = 0; + this.d = 1; + this.e = 0; + this.f = 0; + } + } + (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]], + matrix = [[a, c, e], [b, d, f], [0, 0, 1]], + x, y, z, res; + + if (a && a instanceof Matrix) { + matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]]; + } + + for (x = 0; x < 3; x++) { + for (y = 0; y < 3; y++) { + res = 0; + for (z = 0; z < 3; z++) { + res += m[x][z] * matrix[z][y]; + } + out[x][y] = res; + } + } + this.a = out[0][0]; + this.b = out[1][0]; + this.c = out[0][1]; + this.d = out[1][1]; + 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; + y = y || 0; + var cos = +math.cos(a).toFixed(9), + sin = +math.sin(a).toFixed(9); + 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; + }; + matrixproto.get = function (i) { + return +this[Str.fromCharCode(97 + i)].toFixed(4); + }; + matrixproto.toString = function () { + return R.svg ? + "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")" : + [this.get(0), this.get(2), this.get(1), this.get(3), 0, 0].join(); + }; + matrixproto.toFilter = function () { + return "progid:DXImageTransform.Microsoft.Matrix(M11=" + this.get(0) + + ", M12=" + this.get(2) + ", M21=" + this.get(1) + ", M22=" + this.get(3) + + ", Dx=" + this.get(4) + ", Dy=" + this.get(5) + ", sizingmethod='auto expand')"; + }; + matrixproto.offset = function () { + return [this.e.toFixed(4), this.f.toFixed(4)]; + }; + function norm(a) { + return a[0] * a[0] + a[1] * a[1]; + } + function normalize(a) { + var mag = math.sqrt(norm(a)); + a[0] && (a[0] /= mag); + a[1] && (a[1] /= mag); + } + + matrixproto.split = function () { + var out = {}; + // translation + out.dx = this.e; + out.dy = this.f; + + // scale and shear + var row = [[this.a, this.c], [this.b, this.d]]; + out.scalex = math.sqrt(norm(row[0])); + normalize(row[0]); + + out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1]; + row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear]; + + out.scaley = math.sqrt(norm(row[1])); + normalize(row[1]); + out.shear /= out.scaley; + + // rotation + var sin = -row[0][1], + cos = row[1][1]; + if (cos < 0) { + out.rotate = R.deg(math.acos(cos)); + if (sin < 0) { + out.rotate = 360 - out.rotate; + } + } else { + out.rotate = R.deg(math.asin(sin)); + } + + out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate); + out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate; + 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) + + (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) + + (s.rotate ? "r" + [s.rotate, 0, 0] : E); + } else { + return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)]; + } + }; + })(Matrix.prototype); + + // WebKit rendering bug workaround method + 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();}); + }; + } else { + paperproto.safari = fun; + } + + var preventDefault = function () { + this.returnValue = false; + }, + preventTouch = function () { + return this.originalEvent.preventDefault(); + }, + stopPropagation = function () { + this.cancelBubble = true; + }, + stopTouch = function () { + return this.originalEvent.stopPropagation(); + }, + addEvent = (function () { + if (g.doc.addEventListener) { + return function (obj, type, fn, element) { + var realName = supportsTouch && touchMap[type] ? touchMap[type] : type, + f = function (e) { + var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, + scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft, + x = e.clientX + scrollX, + y = e.clientY + scrollY; + if (supportsTouch && touchMap[has](type)) { + for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) { + if (e.targetTouches[i].target == obj) { + var olde = e; + e = e.targetTouches[i]; + e.originalEvent = olde; + e.preventDefault = preventTouch; + e.stopPropagation = stopTouch; + break; + } + } + } + return fn.call(element, e, x, y); + }; + obj.addEventListener(realName, f, false); + return function () { + obj.removeEventListener(realName, f, false); + return true; + }; + }; + } else if (g.doc.attachEvent) { + return function (obj, type, fn, element) { + var f = function (e) { + e = e || g.win.event; + var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, + scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft, + x = e.clientX + scrollX, + y = e.clientY + scrollY; + e.preventDefault = e.preventDefault || preventDefault; + e.stopPropagation = e.stopPropagation || stopPropagation; + return fn.call(element, e, x, y); + }; + obj.attachEvent("on" + type, f); + var detacher = function () { + obj.detachEvent("on" + type, f); + return true; + }; + return detacher; + }; + } + })(), + drag = [], + dragMove = function (e) { + var x = e.clientX, + y = e.clientY, + scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, + scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft, + dragi, + j = drag.length; + while (j--) { + dragi = drag[j]; + if (supportsTouch) { + var i = e.touches.length, + touch; + while (i--) { + touch = e.touches[i]; + if (touch.identifier == dragi.el._drag.id) { + x = touch.clientX; + y = touch.clientY; + (e.originalEvent ? e.originalEvent : e).preventDefault(); + break; + } + } + } else { + e.preventDefault(); + } + var node = dragi.el.node, + o, + next = node.nextSibling, + parent = node.parentNode, + display = node.style.display; + g.win.opera && parent.removeChild(node); + node.style.display = "none"; + o = dragi.el.paper.getElementByPoint(x, y); + node.style.display = display; + g.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node)); + o && eve("drag.over." + dragi.el.id, dragi.el, o); + x += scrollX; + y += scrollY; + eve("drag.move." + dragi.el.id, dragi.move_scope || dragi.el, x - dragi.el._drag.x, y - dragi.el._drag.y, x, y, e); + } + }, + dragUp = function (e) { + R.unmousemove(dragMove).unmouseup(dragUp); + var i = drag.length, + dragi; + while (i--) { + dragi = drag[i]; + dragi.el._drag = {}; + eve("drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e); + } + drag = []; + }, + + elproto = R.el = {}; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for (var i = events.length; i--;) { + (function (eventName) { + R[eventName] = elproto[eventName] = function (fn, scope) { + if (R.is(fn, "function")) { + this.events = this.events || []; + this.events.push({name: eventName, f: fn, unbind: addEvent(this.shape || this.node || g.doc, eventName, fn, scope || this)}); + } + return this; + }; + R["un" + eventName] = elproto["un" + eventName] = function (fn) { + var events = this.events, + l = events.length; + while (l--) if (events[l].name == eventName && events[l].f == fn) { + events[l].unbind(); + events.splice(l, 1); + !events.length && delete this.events; + return this; + } + return this; + }; + })(events[i]); + } + + + elproto.data = function (key, value) { + var data = eldata[this.id] = eldata[this.id] || {}; + if (arguments.length == 1) { + if (R.is(key, "object")) { + for (var i in key) if (key[has](i)) { + this.data(i, key[i]); + } + return this; + } + eve("data.get." + this.id, this, data[key], key); + return data[key]; + } + data[key] = value; + eve("data.set." + this.id, this, value, key); + return this; + }; + + elproto.removeData = function (key) { + if (key == null) { + eldata[this.id] = {}; + } else { + eldata[this.id] && delete eldata[this.id][key]; + } + 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(); + var scrollY = g.doc.documentElement.scrollTop || g.doc.body.scrollTop, + scrollX = g.doc.documentElement.scrollLeft || g.doc.body.scrollLeft; + this._drag.x = e.clientX + scrollX; + this._drag.y = e.clientY + scrollY; + this._drag.id = e.identifier; + !drag.length && R.mousemove(dragMove).mouseup(dragUp); + drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope}); + onstart && eve.on("drag.start." + this.id, onstart); + onmove && eve.on("drag.move." + this.id, onmove); + onend && eve.on("drag.end." + this.id, onend); + eve("drag.start." + this.id, start_scope || move_scope || this, e.clientX + scrollX, e.clientY + scrollY, e); + } + this._drag = {}; + draggable.push({el: this, start: start}); + this.mousedown(start); + return this; + }; + + elproto.onDragOver = function (f) { + f ? eve.on("drag.over." + this.id, f) : eve.unbind("drag.over." + this.id); + }; + + elproto.undrag = function () { + var i = draggable.length; + while (i--) if (draggable[i].el == this) { + this.unmousedown(draggable[i].start); + draggable.splice(i, 1); + eve.unbind("drag.*." + this.id); + } + !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(), + doc = elem.ownerDocument, + body = doc.body, + docElem = doc.documentElement, + clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0, + top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop, + left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft; + return { + y: top, + x: left + }; + }; + + paperproto.getElementByPoint = function (x, y) { + var paper = this, + svg = paper.canvas, + target = g.doc.elementFromPoint(x, y); + if (g.win.opera && target.tagName == "svg") { + var so = getOffset(svg), + sr = svg.createSVGRect(); + sr.x = x - so.x; + sr.y = y - so.y; + sr.width = sr.height = 1; + var hits = svg.getIntersectionList(sr, null); + if (hits.length) { + target = hits[hits.length - 1]; + } + } + if (!target) { + return null; + } + while (target.parentNode && target != svg.parentNode && !target.raphael) { + target = target.parentNode; + } + target == paper.canvas.parentNode && (target = svg); + target = target && target.raphael ? paper.getById(target.raphaelid) : null; + return target; + }; + + paperproto.getById = function (id) { + var bot = this.bottom; + while (bot) { + if (bot.id == id) { + return bot; + } + bot = bot.next; + } + return null; + }; + + paperproto.forEach = function (callback, thisArg) { + var bot = this.bottom; + while (bot) { + if (callback.call(thisArg, bot) === false) { + return this; + } + bot = bot.next; + } + return this; + }; + function x_y() { + return this.x + S + this.y; + } + function x_y_w_h() { + return this.x + S + this.y + S + this.width + " \xd7 " + this.height; + } + + elproto.getBBox = function (isWithoutTransform) { + if (this.removed) { + return {}; + } + var _ = this._; + if (isWithoutTransform) { + if (_.dirty || !_.bboxwt) { + this.realPath = getPath[this.type](this); + _.bboxwt = pathDimensions(this.realPath); + _.bboxwt.toString = x_y_w_h; + _.dirty = 0; + } + return _.bboxwt; + } + if (_.dirty || _.dirtyT || !_.bbox) { + if (_.dirty || !this.realPath) { + _.bboxwt = 0; + this.realPath = getPath[this.type](this); + } + _.bbox = pathDimensions(mapPath(this.realPath, this.matrix)); + _.bbox.toString = x_y_w_h; + _.dirty = _.dirtyT = 0; + } + return _.bbox; + }; + + elproto.clone = function () { + if (this.removed) { + return null; + } + var out = this.paper[this.type]().attr(this.attr()); + this.__set__ && this.__set__.push(out); + return out; + }; + + elproto.glow = function (glow) { + if (this.type == "text") { + return null; + } + glow = glow || {}; + var s = { + width: (glow.width || 10) + (+this.attr("stroke-width") || 1), + fill: glow.fill || false, + opacity: glow.opacity || .5, + offsetx: glow.offsetx || 0, + offsety: glow.offsety || 0, + color: glow.color || "#000" + }, + c = s.width / 2, + r = this.paper, + out = r.set(), + path = this.realPath || getPath[this.type](this); + path = this.matrix ? mapPath(path, this.matrix) : path; + for (var i = 1; i < c + 1; i++) { + out.push(r.path(path).attr({ + stroke: s.color, + fill: s.fill ? s.color : "none", + "stroke-linejoin": "round", + "stroke-linecap": "round", + "stroke-width": +(s.width / c * i).toFixed(3), + opacity: +(s.opacity / c).toFixed(3) + })); + } + return out.insertBefore(this).translate(s.offsetx, s.offsety); + }; + var curveslengths = {}, + getPointAtSegmentLength = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) { + var len = 0, + precision = 100, + name = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y].join(), + cache = curveslengths[name], + old, dot; + !cache && (curveslengths[name] = cache = {data: []}); + cache.timer && clearTimeout(cache.timer); + cache.timer = setTimeout(function () {delete curveslengths[name];}, 2e3); + if (length != null && !cache.precision) { + var total = getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y); + cache.precision = ~~total * 10; + cache.data = []; + } + precision = cache.precision || precision; + for (var i = 0; i < precision + 1; i++) { + if (cache.data[i * precision]) { + dot = cache.data[i * precision]; + } else { + dot = R.findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, i / precision); + cache.data[i * precision] = dot; + } + i && (len += pow(pow(old.x - dot.x, 2) + pow(old.y - dot.y, 2), .5)); + if (length != null && len >= length) { + return dot; + } + old = dot; + } + if (length == null) { + return len; + } + }, + getLengthFactory = function (istotal, subpath) { + return function (path, length, onlystart) { + path = path2curve(path); + var x, y, p, l, sp = "", subpaths = {}, point, + len = 0; + for (var i = 0, ii = path.length; i < ii; i++) { + p = path[i]; + if (p[0] == "M") { + x = +p[1]; + y = +p[2]; + } else { + l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]); + if (len + l > length) { + if (subpath && !subpaths.start) { + point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); + sp += ["C" + point.start.x, point.start.y, point.m.x, point.m.y, point.x, point.y]; + if (onlystart) {return sp;} + subpaths.start = sp; + sp = ["M" + point.x, point.y + "C" + point.n.x, point.n.y, point.end.x, point.end.y, p[5], p[6]].join(); + len += l; + x = +p[5]; + y = +p[6]; + continue; + } + if (!istotal && !subpath) { + point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len); + return {x: point.x, y: point.y, alpha: point.alpha}; + } + } + len += l; + x = +p[5]; + y = +p[6]; + } + sp += p.shift() + p; + } + subpaths.end = sp; + point = istotal ? len : subpath ? subpaths : R.findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1); + point.alpha && (point = {x: point.x, y: point.y, alpha: point.alpha}); + return point; + }; + }; + 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; + } + 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) { + return this.node.getTotalLength(); + } + 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; + }, + "<": function (n) { + return pow(n, 1.7); + }, + ">": function (n) { + return pow(n, .48); + }, + "<>": function (n) { + var q = .48 - n / 1.04, + Q = math.sqrt(.1734 + q * q), + x = Q - q, + X = pow(abs(x), 1 / 3) * (x < 0 ? -1 : 1), + y = -Q - q, + Y = pow(abs(y), 1 / 3) * (y < 0 ? -1 : 1), + t = X + Y + .5; + return (1 - t) * 3 * t * t + t * t * t; + }, + backIn: function (n) { + var s = 1.70158; + return n * n * ((s + 1) * n - s); + }, + backOut: function (n) { + n = n - 1; + var s = 1.70158; + return n * n * ((s + 1) * n + s) + 1; + }, + elastic: function (n) { + if (n == !!n) { + return n; + } + return pow(2, -10 * n) * math.sin((n - .075) * (2 * PI) / .3) + 1; + }, + bounce: function (n) { + var s = 7.5625, + p = 2.75, + l; + if (n < (1 / p)) { + l = s * n * n; + } else { + if (n < (2 / p)) { + n -= (1.5 / p); + l = s * n * n + .75; + } else { + if (n < (2.5 / p)) { + n -= (2.25 / p); + l = s * n * n + .9375; + } else { + n -= (2.625 / p); + l = s * n * n + .984375; + } + } + } + return l; + } + }; + ef.easeIn = ef["ease-in"] = ef["<"]; + ef.easeOut = ef["ease-out"] = ef[">"]; + ef.easeInOut = ef["ease-in-out"] = ef["<>"]; + ef["back-in"] = ef.backIn; + ef["back-out"] = ef.backOut; + + var animationElements = [], + requestAnimFrame = window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function (callback) { + setTimeout(callback, 16); + }, + animation = function () { + var Now = +new Date, + l = 0; + for (; l < animationElements.length; l++) { + var e = animationElements[l]; + if (e.el.removed || e.paused) { + continue; + } + var time = Now - e.start, + ms = e.ms, + easing = e.easing, + from = e.from, + diff = e.diff, + to = e.to, + t = e.t, + that = e.el, + set = {}, + now, + init = {}, + key; + if (e.initstatus) { + time = (e.initstatus * e.anim.top - e.prev) / (e.percent - e.prev) * ms; + e.status = e.initstatus; + delete e.initstatus; + e.stop && animationElements.splice(l--, 1); + } else { + e.status = (e.prev + (e.percent - e.prev) * (time / ms)) / e.anim.top; + } + if (time < 0) { + continue; + } + if (time < ms) { + var pos = easing(time / ms); + for (var attr in from) if (from[has](attr)) { + switch (availableAnimAttrs[attr]) { + case nu: + now = +from[attr] + pos * ms * diff[attr]; + break; + case "colour": + now = "rgb(" + [ + upto255(round(from[attr].r + pos * ms * diff[attr].r)), + upto255(round(from[attr].g + pos * ms * diff[attr].g)), + upto255(round(from[attr].b + pos * ms * diff[attr].b)) + ].join(",") + ")"; + break; + case "path": + now = []; + for (var i = 0, ii = from[attr].length; i < ii; i++) { + now[i] = [from[attr][i][0]]; + for (var j = 1, jj = from[attr][i].length; j < jj; j++) { + now[i][j] = +from[attr][i][j] + pos * ms * diff[attr][i][j]; + } + now[i] = now[i].join(S); + } + now = now.join(S); + break; + case "transform": + if (diff[attr].real) { + now = []; + for (i = 0, ii = from[attr].length; i < ii; i++) { + now[i] = [from[attr][i][0]]; + for (j = 1, jj = from[attr][i].length; j < jj; j++) { + now[i][j] = from[attr][i][j] + pos * ms * diff[attr][i][j]; + } + } + } else { + var get = function (i) { + return +from[attr][i] + pos * ms * diff[attr][i]; + }; + // now = [["r", get(2), 0, 0], ["t", get(3), get(4)], ["s", get(0), get(1), 0, 0]]; + now = [["m", get(0), get(1), get(2), get(3), get(4), get(5)]]; + } + break; + case "csv": + if (attr == "clip-rect") { + now = []; + i = 4; + while (i--) { + now[i] = +from[attr][i] + pos * ms * diff[attr][i]; + } + } + break; + default: + var from2 = [][concat](from[attr]); + now = []; + i = that.paper.customAttributes[attr].length; + while (i--) { + now[i] = +from2[i] + pos * ms * diff[attr][i]; + } + break; + } + set[attr] = now; + } + that.attr(set); + (function (id, that, anim) { + setTimeout(function () { + eve("anim.frame." + id, that, anim); + }); + })(that.id, that, e.anim); + } else { + (function(f, el, a) { + setTimeout(function() { + eve("anim.frame." + el.id, el, a); + eve("anim.finish." + el.id, el, a); + R.is(f, "function") && f.call(el); + }); + })(e.callback, that, e.anim); + that.attr(to); + animationElements.splice(l--, 1); + if (e.repeat > 1 && !e.next) { + for (key in to) if (to[has](key)) { + init[key] = e.totalOrigin[key]; + } + e.el.attr(init); + runAnimation(e.anim, e.el, e.anim.percents[0], null, e.totalOrigin, e.repeat - 1); + } + if (e.next && !e.stop) { + runAnimation(e.anim, e.el, e.next, null, e.totalOrigin, e.repeat); + } + } + } + R.svg && that && that.paper && that.paper.safari(); + animationElements.length && requestAnimFrame(animation); + }, + upto255 = function (color) { + return color > 255 ? 255 : color < 0 ? 0 : color; + }; + + elproto.animateWith = function (element, anim, params, ms, easing, callback) { + 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); + }; + function CubicBezierAtTime(t, p1x, p1y, p2x, p2y, duration) { + var cx = 3 * p1x, + bx = 3 * (p2x - p1x) - cx, + ax = 1 - cx - bx, + cy = 3 * p1y, + by = 3 * (p2y - p1y) - cy, + ay = 1 - cy - by; + function sampleCurveX(t) { + return ((ax * t + bx) * t + cx) * t; + } + function solve(x, epsilon) { + var t = solveCurveX(x, epsilon); + return ((ay * t + by) * t + cy) * t; + } + function solveCurveX(x, epsilon) { + var t0, t1, t2, x2, d2, i; + for(t2 = x, i = 0; i < 8; i++) { + x2 = sampleCurveX(t2) - x; + if (abs(x2) < epsilon) { + return t2; + } + d2 = (3 * ax * t2 + 2 * bx) * t2 + cx; + if (abs(d2) < 1e-6) { + break; + } + t2 = t2 - x2 / d2; + } + t0 = 0; + t1 = 1; + t2 = x; + if (t2 < t0) { + return t0; + } + if (t2 > t1) { + return t1; + } + while (t0 < t1) { + x2 = sampleCurveX(t2); + if (abs(x2 - x) < epsilon) { + return t2; + } + if (x > x2) { + t0 = t2; + } else { + t1 = t2; + } + t2 = (t1 - t0) / 2 + t0; + } + return t2; + } + return solve(t, 1 / (200 * duration)); + } + elproto.onAnimation = function (f) { + f ? eve.on("anim.frame." + this.id, f) : eve.unbind("anim.frame." + this.id); + return this; + }; + function Animation(anim, ms) { + var percents = [], + newAnim = {}; + this.ms = ms; + this.times = 1; + if (anim) { + for (var attr in anim) if (anim[has](attr)) { + newAnim[toFloat(attr)] = anim[attr]; + percents.push(toFloat(attr)); + } + percents.sort(sortByNumber); + } + this.anim = newAnim; + 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) { + var a = new Animation(this.anim, this.ms); + a.del = this.del; + a.times = math.floor(mmax(times, 0)) || 1; + return a; + }; + function runAnimation(anim, element, percent, status, totalOrigin, times) { + percent = toFloat(percent); + var params, + isInAnim, + isInAnimSet, + percents = [], + next, + prev, + timestamp, + ms = anim.ms, + from = {}, + to = {}, + diff = {}; + if (status) { + for (i = 0, ii = animationElements.length; i < ii; i++) { + var e = animationElements[i]; + if (e.el.id == element.id && e.anim == anim) { + if (e.percent != percent) { + animationElements.splice(i, 1); + isInAnimSet = 1; + } else { + isInAnim = e; + } + element.attr(e.totalOrigin); + break; + } + } + } else { + status = +to; // NaN + } + for (var i = 0, ii = anim.percents.length; i < ii; i++) { + if (anim.percents[i] == percent || anim.percents[i] > status * anim.top) { + percent = anim.percents[i]; + prev = anim.percents[i - 1] || 0; + ms = ms / anim.top * (percent - prev); + next = anim.percents[i + 1]; + params = anim.anim[percent]; + break; + } else if (status) { + element.attr(anim.anim[anim.percents[i]]); + } + } + if (!params) { + return; + } + if (!isInAnim) { + for (var attr in params) if (params[has](attr)) { + if (availableAnimAttrs[has](attr) || element.paper.customAttributes[has](attr)) { + from[attr] = element.attr(attr); + (from[attr] == null) && (from[attr] = availableAttrs[attr]); + to[attr] = params[attr]; + switch (availableAnimAttrs[attr]) { + case nu: + diff[attr] = (to[attr] - from[attr]) / ms; + break; + case "colour": + from[attr] = R.getRGB(from[attr]); + var toColour = R.getRGB(to[attr]); + diff[attr] = { + r: (toColour.r - from[attr].r) / ms, + g: (toColour.g - from[attr].g) / ms, + b: (toColour.b - from[attr].b) / ms + }; + break; + case "path": + var pathes = path2curve(from[attr], to[attr]), + toPath = pathes[1]; + from[attr] = pathes[0]; + diff[attr] = []; + for (i = 0, ii = from[attr].length; i < ii; i++) { + diff[attr][i] = [0]; + for (var j = 1, jj = from[attr][i].length; j < jj; j++) { + diff[attr][i][j] = (toPath[i][j] - from[attr][i][j]) / ms; + } + } + break; + case "transform": + var _ = element._, + eq = equaliseTransform(_[attr], to[attr]); + if (eq) { + from[attr] = eq.from; + to[attr] = eq.to; + diff[attr] = []; + diff[attr].real = true; + for (i = 0, ii = from[attr].length; i < ii; i++) { + diff[attr][i] = [from[attr][i][0]]; + for (j = 1, jj = from[attr][i].length; j < jj; j++) { + diff[attr][i][j] = (to[attr][i][j] - from[attr][i][j]) / ms; + } + } + } else { + var m = (element.matrix || new Matrix), + to2 = { + _: {transform: _.transform}, + getBBox: function () { + return element.getBBox(1); + } + }; + from[attr] = [ + m.a, + m.b, + m.c, + m.d, + m.e, + m.f + ]; + extractTransform(to2, to[attr]); + to[attr] = to2._.transform; + diff[attr] = [ + (to2.matrix.a - m.a) / ms, + (to2.matrix.b - m.b) / ms, + (to2.matrix.c - m.c) / ms, + (to2.matrix.d - m.d) / ms, + (to2.matrix.e - m.e) / ms, + (to2.matrix.e - m.f) / ms + ]; + // from[attr] = [_.sx, _.sy, _.deg, _.dx, _.dy]; + // var to2 = {_:{}, getBBox: function () { return element.getBBox(); }}; + // extractTransform(to2, to[attr]); + // diff[attr] = [ + // (to2._.sx - _.sx) / ms, + // (to2._.sy - _.sy) / ms, + // (to2._.deg - _.deg) / ms, + // (to2._.dx - _.dx) / ms, + // (to2._.dy - _.dy) / ms + // ]; + } + break; + case "csv": + var values = Str(params[attr])[split](separator), + from2 = Str(from[attr])[split](separator); + if (attr == "clip-rect") { + from[attr] = from2; + diff[attr] = []; + i = from2.length; + while (i--) { + diff[attr][i] = (values[i] - from[attr][i]) / ms; + } + } + to[attr] = values; + break; + default: + values = [][concat](params[attr]); + from2 = [][concat](from[attr]); + diff[attr] = []; + i = element.paper.customAttributes[attr].length; + while (i--) { + diff[attr][i] = ((values[i] || 0) - (from2[i] || 0)) / ms; + } + break; + } + } + } + var easing = params.easing, + easyeasy = R.easing_formulas[easing]; + if (!easyeasy) { + easyeasy = Str(easing).match(bezierrg); + if (easyeasy && easyeasy.length == 5) { + var curve = easyeasy; + easyeasy = function (t) { + return CubicBezierAtTime(t, +curve[1], +curve[2], +curve[3], +curve[4], ms); + }; + } else { + easyeasy = pipe; + } + } + timestamp = params.start || anim.start || +new Date; + e = { + anim: anim, + percent: percent, + timestamp: timestamp, + start: timestamp + (anim.del || 0), + status: 0, + initstatus: status || 0, + stop: false, + ms: ms, + easing: easyeasy, + from: from, + diff: diff, + to: to, + el: element, + callback: params.callback, + prev: prev, + next: next, + repeat: times || anim.times, + origin: element.attr(), + totalOrigin: totalOrigin + }; + animationElements.push(e); + if (status && !isInAnim && !isInAnimSet) { + e.stop = true; + e.start = new Date - ms * status; + if (animationElements.length == 1) { + return animation(); + } + } + if (isInAnimSet) { + e.start = new Date - e.ms * status; + } + animationElements.length == 1 && requestAnimFrame(animation); + } else { + isInAnim.initstatus = status; + isInAnim.start = new Date - isInAnim.ms * status; + } + eve("anim.start." + element.id, element, anim); + } + + R.animation = function (params, ms, easing, callback) { + if (params instanceof Animation) { + return params; + } + if (R.is(easing, "function") || !easing) { + callback = callback || easing || null; + easing = null; + } + params = Object(params); + ms = +ms || 0; + var p = {}, + json, + attr; + for (attr in params) if (params[has](attr) && toFloat(attr) != attr && toFloat(attr) + "%" != attr) { + json = true; + p[attr] = params[attr]; + } + if (!json) { + return new Animation(params, ms); + } else { + easing && (p.easing = easing); + callback && (p.callback = callback); + return new Animation({100: p}, ms); + } + }; + + elproto.animate = function (params, ms, easing, callback) { + var element = this; + if (element.removed) { + callback && callback.call(element); + return element; + } + var anim = params instanceof Animation ? params : R.animation(params, ms, easing, callback); + 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, + len, + e; + if (value != null) { + runAnimation(anim, this, -1, mmin(value, 1)); + return this; + } else { + len = animationElements.length; + for (; i < len; i++) { + e = animationElements[i]; + if (e.el.id == this.id && (!anim || e.anim == anim)) { + if (anim) { + return e.status; + } + out.push({ + anim: e.anim, + status: e.status + }); + } + } + if (anim) { + return 0; + } + 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("anim.pause." + this.id, this, animationElements[i].anim) !== false) { + animationElements[i].paused = true; + } + } + 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]; + if (eve("anim.resume." + this.id, this, e.anim) !== false) { + delete e.paused; + this.status(e.anim, e.status); + } + } + 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("anim.stop." + this.id, this, animationElements[i].anim) !== false) { + animationElements.splice(i--, 1); + } + } + return this; + }; + elproto.toString = function () { + return "Rapha\xebl\u2019s object"; + }; + + // Set + var Set = function (items) { + this.items = []; + this.length = 0; + this.type = "set"; + if (items) { + for (var i = 0, ii = items.length; i < ii; i++) { + if (items[i] && (items[i].constructor == elproto.constructor || items[i].constructor == Set)) { + this[this.items.length] = this.items[this.items.length] = items[i]; + this.length++; + } + } + } + }, + setproto = Set.prototype; + + setproto.push = function () { + var item, + len; + for (var i = 0, ii = arguments.length; i < ii; i++) { + item = arguments[i]; + if (item && (item.constructor == elproto.constructor || item.constructor == Set)) { + len = this.items.length; + this[len] = this.items[len] = item; + this.length++; + } + } + 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) { + return this; + } + } + return this; + }; + for (var method in elproto) if (elproto[has](method)) { + setproto[method] = (function (methodname) { + return function () { + var arg = arguments; + return this.forEach(function (el) { + el[methodname][apply](el, arg); + }); + }; + })(method); + } + setproto.attr = function (name, value) { + if (name && R.is(name, array) && R.is(name[0], "object")) { + for (var j = 0, jj = name.length; j < jj; j++) { + this.items[j].attr(name[j]); + } + } else { + for (var i = 0, ii = this.items.length; i < ii; i++) { + this.items[i].attr(name, value); + } + } + 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)); + var tail = [], + todel = [], + args = [], + i; + for (i = 2; i < arguments.length; i++) { + args.push(arguments[i]); + } + for (i = 0; i < count; i++) { + todel.push(this[index + i]); + } + for (; i < this.length - index; i++) { + tail.push(this[index + i]); + } + var arglen = args.length; + for (i = 0; i < arglen + tail.length; i++) { + this.items[index + i] = this[index + i] = i < arglen ? args[i] : tail[i - arglen]; + } + i = this.items.length = this.length -= count - arglen; + while (this[i]) { + delete this[i++]; + } + 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); + return true; + } + }; + setproto.animate = function (params, ms, easing, callback) { + (R.is(easing, "function") || !easing) && (callback = easing || null); + var len = this.items.length, + i = len, + item, + set = this, + collector; + if (!len) { + return this; + } + callback && (collector = function () { + !--len && callback.call(set); + }); + easing = R.is(easing, string) ? easing : collector; + var anim = R.animation(params, ms, easing, collector); + item = this.items[--i].animate(anim); + while (i--) { + this.items[i] && !this.items[i].removed && this.items[i].animateWith(item, anim); + } + return this; + }; + setproto.insertAfter = function (el) { + var i = this.items.length; + while (i--) { + this.items[i].insertAfter(el); + } + return this; + }; + setproto.getBBox = function () { + var x = [], + y = [], + w = [], + h = []; + for (var i = this.items.length; i--;) if (!this.items[i].removed) { + var box = this.items[i].getBBox(); + x.push(box.x); + y.push(box.y); + w.push(box.x + box.width); + h.push(box.y + box.height); + } + x = mmin[apply](0, x); + y = mmin[apply](0, y); + return { + x: x, + y: y, + width: mmax[apply](0, w) - x, + height: mmax[apply](0, h) - y + }; + }; + setproto.clone = function (s) { + s = new Set; + for (var i = 0, ii = this.items.length; i < ii; i++) { + s.push(this.items[i].clone()); + } + return s; + }; + setproto.toString = function () { + return "Rapha\xebl\u2018s set"; + }; + + + R.registerFont = function (font) { + if (!font.face) { + return font; + } + this.fonts = this.fonts || {}; + var fontcopy = { + w: font.w, + face: {}, + glyphs: {} + }, + family = font.face["font-family"]; + for (var prop in font.face) if (font.face[has](prop)) { + fontcopy.face[prop] = font.face[prop]; + } + if (this.fonts[family]) { + this.fonts[family].push(fontcopy); + } else { + this.fonts[family] = [fontcopy]; + } + if (!font.svg) { + fontcopy.face["units-per-em"] = toInt(font.face["units-per-em"], 10); + for (var glyph in font.glyphs) if (font.glyphs[has](glyph)) { + var path = font.glyphs[glyph]; + fontcopy.glyphs[glyph] = { + w: path.w, + k: {}, + d: path.d && "M" + path.d.replace(/[mlcxtrv]/g, function (command) { + return {l: "L", c: "C", x: "z", t: "m", r: "l", v: "c"}[command] || "M"; + }) + "z" + }; + if (path.k) { + for (var k in path.k) if (path[has](k)) { + fontcopy.glyphs[glyph].k[k] = path.k[k]; + } + } + } + } + return font; + }; + + paperproto.getFont = function (family, weight, style, stretch) { + stretch = stretch || "normal"; + style = style || "normal"; + weight = +weight || {normal: 400, bold: 700, lighter: 300, bolder: 800}[weight] || 400; + if (!R.fonts) { + return; + } + var font = R.fonts[family]; + if (!font) { + var name = new RegExp("(^|\\s)" + family.replace(/[^\w\d\s+!~.:_-]/g, E) + "(\\s|$)", "i"); + for (var fontName in R.fonts) if (R.fonts[has](fontName)) { + if (name.test(fontName)) { + font = R.fonts[fontName]; + break; + } + } + } + var thefont; + if (font) { + for (var i = 0, ii = font.length; i < ii; i++) { + thefont = font[i]; + if (thefont.face["font-weight"] == weight && (thefont.face["font-style"] == style || !thefont.face["font-style"]) && thefont.face["font-stretch"] == stretch) { + break; + } + } + } + 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); + var out = this.set(), + letters = Str(string)[split](E), + shift = 0, + path = E, + scale; + R.is(font, string) && (font = this.getFont(font)); + if (font) { + scale = (size || 16) / font.face["units-per-em"]; + var bb = font.face.bbox[split](separator), + top = +bb[0], + height = +bb[1] + (origin == "baseline" ? bb[3] - bb[1] + (+font.face.descent) : (bb[3] - bb[1]) / 2); + for (var i = 0, ii = letters.length; i < ii; i++) { + var prev = i && font.glyphs[letters[i - 1]] || {}, + curr = font.glyphs[letters[i]]; + shift += i ? (prev.w || font.w) + (prev.k && prev.k[letters[i]] || 0) + (font.w * letter_spacing) : 0; + curr && curr.d && out.push(this.path(curr.d).attr({ + fill: "#000", + stroke: "none", + transform: [["t", shift * scale, 0]] + })); + } + out.transform(["...s", scale, scale, top, height, "t", (x - top) / scale, (y - height) / scale]); + } + return out; + }; + + + paperproto.add = function (json) { + if (R.is(json, "array")) { + var res = this.set(), + i = 0, + ii = json.length, + j; + for (; i < ii; i++) { + j = json[i] || {}; + elements[has](j.type) && res.push(this[j.type]().attr(j)); + } + } + 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) { + return args[++i] == null ? E : args[i]; + })); + return token || E; + }; + + R.fullfill = (function () { + var tokenRegex = /\{([^\}]+)\}/g, + objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties + replacer = function (all, key, obj) { + var res = obj; + key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) { + name = name || quotedName; + if (res) { + if (name in res) { + res = res[name]; + } + typeof res == "function" && isFunc && (res = res()); + } + }); + res = (res == null || res == obj ? all : res) + ""; + return res; + }; + return function (str, obj) { + return String(str).replace(tokenRegex, function (all, key) { + return replacer(all, key, obj); + }); + }; + })(); + + 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) { + if (doc.readyState == null && doc.addEventListener){ + doc.addEventListener(loaded, f = function () { + doc.removeEventListener(loaded, f, false); + doc.readyState = "complete"; + }, false); + doc.readyState = "loading"; + } + function isLoaded() { + (/in/).test(doc.readyState) ? setTimeout(isLoaded, 9) : R.eve("DOMload"); + } + isLoaded(); + })(document, "DOMContentLoaded"); + + oldRaphael.was ? (g.win.Raphael = R) : (Raphael = R); + + eve.on("DOMload", function () { + loaded = true; + }); +})(); + + +// ┌─────────────────────────────────────────────────────────────────────┐ \\ +// │ Raphaël - JavaScript Vector Library │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ SVG Module │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ +// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ +// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ +// └─────────────────────────────────────────────────────────────────────┘ \\ +window.Raphael.svg && function (R) { + var has = "hasOwnProperty", + Str = String, + toFloat = parseFloat, + toInt = parseInt, + math = Math, + mmax = math.max, + abs = math.abs, + pow = math.pow, + separator = /[, ]+/, + eve = R.eve, + E = "", + S = " "; + var xlink = "http://www.w3.org/1999/xlink", + markers = { + block: "M5,0 0,2.5 5,5z", + classic: "M5,0 0,2.5 5,5 3.5,3 3.5,2z", + diamond: "M2.5,0 5,2.5 2.5,5 0,2.5z", + open: "M6,1 1,3.5 6,6", + oval: "M2.5,0A2.5,2.5,0,0,1,2.5,5 2.5,2.5,0,0,1,2.5,0z" + }, + markerCounter = {}; + R.toString = function () { + return "Your browser supports SVG.\nYou are running Rapha\xebl " + this.version; + }; + var $ = function (el, attr) { + if (attr) { + if (typeof el == "string") { + el = $(el); + } + for (var key in attr) if (attr[has](key)) { + if (key.substring(0, 6) == "xlink:") { + el.setAttributeNS(xlink, key.substring(6), Str(attr[key])); + } else { + el.setAttribute(key, Str(attr[key])); + } + } + } else { + el = R._g.doc.createElementNS("http://www.w3.org/2000/svg", el); + el.style && (el.style.webkitTapHighlightColor = "rgba(0,0,0,0)"); + } + return el; + }, + addGradientFill = function (element, gradient) { + var type = "linear", + id = element.id + gradient, + fx = .5, fy = .5, + o = element.node, + SVG = element.paper, + s = o.style, + el = R._g.doc.getElementById(id); + if (!el) { + gradient = Str(gradient).replace(R._radial_gradient, function (all, _fx, _fy) { + type = "radial"; + if (_fx && _fy) { + fx = toFloat(_fx); + fy = toFloat(_fy); + var dir = ((fy > .5) * 2 - 1); + pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && + (fy = math.sqrt(.25 - pow(fx - .5, 2)) * dir + .5) && + fy != .5 && + (fy = fy.toFixed(5) - 1e-5 * dir); + } + return E; + }); + gradient = gradient.split(/\s*\-\s*/); + if (type == "linear") { + var angle = gradient.shift(); + angle = -toFloat(angle); + if (isNaN(angle)) { + return null; + } + var vector = [0, 0, math.cos(R.rad(angle)), math.sin(R.rad(angle))], + max = 1 / (mmax(abs(vector[2]), abs(vector[3])) || 1); + vector[2] *= max; + vector[3] *= max; + if (vector[2] < 0) { + vector[0] = -vector[2]; + vector[2] = 0; + } + if (vector[3] < 0) { + vector[1] = -vector[3]; + vector[3] = 0; + } + } + var dots = R._parseDots(gradient); + if (!dots) { + return null; + } + id = id.replace(/[\(\)\s,\xb0#]/g, "_"); + + if (element.gradient && id != element.gradient.id) { + SVG.defs.removeChild(element.gradient); + delete element.gradient; + } + + if (!element.gradient) { + el = $(type + "Gradient", {id: id}); + element.gradient = el; + $(el, type == "radial" ? { + fx: fx, + fy: fy + } : { + x1: vector[0], + y1: vector[1], + x2: vector[2], + y2: vector[3], + gradientTransform: element.matrix.invert() + }); + SVG.defs.appendChild(el); + for (var i = 0, ii = dots.length; i < ii; i++) { + el.appendChild($("stop", { + offset: dots[i].offset ? dots[i].offset : i ? "100%" : "0%", + "stop-color": dots[i].color || "#fff" + })); + } + } + } + $(o, { + fill: "url(#" + id + ")", + opacity: 1, + "fill-opacity": 1 + }); + s.fill = E; + s.opacity = 1; + s.fillOpacity = 1; + return 1; + }, + updatePosition = function (o) { + var bbox = o.getBBox(1); + $(o.pattern, {patternTransform: o.matrix.invert() + " translate(" + bbox.x + "," + bbox.y + ")"}); + }, + addArrow = function (o, value, isEnd) { + if (o.type == "path") { + var values = Str(value).toLowerCase().split("-"), + p = o.paper, + se = isEnd ? "end" : "start", + node = o.node, + attrs = o.attrs, + stroke = attrs["stroke-width"], + i = values.length, + type = "classic", + from, + to, + dx, + refX, + attr, + w = 3, + h = 3, + t = 5; + while (i--) { + switch (values[i]) { + case "block": + case "classic": + case "oval": + case "diamond": + case "open": + case "none": + type = values[i]; + break; + case "wide": h = 5; break; + case "narrow": h = 2; break; + case "long": w = 5; break; + case "short": w = 2; break; + } + } + if (type == "open") { + w += 2; + h += 2; + t += 2; + dx = 1; + refX = isEnd ? 4 : 1; + attr = { + fill: "none", + stroke: attrs.stroke + }; + } else { + refX = dx = w / 2; + attr = { + fill: attrs.stroke, + stroke: "none" + }; + } + if (o._.arrows) { + if (isEnd) { + o._.arrows.endPath && markerCounter[o._.arrows.endPath]--; + o._.arrows.endMarker && markerCounter[o._.arrows.endMarker]--; + } else { + o._.arrows.startPath && markerCounter[o._.arrows.startPath]--; + o._.arrows.startMarker && markerCounter[o._.arrows.startMarker]--; + } + } else { + o._.arrows = {}; + } + if (type != "none") { + var pathId = "raphael-marker-" + type, + markerId = "raphael-marker-" + se + type + w + h; + if (!R._g.doc.getElementById(pathId)) { + p.defs.appendChild($($("path"), { + "stroke-linecap": "round", + d: markers[type], + id: pathId + })); + markerCounter[pathId] = 1; + } else { + markerCounter[pathId]++; + } + var marker = R._g.doc.getElementById(markerId), + use; + if (!marker) { + marker = $($("marker"), { + id: markerId, + markerHeight: h, + markerWidth: w, + orient: "auto", + refX: refX, + refY: h / 2 + }); + use = $($("use"), { + "xlink:href": "#" + pathId, + transform: (isEnd ? " rotate(180 " + w / 2 + " " + h / 2 + ") " : S) + "scale(" + w / t + "," + h / t + ")", + "stroke-width": 1 / ((w / t + h / t) / 2) + }); + marker.appendChild(use); + p.defs.appendChild(marker); + markerCounter[markerId] = 1; + } else { + markerCounter[markerId]++; + use = marker.getElementsByTagName("use")[0]; + } + $(use, attr); + var delta = dx * (type != "diamond" && type != "oval"); + if (isEnd) { + from = o._.arrows.startdx * stroke || 0; + to = R.getTotalLength(attrs.path) - delta * stroke; + } else { + from = delta * stroke; + to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0); + } + attr = {}; + attr["marker-" + se] = "url(#" + markerId + ")"; + if (to || from) { + attr.d = Raphael.getSubpath(attrs.path, from, to); + } + $(node, attr); + o._.arrows[se + "Path"] = pathId; + o._.arrows[se + "Marker"] = markerId; + o._.arrows[se + "dx"] = delta; + o._.arrows[se + "Type"] = type; + o._.arrows[se + "String"] = value; + } else { + if (isEnd) { + from = o._.arrows.startdx * stroke || 0; + to = R.getTotalLength(attrs.path) - from; + } else { + from = 0; + to = R.getTotalLength(attrs.path) - (o._.arrows.enddx * stroke || 0); + } + o._.arrows[se + "Path"] && $(node, {d: Raphael.getSubpath(attrs.path, from, to)}); + delete o._.arrows[se + "Path"]; + delete o._.arrows[se + "Marker"]; + delete o._.arrows[se + "dx"]; + delete o._.arrows[se + "Type"]; + delete o._.arrows[se + "String"]; + } + for (attr in markerCounter) if (markerCounter[has](attr) && !markerCounter[attr]) { + var item = R._g.doc.getElementById(attr); + item && item.parentNode.removeChild(item); + } + } + }, + dasharray = { + "": [0], + "none": [0], + "-": [3, 1], + ".": [1, 1], + "-.": [3, 1, 1, 1], + "-..": [3, 1, 1, 1, 1, 1], + ". ": [1, 3], + "- ": [4, 3], + "--": [8, 3], + "- .": [4, 3, 1, 3], + "--.": [8, 3, 1, 3], + "--..": [8, 3, 1, 3, 1, 3] + }, + addDashes = function (o, value, params) { + value = dasharray[Str(value).toLowerCase()]; + if (value) { + var width = o.attrs["stroke-width"] || "1", + butt = {round: width, square: width, butt: 0}[o.attrs["stroke-linecap"] || params["stroke-linecap"]] || 0, + dashes = [], + i = value.length; + while (i--) { + dashes[i] = value[i] * width + ((i % 2) ? 1 : -1) * butt; + } + $(o.node, {"stroke-dasharray": dashes.join(",")}); + } + }, + setFillAndStroke = function (o, params) { + var node = o.node, + attrs = o.attrs, + vis = node.style.visibility; + node.style.visibility = "hidden"; + for (var att in params) { + if (params[has](att)) { + if (!R._availableAttrs[has](att)) { + continue; + } + var value = params[att]; + attrs[att] = value; + switch (att) { + case "blur": + o.blur(value); + break; + case "href": + case "title": + case "target": + var pn = node.parentNode; + if (pn.tagName.toLowerCase() != "a") { + var hl = $("a"); + pn.insertBefore(hl, node); + hl.appendChild(node); + pn = hl; + } + if (att == "target" && value == "blank") { + pn.setAttributeNS(xlink, "show", "new"); + } else { + pn.setAttributeNS(xlink, att, value); + } + break; + case "cursor": + node.style.cursor = value; + break; + case "transform": + o.transform(value); + break; + case "arrow-start": + addArrow(o, value); + break; + case "arrow-end": + addArrow(o, value, 1); + break; + case "clip-rect": + var rect = Str(value).split(separator); + if (rect.length == 4) { + o.clip && o.clip.parentNode.parentNode.removeChild(o.clip.parentNode); + var el = $("clipPath"), + rc = $("rect"); + el.id = R.createUUID(); + $(rc, { + x: rect[0], + y: rect[1], + width: rect[2], + height: rect[3] + }); + el.appendChild(rc); + o.paper.defs.appendChild(el); + $(node, {"clip-path": "url(#" + el.id + ")"}); + o.clip = rc; + } + if (!value) { + var path = node.getAttribute("clip-path"); + if (path) { + var clip = R._g.doc.getElementById(path.replace(/(^url\(#|\)$)/g, E)); + clip && clip.parentNode.removeChild(clip); + $(node, {"clip-path": E}); + delete o.clip; + } + } + break; + case "path": + if (o.type == "path") { + $(node, {d: value ? attrs.path = R._pathToAbsolute(value) : "M0,0"}); + o._.dirty = 1; + if (o._.arrows) { + "startString" in o._.arrows && addArrow(o, o._.arrows.startString); + "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); + } + } + break; + case "width": + node.setAttribute(att, value); + o._.dirty = 1; + if (attrs.fx) { + att = "x"; + value = attrs.x; + } else { + break; + } + case "x": + if (attrs.fx) { + value = -attrs.x - (attrs.width || 0); + } + case "rx": + if (att == "rx" && o.type == "rect") { + break; + } + case "cx": + node.setAttribute(att, value); + o.pattern && updatePosition(o); + o._.dirty = 1; + break; + case "height": + node.setAttribute(att, value); + o._.dirty = 1; + if (attrs.fy) { + att = "y"; + value = attrs.y; + } else { + break; + } + case "y": + if (attrs.fy) { + value = -attrs.y - (attrs.height || 0); + } + case "ry": + if (att == "ry" && o.type == "rect") { + break; + } + case "cy": + node.setAttribute(att, value); + o.pattern && updatePosition(o); + o._.dirty = 1; + break; + case "r": + if (o.type == "rect") { + $(node, {rx: value, ry: value}); + } else { + node.setAttribute(att, value); + } + o._.dirty = 1; + break; + case "src": + if (o.type == "image") { + node.setAttributeNS(xlink, "href", value); + } + break; + case "stroke-width": + if (o._.sx != 1 || o._.sy != 1) { + value /= mmax(abs(o._.sx), abs(o._.sy)) || 1; + } + if (o.paper._vbSize) { + value *= o.paper._vbSize; + } + node.setAttribute(att, value); + if (attrs["stroke-dasharray"]) { + addDashes(o, attrs["stroke-dasharray"], params); + } + if (o._.arrows) { + "startString" in o._.arrows && addArrow(o, o._.arrows.startString); + "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); + } + break; + case "stroke-dasharray": + addDashes(o, value, params); + break; + case "fill": + var isURL = Str(value).match(R._ISURL); + if (isURL) { + el = $("pattern"); + var ig = $("image"); + el.id = R.createUUID(); + $(el, {x: 0, y: 0, patternUnits: "userSpaceOnUse", height: 1, width: 1}); + $(ig, {x: 0, y: 0, "xlink:href": isURL[1]}); + el.appendChild(ig); + + (function (el) { + R._preload(isURL[1], function () { + var w = this.offsetWidth, + h = this.offsetHeight; + $(el, {width: w, height: h}); + $(ig, {width: w, height: h}); + o.paper.safari(); + }); + })(el); + o.paper.defs.appendChild(el); + node.style.fill = "url(#" + el.id + ")"; + $(node, {fill: "url(#" + el.id + ")"}); + o.pattern = el; + o.pattern && updatePosition(o); + break; + } + var clr = R.getRGB(value); + if (!clr.error) { + delete params.gradient; + delete attrs.gradient; + !R.is(attrs.opacity, "undefined") && + R.is(params.opacity, "undefined") && + $(node, {opacity: attrs.opacity}); + !R.is(attrs["fill-opacity"], "undefined") && + R.is(params["fill-opacity"], "undefined") && + $(node, {"fill-opacity": attrs["fill-opacity"]}); + } else if ((o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value)) { + if ("opacity" in attrs || "fill-opacity" in attrs) { + var gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E)); + if (gradient) { + var stops = gradient.getElementsByTagName("stop"); + $(stops[stops.length - 1], {"stop-opacity": ("opacity" in attrs ? attrs.opacity : 1) * ("fill-opacity" in attrs ? attrs["fill-opacity"] : 1)}); + } + } + attrs.gradient = value; + attrs.fill = "none"; + break; + } + clr[has]("opacity") && $(node, {"fill-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity}); + case "stroke": + clr = R.getRGB(value); + node.setAttribute(att, clr.hex); + att == "stroke" && clr[has]("opacity") && $(node, {"stroke-opacity": clr.opacity > 1 ? clr.opacity / 100 : clr.opacity}); + if (att == "stroke" && o._.arrows) { + "startString" in o._.arrows && addArrow(o, o._.arrows.startString); + "endString" in o._.arrows && addArrow(o, o._.arrows.endString, 1); + } + break; + case "gradient": + (o.type == "circle" || o.type == "ellipse" || Str(value).charAt() != "r") && addGradientFill(o, value); + break; + case "opacity": + if (attrs.gradient && !attrs[has]("stroke-opacity")) { + $(node, {"stroke-opacity": value > 1 ? value / 100 : value}); + } + // fall + case "fill-opacity": + if (attrs.gradient) { + gradient = R._g.doc.getElementById(node.getAttribute("fill").replace(/^url\(#|\)$/g, E)); + if (gradient) { + stops = gradient.getElementsByTagName("stop"); + $(stops[stops.length - 1], {"stop-opacity": value}); + } + break; + } + default: + att == "font-size" && (value = toInt(value, 10) + "px"); + var cssrule = att.replace(/(\-.)/g, function (w) { + return w.substring(1).toUpperCase(); + }); + node.style[cssrule] = value; + o._.dirty = 1; + node.setAttribute(att, value); + break; + } + } + } + + tuneText(o, params); + node.style.visibility = vis; + }, + leading = 1.2, + tuneText = function (el, params) { + if (el.type != "text" || !(params[has]("text") || params[has]("font") || params[has]("font-size") || params[has]("x") || params[has]("y"))) { + return; + } + var a = el.attrs, + node = el.node, + fontSize = node.firstChild ? toInt(R._g.doc.defaultView.getComputedStyle(node.firstChild, E).getPropertyValue("font-size"), 10) : 10; + + if (params[has]("text")) { + a.text = params.text; + while (node.firstChild) { + node.removeChild(node.firstChild); + } + var texts = Str(params.text).split("\n"), + tspans = [], + tspan; + for (var i = 0, ii = texts.length; i < ii; i++) { + tspan = $("tspan"); + i && $(tspan, {dy: fontSize * leading, x: a.x}); + tspan.appendChild(R._g.doc.createTextNode(texts[i])); + node.appendChild(tspan); + tspans[i] = tspan; + } + } else { + tspans = node.getElementsByTagName("tspan"); + for (i = 0, ii = tspans.length; i < ii; i++) if (i) { + $(tspans[i], {dy: fontSize * leading, x: a.x}); + } else { + $(tspans[0], {dy: 0}); + } + } + $(node, {x: a.x, y: a.y}); + el._.dirty = 1; + var bb = el._getBBox(), + dif = a.y - (bb.y + bb.height / 2); + dif && R.is(dif, "finite") && $(tspans[0], {dy: dif}); + }, + 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._ = { + transform: [], + sx: 1, + sy: 1, + deg: 0, + dx: 0, + dy: 0, + 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; + + Element.prototype = elproto; + elproto.constructor = Element; + + R._engine.path = function (pathString, SVG) { + var el = $("path"); + SVG.canvas && SVG.canvas.appendChild(el); + var p = new Element(el, SVG); + p.type = "path"; + setFillAndStroke(p, { + fill: "none", + stroke: "#000", + path: pathString + }); + return p; + }; + + elproto.rotate = function (deg, cx, cy) { + if (this.removed) { + return this; + } + deg = Str(deg).split(separator); + if (deg.length - 1) { + cx = toFloat(deg[1]); + cy = toFloat(deg[2]); + } + deg = toFloat(deg[0]); + (cy == null) && (cx = cy); + if (cx == null || cy == null) { + var bbox = this.getBBox(1); + cx = bbox.x + bbox.width / 2; + cy = bbox.y + bbox.height / 2; + } + this.transform(this._.transform.concat([["r", deg, cx, cy]])); + return this; + }; + + elproto.scale = function (sx, sy, cx, cy) { + if (this.removed) { + return this; + } + sx = Str(sx).split(separator); + if (sx.length - 1) { + sy = toFloat(sx[1]); + cx = toFloat(sx[2]); + cy = toFloat(sx[3]); + } + sx = toFloat(sx[0]); + (sy == null) && (sy = sx); + (cy == null) && (cx = cy); + if (cx == null || cy == null) { + var bbox = this.getBBox(1); + } + 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]])); + return this; + }; + + elproto.translate = function (dx, dy) { + if (this.removed) { + return this; + } + dx = Str(dx).split(separator); + if (dx.length - 1) { + dy = toFloat(dx[1]); + } + dx = toFloat(dx[0]) || 0; + dy = +dy || 0; + this.transform(this._.transform.concat([["t", dx, dy]])); + return this; + }; + + elproto.transform = function (tstr) { + var _ = this._; + if (tstr == null) { + return _.transform; + } + R._extractTransform(this, tstr); + + 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}); + } + + 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) { + return; + } + var paper = this.paper; + paper.__set__ && paper.__set__.exclude(this); + eve.unbind("*.*." + this.id); + if (this.gradient) { + paper.defs.removeChild(this.gradient); + } + R._tear(this, paper); + this.node.parentNode.removeChild(this.node); + for (var i in this) { + this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; + } + this.removed = true; + }; + elproto._getBBox = function () { + if (this.node.style.display == "none") { + this.show(); + var hide = true; + } + var bbox = {}; + try { + bbox = this.node.getBBox(); + } catch(e) { + // Firefox 3.0.x plays badly here + } finally { + bbox = bbox || {}; + } + hide && this.hide(); + return bbox; + }; + + elproto.attr = function (name, value) { + if (this.removed) { + return this; + } + if (name == null) { + var res = {}; + for (var a in this.attrs) if (this.attrs[has](a)) { + res[a] = this.attrs[a]; + } + res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; + res.transform = this._.transform; + return res; + } + if (value == null && R.is(name, "string")) { + if (name == "fill" && this.attrs.fill == "none" && this.attrs.gradient) { + return this.attrs.gradient; + } + if (name == "transform") { + return this._.transform; + } + var names = name.split(separator), + out = {}; + for (var i = 0, ii = names.length; i < ii; i++) { + name = names[i]; + if (name in this.attrs) { + out[name] = this.attrs[name]; + } else if (R.is(this.paper.customAttributes[name], "function")) { + out[name] = this.paper.customAttributes[name].def; + } else { + out[name] = R._availableAttrs[name]; + } + } + return ii - 1 ? out : out[names[0]]; + } + if (value == null && R.is(name, "array")) { + out = {}; + for (i = 0, ii = name.length; i < ii; i++) { + out[name[i]] = this.attr(name[i]); + } + return out; + } + if (value != null) { + var params = {}; + params[name] = value; + } else if (name != null && R.is(name, "object")) { + params = name; + } + for (var key in params) { + eve("attr." + key + "." + this.id, this, params[key]); + } + for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { + var par = this.paper.customAttributes[key].apply(this, [].concat(params[key])); + this.attrs[key] = params[key]; + for (var subkey in par) if (par[has](subkey)) { + params[subkey] = par[subkey]; + } + } + setFillAndStroke(this, params); + return this; + }; + + elproto.toFront = function () { + if (this.removed) { + return this; + } + if (this.node.parentNode.tagName.toLowerCase() == "a") { + this.node.parentNode.parentNode.appendChild(this.node.parentNode); + } else { + this.node.parentNode.appendChild(this.node); + } + var svg = this.paper; + 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); + } else if (parent.firstChild != this.node) { + parent.insertBefore(this.node, this.node.parentNode.firstChild); + } + R._toback(this, this.paper); + var svg = this.paper; + return this; + }; + + elproto.insertAfter = function (element) { + if (this.removed) { + return this; + } + var node = element.node || element[element.length - 1].node; + if (node.nextSibling) { + node.parentNode.insertBefore(this.node, node.nextSibling); + } else { + node.parentNode.appendChild(this.node); + } + R._insertafter(this, element, this.paper); + return this; + }; + + elproto.insertBefore = function (element) { + if (this.removed) { + return this; + } + var node = element.node || element[0].node; + node.parentNode.insertBefore(this.node, node); + R._insertbefore(this, element, this.paper); + return this; + }; + elproto.blur = function (size) { + // Experimental. No Safari support. Use it on your own risk. + var t = this; + if (+size !== 0) { + var fltr = $("filter"), + blur = $("feGaussianBlur"); + t.attrs.blur = size; + fltr.id = R.createUUID(); + $(blur, {stdDeviation: +size || 1.5}); + fltr.appendChild(blur); + t.paper.defs.appendChild(fltr); + t._blur = fltr; + $(t.node, {filter: "url(#" + fltr.id + ")"}); + } else { + if (t._blur) { + t._blur.parentNode.removeChild(t._blur); + delete t._blur; + delete t.attrs.blur; + } + t.node.removeAttribute("filter"); + } + }; + R._engine.circle = function (svg, x, y, r) { + var el = $("circle"); + svg.canvas && svg.canvas.appendChild(el); + var res = new Element(el, svg); + res.attrs = {cx: x, cy: y, r: r, fill: "none", stroke: "#000"}; + res.type = "circle"; + $(el, res.attrs); + return res; + }; + R._engine.rect = function (svg, x, y, w, h, r) { + var el = $("rect"); + svg.canvas && svg.canvas.appendChild(el); + var res = new Element(el, svg); + res.attrs = {x: x, y: y, width: w, height: h, r: r || 0, rx: r || 0, ry: r || 0, fill: "none", stroke: "#000"}; + res.type = "rect"; + $(el, res.attrs); + return res; + }; + R._engine.ellipse = function (svg, x, y, rx, ry) { + var el = $("ellipse"); + svg.canvas && svg.canvas.appendChild(el); + var res = new Element(el, svg); + res.attrs = {cx: x, cy: y, rx: rx, ry: ry, fill: "none", stroke: "#000"}; + res.type = "ellipse"; + $(el, res.attrs); + return res; + }; + R._engine.image = function (svg, src, x, y, w, h) { + var el = $("image"); + $(el, {x: x, y: y, width: w, height: h, preserveAspectRatio: "none"}); + el.setAttributeNS(xlink, "href", src); + svg.canvas && svg.canvas.appendChild(el); + var res = new Element(el, svg); + res.attrs = {x: x, y: y, width: w, height: h, src: src}; + res.type = "image"; + return res; + }; + R._engine.text = function (svg, x, y, text) { + var el = $("text"); + // $(el, {x: x, y: y, "text-anchor": "middle"}); + svg.canvas && svg.canvas.appendChild(el); + var res = new Element(el, svg); + res.attrs = { + x: x, + y: y, + "text-anchor": "middle", + text: text, + font: R._availableAttrs.font, + stroke: "none", + fill: "#000" + }; + res.type = "text"; + setFillAndStroke(res, res.attrs); + return res; + }; + R._engine.setSize = function (width, height) { + this.width = width || this.width; + this.height = height || this.height; + this.canvas.setAttribute("width", this.width); + this.canvas.setAttribute("height", this.height); + if (this._viewBox) { + this.setViewBox.apply(this, this._viewBox); + } + return this; + }; + R._engine.create = function () { + var con = R._getContainer.apply(0, arguments), + container = con && con.container, + x = con.x, + y = con.y, + width = con.width, + height = con.height; + if (!container) { + throw new Error("SVG container not found."); + } + var cnvs = $("svg"), + css = "overflow:hidden;", + isFloating; + x = x || 0; + y = y || 0; + width = width || 512; + height = height || 342; + $(cnvs, { + height: height, + version: 1.1, + width: width, + xmlns: "http://www.w3.org/2000/svg" + }); + if (container == 1) { + cnvs.style.cssText = css + "position:absolute;left:" + x + "px;top:" + y + "px"; + R._g.doc.body.appendChild(cnvs); + isFloating = 1; + } else { + cnvs.style.cssText = css + "position:relative"; + if (container.firstChild) { + container.insertBefore(cnvs, container.firstChild); + } else { + container.appendChild(cnvs); + } + } + container = new R._Paper; + container.width = width; + container.height = height; + container.canvas = cnvs; + // plugins.call(container, container, R.fn); + container.clear(); + container._left = container._top = 0; + isFloating && (container.renderfix = function () {}); + container.renderfix(); + return container; + }; + R._engine.setViewBox = function (x, y, w, h, fit) { + eve("setViewBox", this, this._viewBox, [x, y, w, h, fit]); + var size = mmax(w / this.width, h / this.height), + top = this.top, + aspectRatio = fit ? "meet" : "xMinYMin", + vb, + sw; + if (x == null) { + if (this._vbSize) { + size = 1; + } + delete this._vbSize; + vb = "0 0 " + this.width + S + this.height; + } else { + this._vbSize = size; + vb = x + S + y + S + w + S + h; + } + $(this.canvas, { + viewBox: vb, + preserveAspectRatio: aspectRatio + }); + while (size && top) { + sw = "stroke-width" in top.attrs ? top.attrs["stroke-width"] : 1; + top.attr({"stroke-width": sw}); + top._.dirty = 1; + top._.dirtyT = 1; + top = top.prev; + } + this._viewBox = [x, y, w, h, !!fit]; + return this; + }; + + R.prototype.renderfix = function () { + var cnvs = this.canvas, + s = cnvs.style, + pos = cnvs.getScreenCTM() || cnvs.createSVGMatrix(), + left = -pos.e % 1, + top = -pos.f % 1; + if (left || top) { + if (left) { + this._left = (this._left + left) % 1; + s.left = this._left + "px"; + } + if (top) { + this._top = (this._top + top) % 1; + s.top = this._top + "px"; + } + } + }; + + R.prototype.clear = function () { + R.eve("clear", this); + var c = this.canvas; + while (c.firstChild) { + c.removeChild(c.firstChild); + } + this.bottom = this.top = null; + (this.desc = $("desc")).appendChild(R._g.doc.createTextNode("Created with Rapha\xebl " + R.version)); + c.appendChild(this.desc); + c.appendChild(this.defs = $("defs")); + }; + + R.prototype.remove = function () { + eve("remove", this); + this.canvas.parentNode && this.canvas.parentNode.removeChild(this.canvas); + for (var i in this) { + this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; + } + }; + var setproto = R.st; + for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { + setproto[method] = (function (methodname) { + return function () { + var arg = arguments; + return this.forEach(function (el) { + el[methodname].apply(el, arg); + }); + }; + })(method); + } +}(window.Raphael); + +// ┌─────────────────────────────────────────────────────────────────────┐ \\ +// │ Raphaël - JavaScript Vector Library │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ VML Module │ \\ +// ├─────────────────────────────────────────────────────────────────────┤ \\ +// │ Copyright (c) 2008-2011 Dmitry Baranovskiy (http://raphaeljs.com) │ \\ +// │ Copyright (c) 2008-2011 Sencha Labs (http://sencha.com) │ \\ +// │ Licensed under the MIT (http://raphaeljs.com/license.html) license. │ \\ +// └─────────────────────────────────────────────────────────────────────┘ \\ +window.Raphael.vml && function (R) { + var has = "hasOwnProperty", + Str = String, + toFloat = parseFloat, + math = Math, + round = math.round, + mmax = math.max, + mmin = math.min, + abs = math.abs, + fillString = "fill", + separator = /[, ]+/, + eve = R.eve, + ms = " progid:DXImageTransform.Microsoft", + S = " ", + E = "", + map = {M: "m", L: "l", C: "c", Z: "x", m: "t", l: "r", c: "v", z: "x"}, + bites = /([clmz]),?([^clmz]*)/gi, + blurregexp = / progid:\S+Blur\([^\)]+\)/g, + val = /-?[^,\s-]+/g, + cssDot = "position:absolute;left:0;top:0;width:1px;height:1px", + zoom = 21600, + pathTypes = {path: 1, rect: 1, image: 1}, + ovalTypes = {circle: 1, ellipse: 1}, + path2vml = function (path) { + var total = /[ahqstv]/ig, + command = R._pathToAbsolute; + Str(path).match(total) && (command = R._path2curve); + total = /[clmz]/g; + if (command == R._pathToAbsolute && !Str(path).match(total)) { + var res = Str(path).replace(bites, function (all, command, args) { + var vals = [], + isMove = command.toLowerCase() == "m", + res = map[command]; + args.replace(val, function (value) { + if (isMove && vals.length == 2) { + res += vals + map[command == "m" ? "l" : "L"]; + vals = []; + } + vals.push(round(value * zoom)); + }); + return res + vals; + }); + return res; + } + var pa = command(path), p, r; + res = []; + for (var i = 0, ii = pa.length; i < ii; i++) { + p = pa[i]; + r = pa[i][0].toLowerCase(); + r == "z" && (r = "x"); + for (var j = 1, jj = p.length; j < jj; j++) { + r += round(p[j] * zoom) + (j != jj - 1 ? "," : E); + } + res.push(r); + } + return res.join(S); + }, + compensation = function (deg, dx, dy) { + var m = R.matrix(); + m.rotate(-deg, .5, .5); + return { + dx: m.x(dx, dy), + dy: m.y(dx, dy) + }; + }, + setCoords = function (p, sx, sy, dx, dy, deg) { + var _ = p._, + m = p.matrix, + fillpos = _.fillpos, + o = p.node, + s = o.style, + y = 1, + flip = "", + dxdy, + kx = zoom / sx, + ky = zoom / sy; + s.visibility = "hidden"; + if (!sx || !sy) { + return; + } + o.coordsize = abs(kx) + S + abs(ky); + s.rotation = deg * (sx * sy < 0 ? -1 : 1); + if (deg) { + var c = compensation(deg, dx, dy); + dx = c.dx; + dy = c.dy; + } + sx < 0 && (flip += "x"); + sy < 0 && (flip += " y") && (y = -1); + s.flip = flip; + o.coordorigin = (dx * -kx) + S + (dy * -ky); + if (fillpos || _.fillsize) { + var fill = o.getElementsByTagName(fillString); + fill = fill && fill[0]; + o.removeChild(fill); + if (fillpos) { + c = compensation(deg, m.x(fillpos[0], fillpos[1]), m.y(fillpos[0], fillpos[1])); + fill.position = c.dx * y + S + c.dy * y; + } + if (_.fillsize) { + fill.size = _.fillsize[0] * abs(sx) + S + _.fillsize[1] * abs(sy); + } + o.appendChild(fill); + } + s.visibility = "visible"; + }; + R.toString = function () { + return "Your browser doesn\u2019t support SVG. Falling down to VML.\nYou are running Rapha\xebl " + this.version; + }; + var addArrow = function (o, value, isEnd) { + var values = Str(value).toLowerCase().split("-"), + se = isEnd ? "end" : "start", + i = values.length, + type = "classic", + w = "medium", + h = "medium"; + while (i--) { + switch (values[i]) { + case "block": + case "classic": + case "oval": + case "diamond": + case "open": + case "none": + type = values[i]; + break; + case "wide": + case "narrow": h = values[i]; break; + case "long": + case "short": w = values[i]; break; + } + } + var stroke = o.node.getElementsByTagName("stroke")[0]; + stroke[se + "arrow"] = type; + stroke[se + "arrowlength"] = w; + stroke[se + "arrowwidth"] = h; + }, + setFillAndStroke = function (o, params) { + // o.paper.canvas.style.display = "none"; + o.attrs = o.attrs || {}; + var node = o.node, + a = o.attrs, + s = node.style, + xy, + newpath = pathTypes[o.type] && (params.x != a.x || params.y != a.y || params.width != a.width || params.height != a.height || params.cx != a.cx || params.cy != a.cy || params.rx != a.rx || params.ry != a.ry || params.r != a.r), + isOval = ovalTypes[o.type] && (a.cx != params.cx || a.cy != params.cy || a.r != params.r || a.rx != params.rx || a.ry != params.ry), + res = o; + + + for (var par in params) if (params[has](par)) { + a[par] = params[par]; + } + if (newpath) { + a.path = R._getPath[o.type](o); + o._.dirty = 1; + } + params.href && (node.href = params.href); + params.title && (node.title = params.title); + params.target && (node.target = params.target); + params.cursor && (s.cursor = params.cursor); + "blur" in params && o.blur(params.blur); + if (params.path && o.type == "path" || newpath) { + node.path = path2vml(~Str(a.path).toLowerCase().indexOf("r") ? R._pathToAbsolute(a.path) : a.path); + if (o.type == "image") { + o._.fillpos = [a.x, a.y]; + o._.fillsize = [a.width, a.height]; + setCoords(o, 1, 1, 0, 0, 0); + } + } + "transform" in params && o.transform(params.transform); + if (isOval) { + var cx = +a.cx, + cy = +a.cy, + rx = +a.rx || +a.r || 0, + ry = +a.ry || +a.r || 0; + node.path = R.format("ar{0},{1},{2},{3},{4},{1},{4},{1}x", round((cx - rx) * zoom), round((cy - ry) * zoom), round((cx + rx) * zoom), round((cy + ry) * zoom), round(cx * zoom)); + } + if ("clip-rect" in params) { + var rect = Str(params["clip-rect"]).split(separator); + if (rect.length == 4) { + rect[2] = +rect[2] + (+rect[0]); + rect[3] = +rect[3] + (+rect[1]); + var div = node.clipRect || R._g.doc.createElement("div"), + dstyle = div.style; + dstyle.clip = R.format("rect({1}px {2}px {3}px {0}px)", rect); + if (!node.clipRect) { + dstyle.position = "absolute"; + dstyle.top = 0; + dstyle.left = 0; + dstyle.width = o.paper.width + "px"; + dstyle.height = o.paper.height + "px"; + node.parentNode.insertBefore(div, node); + div.appendChild(node); + node.clipRect = div; + } + } + if (!params["clip-rect"]) { + node.clipRect && (node.clipRect.style.clip = "auto"); + } + } + if (o.textpath) { + var textpathStyle = o.textpath.style; + params.font && (textpathStyle.font = params.font); + params["font-family"] && (textpathStyle.fontFamily = '"' + params["font-family"].split(",")[0].replace(/^['"]+|['"]+$/g, E) + '"'); + params["font-size"] && (textpathStyle.fontSize = params["font-size"]); + params["font-weight"] && (textpathStyle.fontWeight = params["font-weight"]); + params["font-style"] && (textpathStyle.fontStyle = params["font-style"]); + } + if ("arrow-start" in params) { + addArrow(res, params["arrow-start"]); + } + if ("arrow-end" in params) { + addArrow(res, params["arrow-end"], 1); + } + if (params.opacity != null || + params["stroke-width"] != null || + params.fill != null || + params.src != null || + params.stroke != null || + params["stroke-width"] != null || + params["stroke-opacity"] != null || + params["fill-opacity"] != null || + params["stroke-dasharray"] != null || + params["stroke-miterlimit"] != null || + params["stroke-linejoin"] != null || + params["stroke-linecap"] != null) { + var fill = node.getElementsByTagName(fillString), + newfill = false; + fill = fill && fill[0]; + !fill && (newfill = fill = createNode(fillString)); + if (o.type == "image" && params.src) { + fill.src = params.src; + } + params.fill && (fill.on = true); + if (fill.on == null || params.fill == "none" || params.fill === null) { + fill.on = false; + } + if (fill.on && params.fill) { + var isURL = Str(params.fill).match(R._ISURL); + if (isURL) { + fill.parentNode == node && node.removeChild(fill); + fill.rotate = true; + fill.src = isURL[1]; + fill.type = "tile"; + var bbox = o.getBBox(1); + fill.position = bbox.x + S + bbox.y; + o._.fillpos = [bbox.x, bbox.y]; + + R._preload(isURL[1], function () { + o._.fillsize = [this.offsetWidth, this.offsetHeight]; + }); + } else { + fill.color = R.getRGB(params.fill).hex; + fill.src = E; + fill.type = "solid"; + if (R.getRGB(params.fill).error && (res.type in {circle: 1, ellipse: 1} || Str(params.fill).charAt() != "r") && addGradientFill(res, params.fill, fill)) { + a.fill = "none"; + a.gradient = params.fill; + fill.rotate = false; + } + } + } + if ("fill-opacity" in params || "opacity" in params) { + var opacity = ((+a["fill-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+R.getRGB(params.fill).o + 1 || 2) - 1); + opacity = mmin(mmax(opacity, 0), 1); + fill.opacity = opacity; + if (fill.src) { + fill.color = "none"; + } + } + node.appendChild(fill); + var stroke = (node.getElementsByTagName("stroke") && node.getElementsByTagName("stroke")[0]), + newstroke = false; + !stroke && (newstroke = stroke = createNode("stroke")); + if ((params.stroke && params.stroke != "none") || + params["stroke-width"] || + params["stroke-opacity"] != null || + params["stroke-dasharray"] || + params["stroke-miterlimit"] || + params["stroke-linejoin"] || + params["stroke-linecap"]) { + stroke.on = true; + } + (params.stroke == "none" || params.stroke === null || stroke.on == null || params.stroke == 0 || params["stroke-width"] == 0) && (stroke.on = false); + var strokeColor = R.getRGB(params.stroke); + stroke.on && params.stroke && (stroke.color = strokeColor.hex); + opacity = ((+a["stroke-opacity"] + 1 || 2) - 1) * ((+a.opacity + 1 || 2) - 1) * ((+strokeColor.o + 1 || 2) - 1); + var width = (toFloat(params["stroke-width"]) || 1) * .75; + opacity = mmin(mmax(opacity, 0), 1); + params["stroke-width"] == null && (width = a["stroke-width"]); + 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"); + if (params["stroke-dasharray"]) { + var dasharray = { + "-": "shortdash", + ".": "shortdot", + "-.": "shortdashdot", + "-..": "shortdashdotdot", + ". ": "dot", + "- ": "dash", + "--": "longdash", + "- .": "dashdot", + "--.": "longdashdot", + "--..": "longdashdotdot" + }; + stroke.dashstyle = dasharray[has](params["stroke-dasharray"]) ? dasharray[params["stroke-dasharray"]] : E; + } + newstroke && node.appendChild(stroke); + } + if (res.type == "text") { + res.paper.canvas.style.display = E; + var span = res.paper.span, + m = 100, + fontSize = a.font && a.font.match(/\d+(?:\.\d*)?(?=px)/); + s = span.style; + a.font && (s.font = a.font); + a["font-family"] && (s.fontFamily = a["font-family"]); + a["font-weight"] && (s.fontWeight = a["font-weight"]); + a["font-style"] && (s.fontStyle = a["font-style"]); + fontSize = toFloat(a["font-size"] || fontSize && fontSize[0]) || 10; + s.fontSize = fontSize * m + "px"; + res.textpath.string && (span.innerHTML = Str(res.textpath.string).replace(/")); + var brect = span.getBoundingClientRect(); + res.W = a.w = (brect.right - brect.left) / m; + res.H = a.h = (brect.bottom - brect.top) / m; + // res.paper.canvas.style.display = "none"; + res.X = a.x; + res.Y = a.y + res.H / 2; + + ("x" in params || "y" in params) && (res.path.v = R.format("m{0},{1}l{2},{1}", round(a.x * zoom), round(a.y * zoom), round(a.x * zoom) + 1)); + var dirtyattrs = ["x", "y", "text", "font", "font-family", "font-weight", "font-style", "font-size"]; + for (var d = 0, dd = dirtyattrs.length; d < dd; d++) if (dirtyattrs[d] in params) { + res._.dirty = 1; + break; + } + + // text-anchor emulation + switch (a["text-anchor"]) { + case "start": + res.textpath.style["v-text-align"] = "left"; + res.bbx = res.W / 2; + break; + case "end": + res.textpath.style["v-text-align"] = "right"; + res.bbx = -res.W / 2; + break; + default: + res.textpath.style["v-text-align"] = "center"; + res.bbx = 0; + break; + } + res.textpath.style["v-text-kern"] = true; + } + // res.paper.canvas.style.display = E; + }, + addGradientFill = function (o, gradient, fill) { + o.attrs = o.attrs || {}; + var attrs = o.attrs, + pow = Math.pow, + opacity, + oindex, + type = "linear", + fxfy = ".5 .5"; + o.attrs.gradient = gradient; + gradient = Str(gradient).replace(R._radial_gradient, function (all, fx, fy) { + type = "radial"; + if (fx && fy) { + fx = toFloat(fx); + fy = toFloat(fy); + pow(fx - .5, 2) + pow(fy - .5, 2) > .25 && (fy = math.sqrt(.25 - pow(fx - .5, 2)) * ((fy > .5) * 2 - 1) + .5); + fxfy = fx + S + fy; + } + return E; + }); + gradient = gradient.split(/\s*\-\s*/); + if (type == "linear") { + var angle = gradient.shift(); + angle = -toFloat(angle); + if (isNaN(angle)) { + return null; + } + } + var dots = R._parseDots(gradient); + if (!dots) { + return null; + } + o = o.shape || o.node; + if (dots.length) { + o.removeChild(fill); + fill.on = true; + fill.method = "none"; + fill.color = dots[0].color; + fill.color2 = dots[dots.length - 1].color; + var clrs = []; + for (var i = 0, ii = dots.length; i < ii; i++) { + dots[i].offset && clrs.push(dots[i].offset + S + dots[i].color); + } + fill.colors = clrs.length ? clrs.join() : "0% " + fill.color; + if (type == "radial") { + fill.type = "gradientTitle"; + fill.focus = "100%"; + fill.focussize = "0 0"; + fill.focusposition = fxfy; + fill.angle = 0; + } else { + // fill.rotate= true; + fill.type = "gradient"; + fill.angle = (270 - angle) % 360; + } + o.appendChild(fill); + } + return 1; + }, + Element = function (node, vml) { + this[0] = this.node = node; + node.raphael = true; + this.id = R._oid++; + node.raphaelid = this.id; + this.X = 0; + this.Y = 0; + this.attrs = {}; + this.paper = vml; + this.matrix = R.matrix(); + this._ = { + transform: [], + sx: 1, + sy: 1, + dx: 0, + dy: 0, + deg: 0, + dirty: 1, + dirtyT: 1 + }; + !vml.bottom && (vml.bottom = this); + this.prev = vml.top; + vml.top && (vml.top.next = this); + vml.top = this; + this.next = null; + }; + var elproto = R.el; + + Element.prototype = elproto; + elproto.constructor = Element; + elproto.transform = function (tstr) { + if (tstr == null) { + return this._.transform; + } + var vbs = this.paper._viewBoxShift, + vbt = vbs ? "s" + [vbs.scale, vbs.scale] + "-1-1t" + [vbs.dx, vbs.dy] : E, + oldt; + if (vbs) { + oldt = tstr = Str(tstr).replace(/\.{3}|\u2026/g, this._.transform || E); + } + R._extractTransform(this, vbt + tstr); + var matrix = this.matrix.clone(), + skew = this.skew, + o = this.node, + split, + isGrad = ~Str(this.attrs.fill).indexOf("-"), + isPatt = !Str(this.attrs.fill).indexOf("url("); + matrix.translate(-.5, -.5); + if (isPatt || isGrad || this.type == "image") { + skew.matrix = "1 0 0 1"; + skew.offset = "0 0"; + split = matrix.split(); + if ((isGrad && split.noRotation) || !split.isSimple) { + o.style.filter = matrix.toFilter(); + var bb = this.getBBox(), + bbt = this.getBBox(1), + dx = bb.x - bbt.x, + dy = bb.y - bbt.y; + o.coordorigin = (dx * -zoom) + S + (dy * -zoom); + setCoords(this, 1, 1, dx, dy, 0); + } else { + o.style.filter = E; + setCoords(this, split.scalex, split.scaley, split.dx, split.dy, split.rotate); + } + } else { + o.style.filter = E; + skew.matrix = Str(matrix); + skew.offset = matrix.offset(); + } + oldt && (this._.transform = oldt); + return this; + }; + elproto.rotate = function (deg, cx, cy) { + if (this.removed) { + return this; + } + if (deg == null) { + return; + } + deg = Str(deg).split(separator); + if (deg.length - 1) { + cx = toFloat(deg[1]); + cy = toFloat(deg[2]); + } + deg = toFloat(deg[0]); + (cy == null) && (cx = cy); + if (cx == null || cy == null) { + var bbox = this.getBBox(1); + cx = bbox.x + bbox.width / 2; + cy = bbox.y + bbox.height / 2; + } + this._.dirtyT = 1; + this.transform(this._.transform.concat([["r", deg, cx, cy]])); + return this; + }; + elproto.translate = function (dx, dy) { + if (this.removed) { + return this; + } + dx = Str(dx).split(separator); + if (dx.length - 1) { + dy = toFloat(dx[1]); + } + dx = toFloat(dx[0]) || 0; + dy = +dy || 0; + if (this._.bbox) { + this._.bbox.x += dx; + this._.bbox.y += dy; + } + this.transform(this._.transform.concat([["t", dx, dy]])); + return this; + }; + elproto.scale = function (sx, sy, cx, cy) { + if (this.removed) { + return this; + } + sx = Str(sx).split(separator); + if (sx.length - 1) { + sy = toFloat(sx[1]); + cx = toFloat(sx[2]); + cy = toFloat(sx[3]); + isNaN(cx) && (cx = null); + isNaN(cy) && (cy = null); + } + sx = toFloat(sx[0]); + (sy == null) && (sy = sx); + (cy == null) && (cx = cy); + if (cx == null || cy == null) { + var bbox = this.getBBox(1); + } + 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; + }; + elproto.hide = function () { + !this.removed && (this.node.style.display = "none"); + return this; + }; + elproto.show = function () { + !this.removed && (this.node.style.display = E); + return this; + }; + elproto._getBBox = function () { + if (this.removed) { + return {}; + } + return { + x: this.X + (this.bbx || 0) - this.W / 2, + y: this.Y - this.H, + width: this.W, + height: this.H + }; + }; + elproto.remove = function () { + if (this.removed) { + return; + } + this.paper.__set__ && this.paper.__set__.exclude(this); + R.eve.unbind("*.*." + this.id); + R._tear(this, this.paper); + this.node.parentNode.removeChild(this.node); + this.shape && this.shape.parentNode.removeChild(this.shape); + for (var i in this) { + this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; + } + this.removed = true; + }; + elproto.attr = function (name, value) { + if (this.removed) { + return this; + } + if (name == null) { + var res = {}; + for (var a in this.attrs) if (this.attrs[has](a)) { + res[a] = this.attrs[a]; + } + res.gradient && res.fill == "none" && (res.fill = res.gradient) && delete res.gradient; + res.transform = this._.transform; + return res; + } + if (value == null && R.is(name, "string")) { + if (name == fillString && this.attrs.fill == "none" && this.attrs.gradient) { + return this.attrs.gradient; + } + var names = name.split(separator), + out = {}; + for (var i = 0, ii = names.length; i < ii; i++) { + name = names[i]; + if (name in this.attrs) { + out[name] = this.attrs[name]; + } else if (R.is(this.paper.customAttributes[name], "function")) { + out[name] = this.paper.customAttributes[name].def; + } else { + out[name] = R._availableAttrs[name]; + } + } + return ii - 1 ? out : out[names[0]]; + } + if (this.attrs && value == null && R.is(name, "array")) { + out = {}; + for (i = 0, ii = name.length; i < ii; i++) { + out[name[i]] = this.attr(name[i]); + } + return out; + } + var params; + if (value != null) { + params = {}; + params[name] = value; + } + value == null && R.is(name, "object") && (params = name); + for (var key in params) { + eve("attr." + key + "." + this.id, this, params[key]); + } + if (params) { + for (key in this.paper.customAttributes) if (this.paper.customAttributes[has](key) && params[has](key) && R.is(this.paper.customAttributes[key], "function")) { + var par = this.paper.customAttributes[key].apply(this, [].concat(params[key])); + this.attrs[key] = params[key]; + for (var subkey in par) if (par[has](subkey)) { + params[subkey] = par[subkey]; + } + } + // this.paper.canvas.style.display = "none"; + if (params.text && this.type == "text") { + this.textpath.string = params.text; + } + setFillAndStroke(this, params); + // this.paper.canvas.style.display = E; + } + return this; + }; + elproto.toFront = function () { + !this.removed && this.node.parentNode.appendChild(this.node); + this.paper && this.paper.top != this && R._tofront(this, this.paper); + return this; + }; + elproto.toBack = function () { + if (this.removed) { + return this; + } + if (this.node.parentNode.firstChild != this.node) { + this.node.parentNode.insertBefore(this.node, this.node.parentNode.firstChild); + R._toback(this, this.paper); + } + return this; + }; + elproto.insertAfter = function (element) { + if (this.removed) { + return this; + } + if (element.constructor == R.st.constructor) { + element = element[element.length - 1]; + } + if (element.node.nextSibling) { + element.node.parentNode.insertBefore(this.node, element.node.nextSibling); + } else { + element.node.parentNode.appendChild(this.node); + } + R._insertafter(this, element, this.paper); + return this; + }; + elproto.insertBefore = function (element) { + if (this.removed) { + return this; + } + if (element.constructor == R.st.constructor) { + element = element[0]; + } + element.node.parentNode.insertBefore(this.node, element.node); + R._insertbefore(this, element, this.paper); + return this; + }; + elproto.blur = function (size) { + var s = this.node.runtimeStyle, + f = s.filter; + f = f.replace(blurregexp, E); + if (+size !== 0) { + this.attrs.blur = size; + s.filter = f + S + ms + ".Blur(pixelradius=" + (+size || 1.5) + ")"; + s.margin = R.format("-{0}px 0 0 -{0}px", round(+size || 1.5)); + } else { + s.filter = f; + s.margin = 0; + delete this.attrs.blur; + } + }; + + R._engine.path = function (pathString, vml) { + var el = createNode("shape"); + el.style.cssText = cssDot; + el.coordsize = zoom + S + zoom; + el.coordorigin = vml.coordorigin; + var p = new Element(el, vml), + attr = {fill: "none", stroke: "#000"}; + pathString && (attr.path = pathString); + p.type = "path"; + p.path = []; + p.Path = E; + setFillAndStroke(p, attr); + vml.canvas.appendChild(el); + var skew = createNode("skew"); + skew.on = true; + el.appendChild(skew); + p.skew = skew; + p.transform(E); + return p; + }; + R._engine.rect = function (vml, x, y, w, h, r) { + var path = R._rectPath(x, y, w, h, r), + res = vml.path(path), + a = res.attrs; + res.X = a.x = x; + res.Y = a.y = y; + res.W = a.width = w; + res.H = a.height = h; + a.r = r; + a.path = path; + res.type = "rect"; + return res; + }; + R._engine.ellipse = function (vml, x, y, rx, ry) { + var res = vml.path(), + a = res.attrs; + res.X = x - rx; + res.Y = y - ry; + res.W = rx * 2; + res.H = ry * 2; + res.type = "ellipse"; + setFillAndStroke(res, { + cx: x, + cy: y, + rx: rx, + ry: ry + }); + return res; + }; + R._engine.circle = function (vml, x, y, r) { + var res = vml.path(), + a = res.attrs; + res.X = x - r; + res.Y = y - r; + res.W = res.H = r * 2; + res.type = "circle"; + setFillAndStroke(res, { + cx: x, + cy: y, + r: r + }); + return res; + }; + R._engine.image = function (vml, src, x, y, w, h) { + var path = R._rectPath(x, y, w, h), + res = vml.path(path).attr({stroke: "none"}), + a = res.attrs, + node = res.node, + fill = node.getElementsByTagName(fillString)[0]; + a.src = src; + res.X = a.x = x; + res.Y = a.y = y; + res.W = a.width = w; + res.H = a.height = h; + a.path = path; + res.type = "image"; + fill.parentNode == node && node.removeChild(fill); + fill.rotate = true; + fill.src = src; + fill.type = "tile"; + res._.fillpos = [x, y]; + res._.fillsize = [w, h]; + node.appendChild(fill); + setCoords(res, 1, 1, 0, 0, 0); + return res; + }; + R._engine.text = function (vml, x, y, text) { + var el = createNode("shape"), + path = createNode("path"), + o = createNode("textpath"); + x = x || 0; + y = y || 0; + text = text || ""; + path.v = R.format("m{0},{1}l{2},{1}", round(x * zoom), round(y * zoom), round(x * zoom) + 1); + path.textpathok = true; + o.string = Str(text); + o.on = true; + el.style.cssText = cssDot; + el.coordsize = zoom + S + zoom; + el.coordorigin = "0 0"; + var p = new Element(el, vml), + attr = { + fill: "#000", + stroke: "none", + font: R._availableAttrs.font, + text: text + }; + p.shape = el; + p.path = path; + p.textpath = o; + p.type = "text"; + p.attrs.text = Str(text); + p.attrs.x = x; + p.attrs.y = y; + p.attrs.w = 1; + p.attrs.h = 1; + setFillAndStroke(p, attr); + el.appendChild(o); + el.appendChild(path); + vml.canvas.appendChild(el); + var skew = createNode("skew"); + skew.on = true; + el.appendChild(skew); + p.skew = skew; + p.transform(E); + return p; + }; + R._engine.setSize = function (width, height) { + var cs = this.canvas.style; + this.width = width; + this.height = height; + width == +width && (width += "px"); + height == +height && (height += "px"); + cs.width = width; + cs.height = height; + cs.clip = "rect(0 " + width + " " + height + " 0)"; + if (this._viewBox) { + R._engine.setViewBox.apply(this, this._viewBox); + } + return this; + }; + R._engine.setViewBox = function (x, y, w, h, fit) { + R.eve("setViewBox", this, this._viewBox, [x, y, w, h, fit]); + var width = this.width, + height = this.height, + size = 1 / mmax(w / width, h / height), + H, W; + if (fit) { + H = height / h; + W = width / w; + if (w * H < width) { + x -= (width - w * H) / 2 / H; + } + if (h * W < height) { + y -= (height - h * W) / 2 / W; + } + } + this._viewBox = [x, y, w, h, !!fit]; + this._viewBoxShift = { + dx: -x, + dy: -y, + scale: size + }; + this.forEach(function (el) { + el.transform("..."); + }); + return this; + }; + var createNode; + R._engine.initWin = function (win) { + var doc = win.document; + doc.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)"); + try { + !doc.namespaces.rvml && doc.namespaces.add("rvml", "urn:schemas-microsoft-com:vml"); + createNode = function (tagName) { + return doc.createElement(''); + }; + } catch (e) { + createNode = function (tagName) { + return doc.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">'); + }; + } + }; + R._engine.initWin(R._g.win); + R._engine.create = function () { + var con = R._getContainer.apply(0, arguments), + container = con.container, + height = con.height, + s, + width = con.width, + x = con.x, + y = con.y; + if (!container) { + throw new Error("VML container not found."); + } + var res = new R._Paper, + c = res.canvas = R._g.doc.createElement("div"), + cs = c.style; + x = x || 0; + y = y || 0; + width = width || 512; + height = height || 342; + res.width = width; + res.height = height; + width == +width && (width += "px"); + height == +height && (height += "px"); + res.coordsize = zoom * 1e3 + S + zoom * 1e3; + res.coordorigin = "0 0"; + res.span = R._g.doc.createElement("span"); + res.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;"; + c.appendChild(res.span); + cs.cssText = R.format("top:0;left:0;width:{0};height:{1};display:inline-block;position:relative;clip:rect(0 {0} {1} 0);overflow:hidden", width, height); + if (container == 1) { + R._g.doc.body.appendChild(c); + cs.left = x + "px"; + cs.top = y + "px"; + cs.position = "absolute"; + } else { + if (container.firstChild) { + container.insertBefore(c, container.firstChild); + } else { + container.appendChild(c); + } + } + // plugins.call(res, res, R.fn); + res.renderfix = function () {}; + return res; + }; + R.prototype.clear = function () { + R.eve("clear", this); + this.canvas.innerHTML = E; + this.span = R._g.doc.createElement("span"); + this.span.style.cssText = "position:absolute;left:-9999em;top:-9999em;padding:0;margin:0;line-height:1;display:inline;"; + this.canvas.appendChild(this.span); + this.bottom = this.top = null; + }; + R.prototype.remove = function () { + R.eve("remove", this); + this.canvas.parentNode.removeChild(this.canvas); + for (var i in this) { + this[i] = typeof this[i] == "function" ? R._removedFactory(i) : null; + } + return true; + }; + + var setproto = R.st; + for (var method in elproto) if (elproto[has](method) && !setproto[has](method)) { + setproto[method] = (function (methodname) { + return function () { + var arg = arguments; + return this.forEach(function (el) { + el[methodname].apply(el, arg); + }); + }; + })(method); + } +}(window.Raphael); \ No newline at end of file diff --git a/test/when/demo-print.css b/test/when/demo-print.css new file mode 100644 index 0000000..c9a3035 --- /dev/null +++ b/test/when/demo-print.css @@ -0,0 +1,13 @@ +body { + background: #fff; + color: #000; + font: 100.1% "Lucida Grande", Lucida, Verdana, sans-serif; +} +#graph { + height: 480px; + left: 50%; + margin: 0 0 0 -320px; + position: absolute; + top: 0; + width: 640px; +} diff --git a/test/when/demo.css b/test/when/demo.css new file mode 100644 index 0000000..ccb1882 --- /dev/null +++ b/test/when/demo.css @@ -0,0 +1,21 @@ +body { + background: #333; + color: #fff; + font: 300 100.1% "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; +} +#graph { + height: 480px; + left: 50%; + margin: -240px 0 0 -320px; + position: absolute; + top: 50%; + width: 640px; +} +#menus { + height: 480px; + left: 50%; + margin: -240px 0 0 -320px; + position: absolute; + top: 50%; + width: 640px; +} diff --git a/test/when/index.html b/test/when/index.html new file mode 100644 index 0000000..4010062 --- /dev/null +++ b/test/when/index.html @@ -0,0 +1,36 @@ + + + + + WHEN + + + + + + +
+ + + \ No newline at end of file diff --git a/test/when/raphael-utils.js b/test/when/raphael-utils.js new file mode 100644 index 0000000..626713e --- /dev/null +++ b/test/when/raphael-utils.js @@ -0,0 +1,33 @@ +Raphael.fn.drawGrid = function (x, y, w, h, wv, hv, color) { + color = color || "#000"; + var path = ["M", Math.round(x) + .5, Math.round(y) + .5, "L", Math.round(x + w) + .5, Math.round(y) + .5, Math.round(x + w) + .5, Math.round(y + h) + .5, Math.round(x) + .5, Math.round(y + h) + .5, Math.round(x) + .5, Math.round(y) + .5], + rowHeight = h / hv, + columnWidth = w / wv; + for (var i = 1; i < hv; i++) { + path = path.concat(["M", Math.round(x) + .5, Math.round(y + i * rowHeight) + .5, "H", Math.round(x + w) + .5]); + } + for (i = 1; i < wv; i++) { + path = path.concat(["M", Math.round(x + i * columnWidth) + .5, Math.round(y) + .5, "V", Math.round(y + h) + .5]); + } + return this.path(path.join(",")).attr({stroke: color}); +}; + +function getAnchors(p1x, p1y, p2x, p2y, p3x, p3y) { + var l1 = (p2x - p1x) / 2, + l2 = (p3x - p2x) / 2, + a = Math.atan((p2x - p1x) / Math.abs(p2y - p1y)), + b = Math.atan((p3x - p2x) / Math.abs(p2y - p3y)); + a = p1y < p2y ? Math.PI - a : a; + b = p3y < p2y ? Math.PI - b : b; + var alpha = Math.PI / 2 - ((a + b) % (Math.PI * 2)) / 2, + dx1 = l1 * Math.sin(alpha + a), + dy1 = l1 * Math.cos(alpha + a), + dx2 = l2 * Math.sin(alpha + b), + dy2 = l2 * Math.cos(alpha + b); + return { + x1: p2x - dx1, + y1: p2y + dy1, + x2: p2x + dx2, + y2: p2y + dy2 + }; +} \ No newline at end of file diff --git a/test/when/when.js b/test/when/when.js new file mode 100644 index 0000000..4e0e6be --- /dev/null +++ b/test/when/when.js @@ -0,0 +1,187 @@ +/* +Tim Redfern Jan 2012 tim@eclectronics.org + +Animated graphing - Edmund Rice School Ties + +see analytics.js example + +http://net.tutsplus.com/tutorials/javascript-ajax/an-introduction-to-the-raphael-js-library/ + +aim for today: have a few items that can be chosen + +1) switch items - multiple lines view .. x amount of lines + 'other' +2) animate between views +3) rollover points +4) label axes +*/ + +var data,raphael,classOfRange,birthplaces,colleges,locations,fields; + +var graphData; + +var maxPaths; + +window.onload = function() { + loadData(); + createMenu(); + //alert(document.getElementById("holder").offsetWidth+","+document.getElementById("holder").offsetHeight); + //seems predictable, gives same result in chrome, firefox, mobile safari + var graph=document.getElementById('graph'); + raphael = new Raphael(graph, graph.offsetWidth, graph.offsetHeight); + drawGraph(); +} + +function graphableData(name) { + //organises a range of data to graph against a variable value + this.name=name; + this.data={}; + this.max=0; + this.addElement = function(element,value) { + if (element in this.data) { + if (value in this.data[element]) this.data[element][value]++; + else this.data[element][value]=1; + } + else { + this.data[element]={}; + this.data[element][value]=1 + } + if (this.data[element][value]>this.max) this.max=this.data[element][value]; + } + this.getElement = function(element) { + if (element in this.data) return data[element]; //returns an associative array + } + this.summary = function() { + var s= ""+name+": "+Object.keys(this.data).length+" elements, max "+this.max+"\n"; + var k=Object.keys(this.data); + //s+=k+":"; + for (i in k) { + s+=k[i]+":"; + var l=Object.keys(this.data[k[i]]); + for (j in l) s+=l[j]+"="+this.data[k[i]][l[j]]+","; + s+="\n"; + } + return s+"\n"; + } + +} + +function loadData() { + maxPaths=8; + //replace with json loader + fields=["Class size","Location","Birthplace","College","Career"]; + fieldNames=["classSize","location","birthplace","college","career"]; + //basic { name:"Joe", surname:"Murphy",school:"Dublin",classOf:"86",location:"Ireland",email:"joem20156@gmail.com"}, + //extended { name:"Joe", surname:"Murphy",school:"Dublin",classOf:"86",location:"Ireland",email:"joem20156@gmail.com",birthplace:"Ireland",college:"UCD",career:"construction",sports:["soccer","hurling"],nickname:"Virgil"}, + data = [ + { school:"Dublin",classOf:"86",location:"Ireland",birthplace:"Ireland",college:"UCD",career:"construction",sports:["soccer","hurling"],nickname:"Virgil"}, + { school:"Dublin",classOf:"87",location:"Ireland",birthplace:"Ireland",college:"NUIG",career:"law",sports:["soccer","gaelic"],nickname:"Con"}, + { school:"Dublin",classOf:"86",location:"Ireland",birthplace:"Ireland",college:"TCD",career:"teaching",sports:["gaelic","hurling"],nickname:"Morty"}, + { school:"Dublin",classOf:"88",location:"USA",birthplace:"UK",college:"UL",career:"army",sports:["soccer"],nickname:"Mick"}, + { school:"Dublin",classOf:"87",location:"Ireland",birthplace:"Ireland",college:"UCD",career:"law",sports:["soccer","gaelic"],nickname:"Johnjoe"}, + { school:"Dublin",classOf:"86",location:"UK",birthplace:"Ireland",college:"TCD",career:"teaching",sports:["handball","hurling"],nickname:"Mossy"}, + { school:"Dublin",classOf:"89",location:"USA",birthplace:"UK",college:"UL",career:"army",sports:["soccer"],nickname:"Mick"}, + { school:"Dublin",classOf:"90",location:"Ireland",birthplace:"Ireland",college:"UCD",career:"law",sports:["soccer","gaelic"],nickname:"Johnjoe"}, + { school:"Dublin",classOf:"88",location:"Ireland",birthplace:"Ireland",college:"UCC",career:"teaching",sports:["handball","hurling"],nickname:"Mossy"}, + ]; + //analyse data to populate menus etc, this may be loaded direct from corresponding server data + classOfRange={}; + classOfRange.start=3000; + classOfRange.end=0; + birthplaces={}; + colleges={}; + locations={}; + for (var i in data) { + var year = parseInt(data[i].classOf); + classOfRange.start=Math.min(classOfRange.start,year); + classOfRange.end=Math.max(classOfRange.end,year); + if (data[i].birthplace in birthplaces) birthplaces[data[i].birthplace]++; + else birthplaces[data[i].birthplace]=1; + if (data[i].college in colleges) colleges[data[i].college]++; + else colleges[data[i].college]=1; + if (data[i].location in locations) locations[data[i].location]++; + else locations[data[i].location]=1; + } + + var numYears=(classOfRange.end-classOfRange.start); + + //prepare all data for graphing + graphData={}; + for (i in fields) graphData[fields[i]]=new graphableData(fields[i]); + for (var i in data) { + var yearField + for (j in fields) { + if (fields[j]=="Class size") { + graphData[fields[j]].addElement("Class size",parseInt(data[i].classOf)); + } + else graphData[fields[j]].addElement(data[i][fieldNames[j]],parseInt(data[i].classOf)); + } + } + + ///* test + var message="from "+classOfRange.start+" to "+classOfRange.end+"\n"; + for (var i in graphData) message+=graphData[i].summary(); + alert(message); + //*/ +} + +function drawGraph() { + var color = "hsl(" + [.6, .5, .5] + ")"; + var numYears=(classOfRange.end-classOfRange.start); + var gutterX=10, + gutterY=16; + //draw grid + var gridX=(raphael.width-(gutterX*2))/numYears; + var gridY=(raphael.height-(gutterY*2)); + raphael.drawGrid(gutterX, gutterY, raphael.width-(gutterX*2), raphael.height -(gutterY*2), numYears, 10, "#000"); + //label axis + var txt = {font: '12px Helvetica, Arial', fill: "#fff"}; + for (var i=0;i<=numYears;i++) raphael.text(gutterX+(i*gridX),raphael.height-gutterY+8,classOfRange.start+i).attr(txt).toBack(); + //construct graph + var graph = raphael.path().attr({stroke: color, "stroke-width": 4, "stroke-linejoin": "round"}), + bgGraph = raphael.path().attr({stroke: "none", opacity: .3, fill: color}); + //default graph is 'Class size' + //find largest class + var classSize=[]; + for (var i=0;i<=numYears;i++) classSize[i]=0; + for (var i in data) { + classSize[parseInt(data[i].classOf)-classOfRange.start]++; + } + var classMax=0; + for (var i in classSize) classMax=Math.max(classMax,classSize[i]); + var path,bgPath; + var stepY=(gridY/classMax); + for (var i=0;i<=numYears;i++) { + var x=gutterX+(i*gridX), + y=raphael.height-gutterY-(stepY*classSize[i]); + if (!i) { + path=["M",x,y,"C",x,y]; + bgPath=["M", gutterX , raphael.height - gutterY, "L", x, y, "C", x, y]; + } + if (i&&i/n"; + menu+="\n"; + document.getElementById("menus").innerHTML=menu; +} + +function doGraph(which){ + //draw 1 or multiple graphs. animate between items + //maximum number of graphs + alert(fields[which]); +} diff --git a/test/where/ import mapinfo.html b/test/where/ import mapinfo.html new file mode 100644 index 0000000..a165f34 --- /dev/null +++ b/test/where/ import mapinfo.html @@ -0,0 +1,367 @@ + + + + OGR2OGR Cheatsheet + + +
+ + + + + + + +
+ PostGIS Spatial Database Engine + + UMN Mapserver + Boston Geographic Information Systems   Checkout our PostGIS in Action book.  First chapter is a free download   PostGreSQL Object Relational Database Management System
+ +
+ + + +
+ PostGIS in Action is out in hard-copy,
download the first chapter
and SQL Primer for free. + Tips and Tricks for PostGIS
+ + + +
+
+ + + + +
+
+
+ +
+ + +
+ + + + + + + + +
  + + GIS Article comments Comments Rss
+
OGR2OGR Cheatsheet

OGR Tools

+

The OGR toolkit is a subkit of the FW Tools Toolkit. The FW Tools Toolkit is a toolkit available in both Linux and Windows executable form as well as source code form. +It has several command line tools. The ones we find most useful are: +

    +
  • OgrInfo - inspects a GIS datasource and spits out summary data or detailed information about the layers, kinds of geometries found in the file.
  • + +
  • Ogr2Ogr - this is a command line tool that converts one Ogr defined data source to another Ogr data source. Ogr supports multiple data formats: ESRI Shapefile, MapInfo Tab file, TIGER, s57, DGN, CSV, DBF, GML, KML, Interlis, SQLite, ODBC, ESRI GeoDatabase (MDB format), PostGIS/PostgreSQL, MySQL .
  • +
+ +

These 2 command line tools can be found in the bin folder of your FWTools install. To start using these tools +

  1. Install the FW Tools tool kit.
  2. +
  3. Launch the FW Tools Shell - in windows this is found under Start->Programs->FW Tools ..
  4. +
  5. From the shell - cd into your directory that has the data you want to convert
  6. +

    + +

    Getting more Help

    +

    If you want a comprehensive listing of options offered by ogr2ogr or ogrinfo, run the following at the FW Tools Shell.

    +
    ogr2ogr --help
    +ogrinfo --help
    +
    +
    + +

    Conversions from MapInfo to Other formats

    +

    Conversion from MapInfo to ESRI Shape

    + +ogr2ogr -f "ESRI Shapefile" mydata.shp mydata.tab +

    Conversion from MapInfo to PostGIS

    +ogr2ogr -f "PostgreSQL" PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" mytabfile.tab + +

    Note: for the above, you can leave out the host if its localhost and user and password if you have your authentication set to trust.

    + +Importing as a different table name +

    In the below example, we don't want OGR to create a table called mytable. We instead want to call the table something different like newtablename. To do so we use the nln option. + +

    +ogr2ogr -f "PostgreSQL" PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" mytabfile.tab -nln newtablename +

    + + +

    When OGR guesses wrong or fails to guess

    +

    Sometimes OGR does not output the right projection, particularly with Units of Feet or data that has no projection info or the projection information can't be easily translated to your system. Sometimes OGR can't match the projection to one in your spatial_ref_sys table so creates a new entry in that table. In these cases you have to tell OGR what the output projection is. You do this with the -a_srs flag. +

    +ogr2ogr -f "PostgreSQL" -a_srs "EPSG:2249" PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" mytabfile.tab +

    + +

    In the above example I told OGR2OGR to assume the source/output projection is in Massachusetts Mainland US Ft. Note: All Spatial Ref Systems can be found in the spatial_ref_sys table of PostGIS or the Data/gcs.csv file of your FW Tools install.

    + +

    Conversions from PostGIS to Other formats

    +

    Conversion from PostGIS to ESRI Shape

    +

    The pgsql2shp and shp2pgsql are usually the best tools for converting back and forth between PostGIS and ESRI for 2 main reasons. + +

    • It has fewer idiosyncracies when converting data
    • +
    • It has a lot fewer dependencies so can fit on your floppy.
    • +

    +

    +

    If you really want to use Ogr2Ogr for this kind of conversion, below is the standard way to do it

    +
    +ogr2ogr -f "ESRI Shapefile" mydata.shp PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" "mytable" +

    +

    Selecting specific fields, sets of data and Geometry

    +

    Sometimes you have more than one geometry field in a table, and ESRI shape can only support one geometry field per shape. Also you may only want a subset of data. In these cases, you will need to select the geometry field to use. The most flexible way to do this is to use the -sql command which will take any sql statement.

    +
    + +ogr2ogr -f "ESRI Shapefile" mydata.shp PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" -sql "SELECT name, the_geom FROM neighborhoods" + +

    Example snippet converting from PostGIS to KML

    + +ogr2ogr -f "KML" neighborhoods.kml PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" -sql "select gid, name, the_geom from neighborhoods" + +
    The below outputs the neighborhood table to KML and sets the KML description field to name of neighborhood
    + +ogr2ogr -f "KML" neighborhoods.kml PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" neighborhoods -dsco NameField=name + + + +

    Exporting multiple tables from PostGIS using Ogr2Ogr

    +

    One way in which ogr2ogr excels above using the pgsql2shp tool is that ogr2ogr can export multiple tables at once. +This is pretty handy for sharing your postgis data with others who do not have a postgis database. +

    +

    The code below will export all your postgis tables out into a folder called mydatadump in ESRI shape (shp) format.

    + + + ogr2ogr -f "ESRI Shapefile" mydatadump PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" + +

    The code below will export all your postgis tables out into a folder called mydatadump in MapInfo .tab format.

    + + ogr2ogr -f "MapInfo File" mydatadump PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" + + +

    Now most of the time you probably only want to output a subset of your postgis tables rather than all your tables. This code exports only the neighborhoods and parcels tables to a folder called mydatadump in ESRI shapefile format + +

    + + ogr2ogr -f "ESRI Shapefile" mydatadump PG:"host=myhost user=myloginname dbname=mydbname password=mypassword" neighborhood parcels + + +

    Conversion from TIGER to other formats

    +

    Topologically Integrated Geographic Encoding and Referencing system (TIGER) is the US Census Bureaus proprietary format for exporting US Census geographic and statistical data. Starting in 2007, they will be using ESRI Shapefile (SHP) as there official export format. So this section may be a bit obsolete for the upcoming versions. +

    + +

    To get the files for your location - you can browse their archive at +http://www.census.gov/geo/www/tiger/index.html

    + +

    Reading the meta data using ogrinfo


    + + + ogrinfo TGR25025.RTI + + +

    Conversion from Tiger to ESRI shape

    +

    Give me all layers in TGR25025

    +

    The tiger files contain a set of layers, so unlike the other outputs we have done, we will specify a folder to dump all the layers into +

    +ogr2ogr -f "ESRI Shapefile" masuffolk TGR25025.RTI + +

    +Note: The above outputs all the tiger layers in the TGR25025 set into a folder called masuffolk that resides within our data folder that we have cded to. + + +

    Just One Layer

    +ogr2ogr -f "ESRI Shapefile" sufcomp.shp TGR25025.RT1 layer CompleteChain + +

    In the above, we are asking for just the CompleteChain layer and to output to a new file called sufcomp.shp. Note it will output shp and the corresponding shx, and prj files. +

    + +

    Conversion from TIGER to MapInfo

    +

    The conversion follows a similar path to ESRI Shape

    +

    All Layers - Each Layer as a single file

    +

    The below will create a folder masuf and output all the layers into that folder and give each a tab file extension

    +
    + +ogr2ogr -f "MapInfo File" masuf TGR25025.RT1 + +

    Single Layer - Single File

    +ogr2ogr -f "MapInfo File" sufcomp.tab TGR25025.RT1 layer CompleteChain + +

    Conversion from Tiger to PostGIS

    +ogr2ogr -update -append -f "PostGreSQL" PG:"host=myserver user=myusername dbname=mydbname password=mypassword" TGR25025.RT1 layer CompleteChain -nln masuf -a_srs "EPSG:4269" + + +

    Note in the above we needed to put the -update -append option because OGR2OGR will try to create a folder if given a file with no extension, which translates to creating a new database.

    + +

    We also put in the -nln masuf to prevent OGR2OGR from creating the table name as CompleteChain

    + +

    Lastly we put in EPSG:4269 to tell OGR to just assume Tiger is in NAD 83 long lat. Without this it creates an entry in the spatial_ref_sys table which is equivalent to the already existing well known 4269. +

    + +

    ESRI GeoDatabase (MDB format)

    +

    FWTools at least for windows, has the ESRI Geodatabase driver (referred to as PGeo for Personal Geodatabase) baked into the binary. This makes it relatively simple to export data out of the Personal Geodatabase +format into other formats such as PostgreSQL or ESRI Shape

    + +

    If you want a sample geo database to play with, try the MassGIS annotation personal geo database http://www.mass.gov/mgis/ftpgnm.htm + +

    See list of Feature Classes

    + +ogrinfo C:\GISData\Geonames.mdb + +
    INFO: Open of `c:\GISData\Geonames.mdb'
    +      using driver `PGeo' successful.
    +1: GEONAMES_ANNO_PLACES
    +2: GEONAMES_ANNO_HYDRO
    +3: GEONAMES_ANNO_HYPSO
    +
    + +

    Import Personal Geodatabase to PostGIS

    +

    To import all feature classes and assign a particular spatial ref

    + +ogr2ogr -f "PostgreSQL" PG:"host=localhost user=someuser dbname=somedb password=somepassword port=5432" C:\GISData\Geonames.mdb -a_srs EPSG:26986 + + +

    Import 1 feature class and reproject and rename geometry column. This example brings in a feature class that is of projection NAD 83 MA meters and transforms to NAD 83 longlat and also renames the feature +class ma_hydro

    + +ogr2ogr -f "PostgreSQL" PG:"host=localhost user=someuser dbname=somedb" C:\Data\Geonames.mdb GEONAMES_ANNO_HYDRO -a_srs EPSG: +26986 -t_srs EPSG:4269 -nln ma_hydro -lco GEOMETRY_NAME=the_geom_4269 + + + +

    Importing from ESRI Shape to MySQL

    +

    MySQL 4 and 5 support spatial objects to a limited extent. The functionality is not as rich as PostGIS, but for basic mapping work and limited spatial analysis, and if you already have MySQL installed, it may suit your needs just fine. Below is a snippet of code that will import a shape file called world_adm0.shp into a MySQL database and will rename it world. NOTE: that if you have a virgin MySQL database with no geometry_columns or spatial_ref_sys table, then those will automatically be created. +

    + + +ogr2ogr -f "MySQL" MYSQL:"mydb,host=myhost,user=mylogin,password=mypassword,port=3306" -nln "world" -a_srs "EPSG:4326" path/to/world_adm0.shp + + +

    Using OGR to Import Non-spatial Data

    +

    While OGR was designed primarily to transform data between different spatial datasources, it is a little known fact that it +can be used as well for importing non-spatial datasources such as Dbase files and CSV files.

    + +

    Importing Dbase file into PostgreSQL using Ogr2Ogr

    +

    In the below example, we will demonstrate importing a Dbase file into PostgreSQL using OGR2OGR

    +ogr2ogr -f "PostgreSQL" PG:"host=myserver user=myusername dbname=mydbname password=mypassword" sometable.dbf -nln "sometable"

    Post Comments About OGR2OGR Cheatsheet

    + + +
    + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     CommenterComment
    11/16/2011 6:14:14 PMHeidi OchisAny ideas on when or if the ESRI GeoDatabase(gdb)format will be included in the OGR2OGR conversion list?
    7/6/2011 4:55:58 AMRobHello,
    I am trying to convert a .shp file to a .tab file whilst also only selecting records that have a date field that equals within the last 30 days.

    However I am struggling to filter the data at all on the date field. I have tried using "-where" & "-sql" and I cannot filter the data even on a particular date. I think I must be using the wrong format for dates, but I've tried every combination I can think of.

    Does anyone have any examples of working "-where" or "-sql" clauses on date fields?

    Thanks
    5/18/2011 12:29:32 PMbespinI'm running 2008 SP1, not R2. I did find that if you include the table name as part of the conn string it works. It won't let me use -sql though so it's a bit less flexible.

    This works : http://pastebin.com/kTDuYg1a
    5/18/2011 3:24:46 AMReginaSorry -- no haven't tried. Are you running MSSQL 2008 plain or MSSQL 2008 R2. I recall people having issues with another loader I forget which when using against R2. So I presume there must have been changes between the 2 releases.
    5/16/2011 2:55:07 PMbespinHave you tried using the latest ogr2ogr (I'm running it from OSGeo4W) with MSSQL 2008 geometery? I'm having problems doing a simple dump to shp. The syntax is similar to what you have for PG.

    Every row returns the error "ERROR 1: GetNextRawFeature(): Corrupt data" The shp comes out with attributes and no geometry.
    4/28/2011 8:07:54 AMReginaGarret,

    I think you have your arguments confused. a_srs is the assumed projection and t_srs is what you want to transform it to.

    If it still doesn't work make sure OGR2OGR can find you epsg file. As I recall I think the environment variable is GDAL_DATA though install should have put that in.
    4/27/2011 3:31:48 PMgarrethi, great software. However, I cannot get -a_srs to work properly. I've specifed EPSG:29902 but when I add the PostGIS layer in QGIS, the projection is always geographic WGS84... so I have to manually specify the projection.
    4/25/2011 11:11:12 AMReginaEriovaldo,

    You need to set the encoding.

    Try setting the environment variable
    something like this.

    export PGCLIENTENCODING=latin1

    On windows 7 set it in system -> Control Panel -> System -> Advanced System Settings -> Environment variables
    4/21/2011 3:03:57 PMEriovaldoI am using ogr2ogr and I got in trouble with the tool running on DOS - Windows 7.
    The command does not work fine when using special characters.

    For example:

    Command: INSERT INTO "spatial_treina"."table" ("id", "name")
    VALUES (5470, '231260', 'SÒo LuÝs do Curu')
    RETURNING ogc_fid
    ERROR 1: INSERT command for new feature failed.
    ERRO: sequ+¬ncia de bytes +® inv+ílida para codifica+º+úo "UTF8": 0xe36f20

    the correct should be: São Luís do Curu.

    How can I configure the DOS in order do not generate this kind of character.
    1/21/2010 10:07:18 PMChris McCarthyThe code suggestion for converting MapInfo to PostGIS didn't work for me because a quotation mark was in the wrong place. It should read:

    ogr2ogr -f "PostgreSQL" "PG:host=myhost user=myloginname dbname=mydbname password=mypassword" mytabfile.tab

    Note the double quote after PG: should be before PG:.

    This dogged me for a whole day.
    7/17/2009 5:32:28 PMReginaI'm not sure its possible with plain OGR2OGR. I know its doable in UMN Mapserver using the OGR2OGR driver so I assume it must be possible. I'll experiment with this and see what I come up with.

    Is output the folder where your shape and dbf files reside? I suspect for this to work, you need to specifiy the folder name not the shapefile name as you would normally.

    Here is an example of how its done in UMN Mapserver

    http://www.mail-archive.com/mapserver-users@lists.umn.edu/msg13477.html
    7/10/2009 7:32:07 PMKRDI would like to see the syntax for an OGR2OGR join involving a shapefile and a dbf lookup table. The following syntax should work, but does not:

    SELECT * FROM table1, table2 WHERE table1.field1=table2.fieldA

    Neither JOIN nor LEFT JOIN syntax works either.

    An example of what I really want to do is:

    ogr2ogr -sql "SELECT * FROM soils LEFT JOIN master ON soils.MUKEY = master.MUKEY" output soils.shp

    If I can get the join working, then I can move on to enhance the operation to select only certain field and records (shapes)

    Thanks,
    +
    +
    + + + + + + + + + + + + +
     
    + GDAL and OGR: geodata conversion and re-projection tools +
    Demonstrates using Ogr and GDAL to reproject vector and raster data. This is a tutorial provided by California Soil Resource Lab.
    + FW Tools - GIS Tool Kit +
    + GDAL OGR2OGR for Data Loading +
    Article detailing how to use ogr2ogr for loading non-spatial data into PostgreSQL.
    + Loading TIGER basedata: GeoServer and PostGIS +
    +
    +
+ + +
+
+ +
+ +

+ This Document is available under the GNU Free Documentation License 1.2 + http://www.gnu.org/copyleft/fdl.html & for download at the BostonGIS site http://www.bostongis.com +

+
+ Boston GIS      Copyright 2012      Paragon Corporation +
+
+ + + + + \ No newline at end of file diff --git a/test/where/CousinMarriageWorld.svgz b/test/where/CousinMarriageWorld.svgz new file mode 100644 index 0000000..c815dda Binary files /dev/null and b/test/where/CousinMarriageWorld.svgz differ diff --git a/test/where/Ireland_complete.svg b/test/where/Ireland_complete.svg new file mode 100644 index 0000000..698fd38 --- /dev/null +++ b/test/where/Ireland_complete.svg @@ -0,0 +1,291 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Ireland-Counties + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/where/Ireland_inks.svg b/test/where/Ireland_inks.svg new file mode 100644 index 0000000..f032966 --- /dev/null +++ b/test/where/Ireland_inks.svg @@ -0,0 +1,312 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/where/Ireland_just_counties.svg b/test/where/Ireland_just_counties.svg new file mode 100644 index 0000000..0eb483c --- /dev/null +++ b/test/where/Ireland_just_counties.svg @@ -0,0 +1,316 @@ + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/where/Ireland_trad_counties_inks.svg b/test/where/Ireland_trad_counties_inks.svg new file mode 100644 index 0000000..ab50542 --- /dev/null +++ b/test/where/Ireland_trad_counties_inks.svg @@ -0,0 +1,1600 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/where/Ireland_trad_counties_named.svg b/test/where/Ireland_trad_counties_named.svg new file mode 100644 index 0000000..5c24e51 --- /dev/null +++ b/test/where/Ireland_trad_counties_named.svg @@ -0,0 +1,1481 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/where/Ireland_trad_counties_named_RU.svg b/test/where/Ireland_trad_counties_named_RU.svg new file mode 100644 index 0000000..d1c6b5b --- /dev/null +++ b/test/where/Ireland_trad_counties_named_RU.svg @@ -0,0 +1,1611 @@ + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + 22 June 2007 + + + Fut.Perf. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git "a/test/where/Rapha\303\253l \302\267 Australia.html" "b/test/where/Rapha\303\253l \302\267 Australia.html" new file mode 100644 index 0000000..00aa196 --- /dev/null +++ "b/test/where/Rapha\303\253l \302\267 Australia.html" @@ -0,0 +1,162 @@ + + + + + Raphaël · Australia + + + + + + + +
+
Created with Raphaël 2.0.0
+
+

New South Wales

+

+ New South Wales (abbreviated as NSW) is Australia’s oldest and most populous state, located in the south-east of the + country, north of Victoria and south of Queensland. It was founded in 1788 and originally comprised much of the + Australian mainland, as well as Lord Howe Island and Norfolk Island. New Zealand was not initially part of the colony, + although when Britain annexed New Zealand in 1840 it was briefly a part of New South Wales. During the 19th century + large areas were successively separated to form the British colonies of Tasmania, South Australia, Victoria, + Queensland, and New Zealand. +

+
+
+

Victoria

+

+ Victoria is a state located in the south-eastern corner of Australia. It is the smallest mainland state in area but + the most densely populated and urbanised. Prior to European settlement, some 30,000 Indigenous Australians lived in + the area now occupied by the state. By contrast, over five million people now inhabit the region. European settlement + in Victoria began in the 1830s as a farming community. Victoria is the second most populous Australian state, after New South Wales, with + an estimated population of 5,205,200 as of June 2007. Melbourne is Victoria’s capital and largest city, with more + than 70% of all Victorians living there. +

+
+
+

Western Australia

+

+ Western Australia is a state occupying the entire western third of the Australian continent. The nation’s largest + state and the second largest sub-national entity in the world, it has 2.1 million inhabitants (10% of the national + total), 85% of whom live in the south-west corner of the state. The people of Western Australia are often + colloquially referred to as sand-gropers, the common name of an insect found on sand dunes around Perth. +

+
+
+

South Australia

+

+ South Australia is a state of Australia in the southern central part of the country. It covers some of the most arid + parts of the continent; with a total land area of 983,482 square kilometres, it is the fourth largest + of Australia’s six states and two territories. It is bordered to the west by Western Australia, to the north by the + Northern Territory and Queensland, to the east by Queensland, New South Wales and Victoria, and along the south by + the Great Australian Bight and the Southern Ocean. With nearly 1.6 million people, the state comprises less than + 10% of the Australian population and ranks fifth in population among the states and territories. +

+
+
+

Northern Territory

+

+ The Northern Territory is a federal territory of Australia, occupying much of the center of the mainland continent, + as well as the central northern regions. It shares borders with Western Australia to the west, South Australia to the + south, and Queensland to the east. To the north, the territory is bordered by the Timor Sea, the Arafura Sea and the + Gulf of Carpentaria. Despite its large area — over 1,349,129 square kilometres, making it the third + largest Australian federal division — it is sparsely populated. With a population of 218,380 it is the least populous + division in the country. +

+
+
+

Queensland

+

+ Queensland is a state of Australia, occupying the north-eastern corner of the mainland continent. It is bordered by + the Northern Territory to the west, South Australia to the south-west and New South Wales to the south. To the east, + Queensland is bordered by the Coral Sea and Pacific Ocean. The state is Australia’s second largest by area, following + Western Australia, and the country's third most populous after New South Wales and Victoria. +

+
+
+

Tasmania

+

+ Tasmania is an Australian island and state of the same name. It is located 240 kilometres south of the + eastern side of the continent, being separated from it by Bass Strait. The state of Tasmania includes the island of + Tasmania and other surrounding islands. Tasmania has an estimated population of 494,520 (March 2008) and an area + of 68,401 square kilometres. + Tasmania is promoted as the Natural State and the "Island of Inspiration" owing to its large and relatively + unspoiled natural environment. The island is 364 kilometres long from the northernmost point to the southernmost point and 306 + kilometres from west to east. +

+
+
+

Demo of Raphaël—JavaScript Vector Library

+ + + \ No newline at end of file diff --git a/test/where/Republic_of_Ireland_counties_and_cities.svg b/test/where/Republic_of_Ireland_counties_and_cities.svg new file mode 100644 index 0000000..165a110 --- /dev/null +++ b/test/where/Republic_of_Ireland_counties_and_cities.svg @@ -0,0 +1,7494 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/where/World_map_-_low_resolution.svgz b/test/where/World_map_-_low_resolution.svgz new file mode 100644 index 0000000..35ba55d Binary files /dev/null and b/test/where/World_map_-_low_resolution.svgz differ diff --git a/test/where/demo-print.css b/test/where/demo-print.css new file mode 100644 index 0000000..04c724b --- /dev/null +++ b/test/where/demo-print.css @@ -0,0 +1,20 @@ +body { + background: #fff; + color: #000; + font: 100.1% "Lucida Grande", Lucida, Verdana, sans-serif; +} +#holder { + height: 480px; + left: 50%; + margin: 0 0 0 -320px; + position: absolute; + top: 0; + width: 640px; +} +#copy { + bottom: 0; + font-size: .7em; + position: absolute; + right: 1em; + text-align: right; +} diff --git a/test/where/demo.css b/test/where/demo.css new file mode 100644 index 0000000..a7940af --- /dev/null +++ b/test/where/demo.css @@ -0,0 +1,23 @@ +body { + background: #333; + color: #fff; + font: 300 100.1% "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; +} +#holder { + height: 480px; + left: 50%; + margin: -240px 0 0 -320px; + position: absolute; + top: 50%; + width: 640px; +} +#copy { + bottom: 0; + font: 300 .7em "Helvetica Neue", Helvetica, "Arial Unicode MS", Arial, sans-serif; + position: absolute; + right: 1em; + text-align: right; +} +#copy a { + color: #fff; +} diff --git a/test/where/g.raphael-min.js b/test/where/g.raphael-min.js new file mode 100644 index 0000000..ec0ce1f --- /dev/null +++ b/test/where/g.raphael-min.js @@ -0,0 +1,7 @@ +/*! + * g.Raphael 0.5 - Charting library, based on Raphaël + * + * Copyright (c) 2009 Dmitry Baranovskiy (http://g.raphaeljs.com) + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license. + */ +Raphael.el.popup=function(d,k,h,g){var c=this.paper||this[0].paper,f,j,b,e,a;if(!c){return}switch(this.type){case"text":case"circle":case"ellipse":b=true;break;default:b=false}d=d==null?"up":d;k=k||5;f=this.getBBox();h=typeof h=="number"?h:(b?f.x+f.width/2:f.x);g=typeof g=="number"?g:(b?f.y+f.height/2:f.y);e=Math.max(f.width/2-k,0);a=Math.max(f.height/2-k,0);this.translate(h-f.x-(b?f.width/2:0),g-f.y-(b?f.height/2:0));f=this.getBBox();var i={up:["M",h,g,"l",-k,-k,-e,0,"a",k,k,0,0,1,-k,-k,"l",0,-f.height,"a",k,k,0,0,1,k,-k,"l",k*2+e*2,0,"a",k,k,0,0,1,k,k,"l",0,f.height,"a",k,k,0,0,1,-k,k,"l",-e,0,"z"].join(","),down:["M",h,g,"l",k,k,e,0,"a",k,k,0,0,1,k,k,"l",0,f.height,"a",k,k,0,0,1,-k,k,"l",-(k*2+e*2),0,"a",k,k,0,0,1,-k,-k,"l",0,-f.height,"a",k,k,0,0,1,k,-k,"l",e,0,"z"].join(","),left:["M",h,g,"l",-k,k,0,a,"a",k,k,0,0,1,-k,k,"l",-f.width,0,"a",k,k,0,0,1,-k,-k,"l",0,-(k*2+a*2),"a",k,k,0,0,1,k,-k,"l",f.width,0,"a",k,k,0,0,1,k,k,"l",0,a,"z"].join(","),right:["M",h,g,"l",k,-k,0,-a,"a",k,k,0,0,1,k,-k,"l",f.width,0,"a",k,k,0,0,1,k,k,"l",0,k*2+a*2,"a",k,k,0,0,1,-k,k,"l",-f.width,0,"a",k,k,0,0,1,-k,-k,"l",0,-a,"z"].join(",")};j={up:{x:-!b*(f.width/2),y:-k*2-(b?f.height/2:f.height)},down:{x:-!b*(f.width/2),y:k*2+(b?f.height/2:f.height)},left:{x:-k*2-(b?f.width/2:f.width),y:-!b*(f.height/2)},right:{x:k*2+(b?f.width/2:f.width),y:-!b*(f.height/2)}}[d];this.translate(j.x,j.y);return c.path(i[d]).attr({fill:"#000",stroke:"none"}).insertBefore(this.node?this:this[0])};Raphael.el.tag=function(f,b,l,k){var i=3,e=this.paper||this[0].paper;if(!e){return}var c=e.path().attr({fill:"#000",stroke:"#000"}),j=this.getBBox(),m,h,a,g;switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}f=f||0;l=typeof l=="number"?l:(a?j.x+j.width/2:j.x);k=typeof k=="number"?k:(a?j.y+j.height/2:j.y);b=b==null?5:b;h=0.5522*b;if(j.height>=b*2){c.attr({path:["M",l,k+b,"a",b,b,0,1,1,0,-b*2,b,b,0,1,1,0,b*2,"m",0,-b*2-i,"a",b+i,b+i,0,1,0,0,(b+i)*2,"L",l+b+i,k+j.height/2+i,"l",j.width+2*i,0,0,-j.height-2*i,-j.width-2*i,0,"L",l,k-b-i].join(",")})}else{m=Math.sqrt(Math.pow(b+i,2)-Math.pow(j.height/2+i,2));c.attr({path:["M",l,k+b,"c",-h,0,-b,h-b,-b,-b,0,-h,b-h,-b,b,-b,h,0,b,b-h,b,b,0,h,h-b,b,-b,b,"M",l+m,k-j.height/2-i,"a",b+i,b+i,0,1,0,0,j.height+2*i,"l",b+i-m+j.width+2*i,0,0,-j.height-2*i,"L",l+m,k-j.height/2-i].join(",")})}f=360-f;c.rotate(f,l,k);if(this.attrs){this.attr(this.attrs.x?"x":"cx",l+b+i+(!a?this.type=="text"?j.width:0:j.width/2)).attr("y",a?k:k-j.height/2);this.rotate(f,l,k);f>90&&f<270&&this.attr(this.attrs.x?"x":"cx",l-b-i-(!a?j.width:j.width/2)).rotate(180,l,k)}else{if(f>90&&f<270){this.translate(l-j.x-j.width-b-i,k-j.y-j.height/2);this.rotate(f-180,j.x+j.width+b+i,j.y+j.height/2)}else{this.translate(l-j.x+b+i,k-j.y-j.height/2);this.rotate(f,j.x-b-i,j.y+j.height/2)}}return c.insertBefore(this.node?this:this[0])};Raphael.el.drop=function(d,g,f){var e=this.getBBox(),c=this.paper||this[0].paper,a,j,b,i,h;if(!c){return}switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}d=d||0;g=typeof g=="number"?g:(a?e.x+e.width/2:e.x);f=typeof f=="number"?f:(a?e.y+e.height/2:e.y);j=Math.max(e.width,e.height)+Math.min(e.width,e.height);b=c.path(["M",g,f,"l",j,0,"A",j*0.4,j*0.4,0,1,0,g+j*0.7,f-j*0.7,"z"]).attr({fill:"#000",stroke:"none"}).rotate(22.5-d,g,f);d=(d+90)*Math.PI/180;i=(g+j*Math.sin(d))-(a?0:e.width/2);h=(f+j*Math.cos(d))-(a?0:e.height/2);this.attrs?this.attr(this.attrs.x?"x":"cx",i).attr(this.attrs.y?"y":"cy",h):this.translate(i-e.x,h-e.y);return b.insertBefore(this.node?this:this[0])};Raphael.el.flag=function(e,k,j){var g=3,c=this.paper||this[0].paper;if(!c){return}var b=c.path().attr({fill:"#000",stroke:"#000"}),i=this.getBBox(),f=i.height/2,a;switch(this.type){case"text":case"circle":case"ellipse":a=true;break;default:a=false}e=e||0;k=typeof k=="number"?k:(a?i.x+i.width/2:i.x);j=typeof j=="number"?j:(a?i.y+i.height/2:i.y);b.attr({path:["M",k,j,"l",f+g,-f-g,i.width+2*g,0,0,i.height+2*g,-i.width-2*g,0,"z"].join(",")});e=360-e;b.rotate(e,k,j);if(this.attrs){this.attr(this.attrs.x?"x":"cx",k+f+g+(!a?this.type=="text"?i.width:0:i.width/2)).attr("y",a?j:j-i.height/2);this.rotate(e,k,j);e>90&&e<270&&this.attr(this.attrs.x?"x":"cx",k-f-g-(!a?i.width:i.width/2)).rotate(180,k,j)}else{if(e>90&&e<270){this.translate(k-i.x-i.width-f-g,j-i.y-i.height/2);this.rotate(e-180,i.x+i.width+f+g,i.y+i.height/2)}else{this.translate(k-i.x+f+g,j-i.y-i.height/2);this.rotate(e,i.x-f-g,i.y+i.height/2)}}return b.insertBefore(this.node?this:this[0])};Raphael.el.label=function(){var c=this.getBBox(),b=this.paper||this[0].paper,a=Math.min(20,c.width+10,c.height+10)/2;if(!b){return}return b.rect(c.x-a/2,c.y-a/2,c.width+a,c.height+a,a).attr({stroke:"none",fill:"#000"}).insertBefore(this.node?this:this[0])};Raphael.el.blob=function(z,j,i){var g=this.getBBox(),B=Math.PI/180,n=this.paper||this[0].paper,r,A,q;if(!n){return}switch(this.type){case"text":case"circle":case"ellipse":A=true;break;default:A=false}r=n.path().attr({fill:"#000",stroke:"none"});z=(+z+1?z:45)+90;q=Math.min(g.height,g.width);j=typeof j=="number"?j:(A?g.x+g.width/2:g.x);i=typeof i=="number"?i:(A?g.y+g.height/2:g.y);var m=Math.max(g.width+q,q*25/12),t=Math.max(g.height+q,q*25/12),u=j+q*Math.sin((z-22.5)*B),b=i+q*Math.cos((z-22.5)*B),v=j+q*Math.sin((z+22.5)*B),d=i+q*Math.cos((z+22.5)*B),o=(v-u)/2,l=(d-b)/2,f=m/2,e=t/2,s=-Math.sqrt(Math.abs(f*f*e*e-f*f*l*l-e*e*o*o)/(f*f*l*l+e*e*o*o)),c=s*f*l/e+(v+u)/2,a=s*-e*o/f+(d+b)/2;r.attr({x:c,y:a,path:["M",j,i,"L",v,d,"A",f,e,0,1,1,u,b,"z"].join(",")});this.translate(c-g.x-g.width/2,a-g.y-g.height/2);return r.insertBefore(this.node?this:this[0])};Raphael.fn.label=function(a,d,b){var c=this.set();b=this.text(a,d,b).attr(Raphael.g.txtattr);return c.push(b.label(),b)};Raphael.fn.popup=function(a,f,d,b,c){var e=this.set();d=this.text(a,f,d).attr(Raphael.g.txtattr);return e.push(d.popup(b,c),d)};Raphael.fn.tag=function(a,f,d,c,b){var e=this.set();d=this.text(a,f,d).attr(Raphael.g.txtattr);return e.push(d.tag(c,b),d)};Raphael.fn.flag=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.flag(b),c)};Raphael.fn.drop=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.drop(b),c)};Raphael.fn.blob=function(a,e,c,b){var d=this.set();c=this.text(a,e,c).attr(Raphael.g.txtattr);return d.push(c.blob(b),c)};Raphael.el.lighter=function(b){b=b||2;var a=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[a[0],a[1]];a[0]=Raphael.rgb2hsb(Raphael.getRGB(a[0]).hex);a[1]=Raphael.rgb2hsb(Raphael.getRGB(a[1]).hex);a[0].b=Math.min(a[0].b*b,1);a[0].s=a[0].s/b;a[1].b=Math.min(a[1].b*b,1);a[1].s=a[1].s/b;this.attr({fill:"hsb("+[a[0].h,a[0].s,a[0].b]+")",stroke:"hsb("+[a[1].h,a[1].s,a[1].b]+")"});return this};Raphael.el.darker=function(b){b=b||2;var a=[this.attrs.fill,this.attrs.stroke];this.fs=this.fs||[a[0],a[1]];a[0]=Raphael.rgb2hsb(Raphael.getRGB(a[0]).hex);a[1]=Raphael.rgb2hsb(Raphael.getRGB(a[1]).hex);a[0].s=Math.min(a[0].s*b,1);a[0].b=a[0].b/b;a[1].s=Math.min(a[1].s*b,1);a[1].b=a[1].b/b;this.attr({fill:"hsb("+[a[0].h,a[0].s,a[0].b]+")",stroke:"hsb("+[a[1].h,a[1].s,a[1].b]+")"});return this};Raphael.el.resetBrightness=function(){if(this.fs){this.attr({fill:this.fs[0],stroke:this.fs[1]});delete this.fs}return this};(function(){var c=["lighter","darker","resetBrightness"],a=["popup","tag","flag","label","drop","blob"];for(var b in a){(function(d){Raphael.st[d]=function(){return Raphael.el[d].apply(this,arguments)}})(a[b])}for(var b in c){(function(d){Raphael.st[d]=function(){for(var e=0;e0?0:0.5))*Math.pow(10,b))/Math.pow(10,b);return{from:e,to:l,power:b}},axis:function(p,o,k,D,e,G,g,J,h,a,q){a=a==null?2:a;h=h||"t";G=G||10;q=arguments[arguments.length-1];var C=h=="|"||h==" "?["M",p+0.5,o,"l",0,0.001]:g==1||g==3?["M",p+0.5,o,"l",0,-k]:["M",p,o+0.5,"l",k,0],s=this.snapEnds(D,e,G),H=s.from,z=s.to,F=s.power,E=0,w={font:"11px 'Fontin Sans', Fontin-Sans, sans-serif"},v=q.set(),I;I=(z-H)/G;var n=H,m=F>0?F:0;r=k/G;if(+g==1||+g==3){var b=o,u=(g-1?1:-1)*(a+3+!!(g-1));while(b>=o-k){h!="-"&&h!=" "&&(C=C.concat(["M",p-(h=="+"||h=="|"?a:!(g-1)*a*2),b+0.5,"l",a*2+1,0]));v.push(q.text(p+u,b,(J&&J[E++])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w).attr({"text-anchor":g-1?"start":"end"}));n+=I;b-=r}if(Math.round(b+r-(o-k))){h!="-"&&h!=" "&&(C=C.concat(["M",p-(h=="+"||h=="|"?a:!(g-1)*a*2),o-k+0.5,"l",a*2+1,0]));v.push(q.text(p+u,o-k,(J&&J[E])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w).attr({"text-anchor":g-1?"start":"end"}))}}else{n=H;m=(F>0)*F;u=(g?-1:1)*(a+9+!g);var c=p,r=k/G,A=0,B=0;while(c<=p+k){h!="-"&&h!=" "&&(C=C.concat(["M",c+0.5,o-(h=="+"?a:!!g*a*2),"l",0,a*2+1]));v.push(A=q.text(c,o+u,(J&&J[E++])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w));var l=A.getBBox();if(B>=l.x-5){v.pop(v.length-1).remove()}else{B=l.x+l.width}n+=I;c+=r}if(Math.round(c-r-p-k)){h!="-"&&h!=" "&&(C=C.concat(["M",p+k+0.5,o-(h=="+"?a:!!g*a*2),"l",0,a*2+1]));v.push(q.text(p+k,o+u,(J&&J[E])||(Math.round(n)==n?n:+n.toFixed(m))).attr(w))}}var K=q.path(C);K.text=v;K.all=q.set([K,v]);K.remove=function(){this.text.remove();this.constructor.prototype.remove.call(this)};return K},labelise:function(a,c,b){if(a){return(a+"").replace(/(##+(?:\.#+)?)|(%%+(?:\.%+)?)/g,function(d,f,e){if(f){return(+c).toFixed(f.replace(/^#+\.?/g,"").length)}if(e){return(c*100/b).toFixed(e.replace(/^%+\.?/g,"").length)+"%"}})}else{return(+c).toFixed(0)}}}; \ No newline at end of file diff --git a/test/where/importdemo.html b/test/where/importdemo.html new file mode 100644 index 0000000..b2f9240 --- /dev/null +++ b/test/where/importdemo.html @@ -0,0 +1,813 @@ + + + + + + + + + demo.html at master from wout/raphael-svg-import - GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+

+ wout / + raphael-svg-import +

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +

Latest commit to the master branch

+ +
+

+ updated raphael to 1.5.2 + +

+
+ commit 9d59748129 + +
+ + wout + authored + +
+
+
+ + + +
+ + + +
+
+ + +
+
+
+
+ Txt + 100644 + 37 lines (35 sloc) + 1.141 kb +
+ +
+
+ + + + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+
+
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>Raphael SVG Import - Interactive demo</title>
    <style type="text/css" media="screen">
      body, html {
        margin: 0;
        padding: 0;
        background-color: #fff;
        height: 100%;
      }
      #paper {
        width:100%;
        height: 100%;
      }
      #buttons {
        position: absolute;
        right: 10px;
        top: 10px;
      }
    </style>
  </head>
  
  <body>
    <div id="paper"></div>
    <div id="buttons">
      <input type="button" name="import" value="Import SVG" class="button" onclick="importSVG()" />
    </div>
  </body>
  <script src="lib/raphael-min.js" type="text/javascript" charset="utf-8"></script>
  <script src="lib/raphael-shapes.js" type="text/javascript" charset="utf-8"></script>
  <script src="raphael-svg-import.js" type="text/javascript" charset="utf-8"></script>
  <script src="src/demo.js" type="text/javascript" charset="utf-8"></script>
</html>

+
+
+ +
+
+
+
+ +
+ + + +
+
+ + + + + + + + + +
+

Markdown Cheat Sheet

+ +
+ +
+
+

Format Text

+

Headers

+
+# This is an <h1> tag
+## This is an <h2> tag
+###### This is an <h6> tag
+

Text styles

+
+*This text will be italic*
+_This will also be italic_
+**This text will be bold**
+__This will also be bold__
+
+*You **can** combine them*
+
+
+
+

Lists

+

Unordered

+
+* Item 1
+* Item 2
+  * Item 2a
+  * Item 2b
+

Ordered

+
+1. Item 1
+2. Item 2
+3. Item 3
+   * Item 3a
+   * Item 3b
+
+
+

Miscellaneous

+

Images

+
+![GitHub Logo](/images/logo.png)
+Format: ![Alt Text](url)
+
+

Links

+
+http://github.com - automatic!
+[GitHub](http://github.com)
+

Blockquotes

+
+As Kanye West said:
+
+> We're living the future so
+> the present is our past.
+
+
+
+
+ +

Code Examples in Markdown

+
+

Syntax highlighting with GFM

+
+```javascript
+function fancyAlert(arg) {
+  if(arg) {
+    $.facebox({div:'#foo'})
+  }
+}
+```
+
+
+

Or, indent your code 4 spaces

+
+Here is a Python code example
+without syntax highlighting:
+
+    def foo:
+      if not bar:
+        return true
+
+
+

Inline code for comments

+
+I think you should use an
+`<addr>` element here instead.
+
+
+ +
+
+ + +
+ +
+

Something went wrong with that request. Please try again. Dismiss

+
+ + + + + + + diff --git a/test/where/index.html b/test/where/index.html new file mode 100644 index 0000000..3451dc2 --- /dev/null +++ b/test/where/index.html @@ -0,0 +1,50 @@ + + + + + Raphaël · Australia + + + + + + + +
+
+
+
+
+
+
+

Demo of Raphaël—JavaScript Vector Library

+ + \ No newline at end of file diff --git a/test/where/main.js b/test/where/main.js new file mode 100644 index 0000000..f678efa --- /dev/null +++ b/test/where/main.js @@ -0,0 +1,42 @@ +window.onload = function () { + var R = Raphael("paper", 300, 300); + var attr = { + fill: "#333", + stroke: "#666", + "stroke-width": 1, + "stroke-linejoin": "round" + }; + var eire = {}; + //eire.kerry = R.path("m 106.0225,848.20339 c -0.306,10e-4 -0.53263,0.0705 -0.63191,0.23774 -1.41569,2.38404 -3.0829,3.18648 -5.05527,2.42748 -0.702485,-0.27028 -2.198339,-2.73104 -2.627742,-1.0135 -0.236592,0.94633 -2.869687,3.13447 -3.441093,1.42028 -0.428767,-1.28639 -2.428612,-2.20425 -2.827949,-0.60698 -0.08231,0.32934 -1.569962,4.01148 -1.620429,4.04176 -2.527956,1.51678 -1.566308,2.39064 -2.62774,4.24818 -1.264954,2.21366 -2.786796,2.02621 -5.055271,3.03446 -0.606733,0.26963 -1.2895,0.40863 -1.820654,0.80704 -0.7627,0.572 -2.602979,-0.51819 -2.8342,0.40668 -0.266543,1.06616 -1.991021,3.20849 -3.84151,1.82065 -1.066988,-0.80024 -5.261736,-2.49776 -5.261736,0 0,1.48329 -0.0499,4.8488 2.027113,4.8488 2.572878,0 1.931134,1.31943 3.434832,1.8207 3.342845,1.11421 -0.141133,3.29369 1.620439,5.05527 0.976629,0.97662 2.364761,3.06445 0.406674,3.84766 -1.125889,0.45042 -4.231627,1.7216 -0.606883,2.62779 1.028513,0.25717 2.55558,-0.60688 4.241918,-0.60688 0.984732,0 4.014706,-0.52725 4.248185,0.40668 0.610116,2.44049 -3.286812,3.28137 -5.055271,3.63509 -1.053388,0.21062 -9.039305,0.52604 -9.103247,0.20646 -0.456296,-2.28158 -3.944878,-1.14299 -4.041709,-1.8207 -0.216065,-1.51247 -2.227322,-2.05879 -2.227322,-3.44104 0,-1.54401 1.553414,-2.90688 -0.400418,-2.62779 -0.969135,0.13845 -4.071791,0.75319 -3.234618,2.42759 0.410058,0.8201 0.807087,1.10385 0.807087,2.0208 0,3.21335 -0.751734,1.41398 -2.8342,1.41398 -2.930971,0 -3.609023,0.39366 -6.062582,1.62049 -1.109757,0.55483 -1.9475,0.14099 -1.320116,-1.11371 0.01977,-0.0396 1.749479,-3.80727 1.420221,-3.74136 -2.975868,0.59508 -2.998006,2.11291 -5.161627,2.83416 -0.741969,0.31798 -1.654751,1.22518 -2.221071,1.41392 -1.448686,0.48291 -3.884495,0.24726 -3.441083,2.02091 0.255426,1.02172 0.606883,1.77265 0.606883,3.03437 0,2.2574 -2.002823,-0.018 -3.234623,1.21386 -1.55342,1.55337 -3.569947,-0.0575 -4.248179,-1.41407 -0.200434,-0.40082 -2.427531,-2.3501 -2.427531,-0.40663 0,1.21347 0,2.42788 0,3.6413 0,0.87902 -2.673293,0.66029 -2.221071,1.41397 1.192518,1.98758 1.413979,1.54121 1.413979,3.44109 0,1.50742 -0.432401,2.81509 0.807092,3.43488 0.269656,0.13474 0.537845,0.2842 0.813353,0.40663 0.606717,0.26968 1.097824,0.2466 1.714282,0 0.917522,-0.36699 1.698356,-1.36147 2.734096,-1.62049 1.268933,-0.31718 1.185296,-1.99093 2.62774,-1.41393 1.579016,0.63161 1.938366,-0.11772 3.034424,-1.21376 1.984809,-1.98477 0.669328,0.33365 2.827948,0.81335 0.606718,0.13484 1.199121,0.40041 1.820639,0.40041 0.938974,0 2.406269,-1.91825 2.634006,-1.0073 0.274291,1.09715 0.919013,2.8279 2.421265,2.828 1.514324,0 2.090039,-1.01361 2.634006,-1.01361 1.443305,0 2.351977,-0.99473 3.841501,-1.2075 1.614528,-0.23065 6.449149,1.12557 7.68301,0.2002 1.679697,-1.25981 2.604741,-0.79868 4.24818,-1.62044 1.614428,-0.80724 2.248594,-1.61413 4.248184,-1.61413 0.393025,0 5.25548,0.12348 5.25548,1.41393 0,2.23778 -0.641519,2.27302 -1.820653,4.04176 -0.80547,1.20811 -2.200965,2.7375 -4.241928,2.22727 -1.383713,-0.34596 -2.498891,-1.48154 -4.24817,-0.60688 -1.466939,0.73351 0.01427,2.94452 -0.813353,3.44114 -1.963722,1.17818 -3.868203,1.73075 -6.062571,2.8279 -1.744459,0.87226 -4.358625,0.51879 -6.875919,1.62049 -1.744214,0.76324 -4.278256,2.47683 -6.068823,2.22101 -0.943794,-0.13484 -2.094019,0.85685 -3.034424,1.01356 -1.714738,0.2858 -0.775814,2.33018 -1.213761,2.42758 -1.795297,0.39887 -4.468504,0.31993 -3.84151,2.8279 0.286444,1.14574 1.824287,3.23097 0.807101,4.24818 -1.909175,1.90919 -0.576741,3.44109 -4.648602,3.44109 -0.981368,0 -4.269131,1.60632 -4.248179,1.61418 0.790009,0.29621 3.84151,1.22673 3.84151,2.62779 0,0.6243 -0.341981,4.48377 0,4.65485 0.548187,0.27404 3.411012,1.21367 4.047961,1.21372 0.292725,0 2.597694,-1.59046 2.62774,-1.62049 0.282975,-0.2829 0.62335,-1.64362 1.213771,-2.62769 0.261227,-0.43541 3.039143,-3.62553 3.8415,-2.02081 0.941281,1.88251 0.338993,3.43398 -1.013552,4.44829 -1.84631,1.38474 -0.05184,2.57589 1.013552,3.64135 0.895624,0.89563 3.434841,0.34756 3.434841,1.61413 0,3.33848 -0.0482,4.06193 3.034409,3.03446 1.147512,-0.38255 2.048416,-2.0208 3.847767,-2.0208 3.071568,0 1.801604,-1.83472 3.434827,-3.23468 0.471902,-0.40452 0.792451,-1.21381 1.413969,-1.21376 2.401224,0 1.736751,-0.93873 3.441093,-1.62049 2.544678,-1.01786 5.461945,1.3459 5.461945,1.01366 0,-2.40131 3.370099,-0.27729 4.241928,-2.02091 1.057383,-2.11481 1.442439,-2.02712 4.24817,-2.02712 2.051414,0 2.789613,-2.0209 4.855062,-2.0209 1.640225,0 3.015819,-0.40042 4.654853,-0.40042 1.497517,0 1.586875,1.31057 1.207519,2.828 -0.572527,2.29009 -2.351061,2.22727 -4.84881,2.22727 -1.733127,0 -4.157741,-0.5744 -4.654854,1.41408 -0.293386,1.17352 -4.331001,1.08262 -4.248179,1.41392 0.33152,1.32613 1.117089,3.31521 -0.807092,2.83425 -0.539307,-0.13489 -1.081127,-0.27188 -1.62044,-0.40677 -0.510797,-0.12763 -0.607538,-1.55632 -1.0073,-1.21372 -0.899803,0.77126 -0.775824,2.91439 -1.783104,3.20334 0.490957,1.47384 0.337847,5.26605 0.337847,6.97608 0,2.60356 2.53176,0.45152 3.434827,0 0.87272,-0.43641 2.860672,-1.99939 5.149124,-2.57148 1.324451,-0.3311 3.248066,-1.84312 3.71638,-3.71638 0.706096,-2.82439 3.500144,-2.00209 6.575596,-2.00209 1.623543,0 3.246845,-0.19245 4.86758,-0.2878 1.029459,-0.0606 1.540201,-1.71428 2.57144,-1.71428 2.99763,0 3.19943,-3.19939 4.86131,-4.86132 1.02639,-1.02642 6.34535,-0.4349 8.00835,-1.43275 1.13584,-0.68151 0.5756,-5.10547 0.5756,-6.29411 0,-1.8255 0.35426,-3.71948 1.42649,-5.14902 1.79392,-2.39194 7.15121,-1.97481 7.15121,-5.43071 0,-2.41266 -4.14879,-0.84954 -2.57144,-4.00417 1.01499,-2.02997 2.28499,-2.28854 0.28155,-4.29198 -1.28803,-1.28809 -0.28155,-3.89226 -0.28155,-5.43066 0,-1.01871 -1.23229,-3.57753 -1.43274,-4.57978 -0.52268,-2.61337 -2.03221,-3.84836 -3.43484,-5.71846 -1.8508,-2.46777 1.45476,-3.08251 2.57769,-4.57972 0.58952,-0.78612 2.10161,-3.53264 2.28989,-4.28577 0.0219,-0.0878 -0.17183,-0.50268 -0.31908,-0.93223 -0.37455,-0.25887 -0.74527,-0.52529 -1.11366,-0.78827 2.17612,0 -3.55915,-2.87094 -5.71846,-3.14082 -2.89514,-0.36188 -2.81216,-1.69742 -2.00209,-3.72268 0.95169,-2.37918 1.08249,-2.12067 0,-4.28567 -0.80173,-1.60347 1.64877,-3.58099 2.28363,-4.00418 0.32839,-0.21893 -0.44112,-5.48852 0.2878,-6.58186 1.12033,-1.6805 -1.17194,-4.0312 -2.00209,-4.86132 -0.72764,-0.72766 -0.60286,-4.16009 -0.5756,-5.56831 -0.18064,-0.0392 -0.38935,-0.0948 -0.61939,-0.16261 -0.52966,0.18689 -0.66219,0.0535 -0.68822,-0.21283 -1.13918,-0.36292 -2.48908,-0.8173 -3.29093,-0.81329 z").attr(attr); + //eire.kerry = R.path("M 211.38213,696.5421 C 210.77078,696.5451 210.31798,696.683 210.11963,697.0171 C 207.2912,701.7802 203.96026,703.3834 200.01963,701.867 C 198.61613,701.327 195.62754,696.4106 194.76963,699.8421 C 194.29694,701.7328 189.03624,706.1045 187.89462,702.6797 C 187.03798,700.1096 183.04246,698.2758 182.24462,701.467 C 182.08018,702.125 179.10797,709.4816 179.00714,709.5421 C 173.9565,712.5725 175.87779,714.3184 173.75714,718.0296 C 171.22987,722.4523 168.18936,722.0778 163.65714,724.0922 C 162.44494,724.6309 161.08083,724.9086 160.01963,725.7046 C 158.49582,726.8474 154.8191,724.6693 154.35714,726.5171 C 153.82461,728.6472 150.37925,732.9274 146.68213,730.1546 C 144.55038,728.5558 136.16963,725.1643 136.16963,730.1546 C 136.16963,733.1181 136.06989,739.8421 140.21963,739.8421 C 145.36002,739.8421 144.07787,742.4782 147.08213,743.4797 C 153.76085,745.7058 146.80016,750.0602 150.31963,753.5797 C 152.27085,755.5309 155.04422,759.7022 151.13213,761.267 C 148.8827,762.1669 142.6777,764.7066 149.91963,766.5171 C 151.97451,767.0309 155.02546,765.3046 158.39462,765.3046 C 160.36203,765.3046 166.41566,764.2512 166.88213,766.1171 C 168.10109,770.993 160.31536,772.673 156.78213,773.3797 C 154.67755,773.8005 138.72237,774.4307 138.59462,773.7922 C 137.68298,769.2338 130.71309,771.5086 130.51963,770.1546 C 130.08795,767.1328 126.06963,766.0413 126.06963,763.2797 C 126.06963,760.1949 129.17322,757.472 125.26963,758.0296 C 123.33338,758.3062 117.13454,759.5344 118.80714,762.8797 C 119.6264,764.5182 120.41963,765.0851 120.41963,766.9171 C 120.41963,773.3371 118.91773,769.7421 114.75714,769.7421 C 108.90131,769.7421 107.54662,770.5286 102.64462,772.9797 C 100.42742,774.0882 98.75368,773.2614 100.00714,770.7546 C 100.04669,770.6755 103.50245,763.148 102.84462,763.2797 C 96.89909,764.4686 96.85486,767.5011 92.53213,768.9421 C 91.04974,769.5774 89.22608,771.3899 88.09462,771.767 C 85.20027,772.7318 80.33373,772.261 81.21963,775.8046 C 81.72995,777.8459 82.43213,779.3462 82.43213,781.867 C 82.43213,786.3771 78.43066,781.831 75.96963,784.2922 C 72.86603,787.3957 68.83718,784.1773 67.48213,781.467 C 67.08168,780.6662 62.63213,776.7717 62.63213,780.6546 C 62.63213,783.079 62.63213,785.5053 62.63213,787.9296 C 62.63213,789.6858 57.29112,789.2488 58.19462,790.7546 C 60.57717,794.7256 61.01963,793.8338 61.01963,797.6296 C 61.01963,800.6413 60.15573,803.2539 62.63213,804.4922 C 63.17088,804.7614 63.7067,805.06 64.25714,805.3046 C 65.46931,805.8434 66.4505,805.7973 67.68213,805.3046 C 69.51526,804.5714 71.0753,802.5845 73.14462,802.067 C 75.67984,801.4333 75.51274,798.0893 78.39462,799.2421 C 81.54936,800.504 82.26731,799.0069 84.45714,796.8171 C 88.42262,792.8517 85.7944,797.4837 90.10714,798.4421 C 91.31931,798.7115 92.50288,799.2421 93.74462,799.2421 C 95.62061,799.2421 98.55214,795.4096 99.00714,797.2296 C 99.55515,799.4216 100.84325,802.8795 103.84462,802.8797 C 106.87011,802.8797 108.02034,800.8546 109.10714,800.8546 C 111.99074,800.8546 113.80619,798.8672 116.78213,798.4421 C 120.00782,797.9813 129.66698,800.6909 132.13213,798.8421 C 135.48802,796.3251 137.33618,797.2464 140.61963,795.6046 C 143.84512,793.9918 145.11213,792.3797 149.10714,792.3797 C 149.89237,792.3797 159.60714,792.6264 159.60714,795.2046 C 159.60714,799.6755 158.32544,799.7459 155.96963,803.2797 C 154.36037,805.6934 151.57229,808.749 147.49462,807.7296 C 144.73008,807.0384 142.50205,804.7696 139.00714,806.5171 C 136.07632,807.9826 139.03562,812.4 137.38213,813.3922 C 133.45878,815.7461 129.65379,816.8501 125.26963,819.0421 C 121.78435,820.7848 116.56147,820.0786 111.53213,822.2797 C 108.04734,823.8046 102.98454,827.2282 99.40714,826.7171 C 97.52152,826.4477 95.22347,828.429 93.34462,828.7421 C 89.91872,829.3131 91.79461,833.3976 90.91963,833.5922 C 87.33278,834.3891 81.99194,834.2314 83.24462,839.2421 C 83.81691,841.5312 86.88939,845.6973 84.85714,847.7296 C 81.04277,851.544 83.70486,854.6046 75.56963,854.6046 C 73.60894,854.6046 67.04027,857.8139 67.08213,857.8296 C 68.6605,858.4214 74.75714,860.2805 74.75714,863.0797 C 74.75714,864.327 74.07389,872.0379 74.75714,872.3797 C 75.85237,872.9272 81.57205,874.8045 82.84462,874.8046 C 83.42946,874.8046 88.03459,871.627 88.09462,871.567 C 88.65998,871.0018 89.34002,868.2832 90.51963,866.3171 C 91.04154,865.4472 96.59158,859.0736 98.19462,862.2797 C 100.07522,866.0408 98.8719,869.1405 96.16963,871.167 C 92.48086,873.9336 96.06605,876.3134 98.19462,878.4421 C 99.984,880.2315 105.05714,879.1365 105.05714,881.667 C 105.05714,888.337 104.96088,889.7824 111.11963,887.7296 C 113.41226,886.9653 115.21219,883.6922 118.80714,883.6922 C 124.94387,883.6922 122.40659,880.0266 125.66963,877.2296 C 126.61245,876.4214 127.25288,874.8045 128.49462,874.8046 C 133.29206,874.8046 131.9645,872.9291 135.36963,871.567 C 140.45368,869.5334 146.28213,874.256 146.28213,873.5922 C 146.28213,868.7946 153.0153,873.0382 154.75714,869.5546 C 156.8697,865.3294 157.63901,865.5046 163.24462,865.5046 C 167.34317,865.5046 168.81803,861.467 172.94462,861.467 C 176.22165,861.467 178.96997,860.667 182.24462,860.667 C 185.23653,860.667 185.41506,863.2854 184.65714,866.3171 C 183.51328,870.8925 179.95992,870.767 174.96963,870.767 C 171.50699,870.767 166.66282,869.6194 165.66963,873.5922 C 165.08347,875.9368 157.01666,875.7552 157.18213,876.4171 C 157.84448,879.0666 159.41398,883.0406 155.56963,882.0797 C 154.49214,881.8102 153.40963,881.5365 152.33213,881.267 C 151.3116,881.012 151.11832,878.1576 150.31963,878.8421 C 148.5219,880.383 148.7696,884.6648 146.75714,885.2421 C 147.73803,888.1867 147.43213,895.7632 147.43213,899.1797 C 147.43213,904.3814 152.49037,900.0818 154.29462,899.1797 C 156.03824,898.3078 160.01,895.1851 164.58213,894.0421 C 167.22827,893.3806 171.07149,890.3597 172.00714,886.6171 C 173.41786,880.9742 179.00013,882.6171 185.14462,882.6171 C 188.38832,882.6171 191.63154,882.2326 194.86963,882.0421 C 196.9264,881.9211 197.94682,878.6171 200.00714,878.6171 C 205.99616,878.6171 206.39934,872.225 209.71963,868.9046 C 211.77027,866.8539 222.3971,868.0357 225.71963,866.0421 C 227.98894,864.6805 226.86963,855.8418 226.86963,853.467 C 226.86963,849.8198 227.57742,846.0358 229.71963,843.1797 C 233.30373,838.4008 244.00714,839.2342 244.00714,832.3296 C 244.00714,827.5093 235.71822,830.6323 238.86963,824.3296 C 240.89749,820.2739 243.43483,819.7573 239.43213,815.7546 C 236.85877,813.1811 238.86963,807.9782 238.86963,804.9046 C 238.86963,802.8693 236.40762,797.757 236.00714,795.7546 C 234.96286,790.5333 231.94694,788.0659 229.14462,784.3296 C 225.44688,779.3992 232.0511,778.171 234.29462,775.1797 C 235.47242,773.6091 238.49346,768.1218 238.86963,766.6171 C 238.91347,766.4418 238.52632,765.6128 238.23213,764.7546 C 237.48381,764.2374 236.74315,763.7051 236.00714,763.1797 C 240.35483,763.1797 228.89626,757.4438 224.58213,756.9046 C 218.7979,756.1816 218.96368,753.5133 220.58213,749.467 C 222.48352,744.7136 222.74486,745.2301 220.58213,740.9046 C 218.98034,737.701 223.87624,733.7501 225.14462,732.9046 C 225.80072,732.4672 224.2633,721.939 225.71963,719.7546 C 227.95795,716.3971 223.37819,711.7006 221.71963,710.0421 C 220.26587,708.5883 220.51517,701.7306 220.56963,698.9171 C 220.20872,698.8387 219.79174,698.7277 219.33213,698.5922 C 218.27392,698.9656 218.00914,698.6992 217.95714,698.167 C 215.68114,697.4419 212.98416,696.5341 211.38213,696.5421 z ").attr(attr); + + //eire.antrim = R.path("M278.939,132.632l-0.641-0.853l0.183-1.97l-0.975,0.091l-0.92-0.092l-0.506,0.415l-0.526,0.234l-0.541,0.053l-0.939-0.271l-1.049,0.468l-0.813-0.833l-0.938-0.272l-0.851,0.631l-0.67,0.614l-1.083,0.106l-0.904,0.09l-0.108,0.741l0.288,1.068l0.722-0.073l-0.651,0.795l-0.129,0.559l-1.049,0.47l-0.757-0.291l-0.433-0.688l-0.651,0.794l-0.651,0.795l-0.309,0.578l-0.688,0.433l-0.47-1.049l-0.069-0.723l-0.435-0.688l-0.415-0.507l-0.631-0.85l-1.121-0.254l-1.643-0.021l-0.577-0.309l-0.761-0.29l-0.722,0.071l-0.235-0.524l-0.903,0.089l-1.41,0.504l-1.3-0.237l-1.321-0.416l-0.541,0.053L250,132.249l-1.104-0.073l-0.073,1.102l-0.722,0.072l0.053,0.543l-0.869,0.449l-53.113-0.052l-0.002,0.043v45.292l0.08-0.038l1.109-0.168l1.834,0.86l1.024-0.723l1.748,0.305l2.12,0.248l1.73,1.44l0.492,2.009l1.092,0.971l0.045-0.953l1.055-0.539l0.98,0.232l1.721,0.119l1.008,0.413l0.604,2.748l1.444,2.054l1.138,0.018l1.619,0.701l1.973,1.783l0.379,1.268l1.277,0.943l1.619,0.701l1.295-0.195l-0.223-1.481l0.471-0.638l0.741-0.11l0.823,0.444l1.85-0.28l1.434,0.729l0.925-0.139l1.223,0.571l1.164,0.204l0.658-0.666l0.896-0.327l1.037,0.603l1.961,0.461l1.451-0.408l1.083-0.354l0.74-0.111l0.711-0.295l0.899-0.326l1.433,0.73l-0.204,1.168l0.566,1.235l0.722,1.028l0.354,1.082l-0.178,1.349l8.182,4.065l1.721,0.121l0.873,0.643h0.513l-0.213,0.64l0.112-0.336l0.227,0.167l0.939-0.471l-0.213-1.704l0.427-0.212h0.425l-0.425-1.065l-0.853-0.213l0.426-0.853l-0.426-1.064l0.426,0.214l0.427-1.491l0.851-3.406l-0.213-2.131l0.426-1.277h-0.426l1.065-0.852l-0.64-0.853l0.854,0.213l1.703-4.046l1.49-0.428l-0.641-1.275l0.641-0.214v0.853l0.424-0.214l-0.424-1.276l-0.426,0.213l0.213-0.426l-0.854-0.213l1.49-0.64l0.427-1.491l-0.427-0.639l0.64-0.215v-1.489l1.703-1.703l-0.638-0.214l1.063-0.213l-1.276-0.426l1.489-0.213l0.214-1.064l-0.64,0.426l-0.427-0.426l0.64,0.213l-0.213-0.639l0.64,0.426l0.213-1.704v-0.212l-0.427,0.425v-0.639l-0.213,0.214l-0.213-0.641l0.64,0.427l0.213-1.064v0.853l0.852-0.426l0.214-1.064l-0.427-0.427h0.854l0.637-1.703l-0.637,0.853l-0.214-0.853h0.638v-0.853l0.213,0.853l0.854-1.491l-0.213-0.426h0.427v0.64l2.556-1.491l-0.853-0.213l-0.853,0.639l-0.213-0.213l0.426-0.426l-0.213-0.426l0.853,0.426l0.638-0.426l0.215,0.426l0.853-1.277l1.489-0.853l0.214-1.702l-0.64-0.215v0.428l-0.852-0.428h1.064l0.213-1.49l1.49-1.277l1.918-6.176l-0.213-4.26l1.489-3.834l0.213-0.639l0.64-3.62l-0.64-0.426l0.64,0.213l-0.213-0.853l1.703-3.193h-0.426l0.426-0.214L278.939,132.632z M261.268,143.072h-0.215l-0.213-0.639l0.641-0.214L261.268,143.072z").attr(attr); + //eire.kerry = R.path("m 211.38213,696.5421 l -1.2625,0.475 l -10.1,4.8499 l -5.25,-2.0249 l -6.87501,2.8376 l -5.65,-1.2127 l -3.23748,8.0751 l -5.25,8.4875 l -10.1,6.0626 l -3.63751,1.6124 l -5.66249,0.8125 l -7.67501,3.6375 l -10.5125,0 l 4.05,9.6875 l 6.8625,3.6376 l 3.2375,10.1 l 0.8125,7.6873 l -1.2125,5.2501 l 8.47499,-1.2125 l 8.48751,0.8125 l -10.1,7.2626 l -18.18751,0.4125 l -8.07499,-3.6376 l -4.45,-6.8749 l -0.8,-5.2501 l -6.46249,4.8501 l 1.61249,4.0374 l -5.66249,2.825 l -12.11252,3.2376 l -2.63748,-2.2251 l 2.83748,-7.4749 l -10.31249,5.6624 l -4.43751,2.8249 l -6.87499,4.0376 l 1.2125,6.0624 l -6.4625,2.4252 l -8.4875,-2.8252 l -4.85,-0.8124 l 0,7.275 l -4.43751,2.825 l 2.82501,6.875 l 1.6125,6.8626 l 1.62501,0.8124 l 3.42499,0 l 5.46249,-3.2376 l 5.25,-2.8249 l 6.06252,-2.425 l 5.65,1.625 l 3.63748,0.8 l 5.26252,-2.0125 l 4.83748,5.6501 l 5.26252,-2.0251 l 7.67499,-2.4125 l 15.35,0.4 l 8.4875,-3.2375 l 8.48751,-3.2249 l 10.5,2.8249 l -3.63751,8.0751 l -8.47501,4.4499 l -8.48748,-1.2125 l -1.62501,6.8751 l -12.1125,5.6499 l -13.7375,3.2376 l -12.12499,4.4374 l -6.06252,2.025 l -2.42499,4.8501 l -7.67501,5.6499 l 1.61252,8.4875 l -9.28751,6.875 l -8.4875,3.225 l 7.67501,5.2501 l 0,9.3 l 8.08748,2.4249 l 5.25,-3.2376 l 2.42501,-5.2499 l 7.67499,-4.0374 l -2.02499,8.8873 l 2.02499,7.2751 l 6.86252,3.2249 l 6.06249,6.0626 l 7.68751,-4.0374 l 6.86249,-6.4626 l 2.82499,-2.425 l 6.87501,-3.2376 l 10.9125,2.0252 l 8.47501,-4.0376 l 8.48748,-4.05 l 9.7,-4.0376 l 9.3,-0.8 l 2.41252,5.6501 l -9.68751,4.4499 l -9.3,2.8252 l -8.4875,2.8249 l -1.6125,5.6626 l -3.2375,-0.8127 l -2.0125,-2.4249 l -3.56249,6.4 l 0.67499,13.9376 l 6.86249,0 l 10.28751,-5.1376 l 7.42501,-7.425 l 13.13748,-4 l 9.72501,-0.575 l 5.13751,-3.425 l 9.71249,-9.7125 l 16,-2.8625 l 1.15,-12.5751 l 2.85,-10.2873 l 14.28751,-10.8501 l -5.13751,-8 l 0.5625,-8.575 l -0.5625,-10.85 l -2.86249,-9.15 l -6.86252,-11.425 l 5.15,-9.1499 l 4.57501,-8.5626 l -0.6375,-1.8625 l -2.22499,-1.5749 l -11.42501,-6.2751 l -4,-7.4376 l 0,-8.5624 l 4.56249,-8 l 0.57501,-13.15 l -4,-9.7125 l -1.15,-11.125 l -1.2375,-0.3249 l -1.37499,-0.4252 z").attr(attr); + //eire.antrim = R.path("m 693.1376,223.0642 l 4.9,-19.6876 l 16.24992,-10.7875 l 1.31712,-27.2046 l -5.04512,9.5286 l -5.98448,-10.899 l -12.7,-16.1499 l -13.2,-15.5 l -5.55008,-12.9876 l -1.3624,-18.6 l -3.02496,-7.3 l -18.01552,-8.332 l -15.55952,-4.8931 l -26.17504,-2.2 l L l 600,87.439 l l l -5.05952,6.5 l 2.89008,21.426 l 3.72176,24.3472 l 3.06432,12.1334 l 7.376,23.0262 l 3.99488,18.4423 l 8.62208,8.5109 l 21.90288,1.3516 l -8.8,20.8375 l -1.78496,21.1709 l 4.51008,6.8166 l 18.13152,4.0835 l 17.36112,-13.0478 l 14.74832,-4.3899 z").attr(attr); + //eire.kerry = R.path().attr(attr); + eire.kerry = R.path("m 56.090017,180.71562 c -0.143868,7.1e-4 -0.250425,0.0332 -0.297102,0.11178 -0.66561,1.12089 -1.449475,1.49817 -2.376817,1.14132 -0.330283,-0.12708 -1.033583,-1.28404 -1.235473,-0.47652 -0.111238,0.44494 -1.349229,1.47372 -1.617885,0.66777 -0.201592,-0.60482 -1.141851,-1.03636 -1.329605,-0.28538 -0.0387,0.15485 -0.738143,1.88606 -0.761871,1.9003 -1.188558,0.71314 -0.736424,1.124 -1.235473,1.99735 -0.594739,1.04079 -1.310257,0.95265 -2.376817,1.4267 -0.285265,0.12677 -0.606278,0.19212 -0.856009,0.37944 -0.358595,0.26894 -1.223832,-0.24363 -1.332544,0.19121 -0.125319,0.50127 -0.93611,1.50852 -1.806147,0.856 -0.501661,-0.37624 -2.473889,-1.17435 -2.473889,0 0,0.6974 -0.02346,2.27975 0.953079,2.27975 1.20968,0 0.907954,0.62035 1.614941,0.85603 1.571692,0.52386 -0.06636,1.54858 0.761875,2.37681 0.459178,0.45918 1.11183,1.4408 0.191205,1.80904 -0.529355,0.21178 -1.989567,0.80944 -0.285336,1.2355 0.483572,0.12091 1.201547,-0.28533 1.994405,-0.28533 0.462988,0 1.887578,-0.2479 1.997352,0.1912 0.286856,1.14744 -1.545347,1.54279 -2.376816,1.7091 -0.495267,0.099 -4.249973,0.24733 -4.280037,0.0971 -0.214534,-1.07272 -1.854747,-0.5374 -1.900273,-0.85603 -0.101587,-0.71112 -1.047212,-0.96798 -1.047212,-1.61786 0,-0.72594 0.730363,-1.36672 -0.188262,-1.2355 -0.455655,0.0651 -1.914417,0.35412 -1.520807,1.14137 0.192795,0.38558 0.379464,0.51899 0.379464,0.95011 0,1.51081 -0.353439,0.6648 -1.332544,0.6648 -1.378043,0 -1.69684,0.18509 -2.850419,0.7619 -0.52177,0.26087 -0.915648,0.0663 -0.620674,-0.52363 0.0093,-0.0186 0.822546,-1.79004 0.66774,-1.75905 -1.399152,0.27978 -1.409561,0.99341 -2.426821,1.33252 -0.348849,0.14951 -0.778008,0.57604 -1.044272,0.66478 -0.681123,0.22705 -1.826357,0.11625 -1.61788,0.95016 0.120093,0.48038 0.285335,0.83344 0.285335,1.42666 0,1.06135 -0.941659,-0.008 -1.520809,0.57072 -0.730365,0.73034 -1.678467,-0.027 -1.997349,-0.66485 -0.09424,-0.18845 -1.141342,-1.10494 -1.141342,-0.19118 0,0.57053 0,1.1415 0,1.71201 0,0.41328 -1.256891,0.31044 -1.044272,0.6648 0.560681,0.93449 0.664805,0.72462 0.664805,1.61788 0,0.70874 -0.203301,1.32356 0.379467,1.61497 0.126783,0.0634 0.252876,0.13362 0.38241,0.19118 0.285258,0.12679 0.51616,0.11594 0.805998,0 0.431387,-0.17254 0.798509,-0.64012 1.285478,-0.7619 0.596609,-0.14913 0.557286,-0.93607 1.235474,-0.66478 0.7424,0.29696 0.911354,-0.0554 1.426683,-0.57067 0.933189,-0.93317 0.314695,0.15687 1.329605,0.38241 0.285258,0.0634 0.563785,0.18826 0.856002,0.18826 0.441473,0 1.131346,-0.9019 1.23842,-0.4736 0.128962,0.51584 0.432089,1.32958 1.138396,1.32963 0.711984,0 0.982665,-0.47656 1.23842,-0.47656 0.678593,0 1.10582,-0.46769 1.806143,-0.56773 0.759096,-0.10844 3.03217,0.5292 3.612289,0.0941 0.789736,-0.59232 1.224661,-0.37551 1.99735,-0.76188 0.759049,-0.37953 1.057212,-0.75891 1.997351,-0.75891 0.184787,0 2.470948,0.0581 2.470948,0.66478 0,1.05213 -0.301621,1.0687 -0.856009,1.9003 -0.378705,0.56801 -1.034819,1.28708 -1.99441,1.04719 -0.650575,-0.16266 -1.174894,-0.69657 -1.997345,-0.28534 -0.689705,0.34488 0.0067,1.38442 -0.382411,1.61791 -0.923275,0.55394 -1.818697,0.81374 -2.850414,1.32958 -0.820185,0.41011 -2.049277,0.24392 -3.232823,0.7619 -0.82007,0.35885 -2.01149,1.16452 -2.853354,1.04425 -0.44374,-0.0634 -0.984536,0.40286 -1.426682,0.47654 -0.806212,0.13437 -0.364762,1.09557 -0.570669,1.14136 -0.844088,0.18754 -2.100939,0.15042 -1.806148,1.32958 0.134676,0.53869 0.857718,1.5191 0.379472,1.99735 -0.897629,0.89764 -0.271164,1.61789 -2.185614,1.61789 -0.461406,0 -2.0072,0.75523 -1.997349,0.75893 0.371435,0.13927 1.806147,0.57677 1.806147,1.2355 0,0.29352 -0.160788,2.10811 0,2.18855 0.257739,0.12884 1.603741,0.57062 1.903213,0.57065 0.137629,0 1.221347,-0.74778 1.235474,-0.7619 0.133045,-0.13301 0.293078,-0.77277 0.570673,-1.23545 0.122821,-0.20471 1.428902,-1.7046 1.806143,-0.95012 0.442558,0.8851 0.159383,1.61454 -0.476538,2.09144 -0.868072,0.65106 -0.02437,1.21109 0.476538,1.71203 0.421092,0.4211 1.614945,0.16342 1.614945,0.75891 0,1.56964 -0.02266,1.90979 1.426676,1.42671 0.539521,-0.17987 0.963095,-0.95012 1.809089,-0.95012 1.444146,0 0.847052,-0.86262 1.614938,-1.52083 0.221872,-0.19019 0.372584,-0.5707 0.6648,-0.57067 1.128974,0 0.816561,-0.44136 1.617885,-0.7619 1.196421,-0.47857 2.56802,0.6328 2.56802,0.47659 0,-1.12902 1.584506,-0.13038 1.99441,-0.95017 0.497146,-0.99431 0.678186,-0.95308 1.997345,-0.95308 0.964505,0 1.311581,-0.95016 2.282685,-0.95016 0.771178,0 1.417935,-0.18826 2.188553,-0.18826 0.704081,0 0.746094,0.61618 0.567734,1.32963 -0.269182,1.07672 -1.105389,1.04719 -2.279745,1.04719 -0.814857,0 -1.954828,-0.27007 -2.188554,0.66485 -0.13794,0.55175 -2.036289,0.50901 -1.997349,0.66477 0.15587,0.62351 0.525218,1.5587 -0.379467,1.33257 -0.253564,-0.0634 -0.508309,-0.12783 -0.761875,-0.19125 -0.24016,-0.06 -0.285644,-0.73173 -0.473599,-0.57064 -0.423056,0.36261 -0.364765,1.37024 -0.838354,1.5061 0.230831,0.69294 0.158844,2.47591 0.158844,3.27991 0,1.22411 1.190347,0.21229 1.614938,0 0.410323,-0.20518 1.344991,-0.94004 2.420943,-1.20902 0.622712,-0.15567 1.52713,-0.86658 1.747315,-1.74732 0.331982,-1.32793 1.645649,-0.94131 3.091621,-0.94131 0.763335,0 1.526556,-0.0905 2.288571,-0.13531 0.484016,-0.0285 0.72415,-0.806 1.209001,-0.806 1.409386,0 1.504266,-1.50425 2.285624,-2.28563 0.482574,-0.48259 2.983368,-0.20448 3.765254,-0.67363 0.534033,-0.32042 0.270627,-2.40042 0.270627,-2.95927 0,-0.85829 0.166563,-1.74878 0.670686,-2.4209 0.84344,-1.12461 3.362256,-0.92849 3.362256,-2.55333 0,-1.13436 -1.950618,-0.39943 -1.209002,-1.88263 0.477213,-0.95442 1.074321,-1.07599 0.132372,-2.01794 -0.605584,-0.60562 -0.132372,-1.83001 -0.132372,-2.55331 0,-0.47897 -0.579381,-1.68204 -0.673625,-2.15326 -0.245749,-1.22872 -0.95548,-1.80937 -1.614945,-2.68862 -0.870183,-1.16027 0.683977,-1.4493 1.211941,-2.15323 0.277169,-0.36961 0.988106,-1.66093 1.076629,-2.01503 0.01031,-0.0413 -0.08079,-0.23634 -0.150022,-0.4383 -0.176101,-0.12171 -0.350399,-0.24697 -0.523603,-0.37061 1.023135,0 -1.673391,-1.34982 -2.688628,-1.47671 -1.361194,-0.17014 -1.322181,-0.79807 -0.941314,-1.75028 0.447451,-1.11861 0.508952,-0.99706 0,-2.01498 -0.376946,-0.75389 0.775198,-1.68365 1.073683,-1.88262 0.154399,-0.10294 -0.207399,-2.58052 0.135317,-3.09457 0.52674,-0.79011 -0.551008,-1.89533 -0.941314,-2.28563 -0.342111,-0.34212 -0.283443,-1.95593 -0.270627,-2.61802 -0.08493,-0.0185 -0.18306,-0.0446 -0.291219,-0.0765 -0.249027,0.0879 -0.311337,0.0252 -0.323574,-0.10006 -0.535608,-0.17064 -1.170283,-0.38427 -1.547286,-0.38239 z").attr(attr); + eire.antrim = R.path("m 169.46073,69.292858 c -1.68239,-0.909027 0.52593,-3.438147 1.15311,-4.63305 1.41679,-0.74385 3.20577,-0.714457 3.82406,-2.538605 1.0862,-1.791531 0.48779,-4.374871 0.30996,-6.402013 -0.78284,-0.990685 -0.51226,1.81217 -1.18726,2.24235 -1.25673,1.799861 -1.17634,-1.802309 -1.40832,-2.564844 -0.20295,-1.856152 -2.55137,-2.044532 -2.98867,-3.800529 -0.95769,-1.183042 -3.88536,-1.659723 -3.10633,-3.647589 0.28729,-1.132188 0.61998,-4.144649 -1.30609,-3.05635 -0.61687,-1.156874 -0.58392,-3.194088 -0.32062,-4.377107 0.96847,-0.499155 0.38346,-2.127439 -0.71185,-1.717897 -0.40763,-2.09621 -2.46666,-2.270212 -4.23957,-1.960755 -1.48426,0.150398 -2.69132,-0.190805 -3.66159,-1.151486 -2.20855,0.813083 -4.04057,-1.261053 -6.15973,-0.517722 -1.05578,0.539302 -1.86839,0.982214 -2.11502,2.209145 -0.7218,0.773948 -2.76633,0.433804 -1.19065,1.529634 1.18843,1.439174 0.64789,3.326154 0.68012,5.042145 0.0319,1.828689 -1.13003,4.727369 0.87584,5.729586 -0.50481,1.019136 -0.4059,2.083079 0.72112,2.855332 0.47024,1.831278 0.73415,3.724142 1.73578,5.418718 0.54058,1.244392 -0.73769,4.171194 0.94011,4.339995 0.60986,0.730295 0.36651,2.5459 2.02902,2.002856 1.64195,0.165295 4.13534,-1.540224 5.15437,0.31807 0.7239,2.100635 -2.36556,3.052232 -2.07089,4.903654 1.71782,0.957433 -0.10536,3.476011 -0.42006,4.982113 -1.14158,0.940654 1.58642,0.05996 1.06135,1.604139 1.39209,-0.04876 3.00486,-0.189393 4.26686,0.960963 1.76967,0.347039 3.14501,-1.786872 4.08557,-3.070517 0.22365,-2.044721 2.21965,-1.722015 3.4707,-1.033068 0.84469,-0.996827 0.50025,-2.456381 0.57868,-3.667168 z").attr(attr); + var current = null; + for (var state in eire) { + eire[state].color = Raphael.getColor(); + (function (st, state) { + st[0].style.cursor = "pointer"; + st[0].onmouseover = function () { + current && eire[current].animate({fill: "#333", stroke: "#666"}, 500) && (document.getElementById(current).style.display = ""); + st.animate({fill: st.color, stroke: "#ccc"}, 500); + st.toFront(); + R.safari(); + document.getElementById(state).style.display = "block"; + current = state; + }; + st[0].onmouseout = function () { + st.animate({fill: "#333", stroke: "#666"}, 500); + st.toFront(); + R.safari(); + }; + if (state == "nsw") { + st[0].onmouseover(); + } + })(eire[state], state); + } + }; \ No newline at end of file diff --git a/test/where/raphael-svg-import.js b/test/where/raphael-svg-import.js new file mode 100644 index 0000000..a330792 --- /dev/null +++ b/test/where/raphael-svg-import.js @@ -0,0 +1,878 @@ + + + + + + + + + raphael-svg-import.js at master from wout/raphael-svg-import - GitHub + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + +
+

+ wout / + raphael-svg-import +

+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + +
+ + + + + + + +

Latest commit to the master branch

+ +
+

+ updated raphael to 1.5.2 + +

+
+ commit 9d59748129 + +
+ + wout + authored + +
+
+
+ + + +
+ + + +
+
+ + +
+
+
+
+ Txt + 100644 + 102 lines (88 sloc) + 2.728 kb +
+ +
+
+ + + + + +
+
1
+2
+3
+4
+5
+6
+7
+8
+9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+80
+81
+82
+83
+84
+85
+86
+87
+88
+89
+90
+91
+92
+93
+94
+95
+96
+97
+98
+99
+100
+101
+102
+
+
+
/*
* Raphael SVG Import 0.0.4 - Extension to Raphael JS
*
* Copyright (c) 2011 Wout Fierens
* - Load order fix by Georgi Momchilov
* - Prototype dependency removed by Matt Cook
* Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
*/
Raphael.fn.importSVG = function (rawSVG, set) {
  try {
    if (typeof rawSVG === 'undefined')
      throw 'No data was provided.';
    
    rawSVG = rawSVG.replace(/\n|\r|\t/gi, '');
    
    if (!rawSVG.match(/<svg(.*?)>(.*)<\/svg>/i))
      throw "The data you entered doesn't contain valid SVG.";
    
    var findAttr = new RegExp('([a-z\-]+)="(.*?)"','gi'),
        findStyle = new RegExp('([a-z\-]+) ?: ?([^ ;]+)[ ;]?','gi'),
        findNodes = new RegExp('<(rect|polyline|circle|ellipse|path|polygon|image|text).*?\/>','gi');
    
    while(match = findNodes.exec(rawSVG)){
      var shape, style,
          attr = { 'fill':'#000' },
          node = RegExp.$1;
      
      while(findAttr.exec(match)){
        switch(RegExp.$1) {
          case 'stroke-dasharray':
            attr[RegExp.$1] = '- ';
          break;
          case 'style':
            style = RegExp.$2;
          break;
          default:
            attr[RegExp.$1] = RegExp.$2;
          break;
        }
      };
      
      if (typeof attr['stroke-width'] === 'undefined')
        attr['stroke-width'] = (typeof attr['stroke'] === 'undefined' ? 0 : 1);
      
      if (style)
        while(findStyle.exec(style))
          attr[RegExp.$1] = RegExp.$2;
      
      switch(node) {
        case 'rect':
          shape = this.rect();
        break;
        case 'circle':
          shape = this.circle();
        break;
        case 'ellipse':
          shape = this.ellipse();
        break;
        case 'path':
          shape = this.path(attr['d']);
        break;
        case 'polygon':
          shape = this.polygon(attr['points']);
        break;
        case 'image':
          shape = this.image();
        break;
        //-F case 'text':
        //-F shape = this.text();
        //-F break;
      }
      
      shape.attr(attr);
      
      if (typeof set !== 'undefined')
        set.push(shape);
    };
  } catch (error) {
    alert('The SVG data you entered was invalid! (' + error + ')');
  }
};

// extending raphael with a polygon function
Raphael.fn.polygon = function(pointString) {
  var poly = ['M'],
      point = pointString.split(' ');
      
  for(var i=0; i < point.length; i++) {
     var c = point[i].split(',');
     for(var j=0; j < c.length; j++) {
        var d = parseFloat(c[j]);
        if (d)
          poly.push(d);
     };
     if (i == 0)
      poly.push('L');
  }
  poly.push('Z');
  
  return this.path(poly);
};

+
+
+ +
+
+
+
+ +
+ + + +
+
+ + + + + + + + + +
+

Markdown Cheat Sheet

+ +
+ +
+
+

Format Text

+

Headers

+
+# This is an <h1> tag
+## This is an <h2> tag
+###### This is an <h6> tag
+

Text styles

+
+*This text will be italic*
+_This will also be italic_
+**This text will be bold**
+__This will also be bold__
+
+*You **can** combine them*
+
+
+
+

Lists

+

Unordered

+
+* Item 1
+* Item 2
+  * Item 2a
+  * Item 2b
+

Ordered

+
+1. Item 1
+2. Item 2
+3. Item 3
+   * Item 3a
+   * Item 3b
+
+
+

Miscellaneous

+

Images

+
+![GitHub Logo](/images/logo.png)
+Format: ![Alt Text](url)
+
+

Links

+
+http://github.com - automatic!
+[GitHub](http://github.com)
+

Blockquotes

+
+As Kanye West said:
+
+> We're living the future so
+> the present is our past.
+
+
+
+
+ +

Code Examples in Markdown

+
+

Syntax highlighting with GFM

+
+```javascript
+function fancyAlert(arg) {
+  if(arg) {
+    $.facebox({div:'#foo'})
+  }
+}
+```
+
+
+

Or, indent your code 4 spaces

+
+Here is a Python code example
+without syntax highlighting:
+
+    def foo:
+      if not bar:
+        return true
+
+
+

Inline code for comments

+
+I think you should use an
+`<addr>` element here instead.
+
+
+ +
+
+ + +
+ +
+

Something went wrong with that request. Please try again. Dismiss

+
+ + + + + + + diff --git a/thoughts b/thoughts new file mode 100644 index 0000000..e69de29 diff --git a/thoughts.schoolties.odt b/thoughts.schoolties.odt new file mode 100644 index 0000000..46617c8 Binary files /dev/null and b/thoughts.schoolties.odt differ -- cgit v1.2.3