UNPKG

highcharts

Version:
17 lines (15 loc) 4.67 kB
/* Highmaps JS v8.0.0 (2019-12-10) (c) 2009-2019 Torstein Honsi License: www.highcharts.com/license */ (function(c){"object"===typeof module&&module.exports?(c["default"]=c,module.exports=c):"function"===typeof define&&define.amd?define("highcharts/modules/map-parser",["highcharts","highcharts/modules/data"],function(e){c(e);c.Highcharts=e;return c}):c("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(c){function e(c,l,e,a){c.hasOwnProperty(l)||(c[l]=a.apply(null,e))}c=c?c._modules:{};e(c,"modules/map-parser.src.js",[c["parts/Globals.js"],c["parts/Utilities.js"]],function(c,e){var l=e.extend; e=e.wrap;e(c.Data.prototype,"init",function(a,c){a.call(this,c);c.svg&&this.loadSVG()});l(c.Data.prototype,{pathToArray:function(a,c){var b=0,f=0,e,g=[0,0],k=[0,0],n=function(d,a){return[a.a*d[0]+a.c*d[1]+a.e,a.b*d[0]+a.d*d[1]+a.f]};a=a.replace(/[0-9]+e-?[0-9]+/g,function(d){return+d}).replace(/([A-Za-z])/g," $1 ").replace(/-/g," -").replace(/^\s*/,"").replace(/\s*$/,"").replace(/\s+/g," ").split(/[ ,]+/);if(1===a.length)return[];for(b=0;b<a.length;b++)if(e=/[a-zA-Z]/.test(a[b])){var d=a[b];var p= 2;if("c"===d||"C"===d)p=6;"m"===d?k=[parseFloat(a[b+1])+k[0],parseFloat(a[b+2])+k[1]]:"M"===d&&(k=[parseFloat(a[b+1]),parseFloat(a[b+2])]);if("m"===d||"l"===d||"c"===d){a[b]=d.toUpperCase();var h=!0}else if("M"===d||"L"===d||"C"===d)h=!1;else if("h"===d)h=!0,a[b]="L",a.splice(b+2,0,0);else if("v"===d)h=!0,a[b]="L",a.splice(b+1,0,0);else if("s"===d)h=!0,a[b]="L",a.splice(b+1,2);else if("S"===d)h=!1,a[b]="L",a.splice(b+1,2);else if("H"===d||"h"===d)h=!1,a[b]="L",a.splice(b+2,0,g[1]);else if("V"===d|| "v"===d)h=!1,a[b]="L",a.splice(b+1,0,g[0]);else if("z"===d||"Z"===d)g=k}else a[b]=parseFloat(a[b]),h&&(a[b]+=g[f%2]),1===f%2&&c&&(!h||"m"===d&&3>b)&&(e=n([a[b-1],a[b]],c),a[b-1]=e[0],a[b]=e[1]),f===p-1?(g=[a[b-1],a[b]],f=0):f+=1;"number"===typeof a[0]&&4<=a.length&&(a.unshift("M"),a.splice(3,0,"L"));return a},pathToString:function(a){a.forEach(function(a){var b=a.path;b=b.join(",");b=b.replace(/,?([a-zA-Z]),?/g,"$1");a.path=b});return a},roundPaths:function(a,e){var b=c.seriesTypes.map.prototype; var f={xAxis:{translate:c.Axis.prototype.translate,options:{},minPixelPadding:0},yAxis:{translate:c.Axis.prototype.translate,options:{},minPixelPadding:0}};b.getBox.call(f,a);var m=Math.max(f.maxX-f.minX,f.maxY-f.minY);e=e||1E3;m=e/m;f.xAxis.transA=f.yAxis.transA=m;f.xAxis.len=f.yAxis.len=e;f.xAxis.min=f.minX;f.yAxis.min=(f.minY+e)/m;a.forEach(function(a){var c,e;a.path=e=b.translatePath.call(f,a.path,!0);for(c=e.length;c--;)"number"===typeof e[c]&&(e[c]=Math.round(e[c]));delete a._foundBox});return a}, loadSVG:function(){function a(a){return Array.prototype.slice.call(a.getElementsByTagName("path")).concat(Array.prototype.slice.call(a.getElementsByTagName("polygon"))).concat(Array.prototype.slice.call(a.getElementsByTagName("rect")))}function c(a){if("path"===a.nodeName)return a.getAttribute("d");if("polygon"===a.nodeName)return a.getAttribute("points");if("rect"===a.nodeName){var d=+a.getAttribute("x"),b=+a.getAttribute("y"),c=+a.getAttribute("width");a=+a.getAttribute("height");return[d,b,d+c, b,d+c,b+a,d,b+a,d,b].join(" ")}}function b(a){a=a.getCTM();if(!isNaN(a.f))return a}function e(a){var b=a.getElementsByTagName("desc");return(b=b[0]&&b[0].getElementsByTagName("name"))&&b[0]&&b[0].innerText||a.getAttribute("inkscape:label")||a.getAttribute("id")||a.getAttribute("class")}function m(a){return!/fill[\s]?:[\s]?none/.test(a.getAttribute("style"))&&"none"!==a.getAttribute("fill")}function g(d){var f=[],h,g,l;k.$frame=k.$frame||$("<div>").css({position:"absolute",top:"-9999em"}).appendTo($(document.body)); k.$frame.html(d);d=$("svg",k.$frame)[0];d.removeAttribute("viewBox");var q=a(d);["defs","clipPath"].forEach(function(a){d.getElementsByTagName(a).forEach(function(a){a.getElementsByTagName("path").forEach(function(a){a.skip=!0})})});q.forEach(function(a,b){if(!a.skip){var c=[];0<b&&a.parentNode!==h&&(l=!0);for(h=a.parentNode;a;)c.push(a),a=a.parentNode;c.reverse();if(g)for(a=0;a<g.length;a++)g[a]!==c[a]&&(g=g.slice(0,a));else g=c}});var r=g[g.length-1];l&&r.getElementsByTagName("g").forEach(function(d){var g= [],h;a(d).forEach(function(a){a.skip||(g=g.concat(k.pathToArray(c(a),b(a))),m(a)&&(h=!0),a.skip=!0)});f.push({name:e(d),path:g,hasFill:h})});q.forEach(function(a){a.skip||f.push({name:e(a),path:k.pathToArray(c(a),b(a)),hasFill:m(a)})});k.roundPaths(f);n.complete({series:[{data:f}]})}var k=this,n=this.options;-1!==n.svg.indexOf("<svg")?g(n.svg):jQuery.ajax({url:n.svg,dataType:"text",success:g})}})});e(c,"masters/modules/map-parser.src.js",[],function(){})}); //# sourceMappingURL=map-parser.js.map