@fusioncharts/features
Version:
FusionCharts JavaScript charting framework
1 lines • 25.1 kB
JavaScript
;var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule=true;exports.default=void 0;var _defineProperty2=_interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));var _inheritsLoose2=_interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));var _index=require("@fusioncharts/core/src/component-interface/index.js");var _index2=require("@fusioncharts/core/src/dependency-manager/index.js");var _lib=require("@fusioncharts/core/src/lib");var _arrayHasContent=_interopRequireDefault(require("@fusioncharts/utils/src/type/array-has-content.js"));var _exportUtils=require("../utils/export-utils.js");var _jpegToPdf=require("../utils/jpeg-to-pdf.js");var _libSvgToCanvas=require("../utils/lib-svg-to-canvas.js");function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach((function(r){(0,_defineProperty2.default)(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var copyExportOptions=function copyExportOptions(object){var newObject={},key;for(key in object){newObject[key.toLowerCase()]=object[key]}return newObject},exportLabelStrings={english:"Export As ",french:"Exporter en tant que ",italian:"Esporta come ",german:"Exportieren als ",portuguese:"Exportar como ",spanish:"Exportar como ",catalan:"Exportar com "},ENGLISH="english",LANGUAGE="language",DEFAULT_BG_COLOR="#FFFFFF";var isObject=function isObject(obj){return typeof obj==="object"},getBackgroundColor=function getBackgroundColor(chartInstance){if(chartInstance.jsVars.transparent||(0,_lib.pluckNumber)(chartInstance.options.containerBackgroundOpacity,1)===0){return _lib.BLANKSTRING}return chartInstance.options.containerBackgroundColor||DEFAULT_BG_COLOR},getBackgroundAlpha=function getBackgroundAlpha(chartInstance){if(chartInstance.jsVars.transparent){return 0}return(0,_lib.pluckNumber)(chartInstance.options.containerBackgroundOpacity,1)+""},IMAGEDATA="IMAGE-DATA",xAttrRegx=/\s\bx\b=['"][^'"]+?['"]/gi,yAttrRegx=/\s\by\b=['"][^'"]+?['"]/gi,win=window,doc=win.document,DEFAULT_EXPORT_URL=win.location.protocol==="https:"?"https://export.api3.fusioncharts.com/":"http://export.api3.fusioncharts.com/",DEFAULT_LOG_URL=win.location.protocol==="https:"?"https://export.api3.fusioncharts.com/api/v1.0/logs":"http://export.api3.fusioncharts.com/api/v1.0/logs",isIOS=win.navigator.userAgent.match(/(iPad|iPhone|iPod)/g);var ExportModule=exports.default=function(_ComponentInterface){function ExportModule(){var _this;_this=_ComponentInterface.call(this)||this;_this.config={exportOption:{},chartConfig:{caption:"",subcaption:"",width:"",height:""}};return _this}(0,_inheritsLoose2.default)(ExportModule,_ComponentInterface);var _proto=ExportModule.prototype;_proto.getName=function getName(){return"exportModule"};_proto.getType=function getType(){return"extension"};_proto.configureMenuBar=function configureMenuBar(){var _this$getFromEnv;var exporter=this,toolbar=exporter.getFromEnv("toolbar"),lang=(_this$getFromEnv=this.getFromEnv(LANGUAGE))!=null?_this$getFromEnv:ENGLISH,isbtoaSupported=!!win.btoa,exportString=exportLabelStrings[lang],chartObj=exporter.getFromEnv("chart"),exportFormats=exporter.getFromEnv("chart-attrib").exportformats,hamBurger=toolbar.getChild("hamburgerMenu-"+toolbar.getId()+"-"+chartObj.getId()+"-0"),exportTypes,exportParam,type,excelexport=(0,_index2.getDep)("Excelexport"),i,length,fn,exportMap={PNG:exportString+_exportUtils.EXPORTFORMAT.PNG.toUpperCase(),JPG:exportString+_exportUtils.EXPORTFORMAT.JPG.toUpperCase(),PDF:exportString+_exportUtils.EXPORTFORMAT.PDF.toUpperCase(),SVG:exportString+_exportUtils.EXPORTFORMAT.SVG.toUpperCase(),CSV:exportString+_exportUtils.EXPORTFORMAT.CSV.toUpperCase(),XLSX:exportString+_exportUtils.EXPORTFORMAT.XLSX.toUpperCase(),XLS:exportString+_exportUtils.EXPORTFORMAT.XLS.toUpperCase()},exportOptionObj,list=[],usrExportType,iscustomExportFormatsOverwritesXlsx;if(exporter.config.exportOption.exportenabled){fn=function fn(exportTypeName){return function(){exporter.config.exportOption.exportformat=exportTypeName;exporter.exportChart({})}};if(exportFormats){exportTypes=exportFormats.split("|");for(i=0,length=exportTypes.length;i<length;i++){exportParam=exportTypes[i].split("=");type=(0,_lib.trimString)(exportParam[0].toUpperCase());if(type.toLowerCase()===_exportUtils.EXPORTFORMAT.XLSX){iscustomExportFormatsOverwritesXlsx=true}exportMap[type]&&(exportMap[type]=exportParam[1]||exportMap[type]);exportMap[type]&&(usrExportType||(usrExportType={}))&&(usrExportType[type]=true)}}exporter.config.exportOption.exportformats=_objectSpread({},exportMap);for(type in exportMap){if(type==="XLSX"&&(!isbtoaSupported||!excelexport||excelexport&&excelexport.then)||usrExportType&&!usrExportType[type]){continue}if(type==="XLS"){continue}if(type==="CSV"&&!isbtoaSupported){continue}exportOptionObj={name:exportMap[type],handler:fn(type),action:"click"};list.push(exportOptionObj)}hamBurger.appendInMenu(list);if(isbtoaSupported&&excelexport&&excelexport.then){excelexport.then((function(){if(!exportFormats||iscustomExportFormatsOverwritesXlsx){hamBurger.appendInMenu([{name:exportMap.XLSX,handler:fn("XLSX"),action:"click"}]);hamBurger.asyncDraw()}}))}}};_proto.configure=function configure(options){var chartInstance=this.getFromEnv("chartInstance"),exportConfig=this.config,exportChartConfig=exportConfig.chartConfig,exportOption=exportConfig.exportOption,config=options.chartConfig;config.caption&&(exportChartConfig.caption=(0,_lib.pluck)(config.caption,""));config.subcaption&&(exportChartConfig.subcaption=(0,_lib.pluck)(config.subcaption,""));exportOption.exportenabled=(0,_lib.pluckNumber)(config.exportenabled,0);exportOption.exportshowmenuitem=(0,_lib.pluckNumber)(config.exportshowmenuitem,1);exportOption.exportformat=(0,_lib.pluck)(config.exportformat,_exportUtils.EXPORTFORMAT.PNG);exportOption.exporthandler=(0,_lib.pluck)(config.html5exporthandler,config.exporthandler,DEFAULT_EXPORT_URL);exportOption.exportaction=function(){var exportAction;if(config.exportaction&&typeof config.exportaction==="string"){exportAction=config.exportaction.toLowerCase();return[_exportUtils.EXPORTACTION.DOWNLOAD,_exportUtils.EXPORTACTION.SAVE,_exportUtils.EXPORTACTION.DOWNLOADSAVE].indexOf(exportAction)>=0?exportAction:_exportUtils.EXPORTACTION.DOWNLOAD}return _exportUtils.EXPORTACTION.DOWNLOAD}();exportOption.exporttargetwindow=(0,_lib.pluck)(config.exporttargetwindow,isIOS?"_parent":"_self");exportOption.exportfilename=(0,_lib.pluck)(config.exportfilename,"FusionCharts");exportOption.exportparameters=(0,_lib.pluck)(config.exportparameters,"");exportOption.exportcallback=(0,_lib.pluck)(config.exportcallback,"");exportOption.exportwithimages=(0,_lib.pluckNumber)(config.exportwithimages,1);exportOption.exportmode=function(){var exportMode;if(typeof config.exportatclientside!=="undefined"){exportMode={1:_exportUtils.EXPORTMODE.AUTO,0:_exportUtils.EXPORTMODE.AUTO}[config.exportatclientside]}exportMode=config.exportmode||exportMode||_exportUtils.EXPORTMODE.AUTO;exportMode=exportMode.toLowerCase();return exportMode}();exportOption.logenabled=(0,_lib.pluckNumber)(config.logenabled,0);exportOption.loghandler=(0,_lib.pluck)(config.html5loghandler,config.loghandler,DEFAULT_LOG_URL);exportOption.logmode=function(){var logMode=config.logmode;if(typeof logMode!=="undefined"&&typeof logMode==="string"&&logMode.toUpperCase()in _exportUtils.LOGMODE){return _exportUtils.LOGMODE[logMode.toUpperCase()]}return _exportUtils.LOGMODE.AUTO}();exportOption.bgcolor=getBackgroundColor(chartInstance);exportOption.bgalpha=getBackgroundAlpha(chartInstance);if(exportOption.exportshowmenuitem){this.configureMenuBar()}};_proto.exportChart=function exportChart(exportOption){var self=this,chartInstance=self.getFromEnv("chartInstance"),chart=self.getFromEnv("chart"),exportOptionsLowerKeys=isObject(exportOption)&©ExportOptions(exportOption)||{},optionsExport=(0,_lib.extend2)((0,_lib.extend2)({},self.config.exportOption),exportOptionsLowerKeys),exportFormat=(optionsExport.exportformat||_exportUtils.EXPORTFORMAT.PNG).toLowerCase(),exportHandler=optionsExport.exporthandler,exportAction=optionsExport.exportaction,exportTargetWindow=optionsExport.exporttargetwindow||"",exportFileName=optionsExport.exportfilename,exportParameters=optionsExport.exportparameters,exportCallback=optionsExport.exportcallback,exportWithImages=optionsExport.exportwithimages,exportMode=optionsExport.exportmode,logEnabled=optionsExport.logenabled,logHandler=optionsExport.loghandler,logMode=optionsExport.logmode,xlsArr,csv,csvUri,undef,fireExportDataReadyEventOnChart=function fireExportDataReadyEventOnChart(postData){chart.fireChartInstanceEvent("exportDataReady",postData)};chart.fireChartInstanceEvent("beforeExport",optionsExport,undef,(function(){var chartId=chartInstance.id,chartCaption=self.config.chartConfig.caption,chartSubcaption=self.config.chartConfig.subcaption,paper=this.apiInstance.getFromEnv("paper"),useCanvas=this.apiInstance.getFromEnv("core-options")["export"].useCanvas,postData,svg,svgForClientSideExport,menuBar=(0,_arrayHasContent.default)(chart.getChildren("chartMenuBar"))?chart.getChildren("chartMenuBar")[0]:chart.getChildren("actionBar")[0],hamBurger=menuBar.getChild("hamburgerMenu-"+menuBar.getId()+"-"+chart.getId()+"-0"),containerGroup,clientSideExportedEventsParam={DOMId:chartId,height:paper.height,width:paper.width,fileName:exportFileName+"."+exportFormat,statusCode:undef,statusMessage:undef,notice:undef},exportOptionObject={exportAction:exportAction,exportTargetWindow:exportTargetWindow,exportCallback:exportCallback,fusionCharts:chartInstance,paper:paper,chartId:chartId,exportHandler:exportHandler,logEnabled:logEnabled,logMode:logMode,logHandler:logHandler},createPostDataForExport=function createPostDataForExport(streamType,streamValue,configuredExportAction){var _logEnabled;_logEnabled=!!logEnabled;if(logMode===_exportUtils.LOGMODE.CLIENT){_logEnabled=false}return{charttype:chartInstance.chartType(),stream_type:streamType||"",stream:streamValue||"",meta_bgColor:optionsExport.bgcolor||"",meta_bgAlpha:optionsExport.bgalpha||"1",meta_DOMId:chartInstance.id,meta_width:paper.width||self.config.chartConfig.width,meta_height:paper.height||self.config.chartConfig.height,chart_caption:chartCaption,chart_sub_caption:chartSubcaption,is_single_export:true,is_full_version:!true,version:_lib.PROJECT_VERSION,user_time_zone:-(new Date).getTimezoneOffset(),log_enabled:_logEnabled,parameters:["exportfilename="+exportFileName,"exportformat="+exportFormat,"exportaction="+(0,_exportUtils.createExportActionOldString)(exportAction),"exportactionnew="+exportAction,"configuredexportaction="+(configuredExportAction||exportAction),"exportparameters="+exportParameters].join("|")}},createPostDataForLog=function createPostDataForLog(){return{chartType:chartInstance.chartType(),chartCaption:chartCaption,chartSubCaption:chartSubcaption,isSingleExport:true,isFullVersion:!true,exportAction:exportAction,userTimeZone:-(new Date).getTimezoneOffset(),exportFileName:[exportFileName,exportFormat].join("."),exportFormat:exportFormat,version:_lib.PROJECT_VERSION}},noPrepareAndExportData=function noPrepareAndExportData(svgToExport){(0,_libSvgToCanvas.downloadCharts)(null,null,null,createPostDataForExport(_exportUtils.EXPORTFORMAT.SVG,svgToExport),exportOptionObject)},prepareAndExportData=function prepareAndExportData(svgToExportURL){var canvas,exportPostData,svgToExport=svgToExportURL;if(_libSvgToCanvas.browserDetails.hasCanvas&&typeof win.btoa!=="undefined"){canvas=doc.createElement("canvas");canvas.width=paper.width;canvas.height=paper.height;svgToExport=(0,_exportUtils.embedImagesWithNonDataURL)(svgToExport);svgForClientSideExport=(0,_exportUtils.replaceImagesWithNonDataUrl)(svgForClientSideExport);if((0,_exportUtils.hasUndownloadableImage)(svgToExport)||exportFormat===_exportUtils.EXPORTFORMAT.SVG){exportPostData=createPostDataForExport(_exportUtils.EXPORTFORMAT.SVG,svgToExport);(0,_libSvgToCanvas.downloadCharts)(null,null,null,exportPostData,exportOptionObject)}else{(0,_libSvgToCanvas.drawSvgOnCanvas)({svg:svgForClientSideExport,canvas:canvas,x:0,y:0,width:paper.width,height:paper.height,useCanvas:useCanvas},(function(){var dataURI;switch(exportFormat){case _exportUtils.EXPORTFORMAT.PNG:dataURI=canvas.toDataURL("image/png");break;case _exportUtils.EXPORTFORMAT.JPEG:dataURI=canvas.toDataURL("image/jpeg");break;case _exportUtils.EXPORTFORMAT.PDF:(0,_jpegToPdf.addImage)(canvas.toDataURL("image/jpeg"),paper.height,paper.width);dataURI=(0,_jpegToPdf.getDataUrl)();break;default:dataURI=canvas.toDataURL("image/jpeg");break}exportPostData=createPostDataForExport(IMAGEDATA,dataURI);(0,_libSvgToCanvas.downloadCharts)(null,null,null,exportPostData,exportOptionObject)}))}}else{noPrepareAndExportData(svgToExport)}},getImageDataUrl=function getImageDataUrl(type,callback,exportOptions){var canvas;canvas=doc.createElement("canvas");canvas.width=paper.width;canvas.height=paper.height;(0,_libSvgToCanvas.drawSvgOnCanvas)({svg:svgForClientSideExport,canvas:canvas,x:0,y:0,width:paper.width,height:paper.height,useCanvas:useCanvas},(function(){switch(type){case _exportUtils.EXPORTFORMAT.PNG:callback(type,canvas.toDataURL("image/png"),exportFileName,exportOptions);break;case _exportUtils.EXPORTFORMAT.JPEG:callback(type,canvas.toDataURL("image/jpeg"),exportFileName,exportOptions);break;case _exportUtils.EXPORTFORMAT.PDF:callback(type,canvas.toDataURL("image/jpeg"),exportFileName,exportOptions);break;default:callback(type,canvas.toDataURL("image/jpeg"),exportFileName,exportOptions);break}}))},prepareClientSideDownload=function prepareClientSideDownload(exportFrmt,userImageUrl,exprtFileName,downloadOptions,mode){var imageUrl=userImageUrl;if(exportFrmt===_exportUtils.EXPORTFORMAT.PDF){(0,_jpegToPdf.addImage)(imageUrl,paper.height,paper.width);imageUrl=(0,_jpegToPdf.getDataUrl)()}if(mode===_exportUtils.EXPORTMODE.AUTO){postData=createPostDataForExport(IMAGEDATA,imageUrl)}else{postData=null}(0,_libSvgToCanvas.downloadCharts)("url",imageUrl,exprtFileName+"."+exportFrmt,postData,downloadOptions)},saveAfterProcessingAtClientSide=function saveAfterProcessingAtClientSide(svgToExport,exportOptions,callback){var svgDataURI,callbackModified;if(exportFormat===_exportUtils.EXPORTFORMAT.SVG){svgDataURI=(0,_exportUtils.svgStrToDataUrl)(svgToExport);callback(svgDataURI,exportOptions)}else{callbackModified=function callbackModified(){callback(arguments[1],exportOptions)};getImageDataUrl(exportFormat,callbackModified,exportOptions)}},exportAtClientSide=function exportAtClientSide(svgToBeExported,exportOptions,mode){var svgDataURI,prepareClientSideDownloadModified;if(exportFormat===_exportUtils.EXPORTFORMAT.SVG){svgDataURI=(0,_exportUtils.svgStrToDataUrl)(svgToBeExported);if(mode===_exportUtils.EXPORTMODE.AUTO){postData=createPostDataForExport(IMAGEDATA,svgDataURI)}else{postData=null}(0,_libSvgToCanvas.downloadCharts)("url",svgDataURI,exportFileName+"."+exportFormat,postData,exportOptions)}else{prepareClientSideDownloadModified=function prepareClientSideDownloadModified(){prepareClientSideDownload(arguments[0],arguments[1],arguments[2],arguments[3],mode)};getImageDataUrl(exportFormat,prepareClientSideDownloadModified,exportOptions)}},createXlsArr=function createXlsArr(){var count=0;xlsArr=[];csv.replace(/[^\r\n]+/g,(function(match){xlsArr[count]=[];xlsArr[count]=match.split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/).map((function(x){return x.replace(/"/g,_lib.BLANKSTRING)}));count+=1}))},getExcelData=function getExcelData(){var base64=function base64(s){return win.btoa(win.unescape(encodeURIComponent(s)))},uri="data:application/vnd.ms-excel;base64,";var getData=function getData(){var tags,thead,tbody,i,j,length,len;if(!xlsArr.length){return""}tags="<table align='center' >";for(i=0,len=xlsArr.length;i<len;i+=1){if(i===0){thead="<thead valign='top'><tr>";for(j=0,length=xlsArr[i].length;j<length;j+=1){thead+="<th>"+xlsArr[i][j]+"</th>"}thead+="</tr></thead>";tbody="<tbody>"}else{tbody+="<tr>";for(j=0,length=xlsArr[i].length;j<length;j+=1){tbody+="<td>"+xlsArr[i][j]+"</td>"}tbody+="</tr>"}}tbody+="</tbody>";return tags+thead+tbody+"</table>"};return uri+base64("<html xmlns:o='urn:schemas-microsoft-com:office:office'"+"xmlns:x='urn:schemas-microsoft-com:office:excel'"+"xmlns='http://www.w3.org/TR/REC-html40'><head>\x3c!--[if gte mso 9]><xml>"+"<x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name>"+"<x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet>"+"</x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--\x3e</head><body>"+getData()+"</body></html>")},raiseEventExportDataReady=fireExportDataReadyEventOnChart,logSeparatelyIfLogModeCLient=function logSeparatelyIfLogModeCLient(mode){if(mode===_exportUtils.LOGMODE.CLIENT){(0,_exportUtils.logCharts)(createPostDataForLog(),exportOptionObject)}},handleCSVandXLSXexport=function handleCSVandXLSXexport(uri,encodeStr){browserCanSelfDownload=typeof win.btoa!=="undefined"&&(_libSvgToCanvas.browserDetails.name==="Chrome"||_libSvgToCanvas.browserDetails.name==="Firefox"||_libSvgToCanvas.browserDetails.name==="Safari"||_libSvgToCanvas.browserDetails.name==="Edge"||_libSvgToCanvas.browserDetails.name==="ie");if(exportMode!=="server"&&browserCanSelfDownload){if(exportAction===_exportUtils.EXPORTACTION.DOWNLOAD||exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){if(exportFormat==="xlsx"||exportFormat==="csv"){(0,_libSvgToCanvas.downloadCharts)("blob",uri,exportFileName+"."+exportFormat,null,exportOptionObject)}else if(exportFormat==="xls"){var excelUri=getExcelData();(0,_libSvgToCanvas.downloadCharts)("url",excelUri,exportFileName+"."+exportFormat,null,exportOptionObject)}chart.fireChartInstanceEvent("exported",clientSideExportedEventsParam)}if(exportAction===_exportUtils.EXPORTACTION.SAVE||exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){configuredExportAction=exportAction;if(exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){exportAction=_exportUtils.EXPORTACTION.SAVE}postData=createPostDataForExport(IMAGEDATA,uri,configuredExportAction);(0,_libSvgToCanvas.downloadCharts)(null,null,null,postData,exportOptionObject);logSeparatelyIfLogModeCLient(logMode)}else if(logMode!==_exportUtils.LOGMODE.SERVER){(0,_exportUtils.logCharts)(createPostDataForLog(),exportOptionObject)}}else{var fileReader=new FileReader;fileReader.onload=function serverSideExport(e){var tempUintArrayStr=_lib.BLANKSTRING,bytes=new Uint8Array(e.target.result),length=bytes.byteLength;for(var i=0;i<length;i++){tempUintArrayStr+=String.fromCharCode(bytes[i])}tempUintArrayStr=encodeStr+win.btoa(tempUintArrayStr);(0,_libSvgToCanvas.downloadCharts)(null,null,null,createPostDataForExport(IMAGEDATA,tempUintArrayStr),exportOptionObject);logSeparatelyIfLogModeCLient(logMode)};fileReader.readAsArrayBuffer(uri)}},browserCanSelfDownload,configuredExportAction,exportJSONtoEXCEL,dontCacheImages;if(exportFormat==="xlsx"||exportFormat==="xls"){if(typeof win.btoa!=="undefined"){csv=chartInstance.getCSVData()}else{chart.fireChartInstanceEvent("exportCancelled",optionsExport);return false}raiseEventExportDataReady();createXlsArr();exportJSONtoEXCEL=(0,_index2.getDep)("ExcelExport");exportJSONtoEXCEL&&exportJSONtoEXCEL(xlsArr).then((function(content){handleCSVandXLSXexport(content,"data:application/vnd.ms-excel;base64,")}))}else if(exportFormat==="csv"){if(typeof win.btoa!=="undefined"){csv=chartInstance.getCSVData()}else{chart.fireChartInstanceEvent("exportCancelled",optionsExport);return false}raiseEventExportDataReady();csvUri=new Blob([csv],{type:"text/csv;base64;"});handleCSVandXLSXexport(csvUri,"data:text/csv;base64,")}else{containerGroup=hamBurger.getChild("listContainer").getLinkedParent().getGraphicalElement("button","button");containerGroup&&containerGroup.attr("visibility","hidden");svg=paper.toSVG(exportWithImages);svgForClientSideExport=paper.toSVG(exportWithImages&&(0,_libSvgToCanvas.isCanvasElemSupported)());svgForClientSideExport=svgForClientSideExport.replace(/ /gi," ");containerGroup&&containerGroup.attr("visibility","visible");svg=svg.replace(/(\sd\s*=\s*["'])[M\s\d\.]*(["'])/gi,"$1M 0 0 L 0 0$2");svg=svg.replace(/NS\d+:/gi,"xlink:");svg=svg.replace(/ /gi," ");svgForClientSideExport=svgForClientSideExport.replace(/NS\d+:/gi,"xlink:");svgForClientSideExport=svgForClientSideExport.replace(/(\sd\s*=\s*["'])[M\s\d\.]*(["'])/gi,"$1M 0 0 L 0 0$2");svgForClientSideExport=svgForClientSideExport.replace(/(xlink:title\s*=\s*)['"].*?["']/gi,"");svg=svg.replace(/[\w\-]+\=\"undefined\"/gi,"");svg=svg.replace(/(xlink:title\s*=\s*)['"].*?["']/gi,"");svg=svg.replace(/rgba\(([^\)]+)\)/gi,(function(RGBStr){return"#"+new _lib.RGBtoHex(RGBStr.split(","))}));svg=svg.replace(/<svg[^>]+/i,(function(svgString){var str=svgString;if(!str.match(/height/i)&&(paper.height||self.config.chartConfig.height)){str+=' height="'+(paper.height||self.config.chartConfig.height)+'"'}if(!str.match(/width/i)&&(paper.width||self.config.chartConfig.width)){str+=' width="'+(paper.width||self.config.chartConfig.width)+'"'}return str}));svg=svg.replace(/(([\w]+\-)?opacity\s*=\s*)['"][\d\.]+e[\-\+][\d]+["']/gi,'$1"0.001"');svg=svg.replace(/(([\w]+\-)?opacity\s*:\s*)[\d\.]+e[\-\+][\d]+/gi,"$10.001");svg=svg.replace(/<text[^\>]+/gi,(function(text){var fullText=text;fullText=fullText.replace(/stroke\=[\"\']([a-z0-9\#]+)?[\"\']/gi,"");fullText=fullText.replace(/stroke\s*\:\s*([a-z0-9\#]+)?;?/gi,"");fullText=fullText.replace(/stroke-width\=[\"\']([a-z0-9\#]+)?[\"\']/gi,"");fullText=fullText.replace(/stroke-width\s*\:\s*([a-z0-9\#]+)?;?/gi,"");fullText=fullText.replace(/stroke-opacity\=[\"\']([a-z0-9\#]+)?[\"\']/gi,"");fullText=fullText.replace(/stroke-opacity\s*\:\s*([a-z0-9\#]+)?;?/gi,"");fullText=fullText.replace(/(<text[^\>]+fill\=)([\"\'][^\"\']+[\"\'])([^\>]+)/gi,'$1$2 stroke=$2 stroke-width="0.2"$3');fullText=fullText.replace(/(<text[^\>]+fill-opacity\=)([\"\'][^\"\']+[\"\'])([^\>]+)/gi,"$1$2 stroke-opacity=$2 $3");return fullText}));svg=svg.replace(/<(\b[^<>s\s]+\b)[^\>]+?opacity\s*=\s*['"][^1][^\>]+?(\/>|>[\s\r\n]*?<\/\1>)/gi,(function(fullText,tagName){var recrXCommand=xAttrRegx.exec(fullText)||"",recrYCommand=yAttrRegx.exec(fullText)||"",prop;prop=' opacity="1" stroke-opacity="1" fill="#cccccc" stroke-width="0" r="0" height="0.5" width="0.5" d="M 0 0 L 1 1" />';return fullText+"<"+tagName+recrXCommand+recrYCommand+prop}));svg=(0,_exportUtils.makeImageUrlsAbsolute)(svg);svgForClientSideExport=(0,_exportUtils.makeImageUrlsAbsolute)(svgForClientSideExport);dontCacheImages=exportMode===_exportUtils.EXPORTMODE.SERVER;(0,_exportUtils.cacheAllImages)(svg,dontCacheImages,(function(){postData=createPostDataForExport(_exportUtils.EXPORTFORMAT.SVG,svg);raiseEventExportDataReady(postData);postData=null;var configuredExptAction,canBrowserSelfDownload=typeof win.btoa!=="undefined"&&(_libSvgToCanvas.browserDetails.name==="Chrome"||_libSvgToCanvas.browserDetails.name==="Firefox"||_libSvgToCanvas.browserDetails.name==="Safari"||_libSvgToCanvas.browserDetails.name==="Edge"||_libSvgToCanvas.browserDetails.name==="ie");if((exportMode===_exportUtils.EXPORTMODE.CLIENT||exportMode===_exportUtils.EXPORTMODE.AUTO&&!(0,_exportUtils.hasUndownloadableImage)(svg))&&canBrowserSelfDownload){svgForClientSideExport=(0,_exportUtils.replaceImagesWithNonDataUrl)(svgForClientSideExport);if(exportAction===_exportUtils.EXPORTACTION.DOWNLOAD||exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){exportAtClientSide(svgForClientSideExport,exportOptionObject,exportMode);chart.fireChartInstanceEvent("exported",clientSideExportedEventsParam)}if(exportAction===_exportUtils.EXPORTACTION.SAVE||exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){configuredExptAction=exportAction;if(exportAction===_exportUtils.EXPORTACTION.DOWNLOADSAVE){exportAction=_exportUtils.EXPORTACTION.SAVE}saveAfterProcessingAtClientSide(svgForClientSideExport,exportOptionObject,(function(dataUri,exportOptionObj){postData=createPostDataForExport(IMAGEDATA,dataUri,configuredExptAction);(0,_libSvgToCanvas.downloadCharts)(null,null,null,postData,exportOptionObj);logSeparatelyIfLogModeCLient(logMode)}));chart.fireChartInstanceEvent("exported",clientSideExportedEventsParam)}else if(logMode!==_exportUtils.LOGMODE.SERVER){(0,_exportUtils.logCharts)(createPostDataForLog(),exportOptionObject)}}else if(exportMode===_exportUtils.EXPORTMODE.AUTO){prepareAndExportData(svg);logSeparatelyIfLogModeCLient(logMode)}else if(exportMode===_exportUtils.EXPORTMODE.SERVER){noPrepareAndExportData(svg);logSeparatelyIfLogModeCLient(logMode)}}))}}),(function(){chart.fireChartInstanceEvent("exportCancelled",optionsExport)}))};return ExportModule}(_index.ComponentInterface);