├── .gitignore ├── d3-geomap.jpg ├── SRTM30_Plus ├── srtm30plus.jpg ├── srtm30plus_hilldhading_B.overview_res5km.jpg └── COPYRIGHT.txt ├── examples ├── GitHub-Mark-64px.png ├── goldmines │ ├── Grasberg_mine.jpg │ ├── Muruntov_mine.JPG │ ├── lihir-gold-mine.jpg │ ├── obuasi-gold-mine.png │ ├── oyu-tolgoi-mine.jpg │ ├── south_deep_ops.jpg │ ├── mponeng-mine-shaft.jpg │ ├── pueblo-viejo-mine.jpg │ ├── olimpiada-gold-mine.jpg │ └── cadia-valley-operations.jpg ├── prism │ ├── he │ │ ├── bower.json │ │ ├── .bower.json │ │ ├── LICENSE-MIT.txt │ │ └── README.md │ └── prismjs │ │ ├── bower.json │ │ ├── LICENSE │ │ ├── prism.css │ │ └── prism.js ├── marks.html ├── multiselect.html ├── backgrounds.html ├── css.html ├── responsive-size.html ├── index.html ├── world.html ├── rawdata_2222.txt ├── rawdata_2187.txt ├── markers.html ├── mouse-touch.html ├── rawdata_2001.txt ├── cia.html ├── ebola.html ├── usa.html └── project-docs.html ├── Equirectangular_projection_SW.jpg ├── bower.json ├── datamaps ├── LICENSE ├── usa.topo.json └── datamaps.js ├── LICENSE ├── README.md └── d3-geomap.html /.gitignore: -------------------------------------------------------------------------------- 1 | .directory 2 | bower_components 3 | -------------------------------------------------------------------------------- /d3-geomap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/d3-geomap.jpg -------------------------------------------------------------------------------- /SRTM30_Plus/srtm30plus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/SRTM30_Plus/srtm30plus.jpg -------------------------------------------------------------------------------- /examples/GitHub-Mark-64px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/GitHub-Mark-64px.png -------------------------------------------------------------------------------- /Equirectangular_projection_SW.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/Equirectangular_projection_SW.jpg -------------------------------------------------------------------------------- /examples/goldmines/Grasberg_mine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/Grasberg_mine.jpg -------------------------------------------------------------------------------- /examples/goldmines/Muruntov_mine.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/Muruntov_mine.JPG -------------------------------------------------------------------------------- /examples/goldmines/lihir-gold-mine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/lihir-gold-mine.jpg -------------------------------------------------------------------------------- /examples/goldmines/obuasi-gold-mine.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/obuasi-gold-mine.png -------------------------------------------------------------------------------- /examples/goldmines/oyu-tolgoi-mine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/oyu-tolgoi-mine.jpg -------------------------------------------------------------------------------- /examples/goldmines/south_deep_ops.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/south_deep_ops.jpg -------------------------------------------------------------------------------- /examples/goldmines/mponeng-mine-shaft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/mponeng-mine-shaft.jpg -------------------------------------------------------------------------------- /examples/goldmines/pueblo-viejo-mine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/pueblo-viejo-mine.jpg -------------------------------------------------------------------------------- /examples/goldmines/olimpiada-gold-mine.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/olimpiada-gold-mine.jpg -------------------------------------------------------------------------------- /examples/goldmines/cadia-valley-operations.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/examples/goldmines/cadia-valley-operations.jpg -------------------------------------------------------------------------------- /SRTM30_Plus/srtm30plus_hilldhading_B.overview_res5km.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stevenrskelton/d3-geomap/HEAD/SRTM30_Plus/srtm30plus_hilldhading_B.overview_res5km.jpg -------------------------------------------------------------------------------- /examples/prism/he/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "he", 3 | "version": "0.3.6", 4 | "main": "he.js", 5 | "ignore": [ 6 | "bin", 7 | "coverage", 8 | "data", 9 | "man", 10 | "scripts", 11 | "src", 12 | "tests", 13 | ".*", 14 | "component.json", 15 | "Gruntfile.js", 16 | "node_modules", 17 | "package.json" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /examples/prism/prismjs/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prismjs", 3 | "main": [ 4 | "prism.js", 5 | "prism.css" 6 | ], 7 | "homepage": "http://prismjs.com", 8 | "authors": "Lea Verou", 9 | "description": "Lightweight, robust, elegant syntax highlighting. A spin-off project from Dabblet.", 10 | "license": "MIT", 11 | "ignore": [ 12 | "**/.*", 13 | "img", 14 | "templates", 15 | "CNAME", 16 | "*.html", 17 | "style.css", 18 | "favicon.png", 19 | "logo.svg", 20 | "download.js", 21 | "prefixfree.min.js", 22 | "utopia.js", 23 | "code.js", 24 | "components.js" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /examples/prism/he/.bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "he", 3 | "version": "0.3.6", 4 | "main": "he.js", 5 | "ignore": [ 6 | "bin", 7 | "coverage", 8 | "data", 9 | "man", 10 | "scripts", 11 | "src", 12 | "tests", 13 | ".*", 14 | "component.json", 15 | "Gruntfile.js", 16 | "node_modules", 17 | "package.json" 18 | ], 19 | "homepage": "https://github.com/mathiasbynens/he", 20 | "_release": "0.3.6", 21 | "_resolution": { 22 | "type": "version", 23 | "tag": "v0.3.6", 24 | "commit": "3a1bdc4dbc0cdc8739216c8e92878723ab274662" 25 | }, 26 | "_source": "git://github.com/mathiasbynens/he.git", 27 | "_target": "~0.3.6", 28 | "_originalSource": "he" 29 | } -------------------------------------------------------------------------------- /examples/marks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Marks

15 | 16 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "d3-geomap", 3 | "homepage": "https://github.com/stevenrskelton/d3-geomap", 4 | "description": "Polymer Web Component for geographic topology visualization", 5 | "main": "d3-geomap.html", 6 | "authors": [ 7 | "Steven Skelton" 8 | ], 9 | "license": "MIT", 10 | "ignore": [ 11 | "**/.*", 12 | "node_modules", 13 | "bower_components", 14 | "test", 15 | "tests" 16 | ], 17 | "keywords": [ 18 | "web-component", 19 | "web-components", 20 | "polymer", 21 | "datamaps", 22 | "d3", 23 | "geography", 24 | "countries", 25 | "world", 26 | "map" 27 | ], 28 | "dependencies": { 29 | "polymer": "Polymer/polymer#^0.5.5", 30 | "d3": "d3#>=3.4.11", 31 | "topojson": "topojson#>=1.6.18" 32 | }, 33 | "devDependencies": { 34 | "core-elements": "Polymer/core-elements#^0.5.5", 35 | "sortable-table": "sortable-table#>=0.10.1", 36 | "flag-icon": "flag-icon#>=0.7.1", 37 | "transform-to-json": "transform-to-json#>=1.0.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /datamaps/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2012 Mark DiMarco 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Steven Skelton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /examples/prism/prismjs/LICENSE: -------------------------------------------------------------------------------- 1 | MIT LICENSE 2 | 3 | Copyright (c) 2012-2013 Lea Verou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/prism/he/LICENSE-MIT.txt: -------------------------------------------------------------------------------- 1 | Copyright Mathias Bynens 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /SRTM30_Plus/COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | David T. Sandwell, Walter H. F. Smith, and Joseph J. Becker Copyright 2008 2 | The Regents of the University of California 3 | All Rights Reserved 4 | 5 | Permission to copy, modify and distribute any part of this gridded bathymetry at 30 second resolution for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice, this paragraph and the following three paragraphs appear in all copies. 6 | 7 | Those desiring to incorporate this global bathymetry into commercial products or use for commercial purposes should contact the Technology Transfer & Intellectual Property Services, University of California, San Diego, 9500 Gilman Drive, Mail Code 0910, La Jolla, CA 92093-0910, Ph: (858) 534-5815, FAX: (858) 534-7345, E-MAIL:invent@ucsd.edu. 8 | 9 | IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS global bathymetry, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | 11 | THE global bathymetry PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE USE OF THE global bathymetry WILL NOT INFRINGE ANY PATENT, TRADEMARK OR OTHER RIGHTS. 12 | -------------------------------------------------------------------------------- /examples/multiselect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 24 | 25 | 26 | 27 |

Multi-select

28 | 29 | Enable built in region selection. 30 | 31 |

32 | 33 | 34 | 39 | 40 | 41 | 47 | 48 |

49 | 50 | 67 | 68 | -------------------------------------------------------------------------------- /examples/backgrounds.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 20 | 21 | 22 | 23 |

Backgrounds

24 | 25 | Different maps available (you are always free to use your own). Large images, please be patient. 26 | 27 |

28 | 29 | 36 | 37 | 44 | 45 | 74 | 75 | -------------------------------------------------------------------------------- /examples/prism/prismjs/prism.css: -------------------------------------------------------------------------------- 1 | /** 2 | * prism.js default theme for JavaScript, CSS and HTML 3 | * Based on dabblet (http://dabblet.com) 4 | * @author Lea Verou 5 | */ 6 | 7 | code[class*="language-"], 8 | pre[class*="language-"] { 9 | color: black; 10 | text-shadow: 0 1px white; 11 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 12 | direction: ltr; 13 | text-align: left; 14 | white-space: pre; 15 | word-spacing: normal; 16 | 17 | -moz-tab-size: 4; 18 | -o-tab-size: 4; 19 | tab-size: 4; 20 | 21 | -webkit-hyphens: none; 22 | -moz-hyphens: none; 23 | -ms-hyphens: none; 24 | hyphens: none; 25 | } 26 | 27 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, 28 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { 29 | text-shadow: none; 30 | background: #b3d4fc; 31 | } 32 | 33 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection, 34 | code[class*="language-"]::selection, code[class*="language-"] ::selection { 35 | text-shadow: none; 36 | background: #b3d4fc; 37 | } 38 | 39 | @media print { 40 | code[class*="language-"], 41 | pre[class*="language-"] { 42 | text-shadow: none; 43 | } 44 | } 45 | 46 | /* Code blocks */ 47 | pre[class*="language-"] { 48 | padding: 1em; 49 | margin: .5em 0; 50 | overflow: auto; 51 | } 52 | 53 | :not(pre) > code[class*="language-"], 54 | pre[class*="language-"] { 55 | background: #f5f2f0; 56 | } 57 | 58 | /* Inline code */ 59 | :not(pre) > code[class*="language-"] { 60 | padding: .1em; 61 | border-radius: .3em; 62 | } 63 | 64 | .token.comment, 65 | .token.prolog, 66 | .token.doctype, 67 | .token.cdata { 68 | color: slategray; 69 | } 70 | 71 | .token.punctuation { 72 | color: #999; 73 | } 74 | 75 | .namespace { 76 | opacity: .7; 77 | } 78 | 79 | .token.property, 80 | .token.tag, 81 | .token.boolean, 82 | .token.number { 83 | color: #905; 84 | } 85 | 86 | .token.selector, 87 | .token.attr-name, 88 | .token.string { 89 | color: #690; 90 | } 91 | 92 | .token.operator, 93 | .token.entity, 94 | .token.url, 95 | .language-css .token.string, 96 | .style .token.string { 97 | color: #a67f59; 98 | background: hsla(0,0%,100%,.5); 99 | } 100 | 101 | .token.atrule, 102 | .token.attr-value, 103 | .token.keyword { 104 | color: #07a; 105 | } 106 | 107 | 108 | .token.regex, 109 | .token.important { 110 | color: #e90; 111 | } 112 | 113 | .token.important { 114 | font-weight: bold; 115 | } 116 | 117 | .token.entity { 118 | cursor: help; 119 | } -------------------------------------------------------------------------------- /examples/css.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 20 | 21 | 22 | 23 |

CSS Styling

24 | 25 | Default background, land, highlight, and border colors should be exposed. 26 | 27 |

28 | 29 | 35 | 36 | 42 | 43 | 49 | 50 | 56 | 57 |

58 | 59 | 98 | 99 | -------------------------------------------------------------------------------- /examples/responsive-size.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 17 |

Responsiveness and Size

18 | 19 | Not working: in progress... 20 | 21 |

22 | 23 | Map should fill parent element, respecting specified width and height.
24 | cover will scale as large as possible so that the area is completely covered by the map. Some parts of the map may not be in view, so it is recommended to enable pan. 25 | 26 |

27 | 56 | 57 | 78 | 96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | D3 SVG Geographic Map 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Getting Started

13 | 14 |

Setup

15 | 16 |
    17 |
  1. 18 | Add the library using the Javascript package manager Bower: 19 | bower install --save d3-geomap 20 |
  2. 21 |
  3. 22 | Import Web Components' polyfill: 23 | <script src="bower_components/webcomponentsjs/webcomponents.min.js"></script> 24 |
  4. 25 |
  5. 26 | Import Custom Element: 27 | <link rel="import" href="bower_components/d3-geomap/d3-geomap.html"> 28 |
  6. 29 |
  7. 30 |

    31 | Start using it! 32 |

    33 | 34 | <d3-geomap> 35 | <!-- add templates here --> 36 | </d3-geomap> 37 | 38 |
  8. 39 |
40 | 41 |

Element Attributes

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 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 |
AttributeOptionsDefaultDescription
dataobjectnullkeys are region id, values are arbitrary data to be associated with region
hoverobjectnullRegion hovered over by user pointer
hoverTypestringnullType of area being hovered over, region or marker
mapstringworldAcceptable values are world and usa, will render world and USA maps respectivily.
multiselectbooleanfalseIf true, selected is automatically populated by user clicks
themeobject_default_CSS styles to apply to map, see [Themes]
selectedobjectnullkeys are region id, values are a CSS color. Also supports an array if region ids where defaultSelectedFill color is assumed
projectionobject_default_Center of map and size, see [Projection]
panbooleanfalseEnable mouse/touch pan on drag
zoombooleanfalseEnable mouse scroll-wheel/touch pinch zoom
hovertemplateidnullSee [hovertemplate]
markerHoverTemplateidnullSee [markerHoverTemplate]
127 | 128 |

Element Events

129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 |
EventValueDescription
clickedobjectRegion clicked by user
146 | 147 |

Region IDs

148 | 149 |

150 | Region IDs are used to uniquely identify regions, and are the keys to both the data and selected object maps.
151 | The world country map uses 3 letter ISO 3166-1 alpha-3 country codes,
152 | while the USA state map uses 2 letter ANSI standard INCITS 38:2009 codes. 153 |

154 | 155 | 156 | -------------------------------------------------------------------------------- /examples/world.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

World Countries Map

16 | 17 | World countries map with dynamic region colouring, highlighting, and user hover and click events. 18 | 19 |

20 | 21 | 39 | 40 |

41 | 42 |

43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 |
54 | 57 |
58 | 61 |
62 |
63 | 64 | 157 | 158 | -------------------------------------------------------------------------------- /examples/rawdata_2222.txt: -------------------------------------------------------------------------------- 1 | 1 Kuwait 29.20 2 Macau 23.30 3 Congo, Republic of the 14.00 4 Norway 13.10 5 Brunei 9.80 6 Qatar 9.10 7 Saudi Arabia 6.20 8 Malta 5.50 9 United Arab Emirates 5.00 10 Saint Kitts and Nevis 4.80 11 Saint Pierre and Miquelon 4.60 12 French Polynesia 3.90 13 Belize 3.50 14 Angola 3.40 15 Solomon Islands 2.50 16 Montenegro 2.20 17 Gibraltar 2.10 18 Seychelles 2.00 19 Greenland 1.90 20 Hong Kong 1.80 21 Brazil 1.60 22 Micronesia, Federated States of 1.50 23 Switzerland 1.40 24 Singapore 1.30 25 Guernsey 1.20 26 Turkmenistan 1.10 27 Cook Islands 1.00 28 Bosnia and Herzegovina 1.00 29 Peru 1.00 30 Iraq 0.90 31 Korea, South 0.70 32 Botswana 0.60 33 Isle of Man 0.50 34 Azerbaijan 0.50 35 Marshall Islands 0.40 36 Comoros 0.40 37 Colombia 0.40 38 Vanuatu 0.30 39 Equatorial Guinea 0.20 40 Bolivia 0.10 41 Germany 0.10 42 Poland 0.00 43 Tajikistan 0.00 44 British Virgin Islands 0.00 45 Saint Vincent and the Grenadines 0.00 46 Tonga 0.00 47 Latvia -0.20 48 Belarus -0.20 49 Andorra -0.30 50 Armenia -0.30 51 Nicaragua -0.30 52 Uzbekistan -0.40 53 Jersey -0.40 54 Curacao -0.40 55 Korea, North -0.40 56 Libya -0.50 57 Russia -0.50 58 Estonia -0.50 59 Mauritania -0.60 60 Mali -0.70 61 Antigua and Barbuda -0.80 62 Lesotho -0.90 63 Chile -1.00 64 Swaziland -1.10 65 Monaco -1.20 66 Australia -1.30 67 Benin -1.30 68 Oman -1.30 69 Djibouti -1.40 70 Malawi -1.40 71 Iceland -1.50 72 Israel -1.50 73 Nigeria -1.50 74 Paraguay -1.60 75 Liechtenstein -1.60 76 Timor-Leste -1.60 77 Laos -1.60 78 Luxembourg -1.70 79 Moldova -1.80 80 Kosovo -1.80 81 Philippines -1.80 82 Trinidad and Tobago -1.80 83 Guinea-Bissau -1.80 84 Jamaica -1.80 85 Mauritius -1.90 86 New Zealand -1.90 87 Lithuania -2.00 88 Sweden -2.00 89 China -2.10 90 Czech Republic -2.10 91 Turkey -2.10 92 Finland -2.30 93 Kazakhstan -2.30 94 Algeria -2.30 95 Madagascar -2.30 96 Suriname -2.30 97 Niger -2.40 98 Bulgaria -2.40 99 Palau -2.40 100 Bhutan -2.40 101 Bermuda -2.50 102 Cayman Islands -2.50 103 Denmark -2.50 104 Ecuador -2.50 105 Mexico -2.50 106 Romania -2.50 107 Taiwan -2.50 108 Fiji -2.60 109 Uruguay -2.60 110 Panama -2.60 111 Cambodia -2.70 112 Guatemala -2.70 113 Uganda -2.70 114 Saint Lucia -2.70 115 Georgia -2.70 116 Ethiopia -2.80 117 Liberia -2.90 118 Austria -2.90 119 Hungary -2.90 120 Canada -2.90 121 San Marino -2.90 122 Guam -3.00 123 Dominican Republic -3.00 124 Sierra Leone -3.00 125 Nepal -3.10 126 Puerto Rico -3.10 127 Argentina -3.20 128 Belgium -3.20 129 Burkina Faso -3.20 130 Italy -3.30 131 Burundi -3.30 132 Netherlands -3.30 133 Indonesia -3.30 134 Cote d'Ivoire -3.40 135 Burma -3.40 136 Slovakia -3.40 137 Congo, Democratic Republic of the -3.50 138 United Kingdom -3.60 139 Togo -3.70 140 Cuba -3.70 141 Bahrain -3.80 142 United States -4.00 143 Gambia, The -4.00 144 Thailand -4.00 145 Tuvalu -4.00 146 Greece -4.00 147 El Salvador -4.00 148 Grenada -4.10 149 Macedonia -4.10 150 France -4.10 151 Kenya -4.10 152 Central African Republic -4.10 153 Vietnam -4.20 154 Cameroon -4.30 155 Rwanda -4.30 156 Slovenia -4.40 157 Malaysia -4.40 158 Croatia -4.40 159 Sudan -4.40 160 Iran -4.50 161 Kyrgyzstan -4.60 162 Papua New Guinea -4.60 163 South Africa -4.80 164 Bangladesh -4.90 165 Serbia -4.90 166 Anguilla -5.00 167 Falkland Islands (Islas Malvinas) -5.00 168 Costa Rica -5.00 169 Guinea -5.10 170 Portugal -5.10 171 Ukraine -5.20 172 Senegal -5.30 173 Haiti -5.40 174 Tanzania -5.60 175 India -5.70 176 Cyprus -5.70 177 Chad -5.90 178 American Samoa -6.10 179 Albania -6.10 180 Samoa -6.10 181 Honduras -6.20 182 Sri Lanka -6.40 183 Guyana -6.40 184 Namibia -6.50 185 Spain -6.80 186 Barbados -7.00 187 Ireland -7.20 188 Tunisia -7.50 189 Aruba -7.50 190 Dominica -7.50 191 Pakistan -7.70 192 Gabon -7.90 193 Northern Mariana Islands -7.90 194 Syria -8.00 195 Morocco -8.00 196 Mongolia -8.10 197 Bahamas, The -8.20 198 Japan -8.20 199 Zambia -8.40 200 Afghanistan -8.70 201 Mozambique -8.80 202 Lebanon -9.40 203 Ghana -9.50 204 Cabo Verde -9.80 205 Venezuela -9.80 206 Yemen -10.30 207 Jordan -11.30 208 Sao Tome and Principe -11.70 209 Faroe Islands -11.90 210 Maldives -12.30 211 Niue -12.60 212 Eritrea -13.00 213 Egypt -13.30 214 South Sudan -15.50 215 West Bank -16.60 216 Kiribati -29.80 2 | -------------------------------------------------------------------------------- /examples/rawdata_2187.txt: -------------------------------------------------------------------------------- 1 | 1 Germany $ 257,100,000,000 2 China $ 182,800,000,000 3 Saudi Arabia $ 132,200,000,000 4 Russia $ 74,800,000,000 5 Kuwait $ 69,130,000,000 6 Norway $ 67,400,000,000 7 Netherlands $ 65,870,000,000 8 Switzerland $ 65,600,000,000 9 Taiwan $ 56,660,000,000 10 Japan $ 56,600,000,000 11 Korea, South $ 55,690,000,000 12 Singapore $ 54,400,000,000 13 United Arab Emirates $ 52,670,000,000 14 Qatar $ 47,560,000,000 15 Sweden $ 39,000,000,000 16 Denmark $ 19,600,000,000 17 Macau $ 18,690,000,000 18 Malaysia $ 16,670,000,000 19 Nigeria $ 16,160,000,000 20 Azerbaijan $ 13,280,000,000 21 Iraq $ 12,850,000,000 22 Angola $ 10,690,000,000 23 Austria $ 10,600,000,000 24 Vietnam $ 8,162,000,000 25 Philippines $ 7,512,000,000 26 Ireland $ 7,300,000,000 27 Oman $ 7,249,000,000 28 Algeria $ 6,697,000,000 29 Hong Kong $ 5,614,000,000 30 Israel $ 5,259,000,000 31 Brunei $ 3,977,000,000 32 Bangladesh $ 3,541,000,000 33 Slovakia $ 3,315,000,000 34 Venezuela $ 3,195,000,000 35 Slovenia $ 2,954,000,000 36 Libya $ 2,727,000,000 37 Luxembourg $ 2,700,000,000 38 Timor-Leste $ 2,375,000,000 39 Spain $ 2,100,000,000 40 Greece $ 2,021,000,000 41 Kazakhstan $ 1,965,000,000 42 Bahrain $ 1,907,000,000 43 Uzbekistan $ 1,801,000,000 44 Gabon $ 1,783,000,000 45 Hungary $ 1,722,000,000 46 Paraguay $ 1,376,000,000 47 Botswana $ 1,375,000,000 48 Bolivia $ 1,012,000,000 49 Portugal $ 1,000,000,000 50 Nepal $ 648,000,000 51 Congo, Republic of the $ 638,200,000 52 Trinidad and Tobago $ 414,100,000 53 Bhutan $ 401,500,000 54 British Virgin Islands $ 362,600,000 55 Cuba $ 289,800,000 56 Turkmenistan $ 285,900,000 57 Malta $ 133,100,000 58 Suriname $ 102,500,000 59 Cook Islands $ 26,670,000 60 Solomon Islands $ -1,200,000 61 Swaziland $ -1,500,000 62 Tuvalu $ -7,700,000 63 Palau $ -20,800,000 64 Belize $ -32,000,000 65 Micronesia, Federated States of $ -34,300,000 66 Kiribati $ -35,010,000 67 Tonga $ -43,300,000 68 Comoros $ -45,200,000 69 Guinea-Bissau $ -47,300,000 70 Anguilla $ -54,300,000 71 Sao Tome and Principe $ -59,000,000 72 Samoa $ -76,110,000 73 Dominica $ -91,500,000 74 Cabo Verde $ -100,000,000 75 Iceland $ -100,000,000 76 Croatia $ -102,300,000 77 Vanuatu $ -118,000,000 78 Saint Kitts and Nevis $ -133,100,000 79 Central African Republic $ -133,800,000 80 Seychelles $ -140,000,000 81 Gambia, The $ -163,700,000 82 Antigua and Barbuda $ -164,800,000 83 Bulgaria $ -182,300,000 84 Macedonia $ -194,100,000 85 Saint Vincent and the Grenadines $ -207,700,000 86 Eritrea $ -210,100,000 87 Saint Lucia $ -210,200,000 88 Grenada $ -214,400,000 89 Djibouti $ -219,500,000 90 Barbados $ -276,600,000 91 Malawi $ -280,100,000 92 Tajikistan $ -330,000,000 93 Estonia $ -352,300,000 94 Togo $ -355,100,000 95 Cyprus $ -358,200,000 96 Burkina Faso $ -364,900,000 97 Sierra Leone $ -463,300,000 98 Laos $ -484,300,000 99 Fiji $ -492,300,000 100 Burundi $ -492,500,000 101 Moldova $ -507,700,000 102 Guyana $ -510,700,000 103 Lesotho $ -518,400,000 104 Lithuania $ -567,000,000 105 Zimbabwe $ -576,000,000 106 Maldives $ -600,000,000 107 Latvia $ -613,900,000 108 Cote d'Ivoire $ -623,000,000 109 Namibia $ -658,400,000 110 Rwanda $ -667,900,000 111 Benin $ -699,300,000 112 Armenia $ -720,600,000 113 Liberia $ -742,400,000 114 Afghanistan $ -743,900,000 115 Ecuador $ -827,100,000 116 Chad $ -827,100,000 117 Mali $ -918,000,000 118 Kosovo $ -919,700,000 119 Bosnia and Herzegovina $ -939,500,000 120 Mauritius $ -1,099,000,000 121 Kyrgyzstan $ -1,125,000,000 122 Mauritania $ -1,240,000,000 123 Zambia $ -1,250,000,000 124 Cambodia $ -1,262,000,000 125 Haiti $ -1,278,000,000 126 Albania $ -1,280,000,000 127 Senegal $ -1,291,000,000 128 El Salvador $ -1,331,000,000 129 Bahamas, The $ -1,372,000,000 130 Georgia $ -1,375,000,000 131 Niger $ -1,450,000,000 132 Cameroon $ -1,461,000,000 133 Nicaragua $ -1,578,000,000 134 Jamaica $ -1,583,000,000 135 Honduras $ -1,636,000,000 136 Guinea $ -1,754,000,000 137 Serbia $ -1,807,000,000 138 Guatemala $ -1,822,000,000 139 Uganda $ -1,908,000,000 140 Montenegro $ -1,938,000,000 141 Madagascar $ -1,945,000,000 142 Sudan $ -1,980,000,000 143 Romania $ -1,986,000,000 144 Finland $ -2,000,000,000 145 West Bank $ -2,100,000,000 146 Dominican Republic $ -2,330,000,000 147 Pakistan $ -2,360,000,000 148 Argentina $ -2,371,000,000 149 Papua New Guinea $ -2,396,000,000 150 Italy $ -2,400,000,000 151 Sri Lanka $ -2,452,000,000 152 Congo, Democratic Republic of the $ -2,544,000,000 153 Burma $ -2,596,000,000 154 Costa Rica $ -2,673,000,000 155 Uruguay $ -2,721,000,000 156 Ethiopia $ -2,744,000,000 157 Equatorial Guinea $ -2,916,000,000 158 Thailand $ -3,200,000,000 159 Lebanon $ -3,224,000,000 160 Czech Republic $ -3,270,000,000 161 Yemen $ -3,312,000,000 162 Mongolia $ -3,639,000,000 163 Belarus $ -4,245,000,000 164 Kenya $ -4,495,000,000 165 Tunisia $ -4,556,000,000 166 Jordan $ -4,766,000,000 167 Tanzania $ -4,857,000,000 168 Panama $ -5,064,000,000 169 Ghana $ -5,149,000,000 170 Syria $ -5,879,000,000 171 Mozambique $ -5,884,000,000 172 Egypt $ -6,035,000,000 173 New Zealand $ -8,358,000,000 174 Iran $ -8,659,000,000 175 Belgium $ -9,100,000,000 176 Morocco $ -9,595,000,000 177 Peru $ -10,310,000,000 178 Chile $ -10,970,000,000 179 Colombia $ -11,020,000,000 180 Poland $ -11,060,000,000 181 Ukraine $ -11,920,000,000 182 Mexico $ -14,180,000,000 183 South Africa $ -23,780,000,000 184 Indonesia $ -28,720,000,000 185 European Union $ -34,490,000,000 186 Australia $ -44,900,000,000 187 Turkey $ -58,350,000,000 188 France $ -58,970,000,000 189 Canada $ -59,500,000,000 190 India $ -74,790,000,000 191 Brazil $ -77,630,000,000 192 United Kingdom $ -93,600,000,000 193 United States $ -360,700,000,000 2 | -------------------------------------------------------------------------------- /examples/markers.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Markers and Bubbles

15 | 16 | Markers can be rendered on the map, the most common is a bubble. 17 | Marker overlays are specified using the markerHoverTemplate attribute. 18 | 19 | <d3-geomap markerHoverTemplate="markerhovertemplate"> 20 | <fill name="MINE" color="rgba(255,215,0,0.95)"></fill> 21 | 22 | <marker 23 | name="Grasberg" 24 | latitude="-4.0310" 25 | longitude="137.0657" 26 | radius="36" 27 | fillkey="MINE" 28 | reserves="106.231" 29 | country="Indonesia" 30 | image="Grasberg_mine.jpg" 31 | ></marker> 32 | <!-- more markers --> 33 | 34 | <template id="markerhovertemplate"> 35 | <!-- HTML --> 36 | </template> 37 | </d3-geomap> 38 | 39 |

Demo

40 | 41 | 175 | 176 |

<marker> Attributes

177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 |
AttributeOptionsDescription
namestringUnique name of region.
latitudefloatGeographic coordinate that specifies the north-south position. Ranges from 90 at the north, 0 at the equator, and -90 at the south
longitudefloatAngle east or west from the Prime Meridian, ranging from 0° at the Prime Meridian to +180° eastward and −180° westward
radiusintegerSize in pixels for the radius of a bubble
fillkeystringNamed fill to use
*anyUser specified data fields to be accessible in template
219 | 220 | 221 | -------------------------------------------------------------------------------- /examples/mouse-touch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 35 | 36 | 37 | 38 |

Mouse & Touch Interactions

39 | 40 |

41 | Map background should be adjusted by mouse zoom and pan functionality. 42 | Zoom should stay centered, and not allow areas outside the map to be visible. 43 | Pan should not allow areas outside the map to be visible. 44 |

45 | 46 | 47 | 111 | 159 | 160 | 161 | 162 | 163 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | <d3-geomap> 2 | ============= 3 | 4 | Polymer Web Component for geographic topology visualization. 5 | 6 | ![Screenshot](https://raw.githubusercontent.com/stevenrskelton/d3-geomap/master/d3-geomap.jpg "Screenshot") 7 | 8 | This is a web component wrapper to another SVG map visualization library [DataMaps](http://datamaps.github.io/) by Mark DiMarco. 9 | It uses the popular [D3 Data-Driven Documents](http://d3js.org/) to handle low level HTML and SVG rendering. 10 | 11 | Features will mirror DataMaps features, however the format for interaction will be adjusted to follow the web component paradigm. 12 | This means significant simplifications will be made to provide an improved usability for the majority of users. Advanced use cases may find 13 | a web component encapsulation too restrictive, and those uses are outside the scope of this project. 14 | 15 | Maintained by [Steven Skelton](https://github.com/stevenrskelton) 16 | 17 | ## Live Demos 18 | 19 | > [World Countries Map](https://stevenrskelton.github.io/d3-geomap/examples/world.html) 20 | 21 | > [USA State Map](https://stevenrskelton.github.io/d3-geomap/examples/usa.html) 22 | 23 | > [Backgrounds](https://stevenrskelton.github.io/d3-geomap/examples/backgrounds.html) 24 | 25 | > [Markers](https://stevenrskelton.github.io/d3-geomap/examples/markers.html) 26 | 27 | > [Mouse and Touch Control](https://stevenrskelton.github.io/d3-geomap/examples/mouse-touch.html) 28 | 29 | > [Multi-Select](https://stevenrskelton.github.io/d3-geomap/examples/multiselect.html) 30 | 31 | > [CSS Styling](https://stevenrskelton.github.io/d3-geomap/examples/css.html) 32 | 33 | 34 | ## Usage 35 | 36 | 1. Add the library using the Javascript package manager [Bower](http://bower.io/): 37 | 38 | ```bower install --save d3-geomap``` 39 | 40 | 2. Import Web Components' polyfill: 41 | 42 | ```html 43 | 44 | ``` 45 | 46 | 3. Import Custom Element: 47 | 48 | ```html 49 | 50 | ``` 51 | 52 | 4. Start using it! 53 | 54 | ```html 55 | 56 | 57 | 58 | ``` 59 | 60 | ## Options 61 | 62 | Attribute | Type | Default | Description 63 | --- | --- | --- | --- 64 | `data` | *object* | `null` | keys are region id, values are arbitrary data to be associated with region 65 | `hover` | *object* | `null` | Region hovered over by user pointer 66 | `map` | *string* | world | Acceptable values are `world` and `usa`, will render world and USA maps respectivily. 67 | `multiselect` | *boolean* | `false` | If true, `selected` is automatically populated by user clicks 68 | `theme` | *object* | _default_ | CSS styles to apply to map, _see_ [Themes](#themes) 69 | `selected` | *object* | `null` | keys are region id, values are a CSS color. Also supports an `array` if region ids where `defaultSelectedFill` color is assumed 70 | `projection` | *object* | _default_ | Center of map and size, _see_ [Projection](#projection) 71 | `pan` | *boolean* | `false` | Enable mouse/touch pan on drag 72 | `zoom` | *boolean* | `false` | Enable mouse scroll-wheel/touch pinch zoom 73 | `hovertemplate` | *function* | `null` | _See_ [hovertemplate](#hovertemplate) 74 | 75 | Event | Value | Description 76 | --- | --- | --- 77 | `clicked` | *object* | Region clicked by user 78 | 79 | ## Region IDs 80 | 81 | Region IDs are used to uniquely identify regions, and are the keys to both the `data` and `selected` object maps. 82 | The world country map uses 3 letter [ISO 3166-1 alpha-3](http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) country codes, 83 | while the USA state map uses 2 letter [ANSI standard INCITS 38:2009](http://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations) codes. 84 | 85 | ## Themes 86 | 87 | The map is capable to be styled via the `theme` attribute, which has the following properties: 88 | 89 | Attribute | Type | Default | Description 90 | --- | --- | --- | --- 91 | `defaultFill` | *color* | #ABDDA4 | Regular fill for all land regions 92 | `defaultSelectedFill` | *color* | #FBB917 | Fill for selected regions if `selected` is an array 93 | `backgroundColor` | *color* | transparent | Background fill for map (water) 94 | `borderWidth` | *int* | 1 | Border width (px) for regular regions 95 | `borderColor` | *color* | #FDFDFD | Border color for regular regions 96 | `highlightFillColor` | *color* | #FC8D59 | Fill for highlighted/hover region 97 | `highlightBorderColor` | *color* | rgba (250, 15, 160, 0.2) | Border color for highlighted/hover region 98 | `highlightBorderWidth` | *int* | 2 | Border width (px) for highlighted/hover region 99 | `cursor` | *cursor* | pointer | _See the W3C Spec_ [http://www.w3.org/wiki/CSS/Properties/cursor](http://www.w3.org/wiki/CSS/Properties/cursor) 100 | `backgroundImage` | *image* | none | _See the W3C Spec_ [http://www.w3.org/TR/css3-background/#the-background-image](http://www.w3.org/TR/css3-background/#the-background-image) 101 | 102 | ## Projection 103 | 104 | The map can be centered and scaled using the `zoom` object, which has the following properties: 105 | 106 | Attribute | Type | Default | Description 107 | --- | --- | --- | --- 108 | `x` | *float* | 0 | Horizontal offset from center in °, range [-180,180] 109 | `y` | *float* | 0 | Vertical offset from center in °, range [-90,90] 110 | `scale` | *float* | 1.0 | Scale 1x = 100% 111 | `zoomIncrement` | *float* | 0.1 | Percent to increment/deincrement on mouse zoom 112 | `zoomScale` | *float* | 1.0 | Scale due to zoom, 1x = 100% 113 | `panX` | *float* | 0 | Horizontal offset from center, in pixels 114 | `panY` | *float* | 0 | Vertical offset from center, in pixels 115 | 116 | ## Backgrounds 117 | 118 | Backgrounds are applied to a `div[id="container"]` that contains the `svg` map element. Changing the __zoom__ will automatically 119 | adjust the background to be in the appropriate position. 120 | 121 | The __world__ topology is a standard [Equirectangular projection](http://en.wikipedia.org/wiki/Equirectangular_projection). 122 | 123 | The __usa__ topology is an [Albers USA projection](http://bl.ocks.org/mbostock/4090848). 124 | 125 | ### Templates 126 | 127 | All templates must be nested inside the `` tag to be accessible to the polymer element. 128 | 129 | Any filter used (eg: `sum` in a following example) must be a member of `PolymerExpressions.prototype`. 130 | See the [Polymer Filters](#polymer-filters) section for more details. 131 | 132 | As always, only a very limited subset of Javascript is allowed within `{{ }}` expressions. 133 | See the [Polymer documentation](http://www.polymer-project.org/docs/polymer/expressions.html) on Expression syntax. 134 | 135 | #### hoverTemplate 136 | 137 | Renderer for what shows when a region is hovered over. 138 | 139 | Template Variable | Description 140 | --- | --- 141 | `{{hover.id}}` | [RegionID](#region-ids) of region 142 | `{{hover.name}}` | Name of region 143 | `{{hover.data}}` | Custom user data assigned to region (_empty by_default_) 144 | 145 | ## History 146 | 147 | For detailed changelog, check [Releases](https://github.com/stevenrskelton/d3-geomap/releases). 148 | 149 | ## License 150 | 151 | [MIT License](http://opensource.org/licenses/MIT) © Steven Skelton -------------------------------------------------------------------------------- /examples/rawdata_2001.txt: -------------------------------------------------------------------------------- 1 | 1 United States $ 16,720,000,000,000 2 European Union $ 15,850,000,000,000 3 China $ 13,390,000,000,000 4 India $ 4,990,000,000,000 5 Japan $ 4,729,000,000,000 6 Germany $ 3,227,000,000,000 7 Russia $ 2,553,000,000,000 8 Brazil $ 2,416,000,000,000 9 United Kingdom $ 2,387,000,000,000 10 France $ 2,276,000,000,000 11 Mexico $ 1,845,000,000,000 12 Italy $ 1,805,000,000,000 13 Korea, South $ 1,666,000,000,000 14 Canada $ 1,518,000,000,000 15 Spain $ 1,389,000,000,000 16 Indonesia $ 1,285,000,000,000 17 Turkey $ 1,167,000,000,000 18 Australia $ 998,300,000,000 19 Iran $ 987,100,000,000 20 Saudi Arabia $ 927,800,000,000 21 Taiwan $ 926,400,000,000 22 Poland $ 814,000,000,000 23 Argentina $ 771,000,000,000 24 Netherlands $ 699,700,000,000 25 Thailand $ 673,000,000,000 26 South Africa $ 595,700,000,000 27 Pakistan $ 574,100,000,000 28 Egypt $ 551,400,000,000 29 Colombia $ 526,500,000,000 30 Malaysia $ 525,000,000,000 31 Nigeria $ 478,500,000,000 32 Philippines $ 454,300,000,000 33 Belgium $ 421,700,000,000 34 Venezuela $ 407,400,000,000 35 Sweden $ 393,800,000,000 36 Hong Kong $ 381,300,000,000 37 Switzerland $ 371,200,000,000 38 Austria $ 361,000,000,000 39 Vietnam $ 358,900,000,000 40 Peru $ 344,000,000,000 41 Singapore $ 339,000,000,000 42 Ukraine $ 337,400,000,000 43 Chile $ 335,400,000,000 44 Bangladesh $ 324,600,000,000 45 Romania $ 288,500,000,000 46 Czech Republic $ 285,600,000,000 47 Algeria $ 284,700,000,000 48 Norway $ 282,200,000,000 49 Israel $ 273,200,000,000 50 United Arab Emirates $ 269,800,000,000 51 Greece $ 267,100,000,000 52 Iraq $ 249,400,000,000 53 Kazakhstan $ 243,600,000,000 54 Portugal $ 243,300,000,000 55 Denmark $ 211,300,000,000 56 Qatar $ 198,700,000,000 57 Hungary $ 196,600,000,000 58 Finland $ 195,500,000,000 59 Ireland $ 190,400,000,000 60 Morocco $ 180,000,000,000 61 Kuwait $ 165,800,000,000 62 Ecuador $ 157,600,000,000 63 Belarus $ 150,400,000,000 64 New Zealand $ 136,000,000,000 65 Sri Lanka $ 134,500,000,000 66 Slovakia $ 133,400,000,000 67 Angola $ 131,800,000,000 68 Cuba $ 121,000,000,000 69 Ethiopia $ 118,200,000,000 70 Uzbekistan $ 112,600,000,000 71 Burma $ 111,100,000,000 72 Tunisia $ 108,400,000,000 73 Syria $ 107,600,000,000 74 Bulgaria $ 104,600,000,000 75 Azerbaijan $ 102,700,000,000 76 Dominican Republic $ 101,000,000,000 77 Oman $ 94,860,000,000 78 Ghana $ 90,410,000,000 79 Sudan $ 89,970,000,000 80 Guatemala $ 81,510,000,000 81 Serbia $ 80,470,000,000 82 Kenya $ 79,900,000,000 83 Tanzania $ 79,290,000,000 84 Croatia $ 78,900,000,000 85 Libya $ 73,600,000,000 86 Lithuania $ 67,430,000,000 87 Puerto Rico $ 64,840,000,000 88 Lebanon $ 64,310,000,000 89 Yemen $ 61,630,000,000 90 Panama $ 61,540,000,000 91 Costa Rica $ 61,430,000,000 92 Bolivia $ 59,110,000,000 93 Slovenia $ 57,360,000,000 94 Uruguay $ 56,270,000,000 95 Turkmenistan $ 55,160,000,000 96 Uganda $ 54,370,000,000 97 Cameroon $ 53,160,000,000 98 Macau $ 51,680,000,000 99 El Salvador $ 47,470,000,000 100 Paraguay $ 45,900,000,000 101 Afghanistan $ 45,300,000,000 102 Cote d'Ivoire $ 43,670,000,000 103 Luxembourg $ 42,670,000,000 104 Nepal $ 42,060,000,000 105 Jordan $ 40,020,000,000 106 Korea, North $ 40,000,000,000 107 Cambodia $ 39,640,000,000 108 Honduras $ 39,230,000,000 109 Latvia $ 38,870,000,000 110 Bahrain $ 34,960,000,000 111 Botswana $ 34,000,000,000 112 Bosnia and Herzegovina $ 32,160,000,000 113 Gabon $ 30,060,000,000 114 Estonia $ 29,940,000,000 115 Congo, Democratic Republic of the $ 29,390,000,000 116 Albania $ 28,340,000,000 117 Mozambique $ 28,150,000,000 118 Chad $ 28,000,000,000 119 Nicaragua $ 27,970,000,000 120 Senegal $ 27,720,000,000 121 Georgia $ 27,300,000,000 122 Trinidad and Tobago $ 27,140,000,000 123 Burkina Faso $ 26,510,000,000 124 Zambia $ 25,470,000,000 125 Timor-Leste $ 25,410,000,000 126 Jamaica $ 25,130,000,000 127 Macedonia $ 22,570,000,000 128 Brunei $ 22,250,000,000 129 Madagascar $ 22,030,000,000 130 Cyprus $ 21,620,000,000 131 Mauritius $ 20,950,000,000 132 Laos $ 20,780,000,000 133 Armenia $ 20,610,000,000 134 Congo, Republic of the $ 20,260,000,000 135 Papua New Guinea $ 19,960,000,000 136 Equatorial Guinea $ 19,680,000,000 137 Tajikistan $ 19,200,000,000 138 Mali $ 18,900,000,000 139 Namibia $ 17,790,000,000 140 Mongolia $ 17,030,000,000 141 Benin $ 16,650,000,000 142 Rwanda $ 16,370,000,000 143 Malawi $ 15,020,000,000 144 South Sudan $ 14,710,000,000 145 Kyrgyzstan $ 14,300,000,000 146 Kosovo $ 14,110,000,000 147 Niger $ 13,980,000,000 148 Haiti $ 13,420,000,000 149 Moldova $ 13,250,000,000 150 Iceland $ 13,110,000,000 151 Guinea $ 12,560,000,000 152 Bahamas, The $ 11,400,000,000 153 Malta $ 11,220,000,000 154 New Caledonia $ 9,280,000,000 155 Sierra Leone $ 9,156,000,000 156 Mauritania $ 8,204,000,000 157 West Bank $ 8,022,000,000 158 Zimbabwe $ 7,496,000,000 159 Montenegro $ 7,429,000,000 160 Togo $ 7,348,000,000 161 Suriname $ 7,120,000,000 162 Barbados $ 7,004,000,000 163 Guyana $ 6,593,000,000 164 Swaziland $ 6,259,000,000 165 Monaco $ 6,213,000,000 166 Somalia $ 5,896,000,000 167 Burundi $ 5,750,000,000 168 French Polynesia $ 5,650,000,000 169 Bermuda $ 5,600,000,000 170 Bhutan $ 5,235,000,000 171 Jersey $ 5,100,000,000 172 Eritrea $ 4,717,000,000 173 Guam $ 4,600,000,000 174 Fiji $ 4,450,000,000 175 Lesotho $ 4,265,000,000 176 Isle of Man $ 4,076,000,000 177 Gambia, The $ 3,678,000,000 178 Central African Republic $ 3,336,000,000 179 Liechtenstein $ 3,200,000,000 180 Andorra $ 3,163,000,000 181 Curacao $ 3,128,000,000 182 Belize $ 3,083,000,000 183 Maldives $ 3,073,000,000 184 Liberia $ 2,898,000,000 185 Guernsey $ 2,742,000,000 186 Aruba $ 2,516,000,000 187 Djibouti $ 2,505,000,000 188 Seychelles $ 2,404,000,000 189 Cayman Islands $ 2,250,000,000 190 Cabo Verde $ 2,222,000,000 191 Saint Lucia $ 2,216,000,000 192 Greenland $ 2,133,000,000 193 Guinea-Bissau $ 2,005,000,000 194 Solomon Islands $ 1,958,000,000 195 Antigua and Barbuda $ 1,610,000,000 196 Virgin Islands $ 1,577,000,000 197 Faroe Islands $ 1,471,000,000 198 Grenada $ 1,458,000,000 199 Saint Vincent and the Grenadines $ 1,335,000,000 200 San Marino $ 1,306,000,000 201 Gibraltar $ 1,275,000,000 202 Vanuatu $ 1,270,000,000 203 Samoa $ 1,145,000,000 204 Dominica $ 1,015,000,000 205 Saint Kitts and Nevis $ 952,000,000 206 Comoros $ 911,000,000 207 Western Sahara $ 906,500,000 208 Tonga $ 846,000,000 209 Sint Maarten $ 798,300,000 210 Micronesia, Federated States of $ 754,000,000 211 Northern Mariana Islands $ 733,000,000 212 Kiribati $ 698,000,000 213 Turks and Caicos Islands $ 632,000,000 214 American Samoa $ 575,300,000 215 British Virgin Islands $ 500,000,000 216 Marshall Islands $ 486,000,000 217 Sao Tome and Principe $ 421,000,000 218 Palau $ 245,500,000 219 Saint Pierre and Miquelon $ 215,300,000 220 Cook Islands $ 183,200,000 221 Anguilla $ 175,400,000 222 Falkland Islands (Islas Malvinas) $ 164,500,000 223 Wallis and Futuna $ 60,000,000 224 Nauru $ 60,000,000 225 Montserrat $ 43,780,000 226 Tuvalu $ 40,000,000 227 Saint Helena, Ascension, and Tristan da Cunha $ 31,100,000 228 Niue $ 10,010,000 229 Tokelau $ 1,500,000 2 | -------------------------------------------------------------------------------- /examples/cia.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

CIA World Factbook

17 | 18 | 62 | 63 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 194 | 195 | -------------------------------------------------------------------------------- /examples/ebola.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 24 | 25 | 26 | 27 |

Major Ebola Outbreaks

28 |

Confirmed cases and years

29 | 30 |

31 | 32 | 33 | 62 | 63 | 64 | 116 | 117 | 194 | 195 | -------------------------------------------------------------------------------- /examples/usa.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | D3 SVG Geographic Map 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

USA States Map

16 | 17 | United States of America state map with dynamic region colouring, highlighting, user hover and click events, and custom data. 18 | 19 | 43 | 44 |

45 | 46 |

47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 |
57 |
58 | 61 |
62 | 65 |
66 |
67 | 68 | 187 | 188 | -------------------------------------------------------------------------------- /examples/prism/he/README.md: -------------------------------------------------------------------------------- 1 | # he [![Build status](https://travis-ci.org/mathiasbynens/he.png?branch=master)](https://travis-ci.org/mathiasbynens/he) [![Dependency status](https://gemnasium.com/mathiasbynens/he.png)](https://gemnasium.com/mathiasbynens/he) 2 | 3 | _he_ (for “HTML entities”) is a robust HTML entity encoder/decoder written in JavaScript. It supports [all standardized named character references as per HTML](http://www.whatwg.org/specs/web-apps/current-work/multipage/named-character-references.html), handles [ambiguous ampersands](http://mathiasbynens.be/notes/ambiguous-ampersands) and other edge cases [just like a browser would](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references), has an extensive test suite, and — contrary to many other JavaScript solutions — _he_ handles astral Unicode symbols just fine. [An online demo is available.](http://mothereff.in/html-entities) 4 | 5 | ## Installation 6 | 7 | Via [npm](http://npmjs.org/): 8 | 9 | ```bash 10 | npm install he 11 | ``` 12 | 13 | Via [Bower](http://bower.io/): 14 | 15 | ```bash 16 | bower install he 17 | ``` 18 | 19 | Via [Component](https://github.com/component/component): 20 | 21 | ```bash 22 | component install mathiasbynens/he 23 | ``` 24 | 25 | In a browser: 26 | 27 | ```html 28 | 29 | ``` 30 | 31 | In [Narwhal](http://narwhaljs.org/), [Node.js](http://nodejs.org/), and [RingoJS](http://ringojs.org/): 32 | 33 | ```js 34 | var he = require('he'); 35 | ``` 36 | 37 | In [Rhino](http://www.mozilla.org/rhino/): 38 | 39 | ```js 40 | load('he.js'); 41 | ``` 42 | 43 | Using an AMD loader like [RequireJS](http://requirejs.org/): 44 | 45 | ```js 46 | require( 47 | { 48 | 'paths': { 49 | 'he': 'path/to/he' 50 | } 51 | }, 52 | ['he'], 53 | function(he) { 54 | console.log(he); 55 | } 56 | ); 57 | ``` 58 | 59 | ## API 60 | 61 | ### `he.version` 62 | 63 | A string representing the semantic version number. 64 | 65 | ### `he.encode(text, options)` 66 | 67 | This function takes a string of text and encodes (by default) any symbols that aren’t printable ASCII symbols, replacing them with character references. As long as the input string contains allowed code points only, the return value of this function is always valid HTML. 68 | 69 | ```js 70 | he.encode('foo © bar ≠ baz 𝌆 qux'); 71 | // → 'foo © bar ≠ baz 𝌆 qux' 72 | ``` 73 | 74 | The `options` object is optional. It recognizes the following properties: 75 | 76 | #### `useNamedReferences` 77 | 78 | The default value for the `useNamedReferences` option is `false`. This means that `encode()` will not use any named character references (e.g. `©`) in the output — hexadecimal escapes (e.g. `©`) will be used instead. Set it to `true` to enable the use of named references. 79 | 80 | **Note that if compatibility with older browsers is a concern, this option should remain disabled.** 81 | 82 | ```js 83 | // Using the global default setting (defaults to `false`): 84 | he.encode('foo © bar ≠ baz 𝌆 qux'); 85 | // → 'foo © bar ≠ baz 𝌆 qux' 86 | 87 | // Passing an `options` object to `encode`, to explicitly disallow named references: 88 | he.encode('foo © bar ≠ baz 𝌆 qux', { 89 | 'useNamedReferences': false 90 | }); 91 | // → 'foo © bar ≠ baz 𝌆 qux' 92 | 93 | // Passing an `options` object to `encode`, to explicitly allow named references: 94 | he.encode('foo © bar ≠ baz 𝌆 qux', { 95 | 'useNamedReferences': true 96 | }); 97 | // → 'foo © bar ≠ baz 𝌆 qux' 98 | ``` 99 | 100 | #### `encodeEverything` 101 | 102 | The default value for the `encodeEverything` option is `false`. This means that `encode()` will not use any character references for printable ASCII symbols that don’t need escaping. Set it to `true` to encode every symbol in the input string. 103 | 104 | ```js 105 | // Using the global default setting (defaults to `false`): 106 | he.encode('foo © bar ≠ baz 𝌆 qux'); 107 | // → 'foo © bar ≠ baz 𝌆 qux' 108 | 109 | // Passing an `options` object to `encode`, to explicitly encode all symbols: 110 | he.encode('foo © bar ≠ baz 𝌆 qux', { 111 | 'encodeEverything': true 112 | }); 113 | // → 'foo © bar ≠ baz 𝌆 qux' 114 | 115 | // This setting can be combined with the `useNamedReferences` option: 116 | he.encode('foo © bar ≠ baz 𝌆 qux', { 117 | 'encodeEverything': true, 118 | 'useNamedReferences': true 119 | }); 120 | // → 'foo © bar ≠ baz 𝌆 qux' 121 | ``` 122 | 123 | #### Overriding default `encode` options globally 124 | 125 | The global default setting can be overridden by modifying the `he.encode.options` object. This saves you from passing in an `options` object for every call to `encode` if you want to use the non-default setting. 126 | 127 | ```js 128 | // Read the global default setting: 129 | he.encode.options.useNamedReferences; 130 | // → `false` by default 131 | 132 | // Override the global default setting: 133 | he.encode.options.useNamedReferences = true; 134 | 135 | // Using the global default setting, which is now `true`: 136 | he.encode('foo © bar ≠ baz 𝌆 qux'); 137 | // → 'foo © bar ≠ baz 𝌆 qux' 138 | ``` 139 | 140 | ### `he.decode(html, options)` 141 | 142 | This function takes a string of HTML and decodes any named and numerical character references in it using [the algorithm described in section 12.2.4.69 of the HTML spec](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references). 143 | 144 | ```js 145 | he.decode('foo © bar ≠ baz 𝌆 qux'); 146 | // → 'foo © bar ≠ baz 𝌆 qux' 147 | ``` 148 | 149 | The `options` object is optional. It recognizes the following properties: 150 | 151 | #### `isAttributeValue` 152 | 153 | The default value for the `isAttributeValue` option is `false`. This means that `decode()` will decode the string as if it were used in a text context in an HTML document. HTML has different rules for parsing character references in attribute values — set this option to `true` to treat the input string as if it were used as an attribute value. 154 | 155 | ```js 156 | // Using the global default setting (defaults to `false`, i.e. HTML text context): 157 | he.decode('foo&bar'); 158 | // → 'foo&bar' 159 | 160 | // Passing an `options` object to `decode`, to explicitly assume an HTML text context: 161 | he.decode('foo&bar', { 162 | 'isAttributeValue': false 163 | }); 164 | // → 'foo&bar' 165 | 166 | // Passing an `options` object to `decode`, to explicitly assume an HTML attribute value context: 167 | he.decode('foo&bar', { 168 | 'isAttributeValue': true 169 | }); 170 | // → 'foo&bar' 171 | ``` 172 | 173 | #### `strict` 174 | 175 | The default value for the `strict` option is `false`. This means that `decode()` will decode any HTML text content you feed it, even if it contains any entities that cause [parse errors](http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#tokenizing-character-references). To throw an error when such invalid HTML is encountered, set the `strict` option to `true`. This option makes it possible to use _he_ as part of HTML parsers and HTML validators. 176 | 177 | ```js 178 | // Using the global default setting (defaults to `false`, i.e. error-tolerant mode): 179 | he.decode('foo&bar'); 180 | // → 'foo&bar' 181 | 182 | // Passing an `options` object to `decode`, to explicitly enable error-tolerant mode: 183 | he.decode('foo&bar', { 184 | 'strict': false 185 | }); 186 | // → 'foo&bar' 187 | 188 | // Passing an `options` object to `decode`, to explicitly enable strict mode: 189 | he.decode('foo&bar', { 190 | 'strict': true 191 | }); 192 | // → Parse error 193 | ``` 194 | 195 | #### Overriding default `decode` options globally 196 | 197 | The global default settings for the `decode` function can be overridden by modifying the `he.decode.options` object. This saves you from passing in an `options` object for every call to `decode` if you want to use a non-default setting. 198 | 199 | ```js 200 | // Read the global default setting: 201 | he.decode.options.isAttributeValue; 202 | // → `false` by default 203 | 204 | // Override the global default setting: 205 | he.decode.options.isAttributeValue = true; 206 | 207 | // Using the global default setting, which is now `true`: 208 | he.decode('foo&bar'); 209 | // → 'foo&bar' 210 | ``` 211 | 212 | ### `he.escape(text)` 213 | 214 | This function takes a string of text and escapes it for use in text contexts in XML or HTML documents. Only the following characters are escaped: `&`, `<`, `>`, `"`, and `'`. 215 | 216 | ```js 217 | he.escape(''); 218 | // → '<img src='x' onerror="prompt(1)">' 219 | ``` 220 | 221 | ### `he.unescape(html, options)` 222 | 223 | `he.unescape` is an alias for `he.decode`. It takes a string of HTML and decodes any named and numerical character references in it. 224 | 225 | ### Using the `he` binary 226 | 227 | To use the `he` binary in your shell, simply install _he_ globally using npm: 228 | 229 | ```bash 230 | npm install -g he 231 | ``` 232 | 233 | After that you will be able to encode/decode HTML entities from the command line: 234 | 235 | ```bash 236 | $ he --encode 'föo ♥ bår 𝌆 baz' 237 | föo ♥ bår 𝌆 baz 238 | 239 | $ he --encode --use-named-refs 'föo ♥ bår 𝌆 baz' 240 | föo ♥ bår 𝌆 baz 241 | 242 | $ he --decode 'föo ♥ bår 𝌆 baz' 243 | föo ♥ bår 𝌆 baz 244 | ``` 245 | 246 | Read a local text file, encode it for use in an HTML text context, and save the result to a new file: 247 | 248 | ```bash 249 | $ he --encode < foo.txt > foo-escaped.html 250 | ``` 251 | 252 | Or do the same with an online text file: 253 | 254 | ```bash 255 | $ curl -sL "http://git.io/HnfEaw" | he --encode > escaped.html 256 | ``` 257 | 258 | Or, the opposite — read a local file containing a snippet of HTML in a text context, decode it back to plain text, and save the result to a new file: 259 | 260 | ```bash 261 | $ he --decode < foo-escaped.html > foo.txt 262 | ``` 263 | 264 | Or do the same with an online HTML snippet: 265 | 266 | ```bash 267 | $ curl -sL "http://git.io/HnfEaw" | he --decode > decoded.txt 268 | ``` 269 | 270 | See `he --help` for the full list of options. 271 | 272 | ## Support 273 | 274 | he has been tested in at least Chrome 27-29, Firefox 3-22, Safari 4-6, Opera 10-12, IE 6-10, Node.js v0.10.0, Narwhal 0.3.2, RingoJS 0.8-0.9, PhantomJS 1.9.0, and Rhino 1.7RC4. 275 | 276 | ## Unit tests & code coverage 277 | 278 | After cloning this repository, run `npm install` to install the dependencies needed for he development and testing. You may want to install Istanbul _globally_ using `npm install istanbul -g`. 279 | 280 | Once that’s done, you can run the unit tests in Node using `npm test` or `node tests/tests.js`. To run the tests in Rhino, Ringo, Narwhal, and web browsers as well, use `grunt test`. 281 | 282 | To generate [the code coverage report](http://rawgithub.com/mathiasbynens/he/master/coverage/he/he.js.html), use `grunt cover`. 283 | 284 | ## Acknowledgements 285 | 286 | Thanks to [Simon Pieters](http://simon.html5.org/) (@zcorpan) for the many suggestions. 287 | 288 | ## Author 289 | 290 | | [![twitter/mathias](http://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](http://twitter.com/mathias "Follow @mathias on Twitter") | 291 | |---| 292 | | [Mathias Bynens](http://mathiasbynens.be/) | 293 | 294 | ## License 295 | 296 | _he_ is available under the [MIT](http://mths.be/mit) license. 297 | -------------------------------------------------------------------------------- /examples/project-docs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 31 | 65 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 140 | 288 | -------------------------------------------------------------------------------- /examples/prism/prismjs/prism.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* ********************************************** 4 | Begin prism-core.js 5 | ********************************************** */ 6 | 7 | /** 8 | * Prism: Lightweight, robust, elegant syntax highlighting 9 | * MIT license http://www.opensource.org/licenses/mit-license.php/ 10 | * @author Lea Verou http://lea.verou.me 11 | */ 12 | 13 | (function(){ 14 | 15 | // Private helper vars 16 | var lang = /\blang(?:uage)?-(?!\*)(\w+)\b/i; 17 | 18 | var _ = self.Prism = { 19 | util: { 20 | type: function (o) { 21 | return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]; 22 | }, 23 | 24 | // Deep clone a language definition (e.g. to extend it) 25 | clone: function (o) { 26 | var type = _.util.type(o); 27 | 28 | switch (type) { 29 | case 'Object': 30 | var clone = {}; 31 | 32 | for (var key in o) { 33 | if (o.hasOwnProperty(key)) { 34 | clone[key] = _.util.clone(o[key]); 35 | } 36 | } 37 | 38 | return clone; 39 | 40 | case 'Array': 41 | return o.slice(); 42 | } 43 | 44 | return o; 45 | } 46 | }, 47 | 48 | languages: { 49 | extend: function (id, redef) { 50 | var lang = _.util.clone(_.languages[id]); 51 | 52 | for (var key in redef) { 53 | lang[key] = redef[key]; 54 | } 55 | 56 | return lang; 57 | }, 58 | 59 | // Insert a token before another token in a language literal 60 | insertBefore: function (inside, before, insert, root) { 61 | root = root || _.languages; 62 | var grammar = root[inside]; 63 | var ret = {}; 64 | 65 | for (var token in grammar) { 66 | 67 | if (grammar.hasOwnProperty(token)) { 68 | 69 | if (token == before) { 70 | 71 | for (var newToken in insert) { 72 | 73 | if (insert.hasOwnProperty(newToken)) { 74 | ret[newToken] = insert[newToken]; 75 | } 76 | } 77 | } 78 | 79 | ret[token] = grammar[token]; 80 | } 81 | } 82 | 83 | return root[inside] = ret; 84 | }, 85 | 86 | // Traverse a language definition with Depth First Search 87 | DFS: function(o, callback) { 88 | for (var i in o) { 89 | callback.call(o, i, o[i]); 90 | 91 | if (_.util.type(o) === 'Object') { 92 | _.languages.DFS(o[i], callback); 93 | } 94 | } 95 | } 96 | }, 97 | 98 | highlightAll: function(async, callback) { 99 | var elements = document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'); 100 | 101 | for (var i=0, element; element = elements[i++];) { 102 | _.highlightElement(element, async === true, callback); 103 | } 104 | }, 105 | 106 | highlightElement: function(element, async, callback) { 107 | // Find language 108 | var language, grammar, parent = element; 109 | 110 | while (parent && !lang.test(parent.className)) { 111 | parent = parent.parentNode; 112 | } 113 | 114 | if (parent) { 115 | language = (parent.className.match(lang) || [,''])[1]; 116 | grammar = _.languages[language]; 117 | } 118 | 119 | if (!grammar) { 120 | return; 121 | } 122 | 123 | // Set language on the element, if not present 124 | element.className = element.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; 125 | 126 | // Set language on the parent, for styling 127 | parent = element.parentNode; 128 | 129 | if (/pre/i.test(parent.nodeName)) { 130 | parent.className = parent.className.replace(lang, '').replace(/\s+/g, ' ') + ' language-' + language; 131 | } 132 | 133 | var code = element.textContent; 134 | 135 | if(!code) { 136 | return; 137 | } 138 | 139 | code = code.replace(/&/g, '&').replace(/ text.length) { 218 | // Something went terribly wrong, ABORT, ABORT! 219 | break tokenloop; 220 | } 221 | 222 | if (str instanceof Token) { 223 | continue; 224 | } 225 | 226 | pattern.lastIndex = 0; 227 | 228 | var match = pattern.exec(str); 229 | 230 | if (match) { 231 | if(lookbehind) { 232 | lookbehindLength = match[1].length; 233 | } 234 | 235 | var from = match.index - 1 + lookbehindLength, 236 | match = match[0].slice(lookbehindLength), 237 | len = match.length, 238 | to = from + len, 239 | before = str.slice(0, from + 1), 240 | after = str.slice(to + 1); 241 | 242 | var args = [i, 1]; 243 | 244 | if (before) { 245 | args.push(before); 246 | } 247 | 248 | var wrapped = new Token(token, inside? _.tokenize(match, inside) : match); 249 | 250 | args.push(wrapped); 251 | 252 | if (after) { 253 | args.push(after); 254 | } 255 | 256 | Array.prototype.splice.apply(strarr, args); 257 | } 258 | } 259 | } 260 | 261 | return strarr; 262 | }, 263 | 264 | hooks: { 265 | all: {}, 266 | 267 | add: function (name, callback) { 268 | var hooks = _.hooks.all; 269 | 270 | hooks[name] = hooks[name] || []; 271 | 272 | hooks[name].push(callback); 273 | }, 274 | 275 | run: function (name, env) { 276 | var callbacks = _.hooks.all[name]; 277 | 278 | if (!callbacks || !callbacks.length) { 279 | return; 280 | } 281 | 282 | for (var i=0, callback; callback = callbacks[i++];) { 283 | callback(env); 284 | } 285 | } 286 | } 287 | }; 288 | 289 | var Token = _.Token = function(type, content) { 290 | this.type = type; 291 | this.content = content; 292 | }; 293 | 294 | Token.stringify = function(o, language, parent) { 295 | if (typeof o == 'string') { 296 | return o; 297 | } 298 | 299 | if (Object.prototype.toString.call(o) == '[object Array]') { 300 | return o.map(function(element) { 301 | return Token.stringify(element, language, o); 302 | }).join(''); 303 | } 304 | 305 | var env = { 306 | type: o.type, 307 | content: Token.stringify(o.content, language, parent), 308 | tag: 'span', 309 | classes: ['token', o.type], 310 | attributes: {}, 311 | language: language, 312 | parent: parent 313 | }; 314 | 315 | if (env.type == 'comment') { 316 | env.attributes['spellcheck'] = 'true'; 317 | } 318 | 319 | _.hooks.run('wrap', env); 320 | 321 | var attributes = ''; 322 | 323 | for (var name in env.attributes) { 324 | attributes += name + '="' + (env.attributes[name] || '') + '"'; 325 | } 326 | 327 | return '<' + env.tag + ' class="' + env.classes.join(' ') + '" ' + attributes + '>' + env.content + ''; 328 | 329 | }; 330 | 331 | if (!self.document) { 332 | // In worker 333 | self.addEventListener('message', function(evt) { 334 | var message = JSON.parse(evt.data), 335 | lang = message.language, 336 | code = message.code; 337 | 338 | self.postMessage(JSON.stringify(_.tokenize(code, _.languages[lang]))); 339 | self.close(); 340 | }, false); 341 | 342 | return; 343 | } 344 | 345 | // Get current script and highlight 346 | var script = document.getElementsByTagName('script'); 347 | 348 | script = script[script.length - 1]; 349 | 350 | if (script) { 351 | _.filename = script.src; 352 | 353 | if (document.addEventListener && !script.hasAttribute('data-manual')) { 354 | document.addEventListener('DOMContentLoaded', _.highlightAll); 355 | } 356 | } 357 | 358 | })(); 359 | 360 | /* ********************************************** 361 | Begin prism-markup.js 362 | ********************************************** */ 363 | 364 | Prism.languages.markup = { 365 | 'comment': /<!--[\w\W]*?-->/g, 366 | 'prolog': /<\?.+?\?>/, 367 | 'doctype': /<!DOCTYPE.+?>/, 368 | 'cdata': /<!\[CDATA\[[\w\W]*?]]>/i, 369 | 'tag': { 370 | pattern: /<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/gi, 371 | inside: { 372 | 'tag': { 373 | pattern: /^<\/?[\w:-]+/i, 374 | inside: { 375 | 'punctuation': /^<\/?/, 376 | 'namespace': /^[\w-]+?:/ 377 | } 378 | }, 379 | 'attr-value': { 380 | pattern: /=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi, 381 | inside: { 382 | 'punctuation': /=|>|"/g 383 | } 384 | }, 385 | 'punctuation': /\/?>/g, 386 | 'attr-name': { 387 | pattern: /[\w:-]+/g, 388 | inside: { 389 | 'namespace': /^[\w-]+?:/ 390 | } 391 | } 392 | 393 | } 394 | }, 395 | 'entity': /&#?[\da-z]{1,8};/gi 396 | }; 397 | 398 | // Plugin to make entity title show the real entity, idea by Roman Komarov 399 | Prism.hooks.add('wrap', function(env) { 400 | 401 | if (env.type === 'entity') { 402 | env.attributes['title'] = env.content.replace(/&/, '&'); 403 | } 404 | }); 405 | 406 | /* ********************************************** 407 | Begin prism-css.js 408 | ********************************************** */ 409 | 410 | Prism.languages.css = { 411 | 'comment': /\/\*[\w\W]*?\*\//g, 412 | 'atrule': { 413 | pattern: /@[\w-]+?.*?(;|(?=\s*{))/gi, 414 | inside: { 415 | 'punctuation': /[;:]/g 416 | } 417 | }, 418 | 'url': /url\((["']?).*?\1\)/gi, 419 | 'selector': /[^\{\}\s][^\{\};]*(?=\s*\{)/g, 420 | 'property': /(\b|\B)[\w-]+(?=\s*:)/ig, 421 | 'string': /("|')(\\?.)*?\1/g, 422 | 'important': /\B!important\b/gi, 423 | 'ignore': /&(lt|gt|amp);/gi, 424 | 'punctuation': /[\{\};:]/g 425 | }; 426 | 427 | if (Prism.languages.markup) { 428 | Prism.languages.insertBefore('markup', 'tag', { 429 | 'style': { 430 | pattern: /(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig, 431 | inside: { 432 | 'tag': { 433 | pattern: /(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig, 434 | inside: Prism.languages.markup.tag.inside 435 | }, 436 | rest: Prism.languages.css 437 | } 438 | } 439 | }); 440 | } 441 | 442 | /* ********************************************** 443 | Begin prism-clike.js 444 | ********************************************** */ 445 | 446 | Prism.languages.clike = { 447 | 'comment': { 448 | pattern: /(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g, 449 | lookbehind: true 450 | }, 451 | 'string': /("|')(\\?.)*?\1/g, 452 | 'class-name': { 453 | pattern: /((?:class|interface|extends|implements|trait|instanceof|new)\s+)[a-z0-9_\.\\]+/ig, 454 | lookbehind: true, 455 | inside: { 456 | punctuation: /(\.|\\)/ 457 | } 458 | }, 459 | 'keyword': /\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g, 460 | 'boolean': /\b(true|false)\b/g, 461 | 'function': { 462 | pattern: /[a-z0-9_]+\(/ig, 463 | inside: { 464 | punctuation: /\(/ 465 | } 466 | }, 467 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g, 468 | 'operator': /[-+]{1,2}|!|=?<|=?>|={1,2}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g, 469 | 'ignore': /&(lt|gt|amp);/gi, 470 | 'punctuation': /[{}[\];(),.:]/g 471 | }; 472 | 473 | /* ********************************************** 474 | Begin prism-javascript.js 475 | ********************************************** */ 476 | 477 | Prism.languages.javascript = Prism.languages.extend('clike', { 478 | 'keyword': /\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g, 479 | 'number': /\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g 480 | }); 481 | 482 | Prism.languages.insertBefore('javascript', 'keyword', { 483 | 'regex': { 484 | pattern: /(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g, 485 | lookbehind: true 486 | } 487 | }); 488 | 489 | if (Prism.languages.markup) { 490 | Prism.languages.insertBefore('markup', 'tag', { 491 | 'script': { 492 | pattern: /(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig, 493 | inside: { 494 | 'tag': { 495 | pattern: /(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig, 496 | inside: Prism.languages.markup.tag.inside 497 | }, 498 | rest: Prism.languages.javascript 499 | } 500 | } 501 | }); 502 | } 503 | 504 | /* ********************************************** 505 | Begin prism-file-highlight.js 506 | ********************************************** */ 507 | 508 | (function(){ 509 | 510 | if (!self.Prism || !self.document || !document.querySelector) { 511 | return; 512 | } 513 | 514 | var Extensions = { 515 | 'js': 'javascript', 516 | 'html': 'markup', 517 | 'svg': 'markup' 518 | }; 519 | 520 | Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function(pre) { 521 | var src = pre.getAttribute('data-src'); 522 | var extension = (src.match(/\.(\w+)$/) || [,''])[1]; 523 | var language = Extensions[extension] || extension; 524 | 525 | var code = document.createElement('code'); 526 | code.className = 'language-' + language; 527 | 528 | pre.textContent = ''; 529 | 530 | code.textContent = 'Loading…'; 531 | 532 | pre.appendChild(code); 533 | 534 | var xhr = new XMLHttpRequest(); 535 | 536 | xhr.open('GET', src, true); 537 | 538 | xhr.onreadystatechange = function() { 539 | if (xhr.readyState == 4) { 540 | 541 | if (xhr.status < 400 && xhr.responseText) { 542 | code.textContent = xhr.responseText; 543 | 544 | Prism.highlightElement(code); 545 | } 546 | else if (xhr.status >= 400) { 547 | code.textContent = '✖ Error ' + xhr.status + ' while fetching file: ' + xhr.statusText; 548 | } 549 | else { 550 | code.textContent = '✖ Error: File does not exist or is empty'; 551 | } 552 | } 553 | }; 554 | 555 | xhr.send(null); 556 | }); 557 | 558 | })(); -------------------------------------------------------------------------------- /d3-geomap.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 84 | 514 | -------------------------------------------------------------------------------- /datamaps/usa.topo.json: -------------------------------------------------------------------------------- 1 | {"type":"Topology","transform":{"scale":[0.03514630243024302,0.005240860686068607],"translate":[-178.123152,18.948267]},"objects":{"usa":{"type":"GeometryCollection","geometries":[{"type":"Polygon","id":"AL","arcs":[[0,1,2,3,4]],"properties":{"name":"Alabama"}},{"type":"MultiPolygon","id":"AK","arcs":[[[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]]],"properties":{"name":"Alaska"}},{"type":"Polygon","id":"AZ","arcs":[[44,45,46,47,48]],"properties":{"name":"Arizona"}},{"type":"Polygon","id":"AR","arcs":[[49,50,51,52,53,54]],"properties":{"name":"Arkansas"}},{"type":"Polygon","id":"CA","arcs":[[55,-47,56,57]],"properties":{"name":"California"}},{"type":"Polygon","id":"CO","arcs":[[58,59,60,61,62,63]],"properties":{"name":"Colorado"}},{"type":"Polygon","id":"CT","arcs":[[64,65,66,67]],"properties":{"name":"Connecticut"}},{"type":"Polygon","id":"DE","arcs":[[68,69,70,71]],"properties":{"name":"Delaware"}},{"type":"Polygon","id":"DC","arcs":[[72,73]],"properties":{"name":"District of Columbia"}},{"type":"Polygon","id":"FL","arcs":[[74,75,-2]],"properties":{"name":"Florida"}},{"type":"Polygon","id":"GA","arcs":[[76,77,-75,-1,78,79]],"properties":{"name":"Georgia"}},{"type":"MultiPolygon","id":"HI","arcs":[[[80]],[[81]],[[82]],[[83]],[[84]]],"properties":{"name":"Hawaii"}},{"type":"Polygon","id":"ID","arcs":[[85,86,87,88,89,90,91]],"properties":{"name":"Idaho"}},{"type":"Polygon","id":"IL","arcs":[[92,93,94,95,96,97]],"properties":{"name":"Illinois"}},{"type":"Polygon","id":"IN","arcs":[[98,99,-95,100,101]],"properties":{"name":"Indiana"}},{"type":"Polygon","id":"IA","arcs":[[102,-98,103,104,105,106]],"properties":{"name":"Iowa"}},{"type":"Polygon","id":"KS","arcs":[[107,108,-60,109]],"properties":{"name":"Kansas"}},{"type":"Polygon","id":"KY","arcs":[[110,111,112,113,-96,-100,114]],"properties":{"name":"Kentucky"}},{"type":"Polygon","id":"LA","arcs":[[115,116,117,-52]],"properties":{"name":"Louisiana"}},{"type":"Polygon","id":"ME","arcs":[[118,119]],"properties":{"name":"Maine"}},{"type":"MultiPolygon","id":"MD","arcs":[[[120]],[[-71,121,122,123,124,-74,125,126,127]]],"properties":{"name":"Maryland"}},{"type":"Polygon","id":"MA","arcs":[[128,129,130,131,-68,132,133,134]],"properties":{"name":"Massachusetts"}},{"type":"MultiPolygon","id":"MI","arcs":[[[-102,135,136]],[[137]],[[138,139]],[[140]]],"properties":{"name":"Michigan"}},{"type":"Polygon","id":"MN","arcs":[[-107,141,142,143,144]],"properties":{"name":"Minnesota"}},{"type":"Polygon","id":"MS","arcs":[[-4,145,-116,-51,146]],"properties":{"name":"Mississippi"}},{"type":"Polygon","id":"MO","arcs":[[-97,-114,147,-55,148,-108,149,-104]],"properties":{"name":"Missouri"}},{"type":"Polygon","id":"MT","arcs":[[150,151,-92,152,153]],"properties":{"name":"Montana"}},{"type":"Polygon","id":"NE","arcs":[[-105,-150,-110,-59,154,155]],"properties":{"name":"Nebraska"}},{"type":"Polygon","id":"NV","arcs":[[156,-48,-56,157,-88]],"properties":{"name":"Nevada"}},{"type":"Polygon","id":"NH","arcs":[[-135,158,159,-120,160]],"properties":{"name":"New Hampshire"}},{"type":"Polygon","id":"NJ","arcs":[[161,-69,162,163]],"properties":{"name":"New Jersey"}},{"type":"Polygon","id":"NM","arcs":[[164,165,166,-45,-62]],"properties":{"name":"New Mexico"}},{"type":"Polygon","id":"NY","arcs":[[-133,-67,167,-164,168,169,170]],"properties":{"name":"New York"}},{"type":"Polygon","id":"NC","arcs":[[171,172,-80,173,174]],"properties":{"name":"North Carolina"}},{"type":"Polygon","id":"ND","arcs":[[175,-154,176,-143]],"properties":{"name":"North Dakota"}},{"type":"Polygon","id":"OH","arcs":[[177,-115,-99,-137,178,179]],"properties":{"name":"Ohio"}},{"type":"Polygon","id":"OK","arcs":[[-149,-54,180,-165,-61,-109]],"properties":{"name":"Oklahoma"}},{"type":"Polygon","id":"OR","arcs":[[-89,-158,-58,181,182]],"properties":{"name":"Oregon"}},{"type":"Polygon","id":"PA","arcs":[[-163,-72,-128,183,-180,184,-169]],"properties":{"name":"Pennsylvania"}},{"type":"MultiPolygon","id":"RI","arcs":[[[185,-130]],[[186,-65,-132]]],"properties":{"name":"Rhode Island"}},{"type":"Polygon","id":"SC","arcs":[[187,-77,-173]],"properties":{"name":"South Carolina"}},{"type":"Polygon","id":"SD","arcs":[[-142,-106,-156,188,-151,-176]],"properties":{"name":"South Dakota"}},{"type":"Polygon","id":"TN","arcs":[[189,-174,-79,-5,-147,-50,-148,-113]],"properties":{"name":"Tennessee"}},{"type":"Polygon","id":"TX","arcs":[[-53,-118,190,-166,-181]],"properties":{"name":"Texas"}},{"type":"Polygon","id":"UT","arcs":[[191,-63,-49,-157,-87]],"properties":{"name":"Utah"}},{"type":"Polygon","id":"VT","arcs":[[-134,-171,192,-159]],"properties":{"name":"Vermont"}},{"type":"MultiPolygon","id":"VA","arcs":[[[193,-123]],[[120]],[[-126,-73,-125,194,-175,-190,-112,195]]],"properties":{"name":"Virginia"}},{"type":"MultiPolygon","id":"WA","arcs":[[[-183,196,-90]],[[197]],[[198]]],"properties":{"name":"Washington"}},{"type":"Polygon","id":"WV","arcs":[[-184,-127,-196,-111,-178]],"properties":{"name":"West Virginia"}},{"type":"Polygon","id":"WI","arcs":[[199,-93,-103,-145,200,-140]],"properties":{"name":"Wisconsin"}},{"type":"Polygon","id":"WY","arcs":[[-189,-155,-64,-192,-86,-152]],"properties":{"name":"Wyoming"}}]}},"arcs":[[[2632,3060],[5,-164],[7,-242],[4,-53],[3,-30],[-2,-19],[4,-11],[-5,-25],[0,-24],[-2,-32],[2,-57],[-2,-51],[3,-52]],[[2649,2300],[-14,-1],[-59,0],[-1,-25],[6,-37],[-1,-31],[2,-16],[-4,-28]],[[2578,2162],[-4,-6],[-7,31],[-1,47],[-2,6],[-3,-36],[-1,-34],[-7,9]],[[2553,2179],[-2,291],[6,363],[4,209],[-3,20]],[[2558,3062],[24,1],[50,-3]],[[1324,6901],[1,32],[6,-19],[-1,-32],[-8,4],[2,15]],[[1317,6960],[5,-23],[-3,-33],[-2,11],[0,45]],[[1285,7153],[6,5],[3,-8],[-1,-28],[-6,-6],[-5,17],[3,20]],[[1267,7137],[12,-7],[3,-36],[13,-41],[4,-25],[0,-21],[3,-4],[1,-27],[5,-27],[0,-25],[3,8],[2,-19],[1,-74],[-3,-17],[-7,3],[-3,38],[-2,-3],[-6,28],[-2,-10],[-5,10],[1,-28],[5,7],[3,-10],[-2,-39],[-5,4],[-9,49],[-2,25],[1,26],[-7,-2],[0,20],[5,2],[5,18],[-2,31],[-6,7],[-1,50],[-2,25],[-4,-18],[-2,28],[4,14],[-3,32],[2,8]],[[1263,6985],[5,-12],[4,15],[4,-7],[-4,-28],[-6,8],[-3,24]],[[1258,7247],[-4,19],[5,13],[15,-18],[7,1],[5,-36],[9,-29],[-1,-22],[-5,-11],[-6,5],[-5,-14],[-6,9],[-7,-9],[-1,45],[0,30],[-5,1],[-1,16]],[[1252,7162],[-4,14],[-4,32],[0,24],[3,11],[4,-11],[0,20],[12,-35],[1,-33],[-4,-5],[-3,-37],[3,-11],[-3,-43],[-5,9],[0,-27],[-3,13],[-2,54],[5,25]],[[1207,7331],[8,38],[3,-16],[7,-13],[6,-2],[0,-30],[6,-99],[0,-85],[-1,-22],[-4,13],[-10,84],[-7,25],[3,20],[-3,48],[-8,39]],[[1235,7494],[10,-15],[5,2],[0,-14],[8,-52],[-5,8],[-2,-18],[6,-27],[2,-48],[-6,-13],[-2,-16],[-10,-35],[-3,1],[-1,37],[2,22],[-1,32],[-3,40],[0,21],[-2,51],[-4,22],[-1,38],[7,-36]],[[1203,7324],[4,0],[4,-35],[-2,-24],[-6,-5],[0,38],[0,26]],[[1207,7331],[-5,7],[-3,26],[-6,18],[-5,37],[-6,17],[1,30],[4,10],[1,26],[3,-11],[8,-1],[6,17],[8,-23],[-5,-26],[2,-9],[4,28],[10,-9],[5,-21],[-3,-38],[3,-3],[3,-50],[-7,-7],[-14,41],[0,-42],[-4,-17]],[[883,7871],[-12,-48],[-1,-19],[-9,-12],[2,29],[10,30],[7,34],[3,-14]],[[870,7943],[-2,-39],[-4,-41],[-6,14],[5,47],[7,19]],[[863,9788],[3,-8],[15,-9],[8,5],[10,0],[12,-7],[7,4],[7,-15],[12,-18],[16,-4],[5,10],[11,6],[4,14],[12,2],[0,-9],[7,5],[15,-15],[9,-24],[10,-11],[2,-11],[8,-2],[8,-18],[1,-11],[5,9],[6,-7],[0,-1783],[13,-16],[2,17],[14,-24],[8,30],[18,4],[-3,-52],[4,-17],[10,-17],[2,-27],[29,-101],[4,-63],[6,17],[12,31],[7,1],[3,23],[0,34],[5,0],[1,31],[9,7],[13,26],[13,-45],[-1,-27],[3,-27],[7,-7],[10,-40],[-1,-12],[4,-22],[12,-25],[19,-110],[3,-29],[6,-29],[8,-65],[9,-55],[-3,-23],[9,-9],[-2,-33],[7,-14],[1,-38],[7,2],[14,-40],[9,-7],[5,-19],[4,-5],[1,-19],[9,-5],[3,-23],[-4,-43],[1,-36],[4,-58],[-4,-15],[-6,-53],[-10,-39],[-3,20],[-4,-6],[-3,39],[1,17],[-3,20],[7,21],[-2,7],[-7,-26],[-3,17],[-4,-10],[-12,42],[4,46],[-8,-15],[0,-23],[-6,17],[-1,22],[4,24],[-1,24],[-6,-19],[-6,42],[-3,-8],[-2,36],[5,23],[6,0],[-2,28],[3,36],[-5,-1],[-9,32],[-6,37],[-15,27],[0,77],[-4,9],[1,31],[-5,9],[-8,42],[-2,22],[-12,7],[-14,56],[-6,132],[-3,-30],[1,-27],[6,-53],[-1,-8],[3,-43],[0,-28],[-6,6],[-4,31],[-6,6],[-8,-9],[0,45],[-5,38],[-5,-12],[-17,40],[-2,-11],[10,-13],[7,-31],[3,-1],[1,-25],[4,-30],[-10,-16],[-5,10],[0,-26],[-8,20],[-2,14],[-5,0],[-13,38],[-10,33],[-1,20],[-5,30],[-14,21],[-9,21],[-14,26],[-9,24],[1,26],[2,-9],[3,17],[-3,38],[4,21],[-2,9],[-7,-40],[-14,-26],[-18,10],[-14,24],[-1,18],[-7,-4],[-7,14],[-17,12],[-9,1],[-21,-10],[-8,-7],[-10,27],[-12,12],[-3,17],[-2,28],[-8,-2],[-3,-25],[-15,34],[-2,14],[-15,-27],[-7,-32],[-3,30],[3,17],[4,-5],[14,22],[-2,17],[-6,-8],[-3,22],[-6,3],[-6,55],[-3,-13],[-8,-8],[-3,8],[-3,-18],[-11,6],[-1,-20],[-7,-5],[-3,7],[2,36],[-3,-1],[-5,-38],[7,-12],[1,-27],[4,-30],[-3,-31],[-5,10],[-2,-15],[6,-7],[3,-41],[-8,-9],[-4,9],[-7,-12],[-3,10],[-9,-2],[0,16],[-4,-10],[-3,-20],[-3,18],[-5,-25],[2,-12],[-6,-15],[-6,-2],[-3,-20],[-6,-17],[-4,6],[-5,-21],[-4,1],[-8,-43],[-9,-3],[-3,14],[-5,-23],[-11,17],[2,33],[8,11],[4,-2],[2,13],[8,25],[0,21],[-11,-28],[-9,16],[-1,12],[5,48],[8,34],[1,29],[2,5],[1,30],[-4,34],[10,12],[19,48],[4,-19],[6,-5],[9,20],[-10,26],[-4,20],[-7,-2],[-5,9],[-2,-8],[-9,-14],[-4,-26],[-9,-6],[-9,-30],[-1,-20],[-7,-11],[-2,-22],[-5,-13],[-2,-39],[-10,-25],[5,-20],[-4,-29],[-9,-5],[-1,-38],[-8,-13],[-3,15],[-4,-29],[-5,-1],[1,-21],[-11,-13],[-2,-57],[12,-3],[10,-16],[3,-19],[-4,-30],[-7,-19],[-6,-1],[0,-17],[-4,-6],[1,-21],[-4,-31],[-9,-29],[-5,0],[-5,-11],[-5,2],[-4,-11],[2,-16],[-7,-8],[-2,-23],[-5,14],[-5,-45],[-9,4],[1,-24],[-6,6],[-3,-11],[0,-32],[-6,-50],[-10,-6],[-7,-23],[-2,-13],[-5,18],[-8,-48],[-2,13],[-5,-4],[-1,-27],[-5,-10],[-6,4],[-4,-27],[8,-9],[-9,-60],[-25,-20],[-6,-54],[-2,12],[1,33],[-5,6],[-6,-13],[-1,-14],[-10,-22],[-4,-25],[-1,18],[-2,-21],[-6,14],[-10,-33],[-8,2],[1,25],[-4,24],[-3,-20],[1,-21],[-11,-64],[-3,16],[-1,-24],[-8,4],[-1,38],[-4,8],[-2,-14],[4,-16],[-2,-27],[-5,-13],[-5,29],[-5,2],[-1,-11],[5,-17],[-9,-27],[6,-7],[0,-13],[-5,9],[-7,-25],[-15,1],[-7,-16],[0,-13],[-8,-15],[-6,6],[-2,35],[6,12],[4,43],[6,1],[13,28],[10,1],[4,-27],[3,20],[-1,23],[6,10],[7,0],[8,50],[10,45],[12,40],[15,18],[6,-9],[6,12],[1,-17],[-3,-19],[4,-14],[1,23],[7,2],[2,-15],[5,-5],[0,18],[-8,15],[0,11],[5,49],[6,28],[9,27],[15,24],[10,35],[5,-13],[4,5],[-1,22],[1,21],[8,44],[11,28],[8,38],[0,21],[7,148],[11,40],[-1,31],[-27,-45],[-8,6],[-2,18],[-5,9],[-1,21],[-4,-10],[-3,-32],[5,-41],[-6,-18],[-5,7],[-9,64],[-6,33],[-4,0],[-2,-24],[-3,-4],[-4,19],[-5,4],[-2,32],[-16,-37],[-13,-26],[-1,-14],[-11,-22],[-6,20],[5,23],[-1,54],[-4,57],[7,24],[-6,49],[-5,27],[-4,39],[-6,17],[-2,-34],[-7,-8],[-12,-22],[-14,-9],[-7,2],[-7,12],[-1,30],[-5,9],[-9,42],[-8,8],[-8,46],[6,21],[1,39],[-5,-8],[0,24],[2,19],[-6,18],[0,-19],[-7,8],[-1,32],[-6,4],[-3,22],[0,27],[-5,-12],[-1,26],[7,6],[-6,30],[10,2],[0,35],[2,24],[18,77],[4,23],[3,-5],[-2,33],[7,55],[6,22],[11,9],[8,-9],[12,-33],[8,4],[11,32],[11,49],[6,6],[1,-13],[13,0],[12,10],[11,52],[0,12],[-5,48],[-1,28],[-8,31],[-3,26],[8,-7],[8,22],[0,20],[-10,39],[-8,-30],[-7,5],[-6,-17],[-8,-4],[-2,-11],[-9,-17],[-2,-28],[-5,-12],[-2,34],[-5,7],[-4,-26],[-2,12],[-10,19],[-20,-1],[-14,-21],[-6,-3],[-11,13],[-22,14],[-6,12],[-3,19],[2,26],[-8,22],[2,24],[5,12],[-2,31],[-8,0],[-6,8],[-13,6],[-7,16],[-10,16],[-1,19],[16,27],[20,43],[15,27],[8,-15],[8,-3],[2,21],[-5,3],[-1,18],[20,29],[22,22],[12,2],[7,-7],[-4,-32],[2,-22],[-3,-15],[4,-26],[8,5],[10,-5],[11,6],[4,-10],[7,-2],[7,10],[8,-11],[9,42],[5,2],[5,-8],[2,24],[-12,11],[-11,-9],[1,31],[-8,34],[-10,10],[-2,30],[7,8],[9,-31],[-1,-24],[4,-18],[10,-22],[2,23],[-11,30],[5,54],[-4,10],[-11,-12],[-11,3],[-2,10],[-6,-10],[-24,23],[0,24],[-7,54],[-6,19],[-9,17],[-19,46],[-9,18],[-8,4],[-13,31],[-12,18],[-1,6],[9,10],[4,29],[1,59],[25,-4],[31,13],[8,11],[12,29],[12,45],[3,45],[5,38],[10,33],[5,24],[13,38],[2,-10],[11,-3],[16,20],[10,21],[24,64],[9,4],[1,-10],[9,7],[9,-2],[18,9],[17,28],[17,58],[7,13],[2,-10],[26,-24],[2,-17],[-9,-22],[-4,-1],[0,-29],[14,9],[0,16],[6,14],[2,-8],[5,33],[13,-30],[-2,-23],[8,-6],[5,-14],[7,22],[13,1],[7,7],[18,-7],[10,-8],[-5,-45],[17,-12],[2,-11],[16,-20],[1,9],[12,13],[11,-1],[0,-11],[7,-1],[7,15],[11,2],[9,-6],[11,-16],[5,3],[7,-22],[4,9],[7,-7],[5,-13]],[[717,7456],[-1,-8],[-9,13],[7,49],[6,4],[4,45],[5,-40],[4,14],[8,-22],[0,-31],[-11,-4],[-5,-13],[-8,-7]],[[688,7363],[8,25],[-8,6],[0,22],[6,14],[5,-10],[0,-22],[3,15],[0,32],[5,-15],[1,21],[5,-12],[5,0],[5,11],[7,-20],[0,-55],[9,4],[-6,-37],[-11,15],[4,-24],[-3,-20],[-6,10],[0,-38],[-8,-10],[-3,-16],[-5,15],[-6,-40],[-4,-4],[-5,-18],[-2,43],[-6,-23],[-1,13],[-6,14],[0,39],[-6,15],[4,45],[11,28],[7,-2],[1,-21]],[[671,7185],[-6,-39],[-2,6],[8,33]],[[640,7055],[4,-2],[-1,-40],[-8,6],[-1,13],[6,23]],[[519,6933],[-2,-41],[-9,-33],[5,51],[2,-5],[4,28]],[[501,6947],[5,0],[0,-20],[-5,-23],[-5,15],[-3,-14],[-2,35],[2,12],[8,-5]],[[451,6875],[1,-16],[-3,-11],[-3,18],[5,9]],[[447,8527],[-4,-19],[-2,16],[6,3]],[[436,6781],[6,-7],[-1,-16],[-5,1],[0,22]],[[358,6745],[2,-22],[-5,-10],[-1,23],[4,9]],[[352,6718],[-8,-21],[-2,14],[3,19],[7,-12]],[[335,7902],[6,7],[2,-14],[5,3],[6,-12],[1,-54],[-3,-18],[-7,-11],[-2,-18],[-11,20],[-5,-1],[-10,28],[-4,0],[-6,15],[-3,25],[4,7],[10,-7],[5,20],[5,2],[3,14],[4,-6]],[[334,6690],[5,-14],[-10,-36],[1,-6],[12,26],[0,-15],[-5,-17],[-8,-12],[-1,-18],[-8,-18],[-7,-1],[-5,-18],[-9,-16],[-5,17],[9,20],[3,-3],[8,16],[-2,19],[4,20],[6,-9],[1,12],[-7,4],[-4,14],[4,23],[11,13],[2,-26],[5,25]],[[266,6527],[10,37],[1,16],[4,17],[7,9],[3,-10],[1,-25],[-12,-27],[-6,-40],[-6,-13],[-2,36]],[[238,6477],[2,-19],[-8,-1],[-1,13],[7,7]],[[227,7303],[-4,-18],[-1,18],[5,0]],[[212,6440],[2,-18],[-5,-13],[-1,19],[4,12]],[[182,8542],[22,-28],[13,24],[6,-2],[5,-14],[2,-23],[11,-12],[4,-12],[15,-5],[8,-8],[-4,-28],[-7,6],[-8,-5],[-4,-13],[-4,-28],[-5,26],[-6,18],[-6,2],[-3,20],[-15,25],[-6,1],[-11,-22],[-7,11],[-4,23],[4,44]],[[162,6381],[0,-22],[-5,-4],[1,19],[4,7]],[[128,6335],[4,-8],[10,1],[1,-7],[-13,-9],[-2,23]],[[108,6360],[0,19],[4,7],[6,-19],[-2,-17],[-4,1],[1,-20],[-5,-2],[-12,-21],[-6,6],[2,15],[7,-2],[9,33]],[[47,6279],[5,3],[0,-24],[-6,3],[-8,-28],[-4,37],[4,1],[0,29],[5,1],[0,-21],[4,-1]],[[28,6296],[3,-9],[-2,-32],[-5,-10],[0,20],[4,31]],[[0,6291],[5,-1],[4,-23],[-4,-27],[-5,51]],[[9993,6496],[6,-13],[0,-19],[-11,-12],[-8,31],[0,15],[13,-2]],[[1966,3444],[-1,-1081]],[[1965,2363],[-57,0],[-34,71],[-73,150],[3,43]],[[1804,2627],[6,8],[1,16],[-1,36],[-4,1],[-2,71],[6,27],[0,28],[-1,45],[4,34],[4,12],[4,25],[-6,27],[-4,51],[-5,31],[0,24]],[[1806,3063],[2,26],[0,36],[-3,36],[-2,112],[11,7],[3,-23],[3,1],[3,33],[0,153]],[[1823,3444],[101,2],[42,-2]],[[2515,3253],[-1,-35],[-4,-11],[-1,-29],[-5,-31],[0,-46],[-3,-34],[-3,-5]],[[2498,3062],[2,-17],[-4,-14],[-2,-33],[-3,-8],[0,-38],[-5,-10],[0,-13],[-6,-31],[2,-21],[-5,-30],[-5,-59],[5,-25],[-2,-16],[1,-39],[-2,-26]],[[2474,2682],[-69,3],[-13,0]],[[2392,2685],[0,101],[-4,8],[-5,-9],[-3,18]],[[2380,2803],[1,335],[-5,211]],[[2376,3349],[4,0],[123,-1],[2,-36],[-4,-23],[-4,-36],[18,0]],[[1654,4398],[0,-331],[0,-241],[36,-171],[35,-169],[27,-137],[20,-101],[34,-185]],[[1804,2627],[-38,-18],[-30,-16],[-4,25],[0,40],[-2,47],[-4,33],[-9,46],[-12,43],[-2,-12],[-4,8],[1,18],[-5,39],[-7,-8],[-12,28],[-2,23],[-8,28],[-9,-1],[-7,13],[-10,-6],[-5,26],[1,53],[-1,8],[1,38],[-8,28],[0,39],[-3,2],[-4,33],[-4,8],[-1,20],[-11,79],[-5,23],[-1,61],[2,-5],[2,37],[-4,33],[-5,-4],[-7,30],[-2,24],[0,23],[-3,31],[0,50],[5,0],[-2,70],[-2,-7],[-1,-35],[-5,-7],[-7,26],[-1,45],[-4,35],[-6,22],[-3,25],[-9,50],[2,14],[-4,64],[2,35],[-3,54],[-7,52],[-7,29],[-2,35],[7,83],[2,29],[-2,22],[3,57],[-2,52],[-3,13],[1,42]],[[1534,4399],[28,1],[24,1],[38,-3],[30,0]],[[2107,4208],[57,0],[0,-191]],[[2164,4017],[1,-574]],[[2165,3443],[-28,1]],[[2137,3444],[-38,-1],[-72,0],[-15,1],[-46,0]],[[1966,3444],[0,223],[-1,21],[0,162],[0,357]],[[1965,4207],[32,1],[63,-1],[47,1]],[[3025,4400],[0,-113],[-2,-18]],[[3023,4269],[-2,3],[-12,-14],[-15,4],[-7,-26],[-7,-9],[-8,-22]],[[2972,4205],[-2,22],[7,21],[-2,16],[2,144]],[[2977,4408],[12,-2],[36,-3],[0,-3]],[[2922,3980],[-2,-23]],[[2920,3957],[-3,-13],[0,-30],[5,-29],[1,-47],[6,-49],[3,-2],[1,-66]],[[2933,3721],[-19,2],[-2,241]],[[2912,3964],[5,21],[5,-5]],[[2876,3786],[-2,27]],[[2874,3813],[2,12],[4,-19],[-4,-20]],[[2649,2300],[4,-55],[39,-13],[37,-14],[1,-41],[4,1],[1,39],[-1,35],[2,15],[7,-16],[8,-7]],[[2751,2244],[1,-83],[4,-93],[8,-122],[13,-131],[-2,-9],[1,-61],[5,-68],[8,-137],[2,-42],[0,-44],[-3,-158],[-3,-3],[-3,-49],[1,-16],[-5,-36],[-2,9],[-6,-15],[-9,-8],[-2,20],[1,29],[-7,85],[-5,15],[-4,-11],[-3,47],[-1,38],[-6,43],[-2,28],[1,41],[-3,8],[1,-24],[-3,-7],[-9,104],[-4,26],[9,76],[-6,-4],[-4,-24],[-3,38],[5,104],[1,87],[-4,21],[-1,28],[-5,6],[-7,46],[-5,19],[0,28],[-4,11],[-3,31],[-11,42],[-9,-10],[0,-29],[-3,5],[-12,-35],[-12,-9],[0,21],[-3,25],[-15,57],[-10,24],[-10,6],[-8,-4],[-17,-18]],[[2703,3063],[-6,-41],[0,-20],[9,-40],[3,3],[5,-42],[1,-22],[4,-40],[7,-24],[3,-35],[8,-33],[0,-22],[5,-35],[7,-29],[2,-32],[1,-40],[3,-14],[5,-51],[0,-33],[7,-16]],[[2767,2497],[-7,-65],[-2,-34],[-3,-29],[0,-30],[-3,-14],[-1,-81]],[[2632,3060],[37,1]],[[2669,3061],[20,-1],[14,3]],[[640,0],[-7,17],[-1,16],[1,43],[-5,73],[4,24],[2,34],[-2,22],[1,23],[8,-27],[9,-20],[5,-29],[0,-26],[8,-40],[-5,-34],[-8,-15],[-7,-25],[-3,-36]],[[613,397],[3,-26],[4,11],[9,-30],[-1,-27],[-9,-14],[-2,6],[-1,33],[-5,7],[-1,19],[3,21]],[[602,432],[-3,-20],[-7,0],[2,22],[8,-2]],[[574,525],[3,-45],[-2,-26],[-6,-5],[-4,54],[4,1],[5,21]],[[531,626],[3,-2],[2,-20],[-1,-28],[-4,-18],[-9,22],[1,31],[8,15]],[[1908,4871],[0,-472]],[[1908,4399],[-31,-1],[-54,0]],[[1823,4398],[-85,1]],[[1738,4399],[0,349],[4,62],[-2,16],[-6,3],[-2,26],[6,68],[3,6],[3,29],[-1,17],[4,23],[1,34],[6,56],[-2,26],[-7,14],[-4,32]],[[1741,5160],[0,34],[-3,33],[0,16],[0,255],[0,236]],[[1738,5734],[28,0]],[[1766,5734],[0,-195],[9,-54],[1,-52],[5,-23],[6,-8],[0,-14],[11,-51],[1,-21],[8,-20],[0,-12],[8,1],[-4,-71],[-1,-45],[3,-29],[-5,-21],[2,-20],[-1,-21],[6,-20],[7,26],[3,21],[5,-19],[-1,-15],[3,-37],[5,-39],[3,-13],[0,-37],[3,-16],[6,-2],[4,-61],[3,-11],[3,18],[9,-1],[7,17],[3,-10],[7,9],[2,-11],[5,8],[7,39],[4,-33],[5,-20]],[[2489,4496],[53,-3],[28,0]],[[2570,4493],[-1,-37],[4,-43],[5,-70]],[[2578,4343],[0,-450],[-3,-35],[3,-40],[1,-34],[-4,-27],[-1,-25],[-5,-41],[-3,-3],[0,-24],[-2,-9],[-1,-45],[0,-13]],[[2563,3597],[-3,-27],[2,-34],[-11,-17],[-1,-20],[2,-25],[-3,-16],[-11,29],[-3,-2],[-4,-33],[1,-11]],[[2532,3441],[-5,2],[-6,55],[2,12],[-2,37],[0,29],[-9,41],[-3,-4],[-3,25],[-9,38],[0,31],[5,49],[-1,18],[3,23],[-4,13],[-6,9],[-3,-18],[-3,11],[-1,63],[-10,41],[-9,49],[-3,58],[-1,39],[3,27]],[[2467,4089],[0,35],[8,21],[1,29],[4,19],[0,33],[-4,27],[2,34],[11,9],[9,24],[0,29],[4,13],[1,37],[0,24],[-7,18],[-1,20],[-6,35]],[[2655,4340],[0,-228],[0,-266]],[[2655,3846],[-2,-9],[2,-52],[-5,-1],[-5,-18],[-8,9],[1,-38],[-5,-16],[-2,-24],[-5,-9],[-3,-48],[-3,-13],[-6,18],[-1,22],[-7,-24],[1,-21],[-7,-7],[-1,19],[-8,-19],[-2,-20],[-7,28],[-4,-6],[-2,13],[-3,-13],[-7,-2],[-3,-18]],[[2578,4343],[3,-12],[8,0],[9,22]],[[2598,4353],[23,0],[34,0],[0,-13]],[[2473,4685],[0,-28],[4,-19],[-3,-23],[1,-43],[2,-30],[10,-22],[2,-24]],[[2467,4089],[-3,7],[-6,38],[-3,-1],[-40,-5],[-39,-2],[-33,3]],[[2343,4129],[-3,25],[2,49],[-3,43],[0,48],[-5,17],[-1,26],[2,23],[-2,33],[-4,13],[-5,86]],[[2324,4492],[-5,41],[2,29],[1,37],[2,14],[-3,19],[1,33],[-2,16],[4,4]],[[2324,4685],[144,0],[5,0]],[[2356,4017],[3,-18],[9,-14],[-6,-56],[4,-18],[4,-45],[6,-10],[0,-412]],[[2376,3444],[-156,0],[-55,-1]],[[2164,4017],[5,0],[187,0]],[[2718,3716],[-1,-57],[4,-37],[4,-28],[2,-22],[5,-22],[4,-3]],[[2736,3547],[-11,-51],[-11,-29],[0,-14],[-4,-13],[0,-16],[-6,-8],[-1,-21],[-16,-27]],[[2687,3368],[0,-3],[-24,2],[-22,6],[-5,-2],[-32,8],[-36,-5],[-6,9],[1,-35],[-36,2],[-3,-2]],[[2524,3348],[1,24],[5,-8],[2,77]],[[2655,3846],[11,0],[5,-40],[1,-17],[9,-7],[6,-26],[5,13],[10,-14],[4,19],[4,6],[1,-32],[3,-6],[4,-26]],[[2474,2682],[3,-22],[-2,-9],[-1,-38],[5,-24],[0,-57],[-3,-44],[-7,-27],[-2,-43],[-2,4],[-1,-70],[-3,-2],[2,-37],[-2,-14],[54,0],[-3,-63],[4,-41],[1,-32],[4,-20]],[[2521,2143],[-9,-26],[0,-19],[7,-12],[3,30],[6,-30],[-1,-24],[-3,-11],[-7,10],[1,-18],[-2,-27],[5,-24],[9,-7],[3,-29],[3,-4],[-5,-32],[-5,6],[-4,33],[-10,18],[0,33],[-6,-11],[1,-27],[-3,-25],[-3,-4],[-3,28],[-7,1],[-2,-29],[-4,-9],[-5,18],[-4,2],[-3,47],[-7,21],[-2,-3],[-3,40],[-7,-5],[0,24],[-8,-23],[1,-18],[-5,-17],[-9,8],[-10,27],[-7,11],[-16,-9],[-2,-8]],[[2398,2049],[-2,19],[6,68],[-2,37],[2,20],[-1,26],[3,19],[3,50],[0,40],[-8,78],[0,41],[-7,42],[0,196]],[[3046,5029],[12,26],[-2,13],[5,30],[4,13],[-1,12],[5,18],[-1,33],[2,50],[5,17],[1,53],[22,147],[6,-7],[0,-35],[4,-13],[9,21],[6,0],[4,14],[8,-31],[4,-25],[1,-214],[-1,-51],[10,-14],[-2,-22],[3,-21],[-2,-18],[4,-30],[5,7],[5,-68],[-6,-31],[-3,12],[-3,-21],[-4,5],[0,-18],[-6,2],[-8,-40],[-2,28],[-3,2],[1,-30],[-6,-15],[-2,24],[-3,-12],[-7,0],[0,28],[-5,-6],[1,-20],[-4,-42],[1,-12],[-6,-23],[-5,9],[-3,-24],[-4,-3],[-4,-20],[-4,4],[-1,21],[-7,-34],[2,-21],[-5,-7],[0,-18],[-5,-22],[-5,-50]],[[3056,4600],[-3,14],[0,19],[-4,22],[-2,250],[-1,124]],[[2904,3626],[2,0],[-1,0],[-1,0]],[[2933,3721],[-6,-80]],[[2927,3641],[-4,-3],[-8,-12]],[[2915,3626],[-6,-8],[0,31],[-2,13],[3,13],[-4,32],[-2,-14],[-6,3],[-2,35],[2,0],[0,45],[2,18],[-2,60],[3,36],[5,6],[0,37],[-3,-5],[0,-18],[-8,-25],[-2,-21],[0,-56],[-3,-26],[1,-44],[4,-30],[-1,-23],[3,-23],[-2,-16],[-6,30],[-10,15],[-2,29],[-6,-16],[-2,23],[5,29]],[[2874,3756],[2,30]],[[2874,3813],[-4,18],[-6,10],[0,28],[-3,15],[-4,4]],[[2857,3888],[-4,53],[-4,0],[-5,18],[-3,-15],[-5,1],[-1,-21],[-8,14],[-6,-28],[-3,6],[-6,-33],[-6,-17],[1,98]],[[2807,3964],[105,0]],[[3053,4565],[1,-34],[-1,-27],[-5,-25],[0,-29],[6,-4],[4,-31],[0,-24],[3,-6],[0,-22],[8,-19],[9,18],[-2,-26],[-13,-23],[-5,-1],[-3,18],[-5,-6],[0,-13],[-5,-9]],[[3045,4302],[-3,35]],[[3042,4337],[0,6]],[[3042,4343],[-3,14],[-2,45],[-4,0],[-8,-2]],[[2977,4408],[0,7],[6,126]],[[2983,4541],[23,-3]],[[3006,4538],[34,-7],[3,18],[7,19],[3,-3]],[[2598,4353],[5,25],[4,43],[4,26],[3,36],[1,52],[0,57],[-9,111],[3,42],[-2,50],[6,51],[2,43],[-1,23],[5,9],[0,31],[8,9],[5,34],[0,-69],[3,-3],[3,35],[1,58],[2,15],[8,9],[-3,41],[5,35],[7,2],[7,-22],[7,-3],[3,-28],[6,-2],[9,-25],[3,1],[4,-41],[-3,-21],[3,-29],[2,-32],[-2,-71],[-6,-18],[-1,-37],[-7,-12],[-4,-44],[2,-17],[6,-15],[6,24],[6,49],[10,19],[5,-15],[3,-27],[3,-80],[0,-39],[3,-48],[-3,-69],[-4,-11],[-1,25],[-3,-7],[-3,-58],[-6,-21],[-2,-44],[-7,-37],[0,-16]],[[2694,4347],[-39,-7]],[[2635,5110],[1,-23],[-4,-4],[1,33],[2,-6]],[[2496,5270],[11,20],[5,23],[12,9],[8,29],[4,1],[3,20],[9,28],[4,24],[7,15],[6,-13],[-11,-59],[-2,-19],[0,-36],[5,27],[10,-4],[8,-19],[7,-52],[3,-10],[7,9],[2,-12],[7,-6],[16,44],[8,4],[10,-2],[7,15],[6,1],[1,-54],[5,-7],[6,8],[2,-12],[4,16],[8,5],[1,-67],[3,-28],[6,-8],[1,19],[5,0],[3,-20],[-3,-14],[-15,12],[-8,-8],[-8,23],[-2,-21],[1,-18],[-4,4],[-5,27],[-9,15],[-5,1],[-4,-25],[-8,-6],[-8,5],[-3,-10],[-1,-21],[-9,-18],[1,25],[-4,5],[-2,-26],[-6,-1],[-3,-11],[-5,-45],[-8,-58],[1,-5]],[[2576,4989],[-4,20],[2,27],[-7,4],[3,26],[0,34],[-5,23],[-4,24],[-12,19],[-4,-7],[-12,29],[-29,38],[-3,33],[-5,11]],[[2541,5539],[-7,-24],[-4,-3],[1,19],[18,45],[-4,-31],[-4,-6]],[[2324,4685],[0,343],[-7,22],[-5,36],[8,41],[1,22]],[[2321,5149],[-1,76],[-4,20],[-2,42],[0,51],[-1,8],[-1,123],[-5,65],[-3,36],[0,77],[1,27],[-3,60]],[[2302,5734],[59,0],[0,73],[5,-2],[4,-14],[4,-100],[3,-11],[9,-3],[1,-10],[11,-4],[1,-21],[10,5],[0,9],[7,10],[6,-4],[8,-16],[2,-19],[4,2],[4,-43],[2,18],[7,8],[1,-18],[9,-12],[0,-17],[4,-14],[8,8],[5,18],[8,12],[2,-28],[5,6],[6,-6],[6,4],[8,-24],[7,4],[0,-10],[-10,-24],[-13,-19],[-9,-20],[-12,-49],[-5,-31],[-8,-34],[-13,-46],[2,-16]],[[2450,5296],[-2,9],[-6,-16],[0,-113],[-2,-11],[-8,-16],[-6,-41],[-1,-27],[3,-2],[4,-24],[-3,-29],[0,-33],[-2,-70],[8,-34],[6,-3],[3,-21],[8,-21],[2,-25],[8,-33],[5,-7],[5,-42],[-1,-30],[2,-22]],[[2553,2179],[-3,-8],[-7,4],[-3,12],[-7,-8],[-9,-22],[-3,-14]],[[2498,3062],[53,0],[7,0]],[[2524,3348],[-2,0],[-2,0],[1,-47],[-6,-48]],[[2376,3349],[0,95]],[[2356,4017],[-7,50],[-6,62]],[[2108,5151],[0,-181],[-1,0]],[[2107,4970],[-53,1],[-90,0],[-56,0],[0,-100]],[[1766,5734],[130,-1],[58,1],[154,0]],[[2108,5734],[0,-217],[0,-366]],[[2107,4208],[0,382]],[[2107,4590],[21,0],[49,-1],[88,0],[1,-10],[15,-34],[4,19],[4,-4],[13,0],[15,-36],[2,-27],[5,-5]],[[1823,4398],[0,-954]],[[1654,4398],[37,-1],[47,2]],[[3006,4538],[-2,14],[0,28],[3,11],[-1,27],[3,81],[5,37],[2,43],[3,16],[-1,47],[10,17],[5,33],[-3,31],[4,32],[0,18]],[[3034,4973],[4,49],[6,-5],[2,12]],[[3056,4600],[-3,-35]],[[2962,4152],[-5,-13],[-2,-29],[8,-14],[0,-22],[-3,-103],[-9,-76],[-6,-22],[-5,-48],[-3,31],[-8,16],[-10,42],[-1,28],[0,4],[2,11]],[[2922,3980],[8,15],[0,15],[9,31],[2,17],[-9,39],[0,24],[-3,6],[-1,22],[5,33],[-3,20],[7,40],[2,21],[4,13]],[[2943,4276],[13,-41],[9,-28],[-3,-55]],[[2137,3444],[0,-95]],[[2137,3349],[-1,0],[0,-474],[0,-193],[0,-192],[-101,0],[-1,-18],[3,-22]],[[2037,2450],[-48,0],[0,-87],[-24,0]],[[2972,4205],[13,-15],[2,11],[10,0],[6,6],[8,31],[1,-22],[5,-10],[-11,-28],[-22,-42],[-9,-8],[-6,2],[-5,-9],[-2,31]],[[2943,4276],[-2,14],[-4,1],[-5,32],[1,29],[-4,22],[-2,-2],[-3,27],[-125,0],[0,48],[0,3]],[[2799,4450],[17,54],[3,26],[5,18],[-2,32],[-2,7],[-2,52],[17,22],[15,-1],[6,-5],[6,-21],[4,8],[12,-1],[8,14],[8,34],[5,1],[0,52],[3,31],[-7,21],[2,24],[11,32],[4,28],[14,64],[13,32],[19,-5],[23,4]],[[2981,4973],[1,-39],[-2,-36],[3,-34],[-1,-37],[-3,-39],[2,-52],[-1,-16],[4,-31],[-1,-132],[0,-16]],[[2909,3359],[4,-77],[-8,8],[-1,-10],[-10,-11],[-1,-11],[-7,-3],[0,-13],[8,9],[1,-8],[9,9],[3,-18],[5,8],[2,-46],[-2,-22],[-3,-2],[-8,-47],[-9,-2],[-2,-33],[4,-32],[4,-6],[-6,-54],[-6,7],[-9,-6],[-6,-11],[-10,-37],[-7,-48],[-4,-60],[-6,13],[-11,-12]],[[2833,2844],[-32,181],[-32,4],[1,21],[-5,33],[-3,-12],[0,20],[-35,10],[-8,-8],[-6,-17],[-10,-13]],[[2669,3061],[1,45],[5,4],[3,31],[7,29],[7,1],[7,29],[8,10],[6,43],[4,13],[1,-19],[11,37],[5,-8],[4,36],[5,9],[1,45]],[[2744,3366],[20,-5],[19,-3],[23,-1],[103,2]],[[2321,5149],[-213,2]],[[2108,5734],[194,0]],[[2777,4138],[-4,-10],[2,-21],[0,-29],[-4,-46],[-3,-70],[-11,-62],[-3,-8],[-4,12],[-3,-27],[-3,1],[-4,-36],[1,-22],[-3,-18],[-4,29],[-5,-46],[1,-29],[-3,-11],[-1,-25],[-8,-4]],[[2694,4347],[11,-26],[3,-15],[3,14],[6,-30],[4,-9],[14,25],[7,-6],[9,36],[12,34],[14,24]],[[2777,4394],[0,-256]],[[2380,2803],[-11,21],[-3,22],[-7,18],[-2,-16],[-8,1],[-1,10],[-7,-19],[-3,11],[-6,-10],[-5,-29],[-2,17],[-6,14],[-7,0],[-2,21],[-7,-42],[-2,24],[-3,-8],[-3,16],[-7,15],[-5,-25],[-2,26],[-4,3],[-2,21],[-6,8],[-3,-18],[-3,16],[-5,-2],[-6,17],[-6,-2],[-2,36],[-9,2],[-4,-6],[-6,37],[-2,-3],[0,370],[-52,0],[-34,0]],[[1534,4399],[-4,22],[-2,61],[0,43],[-4,33],[3,32],[2,51],[4,54],[2,48],[3,162],[0,22],[3,71],[1,99],[-2,54],[1,32],[12,29]],[[1553,5212],[5,-22],[4,5],[3,2],[6,-20],[3,-23],[1,-57],[15,-21],[12,30],[8,3],[9,-10],[1,-13],[16,27],[3,-9],[9,5],[7,19],[12,17],[12,4],[4,12],[58,-1]],[[2807,3964],[-30,0],[0,174]],[[2777,4394],[5,11],[17,45]],[[3045,4302],[-6,-4],[3,39]],[[3042,4343],[-4,3],[-3,-28],[-1,-40],[-11,-9]],[[2833,2844],[-5,-10],[-6,-31],[-6,-49],[-1,-40],[-5,-31],[-6,0],[-2,-23],[-6,-25],[-4,-28],[-6,-11],[-6,-29],[-1,-14],[-6,-16],[-6,-40]],[[2107,4590],[0,380]],[[2687,3368],[57,-2]],[[2398,2049],[-5,-1],[-14,-26],[-6,15],[-1,31],[-3,-22],[-3,5],[-1,-27],[3,-11],[0,-36],[-5,-37],[-9,-47],[-17,-51],[-2,9],[-5,-13],[0,12],[-7,-9],[-3,24],[-2,-5],[7,-49],[-5,-16],[-5,10],[-1,-35],[-7,-35],[-6,-66],[-4,-69],[-3,5],[-1,-25],[3,6],[-2,-50],[-2,-2],[0,-28],[3,-16],[1,-57],[3,-20],[0,-37],[3,-32],[-9,-20],[-3,25],[-7,10],[-9,-3],[-8,32],[-5,3],[-5,25],[-6,8],[-4,24],[-2,58],[-5,34],[0,30],[-2,31],[1,27],[-4,30],[-3,4],[-5,27],[-1,34],[-5,32],[-6,26],[-3,57],[-2,16],[-4,46],[-1,38],[-4,27],[-6,24],[-1,16],[-6,15],[-4,42],[-13,9],[-7,-2],[-7,15],[-1,-20],[-7,-6],[-5,-40],[-3,-64],[-2,-1],[-4,-37],[-5,-1],[-7,29],[-17,47],[-4,25],[-6,24],[-5,54],[-1,49],[-4,40],[-2,35],[-3,22],[-11,32],[-6,44],[-4,15],[-6,38],[-7,20],[-5,50],[-4,11]],[[1908,4399],[0,-192],[57,0]],[[2981,4973],[30,-2],[23,2]],[[2927,3641],[-4,-32],[-3,-12],[-3,-44],[-6,-71],[-5,-15],[-1,27],[2,58],[8,74]],[[2874,3756],[-4,-8],[-2,-28],[1,-19],[8,6],[1,-31],[10,-12],[3,-24],[8,-26],[-4,-54],[4,-41],[-4,-20],[-1,-24],[4,-15],[-4,-23],[-6,30],[-1,-10],[5,-22],[14,-5],[3,-71]],[[2736,3547],[-1,-16],[4,-32],[5,-16],[4,1],[5,25],[4,-20],[7,11],[13,36],[1,-11],[5,17],[0,34],[4,30],[5,29],[2,34],[6,36],[2,44],[5,-27],[4,-8],[3,16],[6,68],[4,-17],[13,77],[2,57],[15,-64],[3,37]],[[1553,5212],[-5,7],[-4,-12],[-6,17],[1,26],[4,14],[-6,40],[-4,103],[-2,14],[-3,73],[-6,28],[-2,56],[3,38],[6,-18],[11,-24],[8,1],[8,-9],[8,9],[3,-16],[7,1],[5,-42],[3,3],[1,-56],[2,-52],[3,6],[-3,43],[1,43],[4,44],[-3,18],[-1,31],[-3,35],[2,25],[-2,29],[-5,4],[-4,22],[1,21],[163,0]],[[1576,5602],[4,9],[0,-39],[-5,15],[1,15]],[[1568,5655],[3,25],[4,-30],[-1,-27],[-7,8],[1,24]],[[2576,4989],[-1,-23],[-6,-4],[-4,-44],[-2,-30],[3,-6],[5,20],[4,38],[6,15],[5,48],[6,10],[-1,-25],[-4,-23],[-8,-79],[-2,-44],[0,-32],[-3,-10],[-2,-43],[1,-37],[-3,-24],[-3,-59],[0,-47],[4,-42],[-1,-55]],[[2450,5296],[6,-2],[20,33],[8,17],[2,-13],[-4,-25],[9,-33],[5,-3]]]} -------------------------------------------------------------------------------- /datamaps/datamaps.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var svg; 3 | 4 | //save off default references 5 | var d3 = window.d3, topojson = window.topojson; 6 | 7 | var defaultOptions = { 8 | scope: 'world', 9 | responsive: false, 10 | setProjection: setProjection, 11 | projection: 'equirectangular', 12 | dataType: 'json', 13 | done: function() {}, 14 | fills: { 15 | defaultFill: '#ABDDA4' 16 | }, 17 | geographyConfig: { 18 | dataUrl: null, 19 | hideAntarctica: true, 20 | borderWidth: 1, 21 | borderColor: '#FDFDFD', 22 | popupTemplate: function(geography, data) { 23 | return '
' + geography.properties.name + '
'; 24 | }, 25 | popupOnHover: true, 26 | highlightOnHover: true, 27 | highlightFillColor: '#FC8D59', 28 | highlightBorderColor: 'rgba(250, 15, 160, 0.2)', 29 | highlightBorderWidth: 2 30 | }, 31 | projectionConfig: { 32 | rotation: [97, 0] 33 | }, 34 | bubblesConfig: { 35 | borderWidth: 2, 36 | borderColor: '#FFFFFF', 37 | popupOnHover: true, 38 | popupTemplate: function(geography, data) { 39 | return '
' + data.name + '
'; 40 | }, 41 | fillOpacity: 0.75, 42 | animate: true, 43 | highlightOnHover: true, 44 | highlightFillColor: '#FC8D59', 45 | highlightBorderColor: 'rgba(250, 15, 160, 0.2)', 46 | highlightBorderWidth: 2, 47 | highlightFillOpacity: 0.85, 48 | exitDelay: 100 49 | }, 50 | arcConfig: { 51 | strokeColor: '#DD1C77', 52 | strokeWidth: 1, 53 | arcSharpness: 1, 54 | animationSpeed: 600 55 | }, 56 | backgroundConfig: { 57 | backgroundImage: null 58 | }, 59 | pointerConfig: { 60 | pan: true, 61 | panBounds: true, 62 | zoom: true, 63 | zoomIncrement: 0.1 64 | } 65 | }; 66 | 67 | function addContainer( element, height, width ) { 68 | this.svg = d3.select( element ).append('svg') 69 | .attr('width', width || element.offsetWidth) 70 | .attr('data-width', width || element.offsetWidth) 71 | .attr('class', 'datamap') 72 | .attr('height', height || element.offsetHeight) 73 | .style('overflow', 'hidden'); // IE10+ doesn't respect height/width when map is zoomed in 74 | 75 | if (this.options.responsive) { 76 | d3.select(this.options.element).style({'position': 'relative', 'padding-bottom': '60%'}); 77 | d3.select(this.options.element).select('svg').style({'position': 'absolute', 'width': '100%', 'height': '100%'}); 78 | d3.select(this.options.element).select('svg').select('g').selectAll('path').style('vector-effect', 'non-scaling-stroke'); 79 | } 80 | 81 | return this.svg; 82 | } 83 | 84 | // setProjection takes the svg element and options 85 | function setProjection( element, options ) { 86 | var width = options.width || element.offsetWidth; 87 | var height = options.height || element.offsetHeight; 88 | var projection, path; 89 | var svg = this.svg; 90 | 91 | if ( options && typeof options.scope === 'undefined') { 92 | options.scope = 'world'; 93 | } 94 | 95 | if ( options.scope === 'usa' ) { 96 | projection = d3.geo.albersUsa() 97 | .scale(width) 98 | .translate([width / 2, height / 2]); 99 | } 100 | else if ( options.scope === 'world' ) { 101 | projection = d3.geo[options.projection]() 102 | .scale((width + 1) / 2 / Math.PI) 103 | .translate([width / 2, height / (options.projection === "mercator" ? 1.45 : 1.8)]); 104 | } 105 | 106 | if ( options.projection === 'orthographic' ) { 107 | 108 | svg.append("defs").append("path") 109 | .datum({type: "Sphere"}) 110 | .attr("id", "sphere") 111 | .attr("d", path); 112 | 113 | svg.append("use") 114 | .attr("class", "stroke") 115 | .attr("xlink:href", "#sphere"); 116 | 117 | svg.append("use") 118 | .attr("class", "fill") 119 | .attr("xlink:href", "#sphere"); 120 | projection.scale(250).clipAngle(90).rotate(options.projectionConfig.rotation) 121 | } 122 | 123 | path = d3.geo.path() 124 | .projection( projection ); 125 | 126 | return {path: path, projection: projection}; 127 | } 128 | 129 | function addStyleBlock() { 130 | if ( d3.select('.datamaps-style-block').empty() ) { 131 | d3.select('head').append('style').attr('class', 'datamaps-style-block') 132 | .html('.datamap path.datamaps-graticule { fill: none; stroke: #777; stroke-width: 0.5px; stroke-opacity: .5; pointer-events: none; } .datamap .labels {pointer-events: none;} .datamap path {stroke: #FFFFFF; stroke-width: 1px;} .datamaps-legend dt, .datamaps-legend dd { float: left; margin: 0 3px 0 0;} .datamaps-legend dd {width: 20px; margin-right: 6px; border-radius: 3px;} .datamaps-legend {padding-bottom: 20px; z-index: 1001; position: absolute; left: 4px; font-size: 12px; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;} .datamaps-hoverover {display: none; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } .hoverinfo {padding: 4px; border-radius: 1px; background-color: #FFF; box-shadow: 1px 1px 5px #CCC; font-size: 12px; border: 1px solid #CCC; } .hoverinfo hr {border:1px dotted #CCC; }'); 133 | } 134 | } 135 | 136 | function drawSubunits( data ) { 137 | var fillData = this.options.fills, 138 | colorCodeData = this.options.data || {}, 139 | geoConfig = this.options.geographyConfig; 140 | 141 | 142 | var subunits = this.svg.select('g.datamaps-subunits'); 143 | if ( subunits.empty() ) { 144 | subunits = this.addLayer('datamaps-subunits', null, true); 145 | } 146 | 147 | var geoData = topojson.feature( data, data.objects[ this.options.scope ] ).features; 148 | if ( geoConfig.hideAntarctica ) { 149 | geoData = geoData.filter(function(feature) { 150 | return feature.id !== "ATA"; 151 | }); 152 | } 153 | this.geoData = geoData; 154 | 155 | var geo = subunits.selectAll('path.datamaps-subunit').data( geoData ); 156 | 157 | return geo.enter() 158 | .append('path') 159 | .attr('d', this.path) 160 | .attr('class', function(d) { 161 | return 'datamaps-subunit ' + d.id; 162 | }) 163 | .attr('data-info', function(d) { 164 | return JSON.stringify( colorCodeData[d.id]); 165 | }) 166 | .style('fill', function(d) { 167 | var fillColor; 168 | 169 | if ( colorCodeData[d.id] ) { 170 | fillColor = fillData[ colorCodeData[d.id].fillKey ]; 171 | } 172 | 173 | return fillColor || fillData.defaultFill; 174 | }) 175 | .style('stroke-width', geoConfig.borderWidth) 176 | .style('stroke', geoConfig.borderColor); 177 | } 178 | 179 | function handleGeographyConfig () { 180 | var hoverover; 181 | var svg = this.svg; 182 | var self = this; 183 | var options = this.options.geographyConfig; 184 | 185 | if ( options.highlightOnHover || options.popupOnHover ) { 186 | svg.selectAll('.datamaps-subunit') 187 | .on('mouseover', function(d) { 188 | var $this = d3.select(this); 189 | 190 | if ( options.highlightOnHover ) { 191 | var previousAttributes = { 192 | 'fill': $this.style('fill'), 193 | 'stroke': $this.style('stroke'), 194 | 'stroke-width': $this.style('stroke-width'), 195 | 'fill-opacity': $this.style('fill-opacity') 196 | }; 197 | 198 | $this 199 | .style('fill', options.highlightFillColor) 200 | .style('stroke', options.highlightBorderColor) 201 | .style('stroke-width', options.highlightBorderWidth) 202 | .style('fill-opacity', options.highlightFillOpacity); 203 | if(!$this.attr('data-previousAttributes')) 204 | $this.attr('data-previousAttributes', JSON.stringify(previousAttributes)); 205 | 206 | //as per discussion on https://github.com/markmarkoh/datamaps/issues/19 207 | if ( ! /((MSIE)|(Trident))/.test ) { 208 | moveToFront.call(this); 209 | } 210 | } 211 | 212 | if ( options.popupOnHover ) { 213 | self.updatePopup($this, d, options, svg); 214 | } 215 | }) 216 | .on('mouseout', function() { 217 | var $this = d3.select(this); 218 | 219 | if (options.highlightOnHover) { 220 | //reapply previous attributes 221 | var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); 222 | for ( var attr in previousAttributes ) { 223 | $this.style(attr, previousAttributes[attr]); 224 | } 225 | $this.attr('data-previousAttributes',null); 226 | } 227 | $this.on('mousemove', null); 228 | d3.select(self.options.element).selectAll('.datamaps-hoverover').style('display', 'none'); 229 | }); 230 | } 231 | 232 | function moveToFront() { 233 | this.parentNode.appendChild(this); 234 | } 235 | } 236 | 237 | //plugin to add a simple map legend 238 | function addLegend(layer, data, options) { 239 | data = data || {}; 240 | if ( !this.options.fills ) { 241 | return; 242 | } 243 | 244 | var html = '
'; 245 | var label = ''; 246 | if ( data.legendTitle ) { 247 | html = '

' + data.legendTitle + '

' + html; 248 | } 249 | for ( var fillKey in this.options.fills ) { 250 | 251 | if ( fillKey === 'defaultFill') { 252 | if (! data.defaultFillName ) { 253 | continue; 254 | } 255 | label = data.defaultFillName; 256 | } else { 257 | if (data.labels && data.labels[fillKey]) { 258 | label = data.labels[fillKey]; 259 | } else { 260 | label= fillKey + ': '; 261 | } 262 | } 263 | html += '
' + label + '
'; 264 | html += '
 
'; 265 | } 266 | html += '
'; 267 | 268 | var hoverover = d3.select( this.options.element ).append('div') 269 | .attr('class', 'datamaps-legend') 270 | .html(html); 271 | } 272 | 273 | function addGraticule ( layer, options ) { 274 | var graticule = d3.geo.graticule(); 275 | this.svg.insert("path", '.datamaps-subunits') 276 | .datum(graticule) 277 | .attr("class", "datamaps-graticule") 278 | .attr("d", this.path); 279 | } 280 | 281 | function handleArcs (layer, data, options) { 282 | var self = this, 283 | svg = this.svg; 284 | 285 | if ( !data || (data && !data.slice) ) { 286 | throw "Datamaps Error - arcs must be an array"; 287 | } 288 | 289 | if ( typeof options === "undefined" ) { 290 | options = defaultOptions.arcConfig; 291 | } 292 | 293 | var arcs = layer.selectAll('path.datamaps-arc').data( data, JSON.stringify ); 294 | 295 | arcs 296 | .enter() 297 | .append('svg:path') 298 | .attr('class', 'datamaps-arc') 299 | .style('stroke-linecap', 'round') 300 | .style('stroke', function(datum) { 301 | if ( datum.options && datum.options.strokeColor) { 302 | return datum.options.strokeColor; 303 | } 304 | return options.strokeColor 305 | }) 306 | .style('fill', 'none') 307 | .style('stroke-width', function(datum) { 308 | if ( datum.options && datum.options.strokeWidth) { 309 | return datum.options.strokeWidth; 310 | } 311 | return options.strokeWidth; 312 | }) 313 | .attr('d', function(datum) { 314 | var originXY = self.latLngToXY(datum.origin.latitude, datum.origin.longitude); 315 | var destXY = self.latLngToXY(datum.destination.latitude, datum.destination.longitude); 316 | var midXY = [ (originXY[0] + destXY[0]) / 2, (originXY[1] + destXY[1]) / 2]; 317 | return "M" + originXY[0] + ',' + originXY[1] + "S" + (midXY[0] + (50 * options.arcSharpness)) + "," + (midXY[1] - (75 * options.arcSharpness)) + "," + destXY[0] + "," + destXY[1]; 318 | }) 319 | .transition() 320 | .delay(100) 321 | .style('fill', function() { 322 | /* 323 | Thank you Jake Archibald, this is awesome. 324 | Source: http://jakearchibald.com/2013/animated-line-drawing-svg/ 325 | */ 326 | var length = this.getTotalLength(); 327 | this.style.transition = this.style.WebkitTransition = 'none'; 328 | this.style.strokeDasharray = length + ' ' + length; 329 | this.style.strokeDashoffset = length; 330 | this.getBoundingClientRect(); 331 | this.style.transition = this.style.WebkitTransition = 'stroke-dashoffset ' + options.animationSpeed + 'ms ease-out'; 332 | this.style.strokeDashoffset = '0'; 333 | return 'none'; 334 | }) 335 | 336 | arcs.exit() 337 | .transition() 338 | .style('opacity', 0) 339 | .remove(); 340 | } 341 | 342 | function handleLabels ( layer, options ) { 343 | var self = this; 344 | options = options || {}; 345 | var labelStartCoodinates = this.projection([-67.707617, 42.722131]); 346 | this.svg.selectAll(".datamaps-subunit") 347 | .attr("data-foo", function(d) { 348 | var center = self.path.centroid(d); 349 | var xOffset = 7.5, yOffset = 5; 350 | 351 | if ( ["FL", "KY", "MI"].indexOf(d.id) > -1 ) xOffset = -2.5; 352 | if ( d.id === "NY" ) xOffset = -1; 353 | if ( d.id === "MI" ) yOffset = 18; 354 | if ( d.id === "LA" ) xOffset = 13; 355 | 356 | var x,y; 357 | 358 | x = center[0] - xOffset; 359 | y = center[1] + yOffset; 360 | 361 | var smallStateIndex = ["VT", "NH", "MA", "RI", "CT", "NJ", "DE", "MD", "DC"].indexOf(d.id); 362 | if ( smallStateIndex > -1) { 363 | var yStart = labelStartCoodinates[1]; 364 | x = labelStartCoodinates[0]; 365 | y = yStart + (smallStateIndex * (2+ (options.fontSize || 12))); 366 | layer.append("line") 367 | .attr("x1", x - 3) 368 | .attr("y1", y - 5) 369 | .attr("x2", center[0]) 370 | .attr("y2", center[1]) 371 | .style("stroke", options.labelColor || "#000") 372 | .style("stroke-width", options.lineWidth || 1) 373 | } 374 | 375 | layer.append("text") 376 | .attr("x", x) 377 | .attr("y", y) 378 | .style("font-size", (options.fontSize || 10) + 'px') 379 | .style("font-family", options.fontFamily || "Verdana") 380 | .style("fill", options.labelColor || "#000") 381 | .text( d.id ); 382 | return "bar"; 383 | }); 384 | } 385 | 386 | 387 | function handleBubbles (layer, data, options ) { 388 | var self = this, 389 | fillData = this.options.fills, 390 | svg = this.svg; 391 | 392 | if ( !data || (data && !data.slice) ) { 393 | throw "Datamaps Error - bubbles must be an array"; 394 | } 395 | 396 | var bubbles = layer.selectAll('circle.datamaps-bubble').data( data, JSON.stringify ); 397 | 398 | bubbles 399 | .enter() 400 | .append('svg:circle') 401 | .attr('class', 'datamaps-bubble') 402 | .attr('cx', function ( datum ) { 403 | var latLng; 404 | if ( datumHasCoords(datum) ) { 405 | latLng = self.latLngToXY(datum.latitude, datum.longitude); 406 | } 407 | else if ( datum.centered ) { 408 | latLng = self.path.centroid(svg.select('path.' + datum.centered).data()[0]); 409 | } 410 | if ( latLng ) return latLng[0]; 411 | }) 412 | .attr('cy', function ( datum ) { 413 | var latLng; 414 | if ( datumHasCoords(datum) ) { 415 | latLng = self.latLngToXY(datum.latitude, datum.longitude); 416 | } 417 | else if ( datum.centered ) { 418 | latLng = self.path.centroid(svg.select('path.' + datum.centered).data()[0]); 419 | } 420 | if ( latLng ) return latLng[1];; 421 | }) 422 | .attr('r', 0) //for animation purposes 423 | .attr('data-info', function(d) { 424 | return JSON.stringify(d); 425 | }) 426 | .style('stroke', function ( datum ) { 427 | return typeof datum.borderColor !== 'undefined' ? datum.borderColor : options.borderColor; 428 | }) 429 | .style('stroke-width', function ( datum ) { 430 | return typeof datum.borderWidth !== 'undefined' ? datum.borderWidth : options.borderWidth; 431 | }) 432 | .style('fill-opacity', function ( datum ) { 433 | return typeof datum.fillOpacity !== 'undefined' ? datum.fillOpacity : options.fillOpacity; 434 | }) 435 | .style('fill', function ( datum ) { 436 | var fillColor = fillData[ datum.fillKey ]; 437 | return fillColor || fillData.defaultFill; 438 | }) 439 | .on('mouseover', function ( datum ) { 440 | var $this = d3.select(this); 441 | 442 | if (options.highlightOnHover) { 443 | //save all previous attributes for mouseout 444 | var previousAttributes = { 445 | 'fill': $this.style('fill'), 446 | 'stroke': $this.style('stroke'), 447 | 'stroke-width': $this.style('stroke-width'), 448 | 'fill-opacity': $this.style('fill-opacity') 449 | }; 450 | 451 | $this 452 | .style('fill', options.highlightFillColor) 453 | .style('stroke', options.highlightBorderColor) 454 | .style('stroke-width', options.highlightBorderWidth) 455 | .style('fill-opacity', options.highlightFillOpacity) 456 | .attr('data-previousAttributes', JSON.stringify(previousAttributes)); 457 | } 458 | 459 | if (options.popupOnHover) { 460 | self.updatePopup($this, datum, options, svg); 461 | } 462 | }) 463 | .on('mouseout', function ( datum ) { 464 | var $this = d3.select(this); 465 | 466 | if (options.highlightOnHover) { 467 | //reapply previous attributes 468 | var previousAttributes = JSON.parse( $this.attr('data-previousAttributes') ); 469 | for ( var attr in previousAttributes ) { 470 | $this.style(attr, previousAttributes[attr]); 471 | } 472 | } 473 | 474 | d3.selectAll('.datamaps-hoverover').style('display', 'none'); 475 | }) 476 | .transition().duration(400) 477 | .attr('r', function ( datum ) { 478 | return datum.radius; 479 | }); 480 | 481 | bubbles.exit() 482 | .transition() 483 | .delay(options.exitDelay) 484 | .attr("r", 0) 485 | .remove(); 486 | 487 | function datumHasCoords (datum) { 488 | return typeof datum !== 'undefined' && typeof datum.latitude !== 'undefined' && typeof datum.longitude !== 'undefined'; 489 | } 490 | 491 | } 492 | 493 | function handlePointer (layer, data, options) { 494 | 495 | var self = this, 496 | svg = this.svg, 497 | position = null; 498 | 499 | var cleanExit = true; 500 | 501 | if(options.pan){ 502 | var oldCursor; 503 | function mousedown(){ 504 | if(d3.event.which == 1){ 505 | position = d3.mouse(this); 506 | var transform = getSVGTransform(self.svg); 507 | if(cleanExit) oldCursor = svg.node().style.cursor; 508 | cleanExit = false; 509 | svg.style('cursor','move'); 510 | 511 | function pointermove(){ 512 | var newPosition = d3.mouse(this); 513 | //scale to keep movements proportional to mouse movements 514 | var x = (newPosition[0] - (position[0]||0)) / transform.scale; 515 | var y = (newPosition[1] - (position[1]||0)) / transform.scale; 516 | setSVGTranslation(svg, transform.x + x, transform.y + y, options.panBounds); 517 | } 518 | svg.on('mousemove', pointermove); 519 | svg.on('touchmove', pointermove); 520 | svg.on('pointermove', pointermove); 521 | 522 | //disable built in image dragging for firefox 523 | svg.on('dragstart', function(e){ d3.event.preventDefault(); }) 524 | 525 | function pointerup() { 526 | svg.style('cursor',oldCursor); 527 | oldCursor = null; 528 | cleanExit = true; 529 | svg.on('mousemove', null); 530 | svg.on('touchmove', null); 531 | svg.on('pointermove', null); 532 | } 533 | svg.on('mouseup', pointerup); 534 | svg.on('touchend', pointerup); 535 | svg.on('pointerup', pointerup); 536 | } 537 | } 538 | svg.on('mousedown', mousedown); 539 | svg.on('touchstart', mousedown); 540 | svg.on('pointerdown', mousedown); 541 | 542 | function pointerout(){ 543 | svg.style('cursor',oldCursor); 544 | oldCursor = null; 545 | cleanExit = true; 546 | svg.on('mousemove', null); 547 | svg.on('touchmove', null); 548 | svg.on('pointermove', null); 549 | } 550 | svg.on('mouseout', pointerout); 551 | svg.on('pointerout', pointerout); 552 | } 553 | 554 | if(options.zoom){ 555 | function mousewheel( datum ) { 556 | var change = (d3.event.type == 'mousewheel') ? d3.event.wheelDelta : -d3.event.detail; 557 | if (change > 0){ 558 | setSVGScale(self.svg, 1 + options.zoomIncrement); 559 | }else{ 560 | setSVGScale(self.svg, 1 - options.zoomIncrement); 561 | } 562 | d3.event.stopPropagation(); 563 | }; 564 | svg.on('mousewheel', mousewheel); 565 | svg.on('DOMMouseScroll', mousewheel); 566 | } 567 | } 568 | 569 | function getSVGTransform(svg){ 570 | var b = svg.select('g.datamaps-subunits').node().transform.baseVal; 571 | var count = b.numberOfItems; 572 | var sx = 1, x = 0, y = 0; 573 | for(var i=0;i= diffX && diffX <= 0) x = current.x; 629 | if(size.y >= diffY && diffY <= 0) y = current.y; 630 | if(w - size.x - size.width + diffX >= 0 && diffX >= 0) x = current.x; 631 | if(h - size.y - size.height + diffY >= 0 && diffY >= 0) y = current.y; 632 | } 633 | 634 | if(x!=current.x || y!=current.y){ 635 | svg.selectAll('g').each(function() { 636 | var g = this; 637 | var b = g.transform.baseVal; 638 | var count = b.numberOfItems; 639 | var t = null, s = null; 640 | for(var i=0;i 0 ) { 735 | addContainer.call(this, this.options.element, this.options.height, this.options.width ); 736 | } 737 | 738 | /* Add core plugins to this instance */ 739 | this.addPlugin('bubbles', handleBubbles); 740 | this.addPlugin('legend', addLegend); 741 | this.addPlugin('arc', handleArcs); 742 | this.addPlugin('labels', handleLabels); 743 | this.addPlugin('graticule', addGraticule); 744 | this.addPlugin('pointer', handlePointer); 745 | 746 | //append style block with basic hoverover styles 747 | if ( ! this.options.disableDefaultStyles ) { 748 | addStyleBlock(); 749 | } 750 | 751 | return this.draw(); 752 | } 753 | 754 | // resize map 755 | Datamap.prototype.resize = function () { 756 | 757 | var self = this; 758 | var options = self.options; 759 | 760 | if (options.responsive) { 761 | var prefix = '-webkit-transform' in document.body.style ? '-webkit-' : '-moz-transform' in document.body.style ? '-moz-' : '-ms-transform' in document.body.style ? '-ms-' : '', 762 | newsize = options.element.clientWidth, 763 | oldsize = d3.select( options.element).select('svg').attr('data-width'); 764 | 765 | d3.select(options.element).select('svg').selectAll('g').style(prefix + 'transform', 'scale(' + (newsize / oldsize) + ')'); 766 | } 767 | } 768 | 769 | // actually draw the features(states & countries) 770 | Datamap.prototype.draw = function() { 771 | //save off in a closure 772 | var self = this; 773 | var options = self.options; 774 | 775 | //set projections and paths based on scope 776 | var pathAndProjection = options.setProjection.apply(self, [options.element, options] ); 777 | 778 | this.path = pathAndProjection.path; 779 | this.projection = pathAndProjection.projection; 780 | 781 | //if custom URL for topojson data, retrieve it and render 782 | if ( options.geographyConfig.dataUrl ) { 783 | d3.json( options.geographyConfig.dataUrl, function(error, results) { 784 | if ( error ) throw new Error(error); 785 | self.customTopo = results; 786 | draw( results ); 787 | }); 788 | } 789 | else { 790 | draw( this[options.scope + 'Topo'] || options.geographyConfig.dataJson); 791 | } 792 | 793 | return this; 794 | 795 | function draw (data) { 796 | // if fetching remote data, draw the map first then call `updateChoropleth` 797 | if ( self.options.dataUrl ) { 798 | //allow for csv or json data types 799 | d3[self.options.dataType](self.options.dataUrl, function(data) { 800 | //in the case of csv, transform data to object 801 | if ( self.options.dataType === 'csv' && (data && data.slice) ) { 802 | var tmpData = {}; 803 | for(var i = 0; i < data.length; i++) { 804 | tmpData[data[i].id] = data[i]; 805 | } 806 | data = tmpData; 807 | } 808 | Datamaps.prototype.updateChoropleth.call(self, data); 809 | }); 810 | } 811 | self.subunits = drawSubunits.call(self, data); 812 | handleGeographyConfig.call(self); 813 | 814 | if ( self.options.geographyConfig.popupOnHover || self.options.bubblesConfig.popupOnHover) { 815 | hoverover = d3.select( self.options.element ).append('div') 816 | .attr('class', 'datamaps-hoverover') 817 | .style('z-index', 10001) 818 | .style('position', 'absolute'); 819 | } 820 | 821 | //fire off finished callback 822 | self.addPlugin('background', handleBackground); 823 | self.options.done(self); 824 | } 825 | }; 826 | // redraw current topology using new projection & options 827 | Datamap.prototype.redraw = function() { 828 | var self = this; 829 | var options = self.options; 830 | if(self.subunits){ 831 | var pathAndProjection = options.setProjection.apply(self, [options.element, options] ); 832 | self.path = pathAndProjection.path; 833 | self.projection = pathAndProjection.projection; 834 | 835 | var geo = self.subunits.data( self.geoData ); 836 | 837 | //helper function to raise event after all transitions complete 838 | function endall(transition, callback) { 839 | var n = 0; 840 | transition 841 | .each(function() { ++n; }) 842 | .each("end", function() { if (!--n) callback.apply(this, arguments); }); 843 | } 844 | 845 | geo.transition().duration(0).attr('d', self.path).call(endall, function(){ 846 | var event = document.createEvent("Event"); 847 | event.initEvent("topologychange", true, true); 848 | self.svg.node().dispatchEvent(event); 849 | }); 850 | } 851 | } 852 | /************************************** 853 | TopoJSON 854 | ***************************************/ 855 | Datamap.prototype.worldTopo = '__WORLD__'; 856 | Datamap.prototype.usaTopo = '__USA__'; 857 | 858 | /************************************** 859 | Utilities 860 | ***************************************/ 861 | 862 | //convert lat/lng coords to X / Y coords 863 | Datamap.prototype.latLngToXY = function(lat, lng) { 864 | return this.projection([lng, lat]); 865 | }; 866 | 867 | //add layer to root SVG 868 | Datamap.prototype.addLayer = function( className, id, first ) { 869 | var layer; 870 | if ( first ) { 871 | layer = this.svg.insert('g', ':first-child') 872 | } 873 | else { 874 | layer = this.svg.append('g') 875 | } 876 | return layer.attr('id', id || '') 877 | .attr('class', className || ''); 878 | }; 879 | 880 | Datamap.prototype.updateChoropleth = function(data) { 881 | var svg = this.svg; 882 | for ( var subunit in data ) { 883 | if ( data.hasOwnProperty(subunit) ) { 884 | var color; 885 | var subunitData = data[subunit] 886 | if ( ! subunit ) { 887 | continue; 888 | } 889 | else if ( typeof subunitData === "string" ) { 890 | color = subunitData; 891 | } 892 | else if ( typeof subunitData.color === "string" ) { 893 | color = subunitData.color; 894 | } 895 | else { 896 | color = this.options.fills[ subunitData.fillKey ]; 897 | } 898 | //if it's an object, overriding the previous data 899 | if ( subunitData === Object(subunitData) ) { 900 | this.options.data[subunit] = defaults(subunitData, this.options.data[subunit] || {}); 901 | var geo = this.svg.select('.' + subunit).attr('data-info', JSON.stringify(this.options.data[subunit])); 902 | var $this = this.svg.select('.' + subunit); 903 | if($this.node()){ 904 | var previousAttributes = JSON.parse($this.node().getAttribute('data-previousAttributes')); 905 | if(!previousAttributes){ 906 | var previousAttributes = { 907 | 'fill': $this.style('fill'), 908 | 'stroke': $this.style('stroke'), 909 | 'stroke-width': $this.style('stroke-width'), 910 | 'fill-opacity': $this.style('fill-opacity') 911 | }; 912 | } 913 | previousAttributes.fill = color; 914 | this.svg.select('.' + subunit).attr('data-previousAttributes',JSON.stringify(previousAttributes)); 915 | } 916 | } 917 | svg 918 | .selectAll('.' + subunit) 919 | .transition() 920 | .style('fill', color); 921 | } 922 | } 923 | }; 924 | 925 | Datamap.prototype.updatePopup = function (element, d, options) { 926 | var self = this; 927 | element.on('mousemove', null); 928 | element.on('mousemove', function() { 929 | var position = d3.mouse(this); 930 | //replaced code that renders a DIV with a call to template 931 | var transform = getSVGTransform(self.svg); 932 | var elementData = element.data()[0]; 933 | var id = elementData.id; 934 | var name = (elementData.properties ? elementData.properties.name : elementData.name); 935 | var data = JSON.parse(element.attr('data-info')); 936 | var top = ((position[1] + transform.y) * transform.scale + 30); 937 | var left = ((position[0] + transform.x) * transform.scale); 938 | options.popupTemplate({ id:id, name:name, data:data }, top, left); 939 | }); 940 | 941 | d3.select(self.svg[0][0].parentNode).select('.datamaps-hoverover').style('display', 'block'); 942 | }; 943 | 944 | Datamap.prototype.addPlugin = function( name, pluginFn ) { 945 | var self = this; 946 | if ( typeof Datamap.prototype[name] === "undefined" ) { 947 | Datamap.prototype[name] = function(data, options, callback, createNewLayer) { 948 | var layer; 949 | if ( typeof createNewLayer === "undefined" ) { 950 | createNewLayer = false; 951 | } 952 | 953 | if ( typeof options === 'function' ) { 954 | callback = options; 955 | options = undefined; 956 | } 957 | 958 | options = defaults(options || {}, defaultOptions[name + 'Config']); 959 | 960 | //add a single layer, reuse the old layer 961 | if ( !createNewLayer && this.options[name + 'Layer'] ) { 962 | layer = this.options[name + 'Layer']; 963 | options = options || this.options[name + 'Options']; 964 | } 965 | else { 966 | layer = this.addLayer(name); 967 | this.options[name + 'Layer'] = layer; 968 | this.options[name + 'Options'] = options; 969 | } 970 | pluginFn.apply(this, [layer, data, options]); 971 | if ( callback ) { 972 | callback(layer); 973 | } 974 | }; 975 | } 976 | }; 977 | 978 | // expose library 979 | if ( typeof define === "function" && define.amd ) { 980 | define( "datamaps", function(require) { d3 = require('d3'); topojson = require('topojson'); return Datamap; } ); 981 | } 982 | else { 983 | window.Datamap = window.Datamaps = Datamap; 984 | } 985 | 986 | if ( window.jQuery ) { 987 | window.jQuery.fn.datamaps = function(options, callback) { 988 | options = options || {}; 989 | options.element = this[0]; 990 | var datamap = new Datamap(options); 991 | if ( typeof callback === "function" ) { 992 | callback(datamap, options); 993 | } 994 | return this; 995 | }; 996 | } 997 | })(); 998 | --------------------------------------------------------------------------------