云链智安app
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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707
  1. var __renderjsModules={};
  2. __renderjsModules.f9cb76fc = (() => {
  3. var __defProp = Object.defineProperty;
  4. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  5. var __getOwnPropNames = Object.getOwnPropertyNames;
  6. var __hasOwnProp = Object.prototype.hasOwnProperty;
  7. var __export = (target, all) => {
  8. for (var name in all)
  9. __defProp(target, name, { get: all[name], enumerable: true });
  10. };
  11. var __copyProps = (to, from, except, desc) => {
  12. if (from && typeof from === "object" || typeof from === "function") {
  13. for (let key of __getOwnPropNames(from))
  14. if (!__hasOwnProp.call(to, key) && key !== except)
  15. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  16. }
  17. return to;
  18. };
  19. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  20. // <stdin>
  21. var stdin_exports = {};
  22. __export(stdin_exports, {
  23. default: () => stdin_default
  24. });
  25. // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/u-charts.js
  26. var config = {
  27. version: "v2.5.0-20230101",
  28. yAxisWidth: 15,
  29. xAxisHeight: 22,
  30. padding: [10, 10, 10, 10],
  31. rotate: false,
  32. fontSize: 13,
  33. fontColor: "#666666",
  34. dataPointShape: ["circle", "circle", "circle", "circle"],
  35. color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
  36. linearColor: ["#0EE2F8", "#2BDCA8", "#FA7D8D", "#EB88E2", "#2AE3A0", "#0EE2F8", "#EB88E2", "#6773E3", "#F78A85"],
  37. pieChartLinePadding: 15,
  38. pieChartTextPadding: 5,
  39. titleFontSize: 20,
  40. subtitleFontSize: 15,
  41. radarLabelTextMargin: 13
  42. };
  43. var assign = function(target, ...varArgs) {
  44. if (target == null) {
  45. throw new TypeError("[uCharts] Cannot convert undefined or null to object");
  46. }
  47. if (!varArgs || varArgs.length <= 0) {
  48. return target;
  49. }
  50. function deepAssign(obj1, obj2) {
  51. for (let key in obj2) {
  52. obj1[key] = obj1[key] && obj1[key].toString() === "[object Object]" ? deepAssign(obj1[key], obj2[key]) : obj1[key] = obj2[key];
  53. }
  54. return obj1;
  55. }
  56. varArgs.forEach((val) => {
  57. target = deepAssign(target, val);
  58. });
  59. return target;
  60. };
  61. var util = {
  62. toFixed: function toFixed(num, limit) {
  63. limit = limit || 2;
  64. if (this.isFloat(num)) {
  65. num = num.toFixed(limit);
  66. }
  67. return num;
  68. },
  69. isFloat: function isFloat(num) {
  70. return num % 1 !== 0;
  71. },
  72. approximatelyEqual: function approximatelyEqual(num1, num2) {
  73. return Math.abs(num1 - num2) < 1e-10;
  74. },
  75. isSameSign: function isSameSign(num1, num2) {
  76. return Math.abs(num1) === num1 && Math.abs(num2) === num2 || Math.abs(num1) !== num1 && Math.abs(num2) !== num2;
  77. },
  78. isSameXCoordinateArea: function isSameXCoordinateArea(p1, p2) {
  79. return this.isSameSign(p1.x, p2.x);
  80. },
  81. isCollision: function isCollision(obj1, obj2) {
  82. obj1.end = {};
  83. obj1.end.x = obj1.start.x + obj1.width;
  84. obj1.end.y = obj1.start.y - obj1.height;
  85. obj2.end = {};
  86. obj2.end.x = obj2.start.x + obj2.width;
  87. obj2.end.y = obj2.start.y - obj2.height;
  88. var flag = obj2.start.x > obj1.end.x || obj2.end.x < obj1.start.x || obj2.end.y > obj1.start.y || obj2.start.y < obj1.end.y;
  89. return !flag;
  90. }
  91. };
  92. function hexToRgb(hexValue, opc) {
  93. var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
  94. var hex = hexValue.replace(rgx, function(m, r2, g2, b2) {
  95. return r2 + r2 + g2 + g2 + b2 + b2;
  96. });
  97. var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
  98. var r = parseInt(rgb[1], 16);
  99. var g = parseInt(rgb[2], 16);
  100. var b = parseInt(rgb[3], 16);
  101. return "rgba(" + r + "," + g + "," + b + "," + opc + ")";
  102. }
  103. function findRange(num, type, limit) {
  104. if (isNaN(num)) {
  105. throw new Error("[uCharts] series\u6570\u636E\u9700\u4E3ANumber\u683C\u5F0F");
  106. }
  107. limit = limit || 10;
  108. type = type ? type : "upper";
  109. var multiple = 1;
  110. while (limit < 1) {
  111. limit *= 10;
  112. multiple *= 10;
  113. }
  114. if (type === "upper") {
  115. num = Math.ceil(num * multiple);
  116. } else {
  117. num = Math.floor(num * multiple);
  118. }
  119. while (num % limit !== 0) {
  120. if (type === "upper") {
  121. if (num == num + 1) {
  122. break;
  123. }
  124. num++;
  125. } else {
  126. num--;
  127. }
  128. }
  129. return num / multiple;
  130. }
  131. function calCandleMA(dayArr, nameArr, colorArr, kdata) {
  132. let seriesTemp = [];
  133. for (let k = 0; k < dayArr.length; k++) {
  134. let seriesItem = {
  135. data: [],
  136. name: nameArr[k],
  137. color: colorArr[k]
  138. };
  139. for (let i = 0, len = kdata.length; i < len; i++) {
  140. if (i < dayArr[k]) {
  141. seriesItem.data.push(null);
  142. continue;
  143. }
  144. let sum = 0;
  145. for (let j = 0; j < dayArr[k]; j++) {
  146. sum += kdata[i - j][1];
  147. }
  148. seriesItem.data.push(+(sum / dayArr[k]).toFixed(3));
  149. }
  150. seriesTemp.push(seriesItem);
  151. }
  152. return seriesTemp;
  153. }
  154. function calValidDistance(self, distance, chartData, config2, opts) {
  155. var dataChartAreaWidth = opts.width - opts.area[1] - opts.area[3];
  156. var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length - 1);
  157. if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
  158. if (opts.extra.mount.widthRatio > 2)
  159. opts.extra.mount.widthRatio = 2;
  160. dataChartWidth += (opts.extra.mount.widthRatio - 1) * chartData.eachSpacing;
  161. }
  162. var validDistance = distance;
  163. if (distance >= 0) {
  164. validDistance = 0;
  165. self.uevent.trigger("scrollLeft");
  166. self.scrollOption.position = "left";
  167. opts.xAxis.scrollPosition = "left";
  168. } else if (Math.abs(distance) >= dataChartWidth - dataChartAreaWidth) {
  169. validDistance = dataChartAreaWidth - dataChartWidth;
  170. self.uevent.trigger("scrollRight");
  171. self.scrollOption.position = "right";
  172. opts.xAxis.scrollPosition = "right";
  173. } else {
  174. self.scrollOption.position = distance;
  175. opts.xAxis.scrollPosition = distance;
  176. }
  177. return validDistance;
  178. }
  179. function isInAngleRange(angle, startAngle, endAngle) {
  180. function adjust(angle2) {
  181. while (angle2 < 0) {
  182. angle2 += 2 * Math.PI;
  183. }
  184. while (angle2 > 2 * Math.PI) {
  185. angle2 -= 2 * Math.PI;
  186. }
  187. return angle2;
  188. }
  189. angle = adjust(angle);
  190. startAngle = adjust(startAngle);
  191. endAngle = adjust(endAngle);
  192. if (startAngle > endAngle) {
  193. endAngle += 2 * Math.PI;
  194. if (angle < startAngle) {
  195. angle += 2 * Math.PI;
  196. }
  197. }
  198. return angle >= startAngle && angle <= endAngle;
  199. }
  200. function createCurveControlPoints(points, i) {
  201. function isNotMiddlePoint(points2, i2) {
  202. if (points2[i2 - 1] && points2[i2 + 1]) {
  203. return points2[i2].y >= Math.max(points2[i2 - 1].y, points2[i2 + 1].y) || points2[i2].y <= Math.min(
  204. points2[i2 - 1].y,
  205. points2[i2 + 1].y
  206. );
  207. } else {
  208. return false;
  209. }
  210. }
  211. function isNotMiddlePointX(points2, i2) {
  212. if (points2[i2 - 1] && points2[i2 + 1]) {
  213. return points2[i2].x >= Math.max(points2[i2 - 1].x, points2[i2 + 1].x) || points2[i2].x <= Math.min(
  214. points2[i2 - 1].x,
  215. points2[i2 + 1].x
  216. );
  217. } else {
  218. return false;
  219. }
  220. }
  221. var a = 0.2;
  222. var b = 0.2;
  223. var pAx = null;
  224. var pAy = null;
  225. var pBx = null;
  226. var pBy = null;
  227. if (i < 1) {
  228. pAx = points[0].x + (points[1].x - points[0].x) * a;
  229. pAy = points[0].y + (points[1].y - points[0].y) * a;
  230. } else {
  231. pAx = points[i].x + (points[i + 1].x - points[i - 1].x) * a;
  232. pAy = points[i].y + (points[i + 1].y - points[i - 1].y) * a;
  233. }
  234. if (i > points.length - 3) {
  235. var last = points.length - 1;
  236. pBx = points[last].x - (points[last].x - points[last - 1].x) * b;
  237. pBy = points[last].y - (points[last].y - points[last - 1].y) * b;
  238. } else {
  239. pBx = points[i + 1].x - (points[i + 2].x - points[i].x) * b;
  240. pBy = points[i + 1].y - (points[i + 2].y - points[i].y) * b;
  241. }
  242. if (isNotMiddlePoint(points, i + 1)) {
  243. pBy = points[i + 1].y;
  244. }
  245. if (isNotMiddlePoint(points, i)) {
  246. pAy = points[i].y;
  247. }
  248. if (isNotMiddlePointX(points, i + 1)) {
  249. pBx = points[i + 1].x;
  250. }
  251. if (isNotMiddlePointX(points, i)) {
  252. pAx = points[i].x;
  253. }
  254. if (pAy >= Math.max(points[i].y, points[i + 1].y) || pAy <= Math.min(points[i].y, points[i + 1].y)) {
  255. pAy = points[i].y;
  256. }
  257. if (pBy >= Math.max(points[i].y, points[i + 1].y) || pBy <= Math.min(points[i].y, points[i + 1].y)) {
  258. pBy = points[i + 1].y;
  259. }
  260. if (pAx >= Math.max(points[i].x, points[i + 1].x) || pAx <= Math.min(points[i].x, points[i + 1].x)) {
  261. pAx = points[i].x;
  262. }
  263. if (pBx >= Math.max(points[i].x, points[i + 1].x) || pBx <= Math.min(points[i].x, points[i + 1].x)) {
  264. pBx = points[i + 1].x;
  265. }
  266. return {
  267. ctrA: {
  268. x: pAx,
  269. y: pAy
  270. },
  271. ctrB: {
  272. x: pBx,
  273. y: pBy
  274. }
  275. };
  276. }
  277. function convertCoordinateOrigin(x, y, center) {
  278. return {
  279. x: center.x + x,
  280. y: center.y - y
  281. };
  282. }
  283. function avoidCollision(obj, target) {
  284. if (target) {
  285. while (util.isCollision(obj, target)) {
  286. if (obj.start.x > 0) {
  287. obj.start.y--;
  288. } else if (obj.start.x < 0) {
  289. obj.start.y++;
  290. } else {
  291. if (obj.start.y > 0) {
  292. obj.start.y++;
  293. } else {
  294. obj.start.y--;
  295. }
  296. }
  297. }
  298. }
  299. return obj;
  300. }
  301. function fixPieSeries(series, opts, config2) {
  302. let pieSeriesArr = [];
  303. if (series.length > 0 && series[0].data.constructor.toString().indexOf("Array") > -1) {
  304. opts._pieSeries_ = series;
  305. let oldseries = series[0].data;
  306. for (var i = 0; i < oldseries.length; i++) {
  307. oldseries[i].formatter = series[0].formatter;
  308. oldseries[i].data = oldseries[i].value;
  309. pieSeriesArr.push(oldseries[i]);
  310. }
  311. opts.series = pieSeriesArr;
  312. } else {
  313. pieSeriesArr = series;
  314. }
  315. return pieSeriesArr;
  316. }
  317. function fillSeries(series, opts, config2) {
  318. var index = 0;
  319. for (var i = 0; i < series.length; i++) {
  320. let item = series[i];
  321. if (!item.color) {
  322. item.color = config2.color[index];
  323. index = (index + 1) % config2.color.length;
  324. }
  325. if (!item.linearIndex) {
  326. item.linearIndex = i;
  327. }
  328. if (!item.index) {
  329. item.index = 0;
  330. }
  331. if (!item.type) {
  332. item.type = opts.type;
  333. }
  334. if (typeof item.show == "undefined") {
  335. item.show = true;
  336. }
  337. if (!item.type) {
  338. item.type = opts.type;
  339. }
  340. if (!item.pointShape) {
  341. item.pointShape = "circle";
  342. }
  343. if (!item.legendShape) {
  344. switch (item.type) {
  345. case "line":
  346. item.legendShape = "line";
  347. break;
  348. case "column":
  349. case "bar":
  350. item.legendShape = "rect";
  351. break;
  352. case "area":
  353. case "mount":
  354. item.legendShape = "triangle";
  355. break;
  356. default:
  357. item.legendShape = "circle";
  358. }
  359. }
  360. }
  361. return series;
  362. }
  363. function fillCustomColor(linearType, customColor, series, config2) {
  364. var newcolor = customColor || [];
  365. if (linearType == "custom" && newcolor.length == 0) {
  366. newcolor = config2.linearColor;
  367. }
  368. if (linearType == "custom" && newcolor.length < series.length) {
  369. let chazhi = series.length - newcolor.length;
  370. for (var i = 0; i < chazhi; i++) {
  371. newcolor.push(config2.linearColor[(i + 1) % config2.linearColor.length]);
  372. }
  373. }
  374. return newcolor;
  375. }
  376. function getDataRange(minData, maxData) {
  377. var limit = 0;
  378. var range = maxData - minData;
  379. if (range >= 1e4) {
  380. limit = 1e3;
  381. } else if (range >= 1e3) {
  382. limit = 100;
  383. } else if (range >= 100) {
  384. limit = 10;
  385. } else if (range >= 10) {
  386. limit = 5;
  387. } else if (range >= 1) {
  388. limit = 1;
  389. } else if (range >= 0.1) {
  390. limit = 0.1;
  391. } else if (range >= 0.01) {
  392. limit = 0.01;
  393. } else if (range >= 1e-3) {
  394. limit = 1e-3;
  395. } else if (range >= 1e-4) {
  396. limit = 1e-4;
  397. } else if (range >= 1e-5) {
  398. limit = 1e-5;
  399. } else {
  400. limit = 1e-6;
  401. }
  402. return {
  403. minRange: findRange(minData, "lower", limit),
  404. maxRange: findRange(maxData, "upper", limit)
  405. };
  406. }
  407. function measureText(text, fontSize, context) {
  408. var width = 0;
  409. text = String(text);
  410. context = false;
  411. if (context !== false && context !== void 0 && context.setFontSize && context.measureText) {
  412. context.setFontSize(fontSize);
  413. return context.measureText(text).width;
  414. } else {
  415. var text = text.split("");
  416. for (let i = 0; i < text.length; i++) {
  417. let item = text[i];
  418. if (/[a-zA-Z]/.test(item)) {
  419. width += 7;
  420. } else if (/[0-9]/.test(item)) {
  421. width += 5.5;
  422. } else if (/\./.test(item)) {
  423. width += 2.7;
  424. } else if (/-/.test(item)) {
  425. width += 3.25;
  426. } else if (/:/.test(item)) {
  427. width += 2.5;
  428. } else if (/[\u4e00-\u9fa5]/.test(item)) {
  429. width += 10;
  430. } else if (/\(|\)/.test(item)) {
  431. width += 3.73;
  432. } else if (/\s/.test(item)) {
  433. width += 2.5;
  434. } else if (/%/.test(item)) {
  435. width += 8;
  436. } else {
  437. width += 10;
  438. }
  439. }
  440. return width * fontSize / 10;
  441. }
  442. }
  443. function dataCombine(series) {
  444. return series.reduce(function(a, b) {
  445. return (a.data ? a.data : a).concat(b.data);
  446. }, []);
  447. }
  448. function dataCombineStack(series, len) {
  449. var sum = new Array(len);
  450. for (var j = 0; j < sum.length; j++) {
  451. sum[j] = 0;
  452. }
  453. for (var i = 0; i < series.length; i++) {
  454. for (var j = 0; j < sum.length; j++) {
  455. sum[j] += series[i].data[j];
  456. }
  457. }
  458. return series.reduce(function(a, b) {
  459. return (a.data ? a.data : a).concat(b.data).concat(sum);
  460. }, []);
  461. }
  462. function getTouches(touches, opts, e) {
  463. let x, y;
  464. if (touches.clientX) {
  465. if (opts.rotate) {
  466. y = opts.height - touches.clientX * opts.pix;
  467. x = (touches.pageY - e.currentTarget.offsetTop - opts.height / opts.pix / 2 * (opts.pix - 1)) * opts.pix;
  468. } else {
  469. x = touches.clientX * opts.pix;
  470. y = (touches.pageY - e.currentTarget.offsetTop - opts.height / opts.pix / 2 * (opts.pix - 1)) * opts.pix;
  471. }
  472. } else {
  473. if (opts.rotate) {
  474. y = opts.height - touches.x * opts.pix;
  475. x = touches.y * opts.pix;
  476. } else {
  477. x = touches.x * opts.pix;
  478. y = touches.y * opts.pix;
  479. }
  480. }
  481. return {
  482. x,
  483. y
  484. };
  485. }
  486. function getSeriesDataItem(series, index, group) {
  487. var data = [];
  488. var newSeries = [];
  489. var indexIsArr = index.constructor.toString().indexOf("Array") > -1;
  490. if (indexIsArr) {
  491. let tempSeries = filterSeries(series);
  492. for (var i = 0; i < group.length; i++) {
  493. newSeries.push(tempSeries[group[i]]);
  494. }
  495. } else {
  496. newSeries = series;
  497. }
  498. ;
  499. for (let i2 = 0; i2 < newSeries.length; i2++) {
  500. let item = newSeries[i2];
  501. let tmpindex = -1;
  502. if (indexIsArr) {
  503. tmpindex = index[i2];
  504. } else {
  505. tmpindex = index;
  506. }
  507. if (item.data[tmpindex] !== null && typeof item.data[tmpindex] !== "undefined" && item.show) {
  508. let seriesItem = {};
  509. seriesItem.color = item.color;
  510. seriesItem.type = item.type;
  511. seriesItem.style = item.style;
  512. seriesItem.pointShape = item.pointShape;
  513. seriesItem.disableLegend = item.disableLegend;
  514. seriesItem.legendShape = item.legendShape;
  515. seriesItem.name = item.name;
  516. seriesItem.show = item.show;
  517. seriesItem.data = item.formatter ? item.formatter(item.data[tmpindex]) : item.data[tmpindex];
  518. data.push(seriesItem);
  519. }
  520. }
  521. return data;
  522. }
  523. function getMaxTextListLength(list, fontSize, context) {
  524. var lengthList = list.map(function(item) {
  525. return measureText(item, fontSize, context);
  526. });
  527. return Math.max.apply(null, lengthList);
  528. }
  529. function getRadarCoordinateSeries(length) {
  530. var eachAngle = 2 * Math.PI / length;
  531. var CoordinateSeries = [];
  532. for (var i = 0; i < length; i++) {
  533. CoordinateSeries.push(eachAngle * i);
  534. }
  535. return CoordinateSeries.map(function(item) {
  536. return -1 * item + Math.PI / 2;
  537. });
  538. }
  539. function getToolTipData(seriesData, opts, index, group, categories) {
  540. var option = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
  541. var calPoints = opts.chartData.calPoints ? opts.chartData.calPoints : [];
  542. let points = {};
  543. if (group.length > 0) {
  544. let filterPoints = [];
  545. for (let i = 0; i < group.length; i++) {
  546. filterPoints.push(calPoints[group[i]]);
  547. }
  548. points = filterPoints[0][index[0]];
  549. } else {
  550. for (let i = 0; i < calPoints.length; i++) {
  551. if (calPoints[i][index]) {
  552. points = calPoints[i][index];
  553. break;
  554. }
  555. }
  556. }
  557. ;
  558. var textList = seriesData.map(function(item) {
  559. let titleText = null;
  560. if (opts.categories && opts.categories.length > 0) {
  561. titleText = categories[index];
  562. }
  563. ;
  564. return {
  565. text: option.formatter ? option.formatter(item, titleText, index, opts) : item.name + ": " + item.data,
  566. color: item.color,
  567. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  568. };
  569. });
  570. var offset = {
  571. x: Math.round(points.x),
  572. y: Math.round(points.y)
  573. };
  574. return {
  575. textList,
  576. offset
  577. };
  578. }
  579. function getMixToolTipData(seriesData, opts, index, categories) {
  580. var option = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {};
  581. var points = opts.chartData.xAxisPoints[index] + opts.chartData.eachSpacing / 2;
  582. var textList = seriesData.map(function(item) {
  583. return {
  584. text: option.formatter ? option.formatter(item, categories[index], index, opts) : item.name + ": " + item.data,
  585. color: item.color,
  586. disableLegend: item.disableLegend ? true : false,
  587. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  588. };
  589. });
  590. textList = textList.filter(function(item) {
  591. if (item.disableLegend !== true) {
  592. return item;
  593. }
  594. });
  595. var offset = {
  596. x: Math.round(points),
  597. y: 0
  598. };
  599. return {
  600. textList,
  601. offset
  602. };
  603. }
  604. function getCandleToolTipData(series, seriesData, opts, index, categories, extra) {
  605. var option = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : {};
  606. var calPoints = opts.chartData.calPoints;
  607. let upColor = extra.color.upFill;
  608. let downColor = extra.color.downFill;
  609. let color3 = [upColor, upColor, downColor, upColor];
  610. var textList = [];
  611. seriesData.map(function(item) {
  612. if (index == 0) {
  613. if (item.data[1] - item.data[0] < 0) {
  614. color3[1] = downColor;
  615. } else {
  616. color3[1] = upColor;
  617. }
  618. } else {
  619. if (item.data[0] < series[index - 1][1]) {
  620. color3[0] = downColor;
  621. }
  622. if (item.data[1] < item.data[0]) {
  623. color3[1] = downColor;
  624. }
  625. if (item.data[2] > series[index - 1][1]) {
  626. color3[2] = upColor;
  627. }
  628. if (item.data[3] < series[index - 1][1]) {
  629. color3[3] = downColor;
  630. }
  631. }
  632. let text1 = {
  633. text: "\u5F00\u76D8\uFF1A" + item.data[0],
  634. color: color3[0],
  635. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  636. };
  637. let text2 = {
  638. text: "\u6536\u76D8\uFF1A" + item.data[1],
  639. color: color3[1],
  640. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  641. };
  642. let text3 = {
  643. text: "\u6700\u4F4E\uFF1A" + item.data[2],
  644. color: color3[2],
  645. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  646. };
  647. let text4 = {
  648. text: "\u6700\u9AD8\uFF1A" + item.data[3],
  649. color: color3[3],
  650. legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
  651. };
  652. textList.push(text1, text2, text3, text4);
  653. });
  654. var validCalPoints = [];
  655. var offset = {
  656. x: 0,
  657. y: 0
  658. };
  659. for (let i = 0; i < calPoints.length; i++) {
  660. let points = calPoints[i];
  661. if (typeof points[index] !== "undefined" && points[index] !== null) {
  662. validCalPoints.push(points[index]);
  663. }
  664. }
  665. offset.x = Math.round(validCalPoints[0][0].x);
  666. return {
  667. textList,
  668. offset
  669. };
  670. }
  671. function filterSeries(series) {
  672. let tempSeries = [];
  673. for (let i = 0; i < series.length; i++) {
  674. if (series[i].show == true) {
  675. tempSeries.push(series[i]);
  676. }
  677. }
  678. return tempSeries;
  679. }
  680. function findCurrentIndex(currentPoints, calPoints, opts, config2) {
  681. var offset = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0;
  682. var current = { index: -1, group: [] };
  683. var spacing = opts.chartData.eachSpacing / 2;
  684. let xAxisPoints = [];
  685. if (calPoints && calPoints.length > 0) {
  686. if (!opts.categories) {
  687. spacing = 0;
  688. } else {
  689. for (let i = 1; i < opts.chartData.xAxisPoints.length; i++) {
  690. xAxisPoints.push(opts.chartData.xAxisPoints[i] - spacing);
  691. }
  692. if ((opts.type == "line" || opts.type == "area") && opts.xAxis.boundaryGap == "justify") {
  693. xAxisPoints = opts.chartData.xAxisPoints;
  694. }
  695. }
  696. if (isInExactChartArea(currentPoints, opts, config2)) {
  697. if (!opts.categories) {
  698. let timePoints = Array(calPoints.length);
  699. for (let i = 0; i < calPoints.length; i++) {
  700. timePoints[i] = Array(calPoints[i].length);
  701. for (let j = 0; j < calPoints[i].length; j++) {
  702. timePoints[i][j] = Math.abs(calPoints[i][j].x - currentPoints.x);
  703. }
  704. }
  705. ;
  706. let pointValue = Array(timePoints.length);
  707. let pointIndex = Array(timePoints.length);
  708. for (let i = 0; i < timePoints.length; i++) {
  709. pointValue[i] = Math.min.apply(null, timePoints[i]);
  710. pointIndex[i] = timePoints[i].indexOf(pointValue[i]);
  711. }
  712. let minValue = Math.min.apply(null, pointValue);
  713. current.index = [];
  714. for (let i = 0; i < pointValue.length; i++) {
  715. if (pointValue[i] == minValue) {
  716. current.group.push(i);
  717. current.index.push(pointIndex[i]);
  718. }
  719. }
  720. ;
  721. } else {
  722. xAxisPoints.forEach(function(item, index) {
  723. if (currentPoints.x + offset + spacing > item) {
  724. current.index = index;
  725. }
  726. });
  727. }
  728. }
  729. }
  730. return current;
  731. }
  732. function findBarChartCurrentIndex(currentPoints, calPoints, opts, config2) {
  733. var offset = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0;
  734. var current = { index: -1, group: [] };
  735. var spacing = opts.chartData.eachSpacing / 2;
  736. let yAxisPoints = opts.chartData.yAxisPoints;
  737. if (calPoints && calPoints.length > 0) {
  738. if (isInExactChartArea(currentPoints, opts, config2)) {
  739. yAxisPoints.forEach(function(item, index) {
  740. if (currentPoints.y + offset + spacing > item) {
  741. current.index = index;
  742. }
  743. });
  744. }
  745. }
  746. return current;
  747. }
  748. function findLegendIndex(currentPoints, legendData, opts) {
  749. let currentIndex = -1;
  750. let gap = 0;
  751. if (isInExactLegendArea(currentPoints, legendData.area)) {
  752. let points = legendData.points;
  753. let index = -1;
  754. for (let i = 0, len = points.length; i < len; i++) {
  755. let item = points[i];
  756. for (let j = 0; j < item.length; j++) {
  757. index += 1;
  758. let area = item[j]["area"];
  759. if (area && currentPoints.x > area[0] - gap && currentPoints.x < area[2] + gap && currentPoints.y > area[1] - gap && currentPoints.y < area[3] + gap) {
  760. currentIndex = index;
  761. break;
  762. }
  763. }
  764. }
  765. return currentIndex;
  766. }
  767. return currentIndex;
  768. }
  769. function isInExactLegendArea(currentPoints, area) {
  770. return currentPoints.x > area.start.x && currentPoints.x < area.end.x && currentPoints.y > area.start.y && currentPoints.y < area.end.y;
  771. }
  772. function isInExactChartArea(currentPoints, opts, config2) {
  773. return currentPoints.x <= opts.width - opts.area[1] + 10 && currentPoints.x >= opts.area[3] - 10 && currentPoints.y >= opts.area[0] && currentPoints.y <= opts.height - opts.area[2];
  774. }
  775. function findRadarChartCurrentIndex(currentPoints, radarData, count) {
  776. var eachAngleArea = 2 * Math.PI / count;
  777. var currentIndex = -1;
  778. if (isInExactPieChartArea(currentPoints, radarData.center, radarData.radius)) {
  779. var fixAngle = function fixAngle2(angle2) {
  780. if (angle2 < 0) {
  781. angle2 += 2 * Math.PI;
  782. }
  783. if (angle2 > 2 * Math.PI) {
  784. angle2 -= 2 * Math.PI;
  785. }
  786. return angle2;
  787. };
  788. var angle = Math.atan2(radarData.center.y - currentPoints.y, currentPoints.x - radarData.center.x);
  789. angle = -1 * angle;
  790. if (angle < 0) {
  791. angle += 2 * Math.PI;
  792. }
  793. var angleList = radarData.angleList.map(function(item) {
  794. item = fixAngle(-1 * item);
  795. return item;
  796. });
  797. angleList.forEach(function(item, index) {
  798. var rangeStart = fixAngle(item - eachAngleArea / 2);
  799. var rangeEnd = fixAngle(item + eachAngleArea / 2);
  800. if (rangeEnd < rangeStart) {
  801. rangeEnd += 2 * Math.PI;
  802. }
  803. if (angle >= rangeStart && angle <= rangeEnd || angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <= rangeEnd) {
  804. currentIndex = index;
  805. }
  806. });
  807. }
  808. return currentIndex;
  809. }
  810. function findFunnelChartCurrentIndex(currentPoints, funnelData) {
  811. var currentIndex = -1;
  812. for (var i = 0, len = funnelData.series.length; i < len; i++) {
  813. var item = funnelData.series[i];
  814. if (currentPoints.x > item.funnelArea[0] && currentPoints.x < item.funnelArea[2] && currentPoints.y > item.funnelArea[1] && currentPoints.y < item.funnelArea[3]) {
  815. currentIndex = i;
  816. break;
  817. }
  818. }
  819. return currentIndex;
  820. }
  821. function findWordChartCurrentIndex(currentPoints, wordData) {
  822. var currentIndex = -1;
  823. for (var i = 0, len = wordData.length; i < len; i++) {
  824. var item = wordData[i];
  825. if (currentPoints.x > item.area[0] && currentPoints.x < item.area[2] && currentPoints.y > item.area[1] && currentPoints.y < item.area[3]) {
  826. currentIndex = i;
  827. break;
  828. }
  829. }
  830. return currentIndex;
  831. }
  832. function findMapChartCurrentIndex(currentPoints, opts) {
  833. var currentIndex = -1;
  834. var cData = opts.chartData.mapData;
  835. var data = opts.series;
  836. var tmp = pointToCoordinate(currentPoints.y, currentPoints.x, cData.bounds, cData.scale, cData.xoffset, cData.yoffset);
  837. var poi = [tmp.x, tmp.y];
  838. for (var i = 0, len = data.length; i < len; i++) {
  839. var item = data[i].geometry.coordinates;
  840. if (isPoiWithinPoly(poi, item, opts.chartData.mapData.mercator)) {
  841. currentIndex = i;
  842. break;
  843. }
  844. }
  845. return currentIndex;
  846. }
  847. function findRoseChartCurrentIndex(currentPoints, pieData, opts) {
  848. var currentIndex = -1;
  849. var series = getRoseDataPoints(opts._series_, opts.extra.rose.type, pieData.radius, pieData.radius);
  850. if (pieData && pieData.center && isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) {
  851. var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x);
  852. angle = -angle;
  853. if (opts.extra.rose && opts.extra.rose.offsetAngle) {
  854. angle = angle - opts.extra.rose.offsetAngle * Math.PI / 180;
  855. }
  856. for (var i = 0, len = series.length; i < len; i++) {
  857. if (isInAngleRange(angle, series[i]._start_, series[i]._start_ + series[i]._rose_proportion_ * 2 * Math.PI)) {
  858. currentIndex = i;
  859. break;
  860. }
  861. }
  862. }
  863. return currentIndex;
  864. }
  865. function findPieChartCurrentIndex(currentPoints, pieData, opts) {
  866. var currentIndex = -1;
  867. var series = getPieDataPoints(pieData.series);
  868. if (pieData && pieData.center && isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) {
  869. var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x);
  870. angle = -angle;
  871. if (opts.extra.pie && opts.extra.pie.offsetAngle) {
  872. angle = angle - opts.extra.pie.offsetAngle * Math.PI / 180;
  873. }
  874. if (opts.extra.ring && opts.extra.ring.offsetAngle) {
  875. angle = angle - opts.extra.ring.offsetAngle * Math.PI / 180;
  876. }
  877. for (var i = 0, len = series.length; i < len; i++) {
  878. if (isInAngleRange(angle, series[i]._start_, series[i]._start_ + series[i]._proportion_ * 2 * Math.PI)) {
  879. currentIndex = i;
  880. break;
  881. }
  882. }
  883. }
  884. return currentIndex;
  885. }
  886. function isInExactPieChartArea(currentPoints, center, radius) {
  887. return Math.pow(currentPoints.x - center.x, 2) + Math.pow(currentPoints.y - center.y, 2) <= Math.pow(radius, 2);
  888. }
  889. function splitPoints(points, eachSeries) {
  890. var newPoints = [];
  891. var items = [];
  892. points.forEach(function(item, index) {
  893. if (eachSeries.connectNulls) {
  894. if (item !== null) {
  895. items.push(item);
  896. }
  897. } else {
  898. if (item !== null) {
  899. items.push(item);
  900. } else {
  901. if (items.length) {
  902. newPoints.push(items);
  903. }
  904. items = [];
  905. }
  906. }
  907. });
  908. if (items.length) {
  909. newPoints.push(items);
  910. }
  911. return newPoints;
  912. }
  913. function calLegendData(series, opts, config2, chartData, context) {
  914. let legendData = {
  915. area: {
  916. start: {
  917. x: 0,
  918. y: 0
  919. },
  920. end: {
  921. x: 0,
  922. y: 0
  923. },
  924. width: 0,
  925. height: 0,
  926. wholeWidth: 0,
  927. wholeHeight: 0
  928. },
  929. points: [],
  930. widthArr: [],
  931. heightArr: []
  932. };
  933. if (opts.legend.show === false) {
  934. chartData.legendData = legendData;
  935. return legendData;
  936. }
  937. let padding = opts.legend.padding * opts.pix;
  938. let margin = opts.legend.margin * opts.pix;
  939. let fontSize = opts.legend.fontSize ? opts.legend.fontSize * opts.pix : config2.fontSize;
  940. let shapeWidth = 15 * opts.pix;
  941. let shapeRight = 5 * opts.pix;
  942. let lineHeight = Math.max(opts.legend.lineHeight * opts.pix, fontSize);
  943. if (opts.legend.position == "top" || opts.legend.position == "bottom") {
  944. let legendList = [];
  945. let widthCount = 0;
  946. let widthCountArr = [];
  947. let currentRow = [];
  948. for (let i = 0; i < series.length; i++) {
  949. let item = series[i];
  950. const legendText = item.legendText ? item.legendText : item.name;
  951. let itemWidth = shapeWidth + shapeRight + measureText(legendText || "undefined", fontSize, context) + opts.legend.itemGap * opts.pix;
  952. if (widthCount + itemWidth > opts.width - opts.area[1] - opts.area[3]) {
  953. legendList.push(currentRow);
  954. widthCountArr.push(widthCount - opts.legend.itemGap * opts.pix);
  955. widthCount = itemWidth;
  956. currentRow = [item];
  957. } else {
  958. widthCount += itemWidth;
  959. currentRow.push(item);
  960. }
  961. }
  962. if (currentRow.length) {
  963. legendList.push(currentRow);
  964. widthCountArr.push(widthCount - opts.legend.itemGap * opts.pix);
  965. legendData.widthArr = widthCountArr;
  966. let legendWidth = Math.max.apply(null, widthCountArr);
  967. switch (opts.legend.float) {
  968. case "left":
  969. legendData.area.start.x = opts.area[3];
  970. legendData.area.end.x = opts.area[3] + legendWidth + 2 * padding;
  971. break;
  972. case "right":
  973. legendData.area.start.x = opts.width - opts.area[1] - legendWidth - 2 * padding;
  974. legendData.area.end.x = opts.width - opts.area[1];
  975. break;
  976. default:
  977. legendData.area.start.x = (opts.width - legendWidth) / 2 - padding;
  978. legendData.area.end.x = (opts.width + legendWidth) / 2 + padding;
  979. }
  980. legendData.area.width = legendWidth + 2 * padding;
  981. legendData.area.wholeWidth = legendWidth + 2 * padding;
  982. legendData.area.height = legendList.length * lineHeight + 2 * padding;
  983. legendData.area.wholeHeight = legendList.length * lineHeight + 2 * padding + 2 * margin;
  984. legendData.points = legendList;
  985. }
  986. } else {
  987. let len = series.length;
  988. let maxHeight = opts.height - opts.area[0] - opts.area[2] - 2 * margin - 2 * padding;
  989. let maxLength = Math.min(Math.floor(maxHeight / lineHeight), len);
  990. legendData.area.height = maxLength * lineHeight + padding * 2;
  991. legendData.area.wholeHeight = maxLength * lineHeight + padding * 2;
  992. switch (opts.legend.float) {
  993. case "top":
  994. legendData.area.start.y = opts.area[0] + margin;
  995. legendData.area.end.y = opts.area[0] + margin + legendData.area.height;
  996. break;
  997. case "bottom":
  998. legendData.area.start.y = opts.height - opts.area[2] - margin - legendData.area.height;
  999. legendData.area.end.y = opts.height - opts.area[2] - margin;
  1000. break;
  1001. default:
  1002. legendData.area.start.y = (opts.height - legendData.area.height) / 2;
  1003. legendData.area.end.y = (opts.height + legendData.area.height) / 2;
  1004. }
  1005. let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor(len / maxLength + 1);
  1006. let currentRow = [];
  1007. for (let i = 0; i < lineNum; i++) {
  1008. let temp = series.slice(i * maxLength, i * maxLength + maxLength);
  1009. currentRow.push(temp);
  1010. }
  1011. legendData.points = currentRow;
  1012. if (currentRow.length) {
  1013. for (let i = 0; i < currentRow.length; i++) {
  1014. let item = currentRow[i];
  1015. let maxWidth = 0;
  1016. for (let j = 0; j < item.length; j++) {
  1017. let itemWidth = shapeWidth + shapeRight + measureText(item[j].name || "undefined", fontSize, context) + opts.legend.itemGap * opts.pix;
  1018. if (itemWidth > maxWidth) {
  1019. maxWidth = itemWidth;
  1020. }
  1021. }
  1022. legendData.widthArr.push(maxWidth);
  1023. legendData.heightArr.push(item.length * lineHeight + padding * 2);
  1024. }
  1025. let legendWidth = 0;
  1026. for (let i = 0; i < legendData.widthArr.length; i++) {
  1027. legendWidth += legendData.widthArr[i];
  1028. }
  1029. legendData.area.width = legendWidth - opts.legend.itemGap * opts.pix + 2 * padding;
  1030. legendData.area.wholeWidth = legendData.area.width + padding;
  1031. }
  1032. }
  1033. switch (opts.legend.position) {
  1034. case "top":
  1035. legendData.area.start.y = opts.area[0] + margin;
  1036. legendData.area.end.y = opts.area[0] + margin + legendData.area.height;
  1037. break;
  1038. case "bottom":
  1039. legendData.area.start.y = opts.height - opts.area[2] - legendData.area.height - margin;
  1040. legendData.area.end.y = opts.height - opts.area[2] - margin;
  1041. break;
  1042. case "left":
  1043. legendData.area.start.x = opts.area[3];
  1044. legendData.area.end.x = opts.area[3] + legendData.area.width;
  1045. break;
  1046. case "right":
  1047. legendData.area.start.x = opts.width - opts.area[1] - legendData.area.width;
  1048. legendData.area.end.x = opts.width - opts.area[1];
  1049. break;
  1050. }
  1051. chartData.legendData = legendData;
  1052. return legendData;
  1053. }
  1054. function calCategoriesData(categories, opts, config2, eachSpacing, context) {
  1055. var result = {
  1056. angle: 0,
  1057. xAxisHeight: opts.xAxis.lineHeight * opts.pix + opts.xAxis.marginTop * opts.pix
  1058. };
  1059. var fontSize = opts.xAxis.fontSize * opts.pix;
  1060. var categoriesTextLenth = categories.map(function(item, index) {
  1061. var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item, index, opts) : item;
  1062. return measureText(String(xitem), fontSize, context);
  1063. });
  1064. var maxTextLength = Math.max.apply(this, categoriesTextLenth);
  1065. if (opts.xAxis.rotateLabel == true) {
  1066. result.angle = opts.xAxis.rotateAngle * Math.PI / 180;
  1067. let tempHeight = opts.xAxis.marginTop * opts.pix * 2 + Math.abs(maxTextLength * Math.sin(result.angle));
  1068. tempHeight = tempHeight < fontSize + opts.xAxis.marginTop * opts.pix * 2 ? tempHeight + opts.xAxis.marginTop * opts.pix * 2 : tempHeight;
  1069. result.xAxisHeight = tempHeight;
  1070. }
  1071. if (opts.enableScroll && opts.xAxis.scrollShow) {
  1072. result.xAxisHeight += 6 * opts.pix;
  1073. }
  1074. if (opts.xAxis.disabled) {
  1075. result.xAxisHeight = 0;
  1076. }
  1077. return result;
  1078. }
  1079. function getXAxisTextList(series, opts, config2, stack) {
  1080. var index = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
  1081. var data;
  1082. if (stack == "stack") {
  1083. data = dataCombineStack(series, opts.categories.length);
  1084. } else {
  1085. data = dataCombine(series);
  1086. }
  1087. var sorted = [];
  1088. data = data.filter(function(item) {
  1089. if (typeof item === "object" && item !== null) {
  1090. if (item.constructor.toString().indexOf("Array") > -1) {
  1091. return item !== null;
  1092. } else {
  1093. return item.value !== null;
  1094. }
  1095. } else {
  1096. return item !== null;
  1097. }
  1098. });
  1099. data.map(function(item) {
  1100. if (typeof item === "object") {
  1101. if (item.constructor.toString().indexOf("Array") > -1) {
  1102. if (opts.type == "candle") {
  1103. item.map(function(subitem) {
  1104. sorted.push(subitem);
  1105. });
  1106. } else {
  1107. sorted.push(item[0]);
  1108. }
  1109. } else {
  1110. sorted.push(item.value);
  1111. }
  1112. } else {
  1113. sorted.push(item);
  1114. }
  1115. });
  1116. var minData = 0;
  1117. var maxData = 0;
  1118. if (sorted.length > 0) {
  1119. minData = Math.min.apply(this, sorted);
  1120. maxData = Math.max.apply(this, sorted);
  1121. }
  1122. if (index > -1) {
  1123. if (typeof opts.xAxis.data[index].min === "number") {
  1124. minData = Math.min(opts.xAxis.data[index].min, minData);
  1125. }
  1126. if (typeof opts.xAxis.data[index].max === "number") {
  1127. maxData = Math.max(opts.xAxis.data[index].max, maxData);
  1128. }
  1129. } else {
  1130. if (typeof opts.xAxis.min === "number") {
  1131. minData = Math.min(opts.xAxis.min, minData);
  1132. }
  1133. if (typeof opts.xAxis.max === "number") {
  1134. maxData = Math.max(opts.xAxis.max, maxData);
  1135. }
  1136. }
  1137. if (minData === maxData) {
  1138. var rangeSpan = maxData || 10;
  1139. maxData += rangeSpan;
  1140. }
  1141. var minRange = minData;
  1142. var maxRange = maxData;
  1143. var range = [];
  1144. var eachRange = (maxRange - minRange) / opts.xAxis.splitNumber;
  1145. for (var i = 0; i <= opts.xAxis.splitNumber; i++) {
  1146. range.push(minRange + eachRange * i);
  1147. }
  1148. return range;
  1149. }
  1150. function calXAxisData(series, opts, config2, context) {
  1151. var columnstyle = assign({}, {
  1152. type: ""
  1153. }, opts.extra.bar);
  1154. var result = {
  1155. angle: 0,
  1156. xAxisHeight: opts.xAxis.lineHeight * opts.pix + opts.xAxis.marginTop * opts.pix
  1157. };
  1158. result.ranges = getXAxisTextList(series, opts, config2, columnstyle.type);
  1159. result.rangesFormat = result.ranges.map(function(item) {
  1160. item = util.toFixed(item, 2);
  1161. return item;
  1162. });
  1163. var xAxisScaleValues = result.ranges.map(function(item) {
  1164. item = util.toFixed(item, 2);
  1165. return item;
  1166. });
  1167. result = Object.assign(result, getXAxisPoints(xAxisScaleValues, opts, config2));
  1168. var eachSpacing = result.eachSpacing;
  1169. var textLength = xAxisScaleValues.map(function(item) {
  1170. return measureText(item, opts.xAxis.fontSize * opts.pix, context);
  1171. });
  1172. if (opts.xAxis.disabled === true) {
  1173. result.xAxisHeight = 0;
  1174. }
  1175. return result;
  1176. }
  1177. function getRadarDataPoints(angleList, center, radius, series, opts) {
  1178. var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
  1179. var radarOption = opts.extra.radar || {};
  1180. radarOption.max = radarOption.max || 0;
  1181. var maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series)));
  1182. var data = [];
  1183. for (let i = 0; i < series.length; i++) {
  1184. let each = series[i];
  1185. let listItem = {};
  1186. listItem.color = each.color;
  1187. listItem.legendShape = each.legendShape;
  1188. listItem.pointShape = each.pointShape;
  1189. listItem.data = [];
  1190. each.data.forEach(function(item, index) {
  1191. let tmp = {};
  1192. tmp.angle = angleList[index];
  1193. tmp.proportion = item / maxData;
  1194. tmp.value = item;
  1195. tmp.position = convertCoordinateOrigin(radius * tmp.proportion * process * Math.cos(tmp.angle), radius * tmp.proportion * process * Math.sin(tmp.angle), center);
  1196. listItem.data.push(tmp);
  1197. });
  1198. data.push(listItem);
  1199. }
  1200. return data;
  1201. }
  1202. function getPieDataPoints(series, radius) {
  1203. var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
  1204. var count = 0;
  1205. var _start_ = 0;
  1206. for (let i = 0; i < series.length; i++) {
  1207. let item = series[i];
  1208. item.data = item.data === null ? 0 : item.data;
  1209. count += item.data;
  1210. }
  1211. for (let i = 0; i < series.length; i++) {
  1212. let item = series[i];
  1213. item.data = item.data === null ? 0 : item.data;
  1214. if (count === 0) {
  1215. item._proportion_ = 1 / series.length * process;
  1216. } else {
  1217. item._proportion_ = item.data / count * process;
  1218. }
  1219. item._radius_ = radius;
  1220. }
  1221. for (let i = 0; i < series.length; i++) {
  1222. let item = series[i];
  1223. item._start_ = _start_;
  1224. _start_ += 2 * item._proportion_ * Math.PI;
  1225. }
  1226. return series;
  1227. }
  1228. function getFunnelDataPoints(series, radius, option, eachSpacing) {
  1229. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  1230. for (let i = 0; i < series.length; i++) {
  1231. if (option.type == "funnel") {
  1232. series[i].radius = series[i].data / series[0].data * radius * process;
  1233. } else {
  1234. series[i].radius = eachSpacing * (series.length - i) / (eachSpacing * series.length) * radius * process;
  1235. }
  1236. series[i]._proportion_ = series[i].data / series[0].data;
  1237. }
  1238. return series;
  1239. }
  1240. function getRoseDataPoints(series, type, minRadius, radius) {
  1241. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  1242. var count = 0;
  1243. var _start_ = 0;
  1244. var dataArr = [];
  1245. for (let i = 0; i < series.length; i++) {
  1246. let item = series[i];
  1247. item.data = item.data === null ? 0 : item.data;
  1248. count += item.data;
  1249. dataArr.push(item.data);
  1250. }
  1251. var minData = Math.min.apply(null, dataArr);
  1252. var maxData = Math.max.apply(null, dataArr);
  1253. var radiusLength = radius - minRadius;
  1254. for (let i = 0; i < series.length; i++) {
  1255. let item = series[i];
  1256. item.data = item.data === null ? 0 : item.data;
  1257. if (count === 0) {
  1258. item._proportion_ = 1 / series.length * process;
  1259. item._rose_proportion_ = 1 / series.length * process;
  1260. } else {
  1261. item._proportion_ = item.data / count * process;
  1262. if (type == "area") {
  1263. item._rose_proportion_ = 1 / series.length * process;
  1264. } else {
  1265. item._rose_proportion_ = item.data / count * process;
  1266. }
  1267. }
  1268. item._radius_ = minRadius + radiusLength * ((item.data - minData) / (maxData - minData)) || radius;
  1269. }
  1270. for (let i = 0; i < series.length; i++) {
  1271. let item = series[i];
  1272. item._start_ = _start_;
  1273. _start_ += 2 * item._rose_proportion_ * Math.PI;
  1274. }
  1275. return series;
  1276. }
  1277. function getArcbarDataPoints(series, arcbarOption) {
  1278. var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
  1279. if (process == 1) {
  1280. process = 0.999999;
  1281. }
  1282. for (let i = 0; i < series.length; i++) {
  1283. let item = series[i];
  1284. item.data = item.data === null ? 0 : item.data;
  1285. let totalAngle;
  1286. if (arcbarOption.type == "circle") {
  1287. totalAngle = 2;
  1288. } else {
  1289. if (arcbarOption.direction == "ccw") {
  1290. if (arcbarOption.startAngle < arcbarOption.endAngle) {
  1291. totalAngle = 2 + arcbarOption.startAngle - arcbarOption.endAngle;
  1292. } else {
  1293. totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
  1294. }
  1295. } else {
  1296. if (arcbarOption.endAngle < arcbarOption.startAngle) {
  1297. totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
  1298. } else {
  1299. totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
  1300. }
  1301. }
  1302. }
  1303. item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle;
  1304. if (arcbarOption.direction == "ccw") {
  1305. item._proportion_ = arcbarOption.startAngle - totalAngle * item.data * process;
  1306. }
  1307. if (item._proportion_ >= 2) {
  1308. item._proportion_ = item._proportion_ % 2;
  1309. }
  1310. }
  1311. return series;
  1312. }
  1313. function getGaugeArcbarDataPoints(series, arcbarOption) {
  1314. var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
  1315. if (process == 1) {
  1316. process = 0.999999;
  1317. }
  1318. for (let i = 0; i < series.length; i++) {
  1319. let item = series[i];
  1320. item.data = item.data === null ? 0 : item.data;
  1321. let totalAngle;
  1322. if (arcbarOption.type == "circle") {
  1323. totalAngle = 2;
  1324. } else {
  1325. if (arcbarOption.endAngle < arcbarOption.startAngle) {
  1326. totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
  1327. } else {
  1328. totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
  1329. }
  1330. }
  1331. item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle;
  1332. if (item._proportion_ >= 2) {
  1333. item._proportion_ = item._proportion_ % 2;
  1334. }
  1335. }
  1336. return series;
  1337. }
  1338. function getGaugeAxisPoints(categories, startAngle, endAngle) {
  1339. let totalAngle;
  1340. if (endAngle < startAngle) {
  1341. totalAngle = 2 + endAngle - startAngle;
  1342. } else {
  1343. totalAngle = startAngle - endAngle;
  1344. }
  1345. let tempStartAngle = startAngle;
  1346. for (let i = 0; i < categories.length; i++) {
  1347. categories[i].value = categories[i].value === null ? 0 : categories[i].value;
  1348. categories[i]._startAngle_ = tempStartAngle;
  1349. categories[i]._endAngle_ = totalAngle * categories[i].value + startAngle;
  1350. if (categories[i]._endAngle_ >= 2) {
  1351. categories[i]._endAngle_ = categories[i]._endAngle_ % 2;
  1352. }
  1353. tempStartAngle = categories[i]._endAngle_;
  1354. }
  1355. return categories;
  1356. }
  1357. function getGaugeDataPoints(series, categories, gaugeOption) {
  1358. let process = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
  1359. for (let i = 0; i < series.length; i++) {
  1360. let item = series[i];
  1361. item.data = item.data === null ? 0 : item.data;
  1362. if (gaugeOption.pointer.color == "auto") {
  1363. for (let i2 = 0; i2 < categories.length; i2++) {
  1364. if (item.data <= categories[i2].value) {
  1365. item.color = categories[i2].color;
  1366. break;
  1367. }
  1368. }
  1369. } else {
  1370. item.color = gaugeOption.pointer.color;
  1371. }
  1372. let totalAngle;
  1373. if (gaugeOption.endAngle < gaugeOption.startAngle) {
  1374. totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
  1375. } else {
  1376. totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
  1377. }
  1378. item._endAngle_ = totalAngle * item.data + gaugeOption.startAngle;
  1379. item._oldAngle_ = gaugeOption.oldAngle;
  1380. if (gaugeOption.oldAngle < gaugeOption.endAngle) {
  1381. item._oldAngle_ += 2;
  1382. }
  1383. if (item.data >= gaugeOption.oldData) {
  1384. item._proportion_ = (item._endAngle_ - item._oldAngle_) * process + gaugeOption.oldAngle;
  1385. } else {
  1386. item._proportion_ = item._oldAngle_ - (item._oldAngle_ - item._endAngle_) * process;
  1387. }
  1388. if (item._proportion_ >= 2) {
  1389. item._proportion_ = item._proportion_ % 2;
  1390. }
  1391. }
  1392. return series;
  1393. }
  1394. function getPieTextMaxLength(series, config2, context, opts) {
  1395. series = getPieDataPoints(series);
  1396. let maxLength = 0;
  1397. for (let i = 0; i < series.length; i++) {
  1398. let item = series[i];
  1399. let text = item.formatter ? item.formatter(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) + "%";
  1400. maxLength = Math.max(maxLength, measureText(text, item.textSize * opts.pix || config2.fontSize, context));
  1401. }
  1402. return maxLength;
  1403. }
  1404. function fixColumeData(points, eachSpacing, columnLen, index, config2, opts) {
  1405. return points.map(function(item) {
  1406. if (item === null) {
  1407. return null;
  1408. }
  1409. var seriesGap = 0;
  1410. var categoryGap = 0;
  1411. if (opts.type == "mix") {
  1412. seriesGap = opts.extra.mix.column.seriesGap * opts.pix || 0;
  1413. categoryGap = opts.extra.mix.column.categoryGap * opts.pix || 0;
  1414. } else {
  1415. seriesGap = opts.extra.column.seriesGap * opts.pix || 0;
  1416. categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
  1417. }
  1418. seriesGap = Math.min(seriesGap, eachSpacing / columnLen);
  1419. categoryGap = Math.min(categoryGap, eachSpacing / columnLen);
  1420. item.width = Math.ceil((eachSpacing - 2 * categoryGap - seriesGap * (columnLen - 1)) / columnLen);
  1421. if (opts.extra.mix && opts.extra.mix.column.width && +opts.extra.mix.column.width > 0) {
  1422. item.width = Math.min(item.width, +opts.extra.mix.column.width * opts.pix);
  1423. }
  1424. if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
  1425. item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
  1426. }
  1427. if (item.width <= 0) {
  1428. item.width = 1;
  1429. }
  1430. item.x += (index + 0.5 - columnLen / 2) * (item.width + seriesGap);
  1431. return item;
  1432. });
  1433. }
  1434. function fixBarData(points, eachSpacing, columnLen, index, config2, opts) {
  1435. return points.map(function(item) {
  1436. if (item === null) {
  1437. return null;
  1438. }
  1439. var seriesGap = 0;
  1440. var categoryGap = 0;
  1441. seriesGap = opts.extra.bar.seriesGap * opts.pix || 0;
  1442. categoryGap = opts.extra.bar.categoryGap * opts.pix || 0;
  1443. seriesGap = Math.min(seriesGap, eachSpacing / columnLen);
  1444. categoryGap = Math.min(categoryGap, eachSpacing / columnLen);
  1445. item.width = Math.ceil((eachSpacing - 2 * categoryGap - seriesGap * (columnLen - 1)) / columnLen);
  1446. if (opts.extra.bar && opts.extra.bar.width && +opts.extra.bar.width > 0) {
  1447. item.width = Math.min(item.width, +opts.extra.bar.width * opts.pix);
  1448. }
  1449. if (item.width <= 0) {
  1450. item.width = 1;
  1451. }
  1452. item.y += (index + 0.5 - columnLen / 2) * (item.width + seriesGap);
  1453. return item;
  1454. });
  1455. }
  1456. function fixColumeMeterData(points, eachSpacing, columnLen, index, config2, opts, border) {
  1457. var categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
  1458. return points.map(function(item) {
  1459. if (item === null) {
  1460. return null;
  1461. }
  1462. item.width = eachSpacing - 2 * categoryGap;
  1463. if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
  1464. item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
  1465. }
  1466. if (index > 0) {
  1467. item.width -= border;
  1468. }
  1469. return item;
  1470. });
  1471. }
  1472. function fixColumeStackData(points, eachSpacing, columnLen, index, config2, opts, series) {
  1473. var categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
  1474. return points.map(function(item, indexn) {
  1475. if (item === null) {
  1476. return null;
  1477. }
  1478. item.width = Math.ceil(eachSpacing - 2 * categoryGap);
  1479. if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
  1480. item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
  1481. }
  1482. if (item.width <= 0) {
  1483. item.width = 1;
  1484. }
  1485. return item;
  1486. });
  1487. }
  1488. function fixBarStackData(points, eachSpacing, columnLen, index, config2, opts, series) {
  1489. var categoryGap = opts.extra.bar.categoryGap * opts.pix || 0;
  1490. return points.map(function(item, indexn) {
  1491. if (item === null) {
  1492. return null;
  1493. }
  1494. item.width = Math.ceil(eachSpacing - 2 * categoryGap);
  1495. if (opts.extra.bar && opts.extra.bar.width && +opts.extra.bar.width > 0) {
  1496. item.width = Math.min(item.width, +opts.extra.bar.width * opts.pix);
  1497. }
  1498. if (item.width <= 0) {
  1499. item.width = 1;
  1500. }
  1501. return item;
  1502. });
  1503. }
  1504. function getXAxisPoints(categories, opts, config2) {
  1505. var spacingValid = opts.width - opts.area[1] - opts.area[3];
  1506. var dataCount = opts.enableScroll ? Math.min(opts.xAxis.itemCount, categories.length) : categories.length;
  1507. if ((opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble" || opts.type == "bar") && dataCount > 1 && opts.xAxis.boundaryGap == "justify") {
  1508. dataCount -= 1;
  1509. }
  1510. var widthRatio = 0;
  1511. if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
  1512. if (opts.extra.mount.widthRatio > 2)
  1513. opts.extra.mount.widthRatio = 2;
  1514. widthRatio = opts.extra.mount.widthRatio - 1;
  1515. dataCount += widthRatio;
  1516. }
  1517. var eachSpacing = spacingValid / dataCount;
  1518. var xAxisPoints = [];
  1519. var startX = opts.area[3];
  1520. var endX = opts.width - opts.area[1];
  1521. categories.forEach(function(item, index) {
  1522. xAxisPoints.push(startX + widthRatio / 2 * eachSpacing + index * eachSpacing);
  1523. });
  1524. if (opts.xAxis.boundaryGap !== "justify") {
  1525. if (opts.enableScroll === true) {
  1526. xAxisPoints.push(startX + widthRatio * eachSpacing + categories.length * eachSpacing);
  1527. } else {
  1528. xAxisPoints.push(endX);
  1529. }
  1530. }
  1531. return {
  1532. xAxisPoints,
  1533. startX,
  1534. endX,
  1535. eachSpacing
  1536. };
  1537. }
  1538. function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2) {
  1539. var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
  1540. var points = [];
  1541. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1542. data.forEach(function(item, index) {
  1543. if (item === null) {
  1544. points.push(null);
  1545. } else {
  1546. var cPoints = [];
  1547. item.forEach(function(items, indexs) {
  1548. var point = {};
  1549. point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
  1550. var value = items.value || items;
  1551. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1552. height *= process;
  1553. point.y = opts.height - Math.round(height) - opts.area[2];
  1554. cPoints.push(point);
  1555. });
  1556. points.push(cPoints);
  1557. }
  1558. });
  1559. return points;
  1560. }
  1561. function getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2) {
  1562. var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
  1563. var boundaryGap = "center";
  1564. if (opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble") {
  1565. boundaryGap = opts.xAxis.boundaryGap;
  1566. }
  1567. var points = [];
  1568. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1569. var validWidth = opts.width - opts.area[1] - opts.area[3];
  1570. data.forEach(function(item, index) {
  1571. if (item === null) {
  1572. points.push(null);
  1573. } else {
  1574. var point = {};
  1575. point.color = item.color;
  1576. point.x = xAxisPoints[index];
  1577. var value = item;
  1578. if (typeof item === "object" && item !== null) {
  1579. if (item.constructor.toString().indexOf("Array") > -1) {
  1580. let xranges, xminRange, xmaxRange;
  1581. xranges = [].concat(opts.chartData.xAxisData.ranges);
  1582. xminRange = xranges.shift();
  1583. xmaxRange = xranges.pop();
  1584. value = item[1];
  1585. point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
  1586. if (opts.type == "bubble") {
  1587. point.r = item[2];
  1588. point.t = item[3];
  1589. }
  1590. } else {
  1591. value = item.value;
  1592. }
  1593. }
  1594. if (boundaryGap == "center") {
  1595. point.x += eachSpacing / 2;
  1596. }
  1597. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1598. height *= process;
  1599. point.y = opts.height - height - opts.area[2];
  1600. points.push(point);
  1601. }
  1602. });
  1603. return points;
  1604. }
  1605. function getLineDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, lineOption, process) {
  1606. var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
  1607. var boundaryGap = opts.xAxis.boundaryGap;
  1608. var points = [];
  1609. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1610. var validWidth = opts.width - opts.area[1] - opts.area[3];
  1611. data.forEach(function(item, index) {
  1612. if (item === null) {
  1613. points.push(null);
  1614. } else {
  1615. var point = {};
  1616. point.color = item.color;
  1617. if (lineOption.animation == "vertical") {
  1618. point.x = xAxisPoints[index];
  1619. var value = item;
  1620. if (typeof item === "object" && item !== null) {
  1621. if (item.constructor.toString().indexOf("Array") > -1) {
  1622. let xranges, xminRange, xmaxRange;
  1623. xranges = [].concat(opts.chartData.xAxisData.ranges);
  1624. xminRange = xranges.shift();
  1625. xmaxRange = xranges.pop();
  1626. value = item[1];
  1627. point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
  1628. } else {
  1629. value = item.value;
  1630. }
  1631. }
  1632. if (boundaryGap == "center") {
  1633. point.x += eachSpacing / 2;
  1634. }
  1635. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1636. height *= process;
  1637. point.y = opts.height - height - opts.area[2];
  1638. points.push(point);
  1639. } else {
  1640. point.x = xAxisPoints[0] + eachSpacing * index * process;
  1641. var value = item;
  1642. if (boundaryGap == "center") {
  1643. point.x += eachSpacing / 2;
  1644. }
  1645. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1646. point.y = opts.height - height - opts.area[2];
  1647. points.push(point);
  1648. }
  1649. }
  1650. });
  1651. return points;
  1652. }
  1653. function getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, zeroPoints, process) {
  1654. var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
  1655. var points = [];
  1656. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1657. var validWidth = opts.width - opts.area[1] - opts.area[3];
  1658. data.forEach(function(item, index) {
  1659. if (item === null) {
  1660. points.push(null);
  1661. } else {
  1662. var point = {};
  1663. point.color = item.color;
  1664. point.x = xAxisPoints[index];
  1665. var value = item;
  1666. if (typeof item === "object" && item !== null) {
  1667. if (item.constructor.toString().indexOf("Array") > -1) {
  1668. let xranges, xminRange, xmaxRange;
  1669. xranges = [].concat(opts.chartData.xAxisData.ranges);
  1670. xminRange = xranges.shift();
  1671. xmaxRange = xranges.pop();
  1672. value = item[1];
  1673. point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
  1674. } else {
  1675. value = item.value;
  1676. }
  1677. }
  1678. point.x += eachSpacing / 2;
  1679. var height = validHeight * (value * process - minRange) / (maxRange - minRange);
  1680. point.y = opts.height - height - opts.area[2];
  1681. points.push(point);
  1682. }
  1683. });
  1684. return points;
  1685. }
  1686. function getMountDataPoints(series, minRange, maxRange, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints) {
  1687. var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
  1688. var points = [];
  1689. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1690. var validWidth = opts.width - opts.area[1] - opts.area[3];
  1691. var mountWidth = eachSpacing * mountOption.widthRatio;
  1692. series.forEach(function(item, index) {
  1693. if (item === null) {
  1694. points.push(null);
  1695. } else {
  1696. var point = {};
  1697. point.color = item.color;
  1698. point.x = xAxisPoints[index];
  1699. point.x += eachSpacing / 2;
  1700. var value = item.data;
  1701. var height = validHeight * (value * process - minRange) / (maxRange - minRange);
  1702. point.y = opts.height - height - opts.area[2];
  1703. point.value = value;
  1704. point.width = mountWidth;
  1705. points.push(point);
  1706. }
  1707. });
  1708. return points;
  1709. }
  1710. function getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2) {
  1711. var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
  1712. var points = [];
  1713. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1714. var validWidth = opts.width - opts.area[1] - opts.area[3];
  1715. data.forEach(function(item, index) {
  1716. if (item === null) {
  1717. points.push(null);
  1718. } else {
  1719. var point = {};
  1720. point.color = item.color;
  1721. point.y = yAxisPoints[index];
  1722. var value = item;
  1723. if (typeof item === "object" && item !== null) {
  1724. value = item.value;
  1725. }
  1726. var height = validWidth * (value - minRange) / (maxRange - minRange);
  1727. height *= process;
  1728. point.height = height;
  1729. point.value = value;
  1730. point.x = height + opts.area[3];
  1731. points.push(point);
  1732. }
  1733. });
  1734. return points;
  1735. }
  1736. function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, stackSeries) {
  1737. var process = arguments.length > 9 && arguments[9] !== void 0 ? arguments[9] : 1;
  1738. var points = [];
  1739. var validHeight = opts.height - opts.area[0] - opts.area[2];
  1740. data.forEach(function(item, index) {
  1741. if (item === null) {
  1742. points.push(null);
  1743. } else {
  1744. var point = {};
  1745. point.color = item.color;
  1746. point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
  1747. if (seriesIndex > 0) {
  1748. var value = 0;
  1749. for (let i = 0; i <= seriesIndex; i++) {
  1750. value += stackSeries[i].data[index];
  1751. }
  1752. var value0 = value - item;
  1753. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1754. var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
  1755. } else {
  1756. var value = item;
  1757. if (typeof item === "object" && item !== null) {
  1758. value = item.value;
  1759. }
  1760. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1761. var height0 = 0;
  1762. }
  1763. var heightc = height0;
  1764. height *= process;
  1765. heightc *= process;
  1766. point.y = opts.height - Math.round(height) - opts.area[2];
  1767. point.y0 = opts.height - Math.round(heightc) - opts.area[2];
  1768. points.push(point);
  1769. }
  1770. });
  1771. return points;
  1772. }
  1773. function getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, stackSeries) {
  1774. var process = arguments.length > 9 && arguments[9] !== void 0 ? arguments[9] : 1;
  1775. var points = [];
  1776. var validHeight = opts.width - opts.area[1] - opts.area[3];
  1777. data.forEach(function(item, index) {
  1778. if (item === null) {
  1779. points.push(null);
  1780. } else {
  1781. var point = {};
  1782. point.color = item.color;
  1783. point.y = yAxisPoints[index];
  1784. if (seriesIndex > 0) {
  1785. var value = 0;
  1786. for (let i = 0; i <= seriesIndex; i++) {
  1787. value += stackSeries[i].data[index];
  1788. }
  1789. var value0 = value - item;
  1790. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1791. var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
  1792. } else {
  1793. var value = item;
  1794. if (typeof item === "object" && item !== null) {
  1795. value = item.value;
  1796. }
  1797. var height = validHeight * (value - minRange) / (maxRange - minRange);
  1798. var height0 = 0;
  1799. }
  1800. var heightc = height0;
  1801. height *= process;
  1802. heightc *= process;
  1803. point.height = height - heightc;
  1804. point.x = opts.area[3] + height;
  1805. point.x0 = opts.area[3] + heightc;
  1806. points.push(point);
  1807. }
  1808. });
  1809. return points;
  1810. }
  1811. function getYAxisTextList(series, opts, config2, stack, yData) {
  1812. var index = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : -1;
  1813. var data;
  1814. if (stack == "stack") {
  1815. data = dataCombineStack(series, opts.categories.length);
  1816. } else {
  1817. data = dataCombine(series);
  1818. }
  1819. var sorted = [];
  1820. data = data.filter(function(item) {
  1821. if (typeof item === "object" && item !== null) {
  1822. if (item.constructor.toString().indexOf("Array") > -1) {
  1823. return item !== null;
  1824. } else {
  1825. return item.value !== null;
  1826. }
  1827. } else {
  1828. return item !== null;
  1829. }
  1830. });
  1831. data.map(function(item) {
  1832. if (typeof item === "object") {
  1833. if (item.constructor.toString().indexOf("Array") > -1) {
  1834. if (opts.type == "candle") {
  1835. item.map(function(subitem) {
  1836. sorted.push(subitem);
  1837. });
  1838. } else {
  1839. sorted.push(item[1]);
  1840. }
  1841. } else {
  1842. sorted.push(item.value);
  1843. }
  1844. } else {
  1845. sorted.push(item);
  1846. }
  1847. });
  1848. var minData = yData.min || 0;
  1849. var maxData = yData.max || 0;
  1850. if (sorted.length > 0) {
  1851. minData = Math.min.apply(this, sorted);
  1852. maxData = Math.max.apply(this, sorted);
  1853. }
  1854. if (minData === maxData) {
  1855. if (maxData == 0) {
  1856. maxData = 10;
  1857. } else {
  1858. minData = 0;
  1859. }
  1860. }
  1861. var dataRange = getDataRange(minData, maxData);
  1862. var minRange = yData.min === void 0 || yData.min === null ? dataRange.minRange : yData.min;
  1863. var maxRange = yData.max === void 0 || yData.max === null ? dataRange.maxRange : yData.max;
  1864. var eachRange = (maxRange - minRange) / opts.yAxis.splitNumber;
  1865. var range = [];
  1866. for (var i = 0; i <= opts.yAxis.splitNumber; i++) {
  1867. range.push(minRange + eachRange * i);
  1868. }
  1869. return range.reverse();
  1870. }
  1871. function calYAxisData(series, opts, config2, context) {
  1872. var columnstyle = assign({}, {
  1873. type: ""
  1874. }, opts.extra.column);
  1875. var YLength = opts.yAxis.data.length;
  1876. var newSeries = new Array(YLength);
  1877. if (YLength > 0) {
  1878. for (let i = 0; i < YLength; i++) {
  1879. newSeries[i] = [];
  1880. for (let j = 0; j < series.length; j++) {
  1881. if (series[j].index == i) {
  1882. newSeries[i].push(series[j]);
  1883. }
  1884. }
  1885. }
  1886. var rangesArr = new Array(YLength);
  1887. var rangesFormatArr = new Array(YLength);
  1888. var yAxisWidthArr = new Array(YLength);
  1889. for (let i = 0; i < YLength; i++) {
  1890. let yData = opts.yAxis.data[i];
  1891. if (opts.yAxis.disabled == true) {
  1892. yData.disabled = true;
  1893. }
  1894. if (yData.type === "categories") {
  1895. if (!yData.formatter) {
  1896. yData.formatter = (val, index, opts2) => {
  1897. return val + (yData.unit || "");
  1898. };
  1899. }
  1900. yData.categories = yData.categories || opts.categories;
  1901. rangesArr[i] = yData.categories;
  1902. } else {
  1903. if (!yData.formatter) {
  1904. yData.formatter = (val, index, opts2) => {
  1905. return util.toFixed(val, yData.tofix || 0) + (yData.unit || "");
  1906. };
  1907. }
  1908. rangesArr[i] = getYAxisTextList(newSeries[i], opts, config2, columnstyle.type, yData, i);
  1909. }
  1910. let yAxisFontSizes = yData.fontSize * opts.pix || config2.fontSize;
  1911. yAxisWidthArr[i] = {
  1912. position: yData.position ? yData.position : "left",
  1913. width: 0
  1914. };
  1915. rangesFormatArr[i] = rangesArr[i].map(function(items, index) {
  1916. items = yData.formatter(items, index, opts);
  1917. yAxisWidthArr[i].width = Math.max(yAxisWidthArr[i].width, measureText(items, yAxisFontSizes, context) + 5);
  1918. return items;
  1919. });
  1920. let calibration = yData.calibration ? 4 * opts.pix : 0;
  1921. yAxisWidthArr[i].width += calibration + 3 * opts.pix;
  1922. if (yData.disabled === true) {
  1923. yAxisWidthArr[i].width = 0;
  1924. }
  1925. }
  1926. } else {
  1927. var rangesArr = new Array(1);
  1928. var rangesFormatArr = new Array(1);
  1929. var yAxisWidthArr = new Array(1);
  1930. if (opts.type === "bar") {
  1931. rangesArr[0] = opts.categories;
  1932. if (!opts.yAxis.formatter) {
  1933. opts.yAxis.formatter = (val, index, opts2) => {
  1934. return val + (opts2.yAxis.unit || "");
  1935. };
  1936. }
  1937. } else {
  1938. if (!opts.yAxis.formatter) {
  1939. opts.yAxis.formatter = (val, index, opts2) => {
  1940. return val.toFixed(opts2.yAxis.tofix) + (opts2.yAxis.unit || "");
  1941. };
  1942. }
  1943. rangesArr[0] = getYAxisTextList(series, opts, config2, columnstyle.type, {});
  1944. }
  1945. yAxisWidthArr[0] = {
  1946. position: "left",
  1947. width: 0
  1948. };
  1949. var yAxisFontSize = opts.yAxis.fontSize * opts.pix || config2.fontSize;
  1950. rangesFormatArr[0] = rangesArr[0].map(function(item, index) {
  1951. item = opts.yAxis.formatter(item, index, opts);
  1952. yAxisWidthArr[0].width = Math.max(yAxisWidthArr[0].width, measureText(item, yAxisFontSize, context) + 5);
  1953. return item;
  1954. });
  1955. yAxisWidthArr[0].width += 3 * opts.pix;
  1956. if (opts.yAxis.disabled === true) {
  1957. yAxisWidthArr[0] = {
  1958. position: "left",
  1959. width: 0
  1960. };
  1961. opts.yAxis.data[0] = {
  1962. disabled: true
  1963. };
  1964. } else {
  1965. opts.yAxis.data[0] = {
  1966. disabled: false,
  1967. position: "left",
  1968. max: opts.yAxis.max,
  1969. min: opts.yAxis.min,
  1970. formatter: opts.yAxis.formatter
  1971. };
  1972. if (opts.type === "bar") {
  1973. opts.yAxis.data[0].categories = opts.categories;
  1974. opts.yAxis.data[0].type = "categories";
  1975. }
  1976. }
  1977. }
  1978. return {
  1979. rangesFormat: rangesFormatArr,
  1980. ranges: rangesArr,
  1981. yAxisWidth: yAxisWidthArr
  1982. };
  1983. }
  1984. function calTooltipYAxisData(point, series, opts, config2, eachSpacing) {
  1985. let ranges = [].concat(opts.chartData.yAxisData.ranges);
  1986. let spacingValid = opts.height - opts.area[0] - opts.area[2];
  1987. let minAxis = opts.area[0];
  1988. let items = [];
  1989. for (let i = 0; i < ranges.length; i++) {
  1990. let maxVal = Math.max.apply(this, ranges[i]);
  1991. let minVal = Math.min.apply(this, ranges[i]);
  1992. let item = maxVal - (maxVal - minVal) * (point - minAxis) / spacingValid;
  1993. item = opts.yAxis.data && opts.yAxis.data[i].formatter ? opts.yAxis.data[i].formatter(item, i, opts) : item.toFixed(0);
  1994. items.push(String(item));
  1995. }
  1996. return items;
  1997. }
  1998. function calMarkLineData(points, opts) {
  1999. let minRange, maxRange;
  2000. let spacingValid = opts.height - opts.area[0] - opts.area[2];
  2001. for (let i = 0; i < points.length; i++) {
  2002. points[i].yAxisIndex = points[i].yAxisIndex ? points[i].yAxisIndex : 0;
  2003. let range = [].concat(opts.chartData.yAxisData.ranges[points[i].yAxisIndex]);
  2004. minRange = range.pop();
  2005. maxRange = range.shift();
  2006. let height = spacingValid * (points[i].value - minRange) / (maxRange - minRange);
  2007. points[i].y = opts.height - Math.round(height) - opts.area[2];
  2008. }
  2009. return points;
  2010. }
  2011. function contextRotate(context, opts) {
  2012. if (opts.rotateLock !== true) {
  2013. context.translate(opts.height, 0);
  2014. context.rotate(90 * Math.PI / 180);
  2015. } else if (opts._rotate_ !== true) {
  2016. context.translate(opts.height, 0);
  2017. context.rotate(90 * Math.PI / 180);
  2018. opts._rotate_ = true;
  2019. }
  2020. }
  2021. function drawPointShape(points, color3, shape, context, opts) {
  2022. context.beginPath();
  2023. if (opts.dataPointShapeType == "hollow") {
  2024. context.setStrokeStyle(color3);
  2025. context.setFillStyle(opts.background);
  2026. context.setLineWidth(2 * opts.pix);
  2027. } else {
  2028. context.setStrokeStyle("#ffffff");
  2029. context.setFillStyle(color3);
  2030. context.setLineWidth(1 * opts.pix);
  2031. }
  2032. if (shape === "diamond") {
  2033. points.forEach(function(item, index) {
  2034. if (item !== null) {
  2035. context.moveTo(item.x, item.y - 4.5);
  2036. context.lineTo(item.x - 4.5, item.y);
  2037. context.lineTo(item.x, item.y + 4.5);
  2038. context.lineTo(item.x + 4.5, item.y);
  2039. context.lineTo(item.x, item.y - 4.5);
  2040. }
  2041. });
  2042. } else if (shape === "circle") {
  2043. points.forEach(function(item, index) {
  2044. if (item !== null) {
  2045. context.moveTo(item.x + 2.5 * opts.pix, item.y);
  2046. context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
  2047. }
  2048. });
  2049. } else if (shape === "square") {
  2050. points.forEach(function(item, index) {
  2051. if (item !== null) {
  2052. context.moveTo(item.x - 3.5, item.y - 3.5);
  2053. context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
  2054. }
  2055. });
  2056. } else if (shape === "triangle") {
  2057. points.forEach(function(item, index) {
  2058. if (item !== null) {
  2059. context.moveTo(item.x, item.y - 4.5);
  2060. context.lineTo(item.x - 4.5, item.y + 4.5);
  2061. context.lineTo(item.x + 4.5, item.y + 4.5);
  2062. context.lineTo(item.x, item.y - 4.5);
  2063. }
  2064. });
  2065. } else if (shape === "none") {
  2066. return;
  2067. }
  2068. context.closePath();
  2069. context.fill();
  2070. context.stroke();
  2071. }
  2072. function drawActivePoint(points, color3, shape, context, opts, option, seriesIndex) {
  2073. if (!opts.tooltip) {
  2074. return;
  2075. }
  2076. if (opts.tooltip.group.length > 0 && opts.tooltip.group.includes(seriesIndex) == false) {
  2077. return;
  2078. }
  2079. var pointIndex = typeof opts.tooltip.index === "number" ? opts.tooltip.index : opts.tooltip.index[opts.tooltip.group.indexOf(seriesIndex)];
  2080. context.beginPath();
  2081. if (option.activeType == "hollow") {
  2082. context.setStrokeStyle(color3);
  2083. context.setFillStyle(opts.background);
  2084. context.setLineWidth(2 * opts.pix);
  2085. } else {
  2086. context.setStrokeStyle("#ffffff");
  2087. context.setFillStyle(color3);
  2088. context.setLineWidth(1 * opts.pix);
  2089. }
  2090. if (shape === "diamond") {
  2091. points.forEach(function(item, index) {
  2092. if (item !== null && pointIndex == index) {
  2093. context.moveTo(item.x, item.y - 4.5);
  2094. context.lineTo(item.x - 4.5, item.y);
  2095. context.lineTo(item.x, item.y + 4.5);
  2096. context.lineTo(item.x + 4.5, item.y);
  2097. context.lineTo(item.x, item.y - 4.5);
  2098. }
  2099. });
  2100. } else if (shape === "circle") {
  2101. points.forEach(function(item, index) {
  2102. if (item !== null && pointIndex == index) {
  2103. context.moveTo(item.x + 2.5 * opts.pix, item.y);
  2104. context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
  2105. }
  2106. });
  2107. } else if (shape === "square") {
  2108. points.forEach(function(item, index) {
  2109. if (item !== null && pointIndex == index) {
  2110. context.moveTo(item.x - 3.5, item.y - 3.5);
  2111. context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
  2112. }
  2113. });
  2114. } else if (shape === "triangle") {
  2115. points.forEach(function(item, index) {
  2116. if (item !== null && pointIndex == index) {
  2117. context.moveTo(item.x, item.y - 4.5);
  2118. context.lineTo(item.x - 4.5, item.y + 4.5);
  2119. context.lineTo(item.x + 4.5, item.y + 4.5);
  2120. context.lineTo(item.x, item.y - 4.5);
  2121. }
  2122. });
  2123. } else if (shape === "none") {
  2124. return;
  2125. }
  2126. context.closePath();
  2127. context.fill();
  2128. context.stroke();
  2129. }
  2130. function drawRingTitle(opts, config2, context, center) {
  2131. var titlefontSize = opts.title.fontSize || config2.titleFontSize;
  2132. var subtitlefontSize = opts.subtitle.fontSize || config2.subtitleFontSize;
  2133. var title = opts.title.name || "";
  2134. var subtitle = opts.subtitle.name || "";
  2135. var titleFontColor = opts.title.color || opts.fontColor;
  2136. var subtitleFontColor = opts.subtitle.color || opts.fontColor;
  2137. var titleHeight = title ? titlefontSize : 0;
  2138. var subtitleHeight = subtitle ? subtitlefontSize : 0;
  2139. var margin = 5;
  2140. if (subtitle) {
  2141. var textWidth = measureText(subtitle, subtitlefontSize * opts.pix, context);
  2142. var startX = center.x - textWidth / 2 + (opts.subtitle.offsetX || 0) * opts.pix;
  2143. var startY = center.y + subtitlefontSize * opts.pix / 2 + (opts.subtitle.offsetY || 0) * opts.pix;
  2144. if (title) {
  2145. startY += (titleHeight * opts.pix + margin) / 2;
  2146. }
  2147. context.beginPath();
  2148. context.setFontSize(subtitlefontSize * opts.pix);
  2149. context.setFillStyle(subtitleFontColor);
  2150. context.fillText(subtitle, startX, startY);
  2151. context.closePath();
  2152. context.stroke();
  2153. }
  2154. if (title) {
  2155. var _textWidth = measureText(title, titlefontSize * opts.pix, context);
  2156. var _startX = center.x - _textWidth / 2 + (opts.title.offsetX || 0);
  2157. var _startY = center.y + titlefontSize * opts.pix / 2 + (opts.title.offsetY || 0) * opts.pix;
  2158. if (subtitle) {
  2159. _startY -= (subtitleHeight * opts.pix + margin) / 2;
  2160. }
  2161. context.beginPath();
  2162. context.setFontSize(titlefontSize * opts.pix);
  2163. context.setFillStyle(titleFontColor);
  2164. context.fillText(title, _startX, _startY);
  2165. context.closePath();
  2166. context.stroke();
  2167. }
  2168. }
  2169. function drawPointText(points, series, config2, context, opts) {
  2170. var data = series.data;
  2171. var textOffset = series.textOffset ? series.textOffset : 0;
  2172. points.forEach(function(item, index) {
  2173. if (item !== null) {
  2174. context.beginPath();
  2175. var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
  2176. context.setFontSize(fontSize);
  2177. context.setFillStyle(series.textColor || opts.fontColor);
  2178. var value = data[index];
  2179. if (typeof data[index] === "object" && data[index] !== null) {
  2180. if (data[index].constructor.toString().indexOf("Array") > -1) {
  2181. value = data[index][1];
  2182. } else {
  2183. value = data[index].value;
  2184. }
  2185. }
  2186. var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
  2187. context.setTextAlign("center");
  2188. context.fillText(String(formatVal), item.x, item.y - 4 + textOffset * opts.pix);
  2189. context.closePath();
  2190. context.stroke();
  2191. context.setTextAlign("left");
  2192. }
  2193. });
  2194. }
  2195. function drawColumePointText(points, series, config2, context, opts) {
  2196. var data = series.data;
  2197. var textOffset = series.textOffset ? series.textOffset : 0;
  2198. var Position = opts.extra.column.labelPosition;
  2199. points.forEach(function(item, index) {
  2200. if (item !== null) {
  2201. context.beginPath();
  2202. var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
  2203. context.setFontSize(fontSize);
  2204. context.setFillStyle(series.textColor || opts.fontColor);
  2205. var value = data[index];
  2206. if (typeof data[index] === "object" && data[index] !== null) {
  2207. if (data[index].constructor.toString().indexOf("Array") > -1) {
  2208. value = data[index][1];
  2209. } else {
  2210. value = data[index].value;
  2211. }
  2212. }
  2213. var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
  2214. context.setTextAlign("center");
  2215. var startY = item.y - 4 * opts.pix + textOffset * opts.pix;
  2216. if (item.y > series.zeroPoints) {
  2217. startY = item.y + textOffset * opts.pix + fontSize;
  2218. }
  2219. if (Position == "insideTop") {
  2220. startY = item.y + fontSize + textOffset * opts.pix;
  2221. if (item.y > series.zeroPoints) {
  2222. startY = item.y - textOffset * opts.pix - 4 * opts.pix;
  2223. }
  2224. }
  2225. if (Position == "center") {
  2226. startY = item.y + textOffset * opts.pix + (opts.height - opts.area[2] - item.y + fontSize) / 2;
  2227. if (series.zeroPoints < opts.height - opts.area[2]) {
  2228. startY = item.y + textOffset * opts.pix + (series.zeroPoints - item.y + fontSize) / 2;
  2229. }
  2230. if (item.y > series.zeroPoints) {
  2231. startY = item.y - textOffset * opts.pix - (item.y - series.zeroPoints - fontSize) / 2;
  2232. }
  2233. if (opts.extra.column.type == "stack") {
  2234. startY = item.y + textOffset * opts.pix + (item.y0 - item.y + fontSize) / 2;
  2235. }
  2236. }
  2237. if (Position == "bottom") {
  2238. startY = opts.height - opts.area[2] + textOffset * opts.pix - 4 * opts.pix;
  2239. if (series.zeroPoints < opts.height - opts.area[2]) {
  2240. startY = series.zeroPoints + textOffset * opts.pix - 4 * opts.pix;
  2241. }
  2242. if (item.y > series.zeroPoints) {
  2243. startY = series.zeroPoints - textOffset * opts.pix + fontSize + 2 * opts.pix;
  2244. }
  2245. if (opts.extra.column.type == "stack") {
  2246. startY = item.y0 + textOffset * opts.pix - 4 * opts.pix;
  2247. }
  2248. }
  2249. context.fillText(String(formatVal), item.x, startY);
  2250. context.closePath();
  2251. context.stroke();
  2252. context.setTextAlign("left");
  2253. }
  2254. });
  2255. }
  2256. function drawMountPointText(points, series, config2, context, opts, zeroPoints) {
  2257. var data = series.data;
  2258. var textOffset = series.textOffset ? series.textOffset : 0;
  2259. var Position = opts.extra.mount.labelPosition;
  2260. points.forEach(function(item, index) {
  2261. if (item !== null) {
  2262. context.beginPath();
  2263. var fontSize = series[index].textSize ? series[index].textSize * opts.pix : config2.fontSize;
  2264. context.setFontSize(fontSize);
  2265. context.setFillStyle(series[index].textColor || opts.fontColor);
  2266. var value = item.value;
  2267. var formatVal = series[index].formatter ? series[index].formatter(value, index, series, opts) : value;
  2268. context.setTextAlign("center");
  2269. var startY = item.y - 4 * opts.pix + textOffset * opts.pix;
  2270. if (item.y > zeroPoints) {
  2271. startY = item.y + textOffset * opts.pix + fontSize;
  2272. }
  2273. context.fillText(String(formatVal), item.x, startY);
  2274. context.closePath();
  2275. context.stroke();
  2276. context.setTextAlign("left");
  2277. }
  2278. });
  2279. }
  2280. function drawBarPointText(points, series, config2, context, opts) {
  2281. var data = series.data;
  2282. var textOffset = series.textOffset ? series.textOffset : 0;
  2283. points.forEach(function(item, index) {
  2284. if (item !== null) {
  2285. context.beginPath();
  2286. var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
  2287. context.setFontSize(fontSize);
  2288. context.setFillStyle(series.textColor || opts.fontColor);
  2289. var value = data[index];
  2290. if (typeof data[index] === "object" && data[index] !== null) {
  2291. value = data[index].value;
  2292. }
  2293. var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
  2294. context.setTextAlign("left");
  2295. context.fillText(String(formatVal), item.x + 4 * opts.pix, item.y + fontSize / 2 - 3);
  2296. context.closePath();
  2297. context.stroke();
  2298. }
  2299. });
  2300. }
  2301. function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config2, context) {
  2302. radius -= gaugeOption.width / 2 + gaugeOption.labelOffset * opts.pix;
  2303. radius = radius < 10 ? 10 : radius;
  2304. let totalAngle;
  2305. if (gaugeOption.endAngle < gaugeOption.startAngle) {
  2306. totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
  2307. } else {
  2308. totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
  2309. }
  2310. let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
  2311. let totalNumber = gaugeOption.endNumber - gaugeOption.startNumber;
  2312. let splitNumber = totalNumber / gaugeOption.splitLine.splitNumber;
  2313. let nowAngle = gaugeOption.startAngle;
  2314. let nowNumber = gaugeOption.startNumber;
  2315. for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
  2316. var pos = {
  2317. x: radius * Math.cos(nowAngle * Math.PI),
  2318. y: radius * Math.sin(nowAngle * Math.PI)
  2319. };
  2320. var labelText = gaugeOption.formatter ? gaugeOption.formatter(nowNumber, i, opts) : nowNumber;
  2321. pos.x += centerPosition.x - measureText(labelText, config2.fontSize, context) / 2;
  2322. pos.y += centerPosition.y;
  2323. var startX = pos.x;
  2324. var startY = pos.y;
  2325. context.beginPath();
  2326. context.setFontSize(config2.fontSize);
  2327. context.setFillStyle(gaugeOption.labelColor || opts.fontColor);
  2328. context.fillText(labelText, startX, startY + config2.fontSize / 2);
  2329. context.closePath();
  2330. context.stroke();
  2331. nowAngle += splitAngle;
  2332. if (nowAngle >= 2) {
  2333. nowAngle = nowAngle % 2;
  2334. }
  2335. nowNumber += splitNumber;
  2336. }
  2337. }
  2338. function drawRadarLabel(angleList, radius, centerPosition, opts, config2, context) {
  2339. var radarOption = opts.extra.radar || {};
  2340. angleList.forEach(function(angle, index) {
  2341. if (radarOption.labelPointShow === true && opts.categories[index] !== "") {
  2342. var posPoint = {
  2343. x: radius * Math.cos(angle),
  2344. y: radius * Math.sin(angle)
  2345. };
  2346. var posPointAxis = convertCoordinateOrigin(posPoint.x, posPoint.y, centerPosition);
  2347. context.setFillStyle(radarOption.labelPointColor);
  2348. context.beginPath();
  2349. context.arc(posPointAxis.x, posPointAxis.y, radarOption.labelPointRadius * opts.pix, 0, 2 * Math.PI, false);
  2350. context.closePath();
  2351. context.fill();
  2352. }
  2353. if (radarOption.labelShow === true) {
  2354. var pos = {
  2355. x: (radius + config2.radarLabelTextMargin * opts.pix) * Math.cos(angle),
  2356. y: (radius + config2.radarLabelTextMargin * opts.pix) * Math.sin(angle)
  2357. };
  2358. var posRelativeCanvas = convertCoordinateOrigin(pos.x, pos.y, centerPosition);
  2359. var startX = posRelativeCanvas.x;
  2360. var startY = posRelativeCanvas.y;
  2361. if (util.approximatelyEqual(pos.x, 0)) {
  2362. startX -= measureText(opts.categories[index] || "", config2.fontSize, context) / 2;
  2363. } else if (pos.x < 0) {
  2364. startX -= measureText(opts.categories[index] || "", config2.fontSize, context);
  2365. }
  2366. context.beginPath();
  2367. context.setFontSize(config2.fontSize);
  2368. context.setFillStyle(radarOption.labelColor || opts.fontColor);
  2369. context.fillText(opts.categories[index] || "", startX, startY + config2.fontSize / 2);
  2370. context.closePath();
  2371. context.stroke();
  2372. }
  2373. });
  2374. }
  2375. function drawPieText(series, opts, config2, context, radius, center) {
  2376. var lineRadius = config2.pieChartLinePadding;
  2377. var textObjectCollection = [];
  2378. var lastTextObject = null;
  2379. var seriesConvert = series.map(function(item, index) {
  2380. var text = item.formatter ? item.formatter(item, index, series, opts) : util.toFixed(item._proportion_.toFixed(4) * 100) + "%";
  2381. text = item.labelText ? item.labelText : text;
  2382. var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2);
  2383. if (item._rose_proportion_) {
  2384. arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._rose_proportion_ / 2);
  2385. }
  2386. var color3 = item.color;
  2387. var radius2 = item._radius_;
  2388. return {
  2389. arc,
  2390. text,
  2391. color: color3,
  2392. radius: radius2,
  2393. textColor: item.textColor,
  2394. textSize: item.textSize,
  2395. labelShow: item.labelShow
  2396. };
  2397. });
  2398. for (let i = 0; i < seriesConvert.length; i++) {
  2399. let item = seriesConvert[i];
  2400. let orginX1 = Math.cos(item.arc) * (item.radius + lineRadius);
  2401. let orginY1 = Math.sin(item.arc) * (item.radius + lineRadius);
  2402. let orginX2 = Math.cos(item.arc) * item.radius;
  2403. let orginY2 = Math.sin(item.arc) * item.radius;
  2404. let orginX3 = orginX1 >= 0 ? orginX1 + config2.pieChartTextPadding : orginX1 - config2.pieChartTextPadding;
  2405. let orginY3 = orginY1;
  2406. let textWidth = measureText(item.text, item.textSize * opts.pix || config2.fontSize, context);
  2407. let startY = orginY3;
  2408. if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, {
  2409. x: orginX3
  2410. })) {
  2411. if (orginX3 > 0) {
  2412. startY = Math.min(orginY3, lastTextObject.start.y);
  2413. } else if (orginX1 < 0) {
  2414. startY = Math.max(orginY3, lastTextObject.start.y);
  2415. } else {
  2416. if (orginY3 > 0) {
  2417. startY = Math.max(orginY3, lastTextObject.start.y);
  2418. } else {
  2419. startY = Math.min(orginY3, lastTextObject.start.y);
  2420. }
  2421. }
  2422. }
  2423. if (orginX3 < 0) {
  2424. orginX3 -= textWidth;
  2425. }
  2426. let textObject = {
  2427. lineStart: {
  2428. x: orginX2,
  2429. y: orginY2
  2430. },
  2431. lineEnd: {
  2432. x: orginX1,
  2433. y: orginY1
  2434. },
  2435. start: {
  2436. x: orginX3,
  2437. y: startY
  2438. },
  2439. width: textWidth,
  2440. height: config2.fontSize,
  2441. text: item.text,
  2442. color: item.color,
  2443. textColor: item.textColor,
  2444. textSize: item.textSize
  2445. };
  2446. lastTextObject = avoidCollision(textObject, lastTextObject);
  2447. textObjectCollection.push(lastTextObject);
  2448. }
  2449. for (let i = 0; i < textObjectCollection.length; i++) {
  2450. if (seriesConvert[i].labelShow === false) {
  2451. continue;
  2452. }
  2453. let item = textObjectCollection[i];
  2454. let lineStartPoistion = convertCoordinateOrigin(item.lineStart.x, item.lineStart.y, center);
  2455. let lineEndPoistion = convertCoordinateOrigin(item.lineEnd.x, item.lineEnd.y, center);
  2456. let textPosition = convertCoordinateOrigin(item.start.x, item.start.y, center);
  2457. context.setLineWidth(1 * opts.pix);
  2458. context.setFontSize(item.textSize * opts.pix || config2.fontSize);
  2459. context.beginPath();
  2460. context.setStrokeStyle(item.color);
  2461. context.setFillStyle(item.color);
  2462. context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
  2463. let curveStartX = item.start.x < 0 ? textPosition.x + item.width : textPosition.x;
  2464. let textStartX = item.start.x < 0 ? textPosition.x - 5 : textPosition.x + 5;
  2465. context.quadraticCurveTo(lineEndPoistion.x, lineEndPoistion.y, curveStartX, textPosition.y);
  2466. context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
  2467. context.stroke();
  2468. context.closePath();
  2469. context.beginPath();
  2470. context.moveTo(textPosition.x + item.width, textPosition.y);
  2471. context.arc(curveStartX, textPosition.y, 2 * opts.pix, 0, 2 * Math.PI);
  2472. context.closePath();
  2473. context.fill();
  2474. context.beginPath();
  2475. context.setFontSize(item.textSize * opts.pix || config2.fontSize);
  2476. context.setFillStyle(item.textColor || opts.fontColor);
  2477. context.fillText(item.text, textStartX, textPosition.y + 3);
  2478. context.closePath();
  2479. context.stroke();
  2480. context.closePath();
  2481. }
  2482. }
  2483. function drawToolTipSplitLine(offsetX, opts, config2, context) {
  2484. var toolTipOption = opts.extra.tooltip || {};
  2485. toolTipOption.gridType = toolTipOption.gridType == void 0 ? "solid" : toolTipOption.gridType;
  2486. toolTipOption.dashLength = toolTipOption.dashLength == void 0 ? 4 : toolTipOption.dashLength;
  2487. var startY = opts.area[0];
  2488. var endY = opts.height - opts.area[2];
  2489. if (toolTipOption.gridType == "dash") {
  2490. context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
  2491. }
  2492. context.setStrokeStyle(toolTipOption.gridColor || "#cccccc");
  2493. context.setLineWidth(1 * opts.pix);
  2494. context.beginPath();
  2495. context.moveTo(offsetX, startY);
  2496. context.lineTo(offsetX, endY);
  2497. context.stroke();
  2498. context.setLineDash([]);
  2499. if (toolTipOption.xAxisLabel) {
  2500. let labelText = opts.categories[opts.tooltip.index];
  2501. context.setFontSize(config2.fontSize);
  2502. let textWidth = measureText(labelText, config2.fontSize, context);
  2503. let textX = offsetX - 0.5 * textWidth;
  2504. let textY = endY + 2 * opts.pix;
  2505. context.beginPath();
  2506. context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config2.toolTipBackground, toolTipOption.labelBgOpacity || config2.toolTipOpacity));
  2507. context.setStrokeStyle(toolTipOption.labelBgColor || config2.toolTipBackground);
  2508. context.setLineWidth(1 * opts.pix);
  2509. context.rect(textX - toolTipOption.boxPadding * opts.pix, textY, textWidth + 2 * toolTipOption.boxPadding * opts.pix, config2.fontSize + 2 * toolTipOption.boxPadding * opts.pix);
  2510. context.closePath();
  2511. context.stroke();
  2512. context.fill();
  2513. context.beginPath();
  2514. context.setFontSize(config2.fontSize);
  2515. context.setFillStyle(toolTipOption.labelFontColor || opts.fontColor);
  2516. context.fillText(String(labelText), textX, textY + toolTipOption.boxPadding * opts.pix + config2.fontSize);
  2517. context.closePath();
  2518. context.stroke();
  2519. }
  2520. }
  2521. function drawMarkLine(opts, config2, context) {
  2522. let markLineOption = assign({}, {
  2523. type: "solid",
  2524. dashLength: 4,
  2525. data: []
  2526. }, opts.extra.markLine);
  2527. let startX = opts.area[3];
  2528. let endX = opts.width - opts.area[1];
  2529. let points = calMarkLineData(markLineOption.data, opts);
  2530. for (let i = 0; i < points.length; i++) {
  2531. let item = assign({}, {
  2532. lineColor: "#DE4A42",
  2533. showLabel: false,
  2534. labelFontSize: 13,
  2535. labelPadding: 6,
  2536. labelFontColor: "#666666",
  2537. labelBgColor: "#DFE8FF",
  2538. labelBgOpacity: 0.8,
  2539. labelAlign: "left",
  2540. labelOffsetX: 0,
  2541. labelOffsetY: 0
  2542. }, points[i]);
  2543. if (markLineOption.type == "dash") {
  2544. context.setLineDash([markLineOption.dashLength, markLineOption.dashLength]);
  2545. }
  2546. context.setStrokeStyle(item.lineColor);
  2547. context.setLineWidth(1 * opts.pix);
  2548. context.beginPath();
  2549. context.moveTo(startX, item.y);
  2550. context.lineTo(endX, item.y);
  2551. context.stroke();
  2552. context.setLineDash([]);
  2553. if (item.showLabel) {
  2554. let fontSize = item.labelFontSize * opts.pix;
  2555. let labelText = item.labelText ? item.labelText : item.value;
  2556. context.setFontSize(fontSize);
  2557. let textWidth = measureText(labelText, fontSize, context);
  2558. let bgWidth = textWidth + item.labelPadding * opts.pix * 2;
  2559. let bgStartX = item.labelAlign == "left" ? opts.area[3] - bgWidth : opts.width - opts.area[1];
  2560. bgStartX += item.labelOffsetX;
  2561. let bgStartY = item.y - 0.5 * fontSize - item.labelPadding * opts.pix;
  2562. bgStartY += item.labelOffsetY;
  2563. let textX = bgStartX + item.labelPadding * opts.pix;
  2564. let textY = item.y;
  2565. context.setFillStyle(hexToRgb(item.labelBgColor, item.labelBgOpacity));
  2566. context.setStrokeStyle(item.labelBgColor);
  2567. context.setLineWidth(1 * opts.pix);
  2568. context.beginPath();
  2569. context.rect(bgStartX, bgStartY, bgWidth, fontSize + 2 * item.labelPadding * opts.pix);
  2570. context.closePath();
  2571. context.stroke();
  2572. context.fill();
  2573. context.setFontSize(fontSize);
  2574. context.setTextAlign("left");
  2575. context.setFillStyle(item.labelFontColor);
  2576. context.fillText(String(labelText), textX, bgStartY + fontSize + item.labelPadding * opts.pix / 2);
  2577. context.stroke();
  2578. context.setTextAlign("left");
  2579. }
  2580. }
  2581. }
  2582. function drawToolTipHorizentalLine(opts, config2, context, eachSpacing, xAxisPoints) {
  2583. var toolTipOption = assign({}, {
  2584. gridType: "solid",
  2585. dashLength: 4
  2586. }, opts.extra.tooltip);
  2587. var startX = opts.area[3];
  2588. var endX = opts.width - opts.area[1];
  2589. if (toolTipOption.gridType == "dash") {
  2590. context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
  2591. }
  2592. context.setStrokeStyle(toolTipOption.gridColor || "#cccccc");
  2593. context.setLineWidth(1 * opts.pix);
  2594. context.beginPath();
  2595. context.moveTo(startX, opts.tooltip.offset.y);
  2596. context.lineTo(endX, opts.tooltip.offset.y);
  2597. context.stroke();
  2598. context.setLineDash([]);
  2599. if (toolTipOption.yAxisLabel) {
  2600. let boxPadding = toolTipOption.boxPadding * opts.pix;
  2601. let labelText = calTooltipYAxisData(opts.tooltip.offset.y, opts.series, opts, config2, eachSpacing);
  2602. let widthArr = opts.chartData.yAxisData.yAxisWidth;
  2603. let tStartLeft = opts.area[3];
  2604. let tStartRight = opts.width - opts.area[1];
  2605. for (let i = 0; i < labelText.length; i++) {
  2606. context.setFontSize(toolTipOption.fontSize * opts.pix);
  2607. let textWidth = measureText(labelText[i], toolTipOption.fontSize * opts.pix, context);
  2608. let bgStartX, bgEndX, bgWidth;
  2609. if (widthArr[i].position == "left") {
  2610. bgStartX = tStartLeft - (textWidth + boxPadding * 2) - 2 * opts.pix;
  2611. bgEndX = Math.max(bgStartX, bgStartX + textWidth + boxPadding * 2);
  2612. } else {
  2613. bgStartX = tStartRight + 2 * opts.pix;
  2614. bgEndX = Math.max(bgStartX + widthArr[i].width, bgStartX + textWidth + boxPadding * 2);
  2615. }
  2616. bgWidth = bgEndX - bgStartX;
  2617. let textX = bgStartX + (bgWidth - textWidth) / 2;
  2618. let textY = opts.tooltip.offset.y;
  2619. context.beginPath();
  2620. context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config2.toolTipBackground, toolTipOption.labelBgOpacity || config2.toolTipOpacity));
  2621. context.setStrokeStyle(toolTipOption.labelBgColor || config2.toolTipBackground);
  2622. context.setLineWidth(1 * opts.pix);
  2623. context.rect(bgStartX, textY - 0.5 * config2.fontSize - boxPadding, bgWidth, config2.fontSize + 2 * boxPadding);
  2624. context.closePath();
  2625. context.stroke();
  2626. context.fill();
  2627. context.beginPath();
  2628. context.setFontSize(config2.fontSize);
  2629. context.setFillStyle(toolTipOption.labelFontColor || opts.fontColor);
  2630. context.fillText(labelText[i], textX, textY + 0.5 * config2.fontSize);
  2631. context.closePath();
  2632. context.stroke();
  2633. if (widthArr[i].position == "left") {
  2634. tStartLeft -= widthArr[i].width + opts.yAxis.padding * opts.pix;
  2635. } else {
  2636. tStartRight += widthArr[i].width + opts.yAxis.padding * opts.pix;
  2637. }
  2638. }
  2639. }
  2640. }
  2641. function drawToolTipSplitArea(offsetX, opts, config2, context, eachSpacing) {
  2642. var toolTipOption = assign({}, {
  2643. activeBgColor: "#000000",
  2644. activeBgOpacity: 0.08,
  2645. activeWidth: eachSpacing
  2646. }, opts.extra.column);
  2647. toolTipOption.activeWidth = toolTipOption.activeWidth > eachSpacing ? eachSpacing : toolTipOption.activeWidth;
  2648. var startY = opts.area[0];
  2649. var endY = opts.height - opts.area[2];
  2650. context.beginPath();
  2651. context.setFillStyle(hexToRgb(toolTipOption.activeBgColor, toolTipOption.activeBgOpacity));
  2652. context.rect(offsetX - toolTipOption.activeWidth / 2, startY, toolTipOption.activeWidth, endY - startY);
  2653. context.closePath();
  2654. context.fill();
  2655. context.setFillStyle("#FFFFFF");
  2656. }
  2657. function drawBarToolTipSplitArea(offsetX, opts, config2, context, eachSpacing) {
  2658. var toolTipOption = assign({}, {
  2659. activeBgColor: "#000000",
  2660. activeBgOpacity: 0.08
  2661. }, opts.extra.bar);
  2662. var startX = opts.area[3];
  2663. var endX = opts.width - opts.area[1];
  2664. context.beginPath();
  2665. context.setFillStyle(hexToRgb(toolTipOption.activeBgColor, toolTipOption.activeBgOpacity));
  2666. context.rect(startX, offsetX - eachSpacing / 2, endX - startX, eachSpacing);
  2667. context.closePath();
  2668. context.fill();
  2669. context.setFillStyle("#FFFFFF");
  2670. }
  2671. function drawToolTip(textList, offset, opts, config2, context, eachSpacing, xAxisPoints) {
  2672. var toolTipOption = assign({}, {
  2673. showBox: true,
  2674. showArrow: true,
  2675. showCategory: false,
  2676. bgColor: "#000000",
  2677. bgOpacity: 0.7,
  2678. borderColor: "#000000",
  2679. borderWidth: 0,
  2680. borderRadius: 0,
  2681. borderOpacity: 0.7,
  2682. boxPadding: 3,
  2683. fontColor: "#FFFFFF",
  2684. fontSize: 13,
  2685. lineHeight: 20,
  2686. legendShow: true,
  2687. legendShape: "auto",
  2688. splitLine: true
  2689. }, opts.extra.tooltip);
  2690. if (toolTipOption.showCategory == true && opts.categories) {
  2691. textList.unshift({ text: opts.categories[opts.tooltip.index], color: null });
  2692. }
  2693. var fontSize = toolTipOption.fontSize * opts.pix;
  2694. var lineHeight = toolTipOption.lineHeight * opts.pix;
  2695. var boxPadding = toolTipOption.boxPadding * opts.pix;
  2696. var legendWidth = fontSize;
  2697. var legendMarginRight = 5 * opts.pix;
  2698. if (toolTipOption.legendShow == false) {
  2699. legendWidth = 0;
  2700. legendMarginRight = 0;
  2701. }
  2702. var arrowWidth = toolTipOption.showArrow ? 8 * opts.pix : 0;
  2703. var isOverRightBorder = false;
  2704. if (opts.type == "line" || opts.type == "mount" || opts.type == "area" || opts.type == "candle" || opts.type == "mix") {
  2705. if (toolTipOption.splitLine == true) {
  2706. drawToolTipSplitLine(opts.tooltip.offset.x, opts, config2, context);
  2707. }
  2708. }
  2709. offset = assign({
  2710. x: 0,
  2711. y: 0
  2712. }, offset);
  2713. offset.y -= 8 * opts.pix;
  2714. var textWidth = textList.map(function(item) {
  2715. return measureText(item.text, fontSize, context);
  2716. });
  2717. var toolTipWidth = legendWidth + legendMarginRight + 4 * boxPadding + Math.max.apply(null, textWidth);
  2718. var toolTipHeight = 2 * boxPadding + textList.length * lineHeight;
  2719. if (toolTipOption.showBox == false) {
  2720. return;
  2721. }
  2722. if (offset.x - Math.abs(opts._scrollDistance_ || 0) + arrowWidth + toolTipWidth > opts.width) {
  2723. isOverRightBorder = true;
  2724. }
  2725. if (toolTipHeight + offset.y > opts.height) {
  2726. offset.y = opts.height - toolTipHeight;
  2727. }
  2728. context.beginPath();
  2729. context.setFillStyle(hexToRgb(toolTipOption.bgColor, toolTipOption.bgOpacity));
  2730. context.setLineWidth(toolTipOption.borderWidth * opts.pix);
  2731. context.setStrokeStyle(hexToRgb(toolTipOption.borderColor, toolTipOption.borderOpacity));
  2732. var radius = toolTipOption.borderRadius;
  2733. if (isOverRightBorder) {
  2734. if (toolTipWidth + arrowWidth > opts.width) {
  2735. offset.x = opts.width + Math.abs(opts._scrollDistance_ || 0) + arrowWidth + (toolTipWidth - opts.width);
  2736. }
  2737. if (toolTipWidth > offset.x) {
  2738. offset.x = opts.width + Math.abs(opts._scrollDistance_ || 0) + arrowWidth + (toolTipWidth - opts.width);
  2739. }
  2740. if (toolTipOption.showArrow) {
  2741. context.moveTo(offset.x, offset.y + 10 * opts.pix);
  2742. context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pix + 5 * opts.pix);
  2743. }
  2744. context.arc(offset.x - arrowWidth - radius, offset.y + toolTipHeight - radius, radius, 0, Math.PI / 2, false);
  2745. context.arc(
  2746. offset.x - arrowWidth - Math.round(toolTipWidth) + radius,
  2747. offset.y + toolTipHeight - radius,
  2748. radius,
  2749. Math.PI / 2,
  2750. Math.PI,
  2751. false
  2752. );
  2753. context.arc(offset.x - arrowWidth - Math.round(toolTipWidth) + radius, offset.y + radius, radius, -Math.PI, -Math.PI / 2, false);
  2754. context.arc(offset.x - arrowWidth - radius, offset.y + radius, radius, -Math.PI / 2, 0, false);
  2755. if (toolTipOption.showArrow) {
  2756. context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pix - 5 * opts.pix);
  2757. context.lineTo(offset.x, offset.y + 10 * opts.pix);
  2758. }
  2759. } else {
  2760. if (toolTipOption.showArrow) {
  2761. context.moveTo(offset.x, offset.y + 10 * opts.pix);
  2762. context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pix - 5 * opts.pix);
  2763. }
  2764. context.arc(offset.x + arrowWidth + radius, offset.y + radius, radius, -Math.PI, -Math.PI / 2, false);
  2765. context.arc(
  2766. offset.x + arrowWidth + Math.round(toolTipWidth) - radius,
  2767. offset.y + radius,
  2768. radius,
  2769. -Math.PI / 2,
  2770. 0,
  2771. false
  2772. );
  2773. context.arc(
  2774. offset.x + arrowWidth + Math.round(toolTipWidth) - radius,
  2775. offset.y + toolTipHeight - radius,
  2776. radius,
  2777. 0,
  2778. Math.PI / 2,
  2779. false
  2780. );
  2781. context.arc(offset.x + arrowWidth + radius, offset.y + toolTipHeight - radius, radius, Math.PI / 2, Math.PI, false);
  2782. if (toolTipOption.showArrow) {
  2783. context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pix + 5 * opts.pix);
  2784. context.lineTo(offset.x, offset.y + 10 * opts.pix);
  2785. }
  2786. }
  2787. context.closePath();
  2788. context.fill();
  2789. if (toolTipOption.borderWidth > 0) {
  2790. context.stroke();
  2791. }
  2792. if (toolTipOption.legendShow) {
  2793. textList.forEach(function(item, index) {
  2794. if (item.color !== null) {
  2795. context.beginPath();
  2796. context.setFillStyle(item.color);
  2797. var startX = offset.x + arrowWidth + 2 * boxPadding;
  2798. var startY = offset.y + (lineHeight - fontSize) / 2 + lineHeight * index + boxPadding + 1;
  2799. if (isOverRightBorder) {
  2800. startX = offset.x - toolTipWidth - arrowWidth + 2 * boxPadding;
  2801. }
  2802. switch (item.legendShape) {
  2803. case "line":
  2804. context.moveTo(startX, startY + 0.5 * legendWidth - 2 * opts.pix);
  2805. context.fillRect(startX, startY + 0.5 * legendWidth - 2 * opts.pix, legendWidth, 4 * opts.pix);
  2806. break;
  2807. case "triangle":
  2808. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
  2809. context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
  2810. context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
  2811. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
  2812. break;
  2813. case "diamond":
  2814. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
  2815. context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * legendWidth);
  2816. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
  2817. context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * legendWidth);
  2818. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
  2819. break;
  2820. case "circle":
  2821. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth);
  2822. context.arc(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth, 5 * opts.pix, 0, 2 * Math.PI);
  2823. break;
  2824. case "rect":
  2825. context.moveTo(startX, startY + 0.5 * legendWidth - 5 * opts.pix);
  2826. context.fillRect(startX, startY + 0.5 * legendWidth - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
  2827. break;
  2828. case "square":
  2829. context.moveTo(startX + 2 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
  2830. context.fillRect(startX + 2 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix, 10 * opts.pix, 10 * opts.pix);
  2831. break;
  2832. default:
  2833. context.moveTo(startX, startY + 0.5 * legendWidth - 5 * opts.pix);
  2834. context.fillRect(startX, startY + 0.5 * legendWidth - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
  2835. }
  2836. context.closePath();
  2837. context.fill();
  2838. }
  2839. });
  2840. }
  2841. textList.forEach(function(item, index) {
  2842. var startX = offset.x + arrowWidth + 2 * boxPadding + legendWidth + legendMarginRight;
  2843. if (isOverRightBorder) {
  2844. startX = offset.x - toolTipWidth - arrowWidth + 2 * boxPadding + legendWidth + legendMarginRight;
  2845. }
  2846. var startY = offset.y + lineHeight * index + (lineHeight - fontSize) / 2 - 1 + boxPadding + fontSize;
  2847. context.beginPath();
  2848. context.setFontSize(fontSize);
  2849. context.setTextBaseline("normal");
  2850. context.setFillStyle(toolTipOption.fontColor);
  2851. context.fillText(item.text, startX, startY);
  2852. context.closePath();
  2853. context.stroke();
  2854. });
  2855. }
  2856. function drawColumnDataPoints(series, opts, config2, context) {
  2857. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  2858. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  2859. let columnOption = assign({}, {
  2860. type: "group",
  2861. width: eachSpacing / 2,
  2862. meterBorder: 4,
  2863. meterFillColor: "#FFFFFF",
  2864. barBorderCircle: false,
  2865. barBorderRadius: [],
  2866. seriesGap: 2,
  2867. linearType: "none",
  2868. linearOpacity: 1,
  2869. customColor: [],
  2870. colorStop: 0,
  2871. labelPosition: "outside"
  2872. }, opts.extra.column);
  2873. let calPoints = [];
  2874. context.save();
  2875. let leftNum = -2;
  2876. let rightNum = xAxisPoints.length + 2;
  2877. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  2878. context.translate(opts._scrollDistance_, 0);
  2879. leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
  2880. rightNum = leftNum + opts.xAxis.itemCount + 4;
  2881. }
  2882. if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
  2883. drawToolTipSplitArea(opts.tooltip.offset.x, opts, config2, context, eachSpacing);
  2884. }
  2885. columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
  2886. series.forEach(function(eachSeries, seriesIndex) {
  2887. let ranges, minRange, maxRange;
  2888. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  2889. minRange = ranges.pop();
  2890. maxRange = ranges.shift();
  2891. let spacingValid = opts.height - opts.area[0] - opts.area[2];
  2892. let zeroHeight = spacingValid * (0 - minRange) / (maxRange - minRange);
  2893. let zeroPoints = opts.height - Math.round(zeroHeight) - opts.area[2];
  2894. eachSeries.zeroPoints = zeroPoints;
  2895. var data = eachSeries.data;
  2896. switch (columnOption.type) {
  2897. case "group":
  2898. var points = getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, zeroPoints, process);
  2899. var tooltipPoints = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  2900. calPoints.push(tooltipPoints);
  2901. points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config2, opts);
  2902. for (let i = 0; i < points.length; i++) {
  2903. let item = points[i];
  2904. if (item !== null && i > leftNum && i < rightNum) {
  2905. var startX = item.x - item.width / 2;
  2906. var height = opts.height - item.y - opts.area[2];
  2907. context.beginPath();
  2908. var fillColor = item.color || eachSeries.color;
  2909. var strokeColor = item.color || eachSeries.color;
  2910. if (columnOption.linearType !== "none") {
  2911. var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
  2912. if (columnOption.linearType == "opacity") {
  2913. grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
  2914. grd.addColorStop(1, hexToRgb(fillColor, 1));
  2915. } else {
  2916. grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  2917. grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  2918. grd.addColorStop(1, hexToRgb(fillColor, 1));
  2919. }
  2920. fillColor = grd;
  2921. }
  2922. if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
  2923. const left = startX;
  2924. const top = item.y > zeroPoints ? zeroPoints : item.y;
  2925. const width = item.width;
  2926. const height2 = Math.abs(zeroPoints - item.y);
  2927. if (columnOption.barBorderCircle) {
  2928. columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
  2929. }
  2930. if (item.y > zeroPoints) {
  2931. columnOption.barBorderRadius = [0, 0, width / 2, width / 2];
  2932. }
  2933. let [r0, r1, r2, r3] = columnOption.barBorderRadius;
  2934. let minRadius = Math.min(width / 2, height2 / 2);
  2935. r0 = r0 > minRadius ? minRadius : r0;
  2936. r1 = r1 > minRadius ? minRadius : r1;
  2937. r2 = r2 > minRadius ? minRadius : r2;
  2938. r3 = r3 > minRadius ? minRadius : r3;
  2939. r0 = r0 < 0 ? 0 : r0;
  2940. r1 = r1 < 0 ? 0 : r1;
  2941. r2 = r2 < 0 ? 0 : r2;
  2942. r3 = r3 < 0 ? 0 : r3;
  2943. context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
  2944. context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
  2945. context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
  2946. context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
  2947. } else {
  2948. context.moveTo(startX, item.y);
  2949. context.lineTo(startX + item.width, item.y);
  2950. context.lineTo(startX + item.width, zeroPoints);
  2951. context.lineTo(startX, zeroPoints);
  2952. context.lineTo(startX, item.y);
  2953. context.setLineWidth(1);
  2954. context.setStrokeStyle(strokeColor);
  2955. }
  2956. context.setFillStyle(fillColor);
  2957. context.closePath();
  2958. context.fill();
  2959. }
  2960. }
  2961. ;
  2962. break;
  2963. case "stack":
  2964. var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  2965. calPoints.push(points);
  2966. points = fixColumeStackData(points, eachSpacing, series.length, seriesIndex, config2, opts, series);
  2967. for (let i = 0; i < points.length; i++) {
  2968. let item = points[i];
  2969. if (item !== null && i > leftNum && i < rightNum) {
  2970. context.beginPath();
  2971. var fillColor = item.color || eachSeries.color;
  2972. var startX = item.x - item.width / 2 + 1;
  2973. var height = opts.height - item.y - opts.area[2];
  2974. var height0 = opts.height - item.y0 - opts.area[2];
  2975. if (seriesIndex > 0) {
  2976. height -= height0;
  2977. }
  2978. context.setFillStyle(fillColor);
  2979. context.moveTo(startX, item.y);
  2980. context.fillRect(startX, item.y, item.width, height);
  2981. context.closePath();
  2982. context.fill();
  2983. }
  2984. }
  2985. ;
  2986. break;
  2987. case "meter":
  2988. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  2989. calPoints.push(points);
  2990. points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config2, opts, columnOption.meterBorder);
  2991. for (let i = 0; i < points.length; i++) {
  2992. let item = points[i];
  2993. if (item !== null && i > leftNum && i < rightNum) {
  2994. context.beginPath();
  2995. if (seriesIndex == 0 && columnOption.meterBorder > 0) {
  2996. context.setStrokeStyle(eachSeries.color);
  2997. context.setLineWidth(columnOption.meterBorder * opts.pix);
  2998. }
  2999. if (seriesIndex == 0) {
  3000. context.setFillStyle(columnOption.meterFillColor);
  3001. } else {
  3002. context.setFillStyle(item.color || eachSeries.color);
  3003. }
  3004. var startX = item.x - item.width / 2;
  3005. var height = opts.height - item.y - opts.area[2];
  3006. if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
  3007. const left = startX;
  3008. const top = item.y;
  3009. const width = item.width;
  3010. const height2 = zeroPoints - item.y;
  3011. if (columnOption.barBorderCircle) {
  3012. columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
  3013. }
  3014. let [r0, r1, r2, r3] = columnOption.barBorderRadius;
  3015. let minRadius = Math.min(width / 2, height2 / 2);
  3016. r0 = r0 > minRadius ? minRadius : r0;
  3017. r1 = r1 > minRadius ? minRadius : r1;
  3018. r2 = r2 > minRadius ? minRadius : r2;
  3019. r3 = r3 > minRadius ? minRadius : r3;
  3020. r0 = r0 < 0 ? 0 : r0;
  3021. r1 = r1 < 0 ? 0 : r1;
  3022. r2 = r2 < 0 ? 0 : r2;
  3023. r3 = r3 < 0 ? 0 : r3;
  3024. context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
  3025. context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
  3026. context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
  3027. context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
  3028. context.fill();
  3029. } else {
  3030. context.moveTo(startX, item.y);
  3031. context.lineTo(startX + item.width, item.y);
  3032. context.lineTo(startX + item.width, zeroPoints);
  3033. context.lineTo(startX, zeroPoints);
  3034. context.lineTo(startX, item.y);
  3035. context.fill();
  3036. }
  3037. if (seriesIndex == 0 && columnOption.meterBorder > 0) {
  3038. context.closePath();
  3039. context.stroke();
  3040. }
  3041. }
  3042. }
  3043. break;
  3044. }
  3045. });
  3046. if (opts.dataLabel !== false && process === 1) {
  3047. series.forEach(function(eachSeries, seriesIndex) {
  3048. let ranges, minRange, maxRange;
  3049. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3050. minRange = ranges.pop();
  3051. maxRange = ranges.shift();
  3052. var data = eachSeries.data;
  3053. switch (columnOption.type) {
  3054. case "group":
  3055. var points = getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3056. points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config2, opts);
  3057. drawColumePointText(points, eachSeries, config2, context, opts);
  3058. break;
  3059. case "stack":
  3060. var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  3061. drawColumePointText(points, eachSeries, config2, context, opts);
  3062. break;
  3063. case "meter":
  3064. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3065. drawColumePointText(points, eachSeries, config2, context, opts);
  3066. break;
  3067. }
  3068. });
  3069. }
  3070. context.restore();
  3071. return {
  3072. xAxisPoints,
  3073. calPoints,
  3074. eachSpacing
  3075. };
  3076. }
  3077. function drawMountDataPoints(series, opts, config2, context) {
  3078. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3079. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3080. let mountOption = assign({}, {
  3081. type: "mount",
  3082. widthRatio: 1,
  3083. borderWidth: 1,
  3084. barBorderCircle: false,
  3085. barBorderRadius: [],
  3086. linearType: "none",
  3087. linearOpacity: 1,
  3088. customColor: [],
  3089. colorStop: 0
  3090. }, opts.extra.mount);
  3091. mountOption.widthRatio = mountOption.widthRatio <= 0 ? 0 : mountOption.widthRatio;
  3092. mountOption.widthRatio = mountOption.widthRatio >= 2 ? 2 : mountOption.widthRatio;
  3093. let calPoints = [];
  3094. context.save();
  3095. let leftNum = -2;
  3096. let rightNum = xAxisPoints.length + 2;
  3097. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3098. context.translate(opts._scrollDistance_, 0);
  3099. leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
  3100. rightNum = leftNum + opts.xAxis.itemCount + 4;
  3101. }
  3102. mountOption.customColor = fillCustomColor(mountOption.linearType, mountOption.customColor, series, config2);
  3103. let ranges, minRange, maxRange;
  3104. ranges = [].concat(opts.chartData.yAxisData.ranges[0]);
  3105. minRange = ranges.pop();
  3106. maxRange = ranges.shift();
  3107. let spacingValid = opts.height - opts.area[0] - opts.area[2];
  3108. let zeroHeight = spacingValid * (0 - minRange) / (maxRange - minRange);
  3109. let zeroPoints = opts.height - Math.round(zeroHeight) - opts.area[2];
  3110. var points = getMountDataPoints(series, minRange, maxRange, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints, process);
  3111. switch (mountOption.type) {
  3112. case "bar":
  3113. for (let i = 0; i < points.length; i++) {
  3114. let item = points[i];
  3115. if (item !== null && i > leftNum && i < rightNum) {
  3116. var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
  3117. var height = opts.height - item.y - opts.area[2];
  3118. context.beginPath();
  3119. var fillColor = item.color || series[i].color;
  3120. var strokeColor = item.color || series[i].color;
  3121. if (mountOption.linearType !== "none") {
  3122. var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
  3123. if (mountOption.linearType == "opacity") {
  3124. grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
  3125. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3126. } else {
  3127. grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3128. grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3129. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3130. }
  3131. fillColor = grd;
  3132. }
  3133. if (mountOption.barBorderRadius && mountOption.barBorderRadius.length === 4 || mountOption.barBorderCircle === true) {
  3134. const left = startX;
  3135. const top = item.y > zeroPoints ? zeroPoints : item.y;
  3136. const width = item.width;
  3137. const height2 = Math.abs(zeroPoints - item.y);
  3138. if (mountOption.barBorderCircle) {
  3139. mountOption.barBorderRadius = [width / 2, width / 2, 0, 0];
  3140. }
  3141. if (item.y > zeroPoints) {
  3142. mountOption.barBorderRadius = [0, 0, width / 2, width / 2];
  3143. }
  3144. let [r0, r1, r2, r3] = mountOption.barBorderRadius;
  3145. let minRadius = Math.min(width / 2, height2 / 2);
  3146. r0 = r0 > minRadius ? minRadius : r0;
  3147. r1 = r1 > minRadius ? minRadius : r1;
  3148. r2 = r2 > minRadius ? minRadius : r2;
  3149. r3 = r3 > minRadius ? minRadius : r3;
  3150. r0 = r0 < 0 ? 0 : r0;
  3151. r1 = r1 < 0 ? 0 : r1;
  3152. r2 = r2 < 0 ? 0 : r2;
  3153. r3 = r3 < 0 ? 0 : r3;
  3154. context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
  3155. context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
  3156. context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
  3157. context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
  3158. } else {
  3159. context.moveTo(startX, item.y);
  3160. context.lineTo(startX + item.width, item.y);
  3161. context.lineTo(startX + item.width, zeroPoints);
  3162. context.lineTo(startX, zeroPoints);
  3163. context.lineTo(startX, item.y);
  3164. }
  3165. context.setStrokeStyle(strokeColor);
  3166. context.setFillStyle(fillColor);
  3167. if (mountOption.borderWidth > 0) {
  3168. context.setLineWidth(mountOption.borderWidth * opts.pix);
  3169. context.closePath();
  3170. context.stroke();
  3171. }
  3172. context.fill();
  3173. }
  3174. }
  3175. ;
  3176. break;
  3177. case "triangle":
  3178. for (let i = 0; i < points.length; i++) {
  3179. let item = points[i];
  3180. if (item !== null && i > leftNum && i < rightNum) {
  3181. var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
  3182. var height = opts.height - item.y - opts.area[2];
  3183. context.beginPath();
  3184. var fillColor = item.color || series[i].color;
  3185. var strokeColor = item.color || series[i].color;
  3186. if (mountOption.linearType !== "none") {
  3187. var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
  3188. if (mountOption.linearType == "opacity") {
  3189. grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
  3190. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3191. } else {
  3192. grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3193. grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3194. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3195. }
  3196. fillColor = grd;
  3197. }
  3198. context.moveTo(startX, zeroPoints);
  3199. context.lineTo(item.x, item.y);
  3200. context.lineTo(startX + item.width, zeroPoints);
  3201. context.setStrokeStyle(strokeColor);
  3202. context.setFillStyle(fillColor);
  3203. if (mountOption.borderWidth > 0) {
  3204. context.setLineWidth(mountOption.borderWidth * opts.pix);
  3205. context.stroke();
  3206. }
  3207. context.fill();
  3208. }
  3209. }
  3210. ;
  3211. break;
  3212. case "mount":
  3213. for (let i = 0; i < points.length; i++) {
  3214. let item = points[i];
  3215. if (item !== null && i > leftNum && i < rightNum) {
  3216. var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
  3217. var height = opts.height - item.y - opts.area[2];
  3218. context.beginPath();
  3219. var fillColor = item.color || series[i].color;
  3220. var strokeColor = item.color || series[i].color;
  3221. if (mountOption.linearType !== "none") {
  3222. var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
  3223. if (mountOption.linearType == "opacity") {
  3224. grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
  3225. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3226. } else {
  3227. grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3228. grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3229. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3230. }
  3231. fillColor = grd;
  3232. }
  3233. context.moveTo(startX, zeroPoints);
  3234. context.bezierCurveTo(item.x - item.width / 4, zeroPoints, item.x - item.width / 4, item.y, item.x, item.y);
  3235. context.bezierCurveTo(item.x + item.width / 4, item.y, item.x + item.width / 4, zeroPoints, startX + item.width, zeroPoints);
  3236. context.setStrokeStyle(strokeColor);
  3237. context.setFillStyle(fillColor);
  3238. if (mountOption.borderWidth > 0) {
  3239. context.setLineWidth(mountOption.borderWidth * opts.pix);
  3240. context.stroke();
  3241. }
  3242. context.fill();
  3243. }
  3244. }
  3245. ;
  3246. break;
  3247. case "sharp":
  3248. for (let i = 0; i < points.length; i++) {
  3249. let item = points[i];
  3250. if (item !== null && i > leftNum && i < rightNum) {
  3251. var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
  3252. var height = opts.height - item.y - opts.area[2];
  3253. context.beginPath();
  3254. var fillColor = item.color || series[i].color;
  3255. var strokeColor = item.color || series[i].color;
  3256. if (mountOption.linearType !== "none") {
  3257. var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
  3258. if (mountOption.linearType == "opacity") {
  3259. grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
  3260. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3261. } else {
  3262. grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3263. grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
  3264. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3265. }
  3266. fillColor = grd;
  3267. }
  3268. context.moveTo(startX, zeroPoints);
  3269. context.quadraticCurveTo(item.x - 0, zeroPoints - height / 4, item.x, item.y);
  3270. context.quadraticCurveTo(item.x + 0, zeroPoints - height / 4, startX + item.width, zeroPoints);
  3271. context.setStrokeStyle(strokeColor);
  3272. context.setFillStyle(fillColor);
  3273. if (mountOption.borderWidth > 0) {
  3274. context.setLineWidth(mountOption.borderWidth * opts.pix);
  3275. context.stroke();
  3276. }
  3277. context.fill();
  3278. }
  3279. }
  3280. ;
  3281. break;
  3282. }
  3283. if (opts.dataLabel !== false && process === 1) {
  3284. let ranges2, minRange2, maxRange2;
  3285. ranges2 = [].concat(opts.chartData.yAxisData.ranges[0]);
  3286. minRange2 = ranges2.pop();
  3287. maxRange2 = ranges2.shift();
  3288. var points = getMountDataPoints(series, minRange2, maxRange2, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints, process);
  3289. drawMountPointText(points, series, config2, context, opts, zeroPoints);
  3290. }
  3291. context.restore();
  3292. return {
  3293. xAxisPoints,
  3294. calPoints: points,
  3295. eachSpacing
  3296. };
  3297. }
  3298. function drawBarDataPoints(series, opts, config2, context) {
  3299. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3300. let yAxisPoints = [];
  3301. let eachSpacing = (opts.height - opts.area[0] - opts.area[2]) / opts.categories.length;
  3302. for (let i = 0; i < opts.categories.length; i++) {
  3303. yAxisPoints.push(opts.area[0] + eachSpacing / 2 + eachSpacing * i);
  3304. }
  3305. let columnOption = assign({}, {
  3306. type: "group",
  3307. width: eachSpacing / 2,
  3308. meterBorder: 4,
  3309. meterFillColor: "#FFFFFF",
  3310. barBorderCircle: false,
  3311. barBorderRadius: [],
  3312. seriesGap: 2,
  3313. linearType: "none",
  3314. linearOpacity: 1,
  3315. customColor: [],
  3316. colorStop: 0
  3317. }, opts.extra.bar);
  3318. let calPoints = [];
  3319. context.save();
  3320. let leftNum = -2;
  3321. let rightNum = yAxisPoints.length + 2;
  3322. if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
  3323. drawBarToolTipSplitArea(opts.tooltip.offset.y, opts, config2, context, eachSpacing);
  3324. }
  3325. columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
  3326. series.forEach(function(eachSeries, seriesIndex) {
  3327. let ranges, minRange, maxRange;
  3328. ranges = [].concat(opts.chartData.xAxisData.ranges);
  3329. maxRange = ranges.pop();
  3330. minRange = ranges.shift();
  3331. var data = eachSeries.data;
  3332. switch (columnOption.type) {
  3333. case "group":
  3334. var points = getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, process);
  3335. var tooltipPoints = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  3336. calPoints.push(tooltipPoints);
  3337. points = fixBarData(points, eachSpacing, series.length, seriesIndex, config2, opts);
  3338. for (let i = 0; i < points.length; i++) {
  3339. let item = points[i];
  3340. if (item !== null && i > leftNum && i < rightNum) {
  3341. var startX = opts.area[3];
  3342. var startY = item.y - item.width / 2;
  3343. var height = item.height;
  3344. context.beginPath();
  3345. var fillColor = item.color || eachSeries.color;
  3346. var strokeColor = item.color || eachSeries.color;
  3347. if (columnOption.linearType !== "none") {
  3348. var grd = context.createLinearGradient(startX, item.y, item.x, item.y);
  3349. if (columnOption.linearType == "opacity") {
  3350. grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
  3351. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3352. } else {
  3353. grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  3354. grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  3355. grd.addColorStop(1, hexToRgb(fillColor, 1));
  3356. }
  3357. fillColor = grd;
  3358. }
  3359. if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
  3360. const left = startX;
  3361. const width = item.width;
  3362. const top = item.y - item.width / 2;
  3363. const height2 = item.height;
  3364. if (columnOption.barBorderCircle) {
  3365. columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
  3366. }
  3367. let [r0, r1, r2, r3] = columnOption.barBorderRadius;
  3368. let minRadius = Math.min(width / 2, height2 / 2);
  3369. r0 = r0 > minRadius ? minRadius : r0;
  3370. r1 = r1 > minRadius ? minRadius : r1;
  3371. r2 = r2 > minRadius ? minRadius : r2;
  3372. r3 = r3 > minRadius ? minRadius : r3;
  3373. r0 = r0 < 0 ? 0 : r0;
  3374. r1 = r1 < 0 ? 0 : r1;
  3375. r2 = r2 < 0 ? 0 : r2;
  3376. r3 = r3 < 0 ? 0 : r3;
  3377. context.arc(left + r3, top + r3, r3, -Math.PI, -Math.PI / 2);
  3378. context.arc(item.x - r0, top + r0, r0, -Math.PI / 2, 0);
  3379. context.arc(item.x - r1, top + width - r1, r1, 0, Math.PI / 2);
  3380. context.arc(left + r2, top + width - r2, r2, Math.PI / 2, Math.PI);
  3381. } else {
  3382. context.moveTo(startX, startY);
  3383. context.lineTo(item.x, startY);
  3384. context.lineTo(item.x, startY + item.width);
  3385. context.lineTo(startX, startY + item.width);
  3386. context.lineTo(startX, startY);
  3387. context.setLineWidth(1);
  3388. context.setStrokeStyle(strokeColor);
  3389. }
  3390. context.setFillStyle(fillColor);
  3391. context.closePath();
  3392. context.fill();
  3393. }
  3394. }
  3395. ;
  3396. break;
  3397. case "stack":
  3398. var points = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  3399. calPoints.push(points);
  3400. points = fixBarStackData(points, eachSpacing, series.length, seriesIndex, config2, opts, series);
  3401. for (let i = 0; i < points.length; i++) {
  3402. let item = points[i];
  3403. if (item !== null && i > leftNum && i < rightNum) {
  3404. context.beginPath();
  3405. var fillColor = item.color || eachSeries.color;
  3406. var startX = item.x0;
  3407. context.setFillStyle(fillColor);
  3408. context.moveTo(startX, item.y - item.width / 2);
  3409. context.fillRect(startX, item.y - item.width / 2, item.height, item.width);
  3410. context.closePath();
  3411. context.fill();
  3412. }
  3413. }
  3414. ;
  3415. break;
  3416. }
  3417. });
  3418. if (opts.dataLabel !== false && process === 1) {
  3419. series.forEach(function(eachSeries, seriesIndex) {
  3420. let ranges, minRange, maxRange;
  3421. ranges = [].concat(opts.chartData.xAxisData.ranges);
  3422. maxRange = ranges.pop();
  3423. minRange = ranges.shift();
  3424. var data = eachSeries.data;
  3425. switch (columnOption.type) {
  3426. case "group":
  3427. var points = getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, process);
  3428. points = fixBarData(points, eachSpacing, series.length, seriesIndex, config2, opts);
  3429. drawBarPointText(points, eachSeries, config2, context, opts);
  3430. break;
  3431. case "stack":
  3432. var points = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
  3433. drawBarPointText(points, eachSeries, config2, context, opts);
  3434. break;
  3435. }
  3436. });
  3437. }
  3438. return {
  3439. yAxisPoints,
  3440. calPoints,
  3441. eachSpacing
  3442. };
  3443. }
  3444. function drawCandleDataPoints(series, seriesMA, opts, config2, context) {
  3445. var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
  3446. var candleOption = assign({}, {
  3447. color: {},
  3448. average: {}
  3449. }, opts.extra.candle);
  3450. candleOption.color = assign({}, {
  3451. upLine: "#f04864",
  3452. upFill: "#f04864",
  3453. downLine: "#2fc25b",
  3454. downFill: "#2fc25b"
  3455. }, candleOption.color);
  3456. candleOption.average = assign({}, {
  3457. show: false,
  3458. name: [],
  3459. day: [],
  3460. color: config2.color
  3461. }, candleOption.average);
  3462. opts.extra.candle = candleOption;
  3463. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3464. let calPoints = [];
  3465. context.save();
  3466. let leftNum = -2;
  3467. let rightNum = xAxisPoints.length + 2;
  3468. let leftSpace = 0;
  3469. let rightSpace = opts.width + eachSpacing;
  3470. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3471. context.translate(opts._scrollDistance_, 0);
  3472. leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
  3473. rightNum = leftNum + opts.xAxis.itemCount + 4;
  3474. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  3475. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  3476. }
  3477. if (candleOption.average.show || seriesMA) {
  3478. seriesMA.forEach(function(eachSeries, seriesIndex) {
  3479. let ranges, minRange, maxRange;
  3480. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3481. minRange = ranges.pop();
  3482. maxRange = ranges.shift();
  3483. var data = eachSeries.data;
  3484. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3485. var splitPointList = splitPoints(points, eachSeries);
  3486. for (let i = 0; i < splitPointList.length; i++) {
  3487. let points2 = splitPointList[i];
  3488. context.beginPath();
  3489. context.setStrokeStyle(eachSeries.color);
  3490. context.setLineWidth(1);
  3491. if (points2.length === 1) {
  3492. context.moveTo(points2[0].x, points2[0].y);
  3493. context.arc(points2[0].x, points2[0].y, 1, 0, 2 * Math.PI);
  3494. } else {
  3495. context.moveTo(points2[0].x, points2[0].y);
  3496. let startPoint = 0;
  3497. for (let j = 0; j < points2.length; j++) {
  3498. let item = points2[j];
  3499. if (startPoint == 0 && item.x > leftSpace) {
  3500. context.moveTo(item.x, item.y);
  3501. startPoint = 1;
  3502. }
  3503. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3504. var ctrlPoint = createCurveControlPoints(points2, j - 1);
  3505. context.bezierCurveTo(
  3506. ctrlPoint.ctrA.x,
  3507. ctrlPoint.ctrA.y,
  3508. ctrlPoint.ctrB.x,
  3509. ctrlPoint.ctrB.y,
  3510. item.x,
  3511. item.y
  3512. );
  3513. }
  3514. }
  3515. context.moveTo(points2[0].x, points2[0].y);
  3516. }
  3517. context.closePath();
  3518. context.stroke();
  3519. }
  3520. });
  3521. }
  3522. series.forEach(function(eachSeries, seriesIndex) {
  3523. let ranges, minRange, maxRange;
  3524. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3525. minRange = ranges.pop();
  3526. maxRange = ranges.shift();
  3527. var data = eachSeries.data;
  3528. var points = getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3529. calPoints.push(points);
  3530. var splitPointList = splitPoints(points, eachSeries);
  3531. for (let i = 0; i < splitPointList[0].length; i++) {
  3532. if (i > leftNum && i < rightNum) {
  3533. let item = splitPointList[0][i];
  3534. context.beginPath();
  3535. if (data[i][1] - data[i][0] > 0) {
  3536. context.setStrokeStyle(candleOption.color.upLine);
  3537. context.setFillStyle(candleOption.color.upFill);
  3538. context.setLineWidth(1 * opts.pix);
  3539. context.moveTo(item[3].x, item[3].y);
  3540. context.lineTo(item[1].x, item[1].y);
  3541. context.lineTo(item[1].x - eachSpacing / 4, item[1].y);
  3542. context.lineTo(item[0].x - eachSpacing / 4, item[0].y);
  3543. context.lineTo(item[0].x, item[0].y);
  3544. context.lineTo(item[2].x, item[2].y);
  3545. context.lineTo(item[0].x, item[0].y);
  3546. context.lineTo(item[0].x + eachSpacing / 4, item[0].y);
  3547. context.lineTo(item[1].x + eachSpacing / 4, item[1].y);
  3548. context.lineTo(item[1].x, item[1].y);
  3549. context.moveTo(item[3].x, item[3].y);
  3550. } else {
  3551. context.setStrokeStyle(candleOption.color.downLine);
  3552. context.setFillStyle(candleOption.color.downFill);
  3553. context.setLineWidth(1 * opts.pix);
  3554. context.moveTo(item[3].x, item[3].y);
  3555. context.lineTo(item[0].x, item[0].y);
  3556. context.lineTo(item[0].x - eachSpacing / 4, item[0].y);
  3557. context.lineTo(item[1].x - eachSpacing / 4, item[1].y);
  3558. context.lineTo(item[1].x, item[1].y);
  3559. context.lineTo(item[2].x, item[2].y);
  3560. context.lineTo(item[1].x, item[1].y);
  3561. context.lineTo(item[1].x + eachSpacing / 4, item[1].y);
  3562. context.lineTo(item[0].x + eachSpacing / 4, item[0].y);
  3563. context.lineTo(item[0].x, item[0].y);
  3564. context.moveTo(item[3].x, item[3].y);
  3565. }
  3566. context.closePath();
  3567. context.fill();
  3568. context.stroke();
  3569. }
  3570. }
  3571. });
  3572. context.restore();
  3573. return {
  3574. xAxisPoints,
  3575. calPoints,
  3576. eachSpacing
  3577. };
  3578. }
  3579. function drawAreaDataPoints(series, opts, config2, context) {
  3580. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3581. var areaOption = assign({}, {
  3582. type: "straight",
  3583. opacity: 0.2,
  3584. addLine: false,
  3585. width: 2,
  3586. gradient: false,
  3587. activeType: "none"
  3588. }, opts.extra.area);
  3589. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3590. let endY = opts.height - opts.area[2];
  3591. let calPoints = [];
  3592. context.save();
  3593. let leftSpace = 0;
  3594. let rightSpace = opts.width + eachSpacing;
  3595. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3596. context.translate(opts._scrollDistance_, 0);
  3597. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  3598. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  3599. }
  3600. series.forEach(function(eachSeries, seriesIndex) {
  3601. let ranges, minRange, maxRange;
  3602. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3603. minRange = ranges.pop();
  3604. maxRange = ranges.shift();
  3605. let data = eachSeries.data;
  3606. let points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3607. calPoints.push(points);
  3608. let splitPointList = splitPoints(points, eachSeries);
  3609. for (let i = 0; i < splitPointList.length; i++) {
  3610. let points2 = splitPointList[i];
  3611. context.beginPath();
  3612. context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity));
  3613. if (areaOption.gradient) {
  3614. let gradient = context.createLinearGradient(0, opts.area[0], 0, opts.height - opts.area[2]);
  3615. gradient.addColorStop("0", hexToRgb(eachSeries.color, areaOption.opacity));
  3616. gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
  3617. context.setFillStyle(gradient);
  3618. } else {
  3619. context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity));
  3620. }
  3621. context.setLineWidth(areaOption.width * opts.pix);
  3622. if (points2.length > 1) {
  3623. let firstPoint = points2[0];
  3624. let lastPoint = points2[points2.length - 1];
  3625. context.moveTo(firstPoint.x, firstPoint.y);
  3626. let startPoint = 0;
  3627. if (areaOption.type === "curve") {
  3628. for (let j = 0; j < points2.length; j++) {
  3629. let item = points2[j];
  3630. if (startPoint == 0 && item.x > leftSpace) {
  3631. context.moveTo(item.x, item.y);
  3632. startPoint = 1;
  3633. }
  3634. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3635. let ctrlPoint = createCurveControlPoints(points2, j - 1);
  3636. context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
  3637. }
  3638. }
  3639. ;
  3640. }
  3641. if (areaOption.type === "straight") {
  3642. for (let j = 0; j < points2.length; j++) {
  3643. let item = points2[j];
  3644. if (startPoint == 0 && item.x > leftSpace) {
  3645. context.moveTo(item.x, item.y);
  3646. startPoint = 1;
  3647. }
  3648. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3649. context.lineTo(item.x, item.y);
  3650. }
  3651. }
  3652. ;
  3653. }
  3654. if (areaOption.type === "step") {
  3655. for (let j = 0; j < points2.length; j++) {
  3656. let item = points2[j];
  3657. if (startPoint == 0 && item.x > leftSpace) {
  3658. context.moveTo(item.x, item.y);
  3659. startPoint = 1;
  3660. }
  3661. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3662. context.lineTo(item.x, points2[j - 1].y);
  3663. context.lineTo(item.x, item.y);
  3664. }
  3665. }
  3666. ;
  3667. }
  3668. context.lineTo(lastPoint.x, endY);
  3669. context.lineTo(firstPoint.x, endY);
  3670. context.lineTo(firstPoint.x, firstPoint.y);
  3671. } else {
  3672. let item = points2[0];
  3673. context.moveTo(item.x - eachSpacing / 2, item.y);
  3674. }
  3675. context.closePath();
  3676. context.fill();
  3677. if (areaOption.addLine) {
  3678. if (eachSeries.lineType == "dash") {
  3679. let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
  3680. dashLength *= opts.pix;
  3681. context.setLineDash([dashLength, dashLength]);
  3682. }
  3683. context.beginPath();
  3684. context.setStrokeStyle(eachSeries.color);
  3685. context.setLineWidth(areaOption.width * opts.pix);
  3686. if (points2.length === 1) {
  3687. context.moveTo(points2[0].x, points2[0].y);
  3688. } else {
  3689. context.moveTo(points2[0].x, points2[0].y);
  3690. let startPoint = 0;
  3691. if (areaOption.type === "curve") {
  3692. for (let j = 0; j < points2.length; j++) {
  3693. let item = points2[j];
  3694. if (startPoint == 0 && item.x > leftSpace) {
  3695. context.moveTo(item.x, item.y);
  3696. startPoint = 1;
  3697. }
  3698. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3699. let ctrlPoint = createCurveControlPoints(points2, j - 1);
  3700. context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
  3701. }
  3702. }
  3703. ;
  3704. }
  3705. if (areaOption.type === "straight") {
  3706. for (let j = 0; j < points2.length; j++) {
  3707. let item = points2[j];
  3708. if (startPoint == 0 && item.x > leftSpace) {
  3709. context.moveTo(item.x, item.y);
  3710. startPoint = 1;
  3711. }
  3712. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3713. context.lineTo(item.x, item.y);
  3714. }
  3715. }
  3716. ;
  3717. }
  3718. if (areaOption.type === "step") {
  3719. for (let j = 0; j < points2.length; j++) {
  3720. let item = points2[j];
  3721. if (startPoint == 0 && item.x > leftSpace) {
  3722. context.moveTo(item.x, item.y);
  3723. startPoint = 1;
  3724. }
  3725. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3726. context.lineTo(item.x, points2[j - 1].y);
  3727. context.lineTo(item.x, item.y);
  3728. }
  3729. }
  3730. ;
  3731. }
  3732. context.moveTo(points2[0].x, points2[0].y);
  3733. }
  3734. context.stroke();
  3735. context.setLineDash([]);
  3736. }
  3737. }
  3738. if (opts.dataPointShape !== false) {
  3739. drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
  3740. }
  3741. drawActivePoint(points, eachSeries.color, eachSeries.pointShape, context, opts, areaOption, seriesIndex);
  3742. });
  3743. if (opts.dataLabel !== false && process === 1) {
  3744. series.forEach(function(eachSeries, seriesIndex) {
  3745. let ranges, minRange, maxRange;
  3746. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3747. minRange = ranges.pop();
  3748. maxRange = ranges.shift();
  3749. var data = eachSeries.data;
  3750. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3751. drawPointText(points, eachSeries, config2, context, opts);
  3752. });
  3753. }
  3754. context.restore();
  3755. return {
  3756. xAxisPoints,
  3757. calPoints,
  3758. eachSpacing
  3759. };
  3760. }
  3761. function drawScatterDataPoints(series, opts, config2, context) {
  3762. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3763. var scatterOption = assign({}, {
  3764. type: "circle"
  3765. }, opts.extra.scatter);
  3766. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3767. var calPoints = [];
  3768. context.save();
  3769. let leftSpace = 0;
  3770. let rightSpace = opts.width + eachSpacing;
  3771. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3772. context.translate(opts._scrollDistance_, 0);
  3773. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  3774. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  3775. }
  3776. series.forEach(function(eachSeries, seriesIndex) {
  3777. let ranges, minRange, maxRange;
  3778. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3779. minRange = ranges.pop();
  3780. maxRange = ranges.shift();
  3781. var data = eachSeries.data;
  3782. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3783. context.beginPath();
  3784. context.setStrokeStyle(eachSeries.color);
  3785. context.setFillStyle(eachSeries.color);
  3786. context.setLineWidth(1 * opts.pix);
  3787. var shape = eachSeries.pointShape;
  3788. if (shape === "diamond") {
  3789. points.forEach(function(item, index) {
  3790. if (item !== null) {
  3791. context.moveTo(item.x, item.y - 4.5);
  3792. context.lineTo(item.x - 4.5, item.y);
  3793. context.lineTo(item.x, item.y + 4.5);
  3794. context.lineTo(item.x + 4.5, item.y);
  3795. context.lineTo(item.x, item.y - 4.5);
  3796. }
  3797. });
  3798. } else if (shape === "circle") {
  3799. points.forEach(function(item, index) {
  3800. if (item !== null) {
  3801. context.moveTo(item.x + 2.5 * opts.pix, item.y);
  3802. context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
  3803. }
  3804. });
  3805. } else if (shape === "square") {
  3806. points.forEach(function(item, index) {
  3807. if (item !== null) {
  3808. context.moveTo(item.x - 3.5, item.y - 3.5);
  3809. context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
  3810. }
  3811. });
  3812. } else if (shape === "triangle") {
  3813. points.forEach(function(item, index) {
  3814. if (item !== null) {
  3815. context.moveTo(item.x, item.y - 4.5);
  3816. context.lineTo(item.x - 4.5, item.y + 4.5);
  3817. context.lineTo(item.x + 4.5, item.y + 4.5);
  3818. context.lineTo(item.x, item.y - 4.5);
  3819. }
  3820. });
  3821. } else if (shape === "triangle") {
  3822. return;
  3823. }
  3824. context.closePath();
  3825. context.fill();
  3826. context.stroke();
  3827. });
  3828. if (opts.dataLabel !== false && process === 1) {
  3829. series.forEach(function(eachSeries, seriesIndex) {
  3830. let ranges, minRange, maxRange;
  3831. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3832. minRange = ranges.pop();
  3833. maxRange = ranges.shift();
  3834. var data = eachSeries.data;
  3835. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3836. drawPointText(points, eachSeries, config2, context, opts);
  3837. });
  3838. }
  3839. context.restore();
  3840. return {
  3841. xAxisPoints,
  3842. calPoints,
  3843. eachSpacing
  3844. };
  3845. }
  3846. function drawBubbleDataPoints(series, opts, config2, context) {
  3847. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3848. var bubbleOption = assign({}, {
  3849. opacity: 1,
  3850. border: 2
  3851. }, opts.extra.bubble);
  3852. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3853. var calPoints = [];
  3854. context.save();
  3855. let leftSpace = 0;
  3856. let rightSpace = opts.width + eachSpacing;
  3857. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3858. context.translate(opts._scrollDistance_, 0);
  3859. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  3860. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  3861. }
  3862. series.forEach(function(eachSeries, seriesIndex) {
  3863. let ranges, minRange, maxRange;
  3864. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3865. minRange = ranges.pop();
  3866. maxRange = ranges.shift();
  3867. var data = eachSeries.data;
  3868. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  3869. context.beginPath();
  3870. context.setStrokeStyle(eachSeries.color);
  3871. context.setLineWidth(bubbleOption.border * opts.pix);
  3872. context.setFillStyle(hexToRgb(eachSeries.color, bubbleOption.opacity));
  3873. points.forEach(function(item, index) {
  3874. context.moveTo(item.x + item.r, item.y);
  3875. context.arc(item.x, item.y, item.r * opts.pix, 0, 2 * Math.PI, false);
  3876. });
  3877. context.closePath();
  3878. context.fill();
  3879. context.stroke();
  3880. if (opts.dataLabel !== false && process === 1) {
  3881. points.forEach(function(item, index) {
  3882. context.beginPath();
  3883. var fontSize = eachSeries.textSize * opts.pix || config2.fontSize;
  3884. context.setFontSize(fontSize);
  3885. context.setFillStyle(eachSeries.textColor || "#FFFFFF");
  3886. context.setTextAlign("center");
  3887. context.fillText(String(item.t), item.x, item.y + fontSize / 2);
  3888. context.closePath();
  3889. context.stroke();
  3890. context.setTextAlign("left");
  3891. });
  3892. }
  3893. });
  3894. context.restore();
  3895. return {
  3896. xAxisPoints,
  3897. calPoints,
  3898. eachSpacing
  3899. };
  3900. }
  3901. function drawLineDataPoints(series, opts, config2, context) {
  3902. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  3903. var lineOption = assign({}, {
  3904. type: "straight",
  3905. width: 2,
  3906. activeType: "none",
  3907. linearType: "none",
  3908. onShadow: false,
  3909. animation: "vertical"
  3910. }, opts.extra.line);
  3911. lineOption.width *= opts.pix;
  3912. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  3913. var calPoints = [];
  3914. context.save();
  3915. let leftSpace = 0;
  3916. let rightSpace = opts.width + eachSpacing;
  3917. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  3918. context.translate(opts._scrollDistance_, 0);
  3919. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  3920. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  3921. }
  3922. series.forEach(function(eachSeries, seriesIndex) {
  3923. context.beginPath();
  3924. context.setStrokeStyle(eachSeries.color);
  3925. context.moveTo(-1e4, -1e4);
  3926. context.lineTo(-10001, -10001);
  3927. context.stroke();
  3928. let ranges, minRange, maxRange;
  3929. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  3930. minRange = ranges.pop();
  3931. maxRange = ranges.shift();
  3932. var data = eachSeries.data;
  3933. var points = getLineDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, lineOption, process);
  3934. calPoints.push(points);
  3935. var splitPointList = splitPoints(points, eachSeries);
  3936. if (eachSeries.lineType == "dash") {
  3937. let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
  3938. dashLength *= opts.pix;
  3939. context.setLineDash([dashLength, dashLength]);
  3940. }
  3941. context.beginPath();
  3942. var strokeColor = eachSeries.color;
  3943. if (lineOption.linearType !== "none" && eachSeries.linearColor && eachSeries.linearColor.length > 0) {
  3944. var grd = context.createLinearGradient(opts.chartData.xAxisData.startX, opts.height / 2, opts.chartData.xAxisData.endX, opts.height / 2);
  3945. for (var i = 0; i < eachSeries.linearColor.length; i++) {
  3946. grd.addColorStop(eachSeries.linearColor[i][0], hexToRgb(eachSeries.linearColor[i][1], 1));
  3947. }
  3948. strokeColor = grd;
  3949. }
  3950. context.setStrokeStyle(strokeColor);
  3951. if (lineOption.onShadow == true && eachSeries.setShadow && eachSeries.setShadow.length > 0) {
  3952. context.setShadow(eachSeries.setShadow[0], eachSeries.setShadow[1], eachSeries.setShadow[2], eachSeries.setShadow[3]);
  3953. } else {
  3954. context.setShadow(0, 0, 0, "rgba(0,0,0,0)");
  3955. }
  3956. context.setLineWidth(lineOption.width);
  3957. splitPointList.forEach(function(points2, index) {
  3958. if (points2.length === 1) {
  3959. context.moveTo(points2[0].x, points2[0].y);
  3960. } else {
  3961. context.moveTo(points2[0].x, points2[0].y);
  3962. let startPoint = 0;
  3963. if (lineOption.type === "curve") {
  3964. for (let j = 0; j < points2.length; j++) {
  3965. let item = points2[j];
  3966. if (startPoint == 0 && item.x > leftSpace) {
  3967. context.moveTo(item.x, item.y);
  3968. startPoint = 1;
  3969. }
  3970. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3971. var ctrlPoint = createCurveControlPoints(points2, j - 1);
  3972. context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
  3973. }
  3974. }
  3975. ;
  3976. }
  3977. if (lineOption.type === "straight") {
  3978. for (let j = 0; j < points2.length; j++) {
  3979. let item = points2[j];
  3980. if (startPoint == 0 && item.x > leftSpace) {
  3981. context.moveTo(item.x, item.y);
  3982. startPoint = 1;
  3983. }
  3984. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3985. context.lineTo(item.x, item.y);
  3986. }
  3987. }
  3988. ;
  3989. }
  3990. if (lineOption.type === "step") {
  3991. for (let j = 0; j < points2.length; j++) {
  3992. let item = points2[j];
  3993. if (startPoint == 0 && item.x > leftSpace) {
  3994. context.moveTo(item.x, item.y);
  3995. startPoint = 1;
  3996. }
  3997. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  3998. context.lineTo(item.x, points2[j - 1].y);
  3999. context.lineTo(item.x, item.y);
  4000. }
  4001. }
  4002. ;
  4003. }
  4004. context.moveTo(points2[0].x, points2[0].y);
  4005. }
  4006. });
  4007. context.stroke();
  4008. context.setLineDash([]);
  4009. if (opts.dataPointShape !== false) {
  4010. drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
  4011. }
  4012. drawActivePoint(points, eachSeries.color, eachSeries.pointShape, context, opts, lineOption);
  4013. });
  4014. if (opts.dataLabel !== false && process === 1) {
  4015. series.forEach(function(eachSeries, seriesIndex) {
  4016. let ranges, minRange, maxRange;
  4017. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  4018. minRange = ranges.pop();
  4019. maxRange = ranges.shift();
  4020. var data = eachSeries.data;
  4021. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  4022. drawPointText(points, eachSeries, config2, context, opts);
  4023. });
  4024. }
  4025. context.restore();
  4026. return {
  4027. xAxisPoints,
  4028. calPoints,
  4029. eachSpacing
  4030. };
  4031. }
  4032. function drawMixDataPoints(series, opts, config2, context) {
  4033. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  4034. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
  4035. let columnOption = assign({}, {
  4036. width: eachSpacing / 2,
  4037. barBorderCircle: false,
  4038. barBorderRadius: [],
  4039. seriesGap: 2,
  4040. linearType: "none",
  4041. linearOpacity: 1,
  4042. customColor: [],
  4043. colorStop: 0
  4044. }, opts.extra.mix.column);
  4045. let areaOption = assign({}, {
  4046. opacity: 0.2,
  4047. gradient: false
  4048. }, opts.extra.mix.area);
  4049. let lineOption = assign({}, {
  4050. width: 2
  4051. }, opts.extra.mix.line);
  4052. let endY = opts.height - opts.area[2];
  4053. let calPoints = [];
  4054. var columnIndex = 0;
  4055. var columnLength = 0;
  4056. series.forEach(function(eachSeries, seriesIndex) {
  4057. if (eachSeries.type == "column") {
  4058. columnLength += 1;
  4059. }
  4060. });
  4061. context.save();
  4062. let leftNum = -2;
  4063. let rightNum = xAxisPoints.length + 2;
  4064. let leftSpace = 0;
  4065. let rightSpace = opts.width + eachSpacing;
  4066. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  4067. context.translate(opts._scrollDistance_, 0);
  4068. leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
  4069. rightNum = leftNum + opts.xAxis.itemCount + 4;
  4070. leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
  4071. rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
  4072. }
  4073. columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
  4074. series.forEach(function(eachSeries, seriesIndex) {
  4075. let ranges, minRange, maxRange;
  4076. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  4077. minRange = ranges.pop();
  4078. maxRange = ranges.shift();
  4079. var data = eachSeries.data;
  4080. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  4081. calPoints.push(points);
  4082. if (eachSeries.type == "column") {
  4083. points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config2, opts);
  4084. for (let i = 0; i < points.length; i++) {
  4085. let item = points[i];
  4086. if (item !== null && i > leftNum && i < rightNum) {
  4087. var startX = item.x - item.width / 2;
  4088. var height = opts.height - item.y - opts.area[2];
  4089. context.beginPath();
  4090. var fillColor = item.color || eachSeries.color;
  4091. var strokeColor = item.color || eachSeries.color;
  4092. if (columnOption.linearType !== "none") {
  4093. var grd = context.createLinearGradient(startX, item.y, startX, opts.height - opts.area[2]);
  4094. if (columnOption.linearType == "opacity") {
  4095. grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
  4096. grd.addColorStop(1, hexToRgb(fillColor, 1));
  4097. } else {
  4098. grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  4099. grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
  4100. grd.addColorStop(1, hexToRgb(fillColor, 1));
  4101. }
  4102. fillColor = grd;
  4103. }
  4104. if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle) {
  4105. const left = startX;
  4106. const top = item.y;
  4107. const width = item.width;
  4108. const height2 = opts.height - opts.area[2] - item.y;
  4109. if (columnOption.barBorderCircle) {
  4110. columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
  4111. }
  4112. let [r0, r1, r2, r3] = columnOption.barBorderRadius;
  4113. let minRadius = Math.min(width / 2, height2 / 2);
  4114. r0 = r0 > minRadius ? minRadius : r0;
  4115. r1 = r1 > minRadius ? minRadius : r1;
  4116. r2 = r2 > minRadius ? minRadius : r2;
  4117. r3 = r3 > minRadius ? minRadius : r3;
  4118. r0 = r0 < 0 ? 0 : r0;
  4119. r1 = r1 < 0 ? 0 : r1;
  4120. r2 = r2 < 0 ? 0 : r2;
  4121. r3 = r3 < 0 ? 0 : r3;
  4122. context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
  4123. context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
  4124. context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
  4125. context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
  4126. } else {
  4127. context.moveTo(startX, item.y);
  4128. context.lineTo(startX + item.width, item.y);
  4129. context.lineTo(startX + item.width, opts.height - opts.area[2]);
  4130. context.lineTo(startX, opts.height - opts.area[2]);
  4131. context.lineTo(startX, item.y);
  4132. context.setLineWidth(1);
  4133. context.setStrokeStyle(strokeColor);
  4134. }
  4135. context.setFillStyle(fillColor);
  4136. context.closePath();
  4137. context.fill();
  4138. }
  4139. }
  4140. columnIndex += 1;
  4141. }
  4142. if (eachSeries.type == "area") {
  4143. let splitPointList2 = splitPoints(points, eachSeries);
  4144. for (let i = 0; i < splitPointList2.length; i++) {
  4145. let points2 = splitPointList2[i];
  4146. context.beginPath();
  4147. context.setStrokeStyle(eachSeries.color);
  4148. context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity));
  4149. if (areaOption.gradient) {
  4150. let gradient = context.createLinearGradient(0, opts.area[0], 0, opts.height - opts.area[2]);
  4151. gradient.addColorStop("0", hexToRgb(eachSeries.color, areaOption.opacity));
  4152. gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
  4153. context.setFillStyle(gradient);
  4154. } else {
  4155. context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity));
  4156. }
  4157. context.setLineWidth(2 * opts.pix);
  4158. if (points2.length > 1) {
  4159. var firstPoint = points2[0];
  4160. let lastPoint = points2[points2.length - 1];
  4161. context.moveTo(firstPoint.x, firstPoint.y);
  4162. let startPoint = 0;
  4163. if (eachSeries.style === "curve") {
  4164. for (let j = 0; j < points2.length; j++) {
  4165. let item = points2[j];
  4166. if (startPoint == 0 && item.x > leftSpace) {
  4167. context.moveTo(item.x, item.y);
  4168. startPoint = 1;
  4169. }
  4170. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  4171. var ctrlPoint = createCurveControlPoints(points2, j - 1);
  4172. context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
  4173. }
  4174. }
  4175. ;
  4176. } else {
  4177. for (let j = 0; j < points2.length; j++) {
  4178. let item = points2[j];
  4179. if (startPoint == 0 && item.x > leftSpace) {
  4180. context.moveTo(item.x, item.y);
  4181. startPoint = 1;
  4182. }
  4183. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  4184. context.lineTo(item.x, item.y);
  4185. }
  4186. }
  4187. ;
  4188. }
  4189. context.lineTo(lastPoint.x, endY);
  4190. context.lineTo(firstPoint.x, endY);
  4191. context.lineTo(firstPoint.x, firstPoint.y);
  4192. } else {
  4193. let item = points2[0];
  4194. context.moveTo(item.x - eachSpacing / 2, item.y);
  4195. }
  4196. context.closePath();
  4197. context.fill();
  4198. }
  4199. }
  4200. if (eachSeries.type == "line") {
  4201. var splitPointList = splitPoints(points, eachSeries);
  4202. splitPointList.forEach(function(points2, index) {
  4203. if (eachSeries.lineType == "dash") {
  4204. let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
  4205. dashLength *= opts.pix;
  4206. context.setLineDash([dashLength, dashLength]);
  4207. }
  4208. context.beginPath();
  4209. context.setStrokeStyle(eachSeries.color);
  4210. context.setLineWidth(lineOption.width * opts.pix);
  4211. if (points2.length === 1) {
  4212. context.moveTo(points2[0].x, points2[0].y);
  4213. } else {
  4214. context.moveTo(points2[0].x, points2[0].y);
  4215. let startPoint = 0;
  4216. if (eachSeries.style == "curve") {
  4217. for (let j = 0; j < points2.length; j++) {
  4218. let item = points2[j];
  4219. if (startPoint == 0 && item.x > leftSpace) {
  4220. context.moveTo(item.x, item.y);
  4221. startPoint = 1;
  4222. }
  4223. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  4224. var ctrlPoint2 = createCurveControlPoints(points2, j - 1);
  4225. context.bezierCurveTo(
  4226. ctrlPoint2.ctrA.x,
  4227. ctrlPoint2.ctrA.y,
  4228. ctrlPoint2.ctrB.x,
  4229. ctrlPoint2.ctrB.y,
  4230. item.x,
  4231. item.y
  4232. );
  4233. }
  4234. }
  4235. } else {
  4236. for (let j = 0; j < points2.length; j++) {
  4237. let item = points2[j];
  4238. if (startPoint == 0 && item.x > leftSpace) {
  4239. context.moveTo(item.x, item.y);
  4240. startPoint = 1;
  4241. }
  4242. if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
  4243. context.lineTo(item.x, item.y);
  4244. }
  4245. }
  4246. }
  4247. context.moveTo(points2[0].x, points2[0].y);
  4248. }
  4249. context.stroke();
  4250. context.setLineDash([]);
  4251. });
  4252. }
  4253. if (eachSeries.type == "point") {
  4254. eachSeries.addPoint = true;
  4255. }
  4256. if (eachSeries.addPoint == true && eachSeries.type !== "column") {
  4257. drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
  4258. }
  4259. });
  4260. if (opts.dataLabel !== false && process === 1) {
  4261. var columnIndex = 0;
  4262. series.forEach(function(eachSeries, seriesIndex) {
  4263. let ranges, minRange, maxRange;
  4264. ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
  4265. minRange = ranges.pop();
  4266. maxRange = ranges.shift();
  4267. var data = eachSeries.data;
  4268. var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
  4269. if (eachSeries.type !== "column") {
  4270. drawPointText(points, eachSeries, config2, context, opts);
  4271. } else {
  4272. points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config2, opts);
  4273. drawPointText(points, eachSeries, config2, context, opts);
  4274. columnIndex += 1;
  4275. }
  4276. });
  4277. }
  4278. context.restore();
  4279. return {
  4280. xAxisPoints,
  4281. calPoints,
  4282. eachSpacing
  4283. };
  4284. }
  4285. function drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints) {
  4286. var toolTipOption = opts.extra.tooltip || {};
  4287. if (toolTipOption.horizentalLine && opts.tooltip && process === 1 && (opts.type == "line" || opts.type == "area" || opts.type == "column" || opts.type == "mount" || opts.type == "candle" || opts.type == "mix")) {
  4288. drawToolTipHorizentalLine(opts, config2, context, eachSpacing, xAxisPoints);
  4289. }
  4290. context.save();
  4291. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
  4292. context.translate(opts._scrollDistance_, 0);
  4293. }
  4294. if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
  4295. drawToolTip(opts.tooltip.textList, opts.tooltip.offset, opts, config2, context, eachSpacing, xAxisPoints);
  4296. }
  4297. context.restore();
  4298. }
  4299. function drawXAxis(categories, opts, config2, context) {
  4300. let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, startX = xAxisData.startX, endX = xAxisData.endX, eachSpacing = xAxisData.eachSpacing;
  4301. var boundaryGap = "center";
  4302. if (opts.type == "bar" || opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble") {
  4303. boundaryGap = opts.xAxis.boundaryGap;
  4304. }
  4305. var startY = opts.height - opts.area[2];
  4306. var endY = opts.area[0];
  4307. if (opts.enableScroll && opts.xAxis.scrollShow) {
  4308. var scrollY = opts.height - opts.area[2] + config2.xAxisHeight;
  4309. var scrollScreenWidth = endX - startX;
  4310. var scrollTotalWidth = eachSpacing * (xAxisPoints.length - 1);
  4311. if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
  4312. if (opts.extra.mount.widthRatio > 2)
  4313. opts.extra.mount.widthRatio = 2;
  4314. scrollTotalWidth += (opts.extra.mount.widthRatio - 1) * eachSpacing;
  4315. }
  4316. var scrollWidth = scrollScreenWidth * scrollScreenWidth / scrollTotalWidth;
  4317. var scrollLeft = 0;
  4318. if (opts._scrollDistance_) {
  4319. scrollLeft = -opts._scrollDistance_ * scrollScreenWidth / scrollTotalWidth;
  4320. }
  4321. context.beginPath();
  4322. context.setLineCap("round");
  4323. context.setLineWidth(6 * opts.pix);
  4324. context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || "#EFEBEF");
  4325. context.moveTo(startX, scrollY);
  4326. context.lineTo(endX, scrollY);
  4327. context.stroke();
  4328. context.closePath();
  4329. context.beginPath();
  4330. context.setLineCap("round");
  4331. context.setLineWidth(6 * opts.pix);
  4332. context.setStrokeStyle(opts.xAxis.scrollColor || "#A6A6A6");
  4333. context.moveTo(startX + scrollLeft, scrollY);
  4334. context.lineTo(startX + scrollLeft + scrollWidth, scrollY);
  4335. context.stroke();
  4336. context.closePath();
  4337. context.setLineCap("butt");
  4338. }
  4339. context.save();
  4340. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
  4341. context.translate(opts._scrollDistance_, 0);
  4342. }
  4343. if (opts.xAxis.calibration === true) {
  4344. context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
  4345. context.setLineCap("butt");
  4346. context.setLineWidth(1 * opts.pix);
  4347. xAxisPoints.forEach(function(item, index) {
  4348. if (index > 0) {
  4349. context.beginPath();
  4350. context.moveTo(item - eachSpacing / 2, startY);
  4351. context.lineTo(item - eachSpacing / 2, startY + 3 * opts.pix);
  4352. context.closePath();
  4353. context.stroke();
  4354. }
  4355. });
  4356. }
  4357. if (opts.xAxis.disableGrid !== true) {
  4358. context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
  4359. context.setLineCap("butt");
  4360. context.setLineWidth(1 * opts.pix);
  4361. if (opts.xAxis.gridType == "dash") {
  4362. context.setLineDash([opts.xAxis.dashLength * opts.pix, opts.xAxis.dashLength * opts.pix]);
  4363. }
  4364. opts.xAxis.gridEval = opts.xAxis.gridEval || 1;
  4365. xAxisPoints.forEach(function(item, index) {
  4366. if (index % opts.xAxis.gridEval == 0) {
  4367. context.beginPath();
  4368. context.moveTo(item, startY);
  4369. context.lineTo(item, endY);
  4370. context.stroke();
  4371. }
  4372. });
  4373. context.setLineDash([]);
  4374. }
  4375. if (opts.xAxis.disabled !== true) {
  4376. let maxXAxisListLength = categories.length;
  4377. if (opts.xAxis.labelCount) {
  4378. if (opts.xAxis.itemCount) {
  4379. maxXAxisListLength = Math.ceil(categories.length / opts.xAxis.itemCount * opts.xAxis.labelCount);
  4380. } else {
  4381. maxXAxisListLength = opts.xAxis.labelCount;
  4382. }
  4383. maxXAxisListLength -= 1;
  4384. }
  4385. let ratio = Math.ceil(categories.length / maxXAxisListLength);
  4386. let newCategories = [];
  4387. let cgLength = categories.length;
  4388. for (let i = 0; i < cgLength; i++) {
  4389. if (i % ratio !== 0) {
  4390. newCategories.push("");
  4391. } else {
  4392. newCategories.push(categories[i]);
  4393. }
  4394. }
  4395. newCategories[cgLength - 1] = categories[cgLength - 1];
  4396. var xAxisFontSize = opts.xAxis.fontSize * opts.pix || config2.fontSize;
  4397. if (config2._xAxisTextAngle_ === 0) {
  4398. newCategories.forEach(function(item, index) {
  4399. var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item, index, opts) : item;
  4400. var offset = -measureText(String(xitem), xAxisFontSize, context) / 2;
  4401. if (boundaryGap == "center") {
  4402. offset += eachSpacing / 2;
  4403. }
  4404. var scrollHeight = 0;
  4405. if (opts.xAxis.scrollShow) {
  4406. scrollHeight = 6 * opts.pix;
  4407. }
  4408. var _scrollDistance_ = opts._scrollDistance_ || 0;
  4409. var truePoints = boundaryGap == "center" ? xAxisPoints[index] + eachSpacing / 2 : xAxisPoints[index];
  4410. if (truePoints - Math.abs(_scrollDistance_) >= opts.area[3] - 1 && truePoints - Math.abs(_scrollDistance_) <= opts.width - opts.area[1] + 1) {
  4411. context.beginPath();
  4412. context.setFontSize(xAxisFontSize);
  4413. context.setFillStyle(opts.xAxis.fontColor || opts.fontColor);
  4414. context.fillText(String(xitem), xAxisPoints[index] + offset, startY + opts.xAxis.marginTop * opts.pix + (opts.xAxis.lineHeight - opts.xAxis.fontSize) * opts.pix / 2 + opts.xAxis.fontSize * opts.pix);
  4415. context.closePath();
  4416. context.stroke();
  4417. }
  4418. });
  4419. } else {
  4420. newCategories.forEach(function(item, index) {
  4421. var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item) : item;
  4422. var _scrollDistance_ = opts._scrollDistance_ || 0;
  4423. var truePoints = boundaryGap == "center" ? xAxisPoints[index] + eachSpacing / 2 : xAxisPoints[index];
  4424. if (truePoints - Math.abs(_scrollDistance_) >= opts.area[3] - 1 && truePoints - Math.abs(_scrollDistance_) <= opts.width - opts.area[1] + 1) {
  4425. context.save();
  4426. context.beginPath();
  4427. context.setFontSize(xAxisFontSize);
  4428. context.setFillStyle(opts.xAxis.fontColor || opts.fontColor);
  4429. var textWidth = measureText(String(xitem), xAxisFontSize, context);
  4430. var offsetX = xAxisPoints[index];
  4431. if (boundaryGap == "center") {
  4432. offsetX = xAxisPoints[index] + eachSpacing / 2;
  4433. }
  4434. var scrollHeight = 0;
  4435. if (opts.xAxis.scrollShow) {
  4436. scrollHeight = 6 * opts.pix;
  4437. }
  4438. var offsetY = startY + opts.xAxis.marginTop * opts.pix + xAxisFontSize - xAxisFontSize * Math.abs(Math.sin(config2._xAxisTextAngle_));
  4439. if (opts.xAxis.rotateAngle < 0) {
  4440. offsetX -= xAxisFontSize / 2;
  4441. textWidth = 0;
  4442. } else {
  4443. offsetX += xAxisFontSize / 2;
  4444. textWidth = -textWidth;
  4445. }
  4446. context.translate(offsetX, offsetY);
  4447. context.rotate(-1 * config2._xAxisTextAngle_);
  4448. context.fillText(String(xitem), textWidth, 0);
  4449. context.closePath();
  4450. context.stroke();
  4451. context.restore();
  4452. }
  4453. });
  4454. }
  4455. }
  4456. context.restore();
  4457. if (opts.xAxis.title) {
  4458. context.beginPath();
  4459. context.setFontSize(opts.xAxis.titleFontSize * opts.pix);
  4460. context.setFillStyle(opts.xAxis.titleFontColor);
  4461. context.fillText(String(opts.xAxis.title), opts.width - opts.area[1] + opts.xAxis.titleOffsetX * opts.pix, opts.height - opts.area[2] + opts.xAxis.marginTop * opts.pix + (opts.xAxis.lineHeight - opts.xAxis.titleFontSize) * opts.pix / 2 + (opts.xAxis.titleFontSize + opts.xAxis.titleOffsetY) * opts.pix);
  4462. context.closePath();
  4463. context.stroke();
  4464. }
  4465. if (opts.xAxis.axisLine) {
  4466. context.beginPath();
  4467. context.setStrokeStyle(opts.xAxis.axisLineColor);
  4468. context.setLineWidth(1 * opts.pix);
  4469. context.moveTo(startX, opts.height - opts.area[2]);
  4470. context.lineTo(endX, opts.height - opts.area[2]);
  4471. context.stroke();
  4472. }
  4473. }
  4474. function drawYAxisGrid(categories, opts, config2, context) {
  4475. if (opts.yAxis.disableGrid === true) {
  4476. return;
  4477. }
  4478. let spacingValid = opts.height - opts.area[0] - opts.area[2];
  4479. let eachSpacing = spacingValid / opts.yAxis.splitNumber;
  4480. let startX = opts.area[3];
  4481. let xAxisPoints = opts.chartData.xAxisData.xAxisPoints, xAxiseachSpacing = opts.chartData.xAxisData.eachSpacing;
  4482. let TotalWidth = xAxiseachSpacing * (xAxisPoints.length - 1);
  4483. if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
  4484. if (opts.extra.mount.widthRatio > 2)
  4485. opts.extra.mount.widthRatio = 2;
  4486. TotalWidth += (opts.extra.mount.widthRatio - 1) * xAxiseachSpacing;
  4487. }
  4488. let endX = startX + TotalWidth;
  4489. let points = [];
  4490. let startY = 1;
  4491. if (opts.xAxis.axisLine === false) {
  4492. startY = 0;
  4493. }
  4494. for (let i = startY; i < opts.yAxis.splitNumber + 1; i++) {
  4495. points.push(opts.height - opts.area[2] - eachSpacing * i);
  4496. }
  4497. context.save();
  4498. if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
  4499. context.translate(opts._scrollDistance_, 0);
  4500. }
  4501. if (opts.yAxis.gridType == "dash") {
  4502. context.setLineDash([opts.yAxis.dashLength * opts.pix, opts.yAxis.dashLength * opts.pix]);
  4503. }
  4504. context.setStrokeStyle(opts.yAxis.gridColor);
  4505. context.setLineWidth(1 * opts.pix);
  4506. points.forEach(function(item, index) {
  4507. context.beginPath();
  4508. context.moveTo(startX, item);
  4509. context.lineTo(endX, item);
  4510. context.stroke();
  4511. });
  4512. context.setLineDash([]);
  4513. context.restore();
  4514. }
  4515. function drawYAxis(series, opts, config2, context) {
  4516. if (opts.yAxis.disabled === true) {
  4517. return;
  4518. }
  4519. var spacingValid = opts.height - opts.area[0] - opts.area[2];
  4520. var eachSpacing = spacingValid / opts.yAxis.splitNumber;
  4521. var startX = opts.area[3];
  4522. var endX = opts.width - opts.area[1];
  4523. var endY = opts.height - opts.area[2];
  4524. context.beginPath();
  4525. context.setFillStyle(opts.background);
  4526. if (opts.enableScroll == true && opts.xAxis.scrollPosition && opts.xAxis.scrollPosition !== "left") {
  4527. context.fillRect(0, 0, startX, endY + 2 * opts.pix);
  4528. }
  4529. if (opts.enableScroll == true && opts.xAxis.scrollPosition && opts.xAxis.scrollPosition !== "right") {
  4530. context.fillRect(endX, 0, opts.width, endY + 2 * opts.pix);
  4531. }
  4532. context.closePath();
  4533. context.stroke();
  4534. let tStartLeft = opts.area[3];
  4535. let tStartRight = opts.width - opts.area[1];
  4536. let tStartCenter = opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2;
  4537. if (opts.yAxis.data) {
  4538. for (let i = 0; i < opts.yAxis.data.length; i++) {
  4539. let yData = opts.yAxis.data[i];
  4540. var points = [];
  4541. if (yData.type === "categories") {
  4542. for (let i2 = 0; i2 <= yData.categories.length; i2++) {
  4543. points.push(opts.area[0] + spacingValid / yData.categories.length / 2 + spacingValid / yData.categories.length * i2);
  4544. }
  4545. } else {
  4546. for (let i2 = 0; i2 <= opts.yAxis.splitNumber; i2++) {
  4547. points.push(opts.area[0] + eachSpacing * i2);
  4548. }
  4549. }
  4550. if (yData.disabled !== true) {
  4551. let rangesFormat = opts.chartData.yAxisData.rangesFormat[i];
  4552. let yAxisFontSize = yData.fontSize ? yData.fontSize * opts.pix : config2.fontSize;
  4553. let yAxisWidth = opts.chartData.yAxisData.yAxisWidth[i];
  4554. let textAlign = yData.textAlign || "right";
  4555. rangesFormat.forEach(function(item, index) {
  4556. var pos = points[index];
  4557. context.beginPath();
  4558. context.setFontSize(yAxisFontSize);
  4559. context.setLineWidth(1 * opts.pix);
  4560. context.setStrokeStyle(yData.axisLineColor || "#cccccc");
  4561. context.setFillStyle(yData.fontColor || opts.fontColor);
  4562. let tmpstrat = 0;
  4563. let gapwidth = 4 * opts.pix;
  4564. if (yAxisWidth.position == "left") {
  4565. if (yData.calibration == true) {
  4566. context.moveTo(tStartLeft, pos);
  4567. context.lineTo(tStartLeft - 3 * opts.pix, pos);
  4568. gapwidth += 3 * opts.pix;
  4569. }
  4570. switch (textAlign) {
  4571. case "left":
  4572. context.setTextAlign("left");
  4573. tmpstrat = tStartLeft - yAxisWidth.width;
  4574. break;
  4575. case "right":
  4576. context.setTextAlign("right");
  4577. tmpstrat = tStartLeft - gapwidth;
  4578. break;
  4579. default:
  4580. context.setTextAlign("center");
  4581. tmpstrat = tStartLeft - yAxisWidth.width / 2;
  4582. }
  4583. context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
  4584. } else if (yAxisWidth.position == "right") {
  4585. if (yData.calibration == true) {
  4586. context.moveTo(tStartRight, pos);
  4587. context.lineTo(tStartRight + 3 * opts.pix, pos);
  4588. gapwidth += 3 * opts.pix;
  4589. }
  4590. switch (textAlign) {
  4591. case "left":
  4592. context.setTextAlign("left");
  4593. tmpstrat = tStartRight + gapwidth;
  4594. break;
  4595. case "right":
  4596. context.setTextAlign("right");
  4597. tmpstrat = tStartRight + yAxisWidth.width;
  4598. break;
  4599. default:
  4600. context.setTextAlign("center");
  4601. tmpstrat = tStartRight + yAxisWidth.width / 2;
  4602. }
  4603. context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
  4604. } else if (yAxisWidth.position == "center") {
  4605. if (yData.calibration == true) {
  4606. context.moveTo(tStartCenter, pos);
  4607. context.lineTo(tStartCenter - 3 * opts.pix, pos);
  4608. gapwidth += 3 * opts.pix;
  4609. }
  4610. switch (textAlign) {
  4611. case "left":
  4612. context.setTextAlign("left");
  4613. tmpstrat = tStartCenter - yAxisWidth.width;
  4614. break;
  4615. case "right":
  4616. context.setTextAlign("right");
  4617. tmpstrat = tStartCenter - gapwidth;
  4618. break;
  4619. default:
  4620. context.setTextAlign("center");
  4621. tmpstrat = tStartCenter - yAxisWidth.width / 2;
  4622. }
  4623. context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
  4624. }
  4625. context.closePath();
  4626. context.stroke();
  4627. context.setTextAlign("left");
  4628. });
  4629. if (yData.axisLine !== false) {
  4630. context.beginPath();
  4631. context.setStrokeStyle(yData.axisLineColor || "#cccccc");
  4632. context.setLineWidth(1 * opts.pix);
  4633. if (yAxisWidth.position == "left") {
  4634. context.moveTo(tStartLeft, opts.height - opts.area[2]);
  4635. context.lineTo(tStartLeft, opts.area[0]);
  4636. } else if (yAxisWidth.position == "right") {
  4637. context.moveTo(tStartRight, opts.height - opts.area[2]);
  4638. context.lineTo(tStartRight, opts.area[0]);
  4639. } else if (yAxisWidth.position == "center") {
  4640. context.moveTo(tStartCenter, opts.height - opts.area[2]);
  4641. context.lineTo(tStartCenter, opts.area[0]);
  4642. }
  4643. context.stroke();
  4644. }
  4645. if (opts.yAxis.showTitle) {
  4646. let titleFontSize = yData.titleFontSize * opts.pix || config2.fontSize;
  4647. let title = yData.title;
  4648. context.beginPath();
  4649. context.setFontSize(titleFontSize);
  4650. context.setFillStyle(yData.titleFontColor || opts.fontColor);
  4651. if (yAxisWidth.position == "left") {
  4652. context.fillText(title, tStartLeft - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
  4653. } else if (yAxisWidth.position == "right") {
  4654. context.fillText(title, tStartRight - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
  4655. } else if (yAxisWidth.position == "center") {
  4656. context.fillText(title, tStartCenter - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
  4657. }
  4658. context.closePath();
  4659. context.stroke();
  4660. }
  4661. if (yAxisWidth.position == "left") {
  4662. tStartLeft -= yAxisWidth.width + opts.yAxis.padding * opts.pix;
  4663. } else {
  4664. tStartRight += yAxisWidth.width + opts.yAxis.padding * opts.pix;
  4665. }
  4666. }
  4667. }
  4668. }
  4669. }
  4670. function drawLegend(series, opts, config2, context, chartData) {
  4671. if (opts.legend.show === false) {
  4672. return;
  4673. }
  4674. let legendData = chartData.legendData;
  4675. let legendList = legendData.points;
  4676. let legendArea = legendData.area;
  4677. let padding = opts.legend.padding * opts.pix;
  4678. let fontSize = opts.legend.fontSize * opts.pix;
  4679. let shapeWidth = 15 * opts.pix;
  4680. let shapeRight = 5 * opts.pix;
  4681. let itemGap = opts.legend.itemGap * opts.pix;
  4682. let lineHeight = Math.max(opts.legend.lineHeight * opts.pix, fontSize);
  4683. context.beginPath();
  4684. context.setLineWidth(opts.legend.borderWidth * opts.pix);
  4685. context.setStrokeStyle(opts.legend.borderColor);
  4686. context.setFillStyle(opts.legend.backgroundColor);
  4687. context.moveTo(legendArea.start.x, legendArea.start.y);
  4688. context.rect(legendArea.start.x, legendArea.start.y, legendArea.width, legendArea.height);
  4689. context.closePath();
  4690. context.fill();
  4691. context.stroke();
  4692. legendList.forEach(function(itemList, listIndex) {
  4693. let width = 0;
  4694. let height = 0;
  4695. width = legendData.widthArr[listIndex];
  4696. height = legendData.heightArr[listIndex];
  4697. let startX = 0;
  4698. let startY = 0;
  4699. if (opts.legend.position == "top" || opts.legend.position == "bottom") {
  4700. switch (opts.legend.float) {
  4701. case "left":
  4702. startX = legendArea.start.x + padding;
  4703. break;
  4704. case "right":
  4705. startX = legendArea.start.x + legendArea.width - width;
  4706. break;
  4707. default:
  4708. startX = legendArea.start.x + (legendArea.width - width) / 2;
  4709. }
  4710. startY = legendArea.start.y + padding + listIndex * lineHeight;
  4711. } else {
  4712. if (listIndex == 0) {
  4713. width = 0;
  4714. } else {
  4715. width = legendData.widthArr[listIndex - 1];
  4716. }
  4717. startX = legendArea.start.x + padding + width;
  4718. startY = legendArea.start.y + padding + (legendArea.height - height) / 2;
  4719. }
  4720. context.setFontSize(config2.fontSize);
  4721. for (let i = 0; i < itemList.length; i++) {
  4722. let item = itemList[i];
  4723. item.area = [0, 0, 0, 0];
  4724. item.area[0] = startX;
  4725. item.area[1] = startY;
  4726. item.area[3] = startY + lineHeight;
  4727. context.beginPath();
  4728. context.setLineWidth(1 * opts.pix);
  4729. context.setStrokeStyle(item.show ? item.color : opts.legend.hiddenColor);
  4730. context.setFillStyle(item.show ? item.color : opts.legend.hiddenColor);
  4731. switch (item.legendShape) {
  4732. case "line":
  4733. context.moveTo(startX, startY + 0.5 * lineHeight - 2 * opts.pix);
  4734. context.fillRect(startX, startY + 0.5 * lineHeight - 2 * opts.pix, 15 * opts.pix, 4 * opts.pix);
  4735. break;
  4736. case "triangle":
  4737. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
  4738. context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
  4739. context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
  4740. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
  4741. break;
  4742. case "diamond":
  4743. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
  4744. context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * lineHeight);
  4745. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
  4746. context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * lineHeight);
  4747. context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
  4748. break;
  4749. case "circle":
  4750. context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight);
  4751. context.arc(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight, 5 * opts.pix, 0, 2 * Math.PI);
  4752. break;
  4753. case "rect":
  4754. context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pix);
  4755. context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
  4756. break;
  4757. case "square":
  4758. context.moveTo(startX + 5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
  4759. context.fillRect(startX + 5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix, 10 * opts.pix, 10 * opts.pix);
  4760. break;
  4761. case "none":
  4762. break;
  4763. default:
  4764. context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pix);
  4765. context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
  4766. }
  4767. context.closePath();
  4768. context.fill();
  4769. context.stroke();
  4770. startX += shapeWidth + shapeRight;
  4771. let fontTrans = 0.5 * lineHeight + 0.5 * fontSize - 2;
  4772. const legendText = item.legendText ? item.legendText : item.name;
  4773. context.beginPath();
  4774. context.setFontSize(fontSize);
  4775. context.setFillStyle(item.show ? opts.legend.fontColor : opts.legend.hiddenColor);
  4776. context.fillText(legendText, startX, startY + fontTrans);
  4777. context.closePath();
  4778. context.stroke();
  4779. if (opts.legend.position == "top" || opts.legend.position == "bottom") {
  4780. startX += measureText(legendText, fontSize, context) + itemGap;
  4781. item.area[2] = startX;
  4782. } else {
  4783. item.area[2] = startX + measureText(legendText, fontSize, context) + itemGap;
  4784. ;
  4785. startX -= shapeWidth + shapeRight;
  4786. startY += lineHeight;
  4787. }
  4788. }
  4789. });
  4790. }
  4791. function drawPieDataPoints(series, opts, config2, context) {
  4792. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  4793. var pieOption = assign({}, {
  4794. activeOpacity: 0.5,
  4795. activeRadius: 10,
  4796. offsetAngle: 0,
  4797. labelWidth: 15,
  4798. ringWidth: 30,
  4799. customRadius: 0,
  4800. border: false,
  4801. borderWidth: 2,
  4802. borderColor: "#FFFFFF",
  4803. centerColor: "#FFFFFF",
  4804. linearType: "none",
  4805. customColor: []
  4806. }, opts.type == "pie" ? opts.extra.pie : opts.extra.ring);
  4807. var centerPosition = {
  4808. x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
  4809. y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
  4810. };
  4811. if (config2.pieChartLinePadding == 0) {
  4812. config2.pieChartLinePadding = pieOption.activeRadius * opts.pix;
  4813. }
  4814. var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config2.pieChartLinePadding - config2.pieChartTextPadding - config2._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config2.pieChartLinePadding - config2.pieChartTextPadding);
  4815. radius = radius < 10 ? 10 : radius;
  4816. if (pieOption.customRadius > 0) {
  4817. radius = pieOption.customRadius * opts.pix;
  4818. }
  4819. series = getPieDataPoints(series, radius, process);
  4820. var activeRadius = pieOption.activeRadius * opts.pix;
  4821. pieOption.customColor = fillCustomColor(pieOption.linearType, pieOption.customColor, series, config2);
  4822. series = series.map(function(eachSeries) {
  4823. eachSeries._start_ += pieOption.offsetAngle * Math.PI / 180;
  4824. return eachSeries;
  4825. });
  4826. series.forEach(function(eachSeries, seriesIndex) {
  4827. if (opts.tooltip) {
  4828. if (opts.tooltip.index == seriesIndex) {
  4829. context.beginPath();
  4830. context.setFillStyle(hexToRgb(eachSeries.color, pieOption.activeOpacity || 0.5));
  4831. context.moveTo(centerPosition.x, centerPosition.y);
  4832. context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_ + activeRadius, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
  4833. context.closePath();
  4834. context.fill();
  4835. }
  4836. }
  4837. context.beginPath();
  4838. context.setLineWidth(pieOption.borderWidth * opts.pix);
  4839. context.lineJoin = "round";
  4840. context.setStrokeStyle(pieOption.borderColor);
  4841. var fillcolor = eachSeries.color;
  4842. if (pieOption.linearType == "custom") {
  4843. var grd;
  4844. if (context.createCircularGradient) {
  4845. grd = context.createCircularGradient(centerPosition.x, centerPosition.y, eachSeries._radius_);
  4846. } else {
  4847. grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, eachSeries._radius_);
  4848. }
  4849. grd.addColorStop(0, hexToRgb(pieOption.customColor[eachSeries.linearIndex], 1));
  4850. grd.addColorStop(1, hexToRgb(eachSeries.color, 1));
  4851. fillcolor = grd;
  4852. }
  4853. context.setFillStyle(fillcolor);
  4854. context.moveTo(centerPosition.x, centerPosition.y);
  4855. context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
  4856. context.closePath();
  4857. context.fill();
  4858. if (pieOption.border == true) {
  4859. context.stroke();
  4860. }
  4861. });
  4862. if (opts.type === "ring") {
  4863. var innerPieWidth = radius * 0.6;
  4864. if (typeof pieOption.ringWidth === "number" && pieOption.ringWidth > 0) {
  4865. innerPieWidth = Math.max(0, radius - pieOption.ringWidth * opts.pix);
  4866. }
  4867. context.beginPath();
  4868. context.setFillStyle(pieOption.centerColor);
  4869. context.moveTo(centerPosition.x, centerPosition.y);
  4870. context.arc(centerPosition.x, centerPosition.y, innerPieWidth, 0, 2 * Math.PI);
  4871. context.closePath();
  4872. context.fill();
  4873. }
  4874. if (opts.dataLabel !== false && process === 1) {
  4875. drawPieText(series, opts, config2, context, radius, centerPosition);
  4876. }
  4877. if (process === 1 && opts.type === "ring") {
  4878. drawRingTitle(opts, config2, context, centerPosition);
  4879. }
  4880. return {
  4881. center: centerPosition,
  4882. radius,
  4883. series
  4884. };
  4885. }
  4886. function drawRoseDataPoints(series, opts, config2, context) {
  4887. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  4888. var roseOption = assign({}, {
  4889. type: "area",
  4890. activeOpacity: 0.5,
  4891. activeRadius: 10,
  4892. offsetAngle: 0,
  4893. labelWidth: 15,
  4894. border: false,
  4895. borderWidth: 2,
  4896. borderColor: "#FFFFFF",
  4897. linearType: "none",
  4898. customColor: []
  4899. }, opts.extra.rose);
  4900. if (config2.pieChartLinePadding == 0) {
  4901. config2.pieChartLinePadding = roseOption.activeRadius * opts.pix;
  4902. }
  4903. var centerPosition = {
  4904. x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
  4905. y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
  4906. };
  4907. var radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - config2.pieChartLinePadding - config2.pieChartTextPadding - config2._pieTextMaxLength_, (opts.height - opts.area[0] - opts.area[2]) / 2 - config2.pieChartLinePadding - config2.pieChartTextPadding);
  4908. radius = radius < 10 ? 10 : radius;
  4909. var minRadius = roseOption.minRadius || radius * 0.5;
  4910. if (radius < minRadius) {
  4911. radius = minRadius + 10;
  4912. }
  4913. series = getRoseDataPoints(series, roseOption.type, minRadius, radius, process);
  4914. var activeRadius = roseOption.activeRadius * opts.pix;
  4915. roseOption.customColor = fillCustomColor(roseOption.linearType, roseOption.customColor, series, config2);
  4916. series = series.map(function(eachSeries) {
  4917. eachSeries._start_ += (roseOption.offsetAngle || 0) * Math.PI / 180;
  4918. return eachSeries;
  4919. });
  4920. series.forEach(function(eachSeries, seriesIndex) {
  4921. if (opts.tooltip) {
  4922. if (opts.tooltip.index == seriesIndex) {
  4923. context.beginPath();
  4924. context.setFillStyle(hexToRgb(eachSeries.color, roseOption.activeOpacity || 0.5));
  4925. context.moveTo(centerPosition.x, centerPosition.y);
  4926. context.arc(centerPosition.x, centerPosition.y, activeRadius + eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
  4927. context.closePath();
  4928. context.fill();
  4929. }
  4930. }
  4931. context.beginPath();
  4932. context.setLineWidth(roseOption.borderWidth * opts.pix);
  4933. context.lineJoin = "round";
  4934. context.setStrokeStyle(roseOption.borderColor);
  4935. var fillcolor = eachSeries.color;
  4936. if (roseOption.linearType == "custom") {
  4937. var grd;
  4938. if (context.createCircularGradient) {
  4939. grd = context.createCircularGradient(centerPosition.x, centerPosition.y, eachSeries._radius_);
  4940. } else {
  4941. grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, eachSeries._radius_);
  4942. }
  4943. grd.addColorStop(0, hexToRgb(roseOption.customColor[eachSeries.linearIndex], 1));
  4944. grd.addColorStop(1, hexToRgb(eachSeries.color, 1));
  4945. fillcolor = grd;
  4946. }
  4947. context.setFillStyle(fillcolor);
  4948. context.moveTo(centerPosition.x, centerPosition.y);
  4949. context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
  4950. context.closePath();
  4951. context.fill();
  4952. if (roseOption.border == true) {
  4953. context.stroke();
  4954. }
  4955. });
  4956. if (opts.dataLabel !== false && process === 1) {
  4957. drawPieText(series, opts, config2, context, radius, centerPosition);
  4958. }
  4959. return {
  4960. center: centerPosition,
  4961. radius,
  4962. series
  4963. };
  4964. }
  4965. function drawArcbarDataPoints(series, opts, config2, context) {
  4966. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  4967. var arcbarOption = assign({}, {
  4968. startAngle: 0.75,
  4969. endAngle: 0.25,
  4970. type: "default",
  4971. direction: "cw",
  4972. lineCap: "round",
  4973. width: 12,
  4974. gap: 2,
  4975. linearType: "none",
  4976. customColor: []
  4977. }, opts.extra.arcbar);
  4978. series = getArcbarDataPoints(series, arcbarOption, process);
  4979. var centerPosition;
  4980. if (arcbarOption.centerX || arcbarOption.centerY) {
  4981. centerPosition = {
  4982. x: arcbarOption.centerX ? arcbarOption.centerX : opts.width / 2,
  4983. y: arcbarOption.centerY ? arcbarOption.centerY : opts.height / 2
  4984. };
  4985. } else {
  4986. centerPosition = {
  4987. x: opts.width / 2,
  4988. y: opts.height / 2
  4989. };
  4990. }
  4991. var radius;
  4992. if (arcbarOption.radius) {
  4993. radius = arcbarOption.radius;
  4994. } else {
  4995. radius = Math.min(centerPosition.x, centerPosition.y);
  4996. radius -= 5 * opts.pix;
  4997. radius -= arcbarOption.width / 2;
  4998. }
  4999. radius = radius < 10 ? 10 : radius;
  5000. arcbarOption.customColor = fillCustomColor(arcbarOption.linearType, arcbarOption.customColor, series, config2);
  5001. for (let i = 0; i < series.length; i++) {
  5002. let eachSeries = series[i];
  5003. context.setLineWidth(arcbarOption.width * opts.pix);
  5004. context.setStrokeStyle(arcbarOption.backgroundColor || "#E9E9E9");
  5005. context.setLineCap(arcbarOption.lineCap);
  5006. context.beginPath();
  5007. if (arcbarOption.type == "default") {
  5008. context.arc(centerPosition.x, centerPosition.y, radius - (arcbarOption.width * opts.pix + arcbarOption.gap * opts.pix) * i, arcbarOption.startAngle * Math.PI, arcbarOption.endAngle * Math.PI, arcbarOption.direction == "ccw");
  5009. } else {
  5010. context.arc(centerPosition.x, centerPosition.y, radius - (arcbarOption.width * opts.pix + arcbarOption.gap * opts.pix) * i, 0, 2 * Math.PI, arcbarOption.direction == "ccw");
  5011. }
  5012. context.stroke();
  5013. var fillColor = eachSeries.color;
  5014. if (arcbarOption.linearType == "custom") {
  5015. var grd = context.createLinearGradient(centerPosition.x - radius, centerPosition.y, centerPosition.x + radius, centerPosition.y);
  5016. grd.addColorStop(1, hexToRgb(arcbarOption.customColor[eachSeries.linearIndex], 1));
  5017. grd.addColorStop(0, hexToRgb(eachSeries.color, 1));
  5018. fillColor = grd;
  5019. }
  5020. context.setLineWidth(arcbarOption.width * opts.pix);
  5021. context.setStrokeStyle(fillColor);
  5022. context.setLineCap(arcbarOption.lineCap);
  5023. context.beginPath();
  5024. context.arc(centerPosition.x, centerPosition.y, radius - (arcbarOption.width * opts.pix + arcbarOption.gap * opts.pix) * i, arcbarOption.startAngle * Math.PI, eachSeries._proportion_ * Math.PI, arcbarOption.direction == "ccw");
  5025. context.stroke();
  5026. }
  5027. drawRingTitle(opts, config2, context, centerPosition);
  5028. return {
  5029. center: centerPosition,
  5030. radius,
  5031. series
  5032. };
  5033. }
  5034. function drawGaugeDataPoints(categories, series, opts, config2, context) {
  5035. var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
  5036. var gaugeOption = assign({}, {
  5037. type: "default",
  5038. startAngle: 0.75,
  5039. endAngle: 0.25,
  5040. width: 15,
  5041. labelOffset: 13,
  5042. splitLine: {
  5043. fixRadius: 0,
  5044. splitNumber: 10,
  5045. width: 15,
  5046. color: "#FFFFFF",
  5047. childNumber: 5,
  5048. childWidth: 5
  5049. },
  5050. pointer: {
  5051. width: 15,
  5052. color: "auto"
  5053. }
  5054. }, opts.extra.gauge);
  5055. if (gaugeOption.oldAngle == void 0) {
  5056. gaugeOption.oldAngle = gaugeOption.startAngle;
  5057. }
  5058. if (gaugeOption.oldData == void 0) {
  5059. gaugeOption.oldData = 0;
  5060. }
  5061. categories = getGaugeAxisPoints(categories, gaugeOption.startAngle, gaugeOption.endAngle);
  5062. var centerPosition = {
  5063. x: opts.width / 2,
  5064. y: opts.height / 2
  5065. };
  5066. var radius = Math.min(centerPosition.x, centerPosition.y);
  5067. radius -= 5 * opts.pix;
  5068. radius -= gaugeOption.width / 2;
  5069. radius = radius < 10 ? 10 : radius;
  5070. var innerRadius = radius - gaugeOption.width;
  5071. var totalAngle = 0;
  5072. if (gaugeOption.type == "progress") {
  5073. var pieRadius = radius - gaugeOption.width * 3;
  5074. context.beginPath();
  5075. let gradient = context.createLinearGradient(centerPosition.x, centerPosition.y - pieRadius, centerPosition.x, centerPosition.y + pieRadius);
  5076. gradient.addColorStop("0", hexToRgb(series[0].color, 0.3));
  5077. gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
  5078. context.setFillStyle(gradient);
  5079. context.arc(centerPosition.x, centerPosition.y, pieRadius, 0, 2 * Math.PI, false);
  5080. context.fill();
  5081. context.setLineWidth(gaugeOption.width);
  5082. context.setStrokeStyle(hexToRgb(series[0].color, 0.3));
  5083. context.setLineCap("round");
  5084. context.beginPath();
  5085. context.arc(centerPosition.x, centerPosition.y, innerRadius, gaugeOption.startAngle * Math.PI, gaugeOption.endAngle * Math.PI, false);
  5086. context.stroke();
  5087. if (gaugeOption.endAngle < gaugeOption.startAngle) {
  5088. totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
  5089. } else {
  5090. totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
  5091. }
  5092. let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
  5093. let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber;
  5094. let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius;
  5095. let endX = -radius - gaugeOption.width - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width;
  5096. context.save();
  5097. context.translate(centerPosition.x, centerPosition.y);
  5098. context.rotate((gaugeOption.startAngle - 1) * Math.PI);
  5099. let len = gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1;
  5100. let proc = series[0].data * process;
  5101. for (let i = 0; i < len; i++) {
  5102. context.beginPath();
  5103. if (proc > i / len) {
  5104. context.setStrokeStyle(hexToRgb(series[0].color, 1));
  5105. } else {
  5106. context.setStrokeStyle(hexToRgb(series[0].color, 0.3));
  5107. }
  5108. context.setLineWidth(3 * opts.pix);
  5109. context.moveTo(startX, 0);
  5110. context.lineTo(endX, 0);
  5111. context.stroke();
  5112. context.rotate(childAngle * Math.PI);
  5113. }
  5114. context.restore();
  5115. series = getGaugeArcbarDataPoints(series, gaugeOption, process);
  5116. context.setLineWidth(gaugeOption.width);
  5117. context.setStrokeStyle(series[0].color);
  5118. context.setLineCap("round");
  5119. context.beginPath();
  5120. context.arc(centerPosition.x, centerPosition.y, innerRadius, gaugeOption.startAngle * Math.PI, series[0]._proportion_ * Math.PI, false);
  5121. context.stroke();
  5122. let pointerRadius = radius - gaugeOption.width * 2.5;
  5123. context.save();
  5124. context.translate(centerPosition.x, centerPosition.y);
  5125. context.rotate((series[0]._proportion_ - 1) * Math.PI);
  5126. context.beginPath();
  5127. context.setLineWidth(gaugeOption.width / 3);
  5128. let gradient3 = context.createLinearGradient(0, -pointerRadius * 0.6, 0, pointerRadius * 0.6);
  5129. gradient3.addColorStop("0", hexToRgb("#FFFFFF", 0));
  5130. gradient3.addColorStop("0.5", hexToRgb(series[0].color, 1));
  5131. gradient3.addColorStop("1.0", hexToRgb("#FFFFFF", 0));
  5132. context.setStrokeStyle(gradient3);
  5133. context.arc(0, 0, pointerRadius, 0.85 * Math.PI, 1.15 * Math.PI, false);
  5134. context.stroke();
  5135. context.beginPath();
  5136. context.setLineWidth(1);
  5137. context.setStrokeStyle(series[0].color);
  5138. context.setFillStyle(series[0].color);
  5139. context.moveTo(-pointerRadius - gaugeOption.width / 3 / 2, -4);
  5140. context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2 - 4, 0);
  5141. context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2, 4);
  5142. context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2, -4);
  5143. context.stroke();
  5144. context.fill();
  5145. context.restore();
  5146. } else {
  5147. context.setLineWidth(gaugeOption.width);
  5148. context.setLineCap("butt");
  5149. for (let i = 0; i < categories.length; i++) {
  5150. let eachCategories = categories[i];
  5151. context.beginPath();
  5152. context.setStrokeStyle(eachCategories.color);
  5153. context.arc(centerPosition.x, centerPosition.y, radius, eachCategories._startAngle_ * Math.PI, eachCategories._endAngle_ * Math.PI, false);
  5154. context.stroke();
  5155. }
  5156. context.save();
  5157. if (gaugeOption.endAngle < gaugeOption.startAngle) {
  5158. totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
  5159. } else {
  5160. totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
  5161. }
  5162. let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
  5163. let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber;
  5164. let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius;
  5165. let endX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width;
  5166. let childendX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.childWidth;
  5167. context.translate(centerPosition.x, centerPosition.y);
  5168. context.rotate((gaugeOption.startAngle - 1) * Math.PI);
  5169. for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
  5170. context.beginPath();
  5171. context.setStrokeStyle(gaugeOption.splitLine.color);
  5172. context.setLineWidth(2 * opts.pix);
  5173. context.moveTo(startX, 0);
  5174. context.lineTo(endX, 0);
  5175. context.stroke();
  5176. context.rotate(splitAngle * Math.PI);
  5177. }
  5178. context.restore();
  5179. context.save();
  5180. context.translate(centerPosition.x, centerPosition.y);
  5181. context.rotate((gaugeOption.startAngle - 1) * Math.PI);
  5182. for (let i = 0; i < gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1; i++) {
  5183. context.beginPath();
  5184. context.setStrokeStyle(gaugeOption.splitLine.color);
  5185. context.setLineWidth(1 * opts.pix);
  5186. context.moveTo(startX, 0);
  5187. context.lineTo(childendX, 0);
  5188. context.stroke();
  5189. context.rotate(childAngle * Math.PI);
  5190. }
  5191. context.restore();
  5192. series = getGaugeDataPoints(series, categories, gaugeOption, process);
  5193. for (let i = 0; i < series.length; i++) {
  5194. let eachSeries = series[i];
  5195. context.save();
  5196. context.translate(centerPosition.x, centerPosition.y);
  5197. context.rotate((eachSeries._proportion_ - 1) * Math.PI);
  5198. context.beginPath();
  5199. context.setFillStyle(eachSeries.color);
  5200. context.moveTo(gaugeOption.pointer.width, 0);
  5201. context.lineTo(0, -gaugeOption.pointer.width / 2);
  5202. context.lineTo(-innerRadius, 0);
  5203. context.lineTo(0, gaugeOption.pointer.width / 2);
  5204. context.lineTo(gaugeOption.pointer.width, 0);
  5205. context.closePath();
  5206. context.fill();
  5207. context.beginPath();
  5208. context.setFillStyle("#FFFFFF");
  5209. context.arc(0, 0, gaugeOption.pointer.width / 6, 0, 2 * Math.PI, false);
  5210. context.fill();
  5211. context.restore();
  5212. }
  5213. if (opts.dataLabel !== false) {
  5214. drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config2, context);
  5215. }
  5216. }
  5217. drawRingTitle(opts, config2, context, centerPosition);
  5218. if (process === 1 && opts.type === "gauge") {
  5219. opts.extra.gauge.oldAngle = series[0]._proportion_;
  5220. opts.extra.gauge.oldData = series[0].data;
  5221. }
  5222. return {
  5223. center: centerPosition,
  5224. radius,
  5225. innerRadius,
  5226. categories,
  5227. totalAngle
  5228. };
  5229. }
  5230. function drawRadarDataPoints(series, opts, config2, context) {
  5231. var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  5232. var radarOption = assign({}, {
  5233. gridColor: "#cccccc",
  5234. gridType: "radar",
  5235. gridEval: 1,
  5236. axisLabel: false,
  5237. axisLabelTofix: 0,
  5238. labelShow: true,
  5239. labelColor: "#666666",
  5240. labelPointShow: false,
  5241. labelPointRadius: 3,
  5242. labelPointColor: "#cccccc",
  5243. opacity: 0.2,
  5244. gridCount: 3,
  5245. border: false,
  5246. borderWidth: 2,
  5247. linearType: "none",
  5248. customColor: []
  5249. }, opts.extra.radar);
  5250. var coordinateAngle = getRadarCoordinateSeries(opts.categories.length);
  5251. var centerPosition = {
  5252. x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
  5253. y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
  5254. };
  5255. var xr = (opts.width - opts.area[1] - opts.area[3]) / 2;
  5256. var yr = (opts.height - opts.area[0] - opts.area[2]) / 2;
  5257. var radius = Math.min(xr - (getMaxTextListLength(opts.categories, config2.fontSize, context) + config2.radarLabelTextMargin), yr - config2.radarLabelTextMargin);
  5258. radius -= config2.radarLabelTextMargin * opts.pix;
  5259. radius = radius < 10 ? 10 : radius;
  5260. radius = radarOption.radius ? radarOption.radius : radius;
  5261. context.beginPath();
  5262. context.setLineWidth(1 * opts.pix);
  5263. context.setStrokeStyle(radarOption.gridColor);
  5264. coordinateAngle.forEach(function(angle, index) {
  5265. var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition);
  5266. context.moveTo(centerPosition.x, centerPosition.y);
  5267. if (index % radarOption.gridEval == 0) {
  5268. context.lineTo(pos.x, pos.y);
  5269. }
  5270. });
  5271. context.stroke();
  5272. context.closePath();
  5273. var _loop = function _loop2(i2) {
  5274. var startPos = {};
  5275. context.beginPath();
  5276. context.setLineWidth(1 * opts.pix);
  5277. context.setStrokeStyle(radarOption.gridColor);
  5278. if (radarOption.gridType == "radar") {
  5279. coordinateAngle.forEach(function(angle, index) {
  5280. var pos2 = convertCoordinateOrigin(radius / radarOption.gridCount * i2 * Math.cos(angle), radius / radarOption.gridCount * i2 * Math.sin(angle), centerPosition);
  5281. if (index === 0) {
  5282. startPos = pos2;
  5283. context.moveTo(pos2.x, pos2.y);
  5284. } else {
  5285. context.lineTo(pos2.x, pos2.y);
  5286. }
  5287. });
  5288. context.lineTo(startPos.x, startPos.y);
  5289. } else {
  5290. var pos = convertCoordinateOrigin(radius / radarOption.gridCount * i2 * Math.cos(1.5), radius / radarOption.gridCount * i2 * Math.sin(1.5), centerPosition);
  5291. context.arc(centerPosition.x, centerPosition.y, centerPosition.y - pos.y, 0, 2 * Math.PI, false);
  5292. }
  5293. context.stroke();
  5294. context.closePath();
  5295. };
  5296. for (var i = 1; i <= radarOption.gridCount; i++) {
  5297. _loop(i);
  5298. }
  5299. radarOption.customColor = fillCustomColor(radarOption.linearType, radarOption.customColor, series, config2);
  5300. var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process);
  5301. radarDataPoints.forEach(function(eachSeries, seriesIndex) {
  5302. context.beginPath();
  5303. context.setLineWidth(radarOption.borderWidth * opts.pix);
  5304. context.setStrokeStyle(eachSeries.color);
  5305. var fillcolor = hexToRgb(eachSeries.color, radarOption.opacity);
  5306. if (radarOption.linearType == "custom") {
  5307. var grd;
  5308. if (context.createCircularGradient) {
  5309. grd = context.createCircularGradient(centerPosition.x, centerPosition.y, radius);
  5310. } else {
  5311. grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, radius);
  5312. }
  5313. grd.addColorStop(0, hexToRgb(radarOption.customColor[series[seriesIndex].linearIndex], radarOption.opacity));
  5314. grd.addColorStop(1, hexToRgb(eachSeries.color, radarOption.opacity));
  5315. fillcolor = grd;
  5316. }
  5317. context.setFillStyle(fillcolor);
  5318. eachSeries.data.forEach(function(item, index) {
  5319. if (index === 0) {
  5320. context.moveTo(item.position.x, item.position.y);
  5321. } else {
  5322. context.lineTo(item.position.x, item.position.y);
  5323. }
  5324. });
  5325. context.closePath();
  5326. context.fill();
  5327. if (radarOption.border === true) {
  5328. context.stroke();
  5329. }
  5330. context.closePath();
  5331. if (opts.dataPointShape !== false) {
  5332. var points = eachSeries.data.map(function(item) {
  5333. return item.position;
  5334. });
  5335. drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
  5336. }
  5337. });
  5338. if (radarOption.axisLabel === true) {
  5339. const maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series)));
  5340. const stepLength = radius / radarOption.gridCount;
  5341. const fontSize = opts.fontSize * opts.pix;
  5342. context.setFontSize(fontSize);
  5343. context.setFillStyle(opts.fontColor);
  5344. context.setTextAlign("left");
  5345. for (var i = 0; i < radarOption.gridCount + 1; i++) {
  5346. let label = i * maxData / radarOption.gridCount;
  5347. label = label.toFixed(radarOption.axisLabelTofix);
  5348. context.fillText(String(label), centerPosition.x + 3 * opts.pix, centerPosition.y - i * stepLength + fontSize / 2);
  5349. }
  5350. }
  5351. drawRadarLabel(coordinateAngle, radius, centerPosition, opts, config2, context);
  5352. if (opts.dataLabel !== false && process === 1) {
  5353. radarDataPoints.forEach(function(eachSeries, seriesIndex) {
  5354. context.beginPath();
  5355. var fontSize = eachSeries.textSize * opts.pix || config2.fontSize;
  5356. context.setFontSize(fontSize);
  5357. context.setFillStyle(eachSeries.textColor || opts.fontColor);
  5358. eachSeries.data.forEach(function(item, index) {
  5359. if (Math.abs(item.position.x - centerPosition.x) < 2) {
  5360. if (item.position.y < centerPosition.y) {
  5361. context.setTextAlign("center");
  5362. context.fillText(item.value, item.position.x, item.position.y - 4);
  5363. } else {
  5364. context.setTextAlign("center");
  5365. context.fillText(item.value, item.position.x, item.position.y + fontSize + 2);
  5366. }
  5367. } else {
  5368. if (item.position.x < centerPosition.x) {
  5369. context.setTextAlign("right");
  5370. context.fillText(item.value, item.position.x - 4, item.position.y + fontSize / 2 - 2);
  5371. } else {
  5372. context.setTextAlign("left");
  5373. context.fillText(item.value, item.position.x + 4, item.position.y + fontSize / 2 - 2);
  5374. }
  5375. }
  5376. });
  5377. context.closePath();
  5378. context.stroke();
  5379. });
  5380. context.setTextAlign("left");
  5381. }
  5382. return {
  5383. center: centerPosition,
  5384. radius,
  5385. angleList: coordinateAngle
  5386. };
  5387. }
  5388. function lonlat2mercator(longitude, latitude) {
  5389. var mercator = Array(2);
  5390. var x = longitude * 2003750834e-2 / 180;
  5391. var y = Math.log(Math.tan((90 + latitude) * Math.PI / 360)) / (Math.PI / 180);
  5392. y = y * 2003750834e-2 / 180;
  5393. mercator[0] = x;
  5394. mercator[1] = y;
  5395. return mercator;
  5396. }
  5397. function getBoundingBox(data) {
  5398. var bounds = {}, coords;
  5399. bounds.xMin = 180;
  5400. bounds.xMax = 0;
  5401. bounds.yMin = 90;
  5402. bounds.yMax = 0;
  5403. for (var i = 0; i < data.length; i++) {
  5404. var coorda = data[i].geometry.coordinates;
  5405. for (var k = 0; k < coorda.length; k++) {
  5406. coords = coorda[k];
  5407. if (coords.length == 1) {
  5408. coords = coords[0];
  5409. }
  5410. for (var j = 0; j < coords.length; j++) {
  5411. var longitude = coords[j][0];
  5412. var latitude = coords[j][1];
  5413. var point = {
  5414. x: longitude,
  5415. y: latitude
  5416. };
  5417. bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x;
  5418. bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x;
  5419. bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y;
  5420. bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y;
  5421. }
  5422. }
  5423. }
  5424. return bounds;
  5425. }
  5426. function coordinateToPoint(latitude, longitude, bounds, scale, xoffset, yoffset) {
  5427. return {
  5428. x: (longitude - bounds.xMin) * scale + xoffset,
  5429. y: (bounds.yMax - latitude) * scale + yoffset
  5430. };
  5431. }
  5432. function pointToCoordinate(pointY, pointX, bounds, scale, xoffset, yoffset) {
  5433. return {
  5434. x: (pointX - xoffset) / scale + bounds.xMin,
  5435. y: bounds.yMax - (pointY - yoffset) / scale
  5436. };
  5437. }
  5438. function isRayIntersectsSegment(poi, s_poi, e_poi) {
  5439. if (s_poi[1] == e_poi[1]) {
  5440. return false;
  5441. }
  5442. if (s_poi[1] > poi[1] && e_poi[1] > poi[1]) {
  5443. return false;
  5444. }
  5445. if (s_poi[1] < poi[1] && e_poi[1] < poi[1]) {
  5446. return false;
  5447. }
  5448. if (s_poi[1] == poi[1] && e_poi[1] > poi[1]) {
  5449. return false;
  5450. }
  5451. if (e_poi[1] == poi[1] && s_poi[1] > poi[1]) {
  5452. return false;
  5453. }
  5454. if (s_poi[0] < poi[0] && e_poi[1] < poi[1]) {
  5455. return false;
  5456. }
  5457. let xseg = e_poi[0] - (e_poi[0] - s_poi[0]) * (e_poi[1] - poi[1]) / (e_poi[1] - s_poi[1]);
  5458. if (xseg < poi[0]) {
  5459. return false;
  5460. } else {
  5461. return true;
  5462. }
  5463. }
  5464. function isPoiWithinPoly(poi, poly, mercator) {
  5465. let sinsc = 0;
  5466. for (let i = 0; i < poly.length; i++) {
  5467. let epoly = poly[i][0];
  5468. if (poly.length == 1) {
  5469. epoly = poly[i][0];
  5470. }
  5471. for (let j = 0; j < epoly.length - 1; j++) {
  5472. let s_poi = epoly[j];
  5473. let e_poi = epoly[j + 1];
  5474. if (mercator) {
  5475. s_poi = lonlat2mercator(epoly[j][0], epoly[j][1]);
  5476. e_poi = lonlat2mercator(epoly[j + 1][0], epoly[j + 1][1]);
  5477. }
  5478. if (isRayIntersectsSegment(poi, s_poi, e_poi)) {
  5479. sinsc += 1;
  5480. }
  5481. }
  5482. }
  5483. if (sinsc % 2 == 1) {
  5484. return true;
  5485. } else {
  5486. return false;
  5487. }
  5488. }
  5489. function drawMapDataPoints(series, opts, config2, context) {
  5490. var mapOption = assign({}, {
  5491. border: true,
  5492. mercator: false,
  5493. borderWidth: 1,
  5494. active: true,
  5495. borderColor: "#666666",
  5496. fillOpacity: 0.6,
  5497. activeBorderColor: "#f04864",
  5498. activeFillColor: "#facc14",
  5499. activeFillOpacity: 1
  5500. }, opts.extra.map);
  5501. var coords, point;
  5502. var data = series;
  5503. var bounds = getBoundingBox(data);
  5504. if (mapOption.mercator) {
  5505. var max = lonlat2mercator(bounds.xMax, bounds.yMax);
  5506. var min = lonlat2mercator(bounds.xMin, bounds.yMin);
  5507. bounds.xMax = max[0];
  5508. bounds.yMax = max[1];
  5509. bounds.xMin = min[0];
  5510. bounds.yMin = min[1];
  5511. }
  5512. var xScale = opts.width / Math.abs(bounds.xMax - bounds.xMin);
  5513. var yScale = opts.height / Math.abs(bounds.yMax - bounds.yMin);
  5514. var scale = xScale < yScale ? xScale : yScale;
  5515. var xoffset = opts.width / 2 - Math.abs(bounds.xMax - bounds.xMin) / 2 * scale;
  5516. var yoffset = opts.height / 2 - Math.abs(bounds.yMax - bounds.yMin) / 2 * scale;
  5517. for (var i = 0; i < data.length; i++) {
  5518. context.beginPath();
  5519. context.setLineWidth(mapOption.borderWidth * opts.pix);
  5520. context.setStrokeStyle(mapOption.borderColor);
  5521. context.setFillStyle(hexToRgb(series[i].color, series[i].fillOpacity || mapOption.fillOpacity));
  5522. if (mapOption.active == true && opts.tooltip) {
  5523. if (opts.tooltip.index == i) {
  5524. context.setStrokeStyle(mapOption.activeBorderColor);
  5525. context.setFillStyle(hexToRgb(mapOption.activeFillColor, mapOption.activeFillOpacity));
  5526. }
  5527. }
  5528. var coorda = data[i].geometry.coordinates;
  5529. for (var k = 0; k < coorda.length; k++) {
  5530. coords = coorda[k];
  5531. if (coords.length == 1) {
  5532. coords = coords[0];
  5533. }
  5534. for (var j = 0; j < coords.length; j++) {
  5535. var gaosi = Array(2);
  5536. if (mapOption.mercator) {
  5537. gaosi = lonlat2mercator(coords[j][0], coords[j][1]);
  5538. } else {
  5539. gaosi = coords[j];
  5540. }
  5541. point = coordinateToPoint(gaosi[1], gaosi[0], bounds, scale, xoffset, yoffset);
  5542. if (j === 0) {
  5543. context.beginPath();
  5544. context.moveTo(point.x, point.y);
  5545. } else {
  5546. context.lineTo(point.x, point.y);
  5547. }
  5548. }
  5549. context.fill();
  5550. if (mapOption.border == true) {
  5551. context.stroke();
  5552. }
  5553. }
  5554. }
  5555. if (opts.dataLabel == true) {
  5556. for (var i = 0; i < data.length; i++) {
  5557. var centerPoint = data[i].properties.centroid;
  5558. if (centerPoint) {
  5559. if (mapOption.mercator) {
  5560. centerPoint = lonlat2mercator(data[i].properties.centroid[0], data[i].properties.centroid[1]);
  5561. }
  5562. point = coordinateToPoint(centerPoint[1], centerPoint[0], bounds, scale, xoffset, yoffset);
  5563. let fontSize = data[i].textSize * opts.pix || config2.fontSize;
  5564. let fontColor = data[i].textColor || opts.fontColor;
  5565. if (mapOption.active && mapOption.activeTextColor && opts.tooltip && opts.tooltip.index == i) {
  5566. fontColor = mapOption.activeTextColor;
  5567. }
  5568. let text = data[i].properties.name;
  5569. context.beginPath();
  5570. context.setFontSize(fontSize);
  5571. context.setFillStyle(fontColor);
  5572. context.fillText(text, point.x - measureText(text, fontSize, context) / 2, point.y + fontSize / 2);
  5573. context.closePath();
  5574. context.stroke();
  5575. }
  5576. }
  5577. }
  5578. opts.chartData.mapData = {
  5579. bounds,
  5580. scale,
  5581. xoffset,
  5582. yoffset,
  5583. mercator: mapOption.mercator
  5584. };
  5585. drawToolTipBridge(opts, config2, context, 1);
  5586. context.draw();
  5587. }
  5588. function normalInt(min, max, iter) {
  5589. iter = iter == 0 ? 1 : iter;
  5590. var arr = [];
  5591. for (var i = 0; i < iter; i++) {
  5592. arr[i] = Math.random();
  5593. }
  5594. ;
  5595. return Math.floor(arr.reduce(function(i2, j) {
  5596. return i2 + j;
  5597. }) / iter * (max - min)) + min;
  5598. }
  5599. function collisionNew(area, points, width, height) {
  5600. var isIn = false;
  5601. for (let i = 0; i < points.length; i++) {
  5602. if (points[i].area) {
  5603. if (area[3] < points[i].area[1] || area[0] > points[i].area[2] || area[1] > points[i].area[3] || area[2] < points[i].area[0]) {
  5604. if (area[0] < 0 || area[1] < 0 || area[2] > width || area[3] > height) {
  5605. isIn = true;
  5606. break;
  5607. } else {
  5608. isIn = false;
  5609. }
  5610. } else {
  5611. isIn = true;
  5612. break;
  5613. }
  5614. }
  5615. }
  5616. return isIn;
  5617. }
  5618. function getWordCloudPoint(opts, type, context) {
  5619. let points = opts.series;
  5620. switch (type) {
  5621. case "normal":
  5622. for (let i = 0; i < points.length; i++) {
  5623. let text = points[i].name;
  5624. let tHeight = points[i].textSize * opts.pix;
  5625. let tWidth = measureText(text, tHeight, context);
  5626. let x, y;
  5627. let area;
  5628. let breaknum = 0;
  5629. while (true) {
  5630. breaknum++;
  5631. x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
  5632. y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
  5633. area = [
  5634. x - 5 + opts.width / 2,
  5635. y - 5 - tHeight + opts.height / 2,
  5636. x + tWidth + 5 + opts.width / 2,
  5637. y + 5 + opts.height / 2
  5638. ];
  5639. let isCollision2 = collisionNew(area, points, opts.width, opts.height);
  5640. if (!isCollision2)
  5641. break;
  5642. if (breaknum == 1e3) {
  5643. area = [-100, -100, -100, -100];
  5644. break;
  5645. }
  5646. }
  5647. ;
  5648. points[i].area = area;
  5649. }
  5650. break;
  5651. case "vertical":
  5652. let Spin = function() {
  5653. if (Math.random() > 0.7) {
  5654. return true;
  5655. } else {
  5656. return false;
  5657. }
  5658. ;
  5659. };
  5660. ;
  5661. for (let i = 0; i < points.length; i++) {
  5662. let text = points[i].name;
  5663. let tHeight = points[i].textSize * opts.pix;
  5664. let tWidth = measureText(text, tHeight, context);
  5665. let isSpin = Spin();
  5666. let x, y, area, areav;
  5667. let breaknum = 0;
  5668. while (true) {
  5669. breaknum++;
  5670. let isCollision2;
  5671. if (isSpin) {
  5672. x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
  5673. y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
  5674. area = [y - 5 - tWidth + opts.width / 2, -x - 5 + opts.height / 2, y + 5 + opts.width / 2, -x + tHeight + 5 + opts.height / 2];
  5675. areav = [opts.width - (opts.width / 2 - opts.height / 2) - (-x + tHeight + 5 + opts.height / 2) - 5, opts.height / 2 - opts.width / 2 + (y - 5 - tWidth + opts.width / 2) - 5, opts.width - (opts.width / 2 - opts.height / 2) - (-x + tHeight + 5 + opts.height / 2) + tHeight, opts.height / 2 - opts.width / 2 + (y - 5 - tWidth + opts.width / 2) + tWidth + 5];
  5676. isCollision2 = collisionNew(areav, points, opts.height, opts.width);
  5677. } else {
  5678. x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
  5679. y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
  5680. area = [x - 5 + opts.width / 2, y - 5 - tHeight + opts.height / 2, x + tWidth + 5 + opts.width / 2, y + 5 + opts.height / 2];
  5681. isCollision2 = collisionNew(area, points, opts.width, opts.height);
  5682. }
  5683. if (!isCollision2)
  5684. break;
  5685. if (breaknum == 1e3) {
  5686. area = [-1e3, -1e3, -1e3, -1e3];
  5687. break;
  5688. }
  5689. }
  5690. ;
  5691. if (isSpin) {
  5692. points[i].area = areav;
  5693. points[i].areav = area;
  5694. } else {
  5695. points[i].area = area;
  5696. }
  5697. points[i].rotate = isSpin;
  5698. }
  5699. ;
  5700. break;
  5701. }
  5702. return points;
  5703. }
  5704. function drawWordCloudDataPoints(series, opts, config2, context) {
  5705. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  5706. let wordOption = assign({}, {
  5707. type: "normal",
  5708. autoColors: true
  5709. }, opts.extra.word);
  5710. if (!opts.chartData.wordCloudData) {
  5711. opts.chartData.wordCloudData = getWordCloudPoint(opts, wordOption.type, context);
  5712. }
  5713. context.beginPath();
  5714. context.setFillStyle(opts.background);
  5715. context.rect(0, 0, opts.width, opts.height);
  5716. context.fill();
  5717. context.save();
  5718. let points = opts.chartData.wordCloudData;
  5719. context.translate(opts.width / 2, opts.height / 2);
  5720. for (let i = 0; i < points.length; i++) {
  5721. context.save();
  5722. if (points[i].rotate) {
  5723. context.rotate(90 * Math.PI / 180);
  5724. }
  5725. let text = points[i].name;
  5726. let tHeight = points[i].textSize * opts.pix;
  5727. let tWidth = measureText(text, tHeight, context);
  5728. context.beginPath();
  5729. context.setStrokeStyle(points[i].color);
  5730. context.setFillStyle(points[i].color);
  5731. context.setFontSize(tHeight);
  5732. if (points[i].rotate) {
  5733. if (points[i].areav[0] > 0) {
  5734. if (opts.tooltip) {
  5735. if (opts.tooltip.index == i) {
  5736. context.strokeText(text, (points[i].areav[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process);
  5737. } else {
  5738. context.fillText(text, (points[i].areav[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process);
  5739. }
  5740. } else {
  5741. context.fillText(text, (points[i].areav[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].areav[1] + 5 + tHeight - opts.height / 2) * process);
  5742. }
  5743. }
  5744. } else {
  5745. if (points[i].area[0] > 0) {
  5746. if (opts.tooltip) {
  5747. if (opts.tooltip.index == i) {
  5748. context.strokeText(text, (points[i].area[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].area[1] + 5 + tHeight - opts.height / 2) * process);
  5749. } else {
  5750. context.fillText(text, (points[i].area[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].area[1] + 5 + tHeight - opts.height / 2) * process);
  5751. }
  5752. } else {
  5753. context.fillText(text, (points[i].area[0] + 5 - opts.width / 2) * process - tWidth * (1 - process) / 2, (points[i].area[1] + 5 + tHeight - opts.height / 2) * process);
  5754. }
  5755. }
  5756. }
  5757. context.stroke();
  5758. context.restore();
  5759. }
  5760. context.restore();
  5761. }
  5762. function drawFunnelDataPoints(series, opts, config2, context) {
  5763. let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
  5764. let funnelOption = assign({}, {
  5765. type: "funnel",
  5766. activeWidth: 10,
  5767. activeOpacity: 0.3,
  5768. border: false,
  5769. borderWidth: 2,
  5770. borderColor: "#FFFFFF",
  5771. fillOpacity: 1,
  5772. minSize: 0,
  5773. labelAlign: "right",
  5774. linearType: "none",
  5775. customColor: []
  5776. }, opts.extra.funnel);
  5777. let eachSpacing = (opts.height - opts.area[0] - opts.area[2]) / series.length;
  5778. let centerPosition = {
  5779. x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
  5780. y: opts.height - opts.area[2]
  5781. };
  5782. let activeWidth = funnelOption.activeWidth * opts.pix;
  5783. let radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth, (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth);
  5784. let seriesNew = getFunnelDataPoints(series, radius, funnelOption, eachSpacing, process);
  5785. context.save();
  5786. context.translate(centerPosition.x, centerPosition.y);
  5787. funnelOption.customColor = fillCustomColor(funnelOption.linearType, funnelOption.customColor, series, config2);
  5788. if (funnelOption.type == "pyramid") {
  5789. for (let i = 0; i < seriesNew.length; i++) {
  5790. if (i == seriesNew.length - 1) {
  5791. if (opts.tooltip) {
  5792. if (opts.tooltip.index == i) {
  5793. context.beginPath();
  5794. context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
  5795. context.moveTo(-activeWidth, -eachSpacing);
  5796. context.lineTo(-seriesNew[i].radius - activeWidth, 0);
  5797. context.lineTo(seriesNew[i].radius + activeWidth, 0);
  5798. context.lineTo(activeWidth, -eachSpacing);
  5799. context.lineTo(-activeWidth, -eachSpacing);
  5800. context.closePath();
  5801. context.fill();
  5802. }
  5803. }
  5804. seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing * (i + 1), centerPosition.x + seriesNew[i].radius, centerPosition.y - eachSpacing * i];
  5805. context.beginPath();
  5806. context.setLineWidth(funnelOption.borderWidth * opts.pix);
  5807. context.setStrokeStyle(funnelOption.borderColor);
  5808. var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
  5809. if (funnelOption.linearType == "custom") {
  5810. var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
  5811. grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5812. grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
  5813. grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5814. fillColor = grd;
  5815. }
  5816. context.setFillStyle(fillColor);
  5817. context.moveTo(0, -eachSpacing);
  5818. context.lineTo(-seriesNew[i].radius, 0);
  5819. context.lineTo(seriesNew[i].radius, 0);
  5820. context.lineTo(0, -eachSpacing);
  5821. context.closePath();
  5822. context.fill();
  5823. if (funnelOption.border == true) {
  5824. context.stroke();
  5825. }
  5826. } else {
  5827. if (opts.tooltip) {
  5828. if (opts.tooltip.index == i) {
  5829. context.beginPath();
  5830. context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
  5831. context.moveTo(0, 0);
  5832. context.lineTo(-seriesNew[i].radius - activeWidth, 0);
  5833. context.lineTo(-seriesNew[i + 1].radius - activeWidth, -eachSpacing);
  5834. context.lineTo(seriesNew[i + 1].radius + activeWidth, -eachSpacing);
  5835. context.lineTo(seriesNew[i].radius + activeWidth, 0);
  5836. context.lineTo(0, 0);
  5837. context.closePath();
  5838. context.fill();
  5839. }
  5840. }
  5841. seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing * (i + 1), centerPosition.x + seriesNew[i].radius, centerPosition.y - eachSpacing * i];
  5842. context.beginPath();
  5843. context.setLineWidth(funnelOption.borderWidth * opts.pix);
  5844. context.setStrokeStyle(funnelOption.borderColor);
  5845. var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
  5846. if (funnelOption.linearType == "custom") {
  5847. var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
  5848. grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5849. grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
  5850. grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5851. fillColor = grd;
  5852. }
  5853. context.setFillStyle(fillColor);
  5854. context.moveTo(0, 0);
  5855. context.lineTo(-seriesNew[i].radius, 0);
  5856. context.lineTo(-seriesNew[i + 1].radius, -eachSpacing);
  5857. context.lineTo(seriesNew[i + 1].radius, -eachSpacing);
  5858. context.lineTo(seriesNew[i].radius, 0);
  5859. context.lineTo(0, 0);
  5860. context.closePath();
  5861. context.fill();
  5862. if (funnelOption.border == true) {
  5863. context.stroke();
  5864. }
  5865. }
  5866. context.translate(0, -eachSpacing);
  5867. }
  5868. } else {
  5869. context.translate(0, -(seriesNew.length - 1) * eachSpacing);
  5870. for (let i = 0; i < seriesNew.length; i++) {
  5871. if (i == seriesNew.length - 1) {
  5872. if (opts.tooltip) {
  5873. if (opts.tooltip.index == i) {
  5874. context.beginPath();
  5875. context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
  5876. context.moveTo(-activeWidth - funnelOption.minSize / 2, 0);
  5877. context.lineTo(-seriesNew[i].radius - activeWidth, -eachSpacing);
  5878. context.lineTo(seriesNew[i].radius + activeWidth, -eachSpacing);
  5879. context.lineTo(activeWidth + funnelOption.minSize / 2, 0);
  5880. context.lineTo(-activeWidth - funnelOption.minSize / 2, 0);
  5881. context.closePath();
  5882. context.fill();
  5883. }
  5884. }
  5885. seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing, centerPosition.x + seriesNew[i].radius, centerPosition.y];
  5886. context.beginPath();
  5887. context.setLineWidth(funnelOption.borderWidth * opts.pix);
  5888. context.setStrokeStyle(funnelOption.borderColor);
  5889. var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
  5890. if (funnelOption.linearType == "custom") {
  5891. var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
  5892. grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5893. grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
  5894. grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5895. fillColor = grd;
  5896. }
  5897. context.setFillStyle(fillColor);
  5898. context.moveTo(0, 0);
  5899. context.lineTo(-funnelOption.minSize / 2, 0);
  5900. context.lineTo(-seriesNew[i].radius, -eachSpacing);
  5901. context.lineTo(seriesNew[i].radius, -eachSpacing);
  5902. context.lineTo(funnelOption.minSize / 2, 0);
  5903. context.lineTo(0, 0);
  5904. context.closePath();
  5905. context.fill();
  5906. if (funnelOption.border == true) {
  5907. context.stroke();
  5908. }
  5909. } else {
  5910. if (opts.tooltip) {
  5911. if (opts.tooltip.index == i) {
  5912. context.beginPath();
  5913. context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
  5914. context.moveTo(0, 0);
  5915. context.lineTo(-seriesNew[i + 1].radius - activeWidth, 0);
  5916. context.lineTo(-seriesNew[i].radius - activeWidth, -eachSpacing);
  5917. context.lineTo(seriesNew[i].radius + activeWidth, -eachSpacing);
  5918. context.lineTo(seriesNew[i + 1].radius + activeWidth, 0);
  5919. context.lineTo(0, 0);
  5920. context.closePath();
  5921. context.fill();
  5922. }
  5923. }
  5924. seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing * (seriesNew.length - i), centerPosition.x + seriesNew[i].radius, centerPosition.y - eachSpacing * (seriesNew.length - i - 1)];
  5925. context.beginPath();
  5926. context.setLineWidth(funnelOption.borderWidth * opts.pix);
  5927. context.setStrokeStyle(funnelOption.borderColor);
  5928. var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
  5929. if (funnelOption.linearType == "custom") {
  5930. var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
  5931. grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5932. grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
  5933. grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
  5934. fillColor = grd;
  5935. }
  5936. context.setFillStyle(fillColor);
  5937. context.moveTo(0, 0);
  5938. context.lineTo(-seriesNew[i + 1].radius, 0);
  5939. context.lineTo(-seriesNew[i].radius, -eachSpacing);
  5940. context.lineTo(seriesNew[i].radius, -eachSpacing);
  5941. context.lineTo(seriesNew[i + 1].radius, 0);
  5942. context.lineTo(0, 0);
  5943. context.closePath();
  5944. context.fill();
  5945. if (funnelOption.border == true) {
  5946. context.stroke();
  5947. }
  5948. }
  5949. context.translate(0, eachSpacing);
  5950. }
  5951. }
  5952. context.restore();
  5953. if (opts.dataLabel !== false && process === 1) {
  5954. drawFunnelText(seriesNew, opts, context, eachSpacing, funnelOption.labelAlign, activeWidth, centerPosition);
  5955. }
  5956. if (process === 1) {
  5957. drawFunnelCenterText(seriesNew, opts, context, eachSpacing, funnelOption.labelAlign, activeWidth, centerPosition);
  5958. }
  5959. return {
  5960. center: centerPosition,
  5961. radius,
  5962. series: seriesNew
  5963. };
  5964. }
  5965. function drawFunnelText(series, opts, context, eachSpacing, labelAlign, activeWidth, centerPosition) {
  5966. for (let i = 0; i < series.length; i++) {
  5967. let item = series[i];
  5968. if (item.labelShow === false) {
  5969. continue;
  5970. }
  5971. let startX, endX, startY, fontSize;
  5972. let text = item.formatter ? item.formatter(item, i, series, opts) : util.toFixed(item._proportion_ * 100) + "%";
  5973. text = item.labelText ? item.labelText : text;
  5974. if (labelAlign == "right") {
  5975. if (i == series.length - 1) {
  5976. startX = (item.funnelArea[2] + centerPosition.x) / 2;
  5977. } else {
  5978. startX = (item.funnelArea[2] + series[i + 1].funnelArea[2]) / 2;
  5979. }
  5980. endX = startX + activeWidth * 2;
  5981. startY = item.funnelArea[1] + eachSpacing / 2;
  5982. fontSize = item.textSize * opts.pix || opts.fontSize * opts.pix;
  5983. context.setLineWidth(1 * opts.pix);
  5984. context.setStrokeStyle(item.color);
  5985. context.setFillStyle(item.color);
  5986. context.beginPath();
  5987. context.moveTo(startX, startY);
  5988. context.lineTo(endX, startY);
  5989. context.stroke();
  5990. context.closePath();
  5991. context.beginPath();
  5992. context.moveTo(endX, startY);
  5993. context.arc(endX, startY, 2 * opts.pix, 0, 2 * Math.PI);
  5994. context.closePath();
  5995. context.fill();
  5996. context.beginPath();
  5997. context.setFontSize(fontSize);
  5998. context.setFillStyle(item.textColor || opts.fontColor);
  5999. context.fillText(text, endX + 5, startY + fontSize / 2 - 2);
  6000. context.closePath();
  6001. context.stroke();
  6002. context.closePath();
  6003. }
  6004. if (labelAlign == "left") {
  6005. if (i == series.length - 1) {
  6006. startX = (item.funnelArea[0] + centerPosition.x) / 2;
  6007. } else {
  6008. startX = (item.funnelArea[0] + series[i + 1].funnelArea[0]) / 2;
  6009. }
  6010. endX = startX - activeWidth * 2;
  6011. startY = item.funnelArea[1] + eachSpacing / 2;
  6012. fontSize = item.textSize * opts.pix || opts.fontSize * opts.pix;
  6013. context.setLineWidth(1 * opts.pix);
  6014. context.setStrokeStyle(item.color);
  6015. context.setFillStyle(item.color);
  6016. context.beginPath();
  6017. context.moveTo(startX, startY);
  6018. context.lineTo(endX, startY);
  6019. context.stroke();
  6020. context.closePath();
  6021. context.beginPath();
  6022. context.moveTo(endX, startY);
  6023. context.arc(endX, startY, 2, 0, 2 * Math.PI);
  6024. context.closePath();
  6025. context.fill();
  6026. context.beginPath();
  6027. context.setFontSize(fontSize);
  6028. context.setFillStyle(item.textColor || opts.fontColor);
  6029. context.fillText(text, endX - 5 - measureText(text, fontSize, context), startY + fontSize / 2 - 2);
  6030. context.closePath();
  6031. context.stroke();
  6032. context.closePath();
  6033. }
  6034. }
  6035. }
  6036. function drawFunnelCenterText(series, opts, context, eachSpacing, labelAlign, activeWidth, centerPosition) {
  6037. for (let i = 0; i < series.length; i++) {
  6038. let item = series[i];
  6039. let startY, fontSize;
  6040. if (item.centerText) {
  6041. startY = item.funnelArea[1] + eachSpacing / 2;
  6042. fontSize = item.centerTextSize * opts.pix || opts.fontSize * opts.pix;
  6043. context.beginPath();
  6044. context.setFontSize(fontSize);
  6045. context.setFillStyle(item.centerTextColor || "#FFFFFF");
  6046. context.fillText(item.centerText, centerPosition.x - measureText(item.centerText, fontSize, context) / 2, startY + fontSize / 2 - 2);
  6047. context.closePath();
  6048. context.stroke();
  6049. context.closePath();
  6050. }
  6051. }
  6052. }
  6053. function drawCanvas(opts, context) {
  6054. context.save();
  6055. context.translate(0, 0.5);
  6056. context.restore();
  6057. context.draw();
  6058. }
  6059. var Timing = {
  6060. easeIn: function easeIn(pos) {
  6061. return Math.pow(pos, 3);
  6062. },
  6063. easeOut: function easeOut(pos) {
  6064. return Math.pow(pos - 1, 3) + 1;
  6065. },
  6066. easeInOut: function easeInOut(pos) {
  6067. if ((pos /= 0.5) < 1) {
  6068. return 0.5 * Math.pow(pos, 3);
  6069. } else {
  6070. return 0.5 * (Math.pow(pos - 2, 3) + 2);
  6071. }
  6072. },
  6073. linear: function linear(pos) {
  6074. return pos;
  6075. }
  6076. };
  6077. function Animation(opts) {
  6078. this.isStop = false;
  6079. opts.duration = typeof opts.duration === "undefined" ? 1e3 : opts.duration;
  6080. opts.timing = opts.timing || "easeInOut";
  6081. var delay = 17;
  6082. function createAnimationFrame() {
  6083. if (typeof setTimeout !== "undefined") {
  6084. return function(step, delay2) {
  6085. setTimeout(function() {
  6086. var timeStamp = +/* @__PURE__ */ new Date();
  6087. step(timeStamp);
  6088. }, delay2);
  6089. };
  6090. } else if (typeof requestAnimationFrame !== "undefined") {
  6091. return requestAnimationFrame;
  6092. } else {
  6093. return function(step) {
  6094. step(null);
  6095. };
  6096. }
  6097. }
  6098. ;
  6099. var animationFrame = createAnimationFrame();
  6100. var startTimeStamp = null;
  6101. var _step = function step(timestamp) {
  6102. if (timestamp === null || this.isStop === true) {
  6103. opts.onProcess && opts.onProcess(1);
  6104. opts.onAnimationFinish && opts.onAnimationFinish();
  6105. return;
  6106. }
  6107. if (startTimeStamp === null) {
  6108. startTimeStamp = timestamp;
  6109. }
  6110. if (timestamp - startTimeStamp < opts.duration) {
  6111. var process = (timestamp - startTimeStamp) / opts.duration;
  6112. var timingFunction = Timing[opts.timing];
  6113. process = timingFunction(process);
  6114. opts.onProcess && opts.onProcess(process);
  6115. animationFrame(_step, delay);
  6116. } else {
  6117. opts.onProcess && opts.onProcess(1);
  6118. opts.onAnimationFinish && opts.onAnimationFinish();
  6119. }
  6120. };
  6121. _step = _step.bind(this);
  6122. animationFrame(_step, delay);
  6123. }
  6124. Animation.prototype.stop = function() {
  6125. this.isStop = true;
  6126. };
  6127. function drawCharts(type, opts, config2, context) {
  6128. var _this = this;
  6129. var series = opts.series;
  6130. if (type === "pie" || type === "ring" || type === "mount" || type === "rose" || type === "funnel") {
  6131. series = fixPieSeries(series, opts, config2);
  6132. }
  6133. var categories = opts.categories;
  6134. if (type === "mount") {
  6135. categories = [];
  6136. for (let j = 0; j < series.length; j++) {
  6137. if (series[j].show !== false)
  6138. categories.push(series[j].name);
  6139. }
  6140. opts.categories = categories;
  6141. }
  6142. series = fillSeries(series, opts, config2);
  6143. var duration = opts.animation ? opts.duration : 0;
  6144. _this.animationInstance && _this.animationInstance.stop();
  6145. var seriesMA = null;
  6146. if (type == "candle") {
  6147. let average = assign({}, opts.extra.candle.average);
  6148. if (average.show) {
  6149. seriesMA = calCandleMA(average.day, average.name, average.color, series[0].data);
  6150. seriesMA = fillSeries(seriesMA, opts, config2);
  6151. opts.seriesMA = seriesMA;
  6152. } else if (opts.seriesMA) {
  6153. seriesMA = opts.seriesMA = fillSeries(opts.seriesMA, opts, config2);
  6154. } else {
  6155. seriesMA = series;
  6156. }
  6157. } else {
  6158. seriesMA = series;
  6159. }
  6160. opts._series_ = series = filterSeries(series);
  6161. opts.area = new Array(4);
  6162. for (let j = 0; j < 4; j++) {
  6163. opts.area[j] = opts.padding[j] * opts.pix;
  6164. }
  6165. var _calLegendData = calLegendData(seriesMA, opts, config2, opts.chartData, context), legendHeight = _calLegendData.area.wholeHeight, legendWidth = _calLegendData.area.wholeWidth;
  6166. switch (opts.legend.position) {
  6167. case "top":
  6168. opts.area[0] += legendHeight;
  6169. break;
  6170. case "bottom":
  6171. opts.area[2] += legendHeight;
  6172. break;
  6173. case "left":
  6174. opts.area[3] += legendWidth;
  6175. break;
  6176. case "right":
  6177. opts.area[1] += legendWidth;
  6178. break;
  6179. }
  6180. let _calYAxisData = {}, yAxisWidth = 0;
  6181. if (opts.type === "line" || opts.type === "column" || opts.type === "mount" || opts.type === "area" || opts.type === "mix" || opts.type === "candle" || opts.type === "scatter" || opts.type === "bubble" || opts.type === "bar") {
  6182. _calYAxisData = calYAxisData(series, opts, config2, context);
  6183. yAxisWidth = _calYAxisData.yAxisWidth;
  6184. if (opts.yAxis.showTitle) {
  6185. let maxTitleHeight = 0;
  6186. for (let i = 0; i < opts.yAxis.data.length; i++) {
  6187. maxTitleHeight = Math.max(maxTitleHeight, opts.yAxis.data[i].titleFontSize ? opts.yAxis.data[i].titleFontSize * opts.pix : config2.fontSize);
  6188. }
  6189. opts.area[0] += maxTitleHeight;
  6190. }
  6191. let rightIndex = 0, leftIndex = 0;
  6192. for (let i = 0; i < yAxisWidth.length; i++) {
  6193. if (yAxisWidth[i].position == "left") {
  6194. if (leftIndex > 0) {
  6195. opts.area[3] += yAxisWidth[i].width + opts.yAxis.padding * opts.pix;
  6196. } else {
  6197. opts.area[3] += yAxisWidth[i].width;
  6198. }
  6199. leftIndex += 1;
  6200. } else if (yAxisWidth[i].position == "right") {
  6201. if (rightIndex > 0) {
  6202. opts.area[1] += yAxisWidth[i].width + opts.yAxis.padding * opts.pix;
  6203. } else {
  6204. opts.area[1] += yAxisWidth[i].width;
  6205. }
  6206. rightIndex += 1;
  6207. }
  6208. }
  6209. } else {
  6210. config2.yAxisWidth = yAxisWidth;
  6211. }
  6212. opts.chartData.yAxisData = _calYAxisData;
  6213. if (opts.categories && opts.categories.length && opts.type !== "radar" && opts.type !== "gauge" && opts.type !== "bar") {
  6214. opts.chartData.xAxisData = getXAxisPoints(opts.categories, opts, config2);
  6215. let _calCategoriesData = calCategoriesData(opts.categories, opts, config2, opts.chartData.xAxisData.eachSpacing, context), xAxisHeight = _calCategoriesData.xAxisHeight, angle = _calCategoriesData.angle;
  6216. config2.xAxisHeight = xAxisHeight;
  6217. config2._xAxisTextAngle_ = angle;
  6218. opts.area[2] += xAxisHeight;
  6219. opts.chartData.categoriesData = _calCategoriesData;
  6220. } else {
  6221. if (opts.type === "line" || opts.type === "area" || opts.type === "scatter" || opts.type === "bubble" || opts.type === "bar") {
  6222. opts.chartData.xAxisData = calXAxisData(series, opts, config2, context);
  6223. categories = opts.chartData.xAxisData.rangesFormat;
  6224. let _calCategoriesData = calCategoriesData(categories, opts, config2, opts.chartData.xAxisData.eachSpacing, context), xAxisHeight = _calCategoriesData.xAxisHeight, angle = _calCategoriesData.angle;
  6225. config2.xAxisHeight = xAxisHeight;
  6226. config2._xAxisTextAngle_ = angle;
  6227. opts.area[2] += xAxisHeight;
  6228. opts.chartData.categoriesData = _calCategoriesData;
  6229. } else {
  6230. opts.chartData.xAxisData = {
  6231. xAxisPoints: []
  6232. };
  6233. }
  6234. }
  6235. if (opts.enableScroll && opts.xAxis.scrollAlign == "right" && opts._scrollDistance_ === void 0) {
  6236. let offsetLeft = 0, xAxisPoints = opts.chartData.xAxisData.xAxisPoints, startX = opts.chartData.xAxisData.startX, endX = opts.chartData.xAxisData.endX, eachSpacing = opts.chartData.xAxisData.eachSpacing;
  6237. let totalWidth = eachSpacing * (xAxisPoints.length - 1);
  6238. let screenWidth = endX - startX;
  6239. offsetLeft = screenWidth - totalWidth;
  6240. _this.scrollOption.currentOffset = offsetLeft;
  6241. _this.scrollOption.startTouchX = offsetLeft;
  6242. _this.scrollOption.distance = 0;
  6243. _this.scrollOption.lastMoveTime = 0;
  6244. opts._scrollDistance_ = offsetLeft;
  6245. }
  6246. if (type === "pie" || type === "ring" || type === "rose") {
  6247. config2._pieTextMaxLength_ = opts.dataLabel === false ? 0 : getPieTextMaxLength(seriesMA, config2, context, opts);
  6248. }
  6249. switch (type) {
  6250. case "word":
  6251. this.animationInstance = new Animation({
  6252. timing: opts.timing,
  6253. duration,
  6254. onProcess: function(process) {
  6255. context.clearRect(0, 0, opts.width, opts.height);
  6256. if (opts.rotate) {
  6257. contextRotate(context, opts);
  6258. }
  6259. drawWordCloudDataPoints(series, opts, config2, context, process);
  6260. drawCanvas(opts, context);
  6261. },
  6262. onAnimationFinish: function onAnimationFinish() {
  6263. _this.uevent.trigger("renderComplete");
  6264. }
  6265. });
  6266. break;
  6267. case "map":
  6268. context.clearRect(0, 0, opts.width, opts.height);
  6269. drawMapDataPoints(series, opts, config2, context);
  6270. setTimeout(() => {
  6271. this.uevent.trigger("renderComplete");
  6272. }, 50);
  6273. break;
  6274. case "funnel":
  6275. this.animationInstance = new Animation({
  6276. timing: opts.timing,
  6277. duration,
  6278. onProcess: function(process) {
  6279. context.clearRect(0, 0, opts.width, opts.height);
  6280. if (opts.rotate) {
  6281. contextRotate(context, opts);
  6282. }
  6283. opts.chartData.funnelData = drawFunnelDataPoints(series, opts, config2, context, process);
  6284. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6285. drawToolTipBridge(opts, config2, context, process);
  6286. drawCanvas(opts, context);
  6287. },
  6288. onAnimationFinish: function onAnimationFinish() {
  6289. _this.uevent.trigger("renderComplete");
  6290. }
  6291. });
  6292. break;
  6293. case "line":
  6294. this.animationInstance = new Animation({
  6295. timing: opts.timing,
  6296. duration,
  6297. onProcess: function onProcess(process) {
  6298. context.clearRect(0, 0, opts.width, opts.height);
  6299. if (opts.rotate) {
  6300. contextRotate(context, opts);
  6301. }
  6302. drawYAxisGrid(categories, opts, config2, context);
  6303. drawXAxis(categories, opts, config2, context);
  6304. var _drawLineDataPoints = drawLineDataPoints(series, opts, config2, context, process), xAxisPoints = _drawLineDataPoints.xAxisPoints, calPoints = _drawLineDataPoints.calPoints, eachSpacing = _drawLineDataPoints.eachSpacing;
  6305. opts.chartData.xAxisPoints = xAxisPoints;
  6306. opts.chartData.calPoints = calPoints;
  6307. opts.chartData.eachSpacing = eachSpacing;
  6308. drawYAxis(series, opts, config2, context);
  6309. if (opts.enableMarkLine !== false && process === 1) {
  6310. drawMarkLine(opts, config2, context);
  6311. }
  6312. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6313. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6314. drawCanvas(opts, context);
  6315. },
  6316. onAnimationFinish: function onAnimationFinish() {
  6317. _this.uevent.trigger("renderComplete");
  6318. }
  6319. });
  6320. break;
  6321. case "scatter":
  6322. this.animationInstance = new Animation({
  6323. timing: opts.timing,
  6324. duration,
  6325. onProcess: function onProcess(process) {
  6326. context.clearRect(0, 0, opts.width, opts.height);
  6327. if (opts.rotate) {
  6328. contextRotate(context, opts);
  6329. }
  6330. drawYAxisGrid(categories, opts, config2, context);
  6331. drawXAxis(categories, opts, config2, context);
  6332. var _drawScatterDataPoints = drawScatterDataPoints(series, opts, config2, context, process), xAxisPoints = _drawScatterDataPoints.xAxisPoints, calPoints = _drawScatterDataPoints.calPoints, eachSpacing = _drawScatterDataPoints.eachSpacing;
  6333. opts.chartData.xAxisPoints = xAxisPoints;
  6334. opts.chartData.calPoints = calPoints;
  6335. opts.chartData.eachSpacing = eachSpacing;
  6336. drawYAxis(series, opts, config2, context);
  6337. if (opts.enableMarkLine !== false && process === 1) {
  6338. drawMarkLine(opts, config2, context);
  6339. }
  6340. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6341. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6342. drawCanvas(opts, context);
  6343. },
  6344. onAnimationFinish: function onAnimationFinish() {
  6345. _this.uevent.trigger("renderComplete");
  6346. }
  6347. });
  6348. break;
  6349. case "bubble":
  6350. this.animationInstance = new Animation({
  6351. timing: opts.timing,
  6352. duration,
  6353. onProcess: function onProcess(process) {
  6354. context.clearRect(0, 0, opts.width, opts.height);
  6355. if (opts.rotate) {
  6356. contextRotate(context, opts);
  6357. }
  6358. drawYAxisGrid(categories, opts, config2, context);
  6359. drawXAxis(categories, opts, config2, context);
  6360. var _drawBubbleDataPoints = drawBubbleDataPoints(series, opts, config2, context, process), xAxisPoints = _drawBubbleDataPoints.xAxisPoints, calPoints = _drawBubbleDataPoints.calPoints, eachSpacing = _drawBubbleDataPoints.eachSpacing;
  6361. opts.chartData.xAxisPoints = xAxisPoints;
  6362. opts.chartData.calPoints = calPoints;
  6363. opts.chartData.eachSpacing = eachSpacing;
  6364. drawYAxis(series, opts, config2, context);
  6365. if (opts.enableMarkLine !== false && process === 1) {
  6366. drawMarkLine(opts, config2, context);
  6367. }
  6368. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6369. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6370. drawCanvas(opts, context);
  6371. },
  6372. onAnimationFinish: function onAnimationFinish() {
  6373. _this.uevent.trigger("renderComplete");
  6374. }
  6375. });
  6376. break;
  6377. case "mix":
  6378. this.animationInstance = new Animation({
  6379. timing: opts.timing,
  6380. duration,
  6381. onProcess: function onProcess(process) {
  6382. context.clearRect(0, 0, opts.width, opts.height);
  6383. if (opts.rotate) {
  6384. contextRotate(context, opts);
  6385. }
  6386. drawYAxisGrid(categories, opts, config2, context);
  6387. drawXAxis(categories, opts, config2, context);
  6388. var _drawMixDataPoints = drawMixDataPoints(series, opts, config2, context, process), xAxisPoints = _drawMixDataPoints.xAxisPoints, calPoints = _drawMixDataPoints.calPoints, eachSpacing = _drawMixDataPoints.eachSpacing;
  6389. opts.chartData.xAxisPoints = xAxisPoints;
  6390. opts.chartData.calPoints = calPoints;
  6391. opts.chartData.eachSpacing = eachSpacing;
  6392. drawYAxis(series, opts, config2, context);
  6393. if (opts.enableMarkLine !== false && process === 1) {
  6394. drawMarkLine(opts, config2, context);
  6395. }
  6396. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6397. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6398. drawCanvas(opts, context);
  6399. },
  6400. onAnimationFinish: function onAnimationFinish() {
  6401. _this.uevent.trigger("renderComplete");
  6402. }
  6403. });
  6404. break;
  6405. case "column":
  6406. this.animationInstance = new Animation({
  6407. timing: opts.timing,
  6408. duration,
  6409. onProcess: function onProcess(process) {
  6410. context.clearRect(0, 0, opts.width, opts.height);
  6411. if (opts.rotate) {
  6412. contextRotate(context, opts);
  6413. }
  6414. drawYAxisGrid(categories, opts, config2, context);
  6415. drawXAxis(categories, opts, config2, context);
  6416. var _drawColumnDataPoints = drawColumnDataPoints(series, opts, config2, context, process), xAxisPoints = _drawColumnDataPoints.xAxisPoints, calPoints = _drawColumnDataPoints.calPoints, eachSpacing = _drawColumnDataPoints.eachSpacing;
  6417. opts.chartData.xAxisPoints = xAxisPoints;
  6418. opts.chartData.calPoints = calPoints;
  6419. opts.chartData.eachSpacing = eachSpacing;
  6420. drawYAxis(series, opts, config2, context);
  6421. if (opts.enableMarkLine !== false && process === 1) {
  6422. drawMarkLine(opts, config2, context);
  6423. }
  6424. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6425. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6426. drawCanvas(opts, context);
  6427. },
  6428. onAnimationFinish: function onAnimationFinish() {
  6429. _this.uevent.trigger("renderComplete");
  6430. }
  6431. });
  6432. break;
  6433. case "mount":
  6434. this.animationInstance = new Animation({
  6435. timing: opts.timing,
  6436. duration,
  6437. onProcess: function onProcess(process) {
  6438. context.clearRect(0, 0, opts.width, opts.height);
  6439. if (opts.rotate) {
  6440. contextRotate(context, opts);
  6441. }
  6442. drawYAxisGrid(categories, opts, config2, context);
  6443. drawXAxis(categories, opts, config2, context);
  6444. var _drawMountDataPoints = drawMountDataPoints(series, opts, config2, context, process), xAxisPoints = _drawMountDataPoints.xAxisPoints, calPoints = _drawMountDataPoints.calPoints, eachSpacing = _drawMountDataPoints.eachSpacing;
  6445. opts.chartData.xAxisPoints = xAxisPoints;
  6446. opts.chartData.calPoints = calPoints;
  6447. opts.chartData.eachSpacing = eachSpacing;
  6448. drawYAxis(series, opts, config2, context);
  6449. if (opts.enableMarkLine !== false && process === 1) {
  6450. drawMarkLine(opts, config2, context);
  6451. }
  6452. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6453. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6454. drawCanvas(opts, context);
  6455. },
  6456. onAnimationFinish: function onAnimationFinish() {
  6457. _this.uevent.trigger("renderComplete");
  6458. }
  6459. });
  6460. break;
  6461. case "bar":
  6462. this.animationInstance = new Animation({
  6463. timing: opts.timing,
  6464. duration,
  6465. onProcess: function onProcess(process) {
  6466. context.clearRect(0, 0, opts.width, opts.height);
  6467. if (opts.rotate) {
  6468. contextRotate(context, opts);
  6469. }
  6470. drawXAxis(categories, opts, config2, context);
  6471. var _drawBarDataPoints = drawBarDataPoints(series, opts, config2, context, process), yAxisPoints = _drawBarDataPoints.yAxisPoints, calPoints = _drawBarDataPoints.calPoints, eachSpacing = _drawBarDataPoints.eachSpacing;
  6472. opts.chartData.yAxisPoints = yAxisPoints;
  6473. opts.chartData.xAxisPoints = opts.chartData.xAxisData.xAxisPoints;
  6474. opts.chartData.calPoints = calPoints;
  6475. opts.chartData.eachSpacing = eachSpacing;
  6476. drawYAxis(series, opts, config2, context);
  6477. if (opts.enableMarkLine !== false && process === 1) {
  6478. drawMarkLine(opts, config2, context);
  6479. }
  6480. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6481. drawToolTipBridge(opts, config2, context, process, eachSpacing, yAxisPoints);
  6482. drawCanvas(opts, context);
  6483. },
  6484. onAnimationFinish: function onAnimationFinish() {
  6485. _this.uevent.trigger("renderComplete");
  6486. }
  6487. });
  6488. break;
  6489. case "area":
  6490. this.animationInstance = new Animation({
  6491. timing: opts.timing,
  6492. duration,
  6493. onProcess: function onProcess(process) {
  6494. context.clearRect(0, 0, opts.width, opts.height);
  6495. if (opts.rotate) {
  6496. contextRotate(context, opts);
  6497. }
  6498. drawYAxisGrid(categories, opts, config2, context);
  6499. drawXAxis(categories, opts, config2, context);
  6500. var _drawAreaDataPoints = drawAreaDataPoints(series, opts, config2, context, process), xAxisPoints = _drawAreaDataPoints.xAxisPoints, calPoints = _drawAreaDataPoints.calPoints, eachSpacing = _drawAreaDataPoints.eachSpacing;
  6501. opts.chartData.xAxisPoints = xAxisPoints;
  6502. opts.chartData.calPoints = calPoints;
  6503. opts.chartData.eachSpacing = eachSpacing;
  6504. drawYAxis(series, opts, config2, context);
  6505. if (opts.enableMarkLine !== false && process === 1) {
  6506. drawMarkLine(opts, config2, context);
  6507. }
  6508. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6509. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6510. drawCanvas(opts, context);
  6511. },
  6512. onAnimationFinish: function onAnimationFinish() {
  6513. _this.uevent.trigger("renderComplete");
  6514. }
  6515. });
  6516. break;
  6517. case "ring":
  6518. this.animationInstance = new Animation({
  6519. timing: opts.timing,
  6520. duration,
  6521. onProcess: function onProcess(process) {
  6522. context.clearRect(0, 0, opts.width, opts.height);
  6523. if (opts.rotate) {
  6524. contextRotate(context, opts);
  6525. }
  6526. opts.chartData.pieData = drawPieDataPoints(series, opts, config2, context, process);
  6527. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6528. drawToolTipBridge(opts, config2, context, process);
  6529. drawCanvas(opts, context);
  6530. },
  6531. onAnimationFinish: function onAnimationFinish() {
  6532. _this.uevent.trigger("renderComplete");
  6533. }
  6534. });
  6535. break;
  6536. case "pie":
  6537. this.animationInstance = new Animation({
  6538. timing: opts.timing,
  6539. duration,
  6540. onProcess: function onProcess(process) {
  6541. context.clearRect(0, 0, opts.width, opts.height);
  6542. if (opts.rotate) {
  6543. contextRotate(context, opts);
  6544. }
  6545. opts.chartData.pieData = drawPieDataPoints(series, opts, config2, context, process);
  6546. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6547. drawToolTipBridge(opts, config2, context, process);
  6548. drawCanvas(opts, context);
  6549. },
  6550. onAnimationFinish: function onAnimationFinish() {
  6551. _this.uevent.trigger("renderComplete");
  6552. }
  6553. });
  6554. break;
  6555. case "rose":
  6556. this.animationInstance = new Animation({
  6557. timing: opts.timing,
  6558. duration,
  6559. onProcess: function onProcess(process) {
  6560. context.clearRect(0, 0, opts.width, opts.height);
  6561. if (opts.rotate) {
  6562. contextRotate(context, opts);
  6563. }
  6564. opts.chartData.pieData = drawRoseDataPoints(series, opts, config2, context, process);
  6565. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6566. drawToolTipBridge(opts, config2, context, process);
  6567. drawCanvas(opts, context);
  6568. },
  6569. onAnimationFinish: function onAnimationFinish() {
  6570. _this.uevent.trigger("renderComplete");
  6571. }
  6572. });
  6573. break;
  6574. case "radar":
  6575. this.animationInstance = new Animation({
  6576. timing: opts.timing,
  6577. duration,
  6578. onProcess: function onProcess(process) {
  6579. context.clearRect(0, 0, opts.width, opts.height);
  6580. if (opts.rotate) {
  6581. contextRotate(context, opts);
  6582. }
  6583. opts.chartData.radarData = drawRadarDataPoints(series, opts, config2, context, process);
  6584. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6585. drawToolTipBridge(opts, config2, context, process);
  6586. drawCanvas(opts, context);
  6587. },
  6588. onAnimationFinish: function onAnimationFinish() {
  6589. _this.uevent.trigger("renderComplete");
  6590. }
  6591. });
  6592. break;
  6593. case "arcbar":
  6594. this.animationInstance = new Animation({
  6595. timing: opts.timing,
  6596. duration,
  6597. onProcess: function onProcess(process) {
  6598. context.clearRect(0, 0, opts.width, opts.height);
  6599. if (opts.rotate) {
  6600. contextRotate(context, opts);
  6601. }
  6602. opts.chartData.arcbarData = drawArcbarDataPoints(series, opts, config2, context, process);
  6603. drawCanvas(opts, context);
  6604. },
  6605. onAnimationFinish: function onAnimationFinish() {
  6606. _this.uevent.trigger("renderComplete");
  6607. }
  6608. });
  6609. break;
  6610. case "gauge":
  6611. this.animationInstance = new Animation({
  6612. timing: opts.timing,
  6613. duration,
  6614. onProcess: function onProcess(process) {
  6615. context.clearRect(0, 0, opts.width, opts.height);
  6616. if (opts.rotate) {
  6617. contextRotate(context, opts);
  6618. }
  6619. opts.chartData.gaugeData = drawGaugeDataPoints(categories, series, opts, config2, context, process);
  6620. drawCanvas(opts, context);
  6621. },
  6622. onAnimationFinish: function onAnimationFinish() {
  6623. _this.uevent.trigger("renderComplete");
  6624. }
  6625. });
  6626. break;
  6627. case "candle":
  6628. this.animationInstance = new Animation({
  6629. timing: opts.timing,
  6630. duration,
  6631. onProcess: function onProcess(process) {
  6632. context.clearRect(0, 0, opts.width, opts.height);
  6633. if (opts.rotate) {
  6634. contextRotate(context, opts);
  6635. }
  6636. drawYAxisGrid(categories, opts, config2, context);
  6637. drawXAxis(categories, opts, config2, context);
  6638. var _drawCandleDataPoints = drawCandleDataPoints(series, seriesMA, opts, config2, context, process), xAxisPoints = _drawCandleDataPoints.xAxisPoints, calPoints = _drawCandleDataPoints.calPoints, eachSpacing = _drawCandleDataPoints.eachSpacing;
  6639. opts.chartData.xAxisPoints = xAxisPoints;
  6640. opts.chartData.calPoints = calPoints;
  6641. opts.chartData.eachSpacing = eachSpacing;
  6642. drawYAxis(series, opts, config2, context);
  6643. if (opts.enableMarkLine !== false && process === 1) {
  6644. drawMarkLine(opts, config2, context);
  6645. }
  6646. if (seriesMA) {
  6647. drawLegend(seriesMA, opts, config2, context, opts.chartData);
  6648. } else {
  6649. drawLegend(opts.series, opts, config2, context, opts.chartData);
  6650. }
  6651. drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
  6652. drawCanvas(opts, context);
  6653. },
  6654. onAnimationFinish: function onAnimationFinish() {
  6655. _this.uevent.trigger("renderComplete");
  6656. }
  6657. });
  6658. break;
  6659. }
  6660. }
  6661. function uChartsEvent() {
  6662. this.events = {};
  6663. }
  6664. uChartsEvent.prototype.addEventListener = function(type, listener) {
  6665. this.events[type] = this.events[type] || [];
  6666. this.events[type].push(listener);
  6667. };
  6668. uChartsEvent.prototype.delEventListener = function(type) {
  6669. this.events[type] = [];
  6670. };
  6671. uChartsEvent.prototype.trigger = function() {
  6672. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  6673. args[_key] = arguments[_key];
  6674. }
  6675. var type = args[0];
  6676. var params = args.slice(1);
  6677. if (!!this.events[type]) {
  6678. this.events[type].forEach(function(listener) {
  6679. try {
  6680. listener.apply(null, params);
  6681. } catch (e) {
  6682. }
  6683. });
  6684. }
  6685. };
  6686. var uCharts = function uCharts2(opts) {
  6687. opts.pix = opts.pixelRatio ? opts.pixelRatio : 1;
  6688. opts.fontSize = opts.fontSize ? opts.fontSize : 13;
  6689. opts.fontColor = opts.fontColor ? opts.fontColor : config.fontColor;
  6690. if (opts.background == "" || opts.background == "none") {
  6691. opts.background = "#FFFFFF";
  6692. }
  6693. opts.title = assign({}, opts.title);
  6694. opts.subtitle = assign({}, opts.subtitle);
  6695. opts.duration = opts.duration ? opts.duration : 1e3;
  6696. opts.yAxis = assign({}, {
  6697. data: [],
  6698. showTitle: false,
  6699. disabled: false,
  6700. disableGrid: false,
  6701. gridSet: "number",
  6702. splitNumber: 5,
  6703. gridType: "solid",
  6704. dashLength: 4 * opts.pix,
  6705. gridColor: "#cccccc",
  6706. padding: 10,
  6707. fontColor: "#666666"
  6708. }, opts.yAxis);
  6709. opts.xAxis = assign({}, {
  6710. rotateLabel: false,
  6711. rotateAngle: 45,
  6712. disabled: false,
  6713. disableGrid: false,
  6714. splitNumber: 5,
  6715. calibration: false,
  6716. fontColor: "#666666",
  6717. fontSize: 13,
  6718. lineHeight: 20,
  6719. marginTop: 0,
  6720. gridType: "solid",
  6721. dashLength: 4,
  6722. scrollAlign: "left",
  6723. boundaryGap: "center",
  6724. axisLine: true,
  6725. axisLineColor: "#cccccc",
  6726. titleFontSize: 13,
  6727. titleOffsetY: 0,
  6728. titleOffsetX: 0,
  6729. titleFontColor: "#666666"
  6730. }, opts.xAxis);
  6731. opts.xAxis.scrollPosition = opts.xAxis.scrollAlign;
  6732. opts.legend = assign({}, {
  6733. show: true,
  6734. position: "bottom",
  6735. float: "center",
  6736. backgroundColor: "rgba(0,0,0,0)",
  6737. borderColor: "rgba(0,0,0,0)",
  6738. borderWidth: 0,
  6739. padding: 5,
  6740. margin: 5,
  6741. itemGap: 10,
  6742. fontSize: opts.fontSize,
  6743. lineHeight: opts.fontSize,
  6744. fontColor: opts.fontColor,
  6745. formatter: {},
  6746. hiddenColor: "#CECECE"
  6747. }, opts.legend);
  6748. opts.extra = assign({
  6749. tooltip: {
  6750. legendShape: "auto"
  6751. }
  6752. }, opts.extra);
  6753. opts.rotate = opts.rotate ? true : false;
  6754. opts.animation = opts.animation ? true : false;
  6755. opts.rotate = opts.rotate ? true : false;
  6756. opts.canvas2d = opts.canvas2d ? true : false;
  6757. let config$$1 = assign({}, config);
  6758. config$$1.color = opts.color ? opts.color : config$$1.color;
  6759. if (opts.type == "pie") {
  6760. config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.pie.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
  6761. }
  6762. if (opts.type == "ring") {
  6763. config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.ring.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
  6764. }
  6765. if (opts.type == "rose") {
  6766. config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.rose.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
  6767. }
  6768. config$$1.pieChartTextPadding = opts.dataLabel === false ? 0 : config$$1.pieChartTextPadding * opts.pix;
  6769. config$$1.rotate = opts.rotate;
  6770. if (opts.rotate) {
  6771. let tempWidth = opts.width;
  6772. let tempHeight = opts.height;
  6773. opts.width = tempHeight;
  6774. opts.height = tempWidth;
  6775. }
  6776. opts.padding = opts.padding ? opts.padding : config$$1.padding;
  6777. config$$1.yAxisWidth = config.yAxisWidth * opts.pix;
  6778. config$$1.fontSize = opts.fontSize * opts.pix;
  6779. config$$1.titleFontSize = config.titleFontSize * opts.pix;
  6780. config$$1.subtitleFontSize = config.subtitleFontSize * opts.pix;
  6781. if (!opts.context) {
  6782. throw new Error("[uCharts] \u672A\u83B7\u53D6\u5230context\uFF01\u6CE8\u610F\uFF1Av2.0\u7248\u672C\u540E\uFF0C\u9700\u8981\u81EA\u884C\u83B7\u53D6canvas\u7684\u7ED8\u56FE\u4E0A\u4E0B\u6587\u5E76\u4F20\u5165opts.context\uFF01");
  6783. }
  6784. this.context = opts.context;
  6785. if (!this.context.setTextAlign) {
  6786. this.context.setStrokeStyle = function(e) {
  6787. return this.strokeStyle = e;
  6788. };
  6789. this.context.setLineWidth = function(e) {
  6790. return this.lineWidth = e;
  6791. };
  6792. this.context.setLineCap = function(e) {
  6793. return this.lineCap = e;
  6794. };
  6795. this.context.setFontSize = function(e) {
  6796. return this.font = e + "px sans-serif";
  6797. };
  6798. this.context.setFillStyle = function(e) {
  6799. return this.fillStyle = e;
  6800. };
  6801. this.context.setTextAlign = function(e) {
  6802. return this.textAlign = e;
  6803. };
  6804. this.context.setTextBaseline = function(e) {
  6805. return this.textBaseline = e;
  6806. };
  6807. this.context.setShadow = function(offsetX, offsetY, blur, color3) {
  6808. this.shadowColor = color3;
  6809. this.shadowOffsetX = offsetX;
  6810. this.shadowOffsetY = offsetY;
  6811. this.shadowBlur = blur;
  6812. };
  6813. this.context.draw = function() {
  6814. };
  6815. }
  6816. if (!this.context.setLineDash) {
  6817. this.context.setLineDash = function(e) {
  6818. };
  6819. }
  6820. opts.chartData = {};
  6821. this.uevent = new uChartsEvent();
  6822. this.scrollOption = {
  6823. currentOffset: 0,
  6824. startTouchX: 0,
  6825. distance: 0,
  6826. lastMoveTime: 0
  6827. };
  6828. this.opts = opts;
  6829. this.config = config$$1;
  6830. drawCharts.call(this, opts.type, opts, config$$1, this.context);
  6831. };
  6832. uCharts.prototype.updateData = function() {
  6833. let data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
  6834. this.opts = assign({}, this.opts, data);
  6835. this.opts.updateData = true;
  6836. let scrollPosition = data.scrollPosition || "current";
  6837. switch (scrollPosition) {
  6838. case "current":
  6839. this.opts._scrollDistance_ = this.scrollOption.currentOffset;
  6840. break;
  6841. case "left":
  6842. this.opts._scrollDistance_ = 0;
  6843. this.scrollOption = {
  6844. currentOffset: 0,
  6845. startTouchX: 0,
  6846. distance: 0,
  6847. lastMoveTime: 0
  6848. };
  6849. break;
  6850. case "right":
  6851. let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config, this.context), yAxisWidth = _calYAxisData.yAxisWidth;
  6852. this.config.yAxisWidth = yAxisWidth;
  6853. let offsetLeft = 0;
  6854. let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
  6855. let totalWidth = eachSpacing * (xAxisPoints.length - 1);
  6856. let screenWidth = endX - startX;
  6857. offsetLeft = screenWidth - totalWidth;
  6858. this.scrollOption = {
  6859. currentOffset: offsetLeft,
  6860. startTouchX: offsetLeft,
  6861. distance: 0,
  6862. lastMoveTime: 0
  6863. };
  6864. this.opts._scrollDistance_ = offsetLeft;
  6865. break;
  6866. }
  6867. drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
  6868. };
  6869. uCharts.prototype.zoom = function() {
  6870. var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.opts.xAxis.itemCount;
  6871. if (this.opts.enableScroll !== true) {
  6872. console.log("[uCharts] \u8BF7\u542F\u7528\u6EDA\u52A8\u6761\u540E\u4F7F\u7528");
  6873. return;
  6874. }
  6875. let centerPoint = Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) + Math.round(this.opts.xAxis.itemCount / 2);
  6876. this.opts.animation = false;
  6877. this.opts.xAxis.itemCount = val.itemCount;
  6878. let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config, this.context), yAxisWidth = _calYAxisData.yAxisWidth;
  6879. this.config.yAxisWidth = yAxisWidth;
  6880. let offsetLeft = 0;
  6881. let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
  6882. let centerLeft = eachSpacing * centerPoint;
  6883. let screenWidth = endX - startX;
  6884. let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1);
  6885. offsetLeft = screenWidth / 2 - centerLeft;
  6886. if (offsetLeft > 0) {
  6887. offsetLeft = 0;
  6888. }
  6889. if (offsetLeft < MaxLeft) {
  6890. offsetLeft = MaxLeft;
  6891. }
  6892. this.scrollOption = {
  6893. currentOffset: offsetLeft,
  6894. startTouchX: 0,
  6895. distance: 0,
  6896. lastMoveTime: 0
  6897. };
  6898. calValidDistance(this, offsetLeft, this.opts.chartData, this.config, this.opts);
  6899. this.opts._scrollDistance_ = offsetLeft;
  6900. drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
  6901. };
  6902. uCharts.prototype.dobuleZoom = function(e) {
  6903. if (this.opts.enableScroll !== true) {
  6904. console.log("[uCharts] \u8BF7\u542F\u7528\u6EDA\u52A8\u6761\u540E\u4F7F\u7528");
  6905. return;
  6906. }
  6907. const tcs = e.changedTouches;
  6908. if (tcs.length < 2) {
  6909. return;
  6910. }
  6911. for (var i = 0; i < tcs.length; i++) {
  6912. tcs[i].x = tcs[i].x ? tcs[i].x : tcs[i].clientX;
  6913. tcs[i].y = tcs[i].y ? tcs[i].y : tcs[i].clientY;
  6914. }
  6915. const ntcs = [getTouches(tcs[0], this.opts, e), getTouches(tcs[1], this.opts, e)];
  6916. const xlength = Math.abs(ntcs[0].x - ntcs[1].x);
  6917. if (!this.scrollOption.moveCount) {
  6918. let cts0 = { changedTouches: [{ x: tcs[0].x, y: this.opts.area[0] / this.opts.pix + 2 }] };
  6919. let cts1 = { changedTouches: [{ x: tcs[1].x, y: this.opts.area[0] / this.opts.pix + 2 }] };
  6920. if (this.opts.rotate) {
  6921. cts0 = { changedTouches: [{ x: this.opts.height / this.opts.pix - this.opts.area[0] / this.opts.pix - 2, y: tcs[0].y }] };
  6922. cts1 = { changedTouches: [{ x: this.opts.height / this.opts.pix - this.opts.area[0] / this.opts.pix - 2, y: tcs[1].y }] };
  6923. }
  6924. const moveCurrent1 = this.getCurrentDataIndex(cts0).index;
  6925. const moveCurrent2 = this.getCurrentDataIndex(cts1).index;
  6926. const moveCount = Math.abs(moveCurrent1 - moveCurrent2);
  6927. this.scrollOption.moveCount = moveCount;
  6928. this.scrollOption.moveCurrent1 = Math.min(moveCurrent1, moveCurrent2);
  6929. this.scrollOption.moveCurrent2 = Math.max(moveCurrent1, moveCurrent2);
  6930. return;
  6931. }
  6932. let currentEachSpacing = xlength / this.scrollOption.moveCount;
  6933. let itemCount = (this.opts.width - this.opts.area[1] - this.opts.area[3]) / currentEachSpacing;
  6934. itemCount = itemCount <= 2 ? 2 : itemCount;
  6935. itemCount = itemCount >= this.opts.categories.length ? this.opts.categories.length : itemCount;
  6936. this.opts.animation = false;
  6937. this.opts.xAxis.itemCount = itemCount;
  6938. let offsetLeft = 0;
  6939. let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
  6940. let currentLeft = eachSpacing * this.scrollOption.moveCurrent1;
  6941. let screenWidth = endX - startX;
  6942. let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1);
  6943. offsetLeft = -currentLeft + Math.min(ntcs[0].x, ntcs[1].x) - this.opts.area[3] - eachSpacing;
  6944. if (offsetLeft > 0) {
  6945. offsetLeft = 0;
  6946. }
  6947. if (offsetLeft < MaxLeft) {
  6948. offsetLeft = MaxLeft;
  6949. }
  6950. this.scrollOption.currentOffset = offsetLeft;
  6951. this.scrollOption.startTouchX = 0;
  6952. this.scrollOption.distance = 0;
  6953. calValidDistance(this, offsetLeft, this.opts.chartData, this.config, this.opts);
  6954. this.opts._scrollDistance_ = offsetLeft;
  6955. drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
  6956. };
  6957. uCharts.prototype.stopAnimation = function() {
  6958. this.animationInstance && this.animationInstance.stop();
  6959. };
  6960. uCharts.prototype.addEventListener = function(type, listener) {
  6961. this.uevent.addEventListener(type, listener);
  6962. };
  6963. uCharts.prototype.delEventListener = function(type) {
  6964. this.uevent.delEventListener(type);
  6965. };
  6966. uCharts.prototype.getCurrentDataIndex = function(e) {
  6967. var touches = null;
  6968. if (e.changedTouches) {
  6969. touches = e.changedTouches[0];
  6970. } else {
  6971. touches = e.mp.changedTouches[0];
  6972. }
  6973. if (touches) {
  6974. let _touches$ = getTouches(touches, this.opts, e);
  6975. if (this.opts.type === "pie" || this.opts.type === "ring") {
  6976. return findPieChartCurrentIndex({
  6977. x: _touches$.x,
  6978. y: _touches$.y
  6979. }, this.opts.chartData.pieData, this.opts);
  6980. } else if (this.opts.type === "rose") {
  6981. return findRoseChartCurrentIndex({
  6982. x: _touches$.x,
  6983. y: _touches$.y
  6984. }, this.opts.chartData.pieData, this.opts);
  6985. } else if (this.opts.type === "radar") {
  6986. return findRadarChartCurrentIndex({
  6987. x: _touches$.x,
  6988. y: _touches$.y
  6989. }, this.opts.chartData.radarData, this.opts.categories.length);
  6990. } else if (this.opts.type === "funnel") {
  6991. return findFunnelChartCurrentIndex({
  6992. x: _touches$.x,
  6993. y: _touches$.y
  6994. }, this.opts.chartData.funnelData);
  6995. } else if (this.opts.type === "map") {
  6996. return findMapChartCurrentIndex({
  6997. x: _touches$.x,
  6998. y: _touches$.y
  6999. }, this.opts);
  7000. } else if (this.opts.type === "word") {
  7001. return findWordChartCurrentIndex({
  7002. x: _touches$.x,
  7003. y: _touches$.y
  7004. }, this.opts.chartData.wordCloudData);
  7005. } else if (this.opts.type === "bar") {
  7006. return findBarChartCurrentIndex({
  7007. x: _touches$.x,
  7008. y: _touches$.y
  7009. }, this.opts.chartData.calPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
  7010. } else {
  7011. return findCurrentIndex({
  7012. x: _touches$.x,
  7013. y: _touches$.y
  7014. }, this.opts.chartData.calPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
  7015. }
  7016. }
  7017. return -1;
  7018. };
  7019. uCharts.prototype.getLegendDataIndex = function(e) {
  7020. var touches = null;
  7021. if (e.changedTouches) {
  7022. touches = e.changedTouches[0];
  7023. } else {
  7024. touches = e.mp.changedTouches[0];
  7025. }
  7026. if (touches) {
  7027. let _touches$ = getTouches(touches, this.opts, e);
  7028. return findLegendIndex({
  7029. x: _touches$.x,
  7030. y: _touches$.y
  7031. }, this.opts.chartData.legendData);
  7032. }
  7033. return -1;
  7034. };
  7035. uCharts.prototype.touchLegend = function(e) {
  7036. var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  7037. var touches = null;
  7038. if (e.changedTouches) {
  7039. touches = e.changedTouches[0];
  7040. } else {
  7041. touches = e.mp.changedTouches[0];
  7042. }
  7043. if (touches) {
  7044. var _touches$ = getTouches(touches, this.opts, e);
  7045. var index = this.getLegendDataIndex(e);
  7046. if (index >= 0) {
  7047. if (this.opts.type == "candle") {
  7048. this.opts.seriesMA[index].show = !this.opts.seriesMA[index].show;
  7049. } else {
  7050. this.opts.series[index].show = !this.opts.series[index].show;
  7051. }
  7052. this.opts.animation = option.animation ? true : false;
  7053. this.opts._scrollDistance_ = this.scrollOption.currentOffset;
  7054. drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
  7055. }
  7056. }
  7057. };
  7058. uCharts.prototype.showToolTip = function(e) {
  7059. var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
  7060. var touches = null;
  7061. if (e.changedTouches) {
  7062. touches = e.changedTouches[0];
  7063. } else {
  7064. touches = e.mp.changedTouches[0];
  7065. }
  7066. if (!touches) {
  7067. console.log("[uCharts] \u672A\u83B7\u53D6\u5230event\u5750\u6807\u4FE1\u606F");
  7068. }
  7069. var _touches$ = getTouches(touches, this.opts, e);
  7070. var currentOffset = this.scrollOption.currentOffset;
  7071. var opts = assign({}, this.opts, {
  7072. _scrollDistance_: currentOffset,
  7073. animation: false
  7074. });
  7075. if (this.opts.type === "line" || this.opts.type === "area" || this.opts.type === "column" || this.opts.type === "scatter" || this.opts.type === "bubble") {
  7076. var current = this.getCurrentDataIndex(e);
  7077. var index = option.index == void 0 ? current.index : option.index;
  7078. if (index > -1 || index.length > 0) {
  7079. var seriesData = getSeriesDataItem(this.opts.series, index, current.group);
  7080. if (seriesData.length !== 0) {
  7081. var _getToolTipData = getToolTipData(seriesData, this.opts, index, current.group, this.opts.categories, option), textList = _getToolTipData.textList, offset = _getToolTipData.offset;
  7082. offset.y = _touches$.y;
  7083. opts.tooltip = {
  7084. textList: option.textList !== void 0 ? option.textList : textList,
  7085. offset: option.offset !== void 0 ? option.offset : offset,
  7086. option,
  7087. index,
  7088. group: current.group
  7089. };
  7090. }
  7091. }
  7092. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7093. }
  7094. if (this.opts.type === "mount") {
  7095. var index = option.index == void 0 ? this.getCurrentDataIndex(e).index : option.index;
  7096. if (index > -1) {
  7097. var opts = assign({}, this.opts, { animation: false });
  7098. var seriesData = assign({}, opts._series_[index]);
  7099. var textList = [{
  7100. text: option.formatter ? option.formatter(seriesData, void 0, index, opts) : seriesData.name + ": " + seriesData.data,
  7101. color: seriesData.color,
  7102. legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
  7103. }];
  7104. var offset = {
  7105. x: opts.chartData.calPoints[index].x,
  7106. y: _touches$.y
  7107. };
  7108. opts.tooltip = {
  7109. textList: option.textList ? option.textList : textList,
  7110. offset: option.offset !== void 0 ? option.offset : offset,
  7111. option,
  7112. index
  7113. };
  7114. }
  7115. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7116. }
  7117. if (this.opts.type === "bar") {
  7118. var current = this.getCurrentDataIndex(e);
  7119. var index = option.index == void 0 ? current.index : option.index;
  7120. if (index > -1 || index.length > 0) {
  7121. var seriesData = getSeriesDataItem(this.opts.series, index, current.group);
  7122. if (seriesData.length !== 0) {
  7123. var _getToolTipData = getToolTipData(seriesData, this.opts, index, current.group, this.opts.categories, option), textList = _getToolTipData.textList, offset = _getToolTipData.offset;
  7124. offset.x = _touches$.x;
  7125. opts.tooltip = {
  7126. textList: option.textList !== void 0 ? option.textList : textList,
  7127. offset: option.offset !== void 0 ? option.offset : offset,
  7128. option,
  7129. index
  7130. };
  7131. }
  7132. }
  7133. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7134. }
  7135. if (this.opts.type === "mix") {
  7136. var current = this.getCurrentDataIndex(e);
  7137. var index = option.index == void 0 ? current.index : option.index;
  7138. if (index > -1) {
  7139. var currentOffset = this.scrollOption.currentOffset;
  7140. var opts = assign({}, this.opts, {
  7141. _scrollDistance_: currentOffset,
  7142. animation: false
  7143. });
  7144. var seriesData = getSeriesDataItem(this.opts.series, index);
  7145. if (seriesData.length !== 0) {
  7146. var _getMixToolTipData = getMixToolTipData(seriesData, this.opts, index, this.opts.categories, option), textList = _getMixToolTipData.textList, offset = _getMixToolTipData.offset;
  7147. offset.y = _touches$.y;
  7148. opts.tooltip = {
  7149. textList: option.textList ? option.textList : textList,
  7150. offset: option.offset !== void 0 ? option.offset : offset,
  7151. option,
  7152. index
  7153. };
  7154. }
  7155. }
  7156. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7157. }
  7158. if (this.opts.type === "candle") {
  7159. var current = this.getCurrentDataIndex(e);
  7160. var index = option.index == void 0 ? current.index : option.index;
  7161. if (index > -1) {
  7162. var currentOffset = this.scrollOption.currentOffset;
  7163. var opts = assign({}, this.opts, {
  7164. _scrollDistance_: currentOffset,
  7165. animation: false
  7166. });
  7167. var seriesData = getSeriesDataItem(this.opts.series, index);
  7168. if (seriesData.length !== 0) {
  7169. var _getToolTipData = getCandleToolTipData(this.opts.series[0].data, seriesData, this.opts, index, this.opts.categories, this.opts.extra.candle, option), textList = _getToolTipData.textList, offset = _getToolTipData.offset;
  7170. offset.y = _touches$.y;
  7171. opts.tooltip = {
  7172. textList: option.textList ? option.textList : textList,
  7173. offset: option.offset !== void 0 ? option.offset : offset,
  7174. option,
  7175. index
  7176. };
  7177. }
  7178. }
  7179. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7180. }
  7181. if (this.opts.type === "pie" || this.opts.type === "ring" || this.opts.type === "rose" || this.opts.type === "funnel") {
  7182. var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
  7183. if (index > -1) {
  7184. var opts = assign({}, this.opts, { animation: false });
  7185. var seriesData = assign({}, opts._series_[index]);
  7186. var textList = [{
  7187. text: option.formatter ? option.formatter(seriesData, void 0, index, opts) : seriesData.name + ": " + seriesData.data,
  7188. color: seriesData.color,
  7189. legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
  7190. }];
  7191. var offset = {
  7192. x: _touches$.x,
  7193. y: _touches$.y
  7194. };
  7195. opts.tooltip = {
  7196. textList: option.textList ? option.textList : textList,
  7197. offset: option.offset !== void 0 ? option.offset : offset,
  7198. option,
  7199. index
  7200. };
  7201. }
  7202. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7203. }
  7204. if (this.opts.type === "map") {
  7205. var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
  7206. if (index > -1) {
  7207. var opts = assign({}, this.opts, { animation: false });
  7208. var seriesData = assign({}, this.opts.series[index]);
  7209. seriesData.name = seriesData.properties.name;
  7210. var textList = [{
  7211. text: option.formatter ? option.formatter(seriesData, void 0, index, this.opts) : seriesData.name,
  7212. color: seriesData.color,
  7213. legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
  7214. }];
  7215. var offset = {
  7216. x: _touches$.x,
  7217. y: _touches$.y
  7218. };
  7219. opts.tooltip = {
  7220. textList: option.textList ? option.textList : textList,
  7221. offset: option.offset !== void 0 ? option.offset : offset,
  7222. option,
  7223. index
  7224. };
  7225. }
  7226. opts.updateData = false;
  7227. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7228. }
  7229. if (this.opts.type === "word") {
  7230. var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
  7231. if (index > -1) {
  7232. var opts = assign({}, this.opts, { animation: false });
  7233. var seriesData = assign({}, this.opts.series[index]);
  7234. var textList = [{
  7235. text: option.formatter ? option.formatter(seriesData, void 0, index, this.opts) : seriesData.name,
  7236. color: seriesData.color,
  7237. legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
  7238. }];
  7239. var offset = {
  7240. x: _touches$.x,
  7241. y: _touches$.y
  7242. };
  7243. opts.tooltip = {
  7244. textList: option.textList ? option.textList : textList,
  7245. offset: option.offset !== void 0 ? option.offset : offset,
  7246. option,
  7247. index
  7248. };
  7249. }
  7250. opts.updateData = false;
  7251. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7252. }
  7253. if (this.opts.type === "radar") {
  7254. var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
  7255. if (index > -1) {
  7256. var opts = assign({}, this.opts, { animation: false });
  7257. var seriesData = getSeriesDataItem(this.opts.series, index);
  7258. if (seriesData.length !== 0) {
  7259. var textList = seriesData.map((item) => {
  7260. return {
  7261. text: option.formatter ? option.formatter(item, this.opts.categories[index], index, this.opts) : item.name + ": " + item.data,
  7262. color: item.color,
  7263. legendShape: this.opts.extra.tooltip.legendShape == "auto" ? item.legendShape : this.opts.extra.tooltip.legendShape
  7264. };
  7265. });
  7266. var offset = {
  7267. x: _touches$.x,
  7268. y: _touches$.y
  7269. };
  7270. opts.tooltip = {
  7271. textList: option.textList ? option.textList : textList,
  7272. offset: option.offset !== void 0 ? option.offset : offset,
  7273. option,
  7274. index
  7275. };
  7276. }
  7277. }
  7278. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7279. }
  7280. };
  7281. uCharts.prototype.translate = function(distance) {
  7282. this.scrollOption = {
  7283. currentOffset: distance,
  7284. startTouchX: distance,
  7285. distance: 0,
  7286. lastMoveTime: 0
  7287. };
  7288. let opts = assign({}, this.opts, {
  7289. _scrollDistance_: distance,
  7290. animation: false
  7291. });
  7292. drawCharts.call(this, this.opts.type, opts, this.config, this.context);
  7293. };
  7294. uCharts.prototype.scrollStart = function(e) {
  7295. var touches = null;
  7296. if (e.changedTouches) {
  7297. touches = e.changedTouches[0];
  7298. } else {
  7299. touches = e.mp.changedTouches[0];
  7300. }
  7301. var _touches$ = getTouches(touches, this.opts, e);
  7302. if (touches && this.opts.enableScroll === true) {
  7303. this.scrollOption.startTouchX = _touches$.x;
  7304. }
  7305. };
  7306. uCharts.prototype.scroll = function(e) {
  7307. if (this.scrollOption.lastMoveTime === 0) {
  7308. this.scrollOption.lastMoveTime = Date.now();
  7309. }
  7310. let Limit = this.opts.touchMoveLimit || 60;
  7311. let currMoveTime = Date.now();
  7312. let duration = currMoveTime - this.scrollOption.lastMoveTime;
  7313. if (duration < Math.floor(1e3 / Limit))
  7314. return;
  7315. if (this.scrollOption.startTouchX == 0)
  7316. return;
  7317. this.scrollOption.lastMoveTime = currMoveTime;
  7318. var touches = null;
  7319. if (e.changedTouches) {
  7320. touches = e.changedTouches[0];
  7321. } else {
  7322. touches = e.mp.changedTouches[0];
  7323. }
  7324. if (touches && this.opts.enableScroll === true) {
  7325. var _touches$ = getTouches(touches, this.opts, e);
  7326. var _distance;
  7327. _distance = _touches$.x - this.scrollOption.startTouchX;
  7328. var currentOffset = this.scrollOption.currentOffset;
  7329. var validDistance = calValidDistance(this, currentOffset + _distance, this.opts.chartData, this.config, this.opts);
  7330. this.scrollOption.distance = _distance = validDistance - currentOffset;
  7331. var opts = assign({}, this.opts, {
  7332. _scrollDistance_: currentOffset + _distance,
  7333. animation: false
  7334. });
  7335. this.opts = opts;
  7336. drawCharts.call(this, opts.type, opts, this.config, this.context);
  7337. return currentOffset + _distance;
  7338. }
  7339. };
  7340. uCharts.prototype.scrollEnd = function(e) {
  7341. if (this.opts.enableScroll === true) {
  7342. var _scrollOption = this.scrollOption, currentOffset = _scrollOption.currentOffset, distance = _scrollOption.distance;
  7343. this.scrollOption.currentOffset = currentOffset + distance;
  7344. this.scrollOption.distance = 0;
  7345. this.scrollOption.moveCount = 0;
  7346. }
  7347. };
  7348. var u_charts_default = uCharts;
  7349. // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
  7350. var color = ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"];
  7351. var formatDateTime = (timeStamp, returnType) => {
  7352. var date = /* @__PURE__ */ new Date();
  7353. date.setTime(timeStamp * 1e3);
  7354. var y = date.getFullYear();
  7355. var m = date.getMonth() + 1;
  7356. m = m < 10 ? "0" + m : m;
  7357. var d = date.getDate();
  7358. d = d < 10 ? "0" + d : d;
  7359. var h = date.getHours();
  7360. h = h < 10 ? "0" + h : h;
  7361. var minute = date.getMinutes();
  7362. var second = date.getSeconds();
  7363. minute = minute < 10 ? "0" + minute : minute;
  7364. second = second < 10 ? "0" + second : second;
  7365. if (returnType == "full") {
  7366. return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
  7367. }
  7368. if (returnType == "y-m-d") {
  7369. return y + "-" + m + "-" + d;
  7370. }
  7371. if (returnType == "h:m") {
  7372. return h + ":" + minute;
  7373. }
  7374. if (returnType == "h:m:s") {
  7375. return h + ":" + minute + ":" + second;
  7376. }
  7377. return [y, m, d, h, minute, second];
  7378. };
  7379. var cfu = {
  7380. //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
  7381. "type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"],
  7382. "range": ["\u997C\u72B6\u56FE", "\u5706\u73AF\u56FE", "\u73AB\u7470\u56FE", "\u8BCD\u4E91\u56FE", "\u6F0F\u6597\u56FE", "\u5730\u56FE", "\u5706\u5F27\u8FDB\u5EA6\u6761", "\u6298\u7EBF\u56FE", "\u67F1\u72B6\u56FE", "\u5C71\u5CF0\u56FE", "\u6761\u72B6\u56FE", "\u533A\u57DF\u56FE", "\u96F7\u8FBE\u56FE", "\u4EEA\u8868\u76D8", "K\u7EBF\u56FE", "\u6DF7\u5408\u56FE", "\u65F6\u95F4\u8F74\u6298\u7EBF", "\u65F6\u95F4\u8F74\u533A\u57DF", "\u6563\u70B9\u56FE", "\u6C14\u6CE1\u56FE", "\u81EA\u5B9A\u4E49\u7C7B\u578B"],
  7383. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
  7384. //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
  7385. "categories": ["line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
  7386. //instance为实例变量承载属性,不要删除
  7387. "instance": {},
  7388. //option为opts及eopts承载属性,不要删除
  7389. "option": {},
  7390. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  7391. "formatter": {
  7392. "yAxisDemo1": function(val, index, opts) {
  7393. return val + "\u5143";
  7394. },
  7395. "yAxisDemo2": function(val, index, opts) {
  7396. return val.toFixed(2);
  7397. },
  7398. "xAxisDemo1": function(val, index, opts) {
  7399. return val + "\u5E74";
  7400. },
  7401. "xAxisDemo2": function(val, index, opts) {
  7402. return formatDateTime(val, "h:m");
  7403. },
  7404. "seriesDemo1": function(val, index, series, opts) {
  7405. return val + "\u5143";
  7406. },
  7407. "tooltipDemo1": function(item, category, index, opts) {
  7408. if (index == 0) {
  7409. return "\u968F\u4FBF\u7528" + item.data + "\u5E74";
  7410. } else {
  7411. return "\u5176\u4ED6\u6211\u6CA1\u6539" + item.data + "\u5929";
  7412. }
  7413. },
  7414. "pieDemo": function(val, index, series, opts) {
  7415. if (index !== void 0) {
  7416. return series[index].name + "\uFF1A" + series[index].data + "\u5143";
  7417. }
  7418. },
  7419. "timedemo": function(val, index, series) {
  7420. if (series.xAxis.data.includes(Number(val))) {
  7421. return val;
  7422. }
  7423. return "";
  7424. }
  7425. },
  7426. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
  7427. "demotype": {
  7428. //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
  7429. "type": "line",
  7430. "color": color,
  7431. "padding": [15, 10, 0, 15],
  7432. "xAxis": {
  7433. "disableGrid": true
  7434. },
  7435. "yAxis": {
  7436. "gridType": "dash",
  7437. "dashLength": 2
  7438. },
  7439. "legend": {},
  7440. "extra": {
  7441. "line": {
  7442. "type": "curve",
  7443. "width": 2
  7444. }
  7445. }
  7446. },
  7447. //下面是自定义配置,请添加项目所需的通用配置
  7448. "pie": {
  7449. "type": "pie",
  7450. "color": color,
  7451. "padding": [5, 5, 5, 5],
  7452. "extra": {
  7453. "pie": {
  7454. "activeOpacity": 0.5,
  7455. "activeRadius": 10,
  7456. "offsetAngle": 0,
  7457. "labelWidth": 15,
  7458. "border": true,
  7459. "borderWidth": 3,
  7460. "borderColor": "#FFFFFF"
  7461. }
  7462. }
  7463. },
  7464. "ring": {
  7465. "type": "ring",
  7466. "color": color,
  7467. "padding": [5, 5, 5, 5],
  7468. "rotate": false,
  7469. "dataLabel": true,
  7470. "legend": {
  7471. "show": true,
  7472. "position": "right",
  7473. "lineHeight": 25
  7474. },
  7475. "title": {
  7476. "name": "\u6536\u76CA\u7387",
  7477. "fontSize": 15,
  7478. "color": "#666666"
  7479. },
  7480. "subtitle": {
  7481. "name": "70%",
  7482. "fontSize": 25,
  7483. "color": "#7cb5ec"
  7484. },
  7485. "extra": {
  7486. "ring": {
  7487. "ringWidth": 30,
  7488. "activeOpacity": 0.5,
  7489. "activeRadius": 10,
  7490. "offsetAngle": 0,
  7491. "labelWidth": 15,
  7492. "border": true,
  7493. "borderWidth": 3,
  7494. "borderColor": "#FFFFFF"
  7495. }
  7496. }
  7497. },
  7498. "rose": {
  7499. "type": "rose",
  7500. "color": color,
  7501. "padding": [5, 5, 5, 5],
  7502. "legend": {
  7503. "show": true,
  7504. "position": "left",
  7505. "lineHeight": 25
  7506. },
  7507. "extra": {
  7508. "rose": {
  7509. "type": "area",
  7510. "minRadius": 50,
  7511. "activeOpacity": 0.5,
  7512. "activeRadius": 10,
  7513. "offsetAngle": 0,
  7514. "labelWidth": 15,
  7515. "border": false,
  7516. "borderWidth": 2,
  7517. "borderColor": "#FFFFFF"
  7518. }
  7519. }
  7520. },
  7521. "word": {
  7522. "type": "word",
  7523. "color": color,
  7524. "extra": {
  7525. "word": {
  7526. "type": "normal",
  7527. "autoColors": false
  7528. }
  7529. }
  7530. },
  7531. "funnel": {
  7532. "type": "funnel",
  7533. "color": color,
  7534. "padding": [15, 15, 0, 15],
  7535. "extra": {
  7536. "funnel": {
  7537. "activeOpacity": 0.3,
  7538. "activeWidth": 10,
  7539. "border": true,
  7540. "borderWidth": 2,
  7541. "borderColor": "#FFFFFF",
  7542. "fillOpacity": 1,
  7543. "labelAlign": "right"
  7544. }
  7545. }
  7546. },
  7547. "map": {
  7548. "type": "map",
  7549. "color": color,
  7550. "padding": [0, 0, 0, 0],
  7551. "dataLabel": true,
  7552. "extra": {
  7553. "map": {
  7554. "border": true,
  7555. "borderWidth": 1,
  7556. "borderColor": "#666666",
  7557. "fillOpacity": 0.6,
  7558. "activeBorderColor": "#F04864",
  7559. "activeFillColor": "#FACC14",
  7560. "activeFillOpacity": 1
  7561. }
  7562. }
  7563. },
  7564. "arcbar": {
  7565. "type": "arcbar",
  7566. "color": color,
  7567. "title": {
  7568. "name": "\u767E\u5206\u6BD4",
  7569. "fontSize": 25,
  7570. "color": "#00FF00"
  7571. },
  7572. "subtitle": {
  7573. "name": "\u9ED8\u8BA4\u6807\u9898",
  7574. "fontSize": 15,
  7575. "color": "#666666"
  7576. },
  7577. "extra": {
  7578. "arcbar": {
  7579. "type": "default",
  7580. "width": 12,
  7581. "backgroundColor": "#E9E9E9",
  7582. "startAngle": 0.75,
  7583. "endAngle": 0.25,
  7584. "gap": 2
  7585. }
  7586. }
  7587. },
  7588. "line": {
  7589. "type": "line",
  7590. "color": color,
  7591. "padding": [15, 10, 0, 15],
  7592. "xAxis": {
  7593. "disableGrid": true
  7594. },
  7595. "yAxis": {
  7596. "gridType": "dash",
  7597. "dashLength": 2
  7598. },
  7599. "legend": {},
  7600. "extra": {
  7601. "line": {
  7602. "type": "straight",
  7603. "width": 2,
  7604. "activeType": "hollow"
  7605. }
  7606. }
  7607. },
  7608. "tline": {
  7609. "type": "line",
  7610. "color": color,
  7611. "padding": [15, 10, 0, 15],
  7612. "xAxis": {
  7613. "disableGrid": false,
  7614. "boundaryGap": "justify"
  7615. },
  7616. "yAxis": {
  7617. "gridType": "dash",
  7618. "dashLength": 2,
  7619. "data": [
  7620. {
  7621. "min": 0,
  7622. "max": 80
  7623. }
  7624. ]
  7625. },
  7626. "legend": {},
  7627. "extra": {
  7628. "line": {
  7629. "type": "curve",
  7630. "width": 2,
  7631. "activeType": "hollow"
  7632. }
  7633. }
  7634. },
  7635. "tarea": {
  7636. "type": "area",
  7637. "color": color,
  7638. "padding": [15, 10, 0, 15],
  7639. "xAxis": {
  7640. "disableGrid": true,
  7641. "boundaryGap": "justify"
  7642. },
  7643. "yAxis": {
  7644. "gridType": "dash",
  7645. "dashLength": 2,
  7646. "data": [
  7647. {
  7648. "min": 0,
  7649. "max": 80
  7650. }
  7651. ]
  7652. },
  7653. "legend": {},
  7654. "extra": {
  7655. "area": {
  7656. "type": "curve",
  7657. "opacity": 0.2,
  7658. "addLine": true,
  7659. "width": 2,
  7660. "gradient": true,
  7661. "activeType": "hollow"
  7662. }
  7663. }
  7664. },
  7665. "column": {
  7666. "type": "column",
  7667. "color": color,
  7668. "padding": [15, 15, 0, 5],
  7669. "xAxis": {
  7670. "disableGrid": true
  7671. },
  7672. "yAxis": {
  7673. "data": [{ "min": 0 }]
  7674. },
  7675. "legend": {},
  7676. "extra": {
  7677. "column": {
  7678. "type": "group",
  7679. "width": 30,
  7680. "activeBgColor": "#000000",
  7681. "activeBgOpacity": 0.08
  7682. }
  7683. }
  7684. },
  7685. "mount": {
  7686. "type": "mount",
  7687. "color": color,
  7688. "padding": [15, 15, 0, 5],
  7689. "xAxis": {
  7690. "disableGrid": true
  7691. },
  7692. "yAxis": {
  7693. "data": [{ "min": 0 }]
  7694. },
  7695. "legend": {},
  7696. "extra": {
  7697. "mount": {
  7698. "type": "mount",
  7699. "widthRatio": 1.5
  7700. }
  7701. }
  7702. },
  7703. "bar": {
  7704. "type": "bar",
  7705. "color": color,
  7706. "padding": [15, 30, 0, 5],
  7707. "xAxis": {
  7708. "boundaryGap": "justify",
  7709. "disableGrid": false,
  7710. "min": 0,
  7711. "axisLine": false
  7712. },
  7713. "yAxis": {},
  7714. "legend": {},
  7715. "extra": {
  7716. "bar": {
  7717. "type": "group",
  7718. "width": 30,
  7719. "meterBorde": 1,
  7720. "meterFillColor": "#FFFFFF",
  7721. "activeBgColor": "#000000",
  7722. "activeBgOpacity": 0.08
  7723. }
  7724. }
  7725. },
  7726. "area": {
  7727. "type": "area",
  7728. "color": color,
  7729. "padding": [15, 15, 0, 15],
  7730. "xAxis": {
  7731. "disableGrid": true
  7732. },
  7733. "yAxis": {
  7734. "gridType": "dash",
  7735. "dashLength": 2
  7736. },
  7737. "legend": {},
  7738. "extra": {
  7739. "area": {
  7740. "type": "straight",
  7741. "opacity": 0.2,
  7742. "addLine": true,
  7743. "width": 2,
  7744. "gradient": false,
  7745. "activeType": "hollow"
  7746. }
  7747. }
  7748. },
  7749. "radar": {
  7750. "type": "radar",
  7751. "color": color,
  7752. "padding": [5, 5, 5, 5],
  7753. "dataLabel": false,
  7754. "legend": {
  7755. "show": true,
  7756. "position": "right",
  7757. "lineHeight": 25
  7758. },
  7759. "extra": {
  7760. "radar": {
  7761. "gridType": "radar",
  7762. "gridColor": "#CCCCCC",
  7763. "gridCount": 3,
  7764. "opacity": 0.2,
  7765. "max": 200,
  7766. "labelShow": true
  7767. }
  7768. }
  7769. },
  7770. "gauge": {
  7771. "type": "gauge",
  7772. "color": color,
  7773. "title": {
  7774. "name": "66Km/H",
  7775. "fontSize": 25,
  7776. "color": "#2fc25b",
  7777. "offsetY": 50
  7778. },
  7779. "subtitle": {
  7780. "name": "\u5B9E\u65F6\u901F\u5EA6",
  7781. "fontSize": 15,
  7782. "color": "#1890ff",
  7783. "offsetY": -50
  7784. },
  7785. "extra": {
  7786. "gauge": {
  7787. "type": "default",
  7788. "width": 30,
  7789. "labelColor": "#666666",
  7790. "startAngle": 0.75,
  7791. "endAngle": 0.25,
  7792. "startNumber": 0,
  7793. "endNumber": 100,
  7794. "labelFormat": "",
  7795. "splitLine": {
  7796. "fixRadius": 0,
  7797. "splitNumber": 10,
  7798. "width": 30,
  7799. "color": "#FFFFFF",
  7800. "childNumber": 5,
  7801. "childWidth": 12
  7802. },
  7803. "pointer": {
  7804. "width": 24,
  7805. "color": "auto"
  7806. }
  7807. }
  7808. }
  7809. },
  7810. "candle": {
  7811. "type": "candle",
  7812. "color": color,
  7813. "padding": [15, 15, 0, 15],
  7814. "enableScroll": true,
  7815. "enableMarkLine": true,
  7816. "dataLabel": false,
  7817. "xAxis": {
  7818. "labelCount": 4,
  7819. "itemCount": 40,
  7820. "disableGrid": true,
  7821. "gridColor": "#CCCCCC",
  7822. "gridType": "solid",
  7823. "dashLength": 4,
  7824. "scrollShow": true,
  7825. "scrollAlign": "left",
  7826. "scrollColor": "#A6A6A6",
  7827. "scrollBackgroundColor": "#EFEBEF"
  7828. },
  7829. "yAxis": {},
  7830. "legend": {},
  7831. "extra": {
  7832. "candle": {
  7833. "color": {
  7834. "upLine": "#f04864",
  7835. "upFill": "#f04864",
  7836. "downLine": "#2fc25b",
  7837. "downFill": "#2fc25b"
  7838. },
  7839. "average": {
  7840. "show": true,
  7841. "name": ["MA5", "MA10", "MA30"],
  7842. "day": [5, 10, 20],
  7843. "color": ["#1890ff", "#2fc25b", "#facc14"]
  7844. }
  7845. },
  7846. "markLine": {
  7847. "type": "dash",
  7848. "dashLength": 5,
  7849. "data": [
  7850. {
  7851. "value": 2150,
  7852. "lineColor": "#f04864",
  7853. "showLabel": true
  7854. },
  7855. {
  7856. "value": 2350,
  7857. "lineColor": "#f04864",
  7858. "showLabel": true
  7859. }
  7860. ]
  7861. }
  7862. }
  7863. },
  7864. "mix": {
  7865. "type": "mix",
  7866. "color": color,
  7867. "padding": [15, 15, 0, 15],
  7868. "xAxis": {
  7869. "disableGrid": true
  7870. },
  7871. "yAxis": {
  7872. "disabled": false,
  7873. "disableGrid": false,
  7874. "splitNumber": 5,
  7875. "gridType": "dash",
  7876. "dashLength": 4,
  7877. "gridColor": "#CCCCCC",
  7878. "padding": 10,
  7879. "showTitle": true,
  7880. "data": []
  7881. },
  7882. "legend": {},
  7883. "extra": {
  7884. "mix": {
  7885. "column": {
  7886. "width": 20
  7887. }
  7888. }
  7889. }
  7890. },
  7891. "scatter": {
  7892. "type": "scatter",
  7893. "color": color,
  7894. "padding": [15, 15, 0, 15],
  7895. "dataLabel": false,
  7896. "xAxis": {
  7897. "disableGrid": false,
  7898. "gridType": "dash",
  7899. "splitNumber": 5,
  7900. "boundaryGap": "justify",
  7901. "min": 0
  7902. },
  7903. "yAxis": {
  7904. "disableGrid": false,
  7905. "gridType": "dash"
  7906. },
  7907. "legend": {},
  7908. "extra": {
  7909. "scatter": {}
  7910. }
  7911. },
  7912. "bubble": {
  7913. "type": "bubble",
  7914. "color": color,
  7915. "padding": [15, 15, 0, 15],
  7916. "xAxis": {
  7917. "disableGrid": false,
  7918. "gridType": "dash",
  7919. "splitNumber": 5,
  7920. "boundaryGap": "justify",
  7921. "min": 0,
  7922. "max": 250
  7923. },
  7924. "yAxis": {
  7925. "disableGrid": false,
  7926. "gridType": "dash",
  7927. "data": [{
  7928. "min": 0,
  7929. "max": 150
  7930. }]
  7931. },
  7932. "legend": {},
  7933. "extra": {
  7934. "bubble": {
  7935. "border": 2,
  7936. "opacity": 0.5
  7937. }
  7938. }
  7939. }
  7940. };
  7941. var config_ucharts_default = cfu;
  7942. // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/config-echarts.js
  7943. var color2 = ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"];
  7944. var cfe = {
  7945. //demotype为自定义图表类型
  7946. "type": ["pie", "ring", "rose", "funnel", "line", "column", "area", "radar", "gauge", "candle", "demotype"],
  7947. //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型例如最后的"demotype"
  7948. "categories": ["line", "column", "area", "radar", "gauge", "candle", "demotype"],
  7949. //instance为实例变量承载属性,option为eopts承载属性,不要删除
  7950. "instance": {},
  7951. "option": {},
  7952. //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
  7953. "formatter": {
  7954. "tooltipDemo1": function(res) {
  7955. let result = "";
  7956. for (let i in res) {
  7957. if (i == 0) {
  7958. result += res[i].axisValueLabel + "\u5E74\u9500\u552E\u989D";
  7959. }
  7960. let value = "--";
  7961. if (res[i].data !== null) {
  7962. value = res[i].data;
  7963. }
  7964. result += "\n" + res[i].seriesName + "\uFF1A" + value + " \u4E07\u5143";
  7965. result += "<br/>" + res[i].marker + res[i].seriesName + "\uFF1A" + value + " \u4E07\u5143";
  7966. }
  7967. return result;
  7968. },
  7969. legendFormat: function(name) {
  7970. return "\u81EA\u5B9A\u4E49\u56FE\u4F8B+" + name;
  7971. },
  7972. yAxisFormatDemo: function(value, index) {
  7973. return value + "\u5143";
  7974. },
  7975. seriesFormatDemo: function(res) {
  7976. return res.name + "\u5E74" + res.value + "\u5143";
  7977. }
  7978. },
  7979. //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在eopts参数,会将demotype与eopts中option合并后渲染图表。
  7980. "demotype": {
  7981. "color": color2
  7982. //在这里填写echarts的option即可
  7983. },
  7984. //下面是自定义配置,请添加项目所需的通用配置
  7985. "column": {
  7986. "color": color2,
  7987. "title": {
  7988. "text": ""
  7989. },
  7990. "tooltip": {
  7991. "trigger": "axis"
  7992. },
  7993. "grid": {
  7994. "top": 30,
  7995. "bottom": 50,
  7996. "right": 15,
  7997. "left": 40
  7998. },
  7999. "legend": {
  8000. "bottom": "left"
  8001. },
  8002. "toolbox": {
  8003. "show": false
  8004. },
  8005. "xAxis": {
  8006. "type": "category",
  8007. "axisLabel": {
  8008. "color": "#666666"
  8009. },
  8010. "axisLine": {
  8011. "lineStyle": {
  8012. "color": "#CCCCCC"
  8013. }
  8014. },
  8015. "boundaryGap": true,
  8016. "data": []
  8017. },
  8018. "yAxis": {
  8019. "type": "value",
  8020. "axisTick": {
  8021. "show": false
  8022. },
  8023. "axisLabel": {
  8024. "color": "#666666"
  8025. },
  8026. "axisLine": {
  8027. "lineStyle": {
  8028. "color": "#CCCCCC"
  8029. }
  8030. }
  8031. },
  8032. "seriesTemplate": {
  8033. "name": "",
  8034. "type": "bar",
  8035. "data": [],
  8036. "barwidth": 20,
  8037. "label": {
  8038. "show": true,
  8039. "color": "#666666",
  8040. "position": "top"
  8041. }
  8042. }
  8043. },
  8044. "line": {
  8045. "color": color2,
  8046. "title": {
  8047. "text": ""
  8048. },
  8049. "tooltip": {
  8050. "trigger": "axis"
  8051. },
  8052. "grid": {
  8053. "top": 30,
  8054. "bottom": 50,
  8055. "right": 15,
  8056. "left": 40
  8057. },
  8058. "legend": {
  8059. "bottom": "left"
  8060. },
  8061. "toolbox": {
  8062. "show": false
  8063. },
  8064. "xAxis": {
  8065. "type": "category",
  8066. "axisLabel": {
  8067. "color": "#666666"
  8068. },
  8069. "axisLine": {
  8070. "lineStyle": {
  8071. "color": "#CCCCCC"
  8072. }
  8073. },
  8074. "boundaryGap": true,
  8075. "data": []
  8076. },
  8077. "yAxis": {
  8078. "type": "value",
  8079. "axisTick": {
  8080. "show": false
  8081. },
  8082. "axisLabel": {
  8083. "color": "#666666"
  8084. },
  8085. "axisLine": {
  8086. "lineStyle": {
  8087. "color": "#CCCCCC"
  8088. }
  8089. }
  8090. },
  8091. "seriesTemplate": {
  8092. "name": "",
  8093. "type": "line",
  8094. "data": [],
  8095. "barwidth": 20,
  8096. "label": {
  8097. "show": true,
  8098. "color": "#666666",
  8099. "position": "top"
  8100. }
  8101. }
  8102. },
  8103. "area": {
  8104. "color": color2,
  8105. "title": {
  8106. "text": ""
  8107. },
  8108. "tooltip": {
  8109. "trigger": "axis"
  8110. },
  8111. "grid": {
  8112. "top": 30,
  8113. "bottom": 50,
  8114. "right": 15,
  8115. "left": 40
  8116. },
  8117. "legend": {
  8118. "bottom": "left"
  8119. },
  8120. "toolbox": {
  8121. "show": false
  8122. },
  8123. "xAxis": {
  8124. "type": "category",
  8125. "axisLabel": {
  8126. "color": "#666666"
  8127. },
  8128. "axisLine": {
  8129. "lineStyle": {
  8130. "color": "#CCCCCC"
  8131. }
  8132. },
  8133. "boundaryGap": true,
  8134. "data": []
  8135. },
  8136. "yAxis": {
  8137. "type": "value",
  8138. "axisTick": {
  8139. "show": false
  8140. },
  8141. "axisLabel": {
  8142. "color": "#666666"
  8143. },
  8144. "axisLine": {
  8145. "lineStyle": {
  8146. "color": "#CCCCCC"
  8147. }
  8148. }
  8149. },
  8150. "seriesTemplate": {
  8151. "name": "",
  8152. "type": "line",
  8153. "data": [],
  8154. "areaStyle": {},
  8155. "label": {
  8156. "show": true,
  8157. "color": "#666666",
  8158. "position": "top"
  8159. }
  8160. }
  8161. },
  8162. "pie": {
  8163. "color": color2,
  8164. "title": {
  8165. "text": ""
  8166. },
  8167. "tooltip": {
  8168. "trigger": "item"
  8169. },
  8170. "grid": {
  8171. "top": 40,
  8172. "bottom": 30,
  8173. "right": 15,
  8174. "left": 15
  8175. },
  8176. "legend": {
  8177. "bottom": "left"
  8178. },
  8179. "seriesTemplate": {
  8180. "name": "",
  8181. "type": "pie",
  8182. "data": [],
  8183. "radius": "50%",
  8184. "label": {
  8185. "show": true,
  8186. "color": "#666666",
  8187. "position": "top"
  8188. }
  8189. }
  8190. },
  8191. "ring": {
  8192. "color": color2,
  8193. "title": {
  8194. "text": ""
  8195. },
  8196. "tooltip": {
  8197. "trigger": "item"
  8198. },
  8199. "grid": {
  8200. "top": 40,
  8201. "bottom": 30,
  8202. "right": 15,
  8203. "left": 15
  8204. },
  8205. "legend": {
  8206. "bottom": "left"
  8207. },
  8208. "seriesTemplate": {
  8209. "name": "",
  8210. "type": "pie",
  8211. "data": [],
  8212. "radius": ["40%", "70%"],
  8213. "avoidLabelOverlap": false,
  8214. "label": {
  8215. "show": true,
  8216. "color": "#666666",
  8217. "position": "top"
  8218. },
  8219. "labelLine": {
  8220. "show": true
  8221. }
  8222. }
  8223. },
  8224. "rose": {
  8225. "color": color2,
  8226. "title": {
  8227. "text": ""
  8228. },
  8229. "tooltip": {
  8230. "trigger": "item"
  8231. },
  8232. "legend": {
  8233. "top": "bottom"
  8234. },
  8235. "seriesTemplate": {
  8236. "name": "",
  8237. "type": "pie",
  8238. "data": [],
  8239. "radius": "55%",
  8240. "center": ["50%", "50%"],
  8241. "roseType": "area"
  8242. }
  8243. },
  8244. "funnel": {
  8245. "color": color2,
  8246. "title": {
  8247. "text": ""
  8248. },
  8249. "tooltip": {
  8250. "trigger": "item",
  8251. "formatter": "{b} : {c}%"
  8252. },
  8253. "legend": {
  8254. "top": "bottom"
  8255. },
  8256. "seriesTemplate": {
  8257. "name": "",
  8258. "type": "funnel",
  8259. "left": "10%",
  8260. "top": 60,
  8261. "bottom": 60,
  8262. "width": "80%",
  8263. "min": 0,
  8264. "max": 100,
  8265. "minSize": "0%",
  8266. "maxSize": "100%",
  8267. "sort": "descending",
  8268. "gap": 2,
  8269. "label": {
  8270. "show": true,
  8271. "position": "inside"
  8272. },
  8273. "labelLine": {
  8274. "length": 10,
  8275. "lineStyle": {
  8276. "width": 1,
  8277. "type": "solid"
  8278. }
  8279. },
  8280. "itemStyle": {
  8281. "bordercolor": "#fff",
  8282. "borderwidth": 1
  8283. },
  8284. "emphasis": {
  8285. "label": {
  8286. "fontSize": 20
  8287. }
  8288. },
  8289. "data": []
  8290. }
  8291. },
  8292. "gauge": {
  8293. "color": color2,
  8294. "tooltip": {
  8295. "formatter": "{a} <br/>{b} : {c}%"
  8296. },
  8297. "seriesTemplate": {
  8298. "name": "\u4E1A\u52A1\u6307\u6807",
  8299. "type": "gauge",
  8300. "detail": { "formatter": "{value}%" },
  8301. "data": [{ "value": 50, "name": "\u5B8C\u6210\u7387" }]
  8302. }
  8303. },
  8304. "candle": {
  8305. "xAxis": {
  8306. "data": []
  8307. },
  8308. "yAxis": {},
  8309. "color": color2,
  8310. "title": {
  8311. "text": ""
  8312. },
  8313. "dataZoom": [
  8314. {
  8315. "type": "inside",
  8316. "xAxisIndex": [0, 1],
  8317. "start": 10,
  8318. "end": 100
  8319. },
  8320. {
  8321. "show": true,
  8322. "xAxisIndex": [0, 1],
  8323. "type": "slider",
  8324. "bottom": 10,
  8325. "start": 10,
  8326. "end": 100
  8327. }
  8328. ],
  8329. "seriesTemplate": {
  8330. "name": "",
  8331. "type": "k",
  8332. "data": []
  8333. }
  8334. }
  8335. };
  8336. var config_echarts_default = cfe;
  8337. // <stdin>
  8338. var that = {};
  8339. var rootdom = null;
  8340. function rddeepCloneAssign(origin = {}, ...args) {
  8341. for (let i in args) {
  8342. for (let key in args[i]) {
  8343. if (args[i].hasOwnProperty(key)) {
  8344. origin[key] = args[i][key] && typeof args[i][key] === "object" ? rddeepCloneAssign(Array.isArray(args[i][key]) ? [] : {}, origin[key], args[i][key]) : args[i][key];
  8345. }
  8346. }
  8347. }
  8348. return origin;
  8349. }
  8350. function rdformatterAssign(args, formatter) {
  8351. for (let key in args) {
  8352. if (args.hasOwnProperty(key) && args[key] !== null && typeof args[key] === "object") {
  8353. rdformatterAssign(args[key], formatter);
  8354. } else if (key === "format" && typeof args[key] === "string") {
  8355. args["formatter"] = formatter[args[key]] ? formatter[args[key]] : void 0;
  8356. }
  8357. }
  8358. return args;
  8359. }
  8360. var stdin_default = {
  8361. data() {
  8362. return {
  8363. rid: null
  8364. };
  8365. },
  8366. mounted() {
  8367. rootdom = { top: 0, left: 0 };
  8368. setTimeout(() => {
  8369. if (this.rid === null) {
  8370. this.$ownerInstance && this.$ownerInstance.callMethod("getRenderType");
  8371. }
  8372. }, 200);
  8373. },
  8374. destroyed() {
  8375. delete config_ucharts_default.option[this.rid];
  8376. delete config_ucharts_default.instance[this.rid];
  8377. delete config_echarts_default.option[this.rid];
  8378. delete config_echarts_default.instance[this.rid];
  8379. },
  8380. methods: {
  8381. //==============以下是ECharts的方法====================
  8382. ecinit(newVal, oldVal, owner, instance) {
  8383. let cid = JSON.stringify(newVal.id);
  8384. this.rid = cid;
  8385. that[cid] = this.$ownerInstance || instance;
  8386. let eopts = JSON.parse(JSON.stringify(newVal));
  8387. let type = eopts.type;
  8388. if (type && config_echarts_default.type.includes(type)) {
  8389. config_echarts_default.option[cid] = rddeepCloneAssign({}, config_echarts_default[type], eopts);
  8390. } else {
  8391. config_echarts_default.option[cid] = rddeepCloneAssign({}, eopts);
  8392. }
  8393. let newData = eopts.chartData;
  8394. if (newData) {
  8395. if (config_echarts_default.option[cid].xAxis && config_echarts_default.option[cid].xAxis.type && config_echarts_default.option[cid].xAxis.type === "category") {
  8396. config_echarts_default.option[cid].xAxis.data = newData.categories;
  8397. }
  8398. if (config_echarts_default.option[cid].yAxis && config_echarts_default.option[cid].yAxis.type && config_echarts_default.option[cid].yAxis.type === "category") {
  8399. config_echarts_default.option[cid].yAxis.data = newData.categories;
  8400. }
  8401. config_echarts_default.option[cid].series = [];
  8402. for (var i = 0; i < newData.series.length; i++) {
  8403. config_echarts_default.option[cid].seriesTemplate = config_echarts_default.option[cid].seriesTemplate ? config_echarts_default.option[cid].seriesTemplate : {};
  8404. let Template = rddeepCloneAssign({}, config_echarts_default.option[cid].seriesTemplate, newData.series[i]);
  8405. config_echarts_default.option[cid].series.push(Template);
  8406. }
  8407. }
  8408. if (typeof window.echarts === "object") {
  8409. this.newEChart();
  8410. } else {
  8411. const script = document.createElement("script");
  8412. script.src = "./uni_modules/qiun-data-charts/static/app-plus/echarts.min.js";
  8413. script.onload = this.newEChart;
  8414. document.head.appendChild(script);
  8415. }
  8416. },
  8417. ecresize(newVal, oldVal, owner, instance) {
  8418. if (config_echarts_default.instance[this.rid]) {
  8419. config_echarts_default.instance[this.rid].resize();
  8420. }
  8421. },
  8422. newEChart() {
  8423. let cid = this.rid;
  8424. if (config_echarts_default.instance[cid] === void 0) {
  8425. config_echarts_default.instance[cid] = echarts.init(that[cid].$el.children[0]);
  8426. if (config_echarts_default.option[cid].ontap === true) {
  8427. config_echarts_default.instance[cid].on("click", (resdata) => {
  8428. let event = JSON.parse(JSON.stringify({
  8429. x: resdata.event.offsetX,
  8430. y: resdata.event.offsetY
  8431. }));
  8432. that[cid].callMethod("emitMsg", { name: "getIndex", params: { type: "getIndex", event, currentIndex: resdata.dataIndex, value: resdata.data, seriesName: resdata.seriesName, id: cid } });
  8433. });
  8434. config_echarts_default.instance[cid].on("highlight", (resdata) => {
  8435. that[cid].callMethod("emitMsg", { name: "getHighlight", params: { type: "highlight", res: resdata, id: cid } });
  8436. });
  8437. }
  8438. this.updataEChart(cid, config_echarts_default.option[cid]);
  8439. } else {
  8440. this.updataEChart(cid, config_echarts_default.option[cid]);
  8441. }
  8442. },
  8443. updataEChart(cid, option) {
  8444. option = rdformatterAssign(option, config_echarts_default.formatter);
  8445. if (option.tooltip) {
  8446. option.tooltip.show = option.tooltipShow ? true : false;
  8447. option.tooltip.position = this.tooltipPosition();
  8448. if (typeof option.tooltipFormat === "string" && config_echarts_default.formatter[option.tooltipFormat]) {
  8449. option.tooltip.formatter = option.tooltip.formatter ? option.tooltip.formatter : config_echarts_default.formatter[option.tooltipFormat];
  8450. }
  8451. }
  8452. if (option.series) {
  8453. for (let i in option.series) {
  8454. let linearGradient = option.series[i].linearGradient;
  8455. if (linearGradient) {
  8456. option.series[i].color = new echarts.graphic.LinearGradient(linearGradient[0], linearGradient[1], linearGradient[2], linearGradient[3], linearGradient[4]);
  8457. }
  8458. }
  8459. }
  8460. config_echarts_default.instance[cid].setOption(option, option.notMerge);
  8461. config_echarts_default.instance[cid].on("finished", function() {
  8462. that[cid].callMethod("emitMsg", { name: "complete", params: { type: "complete", complete: true, id: cid } });
  8463. if (config_echarts_default.instance[cid]) {
  8464. config_echarts_default.instance[cid].off("finished");
  8465. }
  8466. });
  8467. if (typeof that[cid].$el.children[0].clientWidth != "undefined" && (Math.abs(that[cid].$el.children[0].clientWidth - config_echarts_default.instance[cid].getWidth()) > 3 || Math.abs(that[cid].$el.children[0].clientHeight - config_echarts_default.instance[cid].getHeight()) > 3)) {
  8468. this.ecresize();
  8469. }
  8470. },
  8471. tooltipPosition() {
  8472. return (point, params, dom, rect, size) => {
  8473. let x = point[0];
  8474. let y = point[1];
  8475. let viewWidth = size.viewSize[0];
  8476. let viewHeight = size.viewSize[1];
  8477. let boxWidth = size.contentSize[0];
  8478. let boxHeight = size.contentSize[1];
  8479. let posX = x + 30;
  8480. let posY = y + 30;
  8481. if (posX + boxWidth > viewWidth) {
  8482. posX = x - boxWidth - 30;
  8483. }
  8484. if (posY + boxHeight > viewHeight) {
  8485. posY = y - boxHeight - 30;
  8486. }
  8487. return [posX, posY];
  8488. };
  8489. },
  8490. //==============以下是uCharts的方法====================
  8491. ucinit(newVal, oldVal, owner, instance) {
  8492. if (JSON.stringify(newVal) == JSON.stringify(oldVal)) {
  8493. return;
  8494. }
  8495. if (!newVal.canvasId) {
  8496. return;
  8497. }
  8498. let cid = JSON.parse(JSON.stringify(newVal.canvasId));
  8499. this.rid = cid;
  8500. that[cid] = this.$ownerInstance || instance;
  8501. config_ucharts_default.option[cid] = JSON.parse(JSON.stringify(newVal));
  8502. config_ucharts_default.option[cid] = rdformatterAssign(config_ucharts_default.option[cid], config_ucharts_default.formatter);
  8503. let canvasdom = document.getElementById(cid);
  8504. if (canvasdom && canvasdom.children[0]) {
  8505. config_ucharts_default.option[cid].context = canvasdom.children[0].getContext("2d");
  8506. if (config_ucharts_default.instance[cid] && config_ucharts_default.option[cid] && config_ucharts_default.option[cid].update === true) {
  8507. this.updataUChart();
  8508. } else {
  8509. setTimeout(() => {
  8510. config_ucharts_default.option[cid].context.restore();
  8511. config_ucharts_default.option[cid].context.save();
  8512. this.newUChart();
  8513. }, 100);
  8514. }
  8515. }
  8516. },
  8517. newUChart() {
  8518. let cid = this.rid;
  8519. config_ucharts_default.instance[cid] = new u_charts_default(config_ucharts_default.option[cid]);
  8520. config_ucharts_default.instance[cid].addEventListener("renderComplete", () => {
  8521. that[cid].callMethod("emitMsg", { name: "complete", params: { type: "complete", complete: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8522. config_ucharts_default.instance[cid].delEventListener("renderComplete");
  8523. });
  8524. config_ucharts_default.instance[cid].addEventListener("scrollLeft", () => {
  8525. that[cid].callMethod("emitMsg", { name: "scrollLeft", params: { type: "scrollLeft", scrollLeft: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8526. });
  8527. config_ucharts_default.instance[cid].addEventListener("scrollRight", () => {
  8528. that[cid].callMethod("emitMsg", { name: "scrollRight", params: { type: "scrollRight", scrollRight: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8529. });
  8530. },
  8531. updataUChart() {
  8532. let cid = this.rid;
  8533. config_ucharts_default.instance[cid].updateData(config_ucharts_default.option[cid]);
  8534. },
  8535. tooltipDefault(item, category, index, opts) {
  8536. if (category) {
  8537. let data = item.data;
  8538. if (typeof item.data === "object") {
  8539. data = item.data.value;
  8540. }
  8541. return category + " " + item.name + ":" + data;
  8542. } else {
  8543. if (item.properties && item.properties.name) {
  8544. return item.properties.name;
  8545. } else {
  8546. return item.name + ":" + item.data;
  8547. }
  8548. }
  8549. },
  8550. showTooltip(e, cid) {
  8551. let tc = config_ucharts_default.option[cid].tooltipCustom;
  8552. if (tc && tc !== void 0 && tc !== null) {
  8553. let offset = void 0;
  8554. if (tc.x >= 0 && tc.y >= 0) {
  8555. offset = { x: tc.x, y: tc.y + 10 };
  8556. }
  8557. config_ucharts_default.instance[cid].showToolTip(e, {
  8558. index: tc.index,
  8559. offset,
  8560. textList: tc.textList,
  8561. formatter: (item, category, index, opts) => {
  8562. if (typeof config_ucharts_default.option[cid].tooltipFormat === "string" && config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat]) {
  8563. return config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat](item, category, index, opts);
  8564. } else {
  8565. return this.tooltipDefault(item, category, index, opts);
  8566. }
  8567. }
  8568. });
  8569. } else {
  8570. config_ucharts_default.instance[cid].showToolTip(e, {
  8571. formatter: (item, category, index, opts) => {
  8572. if (typeof config_ucharts_default.option[cid].tooltipFormat === "string" && config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat]) {
  8573. return config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat](item, category, index, opts);
  8574. } else {
  8575. return this.tooltipDefault(item, category, index, opts);
  8576. }
  8577. }
  8578. });
  8579. }
  8580. },
  8581. tap(e) {
  8582. let cid = this.rid;
  8583. let ontap = config_ucharts_default.option[cid].ontap;
  8584. let tooltipShow = config_ucharts_default.option[cid].tooltipShow;
  8585. let tapLegend = config_ucharts_default.option[cid].tapLegend;
  8586. if (ontap == false)
  8587. return;
  8588. let currentIndex = null;
  8589. let legendIndex = null;
  8590. let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
  8591. let tmpe = {};
  8592. if (e.detail.x) {
  8593. tmpe = { x: e.detail.x - rchartdom.left, y: e.detail.y - rchartdom.top + rootdom.top };
  8594. } else {
  8595. tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
  8596. }
  8597. e.changedTouches = [];
  8598. e.changedTouches.unshift(tmpe);
  8599. currentIndex = config_ucharts_default.instance[cid].getCurrentDataIndex(e);
  8600. legendIndex = config_ucharts_default.instance[cid].getLegendDataIndex(e);
  8601. if (tapLegend === true) {
  8602. config_ucharts_default.instance[cid].touchLegend(e);
  8603. }
  8604. if (tooltipShow == true) {
  8605. this.showTooltip(e, cid);
  8606. }
  8607. that[cid].callMethod("emitMsg", { name: "getIndex", params: { type: "getIndex", event: tmpe, currentIndex, legendIndex, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8608. },
  8609. touchStart(e) {
  8610. let cid = this.rid;
  8611. let ontouch = config_ucharts_default.option[cid].ontouch;
  8612. if (ontouch == false)
  8613. return;
  8614. if (config_ucharts_default.option[cid].enableScroll === true && e.touches.length == 1) {
  8615. config_ucharts_default.instance[cid].scrollStart(e);
  8616. }
  8617. that[cid].callMethod("emitMsg", { name: "getTouchStart", params: { type: "touchStart", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8618. },
  8619. touchMove(e) {
  8620. let cid = this.rid;
  8621. let ontouch = config_ucharts_default.option[cid].ontouch;
  8622. if (ontouch == false)
  8623. return;
  8624. if (config_ucharts_default.option[cid].enableScroll === true && e.changedTouches.length == 1) {
  8625. config_ucharts_default.instance[cid].scroll(e);
  8626. }
  8627. if (config_ucharts_default.option[cid].ontap === true && config_ucharts_default.option[cid].enableScroll === false && config_ucharts_default.option[cid].onmovetip === true) {
  8628. let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
  8629. let tmpe = { x: e.changedTouches[0].clientX - rchartdom.left, y: e.changedTouches[0].clientY - rchartdom.top + rootdom.top };
  8630. e.changedTouches.unshift(tmpe);
  8631. if (config_ucharts_default.option[cid].tooltipShow === true) {
  8632. this.showTooltip(e, cid);
  8633. }
  8634. }
  8635. if (ontouch === true && config_ucharts_default.option[cid].enableScroll === true && config_ucharts_default.option[cid].onzoom === true && e.changedTouches.length == 2) {
  8636. config_ucharts_default.instance[cid].dobuleZoom(e);
  8637. }
  8638. that[cid].callMethod("emitMsg", { name: "getTouchMove", params: { type: "touchMove", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8639. },
  8640. touchEnd(e) {
  8641. let cid = this.rid;
  8642. let ontouch = config_ucharts_default.option[cid].ontouch;
  8643. if (ontouch == false)
  8644. return;
  8645. if (config_ucharts_default.option[cid].enableScroll === true && e.touches.length == 0) {
  8646. config_ucharts_default.instance[cid].scrollEnd(e);
  8647. }
  8648. that[cid].callMethod("emitMsg", { name: "getTouchEnd", params: { type: "touchEnd", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8649. },
  8650. mouseDown(e) {
  8651. let cid = this.rid;
  8652. let onmouse = config_ucharts_default.option[cid].onmouse;
  8653. if (onmouse == false)
  8654. return;
  8655. let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
  8656. let tmpe = {};
  8657. tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
  8658. e.changedTouches = [];
  8659. e.changedTouches.unshift(tmpe);
  8660. config_ucharts_default.instance[cid].scrollStart(e);
  8661. config_ucharts_default.option[cid].mousedown = true;
  8662. that[cid].callMethod("emitMsg", { name: "getTouchStart", params: { type: "mouseDown", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8663. },
  8664. mouseMove(e) {
  8665. let cid = this.rid;
  8666. let onmouse = config_ucharts_default.option[cid].onmouse;
  8667. let tooltipShow = config_ucharts_default.option[cid].tooltipShow;
  8668. if (onmouse == false)
  8669. return;
  8670. let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
  8671. let tmpe = {};
  8672. tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
  8673. e.changedTouches = [];
  8674. e.changedTouches.unshift(tmpe);
  8675. if (config_ucharts_default.option[cid].mousedown) {
  8676. config_ucharts_default.instance[cid].scroll(e);
  8677. that[cid].callMethod("emitMsg", { name: "getTouchMove", params: { type: "mouseMove", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8678. } else if (config_ucharts_default.instance[cid]) {
  8679. if (tooltipShow == true) {
  8680. this.showTooltip(e, cid);
  8681. }
  8682. }
  8683. },
  8684. mouseUp(e) {
  8685. let cid = this.rid;
  8686. let onmouse = config_ucharts_default.option[cid].onmouse;
  8687. if (onmouse == false)
  8688. return;
  8689. let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
  8690. let tmpe = {};
  8691. tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
  8692. e.changedTouches = [];
  8693. e.changedTouches.unshift(tmpe);
  8694. config_ucharts_default.instance[cid].scrollEnd(e);
  8695. config_ucharts_default.option[cid].mousedown = false;
  8696. that[cid].callMethod("emitMsg", { name: "getTouchEnd", params: { type: "mouseUp", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
  8697. }
  8698. }
  8699. };
  8700. return __toCommonJS(stdin_exports);
  8701. })();