diff --git a/dist/maptable.css b/dist/maptable.css index 0816b32..83d6821 100755 --- a/dist/maptable.css +++ b/dist/maptable.css @@ -1 +1 @@ -.form-control-inline{min-width:0;width:auto;display:inline}.panel{margin-top:15px}.mt-map-container{width:100%;height:0;position:relative;padding-bottom:52%}.mt-map-container #mt-map{width:100%;height:100%;display:block;position:absolute}.mt-map-country:hover{opacity:.9}.mt-map-tooltip{color:#222;background-color:hsla(0,0%,100%,.9);min-width:200px;max-width:300px;position:absolute}.mt-map-tooltip .badge{margin:5px 10px}.mt-map-marker{opacity:.9}.mt-map-marker:hover{opacity:1}.mt-table-sortable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mt-table-sortable.sort_asc:after{content:"▲";font-size:7px;padding-left:5px}.mt-table-sortable.sort_desc:after{content:"▼";font-size:7px;padding-left:5px}.mt-table-sortable{cursor:pointer}#mt-filters-new{margin:10px}.mt-filter-row{margin:10px;padding-bottom:10px;border-bottom:1px solid #ddd;color:#aaa}.mt-filter-row span{font-size:14px;font-weight:500;color:#333;letter-spacing:1px;line-height:34px;padding-left:4px;padding-right:4px}#mt-map:hover #mt-map-export{opacity:1;transition:opacity .5s linear}#mt-map-export{position:absolute;top:10px;right:10px;opacity:0;transition:opacity .5s linear}.mt-loading{position:absolute;top:50%;color:#999;width:100%;text-align:center;font-size:24px;margin-top:-18px;display:none}#mt-map path{will-change:fill}.mt-blur{filter:blur(18px);transform:translateZ(0)}.mt-sun-gradient{background-image:radial-gradient(circle,rgba(255,192,0,.5) 0,rgba(255,192,0,.15) 45%,rgba(255,192,0,0) 100%)} \ No newline at end of file +.form-control-inline{min-width:0;width:auto;display:inline}.panel{margin-top:15px}.mt-map-container{width:100%;height:0;position:relative;padding-bottom:52%}.mt-map-container #mt-map{width:100%;height:100%;display:block;position:absolute}.mt-map-country:hover{opacity:.9}.mt-map-tooltip{color:#222;background-color:hsla(0,0%,100%,.9);min-width:200px;max-width:300px;position:absolute}.mt-map-tooltip .badge{margin:5px 10px}.mt-map-marker{opacity:.9}.mt-map-marker:hover{opacity:1}.mt-table-sortable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mt-table-sortable.sort_asc:after{content:"▲";font-size:7px;padding-left:5px}.mt-table-sortable.sort_desc:after{content:"▼";font-size:7px;padding-left:5px}.mt-table-sortable{cursor:pointer}#mt-filters-new{margin:10px}.mt-filter-row{margin:10px;padding-bottom:10px;border-bottom:1px solid #ddd;color:#aaa}.mt-filter-row span{font-size:14px;font-weight:500;color:#333;letter-spacing:1px;line-height:34px;padding-left:4px;padding-right:4px}#mt-map:hover #mt-map-export{opacity:1;transition:opacity .5s linear}#mt-map-export{position:absolute;top:10px;right:10px;opacity:0;transition:opacity .5s linear}.mt-loading{position:absolute;top:50%;color:#999;width:100%;text-align:center;font-size:24px;margin-top:-18px;display:none}#mt-map path{will-change:fill}.mt-blur{filter:blur(18px);transform:translateZ(0)}.mt-sun-gradient{background-image:radial-gradient(circle,rgba(255,192,0,.5) 0,rgba(255,192,0,.15) 45%,rgba(255,192,0,0) 100%)}.mt-header-fixed{position:sticky} \ No newline at end of file diff --git a/dist/maptable.js b/dist/maptable.js index 58a573f..5412939 100644 --- a/dist/maptable.js +++ b/dist/maptable.js @@ -2713,7 +2713,6 @@ this.d3.maptable = (function () { this.maptable = maptable; this.options = options; - if (this.options.defaultSorting) { if (Array.isArray(this.options.defaultSorting) && this.options.defaultSorting.length === 2) { this.sorting = this.options.defaultSorting; @@ -2764,6 +2763,20 @@ this.d3.maptable = (function () { this.activeColumns = Object.keys(this.maptable.columnDetails); } + // make table header fixed + if (this.options.header) { + if (this.options.header.className) { + this.header.attr('class', '' + this.options.header.className); + } + + // set custom top header space + if (this.options.header.top) { + this.header.attr('style', 'top:' + (this.options.header.top || '0') + 'px;'); + } else { + this.header.attr('style', 'top:0px;'); + } + } + this.header.selectAll('tr').data([1]).enter().append('tr').selectAll('th').data(this.activeColumns.map(function (k) { return utils.extendRecursive({ key: k }, _this.maptable.columnDetails[k]); })).enter().append('th').attr('class', function (d) { @@ -3383,11 +3396,11 @@ this.d3.maptable = (function () { var customOptions = utils.extendRecursive(defaultOptions, options); - if (!options.map.markers) delete customOptions.map.markers; - if (!options.map.heatmap) delete customOptions.map.heatmap; - if (!options.map.title) delete customOptions.map.title; - if (!options.map.timezones) delete customOptions.map.timezones; - if (!options.map.night) delete customOptions.map.night; + if (options.map && !options.map.markers) delete customOptions.map.markers; + if (options.map && !options.map.heatmap) delete customOptions.map.heatmap; + if (options.map && !options.map.title) delete customOptions.map.title; + if (options.map && !options.map.timezones) delete customOptions.map.timezones; + if (options.map && !options.map.night) delete customOptions.map.night; if (!options.filters) delete customOptions.filters; if (!options.table) delete customOptions.table; diff --git a/dist/maptable.js.map b/dist/maptable.js.map index 683c8ec..0b9848f 100644 --- a/dist/maptable.js.map +++ b/dist/maptable.js.map @@ -1 +1 @@ -{"version":3,"file":"maptable.js","sources":["../src/utils.js","../src/defaultOptions.js","../src/components/Legend.js","../src/components/Watermark.js","../src/components/StackBlur.js","../src/components/solarPosition.js","../src/components/GeoMap.js","../src/components/Filters.js","../src/components/Table.js","../src/maptable.js","../src/index.js"],"sourcesContent":["function appendOptions(select, options, defaultValue) {\n options.forEach((f) => {\n // Filter select\n const option = document.createElement('option');\n option.setAttribute('value', f.value);\n option.innerText = f.text;\n select.appendChild(option);\n });\n select.value = defaultValue;\n}\n\nfunction rangeToBool(el1, range, el2) {\n if (range === '=') {\n return parseInt(el1, 10) === parseInt(el2, 10);\n }\n if (range === '≠') {\n return parseInt(el1, 10) !== parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '>') {\n return parseInt(el1, 10) > parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '<') {\n return parseInt(el1, 10) < parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '≥') {\n return parseInt(el1, 10) >= parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '≤') {\n return parseInt(el1, 10) <= parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n return true;\n}\n\n/* eslint no-loop-func: 0 */\nfunction extendRecursive() {\n const dst = {};\n let src;\n const args = [].splice.call(arguments, 0);\n const toString = ({}).toString;\n\n while (args.length > 0) {\n src = args.splice(0, 1)[0];\n if (toString.call(src) === '[object Object]') {\n Object.keys(src).forEach((p) => {\n if (toString.call(src[p]) === '[object Object]') {\n dst[p] = extendRecursive(dst[p] || {}, src[p]);\n } else {\n dst[p] = src[p];\n }\n });\n }\n }\n return dst;\n}\n\nfunction keyToTile(k) {\n const upperK = k.charAt(0).toUpperCase() + k.slice(1);\n return upperK.replace(/_/g, ' ');\n}\n\nfunction sanitizeKey(k) {\n return k.toLowerCase()\n .replace(/ /g, '_')\n .replace(/\"/g, '')\n .replace(/'/g, '');\n}\n\nfunction toNumber(str) {\n if (!str || str === '') return null;\n const resStr = str.toString().replace(/[^0-9.]+|\\s+/gmi, '');\n if (resStr !== '') return Number(resStr);\n return null;\n}\n\nfunction quantile(array, percentile) {\n array.sort((a, b) => a - b);\n const index = (percentile / 100.0) * (array.length - 1);\n let result;\n if (Math.floor(index) === index) {\n result = array[index];\n } else {\n const i = Math.floor(index);\n const fraction = index - i;\n result = array[i] + (array[i + 1] - array[i]) * fraction;\n }\n return result;\n}\n\nfunction uniqueValues(arr) {\n if (!arr) return arr;\n const a = [];\n for (let i = 0, l = arr.length; i < l; i += 1) {\n if (a.indexOf(arr[i]) === -1 && arr[i] !== '') {\n a.push(arr[i]);\n }\n }\n return a;\n}\n\nconst formatDate = (d, zone) => {\n const newDate = new Date(d.getTime() + zone * 3600 * 1000);\n return newDate.toISOString().split('T')[1].substr(0, 5);\n};\n\nconst isBlank = (str) => (str === null || str === '' || str === undefined);\n\nexport default {\n rangeToBool,\n appendOptions,\n extendRecursive,\n sanitizeKey,\n toNumber,\n keyToTile,\n quantile,\n uniqueValues,\n formatDate,\n isBlank,\n};\n","export default {\n map: {\n longitudeKey: 'longitude',\n latitudeKey: 'latitude',\n countryIdentifierKey: 'country_code',\n countryIdentifierType: 'iso_a2',\n zoom: true,\n saveState: true,\n exportSvg: null,\n exportSvgClient: false,\n ratioFromWidth: 0.5,\n scaleHeight: 1.0,\n scaleZoom: [1, 10],\n fitContentMargin: 10,\n autoFitContent: false,\n tooltipClassName: 'popover bottom',\n countries: {\n legend: false,\n attr: {\n fill: '#FCFCFC',\n stroke: '#CCC',\n 'stroke-width': 0.5,\n },\n tooltipClassName: 'mt-map-tooltip popover bottom',\n },\n heatmap: {\n mask: true,\n weightByAttribute: null,\n weightByAttributeScale: 'linear',\n circles: {\n min: 1,\n max: 90,\n step: 4,\n color: '#FF0000',\n colorStrength: 1,\n blur: 4.0,\n },\n borders: {\n stroke: 1,\n opacity: 0.1,\n color: '#000',\n },\n },\n markers: {\n attr: {\n r: 4,\n fill: 'blue',\n stroke: '#CCC',\n 'stroke-width': 0.5,\n },\n tooltipClassName: 'mt-map-tooltip popover bottom',\n },\n title: {\n fontSize: 12,\n fontFamily: 'Helevetica, Arial, Sans-Serif',\n },\n },\n filters: {\n saveState: true,\n },\n table: {\n className: 'table table-striped table-bordered',\n collapseRowsBy: [],\n },\n};\n","export default class Legend {\n constructor(map) {\n this.legendWidth = 220;\n this.map = map;\n // Create Legend\n this.node = this.map.svg\n .append('g')\n .attr('id', 'mt-map-legend')\n .attr(\n 'transform',\n `translate(${(this.map.getWidth() - 350)}, ${(this.map.getHeight() - 60)})`,\n );\n\n this.buildIndice();\n }\n\n buildScale(domain) {\n const legendGradient = this.node\n .append('defs')\n .append('linearGradient')\n .attr('id', 'mt-map-legend-gradient')\n .attr('x1', '0%')\n .attr('y1', '0%')\n .attr('x2', '100%')\n .attr('y2', '0%');\n\n if (this.map.options.countries.attr.fill.minNegative\n && this.map.options.countries.attr.fill.maxNegative) {\n // todo - maybe watch for domain[0] < 0 && domain[1] < 0? fall back to normal min & max?\n const midPercentNegative = Math.round(((0 - domain[0]) / (domain[1] - domain[0])) * 100);\n const midPercentPositive = midPercentNegative + 1;\n\n legendGradient.append('stop')\n .attr('offset', '0%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.maxNegative};stop-opacity:1`);\n\n legendGradient.append('stop')\n .attr('offset', `${midPercentNegative}%`)\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.minNegative};stop-opacity:1`);\n legendGradient.append('stop')\n .attr('offset', `${midPercentPositive}%`)\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.min};stop-opacity:1`);\n } else {\n legendGradient.append('stop')\n .attr('offset', '0%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.min};stop-opacity:1`);\n }\n\n legendGradient.append('stop')\n .attr('offset', '100%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.max};stop-opacity:1`);\n\n this.node.append('rect')\n .attr('x', 30)\n .attr('y', 0)\n .attr('width', this.legendWidth)\n .attr('height', 15)\n .attr('fill', 'url(#mt-map-legend-gradient)');\n }\n\n buildIndice() {\n const indice = this.node.append('g')\n .attr('id', 'mt-map-legend-indice')\n .attr('style', 'display:none')\n .attr('transform', 'translate(36,15)');\n\n indice.append('polygon')\n .attr('points', '4.5 0 9 5 0 5')\n .attr('fill', '#222222');\n\n indice.append('text')\n .attr('x', 4)\n .attr('y', 13)\n .attr('width', 10)\n .attr('height', 10)\n .attr('text-anchor', 'middle')\n .attr('font-family', 'Arial')\n .attr('font-size', '9')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '1')\n .attr('fill', '#222222')\n .text('0');\n\n this.node.append('text')\n .attr('id', 'mt-map-legend-min')\n .attr('x', 25)\n .attr('y', 13)\n .attr('width', 35)\n .attr('height', 15)\n .attr('text-anchor', 'end')\n .attr('font-family', 'Arial')\n .attr('font-size', '14')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '3')\n .attr('fill', '#222222')\n .text('0');\n\n this.node.append('text')\n .attr('id', 'mt-map-legend-max')\n .attr('y', 13)\n .attr('x', 255)\n .attr('width', 50)\n .attr('height', 15)\n .attr('text-anchor', 'start')\n .attr('font-family', 'Arial')\n .attr('font-size', '14')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '3')\n .attr('fill', '#222222')\n .text('1');\n }\n\n updateExtents(domain) {\n this.node.select('#mt-map-legend').style('opacity', (domain[0] === domain[1]) ? 0 : 1);\n if (this.node.selectAll('mt-map-legend-min').length) {\n this.node.select('#mt-map-legend-min').text(Math.round(domain[0]).toLocaleString());\n this.node.select('#mt-map-legend-max').text(Math.round(domain[1]).toLocaleString());\n\n // pass in the min and max (domain) to the legend\n this.buildScale(domain);\n }\n }\n\n indiceChange(val) {\n if (Number.isNaN(val)) {\n this.node.select('#mt-map-legend-indice')\n .attr('style', 'display:none');\n } else {\n const maxValue = parseInt(this.node.select('#mt-map-legend-max').text(), 10);\n const minValue = parseInt(this.node.select('#mt-map-legend-min').text(), 10);\n const positionDelta = Math.round((0 - (minValue - val) / (maxValue - minValue))\n * this.legendWidth);\n this.node.select('#mt-map-legend-indice text').text(Math.round(val).toLocaleString());\n this.node.select('#mt-map-legend-indice')\n .attr('style', 'display:block')\n .attr('transform', `translate(${(36 + positionDelta)},15)`);\n }\n }\n}\n","export default class Legend {\n constructor(map, options) {\n this.map = map;\n this.src = options.src;\n this.position = options.position;\n this.width = parseInt(options.width, 10);\n this.height = parseInt(options.height, 10);\n this.padding = options.padding || 10;\n this.style = options.style;\n\n if (!options.src) {\n console.warn('Watermak src not found');\n return;\n }\n if (Number.isNaN(this.width)) {\n console.warn('Watermak width not found');\n return;\n }\n if (Number.isNaN(this.height)) {\n console.warn('Watermak height not found');\n return;\n }\n\n if (window.btoa) {\n this.buildWatermark();\n } else {\n console.warn('Watermark not rendered: btoa error');\n }\n }\n\n buildWatermark() {\n d3.xhr(this.src, (res) => {\n let mapWatermarkDelta = 0;\n if (this.map.options.title) mapWatermarkDelta = 30;\n let mime;\n let x;\n let y;\n if (this.src.indexOf('.svg') !== -1) {\n mime = 'image/svg+xml';\n } else if (this.src.indexOf('.jpg') !== -1 || this.src.indexOf('.jpeg') !== -1) {\n mime = 'image/jpeg';\n } else if (this.src.indexOf('.png') !== -1) {\n mime = 'image/png';\n } else {\n console.warn('invalid watermark mime type');\n return;\n }\n const dataUri = `data:${mime};base64,${window.btoa(res.responseText)}`;\n\n if (this.position) {\n const pos = this.position.split(' ');\n if (pos[0] === 'top') {\n y = this.padding;\n } else if (pos[0] === 'middle') {\n y = (this.map.getHeight() - this.height) / 2;\n } else if (pos[0] === 'bottom') {\n y = this.map.getHeight() - this.height - this.padding - mapWatermarkDelta;\n } else {\n console.warn('position should be (top|middle|bottom) (left|middle|right)');\n }\n\n if (pos[1] === 'left') {\n x = this.padding;\n } else if (pos[1] === 'middle') {\n x = (this.map.getWidth() - this.width) / 2;\n } else if (pos[1] === 'right') {\n x = this.map.getWidth() - this.width - this.padding;\n } else {\n console.warn('position should be (top|middle|bottom) (left|middle|right)');\n }\n }\n\n this.node = this.map.svg\n .append('image')\n .attr('xlink:href', dataUri)\n .attr('width', this.width)\n .attr('height', this.height);\n\n if (x && y) {\n this.node.attr('x', x).attr('y', y);\n }\n\n if (this.style) {\n this.node.attr('style', this.style);\n }\n });\n }\n}\n","/* eslint-disable */\n\n/*\n StackBlur - a fast almost Gaussian Blur For Canvas\n Version: 0.5\n Author: Mario Klingemann\n Contact: mario@quasimondo.com\n Website: http://www.quasimondo.com/StackBlurForCanvas\n Twitter: @quasimondo\n In case you find this class useful - especially in commercial projects -\n I am not totally unhappy for a small donation to my PayPal account\n mario@quasimondo.de\n Or support me on flattr:\n https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript\n Copyright (c) 2010 Mario Klingemann\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n */\n\n\nvar mul_table = [\n 512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,\n 454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,\n 482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,\n 437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,\n 497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,\n 320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,\n 446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,\n 329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,\n 505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,\n 399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,\n 324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,\n 268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,\n 451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,\n 385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,\n 332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,\n 289,287,285,282,280,278,275,273,271,269,267,265,263,261,259];\n\n\nvar shg_table = [\n 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,\n 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,\n 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,\n 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 ];\n\n\nfunction processImage(img, canvas, radius, blurAlphaChannel)\n{\n if (typeof(img) == 'string') {\n var img = document.getElementById(img);\n }\n else if (typeof HTMLImageElement !== 'undefined' && !img instanceof HTMLImageElement) {\n return;\n }\n var w = img.naturalWidth;\n var h = img.naturalHeight;\n\n if (typeof(canvas) == 'string') {\n var canvas = document.getElementById(canvas);\n }\n else if (typeof HTMLCanvasElement !== 'undefined' && !canvas instanceof HTMLCanvasElement) {\n return;\n }\n\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n canvas.width = w;\n canvas.height = h;\n\n var context = canvas.getContext('2d');\n context.clearRect(0, 0, w, h);\n context.drawImage(img, 0, 0);\n\n if (Number.isNaN(radius) || radius < 1) return;\n\n if (blurAlphaChannel)\n processCanvasRGBA(canvas, 0, 0, w, h, radius);\n else\n processCanvasRGB(canvas, 0, 0, w, h, radius);\n}\n\nfunction getImageDataFromCanvas(canvas, top_x, top_y, width, height)\n{\n if (typeof(canvas) == 'string')\n var canvas = document.getElementById(canvas);\n else if (typeof HTMLCanvasElement !== 'undefined' && !canvas instanceof HTMLCanvasElement)\n return;\n\n var context = canvas.getContext('2d');\n var imageData;\n\n try {\n try {\n imageData = context.getImageData(top_x, top_y, width, height);\n } catch(e) {\n throw new Error(\"unable to access local image data: \" + e);\n return;\n }\n } catch(e) {\n throw new Error(\"unable to access image data: \" + e);\n }\n\n return imageData;\n}\n\nfunction processCanvasRGBA(canvas, top_x, top_y, width, height, radius)\n{\n if (Number.isNaN(radius) || radius < 1) return;\n radius |= 0;\n\n var imageData = getImageDataFromCanvas(canvas, top_x, top_y, width, height);\n\n imageData = processImageDataRGBA(imageData, top_x, top_y, width, height, radius);\n\n canvas.getContext('2d').putImageData(imageData, top_x, top_y);\n}\n\nfunction processImageDataRGBA(imageData, top_x, top_y, width, height, radius)\n{\n var pixels = imageData.data;\n\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum,\n r_out_sum, g_out_sum, b_out_sum, a_out_sum,\n r_in_sum, g_in_sum, b_in_sum, a_in_sum,\n pr, pg, pb, pa, rbs;\n\n var div = radius + radius + 1;\n var w4 = width << 2;\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n\n var stackStart = new BlurStack();\n var stack = stackStart;\n for (i = 1; i < div; i++)\n {\n stack = stack.next = new BlurStack();\n if (i == radiusPlus1) var stackEnd = stack;\n }\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n\n yw = yi = 0;\n\n var mul_sum = mul_table[radius];\n var shg_sum = shg_table[radius];\n\n for (y = 0; y < height; y++)\n {\n r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;\n\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi+3]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++)\n {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[p+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[p+2])) * rbs;\n a_sum += (stack.a = (pa = pixels[p+3])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n\n stack = stack.next;\n }\n\n\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++)\n {\n pixels[yi+3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa != 0)\n {\n pa = 255 / pa;\n pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi+1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi+2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n } else {\n pixels[yi] = pixels[yi+1] = pixels[yi+2] = 0;\n }\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n\n r_in_sum += (stackIn.r = pixels[p]);\n g_in_sum += (stackIn.g = pixels[p+1]);\n b_in_sum += (stackIn.b = pixels[p+2]);\n a_in_sum += (stackIn.a = pixels[p+3]);\n\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n a_sum += a_in_sum;\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n a_out_sum += (pa = stackOut.a);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n\n stackOut = stackOut.next;\n\n yi += 4;\n }\n yw += width;\n }\n\n\n for (x = 0; x < width; x++)\n {\n g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;\n\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi+3]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++)\n {\n yi = (yp + x) << 2;\n\n r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[yi+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[yi+2])) * rbs;\n a_sum += (stack.a = (pa = pixels[yi+3])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n\n stack = stack.next;\n\n if(i < heightMinus1)\n {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++)\n {\n p = yi << 2;\n pixels[p+3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa > 0)\n {\n pa = 255 / pa;\n pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[p+1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[p+2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n } else {\n pixels[p] = pixels[p+1] = pixels[p+2] = 0;\n }\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n\n p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;\n\n r_sum += (r_in_sum += (stackIn.r = pixels[p]));\n g_sum += (g_in_sum += (stackIn.g = pixels[p+1]));\n b_sum += (b_in_sum += (stackIn.b = pixels[p+2]));\n a_sum += (a_in_sum += (stackIn.a = pixels[p+3]));\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n a_out_sum += (pa = stackOut.a);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n\n stackOut = stackOut.next;\n\n yi += width;\n }\n }\n return imageData;\n}\n\nfunction processCanvasRGB(canvas, top_x, top_y, width, height, radius)\n{\n if (Number.isNaN(radius) || radius < 1) return;\n radius |= 0;\n\n var imageData = getImageDataFromCanvas(canvas, top_x, top_y, width, height);\n imageData = processImageDataRGB(imageData, top_x, top_y, width, height, radius);\n\n canvas.getContext('2d').putImageData(imageData, top_x, top_y);\n}\n\nfunction processImageDataRGB(imageData, top_x, top_y, width, height, radius)\n{\n var pixels = imageData.data;\n\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum,\n r_out_sum, g_out_sum, b_out_sum,\n r_in_sum, g_in_sum, b_in_sum,\n pr, pg, pb, rbs;\n\n var div = radius + radius + 1;\n var w4 = width << 2;\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n\n var stackStart = new BlurStack();\n var stack = stackStart;\n for (i = 1; i < div; i++)\n {\n stack = stack.next = new BlurStack();\n if (i == radiusPlus1) var stackEnd = stack;\n }\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n\n yw = yi = 0;\n\n var mul_sum = mul_table[radius];\n var shg_sum = shg_table[radius];\n\n for (y = 0; y < height; y++)\n {\n r_in_sum = g_in_sum = b_in_sum = r_sum = g_sum = b_sum = 0;\n\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++)\n {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[p+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[p+2])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n\n stack = stack.next;\n }\n\n\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++)\n {\n pixels[yi] = (r_sum * mul_sum) >> shg_sum;\n pixels[yi+1] = (g_sum * mul_sum) >> shg_sum;\n pixels[yi+2] = (b_sum * mul_sum) >> shg_sum;\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n\n r_in_sum += (stackIn.r = pixels[p]);\n g_in_sum += (stackIn.g = pixels[p+1]);\n b_in_sum += (stackIn.b = pixels[p+2]);\n\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n\n stackOut = stackOut.next;\n\n yi += 4;\n }\n yw += width;\n }\n\n\n for (x = 0; x < width; x++)\n {\n g_in_sum = b_in_sum = r_in_sum = g_sum = b_sum = r_sum = 0;\n\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++)\n {\n yi = (yp + x) << 2;\n\n r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[yi+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[yi+2])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n\n stack = stack.next;\n\n if(i < heightMinus1)\n {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++)\n {\n p = yi << 2;\n pixels[p] = (r_sum * mul_sum) >> shg_sum;\n pixels[p+1] = (g_sum * mul_sum) >> shg_sum;\n pixels[p+2] = (b_sum * mul_sum) >> shg_sum;\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n\n p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;\n\n r_sum += (r_in_sum += (stackIn.r = pixels[p]));\n g_sum += (g_in_sum += (stackIn.g = pixels[p+1]));\n b_sum += (b_in_sum += (stackIn.b = pixels[p+2]));\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n\n stackOut = stackOut.next;\n\n yi += width;\n }\n }\n\n return imageData;\n}\n\nfunction BlurStack()\n{\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n}\n\nexport default {\n image: processImage,\n canvasRGBA: processCanvasRGBA,\n canvasRGB: processCanvasRGB,\n imageDataRGBA: processImageDataRGBA,\n imageDataRGB: processImageDataRGB\n};\n","/* eslint-disable max-len */\n// Equations based on NOAA’s Solar Calculator; all angles in radians.\n// http://www.esrl.noaa.gov/gmd/grad/solcalc/\n\nconst π = Math.PI;\nconst radians = π / 180;\nconst degrees = 180 / π;\n\nfunction solarGeometricMeanAnomaly(centuries) {\n return (357.52911 + centuries * (35999.05029 - 0.0001537 * centuries)) * radians;\n}\n\nfunction solarGeometricMeanLongitude(centuries) {\n const l = (280.46646 + centuries * (36000.76983 + centuries * 0.0003032)) % 360;\n return ((l < 0 ? l + 360 : l) / 180) * π;\n}\n\nfunction solarEquationOfCenter(centuries) {\n const m = solarGeometricMeanAnomaly(centuries);\n return (Math.sin(m) * (1.914602 - centuries * (0.004817 + 0.000014 * centuries))\n + Math.sin(m + m) * (0.019993 - 0.000101 * centuries)\n + Math.sin(m + m + m) * 0.000289) * radians;\n}\n\nfunction solarTrueLongitude(centuries) {\n return solarGeometricMeanLongitude(centuries) + solarEquationOfCenter(centuries);\n}\n\nfunction solarApparentLongitude(centuries) {\n return solarTrueLongitude(centuries) - (0.00569 + 0.00478 * Math.sin((125.04 - 1934.136 * centuries) * radians)) * radians;\n}\n\nfunction meanObliquityOfEcliptic(centuries) {\n return (23 + (26 + (21.448 - centuries * (46.8150 + centuries * (0.00059 - centuries * 0.001813))) / 60) / 60) * radians;\n}\n\nfunction obliquityCorrection(centuries) {\n return meanObliquityOfEcliptic(centuries) + 0.00256 * Math.cos((125.04 - 1934.136 * centuries) * radians) * radians;\n}\n\nfunction solarDeclination(centuries) {\n return Math.asin(\n Math.sin(obliquityCorrection(centuries)) * Math.sin(solarApparentLongitude(centuries)),\n );\n}\n\nfunction eccentricityEarthOrbit(centuries) {\n return 0.016708634 - centuries * (0.000042037 + 0.0000001267 * centuries);\n}\n\nfunction equationOfTime(centuries) {\n const e = eccentricityEarthOrbit(centuries);\n const m = solarGeometricMeanAnomaly(centuries);\n const l = solarGeometricMeanLongitude(centuries);\n let y = Math.tan(obliquityCorrection(centuries) / 2);\n y *= y;\n return y * Math.sin(2 * l)\n - 2 * e * Math.sin(m)\n + 4 * e * y * Math.sin(m) * Math.cos(2 * l)\n - 0.5 * y * y * Math.sin(4 * l)\n - 1.25 * e * e * Math.sin(2 * m);\n}\n\nexport function antipode(position) {\n return [position[0] + 180, -position[1]];\n}\n\nexport function solarPosition(time) {\n const centuries = (time - Date.UTC(2000, 0, 1, 12)) / 864e5 / 36525; // since J2000\n const longitude = ((d3.time.day.utc.floor(time) - time) / 864e5) * 360 - 180;\n return [\n longitude - equationOfTime(centuries) * degrees,\n solarDeclination(centuries) * degrees,\n ];\n}\n","import Legend from './Legend';\nimport Watermark from './Watermark';\nimport StackBlur from './StackBlur';\nimport utils from '../utils';\nimport { solarPosition, antipode } from './solarPosition';\n\n/**\n * Used the name GeoMap instead of Map to avoid collision with the native Map class of JS\n */\nexport default class GeoMap {\n /**\n * Geo Mapping class constructor that will initiate the map drawing\n * @param maptable: Maptable main Object\n * @param options: options communicated to map\n * @param jsonWorld: Object that contain TopoJSON dataset\n */\n constructor(maptable, options, jsonWorld) {\n this.maptable = maptable;\n this.scale = 1;\n this.transX = 0;\n this.transY = 0;\n\n this.options = options;\n\n this.jsonWorld = jsonWorld;\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n\n // Map wrapper\n const mapWrapper = this.container.querySelector('.mt-map-container');\n\n const existingMap = this.container.querySelector('#mt-map');\n if (existingMap) {\n // transform #mt-map to .mt-map-container'\n mapWrapper.parentNode.insertBefore(mapWrapper, existingMap);\n existingMap.parentNode.removeChild(existingMap);\n }\n\n // Map\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-map');\n mapWrapper.appendChild(this.node);\n\n this.svg = d3.select(this.node)\n .append('svg')\n .attr('id', 'mt-map-svg')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('xmlns:xlink', 'http://www.w3.org/1999/xlink')\n .attr('viewBox', `0 0 ${this.getWidth()} ${this.getHeight()}`)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight());\n\n this.projection = d3.geo.equirectangular()\n .translate([this.getWidth() / 2, this.getHeight() / (2 * this.options.scaleHeight)])\n .scale((this.getWidth() / 640) * 100)\n .rotate([-12, 0])\n .precision(0.1);\n\n this.path = d3.geo.path().projection(this.projection);\n\n this.enrichData();\n\n this.zoomListener = d3.behavior\n .zoom()\n .scaleExtent(this.options.scaleZoom)\n .on('zoom', this.rescale.bind(this));\n\n // Attach Zoom event to map\n if (this.options.zoom) {\n this.svg = this.svg.call(this.zoomListener.bind(this));\n }\n\n // Add tooltip\n if (this.options.markers) {\n this.tooltipMarkersNode = d3.select(this.node)\n .append('div')\n .attr('id', 'mt-map-markers-tooltip')\n .attr('class', `mt-map-tooltip ${this.options.markers.tooltipClassName}`)\n .style('display', 'none');\n }\n\n if (this.options.countries) {\n this.tooltipCountriesNode = d3.select(this.node)\n .append('div')\n .attr('id', 'mt-map-countries-tooltip')\n .attr('class', `mt-map-tooltip ${this.options.countries.tooltipClassName}`)\n .style('display', 'none');\n }\n\n this.layerGlobal = this.svg.append('g').attr('class', 'mt-map-global');\n this.layerDefs = this.svg.append('defs');\n this.layerDefs.html(`\n \n \n \n \n \n \n `);\n if (this.options.timezones) this.layerTimezones = this.layerGlobal.append('g').attr('class', 'mt-map-timezones');\n this.layerCountries = this.layerGlobal.append('g').attr('class', 'mt-map-countries');\n if (this.options.night) this.layerNight = this.layerGlobal.append('g').attr('class', 'mt-map-night');\n\n if (this.options.heatmap) this.layerHeatmap = this.layerGlobal.append('g').attr('class', 'mt-map-heatmap');\n this.layerMarkers = this.layerGlobal.append('g').attr('class', 'mt-map-markers');\n\n // Add Watermark\n if (this.options.watermark) {\n this.watermark = new Watermark(this, this.options.watermark);\n }\n\n // Add Title\n if (this.options.title) {\n this.buildTitle();\n }\n\n // Add Export SVG Capability\n if (this.options.exportSvgClient || this.options.exportSvg) {\n this.addExportSvgCapability();\n }\n\n // AutoResize\n if (!this.options.width) {\n window.addEventListener('resize', () => {\n this.svg.attr('width', this.getWidth());\n this.svg.attr('height', this.getHeight());\n this.rescale();\n });\n }\n\n // Let's build things\n this.loadGeometries();\n\n // render is triggered by MapTable\n // this.render();\n }\n\n enrichData() {\n // Add coordinates to rawData\n this.maptable.rawData.forEach((d) => {\n d.longitude = parseFloat(d[this.options.longitudeKey]);\n d.latitude = parseFloat(d[this.options.latitudeKey]);\n let coord = [0, 0];\n if (!Number.isNaN(d.longitude) && !Number.isNaN(d.latitude)) {\n coord = this.projection([d.longitude, d.latitude]);\n }\n d.x = coord[0];\n d.y = coord[1];\n });\n }\n\n scaleAttributes() {\n return Math.pow(this.scale, 2 / 3); // eslint-disable-line\n }\n\n getWidth() {\n if (this.options.width) {\n return this.options.width;\n }\n this.options.width = this.node.offsetWidth;\n return this.node.offsetWidth;\n }\n\n getHeight() {\n const deltaHeight = (this.options.title) ? 30 : 0;\n if (!this.options.height && this.options.ratioFromWidth) {\n return this.getWidth() * this.options.ratioFromWidth * this.options.scaleHeight + deltaHeight;\n }\n return this.options.height * this.options.scaleHeight + deltaHeight;\n }\n\n /**\n * Load geometries and built the map components\n */\n loadGeometries() {\n // We filter world data\n if (this.options.filterCountries) {\n this.jsonWorld.objects.countries.geometries = this.jsonWorld.objects.countries\n .geometries.filter(this.options.filterCountries);\n }\n\n // Build countries\n if (this.options.countries) this.buildCountries();\n\n // Build heatmap\n if (this.options.heatmap) this.buildHeatmap();\n\n if (this.options.night) this.buildNight();\n if (\n this.options.timezones\n && (this.options.timezones.path || this.options.timezones.pathData)\n ) this.buildTimezone();\n }\n\n /**\n * Logic to build the heatmap elements (without the filling the heatmap image)\n */\n buildHeatmap() {\n // Build vectors\n const lands = topojson.merge(this.jsonWorld, this.jsonWorld.objects.countries.geometries);\n if (!this.options.heatmap.disableMask) {\n this.maskHeatmap = this.layerHeatmap.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-heatmap-mask');\n\n this.maskHeatmap\n .datum(lands)\n .append('path')\n .attr('class', 'mt-map-heatmap-mask-paths')\n .attr('d', this.path);\n }\n\n this.imgHeatmap = this.layerHeatmap\n .append('image')\n .attr('width', this.getWidth())\n .attr('height', this.getHeight())\n .attr('x', 0)\n .attr('y', 0)\n .attr('class', 'mt-map-heatmap-img');\n\n if (this.options.heatmap.mask) {\n this.imgHeatmap = this.imgHeatmap.attr('clip-path', 'url(#mt-map-heatmap-mask)');\n }\n\n if (this.options.heatmap.borders) {\n const borders = topojson.mesh(\n this.jsonWorld,\n this.jsonWorld.objects.countries,\n (a, b) => a !== b,\n );\n\n this.bordersHeatmap = this.layerHeatmap\n .append('g')\n .attr('class', 'mt-map-heatmap-borders');\n\n this.bordersHeatmap.selectAll('path.mt-map-heatmap-borders-paths')\n .data([lands, borders])\n .enter()\n .append('path')\n .attr('class', 'mt-map-heatmap-borders-paths')\n .attr('fill', 'none')\n .attr('stroke-width', this.options.heatmap.borders.stroke)\n .attr('stroke', this.options.heatmap.borders.color)\n .attr('style', `opacity: ${this.options.heatmap.borders.opacity}`)\n .attr('d', this.path);\n }\n }\n\n /**\n * Logic to build the night position\n */\n buildNight() {\n this.layerNight = this.layerGlobal.append('g')\n .attr('class', 'mt-map-night');\n\n const circle = d3.geo.circle()\n .angle(90);\n\n // Mask night\n this.maskNight = this.layerNight.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-night-mask');\n\n this.maskNight.append('rect')\n .attr('x', 0)\n .attr('y', 30)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight() * 0.82 - 30);\n\n // Build vectors\n this.nightPath = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.path)\n .style('opacity', 0.1);\n\n const userDate = this.options.night.date || Date.UTC();\n const startOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 0,\n 0,\n 0,\n );\n const solarPositionDated = solarPosition(new Date(startOfDay));\n this.nightPath.datum(circle.origin(antipode(solarPositionDated))).attr('d', this.path);\n\n this.nightPathRight = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.nightPath.attr('d'))\n .style('opacity', 0.1)\n .style('transform', `translate3d(${this.getWidth()}px,0,0)`);\n\n this.nightPathLeft = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.nightPath.attr('d'))\n .style('opacity', 0.1)\n .style('transform', `translate3d(${-this.getWidth()}px,0,0)`);\n\n if (!this.options.night.disableSun) {\n const sunCoords = this.projection(solarPositionDated);\n\n this.sunCircleRight = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-right')\n .attr('cx', sunCoords[0])\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleXRight = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-xright')\n .attr('cx', sunCoords[0] + this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleLeft = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-right')\n .attr('cx', sunCoords[0] - this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleXLeft = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-xright')\n .attr('cx', sunCoords[0] - 2 * this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n }\n }\n\n /**\n * Logic to build the timezone strips\n */\n buildTimezone() {\n if (this.options.timezones.pathData) {\n this.loadTimezone(null, JSON.parse(this.options.timezones.pathData));\n } else if (this.options.timezones.path) {\n d3.json(this.options.timezones.path, (errGeoMap, jsonTimezones) => {\n this.loadTimezone(errGeoMap, jsonTimezones);\n });\n }\n }\n\n scaleFontSize(fontSize) {\n return this.getWidth() < 700 ? fontSize * (this.getWidth() / 700) : fontSize;\n }\n\n loadTimezone(err, jsonTimezones) {\n this.dataTimezones = topojson.feature(\n jsonTimezones,\n jsonTimezones.objects.timezones,\n ).features;\n\n // Mask timezone\n this.maskTimezone = this.layerTimezones.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-timezone-mask');\n\n this.maskTimezone.append('rect')\n .attr('x', 0)\n .attr('y', 30)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight() * 0.82 - 30);\n\n // Build timezone paths\n this.layerTimezones\n .selectAll('.mt-map-timezone')\n .data(this.dataTimezones.filter((d) => d.properties.places !== 'Antarctica'))\n .enter()\n .insert('path')\n .attr('class', 'mt-map-timezone')\n .attr('d', this.path)\n .attr('fill', (d) => (d.properties.zone % 2 === 0 ? '#F4F5F5' : 'transparent'))\n .attr('title', (d) => JSON.stringify(d.properties))\n .attr('clip-path', 'url(#mt-map-timezone-mask)')\n .style('opacity', 0.6);\n\n // Add times\n const timezoneTexts = this.dataTimezones.filter((d) => d.properties.places !== 'Antarctica' && d.properties.zone % 1 === 0 && d.properties.zone !== 14);\n const timezoneTextsUnique = [...new Map(timezoneTexts.map((item) => (\n [item.properties.zone, item]\n ))).values()];\n\n this.layerTimezonesText = this.layerTimezones.append('g').attr('class', 'mt-map-timezones-texts');\n this.layerTimezonesText.selectAll('.mt-map-timezone-text')\n .data(timezoneTextsUnique)\n .enter()\n .insert('text')\n .attr('class', 'mt-map-timezone-text')\n .attr('y', this.getHeight() * 0.82 - 5)\n .attr('x', (d) => (d.properties.zone + 10) * (this.getWidth() / 24.5) - 1)\n .attr('dx', (this.getWidth() / 24.5) / 2)\n .attr('font-size', this.scaleFontSize(9))\n .attr('font-family', 'Helevetica, Arial, Sans-Serif')\n .attr('fill', '#999')\n .attr('text-anchor', 'middle')\n .html((d) => (\n utils.formatDate((this.options.timezones.date || new Date()), d.properties.zone)));\n }\n\n /**\n * Get Scale for every circle magnitude\n * @param heatmapDataset: heatmap dataset that we use\n * @returns scale: function - Scale function that output a value [0 - 1]\n */\n getMagnitudeScale(heatmapDataset) {\n const opts = this.options.heatmap;\n const lengthDataset = heatmapDataset.length;\n if (!lengthDataset) return () => 0;\n // const layersPerLocation = (opts.circles.max - opts.circles.min) / opts.circles.step;\n const maxOpacityScale = d3.scale.linear()\n .domain([1, lengthDataset])\n .range([1, 0.25]);\n const centralCircleOpacity = maxOpacityScale(lengthDataset);\n\n const scale = d3.scale.linear()\n .domain([opts.circles.min, 20])\n .range([centralCircleOpacity, 0]);\n return (m) => scale(m);\n }\n\n /**\n * Get Scale for every data point (used for weighting)\n * @returns scale: function - Scale function that output a value [0 - 1]\n */\n getDatumScale() {\n if (!this.options.heatmap.weightByAttribute) return () => 1;\n const dataExtents = d3.extent(this.maptable.data, this.options.heatmap.weightByAttribute);\n const userScale = (this.options.heatmap.weightByAttributeScale === 'log')\n ? d3.scale.log : d3.scale.linear;\n const scale = userScale().domain(dataExtents).range([0.5, 1]);\n return (d) => {\n const val = this.options.heatmap.weightByAttribute(d);\n if (!val) return 0;\n return scale(val);\n };\n }\n\n /**\n * Get the Data URL of the heatmap image\n * @returns {string} base64 image\n */\n getHeatmapData() {\n const canvasHeatmap = d3.select(this.node)\n .append('canvas')\n .attr('id', 'mt-map-heatmap-canvas')\n .attr('width', this.getWidth())\n .attr('height', this.getHeight())\n .attr('style', 'display: none;');\n\n const ctx = canvasHeatmap.node().getContext('2d');\n ctx.globalCompositeOperation = 'multiply';\n const circles = d3.range(\n this.options.heatmap.circles.min,\n this.options.heatmap.circles.max,\n this.options.heatmap.circles.step,\n );\n const datumScale = this.getDatumScale();\n const heatmapDataset = this.maptable.data.filter((d) => datumScale(d) > 0.1);\n const path = this.path.context(ctx);\n const magnitudeScale = this.getMagnitudeScale(heatmapDataset);\n const colorScale = d3.scale.linear()\n .domain([1, 0])\n .range(['#000000', '#FFFFFF']);\n\n // Make a flat white background first\n ctx.beginPath();\n ctx.rect(0, 0, this.getWidth(), this.getHeight());\n ctx.fillStyle = '#ffffff';\n ctx.fill();\n ctx.closePath();\n\n // color strenght factor\n const colorMultiplier = (x) => {\n const a = this.options.heatmap.circles.colorStrength;\n const aa = 1 + ((a - 1) / 100);\n if (a > 1) return (2 - aa) * x + aa - 1;\n return a * x;\n };\n\n // add condensed clouds\n heatmapDataset.forEach((point) => {\n const scaleOpacityDatum = datumScale(point);\n circles.forEach((m) => {\n const opacity = colorMultiplier(magnitudeScale(m) * scaleOpacityDatum);\n if (opacity > 0) {\n ctx.beginPath();\n path(d3.geo.circle().origin([point.longitude, point.latitude]).angle(m - 0.0001)());\n ctx.fillStyle = colorScale(opacity);\n ctx.fill();\n ctx.closePath();\n }\n });\n });\n\n StackBlur.canvasRGBA(\n canvasHeatmap.node(),\n 0,\n 0,\n this.getWidth(),\n this.getHeight(),\n this.options.heatmap.circles.blur,\n );\n\n // Add color layer\n ctx.beginPath();\n ctx.globalCompositeOperation = 'screen';\n ctx.rect(0, 0, this.getWidth(), this.getHeight());\n ctx.fillStyle = this.options.heatmap.circles.color;\n ctx.fill();\n ctx.closePath();\n\n const dataUrl = canvasHeatmap.node().toDataURL();\n canvasHeatmap.remove();\n return dataUrl;\n }\n\n /**\n * Set the data URL to the heatmap image\n */\n updateHeatmap() {\n const dataUrl = this.getHeatmapData();\n this.imgHeatmap.attr('xlink:href', dataUrl);\n }\n\n /**\n * build the paths for the countries\n */\n buildCountries() {\n this.dataCountries = topojson.feature(\n this.jsonWorld,\n this.jsonWorld.objects.countries,\n ).features;\n\n // Build country paths\n this.layerCountries\n .selectAll('.mt-map-country')\n .data(this.dataCountries)\n .enter()\n .insert('path')\n .attr('class', 'mt-map-country')\n .attr('d', this.path);\n\n // Build Country Legend\n this.legendCountry = {};\n\n if (this.shouldRenderLegend()) {\n this.legendCountry.fill = new Legend(this);\n }\n }\n\n shouldRenderLegend() {\n const f = this.options.countries.attr.fill;\n if (!f) return false;\n if (!f.legend || !f.min || !f.max) return false;\n if (f.aggregate && f.aggregate.scale) {\n const scale = (typeof (f.aggregate.scale) === 'function')\n ? f.aggregate.scale.bind(this.maptable)()\n : f.aggregate.scale;\n if (scale !== 'linear') return false;\n }\n return true;\n }\n\n /**\n * Get all mt-map-country elements\n */\n getAllMtMapCountry() {\n if (this.allMtMapCountry) return this.allMtMapCountry;\n this.allMtMapCountry = d3.selectAll(`${this.containerSelector} .mt-map-country`);\n return this.allMtMapCountry;\n }\n\n /**\n * Get all mt-map-marjker elements\n */\n getAllMtMapMarker() {\n if (this.allMtMapMarker) return this.allMtMapMarker;\n this.allMtMapMarker = d3.selectAll(`${this.containerSelector} .mt-map-marker`);\n return this.allMtMapMarker;\n }\n\n /**\n * Set the right color for every country\n */\n updateCountries() {\n // Data from user input\n const dataByCountry = new Map();\n this.maptable.data.forEach((d) => {\n const key = d[this.options.countryIdentifierKey];\n if (!dataByCountry.has(key)) {\n dataByCountry.set(key, []);\n }\n dataByCountry.get(key).push(d);\n });\n\n // We merge both data\n this.dataCountries.forEach((geoDatum) => {\n geoDatum.key = geoDatum.properties[this.options.countryIdentifierType];\n const matchedCountry = dataByCountry.get(geoDatum.key);\n geoDatum.values = matchedCountry || [];\n geoDatum.attr = {};\n geoDatum.rollupValue = {};\n });\n\n // We calculate attributes values\n Object.keys(this.options.countries.attr).forEach((k) => {\n this.setAttrValues(k, this.options.countries.attr[k], this.dataCountries);\n });\n\n // Update SVG\n const countryItem = this.getAllMtMapCountry().each(function (d) {\n const selection = d3.select(this);\n Object.keys(d.attr).forEach((key) => {\n selection.attr(key, d.attr[key]);\n });\n });\n\n // Update Legend\n Object.keys(this.options.countries.attr).forEach((attrKey) => {\n const attrValue = this.options.countries.attr[attrKey];\n if (typeof (attrValue) === 'object' && attrValue.legend && this.legendCountry[attrKey] !== undefined) {\n const scaleDomain = d3.extent(\n this.dataCountries,\n (d) => Number(d.attrProperties[attrKey].value),\n );\n this.legendCountry[attrKey].updateExtents(scaleDomain);\n\n // When we mouseover the legend, it should highlight the indice selected\n countryItem.on('mouseover', (d) => {\n this.legendCountry[attrKey].indiceChange(d.attrProperties[attrKey].value);\n })\n .on('mouseout', () => {\n this.legendCountry[attrKey].indiceChange(NaN);\n });\n }\n });\n\n // Update Tooltip\n if (this.options.countries && this.options.countries.tooltip) {\n this.activateTooltip(\n countryItem,\n this.tooltipCountriesNode,\n this.options.countries.tooltip,\n true,\n );\n }\n }\n\n /**\n * Update night drawings\n */\n updateNight() {\n const userDate = this.options.night.date || Date.UTC();\n const startOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 0,\n 0,\n 0,\n );\n const endOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 23,\n 59,\n 59,\n );\n\n const totalMilliseconds = endOfDay - startOfDay;\n const currentTime = userDate - startOfDay;\n const relativeTranslateX = (currentTime / totalMilliseconds);\n\n this.layerNight.node().style.transform = `translateX(${-this.getWidth() * relativeTranslateX}px)`;\n }\n\n /**\n * Update night drawings\n */\n updateTimezones() {\n const timezoneTexts = document.querySelectorAll('.mt-map-timezone-text');\n const currentDate = this.options.timezones.date || new Date();\n\n Array.from(timezoneTexts).forEach((timezoneText) => {\n timezoneText.textContent = utils.formatDate(\n currentDate,\n timezoneText.__data__.properties.zone,\n );\n });\n }\n\n updateMarkers() {\n const defaultGroupBy = (a) => `${a.longitude},${a.latitude}`;\n\n this.dataMarkers = d3.nest()\n .key(defaultGroupBy)\n .entries(this.maptable.data)\n .filter((d) => d.values[0].x !== 0);\n\n // We merge both data\n this.dataMarkers.forEach((d) => {\n d.attr = {};\n d.attrProperties = {};\n });\n\n // We calculate attributes values\n Object.keys(this.options.markers.attr).forEach((k) => {\n this.setAttrValues(k, this.options.markers.attr[k], this.dataMarkers);\n });\n\n // Enter\n const markerItem = this.layerMarkers\n .selectAll('.mt-map-marker')\n .data(this.dataMarkers);\n let markerObject = markerItem.enter();\n if (this.options.markers.customTag) {\n markerObject = this.options.markers.customTag(markerObject);\n } else {\n markerObject = markerObject.append('svg:circle');\n }\n const markerClassName = (this.options.markers.className)\n ? this.options.markers.className : '';\n\n markerObject.attr('class', `mt-map-marker ${markerClassName}`);\n\n // Exit\n markerItem.exit().transition()\n .attr('r', 0)\n .attr('fill', '#eee')\n .style('opacity', 0)\n .remove();\n\n // Update\n const attrX = (this.options.markers.attrX) ? this.options.markers.attrX : 'cx';\n const attrY = (this.options.markers.attrY) ? this.options.markers.attrY : 'cy';\n\n const attrXDelta = (this.options.markers.attrXDelta) ? this.options.markers.attrXDelta : 0;\n const attrYDelta = (this.options.markers.attrYDelta) ? this.options.markers.attrYDelta : 0;\n\n const markerUpdate = markerItem\n .attr(attrX, (d) => d.values[0].x + attrXDelta)\n .attr(attrY, (d) => d.values[0].y + attrYDelta);\n\n this.getAllMtMapMarker().each(function (d) {\n Object.keys(d.attr).forEach((key) => {\n d3.select(this).attr(key, d.attr[key]);\n });\n });\n\n if (this.options.markers.tooltip) {\n this.activateTooltip(\n markerUpdate,\n this.tooltipMarkersNode,\n this.options.markers.tooltip,\n false,\n );\n }\n\n this.rescale();\n }\n\n fitContent() {\n if (this.maptable.data.length === 0) {\n this.transX = 0;\n this.transY = 0;\n this.scale = 1;\n this.zoomListener.translate([this.transX, this.transY])\n .scale(this.scale);\n return;\n }\n const hor = d3.extent(this.maptable.data, (d) => d.x);\n const ver = d3.extent(this.maptable.data, (d) => d.y);\n\n // center dots with the good ratio\n const ratio = this.getWidth() / this.getHeight();\n const deltaMarker = 20 + ((this.options.title) ? 30 : 0);\n\n const currentWidth = (hor[1] - hor[0]) + deltaMarker;\n const currentHeight = (ver[1] - ver[0]) + deltaMarker;\n\n const realHeight = currentWidth / ratio;\n const realWidth = currentHeight * ratio;\n\n let diffMarginWidth = 0;\n let diffMarginHeight = 0;\n if (realWidth >= currentWidth) {\n diffMarginWidth = (realWidth - currentWidth) / 2;\n } else {\n diffMarginHeight = (realHeight - currentHeight) / 2;\n }\n\n // add layout margin\n hor[0] -= (this.options.fitContentMargin + diffMarginWidth);\n hor[1] += (this.options.fitContentMargin + diffMarginWidth);\n ver[0] -= (this.options.fitContentMargin + diffMarginHeight);\n ver[1] += (this.options.fitContentMargin + diffMarginHeight);\n\n this.scale = this.getWidth() / (hor[1] - hor[0]);\n this.transX = -1 * hor[0] * this.scale;\n this.transY = -1 * ver[0] * this.scale;\n\n this.zoomListener.translate([this.transX, this.transY]).scale(this.scale);\n }\n\n buildTitle() {\n const titleContainer = this.svg\n .append('svg')\n .attr('width', this.getWidth())\n .attr('x', 0)\n .attr('y', (this.getHeight() - 30))\n .attr('height', 30);\n\n if (this.options.title.bgColor) {\n titleContainer.append('rect')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', this.getWidth())\n .attr('height', 30)\n .attr('fill', this.options.title.bgColor);\n }\n\n titleContainer.append('text')\n .attr('id', 'mt-map-title')\n .attr('x', 20)\n .attr('font-size', this.scaleFontSize(this.options.title.fontSize))\n .attr('font-family', this.options.title.fontFamily)\n .attr('y', 20);\n\n if (this.options.title.source) {\n titleContainer.append('text')\n .attr('y', 20)\n .attr('x', (this.getWidth() - 20))\n .attr('text-anchor', 'end')\n .attr('font-size', this.scaleFontSize(this.options.title.fontSize))\n .attr('font-family', this.options.title.fontFamily)\n .html(this.options.title.source());\n }\n }\n\n /**\n * We encode a transaltion to be independent from the dimensions of the visualization\n * @param originalTranslation: Array - original translation value (from screen)\n * @returns encodedTranslation: Array - encoded translation\n */\n encodeTranslation(originalTranslation) {\n const newTx = originalTranslation[0] / (this.scale * this.getWidth());\n\n const newTy = originalTranslation[1] / (this.scale * this.getHeight());\n\n return [newTx, newTy];\n }\n\n /**\n * We decode a translation to adapt it to the dimensions of the visualization\n * @param encodedTranslation: Array - encoded translation\n * @returns originalTranslation: Array - original translation value (from screen)\n */\n decodeTranslation(encodedTranslation) {\n const newTx = encodedTranslation[0] * this.getWidth() * this.scale;\n\n const newTy = encodedTranslation[1] * this.getHeight() * this.scale;\n\n return [newTx, newTy];\n }\n\n /**\n * Restore state from the url hash\n */\n restoreState(defaultZoom) {\n if (!defaultZoom || defaultZoom.length !== 3) return;\n this.scale = defaultZoom[0];\n const originalTranslation = this.decodeTranslation([defaultZoom[1], defaultZoom[2]]);\n this.transX = originalTranslation[0];\n this.transY = originalTranslation[1];\n this.zoomListener.scale(defaultZoom[0])\n .translate(originalTranslation)\n .event(this.svg);\n }\n\n /**\n * Save state into the url hash\n */\n saveState() {\n const encodedTranslation = this.encodeTranslation([this.transX, this.transY]);\n const exportedData = [this.scale, encodedTranslation[0],\n encodedTranslation[1]];\n if (exportedData[0] !== 1 && exportedData[1] !== 0 && exportedData[2] !== 0) {\n this.maptable.saveState('zoom', exportedData);\n } else {\n this.maptable.removeState('zoom');\n }\n }\n\n rescale() {\n const self = this;\n if (d3.event && d3.event.translate) {\n this.scale = d3.event.scale;\n this.transX = (this.scale === 1) ? 0 : d3.event.translate[0];\n this.transY = (this.scale === 1) ? 0 : d3.event.translate[1];\n }\n\n const maxTransX = 0;\n const maxTransY = 0;\n const minTransX = this.getWidth() * (1 - this.scale);\n const minTransY = this.getHeight() * (1 - this.scale);\n\n if (this.transY > maxTransY) {\n this.transY = maxTransY;\n } else if (this.transY < minTransY) {\n this.transY = minTransY;\n }\n\n if (this.transX > maxTransX) {\n this.transX = maxTransX;\n } else if (this.transX < minTransX) {\n this.transX = minTransX;\n }\n\n if (d3.event && d3.event.translate) {\n d3.event.translate[0] = this.transX;\n d3.event.translate[1] = this.transY;\n }\n\n this.layerGlobal.style(\n 'transform',\n `translate(${this.transX}px,${this.transY}px)scale(${this.scale})`,\n );\n\n // Hide tooltip\n if (self.tooltipCountriesNode) self.tooltipCountriesNode.attr('style', 'display:none;');\n if (self.tooltipMarkersNode) self.tooltipMarkersNode.attr('style', 'display:none;');\n\n // Rescale markers size\n if (this.options.markers) {\n // markers\n this.getAllMtMapMarker().each(function (d) {\n // stroke\n if (d.attr['stroke-width']) {\n d3.select(this).attr('stroke-width', d.attr['stroke-width'] / self.scaleAttributes());\n }\n // radius\n if (d.attr.r) {\n d3.select(this).attr('r', d.attr.r / self.scaleAttributes());\n }\n });\n }\n\n // Rescale Sun\n if (this.options.night && !this.options.disableSun) {\n d3.selectAll(`${this.containerSelector} .mt-map-sun`).style(\n 'r',\n (this.getHeight() * 0.35) / this.scale,\n );\n }\n\n // Rescale Country stroke-width\n if (this.options.countries) {\n this.getAllMtMapCountry().style(\n 'stroke-width',\n this.options.countries.attr['stroke-width'] / this.scale,\n );\n }\n\n // Rescale heatmap borders\n if (this.options.heatmap && this.options.heatmap.borders) {\n d3.selectAll(`${this.containerSelector} .mt-map-heatmap-borders-paths`)\n .style('stroke-width', this.options.heatmap.borders.stroke / this.scale);\n }\n\n // save state\n if (this.maptable.firstExecution && this.options.saveState) this.saveState();\n }\n\n setAttrValues(attrKey, attrValue, dataset) {\n if (typeof (attrValue) === 'number' || typeof (attrValue) === 'string') {\n // Static value\n dataset.forEach((d) => {\n d.attr[attrKey] = attrValue;\n });\n } else if (typeof (attrValue) === 'function') {\n // Dynamic value based on the dataset\n dataset.forEach((d) => {\n d.attr[attrKey] = attrValue(d);\n });\n } else if (typeof (attrValue) === 'object') {\n let scale = 'linear';\n let key = null;\n let mode = 'count';\n let scaleToUse = d3.scale.linear();\n if (attrValue.aggregate) {\n key = (typeof (attrValue.aggregate.key) === 'function')\n ? attrValue.aggregate.key.bind(this.maptable)()\n : attrValue.aggregate.key;\n\n mode = (typeof (attrValue.aggregate.mode) === 'function')\n ? attrValue.aggregate.mode.bind(this.maptable)()\n : attrValue.aggregate.mode;\n\n if (typeof (attrValue.aggregate.scale) === 'function') {\n scale = attrValue.aggregate.scale.bind(this.maptable)();\n } else if (attrValue.aggregate.scale) {\n scale = attrValue.aggregate.scale;\n }\n\n if (!key || !mode) {\n throw new Error(`MapTable: You should provide values 'key' & 'mode' for attr.${attrKey}.aggregate`);\n }\n\n // Custom aggregate mode\n if (mode === 'sum') {\n attrValue.rollup = (groupedData) => (\n groupedData.map((d) => Number(d[key])).reduce((a, c) => a + c, 0)\n );\n } else if (mode === 'avg') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const validData = groupedData.filter((d) => !Number.isNaN(Number(d[key])));\n return validData\n .map((d) => Number(d[key]))\n .reduce((a, c) => a + c, 0) / validData.length;\n };\n } else if (mode === 'count') {\n attrValue.rollup = (groupedData) => groupedData.length;\n } else if (mode === 'min') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return groupedValues.reduce((min, p) => (p < min ? p : min), groupedValues[0]);\n };\n } else if (mode === 'max') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return groupedValues.reduce((max, p) => (p > max ? p : max), groupedValues[0]);\n };\n } else if (mode.indexOf('percentile') !== -1) {\n const percentile = utils.toNumber(mode);\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return utils.quantile(groupedValues, percentile);\n };\n } else if (typeof (attrValue.rollup) === 'function') {\n attrValue.rollup = attrValue.rollup.bind(this.maptable);\n }\n\n // Custom scale\n if (scale) {\n if (scale.indexOf('log') !== -1) {\n scaleToUse = d3.scale.log();\n } else if (scale.indexOf('pow') !== -1) {\n scaleToUse = d3.scale.pow().exponent(utils.toNumber(scale) || 1);\n } else if (scale === 'sqrt') {\n scaleToUse = d3.scale.sqrt();\n }\n // Rank scale neeed additional transformations\n }\n }\n\n // Dynamic value based on a scale\n if (!attrValue.rollup) {\n attrValue.rollup = (d) => d.length;\n }\n if (!attrValue.min || !attrValue.max) {\n throw new Error(`MapTable: You should provide values 'min' & 'max' for attr.${attrKey}`);\n }\n\n dataset.forEach((d) => {\n const aggregatedValue = attrValue.rollup(d.values);\n if (!d.attrProperties) d.attrProperties = {};\n if (!d.attrProperties[attrKey]) d.attrProperties[attrKey] = {};\n d.attrProperties[attrKey].value = aggregatedValue;\n if (key) {\n d.attrProperties[attrKey].key = key;\n d.attrProperties[attrKey].mode = mode;\n d.attrProperties[attrKey].scale = scale;\n const c = this.maptable.columnDetails[key];\n d.attrProperties[attrKey].columnDetails = c;\n const datum = {};\n datum[key] = aggregatedValue;\n d.attrProperties[attrKey].formatted = (c && c.cellContent)\n ? c.cellContent.bind(this.maptable)(datum)\n : aggregatedValue;\n }\n });\n if (scale === 'rank') {\n const positiveRanks = utils.uniqueValues([0].concat(dataset\n .map((d) => Math.floor(d.attrProperties[attrKey].value * 100) / 100)\n .filter((v) => v > 0)));\n const negativeRanks = utils.uniqueValues(dataset\n .map((d) => Math.floor(d.attrProperties[attrKey].value * 100) / 100)\n .filter((v) => v < 0));\n\n positiveRanks.sort((a, b) => a - b);\n negativeRanks.sort((a, b) => b - a);\n\n dataset.forEach((d) => {\n if (d.attrProperties[attrKey].value !== 0) {\n const ranks = d.attrProperties[attrKey].value >= 0 ? positiveRanks : negativeRanks;\n const pos = ranks.indexOf(Math.floor(d.attrProperties[attrKey].value * 100) / 100);\n const percentile = Math.round((pos / ranks.length) * 100);\n const newValue = d.attrProperties[attrKey].value < 0\n ? percentile - (percentile * 2)\n : percentile;\n d.attrProperties[attrKey].value = newValue;\n }\n });\n }\n\n let scaleDomain = d3.extent(dataset, (d) => Number(d.attrProperties[attrKey].value));\n if (scaleDomain[0] === 0 && scale && scale.indexOf('log') !== '-1') {\n scaleDomain = d3.extent(\n dataset.filter((v) => Number(v.attrProperties[attrKey].value) !== 0),\n (d) => Number(d.attrProperties[attrKey].value),\n );\n }\n if (attrValue.transform) {\n scaleDomain[0] = attrValue.transform\n .bind(this.maptable)(scaleDomain[0], this.maptable.data);\n scaleDomain[1] = attrValue.transform\n .bind(this.maptable)(scaleDomain[1], this.maptable.data);\n }\n\n let minValue = attrValue.min;\n let maxValue = attrValue.max;\n\n if (attrValue.min === 'minValue') {\n minValue = scaleDomain[0];\n }\n if (attrValue.max === 'maxValue') {\n maxValue = scaleDomain[1];\n }\n\n // check for negative color declarations\n if ((attrValue.maxNegative && !attrValue.minNegative)\n || (!attrValue.maxNegative && attrValue.minNegative)) {\n throw new Error('MapTable: maxNegative or minNegative undefined. Please declare both.');\n }\n const useNegative = (attrValue.maxNegative && attrValue.minNegative);\n let scaleFunction;\n let scaleNegativeFunction;\n\n if (useNegative) {\n scaleFunction = scaleToUse.copy()\n .domain([0, scaleDomain[1]])\n .range([minValue, maxValue]);\n scaleNegativeFunction = scaleToUse.copy()\n .domain([scaleDomain[0], 0])\n .range([attrValue.maxNegative, attrValue.minNegative]);\n } else {\n scaleFunction = scaleToUse\n .domain(scaleDomain)\n .range([minValue, maxValue]);\n }\n\n dataset.forEach((d) => {\n let scaledValue;\n if (!d.values.length || Number.isNaN(d.attrProperties[attrKey].value)) {\n if (typeof (attrValue.empty) === 'undefined') {\n throw new Error(`MapTable: no empty property found for attr.${attrKey}`);\n }\n scaledValue = attrValue.empty;\n } else {\n const originalValueRaw = d.attrProperties[attrKey].value;\n const originalValue = (attrValue.transform)\n ? attrValue.transform.bind(this.maptable)(originalValueRaw, this.maptable.data)\n : originalValueRaw;\n\n if (useNegative && originalValue < 0) {\n scaledValue = scaleNegativeFunction(originalValue);\n } else {\n scaledValue = scaleFunction(originalValue);\n }\n }\n d.attr[attrKey] = scaledValue;\n });\n } else {\n throw new Error(`Maptable: Invalid value for ${attrKey}`);\n }\n }\n\n render() {\n if (this.options.markers) this.updateMarkers();\n if (this.options.countries) this.updateCountries();\n if (this.options.night) this.updateNight();\n if (this.options.timezones) this.updateTimezones();\n if (this.options.title) this.updateTitle();\n if (this.options.heatmap) this.updateHeatmap();\n if (this.options.autoFitContent) {\n this.fitContent();\n this.rescale();\n }\n // On render\n if (this.options.onRender && this.options.onRender.constructor === Function) {\n this.options.onRender.bind(this.maptable)();\n }\n }\n\n updateTitle() {\n if (this.options.title.content) {\n const showing = this.maptable.data.filter((d) => d[this.options.latitudeKey] !== 0).length;\n const total = this.maptable.rawData.filter((d) => d[this.options.latitudeKey] !== 0).length;\n\n let inlineFilters = '';\n if (this.maptable.filters) {\n inlineFilters = this.maptable.filters.getDescription();\n }\n\n this.container.querySelector('#mt-map-title').innerHTML = this.options.title\n .content.bind(this.maptable)(\n showing,\n total,\n inlineFilters,\n this.maptable.data,\n this.maptable.rawData,\n this.dataCountries,\n );\n }\n }\n\n activateTooltip(target, tooltipNode, tooltipContent, isCountry) {\n const self = this;\n target.on(isCountry ? 'mousemove' : 'mouseover', function (d) {\n const content = tooltipContent.bind(this.maptable)(d);\n if (!content) return;\n tooltipNode.html(content).attr('style', 'display:block;position:fixed;');\n\n let mouseLeft;\n let mouseTop;\n const tooltipDelta = tooltipNode.node().offsetWidth / 2;\n if (isCountry) {\n const mapRect = self.node.getBoundingClientRect();\n const mousePosition = d3.mouse(self.svg.node()).map((v) => parseInt(v, 10));\n\n mouseLeft = mapRect.left + mousePosition[0] - tooltipDelta;\n mouseTop = mapRect.top + mousePosition[1] + 10;\n } else {\n const targetRect = this.getBoundingClientRect();\n mouseLeft = (targetRect.left + (targetRect.width / 2) - tooltipDelta);\n mouseTop = (targetRect.top + targetRect.height + 2); // +2 is for the border\n }\n\n tooltipNode.attr(\n 'style',\n `top:${mouseTop}px;left:${mouseLeft}px;display:block;position:fixed;`,\n )\n .on('mouseout', () => {\n tooltipNode.style('display', 'none');\n });\n })\n .on('mouseout', () => {\n tooltipNode.style('display', 'none');\n });\n }\n\n exportSvg() {\n // Get the d3js SVG element\n const svg = this.container.querySelector('#mt-map-svg');\n // Extract the data as SVG text string\n const svgXml = `\n${(new XMLSerializer()).serializeToString(svg)}`;\n\n if (this.options.exportSvgClient) {\n if (!window.saveAs) {\n throw new Error('MapTable: Missing FileSaver.js library');\n }\n const blob = new Blob([svgXml], { type: 'image/svg+xml' });\n window.saveAs(blob, 'visualization.svg');\n } else if (this.options.exportSvg) {\n const form = this.node.querySelector('#mt-map-svg-form');\n form.querySelector('[name=\"data\"]').value = svgXml;\n form.submit();\n }\n }\n\n addExportSvgCapability() {\n const exportNode = document.createElement('div');\n exportNode.setAttribute('id', 'mt-map-export');\n this.container.querySelector('#mt-map').appendChild(exportNode);\n\n const exportButton = document.createElement('button');\n exportButton.setAttribute('class', 'btn btn-xs btn-default');\n exportButton.innerHTML = 'Download';\n exportButton.addEventListener('click', this.exportSvg.bind(this));\n exportNode.appendChild(exportButton);\n\n if (this.options.exportSvg) {\n const exportForm = document.createElement('div');\n exportForm.innerHTML = `
`;\n exportNode.appendChild(exportForm);\n }\n }\n}\n","import utils from '../utils';\n\nexport default class Filters {\n constructor(maptable, options) {\n this.maptable = maptable;\n this.options = options;\n this.criteria = [];\n\n if (this.options.show) {\n const arrayDiff = this.options.show\n .filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0);\n if (arrayDiff.length > 0) {\n throw new Error(`MapTable: invalid columns \"${arrayDiff.join(', ')}\"`);\n }\n this.activeColumns = this.options.show;\n } else {\n this.activeColumns = Object.keys(this.maptable.columnDetails);\n }\n\n this.container = document.createElement('div');\n this.maptable.node.appendChild(this.container);\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n this.node = this.container.querySelector('#mt-filters');\n\n if (!this.node) {\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-filters');\n this.node.setAttribute('class', 'panel panel-default');\n this.maptable.node.appendChild(this.node);\n }\n\n // -- Filters Header\n\n const filtersHeaderNode = document.createElement('div');\n filtersHeaderNode.setAttribute('class', 'panel-heading');\n\n const filtersResetNode = document.createElement('button');\n filtersResetNode.setAttribute('id', 'mt-filters-reset');\n filtersResetNode.setAttribute('class', 'btn btn-default btn-xs pull-right');\n filtersResetNode.style.display = 'none';\n filtersResetNode.style.marginLeft = 5;\n filtersResetNode.innerText = '↺ Reset';\n filtersResetNode.addEventListener('click', this.reset);\n filtersHeaderNode.appendChild(filtersResetNode);\n\n const filtersTitleNode = document.createElement('h3');\n filtersTitleNode.setAttribute('class', 'panel-title');\n filtersTitleNode.appendChild(document.createTextNode('Filters'));\n filtersHeaderNode.appendChild(filtersTitleNode);\n\n this.node.appendChild(filtersHeaderNode);\n\n // -- Filters Content\n const filtersBodyNode = document.createElement('div');\n filtersBodyNode.setAttribute('id', 'mt-filters-content');\n filtersBodyNode.setAttribute('class', 'panel-body');\n\n const filtersElementsNode = document.createElement('div');\n filtersElementsNode.setAttribute('id', 'mt-filters-elements');\n filtersBodyNode.appendChild(filtersElementsNode);\n\n const filtersNewNode = document.createElement('a');\n filtersNewNode.setAttribute('id', 'mt-filters-new');\n filtersNewNode.setAttribute('href', '#');\n filtersNewNode.innerText = '+ New filter';\n filtersNewNode.addEventListener('click', this.add.bind(this));\n filtersBodyNode.appendChild(filtersNewNode);\n\n this.node.appendChild(filtersBodyNode);\n }\n\n /**\n * Add a filter\n * @param evt: Window Event Object\n */\n add(evt) {\n if (evt) evt.preventDefault();\n const possibleFilters = this.getPossibleFilters();\n\n if (possibleFilters.length === 0) {\n return;\n }\n const filterName = possibleFilters[0].key;\n this.create(filterName);\n }\n\n create(filterName, replaceNode) {\n const rowNode = this.buildRow(filterName);\n if (replaceNode) {\n replaceNode.parentNode.replaceChild(rowNode, replaceNode);\n } else {\n this.node.querySelector('#mt-filters-elements').appendChild(rowNode);\n }\n this.criteria.push(filterName);\n this.maptable.render();\n if (this.container.style.display === 'none') {\n this.toggle();\n }\n }\n\n remove(filterName) {\n const rowNode = this.node.querySelector(`[data-mt-filter-name=\"${filterName}\"]`);\n if (rowNode) rowNode.parentNode.removeChild(rowNode);\n const filterIndex = this.criteria.indexOf(filterName);\n this.criteria.splice(filterIndex, 1);\n this.maptable.render();\n }\n\n /**\n * Reset filters\n */\n reset() {\n const rowNodes = this.node.querySelectorAll('[data-mt-filter-name]');\n for (let i = 0; i < rowNodes.length; i += 1) {\n rowNodes[i].parentNode.removeChild(rowNodes[i]);\n }\n this.criteria = [];\n this.maptable.render();\n }\n\n /**\n * Export the current filters to an object\n * @returns exportedFilters: Object - key => value that contain data about the current filters\n */\n exportFilters() {\n const output = {};\n const filtersChildren = this.node.querySelector('#mt-filters-elements').childNodes;\n\n for (let i = 0; i < filtersChildren.length; i += 1) {\n const element = filtersChildren[i];\n const filterName = element.querySelector('.mt-filter-name').value;\n const columnDetails = this.maptable.columnDetails[filterName];\n const filterOutput = [columnDetails.filterMethod];\n if (columnDetails.filterMethod === 'compare') {\n const filterRangeSelect = element.querySelector('.mt-filter-range');\n filterOutput[1] = filterRangeSelect.value;\n if (filterRangeSelect.value !== 'any') {\n if (filterRangeSelect.value === 'BETWEEN') {\n const filterValueMin = element.querySelector('.mt-filter-value-min').value;\n const filterValueMax = element.querySelector('.mt-filter-value-max').value;\n if (filterValueMin !== '' && filterValueMax === '') {\n filterOutput[2] = filterValueMin;\n filterOutput[3] = filterValueMax;\n }\n } else {\n const filterValue = element.querySelector('.mt-filter-value-min').value;\n filterOutput[2] = filterValue;\n }\n }\n } else if (columnDetails.filterMethod === 'field'\n || columnDetails.filterMethod === 'dropdown') {\n filterOutput[1] = '';\n const filterValue = element.querySelector('.mt-filter-value').value;\n filterOutput[2] = filterValue;\n }\n if (filterOutput[1] !== 'any' && filterOutput[2] && filterOutput[2] !== '') {\n output[filterName] = filterOutput;\n }\n }\n return output;\n }\n\n /**\n * Set the value for the current filters\n * @param criteria - Object - same format as the exportedFilters\n */\n setFilters(criteria) {\n this.reset();\n Object.keys(criteria).forEach((filterName) => {\n this.create(filterName);\n const criterion = criteria[filterName];\n const row = document\n .querySelector(`#mt-filters-elements [data-mt-filter-name=\"${filterName}\"]`);\n if (row) {\n if (criterion[0] === 'compare') {\n row.querySelector('.mt-filter-range').value = criterion[1];\n if (criterion[1] !== 'any') {\n if (criterion[1] === 'BETWEEN') {\n row.querySelector('.mt-filter-value-min').value = criterion[2];\n row.querySelector('.mt-filter-value-max').value = criterion[3];\n } else {\n row.querySelector('.mt-filter-value-min').value = criterion[2];\n }\n }\n } else if (criterion[0] === 'field' || criterion[0] === 'dropdown') {\n row.querySelector('.mt-filter-value').value = decodeURIComponent(criterion[2]);\n }\n }\n });\n this.maptable.render();\n }\n\n /**\n * Restore state from the URL hash\n */\n restoreState(defaultCriteria) {\n if (!defaultCriteria) return;\n this.setFilters(defaultCriteria);\n }\n\n /**\n * Get a human readable description of the filters (used for the title)\n * @returns {string} Human readable description\n */\n getDescription() {\n const outputArray = [];\n\n const filtersChildren = this.node.querySelector('#mt-filters-elements').childNodes;\n\n for (let i = 0; i < filtersChildren.length; i += 1) {\n const element = filtersChildren[i];\n const filterName = element.querySelector('.mt-filter-name').value;\n\n const columnDetails = this.maptable.columnDetails[filterName];\n\n let line = '';\n\n if (columnDetails.filterMethod === 'compare') {\n const filterRangeSelect = element.querySelector('.mt-filter-range');\n if (filterRangeSelect.value !== 'any') {\n if (filterRangeSelect.value === 'BETWEEN') {\n const filterValueMin = element.querySelector('.mt-filter-value-min').value;\n const filterValueMax = element.querySelector('.mt-filter-value-max').value;\n if (filterValueMin === '' || filterValueMax === '') continue;\n line += `${columnDetails.title} is between `;\n line += `${filterValueMin} and\n ${filterValueMax}`;\n } else {\n const filterValue = element.querySelector('.mt-filter-value-min').value;\n if (filterValue === '') continue;\n line += `${columnDetails.title} is `;\n line += filterRangeSelect.options[filterRangeSelect.selectedIndex].text;\n line += `${filterValue}`;\n }\n }\n } else if (columnDetails.filterMethod === 'field'\n || columnDetails.filterMethod === 'dropdown') {\n const filterValue = element.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n const separatorWord = (columnDetails.filterMethod === 'field') ? 'contains' : 'is';\n line += `${columnDetails.title} ${separatorWord}\n ${filterValue}`;\n }\n outputArray.push(line);\n }\n return outputArray.join(', ');\n }\n\n buildRow(filterName) {\n const that = this;\n\n const possibleFilters = this.getPossibleFilters();\n\n const columnDetails = this.maptable.columnDetails[filterName];\n\n const rowNode = document.createElement('div');\n rowNode.setAttribute('class', 'mt-filter-row');\n rowNode.setAttribute('data-mt-filter-name', filterName);\n\n // Button to remove filter\n const minusButton = document.createElement('button');\n minusButton.setAttribute('class', 'btn btn-default pull-right');\n minusButton.setAttribute('data-mt-filter-btn-minus', 1);\n minusButton.innerText = '– Remove this filter';\n minusButton.addEventListener('click', () => {\n filterName = rowNode.querySelector('.mt-filter-name').value;\n this.remove(filterName);\n });\n rowNode.appendChild(minusButton);\n\n // Filters separator \"AND\"\n const filterSeparator = document.createElement('span');\n filterSeparator.setAttribute('class', 'mt-filters-and');\n filterSeparator.innerText = 'And ';\n rowNode.appendChild(filterSeparator);\n\n // Filter name select\n const filterNameSelect = document.createElement('select');\n filterNameSelect.setAttribute('class', 'mt-filter-name form-control form-control-inline');\n utils.appendOptions(\n filterNameSelect,\n possibleFilters.map((f) => ({ text: f.title, value: f.key })),\n );\n filterNameSelect.value = filterName;\n\n filterNameSelect.addEventListener('change', function () {\n const oldFilterName = this.parentNode.getAttribute('data-mt-filter-name');\n const newFilterName = this.value;\n that.create(newFilterName, this.parentNode);\n that.remove(oldFilterName);\n that.refresh();\n });\n rowNode.appendChild(filterNameSelect);\n\n // Filter verb\n const filterVerb = document.createElement('span');\n filterVerb.innerText = (columnDetails.filterMethod === 'field') ? ' contains ' : ' is ';\n rowNode.appendChild(filterVerb);\n\n // Filter range\n let filterRange = null;\n if (columnDetails.filterMethod !== 'field' && columnDetails.filterMethod !== 'dropdown') {\n filterRange = document.createElement('select');\n filterRange.setAttribute('class', 'mt-filter-range form-control form-control-inline');\n utils.appendOptions(filterRange, ['any', '=', '≠', '<', '>', '≤', '≥', 'BETWEEN'].map((v) => ({ text: v, value: v })));\n filterRange.addEventListener('change', function () {\n that.handleRangeChange(this);\n });\n rowNode.appendChild(filterRange);\n\n // Little space:\n rowNode.appendChild(document.createTextNode(' '));\n }\n\n // Filter value\n const filterValue = document.createElement('div');\n filterValue.style.display = 'inline-block';\n filterValue.setAttribute('class', 'mt-filter-value-container');\n\n if (columnDetails.filterMethod === 'compare') {\n ['min', 'max'].forEach((val, i) => {\n const filterInput = document.createElement('input');\n filterInput.setAttribute(\n 'class',\n `form-control form-control-inline mt-filter-value-${val}`,\n );\n filterInput.setAttribute('type', columnDetails.filterInputType);\n filterInput.addEventListener('keyup', this.maptable.render.bind(this.maptable));\n filterInput.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterInput);\n if (i === 0) {\n // AND\n const filterValueAnd = document.createElement('span');\n filterValueAnd.setAttribute('class', 'mt-filter-value-and');\n filterValueAnd.innerText = ' and ';\n filterValue.appendChild(filterValueAnd);\n }\n });\n } else if (columnDetails.filterMethod === 'field') {\n const filterInput = document.createElement('input');\n filterInput.setAttribute('class', 'form-control form-control-inline mt-filter-value');\n filterInput.setAttribute('type', 'text');\n filterInput.addEventListener('keyup', this.maptable.render.bind(this.maptable));\n filterInput.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterInput);\n } else if (columnDetails.filterMethod === 'dropdown') {\n const filterSelect = document.createElement('select');\n filterSelect.setAttribute('class', 'form-control form-control-inline mt-filter-value');\n\n const uniqueValues = d3.nest().key((d) => d[filterName])\n .sortKeys(d3.ascending)\n .entries(this.maptable.rawData);\n\n utils.appendOptions(filterSelect, [{ text: 'Any', value: '' }].concat(uniqueValues.map((k) => ({ text: k.key, value: k.key }))));\n\n filterSelect.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterSelect);\n }\n\n rowNode.appendChild(filterValue);\n\n // We trigger it here to handle the value of the filter range\n if (filterRange) {\n this.handleRangeChange(filterRange);\n }\n\n return rowNode;\n }\n\n handleRangeChange(filterRange) {\n const rowNode = filterRange.parentNode;\n if (filterRange.value === 'any') {\n rowNode.querySelector('.mt-filter-value-container').style.display = 'none';\n } else {\n rowNode.querySelector('.mt-filter-value-container').style.display = 'inline-block';\n if (filterRange.value === 'BETWEEN') {\n rowNode.querySelector('.mt-filter-value-min').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-and').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-max').style.display = 'inline-block';\n } else {\n rowNode.querySelector('.mt-filter-value-min').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-and').style.display = 'none';\n rowNode.querySelector('.mt-filter-value-max').style.display = 'none';\n }\n }\n this.maptable.render.bind(this.maptable)();\n }\n\n getPossibleFilters(except) {\n return Object.keys(this.maptable.columnDetails)\n .map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k]))\n .filter((v) => (this.activeColumns.indexOf(v.key) !== -1)\n && (\n (except && except === v.key)\n || (this.criteria.indexOf(v.key) === -1 && v.filterMethod && !v.isVirtual)\n ));\n }\n\n filterData() {\n const that = this;\n this.maptable.data = this.maptable.rawData.filter((d) => {\n const rowNodes = this.node.querySelectorAll('.mt-filter-row');\n let matched = true;\n for (let i = 0; i < rowNodes.length && matched; i += 1) {\n const rowNode = rowNodes[i];\n const filterName = rowNode.getAttribute('data-mt-filter-name');\n const columnDetails = that.maptable.columnDetails[filterName];\n const fmt = columnDetails.dataParse; // shortcut\n\n if (columnDetails.filterMethod === 'dropdown') {\n const filterValue = rowNode.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n if (d[filterName] !== filterValue) matched = false;\n } else if (columnDetails.filterMethod === 'field') {\n const filterValue = rowNode.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n if (d[filterName].toLowerCase().indexOf(filterValue.toLowerCase()) === -1) {\n matched = false;\n }\n } else if (columnDetails.filterMethod === 'compare') {\n const filterRange = rowNode.querySelector('.mt-filter-range').value;\n if (filterRange === 'BETWEEN') {\n const filterValueMin = rowNode.querySelector('.mt-filter-value-min').value;\n const filterValueMax = rowNode.querySelector('.mt-filter-value-max').value;\n if (filterValueMin === '' || filterValueMax === '') continue;\n if (fmt\n && (fmt(d[filterName]) < fmt(filterValueMin)\n || fmt(d[filterName]) > fmt(filterValueMax))\n ) {\n matched = false;\n } else if (\n parseInt(d[filterName], 10) < parseInt(filterValueMin, 10)\n || parseInt(d[filterName], 10) > parseInt(filterValueMax, 10)\n ) {\n matched = false;\n }\n } else {\n const filterValue = rowNode.querySelector('.mt-filter-value-min').value;\n if (filterValue === '') continue;\n if (fmt && !utils.rangeToBool(fmt(d[filterName]), filterRange, fmt(filterValue))) {\n matched = false;\n } else if (!fmt && !utils.rangeToBool(d[filterName], filterRange, filterValue)) {\n matched = false;\n }\n }\n }\n\n if ((fmt && utils.isBlank(fmt(d[filterName]))) || utils.isBlank(d[filterName])) {\n matched = false;\n continue;\n }\n }\n return matched;\n });\n // save state\n if (this.options.saveState) this.maptable.saveState('filters', this.exportFilters());\n }\n\n refresh() {\n // update dropdown\n const filterNameSelects = this.node.querySelectorAll('.mt-filter-name');\n for (let i = 0; i < filterNameSelects.length; i += 1) {\n const filterNameSelect = filterNameSelects[i];\n const filterName = filterNameSelect.value;\n const possibleFilters = this.getPossibleFilters(filterName);\n filterNameSelect.innerHTML = '';\n utils.appendOptions(\n filterNameSelect,\n possibleFilters.map((f) => ({ text: f.title, value: f.key })),\n );\n filterNameSelect.value = filterName;\n }\n\n // Hide the first \"And\"\n if (this.node.querySelectorAll('.mt-filters-and').length > 0) {\n this.node.querySelectorAll('.mt-filters-and')[0].style.visibility = 'hidden';\n }\n\n // Check if we reached the maximum of allowed filters\n const disableNewFilter = (!this.getPossibleFilters().length);\n this.node.querySelector('#mt-filters-new').style.visibility = disableNewFilter\n ? 'hidden' : 'visible';\n }\n\n toggle() {\n if (this.container.style.display === 'none') {\n this.container.style.display = 'block';\n if (this.criteria.length === 0) {\n this.add();\n }\n } else {\n this.container.style.display = 'none';\n }\n }\n}\n","import utils from '../utils';\n\nexport default class Table {\n /**\n * Table componenet constructor\n * @param maptable: Maptable main Object\n * @param options: options communicated to the table\n * @returns {string|*}\n */\n constructor(maptable, options) {\n this.maptable = maptable;\n this.options = options;\n\n if (this.options.defaultSorting) {\n if (Array.isArray(this.options.defaultSorting) && this.options.defaultSorting.length === 2) {\n this.sorting = this.options.defaultSorting;\n } else {\n this.sorting = [this.options.defaultSorting];\n }\n this.sorting.forEach((s) => {\n if (!s.mode) s.mode = 'asc';\n });\n } else {\n this.sorting = [\n {\n key: Object.keys(this.maptable.data[0])[0],\n mode: 'asc',\n },\n ];\n }\n\n this.initialSorting = this.sorting.map((s) => `${s.key},${s.mode}`).join(';');\n this.isSorting = false;\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n\n this.node = this.container.querySelector('#mt-table');\n\n if (!this.node) {\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-table');\n this.maptable.node.appendChild(this.node);\n }\n\n this.node = d3.select(this.node)\n .append('table')\n .attr('class', this.options.className);\n\n this.header = this.node.append('thead');\n\n this.body = this.node.append('tbody');\n\n if (this.options.show) {\n const arrayDiff = this.options.show\n .filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0);\n if (arrayDiff.length > 0) {\n throw new Error(`MapTable: invalid columns \"${arrayDiff.join(', ')}\"`);\n }\n this.activeColumns = this.options.show;\n } else {\n this.activeColumns = Object.keys(this.maptable.columnDetails);\n }\n\n this.header.selectAll('tr')\n .data([1])\n .enter()\n .append('tr')\n .selectAll('th')\n .data(this.activeColumns\n .map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k])))\n .enter()\n .append('th')\n .attr('class', (d) => {\n let output = (d.sorting) ? 'mt-table-sortable' : '';\n output += (d.nowrap) ? ' nowrap' : '';\n return output;\n })\n .attr('data-key', (d) => utils.sanitizeKey(d.key))\n .attr('onselectstart', 'return false;')\n .attr('unselectable', 'on')\n .attr('style', (d) => ((d.nowrap) ? 'white-space:nowrap;' : ''))\n .on('click', (d) => {\n if (this.isSorting) return;\n this.isSorting = true;\n if (d.sorting) {\n this.sortColumn(d.key);\n }\n this.isSorting = false;\n })\n .text((d) => d.title)\n .attr('id', (d) => `column_header_${utils.sanitizeKey(d.key)}`);\n\n // render is triggered by MapTable\n // this.render();\n }\n\n /**\n * Restore state from the url hash\n */\n restoreState(sortingRaw) {\n if (!sortingRaw) return;\n const sortingList = sortingRaw.split(';');\n const defaultSorting = [];\n sortingList.forEach((s) => {\n const sortingData = s.split(',');\n defaultSorting.push({\n key: sortingData[0],\n mode: sortingData[1] || 'asc',\n });\n });\n this.sorting = defaultSorting;\n }\n\n /**\n * Save state into the url hash\n */\n saveState() {\n const encodedSorting = this.sorting.map((s) => `${s.key},${s.mode}`).join(';');\n if (encodedSorting !== this.initialSorting) {\n this.maptable.saveState('sort', encodedSorting);\n }\n }\n\n render() {\n // Apply Sort\n this.applySort();\n\n let tableData = this.maptable.data;\n if (this.options.distinctBy) {\n tableData = d3.nest()\n .key((d) => d[this.options.distinctBy])\n .entries(this.maptable.data)\n .map((g) => g.values[0]);\n }\n\n // Enter\n this.body.selectAll('tr')\n .data(tableData)\n .enter()\n .append('tr');\n\n // Exit\n this.body.selectAll('tr')\n .data(tableData)\n .exit()\n .remove();\n\n // Update\n const uniqueCollapsedRows = [];\n this.body.selectAll('tr')\n .data(tableData)\n .attr('class', (row) => {\n if (this.options.rowClassName) {\n return `line ${this.options.rowClassName(row)}`;\n }\n return 'line';\n })\n .html((row) => {\n let tds = '';\n this.activeColumns.forEach((columnKey) => {\n const column = this.maptable.columnDetails[columnKey];\n tds += ' {\n this.container.querySelector(`#column_header_${utils.sanitizeKey(column.key)}`)\n .setAttribute('class', `mt-table-sortable sort_${column.mode}`);\n });\n this.maptable.data = this.maptable.data.sort((a, b) => {\n let compareBool = false;\n this.sorting.forEach((column) => {\n const d3SortMode = (column.mode === 'asc') ? d3.ascending : d3.descending;\n const columnDetails = this.maptable.columnDetails[column.key];\n let el1 = a[column.key];\n let el2 = b[column.key];\n if (columnDetails.dataParse) {\n el1 = columnDetails.dataParse.bind(this.maptable)(el1);\n el2 = columnDetails.dataParse.bind(this.maptable)(el2);\n } else if (columnDetails.virtual) {\n el2 = columnDetails.virtual.bind(this.maptable)(a);\n el2 = columnDetails.virtual.bind(this.maptable)(b);\n } else if (columnDetails.filterType === 'compare') {\n el1 = Number(el1);\n el2 = Number(el2);\n }\n\n if (typeof el1 === 'string' && typeof el2 === 'string') {\n el1 = el1.toLowerCase();\n el2 = el2.toLowerCase();\n }\n compareBool = compareBool || d3SortMode(el1, el2);\n });\n return compareBool;\n });\n }\n\n /**\n * Sort Table by a column key\n * @param columnKey: String - column key\n */\n sortColumn(key) {\n const sortIndex = this.sorting.map((d) => d.key).indexOf(key);\n const sortValue = { key };\n if (sortIndex === -1) {\n sortValue.mode = 'desc';\n if (d3.event && d3.event.shiftKey) {\n this.sorting[1] = sortValue;\n } else {\n this.sorting = [sortValue];\n }\n } else {\n if (this.sorting[sortIndex].mode === 'asc') {\n this.sorting[sortIndex].mode = 'desc';\n } else {\n this.sorting[sortIndex].mode = 'asc';\n // this.sorting.splice(sortIndex, 1); // to disable sorting\n }\n if (!d3.event.shiftKey) {\n this.sorting = [this.sorting[sortIndex]];\n }\n }\n\n this.saveState();\n this.render();\n }\n}\n","import utils from './utils';\n\nimport GeoMap from './components/GeoMap';\nimport Filters from './components/Filters';\nimport Table from './components/Table';\n\nexport default class MapTable {\n constructor(target, options) {\n this.options = options;\n\n this.state = {};\n this.saveStateTimeout = {};\n this.removeStateTimeout = null;\n\n this.node = document.querySelector(target);\n this.node.setAttribute('style', 'position:relative;');\n\n if (this.options.data.type === 'json') {\n d3.json(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'csv') {\n d3.csv(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'tsv') {\n d3.tsv(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'jsonData') {\n this.loadData(null, JSON.parse(this.options.data.value));\n } else if (this.options.data.type === 'csvData') {\n this.loadData(null, d3.csv.parse(this.options.data.value));\n } else if (this.options.data.type === 'tsvData') {\n this.loadData(null, d3.tsv.parse(this.options.data.value));\n } else if (this.options.data.type === 'data') {\n this.loadData(null, this.options.data.value);\n }\n\n if (this.options.map && this.options.map.heatmap) {\n delete this.options.map.countries;\n }\n }\n\n /**\n * Callback used when we pull the dataset\n * @param err: Error - error data if it happened\n * @param data: Object - dataset object\n */\n loadData(err, data) {\n if (err) {\n throw err;\n }\n this.rawData = data;\n\n if (this.options.data.preFilter) {\n this.rawData = this.rawData.filter(this.options.data.preFilter);\n }\n\n this.setColumnDetails();\n this.data = this.rawData.slice(); // we clone data, so that we can filter it\n // Map\n if (this.options.map) {\n // Map wrapper\n const mapWrapper = document.createElement('div');\n mapWrapper.setAttribute('class', 'mt-map-container');\n const isIE = (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0);\n if (this.options.map.heatmap && isIE) {\n mapWrapper.innerHTML = '
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
';\n this.node.insertBefore(mapWrapper, this.node.firstChild);\n mapWrapper.querySelector('.mt-loading').style.display = 'block';\n this.options.map = false;\n this.buildComponenents();\n return;\n }\n mapWrapper.innerHTML = '
Loading...
';\n this.node.insertBefore(mapWrapper, this.node.firstChild);\n mapWrapper.querySelector('.mt-loading').style.display = 'block';\n if (this.options.map.pathData) {\n this.loadMapData(null, JSON.parse(this.options.map.pathData), mapWrapper);\n } else if (this.options.map.path) {\n d3.json(this.options.map.path, (errGeoMap, jsonWorld) => {\n this.loadMapData(errGeoMap, jsonWorld, mapWrapper);\n });\n } else {\n throw new Error('missing map path|pathData');\n }\n } else {\n this.buildComponenents();\n }\n }\n\n loadMapData(errGeoMap, jsonWorld, mapWrapper) {\n if (errGeoMap) {\n throw errGeoMap;\n }\n this.map = new GeoMap(this, this.options.map, jsonWorld);\n\n mapWrapper.querySelector('.mt-loading').style.display = 'none';\n\n this.buildComponenents();\n }\n\n buildComponenents() {\n // Filters\n if (this.options.filters) {\n this.filters = new Filters(this, this.options.filters);\n }\n\n // Table\n if (this.options.table) {\n this.table = new Table(this, this.options.table);\n }\n\n // Restore state\n this.restoreState();\n window.addEventListener('hashchange', () => {\n this.restoreState();\n });\n\n // Render\n this.render();\n }\n\n /**\n * Load state from url\n * @param stateName: name of the state (either filters or zoom)\n * @param isJson: do we need to decode a json from the state?\n * @return loaded state\n */\n loadState(stateName, isJson) {\n // JSON state\n if (isJson) {\n const v = this.parseState(stateName);\n if (!v) return null;\n try {\n const parsedState = JSON.parse(v);\n this.state[stateName] = parsedState;\n } catch (e) {\n console.log(`Maptable: Invalid URL State for mt-${stateName} ${e.message}`);\n return null;\n }\n } else {\n const v = this.parseState(stateName);\n if (v) this.state[stateName] = v;\n }\n return this.state[stateName];\n }\n\n /**\n * Restore state for filters or/and map zooming and/or sorting\n */\n restoreState() {\n if (this.map) {\n this.loadState('zoom', true);\n this.map.restoreState(this.state.zoom);\n }\n\n if (this.filters) {\n this.loadState('filters', true);\n this.filters.restoreState(this.state.filters);\n }\n\n if (this.table) {\n this.loadState('sort', false);\n this.table.restoreState(this.state.sort);\n }\n }\n\n /**\n * Extract state from the url\n * @param stateName: name of the state (either filters or zoom)\n */\n parseState(stateName) {\n const params = document.location.href.replace(/%21mt/g, '!mt').split(`!mt-${stateName}=`);\n return (params[1]) ? decodeURIComponent(params[1].split('!mt')[0]) : null;\n }\n\n /**\n * Remove state\n * @param stateName: name of the state (either filters or zoom)\n */\n removeState(stateName) {\n window.clearTimeout(this.saveStateTimeout[stateName]);\n delete this.state[stateName];\n this.updateState();\n }\n\n /**\n * Save the state in this.state\n * @param stateName: name of the state (either filters or zoom)\n * @param stateData: object, contain state information\n */\n saveState(stateName, stateData) {\n window.clearTimeout(this.saveStateTimeout[stateName]);\n this.saveStateTimeout[stateName] = window.setTimeout(() => {\n this.state[stateName] = stateData;\n this.updateState();\n }, 200);\n }\n\n /**\n * Update state into the URL hash\n */\n updateState() {\n const newUrl = document.location.href.split('#')[0];\n let stateHash = '';\n Object.keys(this.state).forEach((k) => {\n if (!this.state[k]) return;\n let stateValue = this.state[k];\n if (typeof (this.state[k]) === 'object') {\n if (!Object.keys(this.state[k]).length) return;\n stateValue = JSON.stringify(this.state[k]);\n }\n stateHash += `!mt-${k}=${encodeURIComponent(stateValue)}`;\n });\n if (stateHash !== '') stateHash = `#${stateHash}`;\n if (document.location.href !== `${newUrl}${stateHash}`) {\n window.history.pushState(null, null, `${newUrl}${stateHash}`);\n }\n }\n\n render() {\n if (this.filters) {\n this.filters.filterData();\n this.filters.refresh();\n }\n\n if (this.map) {\n this.map.render();\n // On complete\n if (!this.firstExecution\n && this.options.map.onComplete\n && this.options.map.onComplete.constructor === Function\n ) {\n this.options.map.onComplete.bind(this)();\n }\n }\n\n if (this.table) {\n this.table.render();\n // On complete\n if (!this.firstExecution\n && this.options.table.onComplete\n && this.options.table.onComplete.constructor === Function\n ) {\n this.options.table.onComplete.bind(this)();\n }\n }\n\n // On complete\n if (!this.firstExecution\n && this.options.onComplete\n && this.options.onComplete.constructor === Function\n ) {\n this.options.onComplete.bind(this)();\n }\n this.firstExecution = true;\n }\n\n setColumnDetails() {\n const that = this;\n if (that.rawData.length === 0) {\n return;\n }\n const defaultColumns = {};\n\n Object.keys(that.rawData[0]).forEach((k) => {\n const patternNumber = /^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$/;\n const isNumber = (patternNumber.test(that.rawData[0][k]));\n defaultColumns[k] = {\n title: utils.keyToTile(k),\n filterMethod: (isNumber) ? 'compare' : 'field',\n filterInputType: (isNumber) ? 'number' : 'text',\n sorting: true,\n };\n if (isNumber) {\n defaultColumns[k].dataParse = (val) => parseFloat(val);\n }\n });\n that.columnDetails = utils.extendRecursive(defaultColumns, this.options.columns);\n\n // add isVirtual to columns details\n Object.keys(that.columnDetails).forEach((k) => {\n that.columnDetails[k].isVirtual = (typeof (that.columnDetails[k].virtual) === 'function');\n });\n }\n}\n","/* eslint no-unused-vars: 0 */\nimport utils from './utils';\nimport defaultOptions from './defaultOptions';\nimport MapTable from './maptable';\n\nd3.maptable = function (target) {\n let maptableObject;\n const maptable = {};\n const options = {\n target,\n columns: {},\n data: {},\n map: null,\n filters: null,\n table: null,\n };\n\n maptable.map = function (mapOptions = {}) {\n if (!topojson) {\n throw new Error('Maptable requires topojson.js');\n }\n if (typeof (mapOptions.path) !== 'string' && typeof (mapOptions.pathData) !== 'string') {\n throw new Error('MapTable: map not provided');\n }\n options.map = mapOptions;\n return maptable;\n };\n\n maptable.data = function (data) {\n options.data.type = 'data';\n options.data.value = data;\n return maptable;\n };\n\n maptable.json = function (jsonPath, preFilter) {\n options.data.type = 'json';\n options.data.path = jsonPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.jsonData = function (jsonData) {\n options.data.type = 'jsonData';\n options.data.value = jsonData;\n return maptable;\n };\n\n maptable.csv = function (csvPath, preFilter) {\n options.data.type = 'csv';\n options.data.path = csvPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.csvData = function (csvData) {\n options.data.type = 'csvData';\n options.data.value = csvData;\n return maptable;\n };\n\n maptable.tsv = function (tsvPath, preFilter) {\n options.data.type = 'tsv';\n options.data.path = tsvPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.tsvData = function (tsvData) {\n options.data.type = 'tsvData';\n options.data.value = tsvData;\n return maptable;\n };\n\n maptable.filters = function (filtersOptions = {}) {\n options.filters = filtersOptions;\n return maptable;\n };\n\n maptable.table = function (tableOptions = {}) {\n options.table = tableOptions;\n return maptable;\n };\n\n maptable.columns = function (columns = {}) {\n options.columns = columns;\n return maptable;\n };\n\n maptable.render = function (onComplete) {\n if (typeof (target) !== 'string' || !document.querySelector(target)) {\n throw new Error('MapTable: target not found');\n }\n\n if (!options.data || !options.data.type) {\n throw new Error('MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData');\n }\n\n if (options.map && !options.map.heatmap) options.map.heatmap = null;\n\n if (options.map && options.map.markers === false) options.map.markers = null;\n\n if (options.map && options.map.countries === false) options.map.countries = null;\n\n if (!options.filters) options.filters = null;\n options.onComplete = onComplete;\n\n const customOptions = utils.extendRecursive(defaultOptions, options);\n\n if (!options.map.markers) delete customOptions.map.markers;\n if (!options.map.heatmap) delete customOptions.map.heatmap;\n if (!options.map.title) delete customOptions.map.title;\n if (!options.map.timezones) delete customOptions.map.timezones;\n if (!options.map.night) delete customOptions.map.night;\n if (!options.filters) delete customOptions.filters;\n if (!options.table) delete customOptions.table;\n\n maptableObject = new MapTable(target, customOptions);\n\n // public functions\n return {\n render: () => maptableObject.render(),\n loadState: (stateName, isJson) => maptableObject.loadState(stateName, isJson),\n removeState: (stateName) => maptableObject.removeState(stateName),\n saveState: (stateName, stateData) => maptableObject.saveState(stateName, stateData),\n setTitleContent: (title) => {\n maptableObject.options.map.title.content = () => title;\n },\n setData: (data) => {\n maptableObject.options.data.type = 'data';\n maptableObject.options.data.value = data;\n maptableObject.options.rawData = data;\n maptableObject.rawData = data;\n maptableObject.data = data;\n if (maptableObject.map) {\n maptableObject.map.enrichData();\n }\n },\n setNightDate: (date) => {\n maptableObject.options.map.night.date = date;\n },\n setTimezonesDate: (date) => {\n maptableObject.options.map.timezones.date = date;\n },\n getMapWidth: () => maptableObject.map.getWidth(),\n getMapHeight: () => maptableObject.map.getHeight(),\n };\n };\n return maptable;\n};\n\nif (!d3) {\n throw new Error('Maptable requires d3.js');\n}\n\nexport default d3.maptable;\n"],"names":["appendOptions","select","options","defaultValue","forEach","f","option","document","createElement","setAttribute","value","innerText","text","appendChild","rangeToBool","el1","range","el2","parseInt","extendRecursive","dst","src","args","splice","call","arguments","toString","length","Object","keys","p","keyToTile","k","upperK","charAt","toUpperCase","slice","replace","sanitizeKey","toLowerCase","toNumber","str","resStr","Number","quantile","array","percentile","sort","a","b","index","result","Math","floor","i","fraction","uniqueValues","arr","l","indexOf","push","formatDate","d","zone","newDate","Date","getTime","toISOString","split","substr","isBlank","undefined","map","longitudeKey","latitudeKey","countryIdentifierKey","countryIdentifierType","zoom","saveState","exportSvg","exportSvgClient","ratioFromWidth","scaleHeight","scaleZoom","fitContentMargin","autoFitContent","tooltipClassName","countries","legend","attr","fill","stroke","heatmap","mask","weightByAttribute","weightByAttributeScale","circles","min","max","step","color","colorStrength","blur","borders","opacity","markers","r","title","fontSize","fontFamily","filters","table","className","collapseRowsBy","Legend","legendWidth","node","svg","append","getWidth","getHeight","buildIndice","domain","legendGradient","minNegative","maxNegative","midPercentNegative","round","midPercentPositive","indice","style","selectAll","toLocaleString","buildScale","val","isNaN","maxValue","minValue","positionDelta","position","width","height","padding","console","warn","window","btoa","buildWatermark","d3","xhr","res","mapWatermarkDelta","mime","x","y","dataUri","responseText","pos","mul_table","shg_table","processImage","img","canvas","radius","blurAlphaChannel","getElementById","HTMLImageElement","w","naturalWidth","h","naturalHeight","HTMLCanvasElement","context","getContext","clearRect","drawImage","processCanvasRGBA","processCanvasRGB","getImageDataFromCanvas","top_x","top_y","imageData","getImageData","e","Error","processImageDataRGBA","putImageData","pixels","data","yp","yi","yw","r_sum","g_sum","b_sum","a_sum","r_out_sum","g_out_sum","b_out_sum","a_out_sum","r_in_sum","g_in_sum","b_in_sum","a_in_sum","pr","pg","pb","pa","rbs","div","w4","widthMinus1","heightMinus1","radiusPlus1","sumFactor","stackStart","BlurStack","stack","next","stackEnd","stackIn","stackOut","mul_sum","shg_sum","g","processImageDataRGB","image","canvasRGBA","canvasRGB","imageDataRGBA","imageDataRGB","π","PI","radians","degrees","solarGeometricMeanAnomaly","centuries","solarGeometricMeanLongitude","solarEquationOfCenter","m","sin","solarTrueLongitude","solarApparentLongitude","meanObliquityOfEcliptic","obliquityCorrection","cos","solarDeclination","asin","eccentricityEarthOrbit","equationOfTime","tan","antipode","solarPosition","time","UTC","longitude","day","utc","GeoMap","maptable","jsonWorld","scale","transX","transY","containerSelector","target","container","querySelector","mapWrapper","existingMap","parentNode","insertBefore","removeChild","projection","geo","equirectangular","translate","rotate","precision","path","enrichData","zoomListener","behavior","scaleExtent","on","rescale","bind","tooltipMarkersNode","tooltipCountriesNode","layerGlobal","layerDefs","html","timezones","layerTimezones","layerCountries","night","layerNight","layerHeatmap","layerMarkers","watermark","Watermark","buildTitle","addExportSvgCapability","addEventListener","loadGeometries","rawData","parseFloat","latitude","coord","pow","offsetWidth","deltaHeight","filterCountries","objects","geometries","filter","buildCountries","buildHeatmap","buildNight","pathData","buildTimezone","lands","topojson","merge","disableMask","maskHeatmap","datum","imgHeatmap","mesh","bordersHeatmap","enter","circle","angle","maskNight","nightPath","cssBlur","userDate","date","startOfDay","getUTCFullYear","getUTCMonth","getUTCDate","solarPositionDated","origin","nightPathRight","nightPathLeft","disableSun","sunCoords","sunCircleRight","sunCircleXRight","sunCircleLeft","sunCircleXLeft","loadTimezone","JSON","parse","json","errGeoMap","jsonTimezones","err","dataTimezones","feature","features","maskTimezone","properties","places","insert","stringify","timezoneTexts","timezoneTextsUnique","Map","item","values","layerTimezonesText","scaleFontSize","utils","heatmapDataset","opts","lengthDataset","maxOpacityScale","linear","centralCircleOpacity","dataExtents","extent","userScale","log","canvasHeatmap","ctx","globalCompositeOperation","datumScale","getDatumScale","magnitudeScale","getMagnitudeScale","colorScale","beginPath","rect","fillStyle","closePath","colorMultiplier","aa","point","scaleOpacityDatum","StackBlur","dataUrl","toDataURL","remove","getHeatmapData","dataCountries","legendCountry","shouldRenderLegend","aggregate","allMtMapCountry","allMtMapMarker","dataByCountry","key","has","set","get","geoDatum","matchedCountry","rollupValue","setAttrValues","countryItem","getAllMtMapCountry","each","selection","attrKey","attrValue","scaleDomain","attrProperties","updateExtents","indiceChange","NaN","tooltip","activateTooltip","endOfDay","totalMilliseconds","currentTime","relativeTranslateX","transform","querySelectorAll","currentDate","Array","from","timezoneText","textContent","__data__","defaultGroupBy","dataMarkers","nest","entries","markerItem","markerObject","customTag","markerClassName","exit","transition","attrX","attrY","attrXDelta","attrYDelta","markerUpdate","getAllMtMapMarker","hor","ver","ratio","deltaMarker","currentWidth","currentHeight","realHeight","realWidth","diffMarginWidth","diffMarginHeight","titleContainer","bgColor","source","originalTranslation","newTx","newTy","encodedTranslation","defaultZoom","decodeTranslation","event","encodeTranslation","exportedData","removeState","self","maxTransX","maxTransY","minTransX","minTransY","scaleAttributes","firstExecution","dataset","mode","scaleToUse","rollup","groupedData","reduce","c","validData","groupedValues","exponent","sqrt","aggregatedValue","columnDetails","formatted","cellContent","positiveRanks","concat","v","negativeRanks","ranks","newValue","useNegative","scaleFunction","scaleNegativeFunction","copy","scaledValue","empty","originalValueRaw","originalValue","updateMarkers","updateCountries","updateNight","updateTimezones","updateTitle","updateHeatmap","fitContent","onRender","constructor","Function","content","showing","total","inlineFilters","getDescription","innerHTML","tooltipNode","tooltipContent","isCountry","mouseLeft","mouseTop","tooltipDelta","mapRect","getBoundingClientRect","mousePosition","mouse","left","top","targetRect","svgXml","XMLSerializer","serializeToString","saveAs","blob","Blob","type","form","submit","exportNode","exportButton","exportForm","Filters","criteria","show","arrayDiff","join","activeColumns","filtersHeaderNode","filtersResetNode","display","marginLeft","reset","filtersTitleNode","createTextNode","filtersBodyNode","filtersElementsNode","filtersNewNode","add","evt","preventDefault","possibleFilters","getPossibleFilters","filterName","create","replaceNode","rowNode","buildRow","replaceChild","render","toggle","filterIndex","rowNodes","output","filtersChildren","childNodes","element","filterOutput","filterMethod","filterRangeSelect","filterValueMin","filterValueMax","filterValue","criterion","row","decodeURIComponent","defaultCriteria","setFilters","outputArray","line","selectedIndex","separatorWord","that","minusButton","filterSeparator","filterNameSelect","oldFilterName","getAttribute","newFilterName","refresh","filterVerb","filterRange","handleRangeChange","filterInput","filterInputType","filterValueAnd","filterSelect","sortKeys","ascending","except","isVirtual","matched","fmt","dataParse","exportFilters","filterNameSelects","visibility","disableNewFilter","Table","defaultSorting","isArray","sorting","s","initialSorting","isSorting","header","body","nowrap","sortColumn","sortingRaw","sortingList","sortingData","encodedSorting","applySort","tableData","distinctBy","uniqueCollapsedRows","rowClassName","tds","columnKey","column","virtual","sortableColums","compareBool","d3SortMode","descending","filterType","sortIndex","sortValue","shiftKey","MapTable","state","saveStateTimeout","removeStateTimeout","loadData","csv","tsv","preFilter","setColumnDetails","isIE","navigator","userAgent","appVersion","firstChild","buildComponenents","loadMapData","restoreState","stateName","isJson","parseState","parsedState","message","loadState","params","location","href","clearTimeout","updateState","stateData","setTimeout","newUrl","stateHash","stateValue","encodeURIComponent","history","pushState","filterData","onComplete","defaultColumns","patternNumber","isNumber","test","columns","maptableObject","mapOptions","jsonPath","jsonData","csvPath","csvData","tsvPath","tsvData","filtersOptions","tableOptions","customOptions","defaultOptions","setTitleContent","setData","setNightDate","setTimezonesDate","getMapWidth","getMapHeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,SAASA,aAAT,CAAuBC,MAAvB,EAA+BC,OAA/B,EAAwCC,YAAxC,EAAsD;AACpDD,IAAAA,UAAQE,OAAR,CAAgB,UAACC,CAAD,EAAO;AACrB,IAAA;AACA,IAAA,QAAMC,SAASC,SAASC,aAAT,CAAuB,QAAvB,CAAf;AACAF,IAAAA,WAAOG,YAAP,CAAoB,OAApB,EAA6BJ,EAAEK,KAA/B;AACAJ,IAAAA,WAAOK,SAAP,GAAmBN,EAAEO,IAArB;AACAX,IAAAA,WAAOY,WAAP,CAAmBP,MAAnB;AACD,IAAA,GAND;AAOAL,IAAAA,SAAOS,KAAP,GAAeP,YAAf;AACD,IAAA;;AAED,IAAA,SAASW,WAAT,CAAqBC,GAArB,EAA0BC,KAA1B,EAAiCC,GAAjC,EAAsC;AACpC,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,MAAsBG,SAASD,GAAT,EAAc,EAAd,CAA7B;AACD,IAAA;AACD,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,MAAsBG,SAASD,GAAT,EAAc,EAAd,CAAtB,IAA2CF,QAAQ,EAAnD,IAAyDE,QAAQ,EAAxE;AACD,IAAA;AACD,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,IAAoBG,SAASD,GAAT,EAAc,EAAd,CAApB,IAAyCF,QAAQ,EAAjD,IAAuDE,QAAQ,EAAtE;AACD,IAAA;AACD,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,IAAoBG,SAASD,GAAT,EAAc,EAAd,CAApB,IAA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,IAAA,OAjBI;AAkBL+b,IAAAA,oBAAc,sBAACtY,IAAD,EAAU;AACtBwX,IAAAA,uBAAevsB,OAAf,CAAuBsE,GAAvB,CAA2B+N,KAA3B,CAAiC0C,IAAjC,GAAwCA,IAAxC;AACD,IAAA,OApBI;AAqBLuY,IAAAA,wBAAkB,0BAACvY,IAAD,EAAU;AAC1BwX,IAAAA,uBAAevsB,OAAf,CAAuBsE,GAAvB,CAA2B4N,SAA3B,CAAqC6C,IAArC,GAA4CA,IAA5C;AACD,IAAA,OAvBI;AAwBLwY,IAAAA,mBAAa;AAAA,IAAA,eAAMhB,eAAejoB,GAAf,CAAmB+C,QAAnB,EAAN;AAAA,IAAA,OAxBR;AAyBLmmB,IAAAA,oBAAc;AAAA,IAAA,eAAMjB,eAAejoB,GAAf,CAAmBgD,SAAnB,EAAN;AAAA,IAAA;AAzBT,IAAA,KAAP;AA2BD,IAAA,GA1DD;AA2DA,IAAA,SAAO2I,QAAP;AACD,IAAA,CA/ID;;AAiJA,IAAA,IAAI,CAAC/G,EAAL,EAAS;AACP,IAAA,QAAM,IAAIoC,KAAJ,CAAU,yBAAV,CAAN;AACD,IAAA;;AAED,gBAAepC,GAAG+G,QAAlB;;;;"} \ No newline at end of file +{"version":3,"file":"maptable.js","sources":["../src/utils.js","../src/defaultOptions.js","../src/components/Legend.js","../src/components/Watermark.js","../src/components/StackBlur.js","../src/components/solarPosition.js","../src/components/GeoMap.js","../src/components/Filters.js","../src/components/Table.js","../src/maptable.js","../src/index.js"],"sourcesContent":["function appendOptions(select, options, defaultValue) {\n options.forEach((f) => {\n // Filter select\n const option = document.createElement('option');\n option.setAttribute('value', f.value);\n option.innerText = f.text;\n select.appendChild(option);\n });\n select.value = defaultValue;\n}\n\nfunction rangeToBool(el1, range, el2) {\n if (range === '=') {\n return parseInt(el1, 10) === parseInt(el2, 10);\n }\n if (range === '≠') {\n return parseInt(el1, 10) !== parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '>') {\n return parseInt(el1, 10) > parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '<') {\n return parseInt(el1, 10) < parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '≥') {\n return parseInt(el1, 10) >= parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n if (range === '≤') {\n return parseInt(el1, 10) <= parseInt(el2, 10) && el1 !== '' && el2 !== '';\n }\n return true;\n}\n\n/* eslint no-loop-func: 0 */\nfunction extendRecursive() {\n const dst = {};\n let src;\n const args = [].splice.call(arguments, 0);\n const toString = ({}).toString;\n\n while (args.length > 0) {\n src = args.splice(0, 1)[0];\n if (toString.call(src) === '[object Object]') {\n Object.keys(src).forEach((p) => {\n if (toString.call(src[p]) === '[object Object]') {\n dst[p] = extendRecursive(dst[p] || {}, src[p]);\n } else {\n dst[p] = src[p];\n }\n });\n }\n }\n return dst;\n}\n\nfunction keyToTile(k) {\n const upperK = k.charAt(0).toUpperCase() + k.slice(1);\n return upperK.replace(/_/g, ' ');\n}\n\nfunction sanitizeKey(k) {\n return k.toLowerCase()\n .replace(/ /g, '_')\n .replace(/\"/g, '')\n .replace(/'/g, '');\n}\n\nfunction toNumber(str) {\n if (!str || str === '') return null;\n const resStr = str.toString().replace(/[^0-9.]+|\\s+/gmi, '');\n if (resStr !== '') return Number(resStr);\n return null;\n}\n\nfunction quantile(array, percentile) {\n array.sort((a, b) => a - b);\n const index = (percentile / 100.0) * (array.length - 1);\n let result;\n if (Math.floor(index) === index) {\n result = array[index];\n } else {\n const i = Math.floor(index);\n const fraction = index - i;\n result = array[i] + (array[i + 1] - array[i]) * fraction;\n }\n return result;\n}\n\nfunction uniqueValues(arr) {\n if (!arr) return arr;\n const a = [];\n for (let i = 0, l = arr.length; i < l; i += 1) {\n if (a.indexOf(arr[i]) === -1 && arr[i] !== '') {\n a.push(arr[i]);\n }\n }\n return a;\n}\n\nconst formatDate = (d, zone) => {\n const newDate = new Date(d.getTime() + zone * 3600 * 1000);\n return newDate.toISOString().split('T')[1].substr(0, 5);\n};\n\nconst isBlank = (str) => (str === null || str === '' || str === undefined);\n\nexport default {\n rangeToBool,\n appendOptions,\n extendRecursive,\n sanitizeKey,\n toNumber,\n keyToTile,\n quantile,\n uniqueValues,\n formatDate,\n isBlank,\n};\n","export default {\n map: {\n longitudeKey: 'longitude',\n latitudeKey: 'latitude',\n countryIdentifierKey: 'country_code',\n countryIdentifierType: 'iso_a2',\n zoom: true,\n saveState: true,\n exportSvg: null,\n exportSvgClient: false,\n ratioFromWidth: 0.5,\n scaleHeight: 1.0,\n scaleZoom: [1, 10],\n fitContentMargin: 10,\n autoFitContent: false,\n tooltipClassName: 'popover bottom',\n countries: {\n legend: false,\n attr: {\n fill: '#FCFCFC',\n stroke: '#CCC',\n 'stroke-width': 0.5,\n },\n tooltipClassName: 'mt-map-tooltip popover bottom',\n },\n heatmap: {\n mask: true,\n weightByAttribute: null,\n weightByAttributeScale: 'linear',\n circles: {\n min: 1,\n max: 90,\n step: 4,\n color: '#FF0000',\n colorStrength: 1,\n blur: 4.0,\n },\n borders: {\n stroke: 1,\n opacity: 0.1,\n color: '#000',\n },\n },\n markers: {\n attr: {\n r: 4,\n fill: 'blue',\n stroke: '#CCC',\n 'stroke-width': 0.5,\n },\n tooltipClassName: 'mt-map-tooltip popover bottom',\n },\n title: {\n fontSize: 12,\n fontFamily: 'Helevetica, Arial, Sans-Serif',\n },\n },\n filters: {\n saveState: true,\n },\n table: {\n className: 'table table-striped table-bordered',\n collapseRowsBy: [],\n },\n};\n","export default class Legend {\n constructor(map) {\n this.legendWidth = 220;\n this.map = map;\n // Create Legend\n this.node = this.map.svg\n .append('g')\n .attr('id', 'mt-map-legend')\n .attr(\n 'transform',\n `translate(${(this.map.getWidth() - 350)}, ${(this.map.getHeight() - 60)})`,\n );\n\n this.buildIndice();\n }\n\n buildScale(domain) {\n const legendGradient = this.node\n .append('defs')\n .append('linearGradient')\n .attr('id', 'mt-map-legend-gradient')\n .attr('x1', '0%')\n .attr('y1', '0%')\n .attr('x2', '100%')\n .attr('y2', '0%');\n\n if (this.map.options.countries.attr.fill.minNegative\n && this.map.options.countries.attr.fill.maxNegative) {\n // todo - maybe watch for domain[0] < 0 && domain[1] < 0? fall back to normal min & max?\n const midPercentNegative = Math.round(((0 - domain[0]) / (domain[1] - domain[0])) * 100);\n const midPercentPositive = midPercentNegative + 1;\n\n legendGradient.append('stop')\n .attr('offset', '0%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.maxNegative};stop-opacity:1`);\n\n legendGradient.append('stop')\n .attr('offset', `${midPercentNegative}%`)\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.minNegative};stop-opacity:1`);\n legendGradient.append('stop')\n .attr('offset', `${midPercentPositive}%`)\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.min};stop-opacity:1`);\n } else {\n legendGradient.append('stop')\n .attr('offset', '0%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.min};stop-opacity:1`);\n }\n\n legendGradient.append('stop')\n .attr('offset', '100%')\n .attr('style', `stop-color:${this.map.options.countries.attr.fill.max};stop-opacity:1`);\n\n this.node.append('rect')\n .attr('x', 30)\n .attr('y', 0)\n .attr('width', this.legendWidth)\n .attr('height', 15)\n .attr('fill', 'url(#mt-map-legend-gradient)');\n }\n\n buildIndice() {\n const indice = this.node.append('g')\n .attr('id', 'mt-map-legend-indice')\n .attr('style', 'display:none')\n .attr('transform', 'translate(36,15)');\n\n indice.append('polygon')\n .attr('points', '4.5 0 9 5 0 5')\n .attr('fill', '#222222');\n\n indice.append('text')\n .attr('x', 4)\n .attr('y', 13)\n .attr('width', 10)\n .attr('height', 10)\n .attr('text-anchor', 'middle')\n .attr('font-family', 'Arial')\n .attr('font-size', '9')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '1')\n .attr('fill', '#222222')\n .text('0');\n\n this.node.append('text')\n .attr('id', 'mt-map-legend-min')\n .attr('x', 25)\n .attr('y', 13)\n .attr('width', 35)\n .attr('height', 15)\n .attr('text-anchor', 'end')\n .attr('font-family', 'Arial')\n .attr('font-size', '14')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '3')\n .attr('fill', '#222222')\n .text('0');\n\n this.node.append('text')\n .attr('id', 'mt-map-legend-max')\n .attr('y', 13)\n .attr('x', 255)\n .attr('width', 50)\n .attr('height', 15)\n .attr('text-anchor', 'start')\n .attr('font-family', 'Arial')\n .attr('font-size', '14')\n .attr('stroke', '#FFFFF')\n .attr('stroke-width', '3')\n .attr('fill', '#222222')\n .text('1');\n }\n\n updateExtents(domain) {\n this.node.select('#mt-map-legend').style('opacity', (domain[0] === domain[1]) ? 0 : 1);\n if (this.node.selectAll('mt-map-legend-min').length) {\n this.node.select('#mt-map-legend-min').text(Math.round(domain[0]).toLocaleString());\n this.node.select('#mt-map-legend-max').text(Math.round(domain[1]).toLocaleString());\n\n // pass in the min and max (domain) to the legend\n this.buildScale(domain);\n }\n }\n\n indiceChange(val) {\n if (Number.isNaN(val)) {\n this.node.select('#mt-map-legend-indice')\n .attr('style', 'display:none');\n } else {\n const maxValue = parseInt(this.node.select('#mt-map-legend-max').text(), 10);\n const minValue = parseInt(this.node.select('#mt-map-legend-min').text(), 10);\n const positionDelta = Math.round((0 - (minValue - val) / (maxValue - minValue))\n * this.legendWidth);\n this.node.select('#mt-map-legend-indice text').text(Math.round(val).toLocaleString());\n this.node.select('#mt-map-legend-indice')\n .attr('style', 'display:block')\n .attr('transform', `translate(${(36 + positionDelta)},15)`);\n }\n }\n}\n","export default class Legend {\n constructor(map, options) {\n this.map = map;\n this.src = options.src;\n this.position = options.position;\n this.width = parseInt(options.width, 10);\n this.height = parseInt(options.height, 10);\n this.padding = options.padding || 10;\n this.style = options.style;\n\n if (!options.src) {\n console.warn('Watermak src not found');\n return;\n }\n if (Number.isNaN(this.width)) {\n console.warn('Watermak width not found');\n return;\n }\n if (Number.isNaN(this.height)) {\n console.warn('Watermak height not found');\n return;\n }\n\n if (window.btoa) {\n this.buildWatermark();\n } else {\n console.warn('Watermark not rendered: btoa error');\n }\n }\n\n buildWatermark() {\n d3.xhr(this.src, (res) => {\n let mapWatermarkDelta = 0;\n if (this.map.options.title) mapWatermarkDelta = 30;\n let mime;\n let x;\n let y;\n if (this.src.indexOf('.svg') !== -1) {\n mime = 'image/svg+xml';\n } else if (this.src.indexOf('.jpg') !== -1 || this.src.indexOf('.jpeg') !== -1) {\n mime = 'image/jpeg';\n } else if (this.src.indexOf('.png') !== -1) {\n mime = 'image/png';\n } else {\n console.warn('invalid watermark mime type');\n return;\n }\n const dataUri = `data:${mime};base64,${window.btoa(res.responseText)}`;\n\n if (this.position) {\n const pos = this.position.split(' ');\n if (pos[0] === 'top') {\n y = this.padding;\n } else if (pos[0] === 'middle') {\n y = (this.map.getHeight() - this.height) / 2;\n } else if (pos[0] === 'bottom') {\n y = this.map.getHeight() - this.height - this.padding - mapWatermarkDelta;\n } else {\n console.warn('position should be (top|middle|bottom) (left|middle|right)');\n }\n\n if (pos[1] === 'left') {\n x = this.padding;\n } else if (pos[1] === 'middle') {\n x = (this.map.getWidth() - this.width) / 2;\n } else if (pos[1] === 'right') {\n x = this.map.getWidth() - this.width - this.padding;\n } else {\n console.warn('position should be (top|middle|bottom) (left|middle|right)');\n }\n }\n\n this.node = this.map.svg\n .append('image')\n .attr('xlink:href', dataUri)\n .attr('width', this.width)\n .attr('height', this.height);\n\n if (x && y) {\n this.node.attr('x', x).attr('y', y);\n }\n\n if (this.style) {\n this.node.attr('style', this.style);\n }\n });\n }\n}\n","/* eslint-disable */\n\n/*\n StackBlur - a fast almost Gaussian Blur For Canvas\n Version: 0.5\n Author: Mario Klingemann\n Contact: mario@quasimondo.com\n Website: http://www.quasimondo.com/StackBlurForCanvas\n Twitter: @quasimondo\n In case you find this class useful - especially in commercial projects -\n I am not totally unhappy for a small donation to my PayPal account\n mario@quasimondo.de\n Or support me on flattr:\n https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript\n Copyright (c) 2010 Mario Klingemann\n Permission is hereby granted, free of charge, to any person\n obtaining a copy of this software and associated documentation\n files (the \"Software\"), to deal in the Software without\n restriction, including without limitation the rights to use,\n copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the\n Software is furnished to do so, subject to the following\n conditions:\n The above copyright notice and this permission notice shall be\n included in all copies or substantial portions of the Software.\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n OTHER DEALINGS IN THE SOFTWARE.\n */\n\n\nvar mul_table = [\n 512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,\n 454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,\n 482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,\n 437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,\n 497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,\n 320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,\n 446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,\n 329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,\n 505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,\n 399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,\n 324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,\n 268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,\n 451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,\n 385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,\n 332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,\n 289,287,285,282,280,278,275,273,271,269,267,265,263,261,259];\n\n\nvar shg_table = [\n 9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,\n 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,\n 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,\n 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,\n 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,\n 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,\n 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,\n 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 ];\n\n\nfunction processImage(img, canvas, radius, blurAlphaChannel)\n{\n if (typeof(img) == 'string') {\n var img = document.getElementById(img);\n }\n else if (typeof HTMLImageElement !== 'undefined' && !img instanceof HTMLImageElement) {\n return;\n }\n var w = img.naturalWidth;\n var h = img.naturalHeight;\n\n if (typeof(canvas) == 'string') {\n var canvas = document.getElementById(canvas);\n }\n else if (typeof HTMLCanvasElement !== 'undefined' && !canvas instanceof HTMLCanvasElement) {\n return;\n }\n\n canvas.style.width = w + 'px';\n canvas.style.height = h + 'px';\n canvas.width = w;\n canvas.height = h;\n\n var context = canvas.getContext('2d');\n context.clearRect(0, 0, w, h);\n context.drawImage(img, 0, 0);\n\n if (Number.isNaN(radius) || radius < 1) return;\n\n if (blurAlphaChannel)\n processCanvasRGBA(canvas, 0, 0, w, h, radius);\n else\n processCanvasRGB(canvas, 0, 0, w, h, radius);\n}\n\nfunction getImageDataFromCanvas(canvas, top_x, top_y, width, height)\n{\n if (typeof(canvas) == 'string')\n var canvas = document.getElementById(canvas);\n else if (typeof HTMLCanvasElement !== 'undefined' && !canvas instanceof HTMLCanvasElement)\n return;\n\n var context = canvas.getContext('2d');\n var imageData;\n\n try {\n try {\n imageData = context.getImageData(top_x, top_y, width, height);\n } catch(e) {\n throw new Error(\"unable to access local image data: \" + e);\n return;\n }\n } catch(e) {\n throw new Error(\"unable to access image data: \" + e);\n }\n\n return imageData;\n}\n\nfunction processCanvasRGBA(canvas, top_x, top_y, width, height, radius)\n{\n if (Number.isNaN(radius) || radius < 1) return;\n radius |= 0;\n\n var imageData = getImageDataFromCanvas(canvas, top_x, top_y, width, height);\n\n imageData = processImageDataRGBA(imageData, top_x, top_y, width, height, radius);\n\n canvas.getContext('2d').putImageData(imageData, top_x, top_y);\n}\n\nfunction processImageDataRGBA(imageData, top_x, top_y, width, height, radius)\n{\n var pixels = imageData.data;\n\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum,\n r_out_sum, g_out_sum, b_out_sum, a_out_sum,\n r_in_sum, g_in_sum, b_in_sum, a_in_sum,\n pr, pg, pb, pa, rbs;\n\n var div = radius + radius + 1;\n var w4 = width << 2;\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n\n var stackStart = new BlurStack();\n var stack = stackStart;\n for (i = 1; i < div; i++)\n {\n stack = stack.next = new BlurStack();\n if (i == radiusPlus1) var stackEnd = stack;\n }\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n\n yw = yi = 0;\n\n var mul_sum = mul_table[radius];\n var shg_sum = shg_table[radius];\n\n for (y = 0; y < height; y++)\n {\n r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;\n\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi+3]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++)\n {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[p+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[p+2])) * rbs;\n a_sum += (stack.a = (pa = pixels[p+3])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n\n stack = stack.next;\n }\n\n\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++)\n {\n pixels[yi+3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa != 0)\n {\n pa = 255 / pa;\n pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi+1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[yi+2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n } else {\n pixels[yi] = pixels[yi+1] = pixels[yi+2] = 0;\n }\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n\n r_in_sum += (stackIn.r = pixels[p]);\n g_in_sum += (stackIn.g = pixels[p+1]);\n b_in_sum += (stackIn.b = pixels[p+2]);\n a_in_sum += (stackIn.a = pixels[p+3]);\n\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n a_sum += a_in_sum;\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n a_out_sum += (pa = stackOut.a);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n\n stackOut = stackOut.next;\n\n yi += 4;\n }\n yw += width;\n }\n\n\n for (x = 0; x < width; x++)\n {\n g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;\n\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n a_out_sum = radiusPlus1 * (pa = pixels[yi+3]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n a_sum += sumFactor * pa;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack.a = pa;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++)\n {\n yi = (yp + x) << 2;\n\n r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[yi+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[yi+2])) * rbs;\n a_sum += (stack.a = (pa = pixels[yi+3])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n a_in_sum += pa;\n\n stack = stack.next;\n\n if(i < heightMinus1)\n {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++)\n {\n p = yi << 2;\n pixels[p+3] = pa = (a_sum * mul_sum) >> shg_sum;\n if (pa > 0)\n {\n pa = 255 / pa;\n pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;\n pixels[p+1] = ((g_sum * mul_sum) >> shg_sum) * pa;\n pixels[p+2] = ((b_sum * mul_sum) >> shg_sum) * pa;\n } else {\n pixels[p] = pixels[p+1] = pixels[p+2] = 0;\n }\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n a_sum -= a_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n a_out_sum -= stackIn.a;\n\n p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;\n\n r_sum += (r_in_sum += (stackIn.r = pixels[p]));\n g_sum += (g_in_sum += (stackIn.g = pixels[p+1]));\n b_sum += (b_in_sum += (stackIn.b = pixels[p+2]));\n a_sum += (a_in_sum += (stackIn.a = pixels[p+3]));\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n a_out_sum += (pa = stackOut.a);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n a_in_sum -= pa;\n\n stackOut = stackOut.next;\n\n yi += width;\n }\n }\n return imageData;\n}\n\nfunction processCanvasRGB(canvas, top_x, top_y, width, height, radius)\n{\n if (Number.isNaN(radius) || radius < 1) return;\n radius |= 0;\n\n var imageData = getImageDataFromCanvas(canvas, top_x, top_y, width, height);\n imageData = processImageDataRGB(imageData, top_x, top_y, width, height, radius);\n\n canvas.getContext('2d').putImageData(imageData, top_x, top_y);\n}\n\nfunction processImageDataRGB(imageData, top_x, top_y, width, height, radius)\n{\n var pixels = imageData.data;\n\n var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum,\n r_out_sum, g_out_sum, b_out_sum,\n r_in_sum, g_in_sum, b_in_sum,\n pr, pg, pb, rbs;\n\n var div = radius + radius + 1;\n var w4 = width << 2;\n var widthMinus1 = width - 1;\n var heightMinus1 = height - 1;\n var radiusPlus1 = radius + 1;\n var sumFactor = radiusPlus1 * (radiusPlus1 + 1) / 2;\n\n var stackStart = new BlurStack();\n var stack = stackStart;\n for (i = 1; i < div; i++)\n {\n stack = stack.next = new BlurStack();\n if (i == radiusPlus1) var stackEnd = stack;\n }\n stack.next = stackStart;\n var stackIn = null;\n var stackOut = null;\n\n yw = yi = 0;\n\n var mul_sum = mul_table[radius];\n var shg_sum = shg_table[radius];\n\n for (y = 0; y < height; y++)\n {\n r_in_sum = g_in_sum = b_in_sum = r_sum = g_sum = b_sum = 0;\n\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n for (i = 1; i < radiusPlus1; i++)\n {\n p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);\n r_sum += (stack.r = (pr = pixels[p])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[p+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[p+2])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n\n stack = stack.next;\n }\n\n\n stackIn = stackStart;\n stackOut = stackEnd;\n for (x = 0; x < width; x++)\n {\n pixels[yi] = (r_sum * mul_sum) >> shg_sum;\n pixels[yi+1] = (g_sum * mul_sum) >> shg_sum;\n pixels[yi+2] = (b_sum * mul_sum) >> shg_sum;\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n\n p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;\n\n r_in_sum += (stackIn.r = pixels[p]);\n g_in_sum += (stackIn.g = pixels[p+1]);\n b_in_sum += (stackIn.b = pixels[p+2]);\n\n r_sum += r_in_sum;\n g_sum += g_in_sum;\n b_sum += b_in_sum;\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n\n stackOut = stackOut.next;\n\n yi += 4;\n }\n yw += width;\n }\n\n\n for (x = 0; x < width; x++)\n {\n g_in_sum = b_in_sum = r_in_sum = g_sum = b_sum = r_sum = 0;\n\n yi = x << 2;\n r_out_sum = radiusPlus1 * (pr = pixels[yi]);\n g_out_sum = radiusPlus1 * (pg = pixels[yi+1]);\n b_out_sum = radiusPlus1 * (pb = pixels[yi+2]);\n\n r_sum += sumFactor * pr;\n g_sum += sumFactor * pg;\n b_sum += sumFactor * pb;\n\n stack = stackStart;\n\n for (i = 0; i < radiusPlus1; i++)\n {\n stack.r = pr;\n stack.g = pg;\n stack.b = pb;\n stack = stack.next;\n }\n\n yp = width;\n\n for (i = 1; i <= radius; i++)\n {\n yi = (yp + x) << 2;\n\n r_sum += (stack.r = (pr = pixels[yi])) * (rbs = radiusPlus1 - i);\n g_sum += (stack.g = (pg = pixels[yi+1])) * rbs;\n b_sum += (stack.b = (pb = pixels[yi+2])) * rbs;\n\n r_in_sum += pr;\n g_in_sum += pg;\n b_in_sum += pb;\n\n stack = stack.next;\n\n if(i < heightMinus1)\n {\n yp += width;\n }\n }\n\n yi = x;\n stackIn = stackStart;\n stackOut = stackEnd;\n for (y = 0; y < height; y++)\n {\n p = yi << 2;\n pixels[p] = (r_sum * mul_sum) >> shg_sum;\n pixels[p+1] = (g_sum * mul_sum) >> shg_sum;\n pixels[p+2] = (b_sum * mul_sum) >> shg_sum;\n\n r_sum -= r_out_sum;\n g_sum -= g_out_sum;\n b_sum -= b_out_sum;\n\n r_out_sum -= stackIn.r;\n g_out_sum -= stackIn.g;\n b_out_sum -= stackIn.b;\n\n p = (x + (((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width)) << 2;\n\n r_sum += (r_in_sum += (stackIn.r = pixels[p]));\n g_sum += (g_in_sum += (stackIn.g = pixels[p+1]));\n b_sum += (b_in_sum += (stackIn.b = pixels[p+2]));\n\n stackIn = stackIn.next;\n\n r_out_sum += (pr = stackOut.r);\n g_out_sum += (pg = stackOut.g);\n b_out_sum += (pb = stackOut.b);\n\n r_in_sum -= pr;\n g_in_sum -= pg;\n b_in_sum -= pb;\n\n stackOut = stackOut.next;\n\n yi += width;\n }\n }\n\n return imageData;\n}\n\nfunction BlurStack()\n{\n this.r = 0;\n this.g = 0;\n this.b = 0;\n this.a = 0;\n this.next = null;\n}\n\nexport default {\n image: processImage,\n canvasRGBA: processCanvasRGBA,\n canvasRGB: processCanvasRGB,\n imageDataRGBA: processImageDataRGBA,\n imageDataRGB: processImageDataRGB\n};\n","/* eslint-disable max-len */\n// Equations based on NOAA’s Solar Calculator; all angles in radians.\n// http://www.esrl.noaa.gov/gmd/grad/solcalc/\n\nconst π = Math.PI;\nconst radians = π / 180;\nconst degrees = 180 / π;\n\nfunction solarGeometricMeanAnomaly(centuries) {\n return (357.52911 + centuries * (35999.05029 - 0.0001537 * centuries)) * radians;\n}\n\nfunction solarGeometricMeanLongitude(centuries) {\n const l = (280.46646 + centuries * (36000.76983 + centuries * 0.0003032)) % 360;\n return ((l < 0 ? l + 360 : l) / 180) * π;\n}\n\nfunction solarEquationOfCenter(centuries) {\n const m = solarGeometricMeanAnomaly(centuries);\n return (Math.sin(m) * (1.914602 - centuries * (0.004817 + 0.000014 * centuries))\n + Math.sin(m + m) * (0.019993 - 0.000101 * centuries)\n + Math.sin(m + m + m) * 0.000289) * radians;\n}\n\nfunction solarTrueLongitude(centuries) {\n return solarGeometricMeanLongitude(centuries) + solarEquationOfCenter(centuries);\n}\n\nfunction solarApparentLongitude(centuries) {\n return solarTrueLongitude(centuries) - (0.00569 + 0.00478 * Math.sin((125.04 - 1934.136 * centuries) * radians)) * radians;\n}\n\nfunction meanObliquityOfEcliptic(centuries) {\n return (23 + (26 + (21.448 - centuries * (46.8150 + centuries * (0.00059 - centuries * 0.001813))) / 60) / 60) * radians;\n}\n\nfunction obliquityCorrection(centuries) {\n return meanObliquityOfEcliptic(centuries) + 0.00256 * Math.cos((125.04 - 1934.136 * centuries) * radians) * radians;\n}\n\nfunction solarDeclination(centuries) {\n return Math.asin(\n Math.sin(obliquityCorrection(centuries)) * Math.sin(solarApparentLongitude(centuries)),\n );\n}\n\nfunction eccentricityEarthOrbit(centuries) {\n return 0.016708634 - centuries * (0.000042037 + 0.0000001267 * centuries);\n}\n\nfunction equationOfTime(centuries) {\n const e = eccentricityEarthOrbit(centuries);\n const m = solarGeometricMeanAnomaly(centuries);\n const l = solarGeometricMeanLongitude(centuries);\n let y = Math.tan(obliquityCorrection(centuries) / 2);\n y *= y;\n return y * Math.sin(2 * l)\n - 2 * e * Math.sin(m)\n + 4 * e * y * Math.sin(m) * Math.cos(2 * l)\n - 0.5 * y * y * Math.sin(4 * l)\n - 1.25 * e * e * Math.sin(2 * m);\n}\n\nexport function antipode(position) {\n return [position[0] + 180, -position[1]];\n}\n\nexport function solarPosition(time) {\n const centuries = (time - Date.UTC(2000, 0, 1, 12)) / 864e5 / 36525; // since J2000\n const longitude = ((d3.time.day.utc.floor(time) - time) / 864e5) * 360 - 180;\n return [\n longitude - equationOfTime(centuries) * degrees,\n solarDeclination(centuries) * degrees,\n ];\n}\n","import Legend from './Legend';\nimport Watermark from './Watermark';\nimport StackBlur from './StackBlur';\nimport utils from '../utils';\nimport { solarPosition, antipode } from './solarPosition';\n\n/**\n * Used the name GeoMap instead of Map to avoid collision with the native Map class of JS\n */\nexport default class GeoMap {\n /**\n * Geo Mapping class constructor that will initiate the map drawing\n * @param maptable: Maptable main Object\n * @param options: options communicated to map\n * @param jsonWorld: Object that contain TopoJSON dataset\n */\n constructor(maptable, options, jsonWorld) {\n this.maptable = maptable;\n this.scale = 1;\n this.transX = 0;\n this.transY = 0;\n\n this.options = options;\n\n this.jsonWorld = jsonWorld;\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n\n // Map wrapper\n const mapWrapper = this.container.querySelector('.mt-map-container');\n\n const existingMap = this.container.querySelector('#mt-map');\n if (existingMap) {\n // transform #mt-map to .mt-map-container'\n mapWrapper.parentNode.insertBefore(mapWrapper, existingMap);\n existingMap.parentNode.removeChild(existingMap);\n }\n\n // Map\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-map');\n mapWrapper.appendChild(this.node);\n\n this.svg = d3.select(this.node)\n .append('svg')\n .attr('id', 'mt-map-svg')\n .attr('xmlns', 'http://www.w3.org/2000/svg')\n .attr('xmlns:xlink', 'http://www.w3.org/1999/xlink')\n .attr('viewBox', `0 0 ${this.getWidth()} ${this.getHeight()}`)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight());\n\n this.projection = d3.geo.equirectangular()\n .translate([this.getWidth() / 2, this.getHeight() / (2 * this.options.scaleHeight)])\n .scale((this.getWidth() / 640) * 100)\n .rotate([-12, 0])\n .precision(0.1);\n\n this.path = d3.geo.path().projection(this.projection);\n\n this.enrichData();\n\n this.zoomListener = d3.behavior\n .zoom()\n .scaleExtent(this.options.scaleZoom)\n .on('zoom', this.rescale.bind(this));\n\n // Attach Zoom event to map\n if (this.options.zoom) {\n this.svg = this.svg.call(this.zoomListener.bind(this));\n }\n\n // Add tooltip\n if (this.options.markers) {\n this.tooltipMarkersNode = d3.select(this.node)\n .append('div')\n .attr('id', 'mt-map-markers-tooltip')\n .attr('class', `mt-map-tooltip ${this.options.markers.tooltipClassName}`)\n .style('display', 'none');\n }\n\n if (this.options.countries) {\n this.tooltipCountriesNode = d3.select(this.node)\n .append('div')\n .attr('id', 'mt-map-countries-tooltip')\n .attr('class', `mt-map-tooltip ${this.options.countries.tooltipClassName}`)\n .style('display', 'none');\n }\n\n this.layerGlobal = this.svg.append('g').attr('class', 'mt-map-global');\n this.layerDefs = this.svg.append('defs');\n this.layerDefs.html(`\n \n \n \n \n \n \n `);\n if (this.options.timezones) this.layerTimezones = this.layerGlobal.append('g').attr('class', 'mt-map-timezones');\n this.layerCountries = this.layerGlobal.append('g').attr('class', 'mt-map-countries');\n if (this.options.night) this.layerNight = this.layerGlobal.append('g').attr('class', 'mt-map-night');\n\n if (this.options.heatmap) this.layerHeatmap = this.layerGlobal.append('g').attr('class', 'mt-map-heatmap');\n this.layerMarkers = this.layerGlobal.append('g').attr('class', 'mt-map-markers');\n\n // Add Watermark\n if (this.options.watermark) {\n this.watermark = new Watermark(this, this.options.watermark);\n }\n\n // Add Title\n if (this.options.title) {\n this.buildTitle();\n }\n\n // Add Export SVG Capability\n if (this.options.exportSvgClient || this.options.exportSvg) {\n this.addExportSvgCapability();\n }\n\n // AutoResize\n if (!this.options.width) {\n window.addEventListener('resize', () => {\n this.svg.attr('width', this.getWidth());\n this.svg.attr('height', this.getHeight());\n this.rescale();\n });\n }\n\n // Let's build things\n this.loadGeometries();\n\n // render is triggered by MapTable\n // this.render();\n }\n\n enrichData() {\n // Add coordinates to rawData\n this.maptable.rawData.forEach((d) => {\n d.longitude = parseFloat(d[this.options.longitudeKey]);\n d.latitude = parseFloat(d[this.options.latitudeKey]);\n let coord = [0, 0];\n if (!Number.isNaN(d.longitude) && !Number.isNaN(d.latitude)) {\n coord = this.projection([d.longitude, d.latitude]);\n }\n d.x = coord[0];\n d.y = coord[1];\n });\n }\n\n scaleAttributes() {\n return Math.pow(this.scale, 2 / 3); // eslint-disable-line\n }\n\n getWidth() {\n if (this.options.width) {\n return this.options.width;\n }\n this.options.width = this.node.offsetWidth;\n return this.node.offsetWidth;\n }\n\n getHeight() {\n const deltaHeight = (this.options.title) ? 30 : 0;\n if (!this.options.height && this.options.ratioFromWidth) {\n return this.getWidth() * this.options.ratioFromWidth * this.options.scaleHeight + deltaHeight;\n }\n return this.options.height * this.options.scaleHeight + deltaHeight;\n }\n\n /**\n * Load geometries and built the map components\n */\n loadGeometries() {\n // We filter world data\n if (this.options.filterCountries) {\n this.jsonWorld.objects.countries.geometries = this.jsonWorld.objects.countries\n .geometries.filter(this.options.filterCountries);\n }\n\n // Build countries\n if (this.options.countries) this.buildCountries();\n\n // Build heatmap\n if (this.options.heatmap) this.buildHeatmap();\n\n if (this.options.night) this.buildNight();\n if (\n this.options.timezones\n && (this.options.timezones.path || this.options.timezones.pathData)\n ) this.buildTimezone();\n }\n\n /**\n * Logic to build the heatmap elements (without the filling the heatmap image)\n */\n buildHeatmap() {\n // Build vectors\n const lands = topojson.merge(this.jsonWorld, this.jsonWorld.objects.countries.geometries);\n if (!this.options.heatmap.disableMask) {\n this.maskHeatmap = this.layerHeatmap.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-heatmap-mask');\n\n this.maskHeatmap\n .datum(lands)\n .append('path')\n .attr('class', 'mt-map-heatmap-mask-paths')\n .attr('d', this.path);\n }\n\n this.imgHeatmap = this.layerHeatmap\n .append('image')\n .attr('width', this.getWidth())\n .attr('height', this.getHeight())\n .attr('x', 0)\n .attr('y', 0)\n .attr('class', 'mt-map-heatmap-img');\n\n if (this.options.heatmap.mask) {\n this.imgHeatmap = this.imgHeatmap.attr('clip-path', 'url(#mt-map-heatmap-mask)');\n }\n\n if (this.options.heatmap.borders) {\n const borders = topojson.mesh(\n this.jsonWorld,\n this.jsonWorld.objects.countries,\n (a, b) => a !== b,\n );\n\n this.bordersHeatmap = this.layerHeatmap\n .append('g')\n .attr('class', 'mt-map-heatmap-borders');\n\n this.bordersHeatmap.selectAll('path.mt-map-heatmap-borders-paths')\n .data([lands, borders])\n .enter()\n .append('path')\n .attr('class', 'mt-map-heatmap-borders-paths')\n .attr('fill', 'none')\n .attr('stroke-width', this.options.heatmap.borders.stroke)\n .attr('stroke', this.options.heatmap.borders.color)\n .attr('style', `opacity: ${this.options.heatmap.borders.opacity}`)\n .attr('d', this.path);\n }\n }\n\n /**\n * Logic to build the night position\n */\n buildNight() {\n this.layerNight = this.layerGlobal.append('g')\n .attr('class', 'mt-map-night');\n\n const circle = d3.geo.circle()\n .angle(90);\n\n // Mask night\n this.maskNight = this.layerNight.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-night-mask');\n\n this.maskNight.append('rect')\n .attr('x', 0)\n .attr('y', 30)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight() * 0.82 - 30);\n\n // Build vectors\n this.nightPath = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.path)\n .style('opacity', 0.1);\n\n const userDate = this.options.night.date || Date.UTC();\n const startOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 0,\n 0,\n 0,\n );\n const solarPositionDated = solarPosition(new Date(startOfDay));\n this.nightPath.datum(circle.origin(antipode(solarPositionDated))).attr('d', this.path);\n\n this.nightPathRight = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.nightPath.attr('d'))\n .style('opacity', 0.1)\n .style('transform', `translate3d(${this.getWidth()}px,0,0)`);\n\n this.nightPathLeft = this.layerNight.append('path')\n .attr('class', `mt-map-night-layer${this.options.night.cssBlur ? ' mt-blur' : ''}`)\n .attr('filter', this.options.night.cssBlur ? undefined : 'url(#blur)')\n .attr('clip-path', 'url(#mt-map-night-mask)')\n .attr('d', this.nightPath.attr('d'))\n .style('opacity', 0.1)\n .style('transform', `translate3d(${-this.getWidth()}px,0,0)`);\n\n if (!this.options.night.disableSun) {\n const sunCoords = this.projection(solarPositionDated);\n\n this.sunCircleRight = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-right')\n .attr('cx', sunCoords[0])\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleXRight = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-xright')\n .attr('cx', sunCoords[0] + this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleLeft = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-right')\n .attr('cx', sunCoords[0] - this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n\n this.sunCircleXLeft = this.layerNight.append('svg:circle')\n .attr('class', 'mt-map-sun-xright')\n .attr('cx', sunCoords[0] - 2 * this.getWidth())\n .attr('cy', sunCoords[1])\n .attr('fill', 'url(#sunGradient)')\n .attr('r', this.getHeight() * 0.35);\n }\n }\n\n /**\n * Logic to build the timezone strips\n */\n buildTimezone() {\n if (this.options.timezones.pathData) {\n this.loadTimezone(null, JSON.parse(this.options.timezones.pathData));\n } else if (this.options.timezones.path) {\n d3.json(this.options.timezones.path, (errGeoMap, jsonTimezones) => {\n this.loadTimezone(errGeoMap, jsonTimezones);\n });\n }\n }\n\n scaleFontSize(fontSize) {\n return this.getWidth() < 700 ? fontSize * (this.getWidth() / 700) : fontSize;\n }\n\n loadTimezone(err, jsonTimezones) {\n this.dataTimezones = topojson.feature(\n jsonTimezones,\n jsonTimezones.objects.timezones,\n ).features;\n\n // Mask timezone\n this.maskTimezone = this.layerTimezones.append('defs')\n .append('clipPath')\n .attr('id', 'mt-map-timezone-mask');\n\n this.maskTimezone.append('rect')\n .attr('x', 0)\n .attr('y', 30)\n .attr('width', this.getWidth())\n .attr('height', this.getHeight() * 0.82 - 30);\n\n // Build timezone paths\n this.layerTimezones\n .selectAll('.mt-map-timezone')\n .data(this.dataTimezones.filter((d) => d.properties.places !== 'Antarctica'))\n .enter()\n .insert('path')\n .attr('class', 'mt-map-timezone')\n .attr('d', this.path)\n .attr('fill', (d) => (d.properties.zone % 2 === 0 ? '#F4F5F5' : 'transparent'))\n .attr('title', (d) => JSON.stringify(d.properties))\n .attr('clip-path', 'url(#mt-map-timezone-mask)')\n .style('opacity', 0.6);\n\n // Add times\n const timezoneTexts = this.dataTimezones.filter((d) => d.properties.places !== 'Antarctica' && d.properties.zone % 1 === 0 && d.properties.zone !== 14);\n const timezoneTextsUnique = [...new Map(timezoneTexts.map((item) => (\n [item.properties.zone, item]\n ))).values()];\n\n this.layerTimezonesText = this.layerTimezones.append('g').attr('class', 'mt-map-timezones-texts');\n this.layerTimezonesText.selectAll('.mt-map-timezone-text')\n .data(timezoneTextsUnique)\n .enter()\n .insert('text')\n .attr('class', 'mt-map-timezone-text')\n .attr('y', this.getHeight() * 0.82 - 5)\n .attr('x', (d) => (d.properties.zone + 10) * (this.getWidth() / 24.5) - 1)\n .attr('dx', (this.getWidth() / 24.5) / 2)\n .attr('font-size', this.scaleFontSize(9))\n .attr('font-family', 'Helevetica, Arial, Sans-Serif')\n .attr('fill', '#999')\n .attr('text-anchor', 'middle')\n .html((d) => (\n utils.formatDate((this.options.timezones.date || new Date()), d.properties.zone)));\n }\n\n /**\n * Get Scale for every circle magnitude\n * @param heatmapDataset: heatmap dataset that we use\n * @returns scale: function - Scale function that output a value [0 - 1]\n */\n getMagnitudeScale(heatmapDataset) {\n const opts = this.options.heatmap;\n const lengthDataset = heatmapDataset.length;\n if (!lengthDataset) return () => 0;\n // const layersPerLocation = (opts.circles.max - opts.circles.min) / opts.circles.step;\n const maxOpacityScale = d3.scale.linear()\n .domain([1, lengthDataset])\n .range([1, 0.25]);\n const centralCircleOpacity = maxOpacityScale(lengthDataset);\n\n const scale = d3.scale.linear()\n .domain([opts.circles.min, 20])\n .range([centralCircleOpacity, 0]);\n return (m) => scale(m);\n }\n\n /**\n * Get Scale for every data point (used for weighting)\n * @returns scale: function - Scale function that output a value [0 - 1]\n */\n getDatumScale() {\n if (!this.options.heatmap.weightByAttribute) return () => 1;\n const dataExtents = d3.extent(this.maptable.data, this.options.heatmap.weightByAttribute);\n const userScale = (this.options.heatmap.weightByAttributeScale === 'log')\n ? d3.scale.log : d3.scale.linear;\n const scale = userScale().domain(dataExtents).range([0.5, 1]);\n return (d) => {\n const val = this.options.heatmap.weightByAttribute(d);\n if (!val) return 0;\n return scale(val);\n };\n }\n\n /**\n * Get the Data URL of the heatmap image\n * @returns {string} base64 image\n */\n getHeatmapData() {\n const canvasHeatmap = d3.select(this.node)\n .append('canvas')\n .attr('id', 'mt-map-heatmap-canvas')\n .attr('width', this.getWidth())\n .attr('height', this.getHeight())\n .attr('style', 'display: none;');\n\n const ctx = canvasHeatmap.node().getContext('2d');\n ctx.globalCompositeOperation = 'multiply';\n const circles = d3.range(\n this.options.heatmap.circles.min,\n this.options.heatmap.circles.max,\n this.options.heatmap.circles.step,\n );\n const datumScale = this.getDatumScale();\n const heatmapDataset = this.maptable.data.filter((d) => datumScale(d) > 0.1);\n const path = this.path.context(ctx);\n const magnitudeScale = this.getMagnitudeScale(heatmapDataset);\n const colorScale = d3.scale.linear()\n .domain([1, 0])\n .range(['#000000', '#FFFFFF']);\n\n // Make a flat white background first\n ctx.beginPath();\n ctx.rect(0, 0, this.getWidth(), this.getHeight());\n ctx.fillStyle = '#ffffff';\n ctx.fill();\n ctx.closePath();\n\n // color strenght factor\n const colorMultiplier = (x) => {\n const a = this.options.heatmap.circles.colorStrength;\n const aa = 1 + ((a - 1) / 100);\n if (a > 1) return (2 - aa) * x + aa - 1;\n return a * x;\n };\n\n // add condensed clouds\n heatmapDataset.forEach((point) => {\n const scaleOpacityDatum = datumScale(point);\n circles.forEach((m) => {\n const opacity = colorMultiplier(magnitudeScale(m) * scaleOpacityDatum);\n if (opacity > 0) {\n ctx.beginPath();\n path(d3.geo.circle().origin([point.longitude, point.latitude]).angle(m - 0.0001)());\n ctx.fillStyle = colorScale(opacity);\n ctx.fill();\n ctx.closePath();\n }\n });\n });\n\n StackBlur.canvasRGBA(\n canvasHeatmap.node(),\n 0,\n 0,\n this.getWidth(),\n this.getHeight(),\n this.options.heatmap.circles.blur,\n );\n\n // Add color layer\n ctx.beginPath();\n ctx.globalCompositeOperation = 'screen';\n ctx.rect(0, 0, this.getWidth(), this.getHeight());\n ctx.fillStyle = this.options.heatmap.circles.color;\n ctx.fill();\n ctx.closePath();\n\n const dataUrl = canvasHeatmap.node().toDataURL();\n canvasHeatmap.remove();\n return dataUrl;\n }\n\n /**\n * Set the data URL to the heatmap image\n */\n updateHeatmap() {\n const dataUrl = this.getHeatmapData();\n this.imgHeatmap.attr('xlink:href', dataUrl);\n }\n\n /**\n * build the paths for the countries\n */\n buildCountries() {\n this.dataCountries = topojson.feature(\n this.jsonWorld,\n this.jsonWorld.objects.countries,\n ).features;\n\n // Build country paths\n this.layerCountries\n .selectAll('.mt-map-country')\n .data(this.dataCountries)\n .enter()\n .insert('path')\n .attr('class', 'mt-map-country')\n .attr('d', this.path);\n\n // Build Country Legend\n this.legendCountry = {};\n\n if (this.shouldRenderLegend()) {\n this.legendCountry.fill = new Legend(this);\n }\n }\n\n shouldRenderLegend() {\n const f = this.options.countries.attr.fill;\n if (!f) return false;\n if (!f.legend || !f.min || !f.max) return false;\n if (f.aggregate && f.aggregate.scale) {\n const scale = (typeof (f.aggregate.scale) === 'function')\n ? f.aggregate.scale.bind(this.maptable)()\n : f.aggregate.scale;\n if (scale !== 'linear') return false;\n }\n return true;\n }\n\n /**\n * Get all mt-map-country elements\n */\n getAllMtMapCountry() {\n if (this.allMtMapCountry) return this.allMtMapCountry;\n this.allMtMapCountry = d3.selectAll(`${this.containerSelector} .mt-map-country`);\n return this.allMtMapCountry;\n }\n\n /**\n * Get all mt-map-marjker elements\n */\n getAllMtMapMarker() {\n if (this.allMtMapMarker) return this.allMtMapMarker;\n this.allMtMapMarker = d3.selectAll(`${this.containerSelector} .mt-map-marker`);\n return this.allMtMapMarker;\n }\n\n /**\n * Set the right color for every country\n */\n updateCountries() {\n // Data from user input\n const dataByCountry = new Map();\n this.maptable.data.forEach((d) => {\n const key = d[this.options.countryIdentifierKey];\n if (!dataByCountry.has(key)) {\n dataByCountry.set(key, []);\n }\n dataByCountry.get(key).push(d);\n });\n\n // We merge both data\n this.dataCountries.forEach((geoDatum) => {\n geoDatum.key = geoDatum.properties[this.options.countryIdentifierType];\n const matchedCountry = dataByCountry.get(geoDatum.key);\n geoDatum.values = matchedCountry || [];\n geoDatum.attr = {};\n geoDatum.rollupValue = {};\n });\n\n // We calculate attributes values\n Object.keys(this.options.countries.attr).forEach((k) => {\n this.setAttrValues(k, this.options.countries.attr[k], this.dataCountries);\n });\n\n // Update SVG\n const countryItem = this.getAllMtMapCountry().each(function (d) {\n const selection = d3.select(this);\n Object.keys(d.attr).forEach((key) => {\n selection.attr(key, d.attr[key]);\n });\n });\n\n // Update Legend\n Object.keys(this.options.countries.attr).forEach((attrKey) => {\n const attrValue = this.options.countries.attr[attrKey];\n if (typeof (attrValue) === 'object' && attrValue.legend && this.legendCountry[attrKey] !== undefined) {\n const scaleDomain = d3.extent(\n this.dataCountries,\n (d) => Number(d.attrProperties[attrKey].value),\n );\n this.legendCountry[attrKey].updateExtents(scaleDomain);\n\n // When we mouseover the legend, it should highlight the indice selected\n countryItem.on('mouseover', (d) => {\n this.legendCountry[attrKey].indiceChange(d.attrProperties[attrKey].value);\n })\n .on('mouseout', () => {\n this.legendCountry[attrKey].indiceChange(NaN);\n });\n }\n });\n\n // Update Tooltip\n if (this.options.countries && this.options.countries.tooltip) {\n this.activateTooltip(\n countryItem,\n this.tooltipCountriesNode,\n this.options.countries.tooltip,\n true,\n );\n }\n }\n\n /**\n * Update night drawings\n */\n updateNight() {\n const userDate = this.options.night.date || Date.UTC();\n const startOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 0,\n 0,\n 0,\n );\n const endOfDay = Date.UTC(\n userDate.getUTCFullYear(),\n userDate.getUTCMonth(),\n userDate.getUTCDate(),\n 23,\n 59,\n 59,\n );\n\n const totalMilliseconds = endOfDay - startOfDay;\n const currentTime = userDate - startOfDay;\n const relativeTranslateX = (currentTime / totalMilliseconds);\n\n this.layerNight.node().style.transform = `translateX(${-this.getWidth() * relativeTranslateX}px)`;\n }\n\n /**\n * Update night drawings\n */\n updateTimezones() {\n const timezoneTexts = document.querySelectorAll('.mt-map-timezone-text');\n const currentDate = this.options.timezones.date || new Date();\n\n Array.from(timezoneTexts).forEach((timezoneText) => {\n timezoneText.textContent = utils.formatDate(\n currentDate,\n timezoneText.__data__.properties.zone,\n );\n });\n }\n\n updateMarkers() {\n const defaultGroupBy = (a) => `${a.longitude},${a.latitude}`;\n\n this.dataMarkers = d3.nest()\n .key(defaultGroupBy)\n .entries(this.maptable.data)\n .filter((d) => d.values[0].x !== 0);\n\n // We merge both data\n this.dataMarkers.forEach((d) => {\n d.attr = {};\n d.attrProperties = {};\n });\n\n // We calculate attributes values\n Object.keys(this.options.markers.attr).forEach((k) => {\n this.setAttrValues(k, this.options.markers.attr[k], this.dataMarkers);\n });\n\n // Enter\n const markerItem = this.layerMarkers\n .selectAll('.mt-map-marker')\n .data(this.dataMarkers);\n let markerObject = markerItem.enter();\n if (this.options.markers.customTag) {\n markerObject = this.options.markers.customTag(markerObject);\n } else {\n markerObject = markerObject.append('svg:circle');\n }\n const markerClassName = (this.options.markers.className)\n ? this.options.markers.className : '';\n\n markerObject.attr('class', `mt-map-marker ${markerClassName}`);\n\n // Exit\n markerItem.exit().transition()\n .attr('r', 0)\n .attr('fill', '#eee')\n .style('opacity', 0)\n .remove();\n\n // Update\n const attrX = (this.options.markers.attrX) ? this.options.markers.attrX : 'cx';\n const attrY = (this.options.markers.attrY) ? this.options.markers.attrY : 'cy';\n\n const attrXDelta = (this.options.markers.attrXDelta) ? this.options.markers.attrXDelta : 0;\n const attrYDelta = (this.options.markers.attrYDelta) ? this.options.markers.attrYDelta : 0;\n\n const markerUpdate = markerItem\n .attr(attrX, (d) => d.values[0].x + attrXDelta)\n .attr(attrY, (d) => d.values[0].y + attrYDelta);\n\n this.getAllMtMapMarker().each(function (d) {\n Object.keys(d.attr).forEach((key) => {\n d3.select(this).attr(key, d.attr[key]);\n });\n });\n\n if (this.options.markers.tooltip) {\n this.activateTooltip(\n markerUpdate,\n this.tooltipMarkersNode,\n this.options.markers.tooltip,\n false,\n );\n }\n\n this.rescale();\n }\n\n fitContent() {\n if (this.maptable.data.length === 0) {\n this.transX = 0;\n this.transY = 0;\n this.scale = 1;\n this.zoomListener.translate([this.transX, this.transY])\n .scale(this.scale);\n return;\n }\n const hor = d3.extent(this.maptable.data, (d) => d.x);\n const ver = d3.extent(this.maptable.data, (d) => d.y);\n\n // center dots with the good ratio\n const ratio = this.getWidth() / this.getHeight();\n const deltaMarker = 20 + ((this.options.title) ? 30 : 0);\n\n const currentWidth = (hor[1] - hor[0]) + deltaMarker;\n const currentHeight = (ver[1] - ver[0]) + deltaMarker;\n\n const realHeight = currentWidth / ratio;\n const realWidth = currentHeight * ratio;\n\n let diffMarginWidth = 0;\n let diffMarginHeight = 0;\n if (realWidth >= currentWidth) {\n diffMarginWidth = (realWidth - currentWidth) / 2;\n } else {\n diffMarginHeight = (realHeight - currentHeight) / 2;\n }\n\n // add layout margin\n hor[0] -= (this.options.fitContentMargin + diffMarginWidth);\n hor[1] += (this.options.fitContentMargin + diffMarginWidth);\n ver[0] -= (this.options.fitContentMargin + diffMarginHeight);\n ver[1] += (this.options.fitContentMargin + diffMarginHeight);\n\n this.scale = this.getWidth() / (hor[1] - hor[0]);\n this.transX = -1 * hor[0] * this.scale;\n this.transY = -1 * ver[0] * this.scale;\n\n this.zoomListener.translate([this.transX, this.transY]).scale(this.scale);\n }\n\n buildTitle() {\n const titleContainer = this.svg\n .append('svg')\n .attr('width', this.getWidth())\n .attr('x', 0)\n .attr('y', (this.getHeight() - 30))\n .attr('height', 30);\n\n if (this.options.title.bgColor) {\n titleContainer.append('rect')\n .attr('x', 0)\n .attr('y', 0)\n .attr('width', this.getWidth())\n .attr('height', 30)\n .attr('fill', this.options.title.bgColor);\n }\n\n titleContainer.append('text')\n .attr('id', 'mt-map-title')\n .attr('x', 20)\n .attr('font-size', this.scaleFontSize(this.options.title.fontSize))\n .attr('font-family', this.options.title.fontFamily)\n .attr('y', 20);\n\n if (this.options.title.source) {\n titleContainer.append('text')\n .attr('y', 20)\n .attr('x', (this.getWidth() - 20))\n .attr('text-anchor', 'end')\n .attr('font-size', this.scaleFontSize(this.options.title.fontSize))\n .attr('font-family', this.options.title.fontFamily)\n .html(this.options.title.source());\n }\n }\n\n /**\n * We encode a transaltion to be independent from the dimensions of the visualization\n * @param originalTranslation: Array - original translation value (from screen)\n * @returns encodedTranslation: Array - encoded translation\n */\n encodeTranslation(originalTranslation) {\n const newTx = originalTranslation[0] / (this.scale * this.getWidth());\n\n const newTy = originalTranslation[1] / (this.scale * this.getHeight());\n\n return [newTx, newTy];\n }\n\n /**\n * We decode a translation to adapt it to the dimensions of the visualization\n * @param encodedTranslation: Array - encoded translation\n * @returns originalTranslation: Array - original translation value (from screen)\n */\n decodeTranslation(encodedTranslation) {\n const newTx = encodedTranslation[0] * this.getWidth() * this.scale;\n\n const newTy = encodedTranslation[1] * this.getHeight() * this.scale;\n\n return [newTx, newTy];\n }\n\n /**\n * Restore state from the url hash\n */\n restoreState(defaultZoom) {\n if (!defaultZoom || defaultZoom.length !== 3) return;\n this.scale = defaultZoom[0];\n const originalTranslation = this.decodeTranslation([defaultZoom[1], defaultZoom[2]]);\n this.transX = originalTranslation[0];\n this.transY = originalTranslation[1];\n this.zoomListener.scale(defaultZoom[0])\n .translate(originalTranslation)\n .event(this.svg);\n }\n\n /**\n * Save state into the url hash\n */\n saveState() {\n const encodedTranslation = this.encodeTranslation([this.transX, this.transY]);\n const exportedData = [this.scale, encodedTranslation[0],\n encodedTranslation[1]];\n if (exportedData[0] !== 1 && exportedData[1] !== 0 && exportedData[2] !== 0) {\n this.maptable.saveState('zoom', exportedData);\n } else {\n this.maptable.removeState('zoom');\n }\n }\n\n rescale() {\n const self = this;\n if (d3.event && d3.event.translate) {\n this.scale = d3.event.scale;\n this.transX = (this.scale === 1) ? 0 : d3.event.translate[0];\n this.transY = (this.scale === 1) ? 0 : d3.event.translate[1];\n }\n\n const maxTransX = 0;\n const maxTransY = 0;\n const minTransX = this.getWidth() * (1 - this.scale);\n const minTransY = this.getHeight() * (1 - this.scale);\n\n if (this.transY > maxTransY) {\n this.transY = maxTransY;\n } else if (this.transY < minTransY) {\n this.transY = minTransY;\n }\n\n if (this.transX > maxTransX) {\n this.transX = maxTransX;\n } else if (this.transX < minTransX) {\n this.transX = minTransX;\n }\n\n if (d3.event && d3.event.translate) {\n d3.event.translate[0] = this.transX;\n d3.event.translate[1] = this.transY;\n }\n\n this.layerGlobal.style(\n 'transform',\n `translate(${this.transX}px,${this.transY}px)scale(${this.scale})`,\n );\n\n // Hide tooltip\n if (self.tooltipCountriesNode) self.tooltipCountriesNode.attr('style', 'display:none;');\n if (self.tooltipMarkersNode) self.tooltipMarkersNode.attr('style', 'display:none;');\n\n // Rescale markers size\n if (this.options.markers) {\n // markers\n this.getAllMtMapMarker().each(function (d) {\n // stroke\n if (d.attr['stroke-width']) {\n d3.select(this).attr('stroke-width', d.attr['stroke-width'] / self.scaleAttributes());\n }\n // radius\n if (d.attr.r) {\n d3.select(this).attr('r', d.attr.r / self.scaleAttributes());\n }\n });\n }\n\n // Rescale Sun\n if (this.options.night && !this.options.disableSun) {\n d3.selectAll(`${this.containerSelector} .mt-map-sun`).style(\n 'r',\n (this.getHeight() * 0.35) / this.scale,\n );\n }\n\n // Rescale Country stroke-width\n if (this.options.countries) {\n this.getAllMtMapCountry().style(\n 'stroke-width',\n this.options.countries.attr['stroke-width'] / this.scale,\n );\n }\n\n // Rescale heatmap borders\n if (this.options.heatmap && this.options.heatmap.borders) {\n d3.selectAll(`${this.containerSelector} .mt-map-heatmap-borders-paths`)\n .style('stroke-width', this.options.heatmap.borders.stroke / this.scale);\n }\n\n // save state\n if (this.maptable.firstExecution && this.options.saveState) this.saveState();\n }\n\n setAttrValues(attrKey, attrValue, dataset) {\n if (typeof (attrValue) === 'number' || typeof (attrValue) === 'string') {\n // Static value\n dataset.forEach((d) => {\n d.attr[attrKey] = attrValue;\n });\n } else if (typeof (attrValue) === 'function') {\n // Dynamic value based on the dataset\n dataset.forEach((d) => {\n d.attr[attrKey] = attrValue(d);\n });\n } else if (typeof (attrValue) === 'object') {\n let scale = 'linear';\n let key = null;\n let mode = 'count';\n let scaleToUse = d3.scale.linear();\n if (attrValue.aggregate) {\n key = (typeof (attrValue.aggregate.key) === 'function')\n ? attrValue.aggregate.key.bind(this.maptable)()\n : attrValue.aggregate.key;\n\n mode = (typeof (attrValue.aggregate.mode) === 'function')\n ? attrValue.aggregate.mode.bind(this.maptable)()\n : attrValue.aggregate.mode;\n\n if (typeof (attrValue.aggregate.scale) === 'function') {\n scale = attrValue.aggregate.scale.bind(this.maptable)();\n } else if (attrValue.aggregate.scale) {\n scale = attrValue.aggregate.scale;\n }\n\n if (!key || !mode) {\n throw new Error(`MapTable: You should provide values 'key' & 'mode' for attr.${attrKey}.aggregate`);\n }\n\n // Custom aggregate mode\n if (mode === 'sum') {\n attrValue.rollup = (groupedData) => (\n groupedData.map((d) => Number(d[key])).reduce((a, c) => a + c, 0)\n );\n } else if (mode === 'avg') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const validData = groupedData.filter((d) => !Number.isNaN(Number(d[key])));\n return validData\n .map((d) => Number(d[key]))\n .reduce((a, c) => a + c, 0) / validData.length;\n };\n } else if (mode === 'count') {\n attrValue.rollup = (groupedData) => groupedData.length;\n } else if (mode === 'min') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return groupedValues.reduce((min, p) => (p < min ? p : min), groupedValues[0]);\n };\n } else if (mode === 'max') {\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return groupedValues.reduce((max, p) => (p > max ? p : max), groupedValues[0]);\n };\n } else if (mode.indexOf('percentile') !== -1) {\n const percentile = utils.toNumber(mode);\n attrValue.rollup = (groupedData) => {\n if (!groupedData.length) return 0;\n const groupedValues = groupedData.map((d) => Number(d[key]));\n return utils.quantile(groupedValues, percentile);\n };\n } else if (typeof (attrValue.rollup) === 'function') {\n attrValue.rollup = attrValue.rollup.bind(this.maptable);\n }\n\n // Custom scale\n if (scale) {\n if (scale.indexOf('log') !== -1) {\n scaleToUse = d3.scale.log();\n } else if (scale.indexOf('pow') !== -1) {\n scaleToUse = d3.scale.pow().exponent(utils.toNumber(scale) || 1);\n } else if (scale === 'sqrt') {\n scaleToUse = d3.scale.sqrt();\n }\n // Rank scale neeed additional transformations\n }\n }\n\n // Dynamic value based on a scale\n if (!attrValue.rollup) {\n attrValue.rollup = (d) => d.length;\n }\n if (!attrValue.min || !attrValue.max) {\n throw new Error(`MapTable: You should provide values 'min' & 'max' for attr.${attrKey}`);\n }\n\n dataset.forEach((d) => {\n const aggregatedValue = attrValue.rollup(d.values);\n if (!d.attrProperties) d.attrProperties = {};\n if (!d.attrProperties[attrKey]) d.attrProperties[attrKey] = {};\n d.attrProperties[attrKey].value = aggregatedValue;\n if (key) {\n d.attrProperties[attrKey].key = key;\n d.attrProperties[attrKey].mode = mode;\n d.attrProperties[attrKey].scale = scale;\n const c = this.maptable.columnDetails[key];\n d.attrProperties[attrKey].columnDetails = c;\n const datum = {};\n datum[key] = aggregatedValue;\n d.attrProperties[attrKey].formatted = (c && c.cellContent)\n ? c.cellContent.bind(this.maptable)(datum)\n : aggregatedValue;\n }\n });\n if (scale === 'rank') {\n const positiveRanks = utils.uniqueValues([0].concat(dataset\n .map((d) => Math.floor(d.attrProperties[attrKey].value * 100) / 100)\n .filter((v) => v > 0)));\n const negativeRanks = utils.uniqueValues(dataset\n .map((d) => Math.floor(d.attrProperties[attrKey].value * 100) / 100)\n .filter((v) => v < 0));\n\n positiveRanks.sort((a, b) => a - b);\n negativeRanks.sort((a, b) => b - a);\n\n dataset.forEach((d) => {\n if (d.attrProperties[attrKey].value !== 0) {\n const ranks = d.attrProperties[attrKey].value >= 0 ? positiveRanks : negativeRanks;\n const pos = ranks.indexOf(Math.floor(d.attrProperties[attrKey].value * 100) / 100);\n const percentile = Math.round((pos / ranks.length) * 100);\n const newValue = d.attrProperties[attrKey].value < 0\n ? percentile - (percentile * 2)\n : percentile;\n d.attrProperties[attrKey].value = newValue;\n }\n });\n }\n\n let scaleDomain = d3.extent(dataset, (d) => Number(d.attrProperties[attrKey].value));\n if (scaleDomain[0] === 0 && scale && scale.indexOf('log') !== '-1') {\n scaleDomain = d3.extent(\n dataset.filter((v) => Number(v.attrProperties[attrKey].value) !== 0),\n (d) => Number(d.attrProperties[attrKey].value),\n );\n }\n if (attrValue.transform) {\n scaleDomain[0] = attrValue.transform\n .bind(this.maptable)(scaleDomain[0], this.maptable.data);\n scaleDomain[1] = attrValue.transform\n .bind(this.maptable)(scaleDomain[1], this.maptable.data);\n }\n\n let minValue = attrValue.min;\n let maxValue = attrValue.max;\n\n if (attrValue.min === 'minValue') {\n minValue = scaleDomain[0];\n }\n if (attrValue.max === 'maxValue') {\n maxValue = scaleDomain[1];\n }\n\n // check for negative color declarations\n if ((attrValue.maxNegative && !attrValue.minNegative)\n || (!attrValue.maxNegative && attrValue.minNegative)) {\n throw new Error('MapTable: maxNegative or minNegative undefined. Please declare both.');\n }\n const useNegative = (attrValue.maxNegative && attrValue.minNegative);\n let scaleFunction;\n let scaleNegativeFunction;\n\n if (useNegative) {\n scaleFunction = scaleToUse.copy()\n .domain([0, scaleDomain[1]])\n .range([minValue, maxValue]);\n scaleNegativeFunction = scaleToUse.copy()\n .domain([scaleDomain[0], 0])\n .range([attrValue.maxNegative, attrValue.minNegative]);\n } else {\n scaleFunction = scaleToUse\n .domain(scaleDomain)\n .range([minValue, maxValue]);\n }\n\n dataset.forEach((d) => {\n let scaledValue;\n if (!d.values.length || Number.isNaN(d.attrProperties[attrKey].value)) {\n if (typeof (attrValue.empty) === 'undefined') {\n throw new Error(`MapTable: no empty property found for attr.${attrKey}`);\n }\n scaledValue = attrValue.empty;\n } else {\n const originalValueRaw = d.attrProperties[attrKey].value;\n const originalValue = (attrValue.transform)\n ? attrValue.transform.bind(this.maptable)(originalValueRaw, this.maptable.data)\n : originalValueRaw;\n\n if (useNegative && originalValue < 0) {\n scaledValue = scaleNegativeFunction(originalValue);\n } else {\n scaledValue = scaleFunction(originalValue);\n }\n }\n d.attr[attrKey] = scaledValue;\n });\n } else {\n throw new Error(`Maptable: Invalid value for ${attrKey}`);\n }\n }\n\n render() {\n if (this.options.markers) this.updateMarkers();\n if (this.options.countries) this.updateCountries();\n if (this.options.night) this.updateNight();\n if (this.options.timezones) this.updateTimezones();\n if (this.options.title) this.updateTitle();\n if (this.options.heatmap) this.updateHeatmap();\n if (this.options.autoFitContent) {\n this.fitContent();\n this.rescale();\n }\n // On render\n if (this.options.onRender && this.options.onRender.constructor === Function) {\n this.options.onRender.bind(this.maptable)();\n }\n }\n\n updateTitle() {\n if (this.options.title.content) {\n const showing = this.maptable.data.filter((d) => d[this.options.latitudeKey] !== 0).length;\n const total = this.maptable.rawData.filter((d) => d[this.options.latitudeKey] !== 0).length;\n\n let inlineFilters = '';\n if (this.maptable.filters) {\n inlineFilters = this.maptable.filters.getDescription();\n }\n\n this.container.querySelector('#mt-map-title').innerHTML = this.options.title\n .content.bind(this.maptable)(\n showing,\n total,\n inlineFilters,\n this.maptable.data,\n this.maptable.rawData,\n this.dataCountries,\n );\n }\n }\n\n activateTooltip(target, tooltipNode, tooltipContent, isCountry) {\n const self = this;\n target.on(isCountry ? 'mousemove' : 'mouseover', function (d) {\n const content = tooltipContent.bind(this.maptable)(d);\n if (!content) return;\n tooltipNode.html(content).attr('style', 'display:block;position:fixed;');\n\n let mouseLeft;\n let mouseTop;\n const tooltipDelta = tooltipNode.node().offsetWidth / 2;\n if (isCountry) {\n const mapRect = self.node.getBoundingClientRect();\n const mousePosition = d3.mouse(self.svg.node()).map((v) => parseInt(v, 10));\n\n mouseLeft = mapRect.left + mousePosition[0] - tooltipDelta;\n mouseTop = mapRect.top + mousePosition[1] + 10;\n } else {\n const targetRect = this.getBoundingClientRect();\n mouseLeft = (targetRect.left + (targetRect.width / 2) - tooltipDelta);\n mouseTop = (targetRect.top + targetRect.height + 2); // +2 is for the border\n }\n\n tooltipNode.attr(\n 'style',\n `top:${mouseTop}px;left:${mouseLeft}px;display:block;position:fixed;`,\n )\n .on('mouseout', () => {\n tooltipNode.style('display', 'none');\n });\n })\n .on('mouseout', () => {\n tooltipNode.style('display', 'none');\n });\n }\n\n exportSvg() {\n // Get the d3js SVG element\n const svg = this.container.querySelector('#mt-map-svg');\n // Extract the data as SVG text string\n const svgXml = `\n${(new XMLSerializer()).serializeToString(svg)}`;\n\n if (this.options.exportSvgClient) {\n if (!window.saveAs) {\n throw new Error('MapTable: Missing FileSaver.js library');\n }\n const blob = new Blob([svgXml], { type: 'image/svg+xml' });\n window.saveAs(blob, 'visualization.svg');\n } else if (this.options.exportSvg) {\n const form = this.node.querySelector('#mt-map-svg-form');\n form.querySelector('[name=\"data\"]').value = svgXml;\n form.submit();\n }\n }\n\n addExportSvgCapability() {\n const exportNode = document.createElement('div');\n exportNode.setAttribute('id', 'mt-map-export');\n this.container.querySelector('#mt-map').appendChild(exportNode);\n\n const exportButton = document.createElement('button');\n exportButton.setAttribute('class', 'btn btn-xs btn-default');\n exportButton.innerHTML = 'Download';\n exportButton.addEventListener('click', this.exportSvg.bind(this));\n exportNode.appendChild(exportButton);\n\n if (this.options.exportSvg) {\n const exportForm = document.createElement('div');\n exportForm.innerHTML = `
`;\n exportNode.appendChild(exportForm);\n }\n }\n}\n","import utils from '../utils';\n\nexport default class Filters {\n constructor(maptable, options) {\n this.maptable = maptable;\n this.options = options;\n this.criteria = [];\n\n if (this.options.show) {\n const arrayDiff = this.options.show\n .filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0);\n if (arrayDiff.length > 0) {\n throw new Error(`MapTable: invalid columns \"${arrayDiff.join(', ')}\"`);\n }\n this.activeColumns = this.options.show;\n } else {\n this.activeColumns = Object.keys(this.maptable.columnDetails);\n }\n\n this.container = document.createElement('div');\n this.maptable.node.appendChild(this.container);\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n this.node = this.container.querySelector('#mt-filters');\n\n if (!this.node) {\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-filters');\n this.node.setAttribute('class', 'panel panel-default');\n this.maptable.node.appendChild(this.node);\n }\n\n // -- Filters Header\n\n const filtersHeaderNode = document.createElement('div');\n filtersHeaderNode.setAttribute('class', 'panel-heading');\n\n const filtersResetNode = document.createElement('button');\n filtersResetNode.setAttribute('id', 'mt-filters-reset');\n filtersResetNode.setAttribute('class', 'btn btn-default btn-xs pull-right');\n filtersResetNode.style.display = 'none';\n filtersResetNode.style.marginLeft = 5;\n filtersResetNode.innerText = '↺ Reset';\n filtersResetNode.addEventListener('click', this.reset);\n filtersHeaderNode.appendChild(filtersResetNode);\n\n const filtersTitleNode = document.createElement('h3');\n filtersTitleNode.setAttribute('class', 'panel-title');\n filtersTitleNode.appendChild(document.createTextNode('Filters'));\n filtersHeaderNode.appendChild(filtersTitleNode);\n\n this.node.appendChild(filtersHeaderNode);\n\n // -- Filters Content\n const filtersBodyNode = document.createElement('div');\n filtersBodyNode.setAttribute('id', 'mt-filters-content');\n filtersBodyNode.setAttribute('class', 'panel-body');\n\n const filtersElementsNode = document.createElement('div');\n filtersElementsNode.setAttribute('id', 'mt-filters-elements');\n filtersBodyNode.appendChild(filtersElementsNode);\n\n const filtersNewNode = document.createElement('a');\n filtersNewNode.setAttribute('id', 'mt-filters-new');\n filtersNewNode.setAttribute('href', '#');\n filtersNewNode.innerText = '+ New filter';\n filtersNewNode.addEventListener('click', this.add.bind(this));\n filtersBodyNode.appendChild(filtersNewNode);\n\n this.node.appendChild(filtersBodyNode);\n }\n\n /**\n * Add a filter\n * @param evt: Window Event Object\n */\n add(evt) {\n if (evt) evt.preventDefault();\n const possibleFilters = this.getPossibleFilters();\n\n if (possibleFilters.length === 0) {\n return;\n }\n const filterName = possibleFilters[0].key;\n this.create(filterName);\n }\n\n create(filterName, replaceNode) {\n const rowNode = this.buildRow(filterName);\n if (replaceNode) {\n replaceNode.parentNode.replaceChild(rowNode, replaceNode);\n } else {\n this.node.querySelector('#mt-filters-elements').appendChild(rowNode);\n }\n this.criteria.push(filterName);\n this.maptable.render();\n if (this.container.style.display === 'none') {\n this.toggle();\n }\n }\n\n remove(filterName) {\n const rowNode = this.node.querySelector(`[data-mt-filter-name=\"${filterName}\"]`);\n if (rowNode) rowNode.parentNode.removeChild(rowNode);\n const filterIndex = this.criteria.indexOf(filterName);\n this.criteria.splice(filterIndex, 1);\n this.maptable.render();\n }\n\n /**\n * Reset filters\n */\n reset() {\n const rowNodes = this.node.querySelectorAll('[data-mt-filter-name]');\n for (let i = 0; i < rowNodes.length; i += 1) {\n rowNodes[i].parentNode.removeChild(rowNodes[i]);\n }\n this.criteria = [];\n this.maptable.render();\n }\n\n /**\n * Export the current filters to an object\n * @returns exportedFilters: Object - key => value that contain data about the current filters\n */\n exportFilters() {\n const output = {};\n const filtersChildren = this.node.querySelector('#mt-filters-elements').childNodes;\n\n for (let i = 0; i < filtersChildren.length; i += 1) {\n const element = filtersChildren[i];\n const filterName = element.querySelector('.mt-filter-name').value;\n const columnDetails = this.maptable.columnDetails[filterName];\n const filterOutput = [columnDetails.filterMethod];\n if (columnDetails.filterMethod === 'compare') {\n const filterRangeSelect = element.querySelector('.mt-filter-range');\n filterOutput[1] = filterRangeSelect.value;\n if (filterRangeSelect.value !== 'any') {\n if (filterRangeSelect.value === 'BETWEEN') {\n const filterValueMin = element.querySelector('.mt-filter-value-min').value;\n const filterValueMax = element.querySelector('.mt-filter-value-max').value;\n if (filterValueMin !== '' && filterValueMax === '') {\n filterOutput[2] = filterValueMin;\n filterOutput[3] = filterValueMax;\n }\n } else {\n const filterValue = element.querySelector('.mt-filter-value-min').value;\n filterOutput[2] = filterValue;\n }\n }\n } else if (columnDetails.filterMethod === 'field'\n || columnDetails.filterMethod === 'dropdown') {\n filterOutput[1] = '';\n const filterValue = element.querySelector('.mt-filter-value').value;\n filterOutput[2] = filterValue;\n }\n if (filterOutput[1] !== 'any' && filterOutput[2] && filterOutput[2] !== '') {\n output[filterName] = filterOutput;\n }\n }\n return output;\n }\n\n /**\n * Set the value for the current filters\n * @param criteria - Object - same format as the exportedFilters\n */\n setFilters(criteria) {\n this.reset();\n Object.keys(criteria).forEach((filterName) => {\n this.create(filterName);\n const criterion = criteria[filterName];\n const row = document\n .querySelector(`#mt-filters-elements [data-mt-filter-name=\"${filterName}\"]`);\n if (row) {\n if (criterion[0] === 'compare') {\n row.querySelector('.mt-filter-range').value = criterion[1];\n if (criterion[1] !== 'any') {\n if (criterion[1] === 'BETWEEN') {\n row.querySelector('.mt-filter-value-min').value = criterion[2];\n row.querySelector('.mt-filter-value-max').value = criterion[3];\n } else {\n row.querySelector('.mt-filter-value-min').value = criterion[2];\n }\n }\n } else if (criterion[0] === 'field' || criterion[0] === 'dropdown') {\n row.querySelector('.mt-filter-value').value = decodeURIComponent(criterion[2]);\n }\n }\n });\n this.maptable.render();\n }\n\n /**\n * Restore state from the URL hash\n */\n restoreState(defaultCriteria) {\n if (!defaultCriteria) return;\n this.setFilters(defaultCriteria);\n }\n\n /**\n * Get a human readable description of the filters (used for the title)\n * @returns {string} Human readable description\n */\n getDescription() {\n const outputArray = [];\n\n const filtersChildren = this.node.querySelector('#mt-filters-elements').childNodes;\n\n for (let i = 0; i < filtersChildren.length; i += 1) {\n const element = filtersChildren[i];\n const filterName = element.querySelector('.mt-filter-name').value;\n\n const columnDetails = this.maptable.columnDetails[filterName];\n\n let line = '';\n\n if (columnDetails.filterMethod === 'compare') {\n const filterRangeSelect = element.querySelector('.mt-filter-range');\n if (filterRangeSelect.value !== 'any') {\n if (filterRangeSelect.value === 'BETWEEN') {\n const filterValueMin = element.querySelector('.mt-filter-value-min').value;\n const filterValueMax = element.querySelector('.mt-filter-value-max').value;\n if (filterValueMin === '' || filterValueMax === '') continue;\n line += `${columnDetails.title} is between `;\n line += `${filterValueMin} and\n ${filterValueMax}`;\n } else {\n const filterValue = element.querySelector('.mt-filter-value-min').value;\n if (filterValue === '') continue;\n line += `${columnDetails.title} is `;\n line += filterRangeSelect.options[filterRangeSelect.selectedIndex].text;\n line += `${filterValue}`;\n }\n }\n } else if (columnDetails.filterMethod === 'field'\n || columnDetails.filterMethod === 'dropdown') {\n const filterValue = element.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n const separatorWord = (columnDetails.filterMethod === 'field') ? 'contains' : 'is';\n line += `${columnDetails.title} ${separatorWord}\n ${filterValue}`;\n }\n outputArray.push(line);\n }\n return outputArray.join(', ');\n }\n\n buildRow(filterName) {\n const that = this;\n\n const possibleFilters = this.getPossibleFilters();\n\n const columnDetails = this.maptable.columnDetails[filterName];\n\n const rowNode = document.createElement('div');\n rowNode.setAttribute('class', 'mt-filter-row');\n rowNode.setAttribute('data-mt-filter-name', filterName);\n\n // Button to remove filter\n const minusButton = document.createElement('button');\n minusButton.setAttribute('class', 'btn btn-default pull-right');\n minusButton.setAttribute('data-mt-filter-btn-minus', 1);\n minusButton.innerText = '– Remove this filter';\n minusButton.addEventListener('click', () => {\n filterName = rowNode.querySelector('.mt-filter-name').value;\n this.remove(filterName);\n });\n rowNode.appendChild(minusButton);\n\n // Filters separator \"AND\"\n const filterSeparator = document.createElement('span');\n filterSeparator.setAttribute('class', 'mt-filters-and');\n filterSeparator.innerText = 'And ';\n rowNode.appendChild(filterSeparator);\n\n // Filter name select\n const filterNameSelect = document.createElement('select');\n filterNameSelect.setAttribute('class', 'mt-filter-name form-control form-control-inline');\n utils.appendOptions(\n filterNameSelect,\n possibleFilters.map((f) => ({ text: f.title, value: f.key })),\n );\n filterNameSelect.value = filterName;\n\n filterNameSelect.addEventListener('change', function () {\n const oldFilterName = this.parentNode.getAttribute('data-mt-filter-name');\n const newFilterName = this.value;\n that.create(newFilterName, this.parentNode);\n that.remove(oldFilterName);\n that.refresh();\n });\n rowNode.appendChild(filterNameSelect);\n\n // Filter verb\n const filterVerb = document.createElement('span');\n filterVerb.innerText = (columnDetails.filterMethod === 'field') ? ' contains ' : ' is ';\n rowNode.appendChild(filterVerb);\n\n // Filter range\n let filterRange = null;\n if (columnDetails.filterMethod !== 'field' && columnDetails.filterMethod !== 'dropdown') {\n filterRange = document.createElement('select');\n filterRange.setAttribute('class', 'mt-filter-range form-control form-control-inline');\n utils.appendOptions(filterRange, ['any', '=', '≠', '<', '>', '≤', '≥', 'BETWEEN'].map((v) => ({ text: v, value: v })));\n filterRange.addEventListener('change', function () {\n that.handleRangeChange(this);\n });\n rowNode.appendChild(filterRange);\n\n // Little space:\n rowNode.appendChild(document.createTextNode(' '));\n }\n\n // Filter value\n const filterValue = document.createElement('div');\n filterValue.style.display = 'inline-block';\n filterValue.setAttribute('class', 'mt-filter-value-container');\n\n if (columnDetails.filterMethod === 'compare') {\n ['min', 'max'].forEach((val, i) => {\n const filterInput = document.createElement('input');\n filterInput.setAttribute(\n 'class',\n `form-control form-control-inline mt-filter-value-${val}`,\n );\n filterInput.setAttribute('type', columnDetails.filterInputType);\n filterInput.addEventListener('keyup', this.maptable.render.bind(this.maptable));\n filterInput.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterInput);\n if (i === 0) {\n // AND\n const filterValueAnd = document.createElement('span');\n filterValueAnd.setAttribute('class', 'mt-filter-value-and');\n filterValueAnd.innerText = ' and ';\n filterValue.appendChild(filterValueAnd);\n }\n });\n } else if (columnDetails.filterMethod === 'field') {\n const filterInput = document.createElement('input');\n filterInput.setAttribute('class', 'form-control form-control-inline mt-filter-value');\n filterInput.setAttribute('type', 'text');\n filterInput.addEventListener('keyup', this.maptable.render.bind(this.maptable));\n filterInput.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterInput);\n } else if (columnDetails.filterMethod === 'dropdown') {\n const filterSelect = document.createElement('select');\n filterSelect.setAttribute('class', 'form-control form-control-inline mt-filter-value');\n\n const uniqueValues = d3.nest().key((d) => d[filterName])\n .sortKeys(d3.ascending)\n .entries(this.maptable.rawData);\n\n utils.appendOptions(filterSelect, [{ text: 'Any', value: '' }].concat(uniqueValues.map((k) => ({ text: k.key, value: k.key }))));\n\n filterSelect.addEventListener('change', this.maptable.render.bind(this.maptable));\n filterValue.appendChild(filterSelect);\n }\n\n rowNode.appendChild(filterValue);\n\n // We trigger it here to handle the value of the filter range\n if (filterRange) {\n this.handleRangeChange(filterRange);\n }\n\n return rowNode;\n }\n\n handleRangeChange(filterRange) {\n const rowNode = filterRange.parentNode;\n if (filterRange.value === 'any') {\n rowNode.querySelector('.mt-filter-value-container').style.display = 'none';\n } else {\n rowNode.querySelector('.mt-filter-value-container').style.display = 'inline-block';\n if (filterRange.value === 'BETWEEN') {\n rowNode.querySelector('.mt-filter-value-min').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-and').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-max').style.display = 'inline-block';\n } else {\n rowNode.querySelector('.mt-filter-value-min').style.display = 'inline-block';\n rowNode.querySelector('.mt-filter-value-and').style.display = 'none';\n rowNode.querySelector('.mt-filter-value-max').style.display = 'none';\n }\n }\n this.maptable.render.bind(this.maptable)();\n }\n\n getPossibleFilters(except) {\n return Object.keys(this.maptable.columnDetails)\n .map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k]))\n .filter((v) => (this.activeColumns.indexOf(v.key) !== -1)\n && (\n (except && except === v.key)\n || (this.criteria.indexOf(v.key) === -1 && v.filterMethod && !v.isVirtual)\n ));\n }\n\n filterData() {\n const that = this;\n this.maptable.data = this.maptable.rawData.filter((d) => {\n const rowNodes = this.node.querySelectorAll('.mt-filter-row');\n let matched = true;\n for (let i = 0; i < rowNodes.length && matched; i += 1) {\n const rowNode = rowNodes[i];\n const filterName = rowNode.getAttribute('data-mt-filter-name');\n const columnDetails = that.maptable.columnDetails[filterName];\n const fmt = columnDetails.dataParse; // shortcut\n\n if (columnDetails.filterMethod === 'dropdown') {\n const filterValue = rowNode.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n if (d[filterName] !== filterValue) matched = false;\n } else if (columnDetails.filterMethod === 'field') {\n const filterValue = rowNode.querySelector('.mt-filter-value').value;\n if (filterValue === '') continue;\n if (d[filterName].toLowerCase().indexOf(filterValue.toLowerCase()) === -1) {\n matched = false;\n }\n } else if (columnDetails.filterMethod === 'compare') {\n const filterRange = rowNode.querySelector('.mt-filter-range').value;\n if (filterRange === 'BETWEEN') {\n const filterValueMin = rowNode.querySelector('.mt-filter-value-min').value;\n const filterValueMax = rowNode.querySelector('.mt-filter-value-max').value;\n if (filterValueMin === '' || filterValueMax === '') continue;\n if (fmt\n && (fmt(d[filterName]) < fmt(filterValueMin)\n || fmt(d[filterName]) > fmt(filterValueMax))\n ) {\n matched = false;\n } else if (\n parseInt(d[filterName], 10) < parseInt(filterValueMin, 10)\n || parseInt(d[filterName], 10) > parseInt(filterValueMax, 10)\n ) {\n matched = false;\n }\n } else {\n const filterValue = rowNode.querySelector('.mt-filter-value-min').value;\n if (filterValue === '') continue;\n if (fmt && !utils.rangeToBool(fmt(d[filterName]), filterRange, fmt(filterValue))) {\n matched = false;\n } else if (!fmt && !utils.rangeToBool(d[filterName], filterRange, filterValue)) {\n matched = false;\n }\n }\n }\n\n if ((fmt && utils.isBlank(fmt(d[filterName]))) || utils.isBlank(d[filterName])) {\n matched = false;\n continue;\n }\n }\n return matched;\n });\n // save state\n if (this.options.saveState) this.maptable.saveState('filters', this.exportFilters());\n }\n\n refresh() {\n // update dropdown\n const filterNameSelects = this.node.querySelectorAll('.mt-filter-name');\n for (let i = 0; i < filterNameSelects.length; i += 1) {\n const filterNameSelect = filterNameSelects[i];\n const filterName = filterNameSelect.value;\n const possibleFilters = this.getPossibleFilters(filterName);\n filterNameSelect.innerHTML = '';\n utils.appendOptions(\n filterNameSelect,\n possibleFilters.map((f) => ({ text: f.title, value: f.key })),\n );\n filterNameSelect.value = filterName;\n }\n\n // Hide the first \"And\"\n if (this.node.querySelectorAll('.mt-filters-and').length > 0) {\n this.node.querySelectorAll('.mt-filters-and')[0].style.visibility = 'hidden';\n }\n\n // Check if we reached the maximum of allowed filters\n const disableNewFilter = (!this.getPossibleFilters().length);\n this.node.querySelector('#mt-filters-new').style.visibility = disableNewFilter\n ? 'hidden' : 'visible';\n }\n\n toggle() {\n if (this.container.style.display === 'none') {\n this.container.style.display = 'block';\n if (this.criteria.length === 0) {\n this.add();\n }\n } else {\n this.container.style.display = 'none';\n }\n }\n}\n","import utils from '../utils';\n\nexport default class Table {\n /**\n * Table componenet constructor\n * @param maptable: Maptable main Object\n * @param options: options communicated to the table\n * @returns {string|*}\n */\n constructor(maptable, options) {\n this.maptable = maptable;\n this.options = options;\n if (this.options.defaultSorting) {\n if (Array.isArray(this.options.defaultSorting) && this.options.defaultSorting.length === 2) {\n this.sorting = this.options.defaultSorting;\n } else {\n this.sorting = [this.options.defaultSorting];\n }\n this.sorting.forEach((s) => {\n if (!s.mode) s.mode = 'asc';\n });\n } else {\n this.sorting = [\n {\n key: Object.keys(this.maptable.data[0])[0],\n mode: 'asc',\n },\n ];\n }\n\n this.initialSorting = this.sorting.map((s) => `${s.key},${s.mode}`).join(';');\n this.isSorting = false;\n\n this.containerSelector = maptable.options.target;\n this.container = document.querySelector(maptable.options.target);\n\n this.node = this.container.querySelector('#mt-table');\n\n if (!this.node) {\n this.node = document.createElement('div');\n this.node.setAttribute('id', 'mt-table');\n this.maptable.node.appendChild(this.node);\n }\n\n this.node = d3.select(this.node).append('table').attr('class', this.options.className);\n\n this.header = this.node.append('thead');\n\n this.body = this.node.append('tbody');\n\n if (this.options.show) {\n const arrayDiff = this.options.show.filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0);\n if (arrayDiff.length > 0) {\n throw new Error(`MapTable: invalid columns \"${arrayDiff.join(', ')}\"`);\n }\n this.activeColumns = this.options.show;\n } else {\n this.activeColumns = Object.keys(this.maptable.columnDetails);\n }\n\n // make table header fixed\n if (this.options.header) {\n if (this.options.header.className) {\n this.header.attr('class', `${this.options.header.className}`);\n }\n\n // set custom top header space\n if (this.options.header.top) {\n this.header.attr('style', `top:${this.options.header.top || '0'}px;`);\n } else {\n this.header.attr('style', 'top:0px;');\n }\n }\n\n this.header\n .selectAll('tr')\n .data([1])\n .enter()\n .append('tr')\n .selectAll('th')\n .data(this.activeColumns.map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k])))\n .enter()\n .append('th')\n .attr('class', (d) => {\n let output = d.sorting ? 'mt-table-sortable' : '';\n output += d.nowrap ? ' nowrap' : '';\n return output;\n })\n .attr('data-key', (d) => utils.sanitizeKey(d.key))\n .attr('onselectstart', 'return false;')\n .attr('unselectable', 'on')\n .attr('style', (d) => (d.nowrap ? 'white-space:nowrap;' : ''))\n .on('click', (d) => {\n if (this.isSorting) return;\n this.isSorting = true;\n if (d.sorting) {\n this.sortColumn(d.key);\n }\n this.isSorting = false;\n })\n .text((d) => d.title)\n .attr('id', (d) => `column_header_${utils.sanitizeKey(d.key)}`);\n\n // render is triggered by MapTable\n // this.render();\n }\n\n /**\n * Restore state from the url hash\n */\n restoreState(sortingRaw) {\n if (!sortingRaw) return;\n const sortingList = sortingRaw.split(';');\n const defaultSorting = [];\n sortingList.forEach((s) => {\n const sortingData = s.split(',');\n defaultSorting.push({\n key: sortingData[0],\n mode: sortingData[1] || 'asc',\n });\n });\n this.sorting = defaultSorting;\n }\n\n /**\n * Save state into the url hash\n */\n saveState() {\n const encodedSorting = this.sorting.map((s) => `${s.key},${s.mode}`).join(';');\n if (encodedSorting !== this.initialSorting) {\n this.maptable.saveState('sort', encodedSorting);\n }\n }\n\n render() {\n // Apply Sort\n this.applySort();\n\n let tableData = this.maptable.data;\n if (this.options.distinctBy) {\n tableData = d3\n .nest()\n .key((d) => d[this.options.distinctBy])\n .entries(this.maptable.data)\n .map((g) => g.values[0]);\n }\n\n // Enter\n this.body.selectAll('tr').data(tableData).enter().append('tr');\n\n // Exit\n this.body.selectAll('tr').data(tableData).exit().remove();\n\n // Update\n const uniqueCollapsedRows = [];\n this.body\n .selectAll('tr')\n .data(tableData)\n .attr('class', (row) => {\n if (this.options.rowClassName) {\n return `line ${this.options.rowClassName(row)}`;\n }\n return 'line';\n })\n .html((row) => {\n let tds = '';\n this.activeColumns.forEach((columnKey) => {\n const column = this.maptable.columnDetails[columnKey];\n tds += ' {\n this.container.querySelector(`#column_header_${utils.sanitizeKey(column.key)}`).setAttribute('class', `mt-table-sortable sort_${column.mode}`);\n });\n this.maptable.data = this.maptable.data.sort((a, b) => {\n let compareBool = false;\n this.sorting.forEach((column) => {\n const d3SortMode = column.mode === 'asc' ? d3.ascending : d3.descending;\n const columnDetails = this.maptable.columnDetails[column.key];\n let el1 = a[column.key];\n let el2 = b[column.key];\n if (columnDetails.dataParse) {\n el1 = columnDetails.dataParse.bind(this.maptable)(el1);\n el2 = columnDetails.dataParse.bind(this.maptable)(el2);\n } else if (columnDetails.virtual) {\n el2 = columnDetails.virtual.bind(this.maptable)(a);\n el2 = columnDetails.virtual.bind(this.maptable)(b);\n } else if (columnDetails.filterType === 'compare') {\n el1 = Number(el1);\n el2 = Number(el2);\n }\n\n if (typeof el1 === 'string' && typeof el2 === 'string') {\n el1 = el1.toLowerCase();\n el2 = el2.toLowerCase();\n }\n compareBool = compareBool || d3SortMode(el1, el2);\n });\n return compareBool;\n });\n }\n\n /**\n * Sort Table by a column key\n * @param columnKey: String - column key\n */\n sortColumn(key) {\n const sortIndex = this.sorting.map((d) => d.key).indexOf(key);\n const sortValue = { key };\n if (sortIndex === -1) {\n sortValue.mode = 'desc';\n if (d3.event && d3.event.shiftKey) {\n this.sorting[1] = sortValue;\n } else {\n this.sorting = [sortValue];\n }\n } else {\n if (this.sorting[sortIndex].mode === 'asc') {\n this.sorting[sortIndex].mode = 'desc';\n } else {\n this.sorting[sortIndex].mode = 'asc';\n // this.sorting.splice(sortIndex, 1); // to disable sorting\n }\n if (!d3.event.shiftKey) {\n this.sorting = [this.sorting[sortIndex]];\n }\n }\n\n this.saveState();\n this.render();\n }\n}\n","import utils from './utils';\n\nimport GeoMap from './components/GeoMap';\nimport Filters from './components/Filters';\nimport Table from './components/Table';\n\nexport default class MapTable {\n constructor(target, options) {\n this.options = options;\n\n this.state = {};\n this.saveStateTimeout = {};\n this.removeStateTimeout = null;\n\n this.node = document.querySelector(target);\n this.node.setAttribute('style', 'position:relative;');\n\n if (this.options.data.type === 'json') {\n d3.json(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'csv') {\n d3.csv(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'tsv') {\n d3.tsv(this.options.data.path, this.loadData.bind(this));\n } else if (this.options.data.type === 'jsonData') {\n this.loadData(null, JSON.parse(this.options.data.value));\n } else if (this.options.data.type === 'csvData') {\n this.loadData(null, d3.csv.parse(this.options.data.value));\n } else if (this.options.data.type === 'tsvData') {\n this.loadData(null, d3.tsv.parse(this.options.data.value));\n } else if (this.options.data.type === 'data') {\n this.loadData(null, this.options.data.value);\n }\n\n if (this.options.map && this.options.map.heatmap) {\n delete this.options.map.countries;\n }\n }\n\n /**\n * Callback used when we pull the dataset\n * @param err: Error - error data if it happened\n * @param data: Object - dataset object\n */\n loadData(err, data) {\n if (err) {\n throw err;\n }\n this.rawData = data;\n\n if (this.options.data.preFilter) {\n this.rawData = this.rawData.filter(this.options.data.preFilter);\n }\n\n this.setColumnDetails();\n this.data = this.rawData.slice(); // we clone data, so that we can filter it\n // Map\n if (this.options.map) {\n // Map wrapper\n const mapWrapper = document.createElement('div');\n mapWrapper.setAttribute('class', 'mt-map-container');\n const isIE = (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0);\n if (this.options.map.heatmap && isIE) {\n mapWrapper.innerHTML = '
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
';\n this.node.insertBefore(mapWrapper, this.node.firstChild);\n mapWrapper.querySelector('.mt-loading').style.display = 'block';\n this.options.map = false;\n this.buildComponenents();\n return;\n }\n mapWrapper.innerHTML = '
Loading...
';\n this.node.insertBefore(mapWrapper, this.node.firstChild);\n mapWrapper.querySelector('.mt-loading').style.display = 'block';\n if (this.options.map.pathData) {\n this.loadMapData(null, JSON.parse(this.options.map.pathData), mapWrapper);\n } else if (this.options.map.path) {\n d3.json(this.options.map.path, (errGeoMap, jsonWorld) => {\n this.loadMapData(errGeoMap, jsonWorld, mapWrapper);\n });\n } else {\n throw new Error('missing map path|pathData');\n }\n } else {\n this.buildComponenents();\n }\n }\n\n loadMapData(errGeoMap, jsonWorld, mapWrapper) {\n if (errGeoMap) {\n throw errGeoMap;\n }\n this.map = new GeoMap(this, this.options.map, jsonWorld);\n\n mapWrapper.querySelector('.mt-loading').style.display = 'none';\n\n this.buildComponenents();\n }\n\n buildComponenents() {\n // Filters\n if (this.options.filters) {\n this.filters = new Filters(this, this.options.filters);\n }\n\n // Table\n if (this.options.table) {\n this.table = new Table(this, this.options.table);\n }\n\n // Restore state\n this.restoreState();\n window.addEventListener('hashchange', () => {\n this.restoreState();\n });\n\n // Render\n this.render();\n }\n\n /**\n * Load state from url\n * @param stateName: name of the state (either filters or zoom)\n * @param isJson: do we need to decode a json from the state?\n * @return loaded state\n */\n loadState(stateName, isJson) {\n // JSON state\n if (isJson) {\n const v = this.parseState(stateName);\n if (!v) return null;\n try {\n const parsedState = JSON.parse(v);\n this.state[stateName] = parsedState;\n } catch (e) {\n console.log(`Maptable: Invalid URL State for mt-${stateName} ${e.message}`);\n return null;\n }\n } else {\n const v = this.parseState(stateName);\n if (v) this.state[stateName] = v;\n }\n return this.state[stateName];\n }\n\n /**\n * Restore state for filters or/and map zooming and/or sorting\n */\n restoreState() {\n if (this.map) {\n this.loadState('zoom', true);\n this.map.restoreState(this.state.zoom);\n }\n\n if (this.filters) {\n this.loadState('filters', true);\n this.filters.restoreState(this.state.filters);\n }\n\n if (this.table) {\n this.loadState('sort', false);\n this.table.restoreState(this.state.sort);\n }\n }\n\n /**\n * Extract state from the url\n * @param stateName: name of the state (either filters or zoom)\n */\n parseState(stateName) {\n const params = document.location.href.replace(/%21mt/g, '!mt').split(`!mt-${stateName}=`);\n return (params[1]) ? decodeURIComponent(params[1].split('!mt')[0]) : null;\n }\n\n /**\n * Remove state\n * @param stateName: name of the state (either filters or zoom)\n */\n removeState(stateName) {\n window.clearTimeout(this.saveStateTimeout[stateName]);\n delete this.state[stateName];\n this.updateState();\n }\n\n /**\n * Save the state in this.state\n * @param stateName: name of the state (either filters or zoom)\n * @param stateData: object, contain state information\n */\n saveState(stateName, stateData) {\n window.clearTimeout(this.saveStateTimeout[stateName]);\n this.saveStateTimeout[stateName] = window.setTimeout(() => {\n this.state[stateName] = stateData;\n this.updateState();\n }, 200);\n }\n\n /**\n * Update state into the URL hash\n */\n updateState() {\n const newUrl = document.location.href.split('#')[0];\n let stateHash = '';\n Object.keys(this.state).forEach((k) => {\n if (!this.state[k]) return;\n let stateValue = this.state[k];\n if (typeof (this.state[k]) === 'object') {\n if (!Object.keys(this.state[k]).length) return;\n stateValue = JSON.stringify(this.state[k]);\n }\n stateHash += `!mt-${k}=${encodeURIComponent(stateValue)}`;\n });\n if (stateHash !== '') stateHash = `#${stateHash}`;\n if (document.location.href !== `${newUrl}${stateHash}`) {\n window.history.pushState(null, null, `${newUrl}${stateHash}`);\n }\n }\n\n render() {\n if (this.filters) {\n this.filters.filterData();\n this.filters.refresh();\n }\n\n if (this.map) {\n this.map.render();\n // On complete\n if (!this.firstExecution\n && this.options.map.onComplete\n && this.options.map.onComplete.constructor === Function\n ) {\n this.options.map.onComplete.bind(this)();\n }\n }\n\n if (this.table) {\n this.table.render();\n // On complete\n if (!this.firstExecution\n && this.options.table.onComplete\n && this.options.table.onComplete.constructor === Function\n ) {\n this.options.table.onComplete.bind(this)();\n }\n }\n\n // On complete\n if (!this.firstExecution\n && this.options.onComplete\n && this.options.onComplete.constructor === Function\n ) {\n this.options.onComplete.bind(this)();\n }\n this.firstExecution = true;\n }\n\n setColumnDetails() {\n const that = this;\n if (that.rawData.length === 0) {\n return;\n }\n const defaultColumns = {};\n\n Object.keys(that.rawData[0]).forEach((k) => {\n const patternNumber = /^[-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?$/;\n const isNumber = (patternNumber.test(that.rawData[0][k]));\n defaultColumns[k] = {\n title: utils.keyToTile(k),\n filterMethod: (isNumber) ? 'compare' : 'field',\n filterInputType: (isNumber) ? 'number' : 'text',\n sorting: true,\n };\n if (isNumber) {\n defaultColumns[k].dataParse = (val) => parseFloat(val);\n }\n });\n that.columnDetails = utils.extendRecursive(defaultColumns, this.options.columns);\n\n // add isVirtual to columns details\n Object.keys(that.columnDetails).forEach((k) => {\n that.columnDetails[k].isVirtual = (typeof (that.columnDetails[k].virtual) === 'function');\n });\n }\n}\n","/* eslint no-unused-vars: 0 */\nimport utils from './utils';\nimport defaultOptions from './defaultOptions';\nimport MapTable from './maptable';\n\nd3.maptable = function (target) {\n let maptableObject;\n const maptable = {};\n const options = {\n target,\n columns: {},\n data: {},\n map: null,\n filters: null,\n table: null,\n };\n\n maptable.map = function (mapOptions = {}) {\n if (!topojson) {\n throw new Error('Maptable requires topojson.js');\n }\n if (typeof mapOptions.path !== 'string' && typeof mapOptions.pathData !== 'string') {\n throw new Error('MapTable: map not provided');\n }\n options.map = mapOptions;\n return maptable;\n };\n\n maptable.data = function (data) {\n options.data.type = 'data';\n options.data.value = data;\n return maptable;\n };\n\n maptable.json = function (jsonPath, preFilter) {\n options.data.type = 'json';\n options.data.path = jsonPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.jsonData = function (jsonData) {\n options.data.type = 'jsonData';\n options.data.value = jsonData;\n return maptable;\n };\n\n maptable.csv = function (csvPath, preFilter) {\n options.data.type = 'csv';\n options.data.path = csvPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.csvData = function (csvData) {\n options.data.type = 'csvData';\n options.data.value = csvData;\n return maptable;\n };\n\n maptable.tsv = function (tsvPath, preFilter) {\n options.data.type = 'tsv';\n options.data.path = tsvPath;\n options.data.preFilter = preFilter;\n return maptable;\n };\n\n maptable.tsvData = function (tsvData) {\n options.data.type = 'tsvData';\n options.data.value = tsvData;\n return maptable;\n };\n\n maptable.filters = function (filtersOptions = {}) {\n options.filters = filtersOptions;\n return maptable;\n };\n\n maptable.table = function (tableOptions = {}) {\n options.table = tableOptions;\n return maptable;\n };\n\n maptable.columns = function (columns = {}) {\n options.columns = columns;\n return maptable;\n };\n\n maptable.render = function (onComplete) {\n if (typeof target !== 'string' || !document.querySelector(target)) {\n throw new Error('MapTable: target not found');\n }\n\n if (!options.data || !options.data.type) {\n throw new Error('MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData');\n }\n\n if (options.map && !options.map.heatmap) options.map.heatmap = null;\n\n if (options.map && options.map.markers === false) options.map.markers = null;\n\n if (options.map && options.map.countries === false) options.map.countries = null;\n\n if (!options.filters) options.filters = null;\n options.onComplete = onComplete;\n\n const customOptions = utils.extendRecursive(defaultOptions, options);\n\n if (options.map && !options.map.markers) delete customOptions.map.markers;\n if (options.map && !options.map.heatmap) delete customOptions.map.heatmap;\n if (options.map && !options.map.title) delete customOptions.map.title;\n if (options.map && !options.map.timezones) delete customOptions.map.timezones;\n if (options.map && !options.map.night) delete customOptions.map.night;\n if (!options.filters) delete customOptions.filters;\n if (!options.table) delete customOptions.table;\n\n maptableObject = new MapTable(target, customOptions);\n\n // public functions\n return {\n render: () => maptableObject.render(),\n loadState: (stateName, isJson) => maptableObject.loadState(stateName, isJson),\n removeState: (stateName) => maptableObject.removeState(stateName),\n saveState: (stateName, stateData) => maptableObject.saveState(stateName, stateData),\n setTitleContent: (title) => {\n maptableObject.options.map.title.content = () => title;\n },\n setData: (data) => {\n maptableObject.options.data.type = 'data';\n maptableObject.options.data.value = data;\n maptableObject.options.rawData = data;\n maptableObject.rawData = data;\n maptableObject.data = data;\n if (maptableObject.map) {\n maptableObject.map.enrichData();\n }\n },\n setNightDate: (date) => {\n maptableObject.options.map.night.date = date;\n },\n setTimezonesDate: (date) => {\n maptableObject.options.map.timezones.date = date;\n },\n getMapWidth: () => maptableObject.map.getWidth(),\n getMapHeight: () => maptableObject.map.getHeight(),\n };\n };\n return maptable;\n};\n\nif (!d3) {\n throw new Error('Maptable requires d3.js');\n}\n\nexport default d3.maptable;\n"],"names":["appendOptions","select","options","defaultValue","forEach","f","option","document","createElement","setAttribute","value","innerText","text","appendChild","rangeToBool","el1","range","el2","parseInt","extendRecursive","dst","src","args","splice","call","arguments","toString","length","Object","keys","p","keyToTile","k","upperK","charAt","toUpperCase","slice","replace","sanitizeKey","toLowerCase","toNumber","str","resStr","Number","quantile","array","percentile","sort","a","b","index","result","Math","floor","i","fraction","uniqueValues","arr","l","indexOf","push","formatDate","d","zone","newDate","Date","getTime","toISOString","split","substr","isBlank","undefined","map","longitudeKey","latitudeKey","countryIdentifierKey","countryIdentifierType","zoom","saveState","exportSvg","exportSvgClient","ratioFromWidth","scaleHeight","scaleZoom","fitContentMargin","autoFitContent","tooltipClassName","countries","legend","attr","fill","stroke","heatmap","mask","weightByAttribute","weightByAttributeScale","circles","min","max","step","color","colorStrength","blur","borders","opacity","markers","r","title","fontSize","fontFamily","filters","table","className","collapseRowsBy","Legend","legendWidth","node","svg","append","getWidth","getHeight","buildIndice","domain","legendGradient","minNegative","maxNegative","midPercentNegative","round","midPercentPositive","indice","style","selectAll","toLocaleString","buildScale","val","isNaN","maxValue","minValue","positionDelta","position","width","height","padding","console","warn","window","btoa","buildWatermark","d3","xhr","res","mapWatermarkDelta","mime","x","y","dataUri","responseText","pos","mul_table","shg_table","processImage","img","canvas","radius","blurAlphaChannel","getElementById","HTMLImageElement","w","naturalWidth","h","naturalHeight","HTMLCanvasElement","context","getContext","clearRect","drawImage","processCanvasRGBA","processCanvasRGB","getImageDataFromCanvas","top_x","top_y","imageData","getImageData","e","Error","processImageDataRGBA","putImageData","pixels","data","yp","yi","yw","r_sum","g_sum","b_sum","a_sum","r_out_sum","g_out_sum","b_out_sum","a_out_sum","r_in_sum","g_in_sum","b_in_sum","a_in_sum","pr","pg","pb","pa","rbs","div","w4","widthMinus1","heightMinus1","radiusPlus1","sumFactor","stackStart","BlurStack","stack","next","stackEnd","stackIn","stackOut","mul_sum","shg_sum","g","processImageDataRGB","image","canvasRGBA","canvasRGB","imageDataRGBA","imageDataRGB","π","PI","radians","degrees","solarGeometricMeanAnomaly","centuries","solarGeometricMeanLongitude","solarEquationOfCenter","m","sin","solarTrueLongitude","solarApparentLongitude","meanObliquityOfEcliptic","obliquityCorrection","cos","solarDeclination","asin","eccentricityEarthOrbit","equationOfTime","tan","antipode","solarPosition","time","UTC","longitude","day","utc","GeoMap","maptable","jsonWorld","scale","transX","transY","containerSelector","target","container","querySelector","mapWrapper","existingMap","parentNode","insertBefore","removeChild","projection","geo","equirectangular","translate","rotate","precision","path","enrichData","zoomListener","behavior","scaleExtent","on","rescale","bind","tooltipMarkersNode","tooltipCountriesNode","layerGlobal","layerDefs","html","timezones","layerTimezones","layerCountries","night","layerNight","layerHeatmap","layerMarkers","watermark","Watermark","buildTitle","addExportSvgCapability","addEventListener","loadGeometries","rawData","parseFloat","latitude","coord","pow","offsetWidth","deltaHeight","filterCountries","objects","geometries","filter","buildCountries","buildHeatmap","buildNight","pathData","buildTimezone","lands","topojson","merge","disableMask","maskHeatmap","datum","imgHeatmap","mesh","bordersHeatmap","enter","circle","angle","maskNight","nightPath","cssBlur","userDate","date","startOfDay","getUTCFullYear","getUTCMonth","getUTCDate","solarPositionDated","origin","nightPathRight","nightPathLeft","disableSun","sunCoords","sunCircleRight","sunCircleXRight","sunCircleLeft","sunCircleXLeft","loadTimezone","JSON","parse","json","errGeoMap","jsonTimezones","err","dataTimezones","feature","features","maskTimezone","properties","places","insert","stringify","timezoneTexts","timezoneTextsUnique","Map","item","values","layerTimezonesText","scaleFontSize","utils","heatmapDataset","opts","lengthDataset","maxOpacityScale","linear","centralCircleOpacity","dataExtents","extent","userScale","log","canvasHeatmap","ctx","globalCompositeOperation","datumScale","getDatumScale","magnitudeScale","getMagnitudeScale","colorScale","beginPath","rect","fillStyle","closePath","colorMultiplier","aa","point","scaleOpacityDatum","StackBlur","dataUrl","toDataURL","remove","getHeatmapData","dataCountries","legendCountry","shouldRenderLegend","aggregate","allMtMapCountry","allMtMapMarker","dataByCountry","key","has","set","get","geoDatum","matchedCountry","rollupValue","setAttrValues","countryItem","getAllMtMapCountry","each","selection","attrKey","attrValue","scaleDomain","attrProperties","updateExtents","indiceChange","NaN","tooltip","activateTooltip","endOfDay","totalMilliseconds","currentTime","relativeTranslateX","transform","querySelectorAll","currentDate","Array","from","timezoneText","textContent","__data__","defaultGroupBy","dataMarkers","nest","entries","markerItem","markerObject","customTag","markerClassName","exit","transition","attrX","attrY","attrXDelta","attrYDelta","markerUpdate","getAllMtMapMarker","hor","ver","ratio","deltaMarker","currentWidth","currentHeight","realHeight","realWidth","diffMarginWidth","diffMarginHeight","titleContainer","bgColor","source","originalTranslation","newTx","newTy","encodedTranslation","defaultZoom","decodeTranslation","event","encodeTranslation","exportedData","removeState","self","maxTransX","maxTransY","minTransX","minTransY","scaleAttributes","firstExecution","dataset","mode","scaleToUse","rollup","groupedData","reduce","c","validData","groupedValues","exponent","sqrt","aggregatedValue","columnDetails","formatted","cellContent","positiveRanks","concat","v","negativeRanks","ranks","newValue","useNegative","scaleFunction","scaleNegativeFunction","copy","scaledValue","empty","originalValueRaw","originalValue","updateMarkers","updateCountries","updateNight","updateTimezones","updateTitle","updateHeatmap","fitContent","onRender","constructor","Function","content","showing","total","inlineFilters","getDescription","innerHTML","tooltipNode","tooltipContent","isCountry","mouseLeft","mouseTop","tooltipDelta","mapRect","getBoundingClientRect","mousePosition","mouse","left","top","targetRect","svgXml","XMLSerializer","serializeToString","saveAs","blob","Blob","type","form","submit","exportNode","exportButton","exportForm","Filters","criteria","show","arrayDiff","join","activeColumns","filtersHeaderNode","filtersResetNode","display","marginLeft","reset","filtersTitleNode","createTextNode","filtersBodyNode","filtersElementsNode","filtersNewNode","add","evt","preventDefault","possibleFilters","getPossibleFilters","filterName","create","replaceNode","rowNode","buildRow","replaceChild","render","toggle","filterIndex","rowNodes","output","filtersChildren","childNodes","element","filterOutput","filterMethod","filterRangeSelect","filterValueMin","filterValueMax","filterValue","criterion","row","decodeURIComponent","defaultCriteria","setFilters","outputArray","line","selectedIndex","separatorWord","that","minusButton","filterSeparator","filterNameSelect","oldFilterName","getAttribute","newFilterName","refresh","filterVerb","filterRange","handleRangeChange","filterInput","filterInputType","filterValueAnd","filterSelect","sortKeys","ascending","except","isVirtual","matched","fmt","dataParse","exportFilters","filterNameSelects","visibility","disableNewFilter","Table","defaultSorting","isArray","sorting","s","initialSorting","isSorting","header","body","nowrap","sortColumn","sortingRaw","sortingList","sortingData","encodedSorting","applySort","tableData","distinctBy","uniqueCollapsedRows","rowClassName","tds","columnKey","column","virtual","sortableColums","compareBool","d3SortMode","descending","filterType","sortIndex","sortValue","shiftKey","MapTable","state","saveStateTimeout","removeStateTimeout","loadData","csv","tsv","preFilter","setColumnDetails","isIE","navigator","userAgent","appVersion","firstChild","buildComponenents","loadMapData","restoreState","stateName","isJson","parseState","parsedState","message","loadState","params","location","href","clearTimeout","updateState","stateData","setTimeout","newUrl","stateHash","stateValue","encodeURIComponent","history","pushState","filterData","onComplete","defaultColumns","patternNumber","isNumber","test","columns","maptableObject","mapOptions","jsonPath","jsonData","csvPath","csvData","tsvPath","tsvData","filtersOptions","tableOptions","customOptions","defaultOptions","setTitleContent","setData","setNightDate","setTimezonesDate","getMapWidth","getMapHeight"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA,SAASA,aAAT,CAAuBC,MAAvB,EAA+BC,OAA/B,EAAwCC,YAAxC,EAAsD;AACpDD,IAAAA,UAAQE,OAAR,CAAgB,UAACC,CAAD,EAAO;AACrB,IAAA;AACA,IAAA,QAAMC,SAASC,SAASC,aAAT,CAAuB,QAAvB,CAAf;AACAF,IAAAA,WAAOG,YAAP,CAAoB,OAApB,EAA6BJ,EAAEK,KAA/B;AACAJ,IAAAA,WAAOK,SAAP,GAAmBN,EAAEO,IAArB;AACAX,IAAAA,WAAOY,WAAP,CAAmBP,MAAnB;AACD,IAAA,GAND;AAOAL,IAAAA,SAAOS,KAAP,GAAeP,YAAf;AACD,IAAA;;AAED,IAAA,SAASW,WAAT,CAAqBC,GAArB,EAA0BC,KAA1B,EAAiCC,GAAjC,EAAsC;AACpC,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,MAAsBG,SAASD,GAAT,EAAc,EAAd,CAA7B;AACD,IAAA;AACD,IAAA,MAAID,UAAU,GAAd,EAAmB;AACjB,IAAA,WAAOE,SAASH,GAAT,EAAc,EAAd,MAAsBG,SAASD,GAAT,EAAc,EAAd,CAAtB,IAA2CF,QAAQ,E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,CAAiC0C,IAAjC,GAAwCA,IAAxC;AACD,IAAA,OApBI;AAqBLuY,IAAAA,wBAAkB,0BAACvY,IAAD,EAAU;AAC1BwX,IAAAA,uBAAevsB,OAAf,CAAuBsE,GAAvB,CAA2B4N,SAA3B,CAAqC6C,IAArC,GAA4CA,IAA5C;AACD,IAAA,OAvBI;AAwBLwY,IAAAA,mBAAa;AAAA,IAAA,eAAMhB,eAAejoB,GAAf,CAAmB+C,QAAnB,EAAN;AAAA,IAAA,OAxBR;AAyBLmmB,IAAAA,oBAAc;AAAA,IAAA,eAAMjB,eAAejoB,GAAf,CAAmBgD,SAAnB,EAAN;AAAA,IAAA;AAzBT,IAAA,KAAP;AA2BD,IAAA,GA1DD;AA2DA,IAAA,SAAO2I,QAAP;AACD,IAAA,CA/ID;;AAiJA,IAAA,IAAI,CAAC/G,EAAL,EAAS;AACP,IAAA,QAAM,IAAIoC,KAAJ,CAAU,yBAAV,CAAN;AACD,IAAA;;AAED,gBAAepC,GAAG+G,QAAlB;;;;"} \ No newline at end of file diff --git a/dist/maptable.min.js b/dist/maptable.min.js index 1a3a319..ff11399 100644 --- a/dist/maptable.min.js +++ b/dist/maptable.min.js @@ -1,7 +1,7 @@ /** - * MapTable 2.4.0 - License MIT - Build: Tue Feb 27 2024 17:08:13 GMT+0100 (Central European Standard Time) + * MapTable 2.4.0 - License MIT - Build: Fri May 17 2024 16:15:20 GMT+0545 (Nepal Time) */ -this.d3=this.d3||{},this.d3.maptable=function(){"use strict";function t(t,e,a){e.forEach(function(e){var a=document.createElement("option");a.setAttribute("value",e.value),a.innerText=e.text,t.appendChild(a)}),t.value=a}function e(t,e,a){return"="===e?parseInt(t,10)===parseInt(a,10):"≠"===e?parseInt(t,10)!==parseInt(a,10)&&""!==t&&""!==a:">"===e?parseInt(t,10)>parseInt(a,10)&&""!==t&&""!==a:"<"===e?parseInt(t,10)=parseInt(a,10)&&""!==t&&""!==a:"≤"===e?parseInt(t,10)<=parseInt(a,10)&&""!==t&&""!==a:!0}function a(){for(var t={},e=void 0,i=[].splice.call(arguments,0),n={}.toString;i.length>0;)e=i.splice(0,1)[0],"[object Object]"===n.call(e)&&Object.keys(e).forEach(function(i){"[object Object]"===n.call(e[i])?t[i]=a(t[i]||{},e[i]):t[i]=e[i]});return t}function i(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return e.replace(/_/g," ")}function n(t){return t.toLowerCase().replace(/ /g,"_").replace(/"/g,"").replace(/'/g,"")}function r(t){if(!t||""===t)return null;var e=t.toString().replace(/[^0-9.]+|\s+/gim,"");return""!==e?Number(e):null}function s(t,e){t.sort(function(t,e){return t-e});var a=e/100*(t.length-1),i=void 0;if(Math.floor(a)===a)i=t[a];else{var n=Math.floor(a),r=a-n;i=t[n]+(t[n+1]-t[n])*r}return i}function o(t){if(!t)return t;for(var e=[],a=0,i=t.length;i>a;a+=1)-1===e.indexOf(t[a])&&""!==t[a]&&e.push(t[a]);return e}function l(t,e,a,i){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLImageElement&&!t instanceof HTMLImageElement)return;var n=t.naturalWidth,r=t.naturalHeight;if("string"==typeof e)var e=document.getElementById(e);else if("undefined"!=typeof HTMLCanvasElement&&!e instanceof HTMLCanvasElement)return;e.style.width=n+"px",e.style.height=r+"px",e.width=n,e.height=r;var s=e.getContext("2d");s.clearRect(0,0,n,r),s.drawImage(t,0,0),Number.isNaN(a)||1>a||(i?p(e,0,0,n,r,a):d(e,0,0,n,r,a))}function h(t,e,a,i,n){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLCanvasElement&&!t instanceof HTMLCanvasElement)return;var r,s=t.getContext("2d");try{try{r=s.getImageData(e,a,i,n)}catch(o){throw new Error("unable to access local image data: "+o)}}catch(o){throw new Error("unable to access image data: "+o)}return r}function p(t,e,a,i,n,r){if(!(Number.isNaN(r)||1>r)){r|=0;var s=h(t,e,a,i,n);s=u(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function u(t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,z[h]=(c*Y>>U)*D,z[h+1]=(f*Y>>U)*D,z[h+2]=(g*Y>>U)*D):z[h]=z[h+1]=z[h+2]=0,c-=y,f-=b,g-=k,v-=x,y-=R.r,b-=R.g,k-=R.b,x-=R.a,h=s+((h=o+O)r)){r|=0;var s=h(t,e,a,i,n);s=c(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function c(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,E,N=t.data,T=r+r+1,D=i-1,A=n-1,z=r+1,F=z*(z+1)/2,j=new m,H=j;for(l=1;T>l;l++)if(H=H.next=new m,l==z)var O=H;H.next=j;var P=null,I=null;d=u=0;var L=q[r],B=W[r];for(o=0;n>o;o++){for(k=x=w=c=f=g=0,v=z*(C=N[u]),y=z*(S=N[u+1]),b=z*(M=N[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(l=1;z>l;l++)h=u+((l>D?D:l)<<2),c+=(H.r=C=N[h])*(E=z-l),f+=(H.g=S=N[h+1])*E,g+=(H.b=M=N[h+2])*E,k+=C,x+=S,w+=M,H=H.next;for(P=j,I=O,s=0;i>s;s++)N[u]=c*L>>B,N[u+1]=f*L>>B,N[u+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=d+((h=s+r+1)s;s++){for(x=w=k=f=g=c=0,u=s<<2,v=z*(C=N[u]),y=z*(S=N[u+1]),b=z*(M=N[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(p=i,l=1;r>=l;l++)u=p+s<<2,c+=(H.r=C=N[u])*(E=z-l),f+=(H.g=S=N[u+1])*E,g+=(H.b=M=N[u+2])*E,k+=C,x+=S,w+=M,H=H.next,A>l&&(p+=i);for(u=s,P=j,I=O,o=0;n>o;o++)h=u<<2,N[h]=c*L>>B,N[h+1]=f*L>>B,N[h+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=s+((h=o+z)e?e+360:e)/180*O}function v(t){var e=f(t);return(Math.sin(e)*(1.914602-t*(.004817+14e-6*t))+Math.sin(e+e)*(.019993-101e-6*t)+289e-6*Math.sin(e+e+e))*P}function y(t){return g(t)+v(t)}function b(t){return y(t)-(.00569+.00478*Math.sin((125.04-1934.136*t)*P))*P}function k(t){return(23+(26+(21.448-t*(46.815+t*(59e-5-.001813*t)))/60)/60)*P}function x(t){return k(t)+.00256*Math.cos((125.04-1934.136*t)*P)*P}function w(t){return Math.asin(Math.sin(x(t))*Math.sin(b(t)))}function C(t){return.016708634-t*(42037e-9+1.267e-7*t)}function S(t){var e=C(t),a=f(t),i=g(t),n=Math.tan(x(t)/2);return n*=n,n*Math.sin(2*i)-2*e*Math.sin(a)+4*e*n*Math.sin(a)*Math.cos(2*i)-.5*n*n*Math.sin(4*i)-1.25*e*e*Math.sin(2*a)}function M(t){return[t[0]+180,-t[1]]}function E(t){var e=(t-Date.UTC(2e3,0,1,12))/864e5/36525,a=(d3.time.day.utc.floor(t)-t)/864e5*360-180;return[a-S(e)*I,w(e)*I]}var N={};N["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},N.createClass=function(){function t(t,e){for(var a=0;a\n \n \n \n \n \n '),this.options.timezones&&(this.layerTimezones=this.layerGlobal.append("g").attr("class","mt-map-timezones")),this.layerCountries=this.layerGlobal.append("g").attr("class","mt-map-countries"),this.options.night&&(this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night")),this.options.heatmap&&(this.layerHeatmap=this.layerGlobal.append("g").attr("class","mt-map-heatmap")),this.layerMarkers=this.layerGlobal.append("g").attr("class","mt-map-markers"),this.options.watermark&&(this.watermark=new j(this,this.options.watermark)),this.options.title&&this.buildTitle(),(this.options.exportSvgClient||this.options.exportSvg)&&this.addExportSvgCapability(),this.options.width||window.addEventListener("resize",function(){n.svg.attr("width",n.getWidth()),n.svg.attr("height",n.getHeight()),n.rescale()}),this.loadGeometries()}return N.createClass(t,[{key:"enrichData",value:function(){var t=this;this.maptable.rawData.forEach(function(e){e.longitude=parseFloat(e[t.options.longitudeKey]),e.latitude=parseFloat(e[t.options.latitudeKey]);var a=[0,0];Number.isNaN(e.longitude)||Number.isNaN(e.latitude)||(a=t.projection([e.longitude,e.latitude])),e.x=a[0],e.y=a[1]})}},{key:"scaleAttributes",value:function(){return Math.pow(this.scale,2/3)}},{key:"getWidth",value:function(){return this.options.width?this.options.width:(this.options.width=this.node.offsetWidth,this.node.offsetWidth)}},{key:"getHeight",value:function(){var t=this.options.title?30:0;return!this.options.height&&this.options.ratioFromWidth?this.getWidth()*this.options.ratioFromWidth*this.options.scaleHeight+t:this.options.height*this.options.scaleHeight+t}},{key:"loadGeometries",value:function(){this.options.filterCountries&&(this.jsonWorld.objects.countries.geometries=this.jsonWorld.objects.countries.geometries.filter(this.options.filterCountries)),this.options.countries&&this.buildCountries(),this.options.heatmap&&this.buildHeatmap(),this.options.night&&this.buildNight(),this.options.timezones&&(this.options.timezones.path||this.options.timezones.pathData)&&this.buildTimezone()}},{key:"buildHeatmap",value:function(){var t=topojson.merge(this.jsonWorld,this.jsonWorld.objects.countries.geometries);if(this.options.heatmap.disableMask||(this.maskHeatmap=this.layerHeatmap.append("defs").append("clipPath").attr("id","mt-map-heatmap-mask"),this.maskHeatmap.datum(t).append("path").attr("class","mt-map-heatmap-mask-paths").attr("d",this.path)),this.imgHeatmap=this.layerHeatmap.append("image").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("x",0).attr("y",0).attr("class","mt-map-heatmap-img"),this.options.heatmap.mask&&(this.imgHeatmap=this.imgHeatmap.attr("clip-path","url(#mt-map-heatmap-mask)")),this.options.heatmap.borders){var e=topojson.mesh(this.jsonWorld,this.jsonWorld.objects.countries,function(t,e){return t!==e});this.bordersHeatmap=this.layerHeatmap.append("g").attr("class","mt-map-heatmap-borders"),this.bordersHeatmap.selectAll("path.mt-map-heatmap-borders-paths").data([t,e]).enter().append("path").attr("class","mt-map-heatmap-borders-paths").attr("fill","none").attr("stroke-width",this.options.heatmap.borders.stroke).attr("stroke",this.options.heatmap.borders.color).attr("style","opacity: "+this.options.heatmap.borders.opacity).attr("d",this.path)}}},{key:"buildNight",value:function(){this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night");var t=d3.geo.circle().angle(90);this.maskNight=this.layerNight.append("defs").append("clipPath").attr("id","mt-map-night-mask"),this.maskNight.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.nightPath=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.path).style("opacity",.1);var e=this.options.night.date||Date.UTC(),a=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),0,0,0),i=E(new Date(a));if(this.nightPath.datum(t.origin(M(i))).attr("d",this.path),this.nightPathRight=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+this.getWidth()+"px,0,0)"),this.nightPathLeft=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+-this.getWidth()+"px,0,0)"),!this.options.night.disableSun){var n=this.projection(i);this.sunCircleRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]+this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]-this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]-2*this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight())}}},{key:"buildTimezone",value:function(){var t=this;this.options.timezones.pathData?this.loadTimezone(null,JSON.parse(this.options.timezones.pathData)):this.options.timezones.path&&d3.json(this.options.timezones.path,function(e,a){t.loadTimezone(e,a)})}},{key:"scaleFontSize",value:function(t){return this.getWidth()<700?t*(this.getWidth()/700):t}},{key:"loadTimezone",value:function(t,e){var a=this;this.dataTimezones=topojson.feature(e,e.objects.timezones).features,this.maskTimezone=this.layerTimezones.append("defs").append("clipPath").attr("id","mt-map-timezone-mask"),this.maskTimezone.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.layerTimezones.selectAll(".mt-map-timezone").data(this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places})).enter().insert("path").attr("class","mt-map-timezone").attr("d",this.path).attr("fill",function(t){return t.properties.zone%2===0?"#F4F5F5":"transparent"}).attr("title",function(t){return JSON.stringify(t.properties)}).attr("clip-path","url(#mt-map-timezone-mask)").style("opacity",.6);var i=this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places&&t.properties.zone%1===0&&14!==t.properties.zone}),n=[].concat(N.toConsumableArray(new Map(i.map(function(t){return[t.properties.zone,t]})).values()));this.layerTimezonesText=this.layerTimezones.append("g").attr("class","mt-map-timezones-texts"),this.layerTimezonesText.selectAll(".mt-map-timezone-text").data(n).enter().insert("text").attr("class","mt-map-timezone-text").attr("y",.82*this.getHeight()-5).attr("x",function(t){return(t.properties.zone+10)*(a.getWidth()/24.5)-1}).attr("dx",this.getWidth()/24.5/2).attr("font-size",this.scaleFontSize(9)).attr("font-family","Helevetica, Arial, Sans-Serif").attr("fill","#999").attr("text-anchor","middle").html(function(t){return A.formatDate(a.options.timezones.date||new Date,t.properties.zone)})}},{key:"getMagnitudeScale",value:function(t){var e=this.options.heatmap,a=t.length;if(!a)return function(){return 0};var i=d3.scale.linear().domain([1,a]).range([1,.25]),n=i(a),r=d3.scale.linear().domain([e.circles.min,20]).range([n,0]);return function(t){return r(t)}}},{key:"getDatumScale",value:function(){var t=this;if(!this.options.heatmap.weightByAttribute)return function(){return 1};var e=d3.extent(this.maptable.data,this.options.heatmap.weightByAttribute),a="log"===this.options.heatmap.weightByAttributeScale?d3.scale.log:d3.scale.linear,i=a().domain(e).range([.5,1]);return function(e){var a=t.options.heatmap.weightByAttribute(e);return a?i(a):0}}},{key:"getHeatmapData",value:function(){var t=this,e=d3.select(this.node).append("canvas").attr("id","mt-map-heatmap-canvas").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("style","display: none;"),a=e.node().getContext("2d");a.globalCompositeOperation="multiply";var i=d3.range(this.options.heatmap.circles.min,this.options.heatmap.circles.max,this.options.heatmap.circles.step),n=this.getDatumScale(),r=this.maptable.data.filter(function(t){return n(t)>.1}),s=this.path.context(a),o=this.getMagnitudeScale(r),l=d3.scale.linear().domain([1,0]).range(["#000000","#FFFFFF"]);a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle="#ffffff",a.fill(),a.closePath();var h=function(e){var a=t.options.heatmap.circles.colorStrength,i=1+(a-1)/100;return a>1?(2-i)*e+i-1:a*e};r.forEach(function(t){var e=n(t);i.forEach(function(i){var n=h(o(i)*e);n>0&&(a.beginPath(),s(d3.geo.circle().origin([t.longitude,t.latitude]).angle(i-1e-4)()),a.fillStyle=l(n),a.fill(),a.closePath())})}),H.canvasRGBA(e.node(),0,0,this.getWidth(),this.getHeight(),this.options.heatmap.circles.blur),a.beginPath(),a.globalCompositeOperation="screen",a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle=this.options.heatmap.circles.color,a.fill(),a.closePath();var p=e.node().toDataURL();return e.remove(),p}},{key:"updateHeatmap",value:function(){var t=this.getHeatmapData();this.imgHeatmap.attr("xlink:href",t)}},{key:"buildCountries",value:function(){this.dataCountries=topojson.feature(this.jsonWorld,this.jsonWorld.objects.countries).features,this.layerCountries.selectAll(".mt-map-country").data(this.dataCountries).enter().insert("path").attr("class","mt-map-country").attr("d",this.path),this.legendCountry={},this.shouldRenderLegend()&&(this.legendCountry.fill=new F(this))}},{key:"shouldRenderLegend",value:function(){var t=this.options.countries.attr.fill;if(!t)return!1;if(!t.legend||!t.min||!t.max)return!1;if(t.aggregate&&t.aggregate.scale){var e="function"==typeof t.aggregate.scale?t.aggregate.scale.bind(this.maptable)():t.aggregate.scale;if("linear"!==e)return!1}return!0}},{key:"getAllMtMapCountry",value:function(){return this.allMtMapCountry?this.allMtMapCountry:(this.allMtMapCountry=d3.selectAll(this.containerSelector+" .mt-map-country"),this.allMtMapCountry)}},{key:"getAllMtMapMarker",value:function(){return this.allMtMapMarker?this.allMtMapMarker:(this.allMtMapMarker=d3.selectAll(this.containerSelector+" .mt-map-marker"),this.allMtMapMarker)}},{key:"updateCountries",value:function(){var t=this,e=new Map;this.maptable.data.forEach(function(a){var i=a[t.options.countryIdentifierKey];e.has(i)||e.set(i,[]),e.get(i).push(a)}),this.dataCountries.forEach(function(a){a.key=a.properties[t.options.countryIdentifierType];var i=e.get(a.key);a.values=i||[],a.attr={},a.rollupValue={}}),Object.keys(this.options.countries.attr).forEach(function(e){t.setAttrValues(e,t.options.countries.attr[e],t.dataCountries)});var a=this.getAllMtMapCountry().each(function(t){var e=d3.select(this);Object.keys(t.attr).forEach(function(a){e.attr(a,t.attr[a])})});Object.keys(this.options.countries.attr).forEach(function(e){var i=t.options.countries.attr[e];if("object"===("undefined"==typeof i?"undefined":N["typeof"](i))&&i.legend&&void 0!==t.legendCountry[e]){var n=d3.extent(t.dataCountries,function(t){return Number(t.attrProperties[e].value)});t.legendCountry[e].updateExtents(n),a.on("mouseover",function(a){t.legendCountry[e].indiceChange(a.attrProperties[e].value)}).on("mouseout",function(){t.legendCountry[e].indiceChange(NaN)})}}),this.options.countries&&this.options.countries.tooltip&&this.activateTooltip(a,this.tooltipCountriesNode,this.options.countries.tooltip,!0)}},{key:"updateNight",value:function(){var t=this.options.night.date||Date.UTC(),e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0),a=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),23,59,59),i=a-e,n=t-e,r=n/i;this.layerNight.node().style.transform="translateX("+-this.getWidth()*r+"px)"}},{key:"updateTimezones",value:function(){var t=document.querySelectorAll(".mt-map-timezone-text"),e=this.options.timezones.date||new Date;Array.from(t).forEach(function(t){t.textContent=A.formatDate(e,t.__data__.properties.zone)})}},{key:"updateMarkers",value:function(){var t=this,e=function(t){return t.longitude+","+t.latitude};this.dataMarkers=d3.nest().key(e).entries(this.maptable.data).filter(function(t){return 0!==t.values[0].x}),this.dataMarkers.forEach(function(t){t.attr={},t.attrProperties={}}),Object.keys(this.options.markers.attr).forEach(function(e){t.setAttrValues(e,t.options.markers.attr[e],t.dataMarkers)});var a=this.layerMarkers.selectAll(".mt-map-marker").data(this.dataMarkers),i=a.enter();i=this.options.markers.customTag?this.options.markers.customTag(i):i.append("svg:circle");var n=this.options.markers.className?this.options.markers.className:"";i.attr("class","mt-map-marker "+n),a.exit().transition().attr("r",0).attr("fill","#eee").style("opacity",0).remove();var r=this.options.markers.attrX?this.options.markers.attrX:"cx",s=this.options.markers.attrY?this.options.markers.attrY:"cy",o=this.options.markers.attrXDelta?this.options.markers.attrXDelta:0,l=this.options.markers.attrYDelta?this.options.markers.attrYDelta:0,h=a.attr(r,function(t){return t.values[0].x+o}).attr(s,function(t){return t.values[0].y+l});this.getAllMtMapMarker().each(function(t){var e=this;Object.keys(t.attr).forEach(function(a){d3.select(e).attr(a,t.attr[a])})}),this.options.markers.tooltip&&this.activateTooltip(h,this.tooltipMarkersNode,this.options.markers.tooltip,!1),this.rescale()}},{key:"fitContent",value:function(){if(0===this.maptable.data.length)return this.transX=0,this.transY=0,this.scale=1,void this.zoomListener.translate([this.transX,this.transY]).scale(this.scale);var t=d3.extent(this.maptable.data,function(t){return t.x}),e=d3.extent(this.maptable.data,function(t){return t.y}),a=this.getWidth()/this.getHeight(),i=20+(this.options.title?30:0),n=t[1]-t[0]+i,r=e[1]-e[0]+i,s=n/a,o=r*a,l=0,h=0;o>=n?l=(o-n)/2:h=(s-r)/2,t[0]-=this.options.fitContentMargin+l,t[1]+=this.options.fitContentMargin+l,e[0]-=this.options.fitContentMargin+h,e[1]+=this.options.fitContentMargin+h,this.scale=this.getWidth()/(t[1]-t[0]),this.transX=-1*t[0]*this.scale,this.transY=-1*e[0]*this.scale,this.zoomListener.translate([this.transX,this.transY]).scale(this.scale); -}},{key:"buildTitle",value:function(){var t=this.svg.append("svg").attr("width",this.getWidth()).attr("x",0).attr("y",this.getHeight()-30).attr("height",30);this.options.title.bgColor&&t.append("rect").attr("x",0).attr("y",0).attr("width",this.getWidth()).attr("height",30).attr("fill",this.options.title.bgColor),t.append("text").attr("id","mt-map-title").attr("x",20).attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).attr("y",20),this.options.title.source&&t.append("text").attr("y",20).attr("x",this.getWidth()-20).attr("text-anchor","end").attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).html(this.options.title.source())}},{key:"encodeTranslation",value:function(t){var e=t[0]/(this.scale*this.getWidth()),a=t[1]/(this.scale*this.getHeight());return[e,a]}},{key:"decodeTranslation",value:function(t){var e=t[0]*this.getWidth()*this.scale,a=t[1]*this.getHeight()*this.scale;return[e,a]}},{key:"restoreState",value:function(t){if(t&&3===t.length){this.scale=t[0];var e=this.decodeTranslation([t[1],t[2]]);this.transX=e[0],this.transY=e[1],this.zoomListener.scale(t[0]).translate(e).event(this.svg)}}},{key:"saveState",value:function(){var t=this.encodeTranslation([this.transX,this.transY]),e=[this.scale,t[0],t[1]];1!==e[0]&&0!==e[1]&&0!==e[2]?this.maptable.saveState("zoom",e):this.maptable.removeState("zoom")}},{key:"rescale",value:function(){var t=this;d3.event&&d3.event.translate&&(this.scale=d3.event.scale,this.transX=1===this.scale?0:d3.event.translate[0],this.transY=1===this.scale?0:d3.event.translate[1]);var e=0,a=0,i=this.getWidth()*(1-this.scale),n=this.getHeight()*(1-this.scale);this.transY>a?this.transY=a:this.transYe?this.transX=e:this.transXe?e:t},e[0])};else if("max"===s)e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return e.reduce(function(t,e){return e>t?e:t},e[0])};else if(-1!==s.indexOf("percentile")){var l=A.toNumber(s);e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return A.quantile(e,l)}}else"function"==typeof e.rollup&&(e.rollup=e.rollup.bind(this.maptable));n&&(-1!==n.indexOf("log")?o=d3.scale.log():-1!==n.indexOf("pow")?o=d3.scale.pow().exponent(A.toNumber(n)||1):"sqrt"===n&&(o=d3.scale.sqrt()))}if(e.rollup||(e.rollup=function(t){return t.length}),!e.min||!e.max)throw new Error("MapTable: You should provide values 'min' & 'max' for attr."+t);if(a.forEach(function(a){var o=e.rollup(a.values);if(a.attrProperties||(a.attrProperties={}),a.attrProperties[t]||(a.attrProperties[t]={}),a.attrProperties[t].value=o,r){a.attrProperties[t].key=r,a.attrProperties[t].mode=s,a.attrProperties[t].scale=n;var l=i.maptable.columnDetails[r];a.attrProperties[t].columnDetails=l;var h={};h[r]=o,a.attrProperties[t].formatted=l&&l.cellContent?l.cellContent.bind(i.maptable)(h):o}}),"rank"===n){var h=A.uniqueValues([0].concat(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return t>0}))),p=A.uniqueValues(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return 0>t}));h.sort(function(t,e){return t-e}),p.sort(function(t,e){return e-t}),a.forEach(function(e){if(0!==e.attrProperties[t].value){var a=e.attrProperties[t].value>=0?h:p,i=a.indexOf(Math.floor(100*e.attrProperties[t].value)/100),n=Math.round(i/a.length*100),r=e.attrProperties[t].value<0?n-2*n:n;e.attrProperties[t].value=r}})}var u=d3.extent(a,function(e){return Number(e.attrProperties[t].value)});0===u[0]&&n&&"-1"!==n.indexOf("log")&&(u=d3.extent(a.filter(function(e){return 0!==Number(e.attrProperties[t].value)}),function(e){return Number(e.attrProperties[t].value)})),e.transform&&(u[0]=e.transform.bind(this.maptable)(u[0],this.maptable.data),u[1]=e.transform.bind(this.maptable)(u[1],this.maptable.data));var d=e.min,c=e.max;if("minValue"===e.min&&(d=u[0]),"maxValue"===e.max&&(c=u[1]),e.maxNegative&&!e.minNegative||!e.maxNegative&&e.minNegative)throw new Error("MapTable: maxNegative or minNegative undefined. Please declare both.");var m=e.maxNegative&&e.minNegative,f=void 0,g=void 0;m?(f=o.copy().domain([0,u[1]]).range([d,c]),g=o.copy().domain([u[0],0]).range([e.maxNegative,e.minNegative])):f=o.domain(u).range([d,c]),a.forEach(function(a){var n=void 0;if(!a.values.length||Number.isNaN(a.attrProperties[t].value)){if("undefined"==typeof e.empty)throw new Error("MapTable: no empty property found for attr."+t);n=e.empty}else{var r=a.attrProperties[t].value,s=e.transform?e.transform.bind(i.maptable)(r,i.maptable.data):r;n=m&&0>s?g(s):f(s)}a.attr[t]=n})}}},{key:"render",value:function(){this.options.markers&&this.updateMarkers(),this.options.countries&&this.updateCountries(),this.options.night&&this.updateNight(),this.options.timezones&&this.updateTimezones(),this.options.title&&this.updateTitle(),this.options.heatmap&&this.updateHeatmap(),this.options.autoFitContent&&(this.fitContent(),this.rescale()),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"updateTitle",value:function(){var t=this;if(this.options.title.content){var e=this.maptable.data.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,a=this.maptable.rawData.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,i="";this.maptable.filters&&(i=this.maptable.filters.getDescription()),this.container.querySelector("#mt-map-title").innerHTML=this.options.title.content.bind(this.maptable)(e,a,i,this.maptable.data,this.maptable.rawData,this.dataCountries)}}},{key:"activateTooltip",value:function(t,e,a,i){var n=this;t.on(i?"mousemove":"mouseover",function(t){var r=a.bind(this.maptable)(t);if(r){e.html(r).attr("style","display:block;position:fixed;");var s=void 0,o=void 0,l=e.node().offsetWidth/2;if(i){var h=n.node.getBoundingClientRect(),p=d3.mouse(n.svg.node()).map(function(t){return parseInt(t,10)});s=h.left+p[0]-l,o=h.top+p[1]+10}else{var u=this.getBoundingClientRect();s=u.left+u.width/2-l,o=u.top+u.height+2}e.attr("style","top:"+o+"px;left:"+s+"px;display:block;position:fixed;").on("mouseout",function(){e.style("display","none")})}}).on("mouseout",function(){e.style("display","none")})}},{key:"exportSvg",value:function(){var t=this.container.querySelector("#mt-map-svg"),e='\n'+(new XMLSerializer).serializeToString(t);if(this.options.exportSvgClient){if(!window.saveAs)throw new Error("MapTable: Missing FileSaver.js library");var a=new Blob([e],{type:"image/svg+xml"});window.saveAs(a,"visualization.svg")}else if(this.options.exportSvg){var i=this.node.querySelector("#mt-map-svg-form");i.querySelector('[name="data"]').value=e,i.submit()}}},{key:"addExportSvgCapability",value:function(){var t=document.createElement("div");t.setAttribute("id","mt-map-export"),this.container.querySelector("#mt-map").appendChild(t);var e=document.createElement("button");if(e.setAttribute("class","btn btn-xs btn-default"),e.innerHTML="Download",e.addEventListener("click",this.exportSvg.bind(this)),t.appendChild(e),this.options.exportSvg){var a=document.createElement("div");a.innerHTML='
',t.appendChild(a)}}}]),t}(),B=function(){function t(e,a){var i=this;if(N.classCallCheck(this,t),this.maptable=e,this.options=a,this.criteria=[],this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.container=document.createElement("div"),this.maptable.node.appendChild(this.container),this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-filters"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-filters"),this.node.setAttribute("class","panel panel-default"),this.maptable.node.appendChild(this.node));var r=document.createElement("div");r.setAttribute("class","panel-heading");var s=document.createElement("button");s.setAttribute("id","mt-filters-reset"),s.setAttribute("class","btn btn-default btn-xs pull-right"),s.style.display="none",s.style.marginLeft=5,s.innerText="↺ Reset",s.addEventListener("click",this.reset),r.appendChild(s);var o=document.createElement("h3");o.setAttribute("class","panel-title"),o.appendChild(document.createTextNode("Filters")),r.appendChild(o),this.node.appendChild(r);var l=document.createElement("div");l.setAttribute("id","mt-filters-content"),l.setAttribute("class","panel-body");var h=document.createElement("div");h.setAttribute("id","mt-filters-elements"),l.appendChild(h);var p=document.createElement("a");p.setAttribute("id","mt-filters-new"),p.setAttribute("href","#"),p.innerText="+ New filter",p.addEventListener("click",this.add.bind(this)),l.appendChild(p),this.node.appendChild(l)}return N.createClass(t,[{key:"add",value:function(t){t&&t.preventDefault();var e=this.getPossibleFilters();if(0!==e.length){var a=e[0].key;this.create(a)}}},{key:"create",value:function(t,e){var a=this.buildRow(t);e?e.parentNode.replaceChild(a,e):this.node.querySelector("#mt-filters-elements").appendChild(a),this.criteria.push(t),this.maptable.render(),"none"===this.container.style.display&&this.toggle()}},{key:"remove",value:function(t){var e=this.node.querySelector('[data-mt-filter-name="'+t+'"]');e&&e.parentNode.removeChild(e);var a=this.criteria.indexOf(t);this.criteria.splice(a,1),this.maptable.render()}},{key:"reset",value:function(){for(var t=this.node.querySelectorAll("[data-mt-filter-name]"),e=0;e and\n '+h+""}else{var p=i.querySelector(".mt-filter-value-min").value;if(""===p)continue;s+=r.title+" is ",s+=o.options[o.selectedIndex].text,s+=''+p+""}}else if("field"===r.filterMethod||"dropdown"===r.filterMethod){var u=i.querySelector(".mt-filter-value").value;if(""===u)continue;var d="field"===r.filterMethod?"contains":"is";s+=r.title+" "+d+'\n '+u+""}t.push(s)}return t.join(", ")}},{key:"buildRow",value:function(t){var e=this,a=this,i=this.getPossibleFilters(),n=this.maptable.columnDetails[t],r=document.createElement("div");r.setAttribute("class","mt-filter-row"),r.setAttribute("data-mt-filter-name",t);var s=document.createElement("button");s.setAttribute("class","btn btn-default pull-right"),s.setAttribute("data-mt-filter-btn-minus",1),s.innerText="– Remove this filter",s.addEventListener("click",function(){t=r.querySelector(".mt-filter-name").value,e.remove(t)}),r.appendChild(s);var o=document.createElement("span");o.setAttribute("class","mt-filters-and"),o.innerText="And ",r.appendChild(o);var l=document.createElement("select");l.setAttribute("class","mt-filter-name form-control form-control-inline"),A.appendOptions(l,i.map(function(t){return{text:t.title,value:t.key}})),l.value=t,l.addEventListener("change",function(){var t=this.parentNode.getAttribute("data-mt-filter-name"),e=this.value;a.create(e,this.parentNode),a.remove(t),a.refresh()}),r.appendChild(l);var h=document.createElement("span");h.innerText="field"===n.filterMethod?" contains ":" is ",r.appendChild(h);var p=null;"field"!==n.filterMethod&&"dropdown"!==n.filterMethod&&(p=document.createElement("select"),p.setAttribute("class","mt-filter-range form-control form-control-inline"),A.appendOptions(p,["any","=","≠","<",">","≤","≥","BETWEEN"].map(function(t){return{text:t,value:t}})),p.addEventListener("change",function(){a.handleRangeChange(this)}),r.appendChild(p),r.appendChild(document.createTextNode(" ")));var u=document.createElement("div");if(u.style.display="inline-block",u.setAttribute("class","mt-filter-value-container"),"compare"===n.filterMethod)["min","max"].forEach(function(t,a){var i=document.createElement("input");if(i.setAttribute("class","form-control form-control-inline mt-filter-value-"+t),i.setAttribute("type",n.filterInputType),i.addEventListener("keyup",e.maptable.render.bind(e.maptable)),i.addEventListener("change",e.maptable.render.bind(e.maptable)),u.appendChild(i),0===a){var r=document.createElement("span");r.setAttribute("class","mt-filter-value-and"),r.innerText=" and ",u.appendChild(r)}});else if("field"===n.filterMethod){var d=document.createElement("input");d.setAttribute("class","form-control form-control-inline mt-filter-value"),d.setAttribute("type","text"),d.addEventListener("keyup",this.maptable.render.bind(this.maptable)),d.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(d)}else if("dropdown"===n.filterMethod){var c=document.createElement("select");c.setAttribute("class","form-control form-control-inline mt-filter-value");var m=d3.nest().key(function(e){return e[t]}).sortKeys(d3.ascending).entries(this.maptable.rawData);A.appendOptions(c,[{text:"Any",value:""}].concat(m.map(function(t){return{text:t.key,value:t.key}}))),c.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(c)}return r.appendChild(u),p&&this.handleRangeChange(p),r}},{key:"handleRangeChange",value:function(t){var e=t.parentNode;"any"===t.value?e.querySelector(".mt-filter-value-container").style.display="none":(e.querySelector(".mt-filter-value-container").style.display="inline-block","BETWEEN"===t.value?(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="inline-block",e.querySelector(".mt-filter-value-max").style.display="inline-block"):(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="none",e.querySelector(".mt-filter-value-max").style.display="none")),this.maptable.render.bind(this.maptable)()}},{key:"getPossibleFilters",value:function(t){var e=this;return Object.keys(this.maptable.columnDetails).map(function(t){return A.extendRecursive({key:t},e.maptable.columnDetails[t])}).filter(function(a){return-1!==e.activeColumns.indexOf(a.key)&&(t&&t===a.key||-1===e.criteria.indexOf(a.key)&&a.filterMethod&&!a.isVirtual)})}},{key:"filterData",value:function(){var t=this,e=this;this.maptable.data=this.maptable.rawData.filter(function(a){for(var i=t.node.querySelectorAll(".mt-filter-row"),n=!0,r=0;rh(m))?n=!1:(parseInt(a[o],10)parseInt(m,10))&&(n=!1)}else{var f=s.querySelector(".mt-filter-value-min").value;if(""===f)continue;h&&!A.rangeToBool(h(a[o]),d,h(f))?n=!1:h||A.rangeToBool(a[o],d,f)||(n=!1)}}(h&&A.isBlank(h(a[o]))||A.isBlank(a[o]))&&(n=!1)}return n}),this.options.saveState&&this.maptable.saveState("filters",this.exportFilters())}},{key:"refresh",value:function(){for(var t=this.node.querySelectorAll(".mt-filter-name"),e=0;e0&&(this.node.querySelectorAll(".mt-filters-and")[0].style.visibility="hidden");var r=!this.getPossibleFilters().length;this.node.querySelector("#mt-filters-new").style.visibility=r?"hidden":"visible"}},{key:"toggle",value:function(){"none"===this.container.style.display?(this.container.style.display="block",0===this.criteria.length&&this.add()):this.container.style.display="none"}}]),t}(),R=function(){function t(e,a){var i=this;if(N.classCallCheck(this,t),this.maptable=e,this.options=a,this.options.defaultSorting?(Array.isArray(this.options.defaultSorting)&&2===this.options.defaultSorting.length?this.sorting=this.options.defaultSorting:this.sorting=[this.options.defaultSorting],this.sorting.forEach(function(t){t.mode||(t.mode="asc")})):this.sorting=[{key:Object.keys(this.maptable.data[0])[0],mode:"asc"}],this.initialSorting=this.sorting.map(function(t){return t.key+","+t.mode}).join(";"),this.isSorting=!1,this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-table"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-table"),this.maptable.node.appendChild(this.node)),this.node=d3.select(this.node).append("table").attr("class",this.options.className),this.header=this.node.append("thead"),this.body=this.node.append("tbody"),this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.header.selectAll("tr").data([1]).enter().append("tr").selectAll("th").data(this.activeColumns.map(function(t){return A.extendRecursive({key:t},i.maptable.columnDetails[t])})).enter().append("th").attr("class",function(t){var e=t.sorting?"mt-table-sortable":"";return e+=t.nowrap?" nowrap":""}).attr("data-key",function(t){return A.sanitizeKey(t.key)}).attr("onselectstart","return false;").attr("unselectable","on").attr("style",function(t){return t.nowrap?"white-space:nowrap;":""}).on("click",function(t){i.isSorting||(i.isSorting=!0,t.sorting&&i.sortColumn(t.key),i.isSorting=!1)}).text(function(t){return t.title}).attr("id",function(t){return"column_header_"+A.sanitizeKey(t.key)})}return N.createClass(t,[{key:"restoreState",value:function(t){if(t){var e=t.split(";"),a=[];e.forEach(function(t){var e=t.split(",");a.push({key:e[0],mode:e[1]||"asc"})}),this.sorting=a}}},{key:"saveState",value:function(){var t=this.sorting.map(function(t){return t.key+","+t.mode}).join(";");t!==this.initialSorting&&this.maptable.saveState("sort",t)}},{key:"render",value:function(){var t=this;this.applySort();var e=this.maptable.data;this.options.distinctBy&&(e=d3.nest().key(function(e){return e[t.options.distinctBy]}).entries(this.maptable.data).map(function(t){return t.values[0]})),this.body.selectAll("tr").data(e).enter().append("tr"),this.body.selectAll("tr").data(e).exit().remove();var a=[];this.body.selectAll("tr").data(e).attr("class",function(e){return t.options.rowClassName?"line "+t.options.rowClassName(e):"line"}).html(function(e){var i="";return t.activeColumns.forEach(function(n){var r=t.maptable.columnDetails[n];i+=""}),i}),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"applySort",value:function(){for(var t=this,e=this.container.querySelectorAll(".mt-table-sortable"),a=0;a0;if(this.options.map.heatmap&&n)return i.innerHTML='
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map=!1,void this.buildComponenents();if(i.innerHTML='
Loading...
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map.pathData)this.loadMapData(null,JSON.parse(this.options.map.pathData),i);else{if(!this.options.map.path)throw new Error("missing map path|pathData");d3.json(this.options.map.path,function(t,e){a.loadMapData(t,e,i)})}}else this.buildComponenents()}},{key:"loadMapData",value:function(t,e,a){if(t)throw t;this.map=new L(this,this.options.map,e),a.querySelector(".mt-loading").style.display="none",this.buildComponenents()}},{key:"buildComponenents",value:function(){var t=this;this.options.filters&&(this.filters=new B(this,this.options.filters)),this.options.table&&(this.table=new R(this,this.options.table)),this.restoreState(),window.addEventListener("hashchange",function(){t.restoreState()}),this.render()}},{key:"loadState",value:function(t,e){if(e){var a=this.parseState(t);if(!a)return null;try{var i=JSON.parse(a);this.state[t]=i}catch(n){return console.log("Maptable: Invalid URL State for mt-"+t+" "+n.message),null}}else{var r=this.parseState(t);r&&(this.state[t]=r)}return this.state[t]}},{key:"restoreState",value:function(){this.map&&(this.loadState("zoom",!0),this.map.restoreState(this.state.zoom)),this.filters&&(this.loadState("filters",!0),this.filters.restoreState(this.state.filters)),this.table&&(this.loadState("sort",!1),this.table.restoreState(this.state.sort))}},{key:"parseState",value:function(t){var e=document.location.href.replace(/%21mt/g,"!mt").split("!mt-"+t+"=");return e[1]?decodeURIComponent(e[1].split("!mt")[0]):null}},{key:"removeState",value:function(t){window.clearTimeout(this.saveStateTimeout[t]),delete this.state[t],this.updateState()}},{key:"saveState",value:function(t,e){var a=this;window.clearTimeout(this.saveStateTimeout[t]),this.saveStateTimeout[t]=window.setTimeout(function(){a.state[t]=e,a.updateState()},200)}},{key:"updateState",value:function(){var t=this,e=document.location.href.split("#")[0],a="";Object.keys(this.state).forEach(function(e){if(t.state[e]){var i=t.state[e];if("object"===N["typeof"](t.state[e])){if(!Object.keys(t.state[e]).length)return;i=JSON.stringify(t.state[e])}a+="!mt-"+e+"="+encodeURIComponent(i)}}),""!==a&&(a="#"+a),document.location.href!==""+e+a&&window.history.pushState(null,null,""+e+a)}},{key:"render",value:function(){this.filters&&(this.filters.filterData(),this.filters.refresh()),this.map&&(this.map.render(),!this.firstExecution&&this.options.map.onComplete&&this.options.map.onComplete.constructor===Function&&this.options.map.onComplete.bind(this)()),this.table&&(this.table.render(),!this.firstExecution&&this.options.table.onComplete&&this.options.table.onComplete.constructor===Function&&this.options.table.onComplete.bind(this)()),!this.firstExecution&&this.options.onComplete&&this.options.onComplete.constructor===Function&&this.options.onComplete.bind(this)(),this.firstExecution=!0}},{key:"setColumnDetails",value:function(){var t=this;if(0!==t.rawData.length){var e={};Object.keys(t.rawData[0]).forEach(function(a){var i=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,n=i.test(t.rawData[0][a]);e[a]={title:A.keyToTile(a),filterMethod:n?"compare":"field",filterInputType:n?"number":"text",sorting:!0},n&&(e[a].dataParse=function(t){return parseFloat(t)})}),t.columnDetails=A.extendRecursive(e,this.options.columns),Object.keys(t.columnDetails).forEach(function(e){t.columnDetails[e].isVirtual="function"==typeof t.columnDetails[e].virtual})}}}]),t}();if(d3.maptable=function(t){var e=void 0,a={},i={target:t,columns:{},data:{},map:null,filters:null,table:null};return a.map=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!topojson)throw new Error("Maptable requires topojson.js");if("string"!=typeof t.path&&"string"!=typeof t.pathData)throw new Error("MapTable: map not provided");return i.map=t,a},a.data=function(t){return i.data.type="data",i.data.value=t,a},a.json=function(t,e){return i.data.type="json",i.data.path=t,i.data.preFilter=e,a},a.jsonData=function(t){return i.data.type="jsonData",i.data.value=t,a},a.csv=function(t,e){return i.data.type="csv",i.data.path=t,i.data.preFilter=e,a},a.csvData=function(t){return i.data.type="csvData",i.data.value=t,a},a.tsv=function(t,e){return i.data.type="tsv",i.data.path=t,i.data.preFilter=e,a},a.tsvData=function(t){return i.data.type="tsvData",i.data.value=t,a},a.filters=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.filters=t,a},a.table=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.table=t,a},a.columns=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.columns=t,a},a.render=function(a){if("string"!=typeof t||!document.querySelector(t))throw new Error("MapTable: target not found");if(!i.data||!i.data.type)throw new Error("MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData"); -i.map&&!i.map.heatmap&&(i.map.heatmap=null),i.map&&i.map.markers===!1&&(i.map.markers=null),i.map&&i.map.countries===!1&&(i.map.countries=null),i.filters||(i.filters=null),i.onComplete=a;var n=A.extendRecursive(z,i);return i.map.markers||delete n.map.markers,i.map.heatmap||delete n.map.heatmap,i.map.title||delete n.map.title,i.map.timezones||delete n.map.timezones,i.map.night||delete n.map.night,i.filters||delete n.filters,i.table||delete n.table,e=new G(t,n),{render:function(){return e.render()},loadState:function(t,a){return e.loadState(t,a)},removeState:function(t){return e.removeState(t)},saveState:function(t,a){return e.saveState(t,a)},setTitleContent:function(t){e.options.map.title.content=function(){return t}},setData:function(t){e.options.data.type="data",e.options.data.value=t,e.options.rawData=t,e.rawData=t,e.data=t,e.map&&e.map.enrichData()},setNightDate:function(t){e.options.map.night.date=t},setTimezonesDate:function(t){e.options.map.timezones.date=t},getMapWidth:function(){return e.map.getWidth()},getMapHeight:function(){return e.map.getHeight()}}},a},!d3)throw new Error("Maptable requires d3.js");var Y=d3.maptable;return Y}(); \ No newline at end of file +this.d3=this.d3||{},this.d3.maptable=function(){"use strict";function t(t,e,a){e.forEach(function(e){var a=document.createElement("option");a.setAttribute("value",e.value),a.innerText=e.text,t.appendChild(a)}),t.value=a}function e(t,e,a){return"="===e?parseInt(t,10)===parseInt(a,10):"≠"===e?parseInt(t,10)!==parseInt(a,10)&&""!==t&&""!==a:">"===e?parseInt(t,10)>parseInt(a,10)&&""!==t&&""!==a:"<"===e?parseInt(t,10)=parseInt(a,10)&&""!==t&&""!==a:"≤"===e?parseInt(t,10)<=parseInt(a,10)&&""!==t&&""!==a:!0}function a(){for(var t={},e=void 0,i=[].splice.call(arguments,0),n={}.toString;i.length>0;)e=i.splice(0,1)[0],"[object Object]"===n.call(e)&&Object.keys(e).forEach(function(i){"[object Object]"===n.call(e[i])?t[i]=a(t[i]||{},e[i]):t[i]=e[i]});return t}function i(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return e.replace(/_/g," ")}function n(t){return t.toLowerCase().replace(/ /g,"_").replace(/"/g,"").replace(/'/g,"")}function r(t){if(!t||""===t)return null;var e=t.toString().replace(/[^0-9.]+|\s+/gim,"");return""!==e?Number(e):null}function s(t,e){t.sort(function(t,e){return t-e});var a=e/100*(t.length-1),i=void 0;if(Math.floor(a)===a)i=t[a];else{var n=Math.floor(a),r=a-n;i=t[n]+(t[n+1]-t[n])*r}return i}function o(t){if(!t)return t;for(var e=[],a=0,i=t.length;i>a;a+=1)-1===e.indexOf(t[a])&&""!==t[a]&&e.push(t[a]);return e}function l(t,e,a,i){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLImageElement&&!t instanceof HTMLImageElement)return;var n=t.naturalWidth,r=t.naturalHeight;if("string"==typeof e)var e=document.getElementById(e);else if("undefined"!=typeof HTMLCanvasElement&&!e instanceof HTMLCanvasElement)return;e.style.width=n+"px",e.style.height=r+"px",e.width=n,e.height=r;var s=e.getContext("2d");s.clearRect(0,0,n,r),s.drawImage(t,0,0),Number.isNaN(a)||1>a||(i?p(e,0,0,n,r,a):d(e,0,0,n,r,a))}function h(t,e,a,i,n){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLCanvasElement&&!t instanceof HTMLCanvasElement)return;var r,s=t.getContext("2d");try{try{r=s.getImageData(e,a,i,n)}catch(o){throw new Error("unable to access local image data: "+o)}}catch(o){throw new Error("unable to access image data: "+o)}return r}function p(t,e,a,i,n,r){if(!(Number.isNaN(r)||1>r)){r|=0;var s=h(t,e,a,i,n);s=u(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function u(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,N,E,T,D,A,z=t.data,F=r+r+1,j=i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c-=y,f-=b,g-=k,v-=x,y-=R.r,b-=R.g,k-=R.b,x-=R.a,h=s+((h=o+O)r)){r|=0;var s=h(t,e,a,i,n);s=c(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function c(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,N,E=t.data,T=r+r+1,D=i-1,A=n-1,z=r+1,F=z*(z+1)/2,j=new m,H=j;for(l=1;T>l;l++)if(H=H.next=new m,l==z)var O=H;H.next=j;var P=null,I=null;d=u=0;var L=q[r],B=W[r];for(o=0;n>o;o++){for(k=x=w=c=f=g=0,v=z*(C=E[u]),y=z*(S=E[u+1]),b=z*(M=E[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(l=1;z>l;l++)h=u+((l>D?D:l)<<2),c+=(H.r=C=E[h])*(N=z-l),f+=(H.g=S=E[h+1])*N,g+=(H.b=M=E[h+2])*N,k+=C,x+=S,w+=M,H=H.next;for(P=j,I=O,s=0;i>s;s++)E[u]=c*L>>B,E[u+1]=f*L>>B,E[u+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=d+((h=s+r+1)s;s++){for(x=w=k=f=g=c=0,u=s<<2,v=z*(C=E[u]),y=z*(S=E[u+1]),b=z*(M=E[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(p=i,l=1;r>=l;l++)u=p+s<<2,c+=(H.r=C=E[u])*(N=z-l),f+=(H.g=S=E[u+1])*N,g+=(H.b=M=E[u+2])*N,k+=C,x+=S,w+=M,H=H.next,A>l&&(p+=i);for(u=s,P=j,I=O,o=0;n>o;o++)h=u<<2,E[h]=c*L>>B,E[h+1]=f*L>>B,E[h+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=s+((h=o+z)e?e+360:e)/180*O}function v(t){var e=f(t);return(Math.sin(e)*(1.914602-t*(.004817+14e-6*t))+Math.sin(e+e)*(.019993-101e-6*t)+289e-6*Math.sin(e+e+e))*P}function y(t){return g(t)+v(t)}function b(t){return y(t)-(.00569+.00478*Math.sin((125.04-1934.136*t)*P))*P}function k(t){return(23+(26+(21.448-t*(46.815+t*(59e-5-.001813*t)))/60)/60)*P}function x(t){return k(t)+.00256*Math.cos((125.04-1934.136*t)*P)*P}function w(t){return Math.asin(Math.sin(x(t))*Math.sin(b(t)))}function C(t){return.016708634-t*(42037e-9+1.267e-7*t)}function S(t){var e=C(t),a=f(t),i=g(t),n=Math.tan(x(t)/2);return n*=n,n*Math.sin(2*i)-2*e*Math.sin(a)+4*e*n*Math.sin(a)*Math.cos(2*i)-.5*n*n*Math.sin(4*i)-1.25*e*e*Math.sin(2*a)}function M(t){return[t[0]+180,-t[1]]}function N(t){var e=(t-Date.UTC(2e3,0,1,12))/864e5/36525,a=(d3.time.day.utc.floor(t)-t)/864e5*360-180;return[a-S(e)*I,w(e)*I]}var E={};E["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},E.createClass=function(){function t(t,e){for(var a=0;a\n \n \n \n \n \n '),this.options.timezones&&(this.layerTimezones=this.layerGlobal.append("g").attr("class","mt-map-timezones")),this.layerCountries=this.layerGlobal.append("g").attr("class","mt-map-countries"),this.options.night&&(this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night")),this.options.heatmap&&(this.layerHeatmap=this.layerGlobal.append("g").attr("class","mt-map-heatmap")),this.layerMarkers=this.layerGlobal.append("g").attr("class","mt-map-markers"),this.options.watermark&&(this.watermark=new j(this,this.options.watermark)),this.options.title&&this.buildTitle(),(this.options.exportSvgClient||this.options.exportSvg)&&this.addExportSvgCapability(),this.options.width||window.addEventListener("resize",function(){n.svg.attr("width",n.getWidth()),n.svg.attr("height",n.getHeight()),n.rescale()}),this.loadGeometries()}return E.createClass(t,[{key:"enrichData",value:function(){var t=this;this.maptable.rawData.forEach(function(e){e.longitude=parseFloat(e[t.options.longitudeKey]),e.latitude=parseFloat(e[t.options.latitudeKey]);var a=[0,0];Number.isNaN(e.longitude)||Number.isNaN(e.latitude)||(a=t.projection([e.longitude,e.latitude])),e.x=a[0],e.y=a[1]})}},{key:"scaleAttributes",value:function(){return Math.pow(this.scale,2/3)}},{key:"getWidth",value:function(){return this.options.width?this.options.width:(this.options.width=this.node.offsetWidth,this.node.offsetWidth)}},{key:"getHeight",value:function(){var t=this.options.title?30:0;return!this.options.height&&this.options.ratioFromWidth?this.getWidth()*this.options.ratioFromWidth*this.options.scaleHeight+t:this.options.height*this.options.scaleHeight+t}},{key:"loadGeometries",value:function(){this.options.filterCountries&&(this.jsonWorld.objects.countries.geometries=this.jsonWorld.objects.countries.geometries.filter(this.options.filterCountries)),this.options.countries&&this.buildCountries(),this.options.heatmap&&this.buildHeatmap(),this.options.night&&this.buildNight(),this.options.timezones&&(this.options.timezones.path||this.options.timezones.pathData)&&this.buildTimezone()}},{key:"buildHeatmap",value:function(){var t=topojson.merge(this.jsonWorld,this.jsonWorld.objects.countries.geometries);if(this.options.heatmap.disableMask||(this.maskHeatmap=this.layerHeatmap.append("defs").append("clipPath").attr("id","mt-map-heatmap-mask"),this.maskHeatmap.datum(t).append("path").attr("class","mt-map-heatmap-mask-paths").attr("d",this.path)),this.imgHeatmap=this.layerHeatmap.append("image").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("x",0).attr("y",0).attr("class","mt-map-heatmap-img"),this.options.heatmap.mask&&(this.imgHeatmap=this.imgHeatmap.attr("clip-path","url(#mt-map-heatmap-mask)")),this.options.heatmap.borders){var e=topojson.mesh(this.jsonWorld,this.jsonWorld.objects.countries,function(t,e){return t!==e});this.bordersHeatmap=this.layerHeatmap.append("g").attr("class","mt-map-heatmap-borders"),this.bordersHeatmap.selectAll("path.mt-map-heatmap-borders-paths").data([t,e]).enter().append("path").attr("class","mt-map-heatmap-borders-paths").attr("fill","none").attr("stroke-width",this.options.heatmap.borders.stroke).attr("stroke",this.options.heatmap.borders.color).attr("style","opacity: "+this.options.heatmap.borders.opacity).attr("d",this.path)}}},{key:"buildNight",value:function(){this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night");var t=d3.geo.circle().angle(90);this.maskNight=this.layerNight.append("defs").append("clipPath").attr("id","mt-map-night-mask"),this.maskNight.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.nightPath=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.path).style("opacity",.1);var e=this.options.night.date||Date.UTC(),a=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),0,0,0),i=N(new Date(a));if(this.nightPath.datum(t.origin(M(i))).attr("d",this.path),this.nightPathRight=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+this.getWidth()+"px,0,0)"),this.nightPathLeft=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+-this.getWidth()+"px,0,0)"),!this.options.night.disableSun){var n=this.projection(i);this.sunCircleRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]+this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]-this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]-2*this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight())}}},{key:"buildTimezone",value:function(){var t=this;this.options.timezones.pathData?this.loadTimezone(null,JSON.parse(this.options.timezones.pathData)):this.options.timezones.path&&d3.json(this.options.timezones.path,function(e,a){t.loadTimezone(e,a)})}},{key:"scaleFontSize",value:function(t){return this.getWidth()<700?t*(this.getWidth()/700):t}},{key:"loadTimezone",value:function(t,e){var a=this;this.dataTimezones=topojson.feature(e,e.objects.timezones).features,this.maskTimezone=this.layerTimezones.append("defs").append("clipPath").attr("id","mt-map-timezone-mask"),this.maskTimezone.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.layerTimezones.selectAll(".mt-map-timezone").data(this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places})).enter().insert("path").attr("class","mt-map-timezone").attr("d",this.path).attr("fill",function(t){return t.properties.zone%2===0?"#F4F5F5":"transparent"}).attr("title",function(t){return JSON.stringify(t.properties)}).attr("clip-path","url(#mt-map-timezone-mask)").style("opacity",.6);var i=this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places&&t.properties.zone%1===0&&14!==t.properties.zone}),n=[].concat(E.toConsumableArray(new Map(i.map(function(t){return[t.properties.zone,t]})).values()));this.layerTimezonesText=this.layerTimezones.append("g").attr("class","mt-map-timezones-texts"),this.layerTimezonesText.selectAll(".mt-map-timezone-text").data(n).enter().insert("text").attr("class","mt-map-timezone-text").attr("y",.82*this.getHeight()-5).attr("x",function(t){return(t.properties.zone+10)*(a.getWidth()/24.5)-1}).attr("dx",this.getWidth()/24.5/2).attr("font-size",this.scaleFontSize(9)).attr("font-family","Helevetica, Arial, Sans-Serif").attr("fill","#999").attr("text-anchor","middle").html(function(t){return A.formatDate(a.options.timezones.date||new Date,t.properties.zone)})}},{key:"getMagnitudeScale",value:function(t){var e=this.options.heatmap,a=t.length;if(!a)return function(){return 0};var i=d3.scale.linear().domain([1,a]).range([1,.25]),n=i(a),r=d3.scale.linear().domain([e.circles.min,20]).range([n,0]);return function(t){return r(t)}}},{key:"getDatumScale",value:function(){var t=this;if(!this.options.heatmap.weightByAttribute)return function(){return 1};var e=d3.extent(this.maptable.data,this.options.heatmap.weightByAttribute),a="log"===this.options.heatmap.weightByAttributeScale?d3.scale.log:d3.scale.linear,i=a().domain(e).range([.5,1]);return function(e){var a=t.options.heatmap.weightByAttribute(e);return a?i(a):0}}},{key:"getHeatmapData",value:function(){var t=this,e=d3.select(this.node).append("canvas").attr("id","mt-map-heatmap-canvas").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("style","display: none;"),a=e.node().getContext("2d");a.globalCompositeOperation="multiply";var i=d3.range(this.options.heatmap.circles.min,this.options.heatmap.circles.max,this.options.heatmap.circles.step),n=this.getDatumScale(),r=this.maptable.data.filter(function(t){return n(t)>.1}),s=this.path.context(a),o=this.getMagnitudeScale(r),l=d3.scale.linear().domain([1,0]).range(["#000000","#FFFFFF"]);a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle="#ffffff",a.fill(),a.closePath();var h=function(e){var a=t.options.heatmap.circles.colorStrength,i=1+(a-1)/100;return a>1?(2-i)*e+i-1:a*e};r.forEach(function(t){var e=n(t);i.forEach(function(i){var n=h(o(i)*e);n>0&&(a.beginPath(),s(d3.geo.circle().origin([t.longitude,t.latitude]).angle(i-1e-4)()),a.fillStyle=l(n),a.fill(),a.closePath())})}),H.canvasRGBA(e.node(),0,0,this.getWidth(),this.getHeight(),this.options.heatmap.circles.blur),a.beginPath(),a.globalCompositeOperation="screen",a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle=this.options.heatmap.circles.color,a.fill(),a.closePath();var p=e.node().toDataURL();return e.remove(),p}},{key:"updateHeatmap",value:function(){var t=this.getHeatmapData();this.imgHeatmap.attr("xlink:href",t)}},{key:"buildCountries",value:function(){this.dataCountries=topojson.feature(this.jsonWorld,this.jsonWorld.objects.countries).features,this.layerCountries.selectAll(".mt-map-country").data(this.dataCountries).enter().insert("path").attr("class","mt-map-country").attr("d",this.path),this.legendCountry={},this.shouldRenderLegend()&&(this.legendCountry.fill=new F(this))}},{key:"shouldRenderLegend",value:function(){var t=this.options.countries.attr.fill;if(!t)return!1;if(!t.legend||!t.min||!t.max)return!1;if(t.aggregate&&t.aggregate.scale){var e="function"==typeof t.aggregate.scale?t.aggregate.scale.bind(this.maptable)():t.aggregate.scale;if("linear"!==e)return!1}return!0}},{key:"getAllMtMapCountry",value:function(){return this.allMtMapCountry?this.allMtMapCountry:(this.allMtMapCountry=d3.selectAll(this.containerSelector+" .mt-map-country"),this.allMtMapCountry)}},{key:"getAllMtMapMarker",value:function(){return this.allMtMapMarker?this.allMtMapMarker:(this.allMtMapMarker=d3.selectAll(this.containerSelector+" .mt-map-marker"),this.allMtMapMarker)}},{key:"updateCountries",value:function(){var t=this,e=new Map;this.maptable.data.forEach(function(a){var i=a[t.options.countryIdentifierKey];e.has(i)||e.set(i,[]),e.get(i).push(a)}),this.dataCountries.forEach(function(a){a.key=a.properties[t.options.countryIdentifierType];var i=e.get(a.key);a.values=i||[],a.attr={},a.rollupValue={}}),Object.keys(this.options.countries.attr).forEach(function(e){t.setAttrValues(e,t.options.countries.attr[e],t.dataCountries)});var a=this.getAllMtMapCountry().each(function(t){var e=d3.select(this);Object.keys(t.attr).forEach(function(a){e.attr(a,t.attr[a])})});Object.keys(this.options.countries.attr).forEach(function(e){var i=t.options.countries.attr[e];if("object"===("undefined"==typeof i?"undefined":E["typeof"](i))&&i.legend&&void 0!==t.legendCountry[e]){var n=d3.extent(t.dataCountries,function(t){return Number(t.attrProperties[e].value)});t.legendCountry[e].updateExtents(n),a.on("mouseover",function(a){t.legendCountry[e].indiceChange(a.attrProperties[e].value)}).on("mouseout",function(){t.legendCountry[e].indiceChange(NaN)})}}),this.options.countries&&this.options.countries.tooltip&&this.activateTooltip(a,this.tooltipCountriesNode,this.options.countries.tooltip,!0)}},{key:"updateNight",value:function(){var t=this.options.night.date||Date.UTC(),e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0),a=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),23,59,59),i=a-e,n=t-e,r=n/i;this.layerNight.node().style.transform="translateX("+-this.getWidth()*r+"px)"}},{key:"updateTimezones",value:function(){var t=document.querySelectorAll(".mt-map-timezone-text"),e=this.options.timezones.date||new Date;Array.from(t).forEach(function(t){t.textContent=A.formatDate(e,t.__data__.properties.zone)})}},{key:"updateMarkers",value:function(){var t=this,e=function(t){return t.longitude+","+t.latitude};this.dataMarkers=d3.nest().key(e).entries(this.maptable.data).filter(function(t){return 0!==t.values[0].x}),this.dataMarkers.forEach(function(t){t.attr={},t.attrProperties={}}),Object.keys(this.options.markers.attr).forEach(function(e){t.setAttrValues(e,t.options.markers.attr[e],t.dataMarkers)});var a=this.layerMarkers.selectAll(".mt-map-marker").data(this.dataMarkers),i=a.enter();i=this.options.markers.customTag?this.options.markers.customTag(i):i.append("svg:circle");var n=this.options.markers.className?this.options.markers.className:"";i.attr("class","mt-map-marker "+n),a.exit().transition().attr("r",0).attr("fill","#eee").style("opacity",0).remove();var r=this.options.markers.attrX?this.options.markers.attrX:"cx",s=this.options.markers.attrY?this.options.markers.attrY:"cy",o=this.options.markers.attrXDelta?this.options.markers.attrXDelta:0,l=this.options.markers.attrYDelta?this.options.markers.attrYDelta:0,h=a.attr(r,function(t){return t.values[0].x+o}).attr(s,function(t){return t.values[0].y+l});this.getAllMtMapMarker().each(function(t){var e=this;Object.keys(t.attr).forEach(function(a){d3.select(e).attr(a,t.attr[a])})}),this.options.markers.tooltip&&this.activateTooltip(h,this.tooltipMarkersNode,this.options.markers.tooltip,!1),this.rescale()}},{key:"fitContent",value:function(){if(0===this.maptable.data.length)return this.transX=0,this.transY=0,this.scale=1,void this.zoomListener.translate([this.transX,this.transY]).scale(this.scale);var t=d3.extent(this.maptable.data,function(t){return t.x}),e=d3.extent(this.maptable.data,function(t){return t.y}),a=this.getWidth()/this.getHeight(),i=20+(this.options.title?30:0),n=t[1]-t[0]+i,r=e[1]-e[0]+i,s=n/a,o=r*a,l=0,h=0;o>=n?l=(o-n)/2:h=(s-r)/2,t[0]-=this.options.fitContentMargin+l,t[1]+=this.options.fitContentMargin+l,e[0]-=this.options.fitContentMargin+h,e[1]+=this.options.fitContentMargin+h,this.scale=this.getWidth()/(t[1]-t[0]),this.transX=-1*t[0]*this.scale,this.transY=-1*e[0]*this.scale,this.zoomListener.translate([this.transX,this.transY]).scale(this.scale); +}},{key:"buildTitle",value:function(){var t=this.svg.append("svg").attr("width",this.getWidth()).attr("x",0).attr("y",this.getHeight()-30).attr("height",30);this.options.title.bgColor&&t.append("rect").attr("x",0).attr("y",0).attr("width",this.getWidth()).attr("height",30).attr("fill",this.options.title.bgColor),t.append("text").attr("id","mt-map-title").attr("x",20).attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).attr("y",20),this.options.title.source&&t.append("text").attr("y",20).attr("x",this.getWidth()-20).attr("text-anchor","end").attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).html(this.options.title.source())}},{key:"encodeTranslation",value:function(t){var e=t[0]/(this.scale*this.getWidth()),a=t[1]/(this.scale*this.getHeight());return[e,a]}},{key:"decodeTranslation",value:function(t){var e=t[0]*this.getWidth()*this.scale,a=t[1]*this.getHeight()*this.scale;return[e,a]}},{key:"restoreState",value:function(t){if(t&&3===t.length){this.scale=t[0];var e=this.decodeTranslation([t[1],t[2]]);this.transX=e[0],this.transY=e[1],this.zoomListener.scale(t[0]).translate(e).event(this.svg)}}},{key:"saveState",value:function(){var t=this.encodeTranslation([this.transX,this.transY]),e=[this.scale,t[0],t[1]];1!==e[0]&&0!==e[1]&&0!==e[2]?this.maptable.saveState("zoom",e):this.maptable.removeState("zoom")}},{key:"rescale",value:function(){var t=this;d3.event&&d3.event.translate&&(this.scale=d3.event.scale,this.transX=1===this.scale?0:d3.event.translate[0],this.transY=1===this.scale?0:d3.event.translate[1]);var e=0,a=0,i=this.getWidth()*(1-this.scale),n=this.getHeight()*(1-this.scale);this.transY>a?this.transY=a:this.transYe?this.transX=e:this.transXe?e:t},e[0])};else if("max"===s)e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return e.reduce(function(t,e){return e>t?e:t},e[0])};else if(-1!==s.indexOf("percentile")){var l=A.toNumber(s);e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return A.quantile(e,l)}}else"function"==typeof e.rollup&&(e.rollup=e.rollup.bind(this.maptable));n&&(-1!==n.indexOf("log")?o=d3.scale.log():-1!==n.indexOf("pow")?o=d3.scale.pow().exponent(A.toNumber(n)||1):"sqrt"===n&&(o=d3.scale.sqrt()))}if(e.rollup||(e.rollup=function(t){return t.length}),!e.min||!e.max)throw new Error("MapTable: You should provide values 'min' & 'max' for attr."+t);if(a.forEach(function(a){var o=e.rollup(a.values);if(a.attrProperties||(a.attrProperties={}),a.attrProperties[t]||(a.attrProperties[t]={}),a.attrProperties[t].value=o,r){a.attrProperties[t].key=r,a.attrProperties[t].mode=s,a.attrProperties[t].scale=n;var l=i.maptable.columnDetails[r];a.attrProperties[t].columnDetails=l;var h={};h[r]=o,a.attrProperties[t].formatted=l&&l.cellContent?l.cellContent.bind(i.maptable)(h):o}}),"rank"===n){var h=A.uniqueValues([0].concat(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return t>0}))),p=A.uniqueValues(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return 0>t}));h.sort(function(t,e){return t-e}),p.sort(function(t,e){return e-t}),a.forEach(function(e){if(0!==e.attrProperties[t].value){var a=e.attrProperties[t].value>=0?h:p,i=a.indexOf(Math.floor(100*e.attrProperties[t].value)/100),n=Math.round(i/a.length*100),r=e.attrProperties[t].value<0?n-2*n:n;e.attrProperties[t].value=r}})}var u=d3.extent(a,function(e){return Number(e.attrProperties[t].value)});0===u[0]&&n&&"-1"!==n.indexOf("log")&&(u=d3.extent(a.filter(function(e){return 0!==Number(e.attrProperties[t].value)}),function(e){return Number(e.attrProperties[t].value)})),e.transform&&(u[0]=e.transform.bind(this.maptable)(u[0],this.maptable.data),u[1]=e.transform.bind(this.maptable)(u[1],this.maptable.data));var d=e.min,c=e.max;if("minValue"===e.min&&(d=u[0]),"maxValue"===e.max&&(c=u[1]),e.maxNegative&&!e.minNegative||!e.maxNegative&&e.minNegative)throw new Error("MapTable: maxNegative or minNegative undefined. Please declare both.");var m=e.maxNegative&&e.minNegative,f=void 0,g=void 0;m?(f=o.copy().domain([0,u[1]]).range([d,c]),g=o.copy().domain([u[0],0]).range([e.maxNegative,e.minNegative])):f=o.domain(u).range([d,c]),a.forEach(function(a){var n=void 0;if(!a.values.length||Number.isNaN(a.attrProperties[t].value)){if("undefined"==typeof e.empty)throw new Error("MapTable: no empty property found for attr."+t);n=e.empty}else{var r=a.attrProperties[t].value,s=e.transform?e.transform.bind(i.maptable)(r,i.maptable.data):r;n=m&&0>s?g(s):f(s)}a.attr[t]=n})}}},{key:"render",value:function(){this.options.markers&&this.updateMarkers(),this.options.countries&&this.updateCountries(),this.options.night&&this.updateNight(),this.options.timezones&&this.updateTimezones(),this.options.title&&this.updateTitle(),this.options.heatmap&&this.updateHeatmap(),this.options.autoFitContent&&(this.fitContent(),this.rescale()),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"updateTitle",value:function(){var t=this;if(this.options.title.content){var e=this.maptable.data.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,a=this.maptable.rawData.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,i="";this.maptable.filters&&(i=this.maptable.filters.getDescription()),this.container.querySelector("#mt-map-title").innerHTML=this.options.title.content.bind(this.maptable)(e,a,i,this.maptable.data,this.maptable.rawData,this.dataCountries)}}},{key:"activateTooltip",value:function(t,e,a,i){var n=this;t.on(i?"mousemove":"mouseover",function(t){var r=a.bind(this.maptable)(t);if(r){e.html(r).attr("style","display:block;position:fixed;");var s=void 0,o=void 0,l=e.node().offsetWidth/2;if(i){var h=n.node.getBoundingClientRect(),p=d3.mouse(n.svg.node()).map(function(t){return parseInt(t,10)});s=h.left+p[0]-l,o=h.top+p[1]+10}else{var u=this.getBoundingClientRect();s=u.left+u.width/2-l,o=u.top+u.height+2}e.attr("style","top:"+o+"px;left:"+s+"px;display:block;position:fixed;").on("mouseout",function(){e.style("display","none")})}}).on("mouseout",function(){e.style("display","none")})}},{key:"exportSvg",value:function(){var t=this.container.querySelector("#mt-map-svg"),e='\n'+(new XMLSerializer).serializeToString(t);if(this.options.exportSvgClient){if(!window.saveAs)throw new Error("MapTable: Missing FileSaver.js library");var a=new Blob([e],{type:"image/svg+xml"});window.saveAs(a,"visualization.svg")}else if(this.options.exportSvg){var i=this.node.querySelector("#mt-map-svg-form");i.querySelector('[name="data"]').value=e,i.submit()}}},{key:"addExportSvgCapability",value:function(){var t=document.createElement("div");t.setAttribute("id","mt-map-export"),this.container.querySelector("#mt-map").appendChild(t);var e=document.createElement("button");if(e.setAttribute("class","btn btn-xs btn-default"),e.innerHTML="Download",e.addEventListener("click",this.exportSvg.bind(this)),t.appendChild(e),this.options.exportSvg){var a=document.createElement("div");a.innerHTML='
',t.appendChild(a)}}}]),t}(),B=function(){function t(e,a){var i=this;if(E.classCallCheck(this,t),this.maptable=e,this.options=a,this.criteria=[],this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.container=document.createElement("div"),this.maptable.node.appendChild(this.container),this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-filters"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-filters"),this.node.setAttribute("class","panel panel-default"),this.maptable.node.appendChild(this.node));var r=document.createElement("div");r.setAttribute("class","panel-heading");var s=document.createElement("button");s.setAttribute("id","mt-filters-reset"),s.setAttribute("class","btn btn-default btn-xs pull-right"),s.style.display="none",s.style.marginLeft=5,s.innerText="↺ Reset",s.addEventListener("click",this.reset),r.appendChild(s);var o=document.createElement("h3");o.setAttribute("class","panel-title"),o.appendChild(document.createTextNode("Filters")),r.appendChild(o),this.node.appendChild(r);var l=document.createElement("div");l.setAttribute("id","mt-filters-content"),l.setAttribute("class","panel-body");var h=document.createElement("div");h.setAttribute("id","mt-filters-elements"),l.appendChild(h);var p=document.createElement("a");p.setAttribute("id","mt-filters-new"),p.setAttribute("href","#"),p.innerText="+ New filter",p.addEventListener("click",this.add.bind(this)),l.appendChild(p),this.node.appendChild(l)}return E.createClass(t,[{key:"add",value:function(t){t&&t.preventDefault();var e=this.getPossibleFilters();if(0!==e.length){var a=e[0].key;this.create(a)}}},{key:"create",value:function(t,e){var a=this.buildRow(t);e?e.parentNode.replaceChild(a,e):this.node.querySelector("#mt-filters-elements").appendChild(a),this.criteria.push(t),this.maptable.render(),"none"===this.container.style.display&&this.toggle()}},{key:"remove",value:function(t){var e=this.node.querySelector('[data-mt-filter-name="'+t+'"]');e&&e.parentNode.removeChild(e);var a=this.criteria.indexOf(t);this.criteria.splice(a,1),this.maptable.render()}},{key:"reset",value:function(){for(var t=this.node.querySelectorAll("[data-mt-filter-name]"),e=0;e and\n '+h+""}else{var p=i.querySelector(".mt-filter-value-min").value;if(""===p)continue;s+=r.title+" is ",s+=o.options[o.selectedIndex].text,s+=''+p+""}}else if("field"===r.filterMethod||"dropdown"===r.filterMethod){var u=i.querySelector(".mt-filter-value").value;if(""===u)continue;var d="field"===r.filterMethod?"contains":"is";s+=r.title+" "+d+'\n '+u+""}t.push(s)}return t.join(", ")}},{key:"buildRow",value:function(t){var e=this,a=this,i=this.getPossibleFilters(),n=this.maptable.columnDetails[t],r=document.createElement("div");r.setAttribute("class","mt-filter-row"),r.setAttribute("data-mt-filter-name",t);var s=document.createElement("button");s.setAttribute("class","btn btn-default pull-right"),s.setAttribute("data-mt-filter-btn-minus",1),s.innerText="– Remove this filter",s.addEventListener("click",function(){t=r.querySelector(".mt-filter-name").value,e.remove(t)}),r.appendChild(s);var o=document.createElement("span");o.setAttribute("class","mt-filters-and"),o.innerText="And ",r.appendChild(o);var l=document.createElement("select");l.setAttribute("class","mt-filter-name form-control form-control-inline"),A.appendOptions(l,i.map(function(t){return{text:t.title,value:t.key}})),l.value=t,l.addEventListener("change",function(){var t=this.parentNode.getAttribute("data-mt-filter-name"),e=this.value;a.create(e,this.parentNode),a.remove(t),a.refresh()}),r.appendChild(l);var h=document.createElement("span");h.innerText="field"===n.filterMethod?" contains ":" is ",r.appendChild(h);var p=null;"field"!==n.filterMethod&&"dropdown"!==n.filterMethod&&(p=document.createElement("select"),p.setAttribute("class","mt-filter-range form-control form-control-inline"),A.appendOptions(p,["any","=","≠","<",">","≤","≥","BETWEEN"].map(function(t){return{text:t,value:t}})),p.addEventListener("change",function(){a.handleRangeChange(this)}),r.appendChild(p),r.appendChild(document.createTextNode(" ")));var u=document.createElement("div");if(u.style.display="inline-block",u.setAttribute("class","mt-filter-value-container"),"compare"===n.filterMethod)["min","max"].forEach(function(t,a){var i=document.createElement("input");if(i.setAttribute("class","form-control form-control-inline mt-filter-value-"+t),i.setAttribute("type",n.filterInputType),i.addEventListener("keyup",e.maptable.render.bind(e.maptable)),i.addEventListener("change",e.maptable.render.bind(e.maptable)),u.appendChild(i),0===a){var r=document.createElement("span");r.setAttribute("class","mt-filter-value-and"),r.innerText=" and ",u.appendChild(r)}});else if("field"===n.filterMethod){var d=document.createElement("input");d.setAttribute("class","form-control form-control-inline mt-filter-value"),d.setAttribute("type","text"),d.addEventListener("keyup",this.maptable.render.bind(this.maptable)),d.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(d)}else if("dropdown"===n.filterMethod){var c=document.createElement("select");c.setAttribute("class","form-control form-control-inline mt-filter-value");var m=d3.nest().key(function(e){return e[t]}).sortKeys(d3.ascending).entries(this.maptable.rawData);A.appendOptions(c,[{text:"Any",value:""}].concat(m.map(function(t){return{text:t.key,value:t.key}}))),c.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(c)}return r.appendChild(u),p&&this.handleRangeChange(p),r}},{key:"handleRangeChange",value:function(t){var e=t.parentNode;"any"===t.value?e.querySelector(".mt-filter-value-container").style.display="none":(e.querySelector(".mt-filter-value-container").style.display="inline-block","BETWEEN"===t.value?(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="inline-block",e.querySelector(".mt-filter-value-max").style.display="inline-block"):(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="none",e.querySelector(".mt-filter-value-max").style.display="none")),this.maptable.render.bind(this.maptable)()}},{key:"getPossibleFilters",value:function(t){var e=this;return Object.keys(this.maptable.columnDetails).map(function(t){return A.extendRecursive({key:t},e.maptable.columnDetails[t])}).filter(function(a){return-1!==e.activeColumns.indexOf(a.key)&&(t&&t===a.key||-1===e.criteria.indexOf(a.key)&&a.filterMethod&&!a.isVirtual)})}},{key:"filterData",value:function(){var t=this,e=this;this.maptable.data=this.maptable.rawData.filter(function(a){for(var i=t.node.querySelectorAll(".mt-filter-row"),n=!0,r=0;rh(m))?n=!1:(parseInt(a[o],10)parseInt(m,10))&&(n=!1)}else{var f=s.querySelector(".mt-filter-value-min").value;if(""===f)continue;h&&!A.rangeToBool(h(a[o]),d,h(f))?n=!1:h||A.rangeToBool(a[o],d,f)||(n=!1)}}(h&&A.isBlank(h(a[o]))||A.isBlank(a[o]))&&(n=!1)}return n}),this.options.saveState&&this.maptable.saveState("filters",this.exportFilters())}},{key:"refresh",value:function(){for(var t=this.node.querySelectorAll(".mt-filter-name"),e=0;e0&&(this.node.querySelectorAll(".mt-filters-and")[0].style.visibility="hidden");var r=!this.getPossibleFilters().length;this.node.querySelector("#mt-filters-new").style.visibility=r?"hidden":"visible"}},{key:"toggle",value:function(){"none"===this.container.style.display?(this.container.style.display="block",0===this.criteria.length&&this.add()):this.container.style.display="none"}}]),t}(),R=function(){function t(e,a){var i=this;if(E.classCallCheck(this,t),this.maptable=e,this.options=a,this.options.defaultSorting?(Array.isArray(this.options.defaultSorting)&&2===this.options.defaultSorting.length?this.sorting=this.options.defaultSorting:this.sorting=[this.options.defaultSorting],this.sorting.forEach(function(t){t.mode||(t.mode="asc")})):this.sorting=[{key:Object.keys(this.maptable.data[0])[0],mode:"asc"}],this.initialSorting=this.sorting.map(function(t){return t.key+","+t.mode}).join(";"),this.isSorting=!1,this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-table"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-table"),this.maptable.node.appendChild(this.node)),this.node=d3.select(this.node).append("table").attr("class",this.options.className),this.header=this.node.append("thead"),this.body=this.node.append("tbody"),this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.options.header&&(this.options.header.className&&this.header.attr("class",""+this.options.header.className),this.options.header.top?this.header.attr("style","top:"+(this.options.header.top||"0")+"px;"):this.header.attr("style","top:0px;")),this.header.selectAll("tr").data([1]).enter().append("tr").selectAll("th").data(this.activeColumns.map(function(t){return A.extendRecursive({key:t},i.maptable.columnDetails[t])})).enter().append("th").attr("class",function(t){var e=t.sorting?"mt-table-sortable":"";return e+=t.nowrap?" nowrap":""}).attr("data-key",function(t){return A.sanitizeKey(t.key)}).attr("onselectstart","return false;").attr("unselectable","on").attr("style",function(t){return t.nowrap?"white-space:nowrap;":""}).on("click",function(t){i.isSorting||(i.isSorting=!0,t.sorting&&i.sortColumn(t.key),i.isSorting=!1)}).text(function(t){return t.title}).attr("id",function(t){return"column_header_"+A.sanitizeKey(t.key)})}return E.createClass(t,[{key:"restoreState",value:function(t){if(t){var e=t.split(";"),a=[];e.forEach(function(t){var e=t.split(",");a.push({key:e[0],mode:e[1]||"asc"})}),this.sorting=a}}},{key:"saveState",value:function(){var t=this.sorting.map(function(t){return t.key+","+t.mode}).join(";");t!==this.initialSorting&&this.maptable.saveState("sort",t)}},{key:"render",value:function(){var t=this;this.applySort();var e=this.maptable.data;this.options.distinctBy&&(e=d3.nest().key(function(e){return e[t.options.distinctBy]}).entries(this.maptable.data).map(function(t){return t.values[0]})),this.body.selectAll("tr").data(e).enter().append("tr"),this.body.selectAll("tr").data(e).exit().remove();var a=[];this.body.selectAll("tr").data(e).attr("class",function(e){return t.options.rowClassName?"line "+t.options.rowClassName(e):"line"}).html(function(e){var i="";return t.activeColumns.forEach(function(n){var r=t.maptable.columnDetails[n];i+=""}),i}),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"applySort",value:function(){for(var t=this,e=this.container.querySelectorAll(".mt-table-sortable"),a=0;a0;if(this.options.map.heatmap&&n)return i.innerHTML='
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map=!1,void this.buildComponenents();if(i.innerHTML='
Loading...
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map.pathData)this.loadMapData(null,JSON.parse(this.options.map.pathData),i);else{if(!this.options.map.path)throw new Error("missing map path|pathData");d3.json(this.options.map.path,function(t,e){a.loadMapData(t,e,i)})}}else this.buildComponenents()}},{key:"loadMapData",value:function(t,e,a){if(t)throw t;this.map=new L(this,this.options.map,e),a.querySelector(".mt-loading").style.display="none",this.buildComponenents()}},{key:"buildComponenents",value:function(){var t=this;this.options.filters&&(this.filters=new B(this,this.options.filters)),this.options.table&&(this.table=new R(this,this.options.table)),this.restoreState(),window.addEventListener("hashchange",function(){t.restoreState()}),this.render()}},{key:"loadState",value:function(t,e){if(e){var a=this.parseState(t);if(!a)return null;try{var i=JSON.parse(a);this.state[t]=i}catch(n){return console.log("Maptable: Invalid URL State for mt-"+t+" "+n.message),null}}else{var r=this.parseState(t);r&&(this.state[t]=r)}return this.state[t]}},{key:"restoreState",value:function(){this.map&&(this.loadState("zoom",!0),this.map.restoreState(this.state.zoom)),this.filters&&(this.loadState("filters",!0),this.filters.restoreState(this.state.filters)),this.table&&(this.loadState("sort",!1),this.table.restoreState(this.state.sort))}},{key:"parseState",value:function(t){var e=document.location.href.replace(/%21mt/g,"!mt").split("!mt-"+t+"=");return e[1]?decodeURIComponent(e[1].split("!mt")[0]):null}},{key:"removeState",value:function(t){window.clearTimeout(this.saveStateTimeout[t]),delete this.state[t],this.updateState()}},{key:"saveState",value:function(t,e){var a=this;window.clearTimeout(this.saveStateTimeout[t]),this.saveStateTimeout[t]=window.setTimeout(function(){a.state[t]=e,a.updateState()},200)}},{key:"updateState",value:function(){var t=this,e=document.location.href.split("#")[0],a="";Object.keys(this.state).forEach(function(e){if(t.state[e]){var i=t.state[e];if("object"===E["typeof"](t.state[e])){if(!Object.keys(t.state[e]).length)return;i=JSON.stringify(t.state[e])}a+="!mt-"+e+"="+encodeURIComponent(i)}}),""!==a&&(a="#"+a),document.location.href!==""+e+a&&window.history.pushState(null,null,""+e+a)}},{key:"render",value:function(){this.filters&&(this.filters.filterData(),this.filters.refresh()),this.map&&(this.map.render(),!this.firstExecution&&this.options.map.onComplete&&this.options.map.onComplete.constructor===Function&&this.options.map.onComplete.bind(this)()),this.table&&(this.table.render(),!this.firstExecution&&this.options.table.onComplete&&this.options.table.onComplete.constructor===Function&&this.options.table.onComplete.bind(this)()),!this.firstExecution&&this.options.onComplete&&this.options.onComplete.constructor===Function&&this.options.onComplete.bind(this)(),this.firstExecution=!0}},{key:"setColumnDetails",value:function(){var t=this;if(0!==t.rawData.length){var e={};Object.keys(t.rawData[0]).forEach(function(a){var i=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,n=i.test(t.rawData[0][a]);e[a]={title:A.keyToTile(a),filterMethod:n?"compare":"field",filterInputType:n?"number":"text",sorting:!0},n&&(e[a].dataParse=function(t){return parseFloat(t)})}),t.columnDetails=A.extendRecursive(e,this.options.columns),Object.keys(t.columnDetails).forEach(function(e){t.columnDetails[e].isVirtual="function"==typeof t.columnDetails[e].virtual})}}}]),t}();if(d3.maptable=function(t){var e=void 0,a={},i={target:t,columns:{},data:{},map:null,filters:null,table:null};return a.map=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!topojson)throw new Error("Maptable requires topojson.js");if("string"!=typeof t.path&&"string"!=typeof t.pathData)throw new Error("MapTable: map not provided");return i.map=t,a},a.data=function(t){return i.data.type="data",i.data.value=t,a},a.json=function(t,e){return i.data.type="json",i.data.path=t,i.data.preFilter=e,a},a.jsonData=function(t){return i.data.type="jsonData",i.data.value=t,a},a.csv=function(t,e){return i.data.type="csv",i.data.path=t,i.data.preFilter=e,a},a.csvData=function(t){return i.data.type="csvData",i.data.value=t,a},a.tsv=function(t,e){return i.data.type="tsv",i.data.path=t,i.data.preFilter=e,a},a.tsvData=function(t){return i.data.type="tsvData",i.data.value=t,a},a.filters=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.filters=t,a},a.table=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.table=t,a},a.columns=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.columns=t, +a},a.render=function(a){if("string"!=typeof t||!document.querySelector(t))throw new Error("MapTable: target not found");if(!i.data||!i.data.type)throw new Error("MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData");i.map&&!i.map.heatmap&&(i.map.heatmap=null),i.map&&i.map.markers===!1&&(i.map.markers=null),i.map&&i.map.countries===!1&&(i.map.countries=null),i.filters||(i.filters=null),i.onComplete=a;var n=A.extendRecursive(z,i);return i.map&&!i.map.markers&&delete n.map.markers,i.map&&!i.map.heatmap&&delete n.map.heatmap,i.map&&!i.map.title&&delete n.map.title,i.map&&!i.map.timezones&&delete n.map.timezones,i.map&&!i.map.night&&delete n.map.night,i.filters||delete n.filters,i.table||delete n.table,e=new G(t,n),{render:function(){return e.render()},loadState:function(t,a){return e.loadState(t,a)},removeState:function(t){return e.removeState(t)},saveState:function(t,a){return e.saveState(t,a)},setTitleContent:function(t){e.options.map.title.content=function(){return t}},setData:function(t){e.options.data.type="data",e.options.data.value=t,e.options.rawData=t,e.rawData=t,e.data=t,e.map&&e.map.enrichData()},setNightDate:function(t){e.options.map.night.date=t},setTimezonesDate:function(t){e.options.map.timezones.date=t},getMapWidth:function(){return e.map.getWidth()},getMapHeight:function(){return e.map.getHeight()}}},a},!d3)throw new Error("Maptable requires d3.js");var Y=d3.maptable;return Y}(); \ No newline at end of file diff --git a/docs/examples/table-with-fixed-header.html b/docs/examples/table-with-fixed-header.html new file mode 100644 index 0000000..365e8f8 --- /dev/null +++ b/docs/examples/table-with-fixed-header.html @@ -0,0 +1,84 @@ + + + + + + + MapTable example + + + + + + + + + +
+
+
[Example] Table with fixed header
+
+ Demonstating: rendering a table and filters with fixed table header
+
+ +
+
+ +
+
+ + + + + + \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 7ac1a4d..ddc10db 100644 --- a/docs/index.html +++ b/docs/index.html @@ -77,6 +77,7 @@

MapTable multiple maptables negative values table only + fixed table header tooltip country w/ legend heatmap aggregate diff --git a/docs/maptable.css b/docs/maptable.css index 0816b32..83d6821 100755 --- a/docs/maptable.css +++ b/docs/maptable.css @@ -1 +1 @@ -.form-control-inline{min-width:0;width:auto;display:inline}.panel{margin-top:15px}.mt-map-container{width:100%;height:0;position:relative;padding-bottom:52%}.mt-map-container #mt-map{width:100%;height:100%;display:block;position:absolute}.mt-map-country:hover{opacity:.9}.mt-map-tooltip{color:#222;background-color:hsla(0,0%,100%,.9);min-width:200px;max-width:300px;position:absolute}.mt-map-tooltip .badge{margin:5px 10px}.mt-map-marker{opacity:.9}.mt-map-marker:hover{opacity:1}.mt-table-sortable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mt-table-sortable.sort_asc:after{content:"▲";font-size:7px;padding-left:5px}.mt-table-sortable.sort_desc:after{content:"▼";font-size:7px;padding-left:5px}.mt-table-sortable{cursor:pointer}#mt-filters-new{margin:10px}.mt-filter-row{margin:10px;padding-bottom:10px;border-bottom:1px solid #ddd;color:#aaa}.mt-filter-row span{font-size:14px;font-weight:500;color:#333;letter-spacing:1px;line-height:34px;padding-left:4px;padding-right:4px}#mt-map:hover #mt-map-export{opacity:1;transition:opacity .5s linear}#mt-map-export{position:absolute;top:10px;right:10px;opacity:0;transition:opacity .5s linear}.mt-loading{position:absolute;top:50%;color:#999;width:100%;text-align:center;font-size:24px;margin-top:-18px;display:none}#mt-map path{will-change:fill}.mt-blur{filter:blur(18px);transform:translateZ(0)}.mt-sun-gradient{background-image:radial-gradient(circle,rgba(255,192,0,.5) 0,rgba(255,192,0,.15) 45%,rgba(255,192,0,0) 100%)} \ No newline at end of file +.form-control-inline{min-width:0;width:auto;display:inline}.panel{margin-top:15px}.mt-map-container{width:100%;height:0;position:relative;padding-bottom:52%}.mt-map-container #mt-map{width:100%;height:100%;display:block;position:absolute}.mt-map-country:hover{opacity:.9}.mt-map-tooltip{color:#222;background-color:hsla(0,0%,100%,.9);min-width:200px;max-width:300px;position:absolute}.mt-map-tooltip .badge{margin:5px 10px}.mt-map-marker{opacity:.9}.mt-map-marker:hover{opacity:1}.mt-table-sortable{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.mt-table-sortable.sort_asc:after{content:"▲";font-size:7px;padding-left:5px}.mt-table-sortable.sort_desc:after{content:"▼";font-size:7px;padding-left:5px}.mt-table-sortable{cursor:pointer}#mt-filters-new{margin:10px}.mt-filter-row{margin:10px;padding-bottom:10px;border-bottom:1px solid #ddd;color:#aaa}.mt-filter-row span{font-size:14px;font-weight:500;color:#333;letter-spacing:1px;line-height:34px;padding-left:4px;padding-right:4px}#mt-map:hover #mt-map-export{opacity:1;transition:opacity .5s linear}#mt-map-export{position:absolute;top:10px;right:10px;opacity:0;transition:opacity .5s linear}.mt-loading{position:absolute;top:50%;color:#999;width:100%;text-align:center;font-size:24px;margin-top:-18px;display:none}#mt-map path{will-change:fill}.mt-blur{filter:blur(18px);transform:translateZ(0)}.mt-sun-gradient{background-image:radial-gradient(circle,rgba(255,192,0,.5) 0,rgba(255,192,0,.15) 45%,rgba(255,192,0,0) 100%)}.mt-header-fixed{position:sticky} \ No newline at end of file diff --git a/docs/maptable.js b/docs/maptable.js index 58a573f..5412939 100644 --- a/docs/maptable.js +++ b/docs/maptable.js @@ -2713,7 +2713,6 @@ this.d3.maptable = (function () { this.maptable = maptable; this.options = options; - if (this.options.defaultSorting) { if (Array.isArray(this.options.defaultSorting) && this.options.defaultSorting.length === 2) { this.sorting = this.options.defaultSorting; @@ -2764,6 +2763,20 @@ this.d3.maptable = (function () { this.activeColumns = Object.keys(this.maptable.columnDetails); } + // make table header fixed + if (this.options.header) { + if (this.options.header.className) { + this.header.attr('class', '' + this.options.header.className); + } + + // set custom top header space + if (this.options.header.top) { + this.header.attr('style', 'top:' + (this.options.header.top || '0') + 'px;'); + } else { + this.header.attr('style', 'top:0px;'); + } + } + this.header.selectAll('tr').data([1]).enter().append('tr').selectAll('th').data(this.activeColumns.map(function (k) { return utils.extendRecursive({ key: k }, _this.maptable.columnDetails[k]); })).enter().append('th').attr('class', function (d) { @@ -3383,11 +3396,11 @@ this.d3.maptable = (function () { var customOptions = utils.extendRecursive(defaultOptions, options); - if (!options.map.markers) delete customOptions.map.markers; - if (!options.map.heatmap) delete customOptions.map.heatmap; - if (!options.map.title) delete customOptions.map.title; - if (!options.map.timezones) delete customOptions.map.timezones; - if (!options.map.night) delete customOptions.map.night; + if (options.map && !options.map.markers) delete customOptions.map.markers; + if (options.map && !options.map.heatmap) delete customOptions.map.heatmap; + if (options.map && !options.map.title) delete customOptions.map.title; + if (options.map && !options.map.timezones) delete customOptions.map.timezones; + if (options.map && !options.map.night) delete customOptions.map.night; if (!options.filters) delete customOptions.filters; if (!options.table) delete customOptions.table; diff --git a/docs/maptable.min.js b/docs/maptable.min.js index 1a3a319..ff11399 100644 --- a/docs/maptable.min.js +++ b/docs/maptable.min.js @@ -1,7 +1,7 @@ /** - * MapTable 2.4.0 - License MIT - Build: Tue Feb 27 2024 17:08:13 GMT+0100 (Central European Standard Time) + * MapTable 2.4.0 - License MIT - Build: Fri May 17 2024 16:15:20 GMT+0545 (Nepal Time) */ -this.d3=this.d3||{},this.d3.maptable=function(){"use strict";function t(t,e,a){e.forEach(function(e){var a=document.createElement("option");a.setAttribute("value",e.value),a.innerText=e.text,t.appendChild(a)}),t.value=a}function e(t,e,a){return"="===e?parseInt(t,10)===parseInt(a,10):"≠"===e?parseInt(t,10)!==parseInt(a,10)&&""!==t&&""!==a:">"===e?parseInt(t,10)>parseInt(a,10)&&""!==t&&""!==a:"<"===e?parseInt(t,10)=parseInt(a,10)&&""!==t&&""!==a:"≤"===e?parseInt(t,10)<=parseInt(a,10)&&""!==t&&""!==a:!0}function a(){for(var t={},e=void 0,i=[].splice.call(arguments,0),n={}.toString;i.length>0;)e=i.splice(0,1)[0],"[object Object]"===n.call(e)&&Object.keys(e).forEach(function(i){"[object Object]"===n.call(e[i])?t[i]=a(t[i]||{},e[i]):t[i]=e[i]});return t}function i(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return e.replace(/_/g," ")}function n(t){return t.toLowerCase().replace(/ /g,"_").replace(/"/g,"").replace(/'/g,"")}function r(t){if(!t||""===t)return null;var e=t.toString().replace(/[^0-9.]+|\s+/gim,"");return""!==e?Number(e):null}function s(t,e){t.sort(function(t,e){return t-e});var a=e/100*(t.length-1),i=void 0;if(Math.floor(a)===a)i=t[a];else{var n=Math.floor(a),r=a-n;i=t[n]+(t[n+1]-t[n])*r}return i}function o(t){if(!t)return t;for(var e=[],a=0,i=t.length;i>a;a+=1)-1===e.indexOf(t[a])&&""!==t[a]&&e.push(t[a]);return e}function l(t,e,a,i){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLImageElement&&!t instanceof HTMLImageElement)return;var n=t.naturalWidth,r=t.naturalHeight;if("string"==typeof e)var e=document.getElementById(e);else if("undefined"!=typeof HTMLCanvasElement&&!e instanceof HTMLCanvasElement)return;e.style.width=n+"px",e.style.height=r+"px",e.width=n,e.height=r;var s=e.getContext("2d");s.clearRect(0,0,n,r),s.drawImage(t,0,0),Number.isNaN(a)||1>a||(i?p(e,0,0,n,r,a):d(e,0,0,n,r,a))}function h(t,e,a,i,n){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLCanvasElement&&!t instanceof HTMLCanvasElement)return;var r,s=t.getContext("2d");try{try{r=s.getImageData(e,a,i,n)}catch(o){throw new Error("unable to access local image data: "+o)}}catch(o){throw new Error("unable to access image data: "+o)}return r}function p(t,e,a,i,n,r){if(!(Number.isNaN(r)||1>r)){r|=0;var s=h(t,e,a,i,n);s=u(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function u(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,E,N,T,D,A,z=t.data,F=r+r+1,j=i-1,H=n-1,O=r+1,P=O*(O+1)/2,I=new m,L=I;for(l=1;F>l;l++)if(L=L.next=new m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r)){r|=0;var s=h(t,e,a,i,n);s=c(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function c(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,E,N=t.data,T=r+r+1,D=i-1,A=n-1,z=r+1,F=z*(z+1)/2,j=new m,H=j;for(l=1;T>l;l++)if(H=H.next=new m,l==z)var O=H;H.next=j;var P=null,I=null;d=u=0;var L=q[r],B=W[r];for(o=0;n>o;o++){for(k=x=w=c=f=g=0,v=z*(C=N[u]),y=z*(S=N[u+1]),b=z*(M=N[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(l=1;z>l;l++)h=u+((l>D?D:l)<<2),c+=(H.r=C=N[h])*(E=z-l),f+=(H.g=S=N[h+1])*E,g+=(H.b=M=N[h+2])*E,k+=C,x+=S,w+=M,H=H.next;for(P=j,I=O,s=0;i>s;s++)N[u]=c*L>>B,N[u+1]=f*L>>B,N[u+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=d+((h=s+r+1)s;s++){for(x=w=k=f=g=c=0,u=s<<2,v=z*(C=N[u]),y=z*(S=N[u+1]),b=z*(M=N[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(p=i,l=1;r>=l;l++)u=p+s<<2,c+=(H.r=C=N[u])*(E=z-l),f+=(H.g=S=N[u+1])*E,g+=(H.b=M=N[u+2])*E,k+=C,x+=S,w+=M,H=H.next,A>l&&(p+=i);for(u=s,P=j,I=O,o=0;n>o;o++)h=u<<2,N[h]=c*L>>B,N[h+1]=f*L>>B,N[h+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=s+((h=o+z)e?e+360:e)/180*O}function v(t){var e=f(t);return(Math.sin(e)*(1.914602-t*(.004817+14e-6*t))+Math.sin(e+e)*(.019993-101e-6*t)+289e-6*Math.sin(e+e+e))*P}function y(t){return g(t)+v(t)}function b(t){return y(t)-(.00569+.00478*Math.sin((125.04-1934.136*t)*P))*P}function k(t){return(23+(26+(21.448-t*(46.815+t*(59e-5-.001813*t)))/60)/60)*P}function x(t){return k(t)+.00256*Math.cos((125.04-1934.136*t)*P)*P}function w(t){return Math.asin(Math.sin(x(t))*Math.sin(b(t)))}function C(t){return.016708634-t*(42037e-9+1.267e-7*t)}function S(t){var e=C(t),a=f(t),i=g(t),n=Math.tan(x(t)/2);return n*=n,n*Math.sin(2*i)-2*e*Math.sin(a)+4*e*n*Math.sin(a)*Math.cos(2*i)-.5*n*n*Math.sin(4*i)-1.25*e*e*Math.sin(2*a)}function M(t){return[t[0]+180,-t[1]]}function E(t){var e=(t-Date.UTC(2e3,0,1,12))/864e5/36525,a=(d3.time.day.utc.floor(t)-t)/864e5*360-180;return[a-S(e)*I,w(e)*I]}var N={};N["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},N.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},N.createClass=function(){function t(t,e){for(var a=0;a\n \n \n \n \n \n '),this.options.timezones&&(this.layerTimezones=this.layerGlobal.append("g").attr("class","mt-map-timezones")),this.layerCountries=this.layerGlobal.append("g").attr("class","mt-map-countries"),this.options.night&&(this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night")),this.options.heatmap&&(this.layerHeatmap=this.layerGlobal.append("g").attr("class","mt-map-heatmap")),this.layerMarkers=this.layerGlobal.append("g").attr("class","mt-map-markers"),this.options.watermark&&(this.watermark=new j(this,this.options.watermark)),this.options.title&&this.buildTitle(),(this.options.exportSvgClient||this.options.exportSvg)&&this.addExportSvgCapability(),this.options.width||window.addEventListener("resize",function(){n.svg.attr("width",n.getWidth()),n.svg.attr("height",n.getHeight()),n.rescale()}),this.loadGeometries()}return N.createClass(t,[{key:"enrichData",value:function(){var t=this;this.maptable.rawData.forEach(function(e){e.longitude=parseFloat(e[t.options.longitudeKey]),e.latitude=parseFloat(e[t.options.latitudeKey]);var a=[0,0];Number.isNaN(e.longitude)||Number.isNaN(e.latitude)||(a=t.projection([e.longitude,e.latitude])),e.x=a[0],e.y=a[1]})}},{key:"scaleAttributes",value:function(){return Math.pow(this.scale,2/3)}},{key:"getWidth",value:function(){return this.options.width?this.options.width:(this.options.width=this.node.offsetWidth,this.node.offsetWidth)}},{key:"getHeight",value:function(){var t=this.options.title?30:0;return!this.options.height&&this.options.ratioFromWidth?this.getWidth()*this.options.ratioFromWidth*this.options.scaleHeight+t:this.options.height*this.options.scaleHeight+t}},{key:"loadGeometries",value:function(){this.options.filterCountries&&(this.jsonWorld.objects.countries.geometries=this.jsonWorld.objects.countries.geometries.filter(this.options.filterCountries)),this.options.countries&&this.buildCountries(),this.options.heatmap&&this.buildHeatmap(),this.options.night&&this.buildNight(),this.options.timezones&&(this.options.timezones.path||this.options.timezones.pathData)&&this.buildTimezone()}},{key:"buildHeatmap",value:function(){var t=topojson.merge(this.jsonWorld,this.jsonWorld.objects.countries.geometries);if(this.options.heatmap.disableMask||(this.maskHeatmap=this.layerHeatmap.append("defs").append("clipPath").attr("id","mt-map-heatmap-mask"),this.maskHeatmap.datum(t).append("path").attr("class","mt-map-heatmap-mask-paths").attr("d",this.path)),this.imgHeatmap=this.layerHeatmap.append("image").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("x",0).attr("y",0).attr("class","mt-map-heatmap-img"),this.options.heatmap.mask&&(this.imgHeatmap=this.imgHeatmap.attr("clip-path","url(#mt-map-heatmap-mask)")),this.options.heatmap.borders){var e=topojson.mesh(this.jsonWorld,this.jsonWorld.objects.countries,function(t,e){return t!==e});this.bordersHeatmap=this.layerHeatmap.append("g").attr("class","mt-map-heatmap-borders"),this.bordersHeatmap.selectAll("path.mt-map-heatmap-borders-paths").data([t,e]).enter().append("path").attr("class","mt-map-heatmap-borders-paths").attr("fill","none").attr("stroke-width",this.options.heatmap.borders.stroke).attr("stroke",this.options.heatmap.borders.color).attr("style","opacity: "+this.options.heatmap.borders.opacity).attr("d",this.path)}}},{key:"buildNight",value:function(){this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night");var t=d3.geo.circle().angle(90);this.maskNight=this.layerNight.append("defs").append("clipPath").attr("id","mt-map-night-mask"),this.maskNight.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.nightPath=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.path).style("opacity",.1);var e=this.options.night.date||Date.UTC(),a=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),0,0,0),i=E(new Date(a));if(this.nightPath.datum(t.origin(M(i))).attr("d",this.path),this.nightPathRight=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+this.getWidth()+"px,0,0)"),this.nightPathLeft=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+-this.getWidth()+"px,0,0)"),!this.options.night.disableSun){var n=this.projection(i);this.sunCircleRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]+this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]-this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]-2*this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight())}}},{key:"buildTimezone",value:function(){var t=this;this.options.timezones.pathData?this.loadTimezone(null,JSON.parse(this.options.timezones.pathData)):this.options.timezones.path&&d3.json(this.options.timezones.path,function(e,a){t.loadTimezone(e,a)})}},{key:"scaleFontSize",value:function(t){return this.getWidth()<700?t*(this.getWidth()/700):t}},{key:"loadTimezone",value:function(t,e){var a=this;this.dataTimezones=topojson.feature(e,e.objects.timezones).features,this.maskTimezone=this.layerTimezones.append("defs").append("clipPath").attr("id","mt-map-timezone-mask"),this.maskTimezone.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.layerTimezones.selectAll(".mt-map-timezone").data(this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places})).enter().insert("path").attr("class","mt-map-timezone").attr("d",this.path).attr("fill",function(t){return t.properties.zone%2===0?"#F4F5F5":"transparent"}).attr("title",function(t){return JSON.stringify(t.properties)}).attr("clip-path","url(#mt-map-timezone-mask)").style("opacity",.6);var i=this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places&&t.properties.zone%1===0&&14!==t.properties.zone}),n=[].concat(N.toConsumableArray(new Map(i.map(function(t){return[t.properties.zone,t]})).values()));this.layerTimezonesText=this.layerTimezones.append("g").attr("class","mt-map-timezones-texts"),this.layerTimezonesText.selectAll(".mt-map-timezone-text").data(n).enter().insert("text").attr("class","mt-map-timezone-text").attr("y",.82*this.getHeight()-5).attr("x",function(t){return(t.properties.zone+10)*(a.getWidth()/24.5)-1}).attr("dx",this.getWidth()/24.5/2).attr("font-size",this.scaleFontSize(9)).attr("font-family","Helevetica, Arial, Sans-Serif").attr("fill","#999").attr("text-anchor","middle").html(function(t){return A.formatDate(a.options.timezones.date||new Date,t.properties.zone)})}},{key:"getMagnitudeScale",value:function(t){var e=this.options.heatmap,a=t.length;if(!a)return function(){return 0};var i=d3.scale.linear().domain([1,a]).range([1,.25]),n=i(a),r=d3.scale.linear().domain([e.circles.min,20]).range([n,0]);return function(t){return r(t)}}},{key:"getDatumScale",value:function(){var t=this;if(!this.options.heatmap.weightByAttribute)return function(){return 1};var e=d3.extent(this.maptable.data,this.options.heatmap.weightByAttribute),a="log"===this.options.heatmap.weightByAttributeScale?d3.scale.log:d3.scale.linear,i=a().domain(e).range([.5,1]);return function(e){var a=t.options.heatmap.weightByAttribute(e);return a?i(a):0}}},{key:"getHeatmapData",value:function(){var t=this,e=d3.select(this.node).append("canvas").attr("id","mt-map-heatmap-canvas").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("style","display: none;"),a=e.node().getContext("2d");a.globalCompositeOperation="multiply";var i=d3.range(this.options.heatmap.circles.min,this.options.heatmap.circles.max,this.options.heatmap.circles.step),n=this.getDatumScale(),r=this.maptable.data.filter(function(t){return n(t)>.1}),s=this.path.context(a),o=this.getMagnitudeScale(r),l=d3.scale.linear().domain([1,0]).range(["#000000","#FFFFFF"]);a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle="#ffffff",a.fill(),a.closePath();var h=function(e){var a=t.options.heatmap.circles.colorStrength,i=1+(a-1)/100;return a>1?(2-i)*e+i-1:a*e};r.forEach(function(t){var e=n(t);i.forEach(function(i){var n=h(o(i)*e);n>0&&(a.beginPath(),s(d3.geo.circle().origin([t.longitude,t.latitude]).angle(i-1e-4)()),a.fillStyle=l(n),a.fill(),a.closePath())})}),H.canvasRGBA(e.node(),0,0,this.getWidth(),this.getHeight(),this.options.heatmap.circles.blur),a.beginPath(),a.globalCompositeOperation="screen",a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle=this.options.heatmap.circles.color,a.fill(),a.closePath();var p=e.node().toDataURL();return e.remove(),p}},{key:"updateHeatmap",value:function(){var t=this.getHeatmapData();this.imgHeatmap.attr("xlink:href",t)}},{key:"buildCountries",value:function(){this.dataCountries=topojson.feature(this.jsonWorld,this.jsonWorld.objects.countries).features,this.layerCountries.selectAll(".mt-map-country").data(this.dataCountries).enter().insert("path").attr("class","mt-map-country").attr("d",this.path),this.legendCountry={},this.shouldRenderLegend()&&(this.legendCountry.fill=new F(this))}},{key:"shouldRenderLegend",value:function(){var t=this.options.countries.attr.fill;if(!t)return!1;if(!t.legend||!t.min||!t.max)return!1;if(t.aggregate&&t.aggregate.scale){var e="function"==typeof t.aggregate.scale?t.aggregate.scale.bind(this.maptable)():t.aggregate.scale;if("linear"!==e)return!1}return!0}},{key:"getAllMtMapCountry",value:function(){return this.allMtMapCountry?this.allMtMapCountry:(this.allMtMapCountry=d3.selectAll(this.containerSelector+" .mt-map-country"),this.allMtMapCountry)}},{key:"getAllMtMapMarker",value:function(){return this.allMtMapMarker?this.allMtMapMarker:(this.allMtMapMarker=d3.selectAll(this.containerSelector+" .mt-map-marker"),this.allMtMapMarker)}},{key:"updateCountries",value:function(){var t=this,e=new Map;this.maptable.data.forEach(function(a){var i=a[t.options.countryIdentifierKey];e.has(i)||e.set(i,[]),e.get(i).push(a)}),this.dataCountries.forEach(function(a){a.key=a.properties[t.options.countryIdentifierType];var i=e.get(a.key);a.values=i||[],a.attr={},a.rollupValue={}}),Object.keys(this.options.countries.attr).forEach(function(e){t.setAttrValues(e,t.options.countries.attr[e],t.dataCountries)});var a=this.getAllMtMapCountry().each(function(t){var e=d3.select(this);Object.keys(t.attr).forEach(function(a){e.attr(a,t.attr[a])})});Object.keys(this.options.countries.attr).forEach(function(e){var i=t.options.countries.attr[e];if("object"===("undefined"==typeof i?"undefined":N["typeof"](i))&&i.legend&&void 0!==t.legendCountry[e]){var n=d3.extent(t.dataCountries,function(t){return Number(t.attrProperties[e].value)});t.legendCountry[e].updateExtents(n),a.on("mouseover",function(a){t.legendCountry[e].indiceChange(a.attrProperties[e].value)}).on("mouseout",function(){t.legendCountry[e].indiceChange(NaN)})}}),this.options.countries&&this.options.countries.tooltip&&this.activateTooltip(a,this.tooltipCountriesNode,this.options.countries.tooltip,!0)}},{key:"updateNight",value:function(){var t=this.options.night.date||Date.UTC(),e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0),a=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),23,59,59),i=a-e,n=t-e,r=n/i;this.layerNight.node().style.transform="translateX("+-this.getWidth()*r+"px)"}},{key:"updateTimezones",value:function(){var t=document.querySelectorAll(".mt-map-timezone-text"),e=this.options.timezones.date||new Date;Array.from(t).forEach(function(t){t.textContent=A.formatDate(e,t.__data__.properties.zone)})}},{key:"updateMarkers",value:function(){var t=this,e=function(t){return t.longitude+","+t.latitude};this.dataMarkers=d3.nest().key(e).entries(this.maptable.data).filter(function(t){return 0!==t.values[0].x}),this.dataMarkers.forEach(function(t){t.attr={},t.attrProperties={}}),Object.keys(this.options.markers.attr).forEach(function(e){t.setAttrValues(e,t.options.markers.attr[e],t.dataMarkers)});var a=this.layerMarkers.selectAll(".mt-map-marker").data(this.dataMarkers),i=a.enter();i=this.options.markers.customTag?this.options.markers.customTag(i):i.append("svg:circle");var n=this.options.markers.className?this.options.markers.className:"";i.attr("class","mt-map-marker "+n),a.exit().transition().attr("r",0).attr("fill","#eee").style("opacity",0).remove();var r=this.options.markers.attrX?this.options.markers.attrX:"cx",s=this.options.markers.attrY?this.options.markers.attrY:"cy",o=this.options.markers.attrXDelta?this.options.markers.attrXDelta:0,l=this.options.markers.attrYDelta?this.options.markers.attrYDelta:0,h=a.attr(r,function(t){return t.values[0].x+o}).attr(s,function(t){return t.values[0].y+l});this.getAllMtMapMarker().each(function(t){var e=this;Object.keys(t.attr).forEach(function(a){d3.select(e).attr(a,t.attr[a])})}),this.options.markers.tooltip&&this.activateTooltip(h,this.tooltipMarkersNode,this.options.markers.tooltip,!1),this.rescale()}},{key:"fitContent",value:function(){if(0===this.maptable.data.length)return this.transX=0,this.transY=0,this.scale=1,void this.zoomListener.translate([this.transX,this.transY]).scale(this.scale);var t=d3.extent(this.maptable.data,function(t){return t.x}),e=d3.extent(this.maptable.data,function(t){return t.y}),a=this.getWidth()/this.getHeight(),i=20+(this.options.title?30:0),n=t[1]-t[0]+i,r=e[1]-e[0]+i,s=n/a,o=r*a,l=0,h=0;o>=n?l=(o-n)/2:h=(s-r)/2,t[0]-=this.options.fitContentMargin+l,t[1]+=this.options.fitContentMargin+l,e[0]-=this.options.fitContentMargin+h,e[1]+=this.options.fitContentMargin+h,this.scale=this.getWidth()/(t[1]-t[0]),this.transX=-1*t[0]*this.scale,this.transY=-1*e[0]*this.scale,this.zoomListener.translate([this.transX,this.transY]).scale(this.scale); -}},{key:"buildTitle",value:function(){var t=this.svg.append("svg").attr("width",this.getWidth()).attr("x",0).attr("y",this.getHeight()-30).attr("height",30);this.options.title.bgColor&&t.append("rect").attr("x",0).attr("y",0).attr("width",this.getWidth()).attr("height",30).attr("fill",this.options.title.bgColor),t.append("text").attr("id","mt-map-title").attr("x",20).attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).attr("y",20),this.options.title.source&&t.append("text").attr("y",20).attr("x",this.getWidth()-20).attr("text-anchor","end").attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).html(this.options.title.source())}},{key:"encodeTranslation",value:function(t){var e=t[0]/(this.scale*this.getWidth()),a=t[1]/(this.scale*this.getHeight());return[e,a]}},{key:"decodeTranslation",value:function(t){var e=t[0]*this.getWidth()*this.scale,a=t[1]*this.getHeight()*this.scale;return[e,a]}},{key:"restoreState",value:function(t){if(t&&3===t.length){this.scale=t[0];var e=this.decodeTranslation([t[1],t[2]]);this.transX=e[0],this.transY=e[1],this.zoomListener.scale(t[0]).translate(e).event(this.svg)}}},{key:"saveState",value:function(){var t=this.encodeTranslation([this.transX,this.transY]),e=[this.scale,t[0],t[1]];1!==e[0]&&0!==e[1]&&0!==e[2]?this.maptable.saveState("zoom",e):this.maptable.removeState("zoom")}},{key:"rescale",value:function(){var t=this;d3.event&&d3.event.translate&&(this.scale=d3.event.scale,this.transX=1===this.scale?0:d3.event.translate[0],this.transY=1===this.scale?0:d3.event.translate[1]);var e=0,a=0,i=this.getWidth()*(1-this.scale),n=this.getHeight()*(1-this.scale);this.transY>a?this.transY=a:this.transYe?this.transX=e:this.transXe?e:t},e[0])};else if("max"===s)e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return e.reduce(function(t,e){return e>t?e:t},e[0])};else if(-1!==s.indexOf("percentile")){var l=A.toNumber(s);e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return A.quantile(e,l)}}else"function"==typeof e.rollup&&(e.rollup=e.rollup.bind(this.maptable));n&&(-1!==n.indexOf("log")?o=d3.scale.log():-1!==n.indexOf("pow")?o=d3.scale.pow().exponent(A.toNumber(n)||1):"sqrt"===n&&(o=d3.scale.sqrt()))}if(e.rollup||(e.rollup=function(t){return t.length}),!e.min||!e.max)throw new Error("MapTable: You should provide values 'min' & 'max' for attr."+t);if(a.forEach(function(a){var o=e.rollup(a.values);if(a.attrProperties||(a.attrProperties={}),a.attrProperties[t]||(a.attrProperties[t]={}),a.attrProperties[t].value=o,r){a.attrProperties[t].key=r,a.attrProperties[t].mode=s,a.attrProperties[t].scale=n;var l=i.maptable.columnDetails[r];a.attrProperties[t].columnDetails=l;var h={};h[r]=o,a.attrProperties[t].formatted=l&&l.cellContent?l.cellContent.bind(i.maptable)(h):o}}),"rank"===n){var h=A.uniqueValues([0].concat(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return t>0}))),p=A.uniqueValues(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return 0>t}));h.sort(function(t,e){return t-e}),p.sort(function(t,e){return e-t}),a.forEach(function(e){if(0!==e.attrProperties[t].value){var a=e.attrProperties[t].value>=0?h:p,i=a.indexOf(Math.floor(100*e.attrProperties[t].value)/100),n=Math.round(i/a.length*100),r=e.attrProperties[t].value<0?n-2*n:n;e.attrProperties[t].value=r}})}var u=d3.extent(a,function(e){return Number(e.attrProperties[t].value)});0===u[0]&&n&&"-1"!==n.indexOf("log")&&(u=d3.extent(a.filter(function(e){return 0!==Number(e.attrProperties[t].value)}),function(e){return Number(e.attrProperties[t].value)})),e.transform&&(u[0]=e.transform.bind(this.maptable)(u[0],this.maptable.data),u[1]=e.transform.bind(this.maptable)(u[1],this.maptable.data));var d=e.min,c=e.max;if("minValue"===e.min&&(d=u[0]),"maxValue"===e.max&&(c=u[1]),e.maxNegative&&!e.minNegative||!e.maxNegative&&e.minNegative)throw new Error("MapTable: maxNegative or minNegative undefined. Please declare both.");var m=e.maxNegative&&e.minNegative,f=void 0,g=void 0;m?(f=o.copy().domain([0,u[1]]).range([d,c]),g=o.copy().domain([u[0],0]).range([e.maxNegative,e.minNegative])):f=o.domain(u).range([d,c]),a.forEach(function(a){var n=void 0;if(!a.values.length||Number.isNaN(a.attrProperties[t].value)){if("undefined"==typeof e.empty)throw new Error("MapTable: no empty property found for attr."+t);n=e.empty}else{var r=a.attrProperties[t].value,s=e.transform?e.transform.bind(i.maptable)(r,i.maptable.data):r;n=m&&0>s?g(s):f(s)}a.attr[t]=n})}}},{key:"render",value:function(){this.options.markers&&this.updateMarkers(),this.options.countries&&this.updateCountries(),this.options.night&&this.updateNight(),this.options.timezones&&this.updateTimezones(),this.options.title&&this.updateTitle(),this.options.heatmap&&this.updateHeatmap(),this.options.autoFitContent&&(this.fitContent(),this.rescale()),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"updateTitle",value:function(){var t=this;if(this.options.title.content){var e=this.maptable.data.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,a=this.maptable.rawData.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,i="";this.maptable.filters&&(i=this.maptable.filters.getDescription()),this.container.querySelector("#mt-map-title").innerHTML=this.options.title.content.bind(this.maptable)(e,a,i,this.maptable.data,this.maptable.rawData,this.dataCountries)}}},{key:"activateTooltip",value:function(t,e,a,i){var n=this;t.on(i?"mousemove":"mouseover",function(t){var r=a.bind(this.maptable)(t);if(r){e.html(r).attr("style","display:block;position:fixed;");var s=void 0,o=void 0,l=e.node().offsetWidth/2;if(i){var h=n.node.getBoundingClientRect(),p=d3.mouse(n.svg.node()).map(function(t){return parseInt(t,10)});s=h.left+p[0]-l,o=h.top+p[1]+10}else{var u=this.getBoundingClientRect();s=u.left+u.width/2-l,o=u.top+u.height+2}e.attr("style","top:"+o+"px;left:"+s+"px;display:block;position:fixed;").on("mouseout",function(){e.style("display","none")})}}).on("mouseout",function(){e.style("display","none")})}},{key:"exportSvg",value:function(){var t=this.container.querySelector("#mt-map-svg"),e='\n'+(new XMLSerializer).serializeToString(t);if(this.options.exportSvgClient){if(!window.saveAs)throw new Error("MapTable: Missing FileSaver.js library");var a=new Blob([e],{type:"image/svg+xml"});window.saveAs(a,"visualization.svg")}else if(this.options.exportSvg){var i=this.node.querySelector("#mt-map-svg-form");i.querySelector('[name="data"]').value=e,i.submit()}}},{key:"addExportSvgCapability",value:function(){var t=document.createElement("div");t.setAttribute("id","mt-map-export"),this.container.querySelector("#mt-map").appendChild(t);var e=document.createElement("button");if(e.setAttribute("class","btn btn-xs btn-default"),e.innerHTML="Download",e.addEventListener("click",this.exportSvg.bind(this)),t.appendChild(e),this.options.exportSvg){var a=document.createElement("div");a.innerHTML='
',t.appendChild(a)}}}]),t}(),B=function(){function t(e,a){var i=this;if(N.classCallCheck(this,t),this.maptable=e,this.options=a,this.criteria=[],this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.container=document.createElement("div"),this.maptable.node.appendChild(this.container),this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-filters"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-filters"),this.node.setAttribute("class","panel panel-default"),this.maptable.node.appendChild(this.node));var r=document.createElement("div");r.setAttribute("class","panel-heading");var s=document.createElement("button");s.setAttribute("id","mt-filters-reset"),s.setAttribute("class","btn btn-default btn-xs pull-right"),s.style.display="none",s.style.marginLeft=5,s.innerText="↺ Reset",s.addEventListener("click",this.reset),r.appendChild(s);var o=document.createElement("h3");o.setAttribute("class","panel-title"),o.appendChild(document.createTextNode("Filters")),r.appendChild(o),this.node.appendChild(r);var l=document.createElement("div");l.setAttribute("id","mt-filters-content"),l.setAttribute("class","panel-body");var h=document.createElement("div");h.setAttribute("id","mt-filters-elements"),l.appendChild(h);var p=document.createElement("a");p.setAttribute("id","mt-filters-new"),p.setAttribute("href","#"),p.innerText="+ New filter",p.addEventListener("click",this.add.bind(this)),l.appendChild(p),this.node.appendChild(l)}return N.createClass(t,[{key:"add",value:function(t){t&&t.preventDefault();var e=this.getPossibleFilters();if(0!==e.length){var a=e[0].key;this.create(a)}}},{key:"create",value:function(t,e){var a=this.buildRow(t);e?e.parentNode.replaceChild(a,e):this.node.querySelector("#mt-filters-elements").appendChild(a),this.criteria.push(t),this.maptable.render(),"none"===this.container.style.display&&this.toggle()}},{key:"remove",value:function(t){var e=this.node.querySelector('[data-mt-filter-name="'+t+'"]');e&&e.parentNode.removeChild(e);var a=this.criteria.indexOf(t);this.criteria.splice(a,1),this.maptable.render()}},{key:"reset",value:function(){for(var t=this.node.querySelectorAll("[data-mt-filter-name]"),e=0;e and\n '+h+""}else{var p=i.querySelector(".mt-filter-value-min").value;if(""===p)continue;s+=r.title+" is ",s+=o.options[o.selectedIndex].text,s+=''+p+""}}else if("field"===r.filterMethod||"dropdown"===r.filterMethod){var u=i.querySelector(".mt-filter-value").value;if(""===u)continue;var d="field"===r.filterMethod?"contains":"is";s+=r.title+" "+d+'\n '+u+""}t.push(s)}return t.join(", ")}},{key:"buildRow",value:function(t){var e=this,a=this,i=this.getPossibleFilters(),n=this.maptable.columnDetails[t],r=document.createElement("div");r.setAttribute("class","mt-filter-row"),r.setAttribute("data-mt-filter-name",t);var s=document.createElement("button");s.setAttribute("class","btn btn-default pull-right"),s.setAttribute("data-mt-filter-btn-minus",1),s.innerText="– Remove this filter",s.addEventListener("click",function(){t=r.querySelector(".mt-filter-name").value,e.remove(t)}),r.appendChild(s);var o=document.createElement("span");o.setAttribute("class","mt-filters-and"),o.innerText="And ",r.appendChild(o);var l=document.createElement("select");l.setAttribute("class","mt-filter-name form-control form-control-inline"),A.appendOptions(l,i.map(function(t){return{text:t.title,value:t.key}})),l.value=t,l.addEventListener("change",function(){var t=this.parentNode.getAttribute("data-mt-filter-name"),e=this.value;a.create(e,this.parentNode),a.remove(t),a.refresh()}),r.appendChild(l);var h=document.createElement("span");h.innerText="field"===n.filterMethod?" contains ":" is ",r.appendChild(h);var p=null;"field"!==n.filterMethod&&"dropdown"!==n.filterMethod&&(p=document.createElement("select"),p.setAttribute("class","mt-filter-range form-control form-control-inline"),A.appendOptions(p,["any","=","≠","<",">","≤","≥","BETWEEN"].map(function(t){return{text:t,value:t}})),p.addEventListener("change",function(){a.handleRangeChange(this)}),r.appendChild(p),r.appendChild(document.createTextNode(" ")));var u=document.createElement("div");if(u.style.display="inline-block",u.setAttribute("class","mt-filter-value-container"),"compare"===n.filterMethod)["min","max"].forEach(function(t,a){var i=document.createElement("input");if(i.setAttribute("class","form-control form-control-inline mt-filter-value-"+t),i.setAttribute("type",n.filterInputType),i.addEventListener("keyup",e.maptable.render.bind(e.maptable)),i.addEventListener("change",e.maptable.render.bind(e.maptable)),u.appendChild(i),0===a){var r=document.createElement("span");r.setAttribute("class","mt-filter-value-and"),r.innerText=" and ",u.appendChild(r)}});else if("field"===n.filterMethod){var d=document.createElement("input");d.setAttribute("class","form-control form-control-inline mt-filter-value"),d.setAttribute("type","text"),d.addEventListener("keyup",this.maptable.render.bind(this.maptable)),d.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(d)}else if("dropdown"===n.filterMethod){var c=document.createElement("select");c.setAttribute("class","form-control form-control-inline mt-filter-value");var m=d3.nest().key(function(e){return e[t]}).sortKeys(d3.ascending).entries(this.maptable.rawData);A.appendOptions(c,[{text:"Any",value:""}].concat(m.map(function(t){return{text:t.key,value:t.key}}))),c.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(c)}return r.appendChild(u),p&&this.handleRangeChange(p),r}},{key:"handleRangeChange",value:function(t){var e=t.parentNode;"any"===t.value?e.querySelector(".mt-filter-value-container").style.display="none":(e.querySelector(".mt-filter-value-container").style.display="inline-block","BETWEEN"===t.value?(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="inline-block",e.querySelector(".mt-filter-value-max").style.display="inline-block"):(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="none",e.querySelector(".mt-filter-value-max").style.display="none")),this.maptable.render.bind(this.maptable)()}},{key:"getPossibleFilters",value:function(t){var e=this;return Object.keys(this.maptable.columnDetails).map(function(t){return A.extendRecursive({key:t},e.maptable.columnDetails[t])}).filter(function(a){return-1!==e.activeColumns.indexOf(a.key)&&(t&&t===a.key||-1===e.criteria.indexOf(a.key)&&a.filterMethod&&!a.isVirtual)})}},{key:"filterData",value:function(){var t=this,e=this;this.maptable.data=this.maptable.rawData.filter(function(a){for(var i=t.node.querySelectorAll(".mt-filter-row"),n=!0,r=0;rh(m))?n=!1:(parseInt(a[o],10)parseInt(m,10))&&(n=!1)}else{var f=s.querySelector(".mt-filter-value-min").value;if(""===f)continue;h&&!A.rangeToBool(h(a[o]),d,h(f))?n=!1:h||A.rangeToBool(a[o],d,f)||(n=!1)}}(h&&A.isBlank(h(a[o]))||A.isBlank(a[o]))&&(n=!1)}return n}),this.options.saveState&&this.maptable.saveState("filters",this.exportFilters())}},{key:"refresh",value:function(){for(var t=this.node.querySelectorAll(".mt-filter-name"),e=0;e0&&(this.node.querySelectorAll(".mt-filters-and")[0].style.visibility="hidden");var r=!this.getPossibleFilters().length;this.node.querySelector("#mt-filters-new").style.visibility=r?"hidden":"visible"}},{key:"toggle",value:function(){"none"===this.container.style.display?(this.container.style.display="block",0===this.criteria.length&&this.add()):this.container.style.display="none"}}]),t}(),R=function(){function t(e,a){var i=this;if(N.classCallCheck(this,t),this.maptable=e,this.options=a,this.options.defaultSorting?(Array.isArray(this.options.defaultSorting)&&2===this.options.defaultSorting.length?this.sorting=this.options.defaultSorting:this.sorting=[this.options.defaultSorting],this.sorting.forEach(function(t){t.mode||(t.mode="asc")})):this.sorting=[{key:Object.keys(this.maptable.data[0])[0],mode:"asc"}],this.initialSorting=this.sorting.map(function(t){return t.key+","+t.mode}).join(";"),this.isSorting=!1,this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-table"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-table"),this.maptable.node.appendChild(this.node)),this.node=d3.select(this.node).append("table").attr("class",this.options.className),this.header=this.node.append("thead"),this.body=this.node.append("tbody"),this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.header.selectAll("tr").data([1]).enter().append("tr").selectAll("th").data(this.activeColumns.map(function(t){return A.extendRecursive({key:t},i.maptable.columnDetails[t])})).enter().append("th").attr("class",function(t){var e=t.sorting?"mt-table-sortable":"";return e+=t.nowrap?" nowrap":""}).attr("data-key",function(t){return A.sanitizeKey(t.key)}).attr("onselectstart","return false;").attr("unselectable","on").attr("style",function(t){return t.nowrap?"white-space:nowrap;":""}).on("click",function(t){i.isSorting||(i.isSorting=!0,t.sorting&&i.sortColumn(t.key),i.isSorting=!1)}).text(function(t){return t.title}).attr("id",function(t){return"column_header_"+A.sanitizeKey(t.key)})}return N.createClass(t,[{key:"restoreState",value:function(t){if(t){var e=t.split(";"),a=[];e.forEach(function(t){var e=t.split(",");a.push({key:e[0],mode:e[1]||"asc"})}),this.sorting=a}}},{key:"saveState",value:function(){var t=this.sorting.map(function(t){return t.key+","+t.mode}).join(";");t!==this.initialSorting&&this.maptable.saveState("sort",t)}},{key:"render",value:function(){var t=this;this.applySort();var e=this.maptable.data;this.options.distinctBy&&(e=d3.nest().key(function(e){return e[t.options.distinctBy]}).entries(this.maptable.data).map(function(t){return t.values[0]})),this.body.selectAll("tr").data(e).enter().append("tr"),this.body.selectAll("tr").data(e).exit().remove();var a=[];this.body.selectAll("tr").data(e).attr("class",function(e){return t.options.rowClassName?"line "+t.options.rowClassName(e):"line"}).html(function(e){var i="";return t.activeColumns.forEach(function(n){var r=t.maptable.columnDetails[n];i+=""}),i}),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"applySort",value:function(){for(var t=this,e=this.container.querySelectorAll(".mt-table-sortable"),a=0;a0;if(this.options.map.heatmap&&n)return i.innerHTML='
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map=!1,void this.buildComponenents();if(i.innerHTML='
Loading...
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map.pathData)this.loadMapData(null,JSON.parse(this.options.map.pathData),i);else{if(!this.options.map.path)throw new Error("missing map path|pathData");d3.json(this.options.map.path,function(t,e){a.loadMapData(t,e,i)})}}else this.buildComponenents()}},{key:"loadMapData",value:function(t,e,a){if(t)throw t;this.map=new L(this,this.options.map,e),a.querySelector(".mt-loading").style.display="none",this.buildComponenents()}},{key:"buildComponenents",value:function(){var t=this;this.options.filters&&(this.filters=new B(this,this.options.filters)),this.options.table&&(this.table=new R(this,this.options.table)),this.restoreState(),window.addEventListener("hashchange",function(){t.restoreState()}),this.render()}},{key:"loadState",value:function(t,e){if(e){var a=this.parseState(t);if(!a)return null;try{var i=JSON.parse(a);this.state[t]=i}catch(n){return console.log("Maptable: Invalid URL State for mt-"+t+" "+n.message),null}}else{var r=this.parseState(t);r&&(this.state[t]=r)}return this.state[t]}},{key:"restoreState",value:function(){this.map&&(this.loadState("zoom",!0),this.map.restoreState(this.state.zoom)),this.filters&&(this.loadState("filters",!0),this.filters.restoreState(this.state.filters)),this.table&&(this.loadState("sort",!1),this.table.restoreState(this.state.sort))}},{key:"parseState",value:function(t){var e=document.location.href.replace(/%21mt/g,"!mt").split("!mt-"+t+"=");return e[1]?decodeURIComponent(e[1].split("!mt")[0]):null}},{key:"removeState",value:function(t){window.clearTimeout(this.saveStateTimeout[t]),delete this.state[t],this.updateState()}},{key:"saveState",value:function(t,e){var a=this;window.clearTimeout(this.saveStateTimeout[t]),this.saveStateTimeout[t]=window.setTimeout(function(){a.state[t]=e,a.updateState()},200)}},{key:"updateState",value:function(){var t=this,e=document.location.href.split("#")[0],a="";Object.keys(this.state).forEach(function(e){if(t.state[e]){var i=t.state[e];if("object"===N["typeof"](t.state[e])){if(!Object.keys(t.state[e]).length)return;i=JSON.stringify(t.state[e])}a+="!mt-"+e+"="+encodeURIComponent(i)}}),""!==a&&(a="#"+a),document.location.href!==""+e+a&&window.history.pushState(null,null,""+e+a)}},{key:"render",value:function(){this.filters&&(this.filters.filterData(),this.filters.refresh()),this.map&&(this.map.render(),!this.firstExecution&&this.options.map.onComplete&&this.options.map.onComplete.constructor===Function&&this.options.map.onComplete.bind(this)()),this.table&&(this.table.render(),!this.firstExecution&&this.options.table.onComplete&&this.options.table.onComplete.constructor===Function&&this.options.table.onComplete.bind(this)()),!this.firstExecution&&this.options.onComplete&&this.options.onComplete.constructor===Function&&this.options.onComplete.bind(this)(),this.firstExecution=!0}},{key:"setColumnDetails",value:function(){var t=this;if(0!==t.rawData.length){var e={};Object.keys(t.rawData[0]).forEach(function(a){var i=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,n=i.test(t.rawData[0][a]);e[a]={title:A.keyToTile(a),filterMethod:n?"compare":"field",filterInputType:n?"number":"text",sorting:!0},n&&(e[a].dataParse=function(t){return parseFloat(t)})}),t.columnDetails=A.extendRecursive(e,this.options.columns),Object.keys(t.columnDetails).forEach(function(e){t.columnDetails[e].isVirtual="function"==typeof t.columnDetails[e].virtual})}}}]),t}();if(d3.maptable=function(t){var e=void 0,a={},i={target:t,columns:{},data:{},map:null,filters:null,table:null};return a.map=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!topojson)throw new Error("Maptable requires topojson.js");if("string"!=typeof t.path&&"string"!=typeof t.pathData)throw new Error("MapTable: map not provided");return i.map=t,a},a.data=function(t){return i.data.type="data",i.data.value=t,a},a.json=function(t,e){return i.data.type="json",i.data.path=t,i.data.preFilter=e,a},a.jsonData=function(t){return i.data.type="jsonData",i.data.value=t,a},a.csv=function(t,e){return i.data.type="csv",i.data.path=t,i.data.preFilter=e,a},a.csvData=function(t){return i.data.type="csvData",i.data.value=t,a},a.tsv=function(t,e){return i.data.type="tsv",i.data.path=t,i.data.preFilter=e,a},a.tsvData=function(t){return i.data.type="tsvData",i.data.value=t,a},a.filters=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.filters=t,a},a.table=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.table=t,a},a.columns=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.columns=t,a},a.render=function(a){if("string"!=typeof t||!document.querySelector(t))throw new Error("MapTable: target not found");if(!i.data||!i.data.type)throw new Error("MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData"); -i.map&&!i.map.heatmap&&(i.map.heatmap=null),i.map&&i.map.markers===!1&&(i.map.markers=null),i.map&&i.map.countries===!1&&(i.map.countries=null),i.filters||(i.filters=null),i.onComplete=a;var n=A.extendRecursive(z,i);return i.map.markers||delete n.map.markers,i.map.heatmap||delete n.map.heatmap,i.map.title||delete n.map.title,i.map.timezones||delete n.map.timezones,i.map.night||delete n.map.night,i.filters||delete n.filters,i.table||delete n.table,e=new G(t,n),{render:function(){return e.render()},loadState:function(t,a){return e.loadState(t,a)},removeState:function(t){return e.removeState(t)},saveState:function(t,a){return e.saveState(t,a)},setTitleContent:function(t){e.options.map.title.content=function(){return t}},setData:function(t){e.options.data.type="data",e.options.data.value=t,e.options.rawData=t,e.rawData=t,e.data=t,e.map&&e.map.enrichData()},setNightDate:function(t){e.options.map.night.date=t},setTimezonesDate:function(t){e.options.map.timezones.date=t},getMapWidth:function(){return e.map.getWidth()},getMapHeight:function(){return e.map.getHeight()}}},a},!d3)throw new Error("Maptable requires d3.js");var Y=d3.maptable;return Y}(); \ No newline at end of file +this.d3=this.d3||{},this.d3.maptable=function(){"use strict";function t(t,e,a){e.forEach(function(e){var a=document.createElement("option");a.setAttribute("value",e.value),a.innerText=e.text,t.appendChild(a)}),t.value=a}function e(t,e,a){return"="===e?parseInt(t,10)===parseInt(a,10):"≠"===e?parseInt(t,10)!==parseInt(a,10)&&""!==t&&""!==a:">"===e?parseInt(t,10)>parseInt(a,10)&&""!==t&&""!==a:"<"===e?parseInt(t,10)=parseInt(a,10)&&""!==t&&""!==a:"≤"===e?parseInt(t,10)<=parseInt(a,10)&&""!==t&&""!==a:!0}function a(){for(var t={},e=void 0,i=[].splice.call(arguments,0),n={}.toString;i.length>0;)e=i.splice(0,1)[0],"[object Object]"===n.call(e)&&Object.keys(e).forEach(function(i){"[object Object]"===n.call(e[i])?t[i]=a(t[i]||{},e[i]):t[i]=e[i]});return t}function i(t){var e=t.charAt(0).toUpperCase()+t.slice(1);return e.replace(/_/g," ")}function n(t){return t.toLowerCase().replace(/ /g,"_").replace(/"/g,"").replace(/'/g,"")}function r(t){if(!t||""===t)return null;var e=t.toString().replace(/[^0-9.]+|\s+/gim,"");return""!==e?Number(e):null}function s(t,e){t.sort(function(t,e){return t-e});var a=e/100*(t.length-1),i=void 0;if(Math.floor(a)===a)i=t[a];else{var n=Math.floor(a),r=a-n;i=t[n]+(t[n+1]-t[n])*r}return i}function o(t){if(!t)return t;for(var e=[],a=0,i=t.length;i>a;a+=1)-1===e.indexOf(t[a])&&""!==t[a]&&e.push(t[a]);return e}function l(t,e,a,i){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLImageElement&&!t instanceof HTMLImageElement)return;var n=t.naturalWidth,r=t.naturalHeight;if("string"==typeof e)var e=document.getElementById(e);else if("undefined"!=typeof HTMLCanvasElement&&!e instanceof HTMLCanvasElement)return;e.style.width=n+"px",e.style.height=r+"px",e.width=n,e.height=r;var s=e.getContext("2d");s.clearRect(0,0,n,r),s.drawImage(t,0,0),Number.isNaN(a)||1>a||(i?p(e,0,0,n,r,a):d(e,0,0,n,r,a))}function h(t,e,a,i,n){if("string"==typeof t)var t=document.getElementById(t);else if("undefined"!=typeof HTMLCanvasElement&&!t instanceof HTMLCanvasElement)return;var r,s=t.getContext("2d");try{try{r=s.getImageData(e,a,i,n)}catch(o){throw new Error("unable to access local image data: "+o)}}catch(o){throw new Error("unable to access image data: "+o)}return r}function p(t,e,a,i,n,r){if(!(Number.isNaN(r)||1>r)){r|=0;var s=h(t,e,a,i,n);s=u(s,e,a,i,n,r),t.getContext("2d").putImageData(s,e,a)}}function u(t,e,a,i,n,r){var s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,N,E,T,D,A,z=t.data,F=r+r+1,j=i-1,H=n-1,O=r+1,P=O*(O+1)/2,I=new m,L=I;for(l=1;F>l;l++)if(L=L.next=new m,l==O)var B=L;L.next=I;var R=null,G=null;d=u=0;var Y=q[r],U=W[r];for(o=0;n>o;o++){for(w=C=S=M=c=f=g=v=0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s,o,l,h,p,u,d,c,f,g,v,y,b,k,x,w,C,S,M,N,E=t.data,T=r+r+1,D=i-1,A=n-1,z=r+1,F=z*(z+1)/2,j=new m,H=j;for(l=1;T>l;l++)if(H=H.next=new m,l==z)var O=H;H.next=j;var P=null,I=null;d=u=0;var L=q[r],B=W[r];for(o=0;n>o;o++){for(k=x=w=c=f=g=0,v=z*(C=E[u]),y=z*(S=E[u+1]),b=z*(M=E[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(l=1;z>l;l++)h=u+((l>D?D:l)<<2),c+=(H.r=C=E[h])*(N=z-l),f+=(H.g=S=E[h+1])*N,g+=(H.b=M=E[h+2])*N,k+=C,x+=S,w+=M,H=H.next;for(P=j,I=O,s=0;i>s;s++)E[u]=c*L>>B,E[u+1]=f*L>>B,E[u+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=d+((h=s+r+1)s;s++){for(x=w=k=f=g=c=0,u=s<<2,v=z*(C=E[u]),y=z*(S=E[u+1]),b=z*(M=E[u+2]),c+=F*C,f+=F*S,g+=F*M,H=j,l=0;z>l;l++)H.r=C,H.g=S,H.b=M,H=H.next;for(p=i,l=1;r>=l;l++)u=p+s<<2,c+=(H.r=C=E[u])*(N=z-l),f+=(H.g=S=E[u+1])*N,g+=(H.b=M=E[u+2])*N,k+=C,x+=S,w+=M,H=H.next,A>l&&(p+=i);for(u=s,P=j,I=O,o=0;n>o;o++)h=u<<2,E[h]=c*L>>B,E[h+1]=f*L>>B,E[h+2]=g*L>>B,c-=v,f-=y,g-=b,v-=P.r,y-=P.g,b-=P.b,h=s+((h=o+z)e?e+360:e)/180*O}function v(t){var e=f(t);return(Math.sin(e)*(1.914602-t*(.004817+14e-6*t))+Math.sin(e+e)*(.019993-101e-6*t)+289e-6*Math.sin(e+e+e))*P}function y(t){return g(t)+v(t)}function b(t){return y(t)-(.00569+.00478*Math.sin((125.04-1934.136*t)*P))*P}function k(t){return(23+(26+(21.448-t*(46.815+t*(59e-5-.001813*t)))/60)/60)*P}function x(t){return k(t)+.00256*Math.cos((125.04-1934.136*t)*P)*P}function w(t){return Math.asin(Math.sin(x(t))*Math.sin(b(t)))}function C(t){return.016708634-t*(42037e-9+1.267e-7*t)}function S(t){var e=C(t),a=f(t),i=g(t),n=Math.tan(x(t)/2);return n*=n,n*Math.sin(2*i)-2*e*Math.sin(a)+4*e*n*Math.sin(a)*Math.cos(2*i)-.5*n*n*Math.sin(4*i)-1.25*e*e*Math.sin(2*a)}function M(t){return[t[0]+180,-t[1]]}function N(t){var e=(t-Date.UTC(2e3,0,1,12))/864e5/36525,a=(d3.time.day.utc.floor(t)-t)/864e5*360-180;return[a-S(e)*I,w(e)*I]}var E={};E["typeof"]="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E.classCallCheck=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},E.createClass=function(){function t(t,e){for(var a=0;a\n \n \n \n \n \n '),this.options.timezones&&(this.layerTimezones=this.layerGlobal.append("g").attr("class","mt-map-timezones")),this.layerCountries=this.layerGlobal.append("g").attr("class","mt-map-countries"),this.options.night&&(this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night")),this.options.heatmap&&(this.layerHeatmap=this.layerGlobal.append("g").attr("class","mt-map-heatmap")),this.layerMarkers=this.layerGlobal.append("g").attr("class","mt-map-markers"),this.options.watermark&&(this.watermark=new j(this,this.options.watermark)),this.options.title&&this.buildTitle(),(this.options.exportSvgClient||this.options.exportSvg)&&this.addExportSvgCapability(),this.options.width||window.addEventListener("resize",function(){n.svg.attr("width",n.getWidth()),n.svg.attr("height",n.getHeight()),n.rescale()}),this.loadGeometries()}return E.createClass(t,[{key:"enrichData",value:function(){var t=this;this.maptable.rawData.forEach(function(e){e.longitude=parseFloat(e[t.options.longitudeKey]),e.latitude=parseFloat(e[t.options.latitudeKey]);var a=[0,0];Number.isNaN(e.longitude)||Number.isNaN(e.latitude)||(a=t.projection([e.longitude,e.latitude])),e.x=a[0],e.y=a[1]})}},{key:"scaleAttributes",value:function(){return Math.pow(this.scale,2/3)}},{key:"getWidth",value:function(){return this.options.width?this.options.width:(this.options.width=this.node.offsetWidth,this.node.offsetWidth)}},{key:"getHeight",value:function(){var t=this.options.title?30:0;return!this.options.height&&this.options.ratioFromWidth?this.getWidth()*this.options.ratioFromWidth*this.options.scaleHeight+t:this.options.height*this.options.scaleHeight+t}},{key:"loadGeometries",value:function(){this.options.filterCountries&&(this.jsonWorld.objects.countries.geometries=this.jsonWorld.objects.countries.geometries.filter(this.options.filterCountries)),this.options.countries&&this.buildCountries(),this.options.heatmap&&this.buildHeatmap(),this.options.night&&this.buildNight(),this.options.timezones&&(this.options.timezones.path||this.options.timezones.pathData)&&this.buildTimezone()}},{key:"buildHeatmap",value:function(){var t=topojson.merge(this.jsonWorld,this.jsonWorld.objects.countries.geometries);if(this.options.heatmap.disableMask||(this.maskHeatmap=this.layerHeatmap.append("defs").append("clipPath").attr("id","mt-map-heatmap-mask"),this.maskHeatmap.datum(t).append("path").attr("class","mt-map-heatmap-mask-paths").attr("d",this.path)),this.imgHeatmap=this.layerHeatmap.append("image").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("x",0).attr("y",0).attr("class","mt-map-heatmap-img"),this.options.heatmap.mask&&(this.imgHeatmap=this.imgHeatmap.attr("clip-path","url(#mt-map-heatmap-mask)")),this.options.heatmap.borders){var e=topojson.mesh(this.jsonWorld,this.jsonWorld.objects.countries,function(t,e){return t!==e});this.bordersHeatmap=this.layerHeatmap.append("g").attr("class","mt-map-heatmap-borders"),this.bordersHeatmap.selectAll("path.mt-map-heatmap-borders-paths").data([t,e]).enter().append("path").attr("class","mt-map-heatmap-borders-paths").attr("fill","none").attr("stroke-width",this.options.heatmap.borders.stroke).attr("stroke",this.options.heatmap.borders.color).attr("style","opacity: "+this.options.heatmap.borders.opacity).attr("d",this.path)}}},{key:"buildNight",value:function(){this.layerNight=this.layerGlobal.append("g").attr("class","mt-map-night");var t=d3.geo.circle().angle(90);this.maskNight=this.layerNight.append("defs").append("clipPath").attr("id","mt-map-night-mask"),this.maskNight.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.nightPath=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.path).style("opacity",.1);var e=this.options.night.date||Date.UTC(),a=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),0,0,0),i=N(new Date(a));if(this.nightPath.datum(t.origin(M(i))).attr("d",this.path),this.nightPathRight=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+this.getWidth()+"px,0,0)"),this.nightPathLeft=this.layerNight.append("path").attr("class","mt-map-night-layer"+(this.options.night.cssBlur?" mt-blur":"")).attr("filter",this.options.night.cssBlur?void 0:"url(#blur)").attr("clip-path","url(#mt-map-night-mask)").attr("d",this.nightPath.attr("d")).style("opacity",.1).style("transform","translate3d("+-this.getWidth()+"px,0,0)"),!this.options.night.disableSun){var n=this.projection(i);this.sunCircleRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXRight=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]+this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-right").attr("cx",n[0]-this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight()),this.sunCircleXLeft=this.layerNight.append("svg:circle").attr("class","mt-map-sun-xright").attr("cx",n[0]-2*this.getWidth()).attr("cy",n[1]).attr("fill","url(#sunGradient)").attr("r",.35*this.getHeight())}}},{key:"buildTimezone",value:function(){var t=this;this.options.timezones.pathData?this.loadTimezone(null,JSON.parse(this.options.timezones.pathData)):this.options.timezones.path&&d3.json(this.options.timezones.path,function(e,a){t.loadTimezone(e,a)})}},{key:"scaleFontSize",value:function(t){return this.getWidth()<700?t*(this.getWidth()/700):t}},{key:"loadTimezone",value:function(t,e){var a=this;this.dataTimezones=topojson.feature(e,e.objects.timezones).features,this.maskTimezone=this.layerTimezones.append("defs").append("clipPath").attr("id","mt-map-timezone-mask"),this.maskTimezone.append("rect").attr("x",0).attr("y",30).attr("width",this.getWidth()).attr("height",.82*this.getHeight()-30),this.layerTimezones.selectAll(".mt-map-timezone").data(this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places})).enter().insert("path").attr("class","mt-map-timezone").attr("d",this.path).attr("fill",function(t){return t.properties.zone%2===0?"#F4F5F5":"transparent"}).attr("title",function(t){return JSON.stringify(t.properties)}).attr("clip-path","url(#mt-map-timezone-mask)").style("opacity",.6);var i=this.dataTimezones.filter(function(t){return"Antarctica"!==t.properties.places&&t.properties.zone%1===0&&14!==t.properties.zone}),n=[].concat(E.toConsumableArray(new Map(i.map(function(t){return[t.properties.zone,t]})).values()));this.layerTimezonesText=this.layerTimezones.append("g").attr("class","mt-map-timezones-texts"),this.layerTimezonesText.selectAll(".mt-map-timezone-text").data(n).enter().insert("text").attr("class","mt-map-timezone-text").attr("y",.82*this.getHeight()-5).attr("x",function(t){return(t.properties.zone+10)*(a.getWidth()/24.5)-1}).attr("dx",this.getWidth()/24.5/2).attr("font-size",this.scaleFontSize(9)).attr("font-family","Helevetica, Arial, Sans-Serif").attr("fill","#999").attr("text-anchor","middle").html(function(t){return A.formatDate(a.options.timezones.date||new Date,t.properties.zone)})}},{key:"getMagnitudeScale",value:function(t){var e=this.options.heatmap,a=t.length;if(!a)return function(){return 0};var i=d3.scale.linear().domain([1,a]).range([1,.25]),n=i(a),r=d3.scale.linear().domain([e.circles.min,20]).range([n,0]);return function(t){return r(t)}}},{key:"getDatumScale",value:function(){var t=this;if(!this.options.heatmap.weightByAttribute)return function(){return 1};var e=d3.extent(this.maptable.data,this.options.heatmap.weightByAttribute),a="log"===this.options.heatmap.weightByAttributeScale?d3.scale.log:d3.scale.linear,i=a().domain(e).range([.5,1]);return function(e){var a=t.options.heatmap.weightByAttribute(e);return a?i(a):0}}},{key:"getHeatmapData",value:function(){var t=this,e=d3.select(this.node).append("canvas").attr("id","mt-map-heatmap-canvas").attr("width",this.getWidth()).attr("height",this.getHeight()).attr("style","display: none;"),a=e.node().getContext("2d");a.globalCompositeOperation="multiply";var i=d3.range(this.options.heatmap.circles.min,this.options.heatmap.circles.max,this.options.heatmap.circles.step),n=this.getDatumScale(),r=this.maptable.data.filter(function(t){return n(t)>.1}),s=this.path.context(a),o=this.getMagnitudeScale(r),l=d3.scale.linear().domain([1,0]).range(["#000000","#FFFFFF"]);a.beginPath(),a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle="#ffffff",a.fill(),a.closePath();var h=function(e){var a=t.options.heatmap.circles.colorStrength,i=1+(a-1)/100;return a>1?(2-i)*e+i-1:a*e};r.forEach(function(t){var e=n(t);i.forEach(function(i){var n=h(o(i)*e);n>0&&(a.beginPath(),s(d3.geo.circle().origin([t.longitude,t.latitude]).angle(i-1e-4)()),a.fillStyle=l(n),a.fill(),a.closePath())})}),H.canvasRGBA(e.node(),0,0,this.getWidth(),this.getHeight(),this.options.heatmap.circles.blur),a.beginPath(),a.globalCompositeOperation="screen",a.rect(0,0,this.getWidth(),this.getHeight()),a.fillStyle=this.options.heatmap.circles.color,a.fill(),a.closePath();var p=e.node().toDataURL();return e.remove(),p}},{key:"updateHeatmap",value:function(){var t=this.getHeatmapData();this.imgHeatmap.attr("xlink:href",t)}},{key:"buildCountries",value:function(){this.dataCountries=topojson.feature(this.jsonWorld,this.jsonWorld.objects.countries).features,this.layerCountries.selectAll(".mt-map-country").data(this.dataCountries).enter().insert("path").attr("class","mt-map-country").attr("d",this.path),this.legendCountry={},this.shouldRenderLegend()&&(this.legendCountry.fill=new F(this))}},{key:"shouldRenderLegend",value:function(){var t=this.options.countries.attr.fill;if(!t)return!1;if(!t.legend||!t.min||!t.max)return!1;if(t.aggregate&&t.aggregate.scale){var e="function"==typeof t.aggregate.scale?t.aggregate.scale.bind(this.maptable)():t.aggregate.scale;if("linear"!==e)return!1}return!0}},{key:"getAllMtMapCountry",value:function(){return this.allMtMapCountry?this.allMtMapCountry:(this.allMtMapCountry=d3.selectAll(this.containerSelector+" .mt-map-country"),this.allMtMapCountry)}},{key:"getAllMtMapMarker",value:function(){return this.allMtMapMarker?this.allMtMapMarker:(this.allMtMapMarker=d3.selectAll(this.containerSelector+" .mt-map-marker"),this.allMtMapMarker)}},{key:"updateCountries",value:function(){var t=this,e=new Map;this.maptable.data.forEach(function(a){var i=a[t.options.countryIdentifierKey];e.has(i)||e.set(i,[]),e.get(i).push(a)}),this.dataCountries.forEach(function(a){a.key=a.properties[t.options.countryIdentifierType];var i=e.get(a.key);a.values=i||[],a.attr={},a.rollupValue={}}),Object.keys(this.options.countries.attr).forEach(function(e){t.setAttrValues(e,t.options.countries.attr[e],t.dataCountries)});var a=this.getAllMtMapCountry().each(function(t){var e=d3.select(this);Object.keys(t.attr).forEach(function(a){e.attr(a,t.attr[a])})});Object.keys(this.options.countries.attr).forEach(function(e){var i=t.options.countries.attr[e];if("object"===("undefined"==typeof i?"undefined":E["typeof"](i))&&i.legend&&void 0!==t.legendCountry[e]){var n=d3.extent(t.dataCountries,function(t){return Number(t.attrProperties[e].value)});t.legendCountry[e].updateExtents(n),a.on("mouseover",function(a){t.legendCountry[e].indiceChange(a.attrProperties[e].value)}).on("mouseout",function(){t.legendCountry[e].indiceChange(NaN)})}}),this.options.countries&&this.options.countries.tooltip&&this.activateTooltip(a,this.tooltipCountriesNode,this.options.countries.tooltip,!0)}},{key:"updateNight",value:function(){var t=this.options.night.date||Date.UTC(),e=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),0,0,0),a=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate(),23,59,59),i=a-e,n=t-e,r=n/i;this.layerNight.node().style.transform="translateX("+-this.getWidth()*r+"px)"}},{key:"updateTimezones",value:function(){var t=document.querySelectorAll(".mt-map-timezone-text"),e=this.options.timezones.date||new Date;Array.from(t).forEach(function(t){t.textContent=A.formatDate(e,t.__data__.properties.zone)})}},{key:"updateMarkers",value:function(){var t=this,e=function(t){return t.longitude+","+t.latitude};this.dataMarkers=d3.nest().key(e).entries(this.maptable.data).filter(function(t){return 0!==t.values[0].x}),this.dataMarkers.forEach(function(t){t.attr={},t.attrProperties={}}),Object.keys(this.options.markers.attr).forEach(function(e){t.setAttrValues(e,t.options.markers.attr[e],t.dataMarkers)});var a=this.layerMarkers.selectAll(".mt-map-marker").data(this.dataMarkers),i=a.enter();i=this.options.markers.customTag?this.options.markers.customTag(i):i.append("svg:circle");var n=this.options.markers.className?this.options.markers.className:"";i.attr("class","mt-map-marker "+n),a.exit().transition().attr("r",0).attr("fill","#eee").style("opacity",0).remove();var r=this.options.markers.attrX?this.options.markers.attrX:"cx",s=this.options.markers.attrY?this.options.markers.attrY:"cy",o=this.options.markers.attrXDelta?this.options.markers.attrXDelta:0,l=this.options.markers.attrYDelta?this.options.markers.attrYDelta:0,h=a.attr(r,function(t){return t.values[0].x+o}).attr(s,function(t){return t.values[0].y+l});this.getAllMtMapMarker().each(function(t){var e=this;Object.keys(t.attr).forEach(function(a){d3.select(e).attr(a,t.attr[a])})}),this.options.markers.tooltip&&this.activateTooltip(h,this.tooltipMarkersNode,this.options.markers.tooltip,!1),this.rescale()}},{key:"fitContent",value:function(){if(0===this.maptable.data.length)return this.transX=0,this.transY=0,this.scale=1,void this.zoomListener.translate([this.transX,this.transY]).scale(this.scale);var t=d3.extent(this.maptable.data,function(t){return t.x}),e=d3.extent(this.maptable.data,function(t){return t.y}),a=this.getWidth()/this.getHeight(),i=20+(this.options.title?30:0),n=t[1]-t[0]+i,r=e[1]-e[0]+i,s=n/a,o=r*a,l=0,h=0;o>=n?l=(o-n)/2:h=(s-r)/2,t[0]-=this.options.fitContentMargin+l,t[1]+=this.options.fitContentMargin+l,e[0]-=this.options.fitContentMargin+h,e[1]+=this.options.fitContentMargin+h,this.scale=this.getWidth()/(t[1]-t[0]),this.transX=-1*t[0]*this.scale,this.transY=-1*e[0]*this.scale,this.zoomListener.translate([this.transX,this.transY]).scale(this.scale); +}},{key:"buildTitle",value:function(){var t=this.svg.append("svg").attr("width",this.getWidth()).attr("x",0).attr("y",this.getHeight()-30).attr("height",30);this.options.title.bgColor&&t.append("rect").attr("x",0).attr("y",0).attr("width",this.getWidth()).attr("height",30).attr("fill",this.options.title.bgColor),t.append("text").attr("id","mt-map-title").attr("x",20).attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).attr("y",20),this.options.title.source&&t.append("text").attr("y",20).attr("x",this.getWidth()-20).attr("text-anchor","end").attr("font-size",this.scaleFontSize(this.options.title.fontSize)).attr("font-family",this.options.title.fontFamily).html(this.options.title.source())}},{key:"encodeTranslation",value:function(t){var e=t[0]/(this.scale*this.getWidth()),a=t[1]/(this.scale*this.getHeight());return[e,a]}},{key:"decodeTranslation",value:function(t){var e=t[0]*this.getWidth()*this.scale,a=t[1]*this.getHeight()*this.scale;return[e,a]}},{key:"restoreState",value:function(t){if(t&&3===t.length){this.scale=t[0];var e=this.decodeTranslation([t[1],t[2]]);this.transX=e[0],this.transY=e[1],this.zoomListener.scale(t[0]).translate(e).event(this.svg)}}},{key:"saveState",value:function(){var t=this.encodeTranslation([this.transX,this.transY]),e=[this.scale,t[0],t[1]];1!==e[0]&&0!==e[1]&&0!==e[2]?this.maptable.saveState("zoom",e):this.maptable.removeState("zoom")}},{key:"rescale",value:function(){var t=this;d3.event&&d3.event.translate&&(this.scale=d3.event.scale,this.transX=1===this.scale?0:d3.event.translate[0],this.transY=1===this.scale?0:d3.event.translate[1]);var e=0,a=0,i=this.getWidth()*(1-this.scale),n=this.getHeight()*(1-this.scale);this.transY>a?this.transY=a:this.transYe?this.transX=e:this.transXe?e:t},e[0])};else if("max"===s)e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return e.reduce(function(t,e){return e>t?e:t},e[0])};else if(-1!==s.indexOf("percentile")){var l=A.toNumber(s);e.rollup=function(t){if(!t.length)return 0;var e=t.map(function(t){return Number(t[r])});return A.quantile(e,l)}}else"function"==typeof e.rollup&&(e.rollup=e.rollup.bind(this.maptable));n&&(-1!==n.indexOf("log")?o=d3.scale.log():-1!==n.indexOf("pow")?o=d3.scale.pow().exponent(A.toNumber(n)||1):"sqrt"===n&&(o=d3.scale.sqrt()))}if(e.rollup||(e.rollup=function(t){return t.length}),!e.min||!e.max)throw new Error("MapTable: You should provide values 'min' & 'max' for attr."+t);if(a.forEach(function(a){var o=e.rollup(a.values);if(a.attrProperties||(a.attrProperties={}),a.attrProperties[t]||(a.attrProperties[t]={}),a.attrProperties[t].value=o,r){a.attrProperties[t].key=r,a.attrProperties[t].mode=s,a.attrProperties[t].scale=n;var l=i.maptable.columnDetails[r];a.attrProperties[t].columnDetails=l;var h={};h[r]=o,a.attrProperties[t].formatted=l&&l.cellContent?l.cellContent.bind(i.maptable)(h):o}}),"rank"===n){var h=A.uniqueValues([0].concat(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return t>0}))),p=A.uniqueValues(a.map(function(e){return Math.floor(100*e.attrProperties[t].value)/100}).filter(function(t){return 0>t}));h.sort(function(t,e){return t-e}),p.sort(function(t,e){return e-t}),a.forEach(function(e){if(0!==e.attrProperties[t].value){var a=e.attrProperties[t].value>=0?h:p,i=a.indexOf(Math.floor(100*e.attrProperties[t].value)/100),n=Math.round(i/a.length*100),r=e.attrProperties[t].value<0?n-2*n:n;e.attrProperties[t].value=r}})}var u=d3.extent(a,function(e){return Number(e.attrProperties[t].value)});0===u[0]&&n&&"-1"!==n.indexOf("log")&&(u=d3.extent(a.filter(function(e){return 0!==Number(e.attrProperties[t].value)}),function(e){return Number(e.attrProperties[t].value)})),e.transform&&(u[0]=e.transform.bind(this.maptable)(u[0],this.maptable.data),u[1]=e.transform.bind(this.maptable)(u[1],this.maptable.data));var d=e.min,c=e.max;if("minValue"===e.min&&(d=u[0]),"maxValue"===e.max&&(c=u[1]),e.maxNegative&&!e.minNegative||!e.maxNegative&&e.minNegative)throw new Error("MapTable: maxNegative or minNegative undefined. Please declare both.");var m=e.maxNegative&&e.minNegative,f=void 0,g=void 0;m?(f=o.copy().domain([0,u[1]]).range([d,c]),g=o.copy().domain([u[0],0]).range([e.maxNegative,e.minNegative])):f=o.domain(u).range([d,c]),a.forEach(function(a){var n=void 0;if(!a.values.length||Number.isNaN(a.attrProperties[t].value)){if("undefined"==typeof e.empty)throw new Error("MapTable: no empty property found for attr."+t);n=e.empty}else{var r=a.attrProperties[t].value,s=e.transform?e.transform.bind(i.maptable)(r,i.maptable.data):r;n=m&&0>s?g(s):f(s)}a.attr[t]=n})}}},{key:"render",value:function(){this.options.markers&&this.updateMarkers(),this.options.countries&&this.updateCountries(),this.options.night&&this.updateNight(),this.options.timezones&&this.updateTimezones(),this.options.title&&this.updateTitle(),this.options.heatmap&&this.updateHeatmap(),this.options.autoFitContent&&(this.fitContent(),this.rescale()),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"updateTitle",value:function(){var t=this;if(this.options.title.content){var e=this.maptable.data.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,a=this.maptable.rawData.filter(function(e){return 0!==e[t.options.latitudeKey]}).length,i="";this.maptable.filters&&(i=this.maptable.filters.getDescription()),this.container.querySelector("#mt-map-title").innerHTML=this.options.title.content.bind(this.maptable)(e,a,i,this.maptable.data,this.maptable.rawData,this.dataCountries)}}},{key:"activateTooltip",value:function(t,e,a,i){var n=this;t.on(i?"mousemove":"mouseover",function(t){var r=a.bind(this.maptable)(t);if(r){e.html(r).attr("style","display:block;position:fixed;");var s=void 0,o=void 0,l=e.node().offsetWidth/2;if(i){var h=n.node.getBoundingClientRect(),p=d3.mouse(n.svg.node()).map(function(t){return parseInt(t,10)});s=h.left+p[0]-l,o=h.top+p[1]+10}else{var u=this.getBoundingClientRect();s=u.left+u.width/2-l,o=u.top+u.height+2}e.attr("style","top:"+o+"px;left:"+s+"px;display:block;position:fixed;").on("mouseout",function(){e.style("display","none")})}}).on("mouseout",function(){e.style("display","none")})}},{key:"exportSvg",value:function(){var t=this.container.querySelector("#mt-map-svg"),e='\n'+(new XMLSerializer).serializeToString(t);if(this.options.exportSvgClient){if(!window.saveAs)throw new Error("MapTable: Missing FileSaver.js library");var a=new Blob([e],{type:"image/svg+xml"});window.saveAs(a,"visualization.svg")}else if(this.options.exportSvg){var i=this.node.querySelector("#mt-map-svg-form");i.querySelector('[name="data"]').value=e,i.submit()}}},{key:"addExportSvgCapability",value:function(){var t=document.createElement("div");t.setAttribute("id","mt-map-export"),this.container.querySelector("#mt-map").appendChild(t);var e=document.createElement("button");if(e.setAttribute("class","btn btn-xs btn-default"),e.innerHTML="Download",e.addEventListener("click",this.exportSvg.bind(this)),t.appendChild(e),this.options.exportSvg){var a=document.createElement("div");a.innerHTML='
',t.appendChild(a)}}}]),t}(),B=function(){function t(e,a){var i=this;if(E.classCallCheck(this,t),this.maptable=e,this.options=a,this.criteria=[],this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.container=document.createElement("div"),this.maptable.node.appendChild(this.container),this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-filters"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-filters"),this.node.setAttribute("class","panel panel-default"),this.maptable.node.appendChild(this.node));var r=document.createElement("div");r.setAttribute("class","panel-heading");var s=document.createElement("button");s.setAttribute("id","mt-filters-reset"),s.setAttribute("class","btn btn-default btn-xs pull-right"),s.style.display="none",s.style.marginLeft=5,s.innerText="↺ Reset",s.addEventListener("click",this.reset),r.appendChild(s);var o=document.createElement("h3");o.setAttribute("class","panel-title"),o.appendChild(document.createTextNode("Filters")),r.appendChild(o),this.node.appendChild(r);var l=document.createElement("div");l.setAttribute("id","mt-filters-content"),l.setAttribute("class","panel-body");var h=document.createElement("div");h.setAttribute("id","mt-filters-elements"),l.appendChild(h);var p=document.createElement("a");p.setAttribute("id","mt-filters-new"),p.setAttribute("href","#"),p.innerText="+ New filter",p.addEventListener("click",this.add.bind(this)),l.appendChild(p),this.node.appendChild(l)}return E.createClass(t,[{key:"add",value:function(t){t&&t.preventDefault();var e=this.getPossibleFilters();if(0!==e.length){var a=e[0].key;this.create(a)}}},{key:"create",value:function(t,e){var a=this.buildRow(t);e?e.parentNode.replaceChild(a,e):this.node.querySelector("#mt-filters-elements").appendChild(a),this.criteria.push(t),this.maptable.render(),"none"===this.container.style.display&&this.toggle()}},{key:"remove",value:function(t){var e=this.node.querySelector('[data-mt-filter-name="'+t+'"]');e&&e.parentNode.removeChild(e);var a=this.criteria.indexOf(t);this.criteria.splice(a,1),this.maptable.render()}},{key:"reset",value:function(){for(var t=this.node.querySelectorAll("[data-mt-filter-name]"),e=0;e and\n '+h+""}else{var p=i.querySelector(".mt-filter-value-min").value;if(""===p)continue;s+=r.title+" is ",s+=o.options[o.selectedIndex].text,s+=''+p+""}}else if("field"===r.filterMethod||"dropdown"===r.filterMethod){var u=i.querySelector(".mt-filter-value").value;if(""===u)continue;var d="field"===r.filterMethod?"contains":"is";s+=r.title+" "+d+'\n '+u+""}t.push(s)}return t.join(", ")}},{key:"buildRow",value:function(t){var e=this,a=this,i=this.getPossibleFilters(),n=this.maptable.columnDetails[t],r=document.createElement("div");r.setAttribute("class","mt-filter-row"),r.setAttribute("data-mt-filter-name",t);var s=document.createElement("button");s.setAttribute("class","btn btn-default pull-right"),s.setAttribute("data-mt-filter-btn-minus",1),s.innerText="– Remove this filter",s.addEventListener("click",function(){t=r.querySelector(".mt-filter-name").value,e.remove(t)}),r.appendChild(s);var o=document.createElement("span");o.setAttribute("class","mt-filters-and"),o.innerText="And ",r.appendChild(o);var l=document.createElement("select");l.setAttribute("class","mt-filter-name form-control form-control-inline"),A.appendOptions(l,i.map(function(t){return{text:t.title,value:t.key}})),l.value=t,l.addEventListener("change",function(){var t=this.parentNode.getAttribute("data-mt-filter-name"),e=this.value;a.create(e,this.parentNode),a.remove(t),a.refresh()}),r.appendChild(l);var h=document.createElement("span");h.innerText="field"===n.filterMethod?" contains ":" is ",r.appendChild(h);var p=null;"field"!==n.filterMethod&&"dropdown"!==n.filterMethod&&(p=document.createElement("select"),p.setAttribute("class","mt-filter-range form-control form-control-inline"),A.appendOptions(p,["any","=","≠","<",">","≤","≥","BETWEEN"].map(function(t){return{text:t,value:t}})),p.addEventListener("change",function(){a.handleRangeChange(this)}),r.appendChild(p),r.appendChild(document.createTextNode(" ")));var u=document.createElement("div");if(u.style.display="inline-block",u.setAttribute("class","mt-filter-value-container"),"compare"===n.filterMethod)["min","max"].forEach(function(t,a){var i=document.createElement("input");if(i.setAttribute("class","form-control form-control-inline mt-filter-value-"+t),i.setAttribute("type",n.filterInputType),i.addEventListener("keyup",e.maptable.render.bind(e.maptable)),i.addEventListener("change",e.maptable.render.bind(e.maptable)),u.appendChild(i),0===a){var r=document.createElement("span");r.setAttribute("class","mt-filter-value-and"),r.innerText=" and ",u.appendChild(r)}});else if("field"===n.filterMethod){var d=document.createElement("input");d.setAttribute("class","form-control form-control-inline mt-filter-value"),d.setAttribute("type","text"),d.addEventListener("keyup",this.maptable.render.bind(this.maptable)),d.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(d)}else if("dropdown"===n.filterMethod){var c=document.createElement("select");c.setAttribute("class","form-control form-control-inline mt-filter-value");var m=d3.nest().key(function(e){return e[t]}).sortKeys(d3.ascending).entries(this.maptable.rawData);A.appendOptions(c,[{text:"Any",value:""}].concat(m.map(function(t){return{text:t.key,value:t.key}}))),c.addEventListener("change",this.maptable.render.bind(this.maptable)),u.appendChild(c)}return r.appendChild(u),p&&this.handleRangeChange(p),r}},{key:"handleRangeChange",value:function(t){var e=t.parentNode;"any"===t.value?e.querySelector(".mt-filter-value-container").style.display="none":(e.querySelector(".mt-filter-value-container").style.display="inline-block","BETWEEN"===t.value?(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="inline-block",e.querySelector(".mt-filter-value-max").style.display="inline-block"):(e.querySelector(".mt-filter-value-min").style.display="inline-block",e.querySelector(".mt-filter-value-and").style.display="none",e.querySelector(".mt-filter-value-max").style.display="none")),this.maptable.render.bind(this.maptable)()}},{key:"getPossibleFilters",value:function(t){var e=this;return Object.keys(this.maptable.columnDetails).map(function(t){return A.extendRecursive({key:t},e.maptable.columnDetails[t])}).filter(function(a){return-1!==e.activeColumns.indexOf(a.key)&&(t&&t===a.key||-1===e.criteria.indexOf(a.key)&&a.filterMethod&&!a.isVirtual)})}},{key:"filterData",value:function(){var t=this,e=this;this.maptable.data=this.maptable.rawData.filter(function(a){for(var i=t.node.querySelectorAll(".mt-filter-row"),n=!0,r=0;rh(m))?n=!1:(parseInt(a[o],10)parseInt(m,10))&&(n=!1)}else{var f=s.querySelector(".mt-filter-value-min").value;if(""===f)continue;h&&!A.rangeToBool(h(a[o]),d,h(f))?n=!1:h||A.rangeToBool(a[o],d,f)||(n=!1)}}(h&&A.isBlank(h(a[o]))||A.isBlank(a[o]))&&(n=!1)}return n}),this.options.saveState&&this.maptable.saveState("filters",this.exportFilters())}},{key:"refresh",value:function(){for(var t=this.node.querySelectorAll(".mt-filter-name"),e=0;e0&&(this.node.querySelectorAll(".mt-filters-and")[0].style.visibility="hidden");var r=!this.getPossibleFilters().length;this.node.querySelector("#mt-filters-new").style.visibility=r?"hidden":"visible"}},{key:"toggle",value:function(){"none"===this.container.style.display?(this.container.style.display="block",0===this.criteria.length&&this.add()):this.container.style.display="none"}}]),t}(),R=function(){function t(e,a){var i=this;if(E.classCallCheck(this,t),this.maptable=e,this.options=a,this.options.defaultSorting?(Array.isArray(this.options.defaultSorting)&&2===this.options.defaultSorting.length?this.sorting=this.options.defaultSorting:this.sorting=[this.options.defaultSorting],this.sorting.forEach(function(t){t.mode||(t.mode="asc")})):this.sorting=[{key:Object.keys(this.maptable.data[0])[0],mode:"asc"}],this.initialSorting=this.sorting.map(function(t){return t.key+","+t.mode}).join(";"),this.isSorting=!1,this.containerSelector=e.options.target,this.container=document.querySelector(e.options.target),this.node=this.container.querySelector("#mt-table"),this.node||(this.node=document.createElement("div"),this.node.setAttribute("id","mt-table"),this.maptable.node.appendChild(this.node)),this.node=d3.select(this.node).append("table").attr("class",this.options.className),this.header=this.node.append("thead"),this.body=this.node.append("tbody"),this.options.show){var n=this.options.show.filter(function(t){return Object.keys(i.maptable.columnDetails).indexOf(t)<0});if(n.length>0)throw new Error('MapTable: invalid columns "'+n.join(", ")+'"');this.activeColumns=this.options.show}else this.activeColumns=Object.keys(this.maptable.columnDetails);this.options.header&&(this.options.header.className&&this.header.attr("class",""+this.options.header.className),this.options.header.top?this.header.attr("style","top:"+(this.options.header.top||"0")+"px;"):this.header.attr("style","top:0px;")),this.header.selectAll("tr").data([1]).enter().append("tr").selectAll("th").data(this.activeColumns.map(function(t){return A.extendRecursive({key:t},i.maptable.columnDetails[t])})).enter().append("th").attr("class",function(t){var e=t.sorting?"mt-table-sortable":"";return e+=t.nowrap?" nowrap":""}).attr("data-key",function(t){return A.sanitizeKey(t.key)}).attr("onselectstart","return false;").attr("unselectable","on").attr("style",function(t){return t.nowrap?"white-space:nowrap;":""}).on("click",function(t){i.isSorting||(i.isSorting=!0,t.sorting&&i.sortColumn(t.key),i.isSorting=!1)}).text(function(t){return t.title}).attr("id",function(t){return"column_header_"+A.sanitizeKey(t.key)})}return E.createClass(t,[{key:"restoreState",value:function(t){if(t){var e=t.split(";"),a=[];e.forEach(function(t){var e=t.split(",");a.push({key:e[0],mode:e[1]||"asc"})}),this.sorting=a}}},{key:"saveState",value:function(){var t=this.sorting.map(function(t){return t.key+","+t.mode}).join(";");t!==this.initialSorting&&this.maptable.saveState("sort",t)}},{key:"render",value:function(){var t=this;this.applySort();var e=this.maptable.data;this.options.distinctBy&&(e=d3.nest().key(function(e){return e[t.options.distinctBy]}).entries(this.maptable.data).map(function(t){return t.values[0]})),this.body.selectAll("tr").data(e).enter().append("tr"),this.body.selectAll("tr").data(e).exit().remove();var a=[];this.body.selectAll("tr").data(e).attr("class",function(e){return t.options.rowClassName?"line "+t.options.rowClassName(e):"line"}).html(function(e){var i="";return t.activeColumns.forEach(function(n){var r=t.maptable.columnDetails[n];i+=""}),i}),this.options.onRender&&this.options.onRender.constructor===Function&&this.options.onRender.bind(this.maptable)()}},{key:"applySort",value:function(){for(var t=this,e=this.container.querySelectorAll(".mt-table-sortable"),a=0;a0;if(this.options.map.heatmap&&n)return i.innerHTML='
The heatmap feature is not supported with Internet Explorer.
Please use another modern browser to see this map.
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map=!1,void this.buildComponenents();if(i.innerHTML='
Loading...
',this.node.insertBefore(i,this.node.firstChild),i.querySelector(".mt-loading").style.display="block",this.options.map.pathData)this.loadMapData(null,JSON.parse(this.options.map.pathData),i);else{if(!this.options.map.path)throw new Error("missing map path|pathData");d3.json(this.options.map.path,function(t,e){a.loadMapData(t,e,i)})}}else this.buildComponenents()}},{key:"loadMapData",value:function(t,e,a){if(t)throw t;this.map=new L(this,this.options.map,e),a.querySelector(".mt-loading").style.display="none",this.buildComponenents()}},{key:"buildComponenents",value:function(){var t=this;this.options.filters&&(this.filters=new B(this,this.options.filters)),this.options.table&&(this.table=new R(this,this.options.table)),this.restoreState(),window.addEventListener("hashchange",function(){t.restoreState()}),this.render()}},{key:"loadState",value:function(t,e){if(e){var a=this.parseState(t);if(!a)return null;try{var i=JSON.parse(a);this.state[t]=i}catch(n){return console.log("Maptable: Invalid URL State for mt-"+t+" "+n.message),null}}else{var r=this.parseState(t);r&&(this.state[t]=r)}return this.state[t]}},{key:"restoreState",value:function(){this.map&&(this.loadState("zoom",!0),this.map.restoreState(this.state.zoom)),this.filters&&(this.loadState("filters",!0),this.filters.restoreState(this.state.filters)),this.table&&(this.loadState("sort",!1),this.table.restoreState(this.state.sort))}},{key:"parseState",value:function(t){var e=document.location.href.replace(/%21mt/g,"!mt").split("!mt-"+t+"=");return e[1]?decodeURIComponent(e[1].split("!mt")[0]):null}},{key:"removeState",value:function(t){window.clearTimeout(this.saveStateTimeout[t]),delete this.state[t],this.updateState()}},{key:"saveState",value:function(t,e){var a=this;window.clearTimeout(this.saveStateTimeout[t]),this.saveStateTimeout[t]=window.setTimeout(function(){a.state[t]=e,a.updateState()},200)}},{key:"updateState",value:function(){var t=this,e=document.location.href.split("#")[0],a="";Object.keys(this.state).forEach(function(e){if(t.state[e]){var i=t.state[e];if("object"===E["typeof"](t.state[e])){if(!Object.keys(t.state[e]).length)return;i=JSON.stringify(t.state[e])}a+="!mt-"+e+"="+encodeURIComponent(i)}}),""!==a&&(a="#"+a),document.location.href!==""+e+a&&window.history.pushState(null,null,""+e+a)}},{key:"render",value:function(){this.filters&&(this.filters.filterData(),this.filters.refresh()),this.map&&(this.map.render(),!this.firstExecution&&this.options.map.onComplete&&this.options.map.onComplete.constructor===Function&&this.options.map.onComplete.bind(this)()),this.table&&(this.table.render(),!this.firstExecution&&this.options.table.onComplete&&this.options.table.onComplete.constructor===Function&&this.options.table.onComplete.bind(this)()),!this.firstExecution&&this.options.onComplete&&this.options.onComplete.constructor===Function&&this.options.onComplete.bind(this)(),this.firstExecution=!0}},{key:"setColumnDetails",value:function(){var t=this;if(0!==t.rawData.length){var e={};Object.keys(t.rawData[0]).forEach(function(a){var i=/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/,n=i.test(t.rawData[0][a]);e[a]={title:A.keyToTile(a),filterMethod:n?"compare":"field",filterInputType:n?"number":"text",sorting:!0},n&&(e[a].dataParse=function(t){return parseFloat(t)})}),t.columnDetails=A.extendRecursive(e,this.options.columns),Object.keys(t.columnDetails).forEach(function(e){t.columnDetails[e].isVirtual="function"==typeof t.columnDetails[e].virtual})}}}]),t}();if(d3.maptable=function(t){var e=void 0,a={},i={target:t,columns:{},data:{},map:null,filters:null,table:null};return a.map=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!topojson)throw new Error("Maptable requires topojson.js");if("string"!=typeof t.path&&"string"!=typeof t.pathData)throw new Error("MapTable: map not provided");return i.map=t,a},a.data=function(t){return i.data.type="data",i.data.value=t,a},a.json=function(t,e){return i.data.type="json",i.data.path=t,i.data.preFilter=e,a},a.jsonData=function(t){return i.data.type="jsonData",i.data.value=t,a},a.csv=function(t,e){return i.data.type="csv",i.data.path=t,i.data.preFilter=e,a},a.csvData=function(t){return i.data.type="csvData",i.data.value=t,a},a.tsv=function(t,e){return i.data.type="tsv",i.data.path=t,i.data.preFilter=e,a},a.tsvData=function(t){return i.data.type="tsvData",i.data.value=t,a},a.filters=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.filters=t,a},a.table=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.table=t,a},a.columns=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.columns=t, +a},a.render=function(a){if("string"!=typeof t||!document.querySelector(t))throw new Error("MapTable: target not found");if(!i.data||!i.data.type)throw new Error("MapTable: Please provide the path for your dataset data|json|jsonData|csv|csvData|tsv|tsvData");i.map&&!i.map.heatmap&&(i.map.heatmap=null),i.map&&i.map.markers===!1&&(i.map.markers=null),i.map&&i.map.countries===!1&&(i.map.countries=null),i.filters||(i.filters=null),i.onComplete=a;var n=A.extendRecursive(z,i);return i.map&&!i.map.markers&&delete n.map.markers,i.map&&!i.map.heatmap&&delete n.map.heatmap,i.map&&!i.map.title&&delete n.map.title,i.map&&!i.map.timezones&&delete n.map.timezones,i.map&&!i.map.night&&delete n.map.night,i.filters||delete n.filters,i.table||delete n.table,e=new G(t,n),{render:function(){return e.render()},loadState:function(t,a){return e.loadState(t,a)},removeState:function(t){return e.removeState(t)},saveState:function(t,a){return e.saveState(t,a)},setTitleContent:function(t){e.options.map.title.content=function(){return t}},setData:function(t){e.options.data.type="data",e.options.data.value=t,e.options.rawData=t,e.rawData=t,e.data=t,e.map&&e.map.enrichData()},setNightDate:function(t){e.options.map.night.date=t},setTimezonesDate:function(t){e.options.map.timezones.date=t},getMapWidth:function(){return e.map.getWidth()},getMapHeight:function(){return e.map.getHeight()}}},a},!d3)throw new Error("Maptable requires d3.js");var Y=d3.maptable;return Y}(); \ No newline at end of file diff --git a/src/components/Table.js b/src/components/Table.js index 3698e17..b642d72 100644 --- a/src/components/Table.js +++ b/src/components/Table.js @@ -10,7 +10,6 @@ export default class Table { constructor(maptable, options) { this.maptable = maptable; this.options = options; - if (this.options.defaultSorting) { if (Array.isArray(this.options.defaultSorting) && this.options.defaultSorting.length === 2) { this.sorting = this.options.defaultSorting; @@ -43,17 +42,14 @@ export default class Table { this.maptable.node.appendChild(this.node); } - this.node = d3.select(this.node) - .append('table') - .attr('class', this.options.className); + this.node = d3.select(this.node).append('table').attr('class', this.options.className); this.header = this.node.append('thead'); this.body = this.node.append('tbody'); if (this.options.show) { - const arrayDiff = this.options.show - .filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0); + const arrayDiff = this.options.show.filter((i) => Object.keys(this.maptable.columnDetails).indexOf(i) < 0); if (arrayDiff.length > 0) { throw new Error(`MapTable: invalid columns "${arrayDiff.join(', ')}"`); } @@ -62,24 +58,38 @@ export default class Table { this.activeColumns = Object.keys(this.maptable.columnDetails); } - this.header.selectAll('tr') + // make table header fixed + if (this.options.header) { + if (this.options.header.className) { + this.header.attr('class', `${this.options.header.className}`); + } + + // set custom top header space + if (this.options.header.top) { + this.header.attr('style', `top:${this.options.header.top || '0'}px;`); + } else { + this.header.attr('style', 'top:0px;'); + } + } + + this.header + .selectAll('tr') .data([1]) .enter() .append('tr') .selectAll('th') - .data(this.activeColumns - .map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k]))) + .data(this.activeColumns.map((k) => utils.extendRecursive({ key: k }, this.maptable.columnDetails[k]))) .enter() .append('th') .attr('class', (d) => { - let output = (d.sorting) ? 'mt-table-sortable' : ''; - output += (d.nowrap) ? ' nowrap' : ''; + let output = d.sorting ? 'mt-table-sortable' : ''; + output += d.nowrap ? ' nowrap' : ''; return output; }) .attr('data-key', (d) => utils.sanitizeKey(d.key)) .attr('onselectstart', 'return false;') .attr('unselectable', 'on') - .attr('style', (d) => ((d.nowrap) ? 'white-space:nowrap;' : '')) + .attr('style', (d) => (d.nowrap ? 'white-space:nowrap;' : '')) .on('click', (d) => { if (this.isSorting) return; this.isSorting = true; @@ -128,27 +138,23 @@ export default class Table { let tableData = this.maptable.data; if (this.options.distinctBy) { - tableData = d3.nest() + tableData = d3 + .nest() .key((d) => d[this.options.distinctBy]) .entries(this.maptable.data) .map((g) => g.values[0]); } // Enter - this.body.selectAll('tr') - .data(tableData) - .enter() - .append('tr'); + this.body.selectAll('tr').data(tableData).enter().append('tr'); // Exit - this.body.selectAll('tr') - .data(tableData) - .exit() - .remove(); + this.body.selectAll('tr').data(tableData).exit().remove(); // Update const uniqueCollapsedRows = []; - this.body.selectAll('tr') + this.body + .selectAll('tr') .data(tableData) .attr('class', (row) => { if (this.options.rowClassName) { @@ -166,11 +172,7 @@ export default class Table { } tds += '>'; - if (!( - this.options.collapseRowsBy.indexOf(columnKey) !== -1 - && uniqueCollapsedRows[columnKey] - && uniqueCollapsedRows[columnKey] === row[columnKey] - )) { + if (!(this.options.collapseRowsBy.indexOf(columnKey) !== -1 && uniqueCollapsedRows[columnKey] && uniqueCollapsedRows[columnKey] === row[columnKey])) { if (column.cellContent) { tds += column.cellContent(row); } else if (column.virtual) { @@ -197,13 +199,12 @@ export default class Table { sortableColums[i].setAttribute('class', 'mt-table-sortable'); } this.sorting.forEach((column) => { - this.container.querySelector(`#column_header_${utils.sanitizeKey(column.key)}`) - .setAttribute('class', `mt-table-sortable sort_${column.mode}`); + this.container.querySelector(`#column_header_${utils.sanitizeKey(column.key)}`).setAttribute('class', `mt-table-sortable sort_${column.mode}`); }); this.maptable.data = this.maptable.data.sort((a, b) => { let compareBool = false; this.sorting.forEach((column) => { - const d3SortMode = (column.mode === 'asc') ? d3.ascending : d3.descending; + const d3SortMode = column.mode === 'asc' ? d3.ascending : d3.descending; const columnDetails = this.maptable.columnDetails[column.key]; let el1 = a[column.key]; let el2 = b[column.key]; diff --git a/src/index.js b/src/index.js index 6d03a6d..38453cb 100644 --- a/src/index.js +++ b/src/index.js @@ -19,7 +19,7 @@ d3.maptable = function (target) { if (!topojson) { throw new Error('Maptable requires topojson.js'); } - if (typeof (mapOptions.path) !== 'string' && typeof (mapOptions.pathData) !== 'string') { + if (typeof mapOptions.path !== 'string' && typeof mapOptions.pathData !== 'string') { throw new Error('MapTable: map not provided'); } options.map = mapOptions; @@ -87,7 +87,7 @@ d3.maptable = function (target) { }; maptable.render = function (onComplete) { - if (typeof (target) !== 'string' || !document.querySelector(target)) { + if (typeof target !== 'string' || !document.querySelector(target)) { throw new Error('MapTable: target not found'); } @@ -106,11 +106,11 @@ d3.maptable = function (target) { const customOptions = utils.extendRecursive(defaultOptions, options); - if (!options.map.markers) delete customOptions.map.markers; - if (!options.map.heatmap) delete customOptions.map.heatmap; - if (!options.map.title) delete customOptions.map.title; - if (!options.map.timezones) delete customOptions.map.timezones; - if (!options.map.night) delete customOptions.map.night; + if (options.map && !options.map.markers) delete customOptions.map.markers; + if (options.map && !options.map.heatmap) delete customOptions.map.heatmap; + if (options.map && !options.map.title) delete customOptions.map.title; + if (options.map && !options.map.timezones) delete customOptions.map.timezones; + if (options.map && !options.map.night) delete customOptions.map.night; if (!options.filters) delete customOptions.filters; if (!options.table) delete customOptions.table; diff --git a/src/maptable.css b/src/maptable.css index 29335f6..8ccda09 100755 --- a/src/maptable.css +++ b/src/maptable.css @@ -127,4 +127,8 @@ .mt-sun-gradient { background-image: radial-gradient(circle, rgba(255, 192, 0, 0.5) 0%, rgba(255, 192, 0, 0.15) 45%, rgba(255, 192, 0, 0) 100%); +} + +.mt-header-fixed { + position: sticky; } \ No newline at end of file