(function(global,base_factory){typeofexports==='object'&&typeofmodule!=='undefined'?base_factory(exports,require('echarts')):typeofdefine==='function'&&define.amd?define(['exports','echarts'],base_factory):(base_factory((global.dataTool={}),global.echarts));}(this,(function(exports,echarts){'use strict';/** * @module zrender/core/util*///用于处理merge时无法遍历Date等对象的问题vararrayProto=Array.prototype;varnativeMap=arrayProto.map;/** * Those data types can be cloned: * Plain object, Array, TypedArray, number, string, null, undefined. * Those data types will be assgined using the orginal data: * BUILTIN_OBJECT * Instance of user defined class will be cloned to a plain object, without * properties in prototype. * Other data types is not supported (not sure what will happen). * * Caution: do not support clone Date, for performance consideration. * (There might be a large number of date in `series.data`). * So date should not be modified in and out of echarts. * * @param {*} source * @return {*} new *//***@memberOfmodule:zrender/core/util*@param{*}target*@param{*}source*@param{boolean}[overwrite=false]*//***@param{Array}targetAndSourcesThefirstitemistarget,andtherestsaresource.*@param{boolean}[overwrite=false]*@return{*}target*//***@param{*}target*@param{*}source*@memberOfmodule:zrender/core/util*//***@param{*}target*@param{*}source*@param{boolean}[overlay=false]*@memberOfmodule:zrender/core/util*//***查询数组中元素的index*@memberOfmodule:zrender/core/util*//***构造类继承关系**@memberOfmodule:zrender/core/util*@param{Function}clazz源类*@param{Function}baseClazz基类*//***@memberOfmodule:zrender/core/util*@param{Object|Function}target*@param{Object|Function}sorce*@param{boolean}overlay*//***Considertypedarray.*@param{Array|TypedArray}data*//***数组或对象遍历*@memberOfmodule:zrender/core/util*@param{Object|Array}obj*@param{Function}cb*@param{*}[context]*//***数组映射*@memberOfmodule:zrender/core/util*@param{Array}obj*@param{Function}cb*@param{*}[context]*@return{Array}*/function map(obj, cb, context) { if (!(obj && cb)) { return; } if (obj.map && obj.map === nativeMap) { return obj.map(cb, context); } else { var result = []; for (var i = 0, len = obj.length; i < len; i++) { result.push(cb.call(context, obj[i], i, obj)); } return result; }}/***@memberOfmodule:zrender/core/util*@param{Array}obj*@param{Function}cb*@param{Object}[memo]*@param{*}[context]*@return{Array}*//***数组过滤*@memberOfmodule:zrender/core/util*@param{Array}obj*@param{Function}cb*@param{*}[context]*@return{Array}*//***数组项查找*@memberOfmodule:zrender/core/util*@param{Array}obj*@param{Function}cb*@param{*}[context]*@return{*}*//***@memberOfmodule:zrender/core/util*@param{Function}func*@param{*}context*@return{Function}*//***@memberOfmodule:zrender/core/util*@param{Function}func*@return{Function}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***@memberOfmodule:zrender/core/util*@param{*}value*@return{boolean}*//***WhetherisexactlyNaN.NoticeisNaN('a')returnstrue.*@param{*}value*@return{boolean}*//***Ifvalue1isnotnull,thenreturnvalue1,otherwisejudgetrestofvalues.*Lowperformance.*@memberOfmodule:zrender/core/util*@return{*}Finalvalue*//***@memberOfmodule:zrender/core/util*@param{Array}arr*@param{number}startIndex*@param{number}endIndex*@return{Array}*//***Normalizecsslikedarrayconfiguration*e.g.*3=>[3,3,3,3]*[4,2]=>[4,2,4,2]*[4,3,2]=>[4,3,2,3]*@param{number|Array.<number>}val*@return{Array.<number>}*//***@memberOfmodule:zrender/core/util*@param{boolean}condition*@param{string}message*//***@memberOfmodule:zrender/core/util*@param{string}strstringtobetrimed*@return{string}trimedstring*//***Setanobjectasprimitivetobeignoredtraversingchildrenincloneormerge*//**LicensedtotheApacheSoftwareFoundation(ASF)underone*ormorecontributorlicenseagreements.SeetheNOTICEfile*distributedwiththisworkforadditionalinformation*regardingcopyrightownership.TheASFlicensesthisfile*toyouundertheApacheLicense,Version2.0(the*"License");youmaynotusethisfileexceptincompliance*withtheLicense.YoumayobtainacopyoftheLicenseat**http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,*softwaredistributedundertheLicenseisdistributedonan*"AS IS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY*KIND,eitherexpressorimplied.SeetheLicenseforthe*specificlanguagegoverningpermissionsandlimitations*undertheLicense.*///GEXFFileParser// http://gexf.net/1.2draft/gexf-12draft-primer.pdffunctionparse(xml){vardoc;if(typeofxml==='string'){varparser=newDOMParser();doc=parser.parseFromString(xml,'text/xml');}else{doc=xml;}if(!doc||doc.getElementsByTagName('parsererror').length){returnnull;}vargexfRoot=getChildByTagName(doc,'gexf');if(!gexfRoot){returnnull;}vargraphRoot=getChildByTagName(gexfRoot,'graph');varattributes=parseAttributes(getChildByTagName(graphRoot,'attributes'));varattributesMap={};for(vari=0;i<attributes.length;i++){attributesMap[attributes[i].id]=attributes[i];}return{nodes:parseNodes(getChildByTagName(graphRoot,'nodes'),attributesMap),links:parseEdges(getChildByTagName(graphRoot,'edges'))};}functionparseAttributes(parent){returnparent?map(getChildrenByTagName(parent,'attribute'),function(attribDom){return{id:getAttr(attribDom,'id'),title:getAttr(attribDom,'title'),type:getAttr(attribDom,'type')};}):[];}functionparseNodes(parent,attributesMap){returnparent?map(getChildrenByTagName(parent,'node'),function(nodeDom){varid=getAttr(nodeDom,'id');varlabel=getAttr(nodeDom,'label');varnode={id:id,name:label,itemStyle:{normal:{}}};varvizSizeDom=getChildByTagName(nodeDom,'viz:size');varvizPosDom=getChildByTagName(nodeDom,'viz:position');varvizColorDom=getChildByTagName(nodeDom,'viz:color');// var vizShapeDom = getChildByTagName(nodeDom, 'viz:shape');varattvaluesDom=getChildByTagName(nodeDom,'attvalues');if(vizSizeDom){node.symbolSize=parseFloat(getAttr(vizSizeDom,'value'));}if(vizPosDom){node.x=parseFloat(getAttr(vizPosDom,'x'));node.y=parseFloat(getAttr(vizPosDom,'y'));// z}if(vizColorDom){node.itemStyle.normal.color='rgb('+[getAttr(vizColorDom,'r')|0,getAttr(vizColorDom,'g')|0,getAttr(vizColorDom,'b')|0].join(',')+')';}// if (vizShapeDom) {// node.shape = getAttr(vizShapeDom, 'shape');// }if(attvaluesDom){varattvalueDomList=getChildrenByTagName(attvaluesDom,'attvalue');node.attributes={};for(varj=0;j<attvalueDomList.length;j++){varattvalueDom=attvalueDomList[j];varattId=getAttr(attvalueDom,'for');varattValue=getAttr(attvalueDom,'value');varattribute=attributesMap[attId];if(attribute){switch(attribute.type){case'integer':case'long':attValue=parseInt(attValue,10);break;case'float':case'double':attValue=parseFloat(attValue);break;case'boolean':attValue=attValue.toLowerCase()=='true';break;default:}node.attributes[attId]=attValue;}}}returnnode;}):[];}functionparseEdges(parent){returnparent?map(getChildrenByTagName(parent,'edge'),function(edgeDom){varid=getAttr(edgeDom,'id');varlabel=getAttr(edgeDom,'label');varsourceId=getAttr(edgeDom,'source');vartargetId=getAttr(edgeDom,'target');varedge={id:id,name:label,source:sourceId,target:targetId,lineStyle:{normal:{}}};varlineStyle=edge.lineStyle.normal;varvizThicknessDom=getChildByTagName(edgeDom,'viz:thickness');varvizColorDom=getChildByTagName(edgeDom,'viz:color');// var vizShapeDom = getChildByTagName(edgeDom, 'viz:shape');if(vizThicknessDom){lineStyle.width=parseFloat(vizThicknessDom.getAttribute('value'));}if(vizColorDom){lineStyle.color='rgb('+[getAttr(vizColorDom,'r')|0,getAttr(vizColorDom,'g')|0,getAttr(vizColorDom,'b')|0].join(',')+')';}// if (vizShapeDom) {// edge.shape = vizShapeDom.getAttribute('shape');// }returnedge;}):[];}functiongetAttr(el,attrName){returnel.getAttribute(attrName);}functiongetChildByTagName(parent,tagName){varnode=parent.firstChild;while(node){if(node.nodeType!=1||node.nodeName.toLowerCase()!=tagName.toLowerCase()){node=node.nextSibling;}else{returnnode;}}returnnull;}functiongetChildrenByTagName(parent,tagName){varnode=parent.firstChild;varchildren=[];while(node){if(node.nodeName.toLowerCase()==tagName.toLowerCase()){children.push(node);}node=node.nextSibling;}returnchildren;}vargexf=(Object.freeze||Object)({parse:parse});/** Licensed to the Apache Software Foundation (ASF) under one* or more contributor license agreements. See the NOTICE file* distributed with this work for additional information* regarding copyright ownership. The ASF licenses this file* to you under the Apache License, Version 2.0 (the* "License"); you may not use this file except in compliance* with the License. You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,*softwaredistributedundertheLicenseisdistributedonan*"AS IS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY*KIND,eitherexpressorimplied.SeetheLicenseforthe*specificlanguagegoverningpermissionsandlimitations*undertheLicense.*//***Linearmappingavaluefromdomaintorange*@memberOfmodule:echarts/util/number*@param{(number|Array.<number>)}val*@param{Array.<number>}domainDomainextentdomain[0]canbebiggerthandomain[1]*@param{Array.<number>}rangeRangeextentrange[0]canbebiggerthanrange[1]*@param{boolean}clamp*@return{(number|Array.<number>}*//***Convertapercentstringtoabsolutenumber.*ReturnsNaNifpercentisnotavalidstringornumber*@memberOfmodule:echarts/util/number*@param{string|number}percent*@param{number}all*@return{number}*//***(1)Fixroundingerroroffloatnumbers.*(2)Supportreturnstringtoavoidscientificnotationlike'3.5e-7'.**@param{number}x*@param{number}[precision]*@param{boolean}[returnStr]*@return{number|string}*/function asc(arr) { arr.sort(function (a, b) { return a - b; }); return arr;}/***Getprecision*@param{number}val*//***@param{string|number}val*@return{number}*//***Minimaldicernibledataprecisioinaccordingtoasinglepixel.**@param{Array.<number>}dataExtent*@param{Array.<number>}pixelExtent*@return{number}precision*//***Getadataofgivenprecision,assuringthesumofpercentages*invalueListis1.*Thelargestremainermethodisused.*https://en.wikipedia.org/wiki/Largest_remainder_method**@param{Array.<number>}valueListalistofalldata*@param{number}idxindexofthedatatobeprocessedinvalueList*@param{number}precisionintegernumbershowingdigitsofprecision*@return{number}percentrangingfrom0to100*///Number.MAX_SAFE_INTEGER,iedonotsupport./***To0-2*PI,consideringnegativeradian.*@param{number}radian*@return{number}*//***@param{type}radian*@return{boolean}*//*eslint-enable*//***@param{string|Date|number}valueThesevaluescanbeaccepted:*+AninstanceofDate,representatimeinitsowntimezone.*+OrstringinasubsetofISO8601,onlyincluding:*+onlyyear,month,date:'2012-03','2012-03-01','2012-03-01 05','2012-03-01 05:06',*+separatedwithTorspace:'2012-03-01T12:22:33.123','2012-03-01 12:22:33.123',*+timezone:'2012-03-01T12:22:33Z','2012-03-01T12:22:33+8000','2012-03-01T12:22:33-05:00',*allofwhichwillbetreatedaslocaltimeiftimezoneisnotspecified*(see<https://momentjs.com/>).*+Orotherstringformat,including(allofwhichwillbetreatedasloacaltime):*'2012','2012-3-1','2012/3/1','2012/03/01',*'2009/6/12 2:00','2009/6/12 2:05:08','2009/6/12 2:05:08.123'*+atimestamp,whichrepresentatimeinUTC.*@return{Date}date*//***Quantityofanumber.e.g.0.1,1,10,100**@param{number}val*@return{number}*//***finda“nice”numberapproximatelyequaltox.Roundthenumberifround=true,*takeceilingifround=false.Theprimaryobservationisthatthe“nicest”*numbersindecimalare1,2,and5,andallpower-of-tenmultiplesofthesenumbers.**See"Nice Numbers for Graph Labels"ofGraphicGems.**@param{number}valNon-negativevalue.*@param{boolean}round*@return{number}*//***BSD3-Clause**Copyright(c)2010-2015,MichaelBostock*Allrightsreserved.**Redistributionanduseinsourceandbinaryforms,withorwithout*modification,arepermittedprovidedthatthefollowingconditionsaremet:***Redistributionsofsourcecodemustretaintheabovecopyrightnotice,this*listofconditionsandthefollowingdisclaimer.***Redistributionsinbinaryformmustreproducetheabovecopyrightnotice,*thislistofconditionsandthefollowingdisclaimerinthedocumentation*and/orothermaterialsprovidedwiththedistribution.***ThenameMichaelBostockmaynotbeusedtoendorseorpromoteproducts*derivedfromthissoftwarewithoutspecificpriorwrittenpermission.**THISSOFTWAREISPROVIDEDBYTHECOPYRIGHTHOLDERSANDCONTRIBUTORS"AS IS"*ANDANYEXPRESSORIMPLIEDWARRANTIES,INCLUDING,BUTNOTLIMITEDTO,THE*IMPLIEDWARRANTIESOFMERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEARE*DISCLAIMED.INNOEVENTSHALLMICHAELBOSTOCKBELIABLEFORANYDIRECT,*INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,ORCONSEQUENTIALDAMAGES(INCLUDING,*BUTNOTLIMITEDTO,PROCUREMENTOFSUBSTITUTEGOODSORSERVICES;LOSSOFUSE,*DATA,ORPROFITS;ORBUSINESSINTERRUPTION)HOWEVERCAUSEDANDONANYTHEORY*OFLIABILITY,WHETHERINCONTRACT,STRICTLIABILITY,ORTORT(INCLUDING*NEGLIGENCEOROTHERWISE)ARISINGINANYWAYOUTOFTHEUSEOFTHISSOFTWARE,*EVENIFADVISEDOFTHEPOSSIBILITYOFSUCHDAMAGE.*//***@see<https://github.com/mbostock/d3/blob/master/src/arrays/quantile.js>*@see<http://en.wikipedia.org/wiki/Quantile>*@param{Array.<number>}ascArr*/function quantile(ascArr, p) { var H = (ascArr.length - 1) * p + 1; var h = Math.floor(H); var v = +ascArr[h - 1]; var e = H - h; return e ? v + e * (ascArr[h] - v) : v;}/***Orderintervalsasc,andsplitthemwhenoverlap.*expect(numberUtil.reformIntervals([*{interval:[18,62],close:[1,1]},*{interval:[-Infinity,-70],close:[0,0]},*{interval:[-70,-26],close:[1,1]},*{interval:[-26,18],close:[1,1]},*{interval:[62,150],close:[1,1]},*{interval:[106,150],close:[1,1]},*{interval:[150,Infinity],close:[0,0]}*])).toEqual([*{interval:[-Infinity,-70],close:[0,0]},*{interval:[-70,-26],close:[1,1]},*{interval:[-26,18],close:[0,1]},*{interval:[18,62],close:[0,1]},*{interval:[62,150],close:[0,1]},*{interval:[150,Infinity],close:[0,0]}*]);*@param{Array.<Object>}list,where`close`meanopenorclose*oftheinterval,andInfinitycanbeused.*@return{Array.<Object>}Theoriginlist,whichhasbeenreformed.*//***parseFloatNaNsnumeric-castfalsepositives(null|true|false|"")*...butmisinterpretsleading-numberstrings,particularlyhexliterals("0x...")*subtractionforcesinfinitiestoNaN**@param{*}v*@return{boolean}*//**LicensedtotheApacheSoftwareFoundation(ASF)underone*ormorecontributorlicenseagreements.SeetheNOTICEfile*distributedwiththisworkforadditionalinformation*regardingcopyrightownership.TheASFlicensesthisfile*toyouundertheApacheLicense,Version2.0(the*"License");youmaynotusethisfileexceptincompliance*withtheLicense.YoumayobtainacopyoftheLicenseat**http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,*softwaredistributedundertheLicenseisdistributedonan*"AS IS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY*KIND,eitherexpressorimplied.SeetheLicenseforthe*specificlanguagegoverningpermissionsandlimitations*undertheLicense.*//***See:*<https://en.wikipedia.org/wiki/Box_plot#cite_note-frigge_hoaglin_iglewicz-2>*<http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html>**Helpermethodforpreparingdata.**@param{Array.<number>}rawDatalike*[*[12,232,443],(rawdatasetforthefirstbox)*[3843,5545,1232],(rawdatatsetforthesecondbox)*...*]*@param{Object}[opt]**@param{(number|string)}[opt.boundIQR=1.5]Datalessthanminboundisoutlier.*default1.5,meansQ1-1.5*(Q3-Q1).*If'none'/0passed,minboundwillnotbeused.*@param{(number|string)}[opt.layout='horizontal']*Boxplotlayout,canbe'horizontal'or'vertical'*@return{Object}{*boxData:Array.<Array.<number>>*outliers:Array.<Array.<number>>*axisData:Array.<string>*}*/var prepareBoxplotData = function (rawData, opt) { opt = opt || []; var boxData = []; var outliers = []; var axisData = []; var boundIQR = opt.boundIQR; var useExtreme = boundIQR === 'none' || boundIQR === 0; for (var i = 0; i < rawData.length; i++) { axisData.push(i + ''); var ascList = asc(rawData[i].slice()); var Q1 = quantile(ascList, 0.25); var Q2 = quantile(ascList, 0.5); var Q3 = quantile(ascList, 0.75); var min = ascList[0]; var max = ascList[ascList.length - 1]; var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1); var low = useExtreme? min : Math.max(min, Q1 - bound); var high = useExtreme? max : Math.min(max, Q3 + bound); boxData.push([low, Q1, Q2, Q3, high]); for (var j = 0; j < ascList.length; j++) { var dataItem = ascList[j]; if (dataItem < low || dataItem > high) { var outlier = [i, dataItem]; opt.layout === 'vertical' && outlier.reverse(); outliers.push(outlier); } } } return { boxData: boxData, outliers: outliers, axisData: axisData };};/**LicensedtotheApacheSoftwareFoundation(ASF)underone*ormorecontributorlicenseagreements.SeetheNOTICEfile*distributedwiththisworkforadditionalinformation*regardingcopyrightownership.TheASFlicensesthisfile*toyouundertheApacheLicense,Version2.0(the*"License");youmaynotusethisfileexceptincompliance*withtheLicense.YoumayobtainacopyoftheLicenseat**http://www.apache.org/licenses/LICENSE-2.0**Unlessrequiredbyapplicablelaworagreedtoinwriting,*softwaredistributedundertheLicenseisdistributedonan*"AS IS"BASIS,WITHOUTWARRANTIESORCONDITIONSOFANY*KIND,eitherexpressorimplied.SeetheLicenseforthe*specificlanguagegoverningpermissionsandlimitations*undertheLicense.*/var version = '1.0.0';//Forbackwardcompatibility,wherethenamespace`dataTool`will// be mounted on `echarts` is the extension `dataTool` is imported.// But the old version of echarts do not have `dataTool` namespace,// so check it before mounting.if(echarts.dataTool){echarts.dataTool.version=version;echarts.dataTool.gexf=gexf;echarts.dataTool.prepareBoxplotData=prepareBoxplotData;}exports.version=version;exports.gexf=gexf;exports.prepareBoxplotData=prepareBoxplotData;})));//# sourceMappingURL=dataTool.js.map