| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707 |
- var __renderjsModules={};
-
- __renderjsModules.f9cb76fc = (() => {
- var __defProp = Object.defineProperty;
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
- var __getOwnPropNames = Object.getOwnPropertyNames;
- var __hasOwnProp = Object.prototype.hasOwnProperty;
- var __export = (target, all) => {
- for (var name in all)
- __defProp(target, name, { get: all[name], enumerable: true });
- };
- var __copyProps = (to, from, except, desc) => {
- if (from && typeof from === "object" || typeof from === "function") {
- for (let key of __getOwnPropNames(from))
- if (!__hasOwnProp.call(to, key) && key !== except)
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
- }
- return to;
- };
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
-
- // <stdin>
- var stdin_exports = {};
- __export(stdin_exports, {
- default: () => stdin_default
- });
-
- // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/u-charts.js
- var config = {
- version: "v2.5.0-20230101",
- yAxisWidth: 15,
- xAxisHeight: 22,
- padding: [10, 10, 10, 10],
- rotate: false,
- fontSize: 13,
- fontColor: "#666666",
- dataPointShape: ["circle", "circle", "circle", "circle"],
- color: ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"],
- linearColor: ["#0EE2F8", "#2BDCA8", "#FA7D8D", "#EB88E2", "#2AE3A0", "#0EE2F8", "#EB88E2", "#6773E3", "#F78A85"],
- pieChartLinePadding: 15,
- pieChartTextPadding: 5,
- titleFontSize: 20,
- subtitleFontSize: 15,
- radarLabelTextMargin: 13
- };
- var assign = function(target, ...varArgs) {
- if (target == null) {
- throw new TypeError("[uCharts] Cannot convert undefined or null to object");
- }
- if (!varArgs || varArgs.length <= 0) {
- return target;
- }
- function deepAssign(obj1, obj2) {
- for (let key in obj2) {
- obj1[key] = obj1[key] && obj1[key].toString() === "[object Object]" ? deepAssign(obj1[key], obj2[key]) : obj1[key] = obj2[key];
- }
- return obj1;
- }
- varArgs.forEach((val) => {
- target = deepAssign(target, val);
- });
- return target;
- };
- var util = {
- toFixed: function toFixed(num, limit) {
- limit = limit || 2;
- if (this.isFloat(num)) {
- num = num.toFixed(limit);
- }
- return num;
- },
- isFloat: function isFloat(num) {
- return num % 1 !== 0;
- },
- approximatelyEqual: function approximatelyEqual(num1, num2) {
- return Math.abs(num1 - num2) < 1e-10;
- },
- isSameSign: function isSameSign(num1, num2) {
- return Math.abs(num1) === num1 && Math.abs(num2) === num2 || Math.abs(num1) !== num1 && Math.abs(num2) !== num2;
- },
- isSameXCoordinateArea: function isSameXCoordinateArea(p1, p2) {
- return this.isSameSign(p1.x, p2.x);
- },
- isCollision: function isCollision(obj1, obj2) {
- obj1.end = {};
- obj1.end.x = obj1.start.x + obj1.width;
- obj1.end.y = obj1.start.y - obj1.height;
- obj2.end = {};
- obj2.end.x = obj2.start.x + obj2.width;
- obj2.end.y = obj2.start.y - obj2.height;
- 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;
- return !flag;
- }
- };
- function hexToRgb(hexValue, opc) {
- var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
- var hex = hexValue.replace(rgx, function(m, r2, g2, b2) {
- return r2 + r2 + g2 + g2 + b2 + b2;
- });
- var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
- var r = parseInt(rgb[1], 16);
- var g = parseInt(rgb[2], 16);
- var b = parseInt(rgb[3], 16);
- return "rgba(" + r + "," + g + "," + b + "," + opc + ")";
- }
- function findRange(num, type, limit) {
- if (isNaN(num)) {
- throw new Error("[uCharts] series\u6570\u636E\u9700\u4E3ANumber\u683C\u5F0F");
- }
- limit = limit || 10;
- type = type ? type : "upper";
- var multiple = 1;
- while (limit < 1) {
- limit *= 10;
- multiple *= 10;
- }
- if (type === "upper") {
- num = Math.ceil(num * multiple);
- } else {
- num = Math.floor(num * multiple);
- }
- while (num % limit !== 0) {
- if (type === "upper") {
- if (num == num + 1) {
- break;
- }
- num++;
- } else {
- num--;
- }
- }
- return num / multiple;
- }
- function calCandleMA(dayArr, nameArr, colorArr, kdata) {
- let seriesTemp = [];
- for (let k = 0; k < dayArr.length; k++) {
- let seriesItem = {
- data: [],
- name: nameArr[k],
- color: colorArr[k]
- };
- for (let i = 0, len = kdata.length; i < len; i++) {
- if (i < dayArr[k]) {
- seriesItem.data.push(null);
- continue;
- }
- let sum = 0;
- for (let j = 0; j < dayArr[k]; j++) {
- sum += kdata[i - j][1];
- }
- seriesItem.data.push(+(sum / dayArr[k]).toFixed(3));
- }
- seriesTemp.push(seriesItem);
- }
- return seriesTemp;
- }
- function calValidDistance(self, distance, chartData, config2, opts) {
- var dataChartAreaWidth = opts.width - opts.area[1] - opts.area[3];
- var dataChartWidth = chartData.eachSpacing * (opts.chartData.xAxisData.xAxisPoints.length - 1);
- if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
- if (opts.extra.mount.widthRatio > 2)
- opts.extra.mount.widthRatio = 2;
- dataChartWidth += (opts.extra.mount.widthRatio - 1) * chartData.eachSpacing;
- }
- var validDistance = distance;
- if (distance >= 0) {
- validDistance = 0;
- self.uevent.trigger("scrollLeft");
- self.scrollOption.position = "left";
- opts.xAxis.scrollPosition = "left";
- } else if (Math.abs(distance) >= dataChartWidth - dataChartAreaWidth) {
- validDistance = dataChartAreaWidth - dataChartWidth;
- self.uevent.trigger("scrollRight");
- self.scrollOption.position = "right";
- opts.xAxis.scrollPosition = "right";
- } else {
- self.scrollOption.position = distance;
- opts.xAxis.scrollPosition = distance;
- }
- return validDistance;
- }
- function isInAngleRange(angle, startAngle, endAngle) {
- function adjust(angle2) {
- while (angle2 < 0) {
- angle2 += 2 * Math.PI;
- }
- while (angle2 > 2 * Math.PI) {
- angle2 -= 2 * Math.PI;
- }
- return angle2;
- }
- angle = adjust(angle);
- startAngle = adjust(startAngle);
- endAngle = adjust(endAngle);
- if (startAngle > endAngle) {
- endAngle += 2 * Math.PI;
- if (angle < startAngle) {
- angle += 2 * Math.PI;
- }
- }
- return angle >= startAngle && angle <= endAngle;
- }
- function createCurveControlPoints(points, i) {
- function isNotMiddlePoint(points2, i2) {
- if (points2[i2 - 1] && points2[i2 + 1]) {
- return points2[i2].y >= Math.max(points2[i2 - 1].y, points2[i2 + 1].y) || points2[i2].y <= Math.min(
- points2[i2 - 1].y,
- points2[i2 + 1].y
- );
- } else {
- return false;
- }
- }
- function isNotMiddlePointX(points2, i2) {
- if (points2[i2 - 1] && points2[i2 + 1]) {
- return points2[i2].x >= Math.max(points2[i2 - 1].x, points2[i2 + 1].x) || points2[i2].x <= Math.min(
- points2[i2 - 1].x,
- points2[i2 + 1].x
- );
- } else {
- return false;
- }
- }
- var a = 0.2;
- var b = 0.2;
- var pAx = null;
- var pAy = null;
- var pBx = null;
- var pBy = null;
- if (i < 1) {
- pAx = points[0].x + (points[1].x - points[0].x) * a;
- pAy = points[0].y + (points[1].y - points[0].y) * a;
- } else {
- pAx = points[i].x + (points[i + 1].x - points[i - 1].x) * a;
- pAy = points[i].y + (points[i + 1].y - points[i - 1].y) * a;
- }
- if (i > points.length - 3) {
- var last = points.length - 1;
- pBx = points[last].x - (points[last].x - points[last - 1].x) * b;
- pBy = points[last].y - (points[last].y - points[last - 1].y) * b;
- } else {
- pBx = points[i + 1].x - (points[i + 2].x - points[i].x) * b;
- pBy = points[i + 1].y - (points[i + 2].y - points[i].y) * b;
- }
- if (isNotMiddlePoint(points, i + 1)) {
- pBy = points[i + 1].y;
- }
- if (isNotMiddlePoint(points, i)) {
- pAy = points[i].y;
- }
- if (isNotMiddlePointX(points, i + 1)) {
- pBx = points[i + 1].x;
- }
- if (isNotMiddlePointX(points, i)) {
- pAx = points[i].x;
- }
- if (pAy >= Math.max(points[i].y, points[i + 1].y) || pAy <= Math.min(points[i].y, points[i + 1].y)) {
- pAy = points[i].y;
- }
- if (pBy >= Math.max(points[i].y, points[i + 1].y) || pBy <= Math.min(points[i].y, points[i + 1].y)) {
- pBy = points[i + 1].y;
- }
- if (pAx >= Math.max(points[i].x, points[i + 1].x) || pAx <= Math.min(points[i].x, points[i + 1].x)) {
- pAx = points[i].x;
- }
- if (pBx >= Math.max(points[i].x, points[i + 1].x) || pBx <= Math.min(points[i].x, points[i + 1].x)) {
- pBx = points[i + 1].x;
- }
- return {
- ctrA: {
- x: pAx,
- y: pAy
- },
- ctrB: {
- x: pBx,
- y: pBy
- }
- };
- }
- function convertCoordinateOrigin(x, y, center) {
- return {
- x: center.x + x,
- y: center.y - y
- };
- }
- function avoidCollision(obj, target) {
- if (target) {
- while (util.isCollision(obj, target)) {
- if (obj.start.x > 0) {
- obj.start.y--;
- } else if (obj.start.x < 0) {
- obj.start.y++;
- } else {
- if (obj.start.y > 0) {
- obj.start.y++;
- } else {
- obj.start.y--;
- }
- }
- }
- }
- return obj;
- }
- function fixPieSeries(series, opts, config2) {
- let pieSeriesArr = [];
- if (series.length > 0 && series[0].data.constructor.toString().indexOf("Array") > -1) {
- opts._pieSeries_ = series;
- let oldseries = series[0].data;
- for (var i = 0; i < oldseries.length; i++) {
- oldseries[i].formatter = series[0].formatter;
- oldseries[i].data = oldseries[i].value;
- pieSeriesArr.push(oldseries[i]);
- }
- opts.series = pieSeriesArr;
- } else {
- pieSeriesArr = series;
- }
- return pieSeriesArr;
- }
- function fillSeries(series, opts, config2) {
- var index = 0;
- for (var i = 0; i < series.length; i++) {
- let item = series[i];
- if (!item.color) {
- item.color = config2.color[index];
- index = (index + 1) % config2.color.length;
- }
- if (!item.linearIndex) {
- item.linearIndex = i;
- }
- if (!item.index) {
- item.index = 0;
- }
- if (!item.type) {
- item.type = opts.type;
- }
- if (typeof item.show == "undefined") {
- item.show = true;
- }
- if (!item.type) {
- item.type = opts.type;
- }
- if (!item.pointShape) {
- item.pointShape = "circle";
- }
- if (!item.legendShape) {
- switch (item.type) {
- case "line":
- item.legendShape = "line";
- break;
- case "column":
- case "bar":
- item.legendShape = "rect";
- break;
- case "area":
- case "mount":
- item.legendShape = "triangle";
- break;
- default:
- item.legendShape = "circle";
- }
- }
- }
- return series;
- }
- function fillCustomColor(linearType, customColor, series, config2) {
- var newcolor = customColor || [];
- if (linearType == "custom" && newcolor.length == 0) {
- newcolor = config2.linearColor;
- }
- if (linearType == "custom" && newcolor.length < series.length) {
- let chazhi = series.length - newcolor.length;
- for (var i = 0; i < chazhi; i++) {
- newcolor.push(config2.linearColor[(i + 1) % config2.linearColor.length]);
- }
- }
- return newcolor;
- }
- function getDataRange(minData, maxData) {
- var limit = 0;
- var range = maxData - minData;
- if (range >= 1e4) {
- limit = 1e3;
- } else if (range >= 1e3) {
- limit = 100;
- } else if (range >= 100) {
- limit = 10;
- } else if (range >= 10) {
- limit = 5;
- } else if (range >= 1) {
- limit = 1;
- } else if (range >= 0.1) {
- limit = 0.1;
- } else if (range >= 0.01) {
- limit = 0.01;
- } else if (range >= 1e-3) {
- limit = 1e-3;
- } else if (range >= 1e-4) {
- limit = 1e-4;
- } else if (range >= 1e-5) {
- limit = 1e-5;
- } else {
- limit = 1e-6;
- }
- return {
- minRange: findRange(minData, "lower", limit),
- maxRange: findRange(maxData, "upper", limit)
- };
- }
- function measureText(text, fontSize, context) {
- var width = 0;
- text = String(text);
- context = false;
- if (context !== false && context !== void 0 && context.setFontSize && context.measureText) {
- context.setFontSize(fontSize);
- return context.measureText(text).width;
- } else {
- var text = text.split("");
- for (let i = 0; i < text.length; i++) {
- let item = text[i];
- if (/[a-zA-Z]/.test(item)) {
- width += 7;
- } else if (/[0-9]/.test(item)) {
- width += 5.5;
- } else if (/\./.test(item)) {
- width += 2.7;
- } else if (/-/.test(item)) {
- width += 3.25;
- } else if (/:/.test(item)) {
- width += 2.5;
- } else if (/[\u4e00-\u9fa5]/.test(item)) {
- width += 10;
- } else if (/\(|\)/.test(item)) {
- width += 3.73;
- } else if (/\s/.test(item)) {
- width += 2.5;
- } else if (/%/.test(item)) {
- width += 8;
- } else {
- width += 10;
- }
- }
- return width * fontSize / 10;
- }
- }
- function dataCombine(series) {
- return series.reduce(function(a, b) {
- return (a.data ? a.data : a).concat(b.data);
- }, []);
- }
- function dataCombineStack(series, len) {
- var sum = new Array(len);
- for (var j = 0; j < sum.length; j++) {
- sum[j] = 0;
- }
- for (var i = 0; i < series.length; i++) {
- for (var j = 0; j < sum.length; j++) {
- sum[j] += series[i].data[j];
- }
- }
- return series.reduce(function(a, b) {
- return (a.data ? a.data : a).concat(b.data).concat(sum);
- }, []);
- }
- function getTouches(touches, opts, e) {
- let x, y;
- if (touches.clientX) {
- if (opts.rotate) {
- y = opts.height - touches.clientX * opts.pix;
- x = (touches.pageY - e.currentTarget.offsetTop - opts.height / opts.pix / 2 * (opts.pix - 1)) * opts.pix;
- } else {
- x = touches.clientX * opts.pix;
- y = (touches.pageY - e.currentTarget.offsetTop - opts.height / opts.pix / 2 * (opts.pix - 1)) * opts.pix;
- }
- } else {
- if (opts.rotate) {
- y = opts.height - touches.x * opts.pix;
- x = touches.y * opts.pix;
- } else {
- x = touches.x * opts.pix;
- y = touches.y * opts.pix;
- }
- }
- return {
- x,
- y
- };
- }
- function getSeriesDataItem(series, index, group) {
- var data = [];
- var newSeries = [];
- var indexIsArr = index.constructor.toString().indexOf("Array") > -1;
- if (indexIsArr) {
- let tempSeries = filterSeries(series);
- for (var i = 0; i < group.length; i++) {
- newSeries.push(tempSeries[group[i]]);
- }
- } else {
- newSeries = series;
- }
- ;
- for (let i2 = 0; i2 < newSeries.length; i2++) {
- let item = newSeries[i2];
- let tmpindex = -1;
- if (indexIsArr) {
- tmpindex = index[i2];
- } else {
- tmpindex = index;
- }
- if (item.data[tmpindex] !== null && typeof item.data[tmpindex] !== "undefined" && item.show) {
- let seriesItem = {};
- seriesItem.color = item.color;
- seriesItem.type = item.type;
- seriesItem.style = item.style;
- seriesItem.pointShape = item.pointShape;
- seriesItem.disableLegend = item.disableLegend;
- seriesItem.legendShape = item.legendShape;
- seriesItem.name = item.name;
- seriesItem.show = item.show;
- seriesItem.data = item.formatter ? item.formatter(item.data[tmpindex]) : item.data[tmpindex];
- data.push(seriesItem);
- }
- }
- return data;
- }
- function getMaxTextListLength(list, fontSize, context) {
- var lengthList = list.map(function(item) {
- return measureText(item, fontSize, context);
- });
- return Math.max.apply(null, lengthList);
- }
- function getRadarCoordinateSeries(length) {
- var eachAngle = 2 * Math.PI / length;
- var CoordinateSeries = [];
- for (var i = 0; i < length; i++) {
- CoordinateSeries.push(eachAngle * i);
- }
- return CoordinateSeries.map(function(item) {
- return -1 * item + Math.PI / 2;
- });
- }
- function getToolTipData(seriesData, opts, index, group, categories) {
- var option = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : {};
- var calPoints = opts.chartData.calPoints ? opts.chartData.calPoints : [];
- let points = {};
- if (group.length > 0) {
- let filterPoints = [];
- for (let i = 0; i < group.length; i++) {
- filterPoints.push(calPoints[group[i]]);
- }
- points = filterPoints[0][index[0]];
- } else {
- for (let i = 0; i < calPoints.length; i++) {
- if (calPoints[i][index]) {
- points = calPoints[i][index];
- break;
- }
- }
- }
- ;
- var textList = seriesData.map(function(item) {
- let titleText = null;
- if (opts.categories && opts.categories.length > 0) {
- titleText = categories[index];
- }
- ;
- return {
- text: option.formatter ? option.formatter(item, titleText, index, opts) : item.name + ": " + item.data,
- color: item.color,
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- });
- var offset = {
- x: Math.round(points.x),
- y: Math.round(points.y)
- };
- return {
- textList,
- offset
- };
- }
- function getMixToolTipData(seriesData, opts, index, categories) {
- var option = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : {};
- var points = opts.chartData.xAxisPoints[index] + opts.chartData.eachSpacing / 2;
- var textList = seriesData.map(function(item) {
- return {
- text: option.formatter ? option.formatter(item, categories[index], index, opts) : item.name + ": " + item.data,
- color: item.color,
- disableLegend: item.disableLegend ? true : false,
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- });
- textList = textList.filter(function(item) {
- if (item.disableLegend !== true) {
- return item;
- }
- });
- var offset = {
- x: Math.round(points),
- y: 0
- };
- return {
- textList,
- offset
- };
- }
- function getCandleToolTipData(series, seriesData, opts, index, categories, extra) {
- var option = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : {};
- var calPoints = opts.chartData.calPoints;
- let upColor = extra.color.upFill;
- let downColor = extra.color.downFill;
- let color3 = [upColor, upColor, downColor, upColor];
- var textList = [];
- seriesData.map(function(item) {
- if (index == 0) {
- if (item.data[1] - item.data[0] < 0) {
- color3[1] = downColor;
- } else {
- color3[1] = upColor;
- }
- } else {
- if (item.data[0] < series[index - 1][1]) {
- color3[0] = downColor;
- }
- if (item.data[1] < item.data[0]) {
- color3[1] = downColor;
- }
- if (item.data[2] > series[index - 1][1]) {
- color3[2] = upColor;
- }
- if (item.data[3] < series[index - 1][1]) {
- color3[3] = downColor;
- }
- }
- let text1 = {
- text: "\u5F00\u76D8\uFF1A" + item.data[0],
- color: color3[0],
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- let text2 = {
- text: "\u6536\u76D8\uFF1A" + item.data[1],
- color: color3[1],
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- let text3 = {
- text: "\u6700\u4F4E\uFF1A" + item.data[2],
- color: color3[2],
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- let text4 = {
- text: "\u6700\u9AD8\uFF1A" + item.data[3],
- color: color3[3],
- legendShape: opts.extra.tooltip.legendShape == "auto" ? item.legendShape : opts.extra.tooltip.legendShape
- };
- textList.push(text1, text2, text3, text4);
- });
- var validCalPoints = [];
- var offset = {
- x: 0,
- y: 0
- };
- for (let i = 0; i < calPoints.length; i++) {
- let points = calPoints[i];
- if (typeof points[index] !== "undefined" && points[index] !== null) {
- validCalPoints.push(points[index]);
- }
- }
- offset.x = Math.round(validCalPoints[0][0].x);
- return {
- textList,
- offset
- };
- }
- function filterSeries(series) {
- let tempSeries = [];
- for (let i = 0; i < series.length; i++) {
- if (series[i].show == true) {
- tempSeries.push(series[i]);
- }
- }
- return tempSeries;
- }
- function findCurrentIndex(currentPoints, calPoints, opts, config2) {
- var offset = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0;
- var current = { index: -1, group: [] };
- var spacing = opts.chartData.eachSpacing / 2;
- let xAxisPoints = [];
- if (calPoints && calPoints.length > 0) {
- if (!opts.categories) {
- spacing = 0;
- } else {
- for (let i = 1; i < opts.chartData.xAxisPoints.length; i++) {
- xAxisPoints.push(opts.chartData.xAxisPoints[i] - spacing);
- }
- if ((opts.type == "line" || opts.type == "area") && opts.xAxis.boundaryGap == "justify") {
- xAxisPoints = opts.chartData.xAxisPoints;
- }
- }
- if (isInExactChartArea(currentPoints, opts, config2)) {
- if (!opts.categories) {
- let timePoints = Array(calPoints.length);
- for (let i = 0; i < calPoints.length; i++) {
- timePoints[i] = Array(calPoints[i].length);
- for (let j = 0; j < calPoints[i].length; j++) {
- timePoints[i][j] = Math.abs(calPoints[i][j].x - currentPoints.x);
- }
- }
- ;
- let pointValue = Array(timePoints.length);
- let pointIndex = Array(timePoints.length);
- for (let i = 0; i < timePoints.length; i++) {
- pointValue[i] = Math.min.apply(null, timePoints[i]);
- pointIndex[i] = timePoints[i].indexOf(pointValue[i]);
- }
- let minValue = Math.min.apply(null, pointValue);
- current.index = [];
- for (let i = 0; i < pointValue.length; i++) {
- if (pointValue[i] == minValue) {
- current.group.push(i);
- current.index.push(pointIndex[i]);
- }
- }
- ;
- } else {
- xAxisPoints.forEach(function(item, index) {
- if (currentPoints.x + offset + spacing > item) {
- current.index = index;
- }
- });
- }
- }
- }
- return current;
- }
- function findBarChartCurrentIndex(currentPoints, calPoints, opts, config2) {
- var offset = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0;
- var current = { index: -1, group: [] };
- var spacing = opts.chartData.eachSpacing / 2;
- let yAxisPoints = opts.chartData.yAxisPoints;
- if (calPoints && calPoints.length > 0) {
- if (isInExactChartArea(currentPoints, opts, config2)) {
- yAxisPoints.forEach(function(item, index) {
- if (currentPoints.y + offset + spacing > item) {
- current.index = index;
- }
- });
- }
- }
- return current;
- }
- function findLegendIndex(currentPoints, legendData, opts) {
- let currentIndex = -1;
- let gap = 0;
- if (isInExactLegendArea(currentPoints, legendData.area)) {
- let points = legendData.points;
- let index = -1;
- for (let i = 0, len = points.length; i < len; i++) {
- let item = points[i];
- for (let j = 0; j < item.length; j++) {
- index += 1;
- let area = item[j]["area"];
- if (area && currentPoints.x > area[0] - gap && currentPoints.x < area[2] + gap && currentPoints.y > area[1] - gap && currentPoints.y < area[3] + gap) {
- currentIndex = index;
- break;
- }
- }
- }
- return currentIndex;
- }
- return currentIndex;
- }
- function isInExactLegendArea(currentPoints, area) {
- return currentPoints.x > area.start.x && currentPoints.x < area.end.x && currentPoints.y > area.start.y && currentPoints.y < area.end.y;
- }
- function isInExactChartArea(currentPoints, opts, config2) {
- 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];
- }
- function findRadarChartCurrentIndex(currentPoints, radarData, count) {
- var eachAngleArea = 2 * Math.PI / count;
- var currentIndex = -1;
- if (isInExactPieChartArea(currentPoints, radarData.center, radarData.radius)) {
- var fixAngle = function fixAngle2(angle2) {
- if (angle2 < 0) {
- angle2 += 2 * Math.PI;
- }
- if (angle2 > 2 * Math.PI) {
- angle2 -= 2 * Math.PI;
- }
- return angle2;
- };
- var angle = Math.atan2(radarData.center.y - currentPoints.y, currentPoints.x - radarData.center.x);
- angle = -1 * angle;
- if (angle < 0) {
- angle += 2 * Math.PI;
- }
- var angleList = radarData.angleList.map(function(item) {
- item = fixAngle(-1 * item);
- return item;
- });
- angleList.forEach(function(item, index) {
- var rangeStart = fixAngle(item - eachAngleArea / 2);
- var rangeEnd = fixAngle(item + eachAngleArea / 2);
- if (rangeEnd < rangeStart) {
- rangeEnd += 2 * Math.PI;
- }
- if (angle >= rangeStart && angle <= rangeEnd || angle + 2 * Math.PI >= rangeStart && angle + 2 * Math.PI <= rangeEnd) {
- currentIndex = index;
- }
- });
- }
- return currentIndex;
- }
- function findFunnelChartCurrentIndex(currentPoints, funnelData) {
- var currentIndex = -1;
- for (var i = 0, len = funnelData.series.length; i < len; i++) {
- var item = funnelData.series[i];
- if (currentPoints.x > item.funnelArea[0] && currentPoints.x < item.funnelArea[2] && currentPoints.y > item.funnelArea[1] && currentPoints.y < item.funnelArea[3]) {
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
- }
- function findWordChartCurrentIndex(currentPoints, wordData) {
- var currentIndex = -1;
- for (var i = 0, len = wordData.length; i < len; i++) {
- var item = wordData[i];
- if (currentPoints.x > item.area[0] && currentPoints.x < item.area[2] && currentPoints.y > item.area[1] && currentPoints.y < item.area[3]) {
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
- }
- function findMapChartCurrentIndex(currentPoints, opts) {
- var currentIndex = -1;
- var cData = opts.chartData.mapData;
- var data = opts.series;
- var tmp = pointToCoordinate(currentPoints.y, currentPoints.x, cData.bounds, cData.scale, cData.xoffset, cData.yoffset);
- var poi = [tmp.x, tmp.y];
- for (var i = 0, len = data.length; i < len; i++) {
- var item = data[i].geometry.coordinates;
- if (isPoiWithinPoly(poi, item, opts.chartData.mapData.mercator)) {
- currentIndex = i;
- break;
- }
- }
- return currentIndex;
- }
- function findRoseChartCurrentIndex(currentPoints, pieData, opts) {
- var currentIndex = -1;
- var series = getRoseDataPoints(opts._series_, opts.extra.rose.type, pieData.radius, pieData.radius);
- if (pieData && pieData.center && isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) {
- var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x);
- angle = -angle;
- if (opts.extra.rose && opts.extra.rose.offsetAngle) {
- angle = angle - opts.extra.rose.offsetAngle * Math.PI / 180;
- }
- for (var i = 0, len = series.length; i < len; i++) {
- if (isInAngleRange(angle, series[i]._start_, series[i]._start_ + series[i]._rose_proportion_ * 2 * Math.PI)) {
- currentIndex = i;
- break;
- }
- }
- }
- return currentIndex;
- }
- function findPieChartCurrentIndex(currentPoints, pieData, opts) {
- var currentIndex = -1;
- var series = getPieDataPoints(pieData.series);
- if (pieData && pieData.center && isInExactPieChartArea(currentPoints, pieData.center, pieData.radius)) {
- var angle = Math.atan2(pieData.center.y - currentPoints.y, currentPoints.x - pieData.center.x);
- angle = -angle;
- if (opts.extra.pie && opts.extra.pie.offsetAngle) {
- angle = angle - opts.extra.pie.offsetAngle * Math.PI / 180;
- }
- if (opts.extra.ring && opts.extra.ring.offsetAngle) {
- angle = angle - opts.extra.ring.offsetAngle * Math.PI / 180;
- }
- for (var i = 0, len = series.length; i < len; i++) {
- if (isInAngleRange(angle, series[i]._start_, series[i]._start_ + series[i]._proportion_ * 2 * Math.PI)) {
- currentIndex = i;
- break;
- }
- }
- }
- return currentIndex;
- }
- function isInExactPieChartArea(currentPoints, center, radius) {
- return Math.pow(currentPoints.x - center.x, 2) + Math.pow(currentPoints.y - center.y, 2) <= Math.pow(radius, 2);
- }
- function splitPoints(points, eachSeries) {
- var newPoints = [];
- var items = [];
- points.forEach(function(item, index) {
- if (eachSeries.connectNulls) {
- if (item !== null) {
- items.push(item);
- }
- } else {
- if (item !== null) {
- items.push(item);
- } else {
- if (items.length) {
- newPoints.push(items);
- }
- items = [];
- }
- }
- });
- if (items.length) {
- newPoints.push(items);
- }
- return newPoints;
- }
- function calLegendData(series, opts, config2, chartData, context) {
- let legendData = {
- area: {
- start: {
- x: 0,
- y: 0
- },
- end: {
- x: 0,
- y: 0
- },
- width: 0,
- height: 0,
- wholeWidth: 0,
- wholeHeight: 0
- },
- points: [],
- widthArr: [],
- heightArr: []
- };
- if (opts.legend.show === false) {
- chartData.legendData = legendData;
- return legendData;
- }
- let padding = opts.legend.padding * opts.pix;
- let margin = opts.legend.margin * opts.pix;
- let fontSize = opts.legend.fontSize ? opts.legend.fontSize * opts.pix : config2.fontSize;
- let shapeWidth = 15 * opts.pix;
- let shapeRight = 5 * opts.pix;
- let lineHeight = Math.max(opts.legend.lineHeight * opts.pix, fontSize);
- if (opts.legend.position == "top" || opts.legend.position == "bottom") {
- let legendList = [];
- let widthCount = 0;
- let widthCountArr = [];
- let currentRow = [];
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- const legendText = item.legendText ? item.legendText : item.name;
- let itemWidth = shapeWidth + shapeRight + measureText(legendText || "undefined", fontSize, context) + opts.legend.itemGap * opts.pix;
- if (widthCount + itemWidth > opts.width - opts.area[1] - opts.area[3]) {
- legendList.push(currentRow);
- widthCountArr.push(widthCount - opts.legend.itemGap * opts.pix);
- widthCount = itemWidth;
- currentRow = [item];
- } else {
- widthCount += itemWidth;
- currentRow.push(item);
- }
- }
- if (currentRow.length) {
- legendList.push(currentRow);
- widthCountArr.push(widthCount - opts.legend.itemGap * opts.pix);
- legendData.widthArr = widthCountArr;
- let legendWidth = Math.max.apply(null, widthCountArr);
- switch (opts.legend.float) {
- case "left":
- legendData.area.start.x = opts.area[3];
- legendData.area.end.x = opts.area[3] + legendWidth + 2 * padding;
- break;
- case "right":
- legendData.area.start.x = opts.width - opts.area[1] - legendWidth - 2 * padding;
- legendData.area.end.x = opts.width - opts.area[1];
- break;
- default:
- legendData.area.start.x = (opts.width - legendWidth) / 2 - padding;
- legendData.area.end.x = (opts.width + legendWidth) / 2 + padding;
- }
- legendData.area.width = legendWidth + 2 * padding;
- legendData.area.wholeWidth = legendWidth + 2 * padding;
- legendData.area.height = legendList.length * lineHeight + 2 * padding;
- legendData.area.wholeHeight = legendList.length * lineHeight + 2 * padding + 2 * margin;
- legendData.points = legendList;
- }
- } else {
- let len = series.length;
- let maxHeight = opts.height - opts.area[0] - opts.area[2] - 2 * margin - 2 * padding;
- let maxLength = Math.min(Math.floor(maxHeight / lineHeight), len);
- legendData.area.height = maxLength * lineHeight + padding * 2;
- legendData.area.wholeHeight = maxLength * lineHeight + padding * 2;
- switch (opts.legend.float) {
- case "top":
- legendData.area.start.y = opts.area[0] + margin;
- legendData.area.end.y = opts.area[0] + margin + legendData.area.height;
- break;
- case "bottom":
- legendData.area.start.y = opts.height - opts.area[2] - margin - legendData.area.height;
- legendData.area.end.y = opts.height - opts.area[2] - margin;
- break;
- default:
- legendData.area.start.y = (opts.height - legendData.area.height) / 2;
- legendData.area.end.y = (opts.height + legendData.area.height) / 2;
- }
- let lineNum = len % maxLength === 0 ? len / maxLength : Math.floor(len / maxLength + 1);
- let currentRow = [];
- for (let i = 0; i < lineNum; i++) {
- let temp = series.slice(i * maxLength, i * maxLength + maxLength);
- currentRow.push(temp);
- }
- legendData.points = currentRow;
- if (currentRow.length) {
- for (let i = 0; i < currentRow.length; i++) {
- let item = currentRow[i];
- let maxWidth = 0;
- for (let j = 0; j < item.length; j++) {
- let itemWidth = shapeWidth + shapeRight + measureText(item[j].name || "undefined", fontSize, context) + opts.legend.itemGap * opts.pix;
- if (itemWidth > maxWidth) {
- maxWidth = itemWidth;
- }
- }
- legendData.widthArr.push(maxWidth);
- legendData.heightArr.push(item.length * lineHeight + padding * 2);
- }
- let legendWidth = 0;
- for (let i = 0; i < legendData.widthArr.length; i++) {
- legendWidth += legendData.widthArr[i];
- }
- legendData.area.width = legendWidth - opts.legend.itemGap * opts.pix + 2 * padding;
- legendData.area.wholeWidth = legendData.area.width + padding;
- }
- }
- switch (opts.legend.position) {
- case "top":
- legendData.area.start.y = opts.area[0] + margin;
- legendData.area.end.y = opts.area[0] + margin + legendData.area.height;
- break;
- case "bottom":
- legendData.area.start.y = opts.height - opts.area[2] - legendData.area.height - margin;
- legendData.area.end.y = opts.height - opts.area[2] - margin;
- break;
- case "left":
- legendData.area.start.x = opts.area[3];
- legendData.area.end.x = opts.area[3] + legendData.area.width;
- break;
- case "right":
- legendData.area.start.x = opts.width - opts.area[1] - legendData.area.width;
- legendData.area.end.x = opts.width - opts.area[1];
- break;
- }
- chartData.legendData = legendData;
- return legendData;
- }
- function calCategoriesData(categories, opts, config2, eachSpacing, context) {
- var result = {
- angle: 0,
- xAxisHeight: opts.xAxis.lineHeight * opts.pix + opts.xAxis.marginTop * opts.pix
- };
- var fontSize = opts.xAxis.fontSize * opts.pix;
- var categoriesTextLenth = categories.map(function(item, index) {
- var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item, index, opts) : item;
- return measureText(String(xitem), fontSize, context);
- });
- var maxTextLength = Math.max.apply(this, categoriesTextLenth);
- if (opts.xAxis.rotateLabel == true) {
- result.angle = opts.xAxis.rotateAngle * Math.PI / 180;
- let tempHeight = opts.xAxis.marginTop * opts.pix * 2 + Math.abs(maxTextLength * Math.sin(result.angle));
- tempHeight = tempHeight < fontSize + opts.xAxis.marginTop * opts.pix * 2 ? tempHeight + opts.xAxis.marginTop * opts.pix * 2 : tempHeight;
- result.xAxisHeight = tempHeight;
- }
- if (opts.enableScroll && opts.xAxis.scrollShow) {
- result.xAxisHeight += 6 * opts.pix;
- }
- if (opts.xAxis.disabled) {
- result.xAxisHeight = 0;
- }
- return result;
- }
- function getXAxisTextList(series, opts, config2, stack) {
- var index = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : -1;
- var data;
- if (stack == "stack") {
- data = dataCombineStack(series, opts.categories.length);
- } else {
- data = dataCombine(series);
- }
- var sorted = [];
- data = data.filter(function(item) {
- if (typeof item === "object" && item !== null) {
- if (item.constructor.toString().indexOf("Array") > -1) {
- return item !== null;
- } else {
- return item.value !== null;
- }
- } else {
- return item !== null;
- }
- });
- data.map(function(item) {
- if (typeof item === "object") {
- if (item.constructor.toString().indexOf("Array") > -1) {
- if (opts.type == "candle") {
- item.map(function(subitem) {
- sorted.push(subitem);
- });
- } else {
- sorted.push(item[0]);
- }
- } else {
- sorted.push(item.value);
- }
- } else {
- sorted.push(item);
- }
- });
- var minData = 0;
- var maxData = 0;
- if (sorted.length > 0) {
- minData = Math.min.apply(this, sorted);
- maxData = Math.max.apply(this, sorted);
- }
- if (index > -1) {
- if (typeof opts.xAxis.data[index].min === "number") {
- minData = Math.min(opts.xAxis.data[index].min, minData);
- }
- if (typeof opts.xAxis.data[index].max === "number") {
- maxData = Math.max(opts.xAxis.data[index].max, maxData);
- }
- } else {
- if (typeof opts.xAxis.min === "number") {
- minData = Math.min(opts.xAxis.min, minData);
- }
- if (typeof opts.xAxis.max === "number") {
- maxData = Math.max(opts.xAxis.max, maxData);
- }
- }
- if (minData === maxData) {
- var rangeSpan = maxData || 10;
- maxData += rangeSpan;
- }
- var minRange = minData;
- var maxRange = maxData;
- var range = [];
- var eachRange = (maxRange - minRange) / opts.xAxis.splitNumber;
- for (var i = 0; i <= opts.xAxis.splitNumber; i++) {
- range.push(minRange + eachRange * i);
- }
- return range;
- }
- function calXAxisData(series, opts, config2, context) {
- var columnstyle = assign({}, {
- type: ""
- }, opts.extra.bar);
- var result = {
- angle: 0,
- xAxisHeight: opts.xAxis.lineHeight * opts.pix + opts.xAxis.marginTop * opts.pix
- };
- result.ranges = getXAxisTextList(series, opts, config2, columnstyle.type);
- result.rangesFormat = result.ranges.map(function(item) {
- item = util.toFixed(item, 2);
- return item;
- });
- var xAxisScaleValues = result.ranges.map(function(item) {
- item = util.toFixed(item, 2);
- return item;
- });
- result = Object.assign(result, getXAxisPoints(xAxisScaleValues, opts, config2));
- var eachSpacing = result.eachSpacing;
- var textLength = xAxisScaleValues.map(function(item) {
- return measureText(item, opts.xAxis.fontSize * opts.pix, context);
- });
- if (opts.xAxis.disabled === true) {
- result.xAxisHeight = 0;
- }
- return result;
- }
- function getRadarDataPoints(angleList, center, radius, series, opts) {
- var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
- var radarOption = opts.extra.radar || {};
- radarOption.max = radarOption.max || 0;
- var maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series)));
- var data = [];
- for (let i = 0; i < series.length; i++) {
- let each = series[i];
- let listItem = {};
- listItem.color = each.color;
- listItem.legendShape = each.legendShape;
- listItem.pointShape = each.pointShape;
- listItem.data = [];
- each.data.forEach(function(item, index) {
- let tmp = {};
- tmp.angle = angleList[index];
- tmp.proportion = item / maxData;
- tmp.value = item;
- tmp.position = convertCoordinateOrigin(radius * tmp.proportion * process * Math.cos(tmp.angle), radius * tmp.proportion * process * Math.sin(tmp.angle), center);
- listItem.data.push(tmp);
- });
- data.push(listItem);
- }
- return data;
- }
- function getPieDataPoints(series, radius) {
- var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
- var count = 0;
- var _start_ = 0;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- count += item.data;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (count === 0) {
- item._proportion_ = 1 / series.length * process;
- } else {
- item._proportion_ = item.data / count * process;
- }
- item._radius_ = radius;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item._start_ = _start_;
- _start_ += 2 * item._proportion_ * Math.PI;
- }
- return series;
- }
- function getFunnelDataPoints(series, radius, option, eachSpacing) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- for (let i = 0; i < series.length; i++) {
- if (option.type == "funnel") {
- series[i].radius = series[i].data / series[0].data * radius * process;
- } else {
- series[i].radius = eachSpacing * (series.length - i) / (eachSpacing * series.length) * radius * process;
- }
- series[i]._proportion_ = series[i].data / series[0].data;
- }
- return series;
- }
- function getRoseDataPoints(series, type, minRadius, radius) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var count = 0;
- var _start_ = 0;
- var dataArr = [];
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- count += item.data;
- dataArr.push(item.data);
- }
- var minData = Math.min.apply(null, dataArr);
- var maxData = Math.max.apply(null, dataArr);
- var radiusLength = radius - minRadius;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (count === 0) {
- item._proportion_ = 1 / series.length * process;
- item._rose_proportion_ = 1 / series.length * process;
- } else {
- item._proportion_ = item.data / count * process;
- if (type == "area") {
- item._rose_proportion_ = 1 / series.length * process;
- } else {
- item._rose_proportion_ = item.data / count * process;
- }
- }
- item._radius_ = minRadius + radiusLength * ((item.data - minData) / (maxData - minData)) || radius;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item._start_ = _start_;
- _start_ += 2 * item._rose_proportion_ * Math.PI;
- }
- return series;
- }
- function getArcbarDataPoints(series, arcbarOption) {
- var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
- if (process == 1) {
- process = 0.999999;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- let totalAngle;
- if (arcbarOption.type == "circle") {
- totalAngle = 2;
- } else {
- if (arcbarOption.direction == "ccw") {
- if (arcbarOption.startAngle < arcbarOption.endAngle) {
- totalAngle = 2 + arcbarOption.startAngle - arcbarOption.endAngle;
- } else {
- totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
- }
- } else {
- if (arcbarOption.endAngle < arcbarOption.startAngle) {
- totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
- } else {
- totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
- }
- }
- }
- item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle;
- if (arcbarOption.direction == "ccw") {
- item._proportion_ = arcbarOption.startAngle - totalAngle * item.data * process;
- }
- if (item._proportion_ >= 2) {
- item._proportion_ = item._proportion_ % 2;
- }
- }
- return series;
- }
- function getGaugeArcbarDataPoints(series, arcbarOption) {
- var process = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 1;
- if (process == 1) {
- process = 0.999999;
- }
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- let totalAngle;
- if (arcbarOption.type == "circle") {
- totalAngle = 2;
- } else {
- if (arcbarOption.endAngle < arcbarOption.startAngle) {
- totalAngle = 2 + arcbarOption.endAngle - arcbarOption.startAngle;
- } else {
- totalAngle = arcbarOption.startAngle - arcbarOption.endAngle;
- }
- }
- item._proportion_ = totalAngle * item.data * process + arcbarOption.startAngle;
- if (item._proportion_ >= 2) {
- item._proportion_ = item._proportion_ % 2;
- }
- }
- return series;
- }
- function getGaugeAxisPoints(categories, startAngle, endAngle) {
- let totalAngle;
- if (endAngle < startAngle) {
- totalAngle = 2 + endAngle - startAngle;
- } else {
- totalAngle = startAngle - endAngle;
- }
- let tempStartAngle = startAngle;
- for (let i = 0; i < categories.length; i++) {
- categories[i].value = categories[i].value === null ? 0 : categories[i].value;
- categories[i]._startAngle_ = tempStartAngle;
- categories[i]._endAngle_ = totalAngle * categories[i].value + startAngle;
- if (categories[i]._endAngle_ >= 2) {
- categories[i]._endAngle_ = categories[i]._endAngle_ % 2;
- }
- tempStartAngle = categories[i]._endAngle_;
- }
- return categories;
- }
- function getGaugeDataPoints(series, categories, gaugeOption) {
- let process = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : 1;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- item.data = item.data === null ? 0 : item.data;
- if (gaugeOption.pointer.color == "auto") {
- for (let i2 = 0; i2 < categories.length; i2++) {
- if (item.data <= categories[i2].value) {
- item.color = categories[i2].color;
- break;
- }
- }
- } else {
- item.color = gaugeOption.pointer.color;
- }
- let totalAngle;
- if (gaugeOption.endAngle < gaugeOption.startAngle) {
- totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
- } else {
- totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
- }
- item._endAngle_ = totalAngle * item.data + gaugeOption.startAngle;
- item._oldAngle_ = gaugeOption.oldAngle;
- if (gaugeOption.oldAngle < gaugeOption.endAngle) {
- item._oldAngle_ += 2;
- }
- if (item.data >= gaugeOption.oldData) {
- item._proportion_ = (item._endAngle_ - item._oldAngle_) * process + gaugeOption.oldAngle;
- } else {
- item._proportion_ = item._oldAngle_ - (item._oldAngle_ - item._endAngle_) * process;
- }
- if (item._proportion_ >= 2) {
- item._proportion_ = item._proportion_ % 2;
- }
- }
- return series;
- }
- function getPieTextMaxLength(series, config2, context, opts) {
- series = getPieDataPoints(series);
- let maxLength = 0;
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- let text = item.formatter ? item.formatter(+item._proportion_.toFixed(2)) : util.toFixed(item._proportion_ * 100) + "%";
- maxLength = Math.max(maxLength, measureText(text, item.textSize * opts.pix || config2.fontSize, context));
- }
- return maxLength;
- }
- function fixColumeData(points, eachSpacing, columnLen, index, config2, opts) {
- return points.map(function(item) {
- if (item === null) {
- return null;
- }
- var seriesGap = 0;
- var categoryGap = 0;
- if (opts.type == "mix") {
- seriesGap = opts.extra.mix.column.seriesGap * opts.pix || 0;
- categoryGap = opts.extra.mix.column.categoryGap * opts.pix || 0;
- } else {
- seriesGap = opts.extra.column.seriesGap * opts.pix || 0;
- categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
- }
- seriesGap = Math.min(seriesGap, eachSpacing / columnLen);
- categoryGap = Math.min(categoryGap, eachSpacing / columnLen);
- item.width = Math.ceil((eachSpacing - 2 * categoryGap - seriesGap * (columnLen - 1)) / columnLen);
- if (opts.extra.mix && opts.extra.mix.column.width && +opts.extra.mix.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.mix.column.width * opts.pix);
- }
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
- }
- if (item.width <= 0) {
- item.width = 1;
- }
- item.x += (index + 0.5 - columnLen / 2) * (item.width + seriesGap);
- return item;
- });
- }
- function fixBarData(points, eachSpacing, columnLen, index, config2, opts) {
- return points.map(function(item) {
- if (item === null) {
- return null;
- }
- var seriesGap = 0;
- var categoryGap = 0;
- seriesGap = opts.extra.bar.seriesGap * opts.pix || 0;
- categoryGap = opts.extra.bar.categoryGap * opts.pix || 0;
- seriesGap = Math.min(seriesGap, eachSpacing / columnLen);
- categoryGap = Math.min(categoryGap, eachSpacing / columnLen);
- item.width = Math.ceil((eachSpacing - 2 * categoryGap - seriesGap * (columnLen - 1)) / columnLen);
- if (opts.extra.bar && opts.extra.bar.width && +opts.extra.bar.width > 0) {
- item.width = Math.min(item.width, +opts.extra.bar.width * opts.pix);
- }
- if (item.width <= 0) {
- item.width = 1;
- }
- item.y += (index + 0.5 - columnLen / 2) * (item.width + seriesGap);
- return item;
- });
- }
- function fixColumeMeterData(points, eachSpacing, columnLen, index, config2, opts, border) {
- var categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
- return points.map(function(item) {
- if (item === null) {
- return null;
- }
- item.width = eachSpacing - 2 * categoryGap;
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
- }
- if (index > 0) {
- item.width -= border;
- }
- return item;
- });
- }
- function fixColumeStackData(points, eachSpacing, columnLen, index, config2, opts, series) {
- var categoryGap = opts.extra.column.categoryGap * opts.pix || 0;
- return points.map(function(item, indexn) {
- if (item === null) {
- return null;
- }
- item.width = Math.ceil(eachSpacing - 2 * categoryGap);
- if (opts.extra.column && opts.extra.column.width && +opts.extra.column.width > 0) {
- item.width = Math.min(item.width, +opts.extra.column.width * opts.pix);
- }
- if (item.width <= 0) {
- item.width = 1;
- }
- return item;
- });
- }
- function fixBarStackData(points, eachSpacing, columnLen, index, config2, opts, series) {
- var categoryGap = opts.extra.bar.categoryGap * opts.pix || 0;
- return points.map(function(item, indexn) {
- if (item === null) {
- return null;
- }
- item.width = Math.ceil(eachSpacing - 2 * categoryGap);
- if (opts.extra.bar && opts.extra.bar.width && +opts.extra.bar.width > 0) {
- item.width = Math.min(item.width, +opts.extra.bar.width * opts.pix);
- }
- if (item.width <= 0) {
- item.width = 1;
- }
- return item;
- });
- }
- function getXAxisPoints(categories, opts, config2) {
- var spacingValid = opts.width - opts.area[1] - opts.area[3];
- var dataCount = opts.enableScroll ? Math.min(opts.xAxis.itemCount, categories.length) : categories.length;
- if ((opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble" || opts.type == "bar") && dataCount > 1 && opts.xAxis.boundaryGap == "justify") {
- dataCount -= 1;
- }
- var widthRatio = 0;
- if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
- if (opts.extra.mount.widthRatio > 2)
- opts.extra.mount.widthRatio = 2;
- widthRatio = opts.extra.mount.widthRatio - 1;
- dataCount += widthRatio;
- }
- var eachSpacing = spacingValid / dataCount;
- var xAxisPoints = [];
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- categories.forEach(function(item, index) {
- xAxisPoints.push(startX + widthRatio / 2 * eachSpacing + index * eachSpacing);
- });
- if (opts.xAxis.boundaryGap !== "justify") {
- if (opts.enableScroll === true) {
- xAxisPoints.push(startX + widthRatio * eachSpacing + categories.length * eachSpacing);
- } else {
- xAxisPoints.push(endX);
- }
- }
- return {
- xAxisPoints,
- startX,
- endX,
- eachSpacing
- };
- }
- function getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2) {
- var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var cPoints = [];
- item.forEach(function(items, indexs) {
- var point = {};
- point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
- var value = items.value || items;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.y = opts.height - Math.round(height) - opts.area[2];
- cPoints.push(point);
- });
- points.push(cPoints);
- }
- });
- return points;
- }
- function getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2) {
- var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
- var boundaryGap = "center";
- if (opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble") {
- boundaryGap = opts.xAxis.boundaryGap;
- }
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- var validWidth = opts.width - opts.area[1] - opts.area[3];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index];
- var value = item;
- if (typeof item === "object" && item !== null) {
- if (item.constructor.toString().indexOf("Array") > -1) {
- let xranges, xminRange, xmaxRange;
- xranges = [].concat(opts.chartData.xAxisData.ranges);
- xminRange = xranges.shift();
- xmaxRange = xranges.pop();
- value = item[1];
- point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
- if (opts.type == "bubble") {
- point.r = item[2];
- point.t = item[3];
- }
- } else {
- value = item.value;
- }
- }
- if (boundaryGap == "center") {
- point.x += eachSpacing / 2;
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.y = opts.height - height - opts.area[2];
- points.push(point);
- }
- });
- return points;
- }
- function getLineDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, lineOption, process) {
- var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
- var boundaryGap = opts.xAxis.boundaryGap;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- var validWidth = opts.width - opts.area[1] - opts.area[3];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- if (lineOption.animation == "vertical") {
- point.x = xAxisPoints[index];
- var value = item;
- if (typeof item === "object" && item !== null) {
- if (item.constructor.toString().indexOf("Array") > -1) {
- let xranges, xminRange, xmaxRange;
- xranges = [].concat(opts.chartData.xAxisData.ranges);
- xminRange = xranges.shift();
- xmaxRange = xranges.pop();
- value = item[1];
- point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
- } else {
- value = item.value;
- }
- }
- if (boundaryGap == "center") {
- point.x += eachSpacing / 2;
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.y = opts.height - height - opts.area[2];
- points.push(point);
- } else {
- point.x = xAxisPoints[0] + eachSpacing * index * process;
- var value = item;
- if (boundaryGap == "center") {
- point.x += eachSpacing / 2;
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- point.y = opts.height - height - opts.area[2];
- points.push(point);
- }
- }
- });
- return points;
- }
- function getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, zeroPoints, process) {
- var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- var validWidth = opts.width - opts.area[1] - opts.area[3];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index];
- var value = item;
- if (typeof item === "object" && item !== null) {
- if (item.constructor.toString().indexOf("Array") > -1) {
- let xranges, xminRange, xmaxRange;
- xranges = [].concat(opts.chartData.xAxisData.ranges);
- xminRange = xranges.shift();
- xmaxRange = xranges.pop();
- value = item[1];
- point.x = opts.area[3] + validWidth * (item[0] - xminRange) / (xmaxRange - xminRange);
- } else {
- value = item.value;
- }
- }
- point.x += eachSpacing / 2;
- var height = validHeight * (value * process - minRange) / (maxRange - minRange);
- point.y = opts.height - height - opts.area[2];
- points.push(point);
- }
- });
- return points;
- }
- function getMountDataPoints(series, minRange, maxRange, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints) {
- var process = arguments.length > 8 && arguments[8] !== void 0 ? arguments[8] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- var validWidth = opts.width - opts.area[1] - opts.area[3];
- var mountWidth = eachSpacing * mountOption.widthRatio;
- series.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index];
- point.x += eachSpacing / 2;
- var value = item.data;
- var height = validHeight * (value * process - minRange) / (maxRange - minRange);
- point.y = opts.height - height - opts.area[2];
- point.value = value;
- point.width = mountWidth;
- points.push(point);
- }
- });
- return points;
- }
- function getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2) {
- var process = arguments.length > 7 && arguments[7] !== void 0 ? arguments[7] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- var validWidth = opts.width - opts.area[1] - opts.area[3];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.y = yAxisPoints[index];
- var value = item;
- if (typeof item === "object" && item !== null) {
- value = item.value;
- }
- var height = validWidth * (value - minRange) / (maxRange - minRange);
- height *= process;
- point.height = height;
- point.value = value;
- point.x = height + opts.area[3];
- points.push(point);
- }
- });
- return points;
- }
- function getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, stackSeries) {
- var process = arguments.length > 9 && arguments[9] !== void 0 ? arguments[9] : 1;
- var points = [];
- var validHeight = opts.height - opts.area[0] - opts.area[2];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.x = xAxisPoints[index] + Math.round(eachSpacing / 2);
- if (seriesIndex > 0) {
- var value = 0;
- for (let i = 0; i <= seriesIndex; i++) {
- value += stackSeries[i].data[index];
- }
- var value0 = value - item;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
- } else {
- var value = item;
- if (typeof item === "object" && item !== null) {
- value = item.value;
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = 0;
- }
- var heightc = height0;
- height *= process;
- heightc *= process;
- point.y = opts.height - Math.round(height) - opts.area[2];
- point.y0 = opts.height - Math.round(heightc) - opts.area[2];
- points.push(point);
- }
- });
- return points;
- }
- function getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, stackSeries) {
- var process = arguments.length > 9 && arguments[9] !== void 0 ? arguments[9] : 1;
- var points = [];
- var validHeight = opts.width - opts.area[1] - opts.area[3];
- data.forEach(function(item, index) {
- if (item === null) {
- points.push(null);
- } else {
- var point = {};
- point.color = item.color;
- point.y = yAxisPoints[index];
- if (seriesIndex > 0) {
- var value = 0;
- for (let i = 0; i <= seriesIndex; i++) {
- value += stackSeries[i].data[index];
- }
- var value0 = value - item;
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = validHeight * (value0 - minRange) / (maxRange - minRange);
- } else {
- var value = item;
- if (typeof item === "object" && item !== null) {
- value = item.value;
- }
- var height = validHeight * (value - minRange) / (maxRange - minRange);
- var height0 = 0;
- }
- var heightc = height0;
- height *= process;
- heightc *= process;
- point.height = height - heightc;
- point.x = opts.area[3] + height;
- point.x0 = opts.area[3] + heightc;
- points.push(point);
- }
- });
- return points;
- }
- function getYAxisTextList(series, opts, config2, stack, yData) {
- var index = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : -1;
- var data;
- if (stack == "stack") {
- data = dataCombineStack(series, opts.categories.length);
- } else {
- data = dataCombine(series);
- }
- var sorted = [];
- data = data.filter(function(item) {
- if (typeof item === "object" && item !== null) {
- if (item.constructor.toString().indexOf("Array") > -1) {
- return item !== null;
- } else {
- return item.value !== null;
- }
- } else {
- return item !== null;
- }
- });
- data.map(function(item) {
- if (typeof item === "object") {
- if (item.constructor.toString().indexOf("Array") > -1) {
- if (opts.type == "candle") {
- item.map(function(subitem) {
- sorted.push(subitem);
- });
- } else {
- sorted.push(item[1]);
- }
- } else {
- sorted.push(item.value);
- }
- } else {
- sorted.push(item);
- }
- });
- var minData = yData.min || 0;
- var maxData = yData.max || 0;
- if (sorted.length > 0) {
- minData = Math.min.apply(this, sorted);
- maxData = Math.max.apply(this, sorted);
- }
- if (minData === maxData) {
- if (maxData == 0) {
- maxData = 10;
- } else {
- minData = 0;
- }
- }
- var dataRange = getDataRange(minData, maxData);
- var minRange = yData.min === void 0 || yData.min === null ? dataRange.minRange : yData.min;
- var maxRange = yData.max === void 0 || yData.max === null ? dataRange.maxRange : yData.max;
- var eachRange = (maxRange - minRange) / opts.yAxis.splitNumber;
- var range = [];
- for (var i = 0; i <= opts.yAxis.splitNumber; i++) {
- range.push(minRange + eachRange * i);
- }
- return range.reverse();
- }
- function calYAxisData(series, opts, config2, context) {
- var columnstyle = assign({}, {
- type: ""
- }, opts.extra.column);
- var YLength = opts.yAxis.data.length;
- var newSeries = new Array(YLength);
- if (YLength > 0) {
- for (let i = 0; i < YLength; i++) {
- newSeries[i] = [];
- for (let j = 0; j < series.length; j++) {
- if (series[j].index == i) {
- newSeries[i].push(series[j]);
- }
- }
- }
- var rangesArr = new Array(YLength);
- var rangesFormatArr = new Array(YLength);
- var yAxisWidthArr = new Array(YLength);
- for (let i = 0; i < YLength; i++) {
- let yData = opts.yAxis.data[i];
- if (opts.yAxis.disabled == true) {
- yData.disabled = true;
- }
- if (yData.type === "categories") {
- if (!yData.formatter) {
- yData.formatter = (val, index, opts2) => {
- return val + (yData.unit || "");
- };
- }
- yData.categories = yData.categories || opts.categories;
- rangesArr[i] = yData.categories;
- } else {
- if (!yData.formatter) {
- yData.formatter = (val, index, opts2) => {
- return util.toFixed(val, yData.tofix || 0) + (yData.unit || "");
- };
- }
- rangesArr[i] = getYAxisTextList(newSeries[i], opts, config2, columnstyle.type, yData, i);
- }
- let yAxisFontSizes = yData.fontSize * opts.pix || config2.fontSize;
- yAxisWidthArr[i] = {
- position: yData.position ? yData.position : "left",
- width: 0
- };
- rangesFormatArr[i] = rangesArr[i].map(function(items, index) {
- items = yData.formatter(items, index, opts);
- yAxisWidthArr[i].width = Math.max(yAxisWidthArr[i].width, measureText(items, yAxisFontSizes, context) + 5);
- return items;
- });
- let calibration = yData.calibration ? 4 * opts.pix : 0;
- yAxisWidthArr[i].width += calibration + 3 * opts.pix;
- if (yData.disabled === true) {
- yAxisWidthArr[i].width = 0;
- }
- }
- } else {
- var rangesArr = new Array(1);
- var rangesFormatArr = new Array(1);
- var yAxisWidthArr = new Array(1);
- if (opts.type === "bar") {
- rangesArr[0] = opts.categories;
- if (!opts.yAxis.formatter) {
- opts.yAxis.formatter = (val, index, opts2) => {
- return val + (opts2.yAxis.unit || "");
- };
- }
- } else {
- if (!opts.yAxis.formatter) {
- opts.yAxis.formatter = (val, index, opts2) => {
- return val.toFixed(opts2.yAxis.tofix) + (opts2.yAxis.unit || "");
- };
- }
- rangesArr[0] = getYAxisTextList(series, opts, config2, columnstyle.type, {});
- }
- yAxisWidthArr[0] = {
- position: "left",
- width: 0
- };
- var yAxisFontSize = opts.yAxis.fontSize * opts.pix || config2.fontSize;
- rangesFormatArr[0] = rangesArr[0].map(function(item, index) {
- item = opts.yAxis.formatter(item, index, opts);
- yAxisWidthArr[0].width = Math.max(yAxisWidthArr[0].width, measureText(item, yAxisFontSize, context) + 5);
- return item;
- });
- yAxisWidthArr[0].width += 3 * opts.pix;
- if (opts.yAxis.disabled === true) {
- yAxisWidthArr[0] = {
- position: "left",
- width: 0
- };
- opts.yAxis.data[0] = {
- disabled: true
- };
- } else {
- opts.yAxis.data[0] = {
- disabled: false,
- position: "left",
- max: opts.yAxis.max,
- min: opts.yAxis.min,
- formatter: opts.yAxis.formatter
- };
- if (opts.type === "bar") {
- opts.yAxis.data[0].categories = opts.categories;
- opts.yAxis.data[0].type = "categories";
- }
- }
- }
- return {
- rangesFormat: rangesFormatArr,
- ranges: rangesArr,
- yAxisWidth: yAxisWidthArr
- };
- }
- function calTooltipYAxisData(point, series, opts, config2, eachSpacing) {
- let ranges = [].concat(opts.chartData.yAxisData.ranges);
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- let minAxis = opts.area[0];
- let items = [];
- for (let i = 0; i < ranges.length; i++) {
- let maxVal = Math.max.apply(this, ranges[i]);
- let minVal = Math.min.apply(this, ranges[i]);
- let item = maxVal - (maxVal - minVal) * (point - minAxis) / spacingValid;
- item = opts.yAxis.data && opts.yAxis.data[i].formatter ? opts.yAxis.data[i].formatter(item, i, opts) : item.toFixed(0);
- items.push(String(item));
- }
- return items;
- }
- function calMarkLineData(points, opts) {
- let minRange, maxRange;
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- for (let i = 0; i < points.length; i++) {
- points[i].yAxisIndex = points[i].yAxisIndex ? points[i].yAxisIndex : 0;
- let range = [].concat(opts.chartData.yAxisData.ranges[points[i].yAxisIndex]);
- minRange = range.pop();
- maxRange = range.shift();
- let height = spacingValid * (points[i].value - minRange) / (maxRange - minRange);
- points[i].y = opts.height - Math.round(height) - opts.area[2];
- }
- return points;
- }
- function contextRotate(context, opts) {
- if (opts.rotateLock !== true) {
- context.translate(opts.height, 0);
- context.rotate(90 * Math.PI / 180);
- } else if (opts._rotate_ !== true) {
- context.translate(opts.height, 0);
- context.rotate(90 * Math.PI / 180);
- opts._rotate_ = true;
- }
- }
- function drawPointShape(points, color3, shape, context, opts) {
- context.beginPath();
- if (opts.dataPointShapeType == "hollow") {
- context.setStrokeStyle(color3);
- context.setFillStyle(opts.background);
- context.setLineWidth(2 * opts.pix);
- } else {
- context.setStrokeStyle("#ffffff");
- context.setFillStyle(color3);
- context.setLineWidth(1 * opts.pix);
- }
- if (shape === "diamond") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y);
- context.lineTo(item.x, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "circle") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x + 2.5 * opts.pix, item.y);
- context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
- }
- });
- } else if (shape === "square") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x - 3.5, item.y - 3.5);
- context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
- }
- });
- } else if (shape === "triangle") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y + 4.5);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "none") {
- return;
- }
- context.closePath();
- context.fill();
- context.stroke();
- }
- function drawActivePoint(points, color3, shape, context, opts, option, seriesIndex) {
- if (!opts.tooltip) {
- return;
- }
- if (opts.tooltip.group.length > 0 && opts.tooltip.group.includes(seriesIndex) == false) {
- return;
- }
- var pointIndex = typeof opts.tooltip.index === "number" ? opts.tooltip.index : opts.tooltip.index[opts.tooltip.group.indexOf(seriesIndex)];
- context.beginPath();
- if (option.activeType == "hollow") {
- context.setStrokeStyle(color3);
- context.setFillStyle(opts.background);
- context.setLineWidth(2 * opts.pix);
- } else {
- context.setStrokeStyle("#ffffff");
- context.setFillStyle(color3);
- context.setLineWidth(1 * opts.pix);
- }
- if (shape === "diamond") {
- points.forEach(function(item, index) {
- if (item !== null && pointIndex == index) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y);
- context.lineTo(item.x, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "circle") {
- points.forEach(function(item, index) {
- if (item !== null && pointIndex == index) {
- context.moveTo(item.x + 2.5 * opts.pix, item.y);
- context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
- }
- });
- } else if (shape === "square") {
- points.forEach(function(item, index) {
- if (item !== null && pointIndex == index) {
- context.moveTo(item.x - 3.5, item.y - 3.5);
- context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
- }
- });
- } else if (shape === "triangle") {
- points.forEach(function(item, index) {
- if (item !== null && pointIndex == index) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y + 4.5);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "none") {
- return;
- }
- context.closePath();
- context.fill();
- context.stroke();
- }
- function drawRingTitle(opts, config2, context, center) {
- var titlefontSize = opts.title.fontSize || config2.titleFontSize;
- var subtitlefontSize = opts.subtitle.fontSize || config2.subtitleFontSize;
- var title = opts.title.name || "";
- var subtitle = opts.subtitle.name || "";
- var titleFontColor = opts.title.color || opts.fontColor;
- var subtitleFontColor = opts.subtitle.color || opts.fontColor;
- var titleHeight = title ? titlefontSize : 0;
- var subtitleHeight = subtitle ? subtitlefontSize : 0;
- var margin = 5;
- if (subtitle) {
- var textWidth = measureText(subtitle, subtitlefontSize * opts.pix, context);
- var startX = center.x - textWidth / 2 + (opts.subtitle.offsetX || 0) * opts.pix;
- var startY = center.y + subtitlefontSize * opts.pix / 2 + (opts.subtitle.offsetY || 0) * opts.pix;
- if (title) {
- startY += (titleHeight * opts.pix + margin) / 2;
- }
- context.beginPath();
- context.setFontSize(subtitlefontSize * opts.pix);
- context.setFillStyle(subtitleFontColor);
- context.fillText(subtitle, startX, startY);
- context.closePath();
- context.stroke();
- }
- if (title) {
- var _textWidth = measureText(title, titlefontSize * opts.pix, context);
- var _startX = center.x - _textWidth / 2 + (opts.title.offsetX || 0);
- var _startY = center.y + titlefontSize * opts.pix / 2 + (opts.title.offsetY || 0) * opts.pix;
- if (subtitle) {
- _startY -= (subtitleHeight * opts.pix + margin) / 2;
- }
- context.beginPath();
- context.setFontSize(titlefontSize * opts.pix);
- context.setFillStyle(titleFontColor);
- context.fillText(title, _startX, _startY);
- context.closePath();
- context.stroke();
- }
- }
- function drawPointText(points, series, config2, context, opts) {
- var data = series.data;
- var textOffset = series.textOffset ? series.textOffset : 0;
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(series.textColor || opts.fontColor);
- var value = data[index];
- if (typeof data[index] === "object" && data[index] !== null) {
- if (data[index].constructor.toString().indexOf("Array") > -1) {
- value = data[index][1];
- } else {
- value = data[index].value;
- }
- }
- var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
- context.setTextAlign("center");
- context.fillText(String(formatVal), item.x, item.y - 4 + textOffset * opts.pix);
- context.closePath();
- context.stroke();
- context.setTextAlign("left");
- }
- });
- }
- function drawColumePointText(points, series, config2, context, opts) {
- var data = series.data;
- var textOffset = series.textOffset ? series.textOffset : 0;
- var Position = opts.extra.column.labelPosition;
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(series.textColor || opts.fontColor);
- var value = data[index];
- if (typeof data[index] === "object" && data[index] !== null) {
- if (data[index].constructor.toString().indexOf("Array") > -1) {
- value = data[index][1];
- } else {
- value = data[index].value;
- }
- }
- var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
- context.setTextAlign("center");
- var startY = item.y - 4 * opts.pix + textOffset * opts.pix;
- if (item.y > series.zeroPoints) {
- startY = item.y + textOffset * opts.pix + fontSize;
- }
- if (Position == "insideTop") {
- startY = item.y + fontSize + textOffset * opts.pix;
- if (item.y > series.zeroPoints) {
- startY = item.y - textOffset * opts.pix - 4 * opts.pix;
- }
- }
- if (Position == "center") {
- startY = item.y + textOffset * opts.pix + (opts.height - opts.area[2] - item.y + fontSize) / 2;
- if (series.zeroPoints < opts.height - opts.area[2]) {
- startY = item.y + textOffset * opts.pix + (series.zeroPoints - item.y + fontSize) / 2;
- }
- if (item.y > series.zeroPoints) {
- startY = item.y - textOffset * opts.pix - (item.y - series.zeroPoints - fontSize) / 2;
- }
- if (opts.extra.column.type == "stack") {
- startY = item.y + textOffset * opts.pix + (item.y0 - item.y + fontSize) / 2;
- }
- }
- if (Position == "bottom") {
- startY = opts.height - opts.area[2] + textOffset * opts.pix - 4 * opts.pix;
- if (series.zeroPoints < opts.height - opts.area[2]) {
- startY = series.zeroPoints + textOffset * opts.pix - 4 * opts.pix;
- }
- if (item.y > series.zeroPoints) {
- startY = series.zeroPoints - textOffset * opts.pix + fontSize + 2 * opts.pix;
- }
- if (opts.extra.column.type == "stack") {
- startY = item.y0 + textOffset * opts.pix - 4 * opts.pix;
- }
- }
- context.fillText(String(formatVal), item.x, startY);
- context.closePath();
- context.stroke();
- context.setTextAlign("left");
- }
- });
- }
- function drawMountPointText(points, series, config2, context, opts, zeroPoints) {
- var data = series.data;
- var textOffset = series.textOffset ? series.textOffset : 0;
- var Position = opts.extra.mount.labelPosition;
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- var fontSize = series[index].textSize ? series[index].textSize * opts.pix : config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(series[index].textColor || opts.fontColor);
- var value = item.value;
- var formatVal = series[index].formatter ? series[index].formatter(value, index, series, opts) : value;
- context.setTextAlign("center");
- var startY = item.y - 4 * opts.pix + textOffset * opts.pix;
- if (item.y > zeroPoints) {
- startY = item.y + textOffset * opts.pix + fontSize;
- }
- context.fillText(String(formatVal), item.x, startY);
- context.closePath();
- context.stroke();
- context.setTextAlign("left");
- }
- });
- }
- function drawBarPointText(points, series, config2, context, opts) {
- var data = series.data;
- var textOffset = series.textOffset ? series.textOffset : 0;
- points.forEach(function(item, index) {
- if (item !== null) {
- context.beginPath();
- var fontSize = series.textSize ? series.textSize * opts.pix : config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(series.textColor || opts.fontColor);
- var value = data[index];
- if (typeof data[index] === "object" && data[index] !== null) {
- value = data[index].value;
- }
- var formatVal = series.formatter ? series.formatter(value, index, series, opts) : value;
- context.setTextAlign("left");
- context.fillText(String(formatVal), item.x + 4 * opts.pix, item.y + fontSize / 2 - 3);
- context.closePath();
- context.stroke();
- }
- });
- }
- function drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config2, context) {
- radius -= gaugeOption.width / 2 + gaugeOption.labelOffset * opts.pix;
- radius = radius < 10 ? 10 : radius;
- let totalAngle;
- if (gaugeOption.endAngle < gaugeOption.startAngle) {
- totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
- } else {
- totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
- }
- let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
- let totalNumber = gaugeOption.endNumber - gaugeOption.startNumber;
- let splitNumber = totalNumber / gaugeOption.splitLine.splitNumber;
- let nowAngle = gaugeOption.startAngle;
- let nowNumber = gaugeOption.startNumber;
- for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
- var pos = {
- x: radius * Math.cos(nowAngle * Math.PI),
- y: radius * Math.sin(nowAngle * Math.PI)
- };
- var labelText = gaugeOption.formatter ? gaugeOption.formatter(nowNumber, i, opts) : nowNumber;
- pos.x += centerPosition.x - measureText(labelText, config2.fontSize, context) / 2;
- pos.y += centerPosition.y;
- var startX = pos.x;
- var startY = pos.y;
- context.beginPath();
- context.setFontSize(config2.fontSize);
- context.setFillStyle(gaugeOption.labelColor || opts.fontColor);
- context.fillText(labelText, startX, startY + config2.fontSize / 2);
- context.closePath();
- context.stroke();
- nowAngle += splitAngle;
- if (nowAngle >= 2) {
- nowAngle = nowAngle % 2;
- }
- nowNumber += splitNumber;
- }
- }
- function drawRadarLabel(angleList, radius, centerPosition, opts, config2, context) {
- var radarOption = opts.extra.radar || {};
- angleList.forEach(function(angle, index) {
- if (radarOption.labelPointShow === true && opts.categories[index] !== "") {
- var posPoint = {
- x: radius * Math.cos(angle),
- y: radius * Math.sin(angle)
- };
- var posPointAxis = convertCoordinateOrigin(posPoint.x, posPoint.y, centerPosition);
- context.setFillStyle(radarOption.labelPointColor);
- context.beginPath();
- context.arc(posPointAxis.x, posPointAxis.y, radarOption.labelPointRadius * opts.pix, 0, 2 * Math.PI, false);
- context.closePath();
- context.fill();
- }
- if (radarOption.labelShow === true) {
- var pos = {
- x: (radius + config2.radarLabelTextMargin * opts.pix) * Math.cos(angle),
- y: (radius + config2.radarLabelTextMargin * opts.pix) * Math.sin(angle)
- };
- var posRelativeCanvas = convertCoordinateOrigin(pos.x, pos.y, centerPosition);
- var startX = posRelativeCanvas.x;
- var startY = posRelativeCanvas.y;
- if (util.approximatelyEqual(pos.x, 0)) {
- startX -= measureText(opts.categories[index] || "", config2.fontSize, context) / 2;
- } else if (pos.x < 0) {
- startX -= measureText(opts.categories[index] || "", config2.fontSize, context);
- }
- context.beginPath();
- context.setFontSize(config2.fontSize);
- context.setFillStyle(radarOption.labelColor || opts.fontColor);
- context.fillText(opts.categories[index] || "", startX, startY + config2.fontSize / 2);
- context.closePath();
- context.stroke();
- }
- });
- }
- function drawPieText(series, opts, config2, context, radius, center) {
- var lineRadius = config2.pieChartLinePadding;
- var textObjectCollection = [];
- var lastTextObject = null;
- var seriesConvert = series.map(function(item, index) {
- var text = item.formatter ? item.formatter(item, index, series, opts) : util.toFixed(item._proportion_.toFixed(4) * 100) + "%";
- text = item.labelText ? item.labelText : text;
- var arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._proportion_ / 2);
- if (item._rose_proportion_) {
- arc = 2 * Math.PI - (item._start_ + 2 * Math.PI * item._rose_proportion_ / 2);
- }
- var color3 = item.color;
- var radius2 = item._radius_;
- return {
- arc,
- text,
- color: color3,
- radius: radius2,
- textColor: item.textColor,
- textSize: item.textSize,
- labelShow: item.labelShow
- };
- });
- for (let i = 0; i < seriesConvert.length; i++) {
- let item = seriesConvert[i];
- let orginX1 = Math.cos(item.arc) * (item.radius + lineRadius);
- let orginY1 = Math.sin(item.arc) * (item.radius + lineRadius);
- let orginX2 = Math.cos(item.arc) * item.radius;
- let orginY2 = Math.sin(item.arc) * item.radius;
- let orginX3 = orginX1 >= 0 ? orginX1 + config2.pieChartTextPadding : orginX1 - config2.pieChartTextPadding;
- let orginY3 = orginY1;
- let textWidth = measureText(item.text, item.textSize * opts.pix || config2.fontSize, context);
- let startY = orginY3;
- if (lastTextObject && util.isSameXCoordinateArea(lastTextObject.start, {
- x: orginX3
- })) {
- if (orginX3 > 0) {
- startY = Math.min(orginY3, lastTextObject.start.y);
- } else if (orginX1 < 0) {
- startY = Math.max(orginY3, lastTextObject.start.y);
- } else {
- if (orginY3 > 0) {
- startY = Math.max(orginY3, lastTextObject.start.y);
- } else {
- startY = Math.min(orginY3, lastTextObject.start.y);
- }
- }
- }
- if (orginX3 < 0) {
- orginX3 -= textWidth;
- }
- let textObject = {
- lineStart: {
- x: orginX2,
- y: orginY2
- },
- lineEnd: {
- x: orginX1,
- y: orginY1
- },
- start: {
- x: orginX3,
- y: startY
- },
- width: textWidth,
- height: config2.fontSize,
- text: item.text,
- color: item.color,
- textColor: item.textColor,
- textSize: item.textSize
- };
- lastTextObject = avoidCollision(textObject, lastTextObject);
- textObjectCollection.push(lastTextObject);
- }
- for (let i = 0; i < textObjectCollection.length; i++) {
- if (seriesConvert[i].labelShow === false) {
- continue;
- }
- let item = textObjectCollection[i];
- let lineStartPoistion = convertCoordinateOrigin(item.lineStart.x, item.lineStart.y, center);
- let lineEndPoistion = convertCoordinateOrigin(item.lineEnd.x, item.lineEnd.y, center);
- let textPosition = convertCoordinateOrigin(item.start.x, item.start.y, center);
- context.setLineWidth(1 * opts.pix);
- context.setFontSize(item.textSize * opts.pix || config2.fontSize);
- context.beginPath();
- context.setStrokeStyle(item.color);
- context.setFillStyle(item.color);
- context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
- let curveStartX = item.start.x < 0 ? textPosition.x + item.width : textPosition.x;
- let textStartX = item.start.x < 0 ? textPosition.x - 5 : textPosition.x + 5;
- context.quadraticCurveTo(lineEndPoistion.x, lineEndPoistion.y, curveStartX, textPosition.y);
- context.moveTo(lineStartPoistion.x, lineStartPoistion.y);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.moveTo(textPosition.x + item.width, textPosition.y);
- context.arc(curveStartX, textPosition.y, 2 * opts.pix, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFontSize(item.textSize * opts.pix || config2.fontSize);
- context.setFillStyle(item.textColor || opts.fontColor);
- context.fillText(item.text, textStartX, textPosition.y + 3);
- context.closePath();
- context.stroke();
- context.closePath();
- }
- }
- function drawToolTipSplitLine(offsetX, opts, config2, context) {
- var toolTipOption = opts.extra.tooltip || {};
- toolTipOption.gridType = toolTipOption.gridType == void 0 ? "solid" : toolTipOption.gridType;
- toolTipOption.dashLength = toolTipOption.dashLength == void 0 ? 4 : toolTipOption.dashLength;
- var startY = opts.area[0];
- var endY = opts.height - opts.area[2];
- if (toolTipOption.gridType == "dash") {
- context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
- }
- context.setStrokeStyle(toolTipOption.gridColor || "#cccccc");
- context.setLineWidth(1 * opts.pix);
- context.beginPath();
- context.moveTo(offsetX, startY);
- context.lineTo(offsetX, endY);
- context.stroke();
- context.setLineDash([]);
- if (toolTipOption.xAxisLabel) {
- let labelText = opts.categories[opts.tooltip.index];
- context.setFontSize(config2.fontSize);
- let textWidth = measureText(labelText, config2.fontSize, context);
- let textX = offsetX - 0.5 * textWidth;
- let textY = endY + 2 * opts.pix;
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config2.toolTipBackground, toolTipOption.labelBgOpacity || config2.toolTipOpacity));
- context.setStrokeStyle(toolTipOption.labelBgColor || config2.toolTipBackground);
- context.setLineWidth(1 * opts.pix);
- context.rect(textX - toolTipOption.boxPadding * opts.pix, textY, textWidth + 2 * toolTipOption.boxPadding * opts.pix, config2.fontSize + 2 * toolTipOption.boxPadding * opts.pix);
- context.closePath();
- context.stroke();
- context.fill();
- context.beginPath();
- context.setFontSize(config2.fontSize);
- context.setFillStyle(toolTipOption.labelFontColor || opts.fontColor);
- context.fillText(String(labelText), textX, textY + toolTipOption.boxPadding * opts.pix + config2.fontSize);
- context.closePath();
- context.stroke();
- }
- }
- function drawMarkLine(opts, config2, context) {
- let markLineOption = assign({}, {
- type: "solid",
- dashLength: 4,
- data: []
- }, opts.extra.markLine);
- let startX = opts.area[3];
- let endX = opts.width - opts.area[1];
- let points = calMarkLineData(markLineOption.data, opts);
- for (let i = 0; i < points.length; i++) {
- let item = assign({}, {
- lineColor: "#DE4A42",
- showLabel: false,
- labelFontSize: 13,
- labelPadding: 6,
- labelFontColor: "#666666",
- labelBgColor: "#DFE8FF",
- labelBgOpacity: 0.8,
- labelAlign: "left",
- labelOffsetX: 0,
- labelOffsetY: 0
- }, points[i]);
- if (markLineOption.type == "dash") {
- context.setLineDash([markLineOption.dashLength, markLineOption.dashLength]);
- }
- context.setStrokeStyle(item.lineColor);
- context.setLineWidth(1 * opts.pix);
- context.beginPath();
- context.moveTo(startX, item.y);
- context.lineTo(endX, item.y);
- context.stroke();
- context.setLineDash([]);
- if (item.showLabel) {
- let fontSize = item.labelFontSize * opts.pix;
- let labelText = item.labelText ? item.labelText : item.value;
- context.setFontSize(fontSize);
- let textWidth = measureText(labelText, fontSize, context);
- let bgWidth = textWidth + item.labelPadding * opts.pix * 2;
- let bgStartX = item.labelAlign == "left" ? opts.area[3] - bgWidth : opts.width - opts.area[1];
- bgStartX += item.labelOffsetX;
- let bgStartY = item.y - 0.5 * fontSize - item.labelPadding * opts.pix;
- bgStartY += item.labelOffsetY;
- let textX = bgStartX + item.labelPadding * opts.pix;
- let textY = item.y;
- context.setFillStyle(hexToRgb(item.labelBgColor, item.labelBgOpacity));
- context.setStrokeStyle(item.labelBgColor);
- context.setLineWidth(1 * opts.pix);
- context.beginPath();
- context.rect(bgStartX, bgStartY, bgWidth, fontSize + 2 * item.labelPadding * opts.pix);
- context.closePath();
- context.stroke();
- context.fill();
- context.setFontSize(fontSize);
- context.setTextAlign("left");
- context.setFillStyle(item.labelFontColor);
- context.fillText(String(labelText), textX, bgStartY + fontSize + item.labelPadding * opts.pix / 2);
- context.stroke();
- context.setTextAlign("left");
- }
- }
- }
- function drawToolTipHorizentalLine(opts, config2, context, eachSpacing, xAxisPoints) {
- var toolTipOption = assign({}, {
- gridType: "solid",
- dashLength: 4
- }, opts.extra.tooltip);
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- if (toolTipOption.gridType == "dash") {
- context.setLineDash([toolTipOption.dashLength, toolTipOption.dashLength]);
- }
- context.setStrokeStyle(toolTipOption.gridColor || "#cccccc");
- context.setLineWidth(1 * opts.pix);
- context.beginPath();
- context.moveTo(startX, opts.tooltip.offset.y);
- context.lineTo(endX, opts.tooltip.offset.y);
- context.stroke();
- context.setLineDash([]);
- if (toolTipOption.yAxisLabel) {
- let boxPadding = toolTipOption.boxPadding * opts.pix;
- let labelText = calTooltipYAxisData(opts.tooltip.offset.y, opts.series, opts, config2, eachSpacing);
- let widthArr = opts.chartData.yAxisData.yAxisWidth;
- let tStartLeft = opts.area[3];
- let tStartRight = opts.width - opts.area[1];
- for (let i = 0; i < labelText.length; i++) {
- context.setFontSize(toolTipOption.fontSize * opts.pix);
- let textWidth = measureText(labelText[i], toolTipOption.fontSize * opts.pix, context);
- let bgStartX, bgEndX, bgWidth;
- if (widthArr[i].position == "left") {
- bgStartX = tStartLeft - (textWidth + boxPadding * 2) - 2 * opts.pix;
- bgEndX = Math.max(bgStartX, bgStartX + textWidth + boxPadding * 2);
- } else {
- bgStartX = tStartRight + 2 * opts.pix;
- bgEndX = Math.max(bgStartX + widthArr[i].width, bgStartX + textWidth + boxPadding * 2);
- }
- bgWidth = bgEndX - bgStartX;
- let textX = bgStartX + (bgWidth - textWidth) / 2;
- let textY = opts.tooltip.offset.y;
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.labelBgColor || config2.toolTipBackground, toolTipOption.labelBgOpacity || config2.toolTipOpacity));
- context.setStrokeStyle(toolTipOption.labelBgColor || config2.toolTipBackground);
- context.setLineWidth(1 * opts.pix);
- context.rect(bgStartX, textY - 0.5 * config2.fontSize - boxPadding, bgWidth, config2.fontSize + 2 * boxPadding);
- context.closePath();
- context.stroke();
- context.fill();
- context.beginPath();
- context.setFontSize(config2.fontSize);
- context.setFillStyle(toolTipOption.labelFontColor || opts.fontColor);
- context.fillText(labelText[i], textX, textY + 0.5 * config2.fontSize);
- context.closePath();
- context.stroke();
- if (widthArr[i].position == "left") {
- tStartLeft -= widthArr[i].width + opts.yAxis.padding * opts.pix;
- } else {
- tStartRight += widthArr[i].width + opts.yAxis.padding * opts.pix;
- }
- }
- }
- }
- function drawToolTipSplitArea(offsetX, opts, config2, context, eachSpacing) {
- var toolTipOption = assign({}, {
- activeBgColor: "#000000",
- activeBgOpacity: 0.08,
- activeWidth: eachSpacing
- }, opts.extra.column);
- toolTipOption.activeWidth = toolTipOption.activeWidth > eachSpacing ? eachSpacing : toolTipOption.activeWidth;
- var startY = opts.area[0];
- var endY = opts.height - opts.area[2];
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.activeBgColor, toolTipOption.activeBgOpacity));
- context.rect(offsetX - toolTipOption.activeWidth / 2, startY, toolTipOption.activeWidth, endY - startY);
- context.closePath();
- context.fill();
- context.setFillStyle("#FFFFFF");
- }
- function drawBarToolTipSplitArea(offsetX, opts, config2, context, eachSpacing) {
- var toolTipOption = assign({}, {
- activeBgColor: "#000000",
- activeBgOpacity: 0.08
- }, opts.extra.bar);
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.activeBgColor, toolTipOption.activeBgOpacity));
- context.rect(startX, offsetX - eachSpacing / 2, endX - startX, eachSpacing);
- context.closePath();
- context.fill();
- context.setFillStyle("#FFFFFF");
- }
- function drawToolTip(textList, offset, opts, config2, context, eachSpacing, xAxisPoints) {
- var toolTipOption = assign({}, {
- showBox: true,
- showArrow: true,
- showCategory: false,
- bgColor: "#000000",
- bgOpacity: 0.7,
- borderColor: "#000000",
- borderWidth: 0,
- borderRadius: 0,
- borderOpacity: 0.7,
- boxPadding: 3,
- fontColor: "#FFFFFF",
- fontSize: 13,
- lineHeight: 20,
- legendShow: true,
- legendShape: "auto",
- splitLine: true
- }, opts.extra.tooltip);
- if (toolTipOption.showCategory == true && opts.categories) {
- textList.unshift({ text: opts.categories[opts.tooltip.index], color: null });
- }
- var fontSize = toolTipOption.fontSize * opts.pix;
- var lineHeight = toolTipOption.lineHeight * opts.pix;
- var boxPadding = toolTipOption.boxPadding * opts.pix;
- var legendWidth = fontSize;
- var legendMarginRight = 5 * opts.pix;
- if (toolTipOption.legendShow == false) {
- legendWidth = 0;
- legendMarginRight = 0;
- }
- var arrowWidth = toolTipOption.showArrow ? 8 * opts.pix : 0;
- var isOverRightBorder = false;
- if (opts.type == "line" || opts.type == "mount" || opts.type == "area" || opts.type == "candle" || opts.type == "mix") {
- if (toolTipOption.splitLine == true) {
- drawToolTipSplitLine(opts.tooltip.offset.x, opts, config2, context);
- }
- }
- offset = assign({
- x: 0,
- y: 0
- }, offset);
- offset.y -= 8 * opts.pix;
- var textWidth = textList.map(function(item) {
- return measureText(item.text, fontSize, context);
- });
- var toolTipWidth = legendWidth + legendMarginRight + 4 * boxPadding + Math.max.apply(null, textWidth);
- var toolTipHeight = 2 * boxPadding + textList.length * lineHeight;
- if (toolTipOption.showBox == false) {
- return;
- }
- if (offset.x - Math.abs(opts._scrollDistance_ || 0) + arrowWidth + toolTipWidth > opts.width) {
- isOverRightBorder = true;
- }
- if (toolTipHeight + offset.y > opts.height) {
- offset.y = opts.height - toolTipHeight;
- }
- context.beginPath();
- context.setFillStyle(hexToRgb(toolTipOption.bgColor, toolTipOption.bgOpacity));
- context.setLineWidth(toolTipOption.borderWidth * opts.pix);
- context.setStrokeStyle(hexToRgb(toolTipOption.borderColor, toolTipOption.borderOpacity));
- var radius = toolTipOption.borderRadius;
- if (isOverRightBorder) {
- if (toolTipWidth + arrowWidth > opts.width) {
- offset.x = opts.width + Math.abs(opts._scrollDistance_ || 0) + arrowWidth + (toolTipWidth - opts.width);
- }
- if (toolTipWidth > offset.x) {
- offset.x = opts.width + Math.abs(opts._scrollDistance_ || 0) + arrowWidth + (toolTipWidth - opts.width);
- }
- if (toolTipOption.showArrow) {
- context.moveTo(offset.x, offset.y + 10 * opts.pix);
- context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pix + 5 * opts.pix);
- }
- context.arc(offset.x - arrowWidth - radius, offset.y + toolTipHeight - radius, radius, 0, Math.PI / 2, false);
- context.arc(
- offset.x - arrowWidth - Math.round(toolTipWidth) + radius,
- offset.y + toolTipHeight - radius,
- radius,
- Math.PI / 2,
- Math.PI,
- false
- );
- context.arc(offset.x - arrowWidth - Math.round(toolTipWidth) + radius, offset.y + radius, radius, -Math.PI, -Math.PI / 2, false);
- context.arc(offset.x - arrowWidth - radius, offset.y + radius, radius, -Math.PI / 2, 0, false);
- if (toolTipOption.showArrow) {
- context.lineTo(offset.x - arrowWidth, offset.y + 10 * opts.pix - 5 * opts.pix);
- context.lineTo(offset.x, offset.y + 10 * opts.pix);
- }
- } else {
- if (toolTipOption.showArrow) {
- context.moveTo(offset.x, offset.y + 10 * opts.pix);
- context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pix - 5 * opts.pix);
- }
- context.arc(offset.x + arrowWidth + radius, offset.y + radius, radius, -Math.PI, -Math.PI / 2, false);
- context.arc(
- offset.x + arrowWidth + Math.round(toolTipWidth) - radius,
- offset.y + radius,
- radius,
- -Math.PI / 2,
- 0,
- false
- );
- context.arc(
- offset.x + arrowWidth + Math.round(toolTipWidth) - radius,
- offset.y + toolTipHeight - radius,
- radius,
- 0,
- Math.PI / 2,
- false
- );
- context.arc(offset.x + arrowWidth + radius, offset.y + toolTipHeight - radius, radius, Math.PI / 2, Math.PI, false);
- if (toolTipOption.showArrow) {
- context.lineTo(offset.x + arrowWidth, offset.y + 10 * opts.pix + 5 * opts.pix);
- context.lineTo(offset.x, offset.y + 10 * opts.pix);
- }
- }
- context.closePath();
- context.fill();
- if (toolTipOption.borderWidth > 0) {
- context.stroke();
- }
- if (toolTipOption.legendShow) {
- textList.forEach(function(item, index) {
- if (item.color !== null) {
- context.beginPath();
- context.setFillStyle(item.color);
- var startX = offset.x + arrowWidth + 2 * boxPadding;
- var startY = offset.y + (lineHeight - fontSize) / 2 + lineHeight * index + boxPadding + 1;
- if (isOverRightBorder) {
- startX = offset.x - toolTipWidth - arrowWidth + 2 * boxPadding;
- }
- switch (item.legendShape) {
- case "line":
- context.moveTo(startX, startY + 0.5 * legendWidth - 2 * opts.pix);
- context.fillRect(startX, startY + 0.5 * legendWidth - 2 * opts.pix, legendWidth, 4 * opts.pix);
- break;
- case "triangle":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
- context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
- context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
- break;
- case "diamond":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
- context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * legendWidth);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth + 5 * opts.pix);
- context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * legendWidth);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
- break;
- case "circle":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth);
- context.arc(startX + 7.5 * opts.pix, startY + 0.5 * legendWidth, 5 * opts.pix, 0, 2 * Math.PI);
- break;
- case "rect":
- context.moveTo(startX, startY + 0.5 * legendWidth - 5 * opts.pix);
- context.fillRect(startX, startY + 0.5 * legendWidth - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
- break;
- case "square":
- context.moveTo(startX + 2 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix);
- context.fillRect(startX + 2 * opts.pix, startY + 0.5 * legendWidth - 5 * opts.pix, 10 * opts.pix, 10 * opts.pix);
- break;
- default:
- context.moveTo(startX, startY + 0.5 * legendWidth - 5 * opts.pix);
- context.fillRect(startX, startY + 0.5 * legendWidth - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
- }
- context.closePath();
- context.fill();
- }
- });
- }
- textList.forEach(function(item, index) {
- var startX = offset.x + arrowWidth + 2 * boxPadding + legendWidth + legendMarginRight;
- if (isOverRightBorder) {
- startX = offset.x - toolTipWidth - arrowWidth + 2 * boxPadding + legendWidth + legendMarginRight;
- }
- var startY = offset.y + lineHeight * index + (lineHeight - fontSize) / 2 - 1 + boxPadding + fontSize;
- context.beginPath();
- context.setFontSize(fontSize);
- context.setTextBaseline("normal");
- context.setFillStyle(toolTipOption.fontColor);
- context.fillText(item.text, startX, startY);
- context.closePath();
- context.stroke();
- });
- }
- function drawColumnDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- let columnOption = assign({}, {
- type: "group",
- width: eachSpacing / 2,
- meterBorder: 4,
- meterFillColor: "#FFFFFF",
- barBorderCircle: false,
- barBorderRadius: [],
- seriesGap: 2,
- linearType: "none",
- linearOpacity: 1,
- customColor: [],
- colorStop: 0,
- labelPosition: "outside"
- }, opts.extra.column);
- let calPoints = [];
- context.save();
- let leftNum = -2;
- let rightNum = xAxisPoints.length + 2;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
- rightNum = leftNum + opts.xAxis.itemCount + 4;
- }
- if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
- drawToolTipSplitArea(opts.tooltip.offset.x, opts, config2, context, eachSpacing);
- }
- columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- let zeroHeight = spacingValid * (0 - minRange) / (maxRange - minRange);
- let zeroPoints = opts.height - Math.round(zeroHeight) - opts.area[2];
- eachSeries.zeroPoints = zeroPoints;
- var data = eachSeries.data;
- switch (columnOption.type) {
- case "group":
- var points = getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, zeroPoints, process);
- var tooltipPoints = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- calPoints.push(tooltipPoints);
- points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config2, opts);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || eachSeries.color;
- var strokeColor = item.color || eachSeries.color;
- if (columnOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
- if (columnOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
- const left = startX;
- const top = item.y > zeroPoints ? zeroPoints : item.y;
- const width = item.width;
- const height2 = Math.abs(zeroPoints - item.y);
- if (columnOption.barBorderCircle) {
- columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
- }
- if (item.y > zeroPoints) {
- columnOption.barBorderRadius = [0, 0, width / 2, width / 2];
- }
- let [r0, r1, r2, r3] = columnOption.barBorderRadius;
- let minRadius = Math.min(width / 2, height2 / 2);
- r0 = r0 > minRadius ? minRadius : r0;
- r1 = r1 > minRadius ? minRadius : r1;
- r2 = r2 > minRadius ? minRadius : r2;
- r3 = r3 > minRadius ? minRadius : r3;
- r0 = r0 < 0 ? 0 : r0;
- r1 = r1 < 0 ? 0 : r1;
- r2 = r2 < 0 ? 0 : r2;
- r3 = r3 < 0 ? 0 : r3;
- context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
- context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
- context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
- context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
- } else {
- context.moveTo(startX, item.y);
- context.lineTo(startX + item.width, item.y);
- context.lineTo(startX + item.width, zeroPoints);
- context.lineTo(startX, zeroPoints);
- context.lineTo(startX, item.y);
- context.setLineWidth(1);
- context.setStrokeStyle(strokeColor);
- }
- context.setFillStyle(fillColor);
- context.closePath();
- context.fill();
- }
- }
- ;
- break;
- case "stack":
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- calPoints.push(points);
- points = fixColumeStackData(points, eachSpacing, series.length, seriesIndex, config2, opts, series);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- context.beginPath();
- var fillColor = item.color || eachSeries.color;
- var startX = item.x - item.width / 2 + 1;
- var height = opts.height - item.y - opts.area[2];
- var height0 = opts.height - item.y0 - opts.area[2];
- if (seriesIndex > 0) {
- height -= height0;
- }
- context.setFillStyle(fillColor);
- context.moveTo(startX, item.y);
- context.fillRect(startX, item.y, item.width, height);
- context.closePath();
- context.fill();
- }
- }
- ;
- break;
- case "meter":
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- calPoints.push(points);
- points = fixColumeMeterData(points, eachSpacing, series.length, seriesIndex, config2, opts, columnOption.meterBorder);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- context.beginPath();
- if (seriesIndex == 0 && columnOption.meterBorder > 0) {
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(columnOption.meterBorder * opts.pix);
- }
- if (seriesIndex == 0) {
- context.setFillStyle(columnOption.meterFillColor);
- } else {
- context.setFillStyle(item.color || eachSeries.color);
- }
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
- const left = startX;
- const top = item.y;
- const width = item.width;
- const height2 = zeroPoints - item.y;
- if (columnOption.barBorderCircle) {
- columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
- }
- let [r0, r1, r2, r3] = columnOption.barBorderRadius;
- let minRadius = Math.min(width / 2, height2 / 2);
- r0 = r0 > minRadius ? minRadius : r0;
- r1 = r1 > minRadius ? minRadius : r1;
- r2 = r2 > minRadius ? minRadius : r2;
- r3 = r3 > minRadius ? minRadius : r3;
- r0 = r0 < 0 ? 0 : r0;
- r1 = r1 < 0 ? 0 : r1;
- r2 = r2 < 0 ? 0 : r2;
- r3 = r3 < 0 ? 0 : r3;
- context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
- context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
- context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
- context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
- context.fill();
- } else {
- context.moveTo(startX, item.y);
- context.lineTo(startX + item.width, item.y);
- context.lineTo(startX + item.width, zeroPoints);
- context.lineTo(startX, zeroPoints);
- context.lineTo(startX, item.y);
- context.fill();
- }
- if (seriesIndex == 0 && columnOption.meterBorder > 0) {
- context.closePath();
- context.stroke();
- }
- }
- }
- break;
- }
- });
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- switch (columnOption.type) {
- case "group":
- var points = getColumnDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- points = fixColumeData(points, eachSpacing, series.length, seriesIndex, config2, opts);
- drawColumePointText(points, eachSeries, config2, context, opts);
- break;
- case "stack":
- var points = getStackDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- drawColumePointText(points, eachSeries, config2, context, opts);
- break;
- case "meter":
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- drawColumePointText(points, eachSeries, config2, context, opts);
- break;
- }
- });
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawMountDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- let mountOption = assign({}, {
- type: "mount",
- widthRatio: 1,
- borderWidth: 1,
- barBorderCircle: false,
- barBorderRadius: [],
- linearType: "none",
- linearOpacity: 1,
- customColor: [],
- colorStop: 0
- }, opts.extra.mount);
- mountOption.widthRatio = mountOption.widthRatio <= 0 ? 0 : mountOption.widthRatio;
- mountOption.widthRatio = mountOption.widthRatio >= 2 ? 2 : mountOption.widthRatio;
- let calPoints = [];
- context.save();
- let leftNum = -2;
- let rightNum = xAxisPoints.length + 2;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
- rightNum = leftNum + opts.xAxis.itemCount + 4;
- }
- mountOption.customColor = fillCustomColor(mountOption.linearType, mountOption.customColor, series, config2);
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[0]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- let zeroHeight = spacingValid * (0 - minRange) / (maxRange - minRange);
- let zeroPoints = opts.height - Math.round(zeroHeight) - opts.area[2];
- var points = getMountDataPoints(series, minRange, maxRange, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints, process);
- switch (mountOption.type) {
- case "bar":
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || series[i].color;
- var strokeColor = item.color || series[i].color;
- if (mountOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
- if (mountOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- if (mountOption.barBorderRadius && mountOption.barBorderRadius.length === 4 || mountOption.barBorderCircle === true) {
- const left = startX;
- const top = item.y > zeroPoints ? zeroPoints : item.y;
- const width = item.width;
- const height2 = Math.abs(zeroPoints - item.y);
- if (mountOption.barBorderCircle) {
- mountOption.barBorderRadius = [width / 2, width / 2, 0, 0];
- }
- if (item.y > zeroPoints) {
- mountOption.barBorderRadius = [0, 0, width / 2, width / 2];
- }
- let [r0, r1, r2, r3] = mountOption.barBorderRadius;
- let minRadius = Math.min(width / 2, height2 / 2);
- r0 = r0 > minRadius ? minRadius : r0;
- r1 = r1 > minRadius ? minRadius : r1;
- r2 = r2 > minRadius ? minRadius : r2;
- r3 = r3 > minRadius ? minRadius : r3;
- r0 = r0 < 0 ? 0 : r0;
- r1 = r1 < 0 ? 0 : r1;
- r2 = r2 < 0 ? 0 : r2;
- r3 = r3 < 0 ? 0 : r3;
- context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
- context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
- context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
- context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
- } else {
- context.moveTo(startX, item.y);
- context.lineTo(startX + item.width, item.y);
- context.lineTo(startX + item.width, zeroPoints);
- context.lineTo(startX, zeroPoints);
- context.lineTo(startX, item.y);
- }
- context.setStrokeStyle(strokeColor);
- context.setFillStyle(fillColor);
- if (mountOption.borderWidth > 0) {
- context.setLineWidth(mountOption.borderWidth * opts.pix);
- context.closePath();
- context.stroke();
- }
- context.fill();
- }
- }
- ;
- break;
- case "triangle":
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || series[i].color;
- var strokeColor = item.color || series[i].color;
- if (mountOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
- if (mountOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- context.moveTo(startX, zeroPoints);
- context.lineTo(item.x, item.y);
- context.lineTo(startX + item.width, zeroPoints);
- context.setStrokeStyle(strokeColor);
- context.setFillStyle(fillColor);
- if (mountOption.borderWidth > 0) {
- context.setLineWidth(mountOption.borderWidth * opts.pix);
- context.stroke();
- }
- context.fill();
- }
- }
- ;
- break;
- case "mount":
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || series[i].color;
- var strokeColor = item.color || series[i].color;
- if (mountOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
- if (mountOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- context.moveTo(startX, zeroPoints);
- context.bezierCurveTo(item.x - item.width / 4, zeroPoints, item.x - item.width / 4, item.y, item.x, item.y);
- context.bezierCurveTo(item.x + item.width / 4, item.y, item.x + item.width / 4, zeroPoints, startX + item.width, zeroPoints);
- context.setStrokeStyle(strokeColor);
- context.setFillStyle(fillColor);
- if (mountOption.borderWidth > 0) {
- context.setLineWidth(mountOption.borderWidth * opts.pix);
- context.stroke();
- }
- context.fill();
- }
- }
- ;
- break;
- case "sharp":
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - eachSpacing * mountOption.widthRatio / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || series[i].color;
- var strokeColor = item.color || series[i].color;
- if (mountOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, zeroPoints);
- if (mountOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(mountOption.colorStop, hexToRgb(mountOption.customColor[series[i].linearIndex], mountOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- context.moveTo(startX, zeroPoints);
- context.quadraticCurveTo(item.x - 0, zeroPoints - height / 4, item.x, item.y);
- context.quadraticCurveTo(item.x + 0, zeroPoints - height / 4, startX + item.width, zeroPoints);
- context.setStrokeStyle(strokeColor);
- context.setFillStyle(fillColor);
- if (mountOption.borderWidth > 0) {
- context.setLineWidth(mountOption.borderWidth * opts.pix);
- context.stroke();
- }
- context.fill();
- }
- }
- ;
- break;
- }
- if (opts.dataLabel !== false && process === 1) {
- let ranges2, minRange2, maxRange2;
- ranges2 = [].concat(opts.chartData.yAxisData.ranges[0]);
- minRange2 = ranges2.pop();
- maxRange2 = ranges2.shift();
- var points = getMountDataPoints(series, minRange2, maxRange2, xAxisPoints, eachSpacing, opts, mountOption, zeroPoints, process);
- drawMountPointText(points, series, config2, context, opts, zeroPoints);
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints: points,
- eachSpacing
- };
- }
- function drawBarDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let yAxisPoints = [];
- let eachSpacing = (opts.height - opts.area[0] - opts.area[2]) / opts.categories.length;
- for (let i = 0; i < opts.categories.length; i++) {
- yAxisPoints.push(opts.area[0] + eachSpacing / 2 + eachSpacing * i);
- }
- let columnOption = assign({}, {
- type: "group",
- width: eachSpacing / 2,
- meterBorder: 4,
- meterFillColor: "#FFFFFF",
- barBorderCircle: false,
- barBorderRadius: [],
- seriesGap: 2,
- linearType: "none",
- linearOpacity: 1,
- customColor: [],
- colorStop: 0
- }, opts.extra.bar);
- let calPoints = [];
- context.save();
- let leftNum = -2;
- let rightNum = yAxisPoints.length + 2;
- if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
- drawBarToolTipSplitArea(opts.tooltip.offset.y, opts, config2, context, eachSpacing);
- }
- columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.xAxisData.ranges);
- maxRange = ranges.pop();
- minRange = ranges.shift();
- var data = eachSeries.data;
- switch (columnOption.type) {
- case "group":
- var points = getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, process);
- var tooltipPoints = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- calPoints.push(tooltipPoints);
- points = fixBarData(points, eachSpacing, series.length, seriesIndex, config2, opts);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = opts.area[3];
- var startY = item.y - item.width / 2;
- var height = item.height;
- context.beginPath();
- var fillColor = item.color || eachSeries.color;
- var strokeColor = item.color || eachSeries.color;
- if (columnOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, item.x, item.y);
- if (columnOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle === true) {
- const left = startX;
- const width = item.width;
- const top = item.y - item.width / 2;
- const height2 = item.height;
- if (columnOption.barBorderCircle) {
- columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
- }
- let [r0, r1, r2, r3] = columnOption.barBorderRadius;
- let minRadius = Math.min(width / 2, height2 / 2);
- r0 = r0 > minRadius ? minRadius : r0;
- r1 = r1 > minRadius ? minRadius : r1;
- r2 = r2 > minRadius ? minRadius : r2;
- r3 = r3 > minRadius ? minRadius : r3;
- r0 = r0 < 0 ? 0 : r0;
- r1 = r1 < 0 ? 0 : r1;
- r2 = r2 < 0 ? 0 : r2;
- r3 = r3 < 0 ? 0 : r3;
- context.arc(left + r3, top + r3, r3, -Math.PI, -Math.PI / 2);
- context.arc(item.x - r0, top + r0, r0, -Math.PI / 2, 0);
- context.arc(item.x - r1, top + width - r1, r1, 0, Math.PI / 2);
- context.arc(left + r2, top + width - r2, r2, Math.PI / 2, Math.PI);
- } else {
- context.moveTo(startX, startY);
- context.lineTo(item.x, startY);
- context.lineTo(item.x, startY + item.width);
- context.lineTo(startX, startY + item.width);
- context.lineTo(startX, startY);
- context.setLineWidth(1);
- context.setStrokeStyle(strokeColor);
- }
- context.setFillStyle(fillColor);
- context.closePath();
- context.fill();
- }
- }
- ;
- break;
- case "stack":
- var points = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- calPoints.push(points);
- points = fixBarStackData(points, eachSpacing, series.length, seriesIndex, config2, opts, series);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- context.beginPath();
- var fillColor = item.color || eachSeries.color;
- var startX = item.x0;
- context.setFillStyle(fillColor);
- context.moveTo(startX, item.y - item.width / 2);
- context.fillRect(startX, item.y - item.width / 2, item.height, item.width);
- context.closePath();
- context.fill();
- }
- }
- ;
- break;
- }
- });
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.xAxisData.ranges);
- maxRange = ranges.pop();
- minRange = ranges.shift();
- var data = eachSeries.data;
- switch (columnOption.type) {
- case "group":
- var points = getBarDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, process);
- points = fixBarData(points, eachSpacing, series.length, seriesIndex, config2, opts);
- drawBarPointText(points, eachSeries, config2, context, opts);
- break;
- case "stack":
- var points = getBarStackDataPoints(data, minRange, maxRange, yAxisPoints, eachSpacing, opts, config2, seriesIndex, series, process);
- drawBarPointText(points, eachSeries, config2, context, opts);
- break;
- }
- });
- }
- return {
- yAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawCandleDataPoints(series, seriesMA, opts, config2, context) {
- var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
- var candleOption = assign({}, {
- color: {},
- average: {}
- }, opts.extra.candle);
- candleOption.color = assign({}, {
- upLine: "#f04864",
- upFill: "#f04864",
- downLine: "#2fc25b",
- downFill: "#2fc25b"
- }, candleOption.color);
- candleOption.average = assign({}, {
- show: false,
- name: [],
- day: [],
- color: config2.color
- }, candleOption.average);
- opts.extra.candle = candleOption;
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- let calPoints = [];
- context.save();
- let leftNum = -2;
- let rightNum = xAxisPoints.length + 2;
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
- rightNum = leftNum + opts.xAxis.itemCount + 4;
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- if (candleOption.average.show || seriesMA) {
- seriesMA.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- var splitPointList = splitPoints(points, eachSeries);
- for (let i = 0; i < splitPointList.length; i++) {
- let points2 = splitPointList[i];
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(1);
- if (points2.length === 1) {
- context.moveTo(points2[0].x, points2[0].y);
- context.arc(points2[0].x, points2[0].y, 1, 0, 2 * Math.PI);
- } else {
- context.moveTo(points2[0].x, points2[0].y);
- let startPoint = 0;
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- var ctrlPoint = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(
- ctrlPoint.ctrA.x,
- ctrlPoint.ctrA.y,
- ctrlPoint.ctrB.x,
- ctrlPoint.ctrB.y,
- item.x,
- item.y
- );
- }
- }
- context.moveTo(points2[0].x, points2[0].y);
- }
- context.closePath();
- context.stroke();
- }
- });
- }
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getCandleDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- calPoints.push(points);
- var splitPointList = splitPoints(points, eachSeries);
- for (let i = 0; i < splitPointList[0].length; i++) {
- if (i > leftNum && i < rightNum) {
- let item = splitPointList[0][i];
- context.beginPath();
- if (data[i][1] - data[i][0] > 0) {
- context.setStrokeStyle(candleOption.color.upLine);
- context.setFillStyle(candleOption.color.upFill);
- context.setLineWidth(1 * opts.pix);
- context.moveTo(item[3].x, item[3].y);
- context.lineTo(item[1].x, item[1].y);
- context.lineTo(item[1].x - eachSpacing / 4, item[1].y);
- context.lineTo(item[0].x - eachSpacing / 4, item[0].y);
- context.lineTo(item[0].x, item[0].y);
- context.lineTo(item[2].x, item[2].y);
- context.lineTo(item[0].x, item[0].y);
- context.lineTo(item[0].x + eachSpacing / 4, item[0].y);
- context.lineTo(item[1].x + eachSpacing / 4, item[1].y);
- context.lineTo(item[1].x, item[1].y);
- context.moveTo(item[3].x, item[3].y);
- } else {
- context.setStrokeStyle(candleOption.color.downLine);
- context.setFillStyle(candleOption.color.downFill);
- context.setLineWidth(1 * opts.pix);
- context.moveTo(item[3].x, item[3].y);
- context.lineTo(item[0].x, item[0].y);
- context.lineTo(item[0].x - eachSpacing / 4, item[0].y);
- context.lineTo(item[1].x - eachSpacing / 4, item[1].y);
- context.lineTo(item[1].x, item[1].y);
- context.lineTo(item[2].x, item[2].y);
- context.lineTo(item[1].x, item[1].y);
- context.lineTo(item[1].x + eachSpacing / 4, item[1].y);
- context.lineTo(item[0].x + eachSpacing / 4, item[0].y);
- context.lineTo(item[0].x, item[0].y);
- context.moveTo(item[3].x, item[3].y);
- }
- context.closePath();
- context.fill();
- context.stroke();
- }
- }
- });
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawAreaDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var areaOption = assign({}, {
- type: "straight",
- opacity: 0.2,
- addLine: false,
- width: 2,
- gradient: false,
- activeType: "none"
- }, opts.extra.area);
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- let endY = opts.height - opts.area[2];
- let calPoints = [];
- context.save();
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- let data = eachSeries.data;
- let points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- calPoints.push(points);
- let splitPointList = splitPoints(points, eachSeries);
- for (let i = 0; i < splitPointList.length; i++) {
- let points2 = splitPointList[i];
- context.beginPath();
- context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- if (areaOption.gradient) {
- let gradient = context.createLinearGradient(0, opts.area[0], 0, opts.height - opts.area[2]);
- gradient.addColorStop("0", hexToRgb(eachSeries.color, areaOption.opacity));
- gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
- context.setFillStyle(gradient);
- } else {
- context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- }
- context.setLineWidth(areaOption.width * opts.pix);
- if (points2.length > 1) {
- let firstPoint = points2[0];
- let lastPoint = points2[points2.length - 1];
- context.moveTo(firstPoint.x, firstPoint.y);
- let startPoint = 0;
- if (areaOption.type === "curve") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- let ctrlPoint = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
- }
- }
- ;
- }
- if (areaOption.type === "straight") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- if (areaOption.type === "step") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, points2[j - 1].y);
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- context.lineTo(lastPoint.x, endY);
- context.lineTo(firstPoint.x, endY);
- context.lineTo(firstPoint.x, firstPoint.y);
- } else {
- let item = points2[0];
- context.moveTo(item.x - eachSpacing / 2, item.y);
- }
- context.closePath();
- context.fill();
- if (areaOption.addLine) {
- if (eachSeries.lineType == "dash") {
- let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
- dashLength *= opts.pix;
- context.setLineDash([dashLength, dashLength]);
- }
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(areaOption.width * opts.pix);
- if (points2.length === 1) {
- context.moveTo(points2[0].x, points2[0].y);
- } else {
- context.moveTo(points2[0].x, points2[0].y);
- let startPoint = 0;
- if (areaOption.type === "curve") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- let ctrlPoint = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
- }
- }
- ;
- }
- if (areaOption.type === "straight") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- if (areaOption.type === "step") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, points2[j - 1].y);
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- context.moveTo(points2[0].x, points2[0].y);
- }
- context.stroke();
- context.setLineDash([]);
- }
- }
- if (opts.dataPointShape !== false) {
- drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
- }
- drawActivePoint(points, eachSeries.color, eachSeries.pointShape, context, opts, areaOption, seriesIndex);
- });
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- drawPointText(points, eachSeries, config2, context, opts);
- });
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawScatterDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var scatterOption = assign({}, {
- type: "circle"
- }, opts.extra.scatter);
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- var calPoints = [];
- context.save();
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setFillStyle(eachSeries.color);
- context.setLineWidth(1 * opts.pix);
- var shape = eachSeries.pointShape;
- if (shape === "diamond") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y);
- context.lineTo(item.x, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "circle") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x + 2.5 * opts.pix, item.y);
- context.arc(item.x, item.y, 3 * opts.pix, 0, 2 * Math.PI, false);
- }
- });
- } else if (shape === "square") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x - 3.5, item.y - 3.5);
- context.rect(item.x - 3.5, item.y - 3.5, 7, 7);
- }
- });
- } else if (shape === "triangle") {
- points.forEach(function(item, index) {
- if (item !== null) {
- context.moveTo(item.x, item.y - 4.5);
- context.lineTo(item.x - 4.5, item.y + 4.5);
- context.lineTo(item.x + 4.5, item.y + 4.5);
- context.lineTo(item.x, item.y - 4.5);
- }
- });
- } else if (shape === "triangle") {
- return;
- }
- context.closePath();
- context.fill();
- context.stroke();
- });
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- drawPointText(points, eachSeries, config2, context, opts);
- });
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawBubbleDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var bubbleOption = assign({}, {
- opacity: 1,
- border: 2
- }, opts.extra.bubble);
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- var calPoints = [];
- context.save();
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(bubbleOption.border * opts.pix);
- context.setFillStyle(hexToRgb(eachSeries.color, bubbleOption.opacity));
- points.forEach(function(item, index) {
- context.moveTo(item.x + item.r, item.y);
- context.arc(item.x, item.y, item.r * opts.pix, 0, 2 * Math.PI, false);
- });
- context.closePath();
- context.fill();
- context.stroke();
- if (opts.dataLabel !== false && process === 1) {
- points.forEach(function(item, index) {
- context.beginPath();
- var fontSize = eachSeries.textSize * opts.pix || config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(eachSeries.textColor || "#FFFFFF");
- context.setTextAlign("center");
- context.fillText(String(item.t), item.x, item.y + fontSize / 2);
- context.closePath();
- context.stroke();
- context.setTextAlign("left");
- });
- }
- });
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawLineDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var lineOption = assign({}, {
- type: "straight",
- width: 2,
- activeType: "none",
- linearType: "none",
- onShadow: false,
- animation: "vertical"
- }, opts.extra.line);
- lineOption.width *= opts.pix;
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- var calPoints = [];
- context.save();
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- series.forEach(function(eachSeries, seriesIndex) {
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.moveTo(-1e4, -1e4);
- context.lineTo(-10001, -10001);
- context.stroke();
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getLineDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, lineOption, process);
- calPoints.push(points);
- var splitPointList = splitPoints(points, eachSeries);
- if (eachSeries.lineType == "dash") {
- let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
- dashLength *= opts.pix;
- context.setLineDash([dashLength, dashLength]);
- }
- context.beginPath();
- var strokeColor = eachSeries.color;
- if (lineOption.linearType !== "none" && eachSeries.linearColor && eachSeries.linearColor.length > 0) {
- var grd = context.createLinearGradient(opts.chartData.xAxisData.startX, opts.height / 2, opts.chartData.xAxisData.endX, opts.height / 2);
- for (var i = 0; i < eachSeries.linearColor.length; i++) {
- grd.addColorStop(eachSeries.linearColor[i][0], hexToRgb(eachSeries.linearColor[i][1], 1));
- }
- strokeColor = grd;
- }
- context.setStrokeStyle(strokeColor);
- if (lineOption.onShadow == true && eachSeries.setShadow && eachSeries.setShadow.length > 0) {
- context.setShadow(eachSeries.setShadow[0], eachSeries.setShadow[1], eachSeries.setShadow[2], eachSeries.setShadow[3]);
- } else {
- context.setShadow(0, 0, 0, "rgba(0,0,0,0)");
- }
- context.setLineWidth(lineOption.width);
- splitPointList.forEach(function(points2, index) {
- if (points2.length === 1) {
- context.moveTo(points2[0].x, points2[0].y);
- } else {
- context.moveTo(points2[0].x, points2[0].y);
- let startPoint = 0;
- if (lineOption.type === "curve") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- var ctrlPoint = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
- }
- }
- ;
- }
- if (lineOption.type === "straight") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- if (lineOption.type === "step") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, points2[j - 1].y);
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- context.moveTo(points2[0].x, points2[0].y);
- }
- });
- context.stroke();
- context.setLineDash([]);
- if (opts.dataPointShape !== false) {
- drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
- }
- drawActivePoint(points, eachSeries.color, eachSeries.pointShape, context, opts, lineOption);
- });
- if (opts.dataLabel !== false && process === 1) {
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- drawPointText(points, eachSeries, config2, context, opts);
- });
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawMixDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, eachSpacing = xAxisData.eachSpacing;
- let columnOption = assign({}, {
- width: eachSpacing / 2,
- barBorderCircle: false,
- barBorderRadius: [],
- seriesGap: 2,
- linearType: "none",
- linearOpacity: 1,
- customColor: [],
- colorStop: 0
- }, opts.extra.mix.column);
- let areaOption = assign({}, {
- opacity: 0.2,
- gradient: false
- }, opts.extra.mix.area);
- let lineOption = assign({}, {
- width: 2
- }, opts.extra.mix.line);
- let endY = opts.height - opts.area[2];
- let calPoints = [];
- var columnIndex = 0;
- var columnLength = 0;
- series.forEach(function(eachSeries, seriesIndex) {
- if (eachSeries.type == "column") {
- columnLength += 1;
- }
- });
- context.save();
- let leftNum = -2;
- let rightNum = xAxisPoints.length + 2;
- let leftSpace = 0;
- let rightSpace = opts.width + eachSpacing;
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- leftNum = Math.floor(-opts._scrollDistance_ / eachSpacing) - 2;
- rightNum = leftNum + opts.xAxis.itemCount + 4;
- leftSpace = -opts._scrollDistance_ - eachSpacing * 2 + opts.area[3];
- rightSpace = leftSpace + (opts.xAxis.itemCount + 4) * eachSpacing;
- }
- columnOption.customColor = fillCustomColor(columnOption.linearType, columnOption.customColor, series, config2);
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- calPoints.push(points);
- if (eachSeries.type == "column") {
- points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config2, opts);
- for (let i = 0; i < points.length; i++) {
- let item = points[i];
- if (item !== null && i > leftNum && i < rightNum) {
- var startX = item.x - item.width / 2;
- var height = opts.height - item.y - opts.area[2];
- context.beginPath();
- var fillColor = item.color || eachSeries.color;
- var strokeColor = item.color || eachSeries.color;
- if (columnOption.linearType !== "none") {
- var grd = context.createLinearGradient(startX, item.y, startX, opts.height - opts.area[2]);
- if (columnOption.linearType == "opacity") {
- grd.addColorStop(0, hexToRgb(fillColor, columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- } else {
- grd.addColorStop(0, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(columnOption.colorStop, hexToRgb(columnOption.customColor[eachSeries.linearIndex], columnOption.linearOpacity));
- grd.addColorStop(1, hexToRgb(fillColor, 1));
- }
- fillColor = grd;
- }
- if (columnOption.barBorderRadius && columnOption.barBorderRadius.length === 4 || columnOption.barBorderCircle) {
- const left = startX;
- const top = item.y;
- const width = item.width;
- const height2 = opts.height - opts.area[2] - item.y;
- if (columnOption.barBorderCircle) {
- columnOption.barBorderRadius = [width / 2, width / 2, 0, 0];
- }
- let [r0, r1, r2, r3] = columnOption.barBorderRadius;
- let minRadius = Math.min(width / 2, height2 / 2);
- r0 = r0 > minRadius ? minRadius : r0;
- r1 = r1 > minRadius ? minRadius : r1;
- r2 = r2 > minRadius ? minRadius : r2;
- r3 = r3 > minRadius ? minRadius : r3;
- r0 = r0 < 0 ? 0 : r0;
- r1 = r1 < 0 ? 0 : r1;
- r2 = r2 < 0 ? 0 : r2;
- r3 = r3 < 0 ? 0 : r3;
- context.arc(left + r0, top + r0, r0, -Math.PI, -Math.PI / 2);
- context.arc(left + width - r1, top + r1, r1, -Math.PI / 2, 0);
- context.arc(left + width - r2, top + height2 - r2, r2, 0, Math.PI / 2);
- context.arc(left + r3, top + height2 - r3, r3, Math.PI / 2, Math.PI);
- } else {
- context.moveTo(startX, item.y);
- context.lineTo(startX + item.width, item.y);
- context.lineTo(startX + item.width, opts.height - opts.area[2]);
- context.lineTo(startX, opts.height - opts.area[2]);
- context.lineTo(startX, item.y);
- context.setLineWidth(1);
- context.setStrokeStyle(strokeColor);
- }
- context.setFillStyle(fillColor);
- context.closePath();
- context.fill();
- }
- }
- columnIndex += 1;
- }
- if (eachSeries.type == "area") {
- let splitPointList2 = splitPoints(points, eachSeries);
- for (let i = 0; i < splitPointList2.length; i++) {
- let points2 = splitPointList2[i];
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setStrokeStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- if (areaOption.gradient) {
- let gradient = context.createLinearGradient(0, opts.area[0], 0, opts.height - opts.area[2]);
- gradient.addColorStop("0", hexToRgb(eachSeries.color, areaOption.opacity));
- gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
- context.setFillStyle(gradient);
- } else {
- context.setFillStyle(hexToRgb(eachSeries.color, areaOption.opacity));
- }
- context.setLineWidth(2 * opts.pix);
- if (points2.length > 1) {
- var firstPoint = points2[0];
- let lastPoint = points2[points2.length - 1];
- context.moveTo(firstPoint.x, firstPoint.y);
- let startPoint = 0;
- if (eachSeries.style === "curve") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- var ctrlPoint = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(ctrlPoint.ctrA.x, ctrlPoint.ctrA.y, ctrlPoint.ctrB.x, ctrlPoint.ctrB.y, item.x, item.y);
- }
- }
- ;
- } else {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, item.y);
- }
- }
- ;
- }
- context.lineTo(lastPoint.x, endY);
- context.lineTo(firstPoint.x, endY);
- context.lineTo(firstPoint.x, firstPoint.y);
- } else {
- let item = points2[0];
- context.moveTo(item.x - eachSpacing / 2, item.y);
- }
- context.closePath();
- context.fill();
- }
- }
- if (eachSeries.type == "line") {
- var splitPointList = splitPoints(points, eachSeries);
- splitPointList.forEach(function(points2, index) {
- if (eachSeries.lineType == "dash") {
- let dashLength = eachSeries.dashLength ? eachSeries.dashLength : 8;
- dashLength *= opts.pix;
- context.setLineDash([dashLength, dashLength]);
- }
- context.beginPath();
- context.setStrokeStyle(eachSeries.color);
- context.setLineWidth(lineOption.width * opts.pix);
- if (points2.length === 1) {
- context.moveTo(points2[0].x, points2[0].y);
- } else {
- context.moveTo(points2[0].x, points2[0].y);
- let startPoint = 0;
- if (eachSeries.style == "curve") {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- var ctrlPoint2 = createCurveControlPoints(points2, j - 1);
- context.bezierCurveTo(
- ctrlPoint2.ctrA.x,
- ctrlPoint2.ctrA.y,
- ctrlPoint2.ctrB.x,
- ctrlPoint2.ctrB.y,
- item.x,
- item.y
- );
- }
- }
- } else {
- for (let j = 0; j < points2.length; j++) {
- let item = points2[j];
- if (startPoint == 0 && item.x > leftSpace) {
- context.moveTo(item.x, item.y);
- startPoint = 1;
- }
- if (j > 0 && item.x > leftSpace && item.x < rightSpace) {
- context.lineTo(item.x, item.y);
- }
- }
- }
- context.moveTo(points2[0].x, points2[0].y);
- }
- context.stroke();
- context.setLineDash([]);
- });
- }
- if (eachSeries.type == "point") {
- eachSeries.addPoint = true;
- }
- if (eachSeries.addPoint == true && eachSeries.type !== "column") {
- drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
- }
- });
- if (opts.dataLabel !== false && process === 1) {
- var columnIndex = 0;
- series.forEach(function(eachSeries, seriesIndex) {
- let ranges, minRange, maxRange;
- ranges = [].concat(opts.chartData.yAxisData.ranges[eachSeries.index]);
- minRange = ranges.pop();
- maxRange = ranges.shift();
- var data = eachSeries.data;
- var points = getDataPoints(data, minRange, maxRange, xAxisPoints, eachSpacing, opts, config2, process);
- if (eachSeries.type !== "column") {
- drawPointText(points, eachSeries, config2, context, opts);
- } else {
- points = fixColumeData(points, eachSpacing, columnLength, columnIndex, config2, opts);
- drawPointText(points, eachSeries, config2, context, opts);
- columnIndex += 1;
- }
- });
- }
- context.restore();
- return {
- xAxisPoints,
- calPoints,
- eachSpacing
- };
- }
- function drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints) {
- var toolTipOption = opts.extra.tooltip || {};
- 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")) {
- drawToolTipHorizentalLine(opts, config2, context, eachSpacing, xAxisPoints);
- }
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0 && opts.enableScroll === true) {
- context.translate(opts._scrollDistance_, 0);
- }
- if (opts.tooltip && opts.tooltip.textList && opts.tooltip.textList.length && process === 1) {
- drawToolTip(opts.tooltip.textList, opts.tooltip.offset, opts, config2, context, eachSpacing, xAxisPoints);
- }
- context.restore();
- }
- function drawXAxis(categories, opts, config2, context) {
- let xAxisData = opts.chartData.xAxisData, xAxisPoints = xAxisData.xAxisPoints, startX = xAxisData.startX, endX = xAxisData.endX, eachSpacing = xAxisData.eachSpacing;
- var boundaryGap = "center";
- if (opts.type == "bar" || opts.type == "line" || opts.type == "area" || opts.type == "scatter" || opts.type == "bubble") {
- boundaryGap = opts.xAxis.boundaryGap;
- }
- var startY = opts.height - opts.area[2];
- var endY = opts.area[0];
- if (opts.enableScroll && opts.xAxis.scrollShow) {
- var scrollY = opts.height - opts.area[2] + config2.xAxisHeight;
- var scrollScreenWidth = endX - startX;
- var scrollTotalWidth = eachSpacing * (xAxisPoints.length - 1);
- if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
- if (opts.extra.mount.widthRatio > 2)
- opts.extra.mount.widthRatio = 2;
- scrollTotalWidth += (opts.extra.mount.widthRatio - 1) * eachSpacing;
- }
- var scrollWidth = scrollScreenWidth * scrollScreenWidth / scrollTotalWidth;
- var scrollLeft = 0;
- if (opts._scrollDistance_) {
- scrollLeft = -opts._scrollDistance_ * scrollScreenWidth / scrollTotalWidth;
- }
- context.beginPath();
- context.setLineCap("round");
- context.setLineWidth(6 * opts.pix);
- context.setStrokeStyle(opts.xAxis.scrollBackgroundColor || "#EFEBEF");
- context.moveTo(startX, scrollY);
- context.lineTo(endX, scrollY);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.setLineCap("round");
- context.setLineWidth(6 * opts.pix);
- context.setStrokeStyle(opts.xAxis.scrollColor || "#A6A6A6");
- context.moveTo(startX + scrollLeft, scrollY);
- context.lineTo(startX + scrollLeft + scrollWidth, scrollY);
- context.stroke();
- context.closePath();
- context.setLineCap("butt");
- }
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
- context.translate(opts._scrollDistance_, 0);
- }
- if (opts.xAxis.calibration === true) {
- context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
- context.setLineCap("butt");
- context.setLineWidth(1 * opts.pix);
- xAxisPoints.forEach(function(item, index) {
- if (index > 0) {
- context.beginPath();
- context.moveTo(item - eachSpacing / 2, startY);
- context.lineTo(item - eachSpacing / 2, startY + 3 * opts.pix);
- context.closePath();
- context.stroke();
- }
- });
- }
- if (opts.xAxis.disableGrid !== true) {
- context.setStrokeStyle(opts.xAxis.gridColor || "#cccccc");
- context.setLineCap("butt");
- context.setLineWidth(1 * opts.pix);
- if (opts.xAxis.gridType == "dash") {
- context.setLineDash([opts.xAxis.dashLength * opts.pix, opts.xAxis.dashLength * opts.pix]);
- }
- opts.xAxis.gridEval = opts.xAxis.gridEval || 1;
- xAxisPoints.forEach(function(item, index) {
- if (index % opts.xAxis.gridEval == 0) {
- context.beginPath();
- context.moveTo(item, startY);
- context.lineTo(item, endY);
- context.stroke();
- }
- });
- context.setLineDash([]);
- }
- if (opts.xAxis.disabled !== true) {
- let maxXAxisListLength = categories.length;
- if (opts.xAxis.labelCount) {
- if (opts.xAxis.itemCount) {
- maxXAxisListLength = Math.ceil(categories.length / opts.xAxis.itemCount * opts.xAxis.labelCount);
- } else {
- maxXAxisListLength = opts.xAxis.labelCount;
- }
- maxXAxisListLength -= 1;
- }
- let ratio = Math.ceil(categories.length / maxXAxisListLength);
- let newCategories = [];
- let cgLength = categories.length;
- for (let i = 0; i < cgLength; i++) {
- if (i % ratio !== 0) {
- newCategories.push("");
- } else {
- newCategories.push(categories[i]);
- }
- }
- newCategories[cgLength - 1] = categories[cgLength - 1];
- var xAxisFontSize = opts.xAxis.fontSize * opts.pix || config2.fontSize;
- if (config2._xAxisTextAngle_ === 0) {
- newCategories.forEach(function(item, index) {
- var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item, index, opts) : item;
- var offset = -measureText(String(xitem), xAxisFontSize, context) / 2;
- if (boundaryGap == "center") {
- offset += eachSpacing / 2;
- }
- var scrollHeight = 0;
- if (opts.xAxis.scrollShow) {
- scrollHeight = 6 * opts.pix;
- }
- var _scrollDistance_ = opts._scrollDistance_ || 0;
- var truePoints = boundaryGap == "center" ? xAxisPoints[index] + eachSpacing / 2 : xAxisPoints[index];
- if (truePoints - Math.abs(_scrollDistance_) >= opts.area[3] - 1 && truePoints - Math.abs(_scrollDistance_) <= opts.width - opts.area[1] + 1) {
- context.beginPath();
- context.setFontSize(xAxisFontSize);
- context.setFillStyle(opts.xAxis.fontColor || opts.fontColor);
- 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);
- context.closePath();
- context.stroke();
- }
- });
- } else {
- newCategories.forEach(function(item, index) {
- var xitem = opts.xAxis.formatter ? opts.xAxis.formatter(item) : item;
- var _scrollDistance_ = opts._scrollDistance_ || 0;
- var truePoints = boundaryGap == "center" ? xAxisPoints[index] + eachSpacing / 2 : xAxisPoints[index];
- if (truePoints - Math.abs(_scrollDistance_) >= opts.area[3] - 1 && truePoints - Math.abs(_scrollDistance_) <= opts.width - opts.area[1] + 1) {
- context.save();
- context.beginPath();
- context.setFontSize(xAxisFontSize);
- context.setFillStyle(opts.xAxis.fontColor || opts.fontColor);
- var textWidth = measureText(String(xitem), xAxisFontSize, context);
- var offsetX = xAxisPoints[index];
- if (boundaryGap == "center") {
- offsetX = xAxisPoints[index] + eachSpacing / 2;
- }
- var scrollHeight = 0;
- if (opts.xAxis.scrollShow) {
- scrollHeight = 6 * opts.pix;
- }
- var offsetY = startY + opts.xAxis.marginTop * opts.pix + xAxisFontSize - xAxisFontSize * Math.abs(Math.sin(config2._xAxisTextAngle_));
- if (opts.xAxis.rotateAngle < 0) {
- offsetX -= xAxisFontSize / 2;
- textWidth = 0;
- } else {
- offsetX += xAxisFontSize / 2;
- textWidth = -textWidth;
- }
- context.translate(offsetX, offsetY);
- context.rotate(-1 * config2._xAxisTextAngle_);
- context.fillText(String(xitem), textWidth, 0);
- context.closePath();
- context.stroke();
- context.restore();
- }
- });
- }
- }
- context.restore();
- if (opts.xAxis.title) {
- context.beginPath();
- context.setFontSize(opts.xAxis.titleFontSize * opts.pix);
- context.setFillStyle(opts.xAxis.titleFontColor);
- 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);
- context.closePath();
- context.stroke();
- }
- if (opts.xAxis.axisLine) {
- context.beginPath();
- context.setStrokeStyle(opts.xAxis.axisLineColor);
- context.setLineWidth(1 * opts.pix);
- context.moveTo(startX, opts.height - opts.area[2]);
- context.lineTo(endX, opts.height - opts.area[2]);
- context.stroke();
- }
- }
- function drawYAxisGrid(categories, opts, config2, context) {
- if (opts.yAxis.disableGrid === true) {
- return;
- }
- let spacingValid = opts.height - opts.area[0] - opts.area[2];
- let eachSpacing = spacingValid / opts.yAxis.splitNumber;
- let startX = opts.area[3];
- let xAxisPoints = opts.chartData.xAxisData.xAxisPoints, xAxiseachSpacing = opts.chartData.xAxisData.eachSpacing;
- let TotalWidth = xAxiseachSpacing * (xAxisPoints.length - 1);
- if (opts.type == "mount" && opts.extra && opts.extra.mount && opts.extra.mount.widthRatio && opts.extra.mount.widthRatio > 1) {
- if (opts.extra.mount.widthRatio > 2)
- opts.extra.mount.widthRatio = 2;
- TotalWidth += (opts.extra.mount.widthRatio - 1) * xAxiseachSpacing;
- }
- let endX = startX + TotalWidth;
- let points = [];
- let startY = 1;
- if (opts.xAxis.axisLine === false) {
- startY = 0;
- }
- for (let i = startY; i < opts.yAxis.splitNumber + 1; i++) {
- points.push(opts.height - opts.area[2] - eachSpacing * i);
- }
- context.save();
- if (opts._scrollDistance_ && opts._scrollDistance_ !== 0) {
- context.translate(opts._scrollDistance_, 0);
- }
- if (opts.yAxis.gridType == "dash") {
- context.setLineDash([opts.yAxis.dashLength * opts.pix, opts.yAxis.dashLength * opts.pix]);
- }
- context.setStrokeStyle(opts.yAxis.gridColor);
- context.setLineWidth(1 * opts.pix);
- points.forEach(function(item, index) {
- context.beginPath();
- context.moveTo(startX, item);
- context.lineTo(endX, item);
- context.stroke();
- });
- context.setLineDash([]);
- context.restore();
- }
- function drawYAxis(series, opts, config2, context) {
- if (opts.yAxis.disabled === true) {
- return;
- }
- var spacingValid = opts.height - opts.area[0] - opts.area[2];
- var eachSpacing = spacingValid / opts.yAxis.splitNumber;
- var startX = opts.area[3];
- var endX = opts.width - opts.area[1];
- var endY = opts.height - opts.area[2];
- context.beginPath();
- context.setFillStyle(opts.background);
- if (opts.enableScroll == true && opts.xAxis.scrollPosition && opts.xAxis.scrollPosition !== "left") {
- context.fillRect(0, 0, startX, endY + 2 * opts.pix);
- }
- if (opts.enableScroll == true && opts.xAxis.scrollPosition && opts.xAxis.scrollPosition !== "right") {
- context.fillRect(endX, 0, opts.width, endY + 2 * opts.pix);
- }
- context.closePath();
- context.stroke();
- let tStartLeft = opts.area[3];
- let tStartRight = opts.width - opts.area[1];
- let tStartCenter = opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2;
- if (opts.yAxis.data) {
- for (let i = 0; i < opts.yAxis.data.length; i++) {
- let yData = opts.yAxis.data[i];
- var points = [];
- if (yData.type === "categories") {
- for (let i2 = 0; i2 <= yData.categories.length; i2++) {
- points.push(opts.area[0] + spacingValid / yData.categories.length / 2 + spacingValid / yData.categories.length * i2);
- }
- } else {
- for (let i2 = 0; i2 <= opts.yAxis.splitNumber; i2++) {
- points.push(opts.area[0] + eachSpacing * i2);
- }
- }
- if (yData.disabled !== true) {
- let rangesFormat = opts.chartData.yAxisData.rangesFormat[i];
- let yAxisFontSize = yData.fontSize ? yData.fontSize * opts.pix : config2.fontSize;
- let yAxisWidth = opts.chartData.yAxisData.yAxisWidth[i];
- let textAlign = yData.textAlign || "right";
- rangesFormat.forEach(function(item, index) {
- var pos = points[index];
- context.beginPath();
- context.setFontSize(yAxisFontSize);
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(yData.axisLineColor || "#cccccc");
- context.setFillStyle(yData.fontColor || opts.fontColor);
- let tmpstrat = 0;
- let gapwidth = 4 * opts.pix;
- if (yAxisWidth.position == "left") {
- if (yData.calibration == true) {
- context.moveTo(tStartLeft, pos);
- context.lineTo(tStartLeft - 3 * opts.pix, pos);
- gapwidth += 3 * opts.pix;
- }
- switch (textAlign) {
- case "left":
- context.setTextAlign("left");
- tmpstrat = tStartLeft - yAxisWidth.width;
- break;
- case "right":
- context.setTextAlign("right");
- tmpstrat = tStartLeft - gapwidth;
- break;
- default:
- context.setTextAlign("center");
- tmpstrat = tStartLeft - yAxisWidth.width / 2;
- }
- context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
- } else if (yAxisWidth.position == "right") {
- if (yData.calibration == true) {
- context.moveTo(tStartRight, pos);
- context.lineTo(tStartRight + 3 * opts.pix, pos);
- gapwidth += 3 * opts.pix;
- }
- switch (textAlign) {
- case "left":
- context.setTextAlign("left");
- tmpstrat = tStartRight + gapwidth;
- break;
- case "right":
- context.setTextAlign("right");
- tmpstrat = tStartRight + yAxisWidth.width;
- break;
- default:
- context.setTextAlign("center");
- tmpstrat = tStartRight + yAxisWidth.width / 2;
- }
- context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
- } else if (yAxisWidth.position == "center") {
- if (yData.calibration == true) {
- context.moveTo(tStartCenter, pos);
- context.lineTo(tStartCenter - 3 * opts.pix, pos);
- gapwidth += 3 * opts.pix;
- }
- switch (textAlign) {
- case "left":
- context.setTextAlign("left");
- tmpstrat = tStartCenter - yAxisWidth.width;
- break;
- case "right":
- context.setTextAlign("right");
- tmpstrat = tStartCenter - gapwidth;
- break;
- default:
- context.setTextAlign("center");
- tmpstrat = tStartCenter - yAxisWidth.width / 2;
- }
- context.fillText(String(item), tmpstrat, pos + yAxisFontSize / 2 - 3 * opts.pix);
- }
- context.closePath();
- context.stroke();
- context.setTextAlign("left");
- });
- if (yData.axisLine !== false) {
- context.beginPath();
- context.setStrokeStyle(yData.axisLineColor || "#cccccc");
- context.setLineWidth(1 * opts.pix);
- if (yAxisWidth.position == "left") {
- context.moveTo(tStartLeft, opts.height - opts.area[2]);
- context.lineTo(tStartLeft, opts.area[0]);
- } else if (yAxisWidth.position == "right") {
- context.moveTo(tStartRight, opts.height - opts.area[2]);
- context.lineTo(tStartRight, opts.area[0]);
- } else if (yAxisWidth.position == "center") {
- context.moveTo(tStartCenter, opts.height - opts.area[2]);
- context.lineTo(tStartCenter, opts.area[0]);
- }
- context.stroke();
- }
- if (opts.yAxis.showTitle) {
- let titleFontSize = yData.titleFontSize * opts.pix || config2.fontSize;
- let title = yData.title;
- context.beginPath();
- context.setFontSize(titleFontSize);
- context.setFillStyle(yData.titleFontColor || opts.fontColor);
- if (yAxisWidth.position == "left") {
- context.fillText(title, tStartLeft - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
- } else if (yAxisWidth.position == "right") {
- context.fillText(title, tStartRight - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
- } else if (yAxisWidth.position == "center") {
- context.fillText(title, tStartCenter - measureText(title, titleFontSize, context) / 2 + (yData.titleOffsetX || 0), opts.area[0] - (10 - (yData.titleOffsetY || 0)) * opts.pix);
- }
- context.closePath();
- context.stroke();
- }
- if (yAxisWidth.position == "left") {
- tStartLeft -= yAxisWidth.width + opts.yAxis.padding * opts.pix;
- } else {
- tStartRight += yAxisWidth.width + opts.yAxis.padding * opts.pix;
- }
- }
- }
- }
- }
- function drawLegend(series, opts, config2, context, chartData) {
- if (opts.legend.show === false) {
- return;
- }
- let legendData = chartData.legendData;
- let legendList = legendData.points;
- let legendArea = legendData.area;
- let padding = opts.legend.padding * opts.pix;
- let fontSize = opts.legend.fontSize * opts.pix;
- let shapeWidth = 15 * opts.pix;
- let shapeRight = 5 * opts.pix;
- let itemGap = opts.legend.itemGap * opts.pix;
- let lineHeight = Math.max(opts.legend.lineHeight * opts.pix, fontSize);
- context.beginPath();
- context.setLineWidth(opts.legend.borderWidth * opts.pix);
- context.setStrokeStyle(opts.legend.borderColor);
- context.setFillStyle(opts.legend.backgroundColor);
- context.moveTo(legendArea.start.x, legendArea.start.y);
- context.rect(legendArea.start.x, legendArea.start.y, legendArea.width, legendArea.height);
- context.closePath();
- context.fill();
- context.stroke();
- legendList.forEach(function(itemList, listIndex) {
- let width = 0;
- let height = 0;
- width = legendData.widthArr[listIndex];
- height = legendData.heightArr[listIndex];
- let startX = 0;
- let startY = 0;
- if (opts.legend.position == "top" || opts.legend.position == "bottom") {
- switch (opts.legend.float) {
- case "left":
- startX = legendArea.start.x + padding;
- break;
- case "right":
- startX = legendArea.start.x + legendArea.width - width;
- break;
- default:
- startX = legendArea.start.x + (legendArea.width - width) / 2;
- }
- startY = legendArea.start.y + padding + listIndex * lineHeight;
- } else {
- if (listIndex == 0) {
- width = 0;
- } else {
- width = legendData.widthArr[listIndex - 1];
- }
- startX = legendArea.start.x + padding + width;
- startY = legendArea.start.y + padding + (legendArea.height - height) / 2;
- }
- context.setFontSize(config2.fontSize);
- for (let i = 0; i < itemList.length; i++) {
- let item = itemList[i];
- item.area = [0, 0, 0, 0];
- item.area[0] = startX;
- item.area[1] = startY;
- item.area[3] = startY + lineHeight;
- context.beginPath();
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(item.show ? item.color : opts.legend.hiddenColor);
- context.setFillStyle(item.show ? item.color : opts.legend.hiddenColor);
- switch (item.legendShape) {
- case "line":
- context.moveTo(startX, startY + 0.5 * lineHeight - 2 * opts.pix);
- context.fillRect(startX, startY + 0.5 * lineHeight - 2 * opts.pix, 15 * opts.pix, 4 * opts.pix);
- break;
- case "triangle":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
- context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
- context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
- break;
- case "diamond":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
- context.lineTo(startX + 2.5 * opts.pix, startY + 0.5 * lineHeight);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight + 5 * opts.pix);
- context.lineTo(startX + 12.5 * opts.pix, startY + 0.5 * lineHeight);
- context.lineTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
- break;
- case "circle":
- context.moveTo(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight);
- context.arc(startX + 7.5 * opts.pix, startY + 0.5 * lineHeight, 5 * opts.pix, 0, 2 * Math.PI);
- break;
- case "rect":
- context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pix);
- context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
- break;
- case "square":
- context.moveTo(startX + 5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix);
- context.fillRect(startX + 5 * opts.pix, startY + 0.5 * lineHeight - 5 * opts.pix, 10 * opts.pix, 10 * opts.pix);
- break;
- case "none":
- break;
- default:
- context.moveTo(startX, startY + 0.5 * lineHeight - 5 * opts.pix);
- context.fillRect(startX, startY + 0.5 * lineHeight - 5 * opts.pix, 15 * opts.pix, 10 * opts.pix);
- }
- context.closePath();
- context.fill();
- context.stroke();
- startX += shapeWidth + shapeRight;
- let fontTrans = 0.5 * lineHeight + 0.5 * fontSize - 2;
- const legendText = item.legendText ? item.legendText : item.name;
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(item.show ? opts.legend.fontColor : opts.legend.hiddenColor);
- context.fillText(legendText, startX, startY + fontTrans);
- context.closePath();
- context.stroke();
- if (opts.legend.position == "top" || opts.legend.position == "bottom") {
- startX += measureText(legendText, fontSize, context) + itemGap;
- item.area[2] = startX;
- } else {
- item.area[2] = startX + measureText(legendText, fontSize, context) + itemGap;
- ;
- startX -= shapeWidth + shapeRight;
- startY += lineHeight;
- }
- }
- });
- }
- function drawPieDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var pieOption = assign({}, {
- activeOpacity: 0.5,
- activeRadius: 10,
- offsetAngle: 0,
- labelWidth: 15,
- ringWidth: 30,
- customRadius: 0,
- border: false,
- borderWidth: 2,
- borderColor: "#FFFFFF",
- centerColor: "#FFFFFF",
- linearType: "none",
- customColor: []
- }, opts.type == "pie" ? opts.extra.pie : opts.extra.ring);
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
- if (config2.pieChartLinePadding == 0) {
- config2.pieChartLinePadding = pieOption.activeRadius * opts.pix;
- }
- 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);
- radius = radius < 10 ? 10 : radius;
- if (pieOption.customRadius > 0) {
- radius = pieOption.customRadius * opts.pix;
- }
- series = getPieDataPoints(series, radius, process);
- var activeRadius = pieOption.activeRadius * opts.pix;
- pieOption.customColor = fillCustomColor(pieOption.linearType, pieOption.customColor, series, config2);
- series = series.map(function(eachSeries) {
- eachSeries._start_ += pieOption.offsetAngle * Math.PI / 180;
- return eachSeries;
- });
- series.forEach(function(eachSeries, seriesIndex) {
- if (opts.tooltip) {
- if (opts.tooltip.index == seriesIndex) {
- context.beginPath();
- context.setFillStyle(hexToRgb(eachSeries.color, pieOption.activeOpacity || 0.5));
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_ + activeRadius, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
- context.closePath();
- context.fill();
- }
- }
- context.beginPath();
- context.setLineWidth(pieOption.borderWidth * opts.pix);
- context.lineJoin = "round";
- context.setStrokeStyle(pieOption.borderColor);
- var fillcolor = eachSeries.color;
- if (pieOption.linearType == "custom") {
- var grd;
- if (context.createCircularGradient) {
- grd = context.createCircularGradient(centerPosition.x, centerPosition.y, eachSeries._radius_);
- } else {
- grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, eachSeries._radius_);
- }
- grd.addColorStop(0, hexToRgb(pieOption.customColor[eachSeries.linearIndex], 1));
- grd.addColorStop(1, hexToRgb(eachSeries.color, 1));
- fillcolor = grd;
- }
- context.setFillStyle(fillcolor);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._proportion_ * Math.PI);
- context.closePath();
- context.fill();
- if (pieOption.border == true) {
- context.stroke();
- }
- });
- if (opts.type === "ring") {
- var innerPieWidth = radius * 0.6;
- if (typeof pieOption.ringWidth === "number" && pieOption.ringWidth > 0) {
- innerPieWidth = Math.max(0, radius - pieOption.ringWidth * opts.pix);
- }
- context.beginPath();
- context.setFillStyle(pieOption.centerColor);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, innerPieWidth, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- }
- if (opts.dataLabel !== false && process === 1) {
- drawPieText(series, opts, config2, context, radius, centerPosition);
- }
- if (process === 1 && opts.type === "ring") {
- drawRingTitle(opts, config2, context, centerPosition);
- }
- return {
- center: centerPosition,
- radius,
- series
- };
- }
- function drawRoseDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var roseOption = assign({}, {
- type: "area",
- activeOpacity: 0.5,
- activeRadius: 10,
- offsetAngle: 0,
- labelWidth: 15,
- border: false,
- borderWidth: 2,
- borderColor: "#FFFFFF",
- linearType: "none",
- customColor: []
- }, opts.extra.rose);
- if (config2.pieChartLinePadding == 0) {
- config2.pieChartLinePadding = roseOption.activeRadius * opts.pix;
- }
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
- 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);
- radius = radius < 10 ? 10 : radius;
- var minRadius = roseOption.minRadius || radius * 0.5;
- if (radius < minRadius) {
- radius = minRadius + 10;
- }
- series = getRoseDataPoints(series, roseOption.type, minRadius, radius, process);
- var activeRadius = roseOption.activeRadius * opts.pix;
- roseOption.customColor = fillCustomColor(roseOption.linearType, roseOption.customColor, series, config2);
- series = series.map(function(eachSeries) {
- eachSeries._start_ += (roseOption.offsetAngle || 0) * Math.PI / 180;
- return eachSeries;
- });
- series.forEach(function(eachSeries, seriesIndex) {
- if (opts.tooltip) {
- if (opts.tooltip.index == seriesIndex) {
- context.beginPath();
- context.setFillStyle(hexToRgb(eachSeries.color, roseOption.activeOpacity || 0.5));
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, activeRadius + eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
- context.closePath();
- context.fill();
- }
- }
- context.beginPath();
- context.setLineWidth(roseOption.borderWidth * opts.pix);
- context.lineJoin = "round";
- context.setStrokeStyle(roseOption.borderColor);
- var fillcolor = eachSeries.color;
- if (roseOption.linearType == "custom") {
- var grd;
- if (context.createCircularGradient) {
- grd = context.createCircularGradient(centerPosition.x, centerPosition.y, eachSeries._radius_);
- } else {
- grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, eachSeries._radius_);
- }
- grd.addColorStop(0, hexToRgb(roseOption.customColor[eachSeries.linearIndex], 1));
- grd.addColorStop(1, hexToRgb(eachSeries.color, 1));
- fillcolor = grd;
- }
- context.setFillStyle(fillcolor);
- context.moveTo(centerPosition.x, centerPosition.y);
- context.arc(centerPosition.x, centerPosition.y, eachSeries._radius_, eachSeries._start_, eachSeries._start_ + 2 * eachSeries._rose_proportion_ * Math.PI);
- context.closePath();
- context.fill();
- if (roseOption.border == true) {
- context.stroke();
- }
- });
- if (opts.dataLabel !== false && process === 1) {
- drawPieText(series, opts, config2, context, radius, centerPosition);
- }
- return {
- center: centerPosition,
- radius,
- series
- };
- }
- function drawArcbarDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var arcbarOption = assign({}, {
- startAngle: 0.75,
- endAngle: 0.25,
- type: "default",
- direction: "cw",
- lineCap: "round",
- width: 12,
- gap: 2,
- linearType: "none",
- customColor: []
- }, opts.extra.arcbar);
- series = getArcbarDataPoints(series, arcbarOption, process);
- var centerPosition;
- if (arcbarOption.centerX || arcbarOption.centerY) {
- centerPosition = {
- x: arcbarOption.centerX ? arcbarOption.centerX : opts.width / 2,
- y: arcbarOption.centerY ? arcbarOption.centerY : opts.height / 2
- };
- } else {
- centerPosition = {
- x: opts.width / 2,
- y: opts.height / 2
- };
- }
- var radius;
- if (arcbarOption.radius) {
- radius = arcbarOption.radius;
- } else {
- radius = Math.min(centerPosition.x, centerPosition.y);
- radius -= 5 * opts.pix;
- radius -= arcbarOption.width / 2;
- }
- radius = radius < 10 ? 10 : radius;
- arcbarOption.customColor = fillCustomColor(arcbarOption.linearType, arcbarOption.customColor, series, config2);
- for (let i = 0; i < series.length; i++) {
- let eachSeries = series[i];
- context.setLineWidth(arcbarOption.width * opts.pix);
- context.setStrokeStyle(arcbarOption.backgroundColor || "#E9E9E9");
- context.setLineCap(arcbarOption.lineCap);
- context.beginPath();
- if (arcbarOption.type == "default") {
- 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");
- } else {
- context.arc(centerPosition.x, centerPosition.y, radius - (arcbarOption.width * opts.pix + arcbarOption.gap * opts.pix) * i, 0, 2 * Math.PI, arcbarOption.direction == "ccw");
- }
- context.stroke();
- var fillColor = eachSeries.color;
- if (arcbarOption.linearType == "custom") {
- var grd = context.createLinearGradient(centerPosition.x - radius, centerPosition.y, centerPosition.x + radius, centerPosition.y);
- grd.addColorStop(1, hexToRgb(arcbarOption.customColor[eachSeries.linearIndex], 1));
- grd.addColorStop(0, hexToRgb(eachSeries.color, 1));
- fillColor = grd;
- }
- context.setLineWidth(arcbarOption.width * opts.pix);
- context.setStrokeStyle(fillColor);
- context.setLineCap(arcbarOption.lineCap);
- context.beginPath();
- 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");
- context.stroke();
- }
- drawRingTitle(opts, config2, context, centerPosition);
- return {
- center: centerPosition,
- radius,
- series
- };
- }
- function drawGaugeDataPoints(categories, series, opts, config2, context) {
- var process = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : 1;
- var gaugeOption = assign({}, {
- type: "default",
- startAngle: 0.75,
- endAngle: 0.25,
- width: 15,
- labelOffset: 13,
- splitLine: {
- fixRadius: 0,
- splitNumber: 10,
- width: 15,
- color: "#FFFFFF",
- childNumber: 5,
- childWidth: 5
- },
- pointer: {
- width: 15,
- color: "auto"
- }
- }, opts.extra.gauge);
- if (gaugeOption.oldAngle == void 0) {
- gaugeOption.oldAngle = gaugeOption.startAngle;
- }
- if (gaugeOption.oldData == void 0) {
- gaugeOption.oldData = 0;
- }
- categories = getGaugeAxisPoints(categories, gaugeOption.startAngle, gaugeOption.endAngle);
- var centerPosition = {
- x: opts.width / 2,
- y: opts.height / 2
- };
- var radius = Math.min(centerPosition.x, centerPosition.y);
- radius -= 5 * opts.pix;
- radius -= gaugeOption.width / 2;
- radius = radius < 10 ? 10 : radius;
- var innerRadius = radius - gaugeOption.width;
- var totalAngle = 0;
- if (gaugeOption.type == "progress") {
- var pieRadius = radius - gaugeOption.width * 3;
- context.beginPath();
- let gradient = context.createLinearGradient(centerPosition.x, centerPosition.y - pieRadius, centerPosition.x, centerPosition.y + pieRadius);
- gradient.addColorStop("0", hexToRgb(series[0].color, 0.3));
- gradient.addColorStop("1.0", hexToRgb("#FFFFFF", 0.1));
- context.setFillStyle(gradient);
- context.arc(centerPosition.x, centerPosition.y, pieRadius, 0, 2 * Math.PI, false);
- context.fill();
- context.setLineWidth(gaugeOption.width);
- context.setStrokeStyle(hexToRgb(series[0].color, 0.3));
- context.setLineCap("round");
- context.beginPath();
- context.arc(centerPosition.x, centerPosition.y, innerRadius, gaugeOption.startAngle * Math.PI, gaugeOption.endAngle * Math.PI, false);
- context.stroke();
- if (gaugeOption.endAngle < gaugeOption.startAngle) {
- totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
- } else {
- totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
- }
- let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
- let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber;
- let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius;
- let endX = -radius - gaugeOption.width - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width;
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((gaugeOption.startAngle - 1) * Math.PI);
- let len = gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1;
- let proc = series[0].data * process;
- for (let i = 0; i < len; i++) {
- context.beginPath();
- if (proc > i / len) {
- context.setStrokeStyle(hexToRgb(series[0].color, 1));
- } else {
- context.setStrokeStyle(hexToRgb(series[0].color, 0.3));
- }
- context.setLineWidth(3 * opts.pix);
- context.moveTo(startX, 0);
- context.lineTo(endX, 0);
- context.stroke();
- context.rotate(childAngle * Math.PI);
- }
- context.restore();
- series = getGaugeArcbarDataPoints(series, gaugeOption, process);
- context.setLineWidth(gaugeOption.width);
- context.setStrokeStyle(series[0].color);
- context.setLineCap("round");
- context.beginPath();
- context.arc(centerPosition.x, centerPosition.y, innerRadius, gaugeOption.startAngle * Math.PI, series[0]._proportion_ * Math.PI, false);
- context.stroke();
- let pointerRadius = radius - gaugeOption.width * 2.5;
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((series[0]._proportion_ - 1) * Math.PI);
- context.beginPath();
- context.setLineWidth(gaugeOption.width / 3);
- let gradient3 = context.createLinearGradient(0, -pointerRadius * 0.6, 0, pointerRadius * 0.6);
- gradient3.addColorStop("0", hexToRgb("#FFFFFF", 0));
- gradient3.addColorStop("0.5", hexToRgb(series[0].color, 1));
- gradient3.addColorStop("1.0", hexToRgb("#FFFFFF", 0));
- context.setStrokeStyle(gradient3);
- context.arc(0, 0, pointerRadius, 0.85 * Math.PI, 1.15 * Math.PI, false);
- context.stroke();
- context.beginPath();
- context.setLineWidth(1);
- context.setStrokeStyle(series[0].color);
- context.setFillStyle(series[0].color);
- context.moveTo(-pointerRadius - gaugeOption.width / 3 / 2, -4);
- context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2 - 4, 0);
- context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2, 4);
- context.lineTo(-pointerRadius - gaugeOption.width / 3 / 2, -4);
- context.stroke();
- context.fill();
- context.restore();
- } else {
- context.setLineWidth(gaugeOption.width);
- context.setLineCap("butt");
- for (let i = 0; i < categories.length; i++) {
- let eachCategories = categories[i];
- context.beginPath();
- context.setStrokeStyle(eachCategories.color);
- context.arc(centerPosition.x, centerPosition.y, radius, eachCategories._startAngle_ * Math.PI, eachCategories._endAngle_ * Math.PI, false);
- context.stroke();
- }
- context.save();
- if (gaugeOption.endAngle < gaugeOption.startAngle) {
- totalAngle = 2 + gaugeOption.endAngle - gaugeOption.startAngle;
- } else {
- totalAngle = gaugeOption.startAngle - gaugeOption.endAngle;
- }
- let splitAngle = totalAngle / gaugeOption.splitLine.splitNumber;
- let childAngle = totalAngle / gaugeOption.splitLine.splitNumber / gaugeOption.splitLine.childNumber;
- let startX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius;
- let endX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.width;
- let childendX = -radius - gaugeOption.width * 0.5 - gaugeOption.splitLine.fixRadius + gaugeOption.splitLine.childWidth;
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((gaugeOption.startAngle - 1) * Math.PI);
- for (let i = 0; i < gaugeOption.splitLine.splitNumber + 1; i++) {
- context.beginPath();
- context.setStrokeStyle(gaugeOption.splitLine.color);
- context.setLineWidth(2 * opts.pix);
- context.moveTo(startX, 0);
- context.lineTo(endX, 0);
- context.stroke();
- context.rotate(splitAngle * Math.PI);
- }
- context.restore();
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((gaugeOption.startAngle - 1) * Math.PI);
- for (let i = 0; i < gaugeOption.splitLine.splitNumber * gaugeOption.splitLine.childNumber + 1; i++) {
- context.beginPath();
- context.setStrokeStyle(gaugeOption.splitLine.color);
- context.setLineWidth(1 * opts.pix);
- context.moveTo(startX, 0);
- context.lineTo(childendX, 0);
- context.stroke();
- context.rotate(childAngle * Math.PI);
- }
- context.restore();
- series = getGaugeDataPoints(series, categories, gaugeOption, process);
- for (let i = 0; i < series.length; i++) {
- let eachSeries = series[i];
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- context.rotate((eachSeries._proportion_ - 1) * Math.PI);
- context.beginPath();
- context.setFillStyle(eachSeries.color);
- context.moveTo(gaugeOption.pointer.width, 0);
- context.lineTo(0, -gaugeOption.pointer.width / 2);
- context.lineTo(-innerRadius, 0);
- context.lineTo(0, gaugeOption.pointer.width / 2);
- context.lineTo(gaugeOption.pointer.width, 0);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFillStyle("#FFFFFF");
- context.arc(0, 0, gaugeOption.pointer.width / 6, 0, 2 * Math.PI, false);
- context.fill();
- context.restore();
- }
- if (opts.dataLabel !== false) {
- drawGaugeLabel(gaugeOption, radius, centerPosition, opts, config2, context);
- }
- }
- drawRingTitle(opts, config2, context, centerPosition);
- if (process === 1 && opts.type === "gauge") {
- opts.extra.gauge.oldAngle = series[0]._proportion_;
- opts.extra.gauge.oldData = series[0].data;
- }
- return {
- center: centerPosition,
- radius,
- innerRadius,
- categories,
- totalAngle
- };
- }
- function drawRadarDataPoints(series, opts, config2, context) {
- var process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- var radarOption = assign({}, {
- gridColor: "#cccccc",
- gridType: "radar",
- gridEval: 1,
- axisLabel: false,
- axisLabelTofix: 0,
- labelShow: true,
- labelColor: "#666666",
- labelPointShow: false,
- labelPointRadius: 3,
- labelPointColor: "#cccccc",
- opacity: 0.2,
- gridCount: 3,
- border: false,
- borderWidth: 2,
- linearType: "none",
- customColor: []
- }, opts.extra.radar);
- var coordinateAngle = getRadarCoordinateSeries(opts.categories.length);
- var centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.area[0] + (opts.height - opts.area[0] - opts.area[2]) / 2
- };
- var xr = (opts.width - opts.area[1] - opts.area[3]) / 2;
- var yr = (opts.height - opts.area[0] - opts.area[2]) / 2;
- var radius = Math.min(xr - (getMaxTextListLength(opts.categories, config2.fontSize, context) + config2.radarLabelTextMargin), yr - config2.radarLabelTextMargin);
- radius -= config2.radarLabelTextMargin * opts.pix;
- radius = radius < 10 ? 10 : radius;
- radius = radarOption.radius ? radarOption.radius : radius;
- context.beginPath();
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(radarOption.gridColor);
- coordinateAngle.forEach(function(angle, index) {
- var pos = convertCoordinateOrigin(radius * Math.cos(angle), radius * Math.sin(angle), centerPosition);
- context.moveTo(centerPosition.x, centerPosition.y);
- if (index % radarOption.gridEval == 0) {
- context.lineTo(pos.x, pos.y);
- }
- });
- context.stroke();
- context.closePath();
- var _loop = function _loop2(i2) {
- var startPos = {};
- context.beginPath();
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(radarOption.gridColor);
- if (radarOption.gridType == "radar") {
- coordinateAngle.forEach(function(angle, index) {
- var pos2 = convertCoordinateOrigin(radius / radarOption.gridCount * i2 * Math.cos(angle), radius / radarOption.gridCount * i2 * Math.sin(angle), centerPosition);
- if (index === 0) {
- startPos = pos2;
- context.moveTo(pos2.x, pos2.y);
- } else {
- context.lineTo(pos2.x, pos2.y);
- }
- });
- context.lineTo(startPos.x, startPos.y);
- } else {
- var pos = convertCoordinateOrigin(radius / radarOption.gridCount * i2 * Math.cos(1.5), radius / radarOption.gridCount * i2 * Math.sin(1.5), centerPosition);
- context.arc(centerPosition.x, centerPosition.y, centerPosition.y - pos.y, 0, 2 * Math.PI, false);
- }
- context.stroke();
- context.closePath();
- };
- for (var i = 1; i <= radarOption.gridCount; i++) {
- _loop(i);
- }
- radarOption.customColor = fillCustomColor(radarOption.linearType, radarOption.customColor, series, config2);
- var radarDataPoints = getRadarDataPoints(coordinateAngle, centerPosition, radius, series, opts, process);
- radarDataPoints.forEach(function(eachSeries, seriesIndex) {
- context.beginPath();
- context.setLineWidth(radarOption.borderWidth * opts.pix);
- context.setStrokeStyle(eachSeries.color);
- var fillcolor = hexToRgb(eachSeries.color, radarOption.opacity);
- if (radarOption.linearType == "custom") {
- var grd;
- if (context.createCircularGradient) {
- grd = context.createCircularGradient(centerPosition.x, centerPosition.y, radius);
- } else {
- grd = context.createRadialGradient(centerPosition.x, centerPosition.y, 0, centerPosition.x, centerPosition.y, radius);
- }
- grd.addColorStop(0, hexToRgb(radarOption.customColor[series[seriesIndex].linearIndex], radarOption.opacity));
- grd.addColorStop(1, hexToRgb(eachSeries.color, radarOption.opacity));
- fillcolor = grd;
- }
- context.setFillStyle(fillcolor);
- eachSeries.data.forEach(function(item, index) {
- if (index === 0) {
- context.moveTo(item.position.x, item.position.y);
- } else {
- context.lineTo(item.position.x, item.position.y);
- }
- });
- context.closePath();
- context.fill();
- if (radarOption.border === true) {
- context.stroke();
- }
- context.closePath();
- if (opts.dataPointShape !== false) {
- var points = eachSeries.data.map(function(item) {
- return item.position;
- });
- drawPointShape(points, eachSeries.color, eachSeries.pointShape, context, opts);
- }
- });
- if (radarOption.axisLabel === true) {
- const maxData = Math.max(radarOption.max, Math.max.apply(null, dataCombine(series)));
- const stepLength = radius / radarOption.gridCount;
- const fontSize = opts.fontSize * opts.pix;
- context.setFontSize(fontSize);
- context.setFillStyle(opts.fontColor);
- context.setTextAlign("left");
- for (var i = 0; i < radarOption.gridCount + 1; i++) {
- let label = i * maxData / radarOption.gridCount;
- label = label.toFixed(radarOption.axisLabelTofix);
- context.fillText(String(label), centerPosition.x + 3 * opts.pix, centerPosition.y - i * stepLength + fontSize / 2);
- }
- }
- drawRadarLabel(coordinateAngle, radius, centerPosition, opts, config2, context);
- if (opts.dataLabel !== false && process === 1) {
- radarDataPoints.forEach(function(eachSeries, seriesIndex) {
- context.beginPath();
- var fontSize = eachSeries.textSize * opts.pix || config2.fontSize;
- context.setFontSize(fontSize);
- context.setFillStyle(eachSeries.textColor || opts.fontColor);
- eachSeries.data.forEach(function(item, index) {
- if (Math.abs(item.position.x - centerPosition.x) < 2) {
- if (item.position.y < centerPosition.y) {
- context.setTextAlign("center");
- context.fillText(item.value, item.position.x, item.position.y - 4);
- } else {
- context.setTextAlign("center");
- context.fillText(item.value, item.position.x, item.position.y + fontSize + 2);
- }
- } else {
- if (item.position.x < centerPosition.x) {
- context.setTextAlign("right");
- context.fillText(item.value, item.position.x - 4, item.position.y + fontSize / 2 - 2);
- } else {
- context.setTextAlign("left");
- context.fillText(item.value, item.position.x + 4, item.position.y + fontSize / 2 - 2);
- }
- }
- });
- context.closePath();
- context.stroke();
- });
- context.setTextAlign("left");
- }
- return {
- center: centerPosition,
- radius,
- angleList: coordinateAngle
- };
- }
- function lonlat2mercator(longitude, latitude) {
- var mercator = Array(2);
- var x = longitude * 2003750834e-2 / 180;
- var y = Math.log(Math.tan((90 + latitude) * Math.PI / 360)) / (Math.PI / 180);
- y = y * 2003750834e-2 / 180;
- mercator[0] = x;
- mercator[1] = y;
- return mercator;
- }
- function getBoundingBox(data) {
- var bounds = {}, coords;
- bounds.xMin = 180;
- bounds.xMax = 0;
- bounds.yMin = 90;
- bounds.yMax = 0;
- for (var i = 0; i < data.length; i++) {
- var coorda = data[i].geometry.coordinates;
- for (var k = 0; k < coorda.length; k++) {
- coords = coorda[k];
- if (coords.length == 1) {
- coords = coords[0];
- }
- for (var j = 0; j < coords.length; j++) {
- var longitude = coords[j][0];
- var latitude = coords[j][1];
- var point = {
- x: longitude,
- y: latitude
- };
- bounds.xMin = bounds.xMin < point.x ? bounds.xMin : point.x;
- bounds.xMax = bounds.xMax > point.x ? bounds.xMax : point.x;
- bounds.yMin = bounds.yMin < point.y ? bounds.yMin : point.y;
- bounds.yMax = bounds.yMax > point.y ? bounds.yMax : point.y;
- }
- }
- }
- return bounds;
- }
- function coordinateToPoint(latitude, longitude, bounds, scale, xoffset, yoffset) {
- return {
- x: (longitude - bounds.xMin) * scale + xoffset,
- y: (bounds.yMax - latitude) * scale + yoffset
- };
- }
- function pointToCoordinate(pointY, pointX, bounds, scale, xoffset, yoffset) {
- return {
- x: (pointX - xoffset) / scale + bounds.xMin,
- y: bounds.yMax - (pointY - yoffset) / scale
- };
- }
- function isRayIntersectsSegment(poi, s_poi, e_poi) {
- if (s_poi[1] == e_poi[1]) {
- return false;
- }
- if (s_poi[1] > poi[1] && e_poi[1] > poi[1]) {
- return false;
- }
- if (s_poi[1] < poi[1] && e_poi[1] < poi[1]) {
- return false;
- }
- if (s_poi[1] == poi[1] && e_poi[1] > poi[1]) {
- return false;
- }
- if (e_poi[1] == poi[1] && s_poi[1] > poi[1]) {
- return false;
- }
- if (s_poi[0] < poi[0] && e_poi[1] < poi[1]) {
- return false;
- }
- let xseg = e_poi[0] - (e_poi[0] - s_poi[0]) * (e_poi[1] - poi[1]) / (e_poi[1] - s_poi[1]);
- if (xseg < poi[0]) {
- return false;
- } else {
- return true;
- }
- }
- function isPoiWithinPoly(poi, poly, mercator) {
- let sinsc = 0;
- for (let i = 0; i < poly.length; i++) {
- let epoly = poly[i][0];
- if (poly.length == 1) {
- epoly = poly[i][0];
- }
- for (let j = 0; j < epoly.length - 1; j++) {
- let s_poi = epoly[j];
- let e_poi = epoly[j + 1];
- if (mercator) {
- s_poi = lonlat2mercator(epoly[j][0], epoly[j][1]);
- e_poi = lonlat2mercator(epoly[j + 1][0], epoly[j + 1][1]);
- }
- if (isRayIntersectsSegment(poi, s_poi, e_poi)) {
- sinsc += 1;
- }
- }
- }
- if (sinsc % 2 == 1) {
- return true;
- } else {
- return false;
- }
- }
- function drawMapDataPoints(series, opts, config2, context) {
- var mapOption = assign({}, {
- border: true,
- mercator: false,
- borderWidth: 1,
- active: true,
- borderColor: "#666666",
- fillOpacity: 0.6,
- activeBorderColor: "#f04864",
- activeFillColor: "#facc14",
- activeFillOpacity: 1
- }, opts.extra.map);
- var coords, point;
- var data = series;
- var bounds = getBoundingBox(data);
- if (mapOption.mercator) {
- var max = lonlat2mercator(bounds.xMax, bounds.yMax);
- var min = lonlat2mercator(bounds.xMin, bounds.yMin);
- bounds.xMax = max[0];
- bounds.yMax = max[1];
- bounds.xMin = min[0];
- bounds.yMin = min[1];
- }
- var xScale = opts.width / Math.abs(bounds.xMax - bounds.xMin);
- var yScale = opts.height / Math.abs(bounds.yMax - bounds.yMin);
- var scale = xScale < yScale ? xScale : yScale;
- var xoffset = opts.width / 2 - Math.abs(bounds.xMax - bounds.xMin) / 2 * scale;
- var yoffset = opts.height / 2 - Math.abs(bounds.yMax - bounds.yMin) / 2 * scale;
- for (var i = 0; i < data.length; i++) {
- context.beginPath();
- context.setLineWidth(mapOption.borderWidth * opts.pix);
- context.setStrokeStyle(mapOption.borderColor);
- context.setFillStyle(hexToRgb(series[i].color, series[i].fillOpacity || mapOption.fillOpacity));
- if (mapOption.active == true && opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.setStrokeStyle(mapOption.activeBorderColor);
- context.setFillStyle(hexToRgb(mapOption.activeFillColor, mapOption.activeFillOpacity));
- }
- }
- var coorda = data[i].geometry.coordinates;
- for (var k = 0; k < coorda.length; k++) {
- coords = coorda[k];
- if (coords.length == 1) {
- coords = coords[0];
- }
- for (var j = 0; j < coords.length; j++) {
- var gaosi = Array(2);
- if (mapOption.mercator) {
- gaosi = lonlat2mercator(coords[j][0], coords[j][1]);
- } else {
- gaosi = coords[j];
- }
- point = coordinateToPoint(gaosi[1], gaosi[0], bounds, scale, xoffset, yoffset);
- if (j === 0) {
- context.beginPath();
- context.moveTo(point.x, point.y);
- } else {
- context.lineTo(point.x, point.y);
- }
- }
- context.fill();
- if (mapOption.border == true) {
- context.stroke();
- }
- }
- }
- if (opts.dataLabel == true) {
- for (var i = 0; i < data.length; i++) {
- var centerPoint = data[i].properties.centroid;
- if (centerPoint) {
- if (mapOption.mercator) {
- centerPoint = lonlat2mercator(data[i].properties.centroid[0], data[i].properties.centroid[1]);
- }
- point = coordinateToPoint(centerPoint[1], centerPoint[0], bounds, scale, xoffset, yoffset);
- let fontSize = data[i].textSize * opts.pix || config2.fontSize;
- let fontColor = data[i].textColor || opts.fontColor;
- if (mapOption.active && mapOption.activeTextColor && opts.tooltip && opts.tooltip.index == i) {
- fontColor = mapOption.activeTextColor;
- }
- let text = data[i].properties.name;
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(fontColor);
- context.fillText(text, point.x - measureText(text, fontSize, context) / 2, point.y + fontSize / 2);
- context.closePath();
- context.stroke();
- }
- }
- }
- opts.chartData.mapData = {
- bounds,
- scale,
- xoffset,
- yoffset,
- mercator: mapOption.mercator
- };
- drawToolTipBridge(opts, config2, context, 1);
- context.draw();
- }
- function normalInt(min, max, iter) {
- iter = iter == 0 ? 1 : iter;
- var arr = [];
- for (var i = 0; i < iter; i++) {
- arr[i] = Math.random();
- }
- ;
- return Math.floor(arr.reduce(function(i2, j) {
- return i2 + j;
- }) / iter * (max - min)) + min;
- }
- function collisionNew(area, points, width, height) {
- var isIn = false;
- for (let i = 0; i < points.length; i++) {
- if (points[i].area) {
- 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]) {
- if (area[0] < 0 || area[1] < 0 || area[2] > width || area[3] > height) {
- isIn = true;
- break;
- } else {
- isIn = false;
- }
- } else {
- isIn = true;
- break;
- }
- }
- }
- return isIn;
- }
- function getWordCloudPoint(opts, type, context) {
- let points = opts.series;
- switch (type) {
- case "normal":
- for (let i = 0; i < points.length; i++) {
- let text = points[i].name;
- let tHeight = points[i].textSize * opts.pix;
- let tWidth = measureText(text, tHeight, context);
- let x, y;
- let area;
- let breaknum = 0;
- while (true) {
- breaknum++;
- x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
- y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
- area = [
- x - 5 + opts.width / 2,
- y - 5 - tHeight + opts.height / 2,
- x + tWidth + 5 + opts.width / 2,
- y + 5 + opts.height / 2
- ];
- let isCollision2 = collisionNew(area, points, opts.width, opts.height);
- if (!isCollision2)
- break;
- if (breaknum == 1e3) {
- area = [-100, -100, -100, -100];
- break;
- }
- }
- ;
- points[i].area = area;
- }
- break;
- case "vertical":
- let Spin = function() {
- if (Math.random() > 0.7) {
- return true;
- } else {
- return false;
- }
- ;
- };
- ;
- for (let i = 0; i < points.length; i++) {
- let text = points[i].name;
- let tHeight = points[i].textSize * opts.pix;
- let tWidth = measureText(text, tHeight, context);
- let isSpin = Spin();
- let x, y, area, areav;
- let breaknum = 0;
- while (true) {
- breaknum++;
- let isCollision2;
- if (isSpin) {
- x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
- y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
- area = [y - 5 - tWidth + opts.width / 2, -x - 5 + opts.height / 2, y + 5 + opts.width / 2, -x + tHeight + 5 + opts.height / 2];
- 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];
- isCollision2 = collisionNew(areav, points, opts.height, opts.width);
- } else {
- x = normalInt(-opts.width / 2, opts.width / 2, 5) - tWidth / 2;
- y = normalInt(-opts.height / 2, opts.height / 2, 5) + tHeight / 2;
- area = [x - 5 + opts.width / 2, y - 5 - tHeight + opts.height / 2, x + tWidth + 5 + opts.width / 2, y + 5 + opts.height / 2];
- isCollision2 = collisionNew(area, points, opts.width, opts.height);
- }
- if (!isCollision2)
- break;
- if (breaknum == 1e3) {
- area = [-1e3, -1e3, -1e3, -1e3];
- break;
- }
- }
- ;
- if (isSpin) {
- points[i].area = areav;
- points[i].areav = area;
- } else {
- points[i].area = area;
- }
- points[i].rotate = isSpin;
- }
- ;
- break;
- }
- return points;
- }
- function drawWordCloudDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let wordOption = assign({}, {
- type: "normal",
- autoColors: true
- }, opts.extra.word);
- if (!opts.chartData.wordCloudData) {
- opts.chartData.wordCloudData = getWordCloudPoint(opts, wordOption.type, context);
- }
- context.beginPath();
- context.setFillStyle(opts.background);
- context.rect(0, 0, opts.width, opts.height);
- context.fill();
- context.save();
- let points = opts.chartData.wordCloudData;
- context.translate(opts.width / 2, opts.height / 2);
- for (let i = 0; i < points.length; i++) {
- context.save();
- if (points[i].rotate) {
- context.rotate(90 * Math.PI / 180);
- }
- let text = points[i].name;
- let tHeight = points[i].textSize * opts.pix;
- let tWidth = measureText(text, tHeight, context);
- context.beginPath();
- context.setStrokeStyle(points[i].color);
- context.setFillStyle(points[i].color);
- context.setFontSize(tHeight);
- if (points[i].rotate) {
- if (points[i].areav[0] > 0) {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- 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);
- } else {
- 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);
- }
- } else {
- 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);
- }
- }
- } else {
- if (points[i].area[0] > 0) {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- 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);
- } else {
- 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);
- }
- } else {
- 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);
- }
- }
- }
- context.stroke();
- context.restore();
- }
- context.restore();
- }
- function drawFunnelDataPoints(series, opts, config2, context) {
- let process = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 1;
- let funnelOption = assign({}, {
- type: "funnel",
- activeWidth: 10,
- activeOpacity: 0.3,
- border: false,
- borderWidth: 2,
- borderColor: "#FFFFFF",
- fillOpacity: 1,
- minSize: 0,
- labelAlign: "right",
- linearType: "none",
- customColor: []
- }, opts.extra.funnel);
- let eachSpacing = (opts.height - opts.area[0] - opts.area[2]) / series.length;
- let centerPosition = {
- x: opts.area[3] + (opts.width - opts.area[1] - opts.area[3]) / 2,
- y: opts.height - opts.area[2]
- };
- let activeWidth = funnelOption.activeWidth * opts.pix;
- let radius = Math.min((opts.width - opts.area[1] - opts.area[3]) / 2 - activeWidth, (opts.height - opts.area[0] - opts.area[2]) / 2 - activeWidth);
- let seriesNew = getFunnelDataPoints(series, radius, funnelOption, eachSpacing, process);
- context.save();
- context.translate(centerPosition.x, centerPosition.y);
- funnelOption.customColor = fillCustomColor(funnelOption.linearType, funnelOption.customColor, series, config2);
- if (funnelOption.type == "pyramid") {
- for (let i = 0; i < seriesNew.length; i++) {
- if (i == seriesNew.length - 1) {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.beginPath();
- context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
- context.moveTo(-activeWidth, -eachSpacing);
- context.lineTo(-seriesNew[i].radius - activeWidth, 0);
- context.lineTo(seriesNew[i].radius + activeWidth, 0);
- context.lineTo(activeWidth, -eachSpacing);
- context.lineTo(-activeWidth, -eachSpacing);
- context.closePath();
- context.fill();
- }
- }
- seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing * (i + 1), centerPosition.x + seriesNew[i].radius, centerPosition.y - eachSpacing * i];
- context.beginPath();
- context.setLineWidth(funnelOption.borderWidth * opts.pix);
- context.setStrokeStyle(funnelOption.borderColor);
- var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
- if (funnelOption.linearType == "custom") {
- var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
- grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
- grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- fillColor = grd;
- }
- context.setFillStyle(fillColor);
- context.moveTo(0, -eachSpacing);
- context.lineTo(-seriesNew[i].radius, 0);
- context.lineTo(seriesNew[i].radius, 0);
- context.lineTo(0, -eachSpacing);
- context.closePath();
- context.fill();
- if (funnelOption.border == true) {
- context.stroke();
- }
- } else {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.beginPath();
- context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
- context.moveTo(0, 0);
- context.lineTo(-seriesNew[i].radius - activeWidth, 0);
- context.lineTo(-seriesNew[i + 1].radius - activeWidth, -eachSpacing);
- context.lineTo(seriesNew[i + 1].radius + activeWidth, -eachSpacing);
- context.lineTo(seriesNew[i].radius + activeWidth, 0);
- context.lineTo(0, 0);
- context.closePath();
- context.fill();
- }
- }
- seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing * (i + 1), centerPosition.x + seriesNew[i].radius, centerPosition.y - eachSpacing * i];
- context.beginPath();
- context.setLineWidth(funnelOption.borderWidth * opts.pix);
- context.setStrokeStyle(funnelOption.borderColor);
- var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
- if (funnelOption.linearType == "custom") {
- var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
- grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
- grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- fillColor = grd;
- }
- context.setFillStyle(fillColor);
- context.moveTo(0, 0);
- context.lineTo(-seriesNew[i].radius, 0);
- context.lineTo(-seriesNew[i + 1].radius, -eachSpacing);
- context.lineTo(seriesNew[i + 1].radius, -eachSpacing);
- context.lineTo(seriesNew[i].radius, 0);
- context.lineTo(0, 0);
- context.closePath();
- context.fill();
- if (funnelOption.border == true) {
- context.stroke();
- }
- }
- context.translate(0, -eachSpacing);
- }
- } else {
- context.translate(0, -(seriesNew.length - 1) * eachSpacing);
- for (let i = 0; i < seriesNew.length; i++) {
- if (i == seriesNew.length - 1) {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.beginPath();
- context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
- context.moveTo(-activeWidth - funnelOption.minSize / 2, 0);
- context.lineTo(-seriesNew[i].radius - activeWidth, -eachSpacing);
- context.lineTo(seriesNew[i].radius + activeWidth, -eachSpacing);
- context.lineTo(activeWidth + funnelOption.minSize / 2, 0);
- context.lineTo(-activeWidth - funnelOption.minSize / 2, 0);
- context.closePath();
- context.fill();
- }
- }
- seriesNew[i].funnelArea = [centerPosition.x - seriesNew[i].radius, centerPosition.y - eachSpacing, centerPosition.x + seriesNew[i].radius, centerPosition.y];
- context.beginPath();
- context.setLineWidth(funnelOption.borderWidth * opts.pix);
- context.setStrokeStyle(funnelOption.borderColor);
- var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
- if (funnelOption.linearType == "custom") {
- var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
- grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
- grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- fillColor = grd;
- }
- context.setFillStyle(fillColor);
- context.moveTo(0, 0);
- context.lineTo(-funnelOption.minSize / 2, 0);
- context.lineTo(-seriesNew[i].radius, -eachSpacing);
- context.lineTo(seriesNew[i].radius, -eachSpacing);
- context.lineTo(funnelOption.minSize / 2, 0);
- context.lineTo(0, 0);
- context.closePath();
- context.fill();
- if (funnelOption.border == true) {
- context.stroke();
- }
- } else {
- if (opts.tooltip) {
- if (opts.tooltip.index == i) {
- context.beginPath();
- context.setFillStyle(hexToRgb(seriesNew[i].color, funnelOption.activeOpacity));
- context.moveTo(0, 0);
- context.lineTo(-seriesNew[i + 1].radius - activeWidth, 0);
- context.lineTo(-seriesNew[i].radius - activeWidth, -eachSpacing);
- context.lineTo(seriesNew[i].radius + activeWidth, -eachSpacing);
- context.lineTo(seriesNew[i + 1].radius + activeWidth, 0);
- context.lineTo(0, 0);
- context.closePath();
- context.fill();
- }
- }
- 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)];
- context.beginPath();
- context.setLineWidth(funnelOption.borderWidth * opts.pix);
- context.setStrokeStyle(funnelOption.borderColor);
- var fillColor = hexToRgb(seriesNew[i].color, funnelOption.fillOpacity);
- if (funnelOption.linearType == "custom") {
- var grd = context.createLinearGradient(seriesNew[i].radius, -eachSpacing, -seriesNew[i].radius, -eachSpacing);
- grd.addColorStop(0, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- grd.addColorStop(0.5, hexToRgb(funnelOption.customColor[seriesNew[i].linearIndex], funnelOption.fillOpacity));
- grd.addColorStop(1, hexToRgb(seriesNew[i].color, funnelOption.fillOpacity));
- fillColor = grd;
- }
- context.setFillStyle(fillColor);
- context.moveTo(0, 0);
- context.lineTo(-seriesNew[i + 1].radius, 0);
- context.lineTo(-seriesNew[i].radius, -eachSpacing);
- context.lineTo(seriesNew[i].radius, -eachSpacing);
- context.lineTo(seriesNew[i + 1].radius, 0);
- context.lineTo(0, 0);
- context.closePath();
- context.fill();
- if (funnelOption.border == true) {
- context.stroke();
- }
- }
- context.translate(0, eachSpacing);
- }
- }
- context.restore();
- if (opts.dataLabel !== false && process === 1) {
- drawFunnelText(seriesNew, opts, context, eachSpacing, funnelOption.labelAlign, activeWidth, centerPosition);
- }
- if (process === 1) {
- drawFunnelCenterText(seriesNew, opts, context, eachSpacing, funnelOption.labelAlign, activeWidth, centerPosition);
- }
- return {
- center: centerPosition,
- radius,
- series: seriesNew
- };
- }
- function drawFunnelText(series, opts, context, eachSpacing, labelAlign, activeWidth, centerPosition) {
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- if (item.labelShow === false) {
- continue;
- }
- let startX, endX, startY, fontSize;
- let text = item.formatter ? item.formatter(item, i, series, opts) : util.toFixed(item._proportion_ * 100) + "%";
- text = item.labelText ? item.labelText : text;
- if (labelAlign == "right") {
- if (i == series.length - 1) {
- startX = (item.funnelArea[2] + centerPosition.x) / 2;
- } else {
- startX = (item.funnelArea[2] + series[i + 1].funnelArea[2]) / 2;
- }
- endX = startX + activeWidth * 2;
- startY = item.funnelArea[1] + eachSpacing / 2;
- fontSize = item.textSize * opts.pix || opts.fontSize * opts.pix;
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(item.color);
- context.setFillStyle(item.color);
- context.beginPath();
- context.moveTo(startX, startY);
- context.lineTo(endX, startY);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.moveTo(endX, startY);
- context.arc(endX, startY, 2 * opts.pix, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(item.textColor || opts.fontColor);
- context.fillText(text, endX + 5, startY + fontSize / 2 - 2);
- context.closePath();
- context.stroke();
- context.closePath();
- }
- if (labelAlign == "left") {
- if (i == series.length - 1) {
- startX = (item.funnelArea[0] + centerPosition.x) / 2;
- } else {
- startX = (item.funnelArea[0] + series[i + 1].funnelArea[0]) / 2;
- }
- endX = startX - activeWidth * 2;
- startY = item.funnelArea[1] + eachSpacing / 2;
- fontSize = item.textSize * opts.pix || opts.fontSize * opts.pix;
- context.setLineWidth(1 * opts.pix);
- context.setStrokeStyle(item.color);
- context.setFillStyle(item.color);
- context.beginPath();
- context.moveTo(startX, startY);
- context.lineTo(endX, startY);
- context.stroke();
- context.closePath();
- context.beginPath();
- context.moveTo(endX, startY);
- context.arc(endX, startY, 2, 0, 2 * Math.PI);
- context.closePath();
- context.fill();
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(item.textColor || opts.fontColor);
- context.fillText(text, endX - 5 - measureText(text, fontSize, context), startY + fontSize / 2 - 2);
- context.closePath();
- context.stroke();
- context.closePath();
- }
- }
- }
- function drawFunnelCenterText(series, opts, context, eachSpacing, labelAlign, activeWidth, centerPosition) {
- for (let i = 0; i < series.length; i++) {
- let item = series[i];
- let startY, fontSize;
- if (item.centerText) {
- startY = item.funnelArea[1] + eachSpacing / 2;
- fontSize = item.centerTextSize * opts.pix || opts.fontSize * opts.pix;
- context.beginPath();
- context.setFontSize(fontSize);
- context.setFillStyle(item.centerTextColor || "#FFFFFF");
- context.fillText(item.centerText, centerPosition.x - measureText(item.centerText, fontSize, context) / 2, startY + fontSize / 2 - 2);
- context.closePath();
- context.stroke();
- context.closePath();
- }
- }
- }
- function drawCanvas(opts, context) {
- context.save();
- context.translate(0, 0.5);
- context.restore();
- context.draw();
- }
- var Timing = {
- easeIn: function easeIn(pos) {
- return Math.pow(pos, 3);
- },
- easeOut: function easeOut(pos) {
- return Math.pow(pos - 1, 3) + 1;
- },
- easeInOut: function easeInOut(pos) {
- if ((pos /= 0.5) < 1) {
- return 0.5 * Math.pow(pos, 3);
- } else {
- return 0.5 * (Math.pow(pos - 2, 3) + 2);
- }
- },
- linear: function linear(pos) {
- return pos;
- }
- };
- function Animation(opts) {
- this.isStop = false;
- opts.duration = typeof opts.duration === "undefined" ? 1e3 : opts.duration;
- opts.timing = opts.timing || "easeInOut";
- var delay = 17;
- function createAnimationFrame() {
- if (typeof setTimeout !== "undefined") {
- return function(step, delay2) {
- setTimeout(function() {
- var timeStamp = +/* @__PURE__ */ new Date();
- step(timeStamp);
- }, delay2);
- };
- } else if (typeof requestAnimationFrame !== "undefined") {
- return requestAnimationFrame;
- } else {
- return function(step) {
- step(null);
- };
- }
- }
- ;
- var animationFrame = createAnimationFrame();
- var startTimeStamp = null;
- var _step = function step(timestamp) {
- if (timestamp === null || this.isStop === true) {
- opts.onProcess && opts.onProcess(1);
- opts.onAnimationFinish && opts.onAnimationFinish();
- return;
- }
- if (startTimeStamp === null) {
- startTimeStamp = timestamp;
- }
- if (timestamp - startTimeStamp < opts.duration) {
- var process = (timestamp - startTimeStamp) / opts.duration;
- var timingFunction = Timing[opts.timing];
- process = timingFunction(process);
- opts.onProcess && opts.onProcess(process);
- animationFrame(_step, delay);
- } else {
- opts.onProcess && opts.onProcess(1);
- opts.onAnimationFinish && opts.onAnimationFinish();
- }
- };
- _step = _step.bind(this);
- animationFrame(_step, delay);
- }
- Animation.prototype.stop = function() {
- this.isStop = true;
- };
- function drawCharts(type, opts, config2, context) {
- var _this = this;
- var series = opts.series;
- if (type === "pie" || type === "ring" || type === "mount" || type === "rose" || type === "funnel") {
- series = fixPieSeries(series, opts, config2);
- }
- var categories = opts.categories;
- if (type === "mount") {
- categories = [];
- for (let j = 0; j < series.length; j++) {
- if (series[j].show !== false)
- categories.push(series[j].name);
- }
- opts.categories = categories;
- }
- series = fillSeries(series, opts, config2);
- var duration = opts.animation ? opts.duration : 0;
- _this.animationInstance && _this.animationInstance.stop();
- var seriesMA = null;
- if (type == "candle") {
- let average = assign({}, opts.extra.candle.average);
- if (average.show) {
- seriesMA = calCandleMA(average.day, average.name, average.color, series[0].data);
- seriesMA = fillSeries(seriesMA, opts, config2);
- opts.seriesMA = seriesMA;
- } else if (opts.seriesMA) {
- seriesMA = opts.seriesMA = fillSeries(opts.seriesMA, opts, config2);
- } else {
- seriesMA = series;
- }
- } else {
- seriesMA = series;
- }
- opts._series_ = series = filterSeries(series);
- opts.area = new Array(4);
- for (let j = 0; j < 4; j++) {
- opts.area[j] = opts.padding[j] * opts.pix;
- }
- var _calLegendData = calLegendData(seriesMA, opts, config2, opts.chartData, context), legendHeight = _calLegendData.area.wholeHeight, legendWidth = _calLegendData.area.wholeWidth;
- switch (opts.legend.position) {
- case "top":
- opts.area[0] += legendHeight;
- break;
- case "bottom":
- opts.area[2] += legendHeight;
- break;
- case "left":
- opts.area[3] += legendWidth;
- break;
- case "right":
- opts.area[1] += legendWidth;
- break;
- }
- let _calYAxisData = {}, yAxisWidth = 0;
- 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") {
- _calYAxisData = calYAxisData(series, opts, config2, context);
- yAxisWidth = _calYAxisData.yAxisWidth;
- if (opts.yAxis.showTitle) {
- let maxTitleHeight = 0;
- for (let i = 0; i < opts.yAxis.data.length; i++) {
- maxTitleHeight = Math.max(maxTitleHeight, opts.yAxis.data[i].titleFontSize ? opts.yAxis.data[i].titleFontSize * opts.pix : config2.fontSize);
- }
- opts.area[0] += maxTitleHeight;
- }
- let rightIndex = 0, leftIndex = 0;
- for (let i = 0; i < yAxisWidth.length; i++) {
- if (yAxisWidth[i].position == "left") {
- if (leftIndex > 0) {
- opts.area[3] += yAxisWidth[i].width + opts.yAxis.padding * opts.pix;
- } else {
- opts.area[3] += yAxisWidth[i].width;
- }
- leftIndex += 1;
- } else if (yAxisWidth[i].position == "right") {
- if (rightIndex > 0) {
- opts.area[1] += yAxisWidth[i].width + opts.yAxis.padding * opts.pix;
- } else {
- opts.area[1] += yAxisWidth[i].width;
- }
- rightIndex += 1;
- }
- }
- } else {
- config2.yAxisWidth = yAxisWidth;
- }
- opts.chartData.yAxisData = _calYAxisData;
- if (opts.categories && opts.categories.length && opts.type !== "radar" && opts.type !== "gauge" && opts.type !== "bar") {
- opts.chartData.xAxisData = getXAxisPoints(opts.categories, opts, config2);
- let _calCategoriesData = calCategoriesData(opts.categories, opts, config2, opts.chartData.xAxisData.eachSpacing, context), xAxisHeight = _calCategoriesData.xAxisHeight, angle = _calCategoriesData.angle;
- config2.xAxisHeight = xAxisHeight;
- config2._xAxisTextAngle_ = angle;
- opts.area[2] += xAxisHeight;
- opts.chartData.categoriesData = _calCategoriesData;
- } else {
- if (opts.type === "line" || opts.type === "area" || opts.type === "scatter" || opts.type === "bubble" || opts.type === "bar") {
- opts.chartData.xAxisData = calXAxisData(series, opts, config2, context);
- categories = opts.chartData.xAxisData.rangesFormat;
- let _calCategoriesData = calCategoriesData(categories, opts, config2, opts.chartData.xAxisData.eachSpacing, context), xAxisHeight = _calCategoriesData.xAxisHeight, angle = _calCategoriesData.angle;
- config2.xAxisHeight = xAxisHeight;
- config2._xAxisTextAngle_ = angle;
- opts.area[2] += xAxisHeight;
- opts.chartData.categoriesData = _calCategoriesData;
- } else {
- opts.chartData.xAxisData = {
- xAxisPoints: []
- };
- }
- }
- if (opts.enableScroll && opts.xAxis.scrollAlign == "right" && opts._scrollDistance_ === void 0) {
- let offsetLeft = 0, xAxisPoints = opts.chartData.xAxisData.xAxisPoints, startX = opts.chartData.xAxisData.startX, endX = opts.chartData.xAxisData.endX, eachSpacing = opts.chartData.xAxisData.eachSpacing;
- let totalWidth = eachSpacing * (xAxisPoints.length - 1);
- let screenWidth = endX - startX;
- offsetLeft = screenWidth - totalWidth;
- _this.scrollOption.currentOffset = offsetLeft;
- _this.scrollOption.startTouchX = offsetLeft;
- _this.scrollOption.distance = 0;
- _this.scrollOption.lastMoveTime = 0;
- opts._scrollDistance_ = offsetLeft;
- }
- if (type === "pie" || type === "ring" || type === "rose") {
- config2._pieTextMaxLength_ = opts.dataLabel === false ? 0 : getPieTextMaxLength(seriesMA, config2, context, opts);
- }
- switch (type) {
- case "word":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawWordCloudDataPoints(series, opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "map":
- context.clearRect(0, 0, opts.width, opts.height);
- drawMapDataPoints(series, opts, config2, context);
- setTimeout(() => {
- this.uevent.trigger("renderComplete");
- }, 50);
- break;
- case "funnel":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.funnelData = drawFunnelDataPoints(series, opts, config2, context, process);
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "line":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawLineDataPoints = drawLineDataPoints(series, opts, config2, context, process), xAxisPoints = _drawLineDataPoints.xAxisPoints, calPoints = _drawLineDataPoints.calPoints, eachSpacing = _drawLineDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "scatter":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawScatterDataPoints = drawScatterDataPoints(series, opts, config2, context, process), xAxisPoints = _drawScatterDataPoints.xAxisPoints, calPoints = _drawScatterDataPoints.calPoints, eachSpacing = _drawScatterDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "bubble":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawBubbleDataPoints = drawBubbleDataPoints(series, opts, config2, context, process), xAxisPoints = _drawBubbleDataPoints.xAxisPoints, calPoints = _drawBubbleDataPoints.calPoints, eachSpacing = _drawBubbleDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "mix":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawMixDataPoints = drawMixDataPoints(series, opts, config2, context, process), xAxisPoints = _drawMixDataPoints.xAxisPoints, calPoints = _drawMixDataPoints.calPoints, eachSpacing = _drawMixDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "column":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawColumnDataPoints = drawColumnDataPoints(series, opts, config2, context, process), xAxisPoints = _drawColumnDataPoints.xAxisPoints, calPoints = _drawColumnDataPoints.calPoints, eachSpacing = _drawColumnDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "mount":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawMountDataPoints = drawMountDataPoints(series, opts, config2, context, process), xAxisPoints = _drawMountDataPoints.xAxisPoints, calPoints = _drawMountDataPoints.calPoints, eachSpacing = _drawMountDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "bar":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawXAxis(categories, opts, config2, context);
- var _drawBarDataPoints = drawBarDataPoints(series, opts, config2, context, process), yAxisPoints = _drawBarDataPoints.yAxisPoints, calPoints = _drawBarDataPoints.calPoints, eachSpacing = _drawBarDataPoints.eachSpacing;
- opts.chartData.yAxisPoints = yAxisPoints;
- opts.chartData.xAxisPoints = opts.chartData.xAxisData.xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, yAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "area":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawAreaDataPoints = drawAreaDataPoints(series, opts, config2, context, process), xAxisPoints = _drawAreaDataPoints.xAxisPoints, calPoints = _drawAreaDataPoints.calPoints, eachSpacing = _drawAreaDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "ring":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.pieData = drawPieDataPoints(series, opts, config2, context, process);
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "pie":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.pieData = drawPieDataPoints(series, opts, config2, context, process);
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "rose":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.pieData = drawRoseDataPoints(series, opts, config2, context, process);
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "radar":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.radarData = drawRadarDataPoints(series, opts, config2, context, process);
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- drawToolTipBridge(opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "arcbar":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.arcbarData = drawArcbarDataPoints(series, opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "gauge":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- opts.chartData.gaugeData = drawGaugeDataPoints(categories, series, opts, config2, context, process);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- case "candle":
- this.animationInstance = new Animation({
- timing: opts.timing,
- duration,
- onProcess: function onProcess(process) {
- context.clearRect(0, 0, opts.width, opts.height);
- if (opts.rotate) {
- contextRotate(context, opts);
- }
- drawYAxisGrid(categories, opts, config2, context);
- drawXAxis(categories, opts, config2, context);
- var _drawCandleDataPoints = drawCandleDataPoints(series, seriesMA, opts, config2, context, process), xAxisPoints = _drawCandleDataPoints.xAxisPoints, calPoints = _drawCandleDataPoints.calPoints, eachSpacing = _drawCandleDataPoints.eachSpacing;
- opts.chartData.xAxisPoints = xAxisPoints;
- opts.chartData.calPoints = calPoints;
- opts.chartData.eachSpacing = eachSpacing;
- drawYAxis(series, opts, config2, context);
- if (opts.enableMarkLine !== false && process === 1) {
- drawMarkLine(opts, config2, context);
- }
- if (seriesMA) {
- drawLegend(seriesMA, opts, config2, context, opts.chartData);
- } else {
- drawLegend(opts.series, opts, config2, context, opts.chartData);
- }
- drawToolTipBridge(opts, config2, context, process, eachSpacing, xAxisPoints);
- drawCanvas(opts, context);
- },
- onAnimationFinish: function onAnimationFinish() {
- _this.uevent.trigger("renderComplete");
- }
- });
- break;
- }
- }
- function uChartsEvent() {
- this.events = {};
- }
- uChartsEvent.prototype.addEventListener = function(type, listener) {
- this.events[type] = this.events[type] || [];
- this.events[type].push(listener);
- };
- uChartsEvent.prototype.delEventListener = function(type) {
- this.events[type] = [];
- };
- uChartsEvent.prototype.trigger = function() {
- for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
- args[_key] = arguments[_key];
- }
- var type = args[0];
- var params = args.slice(1);
- if (!!this.events[type]) {
- this.events[type].forEach(function(listener) {
- try {
- listener.apply(null, params);
- } catch (e) {
- }
- });
- }
- };
- var uCharts = function uCharts2(opts) {
- opts.pix = opts.pixelRatio ? opts.pixelRatio : 1;
- opts.fontSize = opts.fontSize ? opts.fontSize : 13;
- opts.fontColor = opts.fontColor ? opts.fontColor : config.fontColor;
- if (opts.background == "" || opts.background == "none") {
- opts.background = "#FFFFFF";
- }
- opts.title = assign({}, opts.title);
- opts.subtitle = assign({}, opts.subtitle);
- opts.duration = opts.duration ? opts.duration : 1e3;
- opts.yAxis = assign({}, {
- data: [],
- showTitle: false,
- disabled: false,
- disableGrid: false,
- gridSet: "number",
- splitNumber: 5,
- gridType: "solid",
- dashLength: 4 * opts.pix,
- gridColor: "#cccccc",
- padding: 10,
- fontColor: "#666666"
- }, opts.yAxis);
- opts.xAxis = assign({}, {
- rotateLabel: false,
- rotateAngle: 45,
- disabled: false,
- disableGrid: false,
- splitNumber: 5,
- calibration: false,
- fontColor: "#666666",
- fontSize: 13,
- lineHeight: 20,
- marginTop: 0,
- gridType: "solid",
- dashLength: 4,
- scrollAlign: "left",
- boundaryGap: "center",
- axisLine: true,
- axisLineColor: "#cccccc",
- titleFontSize: 13,
- titleOffsetY: 0,
- titleOffsetX: 0,
- titleFontColor: "#666666"
- }, opts.xAxis);
- opts.xAxis.scrollPosition = opts.xAxis.scrollAlign;
- opts.legend = assign({}, {
- show: true,
- position: "bottom",
- float: "center",
- backgroundColor: "rgba(0,0,0,0)",
- borderColor: "rgba(0,0,0,0)",
- borderWidth: 0,
- padding: 5,
- margin: 5,
- itemGap: 10,
- fontSize: opts.fontSize,
- lineHeight: opts.fontSize,
- fontColor: opts.fontColor,
- formatter: {},
- hiddenColor: "#CECECE"
- }, opts.legend);
- opts.extra = assign({
- tooltip: {
- legendShape: "auto"
- }
- }, opts.extra);
- opts.rotate = opts.rotate ? true : false;
- opts.animation = opts.animation ? true : false;
- opts.rotate = opts.rotate ? true : false;
- opts.canvas2d = opts.canvas2d ? true : false;
- let config$$1 = assign({}, config);
- config$$1.color = opts.color ? opts.color : config$$1.color;
- if (opts.type == "pie") {
- config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.pie.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
- }
- if (opts.type == "ring") {
- config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.ring.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
- }
- if (opts.type == "rose") {
- config$$1.pieChartLinePadding = opts.dataLabel === false ? 0 : opts.extra.rose.labelWidth * opts.pix || config$$1.pieChartLinePadding * opts.pix;
- }
- config$$1.pieChartTextPadding = opts.dataLabel === false ? 0 : config$$1.pieChartTextPadding * opts.pix;
- config$$1.rotate = opts.rotate;
- if (opts.rotate) {
- let tempWidth = opts.width;
- let tempHeight = opts.height;
- opts.width = tempHeight;
- opts.height = tempWidth;
- }
- opts.padding = opts.padding ? opts.padding : config$$1.padding;
- config$$1.yAxisWidth = config.yAxisWidth * opts.pix;
- config$$1.fontSize = opts.fontSize * opts.pix;
- config$$1.titleFontSize = config.titleFontSize * opts.pix;
- config$$1.subtitleFontSize = config.subtitleFontSize * opts.pix;
- if (!opts.context) {
- 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");
- }
- this.context = opts.context;
- if (!this.context.setTextAlign) {
- this.context.setStrokeStyle = function(e) {
- return this.strokeStyle = e;
- };
- this.context.setLineWidth = function(e) {
- return this.lineWidth = e;
- };
- this.context.setLineCap = function(e) {
- return this.lineCap = e;
- };
- this.context.setFontSize = function(e) {
- return this.font = e + "px sans-serif";
- };
- this.context.setFillStyle = function(e) {
- return this.fillStyle = e;
- };
- this.context.setTextAlign = function(e) {
- return this.textAlign = e;
- };
- this.context.setTextBaseline = function(e) {
- return this.textBaseline = e;
- };
- this.context.setShadow = function(offsetX, offsetY, blur, color3) {
- this.shadowColor = color3;
- this.shadowOffsetX = offsetX;
- this.shadowOffsetY = offsetY;
- this.shadowBlur = blur;
- };
- this.context.draw = function() {
- };
- }
- if (!this.context.setLineDash) {
- this.context.setLineDash = function(e) {
- };
- }
- opts.chartData = {};
- this.uevent = new uChartsEvent();
- this.scrollOption = {
- currentOffset: 0,
- startTouchX: 0,
- distance: 0,
- lastMoveTime: 0
- };
- this.opts = opts;
- this.config = config$$1;
- drawCharts.call(this, opts.type, opts, config$$1, this.context);
- };
- uCharts.prototype.updateData = function() {
- let data = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
- this.opts = assign({}, this.opts, data);
- this.opts.updateData = true;
- let scrollPosition = data.scrollPosition || "current";
- switch (scrollPosition) {
- case "current":
- this.opts._scrollDistance_ = this.scrollOption.currentOffset;
- break;
- case "left":
- this.opts._scrollDistance_ = 0;
- this.scrollOption = {
- currentOffset: 0,
- startTouchX: 0,
- distance: 0,
- lastMoveTime: 0
- };
- break;
- case "right":
- let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config, this.context), yAxisWidth = _calYAxisData.yAxisWidth;
- this.config.yAxisWidth = yAxisWidth;
- let offsetLeft = 0;
- let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
- let totalWidth = eachSpacing * (xAxisPoints.length - 1);
- let screenWidth = endX - startX;
- offsetLeft = screenWidth - totalWidth;
- this.scrollOption = {
- currentOffset: offsetLeft,
- startTouchX: offsetLeft,
- distance: 0,
- lastMoveTime: 0
- };
- this.opts._scrollDistance_ = offsetLeft;
- break;
- }
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
- };
- uCharts.prototype.zoom = function() {
- var val = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.opts.xAxis.itemCount;
- if (this.opts.enableScroll !== true) {
- console.log("[uCharts] \u8BF7\u542F\u7528\u6EDA\u52A8\u6761\u540E\u4F7F\u7528");
- return;
- }
- let centerPoint = Math.round(Math.abs(this.scrollOption.currentOffset) / this.opts.chartData.eachSpacing) + Math.round(this.opts.xAxis.itemCount / 2);
- this.opts.animation = false;
- this.opts.xAxis.itemCount = val.itemCount;
- let _calYAxisData = calYAxisData(this.opts.series, this.opts, this.config, this.context), yAxisWidth = _calYAxisData.yAxisWidth;
- this.config.yAxisWidth = yAxisWidth;
- let offsetLeft = 0;
- let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
- let centerLeft = eachSpacing * centerPoint;
- let screenWidth = endX - startX;
- let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1);
- offsetLeft = screenWidth / 2 - centerLeft;
- if (offsetLeft > 0) {
- offsetLeft = 0;
- }
- if (offsetLeft < MaxLeft) {
- offsetLeft = MaxLeft;
- }
- this.scrollOption = {
- currentOffset: offsetLeft,
- startTouchX: 0,
- distance: 0,
- lastMoveTime: 0
- };
- calValidDistance(this, offsetLeft, this.opts.chartData, this.config, this.opts);
- this.opts._scrollDistance_ = offsetLeft;
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
- };
- uCharts.prototype.dobuleZoom = function(e) {
- if (this.opts.enableScroll !== true) {
- console.log("[uCharts] \u8BF7\u542F\u7528\u6EDA\u52A8\u6761\u540E\u4F7F\u7528");
- return;
- }
- const tcs = e.changedTouches;
- if (tcs.length < 2) {
- return;
- }
- for (var i = 0; i < tcs.length; i++) {
- tcs[i].x = tcs[i].x ? tcs[i].x : tcs[i].clientX;
- tcs[i].y = tcs[i].y ? tcs[i].y : tcs[i].clientY;
- }
- const ntcs = [getTouches(tcs[0], this.opts, e), getTouches(tcs[1], this.opts, e)];
- const xlength = Math.abs(ntcs[0].x - ntcs[1].x);
- if (!this.scrollOption.moveCount) {
- let cts0 = { changedTouches: [{ x: tcs[0].x, y: this.opts.area[0] / this.opts.pix + 2 }] };
- let cts1 = { changedTouches: [{ x: tcs[1].x, y: this.opts.area[0] / this.opts.pix + 2 }] };
- if (this.opts.rotate) {
- cts0 = { changedTouches: [{ x: this.opts.height / this.opts.pix - this.opts.area[0] / this.opts.pix - 2, y: tcs[0].y }] };
- cts1 = { changedTouches: [{ x: this.opts.height / this.opts.pix - this.opts.area[0] / this.opts.pix - 2, y: tcs[1].y }] };
- }
- const moveCurrent1 = this.getCurrentDataIndex(cts0).index;
- const moveCurrent2 = this.getCurrentDataIndex(cts1).index;
- const moveCount = Math.abs(moveCurrent1 - moveCurrent2);
- this.scrollOption.moveCount = moveCount;
- this.scrollOption.moveCurrent1 = Math.min(moveCurrent1, moveCurrent2);
- this.scrollOption.moveCurrent2 = Math.max(moveCurrent1, moveCurrent2);
- return;
- }
- let currentEachSpacing = xlength / this.scrollOption.moveCount;
- let itemCount = (this.opts.width - this.opts.area[1] - this.opts.area[3]) / currentEachSpacing;
- itemCount = itemCount <= 2 ? 2 : itemCount;
- itemCount = itemCount >= this.opts.categories.length ? this.opts.categories.length : itemCount;
- this.opts.animation = false;
- this.opts.xAxis.itemCount = itemCount;
- let offsetLeft = 0;
- let _getXAxisPoints0 = getXAxisPoints(this.opts.categories, this.opts, this.config), xAxisPoints = _getXAxisPoints0.xAxisPoints, startX = _getXAxisPoints0.startX, endX = _getXAxisPoints0.endX, eachSpacing = _getXAxisPoints0.eachSpacing;
- let currentLeft = eachSpacing * this.scrollOption.moveCurrent1;
- let screenWidth = endX - startX;
- let MaxLeft = screenWidth - eachSpacing * (xAxisPoints.length - 1);
- offsetLeft = -currentLeft + Math.min(ntcs[0].x, ntcs[1].x) - this.opts.area[3] - eachSpacing;
- if (offsetLeft > 0) {
- offsetLeft = 0;
- }
- if (offsetLeft < MaxLeft) {
- offsetLeft = MaxLeft;
- }
- this.scrollOption.currentOffset = offsetLeft;
- this.scrollOption.startTouchX = 0;
- this.scrollOption.distance = 0;
- calValidDistance(this, offsetLeft, this.opts.chartData, this.config, this.opts);
- this.opts._scrollDistance_ = offsetLeft;
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
- };
- uCharts.prototype.stopAnimation = function() {
- this.animationInstance && this.animationInstance.stop();
- };
- uCharts.prototype.addEventListener = function(type, listener) {
- this.uevent.addEventListener(type, listener);
- };
- uCharts.prototype.delEventListener = function(type) {
- this.uevent.delEventListener(type);
- };
- uCharts.prototype.getCurrentDataIndex = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- let _touches$ = getTouches(touches, this.opts, e);
- if (this.opts.type === "pie" || this.opts.type === "ring") {
- return findPieChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.pieData, this.opts);
- } else if (this.opts.type === "rose") {
- return findRoseChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.pieData, this.opts);
- } else if (this.opts.type === "radar") {
- return findRadarChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.radarData, this.opts.categories.length);
- } else if (this.opts.type === "funnel") {
- return findFunnelChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.funnelData);
- } else if (this.opts.type === "map") {
- return findMapChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts);
- } else if (this.opts.type === "word") {
- return findWordChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.wordCloudData);
- } else if (this.opts.type === "bar") {
- return findBarChartCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.calPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
- } else {
- return findCurrentIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.calPoints, this.opts, this.config, Math.abs(this.scrollOption.currentOffset));
- }
- }
- return -1;
- };
- uCharts.prototype.getLegendDataIndex = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- let _touches$ = getTouches(touches, this.opts, e);
- return findLegendIndex({
- x: _touches$.x,
- y: _touches$.y
- }, this.opts.chartData.legendData);
- }
- return -1;
- };
- uCharts.prototype.touchLegend = function(e) {
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches) {
- var _touches$ = getTouches(touches, this.opts, e);
- var index = this.getLegendDataIndex(e);
- if (index >= 0) {
- if (this.opts.type == "candle") {
- this.opts.seriesMA[index].show = !this.opts.seriesMA[index].show;
- } else {
- this.opts.series[index].show = !this.opts.series[index].show;
- }
- this.opts.animation = option.animation ? true : false;
- this.opts._scrollDistance_ = this.scrollOption.currentOffset;
- drawCharts.call(this, this.opts.type, this.opts, this.config, this.context);
- }
- }
- };
- uCharts.prototype.showToolTip = function(e) {
- var option = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (!touches) {
- console.log("[uCharts] \u672A\u83B7\u53D6\u5230event\u5750\u6807\u4FE1\u606F");
- }
- var _touches$ = getTouches(touches, this.opts, e);
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- if (this.opts.type === "line" || this.opts.type === "area" || this.opts.type === "column" || this.opts.type === "scatter" || this.opts.type === "bubble") {
- var current = this.getCurrentDataIndex(e);
- var index = option.index == void 0 ? current.index : option.index;
- if (index > -1 || index.length > 0) {
- var seriesData = getSeriesDataItem(this.opts.series, index, current.group);
- if (seriesData.length !== 0) {
- var _getToolTipData = getToolTipData(seriesData, this.opts, index, current.group, this.opts.categories, option), textList = _getToolTipData.textList, offset = _getToolTipData.offset;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: option.textList !== void 0 ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index,
- group: current.group
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "mount") {
- var index = option.index == void 0 ? this.getCurrentDataIndex(e).index : option.index;
- if (index > -1) {
- var opts = assign({}, this.opts, { animation: false });
- var seriesData = assign({}, opts._series_[index]);
- var textList = [{
- text: option.formatter ? option.formatter(seriesData, void 0, index, opts) : seriesData.name + ": " + seriesData.data,
- color: seriesData.color,
- legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
- }];
- var offset = {
- x: opts.chartData.calPoints[index].x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "bar") {
- var current = this.getCurrentDataIndex(e);
- var index = option.index == void 0 ? current.index : option.index;
- if (index > -1 || index.length > 0) {
- var seriesData = getSeriesDataItem(this.opts.series, index, current.group);
- if (seriesData.length !== 0) {
- var _getToolTipData = getToolTipData(seriesData, this.opts, index, current.group, this.opts.categories, option), textList = _getToolTipData.textList, offset = _getToolTipData.offset;
- offset.x = _touches$.x;
- opts.tooltip = {
- textList: option.textList !== void 0 ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "mix") {
- var current = this.getCurrentDataIndex(e);
- var index = option.index == void 0 ? current.index : option.index;
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var _getMixToolTipData = getMixToolTipData(seriesData, this.opts, index, this.opts.categories, option), textList = _getMixToolTipData.textList, offset = _getMixToolTipData.offset;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "candle") {
- var current = this.getCurrentDataIndex(e);
- var index = option.index == void 0 ? current.index : option.index;
- if (index > -1) {
- var currentOffset = this.scrollOption.currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset,
- animation: false
- });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- 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;
- offset.y = _touches$.y;
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "pie" || this.opts.type === "ring" || this.opts.type === "rose" || this.opts.type === "funnel") {
- var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
- if (index > -1) {
- var opts = assign({}, this.opts, { animation: false });
- var seriesData = assign({}, opts._series_[index]);
- var textList = [{
- text: option.formatter ? option.formatter(seriesData, void 0, index, opts) : seriesData.name + ": " + seriesData.data,
- color: seriesData.color,
- legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
- }];
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "map") {
- var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
- if (index > -1) {
- var opts = assign({}, this.opts, { animation: false });
- var seriesData = assign({}, this.opts.series[index]);
- seriesData.name = seriesData.properties.name;
- var textList = [{
- text: option.formatter ? option.formatter(seriesData, void 0, index, this.opts) : seriesData.name,
- color: seriesData.color,
- legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
- }];
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- opts.updateData = false;
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "word") {
- var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
- if (index > -1) {
- var opts = assign({}, this.opts, { animation: false });
- var seriesData = assign({}, this.opts.series[index]);
- var textList = [{
- text: option.formatter ? option.formatter(seriesData, void 0, index, this.opts) : seriesData.name,
- color: seriesData.color,
- legendShape: this.opts.extra.tooltip.legendShape == "auto" ? seriesData.legendShape : this.opts.extra.tooltip.legendShape
- }];
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- opts.updateData = false;
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- if (this.opts.type === "radar") {
- var index = option.index == void 0 ? this.getCurrentDataIndex(e) : option.index;
- if (index > -1) {
- var opts = assign({}, this.opts, { animation: false });
- var seriesData = getSeriesDataItem(this.opts.series, index);
- if (seriesData.length !== 0) {
- var textList = seriesData.map((item) => {
- return {
- text: option.formatter ? option.formatter(item, this.opts.categories[index], index, this.opts) : item.name + ": " + item.data,
- color: item.color,
- legendShape: this.opts.extra.tooltip.legendShape == "auto" ? item.legendShape : this.opts.extra.tooltip.legendShape
- };
- });
- var offset = {
- x: _touches$.x,
- y: _touches$.y
- };
- opts.tooltip = {
- textList: option.textList ? option.textList : textList,
- offset: option.offset !== void 0 ? option.offset : offset,
- option,
- index
- };
- }
- }
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- }
- };
- uCharts.prototype.translate = function(distance) {
- this.scrollOption = {
- currentOffset: distance,
- startTouchX: distance,
- distance: 0,
- lastMoveTime: 0
- };
- let opts = assign({}, this.opts, {
- _scrollDistance_: distance,
- animation: false
- });
- drawCharts.call(this, this.opts.type, opts, this.config, this.context);
- };
- uCharts.prototype.scrollStart = function(e) {
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- var _touches$ = getTouches(touches, this.opts, e);
- if (touches && this.opts.enableScroll === true) {
- this.scrollOption.startTouchX = _touches$.x;
- }
- };
- uCharts.prototype.scroll = function(e) {
- if (this.scrollOption.lastMoveTime === 0) {
- this.scrollOption.lastMoveTime = Date.now();
- }
- let Limit = this.opts.touchMoveLimit || 60;
- let currMoveTime = Date.now();
- let duration = currMoveTime - this.scrollOption.lastMoveTime;
- if (duration < Math.floor(1e3 / Limit))
- return;
- if (this.scrollOption.startTouchX == 0)
- return;
- this.scrollOption.lastMoveTime = currMoveTime;
- var touches = null;
- if (e.changedTouches) {
- touches = e.changedTouches[0];
- } else {
- touches = e.mp.changedTouches[0];
- }
- if (touches && this.opts.enableScroll === true) {
- var _touches$ = getTouches(touches, this.opts, e);
- var _distance;
- _distance = _touches$.x - this.scrollOption.startTouchX;
- var currentOffset = this.scrollOption.currentOffset;
- var validDistance = calValidDistance(this, currentOffset + _distance, this.opts.chartData, this.config, this.opts);
- this.scrollOption.distance = _distance = validDistance - currentOffset;
- var opts = assign({}, this.opts, {
- _scrollDistance_: currentOffset + _distance,
- animation: false
- });
- this.opts = opts;
- drawCharts.call(this, opts.type, opts, this.config, this.context);
- return currentOffset + _distance;
- }
- };
- uCharts.prototype.scrollEnd = function(e) {
- if (this.opts.enableScroll === true) {
- var _scrollOption = this.scrollOption, currentOffset = _scrollOption.currentOffset, distance = _scrollOption.distance;
- this.scrollOption.currentOffset = currentOffset + distance;
- this.scrollOption.distance = 0;
- this.scrollOption.moveCount = 0;
- }
- };
- var u_charts_default = uCharts;
-
- // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/config-ucharts.js
- var color = ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"];
- var formatDateTime = (timeStamp, returnType) => {
- var date = /* @__PURE__ */ new Date();
- date.setTime(timeStamp * 1e3);
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? "0" + m : m;
- var d = date.getDate();
- d = d < 10 ? "0" + d : d;
- var h = date.getHours();
- h = h < 10 ? "0" + h : h;
- var minute = date.getMinutes();
- var second = date.getSeconds();
- minute = minute < 10 ? "0" + minute : minute;
- second = second < 10 ? "0" + second : second;
- if (returnType == "full") {
- return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
- }
- if (returnType == "y-m-d") {
- return y + "-" + m + "-" + d;
- }
- if (returnType == "h:m") {
- return h + ":" + minute;
- }
- if (returnType == "h:m:s") {
- return h + ":" + minute + ":" + second;
- }
- return [y, m, d, h, minute, second];
- };
- var cfu = {
- //demotype为自定义图表类型,一般不需要自定义图表类型,只需要改根节点上对应的类型即可
- "type": ["pie", "ring", "rose", "word", "funnel", "map", "arcbar", "line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "tline", "tarea", "scatter", "bubble", "demotype"],
- "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"],
- //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型,例如最后的"demotype"
- //自定义类型时需要注意"tline","tarea","scatter","bubble"等时间轴(矢量x轴)类图表,没有categories,不需要加入categories
- "categories": ["line", "column", "mount", "bar", "area", "radar", "gauge", "candle", "mix", "demotype"],
- //instance为实例变量承载属性,不要删除
- "instance": {},
- //option为opts及eopts承载属性,不要删除
- "option": {},
- //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
- "formatter": {
- "yAxisDemo1": function(val, index, opts) {
- return val + "\u5143";
- },
- "yAxisDemo2": function(val, index, opts) {
- return val.toFixed(2);
- },
- "xAxisDemo1": function(val, index, opts) {
- return val + "\u5E74";
- },
- "xAxisDemo2": function(val, index, opts) {
- return formatDateTime(val, "h:m");
- },
- "seriesDemo1": function(val, index, series, opts) {
- return val + "\u5143";
- },
- "tooltipDemo1": function(item, category, index, opts) {
- if (index == 0) {
- return "\u968F\u4FBF\u7528" + item.data + "\u5E74";
- } else {
- return "\u5176\u4ED6\u6211\u6CA1\u6539" + item.data + "\u5929";
- }
- },
- "pieDemo": function(val, index, series, opts) {
- if (index !== void 0) {
- return series[index].name + "\uFF1A" + series[index].data + "\u5143";
- }
- },
- "timedemo": function(val, index, series) {
- if (series.xAxis.data.includes(Number(val))) {
- return val;
- }
- return "";
- }
- },
- //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在opts参数,会将demotype与opts中option合并后渲染图表。
- "demotype": {
- //我这里把曲线图当做了自定义图表类型,您可以根据需要随意指定类型或配置
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2
- },
- "legend": {},
- "extra": {
- "line": {
- "type": "curve",
- "width": 2
- }
- }
- },
- //下面是自定义配置,请添加项目所需的通用配置
- "pie": {
- "type": "pie",
- "color": color,
- "padding": [5, 5, 5, 5],
- "extra": {
- "pie": {
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": true,
- "borderWidth": 3,
- "borderColor": "#FFFFFF"
- }
- }
- },
- "ring": {
- "type": "ring",
- "color": color,
- "padding": [5, 5, 5, 5],
- "rotate": false,
- "dataLabel": true,
- "legend": {
- "show": true,
- "position": "right",
- "lineHeight": 25
- },
- "title": {
- "name": "\u6536\u76CA\u7387",
- "fontSize": 15,
- "color": "#666666"
- },
- "subtitle": {
- "name": "70%",
- "fontSize": 25,
- "color": "#7cb5ec"
- },
- "extra": {
- "ring": {
- "ringWidth": 30,
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": true,
- "borderWidth": 3,
- "borderColor": "#FFFFFF"
- }
- }
- },
- "rose": {
- "type": "rose",
- "color": color,
- "padding": [5, 5, 5, 5],
- "legend": {
- "show": true,
- "position": "left",
- "lineHeight": 25
- },
- "extra": {
- "rose": {
- "type": "area",
- "minRadius": 50,
- "activeOpacity": 0.5,
- "activeRadius": 10,
- "offsetAngle": 0,
- "labelWidth": 15,
- "border": false,
- "borderWidth": 2,
- "borderColor": "#FFFFFF"
- }
- }
- },
- "word": {
- "type": "word",
- "color": color,
- "extra": {
- "word": {
- "type": "normal",
- "autoColors": false
- }
- }
- },
- "funnel": {
- "type": "funnel",
- "color": color,
- "padding": [15, 15, 0, 15],
- "extra": {
- "funnel": {
- "activeOpacity": 0.3,
- "activeWidth": 10,
- "border": true,
- "borderWidth": 2,
- "borderColor": "#FFFFFF",
- "fillOpacity": 1,
- "labelAlign": "right"
- }
- }
- },
- "map": {
- "type": "map",
- "color": color,
- "padding": [0, 0, 0, 0],
- "dataLabel": true,
- "extra": {
- "map": {
- "border": true,
- "borderWidth": 1,
- "borderColor": "#666666",
- "fillOpacity": 0.6,
- "activeBorderColor": "#F04864",
- "activeFillColor": "#FACC14",
- "activeFillOpacity": 1
- }
- }
- },
- "arcbar": {
- "type": "arcbar",
- "color": color,
- "title": {
- "name": "\u767E\u5206\u6BD4",
- "fontSize": 25,
- "color": "#00FF00"
- },
- "subtitle": {
- "name": "\u9ED8\u8BA4\u6807\u9898",
- "fontSize": 15,
- "color": "#666666"
- },
- "extra": {
- "arcbar": {
- "type": "default",
- "width": 12,
- "backgroundColor": "#E9E9E9",
- "startAngle": 0.75,
- "endAngle": 0.25,
- "gap": 2
- }
- }
- },
- "line": {
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2
- },
- "legend": {},
- "extra": {
- "line": {
- "type": "straight",
- "width": 2,
- "activeType": "hollow"
- }
- }
- },
- "tline": {
- "type": "line",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": false,
- "boundaryGap": "justify"
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- "data": [
- {
- "min": 0,
- "max": 80
- }
- ]
- },
- "legend": {},
- "extra": {
- "line": {
- "type": "curve",
- "width": 2,
- "activeType": "hollow"
- }
- }
- },
- "tarea": {
- "type": "area",
- "color": color,
- "padding": [15, 10, 0, 15],
- "xAxis": {
- "disableGrid": true,
- "boundaryGap": "justify"
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2,
- "data": [
- {
- "min": 0,
- "max": 80
- }
- ]
- },
- "legend": {},
- "extra": {
- "area": {
- "type": "curve",
- "opacity": 0.2,
- "addLine": true,
- "width": 2,
- "gradient": true,
- "activeType": "hollow"
- }
- }
- },
- "column": {
- "type": "column",
- "color": color,
- "padding": [15, 15, 0, 5],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "data": [{ "min": 0 }]
- },
- "legend": {},
- "extra": {
- "column": {
- "type": "group",
- "width": 30,
- "activeBgColor": "#000000",
- "activeBgOpacity": 0.08
- }
- }
- },
- "mount": {
- "type": "mount",
- "color": color,
- "padding": [15, 15, 0, 5],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "data": [{ "min": 0 }]
- },
- "legend": {},
- "extra": {
- "mount": {
- "type": "mount",
- "widthRatio": 1.5
- }
- }
- },
- "bar": {
- "type": "bar",
- "color": color,
- "padding": [15, 30, 0, 5],
- "xAxis": {
- "boundaryGap": "justify",
- "disableGrid": false,
- "min": 0,
- "axisLine": false
- },
- "yAxis": {},
- "legend": {},
- "extra": {
- "bar": {
- "type": "group",
- "width": 30,
- "meterBorde": 1,
- "meterFillColor": "#FFFFFF",
- "activeBgColor": "#000000",
- "activeBgOpacity": 0.08
- }
- }
- },
- "area": {
- "type": "area",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "gridType": "dash",
- "dashLength": 2
- },
- "legend": {},
- "extra": {
- "area": {
- "type": "straight",
- "opacity": 0.2,
- "addLine": true,
- "width": 2,
- "gradient": false,
- "activeType": "hollow"
- }
- }
- },
- "radar": {
- "type": "radar",
- "color": color,
- "padding": [5, 5, 5, 5],
- "dataLabel": false,
- "legend": {
- "show": true,
- "position": "right",
- "lineHeight": 25
- },
- "extra": {
- "radar": {
- "gridType": "radar",
- "gridColor": "#CCCCCC",
- "gridCount": 3,
- "opacity": 0.2,
- "max": 200,
- "labelShow": true
- }
- }
- },
- "gauge": {
- "type": "gauge",
- "color": color,
- "title": {
- "name": "66Km/H",
- "fontSize": 25,
- "color": "#2fc25b",
- "offsetY": 50
- },
- "subtitle": {
- "name": "\u5B9E\u65F6\u901F\u5EA6",
- "fontSize": 15,
- "color": "#1890ff",
- "offsetY": -50
- },
- "extra": {
- "gauge": {
- "type": "default",
- "width": 30,
- "labelColor": "#666666",
- "startAngle": 0.75,
- "endAngle": 0.25,
- "startNumber": 0,
- "endNumber": 100,
- "labelFormat": "",
- "splitLine": {
- "fixRadius": 0,
- "splitNumber": 10,
- "width": 30,
- "color": "#FFFFFF",
- "childNumber": 5,
- "childWidth": 12
- },
- "pointer": {
- "width": 24,
- "color": "auto"
- }
- }
- }
- },
- "candle": {
- "type": "candle",
- "color": color,
- "padding": [15, 15, 0, 15],
- "enableScroll": true,
- "enableMarkLine": true,
- "dataLabel": false,
- "xAxis": {
- "labelCount": 4,
- "itemCount": 40,
- "disableGrid": true,
- "gridColor": "#CCCCCC",
- "gridType": "solid",
- "dashLength": 4,
- "scrollShow": true,
- "scrollAlign": "left",
- "scrollColor": "#A6A6A6",
- "scrollBackgroundColor": "#EFEBEF"
- },
- "yAxis": {},
- "legend": {},
- "extra": {
- "candle": {
- "color": {
- "upLine": "#f04864",
- "upFill": "#f04864",
- "downLine": "#2fc25b",
- "downFill": "#2fc25b"
- },
- "average": {
- "show": true,
- "name": ["MA5", "MA10", "MA30"],
- "day": [5, 10, 20],
- "color": ["#1890ff", "#2fc25b", "#facc14"]
- }
- },
- "markLine": {
- "type": "dash",
- "dashLength": 5,
- "data": [
- {
- "value": 2150,
- "lineColor": "#f04864",
- "showLabel": true
- },
- {
- "value": 2350,
- "lineColor": "#f04864",
- "showLabel": true
- }
- ]
- }
- }
- },
- "mix": {
- "type": "mix",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": true
- },
- "yAxis": {
- "disabled": false,
- "disableGrid": false,
- "splitNumber": 5,
- "gridType": "dash",
- "dashLength": 4,
- "gridColor": "#CCCCCC",
- "padding": 10,
- "showTitle": true,
- "data": []
- },
- "legend": {},
- "extra": {
- "mix": {
- "column": {
- "width": 20
- }
- }
- }
- },
- "scatter": {
- "type": "scatter",
- "color": color,
- "padding": [15, 15, 0, 15],
- "dataLabel": false,
- "xAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "splitNumber": 5,
- "boundaryGap": "justify",
- "min": 0
- },
- "yAxis": {
- "disableGrid": false,
- "gridType": "dash"
- },
- "legend": {},
- "extra": {
- "scatter": {}
- }
- },
- "bubble": {
- "type": "bubble",
- "color": color,
- "padding": [15, 15, 0, 15],
- "xAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "splitNumber": 5,
- "boundaryGap": "justify",
- "min": 0,
- "max": 250
- },
- "yAxis": {
- "disableGrid": false,
- "gridType": "dash",
- "data": [{
- "min": 0,
- "max": 150
- }]
- },
- "legend": {},
- "extra": {
- "bubble": {
- "border": 2,
- "opacity": 0.5
- }
- }
- }
- };
- var config_ucharts_default = cfu;
-
- // ../../../../../project/esswisdom_app/uni_modules/qiun-data-charts/js_sdk/u-charts/config-echarts.js
- var color2 = ["#1890FF", "#91CB74", "#FAC858", "#EE6666", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4", "#ea7ccc"];
- var cfe = {
- //demotype为自定义图表类型
- "type": ["pie", "ring", "rose", "funnel", "line", "column", "area", "radar", "gauge", "candle", "demotype"],
- //增加自定义图表类型,如果需要categories,请在这里加入您的图表类型例如最后的"demotype"
- "categories": ["line", "column", "area", "radar", "gauge", "candle", "demotype"],
- //instance为实例变量承载属性,option为eopts承载属性,不要删除
- "instance": {},
- "option": {},
- //下面是自定义format配置,因除H5端外的其他端无法通过props传递函数,只能通过此属性对应下标的方式来替换
- "formatter": {
- "tooltipDemo1": function(res) {
- let result = "";
- for (let i in res) {
- if (i == 0) {
- result += res[i].axisValueLabel + "\u5E74\u9500\u552E\u989D";
- }
- let value = "--";
- if (res[i].data !== null) {
- value = res[i].data;
- }
- result += "\n" + res[i].seriesName + "\uFF1A" + value + " \u4E07\u5143";
- result += "<br/>" + res[i].marker + res[i].seriesName + "\uFF1A" + value + " \u4E07\u5143";
- }
- return result;
- },
- legendFormat: function(name) {
- return "\u81EA\u5B9A\u4E49\u56FE\u4F8B+" + name;
- },
- yAxisFormatDemo: function(value, index) {
- return value + "\u5143";
- },
- seriesFormatDemo: function(res) {
- return res.name + "\u5E74" + res.value + "\u5143";
- }
- },
- //这里演示了自定义您的图表类型的option,可以随意命名,之后在组件上 type="demotype" 后,组件会调用这个花括号里的option,如果组件上还存在eopts参数,会将demotype与eopts中option合并后渲染图表。
- "demotype": {
- "color": color2
- //在这里填写echarts的option即可
- },
- //下面是自定义配置,请添加项目所需的通用配置
- "column": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "axis"
- },
- "grid": {
- "top": 30,
- "bottom": 50,
- "right": 15,
- "left": 40
- },
- "legend": {
- "bottom": "left"
- },
- "toolbox": {
- "show": false
- },
- "xAxis": {
- "type": "category",
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- },
- "boundaryGap": true,
- "data": []
- },
- "yAxis": {
- "type": "value",
- "axisTick": {
- "show": false
- },
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- }
- },
- "seriesTemplate": {
- "name": "",
- "type": "bar",
- "data": [],
- "barwidth": 20,
- "label": {
- "show": true,
- "color": "#666666",
- "position": "top"
- }
- }
- },
- "line": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "axis"
- },
- "grid": {
- "top": 30,
- "bottom": 50,
- "right": 15,
- "left": 40
- },
- "legend": {
- "bottom": "left"
- },
- "toolbox": {
- "show": false
- },
- "xAxis": {
- "type": "category",
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- },
- "boundaryGap": true,
- "data": []
- },
- "yAxis": {
- "type": "value",
- "axisTick": {
- "show": false
- },
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- }
- },
- "seriesTemplate": {
- "name": "",
- "type": "line",
- "data": [],
- "barwidth": 20,
- "label": {
- "show": true,
- "color": "#666666",
- "position": "top"
- }
- }
- },
- "area": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "axis"
- },
- "grid": {
- "top": 30,
- "bottom": 50,
- "right": 15,
- "left": 40
- },
- "legend": {
- "bottom": "left"
- },
- "toolbox": {
- "show": false
- },
- "xAxis": {
- "type": "category",
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- },
- "boundaryGap": true,
- "data": []
- },
- "yAxis": {
- "type": "value",
- "axisTick": {
- "show": false
- },
- "axisLabel": {
- "color": "#666666"
- },
- "axisLine": {
- "lineStyle": {
- "color": "#CCCCCC"
- }
- }
- },
- "seriesTemplate": {
- "name": "",
- "type": "line",
- "data": [],
- "areaStyle": {},
- "label": {
- "show": true,
- "color": "#666666",
- "position": "top"
- }
- }
- },
- "pie": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "item"
- },
- "grid": {
- "top": 40,
- "bottom": 30,
- "right": 15,
- "left": 15
- },
- "legend": {
- "bottom": "left"
- },
- "seriesTemplate": {
- "name": "",
- "type": "pie",
- "data": [],
- "radius": "50%",
- "label": {
- "show": true,
- "color": "#666666",
- "position": "top"
- }
- }
- },
- "ring": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "item"
- },
- "grid": {
- "top": 40,
- "bottom": 30,
- "right": 15,
- "left": 15
- },
- "legend": {
- "bottom": "left"
- },
- "seriesTemplate": {
- "name": "",
- "type": "pie",
- "data": [],
- "radius": ["40%", "70%"],
- "avoidLabelOverlap": false,
- "label": {
- "show": true,
- "color": "#666666",
- "position": "top"
- },
- "labelLine": {
- "show": true
- }
- }
- },
- "rose": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "item"
- },
- "legend": {
- "top": "bottom"
- },
- "seriesTemplate": {
- "name": "",
- "type": "pie",
- "data": [],
- "radius": "55%",
- "center": ["50%", "50%"],
- "roseType": "area"
- }
- },
- "funnel": {
- "color": color2,
- "title": {
- "text": ""
- },
- "tooltip": {
- "trigger": "item",
- "formatter": "{b} : {c}%"
- },
- "legend": {
- "top": "bottom"
- },
- "seriesTemplate": {
- "name": "",
- "type": "funnel",
- "left": "10%",
- "top": 60,
- "bottom": 60,
- "width": "80%",
- "min": 0,
- "max": 100,
- "minSize": "0%",
- "maxSize": "100%",
- "sort": "descending",
- "gap": 2,
- "label": {
- "show": true,
- "position": "inside"
- },
- "labelLine": {
- "length": 10,
- "lineStyle": {
- "width": 1,
- "type": "solid"
- }
- },
- "itemStyle": {
- "bordercolor": "#fff",
- "borderwidth": 1
- },
- "emphasis": {
- "label": {
- "fontSize": 20
- }
- },
- "data": []
- }
- },
- "gauge": {
- "color": color2,
- "tooltip": {
- "formatter": "{a} <br/>{b} : {c}%"
- },
- "seriesTemplate": {
- "name": "\u4E1A\u52A1\u6307\u6807",
- "type": "gauge",
- "detail": { "formatter": "{value}%" },
- "data": [{ "value": 50, "name": "\u5B8C\u6210\u7387" }]
- }
- },
- "candle": {
- "xAxis": {
- "data": []
- },
- "yAxis": {},
- "color": color2,
- "title": {
- "text": ""
- },
- "dataZoom": [
- {
- "type": "inside",
- "xAxisIndex": [0, 1],
- "start": 10,
- "end": 100
- },
- {
- "show": true,
- "xAxisIndex": [0, 1],
- "type": "slider",
- "bottom": 10,
- "start": 10,
- "end": 100
- }
- ],
- "seriesTemplate": {
- "name": "",
- "type": "k",
- "data": []
- }
- }
- };
- var config_echarts_default = cfe;
-
- // <stdin>
- var that = {};
- var rootdom = null;
- function rddeepCloneAssign(origin = {}, ...args) {
- for (let i in args) {
- for (let key in args[i]) {
- if (args[i].hasOwnProperty(key)) {
- origin[key] = args[i][key] && typeof args[i][key] === "object" ? rddeepCloneAssign(Array.isArray(args[i][key]) ? [] : {}, origin[key], args[i][key]) : args[i][key];
- }
- }
- }
- return origin;
- }
- function rdformatterAssign(args, formatter) {
- for (let key in args) {
- if (args.hasOwnProperty(key) && args[key] !== null && typeof args[key] === "object") {
- rdformatterAssign(args[key], formatter);
- } else if (key === "format" && typeof args[key] === "string") {
- args["formatter"] = formatter[args[key]] ? formatter[args[key]] : void 0;
- }
- }
- return args;
- }
- var stdin_default = {
- data() {
- return {
- rid: null
- };
- },
- mounted() {
- rootdom = { top: 0, left: 0 };
- setTimeout(() => {
- if (this.rid === null) {
- this.$ownerInstance && this.$ownerInstance.callMethod("getRenderType");
- }
- }, 200);
- },
- destroyed() {
- delete config_ucharts_default.option[this.rid];
- delete config_ucharts_default.instance[this.rid];
- delete config_echarts_default.option[this.rid];
- delete config_echarts_default.instance[this.rid];
- },
- methods: {
- //==============以下是ECharts的方法====================
- ecinit(newVal, oldVal, owner, instance) {
- let cid = JSON.stringify(newVal.id);
- this.rid = cid;
- that[cid] = this.$ownerInstance || instance;
- let eopts = JSON.parse(JSON.stringify(newVal));
- let type = eopts.type;
- if (type && config_echarts_default.type.includes(type)) {
- config_echarts_default.option[cid] = rddeepCloneAssign({}, config_echarts_default[type], eopts);
- } else {
- config_echarts_default.option[cid] = rddeepCloneAssign({}, eopts);
- }
- let newData = eopts.chartData;
- if (newData) {
- if (config_echarts_default.option[cid].xAxis && config_echarts_default.option[cid].xAxis.type && config_echarts_default.option[cid].xAxis.type === "category") {
- config_echarts_default.option[cid].xAxis.data = newData.categories;
- }
- if (config_echarts_default.option[cid].yAxis && config_echarts_default.option[cid].yAxis.type && config_echarts_default.option[cid].yAxis.type === "category") {
- config_echarts_default.option[cid].yAxis.data = newData.categories;
- }
- config_echarts_default.option[cid].series = [];
- for (var i = 0; i < newData.series.length; i++) {
- config_echarts_default.option[cid].seriesTemplate = config_echarts_default.option[cid].seriesTemplate ? config_echarts_default.option[cid].seriesTemplate : {};
- let Template = rddeepCloneAssign({}, config_echarts_default.option[cid].seriesTemplate, newData.series[i]);
- config_echarts_default.option[cid].series.push(Template);
- }
- }
- if (typeof window.echarts === "object") {
- this.newEChart();
- } else {
- const script = document.createElement("script");
- script.src = "./uni_modules/qiun-data-charts/static/app-plus/echarts.min.js";
- script.onload = this.newEChart;
- document.head.appendChild(script);
- }
- },
- ecresize(newVal, oldVal, owner, instance) {
- if (config_echarts_default.instance[this.rid]) {
- config_echarts_default.instance[this.rid].resize();
- }
- },
- newEChart() {
- let cid = this.rid;
- if (config_echarts_default.instance[cid] === void 0) {
- config_echarts_default.instance[cid] = echarts.init(that[cid].$el.children[0]);
- if (config_echarts_default.option[cid].ontap === true) {
- config_echarts_default.instance[cid].on("click", (resdata) => {
- let event = JSON.parse(JSON.stringify({
- x: resdata.event.offsetX,
- y: resdata.event.offsetY
- }));
- that[cid].callMethod("emitMsg", { name: "getIndex", params: { type: "getIndex", event, currentIndex: resdata.dataIndex, value: resdata.data, seriesName: resdata.seriesName, id: cid } });
- });
- config_echarts_default.instance[cid].on("highlight", (resdata) => {
- that[cid].callMethod("emitMsg", { name: "getHighlight", params: { type: "highlight", res: resdata, id: cid } });
- });
- }
- this.updataEChart(cid, config_echarts_default.option[cid]);
- } else {
- this.updataEChart(cid, config_echarts_default.option[cid]);
- }
- },
- updataEChart(cid, option) {
- option = rdformatterAssign(option, config_echarts_default.formatter);
- if (option.tooltip) {
- option.tooltip.show = option.tooltipShow ? true : false;
- option.tooltip.position = this.tooltipPosition();
- if (typeof option.tooltipFormat === "string" && config_echarts_default.formatter[option.tooltipFormat]) {
- option.tooltip.formatter = option.tooltip.formatter ? option.tooltip.formatter : config_echarts_default.formatter[option.tooltipFormat];
- }
- }
- if (option.series) {
- for (let i in option.series) {
- let linearGradient = option.series[i].linearGradient;
- if (linearGradient) {
- option.series[i].color = new echarts.graphic.LinearGradient(linearGradient[0], linearGradient[1], linearGradient[2], linearGradient[3], linearGradient[4]);
- }
- }
- }
- config_echarts_default.instance[cid].setOption(option, option.notMerge);
- config_echarts_default.instance[cid].on("finished", function() {
- that[cid].callMethod("emitMsg", { name: "complete", params: { type: "complete", complete: true, id: cid } });
- if (config_echarts_default.instance[cid]) {
- config_echarts_default.instance[cid].off("finished");
- }
- });
- 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)) {
- this.ecresize();
- }
- },
- tooltipPosition() {
- return (point, params, dom, rect, size) => {
- let x = point[0];
- let y = point[1];
- let viewWidth = size.viewSize[0];
- let viewHeight = size.viewSize[1];
- let boxWidth = size.contentSize[0];
- let boxHeight = size.contentSize[1];
- let posX = x + 30;
- let posY = y + 30;
- if (posX + boxWidth > viewWidth) {
- posX = x - boxWidth - 30;
- }
- if (posY + boxHeight > viewHeight) {
- posY = y - boxHeight - 30;
- }
- return [posX, posY];
- };
- },
- //==============以下是uCharts的方法====================
- ucinit(newVal, oldVal, owner, instance) {
- if (JSON.stringify(newVal) == JSON.stringify(oldVal)) {
- return;
- }
- if (!newVal.canvasId) {
- return;
- }
- let cid = JSON.parse(JSON.stringify(newVal.canvasId));
- this.rid = cid;
- that[cid] = this.$ownerInstance || instance;
- config_ucharts_default.option[cid] = JSON.parse(JSON.stringify(newVal));
- config_ucharts_default.option[cid] = rdformatterAssign(config_ucharts_default.option[cid], config_ucharts_default.formatter);
- let canvasdom = document.getElementById(cid);
- if (canvasdom && canvasdom.children[0]) {
- config_ucharts_default.option[cid].context = canvasdom.children[0].getContext("2d");
- if (config_ucharts_default.instance[cid] && config_ucharts_default.option[cid] && config_ucharts_default.option[cid].update === true) {
- this.updataUChart();
- } else {
- setTimeout(() => {
- config_ucharts_default.option[cid].context.restore();
- config_ucharts_default.option[cid].context.save();
- this.newUChart();
- }, 100);
- }
- }
- },
- newUChart() {
- let cid = this.rid;
- config_ucharts_default.instance[cid] = new u_charts_default(config_ucharts_default.option[cid]);
- config_ucharts_default.instance[cid].addEventListener("renderComplete", () => {
- that[cid].callMethod("emitMsg", { name: "complete", params: { type: "complete", complete: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- config_ucharts_default.instance[cid].delEventListener("renderComplete");
- });
- config_ucharts_default.instance[cid].addEventListener("scrollLeft", () => {
- that[cid].callMethod("emitMsg", { name: "scrollLeft", params: { type: "scrollLeft", scrollLeft: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- });
- config_ucharts_default.instance[cid].addEventListener("scrollRight", () => {
- that[cid].callMethod("emitMsg", { name: "scrollRight", params: { type: "scrollRight", scrollRight: true, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- });
- },
- updataUChart() {
- let cid = this.rid;
- config_ucharts_default.instance[cid].updateData(config_ucharts_default.option[cid]);
- },
- tooltipDefault(item, category, index, opts) {
- if (category) {
- let data = item.data;
- if (typeof item.data === "object") {
- data = item.data.value;
- }
- return category + " " + item.name + ":" + data;
- } else {
- if (item.properties && item.properties.name) {
- return item.properties.name;
- } else {
- return item.name + ":" + item.data;
- }
- }
- },
- showTooltip(e, cid) {
- let tc = config_ucharts_default.option[cid].tooltipCustom;
- if (tc && tc !== void 0 && tc !== null) {
- let offset = void 0;
- if (tc.x >= 0 && tc.y >= 0) {
- offset = { x: tc.x, y: tc.y + 10 };
- }
- config_ucharts_default.instance[cid].showToolTip(e, {
- index: tc.index,
- offset,
- textList: tc.textList,
- formatter: (item, category, index, opts) => {
- if (typeof config_ucharts_default.option[cid].tooltipFormat === "string" && config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat]) {
- return config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat](item, category, index, opts);
- } else {
- return this.tooltipDefault(item, category, index, opts);
- }
- }
- });
- } else {
- config_ucharts_default.instance[cid].showToolTip(e, {
- formatter: (item, category, index, opts) => {
- if (typeof config_ucharts_default.option[cid].tooltipFormat === "string" && config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat]) {
- return config_ucharts_default.formatter[config_ucharts_default.option[cid].tooltipFormat](item, category, index, opts);
- } else {
- return this.tooltipDefault(item, category, index, opts);
- }
- }
- });
- }
- },
- tap(e) {
- let cid = this.rid;
- let ontap = config_ucharts_default.option[cid].ontap;
- let tooltipShow = config_ucharts_default.option[cid].tooltipShow;
- let tapLegend = config_ucharts_default.option[cid].tapLegend;
- if (ontap == false)
- return;
- let currentIndex = null;
- let legendIndex = null;
- let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
- let tmpe = {};
- if (e.detail.x) {
- tmpe = { x: e.detail.x - rchartdom.left, y: e.detail.y - rchartdom.top + rootdom.top };
- } else {
- tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
- }
- e.changedTouches = [];
- e.changedTouches.unshift(tmpe);
- currentIndex = config_ucharts_default.instance[cid].getCurrentDataIndex(e);
- legendIndex = config_ucharts_default.instance[cid].getLegendDataIndex(e);
- if (tapLegend === true) {
- config_ucharts_default.instance[cid].touchLegend(e);
- }
- if (tooltipShow == true) {
- this.showTooltip(e, cid);
- }
- that[cid].callMethod("emitMsg", { name: "getIndex", params: { type: "getIndex", event: tmpe, currentIndex, legendIndex, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- },
- touchStart(e) {
- let cid = this.rid;
- let ontouch = config_ucharts_default.option[cid].ontouch;
- if (ontouch == false)
- return;
- if (config_ucharts_default.option[cid].enableScroll === true && e.touches.length == 1) {
- config_ucharts_default.instance[cid].scrollStart(e);
- }
- that[cid].callMethod("emitMsg", { name: "getTouchStart", params: { type: "touchStart", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
- },
- touchMove(e) {
- let cid = this.rid;
- let ontouch = config_ucharts_default.option[cid].ontouch;
- if (ontouch == false)
- return;
- if (config_ucharts_default.option[cid].enableScroll === true && e.changedTouches.length == 1) {
- config_ucharts_default.instance[cid].scroll(e);
- }
- if (config_ucharts_default.option[cid].ontap === true && config_ucharts_default.option[cid].enableScroll === false && config_ucharts_default.option[cid].onmovetip === true) {
- let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
- let tmpe = { x: e.changedTouches[0].clientX - rchartdom.left, y: e.changedTouches[0].clientY - rchartdom.top + rootdom.top };
- e.changedTouches.unshift(tmpe);
- if (config_ucharts_default.option[cid].tooltipShow === true) {
- this.showTooltip(e, cid);
- }
- }
- if (ontouch === true && config_ucharts_default.option[cid].enableScroll === true && config_ucharts_default.option[cid].onzoom === true && e.changedTouches.length == 2) {
- config_ucharts_default.instance[cid].dobuleZoom(e);
- }
- that[cid].callMethod("emitMsg", { name: "getTouchMove", params: { type: "touchMove", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
- },
- touchEnd(e) {
- let cid = this.rid;
- let ontouch = config_ucharts_default.option[cid].ontouch;
- if (ontouch == false)
- return;
- if (config_ucharts_default.option[cid].enableScroll === true && e.touches.length == 0) {
- config_ucharts_default.instance[cid].scrollEnd(e);
- }
- that[cid].callMethod("emitMsg", { name: "getTouchEnd", params: { type: "touchEnd", event: e.changedTouches[0], id: cid, opts: config_ucharts_default.instance[cid].opts } });
- },
- mouseDown(e) {
- let cid = this.rid;
- let onmouse = config_ucharts_default.option[cid].onmouse;
- if (onmouse == false)
- return;
- let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
- let tmpe = {};
- tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
- e.changedTouches = [];
- e.changedTouches.unshift(tmpe);
- config_ucharts_default.instance[cid].scrollStart(e);
- config_ucharts_default.option[cid].mousedown = true;
- that[cid].callMethod("emitMsg", { name: "getTouchStart", params: { type: "mouseDown", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- },
- mouseMove(e) {
- let cid = this.rid;
- let onmouse = config_ucharts_default.option[cid].onmouse;
- let tooltipShow = config_ucharts_default.option[cid].tooltipShow;
- if (onmouse == false)
- return;
- let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
- let tmpe = {};
- tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
- e.changedTouches = [];
- e.changedTouches.unshift(tmpe);
- if (config_ucharts_default.option[cid].mousedown) {
- config_ucharts_default.instance[cid].scroll(e);
- that[cid].callMethod("emitMsg", { name: "getTouchMove", params: { type: "mouseMove", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- } else if (config_ucharts_default.instance[cid]) {
- if (tooltipShow == true) {
- this.showTooltip(e, cid);
- }
- }
- },
- mouseUp(e) {
- let cid = this.rid;
- let onmouse = config_ucharts_default.option[cid].onmouse;
- if (onmouse == false)
- return;
- let rchartdom = document.getElementById("UC" + cid).getBoundingClientRect();
- let tmpe = {};
- tmpe = { x: e.clientX - rchartdom.left, y: e.clientY - rchartdom.top + rootdom.top };
- e.changedTouches = [];
- e.changedTouches.unshift(tmpe);
- config_ucharts_default.instance[cid].scrollEnd(e);
- config_ucharts_default.option[cid].mousedown = false;
- that[cid].callMethod("emitMsg", { name: "getTouchEnd", params: { type: "mouseUp", event: tmpe, id: cid, opts: config_ucharts_default.instance[cid].opts } });
- }
- }
- };
- return __toCommonJS(stdin_exports);
- })();
|