No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

exporting.js 16KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Highcharts JS v8.0.4 (2020-03-10)
  3. Exporting module
  4. (c) 2010-2019 Torstein Honsi
  5. License: www.highcharts.com/license
  6. */
  7. (function(e){"object"===typeof module&&module.exports?(e["default"]=e,module.exports=e):"function"===typeof define&&define.amd?define("highcharts/modules/exporting",["highcharts"],function(m){e(m);e.Highcharts=m;return e}):e("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(e){function m(f,g,e,n){f.hasOwnProperty(g)||(f[g]=n.apply(null,e))}e=e?e._modules:{};m(e,"modules/full-screen.src.js",[e["parts/Globals.js"]],function(f){var g=f.addEvent,e=f.Chart,n=function(){function g(h){this.chart=
  8. h;this.isOpen=!1;h.container.parentNode instanceof Element&&(h=h.container.parentNode,this.browserProps||("function"===typeof h.requestFullscreen?this.browserProps={fullscreenChange:"fullscreenchange",requestFullscreen:"requestFullscreen",exitFullscreen:"exitFullscreen"}:h.mozRequestFullScreen?this.browserProps={fullscreenChange:"mozfullscreenchange",requestFullscreen:"mozRequestFullScreen",exitFullscreen:"mozCancelFullScreen"}:h.webkitRequestFullScreen?this.browserProps={fullscreenChange:"webkitfullscreenchange",
  9. requestFullscreen:"webkitRequestFullScreen",exitFullscreen:"webkitExitFullscreen"}:h.msRequestFullscreen&&(this.browserProps={fullscreenChange:"MSFullscreenChange",requestFullscreen:"msRequestFullscreen",exitFullscreen:"msExitFullscreen"})))}g.prototype.close=function(){var h=this.chart;if(this.isOpen&&this.browserProps&&h.container.ownerDocument instanceof Document)h.container.ownerDocument[this.browserProps.exitFullscreen]();this.unbindFullscreenEvent&&this.unbindFullscreenEvent();this.isOpen=!1;
  10. this.setButtonText()};g.prototype.open=function(){var h=this,g=h.chart;if(h.browserProps){h.unbindFullscreenEvent=f.addEvent(g.container.ownerDocument,h.browserProps.fullscreenChange,function(){h.isOpen?(h.isOpen=!1,h.close()):(h.isOpen=!0,h.setButtonText())});if(g.container.parentNode instanceof Element){var e=g.container.parentNode[h.browserProps.requestFullscreen]();if(e)e["catch"](function(){alert("Full screen is not supported inside a frame.")})}f.addEvent(g,"destroy",h.unbindFullscreenEvent)}};
  11. g.prototype.setButtonText=function(){var h,g=this.chart,f=g.exportDivElements,e=g.options.exporting,n=null===(h=null===e||void 0===e?void 0:e.buttons)||void 0===h?void 0:h.contextButton.menuItems;h=g.options.lang;(null===e||void 0===e?0:e.menuItemDefinitions)&&(null===h||void 0===h?0:h.exitFullscreen)&&h.viewFullscreen&&n&&f&&f.length&&(f[n.indexOf("viewFullscreen")].innerHTML=this.isOpen?h.exitFullscreen:e.menuItemDefinitions.viewFullscreen.text||h.viewFullscreen)};g.prototype.toggle=function(){this.isOpen?
  12. this.close():this.open()};return g}();f.Fullscreen=n;g(e,"beforeRender",function(){this.fullscreen=new f.Fullscreen(this)});return f.Fullscreen});m(e,"mixins/navigation.js",[],function(){return{initUpdate:function(f){f.navigation||(f.navigation={updates:[],update:function(g,f){this.updates.forEach(function(e){e.update.call(e.context,g,f)})}})},addUpdate:function(f,g){g.navigation||this.initUpdate(g);g.navigation.updates.push({update:f,context:g})}}});m(e,"modules/exporting.src.js",[e["parts/Globals.js"],
  13. e["parts/Utilities.js"],e["mixins/navigation.js"]],function(f,g,e){var n=g.addEvent,u=g.css,h=g.createElement,m=g.discardElement,x=g.extend,I=g.find,B=g.fireEvent,J=g.isObject,p=g.merge,E=g.objectEach,q=g.pick,K=g.removeEvent,L=g.uniqueKey,w=f.defaultOptions,y=f.doc,C=f.Chart,M=f.isTouchDevice,z=f.win,G=z.navigator.userAgent,F=f.SVGRenderer,H=f.Renderer.prototype.symbols,N=/Edge\/|Trident\/|MSIE /.test(G),O=/firefox/i.test(G);x(w.lang,{viewFullscreen:"View in full screen",exitFullscreen:"Exit from full screen",
  14. printChart:"Print chart",downloadPNG:"Download PNG image",downloadJPEG:"Download JPEG image",downloadPDF:"Download PDF document",downloadSVG:"Download SVG vector image",contextButtonTitle:"Chart context menu"});w.navigation||(w.navigation={});p(!0,w.navigation,{buttonOptions:{theme:{},symbolSize:14,symbolX:12.5,symbolY:10.5,align:"right",buttonSpacing:3,height:22,verticalAlign:"top",width:24}});p(!0,w.navigation,{menuStyle:{border:"1px solid #999999",background:"#ffffff",padding:"5px 0"},menuItemStyle:{padding:"0.5em 1em",
  15. color:"#333333",background:"none",fontSize:M?"14px":"11px",transition:"background 250ms, color 250ms"},menuItemHoverStyle:{background:"#335cad",color:"#ffffff"},buttonOptions:{symbolFill:"#666666",symbolStroke:"#666666",symbolStrokeWidth:3,theme:{padding:5}}});w.exporting={type:"image/png",url:"https://export.highcharts.com/",printMaxWidth:780,scale:2,buttons:{contextButton:{className:"highcharts-contextbutton",menuClassName:"highcharts-contextmenu",symbol:"menu",titleKey:"contextButtonTitle",menuItems:"viewFullscreen printChart separator downloadPNG downloadJPEG downloadPDF downloadSVG".split(" ")}},
  16. menuItemDefinitions:{viewFullscreen:{textKey:"viewFullscreen",onclick:function(){this.fullscreen.toggle()}},printChart:{textKey:"printChart",onclick:function(){this.print()}},separator:{separator:!0},downloadPNG:{textKey:"downloadPNG",onclick:function(){this.exportChart()}},downloadJPEG:{textKey:"downloadJPEG",onclick:function(){this.exportChart({type:"image/jpeg"})}},downloadPDF:{textKey:"downloadPDF",onclick:function(){this.exportChart({type:"application/pdf"})}},downloadSVG:{textKey:"downloadSVG",
  17. onclick:function(){this.exportChart({type:"image/svg+xml"})}}}};f.post=function(a,b,c){var d=h("form",p({method:"post",action:a,enctype:"multipart/form-data"},c),{display:"none"},y.body);E(b,function(a,b){h("input",{type:"hidden",name:b,value:a},null,d)});d.submit();m(d)};f.isSafari&&f.win.matchMedia("print").addListener(function(a){f.printingChart&&(a.matches?f.printingChart.beforePrint():f.printingChart.afterPrint())});x(C.prototype,{sanitizeSVG:function(a,b){var c=a.indexOf("</svg>")+6,d=a.substr(c);
  18. a=a.substr(0,c);b&&b.exporting&&b.exporting.allowHTML&&d&&(d='<foreignObject x="0" y="0" width="'+b.chart.width+'" height="'+b.chart.height+'"><body xmlns="http://www.w3.org/1999/xhtml">'+d+"</body></foreignObject>",a=a.replace("</svg>",d+"</svg>"));a=a.replace(/zIndex="[^"]+"/g,"").replace(/symbolName="[^"]+"/g,"").replace(/jQuery[0-9]+="[^"]+"/g,"").replace(/url\(("|&quot;)(.*?)("|&quot;);?\)/g,"url($2)").replace(/url\([^#]+#/g,"url(#").replace(/<svg /,'<svg xmlns:xlink="http://www.w3.org/1999/xlink" ').replace(/ (|NS[0-9]+:)href=/g,
  19. " xlink:href=").replace(/\n/," ").replace(/(fill|stroke)="rgba\(([ 0-9]+,[ 0-9]+,[ 0-9]+),([ 0-9\.]+)\)"/g,'$1="rgb($2)" $1-opacity="$3"').replace(/&nbsp;/g,"\u00a0").replace(/&shy;/g,"\u00ad");this.ieSanitizeSVG&&(a=this.ieSanitizeSVG(a));return a},getChartHTML:function(){this.styledMode&&this.inlineStyles();return this.container.innerHTML},getSVG:function(a){var b,c=p(this.options,a);c.plotOptions=p(this.userOptions.plotOptions,a&&a.plotOptions);c.time=p(this.userOptions.time,a&&a.time);var d=h("div",
  20. null,{position:"absolute",top:"-9999em",width:this.chartWidth+"px",height:this.chartHeight+"px"},y.body);var g=this.renderTo.style.width;var e=this.renderTo.style.height;g=c.exporting.sourceWidth||c.chart.width||/px$/.test(g)&&parseInt(g,10)||(c.isGantt?800:600);e=c.exporting.sourceHeight||c.chart.height||/px$/.test(e)&&parseInt(e,10)||400;x(c.chart,{animation:!1,renderTo:d,forExport:!0,renderer:"SVGRenderer",width:g,height:e});c.exporting.enabled=!1;delete c.data;c.series=[];this.series.forEach(function(a){b=
  21. p(a.userOptions,{animation:!1,enableMouseTracking:!1,showCheckbox:!1,visible:a.visible});b.isInternal||c.series.push(b)});this.axes.forEach(function(a){a.userOptions.internalKey||(a.userOptions.internalKey=L())});var r=new f.Chart(c,this.callback);a&&["xAxis","yAxis","series"].forEach(function(b){var d={};a[b]&&(d[b]=a[b],r.update(d))});this.axes.forEach(function(a){var b=I(r.axes,function(b){return b.options.internalKey===a.userOptions.internalKey}),d=a.getExtremes(),c=d.userMin;d=d.userMax;b&&("undefined"!==
  22. typeof c&&c!==b.min||"undefined"!==typeof d&&d!==b.max)&&b.setExtremes(c,d,!0,!1)});g=r.getChartHTML();B(this,"getSVG",{chartCopy:r});g=this.sanitizeSVG(g,c);c=null;r.destroy();m(d);return g},getSVGForExport:function(a,b){var c=this.options.exporting;return this.getSVG(p({chart:{borderRadius:0}},c.chartOptions,b,{exporting:{sourceWidth:a&&a.sourceWidth||c.sourceWidth,sourceHeight:a&&a.sourceHeight||c.sourceHeight}}))},getFilename:function(){var a=this.userOptions.title&&this.userOptions.title.text,
  23. b=this.options.exporting.filename;if(b)return b.replace(/\//g,"-");"string"===typeof a&&(b=a.toLowerCase().replace(/<\/?[^>]+(>|$)/g,"").replace(/[\s_]+/g,"-").replace(/[^a-z0-9\-]/g,"").replace(/^[\-]+/g,"").replace(/[\-]+/g,"-").substr(0,24).replace(/[\-]+$/g,""));if(!b||5>b.length)b="chart";return b},exportChart:function(a,b){b=this.getSVGForExport(a,b);a=p(this.options.exporting,a);f.post(a.url,{filename:a.filename?a.filename.replace(/\//g,"-"):this.getFilename(),type:a.type,width:a.width||0,
  24. scale:a.scale,svg:b},a.formAttributes)},moveContainers:function(a){(this.fixedDiv?[this.fixedDiv,this.scrollingContainer]:[this.container]).forEach(function(b){a.appendChild(b)})},beforePrint:function(){var a=y.body,b=this.options.exporting.printMaxWidth,c={childNodes:a.childNodes,origDisplay:[],resetParams:void 0};this.isPrinting=!0;this.pointer.reset(null,0);B(this,"beforePrint");b&&this.chartWidth>b&&(c.resetParams=[this.options.chart.width,void 0,!1],this.setSize(b,void 0,!1));[].forEach.call(c.childNodes,
  25. function(a,b){1===a.nodeType&&(c.origDisplay[b]=a.style.display,a.style.display="none")});this.moveContainers(a);this.printReverseInfo=c},afterPrint:function(){if(this.printReverseInfo){var a=this.printReverseInfo.childNodes,b=this.printReverseInfo.origDisplay,c=this.printReverseInfo.resetParams;this.moveContainers(this.renderTo);[].forEach.call(a,function(a,c){1===a.nodeType&&(a.style.display=b[c]||"")});this.isPrinting=!1;c&&this.setSize.apply(this,c);delete this.printReverseInfo;delete f.printingChart;
  26. B(this,"afterPrint")}},print:function(){var a=this;a.isPrinting||(f.printingChart=a,f.isSafari||a.beforePrint(),setTimeout(function(){z.focus();z.print();f.isSafari||setTimeout(function(){a.afterPrint()},1E3)},1))},contextMenu:function(a,b,c,d,e,f,r){var k=this,D=k.options.navigation,p=k.chartWidth,A=k.chartHeight,t="cache-"+a,l=k[t],v=Math.max(e,f);if(!l){k.exportContextMenu=k[t]=l=h("div",{className:a},{position:"absolute",zIndex:1E3,padding:v+"px",pointerEvents:"auto"},k.fixedDiv||k.container);
  27. var m=h("ul",{className:"highcharts-menu"},{listStyle:"none",margin:0,padding:0},l);k.styledMode||u(m,x({MozBoxShadow:"3px 3px 10px #888",WebkitBoxShadow:"3px 3px 10px #888",boxShadow:"3px 3px 10px #888"},D.menuStyle));l.hideMenu=function(){u(l,{display:"none"});r&&r.setState(0);k.openMenu=!1;u(k.renderTo,{overflow:"hidden"});g.clearTimeout(l.hideTimer);B(k,"exportMenuHidden")};k.exportEvents.push(n(l,"mouseleave",function(){l.hideTimer=z.setTimeout(l.hideMenu,500)}),n(l,"mouseenter",function(){g.clearTimeout(l.hideTimer)}),
  28. n(y,"mouseup",function(b){k.pointer.inClass(b.target,a)||l.hideMenu()}),n(l,"click",function(){k.openMenu&&l.hideMenu()}));b.forEach(function(a){"string"===typeof a&&(a=k.options.exporting.menuItemDefinitions[a]);if(J(a,!0)){if(a.separator)var b=h("hr",null,null,m);else b=h("li",{className:"highcharts-menu-item",onclick:function(b){b&&b.stopPropagation();l.hideMenu();a.onclick&&a.onclick.apply(k,arguments)},innerHTML:a.text||k.options.lang[a.textKey]},null,m),k.styledMode||(b.onmouseover=function(){u(this,
  29. D.menuItemHoverStyle)},b.onmouseout=function(){u(this,D.menuItemStyle)},u(b,x({cursor:"pointer"},D.menuItemStyle)));k.exportDivElements.push(b)}});k.exportDivElements.push(m,l);k.exportMenuWidth=l.offsetWidth;k.exportMenuHeight=l.offsetHeight}b={display:"block"};c+k.exportMenuWidth>p?b.right=p-c-e-v+"px":b.left=c-v+"px";d+f+k.exportMenuHeight>A&&"top"!==r.alignOptions.verticalAlign?b.bottom=A-d-v+"px":b.top=d+f-v+"px";u(l,b);u(k.renderTo,{overflow:""});k.openMenu=!0;B(k,"exportMenuShown")},addButton:function(a){var b=
  30. this,c=b.renderer,d=p(b.options.navigation.buttonOptions,a),g=d.onclick,e=d.menuItems,f=d.symbolSize||12;b.btnCount||(b.btnCount=0);b.exportDivElements||(b.exportDivElements=[],b.exportSVGElements=[]);if(!1!==d.enabled){var k=d.theme,h=k.states,m=h&&h.hover;h=h&&h.select;var A;b.styledMode||(k.fill=q(k.fill,"#ffffff"),k.stroke=q(k.stroke,"none"));delete k.states;g?A=function(a){a&&a.stopPropagation();g.call(b,a)}:e&&(A=function(a){a&&a.stopPropagation();b.contextMenu(t.menuClassName,e,t.translateX,
  31. t.translateY,t.width,t.height,t);t.setState(2)});d.text&&d.symbol?k.paddingLeft=q(k.paddingLeft,25):d.text||x(k,{width:d.width,height:d.height,padding:0});b.styledMode||(k["stroke-linecap"]="round",k.fill=q(k.fill,"#ffffff"),k.stroke=q(k.stroke,"none"));var t=c.button(d.text,0,0,A,k,m,h).addClass(a.className).attr({title:q(b.options.lang[d._titleKey||d.titleKey],"")});t.menuClassName=a.menuClassName||"highcharts-menu-"+b.btnCount++;if(d.symbol){var l=c.symbol(d.symbol,d.symbolX-f/2,d.symbolY-f/2,
  32. f,f,{width:f,height:f}).addClass("highcharts-button-symbol").attr({zIndex:1}).add(t);b.styledMode||l.attr({stroke:d.symbolStroke,fill:d.symbolFill,"stroke-width":d.symbolStrokeWidth||1})}t.add(b.exportingGroup).align(x(d,{width:t.width,x:q(d.x,b.buttonOffset)}),!0,"spacingBox");b.buttonOffset+=(t.width+d.buttonSpacing)*("right"===d.align?-1:1);b.exportSVGElements.push(t,l)}},destroyExport:function(a){var b=a?a.target:this;a=b.exportSVGElements;var c=b.exportDivElements,d=b.exportEvents,f;a&&(a.forEach(function(a,
  33. d){a&&(a.onclick=a.ontouchstart=null,f="cache-"+a.menuClassName,b[f]&&delete b[f],b.exportSVGElements[d]=a.destroy())}),a.length=0);b.exportingGroup&&(b.exportingGroup.destroy(),delete b.exportingGroup);c&&(c.forEach(function(a,d){g.clearTimeout(a.hideTimer);K(a,"mouseleave");b.exportDivElements[d]=a.onmouseout=a.onmouseover=a.ontouchstart=a.onclick=null;m(a)}),c.length=0);d&&(d.forEach(function(a){a()}),d.length=0)}});F.prototype.inlineToAttributes="fill stroke strokeLinecap strokeLinejoin strokeWidth textAnchor x y".split(" ");
  34. F.prototype.inlineBlacklist=[/-/,/^(clipPath|cssText|d|height|width)$/,/^font$/,/[lL]ogical(Width|Height)$/,/perspective/,/TapHighlightColor/,/^transition/,/^length$/];F.prototype.unstyledElements=["clipPath","defs","desc"];C.prototype.inlineStyles=function(){function a(a){return a.replace(/([A-Z])/g,function(a,b){return"-"+b.toLowerCase()})}function b(c){function k(b,e){v=u=!1;if(g){for(q=g.length;q--&&!u;)u=g[q].test(e);v=!u}"transform"===e&&"none"===b&&(v=!0);for(q=f.length;q--&&!v;)v=f[q].test(e)||
  35. "function"===typeof b;v||x[e]===b&&"svg"!==c.nodeName||h[c.nodeName][e]===b||(-1!==d.indexOf(e)?c.setAttribute(a(e),b):l+=a(e)+":"+b+";")}var l="",v,u,q;if(1===c.nodeType&&-1===e.indexOf(c.nodeName)){var r=z.getComputedStyle(c,null);var x="svg"===c.nodeName?{}:z.getComputedStyle(c.parentNode,null);if(!h[c.nodeName]){m=n.getElementsByTagName("svg")[0];var w=n.createElementNS(c.namespaceURI,c.nodeName);m.appendChild(w);h[c.nodeName]=p(z.getComputedStyle(w,null));"text"===c.nodeName&&delete h.text.fill;
  36. m.removeChild(w)}if(O||N)for(var y in r)k(r[y],y);else E(r,k);l&&(r=c.getAttribute("style"),c.setAttribute("style",(r?r+";":"")+l));"svg"===c.nodeName&&c.setAttribute("stroke-width","1px");"text"!==c.nodeName&&[].forEach.call(c.children||c.childNodes,b)}}var c=this.renderer,d=c.inlineToAttributes,f=c.inlineBlacklist,g=c.inlineWhitelist,e=c.unstyledElements,h={},m;c=y.createElement("iframe");u(c,{width:"1px",height:"1px",visibility:"hidden"});y.body.appendChild(c);var n=c.contentWindow.document;n.open();
  37. n.write('<svg xmlns="http://www.w3.org/2000/svg"></svg>');n.close();b(this.container.querySelector("svg"));m.parentNode.removeChild(m)};H.menu=function(a,b,c,d){return["M",a,b+2.5,"L",a+c,b+2.5,"M",a,b+d/2+.5,"L",a+c,b+d/2+.5,"M",a,b+d-1.5,"L",a+c,b+d-1.5]};H.menuball=function(a,b,c,d){a=[];d=d/3-2;return a=a.concat(this.circle(c-d,b,d,d),this.circle(c-d,b+d+4,d,d),this.circle(c-d,b+2*(d+4),d,d))};C.prototype.renderExporting=function(){var a=this,b=a.options.exporting,c=b.buttons,d=a.isDirtyExporting||
  38. !a.exportSVGElements;a.buttonOffset=0;a.isDirtyExporting&&a.destroyExport();d&&!1!==b.enabled&&(a.exportEvents=[],a.exportingGroup=a.exportingGroup||a.renderer.g("exporting-group").attr({zIndex:3}).add(),E(c,function(b){a.addButton(b)}),a.isDirtyExporting=!1);n(a,"destroy",a.destroyExport)};n(C,"init",function(){var a=this;a.exporting={update:function(b,c){a.isDirtyExporting=!0;p(!0,a.options.exporting,b);q(c,!0)&&a.redraw()}};e.addUpdate(function(b,c){a.isDirtyExporting=!0;p(!0,a.options.navigation,
  39. b);q(c,!0)&&a.redraw()},a)});C.prototype.callbacks.push(function(a){a.renderExporting();n(a,"redraw",a.renderExporting)})});m(e,"masters/modules/exporting.src.js",[],function(){})});
  40. //# sourceMappingURL=exporting.js.map