123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708 |
- /*!
- * DevExtreme Web
- * Version: 15.1.4
- * Build date: Jun 22, 2015
- *
- * Copyright (c) 2012 - 2015 Developer Express Inc. ALL RIGHTS RESERVED
- * EULA: https://www.devexpress.com/Support/EULAs/DevExtreme.xml
- */
- "use strict";
- if (!window.DevExpress) {
- /*! Module core, file devexpress.js */
- (function($, global, undefined) {
- global.DevExpress = global.DevExpress || {};
- $.extend(global.DevExpress, {
- VERSION: "15.1.4",
- abstract: function() {
- throw global.DevExpress.Error("E0001");
- },
- stringFormat: function() {
- var s = arguments[0],
- replaceDollarCount,
- reg,
- argument;
- for (var i = 0; i < arguments.length - 1; i++) {
- reg = new RegExp("\\{" + i + "\\}", "gm");
- argument = arguments[i + 1];
- if ($.type(argument) === "string" && argument.indexOf("$") >= 0) {
- replaceDollarCount = "$".replace("$", "$$").length;
- argument = argument.replace("$", replaceDollarCount === 1 ? "$$$$" : "$$")
- }
- s = s.replace(reg, argument)
- }
- return s
- },
- parseUrl: function() {
- var a = document.createElement("a"),
- props = ["protocol", "hostname", "port", "pathname", "search", "hash"];
- var normalizePath = function(value) {
- if (value.charAt(0) !== "/")
- value = "/" + value;
- return value
- };
- return function(url) {
- a.href = url;
- var result = {};
- $.each(props, function() {
- result[this] = a[this]
- });
- result.pathname = normalizePath(result.pathname);
- return result
- }
- }(),
- processHardwareBackButton: function() {
- this.hardwareBackButton.fire()
- },
- hardwareBackButton: $.Callbacks(),
- viewPort: function() {
- var $current;
- return function(element) {
- if (!arguments.length)
- return $current;
- var $element = $(element);
- var isNewViewportFound = !!$element.length;
- var prevViewPort = this.viewPort();
- $current = isNewViewportFound ? $element : $("body");
- this.viewPortChanged.fire(isNewViewportFound ? this.viewPort() : $(), prevViewPort)
- }
- }(),
- viewPortChanged: $.Callbacks(),
- hideTopOverlayCallback: function() {
- var callbacks = [];
- return {
- add: function(callback) {
- var indexOfCallback = $.inArray(callback, callbacks);
- if (indexOfCallback === -1)
- callbacks.push(callback)
- },
- remove: function(callback) {
- var indexOfCallback = $.inArray(callback, callbacks);
- if (indexOfCallback !== -1)
- callbacks.splice(indexOfCallback, 1)
- },
- fire: function() {
- var callback = callbacks.pop(),
- result = !!callback;
- if (result)
- callback();
- return result
- },
- hasCallback: function() {
- return callbacks.length > 0
- },
- reset: function() {
- callbacks = []
- }
- }
- }(),
- compareVersions: function(x, y, maxLevel) {
- function normalizeArg(value) {
- if (typeof value === "string")
- return value.split(".");
- if (typeof value === "number")
- return [value];
- return value
- }
- x = normalizeArg(x);
- y = normalizeArg(y);
- var length = Math.max(x.length, y.length);
- if (isFinite(maxLevel))
- length = Math.min(length, maxLevel);
- for (var i = 0; i < length; i++) {
- var xItem = parseInt(x[i] || 0, 10),
- yItem = parseInt(y[i] || 0, 10);
- if (xItem < yItem)
- return -1;
- if (xItem > yItem)
- return 1
- }
- return 0
- },
- rtlEnabled: false
- });
- $(function() {
- DevExpress.viewPort(".dx-viewport")
- })
- })(jQuery, this);
- /*! Module core, file errors.js */
- (function($, DX) {
- var ERROR_MESSAGES = {
- E0001: "Method is not implemented",
- E0002: "Member name collision: {0}",
- E0003: "A class must be instantiated using the 'new' keyword",
- E0004: "The NAME property of the component is not specified",
- E0005: "Unknown device",
- E0006: "Unknown endpoint key is requested",
- E0007: "'Invalidate' method is called outside the update transaction",
- E0008: "Type of the option name is not appropriate to create an action",
- E0009: "Component '{0}' has not been initialized for an element",
- E0010: "Animation configuration with the '{0}' type requires '{1}' configuration as {2}",
- E0011: "Unknown animation type '{0}'",
- E0012: "jQuery version is too old. Please upgrade jQuery to 1.10.0 or later",
- E0013: "KnockoutJS version is too old. Please upgrade KnockoutJS to 2.3.0 or later",
- E0014: "The 'release' method shouldn't be called for an unlocked Lock object",
- E0015: "Queued task returned an unexpected result",
- E0017: "Event namespace is not defined",
- E0018: "DevExpress.ui.dxPopup widget is required",
- E0020: "Template engine '{0}' is not supported",
- E0021: "Unknown theme is set: {0}",
- E0022: "LINK[rel=dx-theme] tags must go before DevExpress included scripts",
- E0023: "Template name is not specified",
- E0100: "Unknown validation type is detected",
- E0101: "Misconfigured range validation rule is detected",
- E0102: "Misconfigured comparison validation rule is detected",
- E0110: "Unknown validation group is detected",
- E0120: "Adapter for a dxValidator component cannot be configured",
- W0000: "'{0}' is deprecated in {1}. {2}",
- W0001: "{0} - '{1}' option is deprecated in {2}. {3}",
- W0002: "{0} - '{1}' method is deprecated in {2}. {3}",
- W0003: "{0} - '{1}' property is deprecated in {2}. {3}",
- W0004: "Timeout for theme loading is over: {0}",
- W0005: "'{0}' event is deprecated in {1}. {2}"
- };
- var ERROR_URL = "http://js.devexpress.com/error/" + DX.VERSION.split(".").slice(0, 2).join("_") + "/";
- var combineMessage = function(args) {
- var id = args[0];
- args = args.slice(1);
- return formatMessage(id, formatDetails(id, args))
- };
- var formatDetails = function(id, args) {
- args = [DX.ERROR_MESSAGES[id]].concat(args);
- return DX.stringFormat.apply(this, args).replace(/\.*\s*?$/, '')
- };
- var formatMessage = function(id, details) {
- return DX.stringFormat.apply(this, ["{0} - {1}. See:\n{2}", id, details, ERROR_URL + id])
- };
- var makeError = function(args) {
- var id,
- details,
- message;
- id = args[0];
- args = args.slice(1);
- details = formatDetails(id, args);
- message = formatMessage(id, details);
- return $.extend(new Error(message), {
- __id: id,
- __details: details
- })
- };
- $.extend(DX, {
- Error: function() {
- return makeError($.makeArray(arguments))
- },
- log: function(id) {
- var method = "log",
- logger = DX.utils.logger;
- if (/^E\d+$/.test(id))
- method = "error";
- else if (/^W\d+$/.test(id))
- method = "warn";
- logger[method](method === "log" ? id : combineMessage($.makeArray(arguments)))
- },
- ERROR_MESSAGES: ERROR_MESSAGES
- })
- })(jQuery, DevExpress);
- /*! Module core, file class.js */
- (function($, global, DX, undefined) {
- DX.Class = function() {
- var wrapOverridden = function(baseProto, methodName, method) {
- return function() {
- var prevCallBase = this.callBase;
- this.callBase = baseProto[methodName];
- try {
- return method.apply(this, arguments)
- }
- finally {
- this.callBase = prevCallBase
- }
- }
- };
- var clonePrototype = function(obj) {
- var func = function(){};
- func.prototype = obj.prototype;
- return new func
- };
- var classImpl = function(){};
- var redefine = function(members) {
- var that = this;
- if (!members)
- return that;
- var memberNames = $.map(members, function(_, k) {
- return k
- });
- $.each(["toString", "toLocaleString", "valueOf"], function() {
- if (members[this])
- memberNames.push(this)
- });
- $.each(memberNames, function() {
- var overridden = $.isFunction(that.prototype[this]) && $.isFunction(members[this]);
- that.prototype[this] = overridden ? wrapOverridden(that.parent.prototype, this, members[this]) : members[this]
- });
- return that
- };
- var include = function() {
- var classObj = this;
- $.each(arguments, function() {
- if (this.ctor)
- classObj._includedCtors.push(this.ctor);
- if (this.postCtor)
- classObj._includedPostCtors.push(this.postCtor);
- for (var name in this) {
- if (name === "ctor" || name === "postCtor")
- continue;
- if (name in classObj.prototype)
- throw DX.Error("E0002", name);
- classObj.prototype[name] = this[name]
- }
- });
- return classObj
- };
- var subclassOf = function(parentClass) {
- if (this.parent === parentClass)
- return true;
- if (!this.parent || !this.parent.subclassOf)
- return false;
- return this.parent.subclassOf(parentClass)
- };
- classImpl.inherit = function(members) {
- var inheritor = function() {
- if (!this || this === global || typeof this.constructor !== "function")
- throw DX.Error("E0003");
- var instance = this,
- ctor = instance.ctor;
- $.each(instance.constructor._includedCtors, function() {
- this.call(instance)
- });
- if (ctor)
- ctor.apply(instance, arguments);
- $.each(instance.constructor._includedPostCtors, function() {
- this.call(instance)
- })
- };
- inheritor.prototype = clonePrototype(this);
- inheritor.inherit = this.inherit;
- inheritor.redefine = redefine;
- inheritor.include = include;
- inheritor.subclassOf = subclassOf;
- inheritor.parent = this;
- inheritor._includedCtors = this._includedCtors ? this._includedCtors.slice(0) : [];
- inheritor._includedPostCtors = this._includedPostCtors ? this._includedPostCtors.slice(0) : [];
- inheritor.prototype.constructor = inheritor;
- inheritor.redefine(members);
- return inheritor
- };
- return classImpl
- }()
- })(jQuery, this, DevExpress);
- /*! Module core, file queue.js */
- (function($, global, undefined) {
- var DX = global.DevExpress;
- function createQueue(discardPendingTasks) {
- var _tasks = [],
- _busy = false;
- function exec() {
- while (_tasks.length) {
- _busy = true;
- var task = _tasks.shift(),
- result = task();
- if (result === undefined)
- continue;
- if (result.then) {
- $.when(result).always(exec);
- return
- }
- throw DX.Error("E0015");
- }
- _busy = false
- }
- function add(task, removeTaskCallback) {
- if (!discardPendingTasks)
- _tasks.push(task);
- else {
- if (_tasks[0] && removeTaskCallback)
- removeTaskCallback(_tasks[0]);
- _tasks = [task]
- }
- if (!_busy)
- exec()
- }
- function busy() {
- return _busy
- }
- return {
- add: add,
- busy: busy
- }
- }
- $.extend(global.DevExpress, {
- createQueue: createQueue,
- enqueue: createQueue().add
- })
- })(jQuery, this);
- /*! Module core, file inflector.js */
- (function($, DX, undefined) {
- var _normalize = function(text) {
- if (text === undefined || text === null)
- return "";
- return String(text)
- };
- var _ucfirst = function(text) {
- return _normalize(text).charAt(0).toUpperCase() + text.substr(1)
- };
- var _chop = function(text) {
- return _normalize(text).replace(/([a-z\d])([A-Z])/g, "$1 $2").split(/[\s_-]+/)
- };
- var dasherize = function(text) {
- return $.map(_chop(text), function(p) {
- return p.toLowerCase()
- }).join("-")
- };
- var underscore = function(text) {
- return dasherize(text).replace(/-/g, "_")
- };
- var camelize = function(text, upperFirst) {
- return $.map(_chop(text), function(p, i) {
- p = p.toLowerCase();
- if (upperFirst || i > 0)
- p = _ucfirst(p);
- return p
- }).join("")
- };
- var humanize = function(text) {
- return _ucfirst(dasherize(text).replace(/-/g, " "))
- };
- var titleize = function(text) {
- return $.map(_chop(text), function(p) {
- return _ucfirst(p.toLowerCase())
- }).join(" ")
- };
- DX.inflector = {
- dasherize: dasherize,
- camelize: camelize,
- humanize: humanize,
- titleize: titleize,
- underscore: underscore
- }
- })(jQuery, DevExpress);
- /*! Module core, file eventsMixin.js */
- (function($, DX, undefined) {
- var EventsMixin = {
- ctor: function() {
- this._events = {}
- },
- fireEvent: function(eventName, eventArgs) {
- var callbacks = this._events[eventName];
- if (callbacks)
- callbacks.fireWith(this, eventArgs);
- return this
- },
- on: function(eventName, eventHandler) {
- if ($.isPlainObject(eventName))
- $.each(eventName, $.proxy(function(e, h) {
- this.on(e, h)
- }, this));
- else {
- var callbacks = this._events[eventName],
- addFn;
- if (!callbacks) {
- callbacks = $.Callbacks();
- this._events[eventName] = callbacks
- }
- addFn = callbacks.originalAdd || callbacks.add;
- addFn.call(callbacks, eventHandler)
- }
- return this
- },
- off: function(eventName, eventHandler) {
- var callbacks = this._events[eventName];
- if (callbacks)
- if ($.isFunction(eventHandler))
- callbacks.remove(eventHandler);
- else
- callbacks.empty();
- return this
- },
- _disposeEvents: function() {
- $.each(this._events, function() {
- this.empty()
- })
- },
- _callbacksToEvents: function(className, eventNames) {
- var that = this;
- $.each(eventNames, function(_, eventName) {
- var callbacksProperty = that[eventName],
- originalAdd;
- if (callbacksProperty !== undefined) {
- originalAdd = callbacksProperty.add;
- callbacksProperty.originalAdd = originalAdd;
- callbacksProperty.add = function() {
- DX.log("W0003", className, eventName, "14.2", "Use the '" + eventName + "' event instead");
- return originalAdd.apply(that, arguments)
- };
- that._events[eventName] = callbacksProperty
- }
- })
- }
- };
- $.extend(DX, {EventsMixin: EventsMixin})
- })(jQuery, DevExpress);
- /*! Module core, file jquery.js */
- (function($, DX) {
- if (DX.compareVersions($.fn.jquery, [1, 10]) < 0)
- throw DX.Error("E0012");
- })(jQuery, DevExpress);
- /*! Module core, file jquery.selectors.js */
- (function($) {
- var focusable = function(element, tabIndex) {
- var nodeName = element.nodeName.toLowerCase(),
- isTabIndexNotNaN = !isNaN(tabIndex),
- isVisible = visible(element),
- isDisabled = element.disabled,
- isDefaultFocus = /^(input|select|textarea|button|object)$/.test(nodeName),
- isHyperlink = nodeName === "a",
- isFocusable = true;
- if (isDefaultFocus)
- isFocusable = !isDisabled;
- else if (isHyperlink)
- isFocusable = element.href || isTabIndexNotNaN;
- else
- isFocusable = isTabIndexNotNaN;
- return isVisible ? isFocusable : false
- };
- var visible = function(element) {
- var $element = $(element);
- return $element.is(":visible") && $element.css("visibility") !== "hidden" && $element.parents().css("visibility") !== "hidden"
- };
- $.extend(jQuery.expr[':'], {
- "dx-focusable": function(element) {
- return focusable(element, $.attr(element, "tabindex"))
- },
- "dx-tabbable": function(element) {
- var tabIndex = $.attr(element, "tabindex");
- return (isNaN(tabIndex) || tabIndex >= 0) && focusable(element, tabIndex)
- }
- })
- })(jQuery);
- /*! Module core, file utils.common.js */
- (function($, DX, undefined) {
- var isDefined = function(object) {
- return object !== null && object !== undefined
- };
- var isString = function(object) {
- return $.type(object) === 'string'
- };
- var isNumber = function(object) {
- return typeof object === "number" && isFinite(object) || $.isNumeric(object)
- };
- var isObject = function(object) {
- return $.type(object) === 'object'
- };
- var isArray = function(object) {
- return $.type(object) === 'array'
- };
- var isDate = function(object) {
- return $.type(object) === 'date'
- };
- var isFunction = function(object) {
- return $.type(object) === 'function'
- };
- var isExponential = function(value) {
- return isNumber(value) && value.toString().indexOf('e') !== -1
- };
- var ensureDefined = function(value, defaultValue) {
- return isDefined(value) ? value : defaultValue
- };
- var getImageSourceType = function(source) {
- if (!isDefined(source))
- return false;
- if (/^fa fa-|^fa-.* fa/.test(source))
- return "faIcon";
- else if (/^ion-.*|ion.*ion-.*/.test(source))
- return "ionIcon";
- else if (/^glyphicon glyphicon-|^glyphicon-.* glyphicon/.test(source))
- return "glyphIcon";
- else if (/data:.*base64|\.|\//.test(source))
- return "image";
- else if (/^[\w-_]+$/.test(source))
- return "dxIcon";
- else
- return false
- };
- var getImageContainer = function(source) {
- var imageType = getImageSourceType(source),
- ICON_CLASS = "dx-icon";
- switch (imageType) {
- case"image":
- return $("<img>", {src: source}).addClass(ICON_CLASS);
- case"faIcon":
- case"glyphIcon":
- return $("<i>", {"class": ICON_CLASS + " " + source});
- case"ionIcon":
- var result = $("<i>", {"class": ICON_CLASS + " " + source});
- if (!result.hasClass("ion") && !result.hasClass("ionicons"))
- result.addClass("ion");
- return result;
- case"dxIcon":
- return $("<i>", {"class": ICON_CLASS + " " + ICON_CLASS + "-" + source});
- default:
- return null
- }
- };
- var extendFromObject = function(target, source, overrideExistingValues) {
- target = target || {};
- for (var prop in source)
- if (source.hasOwnProperty(prop)) {
- var value = source[prop];
- if (!(prop in target) || overrideExistingValues)
- target[prop] = value
- }
- return target
- };
- var clone = function() {
- function Clone(){}
- return function(obj) {
- Clone.prototype = obj;
- return new Clone
- }
- }();
- var executeAsync = function(action, context) {
- var deferred = $.Deferred(),
- normalizedContext = context || this,
- timerId,
- task = {
- promise: deferred.promise(),
- abort: function() {
- clearTimeout(timerId);
- deferred.rejectWith(normalizedContext)
- }
- },
- callback = function() {
- var result = action.call(normalizedContext);
- if (result && result.done && $.isFunction(result.done))
- result.done(function() {
- deferred.resolveWith(normalizedContext)
- });
- else
- deferred.resolveWith(normalizedContext)
- };
- timerId = (arguments[2] || setTimeout)(callback, 0);
- return task
- };
- var findBestMatches = function(targetFilter, items, mapFn) {
- var bestMatches = [],
- maxMatchCount = 0;
- $.each(items, function(index, itemSrc) {
- var matchCount = 0,
- item = mapFn ? mapFn(itemSrc) : itemSrc;
- $.each(targetFilter, function(paramName) {
- var value = item[paramName];
- if (value === undefined)
- return;
- if (value === targetFilter[paramName]) {
- matchCount++;
- return
- }
- matchCount = -1;
- return false
- });
- if (matchCount < maxMatchCount)
- return;
- if (matchCount > maxMatchCount) {
- bestMatches.length = 0;
- maxMatchCount = matchCount
- }
- bestMatches.push(itemSrc)
- });
- return bestMatches
- };
- var preg_quote = function(str) {
- return (str + "").replace(/([\+\*\?\\\.\[\^\]\$\(\)\{\}\><\|\=\!\:])/g, "\\$1")
- };
- var replaceAll = function(text, searchToken, replacementToken) {
- return text.replace(new RegExp("(" + preg_quote(searchToken) + ")", "gi"), replacementToken)
- };
- var splitPair = function(raw) {
- switch (typeof raw) {
- case"string":
- return raw.split(/\s+/, 2);
- case"object":
- return [raw.x || raw.h, raw.y || raw.v];
- case"number":
- return [raw];
- default:
- return raw
- }
- };
- var stringPairToObject = function(raw) {
- var pair = splitPair(raw),
- h = parseInt(pair && pair[0], 10),
- v = parseInt(pair && pair[1], 10);
- if (!isFinite(h))
- h = 0;
- if (!isFinite(v))
- v = h;
- return {
- h: h,
- v: v
- }
- };
- var orderEach = function(map, func) {
- var keys = [],
- key,
- i;
- for (key in map)
- keys.push(key);
- keys.sort(function(x, y) {
- var isNumberX = DX.utils.isNumber(x),
- isNumberY = DX.utils.isNumber(y);
- if (isNumberX && isNumberY)
- return x - y;
- if (isNumberX && !isNumberY)
- return -1;
- if (!isNumberX && isNumberY)
- return 1;
- if (x < y)
- return -1;
- if (x > y)
- return 1;
- return 0
- });
- for (i = 0; i < keys.length; i++) {
- key = keys[i];
- func(key, map[key])
- }
- };
- function icontains(elem, text) {
- var result = false;
- $.each($(elem).contents(), function(index, content) {
- if (content.nodeType === 3 && (content.textContent || content.nodeValue || "").toLowerCase().indexOf((text || "").toLowerCase()) > -1) {
- result = true;
- return false
- }
- });
- return result
- }
- $.expr[":"].dxicontains = $.expr.createPseudo(function(text) {
- return function(elem) {
- return icontains(elem, text)
- }
- });
- function deepExtendArraySafe(target, changes) {
- var prevValue,
- newValue;
- for (var name in changes) {
- prevValue = target[name];
- newValue = changes[name];
- if (target === newValue)
- continue;
- if ($.isPlainObject(newValue) && !(newValue instanceof $.Event))
- target[name] = deepExtendArraySafe($.isPlainObject(prevValue) ? prevValue : {}, newValue);
- else if (newValue !== undefined)
- target[name] = newValue
- }
- return target
- }
- function unwrapObservable(value) {
- if (DX.support.hasKo)
- return ko.utils.unwrapObservable(value);
- return value
- }
- function normalizeIndexes(items, indexParameterName, currentItem, needIndexCallback) {
- var indexedItems = {},
- parameterIndex = 0;
- $.each(items, function(index, item) {
- index = item[indexParameterName];
- if (isDefined(index)) {
- indexedItems[index] = indexedItems[index] || [];
- if (item === currentItem)
- indexedItems[index].unshift(item);
- else
- indexedItems[index].push(item);
- delete item[indexParameterName]
- }
- });
- orderEach(indexedItems, function(index, items) {
- $.each(items, function() {
- if (index >= 0)
- this[indexParameterName] = parameterIndex++
- })
- });
- $.each(items, function() {
- if (!isDefined(this[indexParameterName]) && (!needIndexCallback || needIndexCallback(this)))
- this[indexParameterName] = parameterIndex++
- });
- return parameterIndex
- }
- DX.utils = {
- isDefined: isDefined,
- isString: isString,
- isNumber: isNumber,
- isObject: isObject,
- isArray: isArray,
- isDate: isDate,
- isFunction: isFunction,
- isExponential: isExponential,
- ensureDefined: ensureDefined,
- extendFromObject: extendFromObject,
- clone: clone,
- executeAsync: executeAsync,
- stringFormat: DX.stringFormat,
- findBestMatches: findBestMatches,
- replaceAll: replaceAll,
- deepExtendArraySafe: deepExtendArraySafe,
- splitPair: splitPair,
- stringPairToObject: stringPairToObject,
- normalizeIndexes: normalizeIndexes,
- orderEach: orderEach,
- unwrapObservable: unwrapObservable,
- getImageSourceType: getImageSourceType,
- getImageContainer: getImageContainer
- }
- })(jQuery, DevExpress);
- /*! Module core, file utils.console.js */
- (function($, DX, undefined) {
- var logger = function() {
- var console = window.console;
- function info(text) {
- if (!console || !$.isFunction(console.info))
- return;
- console.info(text)
- }
- function warn(text) {
- if (!console || !$.isFunction(console.warn))
- return;
- console.warn(text)
- }
- function error(text) {
- if (!console || !$.isFunction(console.error))
- return;
- console.error(text)
- }
- return {
- info: info,
- warn: warn,
- error: error
- }
- }();
- var debug = function() {
- function assert(condition, message) {
- if (!condition)
- throw new Error(message);
- }
- function assertParam(parameter, message) {
- assert(parameter !== null && parameter !== undefined, message)
- }
- return {
- assert: assert,
- assertParam: assertParam
- }
- }();
- $.extend(DX.utils, {
- logger: logger,
- debug: debug
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.math.js */
- (function($, DX, undefined) {
- var PI = Math.PI,
- LN10 = Math.LN10;
- var cos = Math.cos,
- sin = Math.sin,
- abs = Math.abs,
- log = Math.log,
- floor = Math.floor,
- ceil = Math.ceil,
- max = Math.max,
- isNaN = window.isNaN,
- Number = window.Number,
- NaN = window.NaN;
- var isNumber = DX.utils.isNumber,
- isExponential = DX.utils.isExponential;
- var getPrecision = function(value) {
- var stringFraction,
- stringValue = value.toString(),
- pointIndex = stringValue.indexOf('.'),
- startIndex,
- precision;
- if (isExponential(value)) {
- precision = getDecimalOrder(value);
- if (precision < 0)
- return Math.abs(precision);
- else
- return 0
- }
- if (pointIndex !== -1) {
- startIndex = pointIndex + 1;
- stringFraction = stringValue.substring(startIndex, startIndex + 20);
- return stringFraction.length
- }
- return 0
- };
- var getLog = function(value, base) {
- if (!value)
- return NaN;
- return Math.log(value) / Math.log(base)
- };
- var raiseTo = function(power, base) {
- return Math.pow(base, power)
- };
- var sign = function(value) {
- if (value === 0)
- return 0;
- return value / abs(value)
- };
- var normalizeAngle = function(angle) {
- return (angle % 360 + 360) % 360
- };
- var convertAngleToRendererSpace = function(angle) {
- return 90 - angle
- };
- var degreesToRadians = function(value) {
- return PI * value / 180
- };
- var getCosAndSin = function(angle) {
- var angleInRadians = degreesToRadians(angle);
- return {
- cos: cos(angleInRadians),
- sin: sin(angleInRadians)
- }
- };
- var DECIMAL_ORDER_THRESHOLD = 1E-14;
- var getDistance = function(x1, y1, x2, y2) {
- var diffX = x2 - x1,
- diffY = y2 - y1;
- return Math.sqrt(diffY * diffY + diffX * diffX)
- };
- var getDecimalOrder = function(number) {
- var n = abs(number),
- cn;
- if (!isNaN(n)) {
- if (n > 0) {
- n = log(n) / LN10;
- cn = ceil(n);
- return cn - n < DECIMAL_ORDER_THRESHOLD ? cn : floor(n)
- }
- return 0
- }
- return NaN
- };
- var getAppropriateFormat = function(start, end, count) {
- var order = max(getDecimalOrder(start), getDecimalOrder(end)),
- precision = -getDecimalOrder(abs(end - start) / count),
- format;
- if (!isNaN(order) && !isNaN(precision)) {
- if (abs(order) <= 4) {
- format = 'fixedPoint';
- precision < 0 && (precision = 0);
- precision > 4 && (precision = 4)
- }
- else {
- format = 'exponential';
- precision += order - 1;
- precision > 3 && (precision = 3)
- }
- return {
- format: format,
- precision: precision
- }
- }
- return null
- };
- var getFraction = function(value) {
- var valueString,
- dotIndex;
- if (isNumber(value)) {
- valueString = value.toString();
- dotIndex = valueString.indexOf('.');
- if (dotIndex >= 0)
- if (isExponential(value))
- return valueString.substr(dotIndex + 1, valueString.indexOf('e') - dotIndex - 1);
- else {
- valueString = value.toFixed(20);
- return valueString.substr(dotIndex + 1, valueString.length - dotIndex + 1)
- }
- }
- return ''
- };
- var getSignificantDigitPosition = function(value) {
- var fraction = getFraction(value),
- i;
- if (fraction)
- for (i = 0; i < fraction.length; i++)
- if (fraction.charAt(i) !== '0')
- return i + 1;
- return 0
- };
- var adjustValue = function(value) {
- var fraction = getFraction(value),
- nextValue,
- i;
- if (fraction)
- for (i = 1; i <= fraction.length; i++) {
- nextValue = roundValue(value, i);
- if (nextValue !== 0 && fraction[i - 2] && fraction[i - 1] && fraction[i - 2] === fraction[i - 1])
- return nextValue
- }
- return value
- };
- var roundValue = function(value, precision) {
- if (precision > 20)
- precision = 20;
- if (isNumber(value))
- if (isExponential(value))
- return Number(value.toExponential(precision));
- else
- return Number(value.toFixed(precision))
- };
- var applyPrecisionByMinDelta = function(min, delta, value) {
- var minPrecision = getPrecision(min),
- deltaPrecision = getPrecision(delta);
- return roundValue(value, minPrecision < deltaPrecision ? deltaPrecision : minPrecision)
- };
- var fitIntoRange = function(value, minValue, maxValue) {
- return Math.min(Math.max(value, minValue), maxValue)
- };
- var getPower = function(value) {
- return value.toExponential().split("e")[1]
- };
- $.extend(DX.utils, {
- getLog: getLog,
- raiseTo: raiseTo,
- sign: sign,
- normalizeAngle: normalizeAngle,
- convertAngleToRendererSpace: convertAngleToRendererSpace,
- degreesToRadians: degreesToRadians,
- getCosAndSin: getCosAndSin,
- getDecimalOrder: getDecimalOrder,
- getAppropriateFormat: getAppropriateFormat,
- getDistance: getDistance,
- getFraction: getFraction,
- adjustValue: adjustValue,
- roundValue: roundValue,
- applyPrecisionByMinDelta: applyPrecisionByMinDelta,
- getSignificantDigitPosition: getSignificantDigitPosition,
- getPower: getPower,
- fitIntoRange: fitIntoRange
- });
- DX.utils.getPrecision = getPrecision
- })(jQuery, DevExpress);
- /*! Module core, file utils.date.js */
- (function($, DX, undefined) {
- var isObject = DX.utils.isObject,
- isString = DX.utils.isString,
- isDate = DX.utils.isDate,
- isDefined = DX.utils.isDefined;
- var dateUnitIntervals = ['millisecond', 'second', 'minute', 'hour', 'day', 'week', 'month', 'quarter', 'year'];
- var addSubValues = function(value1, value2, isSub) {
- return value1 + (isSub ? -1 : 1) * value2
- };
- var toMilliseconds = function(value) {
- switch (value) {
- case'millisecond':
- return 1;
- case'second':
- return toMilliseconds('millisecond') * 1000;
- case'minute':
- return toMilliseconds('second') * 60;
- case'hour':
- return toMilliseconds('minute') * 60;
- case'day':
- return toMilliseconds('hour') * 24;
- case'week':
- return toMilliseconds('day') * 7;
- case'month':
- return toMilliseconds('day') * 30;
- case'quarter':
- return toMilliseconds('month') * 3;
- case'year':
- return toMilliseconds('day') * 365;
- default:
- return 0
- }
- };
- var convertMillisecondsToDateUnits = function(value) {
- var i,
- dateUnitCount,
- dateUnitInterval,
- dateUnitIntervals = ['millisecond', 'second', 'minute', 'hour', 'day', 'month', 'year'],
- result = {};
- for (i = dateUnitIntervals.length - 1; i >= 0; i--) {
- dateUnitInterval = dateUnitIntervals[i];
- dateUnitCount = Math.floor(value / toMilliseconds(dateUnitInterval));
- if (dateUnitCount > 0) {
- result[dateUnitInterval + 's'] = dateUnitCount;
- value -= convertDateUnitToMilliseconds(dateUnitInterval, dateUnitCount)
- }
- }
- return result
- };
- var dateToMilliseconds = function(tickInterval) {
- var milliseconds = 0;
- if (isObject(tickInterval))
- $.each(tickInterval, function(key, value) {
- milliseconds += convertDateUnitToMilliseconds(key.substr(0, key.length - 1), value)
- });
- if (isString(tickInterval))
- milliseconds = convertDateUnitToMilliseconds(tickInterval, 1);
- return milliseconds
- };
- var convertDateUnitToMilliseconds = function(dateUnit, count) {
- return toMilliseconds(dateUnit) * count
- };
- var getDateUnitInterval = function(tickInterval) {
- var maxInterval = -1,
- i;
- if (isString(tickInterval))
- return tickInterval;
- if (isObject(tickInterval)) {
- $.each(tickInterval, function(key, value) {
- for (i = 0; i < dateUnitIntervals.length; i++)
- if (value && (key === dateUnitIntervals[i] + 's' || key === dateUnitIntervals[i]) && maxInterval < i)
- maxInterval = i
- });
- return dateUnitIntervals[maxInterval]
- }
- return ''
- };
- var correctDateWithUnitBeginning = function(date, dateInterval, withCorrection) {
- var oldDate = new Date(date.getTime()),
- dayMonth,
- firstQuarterMonth,
- dateUnitInterval = getDateUnitInterval(dateInterval);
- switch (dateUnitInterval) {
- case'second':
- date.setMilliseconds(0);
- break;
- case'minute':
- date.setSeconds(0, 0);
- break;
- case'hour':
- date.setMinutes(0, 0, 0);
- break;
- case'year':
- date.setMonth(0);
- case'month':
- date.setDate(1);
- case'day':
- date.setHours(0, 0, 0, 0);
- break;
- case'week':
- dayMonth = date.getDate();
- if (date.getDay() !== 0)
- dayMonth += 7 - date.getDay();
- date.setDate(dayMonth);
- date.setHours(0, 0, 0, 0);
- break;
- case'quarter':
- firstQuarterMonth = DX.formatHelper.getFirstQuarterMonth(date.getMonth());
- if (date.getMonth() !== firstQuarterMonth)
- date.setMonth(firstQuarterMonth);
- date.setDate(1);
- date.setHours(0, 0, 0, 0);
- break
- }
- if (withCorrection && dateUnitInterval !== "hour" && dateUnitInterval !== "minute" && dateUnitInterval !== "second")
- fixTimezoneGap(oldDate, date)
- };
- var getDatesDifferences = function(date1, date2) {
- var differences,
- counter = 0;
- differences = {
- year: date1.getFullYear() !== date2.getFullYear(),
- month: date1.getMonth() !== date2.getMonth(),
- day: date1.getDate() !== date2.getDate(),
- hour: date1.getHours() !== date2.getHours(),
- minute: date1.getMinutes() !== date2.getMinutes(),
- second: date1.getSeconds() !== date2.getSeconds()
- };
- $.each(differences, function(key, value) {
- if (value)
- counter++
- });
- differences.count = counter;
- return differences
- };
- var addInterval = function(value, interval, isNegative) {
- var result = null,
- intervalObject;
- if (isDate(value)) {
- intervalObject = isString(interval) ? getDateIntervalByString(interval.toLowerCase()) : interval;
- result = new Date(value.getTime());
- if (intervalObject.years)
- result.setFullYear(addSubValues(result.getFullYear(), intervalObject.years, isNegative));
- if (intervalObject.quarters)
- result.setMonth(addSubValues(result.getMonth(), 3 * intervalObject.quarters, isNegative));
- if (intervalObject.months)
- result.setMonth(addSubValues(result.getMonth(), intervalObject.months, isNegative));
- if (intervalObject.weeks)
- result.setDate(addSubValues(result.getDate(), 7 * intervalObject.weeks, isNegative));
- if (intervalObject.days)
- result.setDate(addSubValues(result.getDate(), intervalObject.days, isNegative));
- if (intervalObject.hours)
- result.setHours(addSubValues(result.getHours(), intervalObject.hours, isNegative));
- if (intervalObject.minutes)
- result.setMinutes(addSubValues(result.getMinutes(), intervalObject.minutes, isNegative));
- if (intervalObject.seconds)
- result.setSeconds(addSubValues(result.getSeconds(), intervalObject.seconds, isNegative));
- if (intervalObject.milliseconds)
- result.setMilliseconds(addSubValues(value.getMilliseconds(), intervalObject.milliseconds, isNegative))
- }
- else
- result = addSubValues(value, interval, isNegative);
- return result
- };
- var getFirstDateView = function(typeView, date) {
- if (!isDefined(date))
- return;
- if (typeView === "month")
- return getFirstMonthDate(date);
- if (typeView === "year")
- return new Date(date.getFullYear(), 0, 1);
- if (typeView === "decade")
- return new Date(getFirstYearInDecade(date), 0, 1);
- if (typeView === "century")
- return new Date(getFirstDecadeInCentury(date), 0, 1)
- };
- var getLastDateView = function(typeView, date) {
- if (typeView === "month")
- return new Date(date.getFullYear(), date.getMonth(), getLastDayOfMonth(date));
- if (typeView === "year")
- return new Date(date.getFullYear(), 11, 1);
- if (typeView === "decade")
- return new Date(getFirstYearInDecade(date) + 9, 0, 1);
- if (typeView === "century")
- return new Date(getFirstDecadeInCentury(date) + 90, 0, 1)
- };
- var sameView = function(view, date1, date2) {
- return DX.utils[DX.inflector.camelize("same " + view)](date1, date2)
- };
- var getViewUp = function(typeView) {
- switch (typeView) {
- case"month":
- return "year";
- case"year":
- return "decade";
- case"decade":
- return "century";
- default:
- break
- }
- };
- var getViewDown = function(typeView) {
- switch (typeView) {
- case"century":
- return "decade";
- case"decade":
- return "year";
- case"year":
- return "month";
- default:
- break
- }
- };
- var getDifferenceInMonth = function(typeView) {
- var difference = 1;
- if (typeView === "year")
- difference = 12;
- if (typeView === "decade")
- difference = 12 * 10;
- if (typeView === "century")
- difference = 12 * 100;
- return difference
- };
- var getDifferenceInMonthForCells = function(typeView) {
- var difference = 1;
- if (typeView === "decade")
- difference = 12;
- if (typeView === "century")
- difference = 12 * 10;
- return difference
- };
- var getDateIntervalByString = function(intervalString) {
- var result = {};
- switch (intervalString) {
- case'year':
- result.years = 1;
- break;
- case'month':
- result.months = 1;
- break;
- case'quarter':
- result.months = 3;
- break;
- case'week':
- result.days = 7;
- break;
- case'day':
- result.days = 1;
- break;
- case'hour':
- result.hours = 1;
- break;
- case'minute':
- result.minutes = 1;
- break;
- case'second':
- result.seconds = 1;
- break;
- case'millisecond':
- result.milliseconds = 1;
- break
- }
- return result
- };
- var sameMonthAndYear = function(date1, date2) {
- return date1 && date2 && date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth()
- };
- var sameYear = function(date1, date2) {
- return date1 && date2 && date1.getFullYear() === date2.getFullYear()
- };
- var sameDecade = function(date1, date2) {
- if (!isDefined(date1) || !isDefined(date2))
- return;
- var startDecadeDate1 = date1.getFullYear() - date1.getFullYear() % 10,
- startDecadeDate2 = date2.getFullYear() - date2.getFullYear() % 10;
- return date1 && date2 && startDecadeDate1 === startDecadeDate2
- };
- var sameCentury = function(date1, date2) {
- if (!isDefined(date1) || !isDefined(date2))
- return;
- var startCenturyDate1 = date1.getFullYear() - date1.getFullYear() % 100,
- startCenturyDate2 = date2.getFullYear() - date2.getFullYear() % 100;
- return date1 && date2 && startCenturyDate1 === startCenturyDate2
- };
- var getFirstDecadeInCentury = function(date) {
- return date && date.getFullYear() - date.getFullYear() % 100
- };
- var getFirstYearInDecade = function(date) {
- return date && date.getFullYear() - date.getFullYear() % 10
- };
- var getShortDate = function(date) {
- return Globalize.format(date, "yyyy/M/d")
- };
- var getLastDayOfMonth = function(date) {
- date = new Date(date.getFullYear(), date.getMonth() + 1, 0);
- return date.getDate()
- };
- var getFirstMonthDate = function(date) {
- if (!isDefined(date))
- return;
- var newDate = new Date(date.getFullYear(), date.getMonth(), 1);
- return newDate
- };
- var getLastMonthDate = function(date) {
- if (!isDefined(date))
- return;
- var newDate = new Date(date.getFullYear(), date.getMonth() + 1, 0);
- return newDate
- };
- var getFirstWeekDate = function(date, firstDayOfWeek) {
- firstDayOfWeek = firstDayOfWeek || Globalize.culture().calendar.firstDay;
- var delta = (date.getDay() - firstDayOfWeek + 7) % 7;
- var result = new Date(date);
- result.setDate(date.getDate() - delta);
- return result
- };
- var dateInRange = function(date, min, max) {
- return normalizeDate(date, min, max) === date
- };
- var normalizeDate = function(date, min, max) {
- var normalizedDate = date;
- if (isDefined(min) && date < min)
- normalizedDate = min;
- if (isDefined(max) && date > max)
- normalizedDate = max;
- return normalizedDate
- };
- var fixTimezoneGap = function(oldDate, newDate) {
- if (!DX.utils.isDefined(oldDate))
- return;
- var diff = newDate.getHours() - oldDate.getHours(),
- sign,
- trial;
- if (diff === 0)
- return;
- sign = diff === 1 || diff === -23 ? -1 : 1,
- trial = new Date(newDate.getTime() + sign * 3600000);
- if (sign > 0 || trial.getDate() === newDate.getDate())
- newDate.setTime(trial.getTime())
- };
- var makeDate = function(date) {
- if (!(date instanceof Date))
- date = new Date(date);
- return date
- };
- $.extend(DX.utils, {
- dateUnitIntervals: dateUnitIntervals,
- convertMillisecondsToDateUnits: convertMillisecondsToDateUnits,
- dateToMilliseconds: dateToMilliseconds,
- convertDateUnitToMilliseconds: convertDateUnitToMilliseconds,
- getDateUnitInterval: getDateUnitInterval,
- getDatesDifferences: getDatesDifferences,
- correctDateWithUnitBeginning: correctDateWithUnitBeginning,
- addInterval: addInterval,
- getDateIntervalByString: getDateIntervalByString,
- sameMonthAndYear: sameMonthAndYear,
- sameMonth: sameMonthAndYear,
- sameYear: sameYear,
- sameDecade: sameDecade,
- sameCentury: sameCentury,
- sameView: sameView,
- getDifferenceInMonth: getDifferenceInMonth,
- getDifferenceInMonthForCells: getDifferenceInMonthForCells,
- getFirstYearInDecade: getFirstYearInDecade,
- getFirstDecadeInCentury: getFirstDecadeInCentury,
- getShortDate: getShortDate,
- getFirstDateView: getFirstDateView,
- getLastDateView: getLastDateView,
- getViewDown: getViewDown,
- getViewUp: getViewUp,
- getLastMonthDate: getLastMonthDate,
- getFirstMonthDate: getFirstMonthDate,
- getFirstWeekDate: getFirstWeekDate,
- getLastDayOfMonth: getLastDayOfMonth,
- dateInRange: dateInRange,
- normalizeDate: normalizeDate,
- fixTimezoneGap: fixTimezoneGap,
- makeDate: makeDate
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.recurrence.js */
- (function($, DX, undefined) {
- var utils = DX.utils;
- var intervalMap = {
- secondly: "seconds",
- minutely: "minutes",
- hourly: "hours",
- daily: "days",
- weekly: "weeks",
- monthly: "months",
- yearly: "years"
- };
- var dateSetterMap = {
- bysecond: function(date, value) {
- date.setSeconds(value)
- },
- byminute: function(date, value) {
- date.setMinutes(value)
- },
- byhour: function(date, value) {
- date.setHours(value)
- },
- bymonth: function(date, value) {
- date.setMonth(value)
- },
- bymonthday: function(date, value) {
- date.setDate(value)
- },
- byday: function(date, dayOfWeek) {
- date.setDate(date.getDate() - date.getDay() + dayOfWeek)
- }
- };
- var dateGetterMap = {
- bysecond: "getSeconds",
- byminute: "getMinutes",
- byhour: "getHours",
- bymonth: "getMonth",
- bymonthday: "getDate",
- byday: "getDay"
- };
- var dateInRecurrenceRange = function(recurrenceString, currentDate, viewStartDate, viewEndDate) {
- var result = [];
- if (recurrenceString)
- result = getDatesByRecurrence(recurrenceString, currentDate, viewStartDate, viewEndDate);
- return !!result.length
- };
- var normalizeInterval = function(freq, interval) {
- var intervalObject = {},
- intervalField = intervalMap[freq.toLowerCase()];
- intervalObject[intervalField] = interval;
- return intervalObject
- };
- var getDatesByRecurrence = function(recurrenceString, recurrenceStartDate, viewStartDate, viewEndDate) {
- if (!recurrenceString)
- return [];
- var result = [],
- recurrenceRule = getRecurrenceRule(recurrenceString);
- if (!recurrenceRule.freq)
- return result;
- recurrenceRule.interval = normalizeInterval(recurrenceRule.freq, recurrenceRule.interval);
- viewEndDate = utils.normalizeDate(viewEndDate, viewStartDate, recurrenceRule.until);
- var recurrenceCounter = 0,
- dateCounter = 0,
- dateRules = splitDateRules(recurrenceRule),
- ruleDates = getDatesByRules(dateRules, recurrenceStartDate),
- currentDate = ruleDates[0],
- firstDate = new Date(recurrenceStartDate);
- utils.correctDateWithUnitBeginning(firstDate, recurrenceRule.interval);
- var firstDateInterval = getDatePartDiffs(recurrenceStartDate, firstDate);
- while (currentDate <= viewEndDate && recurrenceRule.count !== recurrenceCounter) {
- if (checkDateByRule(currentDate, dateRules)) {
- if (currentDate >= viewStartDate) {
- viewStartDate = new Date(currentDate);
- viewStartDate.setMilliseconds(viewStartDate.getMilliseconds() + 1);
- result.push(new Date(currentDate))
- }
- recurrenceCounter++
- }
- dateCounter++;
- currentDate = ruleDates[dateCounter % ruleDates.length];
- if (dateCounter / ruleDates.length >= 1) {
- dateCounter = 0;
- firstDate = utils.addInterval(firstDate, recurrenceRule.interval);
- ruleDates = getDatesByRules(dateRules, utils.addInterval(firstDate, firstDateInterval));
- currentDate = ruleDates[0]
- }
- }
- return result
- };
- var getDatePartDiffs = function(date1, date2) {
- return {
- years: date1.getFullYear() - date2.getFullYear(),
- months: date1.getMonth() - date2.getMonth(),
- days: date1.getDate() - date2.getDate(),
- hours: date1.getHours() - date2.getHours(),
- minutes: date1.getMinutes() - date2.getMinutes(),
- seconds: date1.getSeconds() - date2.getSeconds()
- }
- };
- var getRecurrenceRule = function(recurrence) {
- if (!recurrence)
- return {};
- var ruleObject = {},
- ruleStrings = recurrence.split(";");
- for (var i = 0, len = ruleStrings.length; i < len; i++) {
- var rule = ruleStrings[i].split("="),
- ruleName = rule[0].toLowerCase(),
- ruleValue = rule[1];
- ruleObject[ruleName] = ruleValue
- }
- return normalizeRRule(ruleObject)
- };
- var normalizeRRule = function(rule) {
- var count = parseInt(rule.count);
- if (!isNaN(count))
- rule.count = count;
- var interval = parseInt(rule.interval);
- rule.interval = isNaN(interval) ? 1 : interval;
- if (rule.freq && rule.until)
- rule.until = getDateByAsciiString(rule.until);
- return rule
- };
- var getDateByAsciiString = function(string) {
- var date = Globalize.parseDate(string, "yyyyMMddThhmmss");
- if (!date)
- date = Globalize.parseDate(string, "yyyyMMdd");
- return date
- };
- var getAsciiStringByDate = function(date) {
- return date.getFullYear() + ('0' + (date.getMonth() + 1)).slice(-2) + ('0' + date.getDate()).slice(-2)
- };
- var splitDateRules = function(rule) {
- var result = [];
- for (var field in dateSetterMap) {
- if (!rule[field])
- continue;
- var ruleFieldValues = rule[field].split(","),
- ruleArray = getDateRuleArray(field, ruleFieldValues);
- result = result.length ? extendObjectArray(ruleArray, result) : ruleArray
- }
- return result
- };
- var getDateRuleArray = function(field, values) {
- var result = [];
- for (var i = 0, length = values.length; i < length; i++) {
- var dateRule = {};
- dateRule[field] = handleRuleFieldValue(field, values[i]);
- result.push(dateRule)
- }
- return result
- };
- var days = {
- SU: 0,
- MO: 1,
- TU: 2,
- WE: 3,
- TH: 4,
- FR: 5,
- SA: 6
- };
- var handleRuleFieldValue = function(field, value) {
- var result = parseInt(value);
- if (field === "bymonth")
- result -= 1;
- if (field === "byday")
- result = days[value];
- return result
- };
- var extendObjectArray = function(firstArray, secondArray) {
- var result = [];
- for (var i = 0, firstArrayLength = firstArray.length; i < firstArrayLength; i++)
- for (var j = 0, secondArrayLength = secondArray.length; j < secondArrayLength; j++)
- result.push($.extend({}, firstArray[i], secondArray[j]));
- return result
- };
- var getDatesByRules = function(dateRules, startDate) {
- var updatedDate = new Date(startDate),
- result = [];
- for (var i = 0, len = dateRules.length; i < len; i++) {
- var current = dateRules[i];
- for (var field in current)
- dateSetterMap[field](updatedDate, current[field]);
- result.push(new Date(updatedDate))
- }
- if (!result.length)
- result.push(updatedDate);
- return result
- };
- var checkDateByRule = function(date, rules) {
- var result = false;
- for (var i = 0; i < rules.length; i++) {
- var current = rules[i],
- currentRuleResult = true;
- for (var field in current)
- if (current[field] !== date[dateGetterMap[field]]())
- currentRuleResult = false;
- result = result || currentRuleResult
- }
- return result || !rules.length
- };
- var getRecurrenceString = function(object) {
- if (!object || !object.freq)
- return;
- var result = "";
- for (var field in object) {
- if (field === "interval" && object[field] < 2)
- continue;
- result += field + "=" + object[field] + ";"
- }
- result = result.substring(0, result.length - 1);
- return result.toUpperCase()
- };
- $.extend(DX.utils, {
- getRecurrenceString: getRecurrenceString,
- getRecurrenceRule: getRecurrenceRule,
- getAsciiStringByDate: getAsciiStringByDate,
- getDatesByRecurrence: getDatesByRecurrence,
- dateInRecurrenceRange: dateInRecurrenceRange
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.dom.js */
- (function($, DX, undefined) {
- var windowResizeCallbacks = function() {
- var prevSize,
- callbacks = $.Callbacks(),
- jqWindow = $(window),
- resizeEventHandlerAttached = false,
- originalCallbacksAdd = callbacks.add,
- originalCallbacksRemove = callbacks.remove;
- var formatSize = function() {
- return [jqWindow.width(), jqWindow.height()].join()
- };
- var handleResize = function() {
- var now = formatSize();
- if (now === prevSize)
- return;
- prevSize = now;
- setTimeout(callbacks.fire)
- };
- prevSize = formatSize();
- callbacks.add = function() {
- var result = originalCallbacksAdd.apply(callbacks, arguments);
- if (!resizeEventHandlerAttached && callbacks.has()) {
- jqWindow.on("resize", handleResize);
- resizeEventHandlerAttached = true
- }
- return result
- };
- callbacks.remove = function() {
- var result = originalCallbacksRemove.apply(callbacks, arguments);
- if (!callbacks.has() && resizeEventHandlerAttached) {
- jqWindow.off("resize", handleResize);
- resizeEventHandlerAttached = false
- }
- return result
- };
- return callbacks
- }();
- var resetActiveElement = function() {
- var activeElement = document.activeElement;
- if (activeElement && activeElement !== document.body && activeElement.blur)
- activeElement.blur()
- };
- var createMarkupFromString = function(str) {
- var tempElement = $("<div />");
- if (window.WinJS)
- WinJS.Utilities.setInnerHTMLUnsafe(tempElement.get(0), str);
- else
- tempElement.append(str);
- return tempElement.contents()
- };
- var initMobileViewport = function(options) {
- options = $.extend({}, options);
- var device = DX.devices.current();
- var realDevice = DX.devices.real();
- var allowZoom = options.allowZoom,
- allowPan = options.allowPan,
- allowSelection = "allowSelection" in options ? options.allowSelection : device.platform === "generic";
- var metaSelector = "meta[name=viewport]";
- if (!$(metaSelector).length)
- $("<meta />").attr("name", "viewport").appendTo("head");
- var metaVerbs = ["width=device-width"],
- msTouchVerbs = [];
- if (allowZoom)
- msTouchVerbs.push("pinch-zoom");
- else
- metaVerbs.push("initial-scale=1.0", "maximum-scale=1.0, user-scalable=no");
- if (allowPan)
- msTouchVerbs.push("pan-x", "pan-y");
- if (!allowPan && !allowZoom)
- $("html, body").css({
- "-ms-content-zooming": "none",
- "-ms-user-select": "none",
- overflow: "hidden"
- });
- else
- $("html").css("-ms-overflow-style", "-ms-autohiding-scrollbar");
- if (!allowSelection && DX.support.supportProp("user-select"))
- $(".dx-viewport").css(DX.support.styleProp("user-select"), "none");
- $(metaSelector).attr("content", metaVerbs.join());
- $("html").css("-ms-touch-action", msTouchVerbs.join(" ") || "none");
- if (DX.support.touch)
- $(document).off(".dxInitMobileViewport").on("dxpointermove.dxInitMobileViewport", function(e) {
- var count = e.pointers.length,
- isTouchEvent = e.pointerType === "touch",
- zoomDisabled = !allowZoom && count > 1,
- panDisabled = !allowPan && count === 1 && !e.isScrollingEvent;
- if (isTouchEvent && (zoomDisabled || panDisabled))
- e.preventDefault()
- });
- realDevice = DX.devices.real();
- if (realDevice.ios) {
- var isPhoneGap = document.location.protocol === "file:";
- if (!isPhoneGap)
- windowResizeCallbacks.add(function() {
- var windowWidth = $(window).width();
- $("body").width(windowWidth)
- })
- }
- if (realDevice.android)
- windowResizeCallbacks.add(function() {
- document.activeElement.scrollIntoViewIfNeeded()
- })
- };
- var triggerVisibilityChangeEvent = function(eventName) {
- var VISIBILITY_CHANGE_SELECTOR = ".dx-visibility-change-handler";
- return function(element) {
- var $element = $(element || "body");
- var $changeHandlers = $element.find(VISIBILITY_CHANGE_SELECTOR).add($element.filter(VISIBILITY_CHANGE_SELECTOR));
- $changeHandlers.each(function() {
- $(this).triggerHandler(eventName)
- })
- }
- };
- var uniqueId = function() {
- var counter = 0;
- return function(prefix) {
- return (prefix || "") + counter++
- }
- }();
- DX.dataOptionsAttributeName = "data-options";
- var getElementOptions = function(element) {
- var optionsString = $(element).attr(DX.dataOptionsAttributeName),
- result;
- if ($.trim(optionsString).charAt(0) !== "{")
- optionsString = "{" + optionsString + "}";
- try {
- result = new Function("return " + optionsString)()
- }
- catch(ex) {
- throw DX.Error("E3018", ex, optionsString);
- }
- return result
- };
- var createComponents = function(elements, componentTypes) {
- var result = [],
- selector = "[" + DX.dataOptionsAttributeName + "]";
- elements.find(selector).addBack(selector).each(function(index, element) {
- var $element = $(element),
- options = getElementOptions(element);
- for (var componentName in options)
- if (!componentTypes || $.inArray(componentName, componentTypes) > -1)
- if ($element[componentName]) {
- $element[componentName](options[componentName]);
- result.push($element[componentName]("instance"))
- }
- });
- return result
- };
- var normalizeTemplateElement = function(element) {
- var $element = DX.utils.isDefined(element) && (element.nodeType || element.jquery) ? $(element) : $("<div>").html(element).contents();
- if ($element.length === 1 && $element.is("script"))
- $element = normalizeTemplateElement(element.html());
- return $element
- };
- var clearSelection = function() {
- if (window.getSelection) {
- if (window.getSelection().empty)
- window.getSelection().empty();
- else if (window.getSelection().removeAllRanges)
- window.getSelection().removeAllRanges()
- }
- else if (document.selection)
- document.selection.empty()
- };
- var closestCommonParent = function(startTarget, endTarget) {
- var $startParents = $(startTarget).parents().addBack(),
- $endParents = $(endTarget).parents().addBack(),
- startingParent = Math.min($startParents.length, $endParents.length) - 1;
- for (var i = startingParent; i >= 0; i--)
- if ($startParents.eq(i).is($endParents.eq(i)))
- return $startParents.get(i)
- };
- var toggleAttr = function($target, attr, value) {
- value ? $target.attr(attr, value) : $target.removeAttr(attr)
- };
- var clipboardText = function(event, text) {
- var clipboard = event.originalEvent && event.originalEvent.clipboardData || window.clipboardData;
- if (arguments.length === 1)
- return clipboard && clipboard.getData("Text");
- clipboard && clipboard.setData("Text", text)
- };
- $.extend(DX.utils, {
- windowResizeCallbacks: windowResizeCallbacks,
- resetActiveElement: resetActiveElement,
- createMarkupFromString: createMarkupFromString,
- triggerShownEvent: triggerVisibilityChangeEvent("dxshown"),
- triggerHidingEvent: triggerVisibilityChangeEvent("dxhiding"),
- initMobileViewport: initMobileViewport,
- getElementOptions: getElementOptions,
- createComponents: createComponents,
- normalizeTemplateElement: normalizeTemplateElement,
- clearSelection: clearSelection,
- uniqueId: uniqueId,
- closestCommonParent: closestCommonParent,
- clipboardText: clipboardText,
- toggleAttr: toggleAttr
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.caret.js */
- (function($, DX, undefined) {
- var getCaret = function(input) {
- if (isObsoleteBrowser(input))
- return getCaretForObsoleteBrowser(input);
- return {
- start: input.selectionStart,
- end: input.selectionEnd
- }
- };
- var setCaret = function(input, position) {
- if (isObsoleteBrowser(input)) {
- setCaretForObsoleteBrowser(input, position);
- return
- }
- if (!$.contains(document, input))
- return;
- input.selectionStart = position.start;
- input.selectionEnd = position.end
- };
- var isObsoleteBrowser = function(input) {
- return !input.setSelectionRange
- };
- var getCaretForObsoleteBrowser = function(input) {
- var range = document.selection.createRange();
- var rangeCopy = range.duplicate();
- range.move('character', -input.value.length);
- range.setEndPoint('EndToStart', rangeCopy);
- return {
- start: range.text.length,
- end: range.text.length + rangeCopy.text.length
- }
- };
- var setCaretForObsoleteBrowser = function(input, position) {
- var range = input.createTextRange();
- range.collapse(true);
- range.moveStart("character", position.start);
- range.moveEnd("character", position.end - position.start);
- range.select()
- };
- var caret = function(input, position) {
- input = $(input).get(0);
- if (!DX.utils.isDefined(position))
- return getCaret(input);
- setCaret(input, position)
- };
- $.extend(DX.utils, {caret: caret})
- })(jQuery, DevExpress);
- /*! Module core, file utils.graphics.js */
- (function($, DX, undefined) {
- var _utils = DX.utils,
- isFunction = _utils.isFunction,
- _inArray = $.inArray,
- isDefined = _utils.isDefined;
- var processSeriesTemplate = function(seriesTemplate, items) {
- var customizeSeries = isFunction(seriesTemplate.customizeSeries) ? seriesTemplate.customizeSeries : $.noop,
- nameField = seriesTemplate.nameField || 'series',
- generatedSeries = {},
- seriesOrder = [],
- series;
- for (var i = 0, length = items.length; i < length; i++) {
- var data = items[i];
- if (nameField in data) {
- series = generatedSeries[data[nameField]];
- if (!series) {
- series = generatedSeries[data[nameField]] = {
- name: data[nameField],
- data: []
- };
- seriesOrder.push(series.name)
- }
- series.data.push(data)
- }
- }
- return $.map(seriesOrder, function(orderedName) {
- var group = generatedSeries[orderedName],
- seriesOptions = customizeSeries.call(null, group.name);
- return $.extend(group, seriesOptions)
- })
- };
- var getCategoriesInfo = function(categories, startValue, endValue) {
- if (!(categories && categories.length > 0))
- return {};
- startValue = isDefined(startValue) ? startValue : categories[0];
- endValue = isDefined(endValue) ? endValue : categories[categories.length - 1];
- var categoriesValue = $.map(categories, function(category) {
- return category && category.valueOf()
- }),
- visibleCategories = [],
- indexStartValue = isDefined(startValue) ? _inArray(startValue.valueOf(), categoriesValue) : 0,
- indexEndValue = isDefined(endValue) ? _inArray(endValue.valueOf(), categoriesValue) : categories.length - 1,
- swapBuf,
- hasVisibleCategories,
- inverted = false,
- visibleCategoriesLen;
- indexStartValue < 0 && (indexStartValue = 0);
- indexEndValue < 0 && (indexEndValue = categories.length - 1);
- if (indexEndValue < indexStartValue) {
- swapBuf = indexEndValue;
- indexEndValue = indexStartValue;
- indexStartValue = swapBuf;
- inverted = true
- }
- visibleCategories = categories.slice(indexStartValue, indexEndValue + 1);
- visibleCategoriesLen = visibleCategories.length;
- hasVisibleCategories = visibleCategoriesLen > 0;
- return {
- categories: hasVisibleCategories ? visibleCategories : null,
- start: hasVisibleCategories ? visibleCategories[inverted ? visibleCategoriesLen - 1 : 0] : null,
- end: hasVisibleCategories ? visibleCategories[inverted ? 0 : visibleCategoriesLen - 1] : null,
- inverted: inverted
- }
- };
- $.extend(_utils, {
- processSeriesTemplate: processSeriesTemplate,
- getCategoriesInfo: getCategoriesInfo
- })
- })(jQuery, DevExpress);
- /*! Module core, file utils.arrays.js */
- (function($, DX, undefined) {
- var isEmptyArray = function(entity) {
- return $.isArray(entity) && !entity.length
- };
- var wrapToArray = function(entity) {
- return $.isArray(entity) ? entity : [entity]
- };
- var removeDublicates = function(from, what) {
- if (!$.isArray(from) || from.length === 0)
- return [];
- if (!$.isArray(what) || what.length === 0)
- return from.slice();
- var result = [];
- $.each(from, function(_, value) {
- var bIndex = $.inArray(value, what);
- if (bIndex === -1)
- result.push(value)
- });
- return result
- };
- $.extend(DX.utils, {
- isEmptyArray: isEmptyArray,
- wrapToArray: wrapToArray,
- removeDublicates: removeDublicates
- })
- })(jQuery, DevExpress);
- /*! Module core, file devices.js */
- (function($, DX, undefined) {
- var KNOWN_UA_TABLE = {
- iPhone: "iPhone",
- iPhone5: "iPhone",
- iPhone6: "iPhone",
- iPhone6plus: "iPhone",
- iPad: "iPad",
- iPadMini: "iPad Mini",
- androidPhone: "Android Mobile",
- androidTablet: "Android",
- win8: "MSAppHost",
- win8Phone: "Windows Phone 8",
- msSurface: "MSIE ARM Tablet PC",
- desktop: "desktop"
- };
- var DEFAULT_DEVICE = {
- deviceType: "",
- platform: "",
- version: [],
- phone: false,
- tablet: false,
- android: false,
- ios: false,
- win8: false,
- generic: false,
- grade: "A",
- mac: false
- };
- $.extend(DEFAULT_DEVICE, {
- platform: "generic",
- deviceType: "desktop",
- generic: true
- });
- var uaParsers = {
- win8: function(userAgent) {
- var isPhone = /windows phone/i.test(userAgent) || userAgent.match(/WPDesktop/),
- isTablet = !isPhone && /arm(.*)trident/i.test(userAgent),
- isDesktop = !isPhone && !isTablet && /msapphost/i.test(userAgent);
- if (!(isPhone || isTablet || isDesktop))
- return;
- var matches = userAgent.match(/windows phone (\d+).(\d+)/i) || userAgent.match(/windows nt (\d+).(\d+)/i),
- version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10)] : [];
- return {
- deviceType: isPhone ? "phone" : isTablet ? "tablet" : "desktop",
- platform: "win8",
- version: version,
- grade: "A"
- }
- },
- ios: function(userAgent) {
- if (!/ip(hone|od|ad)/i.test(userAgent))
- return;
- var isPhone = /ip(hone|od)/i.test(userAgent),
- matches = userAgent.match(/os (\d+)_(\d+)_?(\d+)?/i),
- version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10), parseInt(matches[3] || 0, 10)] : [],
- isIPhone4 = window.screen.height === 960 / 2,
- grade = isIPhone4 ? "B" : "A";
- return {
- deviceType: isPhone ? "phone" : "tablet",
- platform: "ios",
- version: version,
- grade: grade
- }
- },
- android: function(userAgent) {
- if (!/android|htc_|silk/i.test(userAgent))
- return;
- var isPhone = /mobile/i.test(userAgent),
- matches = userAgent.match(/android (\d+)\.(\d+)\.?(\d+)?/i),
- version = matches ? [parseInt(matches[1], 10), parseInt(matches[2], 10), parseInt(matches[3] || 0, 10)] : [],
- worseThan4_4 = version.length > 1 && (version[0] < 4 || version[0] === 4 && version[1] < 4),
- grade = worseThan4_4 ? "B" : "A";
- return {
- deviceType: isPhone ? "phone" : "tablet",
- platform: "android",
- version: version,
- grade: grade
- }
- }
- };
- DX.Devices = DX.Class.inherit({
- ctor: function(options) {
- this._window = options && options.window || window;
- this._realDevice = this._getDevice();
- this._currentDevice = undefined;
- this._currentOrientation = undefined;
- this.orientationChanged = $.Callbacks();
- this._callbacksToEvents("Devices", ["orientationChanged"]);
- this._recalculateOrientation();
- DX.utils.windowResizeCallbacks.add($.proxy(this._recalculateOrientation, this))
- },
- current: function(deviceOrName) {
- if (deviceOrName) {
- this._currentDevice = this._getDevice(deviceOrName);
- this._forced = true;
- DX.ui.themes.init({_autoInit: true})
- }
- else {
- if (!this._currentDevice) {
- deviceOrName = undefined;
- try {
- deviceOrName = this._getDeviceOrNameFromWindowScope()
- }
- catch(e) {
- deviceOrName = this._getDeviceNameFromSessionStorage()
- }
- finally {
- if (!deviceOrName)
- deviceOrName = this._getDeviceNameFromSessionStorage();
- if (deviceOrName)
- this._forced = true
- }
- this._currentDevice = this._getDevice(deviceOrName)
- }
- return this._currentDevice
- }
- },
- real: function() {
- var forceDevice = arguments[0];
- if ($.isPlainObject(forceDevice)) {
- $.extend(this._realDevice, forceDevice);
- return
- }
- return $.extend({}, this._realDevice)
- },
- orientation: function() {
- return this._currentOrientation
- },
- isForced: function() {
- return this._forced
- },
- isRippleEmulator: function() {
- return !!this._window.tinyHippos
- },
- _getCssClasses: function(device) {
- var result = [];
- var realDevice = this._realDevice;
- device = device || this.current();
- if (device.deviceType) {
- result.push("dx-device-" + device.deviceType);
- if (device.deviceType !== "desktop")
- result.push("dx-device-mobile")
- }
- result.push("dx-device-" + realDevice.platform);
- if (realDevice.version && realDevice.version.length)
- result.push("dx-device-" + realDevice.platform + "-" + realDevice.version[0]);
- if (DX.devices.isSimulator())
- result.push("dx-simulator");
- if (DX.rtlEnabled)
- result.push("dx-rtl");
- return result
- },
- attachCssClasses: function(element, device) {
- this._deviceClasses = this._getCssClasses(device).join(" ");
- $(element).addClass(this._deviceClasses)
- },
- detachCssClasses: function(element) {
- $(element).removeClass(this._deviceClasses)
- },
- isSimulator: function() {
- try {
- return this._isSimulator || this._window.top !== this._window.self && this._window.top["dx-force-device"] || this.isRippleEmulator()
- }
- catch(e) {
- return false
- }
- },
- forceSimulator: function() {
- this._isSimulator = true
- },
- _getDevice: function(deviceName) {
- if (deviceName === "genericPhone")
- deviceName = {
- deviceType: "phone",
- platform: "generic",
- generic: true
- };
- if ($.isPlainObject(deviceName))
- return this._fromConfig(deviceName);
- else {
- var ua;
- if (deviceName) {
- ua = KNOWN_UA_TABLE[deviceName];
- if (!ua)
- throw DX.Error("E0005");
- }
- else
- ua = navigator.userAgent;
- return this._fromUA(ua)
- }
- },
- _getDeviceOrNameFromWindowScope: function() {
- var result;
- if (this._window.top["dx-force-device-object"] || this._window.top["dx-force-device"])
- result = this._window.top["dx-force-device-object"] || this._window.top["dx-force-device"];
- return result
- },
- _getDeviceNameFromSessionStorage: function() {
- var sessionStorage;
- try {
- sessionStorage = this._window.sessionStorage
- }
- catch(e) {}
- if (!sessionStorage)
- return;
- var deviceOrName = sessionStorage.getItem("dx-force-device");
- try {
- return $.parseJSON(deviceOrName)
- }
- catch(ex) {
- return deviceOrName
- }
- },
- _fromConfig: function(config) {
- var shortcuts = {
- phone: config.deviceType === "phone",
- tablet: config.deviceType === "tablet",
- android: config.platform === "android",
- ios: config.platform === "ios",
- win8: config.platform === "win8",
- generic: config.platform === "generic"
- };
- return $.extend({}, DEFAULT_DEVICE, this._currentDevice, shortcuts, config)
- },
- _fromUA: function(ua) {
- var config;
- $.each(uaParsers, function(platform, parser) {
- config = parser(ua);
- return !config
- });
- if (config)
- return this._fromConfig(config);
- var isMac = /(mac os)/.test(ua.toLowerCase()),
- deviceWithOS = DEFAULT_DEVICE;
- deviceWithOS.mac = isMac;
- return deviceWithOS
- },
- _changeOrientation: function() {
- var $window = $(this._window),
- orientation = $window.height() > $window.width() ? "portrait" : "landscape";
- if (this._currentOrientation === orientation)
- return;
- this._currentOrientation = orientation;
- this.orientationChanged.fire({orientation: orientation})
- },
- _recalculateOrientation: function() {
- var windowWidth = $(this._window).width();
- if (this._currentWidth === windowWidth)
- return;
- this._currentWidth = windowWidth;
- this._changeOrientation()
- }
- }).include(DX.EventsMixin);
- DX.devices = new DX.Devices;
- DX.viewPortChanged.add(function(viewPort, prevViewport) {
- DX.devices.detachCssClasses(prevViewport);
- DX.devices.attachCssClasses(viewPort)
- })
- })(jQuery, DevExpress);
- /*! Module core, file browser.js */
- (function($, DX, global, undefined) {
- var webkitRegExp = /(webkit)[ \/]([\w.]+)/,
- operaRegExp = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- ieRegExp = /(msie) (\d{1,2}\.\d)/,
- ie11RegExp = /(trident).*rv:(\d{1,2}\.\d)/,
- mozillaRegExp = /(mozilla)(?:.*? rv:([\w.]+))?/;
- var ua = navigator.userAgent.toLowerCase();
- var browser = function() {
- var result = {},
- matches = webkitRegExp.exec(ua) || operaRegExp.exec(ua) || ieRegExp.exec(ua) || ie11RegExp.exec(ua) || ua.indexOf("compatible") < 0 && mozillaRegExp.exec(ua) || [],
- browserName = matches[1],
- browserVersion = matches[2];
- if (browserName === "trident")
- browserName = "msie";
- if (browserName) {
- result[browserName] = true;
- result.version = browserVersion
- }
- return result
- }();
- DX.browser = browser
- })(jQuery, DevExpress, this);
- /*! Module core, file support.js */
- (function($, DX, window) {
- var jsPrefixes = ["", "Webkit", "Moz", "O", "Ms"],
- cssPrefixes = {
- "": "",
- Webkit: "-webkit-",
- Moz: "-moz-",
- O: "-o-",
- ms: "-ms-"
- },
- styles = document.createElement("dx").style;
- var transitionEndEventNames = {
- webkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd',
- msTransition: 'MsTransitionEnd',
- transition: 'transitionend'
- };
- var forEachPrefixes = function(prop, callBack) {
- prop = DX.inflector.camelize(prop, true);
- var result;
- for (var i = 0, cssPrefixesCount = jsPrefixes.length; i < cssPrefixesCount; i++) {
- var jsPrefix = jsPrefixes[i];
- var prefixedProp = jsPrefix + prop;
- var lowerPrefixedProp = DX.inflector.camelize(prefixedProp);
- result = callBack(lowerPrefixedProp, jsPrefix);
- if (result === undefined)
- result = callBack(prefixedProp, jsPrefix);
- if (result !== undefined)
- break
- }
- return result
- };
- var styleProp = function(prop) {
- return forEachPrefixes(prop, function(specific) {
- if (specific in styles)
- return specific
- })
- };
- var stylePropPrefix = function(prop) {
- return forEachPrefixes(prop, function(specific, jsPrefix) {
- if (specific in styles)
- return cssPrefixes[jsPrefix]
- })
- };
- var supportProp = function(prop) {
- return !!styleProp(prop)
- };
- var isNativeScrollingSupported = function() {
- var realDevice = DX.devices.real(),
- realPlatform = realDevice.platform,
- realVersion = realDevice.version,
- isObsoleteAndroid = realVersion && realVersion[0] < 4 && realPlatform === "android",
- isNativeScrollDevice = !isObsoleteAndroid && $.inArray(realPlatform, ["ios", "android", "win8"]) > -1 || realDevice.mac;
- return isNativeScrollDevice
- };
- DX.support = {
- touchEvents: "ontouchstart" in window,
- touch: "ontouchstart" in window || !!window.navigator.msMaxTouchPoints,
- pointer: window.navigator.pointerEnabled || window.navigator.msPointerEnabled,
- transform: supportProp("transform"),
- transition: supportProp("transition"),
- transitionEndEventName: transitionEndEventNames[styleProp("transition")],
- animation: supportProp("animation"),
- nativeScrolling: isNativeScrollingSupported(),
- winJS: "WinJS" in window,
- styleProp: styleProp,
- stylePropPrefix: stylePropPrefix,
- supportProp: supportProp,
- hasKo: !!window.ko,
- hasNg: !window.ko && !!window.angular,
- inputType: function(type) {
- if (type === "text")
- return true;
- var input = document.createElement("input");
- try {
- input.setAttribute("type", type);
- input.value = "wrongValue";
- return !input.value
- }
- catch(e) {
- return false
- }
- }
- }
- })(jQuery, DevExpress, this);
- /*! Module core, file position.js */
- (function($, DX, undefined) {
- var horzRe = /left|right/,
- vertRe = /top|bottom/,
- collisionRe = /fit|flip|none/;
- var normalizeAlign = function(raw) {
- var result = {
- h: "center",
- v: "center"
- };
- var pair = DX.utils.splitPair(raw);
- if (pair)
- $.each(pair, function() {
- var w = String(this).toLowerCase();
- if (horzRe.test(w))
- result.h = w;
- else if (vertRe.test(w))
- result.v = w
- });
- return result
- };
- var normalizeOffset = function(raw) {
- return DX.utils.stringPairToObject(raw)
- };
- var normalizeCollision = function(raw) {
- var pair = DX.utils.splitPair(raw),
- h = String(pair && pair[0]).toLowerCase(),
- v = String(pair && pair[1]).toLowerCase();
- if (!collisionRe.test(h))
- h = "none";
- if (!collisionRe.test(v))
- v = h;
- return {
- h: h,
- v: v
- }
- };
- var getAlignFactor = function(align) {
- switch (align) {
- case"center":
- return 0.5;
- case"right":
- case"bottom":
- return 1;
- default:
- return 0
- }
- };
- var inverseAlign = function(align) {
- switch (align) {
- case"left":
- return "right";
- case"right":
- return "left";
- case"top":
- return "bottom";
- case"bottom":
- return "top";
- default:
- return align
- }
- };
- var calculateOversize = function(data, bounds) {
- var oversize = 0;
- if (data.myLocation < bounds.min)
- oversize += bounds.min - data.myLocation;
- if (data.myLocation > bounds.max)
- oversize += data.myLocation - bounds.max;
- return oversize
- };
- var initMyLocation = function(data) {
- data.myLocation = data.atLocation + getAlignFactor(data.atAlign) * data.atSize - getAlignFactor(data.myAlign) * data.mySize + data.offset
- };
- var decolliders = {
- fit: function(data, bounds) {
- var result = false;
- if (data.myLocation > bounds.max) {
- data.myLocation = bounds.max;
- result = true
- }
- if (data.myLocation < bounds.min) {
- data.myLocation = bounds.min;
- result = true
- }
- return result
- },
- flip: function(data, bounds) {
- if (data.myAlign === "center" && data.atAlign === "center")
- return false;
- if (data.myLocation < bounds.min || data.myLocation > bounds.max) {
- var inverseData = $.extend({}, data, {
- myAlign: inverseAlign(data.myAlign),
- atAlign: inverseAlign(data.atAlign),
- offset: -data.offset
- });
- initMyLocation(inverseData);
- inverseData.oversize = calculateOversize(inverseData, bounds);
- if (inverseData.myLocation >= bounds.min && inverseData.myLocation <= bounds.max || inverseData.myLocation > data.myLocation || inverseData.oversize < data.oversize) {
- data.myLocation = inverseData.myLocation;
- data.oversize = inverseData.oversize;
- return true
- }
- }
- return false
- }
- };
- var scrollbarWidth;
- var defaultPositionResult = {
- h: {
- location: 0,
- flip: false,
- fit: false,
- oversize: 0
- },
- v: {
- location: 0,
- flip: false,
- fit: false,
- oversize: 0
- }
- };
- var calculatePosition = function(what, options) {
- var $what = $(what),
- currentOffset = $what.offset(),
- result = $.extend(true, {}, defaultPositionResult, {
- h: {location: currentOffset.left},
- v: {location: currentOffset.top}
- });
- if (!options)
- return result;
- var my = normalizeAlign(options.my),
- at = normalizeAlign(options.at),
- of = options.of || window,
- offset = normalizeOffset(options.offset),
- collision = normalizeCollision(options.collision),
- boundary = options.boundary,
- boundaryOffset = normalizeOffset(options.boundaryOffset);
- var h = {
- mySize: $what.outerWidth(),
- myAlign: my.h,
- atAlign: at.h,
- offset: offset.h,
- collision: collision.h,
- boundaryOffset: boundaryOffset.h
- };
- var v = {
- mySize: $what.outerHeight(),
- myAlign: my.v,
- atAlign: at.v,
- offset: offset.v,
- collision: collision.v,
- boundaryOffset: boundaryOffset.v
- };
- if (of.preventDefault) {
- h.atLocation = of.pageX;
- v.atLocation = of.pageY;
- h.atSize = 0;
- v.atSize = 0
- }
- else {
- of = $(of);
- if ($.isWindow(of[0])) {
- h.atLocation = of.scrollLeft();
- v.atLocation = of.scrollTop();
- h.atSize = of.width();
- v.atSize = of.height()
- }
- else if (of[0].nodeType === 9) {
- h.atLocation = 0;
- v.atLocation = 0;
- h.atSize = of.width();
- v.atSize = of.height()
- }
- else {
- var o = of.offset();
- h.atLocation = o.left;
- v.atLocation = o.top;
- h.atSize = of.outerWidth();
- v.atSize = of.outerHeight()
- }
- }
- initMyLocation(h);
- initMyLocation(v);
- var bounds = function() {
- var win = $(window),
- windowWidth = win.width(),
- windowHeight = win.height(),
- left = win.scrollLeft(),
- top = win.scrollTop(),
- hScrollbar = document.width > document.documentElement.clientWidth,
- vScrollbar = document.height > document.documentElement.clientHeight,
- hZoomLevel = DX.support.touch ? document.documentElement.clientWidth / (vScrollbar ? windowWidth - scrollbarWidth : windowWidth) : 1,
- vZoomLevel = DX.support.touch ? document.documentElement.clientHeight / (hScrollbar ? windowHeight - scrollbarWidth : windowHeight) : 1;
- if (scrollbarWidth === undefined)
- scrollbarWidth = calculateScrollbarWidth();
- var boundaryWidth = windowWidth,
- boundaryHeight = windowHeight;
- if (boundary) {
- var $boundary = $(boundary),
- boundaryPosition = $boundary.offset();
- left = boundaryPosition.left;
- top = boundaryPosition.top;
- boundaryWidth = $boundary.width();
- boundaryHeight = $boundary.height()
- }
- return {
- h: {
- min: left + h.boundaryOffset,
- max: left + boundaryWidth / hZoomLevel - h.mySize - h.boundaryOffset
- },
- v: {
- min: top + v.boundaryOffset,
- max: top + boundaryHeight / vZoomLevel - v.mySize - v.boundaryOffset
- }
- }
- }();
- h.oversize = calculateOversize(h, bounds.h);
- v.oversize = calculateOversize(v, bounds.v);
- if (decolliders[h.collision])
- result.h[h.collision] = decolliders[h.collision](h, bounds.h);
- if (decolliders[v.collision])
- result.v[v.collision] = decolliders[v.collision](v, bounds.v);
- var preciser = function(number) {
- return options.precise ? number : Math.round(number)
- };
- $.extend(true, result, {
- h: {
- location: preciser(h.myLocation),
- oversize: preciser(h.oversize)
- },
- v: {
- location: preciser(v.myLocation),
- oversize: preciser(v.oversize)
- },
- precise: options.precise
- });
- return result
- };
- var position = function(what, options) {
- var $what = $(what);
- if (!options)
- return $what.offset();
- DX.translator.resetPosition($what);
- var offset = $what.offset(),
- targetPosition = options.h && options.v ? options : calculatePosition($what, options);
- var preciser = function(number) {
- return options.precise ? number : Math.round(number)
- };
- DX.translator.move($what, {
- left: targetPosition.h.location - preciser(offset.left),
- top: targetPosition.v.location - preciser(offset.top)
- });
- return targetPosition
- };
- $.extend(DX, {
- calculatePosition: calculatePosition,
- position: position
- });
- $.extend(DX.position, {
- inverseAlign: inverseAlign,
- normalizeAlign: normalizeAlign
- });
- var calculateScrollbarWidth = function() {
- var $scrollDiv = $("<div>").css({
- width: 100,
- height: 100,
- overflow: "scroll",
- position: "absolute",
- top: -9999
- }).appendTo($("body")),
- result = $scrollDiv.get(0).offsetWidth - $scrollDiv.get(0).clientWidth;
- $scrollDiv.remove();
- return result
- }
- })(jQuery, DevExpress);
- /*! Module core, file action.js */
- (function($, DX, undefined) {
- var actionExecutors = {};
- var registerExecutor = function(name, executor) {
- if ($.isPlainObject(name)) {
- $.each(name, registerExecutor);
- return
- }
- actionExecutors[name] = executor
- };
- var unregisterExecutor = function() {
- var args = $.makeArray(arguments);
- $.each(args, function() {
- delete actionExecutors[this]
- })
- };
- registerExecutor({
- func: {execute: function(e) {
- if ($.isFunction(e.action)) {
- e.result = e.action.apply(e.context, e.args);
- e.handled = true
- }
- }},
- url: {execute: function(e) {
- if (typeof e.action === "string" && e.action.charAt(0) !== "#")
- document.location = e.action
- }},
- hash: {execute: function(e) {
- if (typeof e.action === "string" && e.action.charAt(0) === "#")
- document.location.hash = e.action
- }}
- });
- var Action = DX.Class.inherit({
- ctor: function(action, config) {
- config = config || {};
- this._action = action || $.noop;
- this._context = config.context || window;
- this._beforeExecute = config.beforeExecute || $.noop;
- this._afterExecute = config.afterExecute || $.noop;
- this._component = config.component;
- this._excludeValidators = config.excludeValidators;
- this._validatingTargetName = config.validatingTargetName
- },
- execute: function() {
- var e = {
- action: this._action,
- args: Array.prototype.slice.call(arguments),
- context: this._context,
- component: this._component,
- validatingTargetName: this._validatingTargetName,
- cancel: false,
- handled: false
- };
- if (!this._validateAction(e))
- return;
- this._beforeExecute.call(this._context, e);
- if (e.cancel)
- return;
- var result = this._executeAction(e);
- this._afterExecute.call(this._context, e);
- return result
- },
- _validateAction: function(e) {
- var excludeValidators = this._excludeValidators;
- $.each(actionExecutors, function(name, executor) {
- if (excludeValidators && $.inArray(name, excludeValidators) > -1)
- return;
- if (executor.validate)
- executor.validate(e);
- if (e.cancel)
- return false
- });
- return !e.cancel
- },
- _executeAction: function(e) {
- var result;
- $.each(actionExecutors, function(index, executor) {
- if (executor.execute)
- executor.execute(e);
- if (e.handled) {
- result = e.result;
- return false
- }
- });
- return result
- }
- });
- $.extend(DX, {
- registerActionExecutor: registerExecutor,
- unregisterActionExecutor: unregisterExecutor,
- Action: Action
- });
- DX.__internals = {actionExecutors: actionExecutors}
- })(jQuery, DevExpress);
- /*! Module core, file translator.js */
- (function($, DX, undefined) {
- var support = DX.support,
- TRANSLATOR_DATA_KEY = "dxTranslator",
- TRANSFORM_MATRIX_REGEX = /matrix(3d)?\((.+?)\)/,
- TRANSLATE_REGEX = /translate(?:3d)?\((.+?)\)/;
- var locate = function($element) {
- var translate = support.transform ? getTranslate($element) : getTranslateFallback($element);
- return {
- left: translate.x,
- top: translate.y
- }
- };
- var move = function($element, position) {
- if (!support.transform) {
- $element.css(position);
- return
- }
- var translate = getTranslate($element),
- left = position.left,
- top = position.top;
- if (left !== undefined)
- translate.x = left || 0;
- if (top !== undefined)
- translate.y = top || 0;
- $element.css({transform: getTranslateCss(translate)});
- if (isPersentValue(left) || isPersentValue(top))
- clearCache($element)
- };
- var isPersentValue = function(value) {
- return $.type(value) === "string" && value[value.length - 1] === "%"
- };
- var getTranslateFallback = function($element) {
- var result;
- try {
- var originalTop = $element.css("top"),
- originalLeft = $element.css("left");
- var position = $element.position();
- $element.css({
- transform: "none",
- top: 0,
- left: 0
- });
- clearCache($element);
- var finalPosition = $element.position();
- result = {
- x: position.left - finalPosition.left || parseInt(originalLeft) || 0,
- y: position.top - finalPosition.top || parseInt(originalTop) || 0
- };
- $element.css({
- top: originalTop,
- left: originalLeft
- })
- }
- catch(e) {
- result = {
- x: 0,
- y: 0
- }
- }
- return result
- };
- var getTranslate = function($element) {
- var result = $element.data(TRANSLATOR_DATA_KEY);
- if (!result) {
- var transformValue = $element.css("transform") || getTranslateCss({
- x: 0,
- y: 0
- }),
- matrix = transformValue.match(TRANSFORM_MATRIX_REGEX),
- is3D = matrix && matrix[1];
- if (matrix) {
- matrix = matrix[2].split(",");
- if (is3D === "3d")
- matrix = matrix.slice(12, 15);
- else {
- matrix.push(0);
- matrix = matrix.slice(4, 7)
- }
- }
- else
- matrix = [0, 0, 0];
- result = {
- x: parseFloat(matrix[0]),
- y: parseFloat(matrix[1]),
- z: parseFloat(matrix[2])
- };
- cacheTranslate($element, result)
- }
- return result
- };
- var cacheTranslate = function($element, translate) {
- $element.data(TRANSLATOR_DATA_KEY, translate)
- };
- var clearCache = function($element) {
- $element.removeData(TRANSLATOR_DATA_KEY)
- };
- var resetPosition = function($element) {
- $element.css({
- left: 0,
- top: 0,
- transform: "none"
- });
- clearCache($element)
- };
- var parseTranslate = function(translateString) {
- var result = translateString.match(TRANSLATE_REGEX);
- if (!result || !result[1])
- return;
- result = result[1].split(",");
- result = {
- x: parseFloat(result[0]),
- y: parseFloat(result[1]),
- z: parseFloat(result[2])
- };
- return result
- };
- var getTranslateCss = function(translate) {
- translate.x = translate.x || 0;
- translate.y = translate.y || 0;
- var xValueString = isPersentValue(translate.x) ? translate.x : translate.x + "px";
- var yValueString = isPersentValue(translate.y) ? translate.y : translate.y + "px";
- return "translate(" + xValueString + ", " + yValueString + ")"
- };
- DX.translator = {
- move: move,
- locate: locate,
- clearCache: clearCache,
- parseTranslate: parseTranslate,
- getTranslate: getTranslate,
- getTranslateCss: getTranslateCss,
- resetPosition: resetPosition
- }
- })(jQuery, DevExpress);
- /*! Module core, file animationFrame.js */
- (function($, DX, undefined) {
- var FRAME_ANIMATION_STEP_TIME = 1000 / 60,
- requestAnimationFrame = function(callback) {
- return this.setTimeout(callback, FRAME_ANIMATION_STEP_TIME)
- },
- cancelAnimationFrame = function(requestID) {
- this.clearTimeout(requestID)
- },
- nativeRequestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame,
- nativeCancelAnimationFrame = window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || window.oCancelAnimationFrame || window.msCancelAnimationFrame;
- if (nativeRequestAnimationFrame && nativeCancelAnimationFrame) {
- requestAnimationFrame = nativeRequestAnimationFrame;
- cancelAnimationFrame = nativeCancelAnimationFrame
- }
- if (nativeRequestAnimationFrame && !nativeCancelAnimationFrame) {
- var cancelledRequests = {};
- requestAnimationFrame = function(callback) {
- var requestId = nativeRequestAnimationFrame.call(window, function() {
- try {
- if (requestId in cancelledRequests)
- return;
- callback.apply(this, arguments)
- }
- finally {
- delete cancelledRequests[requestId]
- }
- });
- return requestId
- };
- cancelAnimationFrame = function(requestId) {
- cancelledRequests[requestId] = true
- }
- }
- requestAnimationFrame = $.proxy(requestAnimationFrame, window);
- cancelAnimationFrame = $.proxy(cancelAnimationFrame, window);
- $.extend(DX, {
- requestAnimationFrame: requestAnimationFrame,
- cancelAnimationFrame: cancelAnimationFrame
- })
- })(jQuery, DevExpress);
- /*! Module core, file animator.js */
- (function($, DX, undefined) {
- DX.Animator = DX.Class.inherit({
- ctor: function() {
- this._finished = true;
- this._stopped = false;
- this._proxiedStepCore = $.proxy(this._stepCore, this)
- },
- start: function() {
- this._stopped = false;
- this._finished = false;
- this._stepCore()
- },
- stop: function() {
- this._stopped = true;
- DX.cancelAnimationFrame(this._stepAnimationFrame)
- },
- _stepCore: function() {
- if (this._isStopped()) {
- this._stop();
- return
- }
- if (this._isFinished()) {
- this._finished = true;
- this._complete();
- return
- }
- this._step();
- this._stepAnimationFrame = DX.requestAnimationFrame.call(window, this._proxiedStepCore)
- },
- _step: DX.abstract,
- _isFinished: $.noop,
- _stop: $.noop,
- _complete: $.noop,
- _isStopped: function() {
- return this._stopped
- },
- inProgress: function() {
- return !(this._stopped || this._finished)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file fx.js */
- (function($, DX, undefined) {
- var translator = DX.translator,
- support = DX.support,
- transitionEndEventName = support.transitionEndEventName + ".dxFX",
- removeEventName = "dxremove.dxFX";
- var CSS_TRANSITION_EASING_REGEX = /cubic-bezier\((\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\)/,
- RELATIVE_VALUE_REGEX = /^([+-])=(.*)/i,
- ANIM_DATA_KEY = "dxAnimData",
- ANIM_QUEUE_KEY = "dxAnimQueue",
- TRANSFORM_PROP = "transform";
- var TransitionAnimationStrategy = {
- initAnimation: function($element, config) {
- $element.css({transitionProperty: "none"});
- if (typeof config.from === "string")
- $element.addClass(config.from);
- else
- setProps($element, config.from)
- },
- animate: function($element, config) {
- var that = this,
- deferred = $.Deferred(),
- cleanupWhen = config.cleanupWhen;
- config.transitionAnimation = {finish: function() {
- that._finishTransition($element, config);
- if (cleanupWhen)
- $.when(deferred, cleanupWhen).always(function() {
- that._cleanup($element, config)
- });
- else
- that._cleanup($element, config);
- deferred.resolveWith($element, [config, $element])
- }};
- this._startAnimation($element, config);
- this._completeAnimationCallback($element, config).done(function() {
- config.transitionAnimation.finish()
- });
- if (!config.duration)
- config.transitionAnimation.finish();
- return deferred.promise()
- },
- _completeAnimationCallback: function($element, config) {
- var startTime = $.now() + config.delay,
- deferred = $.Deferred(),
- transitionEndFired = $.Deferred(),
- simulatedTransitionEndFired = $.Deferred(),
- simulatedEndEventTimer,
- waitForJSCompleteTimer;
- config.transitionAnimation.cleanup = function() {
- clearTimeout(simulatedEndEventTimer);
- clearTimeout(waitForJSCompleteTimer)
- };
- $element.one(transitionEndEventName, function() {
- if ($.now() - startTime >= config.duration)
- transitionEndFired.reject()
- }).off(removeEventName).on(removeEventName, function() {
- config.transitionAnimation.cleanup()
- });
- waitForJSCompleteTimer = setTimeout(function() {
- simulatedEndEventTimer = setTimeout(function() {
- simulatedTransitionEndFired.reject()
- }, config.duration + config.delay + DX.fx._simulatedTransitionEndDelay);
- $.when(transitionEndFired, simulatedTransitionEndFired).fail($.proxy(function() {
- deferred.resolve()
- }, this))
- });
- return deferred.promise()
- },
- _startAnimation: function($element, config) {
- $element.css("transform");
- $element.css({
- transitionProperty: "all",
- transitionDelay: config.delay + "ms",
- transitionDuration: config.duration + "ms",
- transitionTimingFunction: config.easing
- });
- if (typeof config.to === "string")
- $element.addClass(config.to);
- else if (config.to)
- setProps($element, config.to)
- },
- _finishTransition: function($element, config) {
- $element.css("transition", "none")
- },
- _cleanup: function($element, config) {
- $element.off(transitionEndEventName);
- config.transitionAnimation.cleanup();
- if (typeof config.from === "string") {
- $element.removeClass(config.from);
- $element.removeClass(config.to)
- }
- },
- stop: function($element, config, jumpToEnd) {
- if (!config)
- return;
- if (jumpToEnd)
- config.transitionAnimation.finish();
- else {
- if ($.isPlainObject(config.to))
- $.each(config.to, function(key) {
- $element.css(key, $element.css(key))
- });
- this._finishTransition($element, config);
- this._cleanup($element, config)
- }
- }
- };
- var FrameAnimationStrategy = {
- initAnimation: function($element, config) {
- setProps($element, config.from)
- },
- animate: function($element, config) {
- var deferred = $.Deferred(),
- that = this;
- if (!config)
- return deferred.reject().promise();
- $.each(config.to, function(prop) {
- if (config.from[prop] === undefined)
- config.from[prop] = that._normalizeValue($element.css(prop))
- });
- if (config.to[TRANSFORM_PROP]) {
- config.from[TRANSFORM_PROP] = that._parseTransform(config.from[TRANSFORM_PROP]);
- config.to[TRANSFORM_PROP] = that._parseTransform(config.to[TRANSFORM_PROP])
- }
- config.frameAnimation = {
- to: config.to,
- from: config.from,
- currentValue: config.from,
- easing: convertTransitionTimingFuncToJQueryEasing(config.easing),
- duration: config.duration,
- startTime: (new Date).valueOf(),
- finish: function() {
- this.currentValue = this.to;
- this.draw();
- deferred.resolve()
- },
- draw: function() {
- var currentValue = $.extend({}, this.currentValue);
- if (currentValue[TRANSFORM_PROP])
- currentValue[TRANSFORM_PROP] = $.map(currentValue[TRANSFORM_PROP], function(value, prop) {
- if (prop === "translate")
- return translator.getTranslateCss(value);
- else if (prop === "scale")
- return "scale(" + value + ")";
- else if (prop.substr(0, prop.length - 1) === "rotate")
- return prop + "(" + value + "deg)"
- }).join(" ");
- $element.css(currentValue)
- }
- };
- if (config.delay) {
- config.frameAnimation.startTime += config.delay;
- config.frameAnimation.delayTimeout = setTimeout(function() {
- that._animationStep($element, config)
- }, config.delay)
- }
- else
- that._animationStep($element, config);
- return deferred.promise()
- },
- _parseTransform: function(transformString) {
- var result = {};
- $.each(transformString.match(/(\w|\d)+\([^\)]*\)\s*/g), function(i, part) {
- var translateData = translator.parseTranslate(part),
- scaleData = part.match(/scale\((.+?)\)/),
- rotateData = part.match(/(rotate.)\((.+)deg\)/);
- if (translateData)
- result.translate = translateData;
- if (scaleData && scaleData[1])
- result.scale = parseFloat(scaleData[1]);
- if (rotateData && rotateData[1])
- result[rotateData[1]] = parseFloat(rotateData[2])
- });
- return result
- },
- stop: function($element, config, jumpToEnd) {
- var frameAnimation = config && config.frameAnimation;
- if (!frameAnimation)
- return;
- clearTimeout(frameAnimation.delayTimeout);
- if (jumpToEnd)
- frameAnimation.finish();
- delete config.frameAnimation
- },
- _animationStep: function($element, config) {
- var frameAnimation = config && config.frameAnimation;
- if (!frameAnimation)
- return;
- var now = (new Date).valueOf();
- if (now >= frameAnimation.startTime + frameAnimation.duration) {
- frameAnimation.finish();
- return
- }
- frameAnimation.currentValue = this._calcStepValue(frameAnimation, now - frameAnimation.startTime);
- frameAnimation.draw();
- DX.requestAnimationFrame($.proxy(function() {
- this._animationStep($element, config)
- }, this))
- },
- _calcStepValue: function(frameAnimation, currentDuration) {
- var calcValueRecursively = function(from, to) {
- var result = $.isArray(to) ? [] : {};
- var calcEasedValue = function(propName) {
- var x = currentDuration / frameAnimation.duration,
- t = currentDuration,
- b = 1 * from[propName],
- c = to[propName] - from[propName],
- d = frameAnimation.duration;
- return $.easing[frameAnimation.easing](x, t, b, c, d)
- };
- $.each(to, function(propName, endPropValue) {
- if (typeof endPropValue === "string" && parseFloat(endPropValue, 10) === false)
- return true;
- result[propName] = typeof endPropValue === "object" ? calcValueRecursively(from[propName], endPropValue) : calcEasedValue(propName)
- });
- return result
- };
- return calcValueRecursively(frameAnimation.from, frameAnimation.to)
- },
- _normalizeValue: function(value) {
- var numericValue = parseFloat(value, 10);
- if (numericValue === false)
- return value;
- return numericValue
- }
- };
- var FallbackToNoAnimationStrategy = {
- initAnimation: function($element, config){},
- animate: function($element, config) {
- return $.Deferred().resolve().promise()
- }
- };
- var animationStrategies = {
- transition: support.transition ? TransitionAnimationStrategy : FrameAnimationStrategy,
- frame: FrameAnimationStrategy,
- noAnimation: FallbackToNoAnimationStrategy
- };
- var getAnimationStrategy = function(config) {
- config = config || {};
- var strategy = config.strategy || "transition";
- if (config.type === "css" && !support.transition)
- strategy = "noAnimation";
- return animationStrategies[strategy]
- };
- var TransitionTimingFuncMap = {
- linear: "cubic-bezier(0, 0, 1, 1)",
- ease: "cubic-bezier(0.25, 0.1, 0.25, 1)",
- "ease-in": "cubic-bezier(0.42, 0, 1, 1)",
- "ease-out": "cubic-bezier(0, 0, 0.58, 1)",
- "ease-in-out": "cubic-bezier(0.42, 0, 0.58, 1)"
- };
- var convertTransitionTimingFuncToJQueryEasing = function(cssTransitionEasing) {
- cssTransitionEasing = TransitionTimingFuncMap[cssTransitionEasing] || cssTransitionEasing;
- var bezCoeffs = cssTransitionEasing.match(CSS_TRANSITION_EASING_REGEX);
- if (!bezCoeffs)
- return "linear";
- bezCoeffs = bezCoeffs.slice(1, 5);
- $.each(bezCoeffs, function(index, value) {
- bezCoeffs[index] = parseFloat(value)
- });
- var easingName = "cubicbezier_" + bezCoeffs.join("_").replace(/\./g, "p");
- if (!$.isFunction($.easing[easingName])) {
- var polynomBezier = function(x1, y1, x2, y2) {
- var Cx = 3 * x1,
- Bx = 3 * (x2 - x1) - Cx,
- Ax = 1 - Cx - Bx,
- Cy = 3 * y1,
- By = 3 * (y2 - y1) - Cy,
- Ay = 1 - Cy - By;
- var bezierX = function(t) {
- return t * (Cx + t * (Bx + t * Ax))
- };
- var bezierY = function(t) {
- return t * (Cy + t * (By + t * Ay))
- };
- var findXfor = function(t) {
- var x = t,
- i = 0,
- z;
- while (i < 14) {
- z = bezierX(x) - t;
- if (Math.abs(z) < 1e-3)
- break;
- x = x - z / derivativeX(x);
- i++
- }
- return x
- };
- var derivativeX = function(t) {
- return Cx + t * (2 * Bx + t * 3 * Ax)
- };
- return function(t) {
- return bezierY(findXfor(t))
- }
- };
- $.easing[easingName] = function(x, t, b, c, d) {
- return c * polynomBezier(bezCoeffs[0], bezCoeffs[1], bezCoeffs[2], bezCoeffs[3])(t / d) + b
- }
- }
- return easingName
- };
- var baseConfigValidator = function(config, animationType, validate, typeMessage) {
- $.each(["from", "to"], function() {
- if (!validate(config[this]))
- throw DX.Error("E0010", animationType, this, typeMessage);
- })
- };
- var isObjectConfigValidator = function(config, animationType) {
- return baseConfigValidator(config, animationType, function(target) {
- return $.isPlainObject(target)
- }, "a plain object")
- };
- var isStringConfigValidator = function(config, animationType) {
- return baseConfigValidator(config, animationType, function(target) {
- return typeof target === "string"
- }, "a string")
- };
- var CustomAnimationConfigurator = {setup: function($element, config){}};
- var CssAnimationConfigurator = {
- validateConfig: function(config) {
- isStringConfigValidator(config, "css")
- },
- setup: function($element, config){}
- };
- var positionAliases = {
- top: {
- my: "bottom center",
- at: "top center"
- },
- bottom: {
- my: "top center",
- at: "bottom center"
- },
- right: {
- my: "left center",
- at: "right center"
- },
- left: {
- my: "right center",
- at: "left center"
- }
- };
- var SlideAnimationConfigurator = {
- validateConfig: function(config) {
- isObjectConfigValidator(config, "slide")
- },
- setup: function($element, config) {
- var location = translator.locate($element);
- if (config.type !== "slide") {
- var positioningConfig = config.type === "slideIn" ? config.from : config.to;
- positioningConfig.position = $.extend({of: window}, positionAliases[config.direction]);
- setupPosition($element, positioningConfig)
- }
- this._setUpConfig(location, config.from);
- this._setUpConfig(location, config.to);
- translator.clearCache($element);
- if (!support.transform && $element.css("position") === "static")
- $element.css("position", "relative")
- },
- _setUpConfig: function(location, config) {
- config.left = "left" in config ? config.left : "+=0";
- config.top = "top" in config ? config.top : "+=0";
- this._initNewPosition(location, config)
- },
- _initNewPosition: function(location, config) {
- var position = {
- left: config.left,
- top: config.top
- };
- delete config.left;
- delete config.top;
- var relativeValue = this._getRelativeValue(position.left);
- if (relativeValue !== undefined)
- position.left = relativeValue + location.left;
- else
- config.left = 0;
- relativeValue = this._getRelativeValue(position.top);
- if (relativeValue !== undefined)
- position.top = relativeValue + location.top;
- else
- config.top = 0;
- var translate = {
- x: 0,
- y: 0
- };
- if (support.transform)
- translate = {
- x: position.left,
- y: position.top
- };
- else {
- config.left = position.left;
- config.top = position.top
- }
- config[TRANSFORM_PROP] = translator.getTranslateCss(translate)
- },
- _getRelativeValue: function(value) {
- var relativeValue;
- if (typeof value === "string" && (relativeValue = RELATIVE_VALUE_REGEX.exec(value)))
- return parseInt(relativeValue[1] + "1") * relativeValue[2]
- }
- };
- var FadeAnimationConfigurator = {setup: function($element, config) {
- var from = config.from,
- fromOpacity = $.isPlainObject(from) ? config.skipElementInitialStyles ? 0 : $element.css("opacity") : String(from),
- toOpacity;
- switch (config.type) {
- case"fadeIn":
- toOpacity = 1;
- break;
- case"fadeOut":
- toOpacity = 0;
- break;
- default:
- toOpacity = String(config.to)
- }
- config.from = {
- visibility: "visible",
- opacity: fromOpacity
- };
- config.to = {opacity: toOpacity}
- }};
- var PopAnimationConfigurator = {
- validateConfig: function(config) {
- isObjectConfigValidator(config, "pop")
- },
- setup: function($element, config) {
- var from = config.from,
- to = config.to,
- fromOpacity = "opacity" in from ? from.opacity : $element.css("opacity"),
- toOpacity = "opacity" in to ? to.opacity : 1,
- fromScale = "scale" in from ? from.scale : 0,
- toScale = "scale" in to ? to.scale : 1;
- config.from = {opacity: fromOpacity};
- var translate = translator.getTranslate($element);
- config.from[TRANSFORM_PROP] = this._getCssTransform(translate, fromScale);
- config.to = {opacity: toOpacity};
- config.to[TRANSFORM_PROP] = this._getCssTransform(translate, toScale)
- },
- _getCssTransform: function(translate, scale) {
- return translator.getTranslateCss(translate) + "scale(" + scale + ")"
- }
- };
- var animationConfigurators = {
- custom: CustomAnimationConfigurator,
- slide: SlideAnimationConfigurator,
- slideIn: SlideAnimationConfigurator,
- slideOut: SlideAnimationConfigurator,
- fade: FadeAnimationConfigurator,
- fadeIn: FadeAnimationConfigurator,
- fadeOut: FadeAnimationConfigurator,
- pop: PopAnimationConfigurator,
- css: CssAnimationConfigurator
- };
- var getAnimationConfigurator = function(config) {
- var result = animationConfigurators[config.type];
- if (!result)
- throw DX.Error("E0011", config.type);
- return result
- };
- var defaultJSConfig = {
- type: "custom",
- from: {},
- to: {},
- duration: 400,
- start: $.noop,
- complete: $.noop,
- easing: "ease",
- delay: 0
- },
- defaultCssConfig = {
- duration: 400,
- easing: "ease",
- delay: 0
- };
- var setupAnimationOnElement = function() {
- var animation = this,
- $element = animation.$element,
- config = animation.config;
- setupPosition($element, config.from);
- setupPosition($element, config.to);
- animation.configurator.setup($element, config);
- $element.data(ANIM_DATA_KEY, animation);
- if (DX.fx.off)
- config.duration = 0;
- animation.strategy.initAnimation($element, config);
- if (config.start)
- config.start.apply(this, [$element, config])
- };
- var startAnimationOnElement = function() {
- var animation = this,
- $element = animation.$element,
- config = animation.config;
- return animation.strategy.animate($element, config).done(function() {
- $element.removeData(ANIM_DATA_KEY);
- if (config.complete)
- config.complete.apply(this, [$element, config]);
- animation.deferred.resolveWith(this, [$element, config])
- })
- };
- var createAnimation = function($element, initialConfig) {
- var defaultConfig = initialConfig.type === "css" ? defaultCssConfig : defaultJSConfig,
- config = $.extend(true, {}, defaultConfig, initialConfig),
- configurator = getAnimationConfigurator(config),
- strategy = getAnimationStrategy(config),
- animation = {
- $element: $element,
- config: config,
- configurator: configurator,
- strategy: strategy,
- setup: setupAnimationOnElement,
- start: startAnimationOnElement,
- deferred: $.Deferred()
- };
- if ($.isFunction(configurator.validateConfig))
- configurator.validateConfig(config);
- return animation
- };
- var animate = function(element, config) {
- var $element = $(element);
- if (!$element.length)
- return $.Deferred().resolve().promise();
- var animation = createAnimation($element, config);
- pushInAnimationQueue($element, animation);
- return animation.deferred.promise()
- };
- var pushInAnimationQueue = function($element, animation) {
- var queueData = getAnimQueueData($element);
- writeAnimQueueData($element, queueData);
- queueData.push(animation);
- if (!isAnimating($element))
- shiftFromAnimationQueue($element, queueData)
- };
- var getAnimQueueData = function($element) {
- return $element.data(ANIM_QUEUE_KEY) || []
- };
- var writeAnimQueueData = function($element, queueData) {
- $element.data(ANIM_QUEUE_KEY, queueData)
- };
- var destroyAnimQueueData = function($element) {
- $element.removeData(ANIM_QUEUE_KEY)
- };
- var isAnimating = function($element) {
- return !!$element.data(ANIM_DATA_KEY)
- };
- var shiftFromAnimationQueue = function($element, queueData) {
- queueData = getAnimQueueData($element);
- if (!queueData.length)
- return;
- var animation = queueData.shift();
- if (queueData.length === 0)
- destroyAnimQueueData($element);
- executeAnimation(animation).done(function() {
- shiftFromAnimationQueue($element)
- })
- };
- var executeAnimation = function(animation) {
- animation.setup();
- return animation.start()
- };
- var setupPosition = function($element, config) {
- if (!config || !config.position)
- return;
- var position = DX.calculatePosition($element, config.position),
- offset = $element.offset(),
- currentPosition = $element.position();
- $.extend(config, {
- left: position.h.location - offset.left + currentPosition.left,
- top: position.v.location - offset.top + currentPosition.top
- });
- delete config.position
- };
- var setProps = function($element, props) {
- $.each(props, function(key, value) {
- $element.css(key, value)
- })
- };
- var stop = function(element, jumpToEnd) {
- var $element = $(element),
- queueData = getAnimQueueData($element);
- $.each(queueData, function(_, animation) {
- animation.config.duration = 0
- });
- if (!isAnimating($element))
- shiftFromAnimationQueue($element, queueData);
- var animation = $element.data(ANIM_DATA_KEY);
- if (animation)
- animation.strategy.stop($element, animation.config, jumpToEnd);
- $element.removeData(ANIM_DATA_KEY);
- destroyAnimQueueData($element)
- };
- DX.fx = {
- off: false,
- animationTypes: animationConfigurators,
- animate: animate,
- createAnimation: createAnimation,
- isAnimating: isAnimating,
- stop: stop,
- _simulatedTransitionEndDelay: 100
- };
- DX.fx.__internals = {convertTransitionTimingFuncToJQueryEasing: convertTransitionTimingFuncToJQueryEasing}
- })(jQuery, DevExpress);
- /*! Module core, file dxProxyUrlFormatter.js */
- (function($, DX, undefined) {
- var location = window.location,
- DXPROXY_HOST = "dxproxy.devexpress.com:8000",
- IS_DXPROXY_ORIGIN = location.host === DXPROXY_HOST,
- urlMapping = {};
- var extractProxyAppId = function() {
- return location.pathname.split("/")[1]
- };
- var urlFormatter = {
- isProxyUsed: function() {
- return IS_DXPROXY_ORIGIN
- },
- formatProxyUrl: function(localUrl) {
- var urlData = DX.parseUrl(localUrl);
- if (!/^(localhost$|127\.)/i.test(urlData.hostname))
- return localUrl;
- var proxyUrlPart = DXPROXY_HOST + "/" + extractProxyAppId() + "_" + urlData.port;
- urlMapping[proxyUrlPart] = urlData.hostname + ":" + urlData.port;
- var resultUrl = "http://" + proxyUrlPart + urlData.pathname + urlData.search;
- return resultUrl
- },
- formatLocalUrl: function(proxyUrl) {
- if (proxyUrl.indexOf(DXPROXY_HOST) < 0)
- return proxyUrl;
- var resultUrl = proxyUrl;
- for (var proxyUrlPart in urlMapping)
- if (urlMapping.hasOwnProperty(proxyUrlPart))
- if (proxyUrl.indexOf(proxyUrlPart) >= 0) {
- resultUrl = proxyUrl.replace(proxyUrlPart, urlMapping[proxyUrlPart]);
- break
- }
- return resultUrl
- }
- };
- DX._proxyUrlFormatter = urlFormatter
- })(jQuery, DevExpress);
- /*! Module core, file endpointSelector.js */
- (function($, DX, undefined) {
- var location = window.location,
- IS_WINJS_ORIGIN = location.protocol === "ms-appx:",
- IS_LOCAL_ORIGIN = isLocalHostName(location.hostname);
- function isLocalHostName(url) {
- return /^(localhost$|127\.)/i.test(url)
- }
- var EndpointSelector = DX.EndpointSelector = function(config) {
- this.config = config
- };
- EndpointSelector.prototype = {urlFor: function(key) {
- var bag = this.config[key];
- if (!bag)
- throw DX.Error("E0006");
- if (DX._proxyUrlFormatter.isProxyUsed())
- return DX._proxyUrlFormatter.formatProxyUrl(bag.local);
- if (bag.production)
- if (IS_WINJS_ORIGIN && !Debug.debuggerEnabled || !IS_WINJS_ORIGIN && !IS_LOCAL_ORIGIN)
- return bag.production;
- return bag.local
- }}
- })(jQuery, DevExpress);
- /*! Module core, file formatHelper.js */
- (function($, DX, undefined) {
- var utils = DX.utils;
- DX.NumericFormat = {
- currency: 'C',
- fixedpoint: 'N',
- exponential: '',
- percent: 'P',
- decimal: 'D'
- };
- DX.LargeNumberFormatPostfixes = {
- 1: 'K',
- 2: 'M',
- 3: 'B',
- 4: 'T'
- };
- var MAX_LARGE_NUMBER_POWER = 4,
- DECIMAL_BASE = 10;
- DX.LargeNumberFormatPowers = {
- largenumber: 'auto',
- thousands: 1,
- millions: 2,
- billions: 3,
- trillions: 4
- };
- DX.DateTimeFormat = {
- longdate: 'D',
- longtime: 'T',
- monthandday: 'M',
- monthandyear: 'Y',
- quarterandyear: 'qq',
- shortdate: 'd',
- shorttime: 't',
- millisecond: 'fff',
- second: 'T',
- minute: 't',
- hour: 't',
- day: 'dd',
- week: 'dd',
- month: 'MMMM',
- quarter: 'qq',
- year: 'yyyy',
- longdatelongtime: 'D',
- shortdateshorttime: 'd',
- shortyear: 'yy'
- };
- DX.formatHelper = {
- defaultQuarterFormat: 'Q{0}',
- romanDigits: ['I', 'II', 'III', 'IV'],
- _addFormatSeparator: function(format1, format2) {
- var separator = ' ';
- if (format2)
- return format1 + separator + format2;
- return format1
- },
- _getDateTimeFormatPattern: function(dateTimeFormat) {
- return Globalize.findClosestCulture().calendar.patterns[DX.DateTimeFormat[dateTimeFormat.toLowerCase()]]
- },
- _isDateFormatContains: function(format) {
- var result = false;
- $.each(DX.DateTimeFormat, function(key) {
- result = key === format.toLowerCase();
- return !result
- });
- return result
- },
- getQuarter: function(month) {
- return Math.floor(month / 3)
- },
- getFirstQuarterMonth: function(month) {
- return this.getQuarter(month) * 3
- },
- _getQuarterString: function(date, format) {
- var quarter = this.getQuarter(date.getMonth());
- switch (format) {
- case'q':
- return this.romanDigits[quarter];
- case'qq':
- return utils.stringFormat(this.defaultQuarterFormat, this.romanDigits[quarter]);
- case'Q':
- return (quarter + 1).toString();
- case'QQ':
- return utils.stringFormat(this.defaultQuarterFormat, (quarter + 1).toString())
- }
- return ''
- },
- _formatCustomString: function(value, format) {
- var regExp = /qq|q|QQ|Q/g,
- quarterFormat,
- result = '',
- index = 0;
- regExp.lastIndex = 0;
- while (index < format.length) {
- quarterFormat = regExp.exec(format);
- if (!quarterFormat || quarterFormat.index > index)
- result += Globalize.format(value, format.substring(index, quarterFormat ? quarterFormat.index : format.length));
- if (quarterFormat) {
- result += this._getQuarterString(value, quarterFormat[0]);
- index = quarterFormat.index + quarterFormat[0].length
- }
- else
- index = format.length
- }
- return result
- },
- _parseNumberFormatString: function(format) {
- var formatList,
- formatObject = {};
- if (!format || typeof format !== 'string')
- return;
- formatList = format.toLowerCase().split(' ');
- $.each(formatList, function(index, value) {
- if (value in DX.NumericFormat)
- formatObject.formatType = value;
- else if (value in DX.LargeNumberFormatPowers)
- formatObject.power = DX.LargeNumberFormatPowers[value]
- });
- if (formatObject.power && !formatObject.formatType)
- formatObject.formatType = 'fixedpoint';
- if (formatObject.formatType)
- return formatObject
- },
- _calculateNumberPower: function(value, base, minPower, maxPower) {
- var number = Math.abs(value);
- var power = 0;
- if (number > 1)
- while (number && number >= base && (maxPower === undefined || power < maxPower)) {
- power++;
- number = number / base
- }
- else if (number > 0 && number < 1)
- while (number < 1 && (minPower === undefined || power > minPower)) {
- power--;
- number = number * base
- }
- return power
- },
- _getNumberByPower: function(number, power, base) {
- var result = number;
- while (power > 0) {
- result = result / base;
- power--
- }
- while (power < 0) {
- result = result * base;
- power++
- }
- return result
- },
- _formatNumber: function(value, formatObject, precision) {
- var powerPostfix;
- if (formatObject.power === 'auto')
- formatObject.power = this._calculateNumberPower(value, 1000, 0, MAX_LARGE_NUMBER_POWER);
- if (formatObject.power)
- value = this._getNumberByPower(value, formatObject.power, 1000);
- powerPostfix = DX.LargeNumberFormatPostfixes[formatObject.power] || '';
- return this._formatNumberCore(value, formatObject.formatType, precision) + powerPostfix
- },
- _formatNumberExponential: function(value, precision) {
- var power = this._calculateNumberPower(value, DECIMAL_BASE),
- number = this._getNumberByPower(value, power, DECIMAL_BASE),
- powString;
- precision = precision === undefined ? 1 : precision;
- if (number.toFixed(precision || 0) >= DECIMAL_BASE) {
- power++;
- number = number / DECIMAL_BASE
- }
- powString = (power >= 0 ? '+' : '') + power.toString();
- return this._formatNumberCore(number, 'fixedpoint', precision) + 'E' + powString
- },
- _formatNumberCore: function(value, format, precision) {
- if (format === 'exponential')
- return this._formatNumberExponential(value, precision);
- else
- return Globalize.format(value, DX.NumericFormat[format] + (utils.isNumber(precision) ? precision : 0))
- },
- _formatDate: function(date, format) {
- var resultFormat = DX.DateTimeFormat[format.toLowerCase()];
- format = format.toLowerCase();
- if (format === 'quarterandyear')
- resultFormat = this._getQuarterString(date, resultFormat) + ' yyyy';
- if (format === 'quarter')
- return this._getQuarterString(date, resultFormat);
- if (format === 'longdatelongtime')
- return this._formatDate(date, 'longdate') + ' ' + this._formatDate(date, 'longtime');
- if (format === 'shortdateshorttime')
- return this._formatDate(date, 'shortDate') + ' ' + this._formatDate(date, 'shortTime');
- return Globalize.format(date, resultFormat)
- },
- format: function(value, format, precision) {
- if ($.isPlainObject(format) && format.format)
- if (format.dateType)
- return this._formatDateEx(value, format);
- else if (utils.isNumber(value) && isFinite(value))
- return this._formatNumberEx(value, format);
- return this._format(value, format, precision)
- },
- _format: function(value, format, precision) {
- var numberFormatObject;
- if (!utils.isString(format) || format === '' || !utils.isNumber(value) && !utils.isDate(value))
- return utils.isDefined(value) ? value.toString() : '';
- numberFormatObject = this._parseNumberFormatString(format);
- if (utils.isNumber(value) && numberFormatObject)
- return this._formatNumber(value, numberFormatObject, precision);
- if (utils.isDate(value) && this._isDateFormatContains(format))
- return this._formatDate(value, format);
- if (!numberFormatObject && !this._isDateFormatContains(format))
- return this._formatCustomString(value, format)
- },
- _formatNumberEx: function(value, formatInfo) {
- var that = this,
- numericFormatType = DX.NumericFormat[formatInfo.format.toLowerCase()],
- numberFormat = Globalize.culture().numberFormat,
- currencyFormat = formatInfo.currencyCulture && Globalize.cultures[formatInfo.currencyCulture] ? Globalize.cultures[formatInfo.currencyCulture].numberFormat.currency : numberFormat.currency,
- percentFormat = numberFormat.percent,
- formatSettings = that._getUnitFormatSettings(value, formatInfo),
- unit = formatSettings.unit,
- precision = formatSettings.precision,
- showTrailingZeros = formatSettings.showTrailingZeros,
- includeGroupSeparator = formatSettings.includeGroupSeparator,
- groupSymbol = numberFormat[","],
- floatingSymbol = numberFormat["."],
- number,
- isNegative,
- pattern,
- currentFormat,
- regexParts = /n|\$|-|%/g,
- result = "";
- if (!utils.isDefined(value))
- return '';
- value = that._applyUnitToValue(value, unit);
- number = Math.abs(value);
- isNegative = value < 0;
- switch (numericFormatType) {
- case DX.NumericFormat.decimal:
- pattern = "n";
- number = Math[isNegative ? "ceil" : "floor"](number);
- if (precision > 0) {
- var str = "" + number;
- for (var i = str.length; i < precision; i += 1)
- str = "0" + str;
- number = str
- }
- if (isNegative)
- number = "-" + number;
- break;
- case DX.NumericFormat.fixedpoint:
- currentFormat = numberFormat;
- case DX.NumericFormat.currency:
- currentFormat = currentFormat || currencyFormat;
- case DX.NumericFormat.percent:
- currentFormat = currentFormat || percentFormat;
- pattern = isNegative ? currentFormat.pattern[0] : currentFormat.pattern[1] || "n";
- number = Globalize.format(number * (numericFormatType === DX.NumericFormat.percent ? 100 : 1), "N" + precision);
- if (!showTrailingZeros)
- number = that._excludeTrailingZeros(number, floatingSymbol);
- if (!includeGroupSeparator)
- number = number.replace(new RegExp('\\' + groupSymbol, 'g'), '');
- break;
- case DX.NumericFormat.exponential:
- return that._formatNumberExponential(value, precision);
- default:
- throw"Illegal numeric format: '" + numericFormatType + "'";
- }
- for (; ; ) {
- var lastIndex = regexParts.lastIndex,
- matches = regexParts.exec(pattern);
- result += pattern.slice(lastIndex, matches ? matches.index : pattern.length);
- if (matches)
- switch (matches[0]) {
- case"-":
- if (/[1-9]/.test(number))
- result += numberFormat["-"];
- break;
- case"$":
- result += currencyFormat.symbol;
- break;
- case"%":
- result += percentFormat.symbol;
- break;
- case"n":
- result += number + unit;
- break
- }
- else
- break
- }
- return (formatInfo.plus && value > 0 ? "+" : '') + result
- },
- _excludeTrailingZeros: function(strValue, floatingSymbol) {
- var floatingIndex = strValue.indexOf(floatingSymbol),
- stopIndex,
- i;
- if (floatingIndex < 0)
- return strValue;
- stopIndex = strValue.length;
- for (i = stopIndex - 1; i >= floatingIndex && (strValue[i] === '0' || i === floatingIndex); i--)
- stopIndex--;
- return strValue.substring(0, stopIndex)
- },
- _getUnitFormatSettings: function(value, formatInfo) {
- var unit = formatInfo.unit || '',
- precision = formatInfo.precision || 0,
- includeGroupSeparator = formatInfo.includeGroupSeparator || false,
- showTrailingZeros = formatInfo.showTrailingZeros === undefined ? true : formatInfo.showTrailingZeros,
- significantDigits = formatInfo.significantDigits || 1,
- absValue;
- if (unit.toLowerCase() === 'auto') {
- showTrailingZeros = false;
- absValue = Math.abs(value);
- if (significantDigits < 1)
- significantDigits = 1;
- if (absValue >= 1000000000) {
- unit = 'B';
- absValue /= 1000000000
- }
- else if (absValue >= 1000000) {
- unit = 'M';
- absValue /= 1000000
- }
- else if (absValue >= 1000) {
- unit = 'K';
- absValue /= 1000
- }
- else
- unit = '';
- if (absValue === 0)
- precision = 0;
- else if (absValue < 1) {
- precision = significantDigits;
- var smallValue = Math.pow(10, -significantDigits);
- while (absValue < smallValue) {
- smallValue /= 10;
- precision++
- }
- }
- else if (absValue >= 100)
- precision = significantDigits - 3;
- else if (absValue >= 10)
- precision = significantDigits - 2;
- else
- precision = significantDigits - 1
- }
- if (precision < 0)
- precision = 0;
- return {
- unit: unit,
- precision: precision,
- showTrailingZeros: showTrailingZeros,
- includeGroupSeparator: includeGroupSeparator
- }
- },
- _applyUnitToValue: function(value, unit) {
- if (unit === 'B')
- return value.toFixed(1) / 1000000000;
- if (unit === 'M')
- return value / 1000000;
- if (unit === 'K')
- return value / 1000;
- return value
- },
- _formatDateEx: function(value, formatInfo) {
- var that = this,
- format = formatInfo.format,
- dateType = formatInfo.dateType,
- calendar = Globalize.culture().calendars.standard,
- time,
- index,
- dateStr;
- format = format.toLowerCase();
- if (!utils.isDefined(value))
- return '';
- if (dateType !== 'num' || format === 'dayofweek')
- switch (format) {
- case'monthyear':
- return that._formatDate(value, 'monthandyear');
- case'quarteryear':
- return that._getQuarterString(value, 'QQ') + ' ' + value.getFullYear();
- case'daymonthyear':
- return that._formatDate(value, dateType + 'Date');
- case'datehour':
- time = new Date(value.getTime());
- time.setMinutes(0);
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(time, 'shorttime') : dateStr + ' ' + that._formatDate(time, 'shorttime');
- case'datehourminute':
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(value, 'shorttime') : dateStr + ' ' + that._formatDate(value, 'shorttime');
- case'datehourminutesecond':
- dateStr = dateType === 'timeOnly' ? '' : that._formatDate(value, dateType + 'Date');
- return dateType === 'timeOnly' ? that._formatDate(value, 'longtime') : dateStr + ' ' + that._formatDate(value, 'longtime');
- case'year':
- dateStr = value.toString();
- return dateType === 'abbr' ? dateStr.slice(2, 4) : dateStr;
- case'dateyear':
- return dateType === 'abbr' ? that._formatDate(value, 'shortyear') : that._formatDate(value, 'year');
- case'quarter':
- return utils.stringFormat(that.defaultQuarterFormat, value.toString());
- case'month':
- index = value - 1;
- return dateType === 'abbr' ? calendar.months.namesAbbr[index] : calendar.months.names[index];
- case'hour':
- if (dateType === 'long') {
- time = new Date;
- time.setHours(value);
- time.setMinutes(0);
- return that._formatDate(time, 'shorttime')
- }
- return value.toString();
- case'dayofweek':
- index = utils.isString(value) ? $.inArray(value, ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']) : value;
- if (dateType !== 'num')
- return dateType === 'abbr' ? calendar.days.namesAbbr[index] : calendar.days.names[index];
- return ((index - calendar.firstDay + 1 + 7) % 8).toString();
- default:
- return value.toString()
- }
- else
- return value.toString()
- },
- getTimeFormat: function(showSecond) {
- if (showSecond)
- return this._getDateTimeFormatPattern('longtime');
- return this._getDateTimeFormatPattern('shorttime')
- },
- getDateFormatByDifferences: function(dateDifferences) {
- var resultFormat = '';
- if (dateDifferences.millisecond)
- resultFormat = DX.DateTimeFormat.millisecond;
- if (dateDifferences.hour || dateDifferences.minute || dateDifferences.second)
- resultFormat = this._addFormatSeparator(this.getTimeFormat(dateDifferences.second), resultFormat);
- if (dateDifferences.year && dateDifferences.month && dateDifferences.day)
- return this._addFormatSeparator(this._getDateTimeFormatPattern('shortdate'), resultFormat);
- if (dateDifferences.year && dateDifferences.month)
- return DX.DateTimeFormat['monthandyear'];
- if (dateDifferences.year)
- return DX.DateTimeFormat['year'];
- if (dateDifferences.month && dateDifferences.day)
- return this._addFormatSeparator(this._getDateTimeFormatPattern('monthandday'), resultFormat);
- if (dateDifferences.month)
- return DX.DateTimeFormat['month'];
- if (dateDifferences.day)
- return this._addFormatSeparator('dddd, dd', resultFormat);
- return resultFormat
- },
- getDateFormatByTicks: function(ticks) {
- var resultFormat,
- maxDif,
- currentDif,
- i;
- if (ticks.length > 1) {
- maxDif = utils.getDatesDifferences(ticks[0], ticks[1]);
- for (i = 1; i < ticks.length - 1; i++) {
- currentDif = utils.getDatesDifferences(ticks[i], ticks[i + 1]);
- if (maxDif.count < currentDif.count)
- maxDif = currentDif
- }
- }
- else
- maxDif = {
- year: true,
- month: true,
- day: true,
- hour: ticks[0].getHours() > 0,
- minute: ticks[0].getMinutes() > 0,
- second: ticks[0].getSeconds() > 0
- };
- resultFormat = this.getDateFormatByDifferences(maxDif);
- return resultFormat
- },
- getDateFormatByTickInterval: function(startValue, endValue, tickInterval) {
- var resultFormat,
- dateDifferences,
- dateUnitInterval,
- dateDifferencesConverter = {
- quarter: 'month',
- week: 'day'
- },
- correctDateDifferences = function(dateDifferences, tickInterval, value) {
- switch (tickInterval) {
- case'year':
- dateDifferences.month = value;
- case'quarter':
- case'month':
- dateDifferences.day = value;
- case'week':
- case'day':
- dateDifferences.hour = value;
- case'hour':
- dateDifferences.minute = value;
- case'minute':
- dateDifferences.second = value;
- case'second':
- dateDifferences.millisecond = value
- }
- },
- correctDifferencesByMaxDate = function(differences, minDate, maxDate) {
- if (!maxDate.getMilliseconds() && maxDate.getSeconds()) {
- if (maxDate.getSeconds() - minDate.getSeconds() === 1) {
- differences.millisecond = true;
- differences.second = false
- }
- }
- else if (!maxDate.getSeconds() && maxDate.getMinutes()) {
- if (maxDate.getMinutes() - minDate.getMinutes() === 1) {
- differences.second = true;
- differences.minute = false
- }
- }
- else if (!maxDate.getMinutes() && maxDate.getHours()) {
- if (maxDate.getHours() - minDate.getHours() === 1) {
- differences.minute = true;
- differences.hour = false
- }
- }
- else if (!maxDate.getHours() && maxDate.getDate() > 1) {
- if (maxDate.getDate() - minDate.getDate() === 1) {
- differences.hour = true;
- differences.day = false
- }
- }
- else if (maxDate.getDate() === 1 && maxDate.getMonth()) {
- if (maxDate.getMonth() - minDate.getMonth() === 1) {
- differences.day = true;
- differences.month = false
- }
- }
- else if (!maxDate.getMonth() && maxDate.getFullYear())
- if (maxDate.getFullYear() - minDate.getFullYear() === 1) {
- differences.month = true;
- differences.year = false
- }
- };
- tickInterval = utils.isString(tickInterval) ? tickInterval.toLowerCase() : tickInterval;
- dateDifferences = utils.getDatesDifferences(startValue, endValue);
- if (startValue !== endValue)
- correctDifferencesByMaxDate(dateDifferences, startValue > endValue ? endValue : startValue, startValue > endValue ? startValue : endValue);
- dateUnitInterval = utils.getDateUnitInterval(dateDifferences);
- correctDateDifferences(dateDifferences, dateUnitInterval, true);
- dateUnitInterval = utils.getDateUnitInterval(tickInterval || 'second');
- correctDateDifferences(dateDifferences, dateUnitInterval, false);
- dateDifferences[dateDifferencesConverter[dateUnitInterval] || dateUnitInterval] = true;
- resultFormat = this.getDateFormatByDifferences(dateDifferences);
- return resultFormat
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file color.js */
- (function(DX, undefined) {
- var standardColorNames = {
- aliceblue: 'f0f8ff',
- antiquewhite: 'faebd7',
- aqua: '00ffff',
- aquamarine: '7fffd4',
- azure: 'f0ffff',
- beige: 'f5f5dc',
- bisque: 'ffe4c4',
- black: '000000',
- blanchedalmond: 'ffebcd',
- blue: '0000ff',
- blueviolet: '8a2be2',
- brown: 'a52a2a',
- burlywood: 'deb887',
- cadetblue: '5f9ea0',
- chartreuse: '7fff00',
- chocolate: 'd2691e',
- coral: 'ff7f50',
- cornflowerblue: '6495ed',
- cornsilk: 'fff8dc',
- crimson: 'dc143c',
- cyan: '00ffff',
- darkblue: '00008b',
- darkcyan: '008b8b',
- darkgoldenrod: 'b8860b',
- darkgray: 'a9a9a9',
- darkgreen: '006400',
- darkkhaki: 'bdb76b',
- darkmagenta: '8b008b',
- darkolivegreen: '556b2f',
- darkorange: 'ff8c00',
- darkorchid: '9932cc',
- darkred: '8b0000',
- darksalmon: 'e9967a',
- darkseagreen: '8fbc8f',
- darkslateblue: '483d8b',
- darkslategray: '2f4f4f',
- darkturquoise: '00ced1',
- darkviolet: '9400d3',
- deeppink: 'ff1493',
- deepskyblue: '00bfff',
- dimgray: '696969',
- dodgerblue: '1e90ff',
- feldspar: 'd19275',
- firebrick: 'b22222',
- floralwhite: 'fffaf0',
- forestgreen: '228b22',
- fuchsia: 'ff00ff',
- gainsboro: 'dcdcdc',
- ghostwhite: 'f8f8ff',
- gold: 'ffd700',
- goldenrod: 'daa520',
- gray: '808080',
- green: '008000',
- greenyellow: 'adff2f',
- honeydew: 'f0fff0',
- hotpink: 'ff69b4',
- indianred: 'cd5c5c',
- indigo: '4b0082',
- ivory: 'fffff0',
- khaki: 'f0e68c',
- lavender: 'e6e6fa',
- lavenderblush: 'fff0f5',
- lawngreen: '7cfc00',
- lemonchiffon: 'fffacd',
- lightblue: 'add8e6',
- lightcoral: 'f08080',
- lightcyan: 'e0ffff',
- lightgoldenrodyellow: 'fafad2',
- lightgrey: 'd3d3d3',
- lightgreen: '90ee90',
- lightpink: 'ffb6c1',
- lightsalmon: 'ffa07a',
- lightseagreen: '20b2aa',
- lightskyblue: '87cefa',
- lightslateblue: '8470ff',
- lightslategray: '778899',
- lightsteelblue: 'b0c4de',
- lightyellow: 'ffffe0',
- lime: '00ff00',
- limegreen: '32cd32',
- linen: 'faf0e6',
- magenta: 'ff00ff',
- maroon: '800000',
- mediumaquamarine: '66cdaa',
- mediumblue: '0000cd',
- mediumorchid: 'ba55d3',
- mediumpurple: '9370d8',
- mediumseagreen: '3cb371',
- mediumslateblue: '7b68ee',
- mediumspringgreen: '00fa9a',
- mediumturquoise: '48d1cc',
- mediumvioletred: 'c71585',
- midnightblue: '191970',
- mintcream: 'f5fffa',
- mistyrose: 'ffe4e1',
- moccasin: 'ffe4b5',
- navajowhite: 'ffdead',
- navy: '000080',
- oldlace: 'fdf5e6',
- olive: '808000',
- olivedrab: '6b8e23',
- orange: 'ffa500',
- orangered: 'ff4500',
- orchid: 'da70d6',
- palegoldenrod: 'eee8aa',
- palegreen: '98fb98',
- paleturquoise: 'afeeee',
- palevioletred: 'd87093',
- papayawhip: 'ffefd5',
- peachpuff: 'ffdab9',
- peru: 'cd853f',
- pink: 'ffc0cb',
- plum: 'dda0dd',
- powderblue: 'b0e0e6',
- purple: '800080',
- red: 'ff0000',
- rosybrown: 'bc8f8f',
- royalblue: '4169e1',
- saddlebrown: '8b4513',
- salmon: 'fa8072',
- sandybrown: 'f4a460',
- seagreen: '2e8b57',
- seashell: 'fff5ee',
- sienna: 'a0522d',
- silver: 'c0c0c0',
- skyblue: '87ceeb',
- slateblue: '6a5acd',
- slategray: '708090',
- snow: 'fffafa',
- springgreen: '00ff7f',
- steelblue: '4682b4',
- tan: 'd2b48c',
- teal: '008080',
- thistle: 'd8bfd8',
- tomato: 'ff6347',
- turquoise: '40e0d0',
- violet: 'ee82ee',
- violetred: 'd02090',
- wheat: 'f5deb3',
- white: 'ffffff',
- whitesmoke: 'f5f5f5',
- yellow: 'ffff00',
- yellowgreen: '9acd32'
- };
- var standardColorTypes = [{
- re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 10), parseInt(colorString[2], 10), parseInt(colorString[3], 10)]
- }
- }, {
- re: /^rgba\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3}),\s*(\d*\.*\d+)\)$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 10), parseInt(colorString[2], 10), parseInt(colorString[3], 10), parseFloat(colorString[4])]
- }
- }, {
- re: /^#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})$/,
- process: function(colorString) {
- return [parseInt(colorString[1], 16), parseInt(colorString[2], 16), parseInt(colorString[3], 16)]
- }
- }, {
- re: /^#([a-f0-9]{1})([a-f0-9]{1})([a-f0-9]{1})$/,
- process: function(colorString) {
- return [parseInt(colorString[1] + colorString[1], 16), parseInt(colorString[2] + colorString[2], 16), parseInt(colorString[3] + colorString[3], 16)]
- }
- }, {
- re: /^hsv\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- var h = parseInt(colorString[1], 10),
- s = parseInt(colorString[2], 10),
- v = parseInt(colorString[3], 10),
- rgb = hsvToRgb(h, s, v);
- return [rgb[0], rgb[1], rgb[2], 1, [h, s, v]]
- }
- }, {
- re: /^hsl\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
- process: function(colorString) {
- var h = parseInt(colorString[1], 10),
- s = parseInt(colorString[2], 10),
- l = parseInt(colorString[3], 10),
- rgb = hslToRgb(h, s, l);
- return [rgb[0], rgb[1], rgb[2], 1, null, [h, s, l]]
- }
- }];
- function Color(value) {
- this.baseColor = value;
- var color;
- if (value) {
- color = String(value).toLowerCase().replace(/ /g, '');
- color = standardColorNames[color] ? '#' + standardColorNames[color] : color;
- color = parseColor(color)
- }
- if (!color)
- this.colorIsInvalid = true;
- color = color || {};
- this.r = normalize(color[0]);
- this.g = normalize(color[1]);
- this.b = normalize(color[2]);
- this.a = normalize(color[3], 1, 1);
- if (color[4])
- this.hsv = {
- h: color[4][0],
- s: color[4][1],
- v: color[4][2]
- };
- else
- this.hsv = toHsvFromRgb(this.r, this.g, this.b);
- if (color[5])
- this.hsl = {
- h: color[5][0],
- s: color[5][1],
- l: color[5][2]
- };
- else
- this.hsl = toHslFromRgb(this.r, this.g, this.b)
- }
- function parseColor(color) {
- if (color === "transparent")
- return [0, 0, 0, 0];
- var i = 0,
- ii = standardColorTypes.length,
- str;
- for (; i < ii; ++i) {
- str = standardColorTypes[i].re.exec(color);
- if (str)
- return standardColorTypes[i].process(str)
- }
- return null
- }
- function normalize(colorComponent, def, max) {
- def = def || 0;
- max = max || 255;
- return colorComponent < 0 || isNaN(colorComponent) ? def : colorComponent > max ? max : colorComponent
- }
- function toHexFromRgb(r, g, b) {
- return '#' + (0X01000000 | r << 16 | g << 8 | b).toString(16).slice(1)
- }
- function toHsvFromRgb(r, g, b) {
- var max = Math.max(r, g, b),
- min = Math.min(r, g, b),
- delta = max - min,
- H,
- S,
- V;
- V = max;
- S = max === 0 ? 0 : 1 - min / max;
- if (max === min)
- H = 0;
- else
- switch (max) {
- case r:
- H = 60 * ((g - b) / delta);
- if (g < b)
- H = H + 360;
- break;
- case g:
- H = 60 * ((b - r) / delta) + 120;
- break;
- case b:
- H = 60 * ((r - g) / delta) + 240;
- break
- }
- S *= 100;
- V *= 100 / 255;
- return {
- h: Math.round(H),
- s: Math.round(S),
- v: Math.round(V)
- }
- }
- function hsvToRgb(h, s, v) {
- var Vdec,
- Vinc,
- Vmin,
- Hi,
- a,
- r,
- g,
- b;
- Hi = Math.floor(h / 60);
- Vmin = (100 - s) * v / 100;
- a = (v - Vmin) * (h % 60 / 60);
- Vinc = Vmin + a;
- Vdec = v - a;
- switch (Hi) {
- case 0:
- r = v;
- g = Vinc;
- b = Vmin;
- break;
- case 1:
- r = Vdec;
- g = v;
- b = Vmin;
- break;
- case 2:
- r = Vmin;
- g = v;
- b = Vinc;
- break;
- case 3:
- r = Vmin;
- g = Vdec;
- b = v;
- break;
- case 4:
- r = Vinc;
- g = Vmin;
- b = v;
- break;
- case 5:
- r = v;
- g = Vmin;
- b = Vdec;
- break
- }
- return [Math.round(r * 2.55), Math.round(g * 2.55), Math.round(b * 2.55)]
- }
- function calculateHue(r, g, b, delta) {
- var max = Math.max(r, g, b);
- switch (max) {
- case r:
- return (g - b) / delta + (g < b ? 6 : 0);
- case g:
- return (b - r) / delta + 2;
- case b:
- return (r - g) / delta + 4
- }
- }
- function toHslFromRgb(r, g, b) {
- r = convertTo01Bounds(r, 255);
- g = convertTo01Bounds(g, 255);
- b = convertTo01Bounds(b, 255);
- var max = Math.max(r, g, b),
- min = Math.min(r, g, b),
- maxMinSumm = max + min,
- h,
- s,
- l = maxMinSumm / 2;
- if (max === min)
- h = s = 0;
- else {
- var delta = max - min;
- if (l > 0.5)
- s = delta / (2 - maxMinSumm);
- else
- s = delta / maxMinSumm;
- h = calculateHue(r, g, b, delta);
- h /= 6
- }
- return {
- h: _round(h * 360),
- s: _round(s * 100),
- l: _round(l * 100)
- }
- }
- function makeTc(colorPart, h) {
- var Tc = h;
- if (colorPart === "r")
- Tc = h + 1 / 3;
- if (colorPart === "b")
- Tc = h - 1 / 3;
- return Tc
- }
- function modifyTc(Tc) {
- if (Tc < 0)
- Tc += 1;
- if (Tc > 1)
- Tc -= 1;
- return Tc
- }
- function hueToRgb(p, q, Tc) {
- Tc = modifyTc(Tc);
- if (Tc < 1 / 6)
- return p + (q - p) * 6 * Tc;
- if (Tc < 1 / 2)
- return q;
- if (Tc < 2 / 3)
- return p + (q - p) * (2 / 3 - Tc) * 6;
- return p
- }
- function hslToRgb(h, s, l) {
- var r,
- g,
- b;
- h = convertTo01Bounds(h, 360),
- s = convertTo01Bounds(s, 100),
- l = convertTo01Bounds(l, 100);
- if (s === 0)
- r = g = b = l;
- else {
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s,
- p = 2 * l - q;
- r = hueToRgb(p, q, makeTc("r", h));
- g = hueToRgb(p, q, makeTc("g", h));
- b = hueToRgb(p, q, makeTc("b", h))
- }
- return [_round(r * 255), _round(g * 255), _round(b * 255)]
- }
- function convertTo01Bounds(n, max) {
- n = Math.min(max, Math.max(0, parseFloat(n)));
- if (Math.abs(n - max) < 0.000001)
- return 1;
- return n % max / parseFloat(max)
- }
- function isIntegerBtwMinAndMax(number, min, max) {
- min = min || 0;
- max = max || 255;
- if (number % 1 !== 0 || number < min || number > max || typeof number !== 'number' || isNaN(number))
- return false;
- return true
- }
- var _round = Math.round;
- Color.prototype = {
- constructor: Color,
- highlight: function(step) {
- step = step || 10;
- return this.alter(step).toHex()
- },
- darken: function(step) {
- step = step || 10;
- return this.alter(-step).toHex()
- },
- alter: function(step) {
- var result = new Color;
- result.r = normalize(this.r + step);
- result.g = normalize(this.g + step);
- result.b = normalize(this.b + step);
- return result
- },
- blend: function(blendColor, opacity) {
- var other = blendColor instanceof Color ? blendColor : new Color(blendColor),
- result = new Color;
- result.r = normalize(_round(this.r * (1 - opacity) + other.r * opacity));
- result.g = normalize(_round(this.g * (1 - opacity) + other.g * opacity));
- result.b = normalize(_round(this.b * (1 - opacity) + other.b * opacity));
- return result
- },
- toHex: function() {
- return toHexFromRgb(this.r, this.g, this.b)
- },
- getPureColor: function() {
- var rgb = hsvToRgb(this.hsv.h, 100, 100);
- return new Color("rgb(" + rgb.join(",") + ")")
- },
- isValidHex: function(hex) {
- return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(hex)
- },
- isValidRGB: function(r, g, b) {
- if (!isIntegerBtwMinAndMax(r) || !isIntegerBtwMinAndMax(g) || !isIntegerBtwMinAndMax(b))
- return false;
- return true
- },
- isValidAlpha: function(a) {
- if (isNaN(a) || a < 0 || a > 1 || typeof a !== 'number')
- return false;
- return true
- },
- colorIsInvalid: false
- };
- DX.Color = Color
- })(DevExpress);
- /*! Module core, file localization.js */
- (function($, DX, undefined) {
- Globalize.localize = function(key, cultureSelector) {
- var neutral = (cultureSelector || this.cultureSelector || "").substring(0, 2);
- return this.findClosestCulture(cultureSelector).messages[key] || this.findClosestCulture(neutral).messages[key] || this.cultures["default"].messages[key]
- };
- var localization = function() {
- var newMessages = {};
- return {
- setup: function(localizablePrefix) {
- this.localizeString = function(text) {
- var regex = new RegExp("(^|[^a-zA-Z_0-9" + localizablePrefix + "-]+)(" + localizablePrefix + "{1,2})([a-zA-Z_0-9-]+)", "g"),
- escapeString = localizablePrefix + localizablePrefix;
- return text.replace(regex, function(str, prefix, escape, localizationKey) {
- var result = prefix + localizablePrefix + localizationKey;
- if (escape !== escapeString)
- if (Globalize.cultures["default"].messages[localizationKey])
- result = prefix + Globalize.localize(localizationKey);
- else
- newMessages[localizationKey] = DX.inflector.humanize(localizationKey);
- return result
- })
- }
- },
- localizeNode: function(node) {
- var that = this;
- $(node).each(function(index, nodeItem) {
- if (!nodeItem.nodeType)
- return;
- if (nodeItem.nodeType === 3)
- nodeItem.nodeValue = that.localizeString(nodeItem.nodeValue);
- else if (!$(nodeItem).is("iframe")) {
- $.each(nodeItem.attributes || [], function(index, attr) {
- if (typeof attr.value === "string") {
- var localizedValue = that.localizeString(attr.value);
- if (attr.value !== localizedValue)
- attr.value = localizedValue
- }
- });
- $(nodeItem).contents().each(function(index, node) {
- that.localizeNode(node)
- })
- }
- })
- },
- getDictionary: function(onlyNew) {
- if (onlyNew)
- return newMessages;
- return $.extend({}, newMessages, Globalize.cultures["default"].messages)
- }
- }
- }();
- localization.setup("@");
- DX.localization = localization
- })(jQuery, DevExpress);
- /*! Module core, file core.en.js */
- Globalize.addCultureInfo("default", {messages: {
- Yes: "Yes",
- No: "No",
- Cancel: "Cancel",
- Clear: "Clear",
- Done: "Done",
- Loading: "Loading...",
- Select: "Select...",
- Search: "Search",
- Back: "Back",
- OK: "OK",
- "dxCollectionWidget-noDataText": "No data to display",
- "validation-required": "Required",
- "validation-required-formatted": "{0} is required",
- "validation-numeric": "Value must be a number",
- "validation-numeric-formatted": "{0} must be a number",
- "validation-range": "Value is out of range",
- "validation-range-formatted": "{0} is out of range",
- "validation-stringLength": "The length of the value is not correct",
- "validation-stringLength-formatted": "The length of {0} is not correct",
- "validation-custom": "Value is invalid",
- "validation-custom-formatted": "{0} is invalid",
- "validation-compare": "Values do not match",
- "validation-compare-formatted": "{0} does not match",
- "validation-pattern": "Value does not match pattern",
- "validation-pattern-formatted": "{0} does not match pattern",
- "validation-email": "Email is invalid",
- "validation-email-formatted": "{0} is invalid",
- "validation-mask": "Value is invalid"
- }});
- /*! Module core, file widgets-base.en.js */
- Globalize.addCultureInfo("default", {messages: {
- "dxLookup-searchPlaceholder": "Minimum character number: {0}",
- "dxList-pullingDownText": "Pull down to refresh...",
- "dxList-pulledDownText": "Release to refresh...",
- "dxList-refreshingText": "Refreshing...",
- "dxList-pageLoadingText": "Loading...",
- "dxList-nextButtonText": "More",
- "dxList-selectAll": "Select All",
- "dxListEditDecorator-delete": "Delete",
- "dxListEditDecorator-more": "More",
- "dxScrollView-pullingDownText": "Pull down to refresh...",
- "dxScrollView-pulledDownText": "Release to refresh...",
- "dxScrollView-refreshingText": "Refreshing...",
- "dxScrollView-reachBottomText": "Loading...",
- "dxDateBox-simulatedDataPickerTitleTime": "Select time",
- "dxDateBox-simulatedDataPickerTitleDate": "Select date",
- "dxDateBox-simulatedDataPickerTitleDateTime": "Select date and time",
- "dxDateBox-validation-datetime": "Value must be a date or time",
- "dxFileUploader-selectFile": "Select file",
- "dxFileUploader-dropFile": "or Drop file here",
- "dxFileUploader-bytes": "bytes",
- "dxFileUploader-kb": "kb",
- "dxFileUploader-Mb": "Mb",
- "dxFileUploader-Gb": "Gb",
- "dxFileUploader-upload": "Upload",
- "dxFileUploader-uploaded": "Uploaded",
- "dxFileUploader-readyToUpload": "Ready to upload",
- "dxFileUploader-uploadFailedMessage": "Upload failed",
- "dxRangeSlider-ariaFrom": "From {0}",
- "dxRangeSlider-ariaTill": "Till {0}",
- "dxSwitch-onText": "ON",
- "dxSwitch-offText": "OFF"
- }});
- /*! Module core, file widgets-mobile.en.js */
- /*! Module core, file widgets-web.en.js */
- Globalize.addCultureInfo("default", {messages: {
- "dxDataGrid-columnChooserTitle": "Column Chooser",
- "dxDataGrid-columnChooserEmptyText": "Drag a column here to hide it",
- "dxDataGrid-groupContinuesMessage": "Continues on the next page",
- "dxDataGrid-groupContinuedMessage": "Continued from the previous page",
- "dxDataGrid-editingEditRow": "Edit",
- "dxDataGrid-editingSaveRowChanges": "Save",
- "dxDataGrid-editingCancelRowChanges": "Cancel",
- "dxDataGrid-editingDeleteRow": "Delete",
- "dxDataGrid-editingUndeleteRow": "Undelete",
- "dxDataGrid-editingConfirmDeleteMessage": "Are you sure you want to delete this record?",
- "dxDataGrid-editingConfirmDeleteTitle": "",
- "dxDataGrid-groupPanelEmptyText": "Drag a column header here to group by that column",
- "dxDataGrid-noDataText": "No data",
- "dxDataGrid-searchPanelPlaceholder": "Search...",
- "dxDataGrid-filterRowShowAllText": "(All)",
- "dxDataGrid-filterRowResetOperationText": "Reset",
- "dxDataGrid-filterRowOperationEquals": "Equals",
- "dxDataGrid-filterRowOperationNotEquals": "Does not equal",
- "dxDataGrid-filterRowOperationLess": "Less than",
- "dxDataGrid-filterRowOperationLessOrEquals": "Less than or equal to",
- "dxDataGrid-filterRowOperationGreater": "Greater than",
- "dxDataGrid-filterRowOperationGreaterOrEquals": "Greater than or equal to",
- "dxDataGrid-filterRowOperationStartsWith": "Starts with",
- "dxDataGrid-filterRowOperationContains": "Contains",
- "dxDataGrid-filterRowOperationNotContains": "Does not contain",
- "dxDataGrid-filterRowOperationEndsWith": "Ends with",
- "dxDataGrid-applyFilterText": "Apply filter",
- "dxDataGrid-trueText": "true",
- "dxDataGrid-falseText": "false",
- "dxDataGrid-sortingAscendingText": "Sort Ascending",
- "dxDataGrid-sortingDescendingText": "Sort Descending",
- "dxDataGrid-sortingClearText": "Clear Sorting",
- "dxDataGrid-editingSaveAllChanges": "Save changes",
- "dxDataGrid-editingCancelAllChanges": "Discard changes",
- "dxDataGrid-editingAddRow": "Add a row",
- "dxDataGrid-summaryMin": "Min: {0}",
- "dxDataGrid-summaryMinOtherColumn": "Min of {1} is {0}",
- "dxDataGrid-summaryMax": "Max: {0}",
- "dxDataGrid-summaryMaxOtherColumn": "Max of {1} is {0}",
- "dxDataGrid-summaryAvg": "Avg: {0}",
- "dxDataGrid-summaryAvgOtherColumn": "Avg of {1} is {0}",
- "dxDataGrid-summarySum": "Sum: {0}",
- "dxDataGrid-summarySumOtherColumn": "Sum of {1} is {0}",
- "dxDataGrid-summaryCount": "Count: {0}",
- "dxDataGrid-columnFixingFix": "Fix",
- "dxDataGrid-columnFixingUnfix": "Unfix",
- "dxDataGrid-columnFixingLeftPosition": "To the left",
- "dxDataGrid-columnFixingRightPosition": "To the right",
- "dxDataGrid-exportTo": "Export to",
- "dxDataGrid-exportToExcel": "Export to Excel file",
- "dxDataGrid-excelFormat": "Excel file",
- "dxDataGrid-selectedRows": "Selected rows",
- "dxDataGrid-headerFilterEmptyValue": "(Blanks)",
- "dxDataGrid-headerFilterOK": "OK",
- "dxDataGrid-headerFilterCancel": "Cancel",
- "dxDataGrid-ariaColumn": "Column",
- "dxDataGrid-ariaValue": "Value",
- "dxDataGrid-ariaFilterCell": "Filter cell",
- "dxDataGrid-ariaCollapse": "Collapse",
- "dxDataGrid-ariaExpand": "Expand",
- "dxDataGrid-ariaDataGrid": "Data grid",
- "dxDataGrid-ariaSearchInGrid": "Search in data grid",
- "dxDataGrid-ariaSelectAll": "Select all",
- "dxDataGrid-ariaSelectRow": "Select row",
- "dxPager-infoText": "Page {0} of {1}",
- "dxPivotGrid-grandTotal": "Grand Total",
- "dxPivotGrid-total": "{0} Total",
- "dxPivotGrid-fieldChooserTitle": "Field Chooser",
- "dxPivotGrid-showFieldChooser": "Show Field Chooser",
- "dxPivotGrid-expandAll": "Expand All",
- "dxPivotGrid-collapseAll": "Collapse All",
- "dxPivotGrid-sortColumnBySummary": "Sort \"{0}\" by This Column",
- "dxPivotGrid-sortRowBySummary": "Sort \"{0}\" by This Row",
- "dxPivotGrid-removeAllSorting": "Remove All Sorting",
- "dxPivotGrid-rowFields": "Row Fields",
- "dxPivotGrid-columnFields": "Column Fields",
- "dxPivotGrid-dataFields": "Data Fields",
- "dxPivotGrid-filterFields": "Filter Fields",
- "dxPivotGrid-allFields": "All Fields",
- "dxScheduler-editorLabelTitle": "Subject",
- "dxScheduler-editorLabelStartDate": "Start Date",
- "dxScheduler-editorLabelEndDate": "End Date",
- "dxScheduler-editorLabelDescription": "Description",
- "dxScheduler-editorLabelRecurrence": "Repeat",
- "dxScheduler-openAppointment": "Open appointment",
- "dxScheduler-recurrenceNever": "Never",
- "dxScheduler-recurrenceDaily": "Daily",
- "dxScheduler-recurrenceWeekly": "Weekly",
- "dxScheduler-recurrenceMonthly": "Monthly",
- "dxScheduler-recurrenceYearly": "Yearly",
- "dxScheduler-recurrenceEvery": "Every",
- "dxScheduler-recurrenceEnd": "End repeat",
- "dxScheduler-recurrenceAfter": "After",
- "dxScheduler-recurrenceOn": "On",
- "dxScheduler-recurrenceRepeatDaily": "day(s)",
- "dxScheduler-recurrenceRepeatWeekly": "week(s)",
- "dxScheduler-recurrenceRepeatMonthly": "month(s)",
- "dxScheduler-recurrenceRepeatYearly": "year(s)",
- "dxScheduler-switcherDay": "Day",
- "dxScheduler-switcherWeek": "Week",
- "dxScheduler-switcherWorkWeek": "Work week",
- "dxScheduler-switcherMonth": "Month",
- "dxScheduler-recurrenceRepeatOnDate": "on date",
- "dxScheduler-recurrenceRepeatCount": "occurrence(s)",
- "dxScheduler-allDay": "All day",
- "dxCalendar-todayButtonText": "Today",
- "dxCalendar-ariaWidgetName": "Calendar",
- "dxColorView-ariaRed": "Red",
- "dxColorView-ariaGreen": "Green",
- "dxColorView-ariaBlue": "Blue",
- "dxColorView-ariaAlpha": "Transparency",
- "dxColorView-ariaHex": "Color code"
- }});
- /*! Module core, file validationEngine.js */
- (function($, DX, undefined) {
- var utils = DX.utils;
- var rulesValidators = {
- required: {
- validate: function(value, rule) {
- if (!utils.isDefined(value))
- return false;
- if (value === false)
- return false;
- value = String(value);
- if (rule.trim || !utils.isDefined(rule.trim))
- value = $.trim(value);
- return value !== ""
- },
- defaultMessage: function() {
- return Globalize.localize("validation-required")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-required-formatted")
- }
- },
- numeric: {
- validate: function(value, rule) {
- if (!rulesValidators.required.validate(value, {}))
- return true;
- if (rule.useCultureSettings && utils.isString(value))
- return !isNaN(Globalize.parseFloat(value));
- else
- return $.isNumeric(value)
- },
- defaultMessage: function() {
- return Globalize.localize("validation-numeric")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-numeric-formatted")
- }
- },
- range: {
- validate: function(value, rule) {
- if (!rulesValidators.required.validate(value, {}))
- return true;
- var validNumber = rulesValidators["numeric"].validate(value, rule),
- validValue = utils.isDefined(value),
- number = validNumber ? parseFloat(value) : validValue && value.valueOf(),
- min = rule.min,
- max = rule.max;
- if (!(validNumber || utils.isDate(value)) && !validValue)
- return false;
- if (utils.isDefined(min)) {
- if (utils.isDefined(max))
- return number >= min && number <= max;
- return number >= min
- }
- else if (utils.isDefined(max))
- return number <= max;
- else
- throw DX.Error("E0101");
- return false
- },
- defaultMessage: function() {
- return Globalize.localize("validation-range")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-range-formatted")
- }
- },
- stringLength: {
- validate: function(value, rule) {
- value = String(value);
- if (rule.trim || !utils.isDefined(rule.trim))
- value = $.trim(value);
- return rulesValidators.range.validate(value.length, $.extend({}, rule))
- },
- defaultMessage: function() {
- return Globalize.localize("validation-stringLength")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-stringLength-formatted")
- }
- },
- custom: {
- validate: function(value, rule) {
- return rule.validationCallback({
- value: value,
- validator: rule.validator,
- rule: rule
- })
- },
- defaultMessage: function() {
- return Globalize.localize("validation-custom")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-custom-formatted")
- }
- },
- compare: {
- validate: function(value, rule) {
- if (!rule.comparisonTarget)
- throw DX.Error("E0102");
- $.extend(rule, {reevaluate: true});
- var otherValue = rule.comparisonTarget(),
- type = rule.comparisonType || "==";
- switch (type) {
- case"==":
- return value == otherValue;
- case"!=":
- return value != otherValue;
- case"===":
- return value === otherValue;
- case"!==":
- return value !== otherValue;
- case">":
- return value > otherValue;
- case">=":
- return value >= otherValue;
- case"<":
- return value < otherValue;
- case"<=":
- return value <= otherValue
- }
- },
- defaultMessage: function() {
- return Globalize.localize("validation-compare")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-compare-formatted")
- }
- },
- pattern: {
- validate: function(value, rule) {
- if (!rulesValidators.required.validate(value, {}))
- return true;
- var pattern = rule.pattern;
- if (utils.isString(pattern))
- pattern = new RegExp(pattern);
- return pattern.test(value)
- },
- defaultMessage: function() {
- return Globalize.localize("validation-pattern")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-pattern-formatted")
- }
- },
- email: {
- validate: function(value, rule) {
- if (!rulesValidators.required.validate(value, {}))
- return true;
- return rulesValidators.pattern.validate(value, $.extend({}, rule, {pattern: /^[\d\w\._\-]+@([\d\w\._\-]+\.)+[\w]+$/i}))
- },
- defaultMessage: function() {
- return Globalize.localize("validation-email")
- },
- defaultFormattedMessage: function() {
- return Globalize.localize("validation-email-formatted")
- }
- }
- };
- var GroupConfig = DX.Class.inherit({
- ctor: function(group) {
- this.group = group;
- this.validators = []
- },
- validate: function() {
- var result = {
- isValid: true,
- brokenRules: [],
- validators: []
- };
- $.each(this.validators, function(_, validator) {
- var validatorResult = validator.validate();
- result.isValid = result.isValid && validatorResult.isValid;
- if (validatorResult.brokenRule)
- result.brokenRules.push(validatorResult.brokenRule);
- result.validators.push(validator)
- });
- this.fireEvent("validated", [{
- validators: result.validators,
- brokenRules: result.brokenRules,
- isValid: result.isValid
- }]);
- return result
- },
- reset: function() {
- $.each(this.validators, function(_, validator) {
- validator.reset()
- })
- }
- }).include(DX.EventsMixin);
- DX.validationEngine = {
- groups: [],
- getGroupConfig: function(group) {
- var result = $.grep(this.groups, function(config) {
- return config.group === group
- });
- if (result.length)
- return result[0]
- },
- initGroups: function() {
- this.groups = [];
- this.addGroup()
- },
- addGroup: function(group) {
- var config = this.getGroupConfig(group);
- if (!config) {
- config = new GroupConfig(group);
- this.groups.push(config)
- }
- return config
- },
- removeGroup: function(group) {
- var config = this.getGroupConfig(group),
- index = $.inArray(config, this.groups);
- if (index > -1)
- this.groups.splice(index, 1);
- return config
- },
- _setDefaultMessage: function(rule, validator, name) {
- if (!utils.isDefined(rule.message))
- if (validator.defaultFormattedMessage && utils.isDefined(name))
- rule.message = validator.defaultFormattedMessage().replace(/\{0\}/, name);
- else
- rule.message = validator.defaultMessage()
- },
- validate: function validate(value, rules, name) {
- var result = {
- name: name,
- value: value,
- brokenRule: null,
- isValid: true,
- validationRules: rules
- },
- that = this;
- $.each(rules || [], function(_, rule) {
- var ruleValidator = rulesValidators[rule.type],
- ruleValidationResult;
- if (ruleValidator) {
- if (utils.isDefined(rule.isValid) && rule.value === value && !rule.reevaluate) {
- if (!rule.isValid) {
- result.isValid = false;
- result.brokenRule = rule;
- return false
- }
- return true
- }
- rule.value = value;
- ruleValidationResult = ruleValidator.validate(value, rule);
- rule.isValid = ruleValidationResult;
- if (!ruleValidationResult) {
- result.isValid = false;
- that._setDefaultMessage(rule, ruleValidator, name);
- result.brokenRule = rule
- }
- if (!rule.isValid)
- return false
- }
- else
- throw DX.Error("E0100");
- });
- return result
- },
- registerValidatorInGroup: function(group, validator) {
- var groupConfig = DX.validationEngine.addGroup(group);
- if ($.inArray(validator, groupConfig.validators) < 0)
- groupConfig.validators.push(validator)
- },
- removeRegistredValidator: function(group, validator) {
- var config = DX.validationEngine.getGroupConfig(group),
- validatorsInGroup = config && config.validators;
- var index = $.inArray(validator, validatorsInGroup);
- if (index > -1)
- validatorsInGroup.splice(index, 1)
- },
- validateGroup: function(group) {
- var groupConfig = DX.validationEngine.getGroupConfig(group);
- if (!groupConfig)
- throw DX.Error("E0110");
- return groupConfig.validate()
- },
- resetGroup: function(group) {
- var groupConfig = DX.validationEngine.getGroupConfig(group);
- if (!groupConfig)
- throw DX.Error("E0110");
- return groupConfig.reset()
- }
- };
- DX.validationEngine.initGroups()
- })(jQuery, DevExpress);
- /*! Module core, file data.errors.js */
- (function($, DX) {
- $.extend(DX.ERROR_MESSAGES, {
- E4000: "[DevExpress.data]: {0}",
- E4001: "Unknown aggregating function is detected: '{0}'",
- E4002: "Unsupported OData protocol version is used",
- E4003: "Unknown filter operation is used: {0}",
- E4004: "The thenby() method is called before the sortby() method",
- E4005: "Store requires a key expression for this operation",
- E4006: "ArrayStore 'data' option must be an array",
- E4007: "Compound keys cannot be auto-generated",
- E4008: "Attempt to insert an item with the a duplicated key",
- E4009: "Data item with specified key value cannot be found",
- E4010: "CustomStore does not support creating queries",
- E4011: "Custom Store method is not implemented or is not a function: {0}",
- E4012: "Custom Store method returns an invalid value: {0}",
- E4013: "Local Store requires the 'name' configuration option is specified",
- E4014: "Unknown key type is detected: {0}",
- E4015: "Unknown entity name or alias is used: {0}",
- E4016: "The compileSetter(expr) method is called with 'self' passed as a parameter",
- E4017: "Keys cannot be modified"
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.js */
- (function($, DX, undefined) {
- var bracketsToDots = function(expr) {
- return expr.replace(/\[/g, ".").replace(/\]/g, "")
- };
- var unwrapObservable = DX.utils.unwrapObservable;
- var isObservable = function(value) {
- return DX.support.hasKo && ko.isObservable(value)
- };
- var readPropValue = function(obj, propName) {
- if (propName === "this")
- return obj;
- return obj[propName]
- };
- var assignPropValue = function(obj, propName, value, options) {
- if (propName === "this")
- throw new DX.Error("E4016");
- var propValue = obj[propName];
- if (options.unwrapObservables && isObservable(propValue))
- propValue(value);
- else
- obj[propName] = value
- };
- var prepareOptions = function(options) {
- options = options || {};
- options.unwrapObservables = options.unwrapObservables !== undefined ? options.unwrapObservables : true;
- return options
- };
- var unwrap = function(value, options) {
- return options.unwrapObservables ? unwrapObservable(value) : value
- };
- var compileGetter = function(expr) {
- if (arguments.length > 1)
- expr = $.makeArray(arguments);
- if (!expr || expr === "this")
- return function(obj) {
- return obj
- };
- if ($.isFunction(expr))
- return expr;
- if ($.isArray(expr))
- return combineGetters(expr);
- expr = bracketsToDots(expr);
- var path = expr.split(".");
- return function(obj, options) {
- options = prepareOptions(options);
- var current = unwrap(obj, options);
- $.each(path, function() {
- if (!current)
- return false;
- var next = unwrap(current[this], options);
- if ($.isFunction(next) && !options.functionsAsIs)
- next = next.call(current);
- current = next
- });
- return current
- }
- };
- var combineGetters = function(getters) {
- var compiledGetters = {};
- $.each(getters, function() {
- compiledGetters[this] = compileGetter(this)
- });
- return function(obj, options) {
- var result = {};
- $.each(compiledGetters, function(name) {
- var value = this(obj, options),
- current,
- path,
- last,
- i;
- if (value === undefined)
- return;
- current = result;
- path = name.split(".");
- last = path.length - 1;
- for (i = 0; i < last; i++)
- current = current[path[i]] = {};
- current[path[i]] = value
- });
- return result
- }
- };
- var compileSetter = function(expr) {
- expr = expr || "this";
- expr = bracketsToDots(expr);
- var pos = expr.lastIndexOf("."),
- targetGetter = compileGetter(expr.substr(0, pos)),
- targetPropName = expr.substr(1 + pos);
- return function(obj, value, options) {
- options = prepareOptions(options);
- var target = targetGetter(obj, {
- functionsAsIs: options.functionsAsIs,
- unwrapObservables: options.unwrapObservables
- }),
- prevTargetValue = readPropValue(target, targetPropName);
- if (!options.functionsAsIs && $.isFunction(prevTargetValue) && !isObservable(prevTargetValue))
- target[targetPropName](value);
- else {
- prevTargetValue = unwrap(prevTargetValue, options);
- if (options.merge && $.isPlainObject(value) && (prevTargetValue === undefined || $.isPlainObject(prevTargetValue)) && !(value instanceof $.Event)) {
- if (!prevTargetValue)
- assignPropValue(target, targetPropName, {}, options);
- DX.utils.deepExtendArraySafe(unwrap(readPropValue(target, targetPropName), options), value)
- }
- else
- assignPropValue(target, targetPropName, value, options)
- }
- }
- };
- var normalizeBinaryCriterion = function(crit) {
- return [crit[0], crit.length < 3 ? "=" : String(crit[1]).toLowerCase(), crit.length < 2 ? true : crit[crit.length - 1]]
- };
- var normalizeSortingInfo = function(info) {
- if (!$.isArray(info))
- info = [info];
- return $.map(info, function(i) {
- return {
- selector: $.isFunction(i) || typeof i === "string" ? i : i.getter || i.field || i.selector,
- desc: !!(i.desc || String(i.dir).charAt(0).toLowerCase() === "d")
- }
- })
- };
- var Guid = DX.Class.inherit({
- ctor: function(value) {
- if (value)
- value = String(value);
- this._value = this._normalize(value || this._generate())
- },
- _normalize: function(value) {
- value = value.replace(/[^a-f0-9]/ig, "").toLowerCase();
- while (value.length < 32)
- value += "0";
- return [value.substr(0, 8), value.substr(8, 4), value.substr(12, 4), value.substr(16, 4), value.substr(20, 12)].join("-")
- },
- _generate: function() {
- var value = "";
- for (var i = 0; i < 32; i++)
- value += Math.round(Math.random() * 15).toString(16);
- return value
- },
- toString: function() {
- return this._value
- },
- valueOf: function() {
- return this._value
- },
- toJSON: function() {
- return this._value
- }
- });
- var toComparable = function(value, caseSensitive) {
- if (value instanceof Date)
- return value.getTime();
- if (value instanceof Guid)
- return value.valueOf();
- if (!caseSensitive && typeof value === "string")
- return value.toLowerCase();
- return value
- };
- var keysEqual = function(keyExpr, key1, key2) {
- if ($.isArray(keyExpr)) {
- var names = $.map(key1, function(v, k) {
- return k
- }),
- name;
- for (var i = 0; i < names.length; i++) {
- name = names[i];
- if (toComparable(key1[name], true) != toComparable(key2[name], true))
- return false
- }
- return true
- }
- return toComparable(key1, true) == toComparable(key2, true)
- };
- var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
- var base64_encode = function(input) {
- if (!$.isArray(input))
- input = stringToByteArray(String(input));
- var result = "";
- function getBase64Char(index) {
- return BASE64_CHARS.charAt(index)
- }
- for (var i = 0; i < input.length; i += 3) {
- var octet1 = input[i],
- octet2 = input[i + 1],
- octet3 = input[i + 2];
- result += $.map([octet1 >> 2, (octet1 & 3) << 4 | octet2 >> 4, isNaN(octet2) ? 64 : (octet2 & 15) << 2 | octet3 >> 6, isNaN(octet3) ? 64 : octet3 & 63], getBase64Char).join("")
- }
- return result
- };
- var stringToByteArray = function(str) {
- var bytes = [],
- code,
- i;
- for (i = 0; i < str.length; i++) {
- code = str.charCodeAt(i);
- if (code < 128)
- bytes.push(code);
- else if (code < 2048)
- bytes.push(192 + (code >> 6), 128 + (code & 63));
- else if (code < 65536)
- bytes.push(224 + (code >> 12), 128 + (code >> 6 & 63), 128 + (code & 63));
- else if (code < 2097152)
- bytes.push(240 + (code >> 18), 128 + (code >> 12 & 63), 128 + (code >> 6 & 63), 128 + (code & 63))
- }
- return bytes
- };
- var errorMessageFromXhr = function() {
- var textStatusMessages = {
- timeout: "Network connection timeout",
- error: "Unspecified network error",
- parsererror: "Unexpected server response"
- };
- var textStatusDetails = {
- timeout: "possible causes: the remote host is not accessible, overloaded or is not included into the domain white-list when being run in the native container",
- error: "if the remote host is located on another domain, make sure it properly supports cross-origin resource sharing (CORS), or use the JSONP approach instead",
- parsererror: "the remote host did not respond with valid JSON data"
- };
- var explainTextStatus = function(textStatus) {
- var result = textStatusMessages[textStatus];
- if (!result)
- return textStatus;
- result += " (" + textStatusDetails[textStatus] + ")";
- return result
- };
- return function(xhr, textStatus) {
- if (xhr.status < 400)
- return explainTextStatus(textStatus);
- return xhr.statusText
- }
- }();
- var aggregators = {
- count: {
- seed: 0,
- step: function(count) {
- return 1 + count
- }
- },
- sum: {
- seed: 0,
- step: function(sum, item) {
- return sum + item
- }
- },
- min: {step: function(min, item) {
- return item < min ? item : min
- }},
- max: {step: function(max, item) {
- return item > max ? item : max
- }},
- avg: {
- seed: [0, 0],
- step: function(pair, value) {
- return [pair[0] + value, pair[1] + 1]
- },
- finalize: function(pair) {
- return pair[1] ? pair[0] / pair[1] : NaN
- }
- }
- };
- function handleError(error) {
- var id = "E4000";
- if (error && "__id" in error)
- id = error.__id;
- DX.log(id, error)
- }
- function multiLevelSearch(options) {
- var itemsGetter = options.itemsGetter,
- itemsSetter = options.itemsSetter,
- criteria = options.criteria,
- data = options.data;
- function selector(x) {
- var hash,
- items = itemsGetter(x);
- if (isNotAnEmptyArray(items)) {
- hash = {};
- itemsSetter(hash, multiLevelSearch({
- data: items,
- criteria: criteria,
- itemsGetter: itemsGetter,
- itemsSetter: itemsSetter
- }));
- return $.extend({}, x, hash)
- }
- return x
- }
- function criterion(x) {
- return isNotAnEmptyArray(itemsGetter(x))
- }
- function isNotAnEmptyArray(x) {
- return $.isArray(x) && x.length > 0
- }
- return DX.data.query(data).select(selector).filter([[criterion], "or", criteria]).toArray()
- }
- var data = DX.data = {
- utils: {
- compileGetter: compileGetter,
- compileSetter: compileSetter,
- normalizeBinaryCriterion: normalizeBinaryCriterion,
- normalizeSortingInfo: normalizeSortingInfo,
- toComparable: toComparable,
- keysEqual: keysEqual,
- errorMessageFromXhr: errorMessageFromXhr,
- aggregators: aggregators,
- multiLevelSearch: multiLevelSearch
- },
- Guid: Guid,
- base64_encode: base64_encode,
- queryImpl: {},
- queryAdapters: {},
- query: function() {
- var impl = $.isArray(arguments[0]) ? "array" : "remote";
- return data.queryImpl[impl].apply(this, arguments)
- },
- errorHandler: null,
- _errorHandler: function(error) {
- handleError(error);
- if (data.errorHandler)
- data.errorHandler(error)
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.aggregateCalculator.js */
- (function($, DX, undefined) {
- var data = DX.data,
- utils = data.utils;
- function isCount(aggregator) {
- return aggregator === utils.aggregators.count
- }
- function normalizeAggregate(aggregate) {
- var selector = utils.compileGetter(aggregate.selector),
- aggregator = aggregate.aggregator;
- if (typeof aggregator === "string") {
- aggregator = data.utils.aggregators[aggregator];
- if (!aggregator)
- throw DX.Error("E4001", aggregate.aggregator);
- }
- return {
- selector: selector,
- aggregator: aggregator
- }
- }
- data.AggregateCalculator = DX.Class.inherit({
- ctor: function(options) {
- this._data = options.data;
- this._groupLevel = options.groupLevel || 0;
- this._totalAggregates = $.map(options.totalAggregates || [], normalizeAggregate);
- this._groupAggregates = $.map(options.groupAggregates || [], normalizeAggregate);
- this._totals = []
- },
- calculate: function() {
- if (this._totalAggregates.length)
- this._calculateTotals(0, {items: this._data});
- if (this._groupAggregates.length && this._groupLevel > 0)
- this._calculateGroups(0, {items: this._data})
- },
- totalAggregates: function() {
- return this._totals
- },
- _aggregate: function(data, aggregates, container) {
- var i,
- j;
- for (i = 0; i < aggregates.length; i++) {
- if (isCount(aggregates[i].aggregator)) {
- container[i] = (container[i] || 0) + data.items.length;
- continue
- }
- for (j = 0; j < data.items.length; j++)
- this._accumulate(i, aggregates[i], container, data.items[j])
- }
- },
- _calculateTotals: function(level, data) {
- var i;
- if (level === 0)
- this._totals = this._seed(this._totalAggregates);
- if (level === this._groupLevel)
- this._aggregate(data, this._totalAggregates, this._totals);
- else
- for (i = 0; i < data.items.length; i++)
- this._calculateTotals(level + 1, data.items[i]);
- if (level === 0)
- this._totals = this._finalize(this._totalAggregates, this._totals)
- },
- _calculateGroups: function(level, data, outerAggregates) {
- var i,
- innerAggregates;
- if (level === this._groupLevel)
- this._aggregate(data, this._groupAggregates, outerAggregates);
- else
- for (i = 0; i < data.items.length; i++) {
- innerAggregates = this._seed(this._groupAggregates);
- this._calculateGroups(level + 1, data.items[i], innerAggregates);
- data.items[i].aggregates = this._finalize(this._groupAggregates, innerAggregates);
- if (level > 0) {
- outerAggregates = outerAggregates || this._seed(this._groupAggregates);
- this._calculateGroups(level + 1, data.items[i], outerAggregates)
- }
- }
- },
- _seed: function(aggregates) {
- return $.map(aggregates, function(aggregate) {
- var aggregator = aggregate.aggregator,
- seed = "seed" in aggregator ? aggregator.seed : NaN;
- return $.isArray(seed) ? [seed] : seed
- })
- },
- _accumulate: function(aggregateIndex, aggregate, results, item) {
- var value = aggregate.selector(item),
- aggregator = aggregate.aggregator;
- results[aggregateIndex] = results[aggregateIndex] !== results[aggregateIndex] ? value : aggregator.step(results[aggregateIndex], value)
- },
- _finalize: function(aggregates, results) {
- return $.map(aggregates, function(aggregate, index) {
- var fin = aggregate.aggregator.finalize;
- return fin ? fin(results[index]) : results[index]
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.query.array.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- data = DX.data,
- queryImpl = data.queryImpl,
- compileGetter = data.utils.compileGetter,
- toComparable = data.utils.toComparable;
- var Iterator = Class.inherit({
- toArray: function() {
- var result = [];
- this.reset();
- while (this.next())
- result.push(this.current());
- return result
- },
- countable: function() {
- return false
- }
- });
- var ArrayIterator = Iterator.inherit({
- ctor: function(array) {
- this.array = array;
- this.index = -1
- },
- next: function() {
- if (this.index + 1 < this.array.length) {
- this.index++;
- return true
- }
- return false
- },
- current: function() {
- return this.array[this.index]
- },
- reset: function() {
- this.index = -1
- },
- toArray: function() {
- return this.array.slice(0)
- },
- countable: function() {
- return true
- },
- count: function() {
- return this.array.length
- }
- });
- var WrappedIterator = Iterator.inherit({
- ctor: function(iter) {
- this.iter = iter
- },
- next: function() {
- return this.iter.next()
- },
- current: function() {
- return this.iter.current()
- },
- reset: function() {
- return this.iter.reset()
- }
- });
- var MapIterator = WrappedIterator.inherit({
- ctor: function(iter, mapper) {
- this.callBase(iter);
- this.index = -1;
- this.mapper = mapper
- },
- current: function() {
- return this.mapper(this.callBase(), this.index)
- },
- next: function() {
- var hasNext = this.callBase();
- if (hasNext)
- this.index++;
- return hasNext
- }
- });
- var SortIterator = Iterator.inherit({
- ctor: function(iter, getter, desc) {
- if (!(iter instanceof MapIterator))
- iter = new MapIterator(iter, this._wrap);
- this.iter = iter;
- this.rules = [{
- getter: getter,
- desc: desc
- }]
- },
- thenBy: function(getter, desc) {
- var result = new SortIterator(this.sortedIter || this.iter, getter, desc);
- if (!this.sortedIter)
- result.rules = this.rules.concat(result.rules);
- return result
- },
- next: function() {
- this._ensureSorted();
- return this.sortedIter.next()
- },
- current: function() {
- this._ensureSorted();
- return this.sortedIter.current()
- },
- reset: function() {
- delete this.sortedIter
- },
- countable: function() {
- return this.sortedIter || this.iter.countable()
- },
- count: function() {
- if (this.sortedIter)
- return this.sortedIter.count();
- return this.iter.count()
- },
- _ensureSorted: function() {
- if (this.sortedIter)
- return;
- $.each(this.rules, function() {
- this.getter = compileGetter(this.getter)
- });
- this.sortedIter = new MapIterator(new ArrayIterator(this.iter.toArray().sort($.proxy(this._compare, this))), this._unwrap)
- },
- _wrap: function(record, index) {
- return {
- index: index,
- value: record
- }
- },
- _unwrap: function(wrappedItem) {
- return wrappedItem.value
- },
- _compare: function(x, y) {
- var xIndex = x.index,
- yIndex = y.index;
- x = x.value;
- y = y.value;
- if (x === y)
- return xIndex - yIndex;
- for (var i = 0, rulesCount = this.rules.length; i < rulesCount; i++) {
- var rule = this.rules[i],
- xValue = toComparable(rule.getter(x)),
- yValue = toComparable(rule.getter(y)),
- factor = rule.desc ? -1 : 1;
- if (xValue < yValue)
- return -factor;
- if (xValue > yValue)
- return factor;
- if (xValue !== yValue)
- return !xValue ? -factor : factor
- }
- return xIndex - yIndex
- }
- });
- var compileCriteria = function() {
- var compileGroup = function(crit) {
- var operands = [],
- bag = ["return function(d) { return "],
- index = 0,
- pushAnd = false;
- $.each(crit, function() {
- if ($.isArray(this) || $.isFunction(this)) {
- if (pushAnd)
- bag.push(" && ");
- operands.push(compileCriteria(this));
- bag.push("op[", index, "](d)");
- index++;
- pushAnd = true
- }
- else {
- bag.push(/and|&/i.test(this) ? " && " : " || ");
- pushAnd = false
- }
- });
- bag.push(" }");
- return new Function("op", bag.join(""))(operands)
- };
- var toString = function(value) {
- return DX.utils.isDefined(value) ? value.toString() : ''
- };
- var compileBinary = function(crit) {
- crit = data.utils.normalizeBinaryCriterion(crit);
- var getter = compileGetter(crit[0]),
- op = crit[1],
- value = crit[2];
- value = toComparable(value);
- switch (op.toLowerCase()) {
- case"=":
- return compileEquals(getter, value);
- case"<>":
- return compileEquals(getter, value, true);
- case">":
- return function(obj) {
- return toComparable(getter(obj)) > value
- };
- case"<":
- return function(obj) {
- return toComparable(getter(obj)) < value
- };
- case">=":
- return function(obj) {
- return toComparable(getter(obj)) >= value
- };
- case"<=":
- return function(obj) {
- return toComparable(getter(obj)) <= value
- };
- case"startswith":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) === 0
- };
- case"endswith":
- return function(obj) {
- var getterValue = toComparable(toString(getter(obj))),
- searchValue = toString(value);
- if (getterValue.length < searchValue.length)
- return false;
- return getterValue.lastIndexOf(value) === getterValue.length - value.length
- };
- case"contains":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) > -1
- };
- case"notcontains":
- return function(obj) {
- return toComparable(toString(getter(obj))).indexOf(value) === -1
- }
- }
- throw DX.Error("E4003", op);
- };
- function compileEquals(getter, value, negate) {
- return function(obj) {
- obj = toComparable(getter(obj));
- var result = useStrictComparison(value) ? obj === value : obj == value;
- if (negate)
- result = !result;
- return result
- }
- }
- function useStrictComparison(value) {
- return value === "" || value === 0 || value === null || value === false || value === undefined
- }
- return function(crit) {
- if ($.isFunction(crit))
- return crit;
- if ($.isArray(crit[0]))
- return compileGroup(crit);
- return compileBinary(crit)
- }
- }();
- var FilterIterator = WrappedIterator.inherit({
- ctor: function(iter, criteria) {
- this.callBase(iter);
- this.criteria = compileCriteria(criteria)
- },
- next: function() {
- while (this.iter.next())
- if (this.criteria(this.current()))
- return true;
- return false
- }
- });
- var GroupIterator = Iterator.inherit({
- ctor: function(iter, getter) {
- this.iter = iter;
- this.getter = getter
- },
- next: function() {
- this._ensureGrouped();
- return this.groupedIter.next()
- },
- current: function() {
- this._ensureGrouped();
- return this.groupedIter.current()
- },
- reset: function() {
- delete this.groupedIter
- },
- countable: function() {
- return !!this.groupedIter
- },
- count: function() {
- return this.groupedIter.count()
- },
- _ensureGrouped: function() {
- if (this.groupedIter)
- return;
- var hash = {},
- keys = [],
- iter = this.iter,
- getter = compileGetter(this.getter);
- iter.reset();
- while (iter.next()) {
- var current = iter.current(),
- key = getter(current);
- if (key in hash)
- hash[key].push(current);
- else {
- hash[key] = [current];
- keys.push(key)
- }
- }
- this.groupedIter = new ArrayIterator($.map(keys, function(key) {
- return {
- key: key,
- items: hash[key]
- }
- }))
- }
- });
- var SelectIterator = WrappedIterator.inherit({
- ctor: function(iter, getter) {
- this.callBase(iter);
- this.getter = compileGetter(getter)
- },
- current: function() {
- return this.getter(this.callBase())
- },
- countable: function() {
- return this.iter.countable()
- },
- count: function() {
- return this.iter.count()
- }
- });
- var SliceIterator = WrappedIterator.inherit({
- ctor: function(iter, skip, take) {
- this.callBase(iter);
- this.skip = Math.max(0, skip);
- this.take = Math.max(0, take);
- this.pos = 0
- },
- next: function() {
- if (this.pos >= this.skip + this.take)
- return false;
- while (this.pos < this.skip && this.iter.next())
- this.pos++;
- this.pos++;
- return this.iter.next()
- },
- reset: function() {
- this.callBase();
- this.pos = 0
- },
- countable: function() {
- return this.iter.countable()
- },
- count: function() {
- return Math.min(this.iter.count() - this.skip, this.take)
- }
- });
- queryImpl.array = function(iter, queryOptions) {
- queryOptions = queryOptions || {};
- if (!(iter instanceof Iterator))
- iter = new ArrayIterator(iter);
- var handleError = function(error) {
- var handler = queryOptions.errorHandler;
- if (handler)
- handler(error);
- data._errorHandler(error)
- };
- var aggregateCore = function(aggregator) {
- var d = $.Deferred().fail(handleError),
- seed,
- step = aggregator.step,
- finalize = aggregator.finalize;
- try {
- iter.reset();
- if ("seed" in aggregator)
- seed = aggregator.seed;
- else
- seed = iter.next() ? iter.current() : NaN;
- var accumulator = seed;
- while (iter.next())
- accumulator = step(accumulator, iter.current());
- d.resolve(finalize ? finalize(accumulator) : accumulator)
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- };
- var aggregate = function(seed, step, finalize) {
- if (arguments.length < 2)
- return aggregateCore({step: arguments[0]});
- return aggregateCore({
- seed: seed,
- step: step,
- finalize: finalize
- })
- };
- var standardAggregate = function(name) {
- return aggregateCore(data.utils.aggregators[name])
- };
- var select = function(getter) {
- if (!$.isFunction(getter) && !$.isArray(getter))
- getter = $.makeArray(arguments);
- return chainQuery(new SelectIterator(iter, getter))
- };
- var selectProp = function(name) {
- return select(compileGetter(name))
- };
- var chainQuery = function(iter) {
- return queryImpl.array(iter, queryOptions)
- };
- return {
- toArray: function() {
- return iter.toArray()
- },
- enumerate: function() {
- var d = $.Deferred().fail(handleError);
- try {
- d.resolve(iter.toArray())
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- },
- sortBy: function(getter, desc) {
- return chainQuery(new SortIterator(iter, getter, desc))
- },
- thenBy: function(getter, desc) {
- if (iter instanceof SortIterator)
- return chainQuery(iter.thenBy(getter, desc));
- throw DX.Error("E4004");
- },
- filter: function(criteria) {
- if (!$.isArray(criteria))
- criteria = $.makeArray(arguments);
- return chainQuery(new FilterIterator(iter, criteria))
- },
- slice: function(skip, take) {
- if (take === undefined)
- take = Number.MAX_VALUE;
- return chainQuery(new SliceIterator(iter, skip, take))
- },
- select: select,
- groupBy: function(getter) {
- return chainQuery(new GroupIterator(iter, getter))
- },
- aggregate: aggregate,
- count: function() {
- if (iter.countable()) {
- var d = $.Deferred().fail(handleError);
- try {
- d.resolve(iter.count())
- }
- catch(x) {
- d.reject(x)
- }
- return d.promise()
- }
- return standardAggregate("count")
- },
- sum: function(getter) {
- if (getter)
- return selectProp(getter).sum();
- return standardAggregate("sum")
- },
- min: function(getter) {
- if (getter)
- return selectProp(getter).min();
- return standardAggregate("min")
- },
- max: function(getter) {
- if (getter)
- return selectProp(getter).max();
- return standardAggregate("max")
- },
- avg: function(getter) {
- if (getter)
- return selectProp(getter).avg();
- return standardAggregate("avg")
- }
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.query.remote.js */
- (function($, DX, undefined) {
- var data = DX.data,
- queryImpl = data.queryImpl;
- queryImpl.remote = function(url, queryOptions, tasks) {
- tasks = tasks || [];
- queryOptions = queryOptions || {};
- var createTask = function(name, args) {
- return {
- name: name,
- args: args
- }
- };
- var exec = function(executorTask) {
- var d = $.Deferred(),
- _adapterFactory,
- _adapter,
- _taskQueue,
- _currentTask,
- _mergedSortArgs;
- var rejectWithNotify = function(error) {
- var handler = queryOptions.errorHandler;
- if (handler)
- handler(error);
- data._errorHandler(error);
- d.reject(error)
- };
- function mergeSortTask(task) {
- switch (task.name) {
- case"sortBy":
- _mergedSortArgs = [task.args];
- return true;
- case"thenBy":
- if (!_mergedSortArgs)
- throw DX.Error("E4004");
- _mergedSortArgs.push(task.args);
- return true
- }
- return false
- }
- function unmergeSortTasks() {
- var head = _taskQueue[0],
- unmergedTasks = [];
- if (head && head.name === "multiSort") {
- _taskQueue.shift();
- $.each(head.args[0], function() {
- unmergedTasks.push(createTask(unmergedTasks.length ? "thenBy" : "sortBy", this))
- })
- }
- _taskQueue = unmergedTasks.concat(_taskQueue)
- }
- try {
- _adapterFactory = queryOptions.adapter || "odata";
- if (!$.isFunction(_adapterFactory))
- _adapterFactory = data.queryAdapters[_adapterFactory];
- _adapter = _adapterFactory(queryOptions);
- _taskQueue = [].concat(tasks).concat(executorTask);
- while (_taskQueue.length) {
- _currentTask = _taskQueue[0];
- if (!mergeSortTask(_currentTask)) {
- if (_mergedSortArgs) {
- _taskQueue.unshift(createTask("multiSort", [_mergedSortArgs]));
- _mergedSortArgs = null;
- continue
- }
- if (String(_currentTask.name) !== "enumerate")
- if (!_adapter[_currentTask.name] || _adapter[_currentTask.name].apply(_adapter, _currentTask.args) === false)
- break
- }
- _taskQueue.shift()
- }
- unmergeSortTasks();
- _adapter.exec(url).done(function(result, extra) {
- if (!_taskQueue.length)
- d.resolve(result, extra);
- else {
- var clientChain = queryImpl.array(result, {errorHandler: queryOptions.errorHandler});
- $.each(_taskQueue, function() {
- clientChain = clientChain[this.name].apply(clientChain, this.args)
- });
- clientChain.done(d.resolve).fail(d.reject)
- }
- }).fail(rejectWithNotify)
- }
- catch(x) {
- rejectWithNotify(x)
- }
- return d.promise()
- };
- var query = {};
- $.each(["sortBy", "thenBy", "filter", "slice", "select", "groupBy"], function() {
- var name = String(this);
- query[name] = function() {
- return queryImpl.remote(url, queryOptions, tasks.concat(createTask(name, arguments)))
- }
- });
- $.each(["count", "min", "max", "sum", "avg", "aggregate", "enumerate"], function() {
- var name = String(this);
- query[name] = function() {
- return exec.call(this, createTask(name, arguments))
- }
- });
- return query
- }
- })(jQuery, DevExpress);
- /*! Module core, file data.odata.js */
- (function($, DX, undefined) {
- var data = DX.data,
- utils = DX.utils,
- Guid = data.Guid,
- isDefined = utils.isDefined;
- var DEFAULT_PROTOCOL_VERSION = 2;
- var GUID_REGEX = /^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$/;
- var VERBOSE_DATE_REGEX = /^\/Date\((-?\d+)((\+|-)?(\d+)?)\)\/$/;
- var ISO8601_DATE_REGEX = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[-+]{1}\d{2}(:?)(\d{2})?)?$/;
- var JSON_VERBOSE_MIME_TYPE = "application/json;odata=verbose";
- function formatISO8601(date, skipZeroTime, skipTimezone) {
- var ret = [];
- var pad = function(n) {
- if (n < 10)
- return "0".concat(n);
- return String(n)
- };
- var isZeroTime = function() {
- return date.getHours() + date.getMinutes() + date.getSeconds() + date.getMilliseconds() < 1
- };
- ret.push(date.getFullYear());
- ret.push("-");
- ret.push(pad(date.getMonth() + 1));
- ret.push("-");
- ret.push(pad(date.getDate()));
- if (!(skipZeroTime && isZeroTime())) {
- ret.push("T");
- ret.push(pad(date.getHours()));
- ret.push(":");
- ret.push(pad(date.getMinutes()));
- ret.push(":");
- ret.push(pad(date.getSeconds()));
- if (date.getMilliseconds()) {
- ret.push(".");
- ret.push(date.getMilliseconds())
- }
- if (!skipTimezone)
- ret.push("Z")
- }
- return ret.join("")
- }
- function parseISO8601(isoString) {
- var result = new Date(0);
- var chunks = isoString.replace("Z", "").split("T"),
- date = /(\d{4})-(\d{2})-(\d{2})/.exec(chunks[0]),
- time = /(\d{2}):(\d{2}):(\d{2})\.?(\d{0,7})?/.exec(chunks[1]);
- result.setDate(Number(date[3]));
- result.setMonth(Number(date[2]) - 1);
- result.setFullYear(Number(date[1]));
- if ($.isArray(time) && time.length) {
- result.setHours(Number(time[1]));
- result.setMinutes(Number(time[2]));
- result.setSeconds(Number(time[3]));
- result.setMilliseconds(Number(String(time[4]).substr(0, 3)) || 0)
- }
- return result
- }
- function isAbsoluteUrl(url) {
- return /^(?:[a-z]+:)?\/\//i.test(url)
- }
- function toAbsoluteUrl(basePath, relativePath) {
- var part,
- baseParts = basePath.split("/"),
- relativeParts = relativePath.split("/");
- baseParts.pop();
- while (relativeParts.length) {
- part = relativeParts.shift();
- if (part === "..")
- baseParts.pop();
- else
- baseParts.push(part)
- }
- return baseParts.join("/")
- }
- var ajaxOptionsForRequest = function(protocolVersion, request, requestOptions) {
- request = $.extend({
- method: "get",
- url: "",
- params: {},
- payload: null,
- headers: {},
- timeout: 30000
- }, request);
- requestOptions = requestOptions || {};
- var beforeSend = requestOptions.beforeSend;
- if (beforeSend)
- beforeSend(request);
- var method = (request.method || "get").toLowerCase(),
- isGet = method === "get",
- useJsonp = isGet && requestOptions.jsonp,
- params = $.extend({}, request.params),
- ajaxData = isGet ? params : formatPayload(request.payload),
- qs = !isGet && $.param(params),
- url = request.url,
- contentType = !isGet && JSON_VERBOSE_MIME_TYPE;
- if (qs)
- url += (url.indexOf("?") > -1 ? "&" : "?") + qs;
- if (useJsonp)
- ajaxData["$format"] = "json";
- return {
- url: url,
- data: ajaxData,
- dataType: useJsonp ? "jsonp" : "json",
- jsonp: useJsonp && "$callback",
- type: method,
- timeout: request.timeout,
- headers: request.headers,
- contentType: contentType,
- accepts: {json: [JSON_VERBOSE_MIME_TYPE, "text/plain"].join()},
- xhrFields: {withCredentials: requestOptions.withCredentials}
- };
- function formatPayload(payload) {
- return JSON.stringify(payload, function(key, value) {
- if (!(this[key] instanceof Date))
- return value;
- value = formatISO8601(this[key]);
- switch (protocolVersion) {
- case 2:
- return value.substr(0, value.length - 1);
- case 3:
- case 4:
- return value;
- default:
- throw DX.Error("E4002");
- }
- })
- }
- };
- var sendRequest = function(protocolVersion, request, requestOptions) {
- var d = $.Deferred();
- var options = ajaxOptionsForRequest(protocolVersion, request, requestOptions);
- $.ajax(options).always(function(obj, textStatus) {
- var tuplet = interpretJsonFormat(obj, textStatus),
- error = tuplet.error,
- data = tuplet.data,
- nextUrl = tuplet.nextUrl,
- extra;
- if (error)
- d.reject(error);
- else if (requestOptions.countOnly)
- d.resolve(tuplet.count);
- else if (nextUrl) {
- if (!isAbsoluteUrl(nextUrl))
- nextUrl = toAbsoluteUrl(options.url, nextUrl);
- sendRequest(protocolVersion, {url: nextUrl}, requestOptions).fail(d.reject).done(function(nextData) {
- d.resolve(data.concat(nextData))
- })
- }
- else {
- if (isFinite(tuplet.count))
- extra = {totalCount: tuplet.count};
- d.resolve(data, extra)
- }
- });
- return d.promise()
- };
- var formatDotNetError = function(errorObj) {
- var message,
- currentError = errorObj;
- if ("message" in errorObj)
- if (errorObj.message.value)
- message = errorObj.message.value;
- else
- message = errorObj.message;
- while (currentError = currentError.innererror || currentError.internalexception) {
- message = currentError.message;
- if (currentError.internalexception && message.indexOf("inner exception") === -1)
- break
- }
- return message
- };
- var errorFromResponse = function(obj, textStatus) {
- if (textStatus === "nocontent")
- return null;
- var httpStatus = 200,
- message = "Unknown error",
- response = obj;
- if (textStatus !== "success") {
- httpStatus = obj.status;
- message = data.utils.errorMessageFromXhr(obj, textStatus);
- try {
- response = $.parseJSON(obj.responseText)
- }
- catch(x) {}
- }
- var errorObj = response && (response.error || response["@odata.error"]);
- if (errorObj) {
- message = formatDotNetError(errorObj) || message;
- if (httpStatus === 200)
- httpStatus = 500;
- if (errorObj.code)
- httpStatus = Number(errorObj.code);
- return $.extend(Error(message), {
- httpStatus: httpStatus,
- errorDetails: errorObj
- })
- }
- else if (httpStatus !== 200)
- return $.extend(Error(message), {httpStatus: httpStatus})
- };
- var interpretJsonFormat = function(obj, textStatus) {
- var error = errorFromResponse(obj, textStatus),
- value;
- if (error)
- return {error: error};
- if (!$.isPlainObject(obj))
- return {data: obj};
- if ("d" in obj && (utils.isArray(obj.d) || utils.isObject(obj.d)))
- value = interpretVerboseJsonFormat(obj, textStatus);
- else
- value = interpretLightJsonFormat(obj, textStatus);
- transformTypes(value);
- return value
- };
- var interpretVerboseJsonFormat = function(obj) {
- var data = obj.d;
- if (!isDefined(data))
- return {error: Error("Malformed or unsupported JSON response received")};
- data = data;
- if (isDefined(data.results))
- data = data.results;
- return {
- data: data,
- nextUrl: obj.d.__next,
- count: parseInt(obj.d.__count, 10)
- }
- };
- var interpretLightJsonFormat = function(obj) {
- var data = obj;
- if (isDefined(data.value))
- data = data.value;
- return {
- data: data,
- nextUrl: obj["@odata.nextLink"],
- count: parseInt(obj["@odata.count"], 10)
- }
- };
- var EdmLiteral = DX.Class.inherit({
- ctor: function(value) {
- this._value = value
- },
- valueOf: function() {
- return this._value
- }
- });
- var transformTypes = function(obj) {
- $.each(obj, function(key, value) {
- if (value !== null && typeof value === "object") {
- if ("results" in value)
- obj[key] = value.results;
- transformTypes(obj[key])
- }
- else if (typeof value === "string")
- if (GUID_REGEX.test(value))
- obj[key] = new Guid(value);
- else if (value.match(VERBOSE_DATE_REGEX)) {
- var date = new Date(Number(RegExp.$1) + RegExp.$2 * 60 * 1000);
- obj[key] = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000)
- }
- else if (ISO8601_DATE_REGEX.test(value))
- obj[key] = new Date(parseISO8601(obj[key]).valueOf())
- })
- };
- var serializeDate = function(date) {
- return "datetime'" + formatISO8601(date, true, true) + "'"
- };
- var serializeString = function(value) {
- return "'" + value.replace(/'/g, "''") + "'"
- };
- var serializePropName = function(propName) {
- if (propName instanceof EdmLiteral)
- return propName.valueOf();
- return propName.replace(/\./g, "/")
- };
- var serializeValueV4 = function(value) {
- if (value instanceof Date)
- return formatISO8601(value, false, false);
- if (value instanceof Guid)
- return value.valueOf();
- return serializeValueV2(value)
- };
- var serializeValueV2 = function(value) {
- if (value instanceof Date)
- return serializeDate(value);
- if (value instanceof Guid)
- return "guid'" + value + "'";
- if (value instanceof EdmLiteral)
- return value.valueOf();
- if (typeof value === "string")
- return serializeString(value);
- return String(value)
- };
- var serializeValue = function(value, protocolVersion) {
- switch (protocolVersion) {
- case 2:
- case 3:
- return serializeValueV2(value);
- case 4:
- return serializeValueV4(value);
- default:
- throw DX.Error("E4002");
- }
- };
- var serializeKey = function(key, protocolVersion) {
- if ($.isPlainObject(key)) {
- var parts = [];
- $.each(key, function(k, v) {
- parts.push(serializePropName(k) + "=" + serializeValue(v, protocolVersion))
- });
- return parts.join()
- }
- return serializeValue(key, protocolVersion)
- };
- var keyConverters = {
- String: function(value) {
- return value + ""
- },
- Int32: function(value) {
- return Math.floor(value)
- },
- Int64: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "L")
- },
- Guid: function(value) {
- if (value instanceof Guid)
- return value;
- return new Guid(value)
- },
- Boolean: function(value) {
- return !!value
- },
- Single: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "f")
- },
- Decimal: function(value) {
- if (value instanceof EdmLiteral)
- return value;
- return new EdmLiteral(value + "m")
- }
- };
- var compileCriteria = function() {
- var createBinaryOperationFormatter = function(op) {
- return function(prop, val, bag) {
- bag.push(prop, " ", op, " ", val)
- }
- };
- var createStringFuncFormatter = function(op, reverse) {
- return function(prop, val, bag) {
- if (reverse)
- bag.push(op, "(", val, ",", prop, ")");
- else
- bag.push(op, "(", prop, ",", val, ")")
- }
- };
- var formatters = {
- "=": createBinaryOperationFormatter("eq"),
- "<>": createBinaryOperationFormatter("ne"),
- ">": createBinaryOperationFormatter("gt"),
- ">=": createBinaryOperationFormatter("ge"),
- "<": createBinaryOperationFormatter("lt"),
- "<=": createBinaryOperationFormatter("le"),
- startswith: createStringFuncFormatter("startswith"),
- endswith: createStringFuncFormatter("endswith")
- };
- var formattersV2 = $.extend({}, formatters, {
- contains: createStringFuncFormatter("substringof", true),
- notcontains: createStringFuncFormatter("not substringof", true)
- });
- var formattersV4 = $.extend({}, formatters, {
- contains: createStringFuncFormatter("contains"),
- notcontains: createStringFuncFormatter("not contains")
- });
- var compileBinary = function(criteria, bag, protocolVersion) {
- criteria = data.utils.normalizeBinaryCriterion(criteria);
- var op = criteria[1],
- formatters = protocolVersion === 4 ? formattersV4 : formattersV2,
- formatter = formatters[op.toLowerCase()];
- if (!formatter)
- throw DX.Error("E4003", op);
- formatter(serializePropName(criteria[0]), serializeValue(criteria[2], protocolVersion), bag)
- };
- var compileGroup = function(criteria, bag, protocolVersion) {
- var pushAnd = false;
- $.each(criteria, function() {
- if ($.isArray(this)) {
- if (pushAnd)
- bag.push(" and ");
- bag.push("(");
- compileCore(this, bag, protocolVersion);
- bag.push(")");
- pushAnd = true
- }
- else {
- bag.push(/and|&/i.test(this) ? " and " : " or ");
- pushAnd = false
- }
- })
- };
- var compileCore = function(criteria, bag, protocolVersion) {
- if ($.isArray(criteria[0]))
- compileGroup(criteria, bag, protocolVersion);
- else
- compileBinary(criteria, bag, protocolVersion)
- };
- return function(criteria, protocolVersion) {
- var bag = [];
- compileCore(criteria, bag, protocolVersion);
- return bag.join("")
- }
- }();
- var createODataQueryAdapter = function(queryOptions) {
- var _sorting = [],
- _criteria = [],
- _select,
- _skip,
- _take,
- _countQuery;
- var hasSlice = function() {
- return _skip || _take !== undefined
- };
- var hasFunction = function(criterion) {
- for (var i = 0; i < criterion.length; i++) {
- if ($.isFunction(criterion[i]))
- return true;
- if ($.isArray(criterion[i]) && hasFunction(criterion[i]))
- return true
- }
- return false
- };
- var generateExpand = function() {
- var hash = {};
- if (queryOptions.expand)
- $.each($.makeArray(queryOptions.expand), function() {
- hash[serializePropName(this)] = 1
- });
- if (_select)
- $.each(_select, function() {
- var path = this.split(".");
- if (path.length < 2)
- return;
- path.pop();
- hash[serializePropName(path.join("."))] = 1
- });
- return $.map(hash, function(k, v) {
- return v
- }).join() || undefined
- };
- var requestData = function() {
- var result = {};
- if (!_countQuery) {
- if (_sorting.length)
- result["$orderby"] = _sorting.join(",");
- if (_skip)
- result["$skip"] = _skip;
- if (_take !== undefined)
- result["$top"] = _take;
- if (_select)
- result["$select"] = serializePropName(_select.join());
- result["$expand"] = generateExpand()
- }
- if (_criteria.length)
- result["$filter"] = compileCriteria(_criteria.length < 2 ? _criteria[0] : _criteria, queryOptions.version);
- if (_countQuery)
- result["$top"] = 0;
- if (queryOptions.requireTotalCount || _countQuery)
- if (queryOptions.version !== 4)
- result["$inlinecount"] = "allpages";
- else
- result["$count"] = "true";
- return result
- };
- queryOptions.version = queryOptions.version || DEFAULT_PROTOCOL_VERSION;
- return {
- exec: function(url) {
- return sendRequest(queryOptions.version, {
- url: url,
- params: $.extend(requestData(), queryOptions && queryOptions.params)
- }, {
- beforeSend: queryOptions.beforeSend,
- jsonp: queryOptions.jsonp,
- withCredentials: queryOptions.withCredentials,
- countOnly: _countQuery
- })
- },
- multiSort: function(args) {
- var rules;
- if (hasSlice())
- return false;
- for (var i = 0; i < args.length; i++) {
- var getter = args[i][0],
- desc = !!args[i][1],
- rule;
- if (typeof getter !== "string")
- return false;
- rule = serializePropName(getter);
- if (desc)
- rule += " desc";
- rules = rules || [];
- rules.push(rule)
- }
- _sorting = rules
- },
- slice: function(skipCount, takeCount) {
- if (hasSlice())
- return false;
- _skip = skipCount;
- _take = takeCount
- },
- filter: function(criterion) {
- if (hasSlice() || $.isFunction(criterion))
- return false;
- if (!$.isArray(criterion))
- criterion = $.makeArray(arguments);
- if (hasFunction(criterion))
- return false;
- if (_criteria.length)
- _criteria.push("and");
- _criteria.push(criterion)
- },
- select: function(expr) {
- if (_select || $.isFunction(expr))
- return false;
- if (!$.isArray(expr))
- expr = $.makeArray(arguments);
- _select = expr
- },
- count: function() {
- _countQuery = true
- }
- }
- };
- $.extend(true, data, {
- EdmLiteral: EdmLiteral,
- utils: {odata: {
- sendRequest: sendRequest,
- serializePropName: serializePropName,
- serializeValue: serializeValue,
- serializeKey: serializeKey,
- keyConverters: keyConverters
- }},
- queryAdapters: {odata: createODataQueryAdapter}
- });
- data.OData__internals = {interpretJsonFormat: interpretJsonFormat}
- })(jQuery, DevExpress);
- /*! Module core, file data.store.abstract.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- abstract = DX.abstract,
- data = DX.data,
- normalizeSortingInfo = data.utils.normalizeSortingInfo;
- var STORE_CALLBACK_NAMES = ["loading", "loaded", "modifying", "modified", "inserting", "inserted", "updating", "updated", "removing", "removed"];
- function multiLevelGroup(query, groupInfo) {
- query = query.groupBy(groupInfo[0].selector);
- if (groupInfo.length > 1)
- query = query.select(function(g) {
- return $.extend({}, g, {items: multiLevelGroup(data.query(g.items), groupInfo.slice(1)).toArray()})
- });
- return query
- }
- data.utils.multiLevelGroup = multiLevelGroup;
- function arrangeSortingInfo(groupInfo, sortInfo) {
- var filteredGroup = [];
- $.each(groupInfo, function(_, group) {
- var collision = $.grep(sortInfo, function(sort) {
- return group.selector === sort.selector
- });
- if (collision.length < 1)
- filteredGroup.push(group)
- });
- return filteredGroup.concat(sortInfo)
- }
- data.utils.arrangeSortingInfo = arrangeSortingInfo;
- data.Store = Class.inherit({
- ctor: function(options) {
- var that = this;
- options = options || {};
- $.each(STORE_CALLBACK_NAMES, function() {
- var eventName = this;
- var callbacks = that[eventName] = $.Callbacks();
- var originalAdd = callbacks.add;
- callbacks.add = function() {
- DX.log("W0003", "Store", eventName, "14.2", "Use the '" + eventName + "' event instead");
- return originalAdd.apply(eventName, arguments)
- };
- if (eventName in options)
- callbacks.add(options[eventName]);
- var propertyName = "on" + eventName.charAt(0).toUpperCase() + eventName.slice(1);
- if (propertyName in options)
- that.on(eventName, options[propertyName])
- });
- this._key = options.key;
- this._errorHandler = options.errorHandler;
- this._useDefaultSearch = true
- },
- _customLoadOptions: function() {
- return null
- },
- key: function() {
- return this._key
- },
- keyOf: function(obj) {
- if (!this._keyGetter)
- this._keyGetter = data.utils.compileGetter(this.key());
- return this._keyGetter(obj)
- },
- _requireKey: function() {
- if (!this.key())
- throw DX.Error("E4005");
- },
- load: function(options) {
- var that = this;
- options = options || {};
- this.fireEvent("loading", [options]);
- this.loading.fire(options);
- return this._loadImpl(options).done(function(result, extra) {
- that.fireEvent("loaded", [result, options]);
- that.loaded.fire(result, extra)
- })
- },
- _loadImpl: function(options) {
- var filter = options.filter,
- sort = options.sort,
- select = options.select,
- group = options.group,
- skip = options.skip,
- take = options.take,
- q = this.createQuery(options);
- if (filter)
- q = q.filter(filter);
- if (group)
- group = normalizeSortingInfo(group);
- if (sort || group) {
- sort = normalizeSortingInfo(sort || []);
- if (group)
- sort = arrangeSortingInfo(group, sort);
- $.each(sort, function(index) {
- q = q[index ? "thenBy" : "sortBy"](this.selector, this.desc)
- })
- }
- if (select)
- q = q.select(select);
- if (group)
- q = multiLevelGroup(q, group);
- if (take || skip)
- q = q.slice(skip || 0, take);
- return q.enumerate()
- },
- createQuery: abstract,
- totalCount: function(options) {
- return this._addFailHandlers(this._totalCountImpl(options))
- },
- _totalCountImpl: function(options) {
- options = options || {};
- var q = this.createQuery(),
- group = options.group,
- filter = options.filter;
- if (filter)
- q = q.filter(filter);
- if (group) {
- group = normalizeSortingInfo(group);
- q = multiLevelGroup(q, group)
- }
- return q.count()
- },
- byKey: function(key, extraOptions) {
- return this._addFailHandlers(this._byKeyImpl(key, extraOptions))
- },
- _byKeyImpl: abstract,
- insert: function(values) {
- var that = this;
- that.fireEvent("modifying");
- that.fireEvent("inserting", [values]);
- that.modifying.fire();
- that.inserting.fire(values);
- return that._addFailHandlers(that._insertImpl(values).done(function(callbackValues, callbackKey) {
- that.fireEvent("inserted", [callbackValues, callbackKey]);
- that.fireEvent("modified");
- that.inserted.fire(callbackValues, callbackKey);
- that.modified.fire()
- }))
- },
- _insertImpl: abstract,
- update: function(key, values) {
- var that = this;
- that.fireEvent("modifying");
- that.fireEvent("updating", [key, values]);
- that.modifying.fire();
- that.updating.fire(key, values);
- return that._addFailHandlers(that._updateImpl(key, values).done(function(callbackKey, callbackValues) {
- that.fireEvent("updated", [callbackKey, callbackValues]);
- that.fireEvent("modified");
- that.updated.fire(callbackKey, callbackValues);
- that.modified.fire()
- }))
- },
- _updateImpl: abstract,
- remove: function(key) {
- var that = this;
- that.fireEvent("modifying");
- that.fireEvent("removing", [key]);
- that.modifying.fire();
- that.removing.fire(key);
- return that._addFailHandlers(that._removeImpl(key).done(function(callbackKey) {
- that.fireEvent("removed", [callbackKey]);
- that.fireEvent("modified");
- that.removed.fire(callbackKey);
- that.modified.fire()
- }))
- },
- _removeImpl: abstract,
- _addFailHandlers: function(deferred) {
- return deferred.fail(this._errorHandler, data._errorHandler)
- }
- }).include(DX.EventsMixin)
- })(jQuery, DevExpress);
- /*! Module core, file data.store.array.js */
- (function($, DX, undefined) {
- var data = DX.data,
- Guid = data.Guid;
- var trivialPromise = function() {
- var d = $.Deferred();
- return d.resolve.apply(d, arguments).promise()
- };
- var rejectedPromise = function() {
- var d = $.Deferred();
- return d.reject.apply(d, arguments).promise()
- };
- data.ArrayStore = data.Store.inherit({
- ctor: function(options) {
- if ($.isArray(options))
- options = {data: options};
- else
- options = options || {};
- this.callBase(options);
- var initialArray = options.data;
- if (initialArray && !$.isArray(initialArray))
- throw DX.Error("E4006");
- this._array = initialArray || []
- },
- createQuery: function() {
- return data.query(this._array, {errorHandler: this._errorHandler})
- },
- _byKeyImpl: function(key) {
- var index = this._indexByKey(key);
- if (index === -1)
- return rejectedPromise(DX.Error("E4009"));
- return trivialPromise(this._array[index])
- },
- _insertImpl: function(values) {
- var keyExpr = this.key(),
- keyValue,
- obj;
- if ($.isPlainObject(values))
- obj = $.extend({}, values);
- else
- obj = values;
- if (keyExpr) {
- keyValue = this.keyOf(obj);
- if (keyValue === undefined || typeof keyValue === "object" && $.isEmptyObject(keyValue)) {
- if ($.isArray(keyExpr))
- throw DX.Error("E4007");
- keyValue = obj[keyExpr] = String(new Guid)
- }
- else if (this._array[this._indexByKey(keyValue)] !== undefined)
- return rejectedPromise(DX.Error("E4008"))
- }
- else
- keyValue = obj;
- this._array.push(obj);
- return trivialPromise(values, keyValue)
- },
- _updateImpl: function(key, values) {
- var target,
- index;
- if (this.key()) {
- if (this.keyOf(values))
- if (!data.utils.keysEqual(this.key(), key, this.keyOf(values)))
- return rejectedPromise(DX.Error("E4017"));
- index = this._indexByKey(key);
- if (index < 0)
- return rejectedPromise(DX.Error("E4009"));
- target = this._array[index]
- }
- else
- target = key;
- DX.utils.deepExtendArraySafe(target, values);
- return trivialPromise(key, values)
- },
- _removeImpl: function(key) {
- var index = this._indexByKey(key);
- if (index > -1)
- this._array.splice(index, 1);
- return trivialPromise(key)
- },
- _indexByKey: function(key) {
- for (var i = 0, arrayLength = this._array.length; i < arrayLength; i++)
- if (data.utils.keysEqual(this.key(), this.keyOf(this._array[i]), key))
- return i;
- return -1
- },
- clear: function() {
- this._array = []
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.local.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- abstract = DX.abstract,
- data = DX.data;
- var LocalStoreBackend = Class.inherit({
- ctor: function(store, storeOptions) {
- this._store = store;
- this._dirty = false;
- var immediate = this._immediate = storeOptions.immediate;
- var flushInterval = Math.max(100, storeOptions.flushInterval || 10 * 1000);
- if (!immediate) {
- var saveProxy = $.proxy(this.save, this);
- setInterval(saveProxy, flushInterval);
- $(window).on("beforeunload", saveProxy);
- if (window.cordova)
- document.addEventListener("pause", saveProxy, false)
- }
- },
- notifyChanged: function() {
- this._dirty = true;
- if (this._immediate)
- this.save()
- },
- load: function() {
- this._store._array = this._loadImpl();
- this._dirty = false
- },
- save: function() {
- if (!this._dirty)
- return;
- this._saveImpl(this._store._array);
- this._dirty = false
- },
- _loadImpl: abstract,
- _saveImpl: abstract
- });
- var DomLocalStoreBackend = LocalStoreBackend.inherit({
- ctor: function(store, storeOptions) {
- this.callBase(store, storeOptions);
- var name = storeOptions.name;
- if (!name)
- throw DX.Error("E4013");
- this._key = "dx-data-localStore-" + name
- },
- _loadImpl: function() {
- var raw = localStorage.getItem(this._key);
- if (raw)
- return JSON.parse(raw);
- return []
- },
- _saveImpl: function(array) {
- if (!array.length)
- localStorage.removeItem(this._key);
- else
- localStorage.setItem(this._key, JSON.stringify(array))
- }
- });
- var localStoreBackends = {dom: DomLocalStoreBackend};
- data.LocalStore = data.ArrayStore.inherit({
- ctor: function(options) {
- if (typeof options === "string")
- options = {name: options};
- else
- options = options || {};
- this.callBase(options);
- this._backend = new localStoreBackends[options.backend || "dom"](this, options);
- this._backend.load()
- },
- clear: function() {
- this.callBase();
- this._backend.notifyChanged()
- },
- _insertImpl: function(values) {
- var b = this._backend;
- return this.callBase(values).done($.proxy(b.notifyChanged, b))
- },
- _updateImpl: function(key, values) {
- var b = this._backend;
- return this.callBase(key, values).done($.proxy(b.notifyChanged, b))
- },
- _removeImpl: function(key) {
- var b = this._backend;
- return this.callBase(key).done($.proxy(b.notifyChanged, b))
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.odata.js */
- (function($, DX, undefined) {
- var Class = DX.Class,
- data = DX.data,
- utils = DX.utils,
- odataUtils = data.utils.odata;
- var DEFAULT_PROTOCOL_VERSION = 2;
- var formatFunctionInvocationUrl = function(baseUrl, args) {
- return DX.stringFormat("{0}({1})", baseUrl, $.map(args || {}, function(value, key) {
- return DX.stringFormat("{0}={1}", key, value)
- }).join(","))
- };
- var escapeServiceOperationParams = function(params, version) {
- if (!params)
- return params;
- var result = {};
- $.each(params, function(k, v) {
- result[k] = odataUtils.serializeValue(v, version)
- });
- return result
- };
- var convertSimpleKey = function(keyType, keyValue) {
- var converter = odataUtils.keyConverters[keyType];
- if (!converter)
- throw DX.Error("E4014", keyType);
- return converter(keyValue)
- };
- var SharedMethods = {
- _extractServiceOptions: function(options) {
- options = options || {};
- this._url = String(options.url).replace(/\/+$/, "");
- this._beforeSend = options.beforeSend;
- this._jsonp = options.jsonp;
- this._version = options.version || DEFAULT_PROTOCOL_VERSION;
- this._withCredentials = options.withCredentials
- },
- _sendRequest: function(url, method, params, payload) {
- return odataUtils.sendRequest(this.version(), {
- url: url,
- method: method,
- params: params || {},
- payload: payload
- }, {
- beforeSend: this._beforeSend,
- jsonp: this._jsonp,
- withCredentials: this._withCredentials
- })
- },
- version: function() {
- return this._version
- }
- };
- var ODataStore = data.Store.inherit({
- ctor: function(options) {
- this.callBase(options);
- this._extractServiceOptions(options);
- this._keyType = options.keyType;
- if (this.version() === 2)
- this._updateMethod = "MERGE";
- else
- this._updateMethod = "PATCH"
- },
- _customLoadOptions: function() {
- return ["expand", "customQueryParams"]
- },
- _byKeyImpl: function(key, extraOptions) {
- var params = {};
- if (extraOptions)
- if (extraOptions.expand)
- params["$expand"] = $.map($.makeArray(extraOptions.expand), odataUtils.serializePropName).join();
- return this._sendRequest(this._byKeyUrl(key), "GET", params)
- },
- createQuery: function(loadOptions) {
- var url,
- queryOptions;
- loadOptions = loadOptions || {};
- queryOptions = {
- beforeSend: this._beforeSend,
- errorHandler: this._errorHandler,
- jsonp: this._jsonp,
- version: this._version,
- withCredentials: this._withCredentials,
- expand: loadOptions.expand,
- requireTotalCount: loadOptions.requireTotalCount
- };
- if (utils.isDefined(loadOptions.urlOverride))
- url = loadOptions.urlOverride;
- else
- url = this._url;
- if ("customQueryParams" in loadOptions) {
- var params = escapeServiceOperationParams(loadOptions.customQueryParams, this.version());
- if (this.version() === 4)
- url = formatFunctionInvocationUrl(url, params);
- else
- queryOptions.params = params
- }
- return data.query(url, queryOptions)
- },
- _insertImpl: function(values) {
- this._requireKey();
- var that = this,
- d = $.Deferred();
- $.when(this._sendRequest(this._url, "POST", null, values)).done(function(serverResponse) {
- d.resolve(values, that.keyOf(serverResponse))
- }).fail(d.reject);
- return d.promise()
- },
- _updateImpl: function(key, values) {
- var d = $.Deferred();
- $.when(this._sendRequest(this._byKeyUrl(key), this._updateMethod, null, values)).done(function() {
- d.resolve(key, values)
- }).fail(d.reject, d);
- return d.promise()
- },
- _removeImpl: function(key) {
- var d = $.Deferred();
- $.when(this._sendRequest(this._byKeyUrl(key), "DELETE")).done(function() {
- d.resolve(key)
- }).fail(d.reject, d);
- return d.promise()
- },
- _byKeyUrl: function(key, useOriginalHost) {
- var keyObj = key,
- keyType = this._keyType,
- baseUrl = useOriginalHost ? DX._proxyUrlFormatter.formatLocalUrl(this._url) : this._url;
- if ($.isPlainObject(keyType)) {
- keyObj = {};
- $.each(keyType, function(subKeyName, subKeyType) {
- keyObj[subKeyName] = convertSimpleKey(subKeyType, key[subKeyName])
- })
- }
- else if (keyType)
- keyObj = convertSimpleKey(keyType, key);
- return baseUrl + "(" + encodeURIComponent(odataUtils.serializeKey(keyObj, this._version)) + ")"
- }
- }).include(SharedMethods);
- var ODataContext = Class.inherit({
- ctor: function(options) {
- var that = this;
- that._extractServiceOptions(options);
- that._errorHandler = options.errorHandler;
- $.each(options.entities || [], function(entityAlias, entityOptions) {
- that[entityAlias] = new ODataStore($.extend({}, options, {url: that._url + "/" + encodeURIComponent(entityOptions.name || entityAlias)}, entityOptions))
- })
- },
- get: function(operationName, params) {
- return this.invoke(operationName, params, "GET")
- },
- invoke: function(operationName, params, httpMethod) {
- params = params || {};
- httpMethod = (httpMethod || "POST").toLowerCase();
- var d = $.Deferred(),
- url = this._url + "/" + encodeURIComponent(operationName),
- payload;
- if (this.version() === 4)
- if (httpMethod === "get") {
- url = formatFunctionInvocationUrl(url, escapeServiceOperationParams(params, this.version()));
- params = null
- }
- else if (httpMethod === "post") {
- payload = params;
- params = null
- }
- $.when(this._sendRequest(url, httpMethod, escapeServiceOperationParams(params, this.version()), payload)).done(function(r) {
- if ($.isPlainObject(r) && operationName in r)
- r = r[operationName];
- d.resolve(r)
- }).fail([this._errorHandler, data._errorHandler, d.reject]);
- return d.promise()
- },
- objectLink: function(entityAlias, key) {
- var store = this[entityAlias];
- if (!store)
- throw DX.Error("E4015", entityAlias);
- if (!utils.isDefined(key))
- return null;
- return {__metadata: {uri: store._byKeyUrl(key, true)}}
- }
- }).include(SharedMethods);
- $.extend(data, {
- ODataStore: ODataStore,
- ODataContext: ODataContext
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.store.custom.js */
- (function($, DX, undefined) {
- var data = DX.data;
- var TOTAL_COUNT = "totalCount",
- LOAD = "load",
- BY_KEY = "byKey",
- INSERT = "insert",
- UPDATE = "update",
- REMOVE = "remove";
- function isPromise(obj) {
- return obj && $.isFunction(obj.then)
- }
- function trivialPromise(value) {
- return $.Deferred().resolve(value).promise()
- }
- function ensureRequiredFuncOption(name, obj) {
- if (!$.isFunction(obj))
- throw DX.Error("E4011", name);
- }
- function throwInvalidUserFuncResult(name) {
- throw DX.Error("E4012", name);
- }
- function createUserFuncFailureHandler(pendingDeferred) {
- function errorMessageFromXhr(promiseArguments) {
- var xhr = promiseArguments[0],
- textStatus = promiseArguments[1];
- if (!xhr || !xhr.getResponseHeader)
- return null;
- return data.utils.errorMessageFromXhr(xhr, textStatus)
- }
- return function(arg) {
- var error;
- if (arg instanceof Error)
- error = arg;
- else
- error = new Error(errorMessageFromXhr(arguments) || arg && String(arg) || "Unknown error");
- pendingDeferred.reject(error)
- }
- }
- data.CustomStore = data.Store.inherit({
- ctor: function(options) {
- options = options || {};
- this.callBase(options);
- this._useDefaultSearch = false;
- this._loadFunc = options[LOAD];
- this._totalCountFunc = options[TOTAL_COUNT];
- this._byKeyFunc = options[BY_KEY];
- this._insertFunc = options[INSERT];
- this._updateFunc = options[UPDATE];
- this._removeFunc = options[REMOVE]
- },
- createQuery: function() {
- throw DX.Error("E4010");
- },
- _totalCountImpl: function(options) {
- var userFunc = this._totalCountFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(TOTAL_COUNT, userFunc);
- userResult = userFunc(options);
- if (!isPromise(userResult)) {
- userResult = Number(userResult);
- if (!isFinite(userResult))
- throwInvalidUserFuncResult(TOTAL_COUNT);
- userResult = trivialPromise(userResult)
- }
- userResult.then(function(count) {
- d.resolve(Number(count))
- }, createUserFuncFailureHandler(d));
- return d.promise()
- },
- _loadImpl: function(options) {
- var userFunc = this._loadFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(LOAD, userFunc);
- userResult = userFunc(options);
- if ($.isArray(userResult))
- userResult = trivialPromise(userResult);
- else if (userResult === null || userResult === undefined)
- userResult = trivialPromise([]);
- else if (!isPromise(userResult))
- throwInvalidUserFuncResult(LOAD);
- userResult.then(function(data, extra) {
- d.resolve(data, extra)
- }, createUserFuncFailureHandler(d));
- return this._addFailHandlers(d.promise())
- },
- _byKeyImpl: function(key, extraOptions) {
- var userFunc = this._byKeyFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(BY_KEY, userFunc);
- userResult = userFunc(key, extraOptions);
- if (!isPromise(userResult))
- userResult = trivialPromise(userResult);
- userResult.then(function(obj) {
- d.resolve(obj)
- }, createUserFuncFailureHandler(d));
- return d.promise()
- },
- _insertImpl: function(values) {
- var userFunc = this._insertFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(INSERT, userFunc);
- userResult = userFunc(values);
- if (!isPromise(userResult))
- userResult = trivialPromise(userResult);
- userResult.then(function(newKey) {
- d.resolve(values, newKey)
- }, createUserFuncFailureHandler(d));
- return d.promise()
- },
- _updateImpl: function(key, values) {
- var userFunc = this._updateFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(UPDATE, userFunc);
- userResult = userFunc(key, values);
- if (!isPromise(userResult))
- userResult = trivialPromise();
- userResult.then(function() {
- d.resolve(key, values)
- }, createUserFuncFailureHandler(d));
- return d.promise()
- },
- _removeImpl: function(key) {
- var userFunc = this._removeFunc,
- userResult,
- d = $.Deferred();
- ensureRequiredFuncOption(REMOVE, userFunc);
- userResult = userFunc(key);
- if (!isPromise(userResult))
- userResult = trivialPromise();
- userResult.then(function() {
- d.resolve(key)
- }, createUserFuncFailureHandler(d));
- return d.promise()
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file data.dataSource.js */
- (function($, DX, undefined) {
- var data = DX.data,
- CustomStore = data.CustomStore,
- Class = DX.Class;
- var storeTypeRegistry = {
- jaydata: "JayDataStore",
- breeze: "BreezeStore",
- odata: "ODataStore",
- local: "LocalStore",
- array: "ArrayStore"
- };
- var nextLoadOperationId = function() {
- var id = -1;
- return function() {
- return ++id
- }
- }();
- var canceledOperationsRegistry = function() {
- var registry = {};
- return {
- add: function(operationId) {
- registry[operationId] = true
- },
- has: function(operationId) {
- return operationId in registry
- },
- remove: function(operationId) {
- delete registry[operationId]
- }
- }
- }();
- var ensureIsNotRejected = function(loadOperationId, pendingDeferred) {
- if (canceledOperationsRegistry.has(loadOperationId)) {
- canceledOperationsRegistry.remove(loadOperationId);
- pendingDeferred.reject("canceled");
- return false
- }
- return true
- };
- function normalizeDataSourceOptions(options) {
- var store;
- function createCustomStoreFromLoadFunc() {
- var storeConfig = {};
- $.each(["key", "load", "byKey", "lookup", "totalCount", "insert", "update", "remove"], function() {
- storeConfig[this] = options[this];
- delete options[this]
- });
- return new CustomStore(storeConfig)
- }
- function createStoreFromConfig(storeConfig) {
- var storeCtor = data[storeTypeRegistry[storeConfig.type]];
- delete storeConfig.type;
- return new storeCtor(storeConfig)
- }
- function createCustomStoreFromUrl(url) {
- return new CustomStore({load: function() {
- return $.getJSON(url)
- }})
- }
- if (typeof options === "string")
- options = createCustomStoreFromUrl(options);
- if (options === undefined)
- options = [];
- if ($.isArray(options) || options instanceof data.Store)
- options = {store: options};
- else
- options = $.extend({}, options);
- if (options.store === undefined)
- options.store = [];
- store = options.store;
- if ("load" in options)
- store = createCustomStoreFromLoadFunc();
- else if ($.isArray(store))
- store = new data.ArrayStore(store);
- else if ($.isPlainObject(store))
- store = createStoreFromConfig($.extend({}, store));
- options.store = store;
- return options
- }
- function normalizeStoreLoadOptionAccessorArguments(originalArguments) {
- switch (originalArguments.length) {
- case 0:
- return undefined;
- case 1:
- return originalArguments[0]
- }
- return $.makeArray(originalArguments)
- }
- function generateStoreLoadOptionAccessor(optionName) {
- return function() {
- var args = normalizeStoreLoadOptionAccessorArguments(arguments);
- if (args !== undefined)
- this._storeLoadOptions[optionName] = args;
- return this._storeLoadOptions[optionName]
- }
- }
- function mapDataRespectingGrouping(items, mapper, groupInfo) {
- function mapRecursive(items, level) {
- if (!DX.utils.isArray(items))
- return items;
- return level ? mapGroup(items, level) : $.map(items, mapper)
- }
- function mapGroup(group, level) {
- return $.map(group, function(item) {
- var result = {
- key: item.key,
- items: mapRecursive(item.items, level - 1)
- };
- if ("aggregates" in item)
- result.aggregates = item.aggregates;
- return result
- })
- }
- return mapRecursive(items, groupInfo ? data.utils.normalizeSortingInfo(groupInfo).length : 0)
- }
- var DataSource = Class.inherit({
- ctor: function(options) {
- options = normalizeDataSourceOptions(options);
- this._store = options.store;
- this._storeLoadOptions = this._extractLoadOptions(options);
- this._mapFunc = options.map;
- this._postProcessFunc = options.postProcess;
- this._pageIndex = options.pageIndex !== undefined ? options.pageIndex : 0;
- this._pageSize = options.pageSize !== undefined ? options.pageSize : 20;
- this._items = [];
- this._totalCount = -1;
- this._isLoaded = false;
- this._loadingCount = 0;
- this._loadQueue = this._createLoadQueue();
- this._searchValue = "searchValue" in options ? options.searchValue : null;
- this._searchOperation = options.searchOperation || "contains";
- this._searchExpr = options.searchExpr;
- this._paginate = options.paginate;
- if (this._paginate === undefined)
- this._paginate = !this.group();
- this._isLastPage = !this._paginate;
- this._userData = {};
- $.each(["changed", "loadError", "loadingChanged"], $.proxy(function(_, eventName) {
- var callbacks = this[eventName] = $.Callbacks();
- var originalAdd = callbacks.add;
- callbacks.add = function() {
- DX.log("W0003", "DataSource", eventName, "14.2", "Use the '" + eventName + "' event instead");
- return originalAdd.apply(eventName, arguments)
- }
- }, this));
- $.each(["changed", "loadError", "loadingChanged", "customizeLoadResult", "customizeStoreLoadOptions"], $.proxy(function(_, eventName) {
- var optionName = "on" + eventName[0].toUpperCase() + eventName.slice(1);
- if (options.hasOwnProperty(optionName))
- this.on(eventName, options[optionName])
- }, this))
- },
- dispose: function() {
- this.changed.empty();
- this.loadError.empty();
- this.loadingChanged.empty();
- this._disposeEvents();
- delete this._store;
- if (this._delayedLoadTask)
- this._delayedLoadTask.abort();
- this._disposed = true
- },
- _extractLoadOptions: function(options) {
- var result = {},
- names = ["sort", "filter", "select", "group", "requireTotalCount"],
- customNames = this._store._customLoadOptions();
- if (customNames)
- names = names.concat(customNames);
- $.each(names, function() {
- result[this] = options[this]
- });
- return result
- },
- loadOptions: function() {
- return this._storeLoadOptions
- },
- items: function() {
- return this._items
- },
- pageIndex: function(newIndex) {
- if (newIndex !== undefined) {
- this._pageIndex = newIndex;
- this._isLastPage = !this._paginate
- }
- return this._pageIndex
- },
- paginate: function(value) {
- if (arguments.length < 1)
- return this._paginate;
- value = !!value;
- if (this._paginate !== value) {
- this._paginate = value;
- this.pageIndex(0)
- }
- },
- pageSize: function(value) {
- if (arguments.length < 1)
- return this._pageSize;
- this._pageSize = value
- },
- isLastPage: function() {
- return this._isLastPage
- },
- sort: generateStoreLoadOptionAccessor("sort"),
- filter: function() {
- var newFilter = normalizeStoreLoadOptionAccessorArguments(arguments);
- if (newFilter !== undefined) {
- this._storeLoadOptions.filter = newFilter;
- this.pageIndex(0)
- }
- return this._storeLoadOptions.filter
- },
- group: generateStoreLoadOptionAccessor("group"),
- select: generateStoreLoadOptionAccessor("select"),
- requireTotalCount: generateStoreLoadOptionAccessor("requireTotalCount"),
- searchValue: function(value) {
- if (value !== undefined) {
- this.pageIndex(0);
- this._searchValue = value
- }
- return this._searchValue
- },
- searchOperation: function(op) {
- if (op !== undefined) {
- this.pageIndex(0);
- this._searchOperation = op
- }
- return this._searchOperation
- },
- searchExpr: function(expr) {
- var argc = arguments.length;
- if (argc) {
- if (argc > 1)
- expr = $.makeArray(arguments);
- this.pageIndex(0);
- this._searchExpr = expr
- }
- return this._searchExpr
- },
- store: function() {
- return this._store
- },
- key: function() {
- return this._store && this._store.key()
- },
- totalCount: function() {
- return this._totalCount
- },
- isLoaded: function() {
- return this._isLoaded
- },
- isLoading: function() {
- return this._loadingCount > 0
- },
- _createLoadQueue: function() {
- return DX.createQueue()
- },
- _changeLoadingCount: function(increment) {
- var oldLoading = this.isLoading(),
- newLoading;
- this._loadingCount += increment;
- newLoading = this.isLoading();
- if (oldLoading ^ newLoading) {
- this.fireEvent("loadingChanged", [newLoading]);
- this.loadingChanged.fire(newLoading)
- }
- },
- _scheduleLoadCallbacks: function(deferred) {
- var that = this;
- that._changeLoadingCount(1);
- deferred.always(function() {
- that._changeLoadingCount(-1)
- })
- },
- _scheduleChangedCallbacks: function(deferred) {
- var that = this;
- deferred.done(function() {
- that.fireEvent("changed");
- that.changed.fire()
- })
- },
- loadSingle: function(propName, propValue) {
- var that = this;
- var d = $.Deferred().fail(function() {
- that.fireEvent("loadError", arguments);
- that.loadError.fire.apply(that, arguments)
- }),
- key = this.key(),
- store = this._store,
- loadOptions = this._createStoreLoadOptions();
- function handleSuccess(data) {
- if (data === null || typeof data === "undefined" || $.isArray(data) && data.length < 1)
- d.reject();
- else
- d.resolve(that._transformLoadedData(data)[0])
- }
- if (arguments.length < 2) {
- propValue = propName;
- propName = key
- }
- delete loadOptions.skip;
- delete loadOptions.group;
- delete loadOptions.refresh;
- delete loadOptions.pageIndex;
- delete loadOptions.searchString;
- if (propName === key || store instanceof data.CustomStore)
- store.byKey(propValue, loadOptions).done(handleSuccess).fail(d.reject);
- else {
- loadOptions.take = 1;
- loadOptions.filter = loadOptions.filter ? [loadOptions.filter, [propName, propValue]] : [propName, propValue];
- store.load(loadOptions).done(handleSuccess).fail(d.reject)
- }
- return d.promise()
- },
- load: function() {
- var that = this,
- d = $.Deferred(),
- loadOptions;
- this._scheduleLoadCallbacks(d);
- this._scheduleChangedCallbacks(d);
- loadOptions = this._createLoadOptions();
- this.fireEvent("customizeStoreLoadOptions", [loadOptions]);
- if (!ensureIsNotRejected(loadOptions.operationId, d))
- return d.promise();
- function errorCallback() {
- if (arguments[0] !== "canceled") {
- that.fireEvent("loadError", arguments);
- that.loadError.fire.apply(that.loadError, arguments)
- }
- }
- function loadTask() {
- if (that._disposed)
- return undefined;
- return that._loadFromStore(loadOptions, d)
- }
- this._loadQueue.add(function() {
- if (typeof loadOptions.delay === "number")
- that._delayedLoadTask = DX.utils.executeAsync(loadTask, loadOptions.delay);
- else
- loadTask();
- return d.promise()
- });
- return d.promise({loadOperationId: loadOptions.operationId}).fail(errorCallback)
- },
- reload: function() {
- var prop,
- userData = this._userData;
- for (prop in userData)
- if (userData.hasOwnProperty(prop))
- delete userData[prop];
- this._totalCount = -1;
- this._isLoaded = false;
- return this.load()
- },
- cancel: function(loadOperationId) {
- canceledOperationsRegistry.add(loadOperationId)
- },
- _addSearchOptions: function(storeLoadOptions) {
- if (this._disposed)
- return;
- if (this.store()._useDefaultSearch)
- this._addSearchFilter(storeLoadOptions);
- else {
- storeLoadOptions.searchOperation = this._searchOperation;
- storeLoadOptions.searchValue = this._searchValue;
- storeLoadOptions.searchExpr = this._searchExpr
- }
- },
- _createStoreLoadOptions: function() {
- var result = $.extend({}, this._storeLoadOptions);
- this._addSearchOptions(result);
- if (this._paginate)
- if (this._pageSize) {
- result.skip = this._pageIndex * this._pageSize;
- result.take = this._pageSize
- }
- result.userData = this._userData;
- return result
- },
- _createLoadOptions: function() {
- return {
- operationId: nextLoadOperationId(),
- storeLoadOptions: this._createStoreLoadOptions()
- }
- },
- _addSearchFilter: function(storeLoadOptions) {
- var value = this._searchValue,
- op = this._searchOperation,
- selector = this._searchExpr,
- searchFilter = [];
- if (!value)
- return;
- if (!selector)
- selector = "this";
- if (!$.isArray(selector))
- selector = [selector];
- $.each(selector, function(i, item) {
- if (searchFilter.length)
- searchFilter.push("or");
- searchFilter.push([item, op, value])
- });
- if (storeLoadOptions.filter)
- storeLoadOptions.filter = [searchFilter, storeLoadOptions.filter];
- else
- storeLoadOptions.filter = searchFilter
- },
- _loadFromStore: function(loadOptions, pendingDeferred) {
- var that = this;
- function handleSuccess(data, extra) {
- function processResult() {
- var loadResult;
- loadResult = $.extend({
- data: data,
- extra: extra
- }, loadOptions);
- that.fireEvent("customizeLoadResult", [loadResult]);
- if (ensureIsNotRejected(loadOptions.operationId, pendingDeferred))
- that._processStoreLoadResult(loadResult, pendingDeferred)
- }
- if (that._disposed)
- return;
- processResult()
- }
- if (!ensureIsNotRejected(loadOptions.operationId, pendingDeferred))
- return pendingDeferred.promise();
- return this.store().load(loadOptions.storeLoadOptions).done(handleSuccess).fail(pendingDeferred.reject)
- },
- _processStoreLoadResult: function(loadResult, pendingDeferred) {
- var that = this;
- var data = loadResult.data,
- extra = loadResult.extra,
- storeLoadOptions = loadResult.storeLoadOptions;
- function resolvePendingDeferred() {
- if (!ensureIsNotRejected(loadResult.operationId, pendingDeferred))
- return pendingDeferred;
- that._isLoaded = true;
- that._totalCount = isFinite(extra.totalCount) ? extra.totalCount : -1;
- return pendingDeferred.resolve(data, extra)
- }
- function proceedLoadingTotalCount() {
- that.store().totalCount(storeLoadOptions).done(function(count) {
- extra.totalCount = count;
- resolvePendingDeferred()
- }).fail(function(){})
- }
- if (that._disposed)
- return;
- data = that._transformLoadedData(data);
- if (!$.isPlainObject(extra))
- extra = {};
- that._items = data;
- if (!data.length || !that._paginate || that._pageSize && data.length < that._pageSize)
- that._isLastPage = true;
- if (storeLoadOptions.requireTotalCount && !isFinite(extra.totalCount))
- proceedLoadingTotalCount();
- else
- resolvePendingDeferred()
- },
- _transformLoadedData: function(data) {
- var result = $.makeArray(data);
- if (this._mapFunc)
- result = mapDataRespectingGrouping(result, this._mapFunc, this.group());
- if (this._postProcessFunc)
- result = this._postProcessFunc(result);
- return result
- }
- }).include(DX.EventsMixin);
- $.extend(true, data, {
- DataSource: DataSource,
- utils: {
- storeTypeRegistry: storeTypeRegistry,
- normalizeDataSourceOptions: normalizeDataSourceOptions
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ko.js */
- (function($, DX) {
- if (DX.support.hasKo && DX.compareVersions(ko.version, [2, 3]) < 0)
- throw DX.Error("E0013");
- })(jQuery, DevExpress);
- /*! Module core, file ng.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- DX.ng = {module: window.angular.module("dx", ["ngSanitize"])}
- })(jQuery, DevExpress);
- /*! Module core, file component.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- dataUtils = DX.data.utils,
- inflector = DX.inflector;
- var Component = DX.Class.inherit({
- NAME: "Component",
- _setDeprecatedOptions: function() {
- this._deprecatedOptions = {}
- },
- _getDeprecatedOptions: function() {
- return this._deprecatedOptions
- },
- _setOptionAliases: function() {
- var aliases = this._optionAliases = {};
- $.each(this._getDeprecatedOptions(), function(optionName, info) {
- var optionAlias = info.alias;
- if (optionAlias)
- aliases[optionName] = optionAlias
- })
- },
- _getOptionAliases: function() {
- return this._optionAliases
- },
- _getOptionAliasesByName: function(optionName) {
- return $.map(this._getOptionAliases(), function(aliasedOption, aliasName) {
- return optionName === aliasedOption ? aliasName : undefined
- })
- },
- _setDefaultOptions: function() {
- this.option({
- onInitialized: null,
- onOptionChanged: null,
- onDisposing: null,
- defaultOptionsRules: null
- })
- },
- _defaultOptionsRules: function() {
- return []
- },
- _setOptionsByDevice: function(userRules) {
- var rules = this._defaultOptionsRules();
- if (this._customRules)
- rules = rules.concat(this._customRules);
- if ($.isArray(userRules))
- rules = rules.concat(userRules);
- this.option(this._convertRulesToOptions(rules))
- },
- _convertRulesToOptions: function(rules) {
- var options = {};
- var currentDevice = DX.devices.current();
- var deviceMatch = function(device, filter) {
- filter = $.makeArray(filter);
- return filter.length === 1 && $.isEmptyObject(filter[0]) || utils.findBestMatches(device, filter).length > 0
- };
- $.each(rules, function(index, rule) {
- var deviceFilter = rule.device || {},
- match;
- if ($.isFunction(deviceFilter))
- match = deviceFilter(currentDevice);
- else
- match = deviceMatch(currentDevice, deviceFilter);
- if (match)
- $.extend(options, rule.options)
- });
- return options
- },
- _isInitialOptionValue: function(name) {
- var isCustomOption = this._customRules && this._convertRulesToOptions(this._customRules).hasOwnProperty(name);
- var isInitialOption = this.option(name) === this._initialOptions[name];
- return !isCustomOption && isInitialOption
- },
- _setOptionsByReference: function() {
- this._optionsByReference = {}
- },
- _getOptionsByReference: function() {
- return this._optionsByReference
- },
- ctor: function(options) {
- if (!this.NAME)
- throw DX.Error("E0004");
- options = options || {};
- this._options = {};
- this._cachedGetters = {};
- this._updateLockCount = 0;
- this._optionChangedCallbacks = options._optionChangedCallbacks || $.Callbacks();
- this._disposingCallbacks = options._disposingCallbacks || $.Callbacks();
- this.optionChanged = $.Callbacks();
- this.disposing = $.Callbacks();
- $.each(["optionChanged", "disposing"], $.proxy(function(_, propertyName) {
- var that = this,
- originalAdd = this[propertyName].add;
- this[propertyName].add = function() {
- DX.log("W0003", that.NAME, propertyName, "14.2", "Use the '" + propertyName + "' event instead");
- return originalAdd.apply(this, arguments)
- }
- }, this));
- this.beginUpdate();
- try {
- this._suppressDeprecatedWarnings();
- this._setOptionsByReference();
- this._setDeprecatedOptions();
- this._setOptionAliases();
- this._setDefaultOptions();
- this._setOptionsByDevice(options.defaultOptionsRules);
- this._resumeDeprecatedWarnings();
- this._initialOptions = $.extend({}, this.option());
- this._initOptions(options)
- }
- finally {
- this.endUpdate()
- }
- },
- _initOptions: function(options) {
- this.option(options)
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- oldValue = dataUtils.toComparable(oldValue, true);
- newValue = dataUtils.toComparable(newValue, true);
- if (oldValue && newValue && oldValue.jquery && newValue.jquery)
- return newValue.is(oldValue);
- var oldValueIsNaN = oldValue !== oldValue,
- newValueIsNaN = newValue !== newValue;
- if (oldValueIsNaN && newValueIsNaN)
- return true;
- if (oldValue === null || typeof oldValue !== "object")
- return oldValue === newValue;
- return false
- },
- _init: function() {
- this._createOptionChangedAction();
- this._createDisposingAction();
- this.on("optionChanged", function(args) {
- this._optionChangedCallbacks.fireWith(this, [args])
- });
- this.on("disposing", function(args) {
- this._disposingCallbacks.fireWith(this, [args])
- })
- },
- _createOptionChangedAction: function() {
- this._optionChangedAction = this._createActionByOption("onOptionChanged", {excludeValidators: ["disabled", "readOnly"]})
- },
- _createDisposingAction: function() {
- this._disposingAction = this._createActionByOption("onDisposing", {excludeValidators: ["disabled", "readOnly"]})
- },
- _optionChanged: function(args) {
- switch (args.name) {
- case"onInitialized":
- break;
- case"onOptionChanged":
- this._createOptionChangedAction();
- break;
- case"onDisposing":
- this._createDisposingAction();
- break;
- case"defaultOptionsRules":
- break
- }
- },
- _dispose: function() {
- this.optionChanged.empty();
- this.disposing.fireWith(this).empty();
- this._disposingAction();
- this._disposeEvents();
- this._disposed = true
- },
- instance: function() {
- return this
- },
- beginUpdate: function() {
- this._updateLockCount++
- },
- endUpdate: function() {
- this._updateLockCount--;
- if (!this._updateLockCount)
- if (!this._initializing && !this._initialized) {
- this._initializing = true;
- try {
- this._init()
- }
- finally {
- this._initializing = false;
- this._initialized = true;
- this._createActionByOption("onInitialized")()
- }
- }
- },
- _logWarningIfDeprecated: function(option) {
- var info = this._getDeprecatedOptions()[option];
- if (info && !this._deprecatedOptionsSuppressed)
- this._logDeprecatedWarning(option, info)
- },
- _logDeprecatedWarningCount: 0,
- _logDeprecatedWarning: function(option, info) {
- var message = info.message || "Use the '" + info.alias + "' option instead";
- DX.log("W0001", this.NAME, option, info.since, message);
- ++this._logDeprecatedWarningCount
- },
- _suppressDeprecatedWarnings: function() {
- this._deprecatedOptionsSuppressed = true
- },
- _resumeDeprecatedWarnings: function() {
- this._deprecatedOptionsSuppressed = false
- },
- _notifyOptionChanged: function(option, value, previousValue) {
- var that = this;
- if (this._initialized)
- $.each(that._getOptionAliasesByName(option).concat([option]), function(index, name) {
- var args = {
- name: name.split(/[.\[]/)[0],
- fullName: name,
- value: value,
- previousValue: previousValue
- };
- that.optionChanged.fireWith(that, [args.name, value, previousValue]);
- that._optionChangedAction($.extend({}, args));
- if (!that._disposed)
- that._optionChanged(args)
- })
- },
- initialOption: function(optionName) {
- var options = this._initialOptions;
- return options[optionName]
- },
- _defaultActionConfig: function() {
- return {
- context: this,
- component: this
- }
- },
- _defaultActionArgs: function() {
- return {component: this}
- },
- _createAction: function(actionSource, config) {
- var that = this,
- action = new DX.Action(actionSource, $.extend(config, that._defaultActionConfig()));
- return function(e) {
- if (!arguments.length)
- e = {};
- if (e instanceof $.Event)
- throw Error("Action must be executed with jQuery.Event like action({ jQueryEvent: event })");
- if (!$.isPlainObject(e))
- e = {actionValue: e};
- return action.execute.call(action, $.extend(e, that._defaultActionArgs()))
- }
- },
- _createActionByOption: function(optionName, config) {
- config = config || {};
- if (typeof optionName !== "string")
- throw DX.Error("E0008");
- var matches = /^on(\w+)/.exec(optionName);
- if (matches) {
- var eventName = inflector.camelize(matches[1]),
- afterExecute = config.afterExecute || $.noop,
- that = this;
- config.afterExecute = function(args) {
- that.fireEvent(eventName, args.args);
- return afterExecute.apply(this, arguments)
- }
- }
- else {
- var optionAlias = this._getOptionAliasesByName(optionName),
- isOptionDeprecated = Boolean(this._getDeprecatedOptions()[optionName]);
- if (isOptionDeprecated) {
- if (optionAlias.length)
- throw Error("The '" + optionName + "' is deprecated and has alias '" + optionAlias + "'");
- }
- else
- throw Error("The '" + optionName + "' option name should start with 'on' prefix");
- }
- this._suppressDeprecatedWarnings();
- var action = this._createAction(this.option(optionName), config);
- this._resumeDeprecatedWarnings();
- return action
- },
- option: function(options) {
- var that = this,
- name = options,
- value = arguments[1],
- optionAliases = this._getOptionAliases();
- var normalizeOptionName = function(name) {
- if (name) {
- that._logWarningIfDeprecated(name);
- if (optionAliases[name])
- name = optionAliases[name]
- }
- return name
- };
- var getOptionValue = function(name, unwrapObservables) {
- if (!that._cachedGetters[name])
- that._cachedGetters[name] = dataUtils.compileGetter(name);
- return that._cachedGetters[name](that._options, {
- functionsAsIs: true,
- unwrapObservables: unwrapObservables
- })
- };
- if (arguments.length < 2 && $.type(name) !== "object") {
- name = normalizeOptionName(name);
- return getOptionValue(name)
- }
- if (typeof name === "string") {
- options = {};
- options[name] = value
- }
- that.beginUpdate();
- try {
- $.each(options, function(name, value) {
- name = normalizeOptionName(name);
- var prevValue = getOptionValue(name, false);
- if (that._optionValuesEqual(name, prevValue, value))
- return;
- dataUtils.compileSetter(name)(that._options, value, {
- functionsAsIs: true,
- merge: !that._getOptionsByReference()[name],
- unwrapObservables: false
- });
- that._notifyOptionChanged(name, value, prevValue)
- })
- }
- finally {
- that.endUpdate()
- }
- }
- }).include(DX.EventsMixin);
- $.extend(DX, {Component: Component})
- })(jQuery, DevExpress);
- /*! Module core, file transitionExecutor.js */
- (function($, DX) {
- var directionPostfixes = {
- forward: " dx-forward",
- backward: " dx-backward",
- none: " dx-no-direction",
- undefined: " dx-no-direction"
- };
- var addToAnimate = function(targetArray, $elements, animationConfig, type) {
- $elements.each(function() {
- var resultAnimationConfig = prepareElementAnimationConfig(animationConfig, type);
- if (resultAnimationConfig)
- targetArray.push({
- $element: $(this),
- animationConfig: resultAnimationConfig
- })
- })
- };
- var prepareElementAnimationConfig = function(config, type) {
- var result;
- if (typeof config === "string") {
- var presetName = config;
- config = DX.animationPresets.getPreset(presetName)
- }
- if (!config)
- result = undefined;
- else if ($.isFunction(config[type]))
- result = config[type];
- else {
- var cssClass = "dx-" + type;
- result = $.extend({skipElementInitialStyles: true}, config);
- if (!result.type || result.type === "css") {
- var extraCssClasses = result.extraCssClasses ? " " + result.extraCssClasses : "";
- result.type = "css";
- result.from = result.from || cssClass + extraCssClasses;
- result.to = result.to || cssClass + "-active"
- }
- }
- return result
- };
- var setupAnimations = function(items, config) {
- var result = [];
- $.each(items, function(index, item) {
- var animationConfig = item.animationConfig,
- $element = item.$element,
- animationInstance;
- if ($.isPlainObject(animationConfig)) {
- var fxConfig = getFXConfig(animationConfig, config);
- fxConfig.staggerDelay = fxConfig.staggerDelay || 0;
- fxConfig.delay = index * fxConfig.staggerDelay + fxConfig.delay;
- animationInstance = DX.fx.createAnimation($element, fxConfig)
- }
- else if ($.isFunction(animationConfig))
- animationInstance = animationConfig($element, config);
- animationInstance.setup();
- result.push({
- $element: $element,
- animationInstance: animationInstance
- })
- });
- return result
- };
- var startAnimations = function(items) {
- for (var i = 0; i < items.length; i++)
- items[i].animationInstance.start()
- };
- var getFXConfig = function(animation, config) {
- var result = animation;
- result.cleanupWhen = config.cleanupWhen;
- result.delay = result.delay || 0;
- if (result.type === "css") {
- var direction = animation.direction || config.direction,
- directionPostfix = directionPostfixes[direction];
- result.from += directionPostfix
- }
- return result
- };
- var TransitionExecutor = DevExpress.Class.inherit({
- ctor: function() {
- this.toEnterItems = [];
- this.toLeaveItems = [];
- this.reset()
- },
- reset: function() {
- this.toEnterItems.length = 0;
- this.toLeaveItems.length = 0
- },
- enter: function($elements, animation) {
- animation = animation || {};
- addToAnimate(this.toEnterItems, $elements, animation, "enter")
- },
- leave: function($elements, animation) {
- animation = animation || {};
- addToAnimate(this.toLeaveItems, $elements, animation, "leave")
- },
- start: function(config) {
- config = $.extend({}, config);
- var that = this,
- result;
- if (!this.toEnterItems.length && !this.toLeaveItems.length) {
- that.reset();
- result = $.Deferred().resolve().promise()
- }
- else {
- var animationItems = [],
- animationDeferreds,
- completeDeferred = $.Deferred();
- config.cleanupWhen = completeDeferred.promise();
- animationItems.push.apply(animationItems, setupAnimations(this.toEnterItems, config));
- animationItems.push.apply(animationItems, setupAnimations(this.toLeaveItems, config));
- animationDeferreds = $.map(animationItems, function(item) {
- return item.animationInstance.deferred
- });
- result = $.when.apply($, animationDeferreds).always(function() {
- completeDeferred.resolve();
- that.reset()
- });
- DX.utils.executeAsync(function() {
- startAnimations(animationItems)
- })
- }
- return result
- }
- });
- var optionPrefix = "preset_";
- var AnimationPresetCollection = DevExpress.Component.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this._customRules = [];
- this._registeredPresets = [];
- this.resetToDefaults()
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- defaultAnimationDuration: 400,
- defaultAnimationDelay: 0,
- defaultStaggerAnimationDuration: 300,
- defaultStaggerAnimationDelay: 40,
- defaultStaggerAnimationStartDelay: 500
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().concat([{
- device: function(device) {
- return device.phone
- },
- options: {
- defaultStaggerAnimationDuration: 350,
- defaultStaggerAnimationDelay: 50,
- defaultStaggerAnimationStartDelay: 0
- }
- }, {
- device: function(device) {
- return device.android
- },
- options: {defaultAnimationDelay: 100}
- }])
- },
- _getPresetOptionName: function(animationName) {
- return optionPrefix + animationName
- },
- resetToDefaults: function() {
- this.clear();
- this.registerDefaultPresets();
- this.applyChanges()
- },
- clear: function(name) {
- var that = this,
- newRegisteredPresets = [];
- $.each(this._registeredPresets, function(index, preset) {
- if (!name || name === preset.name)
- that.option(that._getPresetOptionName(preset.name), undefined);
- else
- newRegisteredPresets.push(preset)
- });
- this._registeredPresets = newRegisteredPresets;
- this.applyChanges()
- },
- registerPreset: function(name, config) {
- this._registeredPresets.push({
- name: name,
- config: config
- })
- },
- applyChanges: function() {
- var that = this;
- this._customRules.length = 0;
- $.each(this._registeredPresets, function(index, preset) {
- var rule = {
- device: preset.config.device,
- options: {}
- };
- rule.options[that._getPresetOptionName(preset.name)] = preset.config.animation;
- that._customRules.push(rule)
- });
- this._setOptionsByDevice()
- },
- getPreset: function(name) {
- var result = name;
- while (typeof result === "string")
- result = this.option(this._getPresetOptionName(result));
- return result
- },
- registerDefaultPresets: function() {
- this.registerPreset("fade", {animation: {
- extraCssClasses: "dx-fade-animation",
- delay: this.option("defaultAnimationDelay"),
- duration: this.option("defaultAnimationDuration")
- }});
- this.registerPreset("slide", {animation: {
- extraCssClasses: "dx-slide-animation",
- delay: this.option("defaultAnimationDelay"),
- duration: this.option("defaultAnimationDuration")
- }});
- this.registerPreset("ios7-slide", {animation: {
- extraCssClasses: "dx-ios7-slide-animation",
- delay: this.option("defaultAnimationDelay"),
- duration: this.option("defaultAnimationDuration")
- }});
- this.registerPreset("overflow", {animation: {
- extraCssClasses: "dx-overflow-animation",
- delay: this.option("defaultAnimationDelay"),
- duration: this.option("defaultAnimationDuration")
- }});
- this.registerPreset("ios7-toolbar", {animation: {
- extraCssClasses: "dx-ios7-toolbar-animation",
- delay: this.option("defaultAnimationDelay"),
- duration: this.option("defaultAnimationDuration")
- }});
- this.registerPreset("stagger-fade", {animation: {
- extraCssClasses: "dx-fade-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-slide", {animation: {
- extraCssClasses: "dx-slide-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-fade-slide", {animation: {
- extraCssClasses: "dx-fade-slide-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-drop", {animation: {
- extraCssClasses: "dx-drop-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-fade-drop", {animation: {
- extraCssClasses: "dx-fade-drop-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-3d-drop", {animation: {
- extraCssClasses: "dx-3d-drop-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }});
- this.registerPreset("stagger-fade-zoom", {animation: {
- extraCssClasses: "dx-fade-zoom-animation",
- staggerDelay: this.option("defaultStaggerAnimationDelay"),
- duration: this.option("defaultStaggerAnimationDuration"),
- delay: this.option("defaultStaggerAnimationStartDelay")
- }})
- }
- });
- DX.TransitionExecutor = TransitionExecutor;
- DX.AnimationPresetCollection = AnimationPresetCollection;
- DX.animationPresets = new AnimationPresetCollection
- })(jQuery, DevExpress);
- /*! Module core, file DOMComponent.js */
- (function($, DX, undefined) {
- var windowResizeCallbacks = DX.utils.windowResizeCallbacks;
- var RTL_DIRECTION_CLASS = "dx-rtl",
- COMPONENT_NAMES_DATA_KEY = "dxComponents",
- VISIBILITY_CHANGE_CLASS = "dx-visibility-change-handler",
- VISIBILITY_CHANGE_EVENTNAMESPACE = "dxVisibilityChange";
- var DOMComponent = DX.Component.inherit({
- NAME: "DOMComponent",
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- width: undefined,
- height: undefined,
- rtlEnabled: DX.rtlEnabled
- })
- },
- ctor: function(element, options) {
- this._$element = $(element);
- this.element().data(this.NAME, this);
- this._attachInstanceToElement(this._$element);
- this.callBase(options)
- },
- _attachInstanceToElement: $.noop,
- _visibilityChanged: DX.abstract,
- _dimensionChanged: DX.abstract,
- _init: function() {
- this.callBase();
- this._attachWindowResizeCallback()
- },
- _attachWindowResizeCallback: function() {
- if (this._isDimensionChangeSupported()) {
- var windowResizeCallBack = this._windowResizeCallBack = $.proxy(this._dimensionChanged, this);
- windowResizeCallbacks.add(windowResizeCallBack)
- }
- },
- _isDimensionChangeSupported: function() {
- return this._dimensionChanged !== DX.abstract
- },
- _render: function() {
- this._toggleRTLDirection(this.option("rtlEnabled"));
- this._renderVisibilityChange();
- this._renderDimensions()
- },
- _renderVisibilityChange: function() {
- if (!this._isVisibilityChangeSupported())
- return;
- this.element().addClass(VISIBILITY_CHANGE_CLASS);
- this._attachVisiblityChangeHandlers()
- },
- _renderDimensions: function() {
- var width = this.option("width"),
- height = this.option("height"),
- $element = this.element();
- $element.outerWidth(width);
- $element.outerHeight(height)
- },
- _attachVisiblityChangeHandlers: function() {
- var that = this;
- that.element().off("." + VISIBILITY_CHANGE_EVENTNAMESPACE).on("dxhiding." + VISIBILITY_CHANGE_EVENTNAMESPACE, function() {
- that._visibilityChanged(false)
- }).on("dxshown." + VISIBILITY_CHANGE_EVENTNAMESPACE, function() {
- that._visibilityChanged(true)
- })
- },
- _isVisibilityChangeSupported: function() {
- return this._visibilityChanged !== DX.abstract
- },
- _clean: $.noop,
- _modelByElement: $.noop,
- _invalidate: function() {
- if (!this._updateLockCount)
- throw DX.Error("E0007");
- this._requireRefresh = true
- },
- _refresh: function() {
- this._clean();
- this._render()
- },
- _dispose: function() {
- this.callBase();
- this._clean();
- this._detachWindowResizeCallback()
- },
- _detachWindowResizeCallback: function() {
- if (this._isDimensionChangeSupported())
- windowResizeCallbacks.remove(this._windowResizeCallBack)
- },
- _toggleRTLDirection: function(rtl) {
- this.element().toggleClass(RTL_DIRECTION_CLASS, rtl)
- },
- _createComponent: function(element, name, config) {
- config = config || {};
- this._extendConfig(config, {rtlEnabled: this.option("rtlEnabled")});
- var $element = $(element)[name](config);
- return $element[name]("instance")
- },
- _extendConfig: function(config, extendConfig) {
- $.each(extendConfig, function(key, value) {
- config[key] = config.hasOwnProperty(key) ? config[key] : value
- })
- },
- _defaultActionConfig: function() {
- return $.extend(this.callBase(), {context: this._modelByElement(this.element())})
- },
- _defaultActionArgs: function() {
- var element = this.element(),
- model = this._modelByElement(this.element());
- return $.extend(this.callBase(), {
- element: element,
- model: model
- })
- },
- _optionChanged: function(args) {
- switch (args.name) {
- case"width":
- case"height":
- this._renderDimensions();
- break;
- case"rtlEnabled":
- this._invalidate();
- break;
- default:
- this.callBase(args);
- break
- }
- },
- endUpdate: function() {
- var requireRender = !this._initializing && !this._initialized;
- this.callBase.apply(this, arguments);
- if (!this._updateLockCount)
- if (requireRender)
- this._render();
- else if (this._requireRefresh) {
- this._requireRefresh = false;
- this._refresh()
- }
- },
- element: function() {
- return this._$element
- }
- });
- var registerComponent = function(name, namespace, componentClass) {
- if (!componentClass) {
- componentClass = namespace;
- namespace = DX
- }
- componentClass.redefine({_attachInstanceToElement: function($element) {
- $element.data(name, this);
- if (!$element.data(COMPONENT_NAMES_DATA_KEY))
- $element.data(COMPONENT_NAMES_DATA_KEY, []);
- $element.data(COMPONENT_NAMES_DATA_KEY).push(name)
- }});
- namespace[name] = componentClass;
- componentClass.prototype.NAME = name;
- componentClass.defaultOptions = function(rule) {
- componentClass.prototype._customRules = componentClass.prototype._customRules || [];
- componentClass.prototype._customRules.push(rule)
- };
- $.fn[name] = function(options) {
- var isMemberInvoke = typeof options === "string",
- result;
- if (isMemberInvoke) {
- var memberName = options,
- memberArgs = $.makeArray(arguments).slice(1);
- this.each(function() {
- var instance = $(this).data(name);
- if (!instance)
- throw DX.Error("E0009", name);
- var member = instance[memberName],
- memberValue = member.apply(instance, memberArgs);
- if (result === undefined)
- result = memberValue
- })
- }
- else {
- this.each(function() {
- var instance = $(this).data(name);
- if (instance)
- instance.option(options);
- else
- new componentClass(this, options)
- });
- result = this
- }
- return result
- }
- };
- var getComponents = function(element) {
- element = $(element);
- var names = element.data(COMPONENT_NAMES_DATA_KEY);
- if (!names)
- return [];
- return $.map(names, function(name) {
- return element.data(name)
- })
- };
- var disposeComponents = function() {
- $.each(getComponents(this), function() {
- this._dispose()
- })
- };
- var originalCleanData = $.cleanData;
- $.cleanData = function(element) {
- $.each(element, disposeComponents);
- return originalCleanData.apply(this, arguments)
- };
- registerComponent("DOMComponent", DOMComponent);
- DX.registerComponent = registerComponent
- })(jQuery, DevExpress);
- /*! Module core, file ui.js */
- (function($, DX, undefined) {
- DX.ui = {};
- var createValidatorByTargetElement = function(condition) {
- return function(e) {
- if (!e.args.length)
- return;
- var args = e.args[0],
- element = args[e.validatingTargetName] || args.element;
- if (element && condition(element))
- e.cancel = true
- }
- };
- DX.registerActionExecutor({
- designMode: {validate: function(e) {
- if (DX.designMode)
- e.cancel = true
- }},
- disabled: {validate: createValidatorByTargetElement(function($target) {
- return $target.is(".dx-state-disabled, .dx-state-disabled *")
- })},
- readOnly: {validate: createValidatorByTargetElement(function($target) {
- return $target.is(".dx-state-readonly, .dx-state-readonly *")
- })}
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.templates.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- triggerShownEvent = DX.utils.triggerShownEvent;
- var getWidgetName = function(widgetConstructor) {
- return widgetConstructor.prototype.NAME
- };
- var TemplateProviderBase = DX.Class.inherit({
- ctor: function() {
- this.widgetTemplatesCache = {}
- },
- createTemplate: DX.abstract,
- getTemplates: function(widget) {
- return this._getWidgetTemplates(widget.constructor)
- },
- _getWidgetTemplates: function(widgetConstructor) {
- if (!getWidgetName(widgetConstructor))
- return {};
- return this._getCachedWidgetTemplates(widgetConstructor)
- },
- _getCachedWidgetTemplates: function(widgetConstructor) {
- var widgetName = getWidgetName(widgetConstructor),
- templatesCache = this.widgetTemplatesCache;
- if (!templatesCache[widgetName])
- templatesCache[widgetName] = $.extend({}, this._getWidgetTemplates(widgetConstructor.parent), this._templatesForWidget(widgetName));
- return templatesCache[widgetName]
- },
- _templatesForWidget: DX.abstract
- });
- var TemplateBase = DX.Class.inherit({
- ctor: function(element, owner) {
- this._element = $(element);
- this._owner = owner
- },
- owner: function() {
- return this._owner
- },
- render: function(data, $container, index) {
- if (data instanceof jQuery) {
- $container = data;
- data = undefined
- }
- if ($container)
- data = this._prepareDataForContainer(data, $container);
- var $result = this._renderCore(data, index, $container);
- if (this._shouldAppend && $container) {
- $container.append($result);
- if ($.contains(document.body, $container.get(0)))
- triggerShownEvent($result)
- }
- return $result
- },
- source: function() {
- return this._element.clone()
- },
- _prepareDataForContainer: function(data) {
- return data
- },
- _renderCore: DX.abstract,
- _shouldAppend: true,
- dispose: function() {
- this._owner = null
- }
- });
- $.extend(ui, {
- TemplateProviderBase: TemplateProviderBase,
- TemplateBase: TemplateBase
- })
- })(jQuery, DevExpress);
- /*! Module core, file jquery.templates.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- isString = DX.utils.isString,
- currentTemplateEngine,
- templateEngines = {};
- var Template = ui.TemplateBase.inherit({
- ctor: function(element, owner) {
- this.callBase(element, owner);
- this._compiledTemplate = currentTemplateEngine.compile(element)
- },
- _renderCore: function(data) {
- return $("<div>").append(currentTemplateEngine.render(this._compiledTemplate, data)).contents()
- }
- });
- var setTemplateEngine = function(templateEngine) {
- if (isString(templateEngine)) {
- currentTemplateEngine = templateEngines[templateEngine];
- if (!currentTemplateEngine)
- throw DX.Error("E0020", templateEngine);
- }
- else
- currentTemplateEngine = templateEngine
- };
- var registerTemplateEngine = function(name, templateEngine) {
- templateEngines[name] = templateEngine
- };
- var outerHtml = function(element) {
- element = $(element);
- if (!element.length || element[0].nodeName.toLowerCase() !== "script")
- element = $("<div>").append(element);
- return element.html()
- };
- registerTemplateEngine("default", {
- compile: function(element) {
- return DX.utils.normalizeTemplateElement(element)
- },
- render: function(template, data) {
- return template.clone()
- }
- });
- registerTemplateEngine("jquery-tmpl", {
- compile: function(element) {
- return $("<div>").append(DX.utils.normalizeTemplateElement(element))
- },
- render: function(template, data) {
- return template.tmpl(data)
- }
- });
- registerTemplateEngine("jsrender", {
- compile: function(element) {
- return $.templates(outerHtml(element))
- },
- render: function(template, data) {
- return template.render(data)
- }
- });
- registerTemplateEngine("mustache", {
- compile: function(element) {
- return Mustache.compile(outerHtml(element))
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("hogan", {
- compile: function(element) {
- return Hogan.compile(outerHtml(element))
- },
- render: function(template, data) {
- return template.render(data)
- }
- });
- registerTemplateEngine("underscore", {
- compile: function(element) {
- return _.template(outerHtml(element))
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("handlebars", {
- compile: function(element) {
- return Handlebars.compile(outerHtml(element))
- },
- render: function(template, data) {
- return template(data)
- }
- });
- registerTemplateEngine("doT", {
- compile: function(element) {
- return doT.template(outerHtml(element))
- },
- render: function(template, data) {
- return template(data)
- }
- });
- setTemplateEngine("default");
- var DefaultTemplate = ui.TemplateBase.inherit({
- ctor: function(render, owner) {
- this.callBase($("<div>"), owner);
- this._render = render
- },
- _renderCore: function(data, index, container) {
- return DX.utils.normalizeTemplateElement(this._render(data, index, container))
- }
- });
- var TemplateProvider = new(ui.TemplateProviderBase.inherit({
- createTemplate: function(element, owner) {
- return new ui.Template(element, owner)
- },
- _templatesForWidget: function(widgetName) {
- var templateGenerators = TEMPLATE_GENERATORS[widgetName] || {},
- templates = {};
- $.each(templateGenerators, function(name, generator) {
- templates[name] = new ui.DefaultTemplate(function() {
- var $markup = generator.apply(this, arguments);
- if (name !== "itemFrame")
- $markup = $markup.contents();
- return $markup
- }, TemplateProvider)
- });
- return templates
- }
- }));
- var TEMPLATE_GENERATORS = {};
- var emptyTemplate = function() {
- return $()
- };
- var ITEM_CONTENT_PLACEHOLDER_CLASS = "dx-item-content-placeholder";
- TEMPLATE_GENERATORS.CollectionWidget = {
- item: function(itemData) {
- var $itemContent = $("<div>");
- if ($.isPlainObject(itemData)) {
- if (itemData.text)
- $itemContent.text(itemData.text);
- if (itemData.html)
- $itemContent.html(itemData.html)
- }
- else
- $itemContent.html(String(itemData));
- return $itemContent
- },
- itemFrame: function(itemData) {
- var $itemFrame = $("<div>");
- $itemFrame.toggleClass("dx-state-invisible", itemData.visible !== undefined && !itemData.visible);
- $itemFrame.toggleClass("dx-state-disabled", !!itemData.disabled);
- var $placeholder = $("<div>").addClass(ITEM_CONTENT_PLACEHOLDER_CLASS);
- $itemFrame.append($placeholder);
- return $itemFrame
- }
- };
- var BUTTON_TEXT_CLASS = "dx-button-text";
- TEMPLATE_GENERATORS.dxButton = {content: function(itemData) {
- var $itemContent = $("<div>"),
- $iconElement = utils.getImageContainer(itemData.icon),
- $textContainer = itemData.text ? $("<span>").text(itemData.text).addClass(BUTTON_TEXT_CLASS) : undefined;
- $itemContent.append($iconElement).append($textContainer);
- return $itemContent
- }};
- var LIST_ITEM_BADGE_CONTAINER_CLASS = "dx-list-item-badge-container",
- LIST_ITEM_BADGE_CLASS = "dx-list-item-badge",
- BADGE_CLASS = "dx-badge",
- LIST_ITEM_CHEVRON_CONTAINER_CLASS = "dx-list-item-chevron-container",
- LIST_ITEM_CHEVRON_CLASS = "dx-list-item-chevron";
- TEMPLATE_GENERATORS.dxList = {
- item: function(itemData) {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.item(itemData);
- if (itemData.key) {
- var $key = $("<div>").text(itemData.key);
- $key.appendTo($itemContent)
- }
- return $itemContent
- },
- itemFrame: function(itemData) {
- var $itemFrame = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(itemData);
- if (itemData.badge) {
- var $badgeContainer = $("<div>").addClass(LIST_ITEM_BADGE_CONTAINER_CLASS),
- $badge = $("<div>").addClass(LIST_ITEM_BADGE_CLASS).addClass(BADGE_CLASS);
- $badge.text(itemData.badge);
- $badgeContainer.append($badge).appendTo($itemFrame)
- }
- if (itemData.showChevron) {
- var $chevronContainer = $("<div>").addClass(LIST_ITEM_CHEVRON_CONTAINER_CLASS),
- $chevron = $("<div>").addClass(LIST_ITEM_CHEVRON_CLASS);
- $chevronContainer.append($chevron).appendTo($itemFrame)
- }
- return $itemFrame
- },
- group: function(groupData) {
- var $groupContent = $("<div>");
- if ($.isPlainObject(groupData)) {
- if (groupData.key)
- $groupContent.text(groupData.key)
- }
- else
- $groupContent.html(String(groupData));
- return $groupContent
- }
- };
- TEMPLATE_GENERATORS.dxDropDownMenu = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxDropDownList = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxRadioGroup = {item: TEMPLATE_GENERATORS.CollectionWidget.item};
- TEMPLATE_GENERATORS.dxScheduler = {item: function(itemData) {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.item(itemData);
- var $details = $("<div>").addClass("dx-scheduler-appointment-content-details");
- if (itemData.startDate)
- $("<strong>").text(Globalize.format(DX.utils.makeDate(itemData.startDate), "t")).appendTo($details);
- if (itemData.endDate)
- $("<strong>").text(" - " + Globalize.format(DX.utils.makeDate(itemData.endDate), "t")).appendTo($details);
- $details.appendTo($itemContent);
- if (itemData.recurrenceRule)
- $("<span>").addClass("dx-scheduler-appointment-recurrence-icon").appendTo($itemContent);
- return $itemContent
- }};
- TEMPLATE_GENERATORS.dxOverlay = {content: emptyTemplate};
- TEMPLATE_GENERATORS.dxSlideOutView = {
- menu: emptyTemplate,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxSlideOut = {
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- menuGroup: TEMPLATE_GENERATORS.dxList.group,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxAccordion = {
- title: function(titleData) {
- var $titleContent = $("<div>"),
- icon = titleData.icon,
- iconSrc = titleData.iconSrc,
- $iconElement = utils.getImageContainer(icon || iconSrc);
- if ($.isPlainObject(titleData)) {
- if (titleData.title)
- $titleContent.text(titleData.title)
- }
- else
- $titleContent.html(String(titleData));
- $iconElement && $iconElement.prependTo($titleContent);
- return $titleContent
- },
- item: TEMPLATE_GENERATORS.CollectionWidget.item
- };
- TEMPLATE_GENERATORS.dxActionSheet = {item: function(itemData) {
- return $("<div>").append($("<div>").dxButton($.extend({onClick: itemData.click}, itemData)))
- }};
- TEMPLATE_GENERATORS.dxGallery = {item: function(itemData) {
- var $itemContent = $("<div>");
- if (itemData.imageSrc)
- $('<img>').attr('src', itemData.imageSrc).appendTo($itemContent);
- else
- $('<img>').attr('src', String(itemData)).appendTo($itemContent);
- return $itemContent
- }};
- var DX_MENU_ITEM_CAPTION_CLASS = 'dx-menu-item-text',
- DX_MENU_ITEM_POPOUT_CLASS = 'dx-menu-item-popout',
- DX_MENU_ITEM_POPOUT_CONTAINER_CLASS = 'dx-menu-item-popout-container';
- TEMPLATE_GENERATORS.dxMenuBase = {item: function(itemData) {
- var $itemContent = $("<div>"),
- icon = itemData.icon,
- iconSrc = itemData.iconSrc,
- $iconElement = utils.getImageContainer(icon || iconSrc);
- $iconElement && $iconElement.appendTo($itemContent);
- var $itemCaption;
- if ($.isPlainObject(itemData) && itemData.text)
- $itemCaption = $('<span>').addClass(DX_MENU_ITEM_CAPTION_CLASS).text(itemData.text);
- else if (!$.isPlainObject(itemData))
- $itemCaption = $('<span>').addClass(DX_MENU_ITEM_CAPTION_CLASS).html(String(itemData));
- $itemContent.append($itemCaption);
- var $popOutImage,
- $popOutContainer;
- if (itemData.items && itemData.items.length > 0) {
- $popOutContainer = $('<span>').addClass(DX_MENU_ITEM_POPOUT_CONTAINER_CLASS).appendTo($itemContent);
- $popOutImage = $('<div>').addClass(DX_MENU_ITEM_POPOUT_CLASS).appendTo($popOutContainer)
- }
- return $itemContent
- }};
- var PANORAMA_ITEM_TITLE_CLASS = "dx-panorama-item-title";
- TEMPLATE_GENERATORS.dxPanorama = {itemFrame: function(itemData) {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(itemData);
- if (itemData.title) {
- var $itemHeader = $("<div>").addClass(PANORAMA_ITEM_TITLE_CLASS).text(itemData.title);
- $itemContent.prepend($itemHeader)
- }
- return $itemContent
- }};
- TEMPLATE_GENERATORS.dxPivotTabs = {item: function(itemData) {
- var $itemContent = $("<div>");
- var $itemText;
- if ($.isPlainObject(itemData))
- $itemText = $("<span>").text(itemData.title);
- else
- $itemText = $("<span>").text(String(itemData));
- $itemContent.html($itemText);
- return $itemContent
- }};
- TEMPLATE_GENERATORS.dxPivot = {
- title: TEMPLATE_GENERATORS.dxPivotTabs.item,
- content: emptyTemplate
- };
- var TABS_ITEM_TEXT_CLASS = "dx-tab-text";
- TEMPLATE_GENERATORS.dxTabs = {
- item: function(itemData) {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.item(itemData);
- if (itemData.html)
- return $itemContent;
- var icon = itemData.icon,
- iconSrc = itemData.iconSrc,
- $iconElement = utils.getImageContainer(icon || iconSrc);
- if (!itemData.html)
- $itemContent.wrapInner($("<span>").addClass(TABS_ITEM_TEXT_CLASS));
- $iconElement && $iconElement.prependTo($itemContent);
- return $itemContent
- },
- itemFrame: function(itemData) {
- var $badge = $(),
- $itemFrame = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(itemData);
- if (itemData.badge)
- $badge = $("<div>", {"class": "dx-tabs-item-badge dx-badge"}).text(itemData.badge);
- $itemFrame.append($badge);
- return $itemFrame
- }
- };
- TEMPLATE_GENERATORS.dxTabPanel = {
- item: TEMPLATE_GENERATORS.CollectionWidget.item,
- title: function(itemData) {
- var itemTitleData = itemData;
- if ($.isPlainObject(itemData))
- itemTitleData = $.extend({}, itemData, {text: itemData.title});
- var $title = TEMPLATE_GENERATORS.dxTabs.item(itemTitleData);
- return $title
- }
- };
- var NAVBAR_ITEM_BADGE_CLASS = "dx-navbar-item-badge";
- TEMPLATE_GENERATORS.dxNavBar = {itemFrame: function(itemData) {
- var $itemFrame = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(itemData);
- if (itemData.badge) {
- var $badge = $("<div>").addClass(NAVBAR_ITEM_BADGE_CLASS).addClass(BADGE_CLASS);
- $badge.text(itemData.badge);
- $badge.appendTo($itemFrame)
- }
- return $itemFrame
- }};
- TEMPLATE_GENERATORS.dxToolbar = {
- item: function(itemData) {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.item(itemData);
- var widget = itemData.widget;
- if (widget) {
- var widgetElement = $("<div>").appendTo($itemContent),
- widgetName = DX.inflector.camelize("dx-" + widget),
- options = itemData.options || {};
- widgetElement[widgetName](options)
- }
- else if (itemData.text)
- $itemContent.wrapInner("<div>");
- return $itemContent
- },
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- actionSheetItem: TEMPLATE_GENERATORS.dxActionSheet.item
- };
- TEMPLATE_GENERATORS.dxTreeView = {item: function(itemData) {
- var $itemContent = $("<div>"),
- icon = itemData.icon,
- iconSrc = itemData.iconSrc,
- $iconElement = utils.getImageContainer(icon || iconSrc);
- if (itemData.html)
- $itemContent.html(itemData.html);
- else {
- $iconElement && $iconElement.appendTo($itemContent);
- $("<span>").text(itemData.text).appendTo($itemContent)
- }
- return $itemContent
- }};
- var popupTitleAndBottom = function(itemData) {
- return $("<div>").append($("<div>").dxToolbar({items: itemData}))
- };
- TEMPLATE_GENERATORS.dxPopup = {
- title: popupTitleAndBottom,
- bottom: popupTitleAndBottom
- };
- TEMPLATE_GENERATORS.dxLookup = {
- title: TEMPLATE_GENERATORS.dxPopup.title,
- group: TEMPLATE_GENERATORS.dxList.group
- };
- TEMPLATE_GENERATORS.dxTagBox = {tag: function(itemData) {
- return $("<div>").append($("<span>").text(itemData))
- }};
- TEMPLATE_GENERATORS.dxCalendar = {cell: function(itemData) {
- return $("<div>").text(itemData.text || String(itemData))
- }};
- $.extend(ui, {
- TemplateProvider: TemplateProvider,
- Template: Template,
- DefaultTemplate: DefaultTemplate,
- setTemplateEngine: setTemplateEngine
- })
- })(jQuery, DevExpress);
- /*! Module core, file ko.components.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- ui = DX.ui,
- LOCKS_DATA_KEY = "dxKoLocks",
- CREATED_WITH_KO_DATA_KEY = "dxKoCreation";
- var Locks = function() {
- var info = {};
- var currentCount = function(lockName) {
- return info[lockName] || 0
- };
- return {
- obtain: function(lockName) {
- info[lockName] = currentCount(lockName) + 1
- },
- release: function(lockName) {
- var count = currentCount(lockName);
- if (count < 1)
- throw DX.Error("E0014");
- if (count === 1)
- delete info[lockName];
- else
- info[lockName] = count - 1
- },
- locked: function(lockName) {
- return currentCount(lockName) > 0
- }
- }
- };
- var editorsBingindHandlers = [];
- var registerComponentKoBinding = function(componentName, componentClass) {
- if (componentClass.subclassOf(ui.Editor))
- editorsBingindHandlers.push(componentName);
- ko.bindingHandlers[componentName] = {init: function(domNode, valueAccessor) {
- var $element = $(domNode),
- optionChangedCallbacks = $.Callbacks(),
- ctorOptions = {
- templateProvider: ui.KoTemplateProvider,
- _optionChangedCallbacks: optionChangedCallbacks
- },
- optionNameToModelMap = {};
- var applyModelValueToOption = function(optionName, modelValue) {
- var component = $element.data(componentName),
- locks = $element.data(LOCKS_DATA_KEY),
- optionValue = ko.unwrap(modelValue);
- if (ko.isWriteableObservable(modelValue))
- optionNameToModelMap[optionName] = modelValue;
- if (component) {
- if (locks.locked(optionName))
- return;
- locks.obtain(optionName);
- try {
- component.option(optionName, optionValue)
- }
- finally {
- locks.release(optionName)
- }
- }
- else
- ctorOptions[optionName] = optionValue
- };
- var handleOptionChanged = function(args) {
- var optionName = args.fullName,
- optionValue = args.value;
- if (!(optionName in optionNameToModelMap))
- return;
- var $element = this._$element,
- locks = $element.data(LOCKS_DATA_KEY);
- if (locks.locked(optionName))
- return;
- locks.obtain(optionName);
- try {
- optionNameToModelMap[optionName](optionValue)
- }
- finally {
- locks.release(optionName)
- }
- };
- var createComponent = function() {
- optionChangedCallbacks.add(handleOptionChanged);
- $element.data(CREATED_WITH_KO_DATA_KEY, true).data(LOCKS_DATA_KEY, new Locks)[componentName](ctorOptions);
- ctorOptions = null
- };
- var unwrapModelValue = function(option, model) {
- var modelUnwrapped;
- ko.computed(function() {
- applyModelValueToOption(option, model);
- modelUnwrapped = ko.unwrap(model)
- }, null, {disposeWhenNodeIsRemoved: domNode});
- if ($.isPlainObject(modelUnwrapped))
- $.each(modelUnwrapped, function(optionName, modelValue) {
- unwrapModelValue(option + "." + optionName, modelValue)
- })
- };
- ko.computed(function() {
- var component = $element.data(componentName);
- if (component)
- component.beginUpdate();
- $.each(ko.unwrap(valueAccessor()), function(optionName, modelValue) {
- unwrapModelValue(optionName, modelValue)
- });
- if (component)
- component.endUpdate();
- else
- createComponent()
- }, null, {disposeWhenNodeIsRemoved: domNode});
- return {controlsDescendantBindings: componentClass.subclassOf(ui.Widget)}
- }};
- if (componentName === "dxValidator")
- ko.bindingHandlers["dxValidator"].after = editorsBingindHandlers
- };
- DX.DOMComponent.redefine({_modelByElement: function(element) {
- if (element.length)
- return ko.dataFor(element.get(0))
- }});
- var originalRegisterComponent = DX.registerComponent;
- var registerKoComponent = function(componentName, _, componentClass) {
- componentClass = componentClass || _;
- originalRegisterComponent.apply(this, arguments);
- registerComponentKoBinding(componentName, componentClass)
- };
- DX.registerComponent = registerKoComponent;
- var cleanKoData = function(element, andSelf) {
- var cleanNode = function() {
- ko.cleanNode(this)
- };
- if (andSelf)
- element.each(cleanNode);
- else
- element.find("*").each(cleanNode)
- };
- var originalEmpty = $.fn.empty;
- $.fn.empty = function() {
- cleanKoData(this, false);
- return originalEmpty.apply(this, arguments)
- };
- var originalRemove = $.fn.remove;
- $.fn.remove = function(selector, keepData) {
- if (!keepData) {
- var subject = this;
- if (selector)
- subject = subject.filter(selector);
- cleanKoData(subject, true)
- }
- return originalRemove.call(this, selector, keepData)
- };
- var originalHtml = $.fn.html;
- $.fn.html = function(value) {
- if (typeof value === "string")
- cleanKoData(this, false);
- return originalHtml.apply(this, arguments)
- };
- ko.bindingHandlers.dxAction = {update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
- var $element = $(element);
- var unwrappedValue = ko.utils.unwrapObservable(valueAccessor()),
- actionSource = unwrappedValue,
- actionOptions = {context: element};
- if (unwrappedValue.execute) {
- actionSource = unwrappedValue.execute;
- $.extend(actionOptions, unwrappedValue)
- }
- var action = new DX.Action(actionSource, actionOptions);
- $element.off(".dxActionBinding").on("dxclick.dxActionBinding", function(e) {
- action.execute({
- element: $element,
- model: viewModel,
- evaluate: function(expression) {
- var context = viewModel;
- if (expression.length > 0 && expression[0] === "$")
- context = ko.contextFor(element);
- var getter = DX.data.utils.compileGetter(expression);
- return getter(context)
- },
- jQueryEvent: e
- });
- if (!actionOptions.bubbling)
- e.stopPropagation()
- })
- }};
- ko.bindingHandlers.dxControlsDescendantBindings = {init: function(_, valueAccessor) {
- return {controlsDescendantBindings: ko.unwrap(valueAccessor())}
- }};
- var render = function($element, options, viewModel, bindingContext) {
- var result = $.Deferred();
- $element.removeClass("dx-pending-rendering-manual");
- $element.addClass("dx-pending-rendering-active");
- if (options.showLoadIndicator && options.showLoadIndicatorImmediately !== true)
- showLoadIndicator($element);
- DX.utils.executeAsync(function() {
- renderImpl($element, options, viewModel, bindingContext).done(function() {
- var shownArgs = {element: $element};
- if (options.onShown)
- options.onShown.apply(viewModel, [shownArgs]);
- result.resolve(shownArgs)
- }).fail(function() {
- result.rejectWith(result, arguments)
- })
- });
- return result.promise()
- };
- var showLoadIndicator = function($container) {
- var $indicator = $('<div/>').dxLoadIndicator({visible: true}).addClass("dx-defered-rendering-load-indicator");
- $container.append($indicator)
- };
- var isElementInViewport = function(element) {
- var rect = element.getBoundingClientRect();
- return rect.bottom >= 0 && rect.right >= 0 && rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.left <= (window.innerWidth || document.documentElement.clientWidth)
- };
- var renderImpl = function($element, options, viewModel, bindingContext) {
- var animatePromise,
- childBindingContext = bindingContext.createChildContext(viewModel),
- renderedArgs = {element: $element};
- $element.find(".dx-defered-rendering-load-indicator").remove();
- ko.applyBindingsToDescendants(childBindingContext, $element[0]);
- options._renderedDeferred.resolve(renderedArgs);
- if (options.onRendered)
- options.onRendered.apply(viewModel, [renderedArgs]);
- $element.children().removeClass("dx-invisible-while-pending-rendering");
- DX.utils.triggerShownEvent($element.children());
- $element.removeClass("dx-pending-rendering");
- $element.removeClass("dx-pending-rendering-active");
- if (options.animation) {
- var transitionExecutor = new DX.TransitionExecutor;
- if (options.staggerItemSelector) {
- $element.find(options.staggerItemSelector).each(function() {
- if (isElementInViewport(this))
- transitionExecutor.enter($(this), options.animation)
- });
- animatePromise = $.when(animatePromise, transitionExecutor.start())
- }
- else {
- transitionExecutor.enter($element, options.animation || "content-rendered");
- animatePromise = transitionExecutor.start()
- }
- }
- else
- animatePromise = $.Deferred().resolve().promise();
- return animatePromise
- };
- var initElement = function($element, options) {
- $element.addClass("dx-defer-rendering dx-pending-rendering dx-loadindicator-container");
- $element.data("dx-rendered-promise", options._renderedDeferred.promise());
- if (options.hiddenUntilRendered)
- $element.children().addClass("dx-invisible-while-pending-rendering");
- if (options.showLoadIndicator && options.showLoadIndicatorImmediately)
- showLoadIndicator($element)
- };
- var initRender = function($element, options, viewModel, bindingContext) {
- var doRender = function() {
- return render($element, options, viewModel, bindingContext)
- };
- if (options.renderWhen)
- options.renderWhen.done(doRender);
- else {
- $element.data("dx-render-delegate", doRender);
- $element.addClass("dx-pending-rendering-manual")
- }
- };
- ko.bindingHandlers.dxDeferRendering = {init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
- var $element = $(element),
- passedOptions = ko.unwrap(valueAccessor()),
- showLoadIndicatorImmediately = ko.unwrap(passedOptions.showLoadIndicatorImmediately),
- hiddenUntilRendered = ko.unwrap(passedOptions.hiddenUntilRendered),
- options = {
- showLoadIndicator: ko.unwrap(passedOptions.showLoadIndicator) || false,
- showLoadIndicatorImmediately: showLoadIndicatorImmediately !== undefined ? showLoadIndicatorImmediately : true,
- hiddenUntilRendered: hiddenUntilRendered !== undefined ? hiddenUntilRendered : true,
- renderWhen: ko.unwrap(passedOptions.renderWhen),
- animation: ko.unwrap(passedOptions.animation),
- staggerItemSelector: ko.unwrap(passedOptions.staggerItemSelector),
- onRendered: ko.unwrap(passedOptions.onRendered),
- onShown: ko.unwrap(passedOptions.onShown),
- _renderedDeferred: $.Deferred()
- };
- initElement($element, options);
- initRender($element, options, viewModel, bindingContext);
- return {controlsDescendantBindings: true}
- }};
- ko.bindingHandlers.dxIcon = {
- init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
- var options = ko.utils.unwrapObservable(valueAccessor()) || {},
- iconElement = DevExpress.utils.getImageContainer(options);
- ko.virtualElements.emptyNode(element);
- if (iconElement)
- ko.virtualElements.prepend(element, iconElement.get(0))
- },
- update: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
- var options = ko.utils.unwrapObservable(valueAccessor()) || {},
- iconElement = DevExpress.utils.getImageContainer(options);
- ko.virtualElements.emptyNode(element);
- if (iconElement)
- ko.virtualElements.prepend(element, iconElement.get(0))
- }
- };
- ko.virtualElements.allowedBindings.dxIcon = true
- })(jQuery, DevExpress);
- /*! Module core, file ng.components.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var ui = DX.ui,
- compileSetter = DX.data.utils.compileSetter,
- compileGetter = DX.data.utils.compileGetter;
- var ITEM_ALIAS_ATTRIBUTE_NAME = "dxItemAlias",
- DEFAULT_MODEL_ALIAS = "scopeValue";
- var SKIP_APPLY_ACTION_CATEGORIES = ["rendering"];
- var phoneJsModule = DX.ng.module;
- var safeApply = function(func, scope) {
- if (scope.$root.$$phase)
- func(scope);
- else
- scope.$apply(function() {
- func(scope)
- })
- };
- var ComponentBuilder = DX.Class.inherit({
- ctor: function(options) {
- this._$element = options.$element;
- this._$templates = options.$templates;
- this._componentClass = options.componentClass;
- this._scope = options.scope;
- this._parse = options.parse;
- this._compile = options.compile;
- this._ngOptions = this._normalizeOptions(options.ngOptions);
- this._itemAlias = options.itemAlias;
- this._componentDisposing = $.Callbacks();
- if (options.ngOptions.data)
- this._initDataScope(options.ngOptions.data)
- },
- _normalizeOptions: function(options) {
- var result = $.extend({}, options);
- if (options.bindingOptions)
- $.each(options.bindingOptions, function(key, value) {
- if ($.type(value) === 'string')
- result.bindingOptions[key] = {dataPath: value}
- });
- return result
- },
- initComponentWithBindings: function() {
- this._initComponentBindings();
- this._initComponent(this._scope);
- this._shownEventTimer = setTimeout($.proxy(function() {
- DX.utils.triggerShownEvent(this._$element)
- }, this))
- },
- _initDataScope: function(data) {
- if (typeof data === "string") {
- var dataStr = data,
- rootScope = this._scope;
- data = rootScope.$eval(data);
- this._scope = rootScope.$new();
- this._synchronizeDataScopes(rootScope, this._scope, data, dataStr)
- }
- $.extend(this._scope, data)
- },
- _synchronizeDataScopes: function(parentScope, childScope, data, parentPrefix) {
- var that = this;
- $.each(data, function(fieldPath) {
- that._synchronizeScopeField({
- parentScope: parentScope,
- childScope: childScope,
- fieldPath: fieldPath,
- parentPrefix: parentPrefix
- })
- })
- },
- _initComponent: function(scope) {
- this._component = new this._componentClass(this._$element, this._evalOptions(scope))
- },
- _initComponentBindings: function() {
- var that = this,
- optionDependencies = {};
- that._disposingCallbacks = $.Callbacks();
- if (that._ngOptions.bindingOptions)
- $.each(that._ngOptions.bindingOptions, function(optionPath, value) {
- var separatorIndex = optionPath.search(/\[|\./),
- optionForSubscribe = separatorIndex > -1 ? optionPath.substring(0, separatorIndex) : optionPath,
- prevWatchMethod,
- clearWatcher,
- valuePath = value.dataPath,
- deepWatch = true,
- forcePlainWatchMethod = false;
- if (value.deep !== undefined)
- forcePlainWatchMethod = deepWatch = !!value.deep;
- if (!optionDependencies[optionForSubscribe])
- optionDependencies[optionForSubscribe] = {};
- optionDependencies[optionForSubscribe][optionPath] = valuePath;
- var watchCallback = function(newValue, oldValue) {
- if (newValue !== oldValue) {
- that._component.option(optionPath, newValue);
- updateWatcher()
- }
- };
- var updateWatcher = function() {
- var watchMethod = $.isArray(that._scope.$eval(valuePath)) && !forcePlainWatchMethod ? "$watchCollection" : "$watch";
- if (prevWatchMethod !== watchMethod) {
- if (clearWatcher)
- clearWatcher();
- clearWatcher = that._scope[watchMethod](valuePath, watchCallback, deepWatch);
- prevWatchMethod = watchMethod
- }
- };
- updateWatcher();
- that._disposingCallbacks.add(function() {
- clearWatcher();
- that._componentDisposing.fire()
- })
- });
- that._optionChangedCallbacks = $.Callbacks().add(function(args) {
- var optionName = args.name,
- optionValue = args.value;
- if (that._scope.$root.$$phase === "$digest" || !optionDependencies || !optionDependencies[optionName])
- return;
- safeApply(function(scope) {
- $.each(optionDependencies[optionName], function(optionPath, valuePath) {
- var getter = compileGetter(optionPath);
- var tmpData = {};
- tmpData[optionName] = optionValue;
- that._parse(valuePath).assign(that._scope, getter(tmpData))
- })
- }, that._scope)
- });
- that._disposingCallbacks.add(function() {
- clearTimeout(that._shownEventTimer)
- })
- },
- _compilerByTemplate: function(template) {
- var that = this,
- scopeItemsPath = this._getScopeItemsPath();
- return function(data, index) {
- var $resultMarkup = $(template).clone(),
- templateScope;
- if (data !== undefined) {
- var dataIsScope = data.$id;
- templateScope = dataIsScope ? data : that._createScopeWithData(data);
- $resultMarkup.on("$destroy", function() {
- var destroyAlreadyCalled = !templateScope.$parent;
- if (destroyAlreadyCalled)
- return;
- templateScope.$destroy()
- })
- }
- else
- templateScope = that._scope;
- if (scopeItemsPath)
- that._synchronizeScopes(templateScope, scopeItemsPath, index);
- safeApply(that._compile($resultMarkup), templateScope);
- return $resultMarkup
- }
- },
- _getScopeItemsPath: function() {
- if (this._componentClass.subclassOf(ui.CollectionWidget) && this._ngOptions.bindingOptions && this._ngOptions.bindingOptions.items)
- return this._ngOptions.bindingOptions.items.dataPath
- },
- _createScopeWithData: function(data) {
- var newScope = this._scope.$new(true);
- data = this._enshureDataIsPlainObject(data);
- $.extend(newScope, data);
- return newScope
- },
- _synchronizeScopes: function(itemScope, parentPrefix, itemIndex) {
- var that = this,
- item = compileGetter(parentPrefix + "[" + itemIndex + "]")(this._scope);
- item = that._enshureDataIsPlainObject(item);
- $.each(item, function(itemPath) {
- that._synchronizeScopeField({
- parentScope: that._scope,
- childScope: itemScope,
- fieldPath: itemPath,
- parentPrefix: parentPrefix,
- itemIndex: itemIndex
- })
- })
- },
- _synchronizeScopeField: function(args) {
- var parentScope = args.parentScope,
- childScope = args.childScope,
- fieldPath = args.fieldPath,
- parentPrefix = args.parentPrefix,
- itemIndex = args.itemIndex;
- var innerPathSuffix = fieldPath === (this._itemAlias || DEFAULT_MODEL_ALIAS) ? "" : "." + fieldPath,
- collectionField = itemIndex !== undefined,
- optionOuterBag = [parentPrefix],
- optionOuterPath;
- if (collectionField)
- optionOuterBag.push("[", itemIndex, "]");
- optionOuterBag.push(innerPathSuffix);
- optionOuterPath = optionOuterBag.join("");
- var clearParentWatcher = parentScope.$watch(optionOuterPath, function(newValue, oldValue) {
- if (newValue !== oldValue)
- compileSetter(fieldPath)(childScope, newValue)
- });
- var clearItemWatcher = childScope.$watch(fieldPath, function(newValue, oldValue) {
- if (newValue !== oldValue) {
- if (collectionField && !compileGetter(parentPrefix)(parentScope)[itemIndex]) {
- clearItemWatcher();
- return
- }
- compileSetter(optionOuterPath)(parentScope, newValue)
- }
- });
- this._componentDisposing.add([clearParentWatcher, clearItemWatcher])
- },
- _evalOptions: function(scope) {
- var result = $.extend({}, this._ngOptions);
- delete result.data;
- delete result.bindingOptions;
- if (this._ngOptions.bindingOptions)
- $.each(this._ngOptions.bindingOptions, function(key, value) {
- result[key] = scope.$eval(value.dataPath)
- });
- result._optionChangedCallbacks = this._optionChangedCallbacks;
- result._disposingCallbacks = this._disposingCallbacks;
- result.templateProvider = ui.NgTemplateProvider;
- result.templateCompiler = $.proxy(function($template) {
- return this._compilerByTemplate($template)
- }, this);
- return result
- },
- _enshureDataIsPlainObject: function(object) {
- var result;
- if ($.isPlainObject(object))
- result = object;
- else {
- result = {};
- result[DEFAULT_MODEL_ALIAS] = object
- }
- if (this._itemAlias)
- result[this._itemAlias] = object;
- return result
- }
- });
- ComponentBuilder = ComponentBuilder.inherit({
- ctor: function(options) {
- this.callBase.apply(this, arguments);
- this._componentName = options.componentName;
- this._ngModel = options.ngModel;
- this._ngModelController = options.ngModelController
- },
- _isNgModelRequired: function() {
- return this._componentClass.subclassOf(ui.Editor) && this._ngModel
- },
- _initComponentBindings: function() {
- this.callBase.apply(this, arguments);
- this._initNgModelBinding()
- },
- _initNgModelBinding: function() {
- if (!this._isNgModelRequired())
- return;
- var that = this;
- var ngModelWatcher = this._scope.$watch(this._ngModel, function(newValue, oldValue) {
- if (newValue === oldValue)
- return;
- that._component.option(that._ngModelOption(), newValue)
- });
- that._optionChangedCallbacks.add(function(args) {
- if (args.name !== that._ngModelOption())
- return;
- that._ngModelController.$setViewValue(args.value)
- });
- this._disposingCallbacks.add(function() {
- ngModelWatcher()
- })
- },
- _ngModelOption: function() {
- if ($.inArray(this._componentName, ["dxFileUploader", "dxTagBox"]) > -1)
- return "values";
- return "value"
- },
- _evalOptions: function() {
- if (!this._isNgModelRequired())
- return this.callBase.apply(this, arguments);
- var result = this.callBase.apply(this, arguments);
- result[this._ngModelOption()] = this._parse(this._ngModel)(this._scope);
- return result
- }
- });
- var NgComponent = DX.DOMComponent.inherit({
- _modelByElement: function(element) {
- if (element.length)
- return element.scope()
- },
- _createActionByOption: function(optionName, config) {
- var action = this.callBase.apply(this, arguments);
- if (config && $.inArray(config.category, SKIP_APPLY_ACTION_CATEGORIES) > -1)
- return action;
- var component = this,
- wrappedAction = function() {
- var that = this,
- scope = component._modelByElement(component.element()),
- args = arguments;
- if (!scope || !scope.$root || scope.$root.$$phase)
- return action.apply(that, args);
- return scope.$apply(function() {
- return action.apply(that, args)
- })
- };
- return wrappedAction
- },
- _createComponent: function(element, name, config) {
- return this.callBase(element, name, $.extend({templateCompiler: this.option("templateCompiler")}, config))
- }
- });
- var registeredComponents = {};
- var originalRegisterComponent = DX.registerComponent;
- var registerNgComponent = function(componentName, _, componentClass) {
- componentClass = componentClass || _;
- originalRegisterComponent.apply(this, arguments);
- if (!registeredComponents[componentName])
- registerComponentDirective(componentName);
- registeredComponents[componentName] = componentClass
- };
- var registerComponentDirective = function(componentName) {
- var priority = componentName !== "dxValidator" ? 1 : 10;
- phoneJsModule.directive(componentName, ["$compile", "$parse", function($compile, $parse) {
- return {
- restrict: "A",
- require: "^?ngModel",
- priority: priority,
- compile: function($element) {
- var componentClass = registeredComponents[componentName],
- $content = componentClass.subclassOf(ui.Widget) ? $element.contents().detach() : null;
- return function(scope, $element, attrs, ngModelController) {
- $element.append($content);
- var componentBuilder = new ComponentBuilder({
- componentClass: componentClass,
- componentName: componentName,
- compile: $compile,
- parse: $parse,
- $element: $element,
- scope: scope,
- ngOptions: attrs[componentName] ? scope.$eval(attrs[componentName]) : {},
- ngModel: attrs.ngModel,
- ngModelController: ngModelController,
- itemAlias: attrs[ITEM_ALIAS_ATTRIBUTE_NAME]
- });
- componentBuilder.initComponentWithBindings()
- }
- }
- }
- }])
- };
- phoneJsModule.filter('dxGlobalize', function() {
- return function(input, param) {
- return Globalize.format(input, param)
- }
- });
- phoneJsModule.directive("dxIcon", ["$compile", function($compile) {
- return {
- restrict: 'E',
- link: function($scope, $element, $attrs) {
- var html = DX.utils.getImageContainer($scope.icon || $scope.iconSrc);
- if (html) {
- var e = $compile(html.get(0))($scope);
- $element.replaceWith(e)
- }
- }
- }
- }]);
- DX.registerComponent = registerNgComponent;
- registerNgComponent("DOMComponent", NgComponent)
- })(jQuery, DevExpress);
- /*! Module core, file ko.templates.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- ui = DX.ui;
- var KoTemplate = ui.TemplateBase.inherit({
- ctor: function(element) {
- this.callBase.apply(this, arguments);
- this._template = $("<div>").append(DX.utils.normalizeTemplateElement(element));
- this._registerKoTemplate()
- },
- _registerKoTemplate: function() {
- var template = this._template.get(0);
- new ko.templateSources.anonymousTemplate(template)['nodes'](template)
- },
- _prepareDataForContainer: function(data, container) {
- var result = data,
- containerElement,
- containerContext;
- if (container.length) {
- containerElement = container.get(0);
- data = data !== undefined ? data : ko.dataFor(containerElement) || {};
- containerContext = ko.contextFor(containerElement);
- if (containerContext)
- result = data === containerContext.$data ? containerContext : containerContext.createChildContext(data);
- else
- result = data
- }
- return result
- },
- _renderCore: function(data) {
- var $renderBag = $("<div>");
- ko.renderTemplate(this._template.get(0), data, null, $renderBag.get(0));
- var $result = $renderBag.contents().detach();
- $renderBag.remove();
- return $result
- },
- dispose: function() {
- this.callBase();
- this._template.remove()
- }
- });
- var KoTemplateProvider = new(ui.TemplateProviderBase.inherit({
- createTemplate: function(element, owner) {
- return new KoTemplate(element, owner)
- },
- applyTemplate: function(element, model) {
- ko.applyBindings(model, element)
- },
- _templatesForWidget: function(widgetName) {
- var templateGenerators = TEMPLATE_GENERATORS[widgetName] || {},
- templates = {};
- $.each(templateGenerators, function(name, generator) {
- var $markup = DX.utils.createMarkupFromString(generator());
- if (name !== "itemFrame")
- $markup = $markup.contents();
- templates[name] = new KoTemplate($markup, KoTemplateProvider)
- });
- return templates
- }
- }));
- var createElementWithBindAttr = function(tagName, bindings, closeTag, additionalProperties) {
- closeTag = closeTag === undefined ? true : closeTag;
- var bindAttr = $.map(bindings, function(value, key) {
- return key + ":" + value
- }).join(",");
- additionalProperties = additionalProperties || "";
- return "<" + tagName + " data-bind=\"" + bindAttr + "\" " + additionalProperties + ">" + (closeTag ? "</" + tagName + ">" : "")
- };
- var defaultKoTemplateBasicBindings = {css: "{ 'dx-state-disabled': $data.disabled, 'dx-state-invisible': !($data.visible === undefined || ko.unwrap($data.visible)) }"};
- var TEMPLATE_GENERATORS = {};
- var emptyTemplate = function() {
- return ""
- };
- TEMPLATE_GENERATORS.CollectionWidget = {
- itemFrame: function() {
- var markup = [createElementWithBindAttr("div", defaultKoTemplateBasicBindings, false), "<div class='dx-item-content-placeholder'></div>", "</div>"];
- return markup.join("")
- },
- item: function() {
- var htmlBinding = createElementWithBindAttr("div", {html: "html"}),
- textBinding = createElementWithBindAttr("div", {text: "text"}),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"});
- var markup = ["<div>", "<!-- ko if: $data.html && !$data.text -->", htmlBinding, "<!-- /ko -->", "<!-- ko if: !$data.html && $data.text -->", textBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }
- };
- var BUTTON_TEXT_CLASS = "dx-button-text";
- TEMPLATE_GENERATORS.dxButton = {content: function() {
- var textBinding = createElementWithBindAttr("span", {
- text: "$data.text",
- css: "{ '" + BUTTON_TEXT_CLASS + "' : !!$data.text }"
- });
- var markup = ["<div>", "<!-- ko dxIcon: $data.icon || $data.iconSrc --><!-- /ko -->", textBinding, "</div>"];
- return markup.join("")
- }};
- var LIST_ITEM_BADGE_CONTAINER_CLASS = "dx-list-item-badge-container",
- LIST_ITEM_BADGE_CLASS = "dx-list-item-badge",
- BADGE_CLASS = "dx-badge",
- LIST_ITEM_CHEVRON_CONTAINER_CLASS = "dx-list-item-chevron-container",
- LIST_ITEM_CHEVRON_CLASS = "dx-list-item-chevron";
- TEMPLATE_GENERATORS.dxList = {
- item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item(),
- keyBinding = createElementWithBindAttr("div", {text: "key"});
- template = [template.substring(0, template.length - 6), "<!-- ko if: $data.key -->" + keyBinding + "<!-- /ko -->", "</div>"];
- return template.join("")
- },
- itemFrame: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(),
- badgeBinding = createElementWithBindAttr("div", {text: "badge"}, true, 'class="' + LIST_ITEM_BADGE_CLASS + " " + BADGE_CLASS + '"');
- var markup = [template.substring(0, template.length - 6), "<!-- ko if: $data.badge -->", "<div class=\"" + LIST_ITEM_BADGE_CONTAINER_CLASS + "\">", badgeBinding, "</div>", "<!-- /ko -->", "<!-- ko if: $data.showChevron -->", "<div class=\"" + LIST_ITEM_CHEVRON_CONTAINER_CLASS + "\">", "<div class=\"" + LIST_ITEM_CHEVRON_CLASS + "\"></div>", "</div>", "<!-- /ko -->", "</div>"];
- return markup.join("")
- },
- group: function() {
- var keyBinding = createElementWithBindAttr("div", {text: "key"}),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"});
- var markup = ["<div>", "<!-- ko if: $data.key -->", keyBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }
- };
- TEMPLATE_GENERATORS.dxDropDownMenu = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxDropDownList = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxRadioGroup = {item: TEMPLATE_GENERATORS.CollectionWidget.item};
- TEMPLATE_GENERATORS.dxScheduler = {item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item(),
- startDateBinding = createElementWithBindAttr("strong", {text: "Globalize.format(DevExpress.utils.makeDate($data.startDate), 't')"}),
- endDateBinding = createElementWithBindAttr("strong", {text: "' - ' + Globalize.format(DevExpress.utils.makeDate($data.endDate), 't')"});
- template = [template.substring(0, template.length - 6), "<div class='dx-scheduler-appointment-content-details'>", "<!-- ko if: $data.startDate -->" + startDateBinding + "<!-- /ko -->", "<!-- ko if: $data.endDate -->" + endDateBinding + "<!-- /ko -->", "</div>", "<!-- ko if: $data.recurrenceRule --><span class='dx-scheduler-appointment-recurrence-icon'></span><!-- /ko -->", "</div>"];
- return template.join("")
- }};
- TEMPLATE_GENERATORS.dxOverlay = {content: emptyTemplate};
- TEMPLATE_GENERATORS.dxSlideOutView = {
- menu: emptyTemplate,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxSlideOut = {
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- menuGroup: TEMPLATE_GENERATORS.dxList.group,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxAccordion = {
- title: function() {
- var titleBinding = createElementWithBindAttr("span", {text: "$.isPlainObject($data) ? $data.title : String($data)"});
- var markup = ["<div>", "<!-- ko dxIcon: $data.icon || $data.iconSrc --><!-- /ko -->", titleBinding, "</div>"];
- return markup.join("")
- },
- item: TEMPLATE_GENERATORS.CollectionWidget.item
- };
- TEMPLATE_GENERATORS.dxResponsiveBox = {item: TEMPLATE_GENERATORS.CollectionWidget.item},
- TEMPLATE_GENERATORS.dxPivotTabs = {item: function() {
- var titleBinding = createElementWithBindAttr("span", {text: "title"}),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"});
- var markup = ["<div>", "<!-- ko if: $data.title -->", titleBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }};
- TEMPLATE_GENERATORS.dxPivot = {
- title: TEMPLATE_GENERATORS.dxPivotTabs.item,
- content: emptyTemplate
- };
- var PANORAMA_ITEM_TITLE_CLASS = "dx-panorama-item-title";
- TEMPLATE_GENERATORS.dxPanorama = {itemFrame: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(),
- headerBinding = createElementWithBindAttr("div", {text: "title"}, true, 'class="' + PANORAMA_ITEM_TITLE_CLASS + '"');
- var divInnerStart = template.indexOf(">") + 1;
- template = [template.substring(0, divInnerStart), "<!-- ko if: $data.title -->", headerBinding, "<!-- /ko -->", template.substring(divInnerStart, template.length)];
- return template.join("")
- }};
- TEMPLATE_GENERATORS.dxActionSheet = {item: function() {
- return ["<div>", createElementWithBindAttr("div", {dxButton: "{ text: $data.text, onClick: $data.clickAction || $data.onClick, type: $data.type, disabled: !!ko.unwrap($data.disabled) }"}), "</div>"].join("")
- }};
- TEMPLATE_GENERATORS.dxToolbar = {
- item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item();
- template = [template.substring(0, template.length - 6), "<!-- ko if: $data.widget -->"];
- $.each(["button", "tabs", "dropDownMenu"], function() {
- var bindingName = DX.inflector.camelize(["dx", "-", this].join("")),
- bindingObj = {};
- bindingObj[bindingName] = "$data.options";
- template.push("<!-- ko if: $data.widget === '", this, "' -->", createElementWithBindAttr("div", bindingObj), "<!-- /ko -->")
- });
- template.push("<!-- /ko -->");
- return template.join("")
- },
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- actionSheetItem: TEMPLATE_GENERATORS.dxActionSheet.item
- };
- TEMPLATE_GENERATORS.dxGallery = {item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item(),
- primitiveBinding = createElementWithBindAttr("div", {text: "String($data)"}),
- imgBinding = createElementWithBindAttr("img", {attr: "{ src: String($data) }"}, false);
- template = [template.substring(0, template.length - 6).replace(primitiveBinding, imgBinding), "<!-- ko if: $data.imageSrc -->", createElementWithBindAttr("img", {attr: "{ src: $data.imageSrc }"}, false), "<!-- /ko -->"].join("");
- return template
- }};
- TEMPLATE_GENERATORS.dxTabs = {
- item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item(),
- basePrimitiveBinding = createElementWithBindAttr("div", {text: "String($data)"}),
- primitiveBinding = "<span class=\"dx-tab-text\" data-bind=\"text: String($data)\"></span>",
- baseTextBinding = createElementWithBindAttr("div", {text: "text"}),
- textBinding = "<!-- ko dxIcon: $data.icon || $data.iconSrc --><!-- /ko -->" + "<span class=\"dx-tab-text\" data-bind=\"text: $data.text\"></span>";
- template = template.replace("<!-- ko if: !$data.html && $data.text -->", "<!-- ko if: !$data.html && ($data.text || $data.icon || $data.iconSrc) -->").replace(basePrimitiveBinding, primitiveBinding).replace(baseTextBinding, textBinding);
- return template
- },
- itemFrame: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(),
- badgeBinding = createElementWithBindAttr("div", {
- attr: "{ 'class': 'dx-tabs-item-badge dx-badge' }",
- text: "badge"
- });
- var markup = [template.substring(0, template.length - 6), "<!-- ko if: $data.badge -->", badgeBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }
- };
- TEMPLATE_GENERATORS.dxTabPanel = {
- item: TEMPLATE_GENERATORS.CollectionWidget.item,
- title: function() {
- var template = TEMPLATE_GENERATORS.dxTabs.item();
- return template.replace(/\$data\.text/g, '$data.title')
- }
- };
- var NAVBAR_ITEM_BADGE_CLASS = "dx-navbar-item-badge";
- TEMPLATE_GENERATORS.dxNavBar = {itemFrame: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.itemFrame(),
- badgeBinding = createElementWithBindAttr("div", {text: "badge"}, true, 'class="' + NAVBAR_ITEM_BADGE_CLASS + " " + BADGE_CLASS + '"');
- var markup = [template.substring(0, template.length - 6), "<!-- ko if: $data.badge -->", badgeBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }};
- TEMPLATE_GENERATORS.dxMenuBase = {item: function() {
- var template = [createElementWithBindAttr("div", defaultKoTemplateBasicBindings, false)],
- textBinding = createElementWithBindAttr("span", {
- text: "text",
- css: "{ 'dx-menu-item-text': true }"
- }),
- primitiveBinding = createElementWithBindAttr("span", {
- text: "String($data)",
- css: "{ 'dx-menu-item-text': true }"
- }),
- popout = "<span class='dx-menu-item-popout-container'><div class='dx-menu-item-popout'></div></span>";
- template.push("<!-- ko dxIcon: $data.icon || $data.iconSrc --><!-- /ko -->", "<!-- ko if: $.isPlainObject($data) && $data.text -->", textBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "<!-- ko if: $data.items -->", popout, "<!-- /ko -->", "</div>");
- return template.join("")
- }};
- TEMPLATE_GENERATORS.dxTreeView = {item: function() {
- var node = [],
- link = createElementWithBindAttr("span", {text: "text"}, true),
- htmlBinding = createElementWithBindAttr("div", {html: "html"});
- node.push("<div>", "<!-- ko if: $data.html && !$data.text -->", htmlBinding, "<!-- /ko -->", "<!-- ko dxIcon: $data.icon || $data.iconSrc --><!-- /ko -->", "<!-- ko if: !$data.html && $data.text -->" + link + "<!-- /ko -->", "</div>");
- return node.join("")
- }};
- TEMPLATE_GENERATORS.dxCalendar = {cell: function() {
- var textBinding = createElementWithBindAttr("span", {text: "text"}),
- primitiveBinding = createElementWithBindAttr("span", {text: "String($data)"});
- var markup = ["<div>", "<!-- ko if: !$data.html && $data.text -->", textBinding, "<!-- /ko -->", "<!-- ko ifnot: $.isPlainObject($data) -->", primitiveBinding, "<!-- /ko -->", "</div>"];
- return markup.join("")
- }};
- var popupTitleAndBottom = function() {
- return ["<div>", createElementWithBindAttr("div", {dxToolbar: "{ items: $data }"}), "</div>"].join("")
- };
- TEMPLATE_GENERATORS.dxPopup = {
- title: popupTitleAndBottom,
- bottom: popupTitleAndBottom
- };
- TEMPLATE_GENERATORS.dxLookup = {
- title: TEMPLATE_GENERATORS.dxPopup.title,
- group: TEMPLATE_GENERATORS.dxList.group
- };
- TEMPLATE_GENERATORS.dxTagBox = {tag: function() {
- return ["<div>", createElementWithBindAttr("span", {text: "$data"})].join("")
- }};
- $.extend(ui, {
- KoTemplateProvider: KoTemplateProvider,
- KoTemplate: KoTemplate
- })
- })(jQuery, DevExpress);
- /*! Module core, file ng.templates.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var ui = DX.ui;
- var TEMPLATE_WRAPPER_CLASS = "dx-template-wrapper";
- var NgTemplate = ui.TemplateBase.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this.setCompiler(this._getParentTemplateCompiler())
- },
- _getParentTemplateCompiler: function() {
- var templateCompiler = null,
- owner = this.owner();
- while (!templateCompiler && owner) {
- templateCompiler = $.isFunction(owner.option) ? owner.option("templateCompiler") : null;
- owner = $.isFunction(owner.owner) ? owner.owner() : null
- }
- return templateCompiler
- },
- _renderCore: function(data, index, $container) {
- var compiledTemplate = this._compiledTemplate,
- result = $.isFunction(compiledTemplate) ? compiledTemplate(data, index, $container) : compiledTemplate;
- return result
- },
- setCompiler: function(templateCompiler) {
- if (!templateCompiler)
- return;
- this._compiledTemplate = templateCompiler(DX.utils.normalizeTemplateElement(this._element))
- }
- });
- var NgTemplateProvider = new(ui.TemplateProviderBase.inherit({
- createTemplate: function(element, owner) {
- return new NgTemplate(element, owner)
- },
- getTemplates: function(widget) {
- var templateCompiler = widget.option("templateCompiler"),
- templates = this.callBase.apply(this, arguments);
- $.each(templates, function(_, template) {
- template.setCompiler(templateCompiler)
- });
- return templates
- },
- _templatesForWidget: function(widgetName) {
- var templateGenerators = TEMPLATE_GENERATORS[widgetName] || {},
- templates = {};
- $.each(templateGenerators, function(name, generator) {
- var $markup = DX.utils.createMarkupFromString(generator());
- templates[name] = new NgTemplate($markup.wrap(), NgTemplateProvider)
- });
- return templates
- }
- }));
- var baseElements = {
- container: function() {
- return $("<div>").addClass(TEMPLATE_WRAPPER_CLASS)
- },
- html: function() {
- return $("<div>").attr("ng-if", "html").attr("ng-bind-html", "html")
- },
- text: function() {
- return $("<div>").attr("ng-if", "text").attr("ng-bind", "text")
- },
- primitive: function() {
- return $("<div>").attr("ng-if", "scopeValue").attr("ng-bind-html", "'' + scopeValue")
- }
- };
- var TEMPLATE_GENERATORS = {};
- var emptyTemplate = function() {
- return $()
- };
- TEMPLATE_GENERATORS.CollectionWidget = {
- item: function() {
- return baseElements.container().append(baseElements.html()).append(baseElements.text()).append(baseElements.primitive())
- },
- itemFrame: function() {
- var $container = $("<div>").attr("ng-class", "{ 'dx-state-invisible': !visible && visible != undefined, 'dx-state-disabled': !!disabled }"),
- $placeholder = $("<div>").addClass("dx-item-content-placeholder");
- $container.append($placeholder);
- return $container
- }
- };
- var BUTTON_TEXT_CLASS = "dx-button-text";
- TEMPLATE_GENERATORS.dxButton = {content: function() {
- var $titleBinding = $("<span>").attr("ng-bind", "text").attr("ng-class", "{ '" + BUTTON_TEXT_CLASS + "' : !!text }"),
- icon = $("<dx-icon>");
- return baseElements.container().append(icon).append($titleBinding).append(baseElements.primitive())
- }};
- var LIST_ITEM_BADGE_CONTAINER_CLASS = "dx-list-item-badge-container",
- LIST_ITEM_BADGE_CLASS = "dx-list-item-badge",
- BADGE_CLASS = "dx-badge",
- LIST_ITEM_CHEVRON_CONTAINER_CLASS = "dx-list-item-chevron-container",
- LIST_ITEM_CHEVRON_CLASS = "dx-list-item-chevron";
- TEMPLATE_GENERATORS.dxList = {
- item: function() {
- return TEMPLATE_GENERATORS.CollectionWidget.item().append($("<div>").attr("ng-if", "key").attr("ng-bind", "key"))
- },
- itemFrame: function() {
- var $badgeContainer = $("<div>").addClass(LIST_ITEM_BADGE_CONTAINER_CLASS).attr("ng-if", "badge"),
- $badge = $("<div>").addClass(LIST_ITEM_BADGE_CLASS).addClass(BADGE_CLASS).attr("ng-bind", "badge");
- var $chevronContainer = $("<div>").addClass(LIST_ITEM_CHEVRON_CONTAINER_CLASS).attr("ng-if", "showChevron"),
- $chevron = $("<div>").addClass(LIST_ITEM_CHEVRON_CLASS);
- return TEMPLATE_GENERATORS.CollectionWidget.itemFrame().append($badgeContainer.append($badge)).append($chevronContainer.append($chevron))
- },
- group: function() {
- var $keyBinding = $("<div>").attr("ng-if", "key").attr("ng-bind", "key");
- return baseElements.container().append($keyBinding).append(baseElements.primitive())
- }
- };
- TEMPLATE_GENERATORS.dxDropDownMenu = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxDropDownList = {item: TEMPLATE_GENERATORS.dxList.item};
- TEMPLATE_GENERATORS.dxRadioGroup = {item: TEMPLATE_GENERATORS.CollectionWidget.item};
- TEMPLATE_GENERATORS.dxScheduler = {item: function() {
- var $itemContent = TEMPLATE_GENERATORS.CollectionWidget.item();
- var $details = $("<div>").addClass("dx-scheduler-appointment-content-details");
- $("<strong>").attr("ng-if", "startDate").text("{{startDate | date : 'shortTime' }}").appendTo($details);
- $("<strong>").attr("ng-if", "endDate").text(" - {{endDate | date : 'shortTime' }}").appendTo($details);
- $details.appendTo($itemContent);
- $("<span>").attr("ng-if", "recurrenceRule").addClass("dx-scheduler-appointment-recurrence-icon").appendTo($itemContent);
- return $itemContent
- }};
- TEMPLATE_GENERATORS.dxOverlay = {content: emptyTemplate};
- TEMPLATE_GENERATORS.dxSlideOutView = {
- menu: emptyTemplate,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxSlideOut = {
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- menuGroup: TEMPLATE_GENERATORS.dxList.group,
- content: emptyTemplate
- };
- TEMPLATE_GENERATORS.dxAccordion = {
- title: function() {
- var $titleBinding = $("<span>").attr("ng-if", "title").attr("ng-bind", "title"),
- icon = $("<dx-icon>");
- return baseElements.container().append(icon).append($titleBinding).append(baseElements.primitive())
- },
- content: TEMPLATE_GENERATORS.CollectionWidget.item
- };
- TEMPLATE_GENERATORS.dxPivotTabs = {item: function() {
- return baseElements.container().append($("<span>").attr("ng-if", "title").attr("ng-bind", "title")).append(baseElements.primitive())
- }};
- TEMPLATE_GENERATORS.dxPivot = {
- title: TEMPLATE_GENERATORS.dxPivotTabs.item,
- content: emptyTemplate
- };
- var PANORAMA_ITEM_TITLE_CLASS = "dx-panorama-item-title";
- TEMPLATE_GENERATORS.dxPanorama = {itemFrame: function() {
- return TEMPLATE_GENERATORS.CollectionWidget.itemFrame().prepend($("<div>").addClass(PANORAMA_ITEM_TITLE_CLASS).attr("ng-if", "title").attr("ng-bind", "title"))
- }};
- TEMPLATE_GENERATORS.dxActionSheet = {item: function() {
- return baseElements.container().append($("<div>").attr("dx-button", "{ bindingOptions: { text: 'text', onClick: 'onClick', type: 'type', disabled: 'disabled' } }"))
- }};
- TEMPLATE_GENERATORS.dxToolbar = {
- item: function() {
- var template = TEMPLATE_GENERATORS.CollectionWidget.item();
- $.each(["button", "tabs", "dropDownMenu"], function(i, widgetName) {
- var bindingName = "dx-" + DX.inflector.dasherize(this);
- $("<div>").attr("ng-if", "widget === '" + widgetName + "'").attr(bindingName, "options").appendTo(template)
- });
- return template
- },
- menuItem: TEMPLATE_GENERATORS.dxList.item,
- actionSheetItem: TEMPLATE_GENERATORS.dxActionSheet.item
- };
- TEMPLATE_GENERATORS.dxGallery = {item: function() {
- return baseElements.container().append(baseElements.html()).append(baseElements.text()).append($("<img>").attr("ng-if", "scopeValue").attr("ng-src", "{{'' + scopeValue}}")).append($("<img>").attr("ng-if", "imageSrc").attr("ng-src", "{{imageSrc}}"))
- }};
- var TABS_ITEM_TEXT_CLASS = "dx-tab-text";
- TEMPLATE_GENERATORS.dxTabs = {
- item: function() {
- var container = baseElements.container();
- var text = $("<span>").addClass(TABS_ITEM_TEXT_CLASS).attr("ng-bind", "text").attr("ng-if", "text"),
- icon = $("<dx-icon>");
- return container.append(baseElements.html()).append(icon).append(text).append(baseElements.primitive().addClass(TABS_ITEM_TEXT_CLASS))
- },
- itemFrame: function() {
- var $badge = $("<div>").addClass("dx-tabs-item-badge dx-badge").attr("ng-bind", "badge").attr("ng-if", "badge");
- return TEMPLATE_GENERATORS.CollectionWidget.itemFrame().append($badge)
- }
- };
- var NAVBAR_ITEM_BADGE_CLASS = "dx-navbar-item-badge";
- TEMPLATE_GENERATORS.dxNavBar = {itemFrame: function() {
- var $badge = $("<div>").addClass(NAVBAR_ITEM_BADGE_CLASS).addClass(BADGE_CLASS).attr("ng-if", "badge").attr("ng-bind", "badge");
- return TEMPLATE_GENERATORS.CollectionWidget.itemFrame().append($badge)
- }};
- TEMPLATE_GENERATORS.dxMenuBase = {item: function() {
- var container = baseElements.container();
- var text = $("<span>").attr("ng-if", "text").addClass("dx-menu-item-text").attr("ng-bind", "text"),
- icon = $("<dx-icon>"),
- popout = $("<span>").addClass("dx-menu-item-popout-container").attr("ng-if", "items").append($("<div>").addClass("dx-menu-item-popout"));
- container.append(baseElements.html()).append(icon).append(text).append(popout).append(baseElements.primitive()).appendTo(container);
- return container
- }};
- TEMPLATE_GENERATORS.dxTreeView = {item: function() {
- var content = baseElements.container(),
- link = $("<span/>").attr("ng-bind", "text"),
- icon = $("<dx-icon>");
- content.append(baseElements.html()).append(icon).append(link).append(baseElements.primitive());
- return content
- }};
- TEMPLATE_GENERATORS.dxTabPanel = {
- item: TEMPLATE_GENERATORS.CollectionWidget.item,
- title: function() {
- var content = TEMPLATE_GENERATORS.dxTabs.item();
- content.find(".dx-tab-text").eq(0).attr("ng-bind", "title").attr("ng-if", "title");
- return content
- }
- };
- var popupTitleAndBottom = function() {
- return $("<div>").attr("dx-toolbar", "{ bindingOptions: { items: 'scopeValue' } }")
- };
- TEMPLATE_GENERATORS.dxPopup = {
- title: popupTitleAndBottom,
- bottom: popupTitleAndBottom
- };
- TEMPLATE_GENERATORS.dxLookup = {
- title: TEMPLATE_GENERATORS.dxPopup.title,
- group: TEMPLATE_GENERATORS.dxList.group
- };
- TEMPLATE_GENERATORS.dxTagBox = {tag: function() {
- return $("<div>").append($("<span>").attr("ng-bind", "scopeValue"))
- }};
- TEMPLATE_GENERATORS.dxCalendar = {cell: function() {
- var $cell = $("<span>").attr("ng-if", "text").attr("ng-bind", "text");
- return baseElements.container().append($cell).append(baseElements.primitive())
- }};
- $.extend(ui, {
- NgTemplate: NgTemplate,
- NgTemplateProvider: NgTemplateProvider
- })
- })(jQuery, DevExpress);
- /*! Module core, file ko.validation.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko;
- var koDxValidator = DX.Class.inherit({
- ctor: function(target, option) {
- var that = this;
- that.target = target;
- that.validationRules = option.validationRules;
- that.name = option.name;
- that.isValid = ko.observable(true);
- that.validationError = ko.observable();
- $.each(this.validationRules, function(_, rule) {
- rule.validator = that
- })
- },
- validate: function() {
- var result = DevExpress.validationEngine.validate(this.target(), this.validationRules, this.name);
- this._applyValidationResult(result);
- return result
- },
- reset: function() {
- this.target(null);
- var result = {
- isValid: true,
- brokenRule: null
- };
- this._applyValidationResult(result);
- return result
- },
- _applyValidationResult: function(result) {
- result.validator = this;
- this.target.dxValidator.isValid(result.isValid);
- this.target.dxValidator.validationError(result.brokenRule);
- this.fireEvent("validated", [result])
- }
- }).include(DX.EventsMixin);
- ko.extenders.dxValidator = function(target, option) {
- target.dxValidator = new koDxValidator(target, option);
- target.subscribe($.proxy(target.dxValidator.validate, target.dxValidator));
- return target
- };
- DevExpress.validationEngine.registerModelForValidation = function(model) {
- $.each(model, function(name, member) {
- if (ko.isObservable(member) && member.dxValidator)
- DevExpress.validationEngine.registerValidatorInGroup(model, member.dxValidator)
- })
- };
- DevExpress.validationEngine.validateModel = DevExpress.validationEngine.validateGroup
- })(jQuery, DevExpress);
- /*! Module core, file ui.themes.js */
- (function($, DX, undefined) {
- var DX_LINK_SELECTOR = "link[rel=dx-theme]",
- THEME_ATTR = "data-theme",
- ACTIVE_ATTR = "data-active";
- var context,
- $activeThemeLink,
- knownThemes,
- currentThemeName,
- pendingThemeName;
- var THEME_MARKER_PREFIX = "dx.";
- function readThemeMarker() {
- var element = $("<div></div>", context).addClass("dx-theme-marker").appendTo(context.documentElement),
- result;
- try {
- result = element.css("font-family");
- if (!result)
- return null;
- result = result.replace(/["']/g, "");
- if (result.substr(0, THEME_MARKER_PREFIX.length) !== THEME_MARKER_PREFIX)
- return null;
- return result.substr(THEME_MARKER_PREFIX.length)
- }
- finally {
- element.remove()
- }
- }
- function waitForThemeLoad(themeName, callback) {
- var timerId,
- waitStartTime;
- pendingThemeName = themeName;
- function handleLoaded() {
- pendingThemeName = null;
- callback()
- }
- if (isPendingThemeLoaded())
- handleLoaded();
- else {
- waitStartTime = $.now();
- timerId = setInterval(function() {
- var isLoaded = isPendingThemeLoaded(),
- isTimeout = !isLoaded && $.now() - waitStartTime > 15 * 1000;
- if (isTimeout)
- DX.log("W0004", pendingThemeName);
- if (isLoaded || isTimeout) {
- clearInterval(timerId);
- handleLoaded()
- }
- }, 10)
- }
- }
- function isPendingThemeLoaded() {
- return !pendingThemeName || readThemeMarker() === pendingThemeName
- }
- function processMarkup() {
- var $allThemeLinks = $(DX_LINK_SELECTOR, context);
- if (!$allThemeLinks.length)
- return;
- knownThemes = {};
- $activeThemeLink = $(DX.utils.createMarkupFromString("<link rel=stylesheet>"), context);
- $allThemeLinks.each(function() {
- var link = $(this, context),
- fullThemeName = link.attr(THEME_ATTR),
- url = link.attr("href"),
- isActive = link.attr(ACTIVE_ATTR) === "true";
- knownThemes[fullThemeName] = {
- url: url,
- isActive: isActive
- }
- });
- $allThemeLinks.last().after($activeThemeLink);
- $allThemeLinks.remove()
- }
- function resolveFullThemeName(desiredThemeName) {
- var desiredThemeParts = desiredThemeName.split("."),
- result = null;
- if (knownThemes)
- $.each(knownThemes, function(knownThemeName, themeData) {
- var knownThemeParts = knownThemeName.split(".");
- if (knownThemeParts[0] !== desiredThemeParts[0])
- return;
- if (desiredThemeParts[1] && desiredThemeParts[1] !== knownThemeParts[1])
- return;
- if (desiredThemeParts[2] && desiredThemeParts[2] !== knownThemeParts[2])
- return;
- if (!result || themeData.isActive)
- result = knownThemeName;
- if (themeData.isActive)
- return false
- });
- return result
- }
- function initContext(newContext) {
- try {
- if (newContext !== context)
- knownThemes = null
- }
- catch(x) {
- knownThemes = null
- }
- context = newContext
- }
- function init(options) {
- options = options || {};
- initContext(options.context || document);
- processMarkup();
- currentThemeName = undefined;
- current(options)
- }
- function current(options) {
- if (!arguments.length)
- return currentThemeName || readThemeMarker();
- detachCssClasses(DX.viewPort(), currentThemeName);
- options = options || {};
- if (typeof options === "string")
- options = {theme: options};
- var isAutoInit = options._autoInit,
- loadCallback = options.loadCallback,
- currentThemeData;
- currentThemeName = options.theme || currentThemeName;
- if (isAutoInit && !currentThemeName)
- currentThemeName = themeNameFromDevice(DX.devices.current());
- currentThemeName = resolveFullThemeName(currentThemeName);
- if (currentThemeName)
- currentThemeData = knownThemes[currentThemeName];
- if (currentThemeData) {
- $activeThemeLink.attr("href", knownThemes[currentThemeName].url);
- if (loadCallback)
- waitForThemeLoad(currentThemeName, loadCallback);
- else if (pendingThemeName)
- pendingThemeName = currentThemeName
- }
- else if (isAutoInit) {
- if (loadCallback)
- loadCallback()
- }
- else
- throw DX.Error("E0021", currentThemeName);
- attachCssClasses(DX.viewPort(), currentThemeName)
- }
- function themeNameFromDevice(device) {
- var themeName = device.platform;
- if (themeName === "ios")
- themeName += "7";
- if (themeName === "android")
- themeName += "5";
- return themeName
- }
- function getCssClasses(themeName) {
- themeName = themeName || current();
- var result = [],
- themeNameParts = themeName && themeName.split(".");
- if (themeNameParts) {
- result.push("dx-theme-" + themeNameParts[0], "dx-theme-" + themeNameParts[0] + "-typography");
- if (themeNameParts.length > 1)
- result.push("dx-color-scheme-" + themeNameParts[1])
- }
- return result
- }
- var themeClasses;
- function attachCssClasses(element, themeName) {
- themeClasses = getCssClasses(themeName).join(" ");
- $(element).addClass(themeClasses)
- }
- function detachCssClasses(element, themeName) {
- $(element).removeClass(themeClasses)
- }
- $.holdReady(true);
- init({
- _autoInit: true,
- loadCallback: function() {
- $.holdReady(false)
- }
- });
- $(function() {
- if ($(DX_LINK_SELECTOR, context).length)
- throw DX.Error("E0022");
- });
- DX.viewPortChanged.add(function(viewPort, prevViewPort) {
- detachCssClasses(prevViewPort);
- attachCssClasses(viewPort)
- });
- DX.ui.themes = {
- init: init,
- current: current,
- attachCssClasses: attachCssClasses,
- detachCssClasses: detachCssClasses
- };
- DX.ui.themes.__internals = {
- themeNameFromDevice: themeNameFromDevice,
- waitForThemeLoad: waitForThemeLoad,
- resetTheme: function() {
- $activeThemeLink.attr("href", "about:blank");
- currentThemeName = null;
- pendingThemeName = null
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- eventNS = $.event,
- hooksNS = eventNS.fixHooks,
- specialNS = eventNS.special,
- EVENT_SOURCES_REGEX = {
- dx: /^dx/i,
- mouse: /(mouse|wheel)/i,
- touch: /^touch/i,
- keyboard: /^key/i,
- pointer: /^(ms)?pointer/i
- };
- var eventSource = function(e) {
- var result = "other";
- $.each(EVENT_SOURCES_REGEX, function(key) {
- if (this.test(e.type)) {
- result = key;
- return false
- }
- });
- return result
- };
- var isDxEvent = function(e) {
- return eventSource(e) === "dx"
- };
- var isNativeMouseEvent = function(e) {
- return eventSource(e) === "mouse"
- };
- var isNativeTouchEvent = function(e) {
- return eventSource(e) === "touch"
- };
- var isPointerEvent = function(e) {
- return eventSource(e) === "pointer"
- };
- var isMouseEvent = function(e) {
- return isNativeMouseEvent(e) || (isPointerEvent(e) || isDxEvent(e)) && e.pointerType === "mouse"
- };
- var isTouchEvent = function(e) {
- return isNativeTouchEvent(e) || (isPointerEvent(e) || isDxEvent(e)) && e.pointerType === "touch"
- };
- var isKeyboardEvent = function(e) {
- return eventSource(e) === "keyboard"
- };
- var eventData = function(e) {
- return {
- x: e.pageX,
- y: e.pageY,
- time: e.timeStamp
- }
- };
- var eventDelta = function(from, to) {
- return {
- x: to.x - from.x,
- y: to.y - from.y,
- time: to.time - from.time || 1
- }
- };
- var hasTouches = function(e) {
- if (isNativeTouchEvent(e))
- return (e.originalEvent.touches || []).length;
- if (isDxEvent(e))
- return (e.pointers || []).length;
- return 0
- };
- var needSkipEvent = function(e) {
- var $target = $(e.target),
- touchInInput = $target.is("input, textarea, select");
- if (e.type === 'dxmousewheel')
- return $target.is("input[type='number'], textarea, select") && $target.is(':focus');
- if (isMouseEvent(e))
- return touchInInput || e.which > 1;
- if (isTouchEvent(e))
- return touchInInput && $target.is(":focus")
- };
- var createEvent = function(originalEvent, args) {
- var event = $.Event(originalEvent),
- fixHook = hooksNS[originalEvent.type] || eventNS.mouseHooks;
- var props = fixHook.props ? eventNS.props.concat(fixHook.props) : eventNS.props,
- propIndex = props.length;
- while (propIndex--) {
- var prop = props[propIndex];
- event[prop] = originalEvent[prop]
- }
- if (args)
- $.extend(event, args);
- return fixHook.filter ? fixHook.filter(event, originalEvent) : event
- };
- var fireEvent = function(props) {
- var event = createEvent(props.originalEvent, props);
- eventNS.trigger(event, null, props.delegateTarget || event.target);
- return event
- };
- var addNamespace = function(eventNames, namespace) {
- if (!namespace)
- throw DX.Error("E0017");
- if (typeof eventNames === "string")
- return addNamespace(eventNames.split(/\s+/g), namespace);
- $.each(eventNames, function(index, eventName) {
- eventNames[index] = eventName + "." + namespace
- });
- return eventNames.join(" ")
- };
- var dxEventHook = {props: eventNS.mouseHooks.props.concat(["pointerType", "pointerId", "pointers"])};
- var registerEvent = function(eventName, eventObject) {
- var strategy = {};
- if ("noBubble" in eventObject)
- strategy.noBubble = eventObject.noBubble;
- if ("bindType" in eventObject)
- strategy.bindType = eventObject.bindType;
- if ("delegateType" in eventObject)
- strategy.delegateType = eventObject.delegateType;
- $.each(["setup", "teardown", "add", "remove", "trigger", "handle", "_default", "dispose"], function(_, methodName) {
- if (!eventObject[methodName])
- return;
- strategy[methodName] = function() {
- var args = $.makeArray(arguments);
- args.unshift(this);
- return eventObject[methodName].apply(eventObject, args)
- }
- });
- hooksNS[eventName] = dxEventHook;
- specialNS[eventName] = strategy
- };
- ui.events = {
- eventSource: eventSource,
- isPointerEvent: isPointerEvent,
- isMouseEvent: isMouseEvent,
- isTouchEvent: isTouchEvent,
- isKeyboardEvent: isKeyboardEvent,
- hasTouches: hasTouches,
- eventData: eventData,
- eventDelta: eventDelta,
- needSkipEvent: needSkipEvent,
- createEvent: createEvent,
- fireEvent: fireEvent,
- addNamespace: addNamespace,
- registerEvent: registerEvent
- }
- })(jQuery, DevExpress);
- /*! Module core, file ko.events.js */
- (function($, DX, undefined) {
- if (!DX.support.hasKo)
- return;
- var ko = window.ko,
- events = DX.ui.events;
- var originalRegisterEvent = events.registerEvent;
- var registerKoEvent = function(eventName, eventObject) {
- originalRegisterEvent(eventName, eventObject);
- var koBindingEventName = events.addNamespace(eventName, eventName + "Binding");
- ko.bindingHandlers[eventName] = {update: function(element, valueAccessor, allBindingsAccessor, viewModel) {
- var $element = $(element),
- unwrappedValue = ko.utils.unwrapObservable(valueAccessor()),
- eventSource = unwrappedValue.execute ? unwrappedValue.execute : unwrappedValue;
- $element.off(koBindingEventName).on(koBindingEventName, $.isPlainObject(unwrappedValue) ? unwrappedValue : {}, function(e) {
- eventSource.call(viewModel, viewModel, e)
- })
- }}
- };
- $.extend(events, {registerEvent: registerKoEvent})
- })(jQuery, DevExpress);
- /*! Module core, file ng.events.js */
- (function($, DX, undefined) {
- if (!DX.support.hasNg)
- return;
- var events = DX.ui.events;
- var originalRegisterEvent = events.registerEvent;
- var registerNgEvent = function(eventName, eventObject) {
- originalRegisterEvent(eventName, eventObject);
- var ngEventName = eventName.slice(0, 2) + eventName.charAt(2).toUpperCase() + eventName.slice(3);
- DX.ng.module.directive(ngEventName, ['$parse', function($parse) {
- return function(scope, element, attr) {
- var attrValue = $.trim(attr[ngEventName]),
- handler,
- eventOptions = {};
- if (attrValue.charAt(0) === "{") {
- eventOptions = scope.$eval(attrValue);
- handler = $parse(eventOptions.execute)
- }
- else
- handler = $parse(attr[ngEventName]);
- element.on(eventName, eventOptions, function(e) {
- scope.$apply(function() {
- handler(scope, {$event: e})
- })
- })
- }
- }])
- };
- $.extend(events, {registerEvent: registerNgEvent})
- })(jQuery, DevExpress);
- /*! Module core, file ui.keyboardProcessor.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- ui.KeyboardProcessor = DX.Class.inherit({
- _keydown: events.addNamespace("keydown", "KeyboardProcessor"),
- codes: {
- "8": "backspace",
- "9": "tab",
- "13": "enter",
- "27": "escape",
- "33": "pageUp",
- "34": "pageDown",
- "35": "end",
- "36": "home",
- "37": "leftArrow",
- "38": "upArrow",
- "39": "rightArrow",
- "40": "downArrow",
- "46": "del",
- "32": "space",
- "70": "F",
- "65": "A",
- "106": "asterisk",
- "109": "minus"
- },
- ctor: function(options) {
- var _this = this;
- options = options || {};
- if (options.element)
- this._element = $(options.element);
- if (options.focusTarget)
- this._focusTarget = options.focusTarget;
- this._handler = options.handler;
- this._context = options.context;
- this._childProcessors = [];
- if (this._element)
- this._element.on(this._keydown, function(e) {
- _this.process(e)
- })
- },
- dispose: function() {
- if (this._element)
- this._element.off(this._keydown);
- this._element = undefined;
- this._handler = undefined;
- this._context = undefined;
- this._childProcessors = undefined
- },
- clearChildren: function() {
- this._childProcessors = []
- },
- push: function(child) {
- if (!this._childProcessors)
- this.clearChildren();
- this._childProcessors.push(child);
- return child
- },
- attachChildProcessor: function() {
- var childProcessor = new ui.KeyboardProcessor;
- this._childProcessors.push(childProcessor);
- return childProcessor
- },
- reinitialize: function(childHandler, childContext) {
- this._context = childContext;
- this._handler = childHandler;
- return this
- },
- process: function(e) {
- if (this._focusTarget && this._focusTarget !== e.target && $.inArray(e.target, this._focusTarget) < 0)
- return false;
- var args = {
- key: this.codes[e.which] || e.which,
- ctrl: e.ctrlKey,
- shift: e.shiftKey,
- alt: e.altKey,
- originalEvent: e
- };
- var handlerResult = this._handler && this._handler.call(this._context, args);
- if (handlerResult && this._childProcessors)
- $.each(this._childProcessors, function(index, childProcessor) {
- childProcessor.process(e)
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.dialog.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils;
- var DEFAULT_BUTTON = {
- text: "OK",
- onClick: function() {
- return true
- }
- };
- var DX_DIALOG_CLASSNAME = "dx-dialog",
- DX_DIALOG_WRAPPER_CLASSNAME = DX_DIALOG_CLASSNAME + "-wrapper",
- DX_DIALOG_ROOT_CLASSNAME = DX_DIALOG_CLASSNAME + "-root",
- DX_DIALOG_CONTENT_CLASSNAME = DX_DIALOG_CLASSNAME + "-content",
- DX_DIALOG_MESSAGE_CLASSNAME = DX_DIALOG_CLASSNAME + "-message",
- DX_DIALOG_BUTTONS_CLASSNAME = DX_DIALOG_CLASSNAME + "-buttons",
- DX_DIALOG_BUTTON_CLASSNAME = DX_DIALOG_CLASSNAME + "-button";
- var FakeDialogComponent = DX.Component.inherit({
- NAME: "dxDialog",
- ctor: function(element, options) {
- this.callBase(options)
- },
- _defaultOptionsRules: function() {
- return this.callBase().concat([{
- device: {platform: "ios"},
- options: {width: 276}
- }, {
- device: {platform: "android"},
- options: {
- lWidth: "60%",
- pWidth: "80%"
- }
- }, {
- device: {
- platform: "win8",
- phone: false
- },
- options: {width: function() {
- return $(window).width()
- }}
- }, {
- device: {
- platform: "win8",
- phone: true
- },
- options: {position: {
- my: "top center",
- at: "top center",
- of: window,
- offset: "0 0"
- }}
- }])
- }
- });
- var dialog = function(options) {
- if (!ui.dxPopup)
- throw DX.Error("E0018");
- var deferred = $.Deferred();
- var defaultOptions = (new FakeDialogComponent).option();
- options = $.extend(defaultOptions, options);
- var $element = $("<div>").addClass(DX_DIALOG_CLASSNAME).appendTo(DX.viewPort());
- var $message = $("<div>").addClass(DX_DIALOG_MESSAGE_CLASSNAME).html(String(options.message));
- var popupButtons = [];
- $.each(options.buttons || [DEFAULT_BUTTON], function() {
- if (this.clickAction) {
- DX.log("W0001", "Dialog", "clickAction", "14.2", "Use 'onClick' option instead");
- this.onClick = this.clickAction
- }
- var action = new DX.Action(this.onClick || this.clickAction, {context: popupInstance});
- popupButtons.push({
- toolbar: 'bottom',
- location: 'center',
- widget: 'button',
- options: {
- text: this.text,
- onClick: function() {
- var result = action.execute(arguments);
- hide(result)
- }
- }
- })
- });
- var popupInstance = $element.dxPopup({
- title: options.title || this.title,
- showTitle: function() {
- var isTitle = options.showTitle === undefined ? true : options.showTitle;
- return isTitle
- }(),
- height: "auto",
- width: function() {
- var isPortrait = $(window).height() > $(window).width(),
- key = (isPortrait ? "p" : "l") + "Width",
- widthOption = options.hasOwnProperty(key) ? options[key] : options["width"];
- return $.isFunction(widthOption) ? widthOption() : widthOption
- },
- showCloseButton: false,
- focusStateEnabled: false,
- onContentReady: function(args) {
- args.component.content().addClass(DX_DIALOG_CONTENT_CLASSNAME).append($message)
- },
- onShowing: function(e) {
- e.component.bottomToolbar().addClass(DX_DIALOG_BUTTONS_CLASSNAME).find(".dx-button").addClass(DX_DIALOG_BUTTON_CLASSNAME).first().focus()
- },
- buttons: popupButtons,
- animation: {
- show: {
- type: "pop",
- duration: 400
- },
- hide: {
- type: "pop",
- duration: 400,
- to: {
- opacity: 0,
- scale: 0
- },
- from: {
- opacity: 1,
- scale: 1
- }
- }
- },
- rtlEnabled: DX.rtlEnabled,
- boundaryOffset: {
- h: 10,
- v: 0
- }
- }).dxPopup("instance");
- popupInstance._wrapper().addClass(DX_DIALOG_WRAPPER_CLASSNAME);
- if (options.position)
- popupInstance.option("position", options.position);
- popupInstance._wrapper().addClass(DX_DIALOG_ROOT_CLASSNAME);
- function show() {
- popupInstance.show();
- utils.resetActiveElement();
- return deferred.promise()
- }
- function hide(value) {
- popupInstance.hide().done(function() {
- popupInstance.element().remove()
- });
- deferred.resolve(value)
- }
- return {
- show: show,
- hide: hide
- }
- };
- var alert = function(message, title, showTitle) {
- var dialogInstance,
- options = $.isPlainObject(message) ? message : {
- title: title,
- message: message,
- showTitle: showTitle
- };
- dialogInstance = ui.dialog.custom(options);
- return dialogInstance.show()
- };
- var confirm = function(message, title, showTitle) {
- var dialogInstance,
- options = $.isPlainObject(message) ? message : {
- title: title,
- message: message,
- showTitle: showTitle,
- buttons: [{
- text: Globalize.localize("Yes"),
- onClick: function() {
- return true
- }
- }, {
- text: Globalize.localize("No"),
- onClick: function() {
- return false
- }
- }]
- };
- dialogInstance = ui.dialog.custom(options);
- return dialogInstance.show()
- };
- var $notify = null;
- var notify = function(message, type, displayTime) {
- var options = $.isPlainObject(message) ? message : {message: message};
- if (!ui.dxToast) {
- alert(options.message);
- return
- }
- if (options.hiddenAction) {
- DX.log("W0001", "Dialog", "hiddenAction", "14.2", "Use 'onHidden' option instead");
- options.onHidden = options.hiddenAction
- }
- var userHiddenAction = options.onHidden;
- $.extend(options, {
- type: type,
- displayTime: displayTime,
- onHidden: function(args) {
- args.element.remove();
- new DX.Action(userHiddenAction, {context: args.model}).execute(arguments)
- }
- });
- $notify = $("<div>").appendTo(DX.viewPort()).dxToast(options);
- $notify.dxToast("instance").show()
- };
- $.extend(ui, {
- notify: notify,
- dialog: {
- custom: dialog,
- alert: alert,
- confirm: confirm
- }
- });
- ui.dialog.FakeDialogComponent = FakeDialogComponent
- })(jQuery, DevExpress);
- /*! Module core, file ui.dataHelper.js */
- (function($, DX, undefined) {
- var data = DX.data;
- var DATA_SOURCE_OPTIONS_METHOD = "_dataSourceOptions",
- DATA_SOURCE_CHANGED_METHOD = "_dataSourceChangedHandler",
- DATA_SOURCE_LOAD_ERROR_METHOD = "_dataSourceLoadErrorHandler",
- DATA_SOURCE_LOADING_CHANGED_METHOD = "_dataSourceLoadingChangedHandler";
- DX.ui.DataHelperMixin = {
- postCtor: function() {
- this.on("disposing", function() {
- this._disposeDataSource()
- })
- },
- _isDataSourceReady: function() {
- return !this._dataSource || this._dataSource.isLoaded()
- },
- _refreshDataSource: function() {
- this._initDataSource();
- this._loadDataSource()
- },
- _initDataSource: function() {
- var dataSourceOptions = this.option("dataSource"),
- widgetDataSourceOptions,
- dataSourceType;
- this._disposeDataSource();
- if (dataSourceOptions) {
- if (dataSourceOptions instanceof data.DataSource) {
- this._isSharedDataSource = true;
- this._dataSource = dataSourceOptions
- }
- else {
- widgetDataSourceOptions = DATA_SOURCE_OPTIONS_METHOD in this ? this[DATA_SOURCE_OPTIONS_METHOD]() : {};
- dataSourceType = this._dataSourceType ? this._dataSourceType() : data.DataSource;
- this._dataSource = new dataSourceType($.extend(true, {}, widgetDataSourceOptions, data.utils.normalizeDataSourceOptions(dataSourceOptions)))
- }
- this._addDataSourceHandlers()
- }
- },
- _addDataSourceHandlers: function() {
- if (DATA_SOURCE_CHANGED_METHOD in this)
- this._addDataSourceChangeHandler();
- if (DATA_SOURCE_LOAD_ERROR_METHOD in this)
- this._addDataSourceLoadErrorHandler();
- if (DATA_SOURCE_LOADING_CHANGED_METHOD in this)
- this._addDataSourceLoadingChangedHandler();
- this._addReadyWatcher()
- },
- _addReadyWatcher: function() {
- this._dataSource.on("loadingChanged", $.proxy(function(isLoading) {
- this._ready && this._ready(!isLoading)
- }, this))
- },
- _addDataSourceChangeHandler: function() {
- var dataSource = this._dataSource;
- this._proxiedDataSourceChangedHandler = $.proxy(function() {
- this[DATA_SOURCE_CHANGED_METHOD](dataSource.items())
- }, this);
- dataSource.on("changed", this._proxiedDataSourceChangedHandler)
- },
- _addDataSourceLoadErrorHandler: function() {
- this._proxiedDataSourceLoadErrorHandler = $.proxy(this[DATA_SOURCE_LOAD_ERROR_METHOD], this);
- this._dataSource.on("loadError", this._proxiedDataSourceLoadErrorHandler)
- },
- _addDataSourceLoadingChangedHandler: function() {
- this._proxiedDataSourceLoadingChangedHandler = $.proxy(this[DATA_SOURCE_LOADING_CHANGED_METHOD], this);
- this._dataSource.on("loadingChanged", this._proxiedDataSourceLoadingChangedHandler)
- },
- _loadDataSource: function() {
- if (this._dataSource) {
- var dataSource = this._dataSource;
- if (dataSource.isLoaded())
- this._proxiedDataSourceChangedHandler && this._proxiedDataSourceChangedHandler();
- else
- dataSource.load()
- }
- },
- _loadSingle: function(key, value) {
- key = key === "this" ? this._dataSource.key() || "this" : key;
- return this._dataSource.loadSingle(key, value)
- },
- _isLastPage: function() {
- return !this._dataSource || this._dataSource.isLastPage() || !this._dataSource._pageSize
- },
- _isDataSourceLoading: function() {
- return this._dataSource && this._dataSource.isLoading()
- },
- _disposeDataSource: function() {
- if (this._dataSource) {
- if (this._isSharedDataSource) {
- delete this._isSharedDataSource;
- this._proxiedDataSourceChangedHandler && this._dataSource.off("changed", this._proxiedDataSourceChangedHandler);
- this._proxiedDataSourceLoadErrorHandler && this._dataSource.off("loadError", this._proxiedDataSourceLoadErrorHandler);
- this._proxiedDataSourceLoadingChangedHandler && this._dataSource.off("loadingChanged", this._proxiedDataSourceLoadingChangedHandler)
- }
- else
- this._dataSource.dispose();
- delete this._dataSource;
- delete this._proxiedDataSourceChangedHandler;
- delete this._proxiedDataSourceLoadErrorHandler;
- delete this._proxiedDataSourceLoadingChangedHandler
- }
- }
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.dataExpression.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- dataUtils = DX.data.utils;
- ui.DataExpressionMixin = $.extend(ui.DataHelperMixin, {
- _dataExpressionDeprecatedOptions: function() {
- return {itemRender: {
- since: "14.2",
- alias: "itemTemplate"
- }}
- },
- _dataExpressionDefaultOptions: function() {
- return {
- items: [],
- dataSource: null,
- itemTemplate: "item",
- value: null,
- valueExpr: "this",
- displayExpr: undefined
- }
- },
- _initDataExpressions: function() {
- this._compileValueGetter();
- this._compileDisplayGetter();
- this._initDynamicTemplates();
- this._initDataSource();
- this._itemsToDataSource()
- },
- _itemsToDataSource: function() {
- if (!this.option("dataSource"))
- this._dataSource = new DevExpress.data.DataSource({
- store: new DevExpress.data.ArrayStore(this.option("items")),
- pageSize: 0
- })
- },
- _compileDisplayGetter: function() {
- this._displayGetter = dataUtils.compileGetter(this._displayGetterExpr())
- },
- _displayGetterExpr: function() {
- return this.option("displayExpr")
- },
- _compileValueGetter: function() {
- this._valueGetter = dataUtils.compileGetter(this._valueGetterExpr())
- },
- _valueGetterExpr: function() {
- return this.option("valueExpr") || "this"
- },
- _loadValue: function(value) {
- var deferred = $.Deferred();
- value = this._unwrappedValue(value);
- if (!utils.isDefined(value))
- return deferred.reject().promise();
- this._loadSingle(this._valueGetterExpr(), value).done($.proxy(function(item) {
- this._isValueEquals(this._valueGetter(item), value) ? deferred.resolve(item) : deferred.reject()
- }, this)).fail(function() {
- deferred.reject()
- });
- return deferred.promise()
- },
- _unwrappedValue: function(value) {
- value = DX.utils.isDefined(value) ? value : this.option("value");
- if (value && this._dataSource && this._valueGetterExpr() === "this") {
- var key = this._dataSource.key();
- if (key && typeof value === "object")
- value = value[key]
- }
- return utils.unwrapObservable(value)
- },
- _isValueEquals: function(value1, value2) {
- var isDefined = utils.isDefined;
- var ensureDefined = utils.ensureDefined;
- var unwrapObservable = utils.unwrapObservable;
- var dataSourceKey = this._dataSource && this._dataSource.key();
- var result = this._compareValues(value1, value2);
- if (!result && isDefined(value1) && isDefined(value2) && dataSourceKey) {
- var valueKey1 = ensureDefined(unwrapObservable(value1[dataSourceKey]), value1);
- var valueKey2 = ensureDefined(unwrapObservable(value2[dataSourceKey]), value2);
- result = this._compareValues(valueKey1, valueKey2)
- }
- return result
- },
- _compareValues: function(value1, value2) {
- return dataUtils.toComparable(value1) === dataUtils.toComparable(value2)
- },
- _initDynamicTemplates: function() {
- if (this._displayGetterExpr())
- this._dynamicTemplates["item"] = new ui.DefaultTemplate($.proxy(function(data) {
- return this._displayGetter(data)
- }, this));
- else
- delete this._dynamicTemplates["item"]
- },
- _setCollectionWidgetItemTemplate: function() {
- this._initDynamicTemplates();
- this._setCollectionWidgetOption("itemTemplate", this._getTemplateByOption("itemTemplate"))
- },
- _dataExpressionOptionChanged: function(args) {
- switch (args.name) {
- case"items":
- this._itemsToDataSource();
- this._setCollectionWidgetOption("items");
- break;
- case"dataSource":
- this._initDataSource();
- break;
- case"itemTemplate":
- this._setCollectionWidgetItemTemplate();
- break;
- case"valueExpr":
- this._compileValueGetter();
- break;
- case"displayExpr":
- this._compileDisplayGetter();
- this._setCollectionWidgetItemTemplate();
- break
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.touchHooks.js */
- (function($, DX, undefined) {
- var touchEventHook = {
- filter: function(event, originalEvent) {
- var touches = originalEvent.touches.length ? originalEvent.touches : originalEvent.changedTouches;
- $.each(["pageX", "pageY", "screenX", "screenY", "clientX", "clientY"], function() {
- event[this] = touches[0][this]
- });
- return event
- },
- props: $.event.mouseHooks.props.concat(["touches", "changedTouches", "targetTouches", "detail", "result", "originalTarget", "charCode", "prevValue"])
- };
- $.each(["touchstart", "touchmove", "touchend", "touchcancel"], function() {
- $.event.fixHooks[this] = touchEventHook
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.mspointerHooks.js */
- (function($, DX, undefined) {
- var POINTER_TYPE_MAP = {
- 2: "touch",
- 3: "pen",
- 4: "mouse"
- };
- var pointerEventHook = {
- filter: function(event, originalEvent) {
- var pointerType = originalEvent.pointerType;
- if ($.isNumeric(pointerType))
- event.pointerType = POINTER_TYPE_MAP[pointerType];
- return event
- },
- props: $.event.mouseHooks.props.concat(["pointerId", "pointerType", "originalTarget", "width", "height", "pressure", "result", "tiltX", "charCode", "tiltY", "detail", "isPrimary", "prevValue"])
- };
- $.each(["MSPointerDown", "MSPointerMove", "MSPointerUp", "MSPointerCancel", "MSPointerOver", "MSPointerOut", "mouseenter", "mouseleave", "pointerdown", "pointermove", "pointerup", "pointercancel", "pointerover", "pointerout", "pointerenter", "pointerleave"], function() {
- $.event.fixHooks[this] = pointerEventHook
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.base.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var POINTER_EVENTS_NAMESPACE = "dxPointerEvents";
- var BaseStrategy = DX.Class.inherit({
- ctor: function(eventName, originalEvents) {
- this._eventName = eventName;
- this._eventNamespace = [POINTER_EVENTS_NAMESPACE, ".", this._eventName].join("");
- this._originalEvents = originalEvents;
- this._handlerCount = 0;
- this.noBubble = this._isNoBubble()
- },
- _isNoBubble: function() {
- var eventName = this._eventName;
- return eventName === "dxpointerenter" || eventName === "dxpointerleave"
- },
- _handler: function(e) {
- var delegateTarget = this._getDelegateTarget(e);
- return this._fireEvent({
- type: this._eventName,
- pointerType: e.pointerType || events.eventSource(e),
- originalEvent: e,
- delegateTarget: delegateTarget
- })
- },
- _getDelegateTarget: function(e) {
- var delegateTarget;
- if (this.noBubble)
- delegateTarget = e.delegateTarget;
- return delegateTarget
- },
- _fireEvent: function(args) {
- return events.fireEvent(args)
- },
- setup: function() {
- return true
- },
- add: function(element, handleObj) {
- if (this._handlerCount <= 0 || this.noBubble) {
- this._selector = handleObj.selector;
- element = this.noBubble ? element : document;
- $(element).on(events.addNamespace(this._originalEvents, this._eventNamespace), this._selector, $.proxy(this._handler, this))
- }
- if (!this.noBubble)
- this._handlerCount++
- },
- remove: function(element) {
- if (!this.noBubble)
- this._handlerCount--
- },
- teardown: function(element) {
- if (this._handlerCount && !this.noBubble)
- return;
- element = this.noBubble ? element : document;
- $(element).off("." + this._eventNamespace, this._selector)
- },
- dispose: function(element) {
- element = this.noBubble ? element : document;
- $(element).off("." + this._eventNamespace)
- }
- });
- events.pointer = {};
- events.pointer.BaseStrategy = BaseStrategy
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.mouse.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- pointer = events.pointer;
- var MouseStrategyEventMap = {
- dxpointerdown: "mousedown",
- dxpointermove: "mousemove",
- dxpointerup: "mouseup",
- dxpointercancel: "",
- dxpointerover: "mouseover",
- dxpointerout: "mouseout",
- dxpointerenter: "mouseenter",
- dxpointerleave: "mouseleave"
- };
- var normalizeMouseEvent = function(e) {
- var pointers = [];
- e.pointerId = 1;
- if (e.type !== "mouseup")
- pointers.push(e);
- return {
- pointers: pointers,
- pointerId: 1
- }
- };
- var MouseStrategy = pointer.BaseStrategy.inherit({_fireEvent: function(args) {
- return this.callBase($.extend(normalizeMouseEvent(args.originalEvent), args))
- }});
- pointer.mouse = {
- strategy: MouseStrategy,
- map: MouseStrategyEventMap,
- normalize: normalizeMouseEvent
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.touch.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- device = $.proxy(DX.devices.real, DX.devices),
- events = ui.events,
- pointer = events.pointer;
- var TouchStrategyEventMap = {
- dxpointerdown: "touchstart",
- dxpointermove: "touchmove",
- dxpointerup: "touchend",
- dxpointercancel: "touchcancel"
- };
- var normalizeTouchEvent = function(e) {
- var pointers = [];
- $.each(e.touches, function(_, touch) {
- pointers.push($.extend({pointerId: touch.identifier}, touch))
- });
- return {
- pointers: pointers,
- pointerId: e.changedTouches[0].identifier
- }
- };
- var skipTouchWithSameIdentifier = function(pointerEvent) {
- return device().platform === "ios" && (pointerEvent === "dxpointerdown" || pointerEvent === "dxpointerup")
- };
- var TouchStrategy = pointer.BaseStrategy.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- this._pointerId = 0
- },
- _handler: function(e) {
- if (skipTouchWithSameIdentifier(this._eventName)) {
- var touch = e.changedTouches[0];
- if (this._pointerId === touch.identifier && this._pointerId !== 0)
- return;
- this._pointerId = touch.identifier
- }
- return this.callBase.apply(this, arguments)
- },
- _fireEvent: function(args) {
- return this.callBase($.extend(normalizeTouchEvent(args.originalEvent), args))
- }
- });
- pointer.touch = {
- strategy: TouchStrategy,
- map: TouchStrategyEventMap,
- normalize: normalizeTouchEvent
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.mouseAndTouch.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- pointer = events.pointer;
- var MouseAndTouchStrategyEventMap = {
- dxpointerdown: "touchstart mousedown",
- dxpointermove: "touchmove mousemove",
- dxpointerup: "touchend mouseup",
- dxpointercancel: "touchcancel",
- dxpointerover: "mouseover",
- dxpointerout: "mouseout",
- dxpointerenter: "mouseenter",
- dxpointerleave: "mouseleave"
- };
- var MouseAndTouchStrategy = pointer.BaseStrategy.inherit({
- EVENT_LOCK_TIMEOUT: 100,
- _handler: function(e) {
- var isMouseEvent = events.isMouseEvent(e);
- if (!isMouseEvent)
- this._skipNextEvents = true;
- if (isMouseEvent && this._mouseLocked)
- return;
- if (isMouseEvent && this._skipNextEvents) {
- this._skipNextEvents = false;
- this._mouseLocked = true;
- clearTimeout(this._unlockMouseTimer);
- this._unlockMouseTimer = setTimeout($.proxy(function() {
- this._mouseLocked = false
- }, this), this.EVENT_LOCK_TIMEOUT);
- return
- }
- return this.callBase(e)
- },
- _fireEvent: function(args) {
- var isMouseEvent = events.isMouseEvent(args.originalEvent),
- normalizer = isMouseEvent ? pointer.mouse.normalize : pointer.touch.normalize;
- return this.callBase($.extend(normalizer(args.originalEvent), args))
- },
- dispose: function() {
- this.callBase();
- this._skipNextEvents = false;
- this._mouseLocked = false;
- clearTimeout(this._unlockMouseTimer)
- }
- });
- pointer.mouseAndTouch = {
- strategy: MouseAndTouchStrategy,
- map: MouseAndTouchStrategyEventMap
- }
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.mspointer.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- pointer = events.pointer;
- var MsPointerStrategyEventMap = {
- dxpointerdown: "MSPointerDown pointerdown",
- dxpointermove: "MSPointerMove pointermove",
- dxpointerup: "MSPointerUp pointerup",
- dxpointercancel: "MSPointerCancel pointercancel",
- dxpointerover: "MSPointerOver pointerover",
- dxpointerout: "MSPointerOut pointerout",
- dxpointerenter: "mouseenter",
- dxpointerleave: "mouseleave"
- };
- var pointers = [];
- var getPointerIndex = function(e) {
- var index = -1;
- $.each(pointers, function(i, pointer) {
- if (e.pointerId === pointer.pointerId) {
- index = i;
- return true
- }
- });
- return index
- };
- var addPointer = function(e) {
- if (getPointerIndex(e) === -1)
- pointers.push(e)
- };
- var removePointer = function(e) {
- pointers.splice(getPointerIndex(e), 1)
- };
- var updatePointer = function(e) {
- pointers[getPointerIndex(e)] = e
- };
- var addEventsListner = function(events, handler) {
- events = events.split(" ");
- $.each(events, function(_, event) {
- document.addEventListener(event, handler, true)
- })
- };
- var activateMspointerStrategy = function() {
- var eventMap = MsPointerStrategyEventMap;
- addEventsListner(eventMap.dxpointerdown, addPointer);
- addEventsListner(eventMap.dxpointermove, updatePointer);
- addEventsListner(eventMap.dxpointerup, removePointer);
- addEventsListner(eventMap.dxpointercancel, removePointer);
- activateMspointerStrategy = $.noop
- };
- var MsPointerStrategy = pointer.BaseStrategy.inherit({
- ctor: function() {
- this.callBase.apply(this, arguments);
- activateMspointerStrategy()
- },
- _fireEvent: function(args) {
- return this.callBase($.extend({
- pointers: pointers,
- pointerId: args.originalEvent.pointerId
- }, args))
- }
- });
- pointer.msPointer = {
- strategy: MsPointerStrategy,
- map: MsPointerStrategyEventMap
- };
- DX.ui.events.__internals = DX.ui.events.__internals || {};
- $.extend(DX.ui.events.__internals, {cleanMsPointers: function() {
- pointers = []
- }})
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.pointer.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- support = DX.support,
- device = $.proxy(DX.devices.real, DX.devices),
- events = ui.events,
- pointer = events.pointer;
- var eventType = function() {
- if (support.pointer)
- return pointer.msPointer;
- if (support.touch && !(device().tablet || device().phone))
- return pointer.mouseAndTouch;
- if (support.touch)
- return pointer.touch;
- return pointer.mouse
- }();
- $.each(eventType.map, function(pointerEvent, originalEvents) {
- events.registerEvent(pointerEvent, new eventType.strategy(pointerEvent, originalEvents))
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.wheel.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var EVENT_NAME = "dxmousewheel",
- EVENT_NAMESPACE = "dxWheel";
- $.event.fixHooks["wheel"] = $.event.mouseHooks;
- var wheelEvent = document.onmousewheel !== undefined ? "mousewheel" : "wheel";
- var wheel = {
- setup: function(element, data) {
- var $element = $(element);
- $element.on(events.addNamespace(wheelEvent, EVENT_NAMESPACE), $.proxy(wheel._wheelHandler, wheel))
- },
- teardown: function(element) {
- var $element = $(element);
- $element.off("." + EVENT_NAMESPACE)
- },
- _wheelHandler: function(e) {
- var delta = this._getWheelDelta(e.originalEvent);
- events.fireEvent({
- type: EVENT_NAME,
- originalEvent: e,
- delta: delta,
- pointerType: "mouse"
- });
- e.stopPropagation()
- },
- _getWheelDelta: function(event) {
- return event.wheelDelta ? event.wheelDelta : -event.deltaY * 30
- }
- };
- events.registerEvent(EVENT_NAME, wheel)
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.hover.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var HOVERSTART_NAMESPACE = "dxHoverStart",
- HOVERSTART = "dxhoverstart",
- POINTERENTER_NAMESPACED_EVENT_NAME = events.addNamespace("dxpointerenter", HOVERSTART_NAMESPACE),
- POINTERDOWN_NAMESPACED_EVENT_NAME = events.addNamespace("dxpointerdown", HOVERSTART_NAMESPACE),
- POINTERUP_NAMESPACED_EVENT_NAME = events.addNamespace("dxpointerup", HOVERSTART_NAMESPACE),
- HOVEREND_NAMESPACE = "dxHoverEnd",
- HOVEREND = "dxhoverend",
- POINTERLEAVE_NAMESPACED_EVENT_NAME = events.addNamespace("dxpointerleave", HOVEREND_NAMESPACE);
- var Hover = DX.Class.inherit({
- noBubble: true,
- add: function(element, handleObj) {
- var $element = $(element);
- $element.off("." + this._namespace).on(this._originalEventName, handleObj.selector, $.proxy(this._handler, this))
- },
- _handler: function(e) {
- if (events.isTouchEvent(e))
- return;
- events.fireEvent({
- type: this._eventName,
- originalEvent: e,
- delegateTarget: e.delegateTarget
- })
- },
- teardown: function(element) {
- $(element).off("." + this._namespace)
- }
- });
- var HoverStart = Hover.inherit({
- ctor: function() {
- this._eventName = HOVERSTART;
- this._originalEventName = POINTERENTER_NAMESPACED_EVENT_NAME;
- this._namespace = HOVERSTART_NAMESPACE;
- this._isMouseDown = false;
- this._eventsAttached = 0
- },
- _handler: function(e) {
- if (!this._isMouseDown)
- this.callBase.apply(this, arguments)
- },
- setup: function() {
- $(document).off("." + HOVERSTART_NAMESPACE).on(POINTERDOWN_NAMESPACED_EVENT_NAME, $.proxy(function() {
- this._isMouseDown = true
- }, this)).on(POINTERUP_NAMESPACED_EVENT_NAME, $.proxy(function() {
- this._isMouseDown = false
- }, this));
- this._eventsAttached++
- },
- teardown: function() {
- this._eventsAttached--;
- if (this._eventsAttached === 0)
- $(document).off("." + HOVERSTART_NAMESPACE)
- }
- });
- var HoverEnd = Hover.inherit({ctor: function() {
- this._eventName = HOVEREND;
- this._originalEventName = POINTERLEAVE_NAMESPACED_EVENT_NAME;
- this._namespace = HOVEREND_NAMESPACE
- }});
- events.registerEvent(HOVERSTART, new HoverStart);
- events.registerEvent(HOVEREND, new HoverEnd)
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.manager.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var MANAGER_EVENT = "dxEventManager",
- EMITTER_DATA = "dxEmitter";
- var EventManager = DX.Class.inherit({
- ctor: function() {
- this._attachHandlers();
- this.reset();
- this._proxiedCancelHandler = $.proxy(this._cancelHandler, this);
- this._proxiedAcceptHandler = $.proxy(this._acceptHandler, this)
- },
- _attachHandlers: function() {
- $(document).on(events.addNamespace("dxpointerdown", MANAGER_EVENT), $.proxy(this._pointerDownHandler, this)).on(events.addNamespace("dxpointermove", MANAGER_EVENT), $.proxy(this._pointerMoveHandler, this)).on(events.addNamespace("dxpointerup dxpointercancel", MANAGER_EVENT), $.proxy(this._pointerUpHandler, this)).on(events.addNamespace("dxmousewheel", MANAGER_EVENT), $.proxy(this._mouseWheelHandler, this))
- },
- _eachEmitter: function(callback) {
- var activeEmitters = this._activeEmitters || [];
- var i = 0;
- while (activeEmitters.length > i) {
- var emitter = activeEmitters[i];
- if (callback(emitter) === false)
- break;
- if (activeEmitters[i] === emitter)
- i++
- }
- },
- _applyToEmitters: function(method, arg) {
- this._eachEmitter(function(emitter) {
- emitter[method].call(emitter, arg)
- })
- },
- reset: function() {
- this._eachEmitter(this._proxiedCancelHandler);
- this._activeEmitters = []
- },
- resetEmitter: function(emitter) {
- this._proxiedCancelHandler(emitter)
- },
- _pointerDownHandler: function(e) {
- if (events.isMouseEvent(e) && e.which > 1)
- return;
- this._updateEmitters(e)
- },
- _updateEmitters: function(e) {
- if (!this._isSetChanged(e))
- return;
- this._cleanEmitters(e);
- this._fetchEmitters(e)
- },
- _isSetChanged: function(e) {
- var currentSet = this._closestEmitter(e);
- var previousSet = this._emittersSet || [];
- var setChanged = currentSet.length !== previousSet.length;
- $.each(currentSet, function(index, emitter) {
- setChanged = setChanged || previousSet[index] !== emitter;
- return !setChanged
- });
- this._emittersSet = currentSet;
- return setChanged
- },
- _closestEmitter: function(e) {
- var that = this,
- result = [],
- $element = $(e.target);
- function handleEmitter(_, emitter) {
- if (!!emitter && emitter.validatePointers(e) && emitter.validate(e)) {
- emitter.addCancelCallback(that._proxiedCancelHandler);
- emitter.addAcceptCallback(that._proxiedAcceptHandler);
- result.push(emitter)
- }
- }
- while ($element.length) {
- var emitters = $.data($element.get(0), EMITTER_DATA) || [];
- $.each(emitters, handleEmitter);
- $element = $element.parent()
- }
- return result
- },
- _acceptHandler: function(acceptedEmitter, e) {
- var that = this;
- this._eachEmitter(function(emitter) {
- if (emitter !== acceptedEmitter)
- that._cancelEmitter(emitter, e)
- })
- },
- _cancelHandler: function(canceledEmitter, e) {
- this._cancelEmitter(canceledEmitter, e)
- },
- _cancelEmitter: function(emitter, e) {
- var activeEmitters = this._activeEmitters;
- if (e)
- emitter.cancel(e);
- else
- emitter.reset();
- emitter.removeCancelCallback();
- emitter.removeAcceptCallback();
- var emitterIndex = $.inArray(emitter, activeEmitters);
- if (emitterIndex > -1)
- activeEmitters.splice(emitterIndex, 1)
- },
- _cleanEmitters: function(e) {
- this._applyToEmitters("end", e);
- this.reset(e)
- },
- _fetchEmitters: function(e) {
- this._activeEmitters = this._emittersSet.slice();
- this._applyToEmitters("start", e)
- },
- _pointerMoveHandler: function(e) {
- this._applyToEmitters("move", e)
- },
- _pointerUpHandler: function(e) {
- this._updateEmitters(e)
- },
- _mouseWheelHandler: function(e) {
- var allowInterruption = true;
- this._eachEmitter(function(emitter) {
- allowInterruption = emitter.allowInterruptionByMousewheel() && allowInterruption;
- return allowInterruption
- });
- if (!allowInterruption)
- return;
- e.pointers = [null];
- this._pointerDownHandler(e);
- this._eachEmitter(function(emitter) {
- var direction = emitter.getDirection ? emitter.getDirection(e) : "",
- prop = direction !== "horizontal" ? "pageY" : "pageX";
- if (direction)
- e[prop] += e.delta;
- return !direction
- });
- this._pointerMoveHandler(e);
- e.pointers = [];
- this._pointerUpHandler(e)
- },
- isActive: function(element) {
- var result = false;
- this._eachEmitter(function(emitter) {
- result = result || emitter.getElement().is(element)
- });
- return result
- }
- });
- var eventManager = new EventManager;
- var EMITTER_SUBSCRIPTION_DATA = "dxEmitterSubscription";
- var registerEmitter = function(emitterConfig) {
- var emitterClass = emitterConfig.emitter,
- emitterName = emitterConfig.events[0],
- emitterEvents = emitterConfig.events;
- $.each(emitterEvents, function(_, eventName) {
- events.registerEvent(eventName, {
- noBubble: !emitterConfig.bubble,
- setup: function(element, data) {
- var subscriptions = $.data(element, EMITTER_SUBSCRIPTION_DATA) || {},
- emitters = $.data(element, EMITTER_DATA) || {},
- emitter = emitters[emitterName] || new emitterClass(element);
- subscriptions[eventName] = true;
- emitters[emitterName] = emitter;
- $.data(element, EMITTER_DATA, emitters);
- $.data(element, EMITTER_SUBSCRIPTION_DATA, subscriptions)
- },
- add: function(element, handleObj) {
- var emitters = $.data(element, EMITTER_DATA),
- emitter = emitters[emitterName];
- emitter.configurate($.extend({delegateSelector: handleObj.selector}, handleObj.data), handleObj.type)
- },
- teardown: function(element) {
- var subscriptions = $.data(element, EMITTER_SUBSCRIPTION_DATA),
- emitters = $.data(element, EMITTER_DATA),
- emitter = emitters[emitterName];
- delete subscriptions[eventName];
- var disposeEmitter = true;
- $.each(emitterEvents, function(_, eventName) {
- disposeEmitter = disposeEmitter && !subscriptions[eventName];
- return disposeEmitter
- });
- if (disposeEmitter) {
- if (eventManager.isActive(element))
- eventManager.resetEmitter(emitter);
- emitter && emitter.dispose();
- delete emitters[emitterName]
- }
- }
- })
- })
- };
- $.extend(events, {registerEmitter: registerEmitter})
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var Emitter = DX.Class.inherit({
- ctor: function(element) {
- this._$element = $(element);
- this._cancelCallback = $.Callbacks();
- this._acceptCallback = $.Callbacks()
- },
- getElement: function() {
- return this._$element
- },
- validate: function(e) {
- return e.type !== "dxmousewheel"
- },
- validatePointers: function(e) {
- return events.hasTouches(e) === 1
- },
- allowInterruptionByMousewheel: function() {
- return true
- },
- configurate: function(data) {
- $.extend(this, data)
- },
- addCancelCallback: function(callback) {
- this._cancelCallback.add(callback)
- },
- removeCancelCallback: function() {
- this._cancelCallback.empty()
- },
- _cancel: function(e) {
- this._cancelCallback.fire(this, e)
- },
- addAcceptCallback: function(callback) {
- this._acceptCallback.add(callback)
- },
- removeAcceptCallback: function() {
- this._acceptCallback.empty()
- },
- _accept: function(e) {
- this._acceptCallback.fire(this, e)
- },
- _requestAccept: function(e) {
- this._acceptRequestEvent = e
- },
- _forgetAccept: function() {
- this._accept(this._acceptRequestEvent);
- this._acceptRequestEvent = null
- },
- start: $.noop,
- move: $.noop,
- end: $.noop,
- cancel: $.noop,
- reset: function() {
- if (this._acceptRequestEvent)
- this._accept(this._acceptRequestEvent)
- },
- _fireEvent: function(eventName, e, params) {
- var eventData = $.extend({
- type: eventName,
- originalEvent: e,
- target: this._getEmitterTarget(e),
- delegateTarget: this.getElement().get(0)
- }, params);
- e = events.fireEvent(eventData);
- if (e.cancel)
- this._cancel(e);
- return e
- },
- _getEmitterTarget: function(e) {
- return (this.delegateSelector ? $(e.target).closest(this.delegateSelector) : this.getElement()).get(0)
- },
- dispose: $.noop
- });
- $.extend(events, {Emitter: Emitter})
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.feedback.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- ACTIVE_EVENT_NAME = "dxactive",
- INACTIVE_EVENT_NAME = "dxinactive",
- ACTIVE_TIMEOUT = 30,
- INACTIVE_TIMEOUT = 400;
- var activeEmitter;
- var FeedbackEmitter = events.Emitter.inherit({
- configurate: function(data, eventName) {
- switch (eventName) {
- case ACTIVE_EVENT_NAME:
- data.activeTimeout = data.timeout;
- break;
- case INACTIVE_EVENT_NAME:
- data.inactiveTimeout = data.timeout;
- break
- }
- this.callBase(data)
- },
- start: function(e) {
- var element = this.getElement().get(0);
- var activeElement = activeEmitter && activeEmitter.getElement().get(0);
- var activeChildExists = $.contains(element, activeElement);
- var childJustActivated = activeEmitter && activeEmitter._activeTimer !== null;
- if (activeChildExists && childJustActivated)
- this._cancel();
- else {
- if (activeEmitter)
- activeEmitter._forceInactiveTimer();
- activeEmitter = this;
- var eventTarget = this._getEmitterTarget(e);
- this._forceActiveTimer = $.proxy(this._fireActive, this, e, eventTarget);
- this._forceInactiveTimer = $.proxy(this._fireInctive, this, e, eventTarget);
- this._startActiveTimer(e)
- }
- },
- cancel: function(e) {
- this.end(e)
- },
- end: function(e) {
- var skipTimers = e.type !== "dxpointerup";
- if (skipTimers)
- this._stopActiveTimer();
- else
- this._forceActiveTimer();
- this._startInactiveTimer(e);
- if (skipTimers)
- this._forceInactiveTimer()
- },
- dispose: function() {
- this._stopActiveTimer();
- this._stopInactiveTimer();
- this.callBase()
- },
- _startActiveTimer: function(e) {
- var activeTimeout = "activeTimeout" in this ? this.activeTimeout : ACTIVE_TIMEOUT;
- this._activeTimer = window.setTimeout(this._forceActiveTimer, activeTimeout)
- },
- _fireActive: function(e, eventTarget) {
- this._stopActiveTimer();
- this._fireEvent(ACTIVE_EVENT_NAME, e, {target: eventTarget})
- },
- _stopActiveTimer: function() {
- clearTimeout(this._activeTimer);
- this._activeTimer = null
- },
- _forceActiveTimer: $.noop,
- _startInactiveTimer: function(e) {
- var inactiveTimeout = "inactiveTimeout" in this ? this.inactiveTimeout : INACTIVE_TIMEOUT;
- this._inactiveTimer = window.setTimeout(this._forceInactiveTimer, inactiveTimeout)
- },
- _fireInctive: function(e, eventTarget) {
- this._stopInactiveTimer();
- activeEmitter = null;
- this._fireEvent(INACTIVE_EVENT_NAME, e, {target: eventTarget})
- },
- _stopInactiveTimer: function() {
- clearTimeout(this._inactiveTimer);
- this._inactiveTimer = null
- },
- _forceInactiveTimer: $.noop,
- lockInactive: function() {
- this._forceActiveTimer();
- this._stopInactiveTimer();
- activeEmitter = null;
- this._cancel();
- return this._forceInactiveTimer
- }
- });
- ui.events = $.extend(ui.events, {lockFeedback: function(deferred) {
- var lockInactive = activeEmitter ? activeEmitter.lockInactive() : $.noop;
- $.when(deferred).always(lockInactive)
- }});
- events.registerEmitter({
- emitter: FeedbackEmitter,
- events: [ACTIVE_EVENT_NAME, INACTIVE_EVENT_NAME]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.click.js */
- (function($, DX, wnd, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- abs = Math.abs,
- CLICK_EVENT_NAME = "dxclick",
- TOUCH_BOUNDARY = 10;
- var isInput = function(element) {
- return $(element).is("input, textarea, select, button ,:focus, :focus *")
- };
- var misc = {requestAnimationFrame: DX.requestAnimationFrame};
- var ClickEmitter = events.Emitter.inherit({
- ctor: function(element) {
- this.callBase(element);
- this._makeElementClickable($(element))
- },
- _makeElementClickable: function($element) {
- if (!$element.attr("onclick"))
- $element.attr("onclick", "void(0)")
- },
- start: function(e) {
- this._blurPrevented = e.dxPreventBlur;
- this._startTarget = e.target;
- this._startEventData = events.eventData(e)
- },
- end: function(e) {
- if (this._eventOutOfElement(e, this.getElement().get(0)) || e.type === "dxpointercancel") {
- this._cancel(e);
- return
- }
- if (!isInput(e.target) && !this._blurPrevented)
- utils.resetActiveElement();
- this._accept(e);
- misc.requestAnimationFrame($.proxy(function() {
- this._fireClickEvent(e)
- }, this))
- },
- _eventOutOfElement: function(e, element) {
- var target = e.target,
- targetChanged = !$.contains(element, target) && element !== target,
- gestureDelta = events.eventDelta(events.eventData(e), this._startEventData),
- boundsExceeded = abs(gestureDelta.x) > TOUCH_BOUNDARY || abs(gestureDelta.y) > TOUCH_BOUNDARY;
- return targetChanged || boundsExceeded
- },
- _fireClickEvent: function(e) {
- this._fireEvent(CLICK_EVENT_NAME, e, {target: utils.closestCommonParent(this._startTarget, e.target)})
- }
- });
- (function() {
- var useNativeClick = DX.devices.real().generic;
- if (useNativeClick) {
- var prevented = null;
- ClickEmitter = ClickEmitter.inherit({
- start: function() {
- prevented = null
- },
- end: $.noop,
- cancel: function() {
- prevented = true
- }
- });
- var clickHandler = function(e) {
- if ((!e.which || e.which === 1) && !prevented)
- events.fireEvent({
- type: CLICK_EVENT_NAME,
- originalEvent: e
- })
- };
- $(document).on(events.addNamespace("click", "NATIVE_DXCLICK_STRATEGY"), clickHandler)
- }
- $.extend(events.__internals, {useNativeClick: useNativeClick})
- })();
- (function() {
- var fixBuggyInertia = DX.devices.real().ios;
- if (fixBuggyInertia) {
- var GESTURE_LOCK_KEY = "dxGestureLock";
- ClickEmitter = ClickEmitter.inherit({_fireClickEvent: function(e) {
- var $element = $(e.target);
- while ($element.length) {
- if ($.data($element.get(0), GESTURE_LOCK_KEY))
- return;
- $element = $element.parent()
- }
- this.callBase.apply(this, arguments)
- }})
- }
- $.extend(events.__internals, {fixBuggyInertia: fixBuggyInertia})
- })();
- (function() {
- var desktopDevice = DX.devices.real().generic;
- if (!desktopDevice) {
- var startTarget = null,
- blurPrevented = false;
- var pointerDownHandler = function(e) {
- startTarget = e.target;
- blurPrevented = e.dxPreventBlur
- };
- var clickHandler = function(e) {
- var $target = $(e.target);
- if (!blurPrevented && startTarget && !$target.is(startTarget) && !$(startTarget).is("label") && isInput($target))
- utils.resetActiveElement();
- startTarget = null;
- blurPrevented = false
- };
- var NATIVE_CLICK_FIXER_NAMESPACE = "NATIVE_CLICK_FIXER";
- $(document).on(events.addNamespace("dxpointerdown", NATIVE_CLICK_FIXER_NAMESPACE), pointerDownHandler).on(events.addNamespace("click", NATIVE_CLICK_FIXER_NAMESPACE), clickHandler)
- }
- })();
- events.registerEmitter({
- emitter: ClickEmitter,
- bubble: true,
- events: [CLICK_EVENT_NAME]
- });
- $.extend(events.__internals, {
- useFastClick: !events.__internals.useNativeClick && !events.__internals.fixBuggyInertia,
- misc: misc
- })
- })(jQuery, DevExpress, window);
- /*! Module core, file ui.events.emitter.hold.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- abs = Math.abs,
- HOLD_EVENT_NAME = "dxhold",
- HOLD_TIMEOUT = 750,
- TOUCH_BOUNDARY = 5;
- var HoldEmitter = events.Emitter.inherit({
- start: function(e) {
- this._startEventData = events.eventData(e);
- this._startTimer(e)
- },
- _startTimer: function(e) {
- var holdTimeout = "timeout" in this ? this.timeout : HOLD_TIMEOUT;
- this._holdTimer = setTimeout($.proxy(function() {
- this._requestAccept(e);
- this._fireEvent(HOLD_EVENT_NAME, e, {target: e.target});
- this._forgetAccept()
- }, this), holdTimeout)
- },
- move: function(e) {
- if (this._touchWasMoved(e))
- this._cancel(e)
- },
- _touchWasMoved: function(e) {
- var delta = events.eventDelta(this._startEventData, events.eventData(e));
- return abs(delta.x) > TOUCH_BOUNDARY || abs(delta.y) > TOUCH_BOUNDARY
- },
- end: function() {
- this._stopTimer()
- },
- _stopTimer: function() {
- clearTimeout(this._holdTimer)
- },
- cancel: function() {
- this._stopTimer()
- }
- });
- events.registerEmitter({
- emitter: HoldEmitter,
- bubble: true,
- events: [HOLD_EVENT_NAME]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.gesture.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- devices = DX.devices,
- support = DX.support,
- abs = Math.abs;
- var SLEEP = 0,
- INITED = 1,
- STARTED = 2,
- TOUCH_BOUNDARY = 10,
- IMMEDIATE_TOUCH_BOUNDARY = 0,
- IMMEDIATE_TIMEOUT = 180;
- var isMousewheelEvent = function(e) {
- return e && e.type === "dxmousewheel"
- };
- var GestureEmitter = events.Emitter.inherit({
- configurate: function(data) {
- this.getElement().css("msTouchAction", data.immediate ? "pinch-zoom" : "");
- this.callBase(data)
- },
- allowInterruptionByMousewheel: function() {
- return this._stage !== STARTED
- },
- getDirection: function() {
- return this.direction
- },
- _cancel: function(e) {
- this.callBase.apply(this, arguments);
- this._togglePointerAddons(true);
- this._stage = SLEEP
- },
- start: function(e) {
- if (events.needSkipEvent(e)) {
- this._cancel(e);
- return
- }
- this._startEvent = events.createEvent(e);
- this._startEventData = events.eventData(e);
- this._prevEventData = this._startEventData;
- this._stage = INITED;
- this._init(e);
- this._setupImmediateTimer()
- },
- _setupImmediateTimer: function() {
- clearTimeout(this._immediateTimer);
- this._immedeateAccepted = false;
- if (!this.immediate)
- return;
- this._immediateTimer = setTimeout($.proxy(function() {
- this._immedeateAccepted = true
- }, this), IMMEDIATE_TIMEOUT)
- },
- move: function(e) {
- if (this._stage === INITED && this._directionConfirmed(e)) {
- this._stage = STARTED;
- this._resetActiveElement();
- this._togglePointerAddons(false, e);
- this._clearSelection(e);
- this._adjustStartEvent(e);
- this._start(this._startEvent);
- this._prevEventData = events.eventData(this._startEvent);
- if (this._stage === SLEEP)
- return;
- this._requestAccept(e);
- this._move(e);
- this._forgetAccept()
- }
- else if (this._stage === STARTED)
- this._move(e);
- this._prevEventData = events.eventData(e)
- },
- _directionConfirmed: function(e) {
- var touchBoundary = this._getTouchBoundary(e),
- delta = events.eventDelta(this._startEventData, events.eventData(e)),
- deltaX = abs(delta.x),
- deltaY = abs(delta.y);
- var horizontalMove = this._validateMove(touchBoundary, deltaX, deltaY),
- verticalMove = this._validateMove(touchBoundary, deltaY, deltaX);
- var direction = this.getDirection(e),
- bothAccepted = direction === "both" && (horizontalMove || verticalMove),
- horizontalAccepted = direction === "horizontal" && horizontalMove,
- verticalAccepted = direction === "vertical" && verticalMove;
- return bothAccepted || horizontalAccepted || verticalAccepted || this._immedeateAccepted
- },
- _validateMove: function(touchBoundary, mainAxis, crossAxis) {
- return mainAxis && mainAxis >= touchBoundary && (this.immediate ? mainAxis >= crossAxis : true)
- },
- _getTouchBoundary: function(e) {
- return this.immediate || isMousewheelEvent(e) ? IMMEDIATE_TOUCH_BOUNDARY : TOUCH_BOUNDARY
- },
- _adjustStartEvent: function(e) {
- var touchBoundary = this._getTouchBoundary(e),
- delta = events.eventDelta(this._startEventData, events.eventData(e));
- this._startEvent.pageX += utils.sign(delta.x) * touchBoundary;
- this._startEvent.pageY += utils.sign(delta.y) * touchBoundary
- },
- _resetActiveElement: function() {
- if (devices.real().platform === "ios" && $(":focus", this.getElement()).length)
- utils.resetActiveElement()
- },
- _togglePointerAddons: function(toggle, e) {
- var isStarted = this._stage === STARTED;
- if (isStarted) {
- this._togglePointerInteration(toggle);
- if (!isMousewheelEvent(e))
- this._togglePointerCursor(toggle)
- }
- },
- _togglePointerInteration: function(toggle) {
- var isDesktop = devices.real().platform === "generic";
- if (isDesktop) {
- $("body").css("pointer-events", toggle ? "" : "none");
- if (support.supportProp("user-select"))
- $("body").css(support.styleProp("user-select"), toggle ? "" : "none")
- }
- },
- _togglePointerCursor: function(toggle) {
- if (toggle)
- $("html").css("cursor", this._originalCursor);
- else {
- this._originalCursor = $("html").css("cursor");
- $("html").css("cursor", this.getElement().css("cursor"))
- }
- },
- _clearSelection: function(e) {
- if (isMousewheelEvent(e) || events.isTouchEvent(e))
- return;
- utils.clearSelection()
- },
- end: function(e) {
- this._togglePointerAddons(true, e);
- if (this._stage === STARTED)
- this._end(e);
- else if (this._stage === INITED)
- this._stop(e);
- this._stage = SLEEP
- },
- dispose: function() {
- clearTimeout(this._immediateTimer);
- this.callBase.apply(this, arguments);
- this._togglePointerAddons(true)
- },
- _init: $.noop,
- _start: $.noop,
- _move: $.noop,
- _stop: $.noop,
- _end: $.noop
- });
- $.extend(events, {GestureEmitter: GestureEmitter});
- var ORIG_TOUCH_BOUNDARY = TOUCH_BOUNDARY;
- $.extend(DX.ui.events.__internals, {
- GESTURE_TOUCH_BOUNDARY: ORIG_TOUCH_BOUNDARY,
- resetTouchBoundary: function() {
- TOUCH_BOUNDARY = ORIG_TOUCH_BOUNDARY;
- events.__internals.GESTURE_TOUCH_BOUNDARY = ORIG_TOUCH_BOUNDARY
- },
- cleanTouchBoundary: function() {
- TOUCH_BOUNDARY = 0
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.gesture.scroll.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events;
- var SCROLL_INIT_EVENT = "dxscrollinit",
- SCROLL_START_EVENT = "dxscrollstart",
- SCROLL_MOVE_EVENT = "dxscroll",
- SCROLL_END_EVENT = "dxscrollend",
- SCROLL_STOP_EVENT = "dxscrollstop",
- SCROLL_CANCEL_EVENT = "dxscrollcancel",
- INERTIA_TIMEOUT = 100,
- VELOCITY_CALC_TIMEOUT = 200,
- FRAME_DURATION = Math.round(1000 / 60),
- GESTURE_LOCK_KEY = "dxGestureLock",
- GESTURE_LOCK_TIMEOUT = 200,
- NAMESPACED_SCROLL_EVENT = events.addNamespace("scroll", "dxScrollEmitter");
- var ScrollEmitter = events.GestureEmitter.inherit({
- ctor: function(element) {
- this.callBase.apply(this, arguments);
- this.direction = "both";
- $.data(element, "scroll", $.proxy(this._treatScroll, this));
- $(element).on(NAMESPACED_SCROLL_EVENT, $.proxy(this._treatScroll, this))
- },
- validate: function() {
- return true
- },
- _domElement: function() {
- return this.getElement().get(0)
- },
- _treatScroll: function() {
- this._prepareGesture();
- this._forgetGesture()
- },
- _prepareGesture: function() {
- if (this._gestureEndTimer)
- this._clearGestureTimer();
- else
- $.data(this._domElement(), GESTURE_LOCK_KEY, true)
- },
- _forgetGesture: function() {
- var that = this;
- this._gestureEndTimer = setTimeout(function() {
- $.data(that._domElement(), GESTURE_LOCK_KEY, false);
- that._gestureEndTimer = null
- }, GESTURE_LOCK_TIMEOUT)
- },
- _init: function(e) {
- if ($.data(this._domElement(), GESTURE_LOCK_KEY))
- this._accept(e);
- this._fireEvent(SCROLL_INIT_EVENT, e)
- },
- move: function(e) {
- this.callBase.apply(this, arguments);
- e.isScrollingEvent = this.isNative || e.isScrollingEvent
- },
- _start: function(e) {
- this._savedEventData = events.eventData(e);
- this._fireEvent(SCROLL_START_EVENT, e, {delta: events.eventDelta(this._savedEventData, events.eventData(e))})
- },
- _move: function(e) {
- var currentEventData = events.eventData(e);
- this._fireEvent(SCROLL_MOVE_EVENT, e, {delta: events.eventDelta(this._prevEventData, currentEventData)});
- var eventDelta = events.eventDelta(this._savedEventData, currentEventData);
- if (eventDelta.time > VELOCITY_CALC_TIMEOUT)
- this._savedEventData = this._prevEventData
- },
- _end: function(e) {
- var endEventDelta = events.eventDelta(this._prevEventData, events.eventData(e));
- var velocity = {
- x: 0,
- y: 0
- };
- var isWheelEvent = e.type === "dxmousewheel";
- if (endEventDelta.time < INERTIA_TIMEOUT) {
- var deltaEventData = events.eventDelta(this._savedEventData, this._prevEventData);
- velocity = {
- x: isWheelEvent ? 0 : deltaEventData.x * FRAME_DURATION / deltaEventData.time,
- y: isWheelEvent ? 0 : deltaEventData.y * FRAME_DURATION / deltaEventData.time
- }
- }
- this._fireEvent(SCROLL_END_EVENT, e, {velocity: velocity})
- },
- _stop: function(e) {
- this._fireEvent(SCROLL_STOP_EVENT, e)
- },
- cancel: function(e) {
- this.callBase.apply(this, arguments);
- this._fireEvent(SCROLL_CANCEL_EVENT, e)
- },
- dispose: function() {
- this.callBase.apply(this, arguments);
- $.data(this._domElement(), GESTURE_LOCK_KEY, false);
- this._clearGestureTimer();
- this.getElement().off(NAMESPACED_SCROLL_EVENT)
- },
- _clearGestureTimer: function() {
- clearTimeout(this._gestureEndTimer);
- this._gestureEndTimer = null
- }
- });
- events.registerEmitter({
- emitter: ScrollEmitter,
- events: [SCROLL_INIT_EVENT, SCROLL_START_EVENT, SCROLL_MOVE_EVENT, SCROLL_END_EVENT, SCROLL_STOP_EVENT, SCROLL_CANCEL_EVENT]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.gesture.swipe.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- SWIPE_START_EVENT = "dxswipestart",
- SWIPE_EVENT = "dxswipe",
- SWIPE_END_EVENT = "dxswipeend";
- var HorizontalStrategy = {
- defaultItemSizeFunc: function() {
- return this.getElement().width()
- },
- getBounds: function() {
- return [this._maxLeftOffset, this._maxRightOffset]
- },
- calcOffsetRatio: function(e) {
- var endEventData = events.eventData(e);
- return (endEventData.x - (this._savedEventData && this._savedEventData.x || 0)) / this._itemSizeFunc().call(this, e)
- },
- isFastSwipe: function(e) {
- var endEventData = events.eventData(e);
- return this.FAST_SWIPE_SPEED_LIMIT * Math.abs(endEventData.x - this._tickData.x) >= endEventData.time - this._tickData.time
- }
- };
- var VerticalStrategy = {
- defaultItemSizeFunc: function() {
- return this.getElement().height()
- },
- getBounds: function() {
- return [this._maxTopOffset, this._maxBottomOffset]
- },
- calcOffsetRatio: function(e) {
- var endEventData = events.eventData(e);
- return (endEventData.y - (this._savedEventData && this._savedEventData.y || 0)) / this._itemSizeFunc().call(this, e)
- },
- isFastSwipe: function(e) {
- var endEventData = events.eventData(e);
- return this.FAST_SWIPE_SPEED_LIMIT * Math.abs(endEventData.y - this._tickData.y) >= endEventData.time - this._tickData.time
- }
- };
- var STRATEGIES = {
- horizontal: HorizontalStrategy,
- vertical: VerticalStrategy
- };
- var SwipeEmitter = events.GestureEmitter.inherit({
- TICK_INTERVAL: 300,
- FAST_SWIPE_SPEED_LIMIT: 5,
- ctor: function(element) {
- this.callBase(element);
- this.direction = "horizontal";
- this.elastic = true
- },
- _getStrategy: function() {
- return STRATEGIES[this.direction]
- },
- _defaultItemSizeFunc: function() {
- return this._getStrategy().defaultItemSizeFunc.call(this)
- },
- _itemSizeFunc: function() {
- return this.itemSizeFunc || this._defaultItemSizeFunc
- },
- _start: function(e) {
- this._savedEventData = events.eventData(e);
- this._tickData = {time: 0};
- e = this._fireEvent(SWIPE_START_EVENT, e);
- if (!e.cancel) {
- this._maxLeftOffset = e.maxLeftOffset;
- this._maxRightOffset = e.maxRightOffset;
- this._maxTopOffset = e.maxTopOffset;
- this._maxBottomOffset = e.maxBottomOffset
- }
- },
- _move: function(e) {
- var strategy = this._getStrategy(),
- moveEventData = events.eventData(e),
- offset = strategy.calcOffsetRatio.call(this, e);
- offset = this._fitOffset(offset, this.elastic);
- if (moveEventData.time - this._tickData.time > this.TICK_INTERVAL)
- this._tickData = moveEventData;
- this._fireEvent(SWIPE_EVENT, e, {offset: offset});
- e.preventDefault()
- },
- _end: function(e) {
- var strategy = this._getStrategy(),
- offsetRatio = strategy.calcOffsetRatio.call(this, e),
- isFast = strategy.isFastSwipe.call(this, e),
- startOffset = offsetRatio,
- targetOffset = this._calcTargetOffset(offsetRatio, isFast);
- startOffset = this._fitOffset(startOffset, this.elastic);
- targetOffset = this._fitOffset(targetOffset, false);
- this._fireEvent(SWIPE_END_EVENT, e, {
- offset: startOffset,
- targetOffset: targetOffset
- })
- },
- _fitOffset: function(offset, elastic) {
- var strategy = this._getStrategy(),
- bounds = strategy.getBounds.call(this);
- if (offset < -bounds[0])
- return elastic ? (-2 * bounds[0] + offset) / 3 : -bounds[0];
- if (offset > bounds[1])
- return elastic ? (2 * bounds[1] + offset) / 3 : bounds[1];
- return offset
- },
- _calcTargetOffset: function(offsetRatio, isFast) {
- var result;
- if (isFast) {
- result = Math.ceil(Math.abs(offsetRatio));
- if (offsetRatio < 0)
- result = -result
- }
- else
- result = Math.round(offsetRatio);
- return result
- }
- });
- events.registerEmitter({
- emitter: SwipeEmitter,
- events: [SWIPE_START_EVENT, SWIPE_EVENT, SWIPE_END_EVENT]
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.gesture.drag.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- wrapToArray = utils.wrapToArray;
- var DRAG_START_EVENT = "dxdragstart",
- DRAG_EVENT = "dxdrag",
- DRAG_END_EVENT = "dxdragend",
- DRAG_ENTER_EVENT = "dxdragenter",
- DRAG_LEAVE_EVENT = "dxdragleave",
- DROP_EVENT = "dxdrop";
- var knownDropTargets = [],
- knownDropTargetSelectors = [],
- knownDropTargetConfigs = [];
- var dropTargetRegistration = {
- setup: function(element, data) {
- var knownDropTarget = $.inArray(element, knownDropTargets) !== -1;
- if (!knownDropTarget) {
- knownDropTargets.push(element);
- knownDropTargetSelectors.push([]);
- knownDropTargetConfigs.push(data || {})
- }
- },
- add: function(element, handleObj) {
- var index = $.inArray(element, knownDropTargets);
- var selector = handleObj.selector;
- if ($.inArray(selector, knownDropTargetSelectors[index]) === -1)
- knownDropTargetSelectors[index].push(selector)
- },
- teardown: function(element, data) {
- var elementEvents = $._data(element, "events"),
- handlersCount = 0;
- $.each([DRAG_ENTER_EVENT, DRAG_LEAVE_EVENT, DROP_EVENT], function(_, eventName) {
- var eventHandlers = elementEvents[eventName];
- if (eventHandlers)
- handlersCount += eventHandlers.length
- });
- if (!handlersCount) {
- var index = $.inArray(element, knownDropTargets);
- knownDropTargets.splice(index, 1);
- knownDropTargetSelectors.splice(index, 1);
- knownDropTargetConfigs.splice(index, 1)
- }
- }
- };
- events.registerEvent(DRAG_ENTER_EVENT, dropTargetRegistration);
- events.registerEvent(DRAG_LEAVE_EVENT, dropTargetRegistration);
- events.registerEvent(DROP_EVENT, dropTargetRegistration);
- var getItemDelegatedTargets = function($element) {
- var dropTargetIndex = $.inArray($element.get(0), knownDropTargets),
- dropTargetSelectors = knownDropTargetSelectors[dropTargetIndex];
- var $delegatedTargets = $element.find(dropTargetSelectors.join(", "));
- if ($.inArray(undefined, dropTargetSelectors) !== -1)
- $delegatedTargets = $delegatedTargets.addBack();
- return $delegatedTargets
- };
- var getItemConfig = function($element) {
- var dropTargetIndex = $.inArray($element.get(0), knownDropTargets);
- return knownDropTargetConfigs[dropTargetIndex]
- };
- var getItemPosition = function(dropTargetConfig, $element) {
- if (dropTargetConfig.itemPositionFunc)
- return dropTargetConfig.itemPositionFunc($element);
- else
- return $element.offset()
- };
- var getItemSize = function(dropTargetConfig, $element) {
- if (dropTargetConfig.itemSizeFunc)
- return dropTargetConfig.itemSizeFunc($element);
- return {
- width: $element.width(),
- height: $element.height()
- }
- };
- var DragEmitter = events.GestureEmitter.inherit({
- ctor: function(element) {
- this.callBase(element);
- this.direction = "both"
- },
- _init: function(e) {
- this._initEvent = e
- },
- _start: function(e) {
- e = this._fireEvent(DRAG_START_EVENT, this._initEvent);
- this._maxLeftOffset = e.maxLeftOffset;
- this._maxRightOffset = e.maxRightOffset;
- this._maxTopOffset = e.maxTopOffset;
- this._maxBottomOffset = e.maxBottomOffset;
- var dropTargets = wrapToArray(e.targetElements || (e.targetElements === null ? [] : knownDropTargets));
- this._dropTargets = $.map(dropTargets, function(element) {
- return $(element).get(0)
- })
- },
- _move: function(e) {
- var eventData = events.eventData(e),
- dragOffset = this._calculateOffset(eventData);
- this._fireEvent(DRAG_EVENT, e, {offset: dragOffset});
- this._processDropTargets(e, dragOffset);
- e.preventDefault()
- },
- _calculateOffset: function(eventData) {
- return {
- x: this._calculateXOffset(eventData),
- y: this._calculateYOffset(eventData)
- }
- },
- _calculateXOffset: function(eventData) {
- if (this.direction !== "vertical") {
- var offset = eventData.x - this._startEventData.x;
- return this._fitOffset(offset, this._maxLeftOffset, this._maxRightOffset)
- }
- return 0
- },
- _calculateYOffset: function(eventData) {
- if (this.direction !== "horizontal") {
- var offset = eventData.y - this._startEventData.y;
- return this._fitOffset(offset, this._maxTopOffset, this._maxBottomOffset)
- }
- return 0
- },
- _fitOffset: function(offset, minOffset, maxOffset) {
- if (minOffset != null)
- offset = Math.max(offset, -minOffset);
- if (maxOffset != null)
- offset = Math.min(offset, maxOffset);
- return offset
- },
- _processDropTargets: function(e, dragOffset) {
- var target = this._findDropTarget(e),
- sameTarget = target === this._currentDropTarget;
- if (!sameTarget) {
- this._fireDropTargetEvent(e, DRAG_LEAVE_EVENT);
- this._currentDropTarget = target;
- this._fireDropTargetEvent(e, DRAG_ENTER_EVENT)
- }
- },
- _fireDropTargetEvent: function(event, eventName) {
- if (!this._currentDropTarget)
- return;
- var eventData = {
- type: eventName,
- originalEvent: event,
- draggingElement: this._$element.get(0),
- target: this._currentDropTarget
- };
- events.fireEvent(eventData)
- },
- _findDropTarget: function(e) {
- var that = this,
- result;
- $.each(knownDropTargets, function(_, target) {
- if (!that._checkDropTargetActive(target))
- return;
- var $target = $(target);
- $.each(getItemDelegatedTargets($target), function(_, delegatedTarget) {
- var $delegatedTarget = $(delegatedTarget);
- if (that._checkDropTarget(getItemConfig($target), $delegatedTarget, e))
- result = delegatedTarget
- })
- });
- return result
- },
- _checkDropTargetActive: function(target) {
- var active = false;
- $.each(this._dropTargets, function(_, activeTarget) {
- active = active || activeTarget === target || $.contains(activeTarget, target);
- return !active
- });
- return active
- },
- _checkDropTarget: function(config, $target, e) {
- var isDraggingElement = $target.get(0) === this._$element.get(0);
- if (isDraggingElement)
- return false;
- var targetPosition = getItemPosition(config, $target);
- if (e.pageX < targetPosition.left)
- return false;
- if (e.pageY < targetPosition.top)
- return false;
- var targetSize = getItemSize(config, $target);
- if (e.pageX > targetPosition.left + targetSize.width)
- return false;
- if (e.pageY > targetPosition.top + targetSize.height)
- return false;
- return $target
- },
- _end: function(e) {
- var eventData = events.eventData(e);
- this._fireEvent(DRAG_END_EVENT, e, {offset: this._calculateOffset(eventData)});
- this._fireDropTargetEvent(e, DROP_EVENT);
- delete this._currentDropTarget
- }
- });
- events.registerEmitter({
- emitter: DragEmitter,
- events: [DRAG_START_EVENT, DRAG_EVENT, DRAG_END_EVENT]
- });
- DX.ui.events.__internals = DX.ui.events.__internals || {};
- $.extend(DX.ui.events.__internals, {dropTargets: knownDropTargets})
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.emitter.transform.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- fitIntoRange = utils.fitIntoRange;
- var DX_PREFIX = "dx",
- TRANSFORM = "transform",
- TRANSLATE = "translate",
- ZOOM = "zoom",
- PINCH = "pinch",
- ROTATE = "rotate",
- START_POSTFIX = "start",
- UPDATE_POSTFIX = "",
- END_POSTFIX = "end";
- var eventAliases = [];
- var addAlias = function(eventName, eventArgs) {
- eventAliases.push({
- name: eventName,
- args: eventArgs
- })
- };
- addAlias(TRANSFORM, {
- scale: true,
- deltaScale: true,
- rotation: true,
- deltaRotation: true,
- translation: true,
- deltaTranslation: true
- });
- addAlias(TRANSLATE, {
- translation: true,
- deltaTranslation: true
- });
- addAlias(ZOOM, {
- scale: true,
- deltaScale: true
- });
- addAlias(PINCH, {
- scale: true,
- deltaScale: true
- });
- addAlias(ROTATE, {
- rotation: true,
- deltaRotation: true
- });
- var getVector = function(first, second) {
- return {
- x: second.pageX - first.pageX,
- y: -second.pageY + first.pageY,
- centerX: (second.pageX + first.pageX) * 0.5,
- centerY: (second.pageY + first.pageY) * 0.5
- }
- };
- var getEventVector = function(e) {
- var pointers = e.pointers;
- return getVector(pointers[0], pointers[1])
- };
- var getDistance = function(vector) {
- return Math.sqrt(vector.x * vector.x + vector.y * vector.y)
- };
- var getScale = function(firstVector, secondVector) {
- return getDistance(firstVector) / getDistance(secondVector)
- };
- var getRotation = function(firstVector, secondVector) {
- var scalarProduct = firstVector.x * secondVector.x + firstVector.y * secondVector.y;
- var distanceProduct = getDistance(firstVector) * getDistance(secondVector);
- if (distanceProduct === 0)
- return 0;
- var sign = utils.sign(firstVector.x * secondVector.y - secondVector.x * firstVector.y);
- var angle = Math.acos(fitIntoRange(scalarProduct / distanceProduct, -1, 1));
- return sign * angle
- };
- var getTranslation = function(firstVector, secondVector) {
- return {
- x: firstVector.centerX - secondVector.centerX,
- y: firstVector.centerY - secondVector.centerY
- }
- };
- var TransformEmitter = events.Emitter.inherit({
- configurate: function(data, eventName) {
- if (eventName.indexOf(ZOOM) > -1)
- DX.log("W0005", eventName, "15.1", "Use '" + eventName.replace(ZOOM, PINCH) + "' event instead");
- this.callBase(data)
- },
- validatePointers: function(e) {
- return events.hasTouches(e) > 1
- },
- start: function(e) {
- this._accept(e);
- var startVector = getEventVector(e);
- this._startVector = startVector;
- this._prevVector = startVector;
- this._fireEventAliases(START_POSTFIX, e)
- },
- move: function(e) {
- var currentVector = getEventVector(e),
- eventArgs = this._getEventArgs(currentVector);
- this._fireEventAliases(UPDATE_POSTFIX, e, eventArgs);
- this._prevVector = currentVector
- },
- end: function(e) {
- var eventArgs = this._getEventArgs(this._prevVector);
- this._fireEventAliases(END_POSTFIX, e, eventArgs)
- },
- _getEventArgs: function(vector) {
- return {
- scale: getScale(vector, this._startVector),
- deltaScale: getScale(vector, this._prevVector),
- rotation: getRotation(vector, this._startVector),
- deltaRotation: getRotation(vector, this._prevVector),
- translation: getTranslation(vector, this._startVector),
- deltaTranslation: getTranslation(vector, this._prevVector)
- }
- },
- _fireEventAliases: function(eventPostfix, originalEvent, eventArgs) {
- eventArgs = eventArgs || {};
- $.each(eventAliases, $.proxy(function(_, eventAlias) {
- var args = {};
- $.each(eventAlias.args, function(name) {
- if (name in eventArgs)
- args[name] = eventArgs[name]
- });
- this._fireEvent(DX_PREFIX + eventAlias.name + eventPostfix, originalEvent, args)
- }, this))
- }
- });
- events.registerEmitter({
- emitter: TransformEmitter,
- events: $.map(eventAliases, function(eventAlias) {
- var eventNames = [];
- $.each([START_POSTFIX, UPDATE_POSTFIX, END_POSTFIX], function(_, eventPostfix) {
- eventNames.push(DX_PREFIX + eventAlias.name + eventPostfix)
- });
- return eventNames
- })
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.dblclick.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- utils = DX.utils,
- DBLCLICK_EVENT_NAME = "dxdblclick",
- DBLCLICK_NAMESPACE = "dxDblClick",
- NAMESPACED_CLICK_EVENT = events.addNamespace("dxclick", DBLCLICK_NAMESPACE),
- DBLCLICK_TIMEOUT = 300;
- var DblClick = DX.Class.inherit({
- ctor: function() {
- this._handlerCount = 0;
- this._forgetLastClick()
- },
- _forgetLastClick: function() {
- this._firstClickTarget = null;
- this._lastClickTimeStamp = -DBLCLICK_TIMEOUT
- },
- add: function() {
- if (this._handlerCount <= 0)
- $(document).on(NAMESPACED_CLICK_EVENT, $.proxy(this._clickHandler, this));
- this._handlerCount++
- },
- _clickHandler: function(e) {
- var timeStamp = e.timeStamp || $.now();
- if (timeStamp - this._lastClickTimeStamp < DBLCLICK_TIMEOUT) {
- events.fireEvent({
- type: DBLCLICK_EVENT_NAME,
- target: utils.closestCommonParent(this._firstClickTarget, e.target),
- originalEvent: e
- });
- this._forgetLastClick()
- }
- else {
- this._firstClickTarget = e.target;
- this._lastClickTimeStamp = timeStamp
- }
- },
- remove: function() {
- this._handlerCount--;
- if (this._handlerCount <= 0) {
- this._forgetLastClick();
- $(document).off(NAMESPACED_CLICK_EVENT)
- }
- }
- });
- events.registerEvent(DBLCLICK_EVENT_NAME, new DblClick)
- })(jQuery, DevExpress);
- /*! Module core, file ui.events.remove.js */
- (function($) {
- (function(cleanData) {
- $.cleanData = function(elements) {
- $.each(elements, function() {
- $(this).triggerHandler("dxremove")
- });
- return cleanData.apply(this, arguments)
- }
- })($.cleanData)
- })(jQuery);
- /*! Module core, file ui.events.contextmenu.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- events = ui.events,
- support = DX.support,
- CONTEXTMENU_NAMESPACE = "dxContexMenu",
- CONTEXTMENU_NAMESPACED_EVENT_NAME = events.addNamespace("contextmenu", CONTEXTMENU_NAMESPACE),
- HOLD_NAMESPACED_EVENT_NAME = events.addNamespace("dxhold", CONTEXTMENU_NAMESPACE),
- CONTEXTMENU_EVENT_NAME = "dxcontextmenu";
- var ContextMenu = DX.Class.inherit({
- setup: function(element, data) {
- var $element = $(element);
- $element.on(CONTEXTMENU_NAMESPACED_EVENT_NAME, $.proxy(this._contextMenuHandler, this));
- if (support.touch || DX.devices.isSimulator())
- $element.on(HOLD_NAMESPACED_EVENT_NAME, $.proxy(this._holdHandler, this))
- },
- _holdHandler: function(e) {
- if (events.isMouseEvent(e) && !DX.devices.isSimulator())
- return;
- this._fireContextMenu(e)
- },
- _contextMenuHandler: function(e) {
- e = this._fireContextMenu(e);
- if (!e.cancel)
- e.preventDefault()
- },
- _fireContextMenu: function(e) {
- return events.fireEvent({
- type: CONTEXTMENU_EVENT_NAME,
- originalEvent: e
- })
- },
- teardown: function(element) {
- $(element).off("." + CONTEXTMENU_NAMESPACE)
- }
- });
- events.registerEvent(CONTEXTMENU_EVENT_NAME, new ContextMenu)
- })(jQuery, DevExpress);
- /*! Module core, file ui.widget.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events,
- UI_FEEDBACK = "UIFeedback",
- WIDGET_CLASS = "dx-widget",
- ACTIVE_STATE_CLASS = "dx-state-active",
- DISABLED_STATE_CLASS = "dx-state-disabled",
- INVISIBLE_STATE_CLASS = "dx-state-invisible",
- HOVER_STATE_CLASS = "dx-state-hover",
- FOCUSED_STATE_CLASS = "dx-state-focused",
- FEEDBACK_SHOW_TIMEOUT = 30,
- FEEDBACK_HIDE_TIMEOUT = 400,
- HOVER_START = "dxhoverstart",
- HOVER_END = "dxhoverend",
- FOCUS_NAMESPACE = "Focus",
- ANONYMOUS_TEMPLATE_NAME = "template",
- TEXT_NODE = 3,
- TEMPLATE_SELECTOR = "[data-options*='dxTemplate']",
- TEMPLATE_WRAPPER_CLASS = "dx-template-wrapper";
- var DynamicTemplate = ui.TemplateBase.inherit({
- ctor: function(compileFunction, owner) {
- this.callBase($(), owner);
- this._compileFunction = compileFunction
- },
- _renderCore: function(data, index, container) {
- if (data === undefined && index === undefined) {
- data = container;
- container = undefined
- }
- var compiledTemplate = index === undefined ? this._compileFunction(data, container) : this._compileFunction(data, index, container);
- var renderResult = compiledTemplate.render(data, container, index);
- if (compiledTemplate.owner() === this)
- compiledTemplate.dispose();
- return renderResult
- }
- });
- var EmptyTemplate = ui.TemplateBase.inherit({
- ctor: function(owner) {
- this.callBase($(), owner)
- },
- _renderCore: function(data, index, container) {
- return $()
- }
- });
- var RendererTemplate = ui.TemplateBase.inherit({_renderCore: function() {
- return this._element
- }});
- ui.Widget = DX.DOMComponent.inherit({
- NAME: "Widget",
- _supportedKeys: function() {
- return {}
- },
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {contentReadyAction: {
- since: "14.2",
- alias: "onContentReady"
- }})
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- disabled: false,
- visible: true,
- hint: undefined,
- activeStateEnabled: false,
- onContentReady: null,
- hoverStateEnabled: false,
- focusStateEnabled: false,
- tabIndex: 0,
- accessKey: null,
- onFocusIn: null,
- onFocusOut: null,
- templateProvider: ui.TemplateProvider,
- _keyboardProcessor: undefined,
- _templates: {}
- })
- },
- _init: function() {
- this.callBase();
- this._feedbackShowTimeout = FEEDBACK_SHOW_TIMEOUT;
- this._feedbackHideTimeout = FEEDBACK_HIDE_TIMEOUT;
- this._tempTemplates = [];
- this._dynamicTemplates = {};
- this._initTemplates();
- this._initContentReadyAction();
- this._initFocusActions()
- },
- _initTemplates: function() {
- this._extractTemplates();
- this._extractAnonimousTemplate()
- },
- _extractTemplates: function() {
- var templates = this.option("_templates"),
- templateElements = this.element().contents().filter(TEMPLATE_SELECTOR);
- var templatesMap = {};
- templateElements.each(function(_, template) {
- var templateOptions = utils.getElementOptions(template).dxTemplate;
- if (!templateOptions)
- return;
- if (!templateOptions.name)
- throw DX.Error("E0023");
- $(template).addClass(TEMPLATE_WRAPPER_CLASS).detach();
- templatesMap[templateOptions.name] = templatesMap[templateOptions.name] || [];
- templatesMap[templateOptions.name].push(template)
- });
- $.each(templatesMap, $.proxy(function(templateName, value) {
- var deviceTemplate = this._findTemplateByDevice(value);
- if (deviceTemplate)
- templates[templateName] = this._createTemplate(deviceTemplate, this)
- }, this))
- },
- _findTemplateByDevice: function(templates) {
- var suitableTemplate = DX.utils.findBestMatches(DX.devices.current(), templates, function(template) {
- return utils.getElementOptions(template).dxTemplate
- })[0];
- $.each(templates, function(index, template) {
- if (template !== suitableTemplate)
- $(template).remove()
- });
- return suitableTemplate
- },
- _extractAnonimousTemplate: function() {
- var templates = this.option("_templates"),
- anonimiousTemplateName = this._getAnonimousTemplateName(),
- $anonimiousTemplate = this.element().contents().detach();
- var $notJunkTemplateContent = $anonimiousTemplate.filter(function(_, element) {
- var isTextNode = element.nodeType === TEXT_NODE,
- isEmptyText = $.trim($(element).text()).length < 1;
- return !(isTextNode && isEmptyText)
- }),
- onlyJunkTemplateContent = $notJunkTemplateContent.length < 1;
- if (!templates[anonimiousTemplateName] && !onlyJunkTemplateContent)
- templates[anonimiousTemplateName] = this._createTemplate($anonimiousTemplate, this)
- },
- _getAriaTarget: function() {
- return this.element()
- },
- _getAnonimousTemplateName: function() {
- return ANONYMOUS_TEMPLATE_NAME
- },
- _getTemplateByOption: function(optionName) {
- return this._getTemplate(this.option(optionName))
- },
- _getTemplate: function(templateSource) {
- if ($.isFunction(templateSource)) {
- var that = this;
- return new DynamicTemplate(function() {
- var templateSourceResult = templateSource.apply(that, arguments);
- if (utils.isDefined(templateSourceResult))
- return that._acquireTemplate(templateSourceResult, this, true);
- else
- return new EmptyTemplate
- }, this)
- }
- return this._acquireTemplate(templateSource, this)
- },
- _acquireTemplate: function(templateSource, owner, preferRenderer) {
- if (templateSource == null)
- return this._createTemplate(utils.normalizeTemplateElement(templateSource), owner);
- if (templateSource instanceof ui.TemplateBase)
- return templateSource;
- if (templateSource.nodeType || templateSource.jquery) {
- templateSource = $(templateSource);
- if (preferRenderer && !templateSource.is("script"))
- return new RendererTemplate(templateSource, owner);
- return this._createTemplate(templateSource, owner)
- }
- if (typeof templateSource === "string") {
- var userTemplate = this.option("_templates")[templateSource];
- if (userTemplate)
- return userTemplate;
- var dynamicTemplate = this._dynamicTemplates[templateSource];
- if (dynamicTemplate)
- return dynamicTemplate;
- var defaultTemplate = this.option("templateProvider").getTemplates(this)[templateSource];
- if (defaultTemplate)
- return defaultTemplate;
- return this._createTemplate(utils.normalizeTemplateElement(templateSource), owner)
- }
- return this._acquireTemplate(templateSource.toString(), owner)
- },
- _createTemplate: function(element, owner) {
- var template = this.option("templateProvider").createTemplate(element, owner);
- this._tempTemplates.push(template);
- return template
- },
- _cleanTemplates: function() {
- var that = this;
- $.each(this.option("_templates"), function(_, template) {
- if (that === template.owner())
- template.dispose()
- });
- $.each(this._tempTemplates, function(_, template) {
- template.dispose()
- })
- },
- _initContentReadyAction: function() {
- this._contentReadyAction = this._createActionByOption("onContentReady", {excludeValidators: ["designMode", "disabled", "readOnly"]})
- },
- _initFocusActions: function() {
- var focusInAction = this._createActionByOption("onFocusIn", {excludeValidators: ["readOnly"]});
- var focusOutAction = this._createActionByOption("onFocusOut", {excludeValidators: ["readOnly"]});
- this._focusInAction = this._createAction(function(e) {
- e.component._focusInHandler(e.jQueryEvent);
- focusInAction(e)
- }, {excludeValidators: ["readOnly"]});
- this._focusOutAction = this._createAction(function(e) {
- e.component._focusOutHandler(e.jQueryEvent);
- focusOutAction(e)
- }, {excludeValidators: ["readOnly"]})
- },
- _render: function() {
- this.element().addClass(WIDGET_CLASS);
- this.callBase();
- this._toggleDisabledState(this.option("disabled"));
- this._toggleVisibility(this.option("visible"));
- this._renderHint();
- this._renderContent();
- this._renderFocusState();
- this._attachFeedbackEvents();
- this._attachHoverEvents()
- },
- _renderHint: function() {
- utils.toggleAttr(this.element(), "title", this.option("hint"))
- },
- _renderContent: function() {
- this._renderContentImpl();
- this._fireContentReadyAction()
- },
- _renderContentImpl: $.noop,
- _fireContentReadyAction: function() {
- this._contentReadyAction()
- },
- _dispose: function() {
- this._cleanTemplates();
- this._contentReadyAction = null;
- this.callBase()
- },
- _clean: function() {
- this._cleanFocusState();
- this.callBase();
- this.element().empty()
- },
- _toggleVisibility: function(visible) {
- this.element().toggleClass(INVISIBLE_STATE_CLASS, !visible);
- this.setAria("hidden", !visible || undefined)
- },
- _renderFocusState: function() {
- if (!this.option("focusStateEnabled") || this.option("disabled"))
- return;
- this._renderFocusTarget();
- this._attachFocusEvents();
- this._attachKeyboardEvents();
- this._renderAccessKey()
- },
- _renderAccessKey: function() {
- var focusTarget = this._focusTarget();
- focusTarget.attr("accesskey", this.option("accessKey"));
- var clickNamespace = events.addNamespace("dxclick", UI_FEEDBACK);
- focusTarget.off(clickNamespace);
- this.option("accessKey") && focusTarget.on(clickNamespace, $.proxy(function(e) {
- if (e.screenX === 0 && !e.offsetX && e.pageX === 0) {
- e.stopImmediatePropagation();
- this.focus()
- }
- }, this))
- },
- _eventBindingTarget: function() {
- return this.element()
- },
- _focusTarget: function() {
- return this._getActiveElement()
- },
- _getActiveElement: function() {
- var activeElement = this._eventBindingTarget();
- if (this._activeStateUnit)
- activeElement = activeElement.find(this._activeStateUnit).not("." + DISABLED_STATE_CLASS);
- return activeElement
- },
- _renderFocusTarget: function() {
- this._focusTarget().attr("tabindex", this.option("tabIndex"))
- },
- _keyboardEventBindingTarget: function() {
- return this._eventBindingTarget()
- },
- _attachFocusEvents: function() {
- var focusInEvent = events.addNamespace("focusin", this.NAME + FOCUS_NAMESPACE);
- var focusOutEvent = events.addNamespace("focusout", this.NAME + FOCUS_NAMESPACE);
- var beforeactivateEventNamespace = events.addNamespace("beforeactivate", this.NAME + FOCUS_NAMESPACE);
- this._focusTarget().off("." + this.NAME + FOCUS_NAMESPACE).on(focusInEvent, $.proxy(function(e) {
- this._focusInAction({jQueryEvent: e})
- }, this)).on(focusOutEvent, $.proxy(function(e) {
- this._focusOutAction({jQueryEvent: e})
- }, this)).on(beforeactivateEventNamespace, function(e) {
- if (!$(e.target).is(":dx-focusable"))
- e.preventDefault()
- })
- },
- _focusInHandler: function(e) {
- this._updateFocusState(e, true)
- },
- _focusOutHandler: function(e) {
- this._updateFocusState(e, false)
- },
- _updateFocusState: function(e, isFocused) {
- var currentTarget = e.currentTarget,
- focusTargets = this._focusTarget();
- if ($.inArray(currentTarget, focusTargets) !== -1)
- $(e.currentTarget).toggleClass(FOCUSED_STATE_CLASS, isFocused)
- },
- _attachKeyboardEvents: function() {
- var processor = this.option("_keyboardProcessor") || new ui.KeyboardProcessor({
- element: this._keyboardEventBindingTarget(),
- focusTarget: this._focusTarget()
- });
- this._keyboardProcessor = processor.reinitialize(this._keyboardHandler, this)
- },
- _keyboardHandler: function(options) {
- var e = options.originalEvent,
- key = options.key;
- var keys = this._supportedKeys(),
- func = keys[key];
- if (func !== undefined) {
- var handler = $.proxy(func, this);
- return handler(e) || false
- }
- else
- return true
- },
- _refreshFocusState: function() {
- this._cleanFocusState();
- this._renderFocusState()
- },
- _cleanFocusState: function() {
- var $element = this._focusTarget();
- $element.off("." + this.NAME + FOCUS_NAMESPACE);
- $element.removeClass(FOCUSED_STATE_CLASS);
- $element.removeAttr("tabindex");
- if (this._keyboardProcessor)
- this._keyboardProcessor.dispose()
- },
- _attachHoverEvents: function() {
- var that = this,
- hoverableSelector = that._activeStateUnit,
- nameStart = events.addNamespace(HOVER_START, UI_FEEDBACK),
- nameEnd = events.addNamespace(HOVER_END, UI_FEEDBACK);
- that._eventBindingTarget().off(nameStart, hoverableSelector).off(nameEnd, hoverableSelector);
- if (that.option("hoverStateEnabled")) {
- var startAction = new DX.Action(function(args) {
- that._hoverStartHandler(args.event);
- var $target = args.element;
- that._refreshHoveredElement($target)
- });
- that._eventBindingTarget().on(nameStart, hoverableSelector, function(e) {
- startAction.execute({
- element: $(e.target),
- event: e
- })
- }).on(nameEnd, hoverableSelector, function(e) {
- that._hoverEndHandler(e);
- that._forgetHoveredElement()
- })
- }
- else
- that._toggleHoverClass(false)
- },
- _hoverStartHandler: $.noop,
- _hoverEndHandler: $.noop,
- _attachFeedbackEvents: function() {
- var that = this,
- feedbackSelector = that._activeStateUnit,
- activeEventName = events.addNamespace("dxactive", UI_FEEDBACK),
- inactiveEventName = events.addNamespace("dxinactive", UI_FEEDBACK);
- that._eventBindingTarget().off(activeEventName, feedbackSelector).off(inactiveEventName, feedbackSelector);
- if (that.option("activeStateEnabled")) {
- var feedbackActionHandler = function(args) {
- var $element = args.element,
- value = args.value;
- that._toggleActiveState($element, value)
- };
- var feedbackAction = new DX.Action(function(args) {
- feedbackActionHandler(args)
- }),
- feedbackActionDisabled = new DX.Action(function(args) {
- feedbackActionHandler(args)
- }, {excludeValidators: ["disabled", "readOnly"]});
- that._eventBindingTarget().on(activeEventName, feedbackSelector, {timeout: that._feedbackShowTimeout}, function(e) {
- feedbackAction.execute({
- element: $(e.currentTarget),
- value: true
- })
- }).on(inactiveEventName, feedbackSelector, {timeout: that._feedbackHideTimeout}, function(e) {
- feedbackActionDisabled.execute({
- element: $(e.currentTarget),
- value: false
- })
- })
- }
- },
- _toggleActiveState: function($element, value) {
- this._toggleHoverClass(!value);
- $element.toggleClass(ACTIVE_STATE_CLASS, value)
- },
- _refreshHoveredElement: function(hoveredElement) {
- var selector = this._activeStateUnit || this.element();
- this._forgetHoveredElement();
- this._hoveredElement = hoveredElement.closest(selector);
- this._toggleHoverClass(true)
- },
- _forgetHoveredElement: function() {
- this._toggleHoverClass(false);
- delete this._hoveredElement
- },
- _toggleHoverClass: function(value) {
- if (this._hoveredElement)
- this._hoveredElement.toggleClass(HOVER_STATE_CLASS, value && this.option("hoverStateEnabled"))
- },
- _toggleDisabledState: function(value) {
- this.element().toggleClass(DISABLED_STATE_CLASS, Boolean(value));
- this._toggleHoverClass(!value);
- this.setAria("disabled", value || undefined)
- },
- _setWidgetOption: function(widgetName, args) {
- if (!this[widgetName])
- return;
- if ($.isPlainObject(args[0])) {
- $.each(args[0], $.proxy(function(option, value) {
- this._setWidgetOption(widgetName, [option, value])
- }, this));
- return
- }
- var optionName = args[0];
- var value = args[1];
- if (args.length === 1)
- value = this.option(optionName);
- var widgetOptionMap = this[widgetName + "OptionMap"];
- this[widgetName].option(widgetOptionMap ? widgetOptionMap(optionName) : optionName, value)
- },
- _createComponent: function(element, name, config) {
- config = config || {};
- this._extendConfig(config, {
- templateProvider: this.option("templateProvider"),
- _templates: this.option("_templates")
- });
- return this.callBase(element, name, config)
- },
- _optionChanged: function(args) {
- switch (args.name) {
- case"disabled":
- this._toggleDisabledState(args.value);
- this._refreshFocusState();
- break;
- case"hint":
- this._renderHint();
- break;
- case"activeStateEnabled":
- this._attachFeedbackEvents();
- break;
- case"hoverStateEnabled":
- this._attachHoverEvents();
- break;
- case"tabIndex":
- case"_keyboardProcessor":
- case"focusStateEnabled":
- this._refreshFocusState();
- break;
- case"onFocusIn":
- case"onFocusOut":
- this._initFocusActions();
- break;
- case"accessKey":
- this._renderAccessKey();
- break;
- case"visible":
- var visible = args.value;
- this._toggleVisibility(visible);
- if (this._isVisibilityChangeSupported())
- this._visibilityChanged(visible);
- break;
- case"onContentReady":
- this._initContentReadyAction();
- break;
- case"_templates":
- case"templateProvider":
- this._refresh();
- break;
- default:
- this.callBase(args)
- }
- },
- beginUpdate: function() {
- this._ready(false);
- this.callBase()
- },
- endUpdate: function() {
- this.callBase();
- if (this._initialized)
- this._ready(true)
- },
- _ready: function(value) {
- if (arguments.length === 0)
- return this._isReady;
- this._isReady = value
- },
- setAria: function() {
- var setAttribute = function(option) {
- var attrName = $.inArray(option.name, ["role", "id"]) + 1 ? option.name : "aria-" + option.name,
- attrValue = option.value;
- if (attrValue === null || attrValue === undefined)
- attrValue = undefined;
- else
- attrValue = attrValue.toString();
- utils.toggleAttr(option.target, attrName, attrValue)
- };
- if (!$.isPlainObject(arguments[0]))
- setAttribute({
- name: arguments[0],
- value: arguments[1],
- target: arguments[2] || this._getAriaTarget()
- });
- else {
- var $target = arguments[1] || this._getAriaTarget();
- $.each(arguments[0], function(key, value) {
- setAttribute({
- name: key,
- value: value,
- target: $target
- })
- })
- }
- },
- isReady: function() {
- return this._ready()
- },
- repaint: function() {
- this._refresh()
- },
- focus: function() {
- this._focusTarget().focus()
- },
- registerKeyHandler: function(key, handler) {
- var currentKeys = this._supportedKeys(),
- addingKeys = {};
- addingKeys[key] = handler;
- this._supportedKeys = function() {
- return $.extend(currentKeys, addingKeys)
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.editor.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- READONLY_STATE_CLASS = "dx-state-readonly",
- INVALID_CLASS = "dx-invalid",
- INVALID_MESSAGE = "dx-invalid-message",
- INVALID_MESSAGE_AUTO = "dx-invalid-message-auto",
- INVALID_MESSAGE_ALWAYS = "dx-invalid-message-always";
- ui.validation = ui.validation || {};
- ui.validation.findGroup = function() {
- var group = this.option("validationGroup"),
- $dxGroup;
- if (!group) {
- $dxGroup = this.element().parents(".dx-validationgroup:first");
- if ($dxGroup.length)
- group = $dxGroup.dxValidationGroup("instance");
- else
- group = this._modelByElement(this.element())
- }
- return group
- };
- ui.Editor = ui.Widget.inherit({
- _init: function() {
- this.callBase();
- this.validationRequest = $.Callbacks();
- var $element = this.element();
- if ($element) {
- $element.data("dx-validation-target", this);
- this.on("disposing", function() {
- $element.data("dx-validation-target", null)
- })
- }
- this._createValueChangeAction()
- },
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {valueChangeAction: {
- since: "14.2",
- alias: "onValueChanged",
- message: "'onValueChanged' option instead"
- }})
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- value: null,
- onValueChanged: null,
- activeStateEnabled: true,
- readOnly: false,
- isValid: true,
- validationError: null,
- validationMessageMode: "auto",
- validationTooltipOffset: {
- h: 0,
- v: -10
- }
- })
- },
- _defaultOptionsRules: function() {
- return this.callBase().concat([{
- device: function(device) {
- return device.platform === "android"
- },
- options: {invalidTooltipOffset: {
- h: 9,
- v: -7
- }}
- }, {
- device: {platform: "win8"},
- options: {invalidTooltipOffset: {
- h: 9,
- v: -4
- }}
- }])
- },
- _attachKeyboardEvents: function() {
- if (this.option("readOnly"))
- return;
- this.callBase.apply(this, arguments);
- this._attachChildKeyboardEvents()
- },
- _attachChildKeyboardEvents: $.noop,
- _setOptionsByReference: function() {
- this.callBase();
- $.extend(this._optionsByReference, {validationError: true})
- },
- _createValueChangeAction: function() {
- this._valueChangeAction = this._createActionByOption("onValueChanged", {excludeValidators: ["disabled", "readOnly"]})
- },
- _suppressValueChangeAction: function() {
- this._valueChangeActionSuppressed = true
- },
- _resumeValueChangeAction: function() {
- this._valueChangeActionSuppressed = false
- },
- _render: function() {
- this._renderValidationState();
- this._toggleReadOnlyState();
- this.callBase()
- },
- _raiseValueChangeAction: function(value, previousValue, extraArguments) {
- this._valueChangeAction(this._valueChangeArgs(value, previousValue))
- },
- _valueChangeArgs: function(value, previousValue) {
- return {
- value: value,
- previousValue: previousValue,
- jQueryEvent: this._valueChangeEventInstance
- }
- },
- _saveValueChangeEvent: function(e) {
- this._valueChangeEventInstance = e
- },
- _renderValidationState: function() {
- var isValid = this.option("isValid"),
- validationError = this.option("validationError"),
- validationMessageMode = this.option("validationMessageMode"),
- $element = this.element();
- $element.toggleClass(INVALID_CLASS, !isValid);
- this.setAria("invalid", !isValid || undefined);
- if (this._$validationMessage) {
- this._$validationMessage.remove();
- this._$validationMessage = null
- }
- if (!isValid && validationError && validationError.message) {
- this._$validationMessage = $("<div/>", {"class": INVALID_MESSAGE}).text(validationError.message).appendTo($element);
- this._createComponent(this._$validationMessage, "dxTooltip", {
- target: $element,
- container: $element,
- position: this._getValidationTooltipPosition("below"),
- closeOnOutsideClick: false,
- closeOnTargetScroll: false,
- animation: null,
- visible: true
- });
- this._$validationMessage.toggleClass(INVALID_MESSAGE_AUTO, validationMessageMode === "auto").toggleClass(INVALID_MESSAGE_ALWAYS, validationMessageMode === "always")
- }
- },
- _getValidationTooltipPosition: function(positionRequest) {
- var rtlEnabled = this.option("rtlEnabled"),
- tooltipPositionSide = rtlEnabled ? "right" : "left",
- tooltipOriginalOffset = this.option("validationTooltipOffset"),
- tooltipOffset = {
- h: tooltipOriginalOffset.h,
- v: tooltipOriginalOffset.v
- },
- verticalPositions = positionRequest === "below" ? [" top", " bottom"] : [" bottom", " top"];
- if (rtlEnabled)
- tooltipOffset.h = -tooltipOffset.h;
- if (positionRequest !== "below")
- tooltipOffset.v = -tooltipOffset.v;
- return {
- offset: tooltipOffset,
- my: tooltipPositionSide + verticalPositions[0],
- at: tooltipPositionSide + verticalPositions[1],
- collision: "none"
- }
- },
- _toggleReadOnlyState: function() {
- this.element().toggleClass(READONLY_STATE_CLASS, this.option("readOnly"));
- this.setAria("readonly", this.option("readOnly") || undefined)
- },
- _optionChanged: function(args) {
- switch (args.name) {
- case"onValueChanged":
- this._createValueChangeAction();
- break;
- case"isValid":
- case"validationError":
- case"validationMessageMode":
- this._renderValidationState();
- break;
- case"readOnly":
- this._toggleReadOnlyState();
- this._refreshFocusState();
- break;
- case"value":
- if (!this._valueChangeActionSuppressed) {
- this._raiseValueChangeAction(args.value, args.previousValue);
- this._saveValueChangeEvent(undefined)
- }
- if (args.value != args.previousValue)
- this.validationRequest.fire({
- value: args.value,
- editor: this
- });
- break;
- default:
- this.callBase(args)
- }
- },
- reset: function() {
- this.option("value", null)
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.CollectionWidget.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils,
- events = ui.events;
- var COLLECTION_CLASS = "dx-collection",
- ITEM_CLASS = "dx-item",
- CONTENT_CLASS_POSTFIX = "-content",
- ITEM_CONTENT_PLACEHOLDER_CLASS = "dx-item-content-placeholder",
- ITEM_DATA_KEY = "dxItemData",
- ITEM_TEMPLATE_ID_PREFIX = "tmpl-",
- ITEMS_SELECTOR = "[data-options*='dxItem']",
- SELECTED_ITEM_CLASS = "dx-item-selected",
- FOCUSED_STATE_CLASS = "dx-state-focused",
- ITEM_RESPONSE_WAIT_CLASS = "dx-item-response-wait",
- EMPTY_COLLECTION = "dx-empty-collection",
- TEMPLATE_WRAPPER_CLASS = "dx-template-wrapper";
- var FOCUS_UP = "up",
- FOCUS_DOWN = "down",
- FOCUS_LEFT = "left",
- FOCUS_RIGHT = "right",
- FOCUS_PAGE_UP = "pageup",
- FOCUS_PAGE_DOWN = "pagedown",
- FOCUS_LAST = "last",
- FOCUS_FIRST = "first";
- var CollectionWidget = ui.Widget.inherit({
- NAME: "CollectionWidget",
- _activeStateUnit: "." + ITEM_CLASS,
- _supportedKeys: function() {
- var click = function(e) {
- var $itemElement = this.option("focusedElement");
- if (!$itemElement)
- return;
- e.target = $itemElement;
- e.currentTarget = $itemElement;
- this._itemClickHandler(e)
- },
- move = function(location, e) {
- e.preventDefault();
- e.stopPropagation();
- this._moveFocus(location, e)
- };
- return $.extend(this.callBase(), {
- space: click,
- enter: click,
- leftArrow: $.proxy(move, this, FOCUS_LEFT),
- rightArrow: $.proxy(move, this, FOCUS_RIGHT),
- upArrow: $.proxy(move, this, FOCUS_UP),
- downArrow: $.proxy(move, this, FOCUS_DOWN),
- pageUp: $.proxy(move, this, FOCUS_UP),
- pageDown: $.proxy(move, this, FOCUS_DOWN),
- home: $.proxy(move, this, FOCUS_FIRST),
- end: $.proxy(move, this, FOCUS_LAST)
- })
- },
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {
- itemClickAction: {
- since: "14.2",
- alias: "onItemClick"
- },
- itemHoldAction: {
- since: "14.2",
- alias: "onItemHold"
- },
- itemRenderedAction: {
- since: "14.2",
- alias: "onItemRendered"
- },
- itemRender: {
- since: "14.2",
- alias: "itemTemplate"
- }
- })
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- selectOnFocus: false,
- loopItemFocus: true,
- items: [],
- itemTemplate: "item",
- onItemRendered: null,
- onItemClick: null,
- onItemHold: null,
- itemHoldTimeout: 750,
- onItemContextMenu: null,
- onFocusedItemChanged: null,
- noDataText: Globalize.localize("dxCollectionWidget-noDataText"),
- dataSource: null,
- _itemAttributes: {},
- itemTemplateProperty: "template",
- focusOnSelectedItem: true,
- focusedElement: null
- })
- },
- _getAnonimousTemplateName: function() {
- return "item"
- },
- _init: function() {
- this.callBase();
- this._cleanRenderedItems();
- this._refreshDataSource()
- },
- _initTemplates: function() {
- this._initItemsFromMarkup();
- this.callBase()
- },
- _initItemsFromMarkup: function() {
- var $items = this.element().contents().filter(ITEMS_SELECTOR);
- if (!$items.length || this.option("items").length)
- return;
- var items = $.map($items, $.proxy(function(item) {
- var $item = $(item);
- var result = utils.getElementOptions(item).dxItem;
- var isTemplateRequired = $.trim($item.html()) && !result.template;
- if (isTemplateRequired)
- result.template = this._prepareItemTemplate($item);
- else
- $item.remove();
- return result
- }, this));
- this.option("items", items)
- },
- _prepareItemTemplate: function($item) {
- var templateId = ITEM_TEMPLATE_ID_PREFIX + new DX.data.Guid;
- var templateOptions = "dxTemplate: { name: \"" + templateId + "\" }";
- $item.attr("data-options", templateOptions).data("options", templateOptions);
- return templateId
- },
- _dataSourceOptions: function() {
- return {paginate: false}
- },
- _cleanRenderedItems: function() {
- this._renderedItemsCount = 0
- },
- _focusTarget: function() {
- return this.element()
- },
- _focusInHandler: function(e) {
- this.callBase.apply(this, arguments);
- var $focusedElement = this.option("focusedElement");
- if ($focusedElement && $focusedElement.length)
- this._setFocusedItem($focusedElement);
- else {
- var $activeItem = this._getActiveItem();
- this.option("focusedElement", $activeItem)
- }
- },
- _focusOutHandler: function(e) {
- this.callBase.apply(this, arguments);
- var $target = this.option("focusedElement");
- if ($target)
- $target.removeClass(FOCUSED_STATE_CLASS)
- },
- _getActiveItem: function(last) {
- var $focusedElement = this.option("focusedElement");
- if ($focusedElement && $focusedElement.length)
- return $focusedElement;
- var index = this.option("focusOnSelectedItem") ? this.option("selectedIndex") : 0,
- activeElements = this._getActiveElement(),
- lastIndex = activeElements.length - 1;
- if (index < 0)
- index = last ? lastIndex : 0;
- return activeElements.eq(index)
- },
- _renderFocusTarget: function() {
- this.callBase.apply(this, arguments);
- this._refreshActiveDescendant()
- },
- _moveFocus: function(location) {
- var $items = this._itemElements().filter(":visible").not(".dx-state-disabled"),
- $newTarget;
- switch (location) {
- case FOCUS_PAGE_UP:
- case FOCUS_UP:
- $newTarget = this._prevItem($items);
- break;
- case FOCUS_PAGE_DOWN:
- case FOCUS_DOWN:
- $newTarget = this._nextItem($items);
- break;
- case FOCUS_RIGHT:
- $newTarget = this.option("rtlEnabled") ? this._prevItem($items) : this._nextItem($items);
- break;
- case FOCUS_LEFT:
- $newTarget = this.option("rtlEnabled") ? this._nextItem($items) : this._prevItem($items);
- break;
- case FOCUS_FIRST:
- $newTarget = $items.first();
- break;
- case FOCUS_LAST:
- $newTarget = $items.last();
- break;
- default:
- return false
- }
- if ($newTarget.length !== 0)
- this.option("focusedElement", $newTarget)
- },
- _prevItem: function($items) {
- var $target = this._getActiveItem(),
- targetIndex = $items.index($target),
- $last = $items.last(),
- $item = $($items[targetIndex - 1]),
- loop = this.option("loopItemFocus");
- if ($item.length === 0 && loop)
- $item = $last;
- return $item
- },
- _nextItem: function($items) {
- var $target = this._getActiveItem(true),
- targetIndex = $items.index($target),
- $first = $items.first(),
- $item = $($items[targetIndex + 1]),
- loop = this.option("loopItemFocus");
- if ($item.length === 0 && loop)
- $item = $first;
- return $item
- },
- _selectFocusedItem: function($target) {
- this.selectItem($target)
- },
- _removeFocusedItem: function($target) {
- if ($target && $target.length) {
- $target.removeClass(FOCUSED_STATE_CLASS);
- $target.removeAttr("id")
- }
- },
- _refreshActiveDescendant: function() {
- this.setAria("activedescendant", "");
- this.setAria("activedescendant", this.getFocusedItemId())
- },
- _setFocusedItem: function($target) {
- if (!$target || !$target.length)
- return;
- $target.attr("id", this.getFocusedItemId());
- $target.addClass(FOCUSED_STATE_CLASS);
- this.onFocusedItemChanged(this.getFocusedItemId());
- this._refreshActiveDescendant();
- if (this.option("selectOnFocus"))
- this._selectFocusedItem($target)
- },
- _optionChanged: function(args) {
- switch (args.name) {
- case"items":
- case"_itemAttributes":
- case"itemTemplateProperty":
- this._cleanRenderedItems();
- this._invalidate();
- break;
- case"dataSource":
- this._refreshDataSource();
- if (!this._dataSource)
- this.option("items", []);
- this._renderEmptyMessage();
- break;
- case"noDataText":
- this._renderEmptyMessage();
- break;
- case"itemTemplate":
- this._invalidate();
- break;
- case"onItemRendered":
- this._createItemRenderAction();
- break;
- case"onItemClick":
- break;
- case"onItemHold":
- case"itemHoldTimeout":
- this._attachHoldEvent();
- break;
- case"onItemContextMenu":
- this._attachContextMenuEvent();
- break;
- case"onFocusedItemChanged":
- this.onFocusedItemChanged = this._createActionByOption("onFocusedItemChanged");
- break;
- case"selectOnFocus":
- case"loopItemFocus":
- case"focusOnSelectedItem":
- break;
- case"focusedElement":
- this._removeFocusedItem(args.previousValue);
- this._setFocusedItem(args.value);
- break;
- default:
- this.callBase(args)
- }
- },
- _loadNextPage: function() {
- var dataSource = this._dataSource;
- this._expectNextPageLoading();
- dataSource.pageIndex(1 + dataSource.pageIndex());
- return dataSource.load()
- },
- _expectNextPageLoading: function() {
- this._startIndexForAppendedItems = 0
- },
- _expectLastItemLoading: function() {
- this._startIndexForAppendedItems = -1
- },
- _forgetNextPageLoading: function() {
- this._startIndexForAppendedItems = null
- },
- _dataSourceChangedHandler: function(newItems) {
- var items = this.option("items");
- if (this._initialized && items && this._shouldAppendItems()) {
- this._renderedItemsCount = items.length;
- if (!this._isLastPage() || this._startIndexForAppendedItems !== -1)
- this.option().items = items.concat(newItems.slice(this._startIndexForAppendedItems));
- this._forgetNextPageLoading();
- this._renderContent();
- this._renderFocusTarget()
- }
- else
- this.option("items", newItems)
- },
- _dataSourceLoadErrorHandler: function() {
- this._forgetNextPageLoading();
- this.option("items", this.option("items"))
- },
- _shouldAppendItems: function() {
- return this._startIndexForAppendedItems != null && this._allowDinamicItemsAppend()
- },
- _allowDinamicItemsAppend: function() {
- return false
- },
- _clean: function() {
- this._cleanFocusState();
- this._cleanItemContainer()
- },
- _cleanItemContainer: function() {
- this._itemContainer().empty()
- },
- _refresh: function() {
- this._cleanRenderedItems();
- this.callBase.apply(this, arguments)
- },
- _itemContainer: function() {
- return this.element()
- },
- _itemClass: function() {
- return ITEM_CLASS
- },
- _itemContentClass: function() {
- return this._itemClass() + CONTENT_CLASS_POSTFIX
- },
- _selectedItemClass: function() {
- return SELECTED_ITEM_CLASS
- },
- _itemResponseWaitClass: function() {
- return ITEM_RESPONSE_WAIT_CLASS
- },
- _itemSelector: function() {
- return "." + this._itemClass()
- },
- _itemDataKey: function() {
- return ITEM_DATA_KEY
- },
- _itemElements: function() {
- return this._itemContainer().find(this._itemSelector())
- },
- _render: function() {
- this.callBase();
- this.element().addClass(COLLECTION_CLASS);
- this._attachClickEvent();
- this._attachHoldEvent();
- this._attachContextMenuEvent();
- this.onFocusedItemChanged = this._createActionByOption("onFocusedItemChanged")
- },
- _attachClickEvent: function() {
- var itemSelector = this._itemSelector(),
- clickEventNamespace = events.addNamespace("dxclick", this.NAME),
- pointerDownEventNamespace = events.addNamespace("dxpointerdown", this.NAME),
- that = this;
- var pointerDownAction = new DX.Action(function(args) {
- var event = args.event;
- that._itemPointerDownHandler(event)
- });
- this._itemContainer().off(clickEventNamespace, itemSelector).off(pointerDownEventNamespace, itemSelector).on(clickEventNamespace, itemSelector, $.proxy(this._itemClickHandler, this)).on(pointerDownEventNamespace, itemSelector, function(e) {
- pointerDownAction.execute({
- element: $(e.target),
- event: e
- })
- })
- },
- _itemClickHandler: function(e) {
- this._itemJQueryEventHandler(e, "onItemClick")
- },
- _itemPointerDownHandler: function(e) {
- if (!this.option("focusStateEnabled"))
- return;
- var elementClass = this._itemClass(),
- $target = $(e.target).closest("." + elementClass);
- if ($target.hasClass(elementClass))
- this.option("focusedElement", $target)
- },
- _attachHoldEvent: function() {
- var $itemContainer = this._itemContainer(),
- itemSelector = this._itemSelector(),
- eventName = events.addNamespace("dxhold", this.NAME);
- $itemContainer.off(eventName, itemSelector);
- if (this._shouldAttachHoldEvent())
- $itemContainer.on(eventName, itemSelector, {timeout: this._getHoldTimeout()}, $.proxy(this._itemHoldHandler, this))
- },
- _getHoldTimeout: function() {
- return this.option("itemHoldTimeout")
- },
- _shouldAttachHoldEvent: function() {
- return this.option("onItemHold")
- },
- _itemHoldHandler: function(e) {
- this._itemJQueryEventHandler(e, "onItemHold")
- },
- _attachContextMenuEvent: function() {
- var $itemContainer = this._itemContainer(),
- itemSelector = this._itemSelector(),
- eventName = events.addNamespace("dxcontextmenu", this.NAME);
- $itemContainer.off(eventName, itemSelector);
- if (this._shouldAttachContextMenuEvent())
- $itemContainer.on(eventName, itemSelector, $.proxy(this._itemContextMenuHandler, this))
- },
- _shouldAttachContextMenuEvent: function() {
- return this.option("onItemContextMenu")
- },
- _itemContextMenuHandler: function(e) {
- this._itemJQueryEventHandler(e, "onItemContextMenu")
- },
- _renderContentImpl: function() {
- var items = this.option("items") || [];
- if (this._renderedItemsCount)
- this._renderItems(items.slice(this._renderedItemsCount));
- else
- this._renderItems(items)
- },
- _renderItems: function(items) {
- if (items.length)
- $.each(items, $.proxy(this._renderItem, this));
- this._renderEmptyMessage()
- },
- _renderItem: function(index, itemData, $container) {
- $container = $container || this._itemContainer();
- var $itemFrame = this._renderItemFrame(index, itemData, $container);
- this._setElementData($itemFrame, itemData);
- var $itemContent = $itemFrame.find("." + ITEM_CONTENT_PLACEHOLDER_CLASS);
- $itemContent.removeClass(ITEM_CONTENT_PLACEHOLDER_CLASS);
- $itemContent = this._renderItemContent(index, itemData, $itemContent);
- this._postprocessRenderItem({
- itemElement: $itemFrame,
- itemContent: $itemContent,
- itemData: itemData,
- itemIndex: index
- });
- this._executeItemRenderAction(index, itemData, $itemFrame);
- this._attachItemClickEvent(itemData, $itemFrame);
- return $itemFrame.attr(this.option("_itemAttributes"))
- },
- _attachItemClickEvent: function(itemData, $itemElement) {
- if (!itemData || !itemData.onClick)
- return;
- $itemElement.on("dxclick", $.proxy(function(e) {
- this._itemEventHandlerByHandler($itemElement, itemData.onClick, {jQueryEvent: e})
- }, this))
- },
- _renderItemContent: function(index, itemData, $container) {
- var $itemNode = itemData && itemData.node;
- var itemTemplateName = this._getItemTemplateName(itemData);
- var itemTemplate = this._getTemplate(itemTemplateName, itemData, index, $container);
- var renderArgs = {
- index: index,
- item: itemData,
- container: $container
- };
- if ($itemNode) {
- $container.replaceWith($itemNode);
- $container = $itemNode;
- this._addItemContentClasses($container, itemData)
- }
- else {
- this._addItemContentClasses($container, itemData);
- var $result = this._createItemByTemplate(itemTemplate, renderArgs);
- if ($result.hasClass(TEMPLATE_WRAPPER_CLASS)) {
- $container.replaceWith($result);
- $container = $result;
- this._addItemContentClasses($container, itemData)
- }
- }
- return $container
- },
- _addItemContentClasses: function($container) {
- $container.addClass([ITEM_CLASS + CONTENT_CLASS_POSTFIX, this._itemContentClass()].join(" "))
- },
- _renderItemFrame: function(index, itemData, $container) {
- var itemFrameTemplate = this.option("templateProvider").getTemplates(this)["itemFrame"],
- $itemFrame = itemFrameTemplate.render(utils.isDefined(itemData) ? itemData : {}, $container, index);
- $itemFrame.appendTo($container);
- return $itemFrame
- },
- _postprocessRenderItem: $.noop,
- _executeItemRenderAction: function(index, itemData, itemElement) {
- this._getItemRenderAction()({
- itemElement: itemElement,
- itemIndex: index,
- itemData: itemData
- })
- },
- _setElementData: function(element, data) {
- element.addClass([ITEM_CLASS, this._itemClass()].join(" ")).data(this._itemDataKey(), data)
- },
- _createItemRenderAction: function() {
- return this._itemRenderAction = this._createActionByOption("onItemRendered", {
- element: this.element(),
- excludeValidators: ["designMode", "disabled", "readOnly"],
- category: "rendering"
- })
- },
- _getItemRenderAction: function() {
- return this._itemRenderAction || this._createItemRenderAction()
- },
- _getItemTemplateName: function(itemData) {
- var templateProperty = this.option("itemTemplateProperty");
- return itemData && itemData[templateProperty] || this.option("itemTemplate")
- },
- _createItemByTemplate: function(itemTemplate, renderArgs) {
- return itemTemplate.render(renderArgs.item, renderArgs.container, renderArgs.index, "ignoreTarget")
- },
- _renderEmptyMessage: function() {
- var noDataText = this.option("noDataText"),
- items = this.option("items"),
- hideNoData = !noDataText || items && items.length || this._isDataSourceLoading();
- if (hideNoData && this._$nodata) {
- this._$nodata.remove();
- this._$nodata = null;
- this.setAria("label", undefined)
- }
- if (!hideNoData) {
- this._$nodata = this._$nodata || $("<div>").addClass("dx-empty-message");
- this._$nodata.appendTo(this._itemContainer()).html(noDataText);
- this.setAria("label", noDataText)
- }
- this.element().toggleClass(EMPTY_COLLECTION, !hideNoData)
- },
- _itemJQueryEventHandler: function(jQueryEvent, handlerOptionName, actionArgs, actionConfig) {
- this._itemEventHandler(jQueryEvent.target, handlerOptionName, $.extend(actionArgs, {jQueryEvent: jQueryEvent}), actionConfig)
- },
- _itemEventHandler: function(initiator, handlerOptionName, actionArgs, actionConfig) {
- var action = this._createActionByOption(handlerOptionName, $.extend({validatingTargetName: "itemElement"}, actionConfig));
- return this._itemEventHandlerImpl(initiator, action, actionArgs)
- },
- _itemEventHandlerByHandler: function(initiator, handler, actionArgs, actionConfig) {
- var action = this._createAction(handler, $.extend({validatingTargetName: "itemElement"}, actionConfig));
- return this._itemEventHandlerImpl(initiator, action, actionArgs)
- },
- _itemEventHandlerImpl: function(initiator, action, actionArgs) {
- var $itemElement = this._closestItemElement($(initiator));
- return action($.extend(this._extendActionArgs($itemElement), actionArgs))
- },
- _extendActionArgs: function($itemElement) {
- return {
- itemElement: $itemElement,
- itemIndex: $itemElement.index(this._itemSelector()),
- itemData: this._getItemData($itemElement)
- }
- },
- _closestItemElement: function($element) {
- return $($element).closest(this._itemSelector())
- },
- _getItemData: function(itemElement) {
- return $(itemElement).data(this._itemDataKey())
- },
- getFocusedItemId: function() {
- if (!this._focusedItemId)
- this._focusedItemId = new DevExpress.data.Guid;
- return this._focusedItemId
- },
- itemElements: function() {
- return this._itemElements()
- },
- itemsContainer: function() {
- return this._itemContainer()
- }
- }).include(ui.DataHelperMixin);
- ui.CollectionWidget = CollectionWidget
- })(jQuery, DevExpress);
- /*! Module core, file ui.CollectionWidget.edit.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- utils = DX.utils;
- var ITEM_DELETING_DATA_KEY = "dxItemDeleting";
- var CollectionWidget = ui.CollectionWidget.inherit({
- _setOptionsByReference: function() {
- this.callBase();
- $.extend(this._optionsByReference, {selectedItem: true})
- },
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {itemSelectAction: {
- since: "14.2",
- message: "Use the 'onSelectionChanged' option instead"
- }})
- },
- _setDefaultOptions: function() {
- this.callBase();
- this.option({
- selectionMode: 'none',
- selectionRequired: false,
- selectionByClick: true,
- selectedItems: [],
- selectedIndex: -1,
- selectedItem: null,
- onSelectionChanged: null,
- onItemReordered: null,
- onItemDeleting: null,
- onItemDeleted: null
- })
- },
- _init: function() {
- this.callBase();
- this._initEditStrategy();
- this._selectedItemIndices = []
- },
- _initEditStrategy: function() {
- var strategy = ui.CollectionWidget.PlainEditStrategy;
- this._editStrategy = new strategy(this)
- },
- _render: function() {
- this._syncSelectionOptions();
- this._normalizeSelectedItems();
- this._initSelectedItems();
- this.callBase();
- this._renderSelection(this._selectedItemIndices, [])
- },
- _syncSelectionOptions: function(byOption) {
- byOption = byOption || this._chooseSelectOption();
- var selectedItem,
- selectedItems;
- switch (byOption) {
- case"selectedIndex":
- selectedItem = this._editStrategy.getItemDataByIndex(this.option("selectedIndex"));
- if (utils.isDefined(selectedItem)) {
- this._setOptionSilent("selectedItems", [selectedItem]);
- this._setOptionSilent("selectedItem", selectedItem)
- }
- else {
- this._setOptionSilent("selectedItems", []);
- this._setOptionSilent("selectedItem", null)
- }
- break;
- case"selectedItems":
- selectedItems = this.option("selectedItems") || [];
- this._setOptionSilent("selectedItem", selectedItems[0]);
- this._setOptionSilent("selectedIndex", this._editStrategy.getIndexByItemData(selectedItems[0]));
- break;
- case"selectedItem":
- selectedItem = this.option("selectedItem");
- if (utils.isDefined(selectedItem)) {
- this._setOptionSilent("selectedItems", [selectedItem]);
- this._setOptionSilent("selectedIndex", this._editStrategy.getIndexByItemData(selectedItem))
- }
- else {
- this._setOptionSilent("selectedItems", []);
- this._setOptionSilent("selectedIndex", -1)
- }
- break
- }
- },
- _chooseSelectOption: function() {
- var optionName = "selectedIndex";
- if (this.option("selectedItems").length)
- optionName = "selectedItems";
- else if (utils.isDefined(this.option("selectedItem")))
- optionName = "selectedItem";
- return optionName
- },
- _normalizeSelectedItems: function() {
- if (this.option("selectionMode") === "none") {
- this._setOptionSilent("selectedItems", []);
- this._syncSelectionOptions("selectedItems")
- }
- else if (this.option("selectionMode") === "single") {
- var newSelection = this._editStrategy.selectedItemIndices(this.option("selectedItems"));
- if (newSelection.length > 1 || !newSelection.length && this.option("selectionRequired") && this.option("items") && this.option("items").length) {
- var normalizedSelection = [newSelection[0] || this._selectedItemIndices[0] || 0];
- this._setOptionSilent("selectedItems", this._editStrategy.fetchSelectedItems(normalizedSelection));
- this._syncSelectionOptions("selectedItems")
- }
- }
- },
- _initSelectedItems: function() {
- this._selectedItemIndices = this._editStrategy.selectedItemIndices(this.option("selectedItems"))
- },
- _renderSelection: $.noop,
- _itemClickHandler: function(e) {
- this._createAction($.proxy(function(e) {
- this._itemSelectHandler(e.jQueryEvent)
- }, this), {validatingTargetName: "itemElement"})({
- itemElement: $(e.currentTarget),
- jQueryEvent: e
- });
- this.callBase.apply(this, arguments)
- },
- _itemSelectHandler: function(e) {
- if (!this.option("selectionByClick"))
- return;
- var $itemElement = e.currentTarget;
- if (this.isItemSelected($itemElement))
- this.unselectItem(e.currentTarget);
- else
- this.selectItem(e.currentTarget)
- },
- _selectedItemElement: function(index) {
- return this._itemElements().eq(index)
- },
- _postprocessRenderItem: function(args) {
- var $itemElement = $(args.itemElement);
- if (this._isItemSelected(this._editStrategy.getNormalizedIndex($itemElement))) {
- $itemElement.addClass(this._selectedItemClass());
- this._setAriaSelected($itemElement, "true")
- }
- else
- this._setAriaSelected($itemElement, "false")
- },
- _updateSelectedItems: function() {
- var oldSelection = this._selectedItemIndices.slice(),
- newSelection = this._editStrategy.selectedItemIndices(),
- addedSelection = utils.removeDublicates(newSelection, oldSelection),
- removedSelection = utils.removeDublicates(oldSelection, newSelection);
- $.each(removedSelection, $.proxy(function(_, normalizedIndex) {
- this._removeSelection(normalizedIndex)
- }, this));
- $.each(addedSelection, $.proxy(function(_, normalizedIndex) {
- this._addSelection(normalizedIndex)
- }, this));
- if (removedSelection.length || addedSelection.length) {
- var selectionChangePromise = this._selectionChangePromise;
- this._updateSelection(addedSelection, removedSelection);
- $.when(selectionChangePromise).done($.proxy(function() {
- this._fireSelectItemEvent(addedSelection, removedSelection);
- this._fireSelectionChangeEvent(addedSelection, removedSelection)
- }, this))
- }
- },
- _fireSelectionChangeEvent: function(addedSelection, removedSelection) {
- this._createActionByOption("onSelectionChanged", {excludeValidators: ["disabled", "readOnly"]})({
- addedItems: this._editStrategy.fetchSelectedItems(addedSelection),
- removedItems: this._editStrategy.fetchSelectedItems(removedSelection)
- })
- },
- _fireSelectItemEvent: function(addedSelection, removedSelection) {
- if (this.NAME === "dxList" && this.option("selectionMode") !== "single")
- return;
- this._itemEventHandler(this._selectedItemElement(addedSelection[0]), "itemSelectAction", {
- selectedIndex: addedSelection[0],
- previousIndex: removedSelection[0]
- }, {excludeValidators: ["disabled", "readOnly"]})
- },
- _updateSelection: function() {
- this._renderSelection.apply(this, arguments)
- },
- _setAriaSelected: function($target, value) {
- this.setAria("selected", value, $target)
- },
- _removeSelection: function(normalizedIndex) {
- var $itemElement = this._editStrategy.getItemElement(normalizedIndex),
- itemSelectionIndex = $.inArray(normalizedIndex, this._selectedItemIndices);
- if (itemSelectionIndex > -1) {
- $itemElement.removeClass(this._selectedItemClass());
- this._setAriaSelected($itemElement, "false");
- this._selectedItemIndices.splice(itemSelectionIndex, 1);
- $itemElement.triggerHandler("stateChanged");
- if (this.NAME === "dxList")
- this._itemEventHandler($itemElement, "itemUnselectAction", {}, {excludeValidators: ["disabled", "readOnly"]})
- }
- },
- _addSelection: function(normalizedIndex) {
- var $itemElement = this._editStrategy.getItemElement(normalizedIndex);
- if (normalizedIndex > -1 && !this._isItemSelected(normalizedIndex)) {
- $itemElement.addClass(this._selectedItemClass());
- this._setAriaSelected($itemElement, "true");
- this._selectedItemIndices.push(normalizedIndex);
- $itemElement.triggerHandler("stateChanged");
- if (this.NAME === "dxList")
- this._itemEventHandler($itemElement, "itemSelectAction", {}, {excludeValidators: ["disabled", "readOnly"]})
- }
- },
- _isItemSelected: function(index) {
- return $.inArray(index, this._selectedItemIndices) > -1
- },
- _optionChanged: function(args) {
- if (this._cancelOptionChange)
- return;
- switch (args.name) {
- case"items":
- if (args.previousValue && args.previousValue.length > 0)
- this._clearSelectedItems();
- this.callBase(args);
- break;
- case"selectionMode":
- this._invalidate();
- break;
- case"selectedIndex":
- case"selectedItem":
- case"selectedItems":
- this._syncSelectionOptions(args.name);
- this._normalizeSelectedItems();
- this._updateSelectedItems();
- break;
- case"selectionRequired":
- this._normalizeSelectedItems();
- this._updateSelectedItems();
- break;
- case"selectionByClick":
- case"onSelectionChanged":
- case"onItemDeleting":
- case"onItemDeleted":
- case"onItemReordered":
- case"itemSelectAction":
- case"itemUnselectAction":
- break;
- default:
- this.callBase(args)
- }
- },
- _clearSelectedItems: function() {
- this._selectedItemIndices = [];
- this.option("selectedItems", [])
- },
- _setOptionSilent: function(name, value) {
- this._cancelOptionChange = true;
- this.option(name, value);
- this._cancelOptionChange = false
- },
- _waitDeletingPrepare: function($itemElement) {
- if ($itemElement.data(ITEM_DELETING_DATA_KEY))
- return $.Deferred().resolve().promise();
- $itemElement.data(ITEM_DELETING_DATA_KEY, true);
- var deferred = $.Deferred(),
- deletePromise = this._itemEventHandler($itemElement, "onItemDeleting", {}, {excludeValidators: ["disabled", "readOnly"]});
- $.when(deletePromise).always($.proxy(function(value) {
- var deletePromiseExists = !deletePromise,
- deletePromiseResolved = !deletePromiseExists && deletePromise.state() === "resolved",
- argumentsSpecified = !!arguments.length,
- shouldDelete = deletePromiseExists || deletePromiseResolved && !argumentsSpecified || deletePromiseResolved && value;
- $itemElement.data(ITEM_DELETING_DATA_KEY, false);
- shouldDelete ? deferred.resolve() : deferred.reject()
- }, this));
- return deferred.promise()
- },
- _deleteItemFromDS: function($item) {
- if (!this._dataSource)
- return $.Deferred().resolve().promise();
- var deferred = $.Deferred(),
- disabledState = this.option("disabled"),
- dataStore = this._dataSource.store();
- this.option("disabled", true);
- if (!dataStore.remove)
- throw DX.Error("E1011");
- dataStore.remove(dataStore.keyOf(this._getItemData($item))).done(function(key) {
- if (key !== undefined)
- deferred.resolve();
- else
- deferred.reject()
- }).fail(function() {
- deferred.reject()
- });
- deferred.always($.proxy(function() {
- this.option("disabled", disabledState)
- }, this));
- return deferred
- },
- _tryRefreshLastPage: function() {
- var deferred = $.Deferred();
- if (this._isLastPage() || this.option("grouped"))
- deferred.resolve();
- else
- this._refreshLastPage().done(function() {
- deferred.resolve()
- });
- return deferred.promise()
- },
- _refreshLastPage: function() {
- this._expectLastItemLoading();
- return this._dataSource.load()
- },
- _updateSelectionAfterDelete: function(fromIndex) {
- var itemIndex = $.inArray(fromIndex, this._selectedItemIndices);
- if (itemIndex > -1)
- this._selectedItemIndices.splice(itemIndex, 1);
- this._editStrategy.updateSelectionAfterDelete(fromIndex);
- this.option("selectedItems", this._editStrategy.fetchSelectedItems())
- },
- _simulateOptionChange: function(optionName) {
- var optionValue = this.option(optionName);
- if (optionValue instanceof DX.data.DataSource)
- return;
- this.fireEvent("optionChanged", [{
- name: optionName,
- fullName: optionName,
- value: optionValue
- }])
- },
- isItemSelected: function(itemElement) {
- return this._isItemSelected(this._editStrategy.getNormalizedIndex(itemElement))
- },
- selectItem: function(itemElement) {
- var itemIndex = this._editStrategy.getNormalizedIndex(itemElement);
- if (itemIndex === -1)
- return;
- var itemSelectionIndex = $.inArray(itemIndex, this._selectedItemIndices);
- if (itemSelectionIndex !== -1)
- return;
- if (this.option("selectionMode") === "single")
- this.option("selectedItems", this._editStrategy.fetchSelectedItems([itemIndex]));
- else {
- var newSelectedIndices = this._selectedItemIndices.slice();
- newSelectedIndices.push(itemIndex);
- this.option("selectedItems", this._editStrategy.fetchSelectedItems(newSelectedIndices))
- }
- },
- unselectItem: function(itemElement) {
- var itemIndex = this._editStrategy.getNormalizedIndex(itemElement);
- if (itemIndex === -1)
- return;
- var itemSelectionIndex = $.inArray(itemIndex, this._selectedItemIndices);
- if (itemSelectionIndex === -1)
- return;
- var newSelectedIndices = this._selectedItemIndices.slice();
- newSelectedIndices.splice(itemSelectionIndex, 1);
- if (this.option("selectionRequired") && newSelectedIndices.length === 0)
- return;
- this.option("selectedItems", this._editStrategy.fetchSelectedItems(newSelectedIndices))
- },
- deleteItem: function(itemElement) {
- var that = this,
- deferred = $.Deferred(),
- $item = this._editStrategy.getItemElement(itemElement),
- index = this._editStrategy.getNormalizedIndex(itemElement),
- changingOption = this._dataSource ? "dataSource" : "items",
- itemResponseWaitClass = this._itemResponseWaitClass();
- if (index > -1)
- this._waitDeletingPrepare($item).done(function() {
- $item.addClass(itemResponseWaitClass);
- that._deleteItemFromDS($item).done(function() {
- that._editStrategy.deleteItemAtIndex(index);
- that._simulateOptionChange(changingOption);
- that._updateSelectionAfterDelete(index);
- that._itemEventHandler($item, "onItemDeleted", {}, {
- beforeExecute: function() {
- $item.detach()
- },
- excludeValidators: ["disabled", "readOnly"]
- });
- that._renderEmptyMessage();
- that._tryRefreshLastPage().done(function() {
- deferred.resolveWith(that)
- })
- }).fail(function() {
- $item.removeClass(itemResponseWaitClass);
- deferred.rejectWith(that)
- })
- }).fail(function() {
- deferred.rejectWith(that)
- });
- else
- deferred.rejectWith(that);
- return deferred.promise()
- },
- reorderItem: function(itemElement, toItemElement) {
- var deferred = $.Deferred(),
- that = this,
- strategy = this._editStrategy,
- $movingItem = strategy.getItemElement(itemElement),
- $destinationItem = strategy.getItemElement(toItemElement),
- movingIndex = strategy.getNormalizedIndex(itemElement),
- destinationIndex = strategy.getNormalizedIndex(toItemElement),
- changingOption;
- var canMoveItems = movingIndex > -1 && destinationIndex > -1 && movingIndex !== destinationIndex;
- if (canMoveItems)
- if (this._dataSource) {
- changingOption = "dataSource";
- deferred.resolveWith(this)
- }
- else {
- changingOption = "items";
- deferred.resolveWith(this)
- }
- else
- deferred.rejectWith(this);
- return deferred.promise().done(function() {
- $destinationItem[strategy.itemPlacementFunc(movingIndex, destinationIndex)]($movingItem);
- var newSelectedItems = strategy.getSelectedItemsAfterReorderItem(movingIndex, destinationIndex);
- strategy.moveItemAtIndexToIndex(movingIndex, destinationIndex);
- that._selectedItemIndices = strategy.selectedItemIndices(newSelectedItems);
- that.option("selectedItems", strategy.fetchSelectedItems());
- that._simulateOptionChange(changingOption);
- that._itemEventHandler($movingItem, "onItemReordered", {
- fromIndex: strategy.getIndex(movingIndex),
- toIndex: strategy.getIndex(destinationIndex)
- }, {excludeValidators: ["disabled", "readOnly"]})
- })
- }
- });
- ui.CollectionWidget = CollectionWidget
- })(jQuery, DevExpress);
- /*! Module core, file ui.collectionWidget.edit.strategy.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- ui.CollectionWidget.EditStrategy = DX.Class.inherit({
- ctor: function(collectionWidget) {
- this._collectionWidget = collectionWidget
- },
- getIndexByItemData: DX.abstract,
- getItemDataByIndex: DX.abstract,
- getNormalizedIndex: function(value) {
- if (this._isNormalisedItemIndex(value))
- return value;
- if (this._isItemIndex(value))
- return this._normalizeItemIndex(value);
- return this._getNormalizedItemIndex(value)
- },
- getIndex: function(value) {
- if (this._isNormalisedItemIndex(value))
- return this._denormalizeItemIndex(value);
- if (this._isItemIndex(value))
- return value;
- return this._denormalizeItemIndex(this._getNormalizedItemIndex(value))
- },
- getItemElement: function(value) {
- if (this._isNormalisedItemIndex(value))
- return this._getItemByNormalizedIndex(value);
- if (this._isItemIndex(value))
- return this._getItemByNormalizedIndex(this._normalizeItemIndex(value));
- return $(value)
- },
- deleteItemAtIndex: DX.abstract,
- updateSelectionAfterDelete: DX.abstract,
- fetchSelectedItems: DX.abstract,
- selectedItemIndices: DX.abstract,
- itemPlacementFunc: function(movingIndex, destinationIndex) {
- return this._itemsFromSameParent(movingIndex, destinationIndex) && movingIndex < destinationIndex ? "after" : "before"
- },
- moveItemAtIndexToIndex: DX.abstract,
- getSelectedItemsAfterReorderItem: function() {
- return this._collectionWidget.option("selectedItems")
- },
- _isNormalisedItemIndex: function(index) {
- return $.isNumeric(index)
- },
- _isItemIndex: DX.abstract,
- _getNormalizedItemIndex: DX.abstract,
- _normalizeItemIndex: DX.abstract,
- _denormalizeItemIndex: DX.abstract,
- _getItemByNormalizedIndex: DX.abstract,
- _itemsFromSameParent: DX.abstract
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.collectionWidget.edit.strategy.plain.js */
- (function($, DX, undefined) {
- var ui = DX.ui;
- ui.CollectionWidget.PlainEditStrategy = ui.CollectionWidget.EditStrategy.inherit({
- _getPlainItems: function() {
- return this._collectionWidget.option("items") || []
- },
- getIndexByItemData: function(itemData) {
- return $.inArray(itemData, this._getPlainItems())
- },
- getItemDataByIndex: function(index) {
- return this._getPlainItems()[index]
- },
- deleteItemAtIndex: function(index) {
- this._getPlainItems().splice(index, 1)
- },
- updateSelectionAfterDelete: function(fromIndex) {
- var selectedItemIndices = this._collectionWidget._selectedItemIndices;
- $.each(selectedItemIndices, function(i, index) {
- if (index > fromIndex)
- selectedItemIndices[i] -= 1
- })
- },
- fetchSelectedItems: function(indices) {
- indices = indices || this._collectionWidget._selectedItemIndices;
- var items = this._getPlainItems(),
- selectedItems = [];
- $.each(indices, function(_, index) {
- selectedItems.push(items[index])
- });
- return selectedItems
- },
- selectedItemIndices: function() {
- var selectedIndices = [],
- items = this._getPlainItems(),
- selected = this._collectionWidget.option("selectedItems");
- $.each(selected, function(_, selectedItem) {
- var index = $.inArray(selectedItem, items);
- if (index !== -1)
- selectedIndices.push(index);
- else
- DX.log("W1002", selectedItem)
- });
- return selectedIndices
- },
- moveItemAtIndexToIndex: function(movingIndex, destinationIndex) {
- var items = this._getPlainItems(),
- movedItemData = items[movingIndex];
- items.splice(movingIndex, 1);
- items.splice(destinationIndex, 0, movedItemData)
- },
- _isItemIndex: function(index) {
- return $.isNumeric(index)
- },
- _getNormalizedItemIndex: function(itemElement) {
- return this._collectionWidget._itemElements().index(itemElement)
- },
- _normalizeItemIndex: function(index) {
- return index
- },
- _denormalizeItemIndex: function(index) {
- return index
- },
- _getItemByNormalizedIndex: function(index) {
- return this._collectionWidget._itemElements().eq(index)
- },
- _itemsFromSameParent: function() {
- return true
- }
- })
- })(jQuery, DevExpress);
- /*! Module core, file ui.tooltip.js */
- (function($, DX, undefined) {
- var $tooltip = null;
- var createTooltip = function(options) {
- options = $.extend({position: "top"}, options);
- var content = options.content;
- delete options.content;
- return $("<div />").html(content).appendTo(DX.viewPort()).dxTooltip(options)
- };
- var removeTooltip = function() {
- if (!$tooltip)
- return;
- $tooltip.remove();
- $tooltip = null
- };
- var tooltip = {
- show: function(options) {
- removeTooltip();
- $tooltip = createTooltip(options);
- return $tooltip.dxTooltip("show")
- },
- hide: function() {
- if (!$tooltip)
- return $.when();
- return $tooltip.dxTooltip("hide").done(removeTooltip).promise()
- }
- };
- DX.ui.tooltip = tooltip
- })(jQuery, DevExpress)
- }
- if (!DevExpress.MOD_VIZ_CORE) {
- if (!window.DevExpress)
- throw Error('Required module is not referenced: core');
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz = {}
- })(DevExpress);
- /*! Module viz-core, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.core = {}
- })(DevExpress);
- /*! Module viz-core, file errorsWarnings.js */
- (function($, DX) {
- $.extend(DX.ERROR_MESSAGES, {
- E2001: "Invalid data source",
- E2002: "Axis type and data type are incompatible",
- E2003: "\"{0}\" data source field contains data of unsupported type",
- E2004: "\"{0}\" data source field is inconsistent",
- E2101: "Unknown series type was specified: {0}",
- E2102: "Ambiguity occurred between two value axes with the same name",
- E2103: "\"{0}\" option must be a function",
- E2104: "Invalid logarithm base",
- E2105: "Invalid value of a \"{0}\"",
- E2106: "Invalid visible range",
- E2202: "Invalid scale {0} value",
- E2203: "The \"{0}\" field of the \"selectedRange\" configuration object is not valid",
- W2001: "{0} cannot be drawn because its container is invisible",
- W2002: "The {0} data field is absent",
- W2003: "Tick interval is too small",
- W2101: "\"{0}\" pane does not exist; \"{1}\" pane is used instead",
- W2102: "Value axis with the \"{0}\" name was created automatically",
- W2103: "Chart title was hidden due to container size",
- W2104: "Legend was hidden due to container size",
- W2105: "Title of \"{0}\" axis was hidden due to container size",
- W2106: "Labels of \"{0}\" axis were hidden due to container size",
- W2301: "Invalid value range"
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file numericTickManager.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _adjustValue = utils.adjustValue,
- _math = Math,
- _abs = _math.abs,
- _ceil = _math.ceil,
- _floor = _math.floor,
- _noop = $.noop,
- MINOR_TICKS_COUNT_LIMIT = 200,
- DEFAULT_MINOR_NUMBER_MULTIPLIERS = [2, 4, 5, 8, 10];
- core.outOfScreen = {
- x: -1000,
- y: -1000
- };
- core.tickManager = {};
- core.tickManager.continuous = {
- _hasUnitBeginningTickCorrection: _noop,
- _removeBoundedOverlappingDates: _noop,
- _correctInterval: function(step) {
- this._tickInterval *= step
- },
- _correctMax: function(tickInterval) {
- this._max = this._adjustNumericTickValue(_ceil(this._max / tickInterval) * tickInterval, tickInterval, this._min)
- },
- _correctMin: function(tickInterval) {
- this._min = this._adjustNumericTickValue(_floor(this._min / tickInterval) * tickInterval, tickInterval, this._min)
- },
- _findBusinessDelta: function(min, max) {
- return _adjustValue(_abs(min - max))
- },
- _findTickIntervalForCustomTicks: function() {
- return _abs(this._customTicks[1] - this._customTicks[0])
- },
- _getBoundInterval: function() {
- var that = this,
- boundCoef = that._options.boundCoef;
- return _isDefined(boundCoef) && isFinite(boundCoef) ? that._tickInterval * _abs(boundCoef) : that._tickInterval / 2
- },
- _getInterval: function(deltaCoef, numberMultipliers) {
- var interval = deltaCoef || this._getDeltaCoef(this._screenDelta, this._businessDelta, this._options.gridSpacingFactor),
- multipliers = numberMultipliers || this._options.numberMultipliers,
- factor,
- result = 0,
- newResult,
- hasResult = false,
- i;
- if (interval > 1.0)
- for (factor = 1; !hasResult; factor *= 10)
- for (i = 0; i < multipliers.length; i++) {
- result = multipliers[i] * factor;
- if (interval <= result) {
- hasResult = true;
- break
- }
- }
- else if (interval > 0) {
- result = 1;
- for (factor = 0.1; !hasResult; factor /= 10)
- for (i = multipliers.length - 1; i >= 0; i--) {
- newResult = multipliers[i] * factor;
- if (interval > newResult) {
- hasResult = true;
- break
- }
- result = newResult
- }
- }
- return _adjustValue(result)
- },
- _getMarginValue: function(min, max, margin) {
- return utils.applyPrecisionByMinDelta(min, margin, _abs(max - min) * margin)
- },
- _getDefaultMinorInterval: function(screenDelta, businessDelta) {
- var deltaCoef = this._getDeltaCoef(screenDelta, businessDelta, this._options.minorGridSpacingFactor),
- multipliers = DEFAULT_MINOR_NUMBER_MULTIPLIERS,
- i = multipliers.length - 1,
- result;
- for (i; i >= 0; i--) {
- result = businessDelta / multipliers[i];
- if (deltaCoef <= result)
- return _adjustValue(result)
- }
- return 0
- },
- _getMinorInterval: function(screenDelta, businessDelta) {
- var that = this,
- options = that._options,
- minorTickInterval = options.minorTickInterval,
- minorTickCount = options.minorTickCount,
- interval,
- intervalsCount,
- count;
- if (isFinite(minorTickInterval) && that._isTickIntervalCorrect(minorTickInterval, MINOR_TICKS_COUNT_LIMIT, businessDelta)) {
- interval = minorTickInterval;
- count = interval < businessDelta ? _ceil(businessDelta / interval) - 1 : 0
- }
- else if (_isDefined(minorTickCount)) {
- intervalsCount = _isDefined(minorTickCount) ? minorTickCount + 1 : _floor(screenDelta / options.minorGridSpacingFactor);
- count = intervalsCount - 1;
- interval = count > 0 ? businessDelta / intervalsCount : 0
- }
- else {
- interval = that._getDefaultMinorInterval(screenDelta, businessDelta);
- count = interval < businessDelta ? _floor(businessDelta / interval) - 1 : 0
- }
- that._minorTickInterval = interval;
- that._minorTickCount = count
- },
- _getNextTickValue: function(value, tickInterval, isTickIntervalNegative) {
- tickInterval = _isDefined(isTickIntervalNegative) && isTickIntervalNegative ? -tickInterval : tickInterval;
- value += tickInterval;
- return this._adjustNumericTickValue(value, tickInterval, this._min)
- },
- _isTickIntervalValid: function(tickInterval) {
- return _isDefined(tickInterval) && isFinite(tickInterval) && tickInterval !== 0
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file datetimeTickManager.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _convertDateUnitToMilliseconds = utils.convertDateUnitToMilliseconds,
- _correctDateWithUnitBeginning = utils.correctDateWithUnitBeginning,
- _dateToMilliseconds = utils.dateToMilliseconds,
- _convertMillisecondsToDateUnits = utils.convertMillisecondsToDateUnits,
- _math = Math,
- _abs = _math.abs,
- _ceil = _math.ceil,
- _floor = _math.floor,
- _round = _math.round,
- MINOR_TICKS_COUNT_LIMIT = 50,
- DEFAULT_DATETIME_MULTIPLIERS = {
- millisecond: [1, 2, 5, 10, 25, 100, 250, 300, 500],
- second: [1, 2, 3, 5, 10, 15, 20, 30],
- minute: [1, 2, 3, 5, 10, 15, 20, 30],
- hour: [1, 2, 3, 4, 6, 8, 12],
- day: [1, 2, 3, 5, 7, 10, 14],
- month: [1, 2, 3, 6]
- };
- core.tickManager.datetime = $.extend({}, core.tickManager.continuous, {
- _correctInterval: function(step) {
- var tickIntervalInMs = _dateToMilliseconds(this._tickInterval);
- this._tickInterval = _convertMillisecondsToDateUnits(tickIntervalInMs * step)
- },
- _correctMax: function(tickInterval) {
- var interval = _dateToMilliseconds(tickInterval);
- this._max = new Date(_ceil(this._max / interval) * interval)
- },
- _correctMin: function(tickInterval) {
- var interval = _dateToMilliseconds(tickInterval);
- this._min = new Date(_floor(this._min / interval) * interval);
- if (this._options.setTicksAtUnitBeginning)
- _correctDateWithUnitBeginning(this._min, tickInterval)
- },
- _findTickIntervalForCustomTicks: function() {
- return _convertMillisecondsToDateUnits(_abs(this._customTicks[1] - this._customTicks[0]))
- },
- _getBoundInterval: function() {
- var that = this,
- interval = that._tickInterval,
- intervalInMs = _dateToMilliseconds(interval),
- boundCoef = that._options.boundCoef,
- boundIntervalInMs = _isDefined(boundCoef) && isFinite(boundCoef) ? intervalInMs * _abs(boundCoef) : intervalInMs / 2;
- return _convertMillisecondsToDateUnits(boundIntervalInMs)
- },
- _getInterval: function(deltaCoef) {
- var interval = deltaCoef || this._getDeltaCoef(this._screenDelta, this._businessDelta, this._options.gridSpacingFactor),
- multipliers = this._options.numberMultipliers,
- result = {},
- factor,
- i,
- key,
- specificMultipliers,
- yearsCount;
- if (interval > 0 && interval < 1.0)
- return {milliseconds: 1};
- if (interval === 0)
- return 0;
- for (key in DEFAULT_DATETIME_MULTIPLIERS)
- if (DEFAULT_DATETIME_MULTIPLIERS.hasOwnProperty(key)) {
- specificMultipliers = DEFAULT_DATETIME_MULTIPLIERS[key];
- for (i = 0; i < specificMultipliers.length; i++)
- if (interval <= _convertDateUnitToMilliseconds(key, specificMultipliers[i])) {
- result[key + 's'] = specificMultipliers[i];
- return result
- }
- }
- for (factor = 1; ; factor *= 10)
- for (i = 0; i < multipliers.length; i++) {
- yearsCount = factor * multipliers[i];
- if (interval <= _convertDateUnitToMilliseconds('year', yearsCount))
- return {years: yearsCount}
- }
- return 0
- },
- _getMarginValue: function(min, max, margin) {
- return _convertMillisecondsToDateUnits(_round(_abs(max - min) * margin))
- },
- _getMinorInterval: function(screenDelta, businessDelta) {
- var that = this,
- options = that._options,
- interval,
- intervalInMs,
- intervalsCount,
- count;
- if (_isDefined(options.minorTickInterval) && that._isTickIntervalCorrect(options.minorTickInterval, MINOR_TICKS_COUNT_LIMIT, businessDelta)) {
- interval = options.minorTickInterval;
- intervalInMs = _dateToMilliseconds(interval);
- count = intervalInMs < businessDelta ? _ceil(businessDelta / intervalInMs) - 1 : 0
- }
- else {
- intervalsCount = _isDefined(options.minorTickCount) ? options.minorTickCount + 1 : _floor(screenDelta / options.minorGridSpacingFactor);
- count = intervalsCount - 1;
- interval = count > 0 ? _convertMillisecondsToDateUnits(businessDelta / intervalsCount) : 0
- }
- that._minorTickInterval = interval;
- that._minorTickCount = count
- },
- _getNextTickValue: function(value, tickInterval, isTickIntervalNegative, isTickIntervalWithPow, withCorrection) {
- var newValue = utils.addInterval(value, tickInterval, isTickIntervalNegative);
- if (this._options.setTicksAtUnitBeginning && withCorrection !== false) {
- _correctDateWithUnitBeginning(newValue, tickInterval, true);
- this._correctDateWithUnitBeginningCalled = true
- }
- return newValue
- },
- _getUnitBeginningMinorTicks: function(minorTicks) {
- var that = this,
- ticks = that._ticks,
- tickInterval = that._findMinorTickInterval(ticks[1], ticks[2]),
- isTickIntervalNegative = true,
- isTickIntervalWithPow = false,
- needCorrectTick = false,
- startTick = that._getNextTickValue(ticks[1], tickInterval, isTickIntervalNegative, isTickIntervalWithPow, needCorrectTick);
- if (that._isTickIntervalValid(tickInterval))
- minorTicks = that._createTicks(minorTicks, tickInterval, startTick, ticks[0], isTickIntervalNegative, isTickIntervalWithPow, needCorrectTick);
- return minorTicks
- },
- _hasUnitBeginningTickCorrection: function() {
- var ticks = this._ticks;
- if (ticks.length < 3)
- return false;
- return ticks[1] - ticks[0] !== ticks[2] - ticks[1] && this._options.setTicksAtUnitBeginning && this._options.minorTickCount
- },
- _isTickIntervalValid: function(tickInterval) {
- return _isDefined(tickInterval) && _dateToMilliseconds(tickInterval) !== 0
- },
- _removeBoundedOverlappingDates: function() {
- var dates = this._ticks;
- if (dates.length > 2 && this.getOverlappingBehavior().mode !== "stagger" && !this._areDisplayValuesValid(dates[0], dates[1]))
- dates.splice(1, 1)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file logarithmicTickManager.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _addInterval = utils.addInterval,
- _adjustValue = utils.adjustValue,
- _getLog = utils.getLog,
- _raiseTo = utils.raiseTo,
- _math = Math,
- _abs = _math.abs,
- _ceil = _math.ceil,
- _floor = _math.floor,
- _round = _math.round;
- core.tickManager.logarithmic = $.extend({}, core.tickManager.continuous, {
- _correctMax: function() {
- var base = this._options.base;
- this._max = _adjustValue(_raiseTo(_ceil(_adjustValue(_getLog(this._max, base))), base))
- },
- _correctMin: function() {
- var base = this._options.base;
- this._min = _adjustValue(_raiseTo(_floor(_adjustValue(_getLog(this._min, base))), base))
- },
- _findBusinessDelta: function(min, max, isTickIntervalWithPow) {
- var delta;
- if (min <= 0 || max <= 0)
- return 0;
- if (isTickIntervalWithPow === false)
- delta = core.tickManager.continuous._findBusinessDelta(min, max);
- else
- delta = _round(_abs(_getLog(min, this._options.base) - _getLog(max, this._options.base)));
- return delta
- },
- _findTickIntervalForCustomTicks: function() {
- return _adjustValue(_getLog(this._customTicks[1] / this._customTicks[0], this._options.base))
- },
- _getInterval: function(deltaCoef) {
- var interval = deltaCoef || this._getDeltaCoef(this._screenDelta, this._businessDelta, this._options.gridSpacingFactor),
- multipliers = this._options.numberMultipliers,
- factor,
- result = 0,
- hasResult = false,
- i;
- if (interval !== 0)
- for (factor = 1; !hasResult; factor *= 10)
- for (i = 0; i < multipliers.length; i++) {
- result = multipliers[i] * factor;
- if (interval <= result) {
- hasResult = true;
- break
- }
- }
- return _adjustValue(result)
- },
- _getMinorInterval: function(screenDelta, businessDelta) {
- var that = this,
- options = that._options,
- minorTickCount = options.minorTickCount,
- intervalsCount = _isDefined(minorTickCount) ? minorTickCount + 1 : _floor(screenDelta / options.minorGridSpacingFactor),
- count = intervalsCount - 1,
- interval = count > 0 ? businessDelta / intervalsCount : 0;
- that._minorTickInterval = interval;
- that._minorTickCount = count
- },
- _getMarginValue: function() {
- return null
- },
- _getNextTickValue: function(value, tickInterval, isTickIntervalNegative, isTickIntervalWithPow) {
- var that = this,
- pow,
- nextTickValue;
- tickInterval = _isDefined(isTickIntervalNegative) && isTickIntervalNegative ? -tickInterval : tickInterval;
- if (isTickIntervalWithPow === false)
- nextTickValue = value + tickInterval;
- else {
- pow = _addInterval(_getLog(value, that._options.base), tickInterval, that._min > that._max);
- nextTickValue = _adjustValue(_raiseTo(pow, that._options.base))
- }
- return nextTickValue
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file tickOverlappingManager.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- coreTickManager = core.tickManager,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _isNumber = utils.isNumber,
- _math = Math,
- _abs = _math.abs,
- _ceil = _math.ceil,
- _floor = _math.floor,
- _atan = _math.atan,
- _max = _math.max,
- _each = $.each,
- _map = $.map,
- _noop = $.noop,
- _isFunction = $.isFunction,
- SCREEN_DELTA_KOEF = 4,
- AXIS_STAGGER_OVERLAPPING_KOEF = 2,
- STAGGER = "stagger",
- ROTATE = "rotate",
- MIN_ARRANGEMENT_TICKS_COUNT = 2;
- function nextState(state) {
- switch (state) {
- case"overlap":
- return STAGGER;
- case STAGGER:
- return ROTATE;
- default:
- return "end"
- }
- }
- function defaultGetTextFunc(value) {
- return value.toString()
- }
- coreTickManager.overlappingMethods = {};
- coreTickManager.overlappingMethods.base = {
- _applyOverlappingBehavior: function() {
- var that = this,
- options = that._options,
- overlappingBehavior = options && options.overlappingBehavior;
- if (overlappingBehavior && overlappingBehavior.mode !== "ignore") {
- that._useAutoArrangement = true;
- that._correctTicks();
- if (overlappingBehavior.mode === "auto") {
- that._applyAutoOverlappingBehavior();
- that._useAutoArrangement = options.overlappingBehavior.isOverlapped
- }
- if (that._useAutoArrangement) {
- if (overlappingBehavior.mode === STAGGER)
- that._screenDelta *= AXIS_STAGGER_OVERLAPPING_KOEF;
- that._applyAutoArrangement()
- }
- }
- },
- _checkBoundedTicksOverlapping: function() {
- this._removeBoundedOverlappingDates();
- this._applyStartEndTicksCorrection()
- },
- getMaxLabelParams: function(ticks) {
- var that = this,
- getText = that._options.getText || defaultGetTextFunc,
- tickWithMaxLength,
- tickTextWithMaxLength,
- maxLength = 0,
- bbox;
- ticks = ticks || that._getMajorTicks();
- if (!ticks.length)
- return {
- width: 0,
- height: 0,
- length: 0,
- y: 0
- };
- _each(ticks, function(_, item) {
- var text = getText(item, that._options.labelOptions),
- length = text.length;
- if (maxLength < length) {
- maxLength = length;
- tickWithMaxLength = item;
- tickTextWithMaxLength = text
- }
- });
- bbox = that._getTextElementBbox(tickWithMaxLength, tickTextWithMaxLength);
- return {
- width: bbox.width,
- height: bbox.height,
- y: bbox.y,
- length: maxLength
- }
- },
- _applyAutoArrangement: function() {
- var that = this,
- options = that._options,
- arrangementStep,
- maxDisplayValueSize;
- if (that._useAutoArrangement) {
- maxDisplayValueSize = that._getTicksSize();
- arrangementStep = that._getAutoArrangementStep(maxDisplayValueSize);
- if (arrangementStep > 1)
- if (_isDefined(that._tickInterval) || _isDefined(that._customTicks))
- that._ticks = that._getAutoArrangementTicks(arrangementStep);
- else {
- options.gridSpacingFactor = maxDisplayValueSize;
- that._ticks = that._createTicks([], that._findTickInterval(), that._min, that._max)
- }
- }
- },
- _getAutoArrangementTicks: function(step) {
- var that = this,
- ticks = that._ticks,
- ticksLength = ticks.length,
- resultTicks = ticks,
- decimatedTicks = that._decimatedTicks || [],
- i;
- if (step > 1) {
- resultTicks = [];
- for (i = 0; i < ticksLength; i++)
- if (i % step === 0)
- resultTicks.push(ticks[i]);
- else
- decimatedTicks.push(ticks[i]);
- that._correctInterval(step)
- }
- return resultTicks
- },
- _isOverlappedTicks: function(screenDelta) {
- return this._getAutoArrangementStep(this._getTicksSize(), screenDelta, -1) > 1
- },
- _areDisplayValuesValid: function(value1, value2) {
- var that = this,
- options = that._options,
- getText = options.getText || defaultGetTextFunc,
- rotationAngle = options.overlappingBehavior && _isNumber(options.overlappingBehavior.rotationAngle) ? options.overlappingBehavior.rotationAngle : 0,
- bBox1 = that._getTextElementBbox(value1, getText(value1, options.labelOptions)),
- bBox2 = that._getTextElementBbox(value2, getText(value2, options.labelOptions)),
- horizontalInverted = bBox1.x > bBox2.x,
- verticalInverted = bBox1.y > bBox2.y,
- hasHorizontalOverlapping,
- hasVerticalOverlapping,
- result;
- if (rotationAngle !== 0)
- result = that._getDistanceByAngle(bBox1.height, rotationAngle) <= _abs(bBox2.x - bBox1.x);
- else {
- hasHorizontalOverlapping = !horizontalInverted ? bBox1.x + bBox1.width > bBox2.x : bBox2.x + bBox2.width > bBox1.x;
- hasVerticalOverlapping = !verticalInverted ? bBox1.y + bBox1.height > bBox2.y : bBox2.y + bBox2.height > bBox1.y;
- result = !(hasHorizontalOverlapping && hasVerticalOverlapping)
- }
- return result
- }
- };
- coreTickManager.overlappingMethods.circular = $.extend({}, coreTickManager.overlappingMethods.base, {
- _correctTicks: _noop,
- _applyAutoOverlappingBehavior: function() {
- this._options.overlappingBehavior.isOverlapped = true
- },
- _getTextElementBbox: function(value, text) {
- var textOptions = $.extend({}, this._options.textOptions, {rotate: 0}),
- delta = _isFunction(this._options.translate) ? this._options.translate(value) : {
- x: 0,
- y: 0
- },
- bbox;
- text = this._options.renderText(text, delta.x, delta.y).css(this._options.textFontStyles).attr(textOptions);
- bbox = text.getBBox();
- text.remove();
- return bbox
- },
- _getTicksSize: function() {
- return this.getMaxLabelParams(this._ticks)
- },
- _applyStartEndTicksCorrection: function() {
- var ticks = this._ticks,
- lastTick = ticks[ticks.length - 1];
- if (ticks.length > 1 && !this._areDisplayValuesValid(ticks[0], lastTick))
- ticks.pop()
- },
- _getAutoArrangementStep: function(maxDisplayValueSize) {
- var that = this,
- options = that._options,
- radius = options.circularRadius,
- startAngle = options.circularStartAngle,
- endAngle = options.circularEndAngle,
- circleDelta = startAngle === endAngle ? 360 : _abs(startAngle - endAngle),
- businessDelta = that._businessDelta || that._ticks.length,
- degreesPerTick = that._tickInterval * circleDelta / businessDelta,
- width = maxDisplayValueSize.width,
- height = maxDisplayValueSize.height,
- angle1 = _abs(2 * _atan(height / (2 * radius - width)) * 180 / _math.PI),
- angle2 = _abs(2 * _atan(width / (2 * radius - height)) * 180 / _math.PI),
- minAngleForTick = _max(angle1, angle2),
- step = 1;
- if (degreesPerTick < minAngleForTick)
- step = _ceil(minAngleForTick / degreesPerTick);
- return _max(1, step)
- }
- });
- coreTickManager.overlappingMethods.linear = $.extend({}, coreTickManager.overlappingMethods.base, {
- _correctTicks: function() {
- var getIntervalFunc = coreTickManager.continuous._getInterval,
- arrangementStep;
- if (this._testingGetIntervalFunc)
- getIntervalFunc = this._testingGetIntervalFunc;
- arrangementStep = _ceil(getIntervalFunc.call(this, this._getDeltaCoef(this._screenDelta * SCREEN_DELTA_KOEF, this._ticks.length))) || this._ticks.length;
- this._appliedArrangementStep = arrangementStep;
- this._ticks = this._getAutoArrangementTicks(arrangementStep)
- },
- _getTextElementBbox: function(value, text) {
- var textOptions = $.extend({}, this._options.textOptions, {rotate: 0}),
- x = 0,
- y = 0,
- delta = _isFunction(this._options.translate) ? this._options.translate(value) : 0,
- bbox;
- if (this._options.isHorizontal)
- x += delta;
- else
- y += delta;
- text = this._options.renderText(text, x, y).css(this._options.textFontStyles).attr(textOptions);
- bbox = text.getBBox();
- text.remove();
- return bbox
- },
- _applyStartEndTicksCorrection: _noop,
- _getAutoArrangementStep: function(maxDisplayValueSize, screenDelta, minArrangementTicksStep) {
- var that = this,
- options = that._options,
- requiredValuesCount,
- textSpacing = options.textSpacing || 0,
- addedSpacing = options.isHorizontal ? textSpacing : 0;
- screenDelta = screenDelta || that._screenDelta;
- minArrangementTicksStep = _isDefined(minArrangementTicksStep) ? minArrangementTicksStep : 1;
- if (options.getCustomAutoArrangementStep)
- return options.getCustomAutoArrangementStep(that._ticks, options);
- if (maxDisplayValueSize > 0) {
- requiredValuesCount = _floor((screenDelta + textSpacing) / (maxDisplayValueSize + addedSpacing));
- requiredValuesCount = requiredValuesCount <= minArrangementTicksStep ? MIN_ARRANGEMENT_TICKS_COUNT : requiredValuesCount;
- return _ceil((options.ticksCount || that._ticks.length) / requiredValuesCount)
- }
- return 1
- },
- _getOptimalRotationAngle: function() {
- var that = this,
- options = that._options,
- tick1 = that._ticks[0],
- tick2 = that._ticks[1],
- outOfScreen = core.outOfScreen,
- textOptions = that._textOptions,
- getText = options.getText || defaultGetTextFunc,
- textFontStyles = options.textFontStyles,
- svgElement1 = options.renderText(getText(tick1, options.labelOptions), outOfScreen.x + options.translate(tick1, !options.isHorizontal), outOfScreen.y).css(textFontStyles).attr(textOptions),
- svgElement2 = options.renderText(getText(tick2, options.labelOptions), outOfScreen.x + options.translate(tick2, !options.isHorizontal), outOfScreen.y).css(textFontStyles).attr(textOptions),
- bBox1 = svgElement1.getBBox(),
- bBox2 = svgElement2.getBBox(),
- angle = _math.asin((bBox1.height + options.textSpacing) / (bBox2.x - bBox1.x)) * 180 / Math.PI;
- svgElement1.remove();
- svgElement2.remove();
- return isNaN(angle) ? 90 : _ceil(angle)
- },
- _applyAutoOverlappingBehavior: function() {
- var that = this,
- overlappingBehavior = that._options.overlappingBehavior,
- screenDelta = that._screenDelta,
- isOverlapped = false,
- rotationAngle = null,
- mode = null,
- state = "overlap";
- while (state !== "end") {
- isOverlapped = rotationAngle && rotationAngle !== 90 ? false : that._isOverlappedTicks(screenDelta);
- state = nextState(isOverlapped ? state : null);
- switch (state) {
- case STAGGER:
- screenDelta *= AXIS_STAGGER_OVERLAPPING_KOEF;
- mode = state;
- break;
- case ROTATE:
- rotationAngle = that._getOptimalRotationAngle();
- screenDelta = that._screenDelta;
- mode = state;
- break
- }
- }
- overlappingBehavior.isOverlapped = isOverlapped;
- overlappingBehavior.mode = mode;
- overlappingBehavior.rotationAngle = rotationAngle
- },
- _getDistanceByAngle: function(elementHeight, rotationAngle) {
- return elementHeight / _abs(_math.sin(rotationAngle * (_math.PI / 180)))
- },
- _getTicksSize: function() {
- var that = this,
- options = that._options,
- ticks = that._ticks,
- ticksString,
- rotationAngle = options.overlappingBehavior ? options.overlappingBehavior.rotationAngle : 0,
- bBox,
- result,
- getText = options.getText || defaultGetTextFunc,
- isRotate = _isNumber(rotationAngle) && rotationAngle !== 0,
- joinNeeded = !isRotate && options.isHorizontal;
- if (ticks.length === 0)
- return 0;
- ticksString = joinNeeded ? _map(ticks, function(tick) {
- return getText(tick, options.labelOptions)
- }).join("\n") : getText(ticks[0], options.labelOptions);
- bBox = that._getTextElementBbox(ticksString, ticksString);
- result = isRotate ? that._getDistanceByAngle(bBox.height, rotationAngle) : options.isHorizontal ? bBox.width : bBox.height;
- return _ceil(result)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file baseTickManager.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- coreTickManager = core.tickManager,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _isNumber = utils.isNumber,
- _addInterval = utils.addInterval,
- _adjustValue = utils.adjustValue,
- _each = $.each,
- _map = $.map,
- _inArray = $.inArray,
- _noop = $.noop,
- DEFAULT_GRID_SPACING_FACTOR = 30,
- DEFAULT_MINOR_GRID_SPACING_FACTOR = 15,
- DEFAULT_NUMBER_MULTIPLIERS = [1, 2, 3, 5],
- TICKS_COUNT_LIMIT = 2000,
- MIN_ARRANGEMENT_TICKS_COUNT = 2;
- function concatAndSort(array1, array2) {
- var array = array1.concat(array2).sort(function(x, y) {
- return _isDefined(x) && _isDefined(y) && x.valueOf() - y.valueOf()
- }),
- length = array.length,
- i;
- for (i = length - 1; i > 0; i--)
- if (_isDefined(array[i]) && _isDefined(array[i - 1]) && array[i].valueOf() === array[i - 1].valueOf())
- array.splice(i, 1);
- return array
- }
- coreTickManager.discrete = $.extend({}, coreTickManager.continuous, {
- _getMinorTicks: _noop,
- _findTickInterval: _noop,
- _createTicks: function() {
- return []
- },
- _getMarginValue: _noop,
- _generateBounds: _noop,
- _correctMin: _noop,
- _correctMax: _noop,
- _findBusinessDelta: _noop,
- _addBoundedTicks: _noop,
- getFullTicks: function() {
- return this._customTicks
- },
- getMinorTicks: function() {
- return this._decimatedTicks || []
- },
- _findTickIntervalForCustomTicks: function() {
- return 1
- }
- });
- coreTickManager.TickManager = DX.Class.inherit({
- ctor: function(types, data, options) {
- options = options || {};
- this.update(types || {}, data || {}, options);
- this._initOverlappingMethods(options.overlappingBehaviorType)
- },
- dispose: function() {
- this._ticks = null;
- this._minorTicks = null;
- this._decimatedTicks = null;
- this._boundaryTicks = null;
- this._options = null
- },
- update: function(types, data, options) {
- this._updateOptions(options || {});
- this._min = data.min;
- this._updateTypes(types || {});
- this._updateData(data || {})
- },
- _updateMinMax: function(data) {
- var min = data.min || 0,
- max = data.max || 0,
- newMinMax = this._applyMinMaxMargins(min, max);
- this._min = this._originalMin = newMinMax.min;
- this._max = this._originalMax = newMinMax.max;
- this._updateBusinessDelta()
- },
- _updateBusinessDelta: function() {
- this._businessDelta = this._findBusinessDelta && this._findBusinessDelta(this._min, this._max)
- },
- _updateTypes: function(types) {
- var that = this,
- axisType = that._validateAxisType(types.axisType),
- dataType = that._validateDataType(types.dataType);
- that._resetMethods();
- this._axisType = axisType;
- this._dataType = dataType;
- this._initMethods()
- },
- _updateData: function(data) {
- data = $.extend({}, data);
- data.min = _isDefined(data.min) ? data.min : this._originalMin;
- data.max = _isDefined(data.max) ? data.max : this._originalMax;
- this._updateMinMax(data);
- this._customTicks = data.customTicks && data.customTicks.slice();
- this._customMinorTicks = data.customMinorTicks;
- this._screenDelta = data.screenDelta || 0
- },
- _updateOptions: function(options) {
- var opt;
- this._options = opt = options;
- this._useAutoArrangement = !!this._options.useTicksAutoArrangement;
- opt.gridSpacingFactor = opt.gridSpacingFactor || DEFAULT_GRID_SPACING_FACTOR;
- opt.minorGridSpacingFactor = opt.minorGridSpacingFactor || DEFAULT_MINOR_GRID_SPACING_FACTOR;
- opt.numberMultipliers = opt.numberMultipliers || DEFAULT_NUMBER_MULTIPLIERS
- },
- getTickBounds: function() {
- return {
- minVisible: this._minBound,
- maxVisible: this._maxBound
- }
- },
- getTicks: function(withoutOverlappingBehavior) {
- var that = this,
- options = that._options;
- that._ticks = that._getMajorTicks();
- that._checkLabelFormat();
- that._decimatedTicks = [];
- that._applyAutoArrangement();
- !withoutOverlappingBehavior && that._applyOverlappingBehavior();
- that._generateBounds();
- if (options.showMinorTicks)
- that._minorTicks = that._customMinorTicks || that._getMinorTicks();
- that._addBoundedTicks();
- !withoutOverlappingBehavior && that._checkBoundedTicksOverlapping();
- return that._ticks
- },
- getMinorTicks: function() {
- var that = this,
- decimatedTicks = that._decimatedTicks || [],
- options = that._options || {},
- hasDecimatedTicks = decimatedTicks.length,
- hasMinorTickOptions = _isDefined(options.minorTickInterval) || _isDefined(options.minorTickCount),
- hasCustomMinorTicks = that._customMinorTicks && that._customMinorTicks.length,
- hasMinorTicks = options.showMinorTicks && (hasMinorTickOptions || hasCustomMinorTicks),
- ticks = hasDecimatedTicks && !hasMinorTicks ? decimatedTicks : that._minorTicks || [];
- return concatAndSort(ticks, [])
- },
- getDecimatedTicks: function() {
- return concatAndSort(this._decimatedTicks || [], [])
- },
- getFullTicks: function() {
- return concatAndSort(this._ticks || [], this.getMinorTicks(), this._axisType)
- },
- getBoundaryTicks: function() {
- return concatAndSort(this._boundaryTicks || [], [])
- },
- getTickInterval: function() {
- return this._tickInterval
- },
- getMinorTickInterval: function() {
- return this._minorTickInterval
- },
- getOverlappingBehavior: function() {
- return this._options.overlappingBehavior
- },
- getOptions: function() {
- return this._options
- },
- _getMajorTicks: function() {
- var ticks;
- if (this._customTicks) {
- ticks = this._customTicks.slice();
- this._tickInterval = ticks.length > 1 ? this._findTickIntervalForCustomTicks() : 0
- }
- else
- ticks = this._createTicks([], this._findTickInterval(), this._min, this._max);
- return ticks
- },
- _applyMargin: function(margin, min, max, isNegative) {
- var coef,
- value = min;
- if (isFinite(margin)) {
- coef = this._getMarginValue(min, max, margin);
- if (coef)
- value = this._getNextTickValue(min, coef, isNegative, false)
- }
- return value
- },
- _applyMinMaxMargins: function(min, max) {
- var options = this._options,
- newMin = min > max ? max : min,
- newMax = max > min ? max : min;
- this._minCorrectionEnabled = this._getCorrectionEnabled(min, "min");
- this._maxCorrectionEnabled = this._getCorrectionEnabled(max, "max");
- if (options && !options.stick) {
- newMin = this._applyMargin(options.minValueMargin, min, max, true);
- newMax = this._applyMargin(options.maxValueMargin, max, min, false)
- }
- return {
- min: newMin,
- max: newMax
- }
- },
- _checkBoundedTickInArray: function(value, array) {
- var arrayValues = _map(array || [], function(item) {
- return item.valueOf()
- }),
- minorTicksIndex = _inArray(value.valueOf(), arrayValues);
- if (minorTicksIndex !== -1)
- array.splice(minorTicksIndex, 1)
- },
- _checkLabelFormat: function() {
- var options = this._options;
- if (this._dataType === "datetime" && !options.hasLabelFormat && this._ticks.length)
- options.labelOptions.format = DX.formatHelper.getDateFormatByTicks(this._ticks)
- },
- _generateBounds: function() {
- var that = this,
- interval = that._getBoundInterval(),
- stick = that._options.stick,
- minStickValue = that._options.minStickValue,
- maxStickValue = that._options.maxStickValue,
- minBound = that._minCorrectionEnabled && !stick ? that._getNextTickValue(that._min, interval, true) : that._originalMin,
- maxBound = that._maxCorrectionEnabled && !stick ? that._getNextTickValue(that._max, interval) : that._originalMax;
- that._minBound = minBound < minStickValue ? minStickValue : minBound;
- that._maxBound = maxBound > maxStickValue ? maxStickValue : maxBound
- },
- _initOverlappingMethods: function(type) {
- this._initMethods(coreTickManager.overlappingMethods[type || "linear"])
- },
- _addBoundedTicks: function() {
- var that = this,
- tickValues = _map(that._ticks, function(tick) {
- return tick.valueOf()
- }),
- min = that._originalMin,
- max = that._originalMax,
- addMinMax = that._options.addMinMax || {};
- that._boundaryTicks = [];
- if (addMinMax.min && _inArray(min.valueOf(), tickValues) === -1) {
- that._ticks.splice(0, 0, min);
- that._boundaryTicks.push(min);
- that._checkBoundedTickInArray(min, that._minorTicks);
- that._checkBoundedTickInArray(min, that._decimatedTicks)
- }
- if (addMinMax.max && _inArray(max.valueOf(), tickValues) === -1) {
- that._ticks.push(max);
- that._boundaryTicks.push(max);
- that._checkBoundedTickInArray(max, that._minorTicks);
- that._checkBoundedTickInArray(max, that._decimatedTicks)
- }
- },
- _getCorrectionEnabled: function(value, marginSelector) {
- var options = this._options || {},
- hasPercentStick = options.percentStick && value === 1,
- hasValueMargin = options[marginSelector + "ValueMargin"];
- return !hasPercentStick && !hasValueMargin
- },
- _validateAxisType: function(type) {
- var defaultType = "continuous",
- allowedTypes = {
- continuous: true,
- discrete: true,
- logarithmic: true
- };
- return allowedTypes[type] ? type : defaultType
- },
- _validateDataType: function(type) {
- var allowedTypes = {
- numeric: true,
- datetime: true,
- string: true
- };
- if (!allowedTypes[type])
- type = _isDefined(this._min) ? this._getDataType(this._min) : "numeric";
- return type
- },
- _getDataType: function(value) {
- return utils.isDate(value) ? 'datetime' : 'numeric'
- },
- _getMethods: function() {
- var methods;
- if (this._axisType === "continuous")
- methods = this._dataType === "datetime" ? coreTickManager.datetime : coreTickManager.continuous;
- else
- methods = coreTickManager[this._axisType] || coreTickManager.continuous;
- return methods
- },
- _resetMethods: function() {
- var that = this,
- methods = that._getMethods();
- _each(methods, function(name) {
- if (that[name])
- delete that[name]
- })
- },
- _initMethods: function(methods) {
- var that = this;
- methods = methods || that._getMethods();
- _each(methods, function(name, func) {
- that[name] = func
- })
- },
- _getDeltaCoef: function(screenDelta, businessDelta, gridSpacingFactor) {
- var count;
- gridSpacingFactor = gridSpacingFactor || this._options.gridSpacingFactor;
- screenDelta = screenDelta || this._screenDelta;
- businessDelta = businessDelta || this._businessDelta;
- count = screenDelta / gridSpacingFactor;
- count = count <= 1 ? MIN_ARRANGEMENT_TICKS_COUNT : count;
- return businessDelta / count
- },
- _adjustNumericTickValue: function(value, interval, min) {
- return utils.isExponential(value) ? _adjustValue(value) : utils.applyPrecisionByMinDelta(min, interval, value)
- },
- _isTickIntervalCorrect: function(tickInterval, tickCountLimit, businessDelta) {
- var date;
- businessDelta = businessDelta || this._businessDelta;
- if (!_isNumber(tickInterval)) {
- date = new Date;
- tickInterval = _addInterval(date, tickInterval) - date;
- if (!tickInterval)
- return false
- }
- if (_isNumber(tickInterval))
- if (tickInterval > 0 && businessDelta / tickInterval > tickCountLimit) {
- if (this._options.incidentOccured)
- this._options.incidentOccured('W2003')
- }
- else
- return true;
- return false
- },
- _correctValue: function(valueTypeSelector, tickInterval, correctionMethod) {
- var that = this,
- correctionEnabledSelector = "_" + valueTypeSelector + "CorrectionEnabled",
- spaceCorrectionSelector = valueTypeSelector + "SpaceCorrection",
- valueSelector = "_" + valueTypeSelector,
- minStickValue = that._options.minStickValue,
- maxStickValue = that._options.maxStickValue;
- if (that[correctionEnabledSelector]) {
- if (that._options[spaceCorrectionSelector])
- that[valueSelector] = that._getNextTickValue(that[valueSelector], tickInterval, valueTypeSelector === "min");
- correctionMethod.call(this, tickInterval)
- }
- if (valueTypeSelector === "min")
- that[valueSelector] = that[valueSelector] < minStickValue ? minStickValue : that[valueSelector];
- if (valueTypeSelector === "max")
- that[valueSelector] = that[valueSelector] > maxStickValue ? maxStickValue : that[valueSelector]
- },
- _findTickInterval: function() {
- var that = this,
- options = that._options,
- tickInterval;
- tickInterval = that._isTickIntervalValid(options.tickInterval) && that._isTickIntervalCorrect(options.tickInterval, TICKS_COUNT_LIMIT) ? options.tickInterval : that._getInterval();
- if (that._isTickIntervalValid(tickInterval)) {
- that._correctValue("min", tickInterval, that._correctMin);
- that._correctValue("max", tickInterval, that._correctMax);
- that._updateBusinessDelta()
- }
- that._tickInterval = tickInterval;
- return tickInterval
- },
- _findMinorTickInterval: function(firstTick, secondTick) {
- var that = this,
- ticks = that._ticks,
- intervals = that._options.stick ? ticks.length - 1 : ticks.length;
- if (intervals < 1)
- intervals = 1;
- that._getMinorInterval(that._screenDelta / intervals, that._findBusinessDelta(firstTick, secondTick, false));
- return that._minorTickInterval
- },
- _createMinorTicks: function(ticks, firstTick, secondTick) {
- var that = this,
- tickInterval = that._findMinorTickInterval(firstTick, secondTick),
- isTickIntervalNegative = false,
- isTickIntervalWithPow = false,
- needCorrectTick = false,
- startTick = that._getNextTickValue(firstTick, tickInterval, isTickIntervalNegative, isTickIntervalWithPow, needCorrectTick);
- if (that._isTickIntervalValid(tickInterval))
- ticks = that._createCountedTicks(ticks, tickInterval, startTick, secondTick, that._minorTickCount, isTickIntervalNegative, isTickIntervalWithPow, needCorrectTick);
- return ticks
- },
- _getMinorTicks: function() {
- var that = this,
- minorTicks = [],
- ticks = that._ticks,
- ticksLength = ticks.length,
- hasUnitBeginningTick = that._hasUnitBeginningTickCorrection(),
- i = hasUnitBeginningTick ? 1 : 0;
- if (ticks.length) {
- minorTicks = that._getBoundedMinorTicks(minorTicks, that._minBound, ticks[0], true);
- if (hasUnitBeginningTick)
- minorTicks = that._getUnitBeginningMinorTicks(minorTicks);
- for (i; i < ticksLength - 1; i++)
- minorTicks = that._createMinorTicks(minorTicks, ticks[i], ticks[i + 1]);
- minorTicks = that._getBoundedMinorTicks(minorTicks, that._maxBound, ticks[ticksLength - 1])
- }
- else
- minorTicks = that._createMinorTicks(minorTicks, that._minBound, that._maxBound);
- return minorTicks
- },
- _createCountedTicks: function(ticks, tickInterval, min, max, count, isTickIntervalWithPow, needMax) {
- var value = min,
- i;
- for (i = 0; i < count; i++) {
- if (!(needMax === false && value.valueOf() === max.valueOf()))
- ticks.push(value);
- value = this._getNextTickValue(value, tickInterval, false, isTickIntervalWithPow, false)
- }
- return ticks
- },
- _createTicks: function(ticks, tickInterval, min, max, isTickIntervalNegative, isTickIntervalWithPow, withCorrection) {
- var that = this,
- value = min,
- newValue = min,
- leftBound,
- rightBound,
- boundedRule;
- if (that._isTickIntervalValid(tickInterval)) {
- boundedRule = min - max < 0;
- do {
- value = newValue;
- if (that._options.stick) {
- if (value >= that._originalMin && value <= that._originalMax)
- ticks.push(value)
- }
- else
- ticks.push(value);
- newValue = that._getNextTickValue(value, tickInterval, isTickIntervalNegative, isTickIntervalWithPow, withCorrection);
- if (value.valueOf() === newValue.valueOf())
- break;
- leftBound = newValue - min >= 0;
- rightBound = max - newValue >= 0
- } while (boundedRule === leftBound && boundedRule === rightBound)
- }
- else
- ticks.push(value);
- return ticks
- },
- _getBoundedMinorTicks: function(minorTicks, boundedTick, tick, isNegative) {
- var that = this,
- needCorrectTick = false,
- nextTick = that._tickInterval ? this._getNextTickValue(tick, that._tickInterval, isNegative, true, needCorrectTick) : boundedTick,
- tickInterval = that._findMinorTickInterval(tick, nextTick),
- isTickIntervalCorrect = that._isTickIntervalCorrect(tickInterval, TICKS_COUNT_LIMIT, that._findBusinessDelta(tick, boundedTick, false)),
- startTick,
- endTick,
- boundedTickValue = boundedTick.valueOf();
- if (isTickIntervalCorrect && that._isTickIntervalValid(tickInterval) && that._minorTickCount > 0) {
- if (isNegative) {
- if (tick.valueOf() <= boundedTickValue)
- return minorTicks;
- while (nextTick.valueOf() < boundedTickValue)
- nextTick = this._getNextTickValue(nextTick, tickInterval, false, false, needCorrectTick);
- startTick = nextTick;
- endTick = that._getNextTickValue(tick, tickInterval, true, false, false)
- }
- else {
- startTick = that._getNextTickValue(tick, tickInterval, false, false, false);
- endTick = boundedTick
- }
- minorTicks = that._createTicks(minorTicks, tickInterval, startTick, endTick, false, false, needCorrectTick)
- }
- return minorTicks
- },
- getTypes: function() {
- return {
- axisType: this._axisType,
- dataType: this._dataType
- }
- },
- getData: function() {
- return {
- min: this._min,
- max: this._max,
- customTicks: this._customTicks,
- customMinorTicks: this._customMinorTicks,
- screenDelta: this._screenDelta
- }
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file numericTranslator.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- isDefined = utils.isDefined,
- round = Math.round;
- DX.viz.core.numericTranslatorFunctions = {
- translate: function(bp) {
- var that = this,
- canvasOptions = that._canvasOptions,
- doubleError = canvasOptions.rangeDoubleError,
- specialValue = that.translateSpecialCase(bp);
- if (isDefined(specialValue))
- return specialValue;
- if (isNaN(bp) || bp.valueOf() + doubleError < canvasOptions.rangeMin || bp.valueOf() - doubleError > canvasOptions.rangeMax)
- return null;
- return that._conversionValue(that._calculateProjection((bp - canvasOptions.rangeMinVisible) * canvasOptions.ratioOfCanvasRange))
- },
- untranslate: function(pos, _directionOffset, enableOutOfCanvas) {
- var canvasOptions = this._canvasOptions,
- startPoint = canvasOptions.startPoint;
- if (!enableOutOfCanvas && (pos < startPoint || pos > canvasOptions.endPoint) || !isDefined(canvasOptions.rangeMin) || !isDefined(canvasOptions.rangeMax))
- return null;
- return this._calculateUnProjection((pos - startPoint) / canvasOptions.ratioOfCanvasRange)
- },
- getInterval: function() {
- return round(this._canvasOptions.ratioOfCanvasRange * (this._businessRange.interval || Math.abs(this._canvasOptions.rangeMax - this._canvasOptions.rangeMin)))
- },
- _getValue: function(val) {
- return val
- },
- zoom: function(translate, scale) {
- var that = this,
- canvasOptions = that._canvasOptions,
- startPoint = canvasOptions.startPoint,
- endPoint = canvasOptions.endPoint,
- newStart = (startPoint + translate) / scale,
- newEnd = (endPoint + translate) / scale,
- minPoint = Math.min(that.translate(that._getValue(canvasOptions.rangeMin)), that.translate(that._getValue(canvasOptions.rangeMax))),
- maxPoint = Math.max(that.translate(that._getValue(canvasOptions.rangeMin)), that.translate(that._getValue(canvasOptions.rangeMax)));
- if (minPoint > newStart) {
- newEnd -= newStart - minPoint;
- newStart = minPoint
- }
- if (maxPoint < newEnd) {
- newStart -= newEnd - maxPoint;
- newEnd = maxPoint
- }
- if (maxPoint - minPoint < newEnd - newStart) {
- newStart = minPoint;
- newEnd = maxPoint
- }
- translate = (endPoint - startPoint) * newStart / (newEnd - newStart) - startPoint;
- scale = (startPoint + translate) / newStart || 1;
- return {
- min: that.untranslate(newStart, undefined, true),
- max: that.untranslate(newEnd, undefined, true),
- translate: translate,
- scale: scale
- }
- },
- getMinScale: function(zoom) {
- return zoom ? 1.1 : 0.9
- },
- getScale: function(val1, val2) {
- var canvasOptions = this._canvasOptions;
- val1 = isDefined(val1) ? val1 : canvasOptions.rangeMin;
- val2 = isDefined(val2) ? val2 : canvasOptions.rangeMax;
- return (canvasOptions.rangeMax - canvasOptions.rangeMin) / Math.abs(val1 - val2)
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file datetimeTranslator.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- numericTranslator = core.numericTranslatorFunctions;
- core.datetimeTranslatorFunctions = {
- translate: numericTranslator.translate,
- untranslate: function() {
- var result = numericTranslator.untranslate.apply(this, arguments);
- return result === null ? result : new Date(result)
- },
- _getValue: numericTranslator._getValue,
- getInterval: numericTranslator.getInterval,
- zoom: numericTranslator.zoom,
- getMinScale: numericTranslator.getMinScale,
- getScale: numericTranslator.getScale
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file categoryTranslator.js */
- (function($, DX, undefined) {
- var isDefined = DX.utils.isDefined,
- round = Math.round;
- DX.viz.core.categoryTranslatorFunctions = {
- translate: function(category, directionOffset) {
- var that = this,
- canvasOptions = that._canvasOptions,
- categoryRecord = that._categoriesToPoints[category],
- stickDelta,
- specialValue = that.translateSpecialCase(category),
- startPointIndex = canvasOptions.startPointIndex || 0,
- stickInterval = that._businessRange.stick ? 0 : 0.5;
- if (isDefined(specialValue))
- return specialValue;
- if (!categoryRecord)
- return null;
- directionOffset = directionOffset || 0;
- directionOffset = canvasOptions.invert ? -directionOffset : directionOffset;
- stickDelta = categoryRecord.index + stickInterval - startPointIndex + directionOffset * 0.5;
- return round(canvasOptions.startPoint + canvasOptions.interval * stickDelta)
- },
- untranslate: function(pos, directionOffset, enableOutOfCanvas) {
- var that = this,
- canvasOptions = that._canvasOptions,
- startPoint = canvasOptions.startPoint,
- categories = that.visibleCategories || that._categories,
- categoriesLength = categories.length,
- result = 0,
- stickInterval = that._businessRange.stick ? 0.5 : 0;
- if (!enableOutOfCanvas && (pos < startPoint || pos > canvasOptions.endPoint))
- return null;
- directionOffset = directionOffset || 0;
- result = round((pos - startPoint) / canvasOptions.interval + stickInterval - 0.5 - directionOffset * 0.5);
- if (categoriesLength === result)
- result--;
- if (result === -1)
- result = 0;
- if (canvasOptions.invert)
- result = categoriesLength - result - 1;
- return categories[result]
- },
- getInterval: function() {
- return this._canvasOptions.interval
- },
- zoom: function(translate, scale) {
- var that = this,
- canvasOptions = that._canvasOptions,
- interval = canvasOptions.interval * scale,
- translateCaltegories = translate / interval,
- stick = that._businessRange.stick,
- startCategoryIndex = parseInt((canvasOptions.startPointIndex || 0) + translateCaltegories + 0.5),
- categoriesLength = parseInt(canvasOptions.canvasLength / interval + (stick ? 1 : 0)) || 1,
- endCategoryIndex,
- newVisibleCategories,
- categories = that._categories,
- newInterval;
- canvasOptions.invert && (categories = categories.slice().reverse());
- if (startCategoryIndex < 0)
- startCategoryIndex = 0;
- endCategoryIndex = startCategoryIndex + categoriesLength;
- if (endCategoryIndex > categories.length) {
- endCategoryIndex = categories.length;
- startCategoryIndex = endCategoryIndex - categoriesLength;
- if (startCategoryIndex < 0)
- startCategoryIndex = 0
- }
- newVisibleCategories = categories.slice(parseInt(startCategoryIndex), parseInt(endCategoryIndex));
- newInterval = that._getDiscreteInterval(newVisibleCategories.length, canvasOptions);
- scale = newInterval / canvasOptions.interval;
- translate = that.translate(newVisibleCategories[0]) * scale - (canvasOptions.startPoint + (stick ? 0 : newInterval / 2));
- return {
- min: !canvasOptions.invert ? newVisibleCategories[0] : newVisibleCategories[newVisibleCategories.length - 1],
- max: !canvasOptions.invert ? newVisibleCategories[newVisibleCategories.length - 1] : newVisibleCategories[0],
- translate: translate,
- scale: scale
- }
- },
- getMinScale: function(zoom) {
- var that = this,
- canvasOptions = that._canvasOptions,
- categoriesLength = (that.visibleCategories || that._categories).length;
- categoriesLength += (parseInt(categoriesLength * 0.1) || 1) * (zoom ? -2 : 2);
- return canvasOptions.canvasLength / (Math.max(categoriesLength, 1) * canvasOptions.interval)
- },
- getScale: function(min, max) {
- var that = this,
- canvasOptions = that._canvasOptions,
- visibleArea = that.getCanvasVisibleArea(),
- stickOffset = !that._businessRange.stick && 1,
- minPoint = that.translate(min, -stickOffset),
- maxPoint = that.translate(max, +stickOffset);
- if (!isDefined(minPoint))
- minPoint = canvasOptions.invert ? visibleArea.max : visibleArea.min;
- if (!isDefined(maxPoint))
- maxPoint = canvasOptions.invert ? visibleArea.min : visibleArea.max;
- return that.canvasLength / Math.abs(maxPoint - minPoint)
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file logarithmicTranslator.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- numericTranslator = core.numericTranslatorFunctions,
- utils = DX.utils,
- raiseTo = utils.raiseTo,
- getLog = utils.getLog;
- core.logarithmicTranslatorFunctions = {
- translate: function(bp) {
- var that = this,
- specialValue = that.translateSpecialCase(bp);
- if (utils.isDefined(specialValue))
- return specialValue;
- return numericTranslator.translate.call(that, getLog(bp, that._businessRange.base))
- },
- untranslate: function() {
- var result = numericTranslator.untranslate.apply(this, arguments);
- return result === null ? result : raiseTo(result, this._businessRange.base)
- },
- getInterval: numericTranslator.getInterval,
- _getValue: function(value) {
- return Math.pow(this._canvasOptions.base, value)
- },
- zoom: numericTranslator.zoom,
- getMinScale: numericTranslator.getMinScale,
- getScale: function(val1, val2) {
- var base = this._businessRange.base;
- val1 = utils.isDefined(val1) ? getLog(val1, base) : undefined;
- val2 = utils.isDefined(val2) ? getLog(val2, base) : undefined;
- return numericTranslator.getScale.call(this, val1, val2)
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file translator1D.js */
- (function(DX, undefined) {
- var _Number = Number;
- function Translator1D() {
- this.setDomain(arguments[0], arguments[1]).setCodomain(arguments[2], arguments[3])
- }
- Translator1D.prototype = {
- constructor: Translator1D,
- setDomain: function(domain1, domain2) {
- var that = this;
- that._domain1 = _Number(domain1);
- that._domain2 = _Number(domain2);
- that._domainDelta = that._domain2 - that._domain1;
- return that
- },
- setCodomain: function(codomain1, codomain2) {
- var that = this;
- that._codomain1 = _Number(codomain1);
- that._codomain2 = _Number(codomain2);
- that._codomainDelta = that._codomain2 - that._codomain1;
- return that
- },
- getDomain: function() {
- return [this._domain1, this._domain2]
- },
- getCodomain: function() {
- return [this._codomain1, this._codomain2]
- },
- getDomainStart: function() {
- return this._domain1
- },
- getDomainEnd: function() {
- return this._domain2
- },
- getCodomainStart: function() {
- return this._codomain1
- },
- getCodomainEnd: function() {
- return this._codomain2
- },
- getDomainRange: function() {
- return this._domainDelta
- },
- getCodomainRange: function() {
- return this._codomainDelta
- },
- translate: function(value) {
- var ratio = (_Number(value) - this._domain1) / this._domainDelta;
- return 0 <= ratio && ratio <= 1 ? this._codomain1 + ratio * this._codomainDelta : NaN
- },
- adjust: function(value) {
- var ratio = (_Number(value) - this._domain1) / this._domainDelta,
- result = NaN;
- if (ratio < 0)
- result = this._domain1;
- else if (ratio > 1)
- result = this._domain2;
- else if (0 <= ratio && ratio <= 1)
- result = _Number(value);
- return result
- }
- };
- DX.viz.core.Translator1D = Translator1D
- })(DevExpress);
- /*! Module viz-core, file translator2D.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- getLog = utils.getLog,
- getPower = utils.getPower,
- isDefined = utils.isDefined,
- _abs = Math.abs,
- CANVAS_PROP = ["width", "height", "left", "top", "bottom", "right"],
- NUMBER_EQUALITY_CORRECTION = 1,
- DATETIME_EQUALITY_CORRECTION = 60000,
- _noop = $.noop,
- _Translator2d;
- var validateCanvas = function(canvas) {
- $.each(CANVAS_PROP, function(_, prop) {
- canvas[prop] = parseInt(canvas[prop]) || 0
- });
- return canvas
- };
- var makeCategoriesToPoints = function(categories, invert) {
- var categoriesToPoints = {},
- category,
- length = categories.length,
- i;
- for (i = 0; i < length; i++) {
- category = categories[i];
- categoriesToPoints[category] = {
- name: category,
- index: invert ? length - 1 - i : i
- }
- }
- return categoriesToPoints
- };
- var validateBusinessRange = function(businessRange) {
- function validate(valueSelector, baseValueSeletor) {
- if (!isDefined(businessRange[valueSelector]) && isDefined(businessRange[baseValueSeletor]))
- businessRange[valueSelector] = businessRange[baseValueSeletor]
- }
- validate("minVisible", "min");
- validate("maxVisible", "max");
- return businessRange
- };
- _Translator2d = core.Translator2D = function(businessRange, canvas, options) {
- this.update(businessRange, canvas, options)
- };
- _Translator2d.prototype = {
- constructor: _Translator2d,
- reinit: function() {
- var that = this,
- range = that._businessRange,
- categories = range.categories || [],
- script = {},
- canvasOptions = that._prepareCanvasOptions(),
- visibleCategories = utils.getCategoriesInfo(categories, range.minVisible, range.maxVisible).categories,
- categoriesLength = (visibleCategories || categories).length;
- switch (range.axisType) {
- case"logarithmic":
- script = core.logarithmicTranslatorFunctions;
- break;
- case"discrete":
- script = core.categoryTranslatorFunctions;
- that._categories = categories;
- canvasOptions.interval = that._getDiscreteInterval(range.addSpiderCategory ? categoriesLength + 1 : categoriesLength, canvasOptions);
- that._categoriesToPoints = makeCategoriesToPoints(categories, canvasOptions.invert);
- if (visibleCategories && visibleCategories.length) {
- canvasOptions.startPointIndex = that._categoriesToPoints[visibleCategories[canvasOptions.invert ? visibleCategories.length - 1 : 0]].index;
- that.visibleCategories = visibleCategories
- }
- break;
- default:
- if (range.dataType === "datetime")
- script = core.datetimeTranslatorFunctions;
- else
- script = core.numericTranslatorFunctions
- }
- that.translate = script.translate;
- that.untranslate = script.untranslate;
- that.getInterval = script.getInterval;
- that.zoom = script.zoom;
- that.getMinScale = script.getMinScale;
- that._getValue = script._getValue;
- that.getScale = script.getScale;
- that._conversionValue = that._options.conversionValue ? function(value) {
- return value
- } : function(value) {
- return Math.round(value)
- }
- },
- _getDiscreteInterval: function(categoriesLength, canvasOptions) {
- var correctedCategoriesCount = categoriesLength - (this._businessRange.stick ? 1 : 0);
- return correctedCategoriesCount > 0 ? canvasOptions.canvasLength / correctedCategoriesCount : canvasOptions.canvasLength
- },
- _getCanvasBounds: function(range) {
- var min = range.min,
- max = range.max,
- minVisible = range.minVisible,
- maxVisible = range.maxVisible,
- newMin,
- newMax,
- base = range.base,
- isDateTime = utils.isDate(max) || utils.isDate(min),
- correction = isDateTime ? DATETIME_EQUALITY_CORRECTION : NUMBER_EQUALITY_CORRECTION;
- if (range.axisType === 'logarithmic') {
- maxVisible = getLog(maxVisible, base);
- minVisible = getLog(minVisible, base);
- min = getLog(min, base);
- max = getLog(max, base)
- }
- if (isDefined(min) && isDefined(max) && min.valueOf() === max.valueOf()) {
- newMin = min.valueOf() - correction;
- newMax = max.valueOf() + correction;
- if (isDateTime) {
- min = new Date(newMin);
- max = new Date(newMax)
- }
- else {
- min = min !== 0 ? newMin : 0;
- max = newMax
- }
- }
- if (isDefined(minVisible) && isDefined(maxVisible) && minVisible.valueOf() === maxVisible.valueOf()) {
- newMin = minVisible.valueOf() - correction;
- newMax = maxVisible.valueOf() + correction;
- if (isDateTime) {
- minVisible = newMin < min.valueOf() ? min : new Date(newMin);
- maxVisible = newMax > max.valueOf() ? max : new Date(newMax)
- }
- else {
- if (minVisible !== 0)
- minVisible = newMin < min ? min : newMin;
- maxVisible = newMax > max ? max : newMax
- }
- }
- return {
- base: base,
- rangeMin: min,
- rangeMax: max,
- rangeMinVisible: minVisible,
- rangeMaxVisible: maxVisible
- }
- },
- _prepareCanvasOptions: function() {
- var that = this,
- businessRange = that._businessRange,
- canvasOptions = that._canvasOptions = that._getCanvasBounds(businessRange),
- length,
- canvas = that._canvas;
- if (that._options.direction === "horizontal") {
- canvasOptions.startPoint = canvas.left;
- length = canvas.width;
- canvasOptions.endPoint = canvas.width - canvas.right;
- canvasOptions.invert = businessRange.invert
- }
- else {
- canvasOptions.startPoint = canvas.top;
- length = canvas.height;
- canvasOptions.endPoint = canvas.height - canvas.bottom;
- canvasOptions.invert = !businessRange.invert
- }
- that.canvasLength = canvasOptions.canvasLength = canvasOptions.endPoint - canvasOptions.startPoint;
- canvasOptions.rangeDoubleError = Math.pow(10, getPower(canvasOptions.rangeMax - canvasOptions.rangeMin) - getPower(length) - 2);
- canvasOptions.ratioOfCanvasRange = canvasOptions.canvasLength / (canvasOptions.rangeMaxVisible - canvasOptions.rangeMinVisible);
- return canvasOptions
- },
- updateBusinessRange: function(businessRange) {
- this._businessRange = validateBusinessRange(businessRange);
- this.reinit()
- },
- update: function(businessRange, canvas, options) {
- var that = this;
- that._options = $.extend(that._options || {}, options);
- that._canvas = validateCanvas(canvas);
- that.updateBusinessRange(businessRange)
- },
- getBusinessRange: function() {
- return this._businessRange
- },
- getCanvasVisibleArea: function() {
- return {
- min: this._canvasOptions.startPoint,
- max: this._canvasOptions.endPoint
- }
- },
- translateSpecialCase: function(value) {
- var that = this,
- canvasOptions = that._canvasOptions,
- startPoint = canvasOptions.startPoint,
- endPoint = canvasOptions.endPoint,
- range = that._businessRange,
- minVisible = range.minVisible,
- maxVisible = range.maxVisible,
- invert,
- result = null;
- switch (value) {
- case"canvas_position_default":
- if (minVisible <= 0 && maxVisible >= 0)
- result = that.translate(0);
- else {
- invert = range.invert ^ (minVisible <= 0 && maxVisible <= 0);
- if (that._options.direction === "horizontal")
- result = invert ? endPoint : startPoint;
- else
- result = invert ? startPoint : endPoint
- }
- break;
- case"canvas_position_left":
- case"canvas_position_top":
- result = startPoint;
- break;
- case"canvas_position_center":
- case"canvas_position_middle":
- result = startPoint + canvasOptions.canvasLength / 2;
- break;
- case"canvas_position_right":
- case"canvas_position_bottom":
- result = endPoint;
- break;
- case"canvas_position_start":
- result = canvasOptions.invert ? endPoint : startPoint;
- break;
- case"canvas_position_end":
- result = canvasOptions.invert ? startPoint : endPoint;
- break
- }
- return result
- },
- _calculateProjection: function(distance) {
- var canvasOptions = this._canvasOptions;
- return canvasOptions.invert ? canvasOptions.endPoint - distance : canvasOptions.startPoint + distance
- },
- _calculateUnProjection: function(distance) {
- var canvasOptions = this._canvasOptions;
- return canvasOptions.invert ? canvasOptions.rangeMaxVisible.valueOf() - distance : canvasOptions.rangeMinVisible.valueOf() + distance
- },
- getVisibleCategories: function() {
- return this.visibleCategories
- },
- getMinBarSize: function(minBarSize) {
- var visibleArea = this.getCanvasVisibleArea(),
- minValue = this.untranslate(visibleArea.min + minBarSize);
- return _abs(this.untranslate(visibleArea.min) - (!isDefined(minValue) ? this.untranslate(visibleArea.max) : minValue))
- },
- translate: _noop,
- untranslate: _noop,
- getInterval: _noop,
- zoom: _noop,
- getMinScale: _noop
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file polarTranslator.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- SHIFT_ANGLE = 90,
- _round = Math.round;
- function PolarTranslator(businessRange, canvas, options) {
- var that = this;
- that._argCanvas = {
- left: 0,
- right: 0,
- width: this._getAngle()
- };
- that._valCanvas = {
- left: 0,
- right: 0
- };
- that.canvas = canvas;
- that._init();
- that._arg = new DX.viz.core.Translator2D(businessRange.arg, that._argCanvas, {
- direction: "horizontal",
- conversionValue: true
- });
- that._val = new DX.viz.core.Translator2D(businessRange.val, that._valCanvas, {direction: "horizontal"});
- that._businessRange = businessRange;
- that.startAngle = utils.isNumber(options.startAngle) ? options.startAngle : 0
- }
- PolarTranslator.prototype = {
- constructor: PolarTranslator,
- _init: function() {
- var canvas = this.canvas;
- this._setCoords({
- x: canvas.left + (canvas.width - canvas.right - canvas.left) / 2,
- y: canvas.top + (canvas.height - canvas.top - canvas.bottom) / 2,
- r: Math.min(canvas.width - canvas.left - canvas.right, canvas.height - canvas.top - canvas.bottom) / 2
- });
- this._valCanvas.width = this._rad
- },
- reinit: function() {
- this._init();
- this._arg.reinit();
- this._val.reinit()
- },
- _setCoords: function(coord) {
- this._x0 = coord.x;
- this._y0 = coord.y;
- this._rad = coord.r < 0 ? 0 : coord.r
- },
- getBusinessRange: function() {
- return this._businessRange
- },
- translate: function(arg, val, offsets) {
- var that = this,
- argTranslate = that._arg.translate(arg, offsets && offsets[0]),
- radius = that._val.translate(val, offsets && offsets[1]),
- angle = utils.isDefined(argTranslate) ? argTranslate + that.startAngle - SHIFT_ANGLE : null,
- cossin = utils.getCosAndSin(angle),
- x,
- y;
- y = _round(that._y0 + radius * cossin.sin);
- x = _round(that._x0 + radius * cossin.cos);
- return {
- x: x,
- y: y,
- angle: angle,
- radius: radius
- }
- },
- getValLength: function() {
- return this._rad
- },
- getCenter: function() {
- return {
- x: this._x0,
- y: this._y0
- }
- },
- getBaseAngle: function() {
- return this.startAngle - SHIFT_ANGLE
- },
- getInterval: function() {
- return this._arg.getInterval()
- },
- getValInterval: function() {
- return this._val.getInterval()
- },
- _getAngle: function() {
- return 360
- },
- getStartAngle: function() {
- return this.startAngle
- },
- getComponent: function(type) {
- var that = this,
- translator = this["_" + type];
- translator.getRadius = function() {
- return that.getValLength()
- };
- translator.getCenter = function() {
- return that.getCenter()
- };
- translator.getStartAngle = function() {
- return that.getStartAngle()
- };
- return translator
- },
- _untranslate: function(x, y) {
- var radius = utils.getDistance(this._x0, this._y0, x, y),
- angle = Math.atan2(y - this._y0, x - this._x0);
- return {
- r: radius,
- phi: angle
- }
- },
- untranslate: function(x, y) {
- var pos = this._untranslate(x, y);
- pos.phi = _round(utils.normalizeAngle(pos.phi * 180 / Math.PI));
- pos.r = _round(pos.r);
- return pos
- },
- getVisibleCategories: $.noop,
- getCanvasVisibleArea: function() {
- return {}
- },
- getMinBarSize: function(minBarSize) {
- return this._val.getMinBarSize(minBarSize)
- }
- };
- DX.viz.core.PolarTranslator = PolarTranslator
- })(jQuery, DevExpress);
- /*! Module viz-core, file rectangle.js */
- (function(DX, undefined) {
- var isFinite = window.isFinite;
- DX.viz.core.Rectangle = DX.Class.inherit({
- ctor: function(options) {
- var that = this;
- options = options || {};
- that.left = Number(options.left) || 0;
- that.right = Number(options.right) || 0;
- that.top = Number(options.top) || 0;
- that.bottom = Number(options.bottom) || 0
- },
- width: function() {
- return this.right - this.left
- },
- height: function() {
- return this.bottom - this.top
- },
- horizontalMiddle: function() {
- return (this.left + this.right) / 2
- },
- verticalMiddle: function() {
- return (this.top + this.bottom) / 2
- },
- raw: function() {
- var that = this;
- return {
- left: that.left,
- top: that.top,
- right: that.right,
- bottom: that.bottom
- }
- },
- clone: function() {
- return new this.constructor(this.raw())
- },
- move: function(dx, dy) {
- var result = this.clone();
- if (isFinite(dx) && isFinite(dy)) {
- result.left += Number(dx);
- result.right += Number(dx);
- result.top += Number(dy);
- result.bottom += Number(dy)
- }
- return result
- },
- inflate: function(dx, dy) {
- var result = this.clone();
- if (isFinite(dx) && isFinite(dy)) {
- result.left -= Number(dx);
- result.right += Number(dx);
- result.top -= Number(dy);
- result.bottom += Number(dy)
- }
- return result
- },
- scale: function(factor) {
- var that = this;
- if (factor > 0)
- return that.inflate(that.width() * (factor - 1) / 2, that.height() * (factor - 1) / 2);
- return that.clone()
- }
- })
- })(DevExpress);
- /*! Module viz-core, file layoutElement.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- _round = Math.round;
- var _splitPair = DX.utils.splitPair;
- var defaultPosition = ["center", "center"],
- defaultOffset = [0, 0];
- var getAlignFactor = function(align) {
- switch (align) {
- case"center":
- return 0.5;
- case"right":
- case"bottom":
- return 1;
- default:
- return 0
- }
- };
- function WrapperLayoutElement(renderElement, bbox) {
- this._renderElement = renderElement;
- this._cacheBBox = bbox
- }
- WrapperLayoutElement.prototype = {
- position: function(options) {
- var that = this,
- ofBBox = options.of.getBBox ? options.of.getBBox() : options.of,
- myBBox = this.getBBox(),
- at = _splitPair(options.at) || defaultPosition,
- my = _splitPair(options.my) || defaultPosition,
- offset = _splitPair(options.offset) || defaultOffset,
- shiftX = -getAlignFactor(my[0]) * myBBox.width + ofBBox.x - myBBox.x + getAlignFactor(at[0]) * ofBBox.width + parseInt(offset[0]),
- shiftY = -getAlignFactor(my[1]) * myBBox.height + ofBBox.y - myBBox.y + getAlignFactor(at[1]) * ofBBox.height + parseInt(offset[1]);
- that._renderElement.move(_round(shiftX), _round(shiftY))
- },
- getBBox: function() {
- return this._cacheBBox || this._renderElement.getBBox()
- },
- draw: function(){}
- };
- core.WrapperLayoutElement = WrapperLayoutElement
- })(jQuery, DevExpress);
- /*! Module viz-core, file themes.js */
- (function(DX, $, undefined) {
- var themes = {},
- themesMapping = {},
- themesSchemeMapping = {},
- _extend = $.extend,
- _each = $.each,
- currentThemeName = null,
- nextCacheUid = 0,
- widgetsCache = {};
- function normalizeName(name) {
- return name ? String(name).toLowerCase() : null
- }
- function findTheme(themeName) {
- var name = normalizeName(themeName);
- return themes[name] || themes[themesMapping[name] || currentThemeName]
- }
- function findThemeNameByName(name, scheme) {
- return themesMapping[name + '.' + scheme] || themesSchemeMapping[name + '.' + scheme] || themesMapping[name]
- }
- function findThemeNameByPlatform(platform, version, scheme) {
- return findThemeNameByName(platform + version, scheme) || findThemeNameByName(platform, scheme)
- }
- function currentTheme(themeName, colorScheme) {
- if (!arguments.length)
- return currentThemeName;
- var scheme = normalizeName(colorScheme);
- currentThemeName = (themeName && themeName.platform ? findThemeNameByPlatform(normalizeName(themeName.platform), themeName.version, scheme) : findThemeNameByName(normalizeName(themeName), scheme)) || currentThemeName;
- return this
- }
- function getThemeInfo(themeName, splitter) {
- var k = themeName.indexOf(splitter);
- return k > 0 ? {
- name: themeName.substring(0, k),
- scheme: themeName.substring(k + 1)
- } : null
- }
- function registerThemeName(themeName, targetThemeName) {
- var themeInfo = getThemeInfo(themeName, '.') || getThemeInfo(themeName, '-') || {name: themeName},
- name = themeInfo.name,
- scheme = themeInfo.scheme;
- if (scheme) {
- themesMapping[name] = themesMapping[name] || targetThemeName;
- themesMapping[name + '.' + scheme] = themesMapping[name + '-' + scheme] = targetThemeName
- }
- else
- themesMapping[name] = targetThemeName
- }
- function registerTheme(theme, baseThemeName) {
- var themeName = normalizeName(theme && theme.name);
- if (themeName) {
- registerThemeName(themeName, themeName);
- themes[themeName] = _extend(true, {}, findTheme(baseThemeName), patchTheme(theme))
- }
- }
- function registerThemeAlias(alias, theme) {
- registerThemeName(normalizeName(alias), normalizeName(theme))
- }
- function registerThemeSchemeAlias(from, to) {
- themesSchemeMapping[from] = to
- }
- function mergeScalar(target, field, source, sourceValue) {
- var _value = source ? source[field] : sourceValue;
- if (_value !== undefined && target[field] === undefined)
- target[field] = _value
- }
- function mergeObject(target, field, source, sourceValue) {
- var _value = source ? source[field] : sourceValue;
- if (_value !== undefined)
- target[field] = _extend(true, {}, _value, target[field])
- }
- function patchTheme(theme) {
- theme = _extend(true, {
- loadingIndicator: {font: {}},
- legend: {
- font: {},
- border: {}
- },
- title: {font: {}},
- tooltip: {font: {}},
- "chart:common": {},
- "chart:common:axis": {
- grid: {},
- minorGrid: {},
- tick: {},
- minorTick: {},
- title: {font: {}},
- label: {font: {}}
- },
- chart: {commonSeriesSettings: {candlestick: {}}},
- pie: {},
- polar: {},
- gauge: {scale: {
- majorTick: {},
- minorTick: {},
- label: {font: {}}
- }},
- barGauge: {},
- map: {background: {}},
- rangeSelector: {
- scale: {label: {font: {}}},
- chart: {}
- },
- sparkline: {},
- bullet: {}
- }, theme);
- mergeScalar(theme.loadingIndicator, "backgroundColor", theme);
- mergeScalar(theme.chart.commonSeriesSettings.candlestick, "innerColor", null, theme.backgroundColor);
- mergeScalar(theme.map.background, "color", null, theme.backgroundColor);
- mergeScalar(theme.title.font, "color", null, theme.primaryTitleColor);
- mergeScalar(theme.legend.font, "color", null, theme.secondaryTitleColor);
- mergeScalar(theme.legend.border, "color", null, theme.axisColor);
- patchAxes(theme);
- _each(["chart", "pie", "polar", "gauge", "barGauge", "map", "rangeSelector", "sparkline", "bullet"], function(_, section) {
- mergeScalar(theme[section], "redrawOnResize", theme);
- mergeScalar(theme[section], "containerBackgroundColor", null, theme.backgroundColor);
- mergeObject(theme[section], "tooltip", theme)
- });
- _each(["chart", "pie", "polar", "gauge", "barGauge", "map", "rangeSelector"], function(_, section) {
- mergeObject(theme[section], "loadingIndicator", theme);
- mergeObject(theme[section], "legend", theme)
- });
- _each(["chart", "pie", "polar", "gauge", "barGauge"], function(_, section) {
- mergeObject(theme[section], "title", theme)
- });
- _each(["gauge", "barGauge"], function(_, section) {
- mergeObject(theme[section], "subtitle", null, theme.title)
- });
- _each(["chart", "pie", "polar"], function(_, section) {
- mergeObject(theme, section, null, theme["chart:common"])
- });
- _each(["chart", "polar"], function(_, section) {
- theme[section] = theme[section] || {};
- mergeObject(theme[section], "commonAxisSettings", null, theme["chart:common:axis"])
- });
- mergeObject(theme.rangeSelector.chart, "commonSeriesSettings", theme.chart);
- mergeObject(theme.rangeSelector.chart, "dataPrepareSettings", theme.chart);
- mergeScalar(theme.map.legend, "backgroundColor", theme);
- return theme
- }
- function patchAxes(theme) {
- var commonAxisSettings = theme["chart:common:axis"],
- colorFieldName = "color";
- _each([commonAxisSettings, commonAxisSettings.grid, commonAxisSettings.minorGrid, commonAxisSettings.tick, commonAxisSettings.minorTick], function(_, obj) {
- mergeScalar(obj, colorFieldName, null, theme.axisColor)
- });
- mergeScalar(commonAxisSettings.title.font, colorFieldName, null, theme.secondaryTitleColor);
- mergeScalar(commonAxisSettings.label.font, colorFieldName, null, theme.axisLabelColor);
- mergeScalar(theme.gauge.scale.label.font, colorFieldName, null, theme.axisLabelColor);
- mergeScalar(theme.gauge.scale.majorTick, colorFieldName, null, theme.backgroundColor);
- mergeScalar(theme.gauge.scale.minorTick, colorFieldName, null, theme.backgroundColor);
- mergeScalar(theme.rangeSelector.scale.label.font, colorFieldName, null, theme.axisLabelColor)
- }
- function addCacheItem(target) {
- var cacheUid = ++nextCacheUid;
- target._cache = cacheUid;
- widgetsCache[cacheUid] = target
- }
- function removeCacheItem(target) {
- delete widgetsCache[target._cache]
- }
- function refreshAll() {
- _each(widgetsCache, function() {
- this.refresh()
- });
- return this
- }
- _extend(DX.viz.core, {
- findTheme: findTheme,
- currentTheme: currentTheme,
- registerTheme: registerTheme,
- registerThemeAlias: registerThemeAlias,
- registerThemeSchemeAlias: registerThemeSchemeAlias,
- refreshAll: refreshAll,
- addCacheItem: addCacheItem,
- removeCacheItem: removeCacheItem
- });
- _extend(DX.viz.core, {
- themes: themes,
- themesMapping: themesMapping,
- themesSchemeMapping: themesSchemeMapping,
- widgetsCache: widgetsCache
- })
- })(DevExpress, jQuery);
- /*! Module viz-core, file palette.js */
- (function(DX, $, undefined) {
- var _String = window.String,
- _floor = Math.floor,
- _ceil = Math.ceil,
- _Color = DX.Color,
- _isArray = DX.utils.isArray,
- _isString = DX.utils.isString,
- _extend = $.extend;
- var palettes = {
- 'default': {
- simpleSet: ['#5f8b95', '#ba4d51', '#af8a53', '#955f71', '#859666', '#7e688c'],
- indicatingSet: ['#a3b97c', '#e1b676', '#ec7f83'],
- gradientSet: ['#5f8b95', '#ba4d51']
- },
- 'harmony light': {
- simpleSet: ['#fcb65e', '#679ec5', '#ad79ce', '#7abd5c', '#e18e92', '#b6d623', '#b7abea', '#85dbd5'],
- indicatingSet: ['#b6d623', '#fcb65e', '#e18e92'],
- gradientSet: ['#7abd5c', '#fcb65e']
- },
- 'soft pastel': {
- simpleSet: ['#60a69f', '#78b6d9', '#6682bb', '#a37182', '#eeba69', '#90ba58', '#456c68', '#7565a4'],
- indicatingSet: ['#90ba58', '#eeba69', '#a37182'],
- gradientSet: ['#78b6d9', '#eeba69']
- },
- pastel: {
- simpleSet: ['#bb7862', '#70b3a1', '#bb626a', '#057d85', '#ab394b', '#dac599', '#153459', '#b1d2c6'],
- indicatingSet: ['#70b3a1', '#dac599', '#bb626a'],
- gradientSet: ['#bb7862', '#70b3a1']
- },
- bright: {
- simpleSet: ['#70c92f', '#f8ca00', '#bd1550', '#e97f02', '#9d419c', '#7e4452', '#9ab57e', '#36a3a6'],
- indicatingSet: ['#70c92f', '#f8ca00', '#bd1550'],
- gradientSet: ['#e97f02', '#f8ca00']
- },
- soft: {
- simpleSet: ['#cbc87b', '#9ab57e', '#e55253', '#7e4452', '#e8c267', '#565077', '#6babac', '#ad6082'],
- indicatingSet: ['#9ab57e', '#e8c267', '#e55253'],
- gradientSet: ['#9ab57e', '#e8c267']
- },
- ocean: {
- simpleSet: ['#75c099', '#acc371', '#378a8a', '#5fa26a', '#064970', '#38c5d2', '#00a7c6', '#6f84bb'],
- indicatingSet: ['#c8e394', '#7bc59d', '#397c8b'],
- gradientSet: ['#acc371', '#38c5d2']
- },
- vintage: {
- simpleSet: ['#dea484', '#efc59c', '#cb715e', '#eb9692', '#a85c4c', '#f2c0b5', '#c96374', '#dd956c'],
- indicatingSet: ['#ffe5c6', '#f4bb9d', '#e57660'],
- gradientSet: ['#efc59c', '#cb715e']
- },
- violet: {
- simpleSet: ['#d1a1d1', '#eeacc5', '#7b5685', '#7e7cad', '#a13d73', '#5b41ab', '#e287e2', '#689cc1'],
- indicatingSet: ['#d8e2f6', '#d0b2da', '#d56a8a'],
- gradientSet: ['#eeacc5', '#7b5685']
- }
- };
- var currentPaletteName = 'default';
- function currentPalette(name) {
- if (name === undefined)
- return currentPaletteName;
- else {
- name = String(name).toLowerCase();
- currentPaletteName = name in palettes ? name : 'default'
- }
- }
- function getPalette(palette, parameters) {
- var result;
- if (_isArray(palette))
- result = palette;
- else {
- parameters = parameters || {};
- var type = parameters.type || 'simpleSet';
- if (_isString(palette)) {
- var name = palette.toLowerCase(),
- baseContainer = palettes[name],
- themedContainer = parameters.theme && palettes[name + '_' + _String(parameters.theme).toLowerCase()];
- result = themedContainer && themedContainer[type] || baseContainer && baseContainer[type]
- }
- if (!result)
- result = palettes[currentPaletteName][type]
- }
- return result ? result.slice(0) : null
- }
- function registerPalette(name, palette, theme) {
- var item = {};
- if (_isArray(palette))
- item.simpleSet = palette.slice(0);
- else if (palette) {
- item.simpleSet = _isArray(palette.simpleSet) ? palette.simpleSet.slice(0) : undefined;
- item.indicatingSet = _isArray(palette.indicatingSet) ? palette.indicatingSet.slice(0) : undefined;
- item.gradientSet = _isArray(palette.gradientSet) ? palette.gradientSet.slice(0) : undefined
- }
- if (item.simpleSet || item.indicatingSet || item.gradientSet) {
- var paletteName = _String(name).toLowerCase();
- if (theme)
- paletteName = paletteName + '_' + _String(theme).toLowerCase();
- _extend(palettes[paletteName] = palettes[paletteName] || {}, item)
- }
- }
- function RingBuf(buf) {
- var ind = 0;
- this.next = function() {
- var res = buf[ind++];
- if (ind === buf.length)
- this.reset();
- return res
- };
- this.reset = function() {
- ind = 0
- }
- }
- function Palette(palette, parameters) {
- parameters = parameters || {};
- this._originalPalette = getPalette(palette, parameters);
- var stepHighlight = parameters ? parameters.stepHighlight || 0 : 0;
- this._paletteSteps = new RingBuf([0, stepHighlight, -stepHighlight]);
- this._resetPalette()
- }
- _extend(Palette.prototype, {
- dispose: function() {
- this._originalPalette = this._palette = this._paletteSteps = null;
- return this
- },
- getNextColor: function() {
- var that = this;
- if (that._currentColor >= that._palette.length)
- that._resetPalette();
- return that._palette[that._currentColor++]
- },
- _resetPalette: function() {
- var that = this;
- that._currentColor = 0;
- var step = that._paletteSteps.next(),
- originalPalette = that._originalPalette;
- if (step) {
- var palette = that._palette = [],
- i = 0,
- ii = originalPalette.length;
- for (; i < ii; ++i)
- palette[i] = getNewColor(originalPalette[i], step)
- }
- else
- that._palette = originalPalette.slice(0)
- },
- reset: function() {
- this._paletteSteps.reset();
- this._resetPalette();
- return this
- }
- });
- function getNewColor(currentColor, step) {
- var newColor = new _Color(currentColor).alter(step),
- lightness = getLightness(newColor);
- if (lightness > 200 || lightness < 55)
- newColor = new _Color(currentColor).alter(-step / 2);
- return newColor.toHex()
- }
- function getLightness(color) {
- return color.r * 0.3 + color.g * 0.59 + color.b * 0.11
- }
- function GradientPalette(source, size) {
- var palette = getPalette(source, {type: 'gradientSet'});
- palette = size > 0 ? createGradientColors(palette, size) : [];
- this.getColor = function(index) {
- return palette[index] || null
- };
- this._DEBUG_source = source;
- this._DEBUG_size = size
- }
- function createGradientColors(source, count) {
- var ncolors = count - 1,
- nsource = source.length - 1,
- colors = [],
- gradient = [],
- i;
- for (i = 0; i <= nsource; ++i)
- colors.push(new _Color(source[i]));
- if (ncolors > 0)
- for (i = 0; i <= ncolors; ++i)
- addColor(i / ncolors);
- else
- addColor(0.5);
- return gradient;
- function addColor(pos) {
- var k = nsource * pos,
- kl = _floor(k),
- kr = _ceil(k);
- gradient.push(colors[kl].blend(colors[kr], k - kl).toHex())
- }
- }
- _extend(DX.viz.core, {
- registerPalette: registerPalette,
- getPalette: getPalette,
- Palette: Palette,
- GradientPalette: GradientPalette,
- currentPalette: currentPalette
- });
- DX.viz.core._DEBUG_palettes = palettes
- })(DevExpress, jQuery);
- /*! Module viz-core, file utils.js */
- (function(DX, $, undefined) {
- var _ceil = Math.ceil,
- _min = Math.min,
- _round = Math.round;
- function selectByKeys(object, keys) {
- return $.map(keys, function(key) {
- return object[key] ? object[key] : null
- })
- }
- function decreaseFields(object, keys, eachDecrease, decrease) {
- var dec = decrease;
- $.each(keys, function(_, key) {
- if (object[key]) {
- object[key] -= eachDecrease;
- dec -= eachDecrease
- }
- });
- return dec
- }
- DX.viz.core.utils = {
- decreaseGaps: function(object, keys, decrease) {
- var arrayGaps;
- do {
- arrayGaps = selectByKeys(object, keys);
- arrayGaps.push(_ceil(decrease / arrayGaps.length));
- decrease = decreaseFields(object, keys, _min.apply(null, arrayGaps), decrease)
- } while (decrease > 0 && arrayGaps.length > 1);
- return decrease
- },
- parseScalar: function(value, defaultValue) {
- return value !== undefined ? value : defaultValue
- },
- enumParser: function(values) {
- var stored = {},
- i,
- ii;
- for (i = 0, ii = values.length; i < ii; ++i)
- stored[String(values[i]).toLowerCase()] = 1;
- return function(value, defaultValue) {
- var _value = String(value).toLowerCase();
- return stored[_value] ? _value : defaultValue
- }
- },
- patchFontOptions: function(options) {
- var fontOptions = {};
- $.each(options || {}, function(key, value) {
- if (/^(cursor|opacity)$/i.test(key));
- else if (key === "color")
- key = "fill";
- else
- key = "font-" + key;
- fontOptions[key] = value
- });
- return fontOptions
- },
- convertPolarToXY: function(centerCoords, startAngle, angle, radius) {
- var shiftAngle = 90,
- cossin;
- angle = DX.utils.isDefined(angle) ? angle + startAngle - shiftAngle : 0;
- cossin = DX.utils.getCosAndSin(angle);
- return {
- x: _round(centerCoords.x + radius * cossin.cos),
- y: _round(centerCoords.y + radius * cossin.sin)
- }
- },
- convertXYToPolar: function(centerCoords, x, y) {
- var radius = DX.utils.getDistance(centerCoords.x, centerCoords.y, x, y),
- angle = Math.atan2(y - centerCoords.y, x - centerCoords.x);
- return {
- phi: _round(DX.utils.normalizeAngle(angle * 180 / Math.PI)),
- r: _round(radius)
- }
- }
- }
- })(DevExpress, jQuery);
- /*! Module viz-core, file baseThemeManager.js */
- (function(DX, $, undefined) {
- var _isString = DX.utils.isString,
- _parseScalar = DX.viz.core.utils.parseScalar,
- _findTheme = DX.viz.core.findTheme,
- _addCacheItem = DX.viz.core.addCacheItem,
- _removeCacheItem = DX.viz.core.removeCacheItem,
- _extend = $.extend,
- _each = $.each;
- function getThemePart(theme, path) {
- var _theme = theme;
- path && _each(path.split('.'), function(_, pathItem) {
- return _theme = _theme[pathItem]
- });
- return _theme
- }
- DX.viz.core.BaseThemeManager = DX.Class.inherit({
- ctor: function() {
- _addCacheItem(this)
- },
- dispose: function() {
- var that = this;
- _removeCacheItem(that);
- that._callback = that._theme = that._font = null;
- return that
- },
- setCallback: function(callback) {
- this._callback = callback;
- return this
- },
- setTheme: function(theme, rtl) {
- this._current = theme;
- this._rtl = rtl;
- return this.refresh()
- },
- refresh: function() {
- var that = this,
- current = that._current || {},
- theme = _findTheme(current.name || current);
- that._themeName = theme.name;
- that._font = _extend({}, theme.font, current.font);
- that._themeSection && _each(that._themeSection.split('.'), function(_, path) {
- theme = _extend(true, {}, theme[path], that._IE8 ? theme[path + 'IE8'] : {})
- });
- that._theme = _extend(true, {}, theme, _isString(current) ? {} : current);
- that._initializeTheme();
- if (_parseScalar(that._rtl, that._theme.rtlEnabled))
- _extend(true, that._theme, that._theme._rtl);
- that._callback();
- return that
- },
- theme: function(path) {
- return getThemePart(this._theme, path)
- },
- themeName: function() {
- return this._themeName
- },
- _initializeTheme: function() {
- var that = this;
- _each(that._fontFields || [], function(_, path) {
- that._initializeFont(getThemePart(that._theme, path))
- })
- },
- _initializeFont: function(font) {
- _extend(font, this._font, _extend({}, font))
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-core, file parseUtils.js */
- (function($, DX) {
- var viz = DX.viz,
- core = viz.core,
- Class = DX.Class,
- isDefined = DX.utils.isDefined;
- var parseUtils = Class.inherit({
- correctValueType: function(type) {
- return type === 'numeric' || type === 'datetime' || type === 'string' ? type : ''
- },
- _parsers: {
- string: function(val) {
- return isDefined(val) ? '' + val : val
- },
- numeric: function(val) {
- if (!isDefined(val))
- return val;
- var parsedVal = Number(val);
- if (isNaN(parsedVal))
- parsedVal = undefined;
- return parsedVal
- },
- datetime: function(val) {
- if (!isDefined(val))
- return val;
- var parsedVal,
- numVal = Number(val);
- if (!isNaN(numVal))
- parsedVal = new Date(numVal);
- else
- parsedVal = new Date(val);
- if (isNaN(Number(parsedVal)))
- parsedVal = undefined;
- return parsedVal
- }
- },
- getParser: function(valueType) {
- return this._parsers[this.correctValueType(valueType)] || $.noop
- }
- });
- core.ParseUtils = parseUtils
- })(jQuery, DevExpress);
- /*! Module viz-core, file loadIndicator.js */
- (function(DX, $, undefined) {
- var _patchFontOptions = DX.viz.core.utils.patchFontOptions;
- var STATE_HIDE = 0,
- STATE_SHOW = 1,
- STATE_ENDLOADING = 2;
- function LoadIndicator(parameters) {
- var that = this;
- that._$widgetContainer = parameters.container;
- that._$container = $("<div>", {css: {
- position: "relative",
- height: 0,
- padding: 0,
- margin: 0,
- border: 0
- }}).appendTo(that._$widgetContainer).hide();
- that._renderer = new DX.viz.renderers.Renderer({animation: {
- easing: "linear",
- duration: 150
- }});
- that._renderer.draw(that._$container[0]);
- that._rect = that._renderer.rect().attr({opacity: 0}).append(that._renderer.root);
- that._text = that._renderer.text().attr({
- align: "center",
- visibility: "hidden"
- }).append(that._renderer.root);
- that._createStates(parameters.eventTrigger)
- }
- LoadIndicator.prototype = {
- constructor: LoadIndicator,
- _createStates: function(eventTrigger) {
- var that = this;
- that._states = {};
- that._states[STATE_HIDE] = {
- o: 0,
- c: function() {
- that._$container.hide();
- eventTrigger("loadingIndicatorReady")
- }
- };
- that._states[STATE_SHOW] = {
- o: 0.85,
- c: function() {
- eventTrigger("loadingIndicatorReady")
- }
- };
- that._states[STATE_ENDLOADING] = {
- o: 1,
- c: function() {
- var onEndLoading = that._onEndLoading;
- that._onEndLoading = null;
- that._noHiding = true;
- onEndLoading && onEndLoading();
- that._noHiding = false;
- that._onCompleteAction && that[that._onCompleteAction]()
- }
- }
- },
- applyCanvas: function(canvas) {
- var width = canvas.width,
- height = canvas.height;
- this._renderer.resize(width, height);
- this._rect.attr({
- width: width,
- height: height
- });
- this._text.attr({
- x: width / 2,
- y: height / 2
- })
- },
- applyOptions: function(options) {
- this._rect.attr({fill: options.backgroundColor});
- this._text.css(_patchFontOptions(options.font)).attr({text: options.text})
- },
- dispose: function() {
- var that = this;
- that._$container.remove();
- that._renderer.dispose();
- that._$widgetContainer = that._$container = that._renderer = that._rect = that._text = that._states = null
- },
- toForeground: function() {
- this._$container.appendTo(this._$widgetContainer)
- },
- forceShow: function() {
- this._rect.stopAnimation(false).attr({opacity: 1})
- },
- _transit: function(stateId) {
- var state = this._states[stateId];
- this._rect.stopAnimation(true).animate({opacity: state.o}, {complete: state.c})
- },
- show: function() {
- var that = this;
- that._isHiding = false;
- if (that._onEndLoading)
- that._onCompleteAction = "show";
- else {
- that._onCompleteAction = null;
- if (!that._visible) {
- that._visible = true;
- that._$container.show();
- that._renderer.root.css({
- position: "absolute",
- left: 0,
- top: that._$widgetContainer.offset().top - that._$container.offset().top
- });
- that._text.attr({visibility: "visible"})
- }
- that._transit(STATE_SHOW)
- }
- },
- endLoading: function(complete) {
- var that = this;
- if (!that._onEndLoading)
- if (that._visible) {
- that._onEndLoading = complete;
- that._transit(STATE_ENDLOADING)
- }
- else
- complete && complete()
- },
- hide: function() {
- var that = this;
- that._isHiding = false;
- if (that._onEndLoading)
- that._onCompleteAction = "hide";
- else {
- that._onCompleteAction = null;
- if (that._visible) {
- that._visible = false;
- that._text.attr({visibility: "hidden"});
- that._transit(STATE_HIDE)
- }
- }
- },
- scheduleHiding: function() {
- if (!this._noHiding) {
- this._isHiding = true;
- this._onCompleteAction = null
- }
- },
- fulfillHiding: function() {
- var isHiding = this._isHiding;
- isHiding && this.hide();
- return isHiding
- }
- };
- DX.viz.core.LoadIndicator = LoadIndicator
- })(DevExpress, jQuery);
- /*! Module viz-core, file tooltip.js */
- (function(DX, $, doc, undefined) {
- var HALF_ARROW_WIDTH = 10,
- FORMAT_PRECISION = {
- argument: ["argumentFormat", "argumentPrecision"],
- percent: ["percent", "percentPrecision"],
- value: ["format", "precision"]
- },
- formatHelper = DX.formatHelper,
- mathCeil = Math.ceil;
- function hideElement($element) {
- $element.css({left: "-9999px"}).detach()
- }
- function Tooltip(params) {
- var that = this,
- renderer,
- root;
- that._eventTrigger = params.eventTrigger;
- that._wrapper = $("<div></div>").css({
- position: "absolute",
- overflow: "visible",
- width: 0,
- height: 0
- }).addClass(params.cssClass);
- that._renderer = renderer = new DX.viz.renderers.Renderer({});
- root = renderer.root;
- root.attr({"pointer-events": "none"});
- renderer.draw(that._wrapper.get(0));
- that._cloud = renderer.path([], "area").sharp().append(root);
- that._shadow = renderer.shadowFilter();
- that._textGroup = renderer.g().attr({align: "center"}).append(root);
- that._text = renderer.text(undefined, 0, 0).append(that._textGroup);
- that._textGroupHtml = $("<div></div>").css({
- position: "absolute",
- width: 0,
- padding: 0,
- margin: 0,
- border: "0px solid transparent"
- }).appendTo(that._wrapper);
- that._textHtml = $("<div></div>").css({
- position: "relative",
- display: "inline-block",
- padding: 0,
- margin: 0,
- border: "0px solid transparent"
- }).appendTo(that._textGroupHtml)
- }
- Tooltip.prototype = {
- constructor: Tooltip,
- dispose: function() {
- this._wrapper.remove();
- this._renderer.dispose();
- this._options = null
- },
- setOptions: function(options) {
- options = options || {};
- var that = this,
- cloudSettings = that._cloudSettigns = {
- opacity: options.opacity,
- filter: that._shadow.ref,
- "stroke-width": null,
- stroke: null
- },
- borderOptions = options.border || {};
- that._shadowSettigns = $.extend({
- x: "-50%",
- y: "-50%",
- width: "200%",
- height: "200%"
- }, options.shadow);
- that._options = options;
- if (borderOptions.visible)
- $.extend(cloudSettings, {
- "stroke-width": borderOptions.width,
- stroke: borderOptions.color,
- "stroke-opacity": borderOptions.opacity,
- dashStyle: borderOptions.dashStyle
- });
- that._textFontStyles = DX.viz.core.utils.patchFontOptions(options.font);
- that._textFontStyles.color = options.font.color;
- that._wrapper.css({"z-index": options.zIndex});
- that._customizeTooltip = $.isFunction(options.customizeTooltip) ? options.customizeTooltip : null;
- return that
- },
- setRendererOptions: function(options) {
- this._renderer.setOptions(options);
- this._textGroupHtml.css({direction: options.rtl ? "rtl" : "ltr"});
- return this
- },
- render: function() {
- var that = this;
- hideElement(that._wrapper);
- that._cloud.attr(that._cloudSettigns);
- that._shadow.attr(that._shadowSettigns);
- that._textGroupHtml.css(that._textFontStyles);
- that._textGroup.css(that._textFontStyles);
- that._text.css(that._textFontStyles);
- that._eventData = null;
- return that
- },
- update: function(options) {
- return this.setOptions(options).render()
- },
- _prepare: function(formatObject, state) {
- var options = this._options,
- customize = {};
- if (this._customizeTooltip) {
- customize = this._customizeTooltip.call(formatObject, formatObject);
- customize = $.isPlainObject(customize) ? customize : {};
- if ("text" in customize)
- state.text = DX.utils.isDefined(customize.text) ? String(customize.text) : "";
- if ("html" in customize)
- state.html = DX.utils.isDefined(customize.html) ? String(customize.html) : ""
- }
- if (!("text" in state) && !("html" in state))
- state.text = formatObject.valueText || "";
- state.color = customize.color || options.color;
- state.borderColor = customize.borderColor || (options.border || {}).color;
- state.textColor = customize.fontColor || (options.font || {}).color;
- return !!state.text || !!state.html
- },
- show: function(formatObject, params, eventData) {
- var that = this,
- state = {},
- options = that._options,
- plr = options.paddingLeftRight,
- ptb = options.paddingTopBottom,
- textGroupHtml = that._textGroupHtml,
- textHtml = that._textHtml,
- bBox,
- contentSize,
- ss = that._shadowSettigns,
- xOff = ss.offsetX,
- yOff = ss.offsetY,
- blur = ss.blur * 2 + 1;
- if (!that._prepare(formatObject, state))
- return false;
- that._state = state;
- state.tc = {};
- that._wrapper.appendTo($("body"));
- that._cloud.attr({
- fill: state.color,
- stroke: state.borderColor
- });
- if (state.html) {
- that._text.attr({text: ""});
- textGroupHtml.css({
- color: state.textColor,
- width: that._getCanvas().width
- });
- textHtml.html(state.html);
- bBox = textHtml.get(0).getBoundingClientRect();
- bBox = {
- x: 0,
- y: 0,
- width: mathCeil(bBox.right - bBox.left),
- height: mathCeil(bBox.bottom - bBox.top)
- };
- textGroupHtml.width(bBox.width);
- textGroupHtml.height(bBox.height)
- }
- else {
- textHtml.html("");
- that._text.css({fill: state.textColor}).attr({text: state.text});
- bBox = that._textGroup.css({fill: state.textColor}).getBBox()
- }
- contentSize = state.contentSize = {
- x: bBox.x - plr,
- y: bBox.y - ptb,
- width: bBox.width + 2 * plr,
- height: bBox.height + 2 * ptb,
- lm: blur - xOff > 0 ? blur - xOff : 0,
- rm: blur + xOff > 0 ? blur + xOff : 0,
- tm: blur - yOff > 0 ? blur - yOff : 0,
- bm: blur + yOff > 0 ? blur + yOff : 0
- };
- contentSize.fullWidth = contentSize.width + contentSize.lm + contentSize.rm;
- contentSize.fullHeight = contentSize.height + contentSize.tm + contentSize.bm + options.arrowLength;
- that.move(params.x, params.y, params.offset);
- that._eventData && that._eventTrigger("tooltipHidden", that._eventData);
- that._eventData = eventData;
- that._eventTrigger("tooltipShown", that._eventData);
- return true
- },
- hide: function() {
- var that = this;
- hideElement(that._wrapper);
- that._eventData && that._eventTrigger("tooltipHidden", that._eventData);
- that._eventData = null
- },
- move: function(x, y, offset) {
- offset = offset || 0;
- var that = this,
- canvas = that._getCanvas(),
- state = that._state,
- coords = state.tc,
- contentSize = state.contentSize;
- if (that._calculatePosition(x, y, offset)) {
- that._cloud.attr({points: coords.cloudPoints}).move(contentSize.lm, contentSize.tm);
- if (state.html)
- that._textGroupHtml.css({
- left: -contentSize.x + contentSize.lm,
- top: -contentSize.y + contentSize.tm + coords.correction
- });
- else
- that._textGroup.move(-contentSize.x + contentSize.lm, -contentSize.y + contentSize.tm + coords.correction);
- that._renderer.resize(coords.hp === "out" ? canvas.fullWidth - canvas.left : contentSize.fullWidth, coords.vp === "out" ? canvas.fullHeight - canvas.top : contentSize.fullHeight)
- }
- that._wrapper.css({
- left: coords.x,
- top: coords.y
- })
- },
- formatValue: function(value, specialFormat) {
- var formatObj = FORMAT_PRECISION[specialFormat || "value"],
- format = formatObj[0] in this._options ? this._options[formatObj[0]] : specialFormat;
- return formatHelper.format(value, format, this._options[formatObj[1]] || 0)
- },
- getLocation: function() {
- return (this._options.location + "").toLowerCase()
- },
- isEnabled: function() {
- return !!this._options.enabled
- },
- isShared: function() {
- return !!this._options.shared
- },
- _calculatePosition: function(x, y, offset) {
- var that = this,
- canvas = that._getCanvas(),
- options = that._options,
- arrowLength = options.arrowLength,
- state = that._state,
- coords = state.tc,
- contentSize = state.contentSize,
- contentWidth = contentSize.width,
- halfContentWidth = contentWidth / 2,
- contentHeight = contentSize.height,
- cTop = y - canvas.top,
- cBottom = canvas.top + canvas.height - y,
- cLeft = x - canvas.left,
- cRight = canvas.width + canvas.left - x,
- tTop = contentHeight + arrowLength + offset + contentSize.tm,
- tBottom = contentHeight + arrowLength + offset + contentSize.bm,
- tLeft = contentWidth + contentSize.lm,
- tRight = contentWidth + contentSize.rm,
- tHalfLeft = halfContentWidth + contentSize.lm,
- tHalfRight = halfContentWidth + contentSize.rm,
- correction = 0,
- cloudPoints,
- arrowPoints = [6, 0],
- x1 = halfContentWidth + HALF_ARROW_WIDTH,
- x2 = halfContentWidth,
- x3 = halfContentWidth - HALF_ARROW_WIDTH,
- y1,
- y3,
- y2 = contentHeight + arrowLength,
- hp = "center",
- vp = "bottom",
- hasDeprecatedPosition;
- y1 = y3 = contentHeight;
- switch (options.verticalAlignment) {
- case"top":
- vp = "bottom";
- hasDeprecatedPosition = true;
- break;
- case"bottom":
- vp = "top";
- hasDeprecatedPosition = true;
- break
- }
- if (!hasDeprecatedPosition)
- if (tTop > cTop && tBottom > cBottom)
- vp = "out";
- else if (tTop > cTop)
- vp = "top";
- hasDeprecatedPosition = false;
- switch (options.horizontalAlignment) {
- case"left":
- hp = "right";
- hasDeprecatedPosition = true;
- break;
- case"center":
- hp = "center";
- hasDeprecatedPosition = true;
- break;
- case"right":
- hp = "left";
- hasDeprecatedPosition = true;
- break
- }
- if (!hasDeprecatedPosition)
- if (tLeft > cLeft && tRight > cRight)
- hp = "out";
- else if (tHalfLeft > cLeft && tRight < cRight)
- hp = "left";
- else if (tHalfRight > cRight && tLeft < cLeft)
- hp = "right";
- if (hp === "out")
- x = canvas.left;
- else if (hp === "left") {
- x1 = HALF_ARROW_WIDTH;
- x2 = x3 = 0
- }
- else if (hp === "right") {
- x1 = x2 = contentWidth;
- x3 = contentWidth - HALF_ARROW_WIDTH;
- x = x - contentWidth
- }
- else if (hp === "center")
- x = x - halfContentWidth;
- if (vp === "out")
- y = canvas.top;
- else if (vp === "top") {
- hp !== "out" && (correction = arrowLength);
- arrowPoints[0] = 2;
- y1 = y3 = arrowLength;
- y2 = x1;
- x1 = x3;
- x3 = y2;
- y2 = 0;
- y = y + offset
- }
- else
- y = y - (contentHeight + arrowLength + offset);
- coords.x = x - contentSize.lm;
- coords.y = y - contentSize.tm;
- coords.correction = correction;
- if (hp === coords.hp && vp === coords.vp)
- return false;
- coords.hp = hp;
- coords.vp = vp;
- cloudPoints = [0, 0 + correction, contentWidth, 0 + correction, contentWidth, contentHeight + correction, 0, contentHeight + correction];
- if (hp !== "out" && vp !== "out") {
- arrowPoints.splice(2, 0, x1, y1, x2, y2, x3, y3);
- cloudPoints.splice.apply(cloudPoints, arrowPoints)
- }
- coords.cloudPoints = cloudPoints;
- return true
- },
- _getCanvas: function() {
- var html = doc.documentElement,
- body = doc.body,
- win = window;
- return {
- left: win.pageXOffset || html.scrollLeft || 0,
- top: win.pageYOffset || html.scrollTop || 0,
- width: html.clientWidth || 0,
- height: html.clientHeight || 0,
- fullWidth: Math.max(body.scrollWidth, html.scrollWidth, body.offsetWidth, html.offsetWidth, body.clientWidth, html.clientWidth),
- fullHeight: Math.max(body.scrollHeight, html.scrollHeight, body.offsetHeight, html.offsetHeight, body.clientHeight, html.clientHeight)
- }
- }
- };
- DX.viz.core.Tooltip = Tooltip
- })(DevExpress, jQuery, document);
- /*! Module viz-core, file legend.js */
- (function(DX, $, undefined) {
- var core = DX.viz.core,
- coreUtils = core.utils,
- WrapperLayoutElement = core.WrapperLayoutElement,
- _Number = Number,
- _String = String,
- _math = Math,
- _round = _math.round,
- _max = _math.max,
- _min = _math.min,
- _ceil = _math.ceil,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _isFunction = utils.isFunction,
- _enumParser = coreUtils.enumParser,
- _extend = $.extend,
- _each = $.each,
- _map = $.map,
- DEFAULT_MARGIN = 10,
- DEFAULT_MARKER_HATCHING_WIDTH = 2,
- DEFAULT_MARKER_HATCHING_STEP = 5,
- CENTER = "center",
- RIGHT = "right",
- LEFT = "left",
- TOP = "top",
- BOTTOM = "bottom",
- HORIZONTAL = "horizontal",
- VERTICAL = "vertical",
- INSIDE = "inside",
- OUTSIDE = "outside",
- NONE = "none",
- HEIGHT = "height",
- WIDTH = "width",
- parseHorizontalAlignment = _enumParser([LEFT, CENTER, RIGHT]),
- parseVerticalAlignment = _enumParser([TOP, BOTTOM]),
- parseOrientation = _enumParser([VERTICAL, HORIZONTAL]),
- parseItemTextPosition = _enumParser([LEFT, RIGHT, TOP, BOTTOM]),
- parsePosition = _enumParser([OUTSIDE, INSIDE]),
- parseItemsAlignment = _enumParser([LEFT, CENTER, RIGHT]);
- function getPattern(renderer, states, action, color) {
- if (!states || !states[action])
- return;
- var direction = states[action].hatching.direction,
- hatching,
- colorFromAction = states[action].fill;
- color = colorFromAction === NONE ? color : colorFromAction;
- direction = !direction || direction === NONE ? RIGHT : direction;
- hatching = _extend({}, states[action].hatching, {
- direction: direction,
- step: DEFAULT_MARKER_HATCHING_STEP,
- width: DEFAULT_MARKER_HATCHING_WIDTH
- });
- return renderer.pattern(color, hatching)
- }
- function parseMargins(options) {
- var margin = options.margin;
- if (margin >= 0) {
- margin = _Number(options.margin);
- margin = {
- top: margin,
- bottom: margin,
- left: margin,
- right: margin
- }
- }
- else
- margin = {
- top: margin.top >= 0 ? _Number(margin.top) : DEFAULT_MARGIN,
- bottom: margin.bottom >= 0 ? _Number(margin.bottom) : DEFAULT_MARGIN,
- left: margin.left >= 0 ? _Number(margin.left) : DEFAULT_MARGIN,
- right: margin.right >= 0 ? _Number(margin.right) : DEFAULT_MARGIN
- };
- options.margin = margin
- }
- function getSizeItem(options, markerSize, labelBBox) {
- var defaultXMargin = 7,
- defaultTopMargin = 4,
- width,
- height;
- switch (options.itemTextPosition) {
- case LEFT:
- case RIGHT:
- width = markerSize + defaultXMargin + labelBBox.width;
- height = _max(markerSize, labelBBox.height);
- break;
- case TOP:
- case BOTTOM:
- width = _max(markerSize, labelBBox.width);
- height = markerSize + defaultTopMargin + labelBBox.height;
- break
- }
- return {
- width: width,
- height: height
- }
- }
- function calculateBboxLabelAndMarker(markerBBox, labelBBox) {
- var bbox = {};
- bbox.left = _min(markerBBox.x, labelBBox.x);
- bbox.top = _min(markerBBox.y, labelBBox.y);
- bbox.right = _max(markerBBox.x + markerBBox.width, labelBBox.x + labelBBox.width);
- bbox.bottom = _max(markerBBox.y + markerBBox.height, labelBBox.y + labelBBox.height);
- return bbox
- }
- function applyMarkerState(id, idToIndexMap, items, stateName) {
- var item = idToIndexMap && items[idToIndexMap[id]];
- if (item)
- item.marker.attr(item.states[stateName])
- }
- function parseOptions(options, textField) {
- if (!options)
- return null;
- DX.utils.debug.assertParam(options.visible, "Visibility was not passed");
- DX.utils.debug.assertParam(options.markerSize, "markerSize was not passed");
- DX.utils.debug.assertParam(options.font.color, "fontColor was not passed");
- DX.utils.debug.assertParam(options.font.family, "fontFamily was not passed");
- DX.utils.debug.assertParam(options.font.size, "fontSize was not passed");
- DX.utils.debug.assertParam(options.paddingLeftRight, "paddingLeftRight was not passed");
- DX.utils.debug.assertParam(options.paddingTopBottom, "paddingTopBottom was not passed");
- DX.utils.debug.assertParam(options.columnItemSpacing, "columnItemSpacing was not passed");
- DX.utils.debug.assertParam(options.rowItemSpacing, "rowItemSpacing was not passed");
- parseMargins(options);
- options.horizontalAlignment = parseHorizontalAlignment(options.horizontalAlignment, RIGHT);
- options.verticalAlignment = parseVerticalAlignment(options.verticalAlignment, options.horizontalAlignment === CENTER ? BOTTOM : TOP);
- options.orientation = parseOrientation(options.orientation, options.horizontalAlignment === CENTER ? HORIZONTAL : VERTICAL);
- options.itemTextPosition = parseItemTextPosition(options.itemTextPosition, options.orientation === HORIZONTAL ? BOTTOM : RIGHT);
- options.position = parsePosition(options.position, OUTSIDE);
- options.itemsAlignment = parseItemsAlignment(options.itemsAlignment, null);
- options.hoverMode = _String(options.hoverMode || "").toLowerCase();
- options.customizeText = _isFunction(options.customizeText) ? options.customizeText : function() {
- return this[textField]
- };
- options.customizeHint = _isFunction(options.customizeHint) ? options.customizeHint : $.noop;
- return options
- }
- function createSquareMarker(renderer, size) {
- return renderer.rect(0, 0, size, size)
- }
- function createCircleMarker(renderer, size) {
- return renderer.circle(size / 2, size / 2, size / 2)
- }
- function isCircle(type) {
- return _String(type).toLowerCase() === "circle"
- }
- function getMarkerCreator(type) {
- return isCircle(type) ? createCircleMarker : createSquareMarker
- }
- function inRect(rect, x, y) {
- return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
- }
- function checkLinesSize(lines, layoutOptions, countItems) {
- var position = {
- x: 0,
- y: 0
- },
- maxMeasureLength = 0,
- maxOrtMeasureLength = 0;
- $.each(lines, function(i, line) {
- var firstItem = line[0];
- $.each(line, function(_, item) {
- var offset = item.offset || layoutOptions.spacing;
- position[layoutOptions.direction] += item[layoutOptions.measure] + offset;
- maxMeasureLength = _max(maxMeasureLength, position[layoutOptions.direction])
- });
- position[layoutOptions.direction] = 0;
- position[layoutOptions.ortDirection] += firstItem[layoutOptions.ortMeasure] + firstItem.ortOffset || layoutOptions.ortSpacing;
- maxOrtMeasureLength = _max(maxOrtMeasureLength, position[layoutOptions.ortDirection])
- });
- if (maxMeasureLength > layoutOptions.length) {
- layoutOptions.countItem = decreaseItemCount(layoutOptions, countItems);
- return true
- }
- }
- function decreaseItemCount(layoutOptions, countItems) {
- layoutOptions.ortCountItem++;
- return _ceil(countItems / layoutOptions.ortCountItem)
- }
- function getLineLength(line, layoutOptions) {
- var lineLength = 0;
- $.each(line, function(_, item) {
- var offset = item.offset || layoutOptions.spacing;
- lineLength += item[layoutOptions.measure] + offset
- });
- return lineLength
- }
- function getMaxLineLength(lines, layoutOptions) {
- var maxLineLength = 0;
- $.each(lines, function(_, line) {
- maxLineLength = _max(maxLineLength, getLineLength(line, layoutOptions))
- });
- return maxLineLength
- }
- function getInitPositionForDirection(line, layoutOptions, maxLineLength) {
- var lineLength = getLineLength(line, layoutOptions),
- initPosition;
- switch (layoutOptions.itemsAlignment) {
- case RIGHT:
- initPosition = maxLineLength - lineLength;
- break;
- case CENTER:
- initPosition = (maxLineLength - lineLength) / 2;
- break;
- default:
- initPosition = 0
- }
- return initPosition
- }
- function getPos(layoutOptions) {
- switch (layoutOptions.itemTextPosition) {
- case BOTTOM:
- return CENTER + " " + TOP;
- case TOP:
- return CENTER + " " + BOTTOM;
- case LEFT:
- return RIGHT + " " + CENTER;
- case RIGHT:
- return LEFT + " " + CENTER
- }
- }
- function getLines(lines, layoutOptions, itemIndex) {
- var tableLine = {};
- if (itemIndex % layoutOptions.countItem === 0)
- if (layoutOptions.markerOffset)
- lines.push([], []);
- else
- lines.push([]);
- if (layoutOptions.markerOffset) {
- tableLine.firstLine = lines[lines.length - 1];
- tableLine.secondLine = lines[lines.length - 2]
- }
- else
- tableLine.firstLine = tableLine.secondLine = lines[lines.length - 1];
- return tableLine
- }
- function setMaxInLine(line, mesuare) {
- var maxLineSize = 0;
- $.each(line, function(_, item) {
- if (!item)
- return;
- maxLineSize = _max(maxLineSize, item[mesuare])
- });
- $.each(line, function(_, item) {
- if (!item)
- return;
- item[mesuare] = maxLineSize
- })
- }
- function transpose(array) {
- var width = array.length,
- height = array[0].length,
- i,
- j,
- transposeArray = [];
- for (i = 0; i < height; i++) {
- transposeArray[i] = [];
- for (j = 0; j < width; j++)
- transposeArray[i][j] = array[j][i]
- }
- return transposeArray
- }
- function getAlign(position) {
- switch (position) {
- case TOP:
- case BOTTOM:
- return CENTER;
- case LEFT:
- return RIGHT;
- case RIGHT:
- return LEFT
- }
- }
- var _Legend = DX.viz.core.Legend = function(settings) {
- var that = this;
- that._renderer = settings.renderer;
- that._legendGroup = settings.group;
- that._backgroundClass = settings.backgroundClass;
- that._itemGroupClass = settings.itemGroupClass;
- that._textField = settings.textField;
- that._getCustomizeObject = settings.getFormatObject;
- that._patterns = []
- };
- _Legend.prototype = {
- constructor: _Legend,
- update: function(data, options) {
- var that = this;
- that._data = data;
- that._boundingRect = {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- that._options = parseOptions(options, that._textField);
- return that
- },
- setSize: function(size) {
- this._size = {
- width: size.width,
- height: size.height
- };
- return this
- },
- draw: function(size) {
- var that = this,
- options = that._options,
- renderer = that._renderer,
- items = that._data;
- size && that.setSize(size);
- that.erase();
- if (!(options && options.visible && items && items.length))
- return that;
- that._insideLegendGroup = renderer.g().append(that._legendGroup);
- that._createBackground();
- that._createItems(that._getItemData());
- that._locateElements(options);
- that._finalUpdate(options);
- return that
- },
- _createItems: function(items) {
- var that = this,
- options = that._options,
- initMarkerSize = options.markerSize,
- renderer = that._renderer,
- markersOptions = [],
- maxMarkerSize = 0,
- i = 0,
- bbox,
- maxBboxWidth = 0,
- maxBboxHeight = 0,
- createMarker = getMarkerCreator(options.markerType);
- _each(items, function(_i, item) {
- maxMarkerSize = _max(maxMarkerSize, _Number(item.size > 0 ? item.size : initMarkerSize))
- });
- that._markersId = {};
- for (; i < that._patterns.length; i++)
- that._patterns[i].dispose();
- that._patterns = [];
- that._items = _map(items, function(dataItem, i) {
- var group = that._insideLegendGroup,
- markerSize = _Number(dataItem.size > 0 ? dataItem.size : initMarkerSize),
- stateOfDataItem = dataItem.states,
- normalState = stateOfDataItem.normal,
- normalStateFill = normalState.fill,
- marker = createMarker(renderer, markerSize).attr({
- fill: normalStateFill || options.markerColor,
- opacity: normalState.opacity
- }).append(group),
- label = that._createLabel(dataItem, group),
- hoverPattern = getPattern(renderer, stateOfDataItem, "hover", normalStateFill),
- selectionPattern = getPattern(renderer, stateOfDataItem, "selection", normalStateFill),
- states = {normal: {fill: normalStateFill}},
- labelBBox = label.getBBox();
- if (hoverPattern) {
- states.hovered = {fill: hoverPattern.id};
- that._patterns.push(hoverPattern)
- }
- if (selectionPattern) {
- states.selected = {fill: selectionPattern.id};
- that._patterns.push(selectionPattern)
- }
- if (dataItem.id !== undefined)
- that._markersId[dataItem.id] = i;
- bbox = getSizeItem(options, markerSize, labelBBox);
- maxBboxWidth = _max(maxBboxWidth, bbox.width);
- maxBboxHeight = _max(maxBboxHeight, bbox.height);
- markersOptions.push({
- size: markerSize,
- marker: marker
- });
- that._createHint(dataItem, label);
- return {
- label: label,
- labelBBox: labelBBox,
- group: group,
- bbox: bbox,
- marker: marker,
- markerSize: markerSize,
- tracker: {id: dataItem.id},
- states: states,
- itemTextPosition: options.itemTextPosition,
- markerOffset: 0,
- bboxs: []
- }
- });
- if (options.equalRowHeight)
- $.each(that._items, function(_, item) {
- item.bbox.height = maxBboxHeight
- })
- },
- _getItemData: function() {
- var items = this._data;
- if (this._options.inverted)
- items = items.slice().reverse();
- return items
- },
- _finalUpdate: function(options) {
- this._adjustBackgroundSettings(options);
- this._setBoundingRect(options.margin)
- },
- erase: function() {
- var that = this,
- insideLegendGroup = that._insideLegendGroup;
- insideLegendGroup && insideLegendGroup.dispose();
- that._insideLegendGroup = that._x1 = that._x2 = that._y2 = that._y2 = null;
- return that
- },
- _locateElements: function(locationOptions) {
- this._moveInInitialValues();
- this._locateRowsColumns(locationOptions)
- },
- _moveInInitialValues: function() {
- var that = this;
- that._legendGroup && that._legendGroup.move(0, 0);
- that._background && that._background.attr({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- })
- },
- applySelected: function(id) {
- applyMarkerState(id, this._markersId, this._items, "selected");
- return this
- },
- applyHover: function(id) {
- applyMarkerState(id, this._markersId, this._items, "hovered");
- return this
- },
- resetItem: function(id) {
- applyMarkerState(id, this._markersId, this._items, "normal");
- return this
- },
- _createLabel: function(data, group) {
- var labelFormatObject = this._getCustomizeObject(data),
- align = getAlign(this._options.itemTextPosition),
- text = this._options.customizeText.call(labelFormatObject, labelFormatObject),
- fontStyle = _isDefined(data.textOpacity) ? _extend({}, this._options.font, {opacity: data.textOpacity}) : this._options.font;
- return this._renderer.text(text, 0, 0).css(coreUtils.patchFontOptions(fontStyle)).attr({align: align}).append(group)
- },
- _createHint: function(data, label) {
- var labelFormatObject = this._getCustomizeObject(data),
- text = this._options.customizeHint.call(labelFormatObject, labelFormatObject);
- if (_isDefined(text) && text !== "")
- label.setTitle(text)
- },
- _createBackground: function() {
- var that = this,
- isInside = that._options.position === INSIDE,
- color = that._options.backgroundColor,
- fill = color || (isInside ? that._options.containerBackgroundColor : NONE);
- if (that._options.border.visible || (isInside || color) && color !== NONE)
- that._background = that._renderer.rect(0, 0, 0, 0).attr({
- fill: fill,
- 'class': that._backgroundClass
- }).append(that._insideLegendGroup)
- },
- _locateRowsColumns: function() {
- var that = this,
- iteration = 0,
- layoutOptions = that._getItemsLayoutOptions(),
- countItems = that._items.length,
- lines;
- do {
- lines = [];
- that._createLines(lines, layoutOptions);
- that._alignLines(lines, layoutOptions);
- iteration++
- } while (checkLinesSize(lines, layoutOptions, countItems) && iteration < countItems);
- that._applyItemPosition(lines, layoutOptions)
- },
- _createLines: function(lines, layoutOptions) {
- $.each(this._items, function(i, item) {
- var tableLine = getLines(lines, layoutOptions, i),
- labelBox = {
- width: item.labelBBox.width,
- height: item.labelBBox.height,
- element: item.label,
- bbox: item.labelBBox,
- pos: getPos(layoutOptions),
- itemIndex: i
- },
- markerBox = {
- width: item.markerSize,
- height: item.markerSize,
- element: item.marker,
- bbox: {
- width: item.markerSize,
- height: item.markerSize,
- x: 0,
- y: 0
- },
- itemIndex: i
- },
- firstItem,
- secondItem,
- offsetDirection = layoutOptions.markerOffset ? "ortOffset" : "offset";
- if (layoutOptions.inverseLabelPosition) {
- firstItem = labelBox;
- secondItem = markerBox
- }
- else {
- firstItem = markerBox;
- secondItem = labelBox
- }
- firstItem[offsetDirection] = layoutOptions.labelOffset;
- tableLine.secondLine.push(firstItem);
- tableLine.firstLine.push(secondItem)
- })
- },
- _alignLines: function(lines, layoutOptions) {
- var i,
- measure = layoutOptions.ortMeasure;
- _each(lines, processLine);
- measure = layoutOptions.measure;
- if (layoutOptions.itemsAlignment) {
- if (layoutOptions.markerOffset)
- for (i = 0; i < lines.length; )
- _each(transpose([lines[i++], lines[i++]]), processLine)
- }
- else
- _each(transpose(lines), processLine);
- function processLine(_, line) {
- setMaxInLine(line, measure)
- }
- },
- _applyItemPosition: function(lines, layoutOptions) {
- var that = this,
- position = {
- x: 0,
- y: 0
- },
- maxLineLength = getMaxLineLength(lines, layoutOptions),
- itemIndex = 0;
- $.each(lines, function(i, line) {
- var firstItem = line[0],
- ortOffset = firstItem.ortOffset || layoutOptions.ortSpacing;
- position[layoutOptions.direction] = getInitPositionForDirection(line, layoutOptions, maxLineLength);
- $.each(line, function(_, item) {
- var offset = item.offset || layoutOptions.spacing,
- wrap = new WrapperLayoutElement(item.element, item.bbox),
- itemBBox = {
- x: position.x,
- y: position.y,
- width: item.width,
- height: item.height
- },
- itemLegend = that._items[item.itemIndex];
- wrap.position({
- of: itemBBox,
- my: item.pos,
- at: item.pos
- });
- itemLegend.bboxs.push(itemBBox);
- position[layoutOptions.direction] += item[layoutOptions.measure] + offset;
- itemIndex++
- });
- position[layoutOptions.ortDirection] += firstItem[layoutOptions.ortMeasure] + ortOffset
- });
- $.each(this._items, function(_, item) {
- var itemBBox = calculateBboxLabelAndMarker(item.bboxs[0], item.bboxs[1]),
- horizontal = that._options.columnItemSpacing / 2,
- vertical = that._options.rowItemSpacing / 2;
- item.tracker.left = itemBBox.left - horizontal;
- item.tracker.right = itemBBox.right + horizontal;
- item.tracker.top = itemBBox.top - vertical;
- item.tracker.bottom = itemBBox.bottom + vertical
- })
- },
- _getItemsLayoutOptions: function() {
- var that = this,
- options = that._options,
- border = options.border.visible,
- orientation = options.orientation,
- layoutOptions = {
- itemsAlignment: options.itemsAlignment,
- orientation: options.orientation
- },
- width = that._size.width - (border ? 2 * options.paddingLeftRight : 0),
- height = that._size.height - (border ? 2 * options.paddingTopBottom : 0);
- if (orientation === HORIZONTAL) {
- layoutOptions.length = width;
- layoutOptions.ortLength = height;
- layoutOptions.spacing = options.columnItemSpacing;
- layoutOptions.direction = "x";
- layoutOptions.measure = WIDTH;
- layoutOptions.ortMeasure = HEIGHT;
- layoutOptions.ortDirection = "y";
- layoutOptions.ortSpacing = options.rowItemSpacing;
- layoutOptions.countItem = options.columnCount;
- layoutOptions.ortCountItem = options.rowCount;
- layoutOptions.marginTextLabel = 4;
- layoutOptions.labelOffset = 7;
- if (options.itemTextPosition === BOTTOM || options.itemTextPosition === TOP) {
- layoutOptions.labelOffset = 4;
- layoutOptions.markerOffset = true
- }
- }
- else {
- layoutOptions.length = height;
- layoutOptions.ortLength = width;
- layoutOptions.spacing = options.rowItemSpacing;
- layoutOptions.direction = "y";
- layoutOptions.measure = HEIGHT;
- layoutOptions.ortMeasure = WIDTH;
- layoutOptions.ortDirection = "x";
- layoutOptions.ortSpacing = options.columnItemSpacing;
- layoutOptions.countItem = options.rowCount;
- layoutOptions.ortCountItem = options.columnCount;
- layoutOptions.marginTextLabel = 7;
- layoutOptions.labelOffset = 4;
- if (options.itemTextPosition === RIGHT || options.itemTextPosition === LEFT) {
- layoutOptions.labelOffset = 7;
- layoutOptions.markerOffset = true
- }
- }
- if (!layoutOptions.countItem)
- if (layoutOptions.ortCountItem)
- layoutOptions.countItem = _ceil(that._items.length / layoutOptions.ortCountItem);
- else
- layoutOptions.countItem = that._items.length;
- if (options.itemTextPosition === TOP || options.itemTextPosition === LEFT)
- layoutOptions.inverseLabelPosition = true;
- layoutOptions.itemTextPosition = options.itemTextPosition;
- layoutOptions.ortCountItem = layoutOptions.ortCountItem || _ceil(that._items.length / layoutOptions.countItem);
- return layoutOptions
- },
- _adjustBackgroundSettings: function(locationOptions) {
- if (!this._background)
- return;
- var border = locationOptions.border,
- legendBox = this._insideLegendGroup.getBBox(),
- backgroundSettings = {
- x: _round(legendBox.x - locationOptions.paddingLeftRight),
- y: _round(legendBox.y - locationOptions.paddingTopBottom),
- width: _round(legendBox.width) + 2 * locationOptions.paddingLeftRight,
- height: _round(legendBox.height) + 2 * locationOptions.paddingTopBottom,
- opacity: locationOptions.backgroundOpacity
- };
- if (border.visible && border.width && border.color && border.color !== NONE) {
- backgroundSettings["stroke-width"] = border.width;
- backgroundSettings.stroke = border.color;
- backgroundSettings["stroke-opacity"] = border.opacity;
- backgroundSettings.dashStyle = border.dashStyle;
- backgroundSettings.rx = border.cornerRadius || 0;
- backgroundSettings.ry = border.cornerRadius || 0
- }
- this._background.attr(backgroundSettings)
- },
- _setBoundingRect: function(margin) {
- if (!this._insideLegendGroup)
- return;
- var box = this._insideLegendGroup.getBBox();
- box.height += margin.top + margin.bottom;
- box.width += margin.left + margin.right;
- box.x -= margin.left;
- box.y -= margin.top;
- this._boundingRect = box
- },
- changeSize: function() {
- this.fit.apply(this, arguments)
- },
- fit: function(sizeForDecrease) {
- var that = this,
- beforeFit = that.getLayoutOptions(),
- afterFit;
- function fitLegendToDirection(direction) {
- var size = $.extend({}, that._size);
- size[direction] = beforeFit[direction] - sizeForDecrease[direction];
- that.draw(size);
- afterFit = that.getLayoutOptions();
- if (that._insideLegendGroup)
- if (beforeFit[direction] - sizeForDecrease[direction] < afterFit[direction]) {
- that._options._incidentOccured("W2104");
- that.erase()
- }
- }
- if (sizeForDecrease.width > 0)
- fitLegendToDirection(WIDTH);
- if (sizeForDecrease.height > 0)
- fitLegendToDirection(HEIGHT);
- return this
- },
- getActionCallback: function(point) {
- var that = this;
- if (that._options.visible)
- return function(act) {
- var pointType = point.type,
- seriesType = pointType || point.series.type;
- if (pointType || seriesType === "pie" || seriesType === "doughnut" || seriesType === "donut")
- that[act] && that[act](point.index)
- };
- else
- return $.noop
- },
- getLayoutOptions: function() {
- var options = this._options,
- boundingRect = this._insideLegendGroup ? this._boundingRect : {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- if (options) {
- boundingRect.verticalAlignment = options.verticalAlignment;
- boundingRect.horizontalAlignment = options.horizontalAlignment;
- if (options.orientation === HORIZONTAL)
- boundingRect.cutLayoutSide = options.verticalAlignment;
- else
- boundingRect.cutLayoutSide = options.horizontalAlignment === CENTER ? options.verticalAlignment : options.horizontalAlignment;
- return boundingRect
- }
- return null
- },
- shift: function(x, y) {
- var that = this,
- box = {};
- if (that._insideLegendGroup) {
- that._insideLegendGroup.attr({
- translateX: x - that._boundingRect.x,
- translateY: y - that._boundingRect.y
- });
- box = that._legendGroup.getBBox()
- }
- that._x1 = box.x;
- that._y1 = box.y;
- that._x2 = box.x + box.width;
- that._y2 = box.y + box.height;
- return that
- },
- getPosition: function() {
- return this._options.position
- },
- coordsIn: function(x, y) {
- return x >= this._x1 && x <= this._x2 && y >= this._y1 && y <= this._y2
- },
- getItemByCoord: function(x, y) {
- var items = this._items,
- legendGroup = this._insideLegendGroup;
- x = x - legendGroup.attr("translateX");
- y = y - legendGroup.attr("translateY");
- for (var i = 0; i < items.length; i++)
- if (inRect(items[i].tracker, x, y))
- return items[i].tracker;
- return null
- },
- dispose: function() {
- var that = this;
- that._legendGroup = that._insideLegendGroup = that._renderer = that._options = that._data = that._items = null;
- return that
- }
- };
- var __getMarkerCreator = getMarkerCreator;
- DX.viz.core._DEBUG_stubMarkerCreator = function(callback) {
- getMarkerCreator = function() {
- return callback
- }
- };
- DX.viz.core._DEBUG_restoreMarkerCreator = function() {
- getMarkerCreator = __getMarkerCreator
- }
- })(DevExpress, jQuery);
- /*! Module viz-core, file range.js */
- (function($, DX, undefined) {
- var core = DX.viz.core,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _isDate = utils.isDate,
- NUMBER_EQUALITY_CORRECTION = 1,
- DATETIME_EQUALITY_CORRECTION = 60000,
- minSelector = "min",
- maxSelector = "max",
- minVisibleSelector = "minVisible",
- maxVisibleSelector = "maxVisible",
- categoriesSelector = "categories",
- baseSelector = "base",
- axisTypeSelector = "axisType",
- _Range;
- function otherLessThan(thisValue, otherValue) {
- return otherValue < thisValue
- }
- function otherGreaterThan(thisValue, otherValue) {
- return otherValue > thisValue
- }
- function compareAndReplace(thisValue, otherValue, setValue, compare) {
- var otherValueDefined = _isDefined(otherValue);
- if (_isDefined(thisValue)) {
- if (otherValueDefined && compare(thisValue, otherValue))
- setValue(otherValue)
- }
- else if (otherValueDefined)
- setValue(otherValue)
- }
- function returnValue(value) {
- return value
- }
- function returnValueOf(value) {
- return value.valueOf()
- }
- function getUniqueCategories(categories, otherCategories, dataType) {
- var length = categories.length,
- found,
- i,
- j,
- valueOf = dataType === "datetime" ? returnValueOf : returnValue;
- if (otherCategories && otherCategories.length)
- for (i = 0; i < otherCategories.length; i++) {
- for (j = 0, found = false; j < length; j++)
- if (valueOf(categories[j]) === valueOf(otherCategories[i])) {
- found = true;
- break
- }
- !found && categories.push(otherCategories[i])
- }
- return categories
- }
- DX.viz.core.__NUMBER_EQUALITY_CORRECTION = NUMBER_EQUALITY_CORRECTION;
- DX.viz.core.__DATETIME_EQUALITY_CORRECTION = DATETIME_EQUALITY_CORRECTION;
- _Range = core.Range = function(range) {
- range && $.extend(this, range)
- };
- _Range.prototype = {
- constructor: _Range,
- dispose: function() {
- this[categoriesSelector] = null
- },
- addRange: function(otherRange) {
- var that = this,
- categories = that[categoriesSelector],
- otherCategories = otherRange[categoriesSelector];
- var compareAndReplaceByField = function(field, compare) {
- compareAndReplace(that[field], otherRange[field], function(value) {
- that[field] = value
- }, compare)
- };
- var controlValuesByVisibleBounds = function(valueField, visibleValueField, compare) {
- compareAndReplace(that[valueField], that[visibleValueField], function(value) {
- _isDefined(that[valueField]) && (that[valueField] = value)
- }, compare)
- };
- var checkField = function(field) {
- that[field] = that[field] || otherRange[field]
- };
- if (utils.isDefined(otherRange.stick))
- that.stick = otherRange.stick;
- checkField("addSpiderCategory");
- checkField("percentStick");
- checkField("minSpaceCorrection");
- checkField("maxSpaceCorrection");
- checkField("invert");
- checkField(axisTypeSelector);
- checkField("dataType");
- if (that[axisTypeSelector] === "logarithmic")
- checkField(baseSelector);
- else
- that[baseSelector] = undefined;
- compareAndReplaceByField(minSelector, otherLessThan);
- compareAndReplaceByField(maxSelector, otherGreaterThan);
- if (that[axisTypeSelector] === "discrete") {
- checkField(minVisibleSelector);
- checkField(maxVisibleSelector)
- }
- else {
- compareAndReplaceByField(minVisibleSelector, otherLessThan);
- compareAndReplaceByField(maxVisibleSelector, otherGreaterThan)
- }
- compareAndReplaceByField("interval", otherLessThan);
- controlValuesByVisibleBounds(minSelector, minVisibleSelector, otherLessThan);
- controlValuesByVisibleBounds(minSelector, maxVisibleSelector, otherLessThan);
- controlValuesByVisibleBounds(maxSelector, maxVisibleSelector, otherGreaterThan);
- controlValuesByVisibleBounds(maxSelector, minVisibleSelector, otherGreaterThan);
- if (categories === undefined)
- that[categoriesSelector] = otherCategories;
- else
- that[categoriesSelector] = getUniqueCategories(categories, otherCategories, that.dataType);
- return this
- },
- isDefined: function() {
- return _isDefined(this[minSelector]) && _isDefined(this[maxSelector]) || _isDefined(this[categoriesSelector])
- },
- setStubData: function(dataType) {
- var that = this,
- year = (new Date).getYear() - 1,
- isDate = dataType === "datetime",
- isCategories = that.axisType === "discrete";
- if (isCategories)
- that.categories = ["0", "1", "2"];
- else {
- that[minSelector] = isDate ? new Date(year, 0, 1) : 0;
- that[maxSelector] = isDate ? new Date(year, 11, 31) : 10
- }
- that.stubData = true;
- return that
- },
- correctValueZeroLevel: function() {
- var that = this;
- if (_isDate(that[maxSelector]) || _isDate(that[minSelector]))
- return that;
- function setZeroLevel(min, max) {
- that[min] < 0 && that[max] < 0 && (that[max] = 0);
- that[min] > 0 && that[max] > 0 && (that[min] = 0)
- }
- setZeroLevel(minSelector, maxSelector);
- setZeroLevel(minVisibleSelector, maxVisibleSelector);
- return that
- },
- checkZeroStick: function() {
- var that = this;
- if (that.min >= 0 && that.max >= 0)
- that.minStickValue = 0;
- else if (that.min <= 0 && that.max <= 0)
- that.maxStickValue = 0;
- return that
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file svgRenderer.js */
- (function($, DX, doc, undefined) {
- var rendererNS = DX.viz.renderers = {},
- math = Math,
- mathMin = math.min,
- mathMax = math.max,
- mathCeil = math.ceil,
- mathFloor = math.floor,
- mathRound = math.round,
- mathSin = math.sin,
- mathCos = math.cos,
- mathAbs = math.abs,
- mathPI = math.PI,
- PI_DIV_180 = mathPI / 180,
- _parseInt = parseInt,
- MAX_PIXEL_COUNT = 1E10,
- SHARPING_CORRECTION = 0.5,
- ARC_COORD_PREC = 5;
- var pxAddingExceptions = {
- "column-count": true,
- "fill-opacity": true,
- "flex-grow": true,
- "flex-shrink": true,
- "font-weight": true,
- "line-height": true,
- opacity: true,
- order: true,
- orphans: true,
- widows: true,
- "z-index": true,
- zoom: true
- };
- var KEY_TEXT = "text",
- KEY_STROKE = "stroke",
- KEY_STROKE_WIDTH = "stroke-width",
- KEY_STROKE_OPACITY = "stroke-opacity",
- KEY_FONT_SIZE = "font-size",
- KEY_FONT_STYLE = "font-style",
- KEY_FONT_WEIGHT = "font-weight",
- KEY_TEXT_DECORATION = "text-decoration",
- NONE = "none";
- var DEFAULTS = {
- scaleX: 1,
- scaleY: 1
- };
- var getNextDefsSvgId = function() {
- var numDefsSvgElements = 1;
- return function() {
- return "DevExpress_" + numDefsSvgElements++
- }
- }();
- function isObjectArgument(value) {
- return typeof value !== "string"
- }
- function isDefined(value) {
- return value !== null && value !== undefined
- }
- function isArray(value) {
- return Object.prototype.toString.call(value) === "[object Array]"
- }
- function isObject(value) {
- return Object.prototype.toString.call(value) === "[object Object]"
- }
- function createElement(tagName) {
- return doc.createElementNS("http://www.w3.org/2000/svg", tagName)
- }
- function getPatternUrl(id, pathModified) {
- return id !== null ? "url(" + (pathModified ? window.location.href : "") + "#" + id + ")" : ""
- }
- function extend(a, b, skipNonDefined) {
- var value;
- for (var key in b) {
- value = b[key];
- if (!skipNonDefined || skipNonDefined && value !== undefined && value !== null)
- a[key] = value
- }
- return a
- }
- function rotateBBox(bbox, center, angle) {
- var cos = Number(mathCos(angle * PI_DIV_180).toFixed(3)),
- sin = Number(mathSin(angle * PI_DIV_180).toFixed(3)),
- w2 = bbox.width / 2,
- h2 = bbox.height / 2,
- xc = bbox.x + w2,
- yc = bbox.y + h2,
- w2_ = mathAbs(w2 * cos) + mathAbs(h2 * sin),
- h2_ = mathAbs(w2 * sin) + mathAbs(h2 * cos),
- xc_ = center[0] + (xc - center[0]) * cos + (yc - center[1]) * sin,
- yc_ = center[1] - (xc - center[0]) * sin + (yc - center[1]) * cos;
- return normalizeBBox({
- x: xc_ - w2_,
- y: yc_ - h2_,
- width: 2 * w2_,
- height: 2 * h2_
- })
- }
- function normalizeBBoxField(value) {
- return -MAX_PIXEL_COUNT < value && value < +MAX_PIXEL_COUNT ? value : 0
- }
- function normalizeBBox(bbox) {
- var rxl = normalizeBBoxField(mathFloor(bbox.x)),
- ryt = normalizeBBoxField(mathFloor(bbox.y)),
- rxr = normalizeBBoxField(mathCeil(bbox.width + bbox.x)),
- ryb = normalizeBBoxField(mathCeil(bbox.height + bbox.y)),
- result = {
- x: rxl,
- y: ryt,
- width: rxr - rxl,
- height: ryb - ryt
- };
- result.isEmpty = !result.x && !result.y && !result.width && !result.height;
- return result
- }
- function getPreserveAspectRatio(location) {
- return {
- full: NONE,
- lefttop: "xMinYMin",
- leftcenter: "xMinYMid",
- leftbottom: "xMinYMax",
- centertop: "xMidYMin",
- center: "xMidYMid",
- centerbottom: "xMidYMax",
- righttop: "xMaxYMin",
- rightcenter: "xMaxYMid",
- rightbottom: "xMaxYMax"
- }[(location || "").toLowerCase()] || NONE
- }
- rendererNS._normalizeArcParams = function(x, y, innerR, outerR, startAngle, endAngle) {
- var isCircle,
- noArc = true;
- if (mathRound(startAngle) !== mathRound(endAngle)) {
- if (mathAbs(endAngle - startAngle) % 360 === 0) {
- startAngle = 0;
- endAngle = 360;
- isCircle = true;
- endAngle -= 0.01
- }
- if (startAngle > 360)
- startAngle = startAngle % 360;
- if (endAngle > 360)
- endAngle = endAngle % 360;
- if (startAngle > endAngle)
- startAngle -= 360;
- noArc = false
- }
- startAngle = startAngle * PI_DIV_180;
- endAngle = endAngle * PI_DIV_180;
- return [x, y, mathMin(outerR, innerR), mathMax(outerR, innerR), mathCos(startAngle), mathSin(startAngle), mathCos(endAngle), mathSin(endAngle), isCircle, mathFloor(mathAbs(endAngle - startAngle) / mathPI) % 2 ? "1" : "0", noArc]
- };
- var buildArcPath = function(x, y, innerR, outerR, startAngleCos, startAngleSin, endAngleCos, endAngleSin, isCircle, longFlag) {
- return ["M", (x + outerR * startAngleCos).toFixed(ARC_COORD_PREC), (y - outerR * startAngleSin).toFixed(ARC_COORD_PREC), "A", outerR.toFixed(ARC_COORD_PREC), outerR.toFixed(ARC_COORD_PREC), 0, longFlag, 0, (x + outerR * endAngleCos).toFixed(ARC_COORD_PREC), (y - outerR * endAngleSin).toFixed(ARC_COORD_PREC), isCircle ? "M" : "L", (x + innerR * endAngleCos).toFixed(5), (y - innerR * endAngleSin).toFixed(ARC_COORD_PREC), "A", innerR.toFixed(ARC_COORD_PREC), innerR.toFixed(ARC_COORD_PREC), 0, longFlag, 1, (x + innerR * startAngleCos).toFixed(ARC_COORD_PREC), (y - innerR * startAngleSin).toFixed(ARC_COORD_PREC), "Z"].join(" ")
- };
- function buildPathSegments(points, type) {
- var list = [["M", 0, 0]];
- switch (type) {
- case"line":
- list = buildLineSegments(points);
- break;
- case"area":
- list = buildLineSegments(points, true);
- break;
- case"bezier":
- list = buildCurveSegments(points);
- break;
- case"bezierarea":
- list = buildCurveSegments(points, true);
- break
- }
- return list
- }
- function buildLineSegments(points, close) {
- return buildSegments(points, buildSimpleLineSegment, close)
- }
- function buildCurveSegments(points, close) {
- return buildSegments(points, buildSimpleCurveSegment, close)
- }
- function buildSegments(points, buildSimpleSegment, close) {
- var i = 0,
- ii = (points || []).length,
- list = [];
- if (isArray(points[0]))
- for (; i < ii; )
- buildSimpleSegment(points[i++], close, list);
- else
- buildSimpleSegment(points, close, list);
- return list
- }
- function buildSimpleLineSegment(points, close, list) {
- var i = 0,
- ii = (points || []).length;
- if (ii)
- if (isObject(points[0]))
- for (; i < ii; )
- list.push([!i ? "M" : "L", points[i].x, points[i++].y]);
- else
- for (; i < ii; )
- list.push([!i ? "M" : "L", points[i++], points[i++]]);
- else
- list.push(["M", 0, 0]);
- close && list.push(["Z"]);
- return list
- }
- function buildSimpleCurveSegment(points, close, list) {
- var i = 2,
- ii = (points || []).length;
- if (ii)
- if (isObject(points[0])) {
- i = 1;
- list.push(["M", points[0].x, points[0].y]);
- for (; i < ii; )
- list.push(["C", points[i].x, points[i++].y, points[i].x, points[i++].y, points[i].x, points[i++].y])
- }
- else {
- list.push(["M", points[0], points[1]]);
- for (; i < ii; )
- list.push(["C", points[i++], points[i++], points[i++], points[i++], points[i++], points[i++]])
- }
- else
- list.push(["M", 0, 0]);
- close && list.push(["Z"]);
- return list
- }
- function combinePathParam(segments) {
- var d = [],
- i = 0,
- length = segments.length;
- for (; i < length; i++)
- d.push(segments[i].join(" "));
- return d.join(" ")
- }
- function compensateSegments(oldSegments, newSegments, type) {
- var oldLength = oldSegments.length,
- newLength = newSegments.length,
- i,
- originalNewSegments,
- makeEqualSegments = type.indexOf("area") !== -1 ? makeEqualAreaSegments : makeEqualLineSegments;
- if (oldLength === 0)
- for (i = 0; i < newLength; i++)
- oldSegments.push(newSegments[i].slice(0));
- else if (oldLength < newLength)
- makeEqualSegments(oldSegments, newSegments, type);
- else if (oldLength > newLength) {
- originalNewSegments = newSegments.slice(0);
- makeEqualSegments(newSegments, oldSegments, type)
- }
- return originalNewSegments
- }
- function prepareConstSegment(constSeg, type) {
- var x = constSeg[constSeg.length - 2],
- y = constSeg[constSeg.length - 1];
- switch (type) {
- case"line":
- case"area":
- constSeg[0] = "L";
- break;
- case"bezier":
- case"bezierarea":
- constSeg[0] = "C";
- constSeg[1] = constSeg[3] = constSeg[5] = x;
- constSeg[2] = constSeg[4] = constSeg[6] = y;
- break
- }
- }
- function makeEqualLineSegments(short, long, type) {
- var constSeg = short[short.length - 1].slice(),
- i = short.length;
- prepareConstSegment(constSeg, type);
- for (; i < long.length; i++)
- short[i] = constSeg.slice(0)
- }
- function makeEqualAreaSegments(short, long, type) {
- var i,
- head,
- shortLength = short.length,
- longLength = long.length,
- constsSeg1,
- constsSeg2;
- if ((shortLength - 1) % 2 === 0 && (longLength - 1) % 2 === 0) {
- i = (shortLength - 1) / 2 - 1;
- head = short.slice(0, i + 1);
- constsSeg1 = head[head.length - 1].slice(0);
- constsSeg2 = short.slice(i + 1)[0].slice(0);
- prepareConstSegment(constsSeg1, type);
- prepareConstSegment(constsSeg2, type);
- for (var j = i; j < (longLength - 1) / 2 - 1; j++) {
- short.splice(j + 1, 0, constsSeg1);
- short.splice(j + 3, 0, constsSeg2)
- }
- }
- }
- function baseCss(styles) {
- var elemStyles = this._styles,
- str = "",
- key,
- value;
- extend(elemStyles, styles || {}, true);
- for (key in elemStyles) {
- value = elemStyles[key];
- if (value === "")
- continue;
- if (typeof value === "number" && !pxAddingExceptions[key])
- value += "px";
- str += key + ":" + value + ";"
- }
- str && this.element.setAttribute("style", str);
- return this
- }
- function baseAttr(attrs) {
- attrs = attrs || {};
- var that = this,
- settings = that._settings,
- attributes = {},
- key,
- value,
- elem = that.element,
- renderer = that.renderer,
- rtl = renderer.rtl,
- hasTransformations,
- recalculateDashStyle,
- sw,
- i;
- if (!isObjectArgument(attrs)) {
- if (attrs in settings)
- return settings[attrs];
- if (attrs in DEFAULTS)
- return DEFAULTS[attrs];
- return 0
- }
- extend(attributes, attrs);
- for (key in attributes) {
- value = attributes[key];
- if (value === undefined)
- continue;
- settings[key] = value;
- if (key === "align") {
- key = "text-anchor";
- value = {
- left: rtl ? "end" : "start",
- center: "middle",
- right: rtl ? "start" : "end"
- }[value] || ""
- }
- else if (key === "dashStyle") {
- recalculateDashStyle = true;
- continue
- }
- else if (key === KEY_STROKE_WIDTH)
- recalculateDashStyle = true;
- else if (key === "clipId") {
- key = "clip-path";
- value = getPatternUrl(value, renderer.pathModified)
- }
- else if (/^(translate(X|Y)|rotate[XY]?|scale(X|Y)|sharp)$/i.test(key)) {
- hasTransformations = true;
- continue
- }
- else if (/^(x|y|d)$/i.test(key))
- hasTransformations = true;
- if (value === null)
- elem.removeAttribute(key);
- else
- elem.setAttribute(key, value)
- }
- if (recalculateDashStyle && "dashStyle" in settings) {
- value = settings.dashStyle;
- sw = ("_originalSW" in that ? that._originalSW : settings[KEY_STROKE_WIDTH]) || 1;
- key = "stroke-dasharray";
- value = value === null ? "" : value.toLowerCase();
- if (value === "" || value === "solid" || value === NONE)
- that.element.removeAttribute(key);
- else {
- value = value.replace(/longdash/g, "8,3,").replace(/dash/g, "4,3,").replace(/dot/g, "1,3,").replace(/,$/, "").split(",");
- i = value.length;
- while (i--)
- value[i] = _parseInt(value[i]) * sw;
- that.element.setAttribute(key, value.join(","))
- }
- }
- if (hasTransformations)
- that._applyTransformation();
- return that
- }
- function createPathAttr(baseAttr) {
- return function(attrs, inh) {
- var that = this,
- segments;
- if (isObjectArgument(attrs)) {
- attrs = extend({}, attrs);
- segments = attrs.segments;
- if ("points" in attrs) {
- segments = buildPathSegments(attrs.points, that.type);
- delete attrs.points
- }
- if (segments) {
- attrs.d = combinePathParam(segments);
- that.segments = segments;
- delete attrs.segments
- }
- }
- return baseAttr.call(that, attrs, inh)
- }
- }
- function createArcAttr(baseAttr, buildArcPath) {
- return function(attrs, inh) {
- var settings = this._settings,
- x,
- y,
- innerRadius,
- outerRadius,
- startAngle,
- endAngle;
- if (isObjectArgument(attrs)) {
- attrs = extend({}, attrs);
- if ("x" in attrs || "y" in attrs || "innerRadius" in attrs || "outerRadius" in attrs || "startAngle" in attrs || "endAngle" in attrs) {
- settings.x = x = "x" in attrs ? attrs.x : settings.x;
- delete attrs.x;
- settings.y = y = "y" in attrs ? attrs.y : settings.y;
- delete attrs.y;
- settings.innerRadius = innerRadius = "innerRadius" in attrs ? attrs.innerRadius : settings.innerRadius;
- delete attrs.innerRadius;
- settings.outerRadius = outerRadius = "outerRadius" in attrs ? attrs.outerRadius : settings.outerRadius;
- delete attrs.outerRadius;
- settings.startAngle = startAngle = "startAngle" in attrs ? attrs.startAngle : settings.startAngle;
- delete attrs.startAngle;
- settings.endAngle = endAngle = "endAngle" in attrs ? attrs.endAngle : settings.endAngle;
- delete attrs.endAngle;
- attrs.d = buildArcPath.apply(this, rendererNS._normalizeArcParams(x, y, innerRadius, outerRadius, startAngle, endAngle))
- }
- }
- return baseAttr.call(this, attrs, inh)
- }
- }
- function createRectAttr(baseAttr) {
- return function(attrs, inh) {
- var that = this,
- x,
- y,
- width,
- height,
- sw,
- maxSW,
- newSW;
- if (isObjectArgument(attrs)) {
- attrs = extend({}, attrs);
- if (!inh && (attrs.x !== undefined || attrs.y !== undefined || attrs.width !== undefined || attrs.height !== undefined || attrs[KEY_STROKE_WIDTH] !== undefined)) {
- attrs.x !== undefined ? x = that._originalX = attrs.x : x = that._originalX || 0;
- attrs.y !== undefined ? y = that._originalY = attrs.y : y = that._originalY || 0;
- attrs.width !== undefined ? width = that._originalWidth = attrs.width : width = that._originalWidth || 0;
- attrs.height !== undefined ? height = that._originalHeight = attrs.height : height = that._originalHeight || 0;
- attrs[KEY_STROKE_WIDTH] !== undefined ? sw = that._originalSW = attrs[KEY_STROKE_WIDTH] : sw = that._originalSW;
- maxSW = ~~((width < height ? width : height) / 2);
- newSW = (sw || 0) < maxSW ? sw || 0 : maxSW;
- attrs.x = x + newSW / 2;
- attrs.y = y + newSW / 2;
- attrs.width = width - newSW;
- attrs.height = height - newSW;
- ((sw || 0) !== newSW || !(newSW === 0 && sw === undefined)) && (attrs[KEY_STROKE_WIDTH] = newSW)
- }
- if ("sharp" in attrs)
- delete attrs.sharp
- }
- return baseAttr.call(that, attrs, inh)
- }
- }
- var pathAttr = createPathAttr(baseAttr),
- arcAttr = createArcAttr(baseAttr, buildArcPath),
- rectAttr = createRectAttr(baseAttr);
- function textAttr(attrs) {
- var that = this,
- settings,
- isResetRequired,
- wasStroked,
- isStroked;
- if (!isObjectArgument(attrs))
- return baseAttr.call(that, attrs);
- attrs = extend({}, attrs);
- settings = that._settings;
- wasStroked = isDefined(settings[KEY_STROKE]) && isDefined(settings[KEY_STROKE_WIDTH]);
- if (attrs[KEY_TEXT] !== undefined) {
- settings[KEY_TEXT] = attrs[KEY_TEXT];
- delete attrs[KEY_TEXT];
- isResetRequired = true
- }
- if (attrs[KEY_STROKE] !== undefined) {
- settings[KEY_STROKE] = attrs[KEY_STROKE];
- delete attrs[KEY_STROKE]
- }
- if (attrs[KEY_STROKE_WIDTH] !== undefined) {
- settings[KEY_STROKE_WIDTH] = attrs[KEY_STROKE_WIDTH];
- delete attrs[KEY_STROKE_WIDTH]
- }
- if (attrs[KEY_STROKE_OPACITY] !== undefined) {
- settings[KEY_STROKE_OPACITY] = attrs[KEY_STROKE_OPACITY];
- delete attrs[KEY_STROKE_OPACITY]
- }
- isStroked = isDefined(settings[KEY_STROKE]) && isDefined(settings[KEY_STROKE_WIDTH]);
- baseAttr.call(that, attrs);
- isResetRequired = isResetRequired || isStroked !== wasStroked && settings[KEY_TEXT];
- if (isResetRequired)
- createTextNodes(that, settings.text, isStroked);
- if (isResetRequired || attrs["x"] !== undefined || attrs["y"] !== undefined)
- locateTextNodes(that);
- if (isStroked)
- strokeTextNodes(that);
- return that
- }
- function textCss(styles) {
- styles = styles || {};
- baseCss.call(this, styles);
- if (KEY_FONT_SIZE in styles)
- locateTextNodes(this);
- return this
- }
- function orderHtmlTree(strCount, node, textArray) {
- var nodeParams = node.params = node.params || {style: {}},
- nodeStyle = nodeParams.style,
- parentStyle = node.parentNode && node.parentNode.params && node.parentNode.params.style || {},
- nativeElementStyle = node.style,
- childCount = node.childNodes.length,
- count = 0;
- if (node.nodeName !== '#text')
- extend(nodeStyle, parentStyle);
- switch (node.tagName) {
- case'B':
- case'STRONG':
- nodeStyle[KEY_FONT_WEIGHT] = 'bold';
- break;
- case'I':
- case'EM':
- nodeStyle[KEY_FONT_STYLE] = 'italic';
- break;
- case'U':
- nodeStyle[KEY_TEXT_DECORATION] = 'underline';
- break;
- case'BR':
- strCount++;
- break
- }
- if (nativeElementStyle) {
- if (nativeElementStyle.fontSize)
- nodeStyle[KEY_FONT_SIZE] = (_parseInt(nativeElementStyle.fontSize, 10) || nodeStyle[KEY_FONT_SIZE]) + 'px';
- nodeStyle.fill = nativeElementStyle.color || nodeStyle.fill;
- nodeStyle[KEY_FONT_STYLE] = nativeElementStyle.fontStyle || nodeStyle[KEY_FONT_STYLE];
- nodeStyle[KEY_FONT_WEIGHT] = nativeElementStyle.fontWeight || nodeStyle[KEY_FONT_WEIGHT];
- nodeStyle[KEY_TEXT_DECORATION] = nativeElementStyle.textDecoration || nodeStyle[KEY_TEXT_DECORATION]
- }
- while (count !== childCount)
- strCount = orderHtmlTree(strCount, node.childNodes[count++], textArray);
- if (node.wholeText !== undefined) {
- extend(nodeStyle, parentStyle);
- textArray.push({
- value: node.wholeText,
- style: nodeStyle,
- line: strCount,
- height: _parseInt(nodeStyle[KEY_FONT_SIZE], 10) || 0
- })
- }
- return strCount
- }
- function adjustLineHeights(items) {
- var i,
- ii,
- currentItem = items[0],
- item;
- for (i = 1, ii = items.length; i < ii; ++i) {
- item = items[i];
- if (item.line === currentItem.line) {
- currentItem.height = mathMax(currentItem.height, item.height);
- currentItem.inherits = currentItem.inherits || item.height === 0;
- item.height = NaN
- }
- else
- currentItem = item
- }
- }
- function parseHTML(text) {
- var items = [],
- div = doc.createElement("div");
- div.innerHTML = text.replace(/\r/g, "").replace(/\n/g, "<br/>");
- orderHtmlTree(0, div, items);
- adjustLineHeights(items);
- return items
- }
- function parseMultiline(text) {
- var texts = text.replace(/\r/g, "").split("\n"),
- i = 0,
- items = [];
- for (; i < texts.length; i++)
- items.push({
- value: texts[i],
- height: 0
- });
- return items
- }
- function createTspans(items, element, fieldName) {
- var i,
- ii,
- item;
- for (i = 0, ii = items.length; i < ii; ++i) {
- item = items[i];
- item[fieldName] = createElement("tspan");
- item[fieldName].appendChild(doc.createTextNode(item.value));
- item.style && baseCss.call({
- element: item[fieldName],
- _styles: {}
- }, item.style);
- element.appendChild(item[fieldName])
- }
- }
- function createTextNodes(wrapper, text, isStroked) {
- var items;
- wrapper._texts = null;
- wrapper.clear();
- if (text === null)
- return;
- text = "" + text;
- if (!wrapper.renderer.encodeHtml && (text.indexOf("<") !== -1 || text.indexOf("&") !== -1))
- items = parseHTML(text);
- else if (text.indexOf("\n") !== -1)
- items = parseMultiline(text);
- else if (isStroked)
- items = [{
- value: text,
- height: 0
- }];
- if (items) {
- if (items.length) {
- wrapper._texts = items;
- if (isStroked)
- createTspans(items, wrapper.element, KEY_STROKE);
- createTspans(items, wrapper.element, "tspan")
- }
- }
- else
- wrapper.element.appendChild(doc.createTextNode(text))
- }
- function setTextNodeAttribute(item, name, value) {
- item.tspan.setAttribute(name, value);
- item.stroke && item.stroke.setAttribute(name, value)
- }
- function locateTextNodes(wrapper) {
- if (!wrapper._texts)
- return;
- var items = wrapper._texts,
- x = wrapper._settings.x,
- lineHeight = wrapper._styles[KEY_FONT_SIZE] || 12,
- i,
- ii,
- item = items[0];
- setTextNodeAttribute(item, "x", x);
- setTextNodeAttribute(item, "y", wrapper._settings.y);
- for (i = 1, ii = items.length; i < ii; ++i) {
- item = items[i];
- if (item.height >= 0) {
- setTextNodeAttribute(item, "x", x);
- setTextNodeAttribute(item, "dy", item.inherits ? mathMax(item.height, lineHeight) : item.height || lineHeight)
- }
- }
- }
- function strokeTextNodes(wrapper) {
- if (!wrapper._texts)
- return;
- var items = wrapper._texts,
- stroke = wrapper._settings[KEY_STROKE],
- strokeWidth = wrapper._settings[KEY_STROKE_WIDTH],
- strokeOpacity = wrapper._settings[KEY_STROKE_OPACITY] || 1,
- tspan,
- i,
- ii;
- for (i = 0, ii = items.length; i < ii; ++i) {
- tspan = items[i].stroke;
- tspan.setAttribute(KEY_STROKE, stroke);
- tspan.setAttribute(KEY_STROKE_WIDTH, strokeWidth);
- tspan.setAttribute(KEY_STROKE_OPACITY, strokeOpacity);
- tspan.setAttribute("stroke-linejoin", "round")
- }
- }
- function baseAnimate(params, options, complete) {
- options = options || {};
- var that = this,
- key,
- value,
- renderer = that.renderer,
- settings = that._settings,
- animationParams = {};
- var defaults = {
- translateX: 0,
- translateY: 0,
- scaleX: 1,
- scaleY: 1,
- rotate: 0,
- rotateX: 0,
- rotateY: 0
- };
- if (complete)
- options.complete = complete;
- if (renderer.animationEnabled()) {
- for (key in params) {
- value = params[key];
- if (/^(translate(X|Y)|rotate[XY]?|scale(X|Y))$/i.test(key)) {
- animationParams.transform = animationParams.transform || {
- from: {},
- to: {}
- };
- animationParams.transform.from[key] = key in settings ? settings[key] : defaults[key];
- animationParams.transform.to[key] = value
- }
- else if (key === "arc" || key === "segments")
- animationParams[key] = value;
- else
- animationParams[key] = {
- from: key in settings ? settings[key] : parseFloat(that.element.getAttribute(key) || 0),
- to: value
- }
- }
- renderer.animateElement(that, animationParams, extend(extend({}, renderer._animation), options))
- }
- else {
- options.step && options.step.call(that, 1, 1);
- options.complete && options.complete.call(that);
- that.attr(params)
- }
- return that
- }
- function pathAnimate(params, options, complete) {
- var that = this,
- curSegments = that.segments || [],
- newSegments,
- endSegments;
- if (that.renderer.animationEnabled() && "points" in params) {
- newSegments = buildPathSegments(params.points, that.type);
- endSegments = compensateSegments(curSegments, newSegments, that.type);
- params.segments = {
- from: curSegments,
- to: newSegments,
- end: endSegments
- };
- delete params.points
- }
- return baseAnimate.call(that, params, options, complete)
- }
- function arcAnimate(params, options, complete) {
- var that = this,
- settings = that._settings,
- arcParams = {
- from: {},
- to: {}
- };
- if (that.renderer.animationEnabled() && ("x" in params || "y" in params || "innerRadius" in params || "outerRadius" in params || "startAngle" in params || "endAngle" in params)) {
- arcParams.from.x = settings.x || 0;
- arcParams.from.y = settings.y || 0;
- arcParams.from.innerRadius = settings.innerRadius || 0;
- arcParams.from.outerRadius = settings.outerRadius || 0;
- arcParams.from.startAngle = settings.startAngle || 0;
- arcParams.from.endAngle = settings.endAngle || 0;
- arcParams.to.x = "x" in params ? params.x : settings.x;
- delete params.x;
- arcParams.to.y = "y" in params ? params.y : settings.y;
- delete params.y;
- arcParams.to.innerRadius = "innerRadius" in params ? params.innerRadius : settings.innerRadius;
- delete params.innerRadius;
- arcParams.to.outerRadius = "outerRadius" in params ? params.outerRadius : settings.outerRadius;
- delete params.outerRadius;
- arcParams.to.startAngle = "startAngle" in params ? params.startAngle : settings.startAngle;
- delete params.startAngle;
- arcParams.to.endAngle = "endAngle" in params ? params.endAngle : settings.endAngle;
- delete params.endAngle;
- params.arc = arcParams
- }
- return baseAnimate.call(that, params, options, complete)
- }
- rendererNS.__mockPrivateFunctions = function(fs) {
- fs = fs || {};
- function mockFunction(mock, orig) {
- if (!mock)
- return orig;
- var originalFunction = orig;
- orig = mock;
- orig._originalFunction = originalFunction;
- return orig
- }
- createElement = mockFunction(fs.createElement, createElement);
- baseAttr = mockFunction(fs.baseAttr, baseAttr);
- baseAnimate = mockFunction(fs.baseAnimate, baseAnimate);
- getNextDefsSvgId = mockFunction(fs.getNextDefsSvgId, getNextDefsSvgId);
- compensateSegments = mockFunction(fs.compensateSegments, compensateSegments);
- buildPathSegments = mockFunction(fs.buildPathSegments, buildPathSegments);
- buildArcPath = mockFunction(fs.buildArcPath, buildArcPath);
- pathAttr = createPathAttr(baseAttr);
- arcAttr = createArcAttr(baseAttr, buildArcPath);
- rectAttr = createRectAttr(baseAttr);
- return {
- createElement: createElement,
- baseAttr: baseAttr,
- baseAnimate: baseAnimate,
- getNextDefsSvgId: getNextDefsSvgId,
- compensateSegments: compensateSegments,
- buildPathSegments: buildPathSegments,
- buildArcPath: buildArcPath
- }
- };
- rendererNS.__restoreMockPrivateFunctions = function() {
- function restoreFunction(func) {
- return func._originalFunction || func
- }
- createElement = restoreFunction(createElement);
- baseAttr = restoreFunction(baseAttr);
- baseAnimate = restoreFunction(baseAnimate);
- getNextDefsSvgId = restoreFunction(getNextDefsSvgId);
- compensateSegments = restoreFunction(compensateSegments);
- buildPathSegments = restoreFunction(buildPathSegments);
- buildArcPath = restoreFunction(buildArcPath);
- pathAttr = createPathAttr(baseAttr);
- arcAttr = createArcAttr(baseAttr, buildArcPath);
- rectAttr = createRectAttr(baseAttr)
- };
- function SvgElement() {
- this.ctor.apply(this, arguments)
- }
- rendererNS.SvgElement = SvgElement;
- SvgElement.prototype = {
- ctor: function(renderer, tagName, type) {
- var that = this;
- that.renderer = renderer;
- that.element = createElement(tagName);
- that._settings = {};
- that._styles = {};
- if (tagName === "path")
- that.type = type || "line";
- if (tagName === "text") {
- that.attr = textAttr;
- that.css = textCss
- }
- else if (tagName === "path")
- if (that.type === "arc") {
- that.attr = arcAttr;
- that.animate = arcAnimate
- }
- else {
- that.attr = pathAttr;
- that.animate = pathAnimate
- }
- else if (tagName === "rect") {
- that.attr = rectAttr;
- that.sharp = function() {
- return this
- }
- }
- that._$element = $(that.element)
- },
- dispose: function() {
- this._$element.remove();
- return this
- },
- append: function(parent) {
- parent = parent || this.renderer.root;
- (parent.element || parent).appendChild(this.element);
- return this
- },
- remove: function() {
- var elem = this.element,
- parent = elem.parentNode;
- parent && parent.removeChild(elem);
- return this
- },
- clear: function() {
- this._$element.empty();
- return this
- },
- toBackground: function() {
- var elem = this.element,
- parent = elem.parentNode;
- parent && parent.insertBefore(elem, parent.firstChild);
- return this
- },
- toForeground: function() {
- var elem = this.element,
- parent = elem.parentNode;
- parent && parent.appendChild(elem);
- return this
- },
- css: baseCss,
- attr: baseAttr,
- sharp: function(pos) {
- return this.attr({sharp: pos || true})
- },
- _applyTransformation: function() {
- var tr = this._settings,
- scaleXDefined,
- scaleYDefined,
- transformations = [],
- rotateX,
- rotateY,
- sharpMode = tr.sharp,
- strokeOdd = tr[KEY_STROKE_WIDTH] % 2,
- correctionX = strokeOdd && (sharpMode === "h" || sharpMode === true) ? SHARPING_CORRECTION : 0,
- correctionY = strokeOdd && (sharpMode === "v" || sharpMode === true) ? SHARPING_CORRECTION : 0;
- if (!("rotateX" in tr))
- rotateX = tr.x;
- else
- rotateX = tr.rotateX;
- if (!("rotateY" in tr))
- rotateY = tr.y;
- else
- rotateY = tr.rotateY;
- transformations.push("translate(" + ((tr.translateX || 0) + correctionX) + "," + ((tr.translateY || 0) + correctionY) + ")");
- if (tr.rotate)
- transformations.push("rotate(" + tr.rotate + "," + (rotateX || 0) + "," + (rotateY || 0) + ")");
- scaleXDefined = isDefined(tr.scaleX);
- scaleYDefined = isDefined(tr.scaleY);
- if (scaleXDefined || scaleYDefined)
- transformations.push("scale(" + (scaleXDefined ? tr.scaleX : 1) + "," + (scaleYDefined ? tr.scaleY : 1) + ")");
- if (transformations.length)
- this.element.setAttribute("transform", transformations.join(" "))
- },
- move: function(x, y, animate, animOptions) {
- var obj = {};
- isDefined(x) && (obj.translateX = x);
- isDefined(y) && (obj.translateY = y);
- if (!animate)
- this.attr(obj);
- else
- this.animate(obj, animOptions);
- return this
- },
- rotate: function(angle, x, y, animate, animOptions) {
- var obj = {rotate: angle || 0};
- isDefined(x) && (obj.rotateX = x);
- isDefined(y) && (obj.rotateY = y);
- if (!animate)
- this.attr(obj);
- else
- this.animate(obj, animOptions);
- return this
- },
- getBBox: function() {
- var elem = this.element,
- transformation = this._settings,
- bBox;
- try {
- bBox = elem.getBBox && elem.getBBox()
- }
- catch(e) {}
- bBox = bBox || {
- x: 0,
- y: 0,
- width: elem.offsetWidth || 0,
- height: elem.offsetHeight || 0
- };
- if (transformation.rotate)
- bBox = rotateBBox(bBox, [("rotateX" in transformation ? transformation.rotateX : transformation.x) || 0, ("rotateY" in transformation ? transformation.rotateY : transformation.y) || 0], -transformation.rotate);
- else
- bBox = normalizeBBox(bBox);
- return bBox
- },
- markup: function() {
- var temp = doc.createElement('div'),
- node = this.element.cloneNode(true);
- temp.appendChild(node);
- return temp.innerHTML
- },
- getOffset: function() {
- return this._$element.offset()
- },
- animate: baseAnimate,
- stopAnimation: function(disableComplete) {
- var animation = this.animation;
- animation && animation.stop(true, disableComplete);
- return this
- },
- setTitle: function(text) {
- var titleElem = createElement('title');
- titleElem.textContent = text || '';
- this.element.appendChild(titleElem)
- },
- on: function() {
- $.fn.on.apply(this._$element, arguments);
- return this
- },
- off: function() {
- $.fn.off.apply(this._$element, arguments);
- return this
- },
- trigger: function() {
- $.fn.trigger.apply(this._$element, arguments);
- return this
- },
- data: function() {
- $.fn.data.apply(this._$element, arguments);
- return this
- }
- };
- function SvgRenderer(options) {
- var that = this;
- that.root = that._createElement("svg", {
- xmlns: "http://www.w3.org/2000/svg",
- "xmlns:xlink": "http://www.w3.org/1999/xlink",
- version: "1.1",
- fill: NONE,
- stroke: NONE,
- "stroke-width": 0,
- "class": options.cssClass
- }).css({
- "line-height": "normal",
- "-ms-user-select": NONE,
- "-moz-user-select": NONE,
- "-webkit-user-select": NONE,
- "-webkit-tap-highlight-color": "rgba(0, 0, 0, 0)",
- display: "block",
- overflow: "hidden"
- });
- that._defs = that._createElement("defs");
- that._animationController = new rendererNS.AnimationController(that.root.element);
- that._animation = {
- enabled: true,
- duration: 1000,
- easing: "easeOutCubic"
- }
- }
- rendererNS.SvgRenderer = SvgRenderer;
- SvgRenderer.prototype = {
- constructor: SvgRenderer,
- setOptions: function(options) {
- var that = this;
- that.pathModified = !!options.pathModified;
- that.rtl = !!options.rtl;
- that.encodeHtml = !!options.encodeHtml,
- that.updateAnimationOptions(options.animation || {});
- that.root.attr({direction: that.rtl ? "rtl" : "ltr"})
- },
- _createElement: function(tagName, attr, type) {
- var elem = new rendererNS.SvgElement(this, tagName, type);
- attr && elem.attr(attr);
- return elem
- },
- draw: function(container) {
- var that = this;
- if (!container || that.drawn)
- return that;
- that.root.append(container);
- that._defs.append(that.root);
- that.drawn = true;
- return that
- },
- resize: function(width, height) {
- if (width >= 0 && height >= 0)
- this.root.attr({
- width: width,
- height: height
- });
- return this
- },
- clear: function() {
- var that = this;
- that.root.remove();
- that._defs.remove();
- that.drawn = null;
- return this
- },
- dispose: function() {
- var that = this,
- key;
- that.root.dispose();
- that._defs.dispose();
- that._animationController.dispose();
- for (key in that)
- that[key] = null;
- return null
- },
- animationEnabled: function() {
- return !!this._animation.enabled
- },
- updateAnimationOptions: function(newOptions) {
- extend(this._animation, newOptions);
- return this
- },
- stopAllAnimations: function(lock) {
- this._animationController[lock ? "lock" : "stop"]();
- return this
- },
- animateElement: function(element, params, options) {
- this._animationController.animateElement(element, params, options);
- return this
- },
- svg: function() {
- return this.root.markup()
- },
- getRootOffset: function() {
- return this.root.getOffset()
- },
- onEndAnimation: function(endAnimation) {
- this._animationController.onEndAnimation(endAnimation)
- },
- rect: function(x, y, width, height) {
- return this._createElement("rect", {
- x: x || 0,
- y: y || 0,
- width: width || 0,
- height: height || 0
- })
- },
- circle: function(x, y, r) {
- return this._createElement("circle", {
- cx: x || 0,
- cy: y || 0,
- r: r || 0
- })
- },
- g: function() {
- return this._createElement("g")
- },
- image: function(x, y, w, h, href, location) {
- var image = this._createElement("image", {
- x: x || 0,
- y: y || 0,
- width: w || 0,
- height: h || 0,
- preserveAspectRatio: getPreserveAspectRatio(location)
- });
- image.element.setAttributeNS("http://www.w3.org/1999/xlink", "href", href || "");
- return image
- },
- path: function(points, type) {
- return this._createElement("path", {points: points || []}, type)
- },
- arc: function(x, y, innerRadius, outerRadius, startAngle, endAngle) {
- return this._createElement("path", {
- x: x || 0,
- y: y || 0,
- innerRadius: innerRadius || 0,
- outerRadius: outerRadius || 0,
- startAngle: startAngle || 0,
- endAngle: endAngle || 0
- }, "arc")
- },
- text: function(text, x, y) {
- return this._createElement("text", {
- text: text,
- x: x || 0,
- y: y || 0
- })
- },
- pattern: function(color, hatching) {
- hatching = hatching || {};
- var that = this,
- id,
- d,
- pattern,
- rect,
- path,
- step = hatching.step || 6,
- stepTo2 = step / 2,
- stepBy15 = step * 1.5,
- direction = (hatching.direction || "").toLowerCase();
- if (direction !== "right" && direction !== "left")
- return {
- id: color,
- append: function() {
- return this
- },
- clear: function(){},
- dispose: function(){},
- remove: function(){}
- };
- id = getNextDefsSvgId();
- d = direction === "right" ? "M " + stepTo2 + " " + -stepTo2 + " L " + -stepTo2 + " " + stepTo2 + " M 0 " + step + " L " + step + " 0 M " + stepBy15 + " " + stepTo2 + " L " + stepTo2 + " " + stepBy15 : "M 0 0 L " + step + " " + step + " M " + -stepTo2 + " " + stepTo2 + " L " + stepTo2 + " " + stepBy15 + " M " + stepTo2 + " " + -stepTo2 + " L " + stepBy15 + " " + stepTo2;
- pattern = that._createElement("pattern", {
- id: id,
- width: step,
- height: step,
- patternUnits: "userSpaceOnUse"
- }).append(that._defs);
- pattern.id = getPatternUrl(id, that.pathModified);
- rect = that.rect(0, 0, step, step).attr({
- fill: color,
- opacity: hatching.opacity
- }).append(pattern);
- path = that._createElement("path", {
- d: d,
- "stroke-width": hatching.width || 1,
- stroke: color
- }).append(pattern);
- pattern.rect = rect;
- pattern.path = path;
- return pattern
- },
- clipRect: function(x, y, width, height) {
- var that = this,
- id = getNextDefsSvgId(),
- clipPath = that._createElement("clipPath", {id: id}).append(that._defs),
- rect = that.rect(x, y, width, height).append(clipPath);
- rect.id = id;
- rect.clipPath = clipPath;
- rect.remove = function() {
- throw"Not implemented";
- };
- rect.dispose = function() {
- clipPath.dispose();
- clipPath = null;
- return this
- };
- return rect
- },
- shadowFilter: function(x, y, width, height, offsetX, offsetY, blur, color, opacity) {
- var that = this,
- id = getNextDefsSvgId(),
- filter = that._createElement("filter", {
- id: id,
- x: x || 0,
- y: y || 0,
- width: width || 0,
- height: height || 0
- }).append(that._defs),
- gaussianBlur = that._createElement("feGaussianBlur", {
- "in": "SourceGraphic",
- result: "gaussianBlurResult",
- stdDeviation: blur || 0
- }).append(filter),
- offset = that._createElement("feOffset", {
- "in": "gaussianBlurResult",
- result: "offsetResult",
- dx: offsetX || 0,
- dy: offsetY || 0
- }).append(filter),
- flood = that._createElement("feFlood", {
- result: "floodResult",
- "flood-color": color || "",
- "flood-opacity": opacity
- }).append(filter),
- composite = that._createElement("feComposite", {
- "in": "floodResult",
- in2: "offsetResult",
- operator: "in",
- result: "compositeResult"
- }).append(filter),
- finalComposite = that._createElement("feComposite", {
- "in": "SourceGraphic",
- in2: "compositeResult",
- operator: "over"
- }).append(filter);
- filter.ref = getPatternUrl(id, that.pathModified);
- filter.gaussianBlur = gaussianBlur;
- filter.offset = offset;
- filter.flood = flood;
- filter.composite = composite;
- filter.finalComposite = finalComposite;
- filter.attr = function(attrs) {
- var that = this,
- filterAttrs = {},
- offsetAttrs = {},
- floodAttrs = {};
- "x" in attrs && (filterAttrs.x = attrs.x);
- "y" in attrs && (filterAttrs.y = attrs.y);
- "width" in attrs && (filterAttrs.width = attrs.width);
- "height" in attrs && (filterAttrs.height = attrs.height);
- baseAttr.call(that, filterAttrs);
- "blur" in attrs && that.gaussianBlur.attr({stdDeviation: attrs.blur});
- "offsetX" in attrs && (offsetAttrs.dx = attrs.offsetX);
- "offsetY" in attrs && (offsetAttrs.dy = attrs.offsetY);
- that.offset.attr(offsetAttrs);
- "color" in attrs && (floodAttrs["flood-color"] = attrs.color);
- "opacity" in attrs && (floodAttrs["flood-opacity"] = attrs.opacity);
- that.flood.attr(floodAttrs);
- return that
- };
- return filter
- }
- };
- rendererNS.rotateBBox = rotateBBox;
- rendererNS._createArcAttr = createArcAttr;
- rendererNS._createPathAttr = createPathAttr;
- rendererNS._createRectAttr = createRectAttr
- })(jQuery, DevExpress, document);
- /*! Module viz-core, file vmlRenderer.js */
- (function($, DX, doc) {
- DX.viz.renderers = DX.viz.renderers || {};
- var rendererNS = DX.viz.renderers,
- math = Math,
- mathMin = math.min,
- mathMax = math.max,
- mathFloor = math.floor,
- mathSin = math.sin,
- mathCos = math.cos,
- baseElementPrototype = rendererNS.SvgElement.prototype,
- documentFragment = doc.createDocumentFragment(),
- DEFAULT_STYLE = {
- behavior: "url(#default#VML)",
- display: "inline-block",
- position: "absolute"
- },
- DEFAULT_ATTRS = {xmlns: 'urn:schemas-microsoft-com:vml'},
- INHERITABLE_PROPERTIES = {
- stroke: true,
- fill: true,
- opacity: true,
- 'stroke-width': true,
- align: true,
- dashStyle: true,
- "stroke-opacity": true,
- 'fill-opacity': true,
- rotate: true,
- rotateX: true,
- rotateY: true
- },
- stub = function(){},
- stubReturnedThis = function() {
- return this
- },
- svgToVmlConv = {
- circle: "oval",
- g: "div",
- path: "shape",
- text: "span"
- },
- FONT_HEIGHT_OFFSET_K = 0.55 + 0.45 / 2,
- DEFAULTS = {
- scaleX: 1,
- scaleY: 1
- },
- pathAttr = rendererNS._createPathAttr(vmlAttr),
- arcAttr = rendererNS._createArcAttr(vmlAttr, buildArcPath),
- rectAttr = rendererNS._createRectAttr(vmlAttr);
- function isDefined(value) {
- return value !== null && value !== undefined
- }
- function extend(a, b) {
- for (var key in b)
- a[key] = b[key];
- return a
- }
- function inArray(array, elem) {
- var i = 0;
- for (; i < array.length; i++)
- if (elem === array[i])
- return i;
- return -1
- }
- function buildArcPath(x, y, innerR, outerR, startAngleCos, startAngleSin, endAngleCos, endAngleSin, isCircle, longFlag, noArc) {
- var xOuterStart = x + outerR * startAngleCos,
- yOuterStart = y - outerR * startAngleSin,
- xOuterEnd = x + outerR * endAngleCos,
- yOuterEnd = y - outerR * endAngleSin,
- xInnerStart = x + innerR * endAngleCos,
- yInnerStart = y - innerR * endAngleSin,
- xInnerEnd = x + innerR * startAngleCos,
- yInnerEnd = y - innerR * startAngleSin;
- return !noArc ? ['wr', mathFloor(x - innerR), mathFloor(y - innerR), mathFloor(x + innerR), mathFloor(y + innerR), mathFloor(xInnerStart), mathFloor(yInnerStart), mathFloor(xInnerEnd), mathFloor(yInnerEnd), isCircle ? 'wr ' : 'at ', mathFloor(x - outerR), mathFloor(y - outerR), mathFloor(x + outerR), mathFloor(y + outerR), mathFloor(xOuterStart), mathFloor(yOuterStart), mathFloor(xOuterEnd), mathFloor(yOuterEnd), 'x e'].join(" ") : "m 0 0 x e"
- }
- function getInheritSettings(settings) {
- var result = {},
- prop,
- value;
- for (prop in INHERITABLE_PROPERTIES) {
- value = settings[prop];
- value !== undefined && (result[prop] = value)
- }
- return result
- }
- function correctBoundingRectWithStrokeWidth(rect, strokeWidth) {
- strokeWidth = Math.ceil(parseInt(strokeWidth) / 2);
- if (strokeWidth && strokeWidth > 1) {
- rect.left -= strokeWidth;
- rect.top -= strokeWidth;
- rect.right += strokeWidth;
- rect.bottom += strokeWidth
- }
- return rect
- }
- function shapeBBox() {
- var points = (this._settings.d || "").match(/[-0-9]+/g),
- i,
- value,
- resultRect = {};
- for (i = 0; i < points.length; i++) {
- value = parseInt(points[i]);
- if (i % 2) {
- resultRect.top = resultRect.top === undefined || value < resultRect.top ? value : resultRect.top;
- resultRect.bottom = resultRect.bottom === undefined || value > resultRect.bottom ? value : resultRect.bottom
- }
- else {
- resultRect.left = resultRect.left === undefined || value < resultRect.left ? value : resultRect.left;
- resultRect.right = resultRect.right === undefined || value > resultRect.right ? value : resultRect.right
- }
- }
- resultRect.left = resultRect.left || 0;
- resultRect.top = resultRect.top || 0;
- resultRect.right = resultRect.right || 0;
- resultRect.bottom = resultRect.bottom || 0;
- return correctBoundingRectWithStrokeWidth(resultRect, this._fullSettings["stroke-width"])
- }
- function baseAttr(attrs, inh) {
- var element = this.element,
- settings = this._settings,
- fullSettings = this._fullSettings,
- value,
- key,
- params = {style: {}},
- appliedAttr,
- elem;
- if (typeof attrs === "string") {
- if (attrs in settings)
- return settings[attrs];
- if (attrs in DEFAULTS)
- return DEFAULTS[attrs];
- return 0
- }
- for (key in attrs) {
- value = attrs[key];
- if (value === undefined)
- continue;
- appliedAttr = fullSettings[key];
- !inh && (settings[key] = value);
- fullSettings[key] = value;
- if (INHERITABLE_PROPERTIES[key])
- value = value === null ? this._parent && this._parent._fullSettings[key] || value : value;
- appliedAttr !== value && this.processAttr(element, key, value, params)
- }
- this._applyTransformation(params);
- this.css(params.style);
- for (var i = 0; i < this._children.length; i++) {
- elem = this._children[i];
- elem !== this._clipRect && elem.attr(extend(getInheritSettings(this._fullSettings), elem._settings), true);
- elem._applyStyleSheet()
- }
- !inh && this._applyStyleSheet();
- return this
- }
- function vmlAttr() {
- var elem = this.element,
- result = baseAttr.apply(this, arguments);
- for (var i = 0; i < elem.childNodes.length; i++) {
- elem.childNodes[i].xmlns = 'urn:schemas-microsoft-com:vml';
- elem.childNodes[i].style.behavior = "url(#default#VML)";
- elem.childNodes[i].style.display = "inline-block"
- }
- return result
- }
- function processVmlAttr(element, attr, value, params) {
- switch (attr) {
- case"stroke":
- value = value || "none";
- element.stroked = value === 'none' ? 'f' : 't';
- attr += "color";
- break;
- case"fill":
- value = value || "none";
- element.filled = value === 'none' ? 'f' : 't';
- attr += "color";
- break;
- case"stroke-width":
- attr = "strokeweight";
- value = value + 'px';
- break;
- case"stroke-linejoin":
- element.stroke.joinstyle = value;
- return;
- case"stroke-linecap":
- element.stroke.endcap = value === "butt" ? "flat" : value;
- return;
- case"opacity":
- value = adjustOpacityValue(value);
- element.fill.opacity = value;
- element.stroke.opacity = value;
- return;
- case"fill-opacity":
- element.fill.opacity = adjustOpacityValue(value);
- return;
- case"stroke-opacity":
- element.stroke.opacity = adjustOpacityValue(value);
- return;
- case"dashStyle":
- if (value === null)
- element.stroke[attr] = "";
- else {
- value = value.toLowerCase();
- if (value === "solid" || value === "none")
- value = "";
- else
- value = value.replace(/longdash/g, "8,3,").replace(/dash/g, "4,3,").replace(/dot/g, "1,3,").replace(/,$/, "");
- element.stroke[attr] = value
- }
- return;
- case"d":
- attr = "path";
- value = (value + '').toLowerCase().replace("z", "x e").replace(/([.]\d+)/g, "");
- break;
- case"href":
- attr = "src";
- break;
- case"width":
- case"height":
- case"visibility":
- params.style[attr] = value || "";
- return;
- case"class":
- attr += "Name";
- break;
- case"translateX":
- case"translateY":
- case"rotate":
- case"rotateX":
- case"rotateY":
- case"scale":
- case"scaleX":
- case"scaleY":
- case"x":
- case"y":
- return
- }
- element[attr] = value
- }
- function adjustOpacityValue(value) {
- return value >= 0.002 ? value : value === null ? 1 : 0.002
- }
- function createElement(tagName) {
- var element = document.createElement(tagName);
- return documentFragment.appendChild(element)
- }
- var VmlElement = function() {
- this.ctor.apply(this, arguments)
- };
- function processAttr(element, attr, value, params) {
- if (!INHERITABLE_PROPERTIES[attr])
- if (attr === "visibility")
- params.style[attr] = value || "";
- else if (attr === "width" || attr === "height")
- params.style[attr] = value;
- else if (attr === "clipId")
- this.applyClipID(value);
- else if (attr === "translateX" || attr === "translateY" || attr === "x" || attr === "y")
- return;
- else if (attr === "class")
- element.className = value;
- else
- element[attr] = value
- }
- var elementMixin = {
- div: {
- processAttr: processAttr,
- attr: baseAttr,
- _applyTransformation: function(params) {
- var style = params.style,
- settings = this._settings,
- fullSettings = this._fullSettings;
- if (fullSettings.rotate) {
- fullSettings.rotateX = fullSettings.rotateX || 0;
- fullSettings.rotateY = fullSettings.rotateY || 0
- }
- style.left = (settings.x || 0) + (settings.translateX || 0);
- style.top = (settings.y || 0) + (settings.translateY || 0)
- },
- _getBBox: function() {
- var left = Infinity,
- top = Infinity,
- right = -Infinity,
- bottom = -Infinity,
- i = 0,
- child,
- children = this._children,
- translateX,
- translateY,
- childBBox,
- childSettings;
- if (!children.length)
- left = top = bottom = right = 0;
- else
- for (; i < children.length; i++) {
- child = children[i];
- if (child === this._clipRect)
- continue;
- translateX = child._fullSettings.translateX || 0;
- translateY = child._fullSettings.translateY || 0;
- childSettings = child._fullSettings;
- childBBox = child._getBBox();
- left = mathMin(left, childBBox.left + translateX);
- right = mathMax(right, childBBox.right + translateX);
- top = mathMin(top, childBBox.top + translateY);
- bottom = mathMax(bottom, childBBox.bottom + translateY)
- }
- return {
- left: left,
- right: right,
- top: top,
- bottom: bottom
- }
- },
- defaultAttrs: {},
- defaultStyle: {position: "absolute"}
- },
- shape: {
- defaultAttrs: extend({
- coordsize: "1,1",
- "stroke-linejoin": "miter"
- }, DEFAULT_ATTRS),
- defaultStyle: extend({
- width: 1,
- height: 1
- }, DEFAULT_STYLE),
- _getBBox: shapeBBox
- },
- image: {processAttr: function(element, attr, value, params) {
- if (attr === "fill" || attr === "stroke")
- return;
- processVmlAttr(element, attr, value, params)
- }},
- oval: {
- processAttr: function(element, attr, value, params) {
- if (attr === "cx" || attr === "cy")
- attr = attr[1];
- else if (attr === "r") {
- value *= 2;
- processVmlAttr(element, "width", value, params);
- attr = "height"
- }
- else if (attr === "x" || attr === "y")
- return;
- processVmlAttr(element, attr, value, params)
- },
- _getBBox: function() {
- var settings = this._fullSettings,
- x = settings.cx || 0,
- y = settings.cy || 0,
- r = settings.r || 0;
- return correctBoundingRectWithStrokeWidth({
- left: x - r,
- top: y - r,
- right: x + r,
- bottom: y + r
- }, settings["stroke-width"] || 1)
- }
- },
- span: {
- defaultAttrs: {},
- defaultStyle: {
- position: 'absolute',
- whiteSpace: 'nowrap'
- },
- processAttr: function(element, attr, value, params) {
- if (attr === "text") {
- value = isDefined(value) ? value.toString().replace(/\r/g, "") : "";
- if (this.renderer.encodeHtml)
- value = value.replace(/</g, "<").replace(/>/g, ">");
- element.innerHTML = value.replace(/\n/g, "<br/>");
- this.css({filter: ""});
- this._bbox = null
- }
- else
- processAttr(element, attr, value, params)
- },
- attr: baseAttr,
- _applyTransformation: function(params) {
- this.element.offsetHeight;
- var that = this,
- style = params.style,
- settings = that._fullSettings,
- x = isDefined(settings.x) ? settings.x : 0,
- y = isDefined(settings.y) ? settings.y : 0,
- bbox = that._bbox || that.element.getBoundingClientRect(),
- textHeight = bbox.bottom - bbox.top,
- textWidth = bbox.right - bbox.left,
- rotateAngle = settings.rotate,
- cos = 1,
- sin = 0,
- rotateX = isDefined(settings.rotateX) ? settings.rotateX : x,
- rotateY = isDefined(settings.rotateY) ? settings.rotateY : y,
- radianAngle,
- marginLeft = 0,
- marginTop = 0,
- fontHeightOffset = textHeight * FONT_HEIGHT_OFFSET_K,
- filter = "",
- alignMultiplier = {
- center: 0.5,
- right: 1
- }[settings.align],
- opacity = this._styles.opacity || settings.opacity || settings["fill-opacity"];
- if (textHeight && textWidth) {
- if (rotateAngle) {
- radianAngle = rotateAngle * Math.PI / 180.0;
- cos = mathCos(radianAngle);
- sin = mathSin(radianAngle);
- marginLeft = (x - rotateX) * cos - (y - rotateY) * sin + rotateX - x;
- marginTop = (x - rotateX) * sin + (y - rotateY) * cos + rotateY - y;
- filter = 'progid:DXImageTransform.Microsoft.Matrix(sizingMethod="auto expand", M11 = ' + cos.toFixed(5) + ', M12 = ' + (-sin).toFixed(5) + ', M21 = ' + sin.toFixed(5) + ', M22 = ' + cos.toFixed(5) + ')'
- }
- if (rotateAngle < 90) {
- marginTop -= fontHeightOffset * cos;
- marginLeft -= (textHeight - fontHeightOffset) * sin
- }
- else if (rotateAngle < 180) {
- marginTop += (textHeight - fontHeightOffset) * cos;
- marginLeft += textWidth * cos - (textHeight - fontHeightOffset) * sin
- }
- else if (rotateAngle < 270) {
- marginTop += (textHeight - fontHeightOffset) * cos + textWidth * sin;
- marginLeft += textWidth * cos + fontHeightOffset * sin
- }
- else {
- marginTop += textWidth * sin - fontHeightOffset * cos;
- marginLeft += fontHeightOffset * sin
- }
- if (rotateAngle && this.renderer.rtl)
- marginLeft -= textWidth - (textHeight * Math.abs(sin) + textWidth * Math.abs(cos));
- if (alignMultiplier) {
- marginLeft -= textWidth * alignMultiplier * cos;
- marginTop -= textWidth * alignMultiplier * sin
- }
- if (isDefined(opacity))
- filter += " progid:DXImageTransform.Microsoft.Alpha(Opacity=" + opacity * 100 + ")";
- x += marginLeft;
- y += marginTop;
- this._bbox = bbox;
- style.filter = (style.filter || "") + filter;
- style.left = x + (settings.translateX || 0);
- style.top = y + (settings.translateY || 0)
- }
- },
- _getBBox: function textBBox() {
- var element = this.element,
- settings = this._fullSettings,
- parentRect = (element.parentNode && element.parentNode.getBoundingClientRect ? element.parentNode : this.renderer.root.element).getBoundingClientRect(),
- boundingRect = element.getBoundingClientRect(),
- left = boundingRect.left - (settings.translateX || 0) - parentRect.left,
- top = boundingRect.top - (settings.translateY || 0) - parentRect.top;
- return {
- left: left,
- top: top,
- right: left + element.offsetWidth,
- bottom: top + element.offsetHeight
- }
- }
- }
- };
- extend(VmlElement.prototype, baseElementPrototype);
- extend(VmlElement.prototype, {
- defaultStyle: DEFAULT_STYLE,
- defaultAttrs: DEFAULT_ATTRS,
- ctor: function(renderer, tagName, type) {
- var that = this,
- tagPrefix = '<';
- that.renderer = renderer;
- that.type = type;
- that._children = [];
- that._settings = {};
- that._fullSettings = {};
- that._styles = {};
- if (tagName !== "div" && tagName !== "span")
- tagPrefix = "<vml:";
- if (tagName === "shape")
- if (that.type === "arc")
- that.attr = arcAttr;
- else
- that.attr = pathAttr;
- else if (tagName === "rect")
- that.attr = rectAttr;
- extend(that, elementMixin[tagName]);
- that.element = createElement(tagPrefix + tagName + "/>");
- that.css(that.defaultStyle).attr(that.defaultAttrs);
- that._$element = $(that.element)
- },
- dispose: function() {
- this.remove();
- this._$element.remove();
- return this
- },
- attr: vmlAttr,
- processAttr: processVmlAttr,
- css: function(css) {
- var elem = this.element,
- value,
- appliedValue,
- key;
- for (key in css) {
- appliedValue = this._styles[key];
- value = css[key];
- if (!isDefined(value))
- continue;
- this._styles[key] = value;
- if (appliedValue === value)
- continue;
- switch (key) {
- case"fill":
- key = "color";
- break;
- case"font-size":
- key = "fontSize";
- if (typeof value === "number")
- value += "px";
- break;
- case"font-weight":
- key = "fontWeight";
- break;
- case"z-index":
- key = "zIndex";
- break;
- case"opacity":
- continue
- }
- try {
- elem.style[key] = value
- }
- catch(_) {
- continue
- }
- }
- return this
- },
- applyClipID: function(id) {
- var clipRect,
- cssValue,
- renderer = this.renderer;
- clipRect = renderer.getClipRect(id);
- if (clipRect) {
- cssValue = clipRect.getValue();
- clipRect.addElement(this)
- }
- else
- cssValue = "rect(-9999px 9999px 9999px -9999px)";
- this._clipRect = this._clipRect || renderer.rect(0, 0, 0, 0).attr({
- "class": "dxc-vml-clip",
- fill: "none",
- opacity: 0.001
- });
- this._clipRect.attr({
- width: renderer.root.attr("width"),
- height: renderer.root.attr("height")
- });
- this.css({
- clip: cssValue,
- width: renderer.root.attr("width"),
- height: renderer.root.attr("height")
- })
- },
- append: function(parent) {
- parent = parent || this.renderer.root;
- (parent.element || parent).appendChild(this.element);
- if (parent._children) {
- this._parent = parent;
- if (inArray(parent._children, this) === -1)
- parent._children.push(this);
- this.attr(extend(getInheritSettings(parent._fullSettings), this._settings), true)
- }
- this._applyStyleSheet();
- if (parent._clipRect && this !== parent._clipRect)
- parent._clipRect.append(parent);
- return this
- },
- _applyTransformation: function(params) {
- var that = this,
- style = params.style,
- element = that.element,
- settings = that._fullSettings,
- x = that.type !== "arc" ? settings.x || settings.cx - settings.r || 0 : 0,
- y = that.type !== "arc" ? settings.y || settings.cy - settings.r || 0 : 0;
- if (settings.rotate) {
- var radianAngle = settings.rotate * Math.PI / 180.0,
- rotateX = isDefined(settings.rotateX) ? settings.rotateX : x,
- rotateY = isDefined(settings.rotateY) ? settings.rotateY : y,
- rx = x + (settings.width || 0 || parseInt(element.style.width || 0)) / 2,
- ry = y + (settings.height || 0 || parseInt(element.style.height || 0)) / 2,
- cos = mathCos(radianAngle),
- sin = mathSin(radianAngle),
- marginLeft = (rx - rotateX) * cos - (ry - rotateY) * sin + rotateX - rx,
- marginTop = (rx - rotateX) * sin + (ry - rotateY) * cos + rotateY - ry;
- x += marginLeft;
- y += marginTop;
- style.rotation = settings.rotate
- }
- style.left = x + (settings.translateX || 0);
- style.top = y + (settings.translateY || 0)
- },
- remove: function() {
- var that = this,
- parent = that._parent;
- if (parent)
- parent._children.splice(inArray(parent._children, that), 1);
- that._parent = null;
- return baseElementPrototype.remove.call(that)
- },
- clear: function() {
- this._children = [];
- return baseElementPrototype.clear.call(this)
- },
- getBBox: function() {
- var clientRect = this._getBBox(),
- x = clientRect.left,
- y = clientRect.top,
- width = clientRect.right - x,
- height = clientRect.bottom - y;
- return {
- x: x,
- y: y,
- width: width,
- height: height,
- isEmpty: !x && !y && !width && !height
- }
- },
- _getBBox: function() {
- var element = this.element,
- settings = this._fullSettings,
- x = settings.x || 0,
- y = settings.y || 0,
- width = parseInt(element.style.width || 0),
- height = parseInt(element.style.height || 0);
- return correctBoundingRectWithStrokeWidth({
- left: x,
- top: y,
- right: x + width,
- bottom: y + height
- }, settings["stroke-width"] || 1)
- },
- _applyStyleSheet: function() {
- if (this._useCSSTheme)
- this.attr(getInheritSettings(this.element.currentStyle), true)
- },
- setTitle: function(text) {
- this.element.setAttribute('title', text)
- }
- });
- var ClipRect = function() {
- this.ctor.apply(this, arguments)
- };
- extend(ClipRect.prototype, VmlElement.prototype);
- extend(ClipRect.prototype, {
- ctor: function(renderer, id) {
- this._settings = this._fullSettings = {};
- this.renderer = renderer;
- this._children = [];
- this._elements = [];
- this.id = id
- },
- attr: function() {
- var result = baseAttr.apply(this, arguments),
- elements = this._elements.slice(),
- element,
- i;
- if (result === this)
- for (i = 0; i < elements.length; i++) {
- element = elements[i];
- if (element._fullSettings.clipId === this.id)
- elements[i].applyClipID(this.id);
- else
- this.removeElement(element)
- }
- return result
- },
- processAttr: stub,
- _applyTransformation: stub,
- append: stubReturnedThis,
- dispose: function() {
- this._elements = null;
- this.renderer.removeClipRect(this.id);
- return this
- },
- addElement: function(element) {
- var elements = this._elements;
- if (inArray(elements, element) === -1)
- elements.push(element)
- },
- removeElement: function(element) {
- var index = inArray(this._elements, element);
- index > -1 && this._elements.splice(index, 1)
- },
- getValue: function() {
- var settings = this._settings,
- left = (settings.x || 0) + (settings.translateX || 0),
- top = (settings.y || 0) + (settings.translateY || 0);
- return "rect(" + top + "px, " + (left + (settings.width || 0)) + "px, " + (top + (settings.height || 0)) + "px, " + left + "px)"
- },
- css: stubReturnedThis,
- remove: stubReturnedThis
- });
- var VmlRenderer = function(options) {
- var that = this;
- that.root = that._createElement("div", {
- fill: "none",
- stroke: "none",
- "stroke-width": 0
- }).css({
- position: "relative",
- display: "inline-block",
- overflow: "hidden"
- });
- that._clipRects = [];
- that._animation = {enabled: false};
- that._defs = {
- clear: stubReturnedThis,
- remove: stubReturnedThis,
- append: stubReturnedThis,
- dispose: stubReturnedThis
- };
- that.setOptions(options)
- };
- extend(VmlRenderer.prototype, rendererNS.SvgRenderer.prototype);
- extend(VmlRenderer.prototype, {
- constructor: VmlRenderer,
- setOptions: function() {
- rendererNS.SvgRenderer.prototype.setOptions.apply(this, arguments);
- this.root.css({direction: this.rtl ? "rtl" : "ltr"})
- },
- _createElement: function(tagName, attr, type) {
- tagName = svgToVmlConv[tagName] || tagName;
- var elem = new rendererNS.VmlElement(this, tagName, type);
- attr && elem.attr(attr);
- return elem
- },
- dispose: function() {
- this.root.dispose();
- return null
- },
- shadowFilter: function() {
- return {
- ref: null,
- append: stubReturnedThis,
- dispose: stubReturnedThis,
- attr: stubReturnedThis,
- css: stubReturnedThis
- }
- },
- clipRect: function(x, y, width, height) {
- var clipRects = this._clipRects,
- id = clipRects.length,
- clipRect = new ClipRect(this, id).attr({
- x: x || 0,
- y: y || 0,
- width: width || 0,
- height: height || 0
- });
- clipRects.push(clipRect);
- return clipRect
- },
- getClipRect: function(id) {
- return this._clipRects[id]
- },
- removeClipRect: function(id) {
- delete this._clipRects[id]
- },
- pattern: function(color) {
- return {
- id: color,
- append: stubReturnedThis,
- remove: stubReturnedThis,
- dispose: stubReturnedThis
- }
- },
- image: function(x, y, w, h, href, location) {
- var image = this._createElement("image", {
- x: x || 0,
- y: y || 0,
- width: w || 0,
- height: h || 0,
- location: location,
- href: href
- });
- return image
- },
- updateAnimationOptions: stubReturnedThis,
- stopAllAnimations: stubReturnedThis,
- svg: function() {
- return ""
- },
- onEndAnimation: function(callback) {
- callback()
- }
- });
- rendererNS.VmlRenderer = VmlRenderer;
- rendererNS.VmlElement = VmlElement;
- rendererNS._VmlClipRect = ClipRect
- })(jQuery, DevExpress, document);
- /*! Module viz-core, file animation.js */
- (function(DX) {
- var rendererNS = DX.viz.renderers,
- noop = function(){},
- easingFunctions = {
- easeOutCubic: function(pos, start, end) {
- return pos === 1 ? end : (1 - Math.pow(1 - pos, 3)) * (end - start) + +start
- },
- linear: function(pos, start, end) {
- return pos === 1 ? end : pos * (end - start) + +start
- }
- };
- rendererNS.easingFunctions = easingFunctions;
- rendererNS.animationSvgStep = {
- segments: function(elem, params, progress, easing, currentParams) {
- var from = params.from,
- to = params.to,
- curSeg,
- seg,
- i,
- j,
- segments = [];
- for (i = 0; i < from.length; i++) {
- curSeg = from[i];
- seg = [curSeg[0]];
- if (curSeg.length > 1)
- for (j = 1; j < curSeg.length; j++)
- seg.push(easing(progress, curSeg[j], to[i][j]));
- segments.push(seg)
- }
- currentParams.segments = params.end && progress === 1 ? params.end : segments;
- elem.attr({segments: segments})
- },
- arc: function(elem, params, progress, easing) {
- var from = params.from,
- to = params.to,
- current = {};
- for (var i in from)
- current[i] = easing(progress, from[i], to[i]);
- elem.attr(current)
- },
- transform: function(elem, params, progress, easing, currentParams) {
- var from = params.from,
- to = params.to,
- current = {};
- for (var i in from)
- current[i] = currentParams[i] = easing(progress, from[i], to[i]);
- elem.attr(current)
- },
- base: function(elem, params, progress, easing, currentParams, attributeName) {
- var obj = {};
- obj[attributeName] = currentParams[attributeName] = easing(progress, params.from, params.to);
- elem.attr(obj)
- },
- _: noop,
- complete: function(element, currentSettings) {
- element.attr(currentSettings)
- }
- };
- function Animation(element, params, options) {
- var that = this;
- that._progress = 0;
- that.element = element;
- that.params = params;
- that.options = options;
- that.duration = options.partitionDuration ? options.duration * options.partitionDuration : options.duration;
- that._animateStep = options.animateStep || rendererNS.animationSvgStep;
- that._easing = easingFunctions[options.easing] || easingFunctions["easeOutCubic"];
- that._currentParams = {};
- that.tick = that._start
- }
- Animation.prototype = {
- _calcProgress: function(now) {
- return Math.min(1, (now - this._startTime) / this.duration)
- },
- _step: function(now) {
- var that = this,
- animateStep = that._animateStep,
- attrName;
- that._progress = that._calcProgress(now);
- for (attrName in that.params) {
- var anim = animateStep[attrName] || animateStep.base;
- anim(that.element, that.params[attrName], that._progress, that._easing, that._currentParams, attrName)
- }
- that.options.step && that.options.step(that._easing(that._progress, 0, 1), that._progress);
- if (that._progress === 1)
- return that.stop();
- return true
- },
- _start: function(now) {
- this._startTime = now;
- this.tick = this._step;
- return true
- },
- _end: function(disableComplete) {
- var that = this;
- that.stop = noop;
- that.tick = noop;
- that._animateStep.complete && that._animateStep.complete(that.element, that._currentParams);
- that.options.complete && !disableComplete && that.options.complete()
- },
- tick: function() {
- return true
- },
- stop: function(breakAnimation, disableComplete) {
- var that = this,
- options = that.options;
- if (!breakAnimation && options.repeatCount && --options.repeatCount > 0) {
- that.tick = that._start;
- return true
- }
- else
- that._end(disableComplete)
- }
- };
- function AnimationController(element) {
- var that = this;
- that._animationCount = 0;
- that._timerId = null;
- that._animations = {};
- that.element = element
- }
- rendererNS.AnimationController = AnimationController;
- AnimationController.prototype = {
- _loop: function() {
- var that = this,
- animations = that._animations,
- activeAnimation = 0,
- now = (new Date).getTime(),
- an,
- endAnimation = that._endAnimation;
- for (an in animations) {
- if (!animations[an].tick(now))
- delete animations[an];
- activeAnimation++
- }
- if (activeAnimation === 0) {
- that.stop();
- that._endAnimationTimer = endAnimation && setTimeout(function() {
- if (that._animationCount === 0) {
- endAnimation();
- that._endAnimation = null
- }
- });
- return
- }
- that._timerId = DX.requestAnimationFrame.call(null, function() {
- that._loop()
- }, that.element)
- },
- addAnimation: function(animation) {
- var that = this;
- that._animations[that._animationCount++] = animation;
- clearTimeout(that._endAnimationTimer);
- if (!that._timerId) {
- clearTimeout(that._startDelay);
- that._startDelay = setTimeout(function() {
- that._timerId = 1;
- that._loop()
- }, 0)
- }
- },
- animateElement: function(elem, params, options) {
- if (elem && params && options) {
- elem.animation && elem.animation.stop(true);
- this.addAnimation(elem.animation = new Animation(elem, params, options))
- }
- },
- onEndAnimation: function(endAnimation) {
- this._animationCount ? this._endAnimation = endAnimation : endAnimation()
- },
- dispose: function() {
- this.stop();
- this.element = null
- },
- stop: function() {
- var that = this;
- that._animations = {};
- that._animationCount = 0;
- DX.cancelAnimationFrame(that._timerId);
- clearTimeout(that._startDelay);
- clearTimeout(that._endAnimationTimer);
- that._timerId = null
- },
- lock: function() {
- var an,
- animations = this._animations;
- for (an in animations)
- animations[an].stop(true, true);
- this.stop()
- }
- };
- rendererNS.Animation = Animation;
- rendererNS.noop = noop
- })(DevExpress);
- /*! Module viz-core, file renderer.js */
- (function($, DX, document) {
- var renderers = DX.viz.renderers,
- browser = DX.browser;
- function isSvg() {
- return !(browser.msie && browser.version < 9) || !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', "svg").createSVGRect
- }
- if (!isSvg()) {
- if (document.namespaces && !document.namespaces.vml) {
- document.namespaces.add('vml', 'urn:schemas-microsoft-com:vml');
- document.createStyleSheet().cssText = 'vml\\:* { behavior:url(#default#VML); display: inline-block; } '
- }
- renderers.Renderer = renderers.VmlRenderer
- }
- else
- renderers.Renderer = renderers.SvgRenderer;
- renderers.isSvg = isSvg
- })(jQuery, DevExpress, document);
- /*! Module viz-core, file seriesConsts.js */
- (function(DX) {
- DX.viz.core.series = DX.viz.core.series || {};
- DX.viz.core.series.helpers = DX.viz.core.series.helpers || {};
- DX.viz.core.series.helpers.consts = {
- events: {
- mouseover: "mouseover",
- mouseout: "mouseout",
- mousemove: "mousemove",
- touchstart: "touchstart",
- touchmove: "touchmove",
- touchend: "touchend",
- mousedown: "mousedown",
- mouseup: "mouseup",
- click: "click",
- selectSeries: "selectseries",
- deselectSeries: "deselectseries",
- selectPoint: "selectpoint",
- deselectPoint: "deselectpoint",
- showPointTooltip: "showpointtooltip",
- hidePointTooltip: "hidepointtooltip"
- },
- states: {
- hover: "hover",
- normal: "normal",
- selected: "selected",
- normalMark: 0,
- hoverMark: 1,
- selectedMark: 2
- },
- animations: {
- showDuration: {duration: 400},
- hideGroup: {opacity: 0.0001},
- showGroup: {opacity: 1}
- },
- pieLabelIndent: 30
- }
- })(DevExpress);
- /*! Module viz-core, file seriesFamily.js */
- (function($, DX, undefined) {
- var utils = DX.utils,
- _math = Math,
- _round = _math.round,
- _abs = _math.abs,
- _pow = _math.pow,
- _each = $.each;
- DX.viz.core.series.helpers.SeriesFamily = DX.Class.inherit(function() {
- var ctor = function(options) {
- var debug = DX.utils.debug;
- debug.assert(options.type, "type was not passed or empty");
- var that = this,
- stubFunction = $.noop;
- that.type = options.type.toLowerCase();
- that.pane = options.pane;
- that.series = [];
- that.updateOptions(options);
- switch (that.type) {
- case"bar":
- that.adjustSeriesDimensions = adjustBarSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = updateBarSeriesValues;
- break;
- case"rangebar":
- that.adjustSeriesDimensions = adjustBarSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- case"fullstackedbar":
- that.fullStacked = true;
- that.adjustSeriesDimensions = adjustStackedBarSeriesDimensions;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = updateStackedSeriesValues;
- break;
- case"stackedbar":
- that.adjustSeriesDimensions = adjustStackedBarSeriesDimensions;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = updateStackedSeriesValues;
- break;
- case"fullstackedarea":
- case"fullstackedline":
- case"fullstackedspline":
- case"fullstackedsplinearea":
- that.fullStacked = true;
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = stubFunction;
- break;
- case"stackedarea":
- case"stackedsplinearea":
- case"stackedline":
- case"stackedspline":
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = adjustStackedSeriesValues;
- that.updateSeriesValues = stubFunction;
- break;
- case"candlestick":
- case"stock":
- that.adjustSeriesDimensions = adjustCandlestickSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- case"bubble":
- that.adjustSeriesDimensions = adjustBubbleSeriesDimensions;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break;
- default:
- that.adjustSeriesDimensions = stubFunction;
- that.adjustSeriesValues = stubFunction;
- that.updateSeriesValues = stubFunction;
- break
- }
- };
- var updateOptions = function(options) {
- this.equalBarWidth = options.equalBarWidth;
- this.minBubbleSize = options.minBubbleSize;
- this.maxBubbleSize = options.maxBubbleSize
- };
- var dispose = function() {
- this.series = null;
- this.translators = null
- };
- var add = function(series) {
- var that = this,
- singleSeries,
- i;
- if (!$.isArray(series))
- series = [series];
- for (i = 0; i < series.length; i++) {
- singleSeries = series[i];
- if (singleSeries.type.toLowerCase() === that.type)
- that.series.push(singleSeries)
- }
- };
- function correctPointCoordinates(points, width, offset) {
- _each(points, function(_, point) {
- point.correctCoordinates({
- width: width,
- offset: offset
- })
- })
- }
- function getStacksWithArgument(stackKeepers, argument) {
- var stacksWithArgument = [];
- _each(stackKeepers, function(stackName, seriesInStack) {
- _each(seriesInStack, function(_, singleSeries) {
- var points = singleSeries.getPointsByArg(argument),
- pointsLength = points.length,
- i;
- for (i = 0; i < pointsLength; ++i)
- if (points[i] && points[i].value) {
- stacksWithArgument.push(stackName);
- return false
- }
- })
- });
- return stacksWithArgument
- }
- function correctPointCoordinatesForStacks(stackKeepers, stacksWithArgument, argument, middleIndex, width, spacing) {
- _each(stackKeepers, function(stackName, seriesInStack) {
- var stackIndex = $.inArray(stackName, stacksWithArgument),
- offset;
- if (stackIndex === -1)
- return;
- offset = (stackIndex - middleIndex + 0.5) * width - (middleIndex - stackIndex - 0.5) * spacing;
- _each(seriesInStack, function(_, singleSeries) {
- _each(singleSeries.getPointsByArg(argument) || [], function(_, point) {
- if (point && point.value)
- point.correctCoordinates({
- width: width,
- offset: offset
- })
- })
- })
- })
- }
- var adjustBarSeriesDimensionsCore = function(series, interval, stackCount, equalBarWidth, seriesStackIndexCallback) {
- var spacing,
- width,
- maxWidth,
- middleIndex,
- stackIndex,
- i,
- points,
- seriesOffset,
- stackName,
- argumentsKeeper = {},
- stackKeepers = {},
- stacksWithArgument,
- count;
- if (equalBarWidth) {
- width = equalBarWidth.width && equalBarWidth.width < 0 ? 0 : equalBarWidth.width;
- spacing = equalBarWidth.spacing && equalBarWidth.spacing < 0 ? 0 : equalBarWidth.spacing;
- if (!spacing)
- if (stackCount > 1) {
- spacing = width ? _round((interval * 0.7 - width * stackCount) / (stackCount - 1)) : _round(interval * 0.7 / stackCount * 0.2);
- if (spacing < 1)
- spacing = 1
- }
- else
- spacing = 0;
- if (!width) {
- width = _round((interval * 0.7 - spacing * (stackCount - 1)) / stackCount);
- if (width < 2)
- width = 2
- }
- if (width * stackCount + spacing * (stackCount - 1) > interval) {
- spacing = _round((interval * 0.7 - width * stackCount) / (stackCount - 1));
- if (spacing < 1) {
- spacing = 1;
- maxWidth = _round((interval * 0.7 - spacing * (stackCount - 1)) / stackCount)
- }
- }
- middleIndex = stackCount / 2;
- for (i = 0; i < series.length; i++) {
- stackIndex = seriesStackIndexCallback(i);
- points = series[i].getPoints();
- seriesOffset = (stackIndex - middleIndex + 0.5) * (maxWidth || width) - (middleIndex - stackIndex - 0.5) * spacing;
- correctPointCoordinates(points, width, seriesOffset)
- }
- }
- else {
- _each(series, function(i, singleSeries) {
- stackName = singleSeries.getStackName && singleSeries.getStackName();
- stackName = stackName || i.toString();
- if (!stackKeepers[stackName])
- stackKeepers[stackName] = [];
- stackKeepers[stackName].push(singleSeries)
- });
- _each(series, function(i, singleSeries) {
- _each(singleSeries.getPoints(), function(_, point) {
- var argument = point.argument;
- if (!argumentsKeeper.hasOwnProperty(argument))
- argumentsKeeper[argument.valueOf()] = 1
- })
- });
- for (var argument in argumentsKeeper) {
- if (!argumentsKeeper.hasOwnProperty(argument))
- continue;
- stacksWithArgument = getStacksWithArgument(stackKeepers, argument);
- count = stacksWithArgument.length;
- spacing = _round(interval * 0.7 / count * 0.2);
- if (spacing < 1)
- spacing = 1;
- width = _round((interval * 0.7 - spacing * (count - 1)) / count);
- if (width < 2)
- width = 2;
- middleIndex = count / 2;
- correctPointCoordinatesForStacks(stackKeepers, stacksWithArgument, argument, middleIndex, width, spacing)
- }
- }
- };
- function checkMinBarSize(value, minShownValue) {
- return _abs(value) < minShownValue ? value >= 0 ? minShownValue : -minShownValue : value
- }
- function getValueType(value) {
- return value >= 0 ? "positive" : "negative"
- }
- function getVisibleSeries(that) {
- return $.map(that.series, function(s) {
- return s.isVisible() ? s : null
- })
- }
- function getAbsStackSumByArg(stackKeepers, stackName, argument) {
- var positiveStackValue = (stackKeepers.positive[stackName] || {})[argument] || 0,
- negativeStackValue = -(stackKeepers.negative[stackName] || {})[argument] || 0;
- return positiveStackValue + negativeStackValue
- }
- var adjustBarSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- equalBarWidth = that.equalBarWidth,
- series = getVisibleSeries(that);
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), series.length, equalBarWidth, function(seriesIndex) {
- return seriesIndex
- })
- };
- var adjustStackedBarSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translators was not passed or empty");
- var that = this,
- series = getVisibleSeries(that),
- stackIndexes = {},
- stackCount = 0,
- equalBarWidth = that.equalBarWidth;
- _each(series, function() {
- var stackName = this.getStackName();
- if (!stackIndexes.hasOwnProperty(stackName))
- stackIndexes[stackName] = stackCount++
- });
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), stackCount, equalBarWidth, function(seriesIndex) {
- return stackIndexes[series[seriesIndex].getStackName()]
- })
- };
- var adjustStackedSeriesValues = function() {
- var that = this,
- series = getVisibleSeries(that),
- stackKeepers = {
- positive: {},
- negative: {}
- },
- holesStack = {
- left: {},
- right: {}
- };
- _each(series, function(seriesIndex, singleSeries) {
- var points = singleSeries.getPoints(),
- hole = false;
- singleSeries._prevSeries = series[seriesIndex - 1],
- singleSeries.holes = $.extend(true, {}, holesStack);
- _each(points, function(index, point) {
- var value = point.initialValue,
- argument = point.argument.valueOf(),
- stackName = singleSeries.getStackName(),
- stacks = value >= 0 ? stackKeepers.positive : stackKeepers.negative,
- currentStack;
- stacks[stackName] = stacks[stackName] || {};
- currentStack = stacks[stackName];
- if (currentStack[argument]) {
- point.correctValue(currentStack[argument]);
- currentStack[argument] += value
- }
- else {
- currentStack[argument] = value;
- point.resetCorrection()
- }
- if (!point.hasValue()) {
- var prevPoint = points[index - 1];
- if (!hole && prevPoint && prevPoint.hasValue()) {
- argument = prevPoint.argument.valueOf();
- prevPoint._skipSetRightHole = true;
- holesStack.right[argument] = (holesStack.right[argument] || 0) + (prevPoint.value - (isFinite(prevPoint.minValue) ? prevPoint.minValue : 0))
- }
- hole = true
- }
- else if (hole) {
- hole = false;
- holesStack.left[argument] = (holesStack.left[argument] || 0) + (point.value - (isFinite(point.minValue) ? point.minValue : 0));
- point._skipSetLeftHole = true
- }
- })
- });
- _each(series, function(seriesIndex, singleSeries) {
- var points = singleSeries.getPoints(),
- holes = singleSeries.holes;
- _each(points, function(index, point) {
- var argument = point.argument.valueOf();
- point.resetHoles();
- !point._skipSetLeftHole && point.setHole(holes.left[argument] || holesStack.left[argument] && 0, "left");
- !point._skipSetRightHole && point.setHole(holes.right[argument] || holesStack.right[argument] && 0, "right");
- point._skipSetLeftHole = null;
- point._skipSetRightHole = null
- })
- });
- that._stackKeepers = stackKeepers;
- setPercentStackedValues(series, stackKeepers, that.fullStacked, holesStack)
- };
- var setPercentStackedValues = function(series, stackKeepers, fullStacked, holeStack) {
- _each(series, function(_, singleSeries) {
- _each(singleSeries.getPoints(), function(_, point) {
- var argument = point.argument.valueOf();
- point.setPercentValue(getAbsStackSumByArg(stackKeepers, singleSeries.getStackName(), argument), fullStacked, holeStack.left[argument], holeStack.right[argument])
- })
- })
- };
- var updateStackedSeriesValues = function(translators) {
- var that = this,
- series = getVisibleSeries(that),
- stack = that._stackKeepers,
- stackKeepers = {
- positive: {},
- negative: {}
- };
- _each(series, function(_, singleSeries) {
- var minBarSize = singleSeries.getOptions().minBarSize,
- minShownBusinessValue = minBarSize && translators.val.getMinBarSize(minBarSize),
- stackName = singleSeries.getStackName();
- _each(singleSeries.getPoints(), function(index, point) {
- if (!point.hasValue())
- return;
- var value = point.initialValue,
- argument = point.argument.valueOf(),
- updateValue,
- valueType,
- currentStack;
- if (that.fullStacked)
- value = _abs(value) / getAbsStackSumByArg(stack, stackName, argument) || 0;
- updateValue = checkMinBarSize(value, minShownBusinessValue);
- valueType = getValueType(updateValue);
- currentStack = stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- if (currentStack[argument]) {
- point.minValue = currentStack[argument];
- currentStack[argument] += updateValue
- }
- else
- currentStack[argument] = updateValue;
- point.value = currentStack[argument]
- })
- });
- if (that.fullStacked)
- updateFullStackedSeriesValues(series, stackKeepers)
- };
- var updateFullStackedSeriesValues = function(series, stackKeepers) {
- _each(series, function(_, singleSeries) {
- var stackName = singleSeries.getStackName ? singleSeries.getStackName() : "default";
- _each(singleSeries.getPoints(), function(index, point) {
- var value = _abs(point.value),
- argument = point.argument.valueOf(),
- valueType = getValueType(value),
- currentStack;
- stackKeepers[valueType][stackName] = stackKeepers[valueType][stackName] || {};
- currentStack = stackKeepers[valueType][stackName];
- point.value = point.value / currentStack[argument] || 0;
- if (utils.isNumber(point.minValue))
- point.minValue = point.minValue / currentStack[argument] || 0
- })
- })
- };
- var updateBarSeriesValues = function(translators) {
- _each(this.series, function(_, singleSeries) {
- var minBarSize = singleSeries.getOptions().minBarSize,
- minShownBusinessValue = minBarSize && translators.val.getMinBarSize(minBarSize);
- if (minShownBusinessValue)
- _each(singleSeries.getPoints(), function(index, point) {
- if (point.hasValue())
- point.value = checkMinBarSize(point.initialValue, minShownBusinessValue)
- })
- })
- };
- var adjustCandlestickSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- series = getVisibleSeries(that);
- adjustBarSeriesDimensionsCore(series, getInterval(that, translators), series.length, true, function(seriesIndex) {
- return seriesIndex
- })
- };
- var getInterval = function(that, translators) {
- var argTranslator = translators.arg;
- that.interval = argTranslator.getInterval();
- return that.interval
- };
- var adjustBubbleSeriesDimensions = function(translators) {
- var debug = DX.utils.debug;
- debug.assert(translators, "translator was not passed or empty");
- var that = this,
- series = getVisibleSeries(that),
- visibleAreaX = translators.arg.getCanvasVisibleArea(),
- visibleAreaY = translators.val.getCanvasVisibleArea(),
- min = Math.min(visibleAreaX.max - visibleAreaX.min, visibleAreaY.max - visibleAreaY.min),
- minBubbleArea = _pow(that.minBubbleSize, 2),
- maxBubbleArea = _pow(min * that.maxBubbleSize, 2),
- equalBubbleSize = (min * that.maxBubbleSize + that.minBubbleSize) / 2,
- minPointSize = Infinity,
- maxPointSize = 0,
- pointSize,
- bubbleArea,
- sizeProportion,
- sizeDispersion,
- areaDispersion;
- _each(series, function(_, seriesItem) {
- _each(seriesItem.getPoints(), function(_, point) {
- maxPointSize = maxPointSize > point.size ? maxPointSize : point.size;
- minPointSize = minPointSize < point.size ? minPointSize : point.size
- })
- });
- sizeDispersion = maxPointSize - minPointSize;
- areaDispersion = _abs(maxBubbleArea - minBubbleArea);
- minPointSize = minPointSize < 0 ? 0 : minPointSize;
- _each(series, function(_, seriesItem) {
- _each(seriesItem.getPoints(), function(_, point) {
- if (maxPointSize === minPointSize)
- pointSize = _round(equalBubbleSize);
- else {
- sizeProportion = _abs(point.size - minPointSize) / sizeDispersion;
- bubbleArea = areaDispersion * sizeProportion + minBubbleArea;
- pointSize = _round(Math.sqrt(bubbleArea))
- }
- point.correctCoordinates(pointSize)
- })
- })
- };
- return {
- ctor: ctor,
- dispose: dispose,
- add: add,
- updateOptions: updateOptions
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-core, file baseSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- core = viz.core,
- seriesNS = core.series,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- _each = $.each,
- _extend = $.extend,
- _isEmptyObject = $.isEmptyObject,
- _Event = $.Event,
- _noop = $.noop,
- SELECTED_STATE = 2,
- HOVER_STATE = 1,
- NONE_MODE = "none",
- INCLUDE_POINTS = "includepoints",
- EXLUDE_POINTS = "excludepoints",
- NEAREST_POINT = "nearestpoint",
- APPLY_SELECTED = "applySelected",
- APPLY_HOVER = "applyHover",
- SYMBOL_POINT = "symbolPoint",
- POLAR_SYMBOL_POINT = "polarSymbolPoint",
- BAR_POINT = "barPoint",
- POLAR_BAR_POINT = "polarBarPoint",
- PIE_POINT = "piePoint",
- HOVER = "hover",
- NORMAL = "normal",
- SELECTION = "selection",
- getEmptyBusinessRange = function() {
- return {
- arg: {},
- val: {}
- }
- };
- function triggerEvent(element, event, point) {
- element && element.trigger(event, point)
- }
- seriesNS.mixins = {
- chart: {pointTypes: {
- scatter: SYMBOL_POINT,
- line: SYMBOL_POINT,
- spline: SYMBOL_POINT,
- stepline: SYMBOL_POINT,
- stackedline: SYMBOL_POINT,
- fullstackedline: SYMBOL_POINT,
- stackedspline: SYMBOL_POINT,
- fullstackedspline: SYMBOL_POINT,
- stackedsplinearea: SYMBOL_POINT,
- fullstackedsplinearea: SYMBOL_POINT,
- area: SYMBOL_POINT,
- splinearea: SYMBOL_POINT,
- steparea: SYMBOL_POINT,
- stackedarea: SYMBOL_POINT,
- fullstackedarea: SYMBOL_POINT,
- rangearea: "rangeSymbolPoint",
- bar: BAR_POINT,
- stackedbar: BAR_POINT,
- fullstackedbar: BAR_POINT,
- rangebar: "rangeBarPoint",
- bubble: "bubblePoint",
- stock: "stockPoint",
- candlestick: "candlestickPoint"
- }},
- pie: {pointTypes: {
- pie: PIE_POINT,
- doughnut: PIE_POINT,
- donut: PIE_POINT
- }},
- polar: {pointTypes: {
- scatter: POLAR_SYMBOL_POINT,
- line: POLAR_SYMBOL_POINT,
- area: POLAR_SYMBOL_POINT,
- bar: POLAR_BAR_POINT,
- stackedbar: POLAR_BAR_POINT
- }}
- };
- function includePointsMode(mode) {
- return mode === INCLUDE_POINTS || mode === "allseriespoints"
- }
- function Series() {
- this.ctor.apply(this, arguments)
- }
- function applyPointStyle(point, styleName) {
- !point.isSelected() && point.applyStyle(styleName)
- }
- seriesNS.Series = Series;
- Series.prototype = {
- ctor: function(renderSettings, options) {
- var that = this;
- that.fullState = 0;
- that._extGroups = renderSettings;
- that._renderer = renderSettings.renderer;
- that._group = renderSettings.renderer.g().attr({"class": "dxc-series"});
- that.updateOptions(options)
- },
- update: function(data, options) {
- this.updateOptions(options);
- this.updateData(data)
- },
- _createLegendState: _noop,
- getLegendStyles: function() {
- return this._styles.legendStyles
- },
- _createStyles: function(options) {
- var that = this,
- mainSeriesColor = options.mainSeriesColor,
- specialMainColor = that._getSpecialColor(mainSeriesColor);
- that._styles = {
- normal: that._parseStyle(options, mainSeriesColor, mainSeriesColor),
- hover: that._parseStyle(options.hoverStyle || {}, specialMainColor, mainSeriesColor),
- selection: that._parseStyle(options.selectionStyle || {}, specialMainColor, mainSeriesColor),
- legendStyles: {
- normal: that._createLegendState(options, mainSeriesColor),
- hover: that._createLegendState(options.hoverStyle || {}, specialMainColor),
- selection: that._createLegendState(options.selectionStyle || {}, specialMainColor)
- }
- }
- },
- setAdjustSeriesLabels: function(adjustSeriesLabels) {
- _each(this._points || [], function(_, point) {
- point.setAdjustSeriesLabels(adjustSeriesLabels)
- })
- },
- setClippingParams: function(baseId, wideId, forceClipping) {
- this._paneClipRectID = baseId;
- this._widePaneClipRectID = wideId;
- this._forceClipping = forceClipping
- },
- applyClip: function() {
- this._group.attr({clipId: this._paneClipRectID})
- },
- resetClip: function() {
- this._group.attr({clipId: null})
- },
- getTagField: function() {
- return this._options.tagField || "tag"
- },
- getValueFields: _noop,
- getArgumentField: _noop,
- getPoints: function() {
- return this._points
- },
- _createPoint: function(data, pointsArray, index) {
- data.index = index;
- var that = this,
- point = pointsArray[index],
- pointsByArgument = that.pointsByArgument,
- options;
- if (that._checkData(data)) {
- options = that._customizePoint(data) || that._getCreatingPointOptions();
- if (point)
- point.update(data, options);
- else {
- point = core.CoreFactory.createPoint(that, data, options);
- pointsArray.push(point)
- }
- pointsByArgument[point.argument.valueOf()] = pointsByArgument[point.argument.valueOf()] || [];
- pointsByArgument[point.argument.valueOf()].push(point);
- return true
- }
- },
- getRangeData: function(zoomArgs, calcIntervalFunction) {
- return this._visible ? _extend(true, {}, this._getRangeData(zoomArgs, calcIntervalFunction)) : getEmptyBusinessRange()
- },
- _deleteGroup: function(groupName) {
- var group = this[groupName];
- if (group) {
- group.dispose();
- this[groupName] = null
- }
- },
- _saveOldAnimationMethods: function() {
- var that = this;
- that._oldClearingAnimation = that._clearingAnimation;
- that._oldUpdateElement = that._updateElement;
- that._oldgetAffineCoordOptions = that._getAffineCoordOptions
- },
- _deleteOldAnimationMethods: function() {
- this._oldClearingAnimation = null;
- this._oldUpdateElement = null;
- this._oldgetAffineCoordOptions = null
- },
- updateOptions: function(newOptions) {
- var that = this,
- widgetType = newOptions.widgetType,
- oldType = that.type,
- newType = newOptions.type;
- that.type = newType && newType.toString().toLowerCase();
- if (!that._checkType(widgetType) || that._checkPolarBarType(widgetType, newOptions)) {
- that.dispose();
- that.isUpdated = false;
- return
- }
- if (oldType !== that.type) {
- that._firstDrawing = true;
- that._saveOldAnimationMethods();
- that._resetType(oldType, widgetType);
- that._setType(that.type, widgetType)
- }
- that._options = newOptions;
- that._pointOptions = null;
- that._deletePatterns();
- that._patterns = [];
- that.name = newOptions.name;
- that.pane = newOptions.pane;
- that.axis = newOptions.axis;
- that.tag = newOptions.tag;
- that._createStyles(newOptions);
- that._updateOptions(newOptions);
- that._visible = newOptions.visible;
- that.isUpdated = true
- },
- _disposePoints: function(points) {
- _each(points || [], function(_, p) {
- p.dispose()
- })
- },
- _correctPointsLength: function(length, points) {
- this._disposePoints(this._oldPoints);
- this._oldPoints = points.splice(length, points.length)
- },
- _getTicksForAggregation: function(min, max, screenDelta, pointSize) {
- var types = {
- axisType: "continuous",
- dataType: utils.isDate(min) ? "datetime" : "numeric"
- },
- data = {
- min: min,
- max: max,
- screenDelta: screenDelta
- },
- options = {
- gridSpacingFactor: pointSize,
- labelOptions: {},
- stick: true
- },
- tickManager = new viz.core.tickManager.TickManager(types, data, options);
- return {
- ticks: tickManager.getTicks(true),
- tickInterval: tickManager.getTickInterval()
- }
- },
- _getRangeCorrector: _noop,
- updateDataType: function(settings) {
- var that = this;
- that.argumentType = settings.argumentType;
- that.valueType = settings.valueType;
- that.argumentAxisType = settings.argumentAxisType;
- that.valueAxisType = settings.valueAxisType;
- that.showZero = settings.showZero;
- return that
- },
- getOptions: function() {
- return this._options
- },
- _resetRangeData: function() {
- this._rangeData = getEmptyBusinessRange()
- },
- updateData: function(data) {
- var that = this,
- points = that._originalPoints || [],
- lastPointIndex = 0,
- options = that._options,
- pointData,
- rangeCorrector;
- that._rangeErrorBarCorrector = rangeCorrector = that._getRangeCorrector();
- that.pointsByArgument = {};
- that._resetRangeData();
- if (data && data.length)
- that._canRenderCompleteHandle = true;
- that._beginUpdateData(data);
- _each(data, function(_, dataItem) {
- pointData = that._getPointData(dataItem, options);
- if (that._createPoint(pointData, points, lastPointIndex)) {
- that._processRange(points[lastPointIndex], lastPointIndex > 0 ? points[lastPointIndex - 1] : null, rangeCorrector);
- lastPointIndex++
- }
- });
- that._disposePoints(that._aggregatedPoints);
- that._aggregatedPoints = null;
- that._points = that._originalPoints = points;
- that._correctPointsLength(lastPointIndex, points);
- that._endUpdateData()
- },
- getTeamplatedFields: function() {
- var that = this,
- fields = that.getValueFields(),
- teampleteFields = [];
- fields.push(that.getTagField());
- _each(fields, function(_, field) {
- var fieldsObject = {};
- fieldsObject.teamplateField = field + that.name;
- fieldsObject.originalField = field;
- teampleteFields.push(fieldsObject)
- });
- return teampleteFields
- },
- resamplePoints: function(argTranslator, min, max) {
- var that = this,
- originalPoints = that.getAllPoints(),
- minI,
- maxI,
- sizePoint,
- tickObject,
- ticks,
- tickInterval;
- if (originalPoints.length) {
- _each(originalPoints, function(i, point) {
- minI = point.argument - min <= 0 ? i : minI;
- if (!maxI)
- maxI = point.argument - max > 0 ? i : null
- });
- minI = minI ? minI : 1;
- maxI = _isDefined(maxI) ? maxI : originalPoints.length - 1;
- min = originalPoints[minI - 1].argument;
- max = originalPoints[maxI].argument;
- sizePoint = that._getPointSize();
- if (that.argumentAxisType !== "discrete" && that.valueAxisType !== "discrete") {
- tickObject = that._getTicksForAggregation(min, max, argTranslator.canvasLength, sizePoint);
- ticks = tickObject.ticks;
- tickInterval = tickObject.tickInterval;
- if (ticks.length === 1) {
- that._points = originalPoints;
- return
- }
- }
- else
- ticks = argTranslator.canvasLength / sizePoint;
- that._points = that._resample(ticks, tickInterval, argTranslator)
- }
- },
- _removeOldSegments: function(startIndex) {
- var that = this;
- _each(that._graphics.splice(startIndex, that._graphics.length) || [], function(_, elem) {
- that._removeElement(elem)
- });
- if (that._trackers)
- _each(that._trackers.splice(startIndex, that._trackers.length) || [], function(_, elem) {
- elem.remove()
- })
- },
- draw: function(translators, animationEnabled, hideLayoutLabels, legendCallback) {
- var that = this,
- drawComplete;
- if (that._oldClearingAnimation && animationEnabled && that._firstDrawing) {
- drawComplete = function() {
- that._draw(translators, true, hideLayoutLabels)
- };
- that._oldClearingAnimation(translators, drawComplete)
- }
- else
- that._draw(translators, animationEnabled, hideLayoutLabels, legendCallback)
- },
- _clearSeries: function() {
- var that = this;
- that._deleteGroup("_elementsGroup");
- that._deleteGroup("_bordersGroup");
- that._deleteTrackers();
- that._graphics = [];
- that._trackers = []
- },
- _draw: function(translators, animationEnabled, hideLayoutLabels, legendCallback) {
- var that = this,
- points = that._points || [],
- segment = [],
- segmentCount = 0,
- firstDrawing = that._firstDrawing,
- closeSegment = points[0] && points[0].hasValue() && that._options.closed,
- groupForPoint;
- that._graphics = that._graphics || [];
- that._prepareSeriesToDrawing();
- if (!that._visible) {
- animationEnabled = false;
- that._group.remove();
- return
- }
- that._group.append(that._extGroups.seriesGroup);
- that.translators = translators;
- that._createGroups(animationEnabled, undefined, firstDrawing);
- that._segments = [];
- that._drawedPoints = [];
- that._firstDrawing = points.length ? false : true;
- groupForPoint = {
- markers: that._markersGroup,
- labels: that._labelsGroup,
- errorBars: that._errorBarGroup
- };
- _each(points, function(i, p) {
- p.translate(translators);
- if (p.hasValue()) {
- that._drawPoint({
- point: p,
- groups: groupForPoint,
- hasAnimation: animationEnabled,
- firstDrawing: firstDrawing,
- legendCallback: legendCallback
- });
- segment.push(p)
- }
- else if (segment.length) {
- that._drawSegment(segment, animationEnabled, segmentCount++);
- segment = []
- }
- });
- segment.length && that._drawSegment(segment, animationEnabled, segmentCount++, closeSegment);
- that._removeOldSegments(segmentCount);
- that._defaultSegments = that._generateDefaultSegments();
- hideLayoutLabels && that.hideLabels();
- animationEnabled && that._animate(firstDrawing);
- if (that.isSelected())
- that._changeStyle(legendCallback, APPLY_SELECTED);
- else if (that.isHovered())
- that._changeStyle(legendCallback, APPLY_HOVER)
- },
- _checkType: function(widgetType) {
- return !!seriesNS.mixins[widgetType][this.type]
- },
- _checkPolarBarType: function(widgetType, options) {
- return widgetType === "polar" && options.spiderWidget && this.type.indexOf("bar") !== -1
- },
- _resetType: function(seriesType, widgetType) {
- var that = this;
- if (seriesType)
- _each(seriesNS.mixins[widgetType][seriesType], function(methodName) {
- delete that[methodName]
- })
- },
- _setType: function(seriesType, widgetType) {
- var that = this;
- _each(seriesNS.mixins[widgetType][seriesType], function(methodName, method) {
- that[methodName] = method
- })
- },
- setSelectedState: function(state, mode, legendCallback) {
- var that = this;
- that.lastSelectionMode = (mode || that._options.selectionMode).toLowerCase();
- if (state && !that.isSelected()) {
- that.fullState = that.fullState | SELECTED_STATE;
- that._nearestPoint && applyPointStyle(that._nearestPoint, "normal");
- that._nearestPoint = null;
- that._changeStyle(legendCallback, APPLY_SELECTED)
- }
- else if (!state && that.isSelected()) {
- that.fullState = that.fullState & ~SELECTED_STATE;
- if (that.isHovered())
- that._changeStyle(legendCallback, APPLY_HOVER, SELECTION);
- else
- that._changeStyle(legendCallback, "resetItem")
- }
- },
- setHoverState: function(state, mode, legendCallback) {
- var that = this;
- that.lastHoverMode = (mode || that._options.hoverMode).toLowerCase();
- if (state && !that.isHovered()) {
- that.fullState = that.fullState | HOVER_STATE;
- !that.isSelected() && that._changeStyle(legendCallback, APPLY_HOVER)
- }
- else if (!state && that.isHovered()) {
- that._nearestPoint = null;
- that.fullState = that.fullState & ~HOVER_STATE;
- !that.isSelected() && that._changeStyle(legendCallback, "resetItem")
- }
- },
- isFullStackedSeries: function() {
- return this.type.indexOf("fullstacked") === 0
- },
- isStackedSeries: function() {
- return this.type.indexOf("stacked") === 0
- },
- isFinancialSeries: function() {
- return this.type === "stock" || this.type === "candlestick"
- },
- _changeStyle: function(legendCallBack, legendAction, prevStyle) {
- var that = this,
- style = that._calcStyle(prevStyle),
- pointStyle;
- if (style.mode === NONE_MODE)
- return;
- legendCallBack && legendCallBack(legendAction);
- if (includePointsMode(style.mode)) {
- pointStyle = style.pointStyle;
- _each(that._points || [], function(_, p) {
- applyPointStyle(p, pointStyle)
- })
- }
- that._applyStyle(style.series)
- },
- _calcStyle: function(prevStyle) {
- var that = this,
- styles = that._styles,
- pointNormalState = false,
- result;
- switch (that.fullState & 3) {
- case 0:
- result = {
- pointStyle: NORMAL,
- mode: INCLUDE_POINTS,
- series: styles.normal
- };
- break;
- case 1:
- pointNormalState = prevStyle === SELECTION && that.lastHoverMode === EXLUDE_POINTS || that.lastHoverMode === NEAREST_POINT && includePointsMode(that.lastSelectionMode);
- result = {
- pointStyle: pointNormalState ? NORMAL : HOVER,
- mode: pointNormalState ? INCLUDE_POINTS : that.lastHoverMode,
- series: styles.hover
- };
- break;
- case 2:
- result = {
- pointStyle: SELECTION,
- mode: that.lastSelectionMode,
- series: styles.selection
- };
- break;
- case 3:
- pointNormalState = that.lastSelectionMode === EXLUDE_POINTS && includePointsMode(that.lastHoverMode);
- result = {
- pointStyle: pointNormalState ? NORMAL : SELECTION,
- mode: pointNormalState ? INCLUDE_POINTS : that.lastSelectionMode,
- series: styles.selection
- }
- }
- return result
- },
- updateHover: function(x, y) {
- var that = this,
- currentNearestPoint = that._nearestPoint,
- point = that.isHovered() && that.lastHoverMode === NEAREST_POINT && that.getNeighborPoint(x, y);
- if (point !== currentNearestPoint && !that.isSelected()) {
- currentNearestPoint && applyPointStyle(currentNearestPoint, "normal");
- if (point) {
- applyPointStyle(point, "hover");
- that._nearestPoint = point
- }
- }
- },
- _getMainAxisName: function() {
- return this._options.rotated ? "X" : "Y"
- },
- areLabelsVisible: function() {
- return !_isDefined(this._options.maxLabelCount) || this._points.length <= this._options.maxLabelCount
- },
- getLabelVisibility: function() {
- return this.areLabelsVisible() && this._options.label && this._options.label.visible
- },
- _customizePoint: function(pointData) {
- var that = this,
- options = that._options,
- customizePoint = options.customizePoint,
- customizeObject,
- pointOptions,
- customLabelOptions,
- customOptions,
- customizeLabel = options.customizeLabel,
- useLabelCustomOptions,
- usePointCustomOptions;
- if (customizeLabel && customizeLabel.call) {
- customizeObject = _extend({seriesName: that.name}, pointData);
- customizeObject.series = that;
- customLabelOptions = customizeLabel.call(customizeObject, customizeObject);
- useLabelCustomOptions = customLabelOptions && !_isEmptyObject(customLabelOptions);
- customLabelOptions = useLabelCustomOptions ? _extend(true, {}, options.label, customLabelOptions) : null
- }
- if (customizePoint && customizePoint.call) {
- customizeObject = customizeObject || _extend({seriesName: that.name}, pointData);
- customizeObject.series = that;
- customOptions = customizePoint.call(customizeObject, customizeObject);
- usePointCustomOptions = customOptions && !_isEmptyObject(customOptions)
- }
- if (useLabelCustomOptions || usePointCustomOptions) {
- pointOptions = that._parsePointOptions(that._preparePointOptions(customOptions), customLabelOptions || options.label, true);
- pointOptions.styles.useLabelCustomOptions = useLabelCustomOptions;
- pointOptions.styles.usePointCustomOptions = usePointCustomOptions
- }
- return pointOptions
- },
- _getLabelOptions: function(labelOptions, defaultColor) {
- var opt = labelOptions || {},
- labelFont = opt.font || {},
- labelBorder = opt.border || {},
- labelConnector = opt.connector || {},
- labelAttributes = {font: {
- color: opt.backgroundColor === "none" && labelFont.color.toLowerCase() === "#ffffff" && opt.position !== "inside" ? defaultColor : labelFont.color,
- family: labelFont.family,
- weight: labelFont.weight,
- size: labelFont.size,
- opacity: labelFont.opacity
- }},
- backgroundAttr = {
- fill: opt.backgroundColor || defaultColor,
- "stroke-width": labelBorder.visible ? labelBorder.width || 0 : 0,
- stroke: labelBorder.visible && labelBorder.width ? labelBorder.color : "none",
- dashStyle: labelBorder.dashStyle
- },
- connectorAttr = {
- stroke: labelConnector.visible && labelConnector.width ? labelConnector.color || defaultColor : "none",
- "stroke-width": labelConnector.visible ? labelConnector.width || 0 : 0
- };
- return {
- alignment: opt.alignment,
- format: opt.format,
- argumentFormat: opt.argumentFormat,
- precision: opt.precision,
- argumentPrecision: opt.argumentPrecision,
- percentPrecision: opt.percentPrecision,
- customizeText: $.isFunction(opt.customizeText) ? opt.customizeText : undefined,
- attributes: labelAttributes,
- visible: labelFont.size !== 0 ? opt.visible : false,
- showForZeroValues: opt.showForZeroValues,
- horizontalOffset: opt.horizontalOffset,
- verticalOffset: opt.verticalOffset,
- radialOffset: opt.radialOffset,
- background: backgroundAttr,
- position: opt.position,
- connector: connectorAttr,
- rotationAngle: opt.rotationAngle
- }
- },
- show: function() {
- if (!this._visible)
- this._changeVisibility(true)
- },
- hide: function() {
- if (this._visible)
- this._changeVisibility(false)
- },
- _changeVisibility: function(visibility) {
- var that = this;
- that._visible = that._options.visible = visibility;
- that._updatePointsVisibility();
- that.hidePointTooltip();
- that._options.visibilityChanged()
- },
- _updatePointsVisibility: $.noop,
- hideLabels: function() {
- _each(this._points, function(_, point) {
- point._label.hide()
- })
- },
- _parsePointOptions: function(pointOptions, labelOptions, isCustomPointOptions) {
- var that = this,
- options = that._options,
- styles = that._createPointStyles(pointOptions, isCustomPointOptions),
- parsedOptions = _extend(true, {}, pointOptions, {
- type: options.type,
- tag: that.tag,
- rotated: options.rotated,
- styles: styles,
- widgetType: options.widgetType,
- visibilityChanged: options.visibilityChanged
- });
- parsedOptions.label = that._getLabelOptions(labelOptions, styles.normal.fill);
- parsedOptions.errorBars = options.valueErrorBar;
- return parsedOptions
- },
- _resample: function(ticks, ticksInterval, argTranslator) {
- var that = this,
- fusPoints = [],
- arrayFusPoints,
- nowIndexTicks = 0,
- lastPointIndex = 0,
- originalPoints = that.getAllPoints(),
- visibleArea;
- if (that.argumentAxisType === "discrete" || that.valueAxisType === "discrete") {
- visibleArea = argTranslator.getCanvasVisibleArea();
- originalPoints = $.map(originalPoints, function(p) {
- var pos = argTranslator.translate(p.argument),
- result;
- if (pos >= visibleArea.min && pos <= visibleArea.max)
- result = p;
- else {
- p.setInvisibility();
- result = null
- }
- return result
- });
- ticksInterval = originalPoints.length / ticks;
- arrayFusPoints = $.map(originalPoints, function(point, index) {
- if (Math.floor(nowIndexTicks) <= index) {
- nowIndexTicks += ticksInterval;
- return point
- }
- point.setInvisibility();
- return null
- });
- return arrayFusPoints
- }
- that._aggregatedPoints = that._aggregatedPoints || [];
- _each(originalPoints, function(_, point) {
- point.setInvisibility();
- switch (that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval)) {
- case true:
- fusPoints.push(point);
- break;
- case"nextInterval":
- var pointData = that._fusionPoints(fusPoints, ticks[nowIndexTicks], nowIndexTicks);
- while (that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval) === "nextInterval")
- nowIndexTicks++;
- fusPoints = [];
- that._isInInterval(point.argument, ticks, nowIndexTicks, ticksInterval) === true && fusPoints.push(point);
- if (that._createPoint(pointData, that._aggregatedPoints, lastPointIndex))
- lastPointIndex++
- }
- });
- if (fusPoints.length) {
- var pointData = that._fusionPoints(fusPoints, ticks[nowIndexTicks], nowIndexTicks);
- if (that._createPoint(pointData, that._aggregatedPoints, lastPointIndex))
- lastPointIndex++
- }
- that._correctPointsLength(lastPointIndex, that._aggregatedPoints);
- that._endUpdateData();
- return that._aggregatedPoints
- },
- _isInInterval: function(argument, ticks, nowIndexTicks, ticksInterval) {
- var minTick = ticks[nowIndexTicks],
- maxTick = ticks[nowIndexTicks + 1],
- sumMinTickTicksInterval;
- ticksInterval = $.isNumeric(ticksInterval) ? ticksInterval : utils.dateToMilliseconds(ticksInterval);
- sumMinTickTicksInterval = utils.isDate(minTick) ? new Date(minTick.getTime() + ticksInterval) : minTick + ticksInterval;
- if (argument >= minTick && argument < sumMinTickTicksInterval)
- return true;
- if (argument < minTick || maxTick === undefined)
- return false;
- return "nextInterval"
- },
- canRenderCompleteHandle: function() {
- var result = this._canRenderCompleteHandle;
- delete this._canRenderCompleteHandle;
- return !!result
- },
- isHovered: function() {
- return !!(this.fullState & 1)
- },
- isSelected: function() {
- return !!(this.fullState & 2)
- },
- isVisible: function() {
- return this._visible
- },
- getAllPoints: function() {
- return (this._originalPoints || []).slice()
- },
- getPointByPos: function(pos) {
- return (this._points || [])[pos]
- },
- getVisiblePoints: function() {
- return (this._drawedPoints || []).slice()
- },
- setPointHoverState: function(point, legendCallback) {
- point.fullState = point.fullState | HOVER_STATE;
- if (!(this.isSelected() && includePointsMode(this.lastSelectionMode)) && !point.isSelected()) {
- point.applyStyle(HOVER);
- legendCallback && legendCallback("applyHover")
- }
- },
- releasePointHoverState: function(point, legendCallback) {
- var that = this;
- point.fullState = point.fullState & ~HOVER_STATE;
- if (!(that.isSelected() && includePointsMode(that.lastSelectionMode)) && !point.isSelected())
- if (!(that.isHovered() && includePointsMode(that.lastHoverMode)) || that.isSelected() && that.lastSelectionMode === EXLUDE_POINTS) {
- point.applyStyle(NORMAL);
- legendCallback && legendCallback("resetItem")
- }
- },
- setPointSelectedState: function(point, legendCallback) {
- point.fullState = point.fullState | SELECTED_STATE;
- point.applyStyle(SELECTION);
- legendCallback && legendCallback("applySelected")
- },
- releasePointSelectedState: function(point, legendCallback) {
- var that = this;
- point.fullState = point.fullState & ~SELECTED_STATE;
- if (that.isHovered() && includePointsMode(that.lastHoverMode) || point.isHovered()) {
- point.applyStyle(HOVER);
- legendCallback && legendCallback("applyHover")
- }
- else if (that.isSelected() && includePointsMode(that.lastSelectionMode)) {
- point.applyStyle(SELECTION);
- legendCallback && legendCallback("applySelected")
- }
- else {
- point.applyStyle(NORMAL);
- legendCallback && legendCallback("resetItem")
- }
- },
- selectPoint: function(point) {
- triggerEvent(this._extGroups.seriesGroup, new _Event("selectpoint"), point)
- },
- deselectPoint: function(point) {
- triggerEvent(this._extGroups.seriesGroup, new _Event("deselectpoint"), point)
- },
- showPointTooltip: function(point) {
- triggerEvent(this._extGroups.seriesGroup, new _Event("showpointtooltip"), point)
- },
- hidePointTooltip: function(point) {
- triggerEvent(this._extGroups.seriesGroup, new _Event("hidepointtooltip"), point)
- },
- select: function() {
- var that = this;
- triggerEvent(that._extGroups.seriesGroup, new _Event("selectseries", {target: that}), that._options.selectionMode);
- that._group.toForeground()
- },
- clearSelection: function clearSelection() {
- var that = this;
- triggerEvent(that._extGroups.seriesGroup, new _Event("deselectseries", {target: that}), that._options.selectionMode)
- },
- getPointByArg: function(arg) {
- return this.getPointsByArg(arg)[0] || null
- },
- getPointsByArg: function(arg) {
- return this.pointsByArgument[arg.valueOf()] || []
- },
- _deletePoints: function() {
- var that = this;
- that._disposePoints(that._originalPoints);
- that._disposePoints(that._aggregatedPoints);
- that._disposePoints(that._oldPoints);
- that._points = null;
- that._oldPoints = null;
- that._aggregatedPoints = null;
- that._originalPoints = null;
- that._drawedPoints = null
- },
- _deletePatterns: function() {
- _each(this._patterns || [], function(_, pattern) {
- pattern && pattern.dispose()
- });
- this._patterns = null
- },
- _deleteTrackers: function() {
- var that = this;
- _each(that._trackers || [], function(_, tracker) {
- tracker.remove()
- });
- that._trackersGroup && that._trackersGroup.dispose();
- that._trackers = that._trackersGroup = null
- },
- dispose: function() {
- var that = this;
- that._deletePoints();
- that._group.dispose();
- that._labelsGroup && that._labelsGroup.dispose();
- that._errorBarGroup && that._errorBarGroup.dispose();
- that._deletePatterns();
- that._deleteTrackers();
- that._group = that._extGroups = that._markersGroup = that._elementsGroup = that._bordersGroup = that._labelsGroup = that._errorBarGroup = that._graphics = that._rangeData = that._renderer = that.translators = that._styles = that._options = that._pointOptions = that._drawedPoints = that._aggregatedPoints = that.pointsByArgument = that._segments = that._prevSeries = null
- },
- correctPosition: _noop,
- drawTrackers: _noop,
- getNeighborPoint: _noop,
- areErrorBarsVisible: _noop,
- getColor: function() {
- return this.getLegendStyles().normal.fill
- },
- getOpacity: function() {
- return this._options.opacity
- },
- getStackName: function() {
- return this.type === "stackedbar" || this.type === "fullstackedbar" ? this._stackName : null
- },
- getPointByCoord: function(x, y) {
- var point = this.getNeighborPoint(x, y);
- return point && point.coordsIn(x, y) ? point : null
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeDataCalculator.js */
- (function($, DX, undefined) {
- var _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _max = _math.max,
- _each = $.each,
- _isEmptyObject = $.isEmptyObject,
- _isDefined = DX.utils.isDefined,
- _isFinite = isFinite,
- MIN_VISIBLE = "minVisible",
- MAX_VISIBLE = "maxVisible",
- DISCRETE = "discrete";
- function _truncateValue(data, value) {
- var min = data.min,
- max = data.max;
- data.min = value < min || !_isDefined(min) ? value : min;
- data.max = value > max || !_isDefined(max) ? value : max
- }
- function _processValue(series, type, value, prevValue, calcInterval) {
- var axis = type === "arg" ? "argument" : "value",
- data = series._rangeData[type],
- minInterval = data.interval,
- interval;
- if (series[axis + "AxisType"] === DISCRETE) {
- data.categories = data.categories || [];
- data.categories.push(value)
- }
- else {
- _truncateValue(data, value);
- if (type === "arg") {
- interval = (_isDefined(prevValue) ? _abs(calcInterval ? calcInterval(value, prevValue) : value - prevValue) : interval) || minInterval;
- data.interval = _isDefined(interval) && (interval < minInterval || !_isDefined(minInterval)) ? interval : minInterval
- }
- }
- }
- function _addToVisibleRange(series, value) {
- var data = series._rangeData.val,
- isDiscrete = series.valueAxisType === DISCRETE;
- if (!isDiscrete) {
- if (value < data.minVisible || !_isDefined(data.minVisible))
- data.minVisible = value;
- if (value > data.maxVisible || !_isDefined(data.maxVisible))
- data.maxVisible = value
- }
- }
- function _processRangeValue(series, val, minVal) {
- var data = series._rangeData.val;
- if (series.valueAxisType === DISCRETE) {
- data.categories = data.categories || [];
- data.categories.push(val, minVal)
- }
- else {
- _truncateValue(data, val);
- _truncateValue(data, minVal)
- }
- }
- function _unique(array) {
- var values = {};
- return $.map(array, function(item) {
- var result = !values[item] ? item : null;
- values[item] = true;
- return result
- })
- }
- function _processZoomArgument(series, zoomArgs, isDiscrete) {
- var data = series._rangeData.arg,
- minArg,
- maxArg;
- if (isDiscrete) {
- data.minVisible = zoomArgs.minArg;
- data.maxVisible = zoomArgs.maxArg;
- return
- }
- minArg = zoomArgs.minArg < zoomArgs.maxArg ? zoomArgs.minArg : zoomArgs.maxArg;
- maxArg = zoomArgs.maxArg > zoomArgs.minArg ? zoomArgs.maxArg : zoomArgs.minArg;
- data.min = minArg < data.min ? minArg : data.min;
- data.max = maxArg > data.max ? maxArg : data.max;
- data.minVisible = minArg;
- data.maxVisible = maxArg
- }
- function _correctZoomValue(series, zoomArgs) {
- var minVal,
- maxVal;
- if (_isDefined(zoomArgs.minVal) && _isDefined(zoomArgs.maxVal)) {
- minVal = zoomArgs.minVal < zoomArgs.maxVal ? zoomArgs.minVal : zoomArgs.maxVal;
- maxVal = zoomArgs.maxVal > zoomArgs.minVal ? zoomArgs.maxVal : zoomArgs.minVal
- }
- if (_isDefined(zoomArgs.minVal)) {
- series._rangeData.val.min = minVal < series._rangeData.val.min ? minVal : series._rangeData.val.min;
- series._rangeData.val.minVisible = minVal
- }
- if (_isDefined(zoomArgs.maxVal)) {
- series._rangeData.val.max = maxVal > series._rangeData.val.max ? maxVal : series._rangeData.val.max;
- series._rangeData.val.maxVisible = maxVal
- }
- }
- function _processZoomValue(series, zoomArgs) {
- var adjustOnZoom = zoomArgs.adjustOnZoom,
- points = series._points || [],
- lastVisibleIndex,
- prevPointAdded = false,
- rangeData = series._rangeData,
- errorBarCorrector = series._rangeErrorBarCorrector;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null;
- if (adjustOnZoom && series.argumentAxisType !== DISCRETE && arg >= rangeData.arg.minVisible && arg <= rangeData.arg.maxVisible) {
- if (!prevPointAdded) {
- if (prevPoint && prevPoint.hasValue()) {
- _addToVisibleRange(series, prevPoint.value);
- _correctMinMaxByErrorBar(rangeData.val, prevPoint, errorBarCorrector, MIN_VISIBLE, MAX_VISIBLE)
- }
- prevPointAdded = true
- }
- if (point.hasValue()) {
- _addToVisibleRange(series, point.value);
- _correctMinMaxByErrorBar(rangeData.val, point, errorBarCorrector, MIN_VISIBLE, MAX_VISIBLE)
- }
- lastVisibleIndex = index
- }
- });
- if (_isDefined(lastVisibleIndex) && lastVisibleIndex < points.length - 1 && points[lastVisibleIndex + 1].hasValue())
- _addToVisibleRange(series, points[lastVisibleIndex + 1].value);
- _correctZoomValue(series, zoomArgs)
- }
- function _processZoomRangeValue(series, zoomArgs, maxValueName, minValueName) {
- var adjustOnZoom = zoomArgs.adjustOnZoom,
- points = series._points || [],
- argRangeData = series._rangeData.arg,
- lastVisibleIndex,
- prevPointAdded = false;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null;
- if (adjustOnZoom && series.argumentAxisType !== DISCRETE && arg >= argRangeData.minVisible && arg <= argRangeData.maxVisible) {
- if (!prevPointAdded) {
- if (prevPoint && prevPoint.hasValue()) {
- _addToVisibleRange(series, prevPoint[maxValueName]);
- _addToVisibleRange(series, prevPoint[minValueName])
- }
- prevPointAdded = true
- }
- if (point.hasValue()) {
- _addToVisibleRange(series, point[maxValueName]);
- _addToVisibleRange(series, point[minValueName])
- }
- lastVisibleIndex = index
- }
- });
- if (_isDefined(lastVisibleIndex) && lastVisibleIndex < points.length - 1 && points[lastVisibleIndex + 1].hasValue())
- _addToVisibleRange(series, points[lastVisibleIndex + 1].value);
- _correctZoomValue(series, zoomArgs)
- }
- function _processNewInterval(series, calcInterval) {
- var data = series._rangeData,
- points = series._points || [],
- isArgumentAxisDiscrete = series.argumentAxisType === DISCRETE;
- delete data.arg.interval;
- _each(points, function(index, point) {
- var arg = point.argument,
- prevPoint = index > 0 ? points[index - 1] : null,
- prevArg = prevPoint && prevPoint.argument;
- !isArgumentAxisDiscrete && _processValue(series, "arg", arg, prevArg, calcInterval)
- })
- }
- function _fillRangeData(series) {
- var data = series._rangeData;
- data.arg.categories && (data.arg.categories = _unique(data.arg.categories));
- data.val.categories && (data.val.categories = _unique(data.val.categories));
- data.arg.axisType = series.argumentAxisType;
- data.arg.dataType = series.argumentType;
- data.val.axisType = series.valueAxisType;
- data.val.dataType = series.valueType;
- data.val.isValueRange = true
- }
- function processTwoValues(series, point, prevPoint, highValueName, lowValueName) {
- var val = point[highValueName],
- minVal = point[lowValueName],
- arg = point.argument,
- prevVal = prevPoint && prevPoint[highValueName],
- prevMinVal = prevPoint && prevPoint[lowValueName],
- prevArg = prevPoint && prevPoint.argument;
- point.hasValue() && _processRangeValue(series, val, minVal, prevVal, prevMinVal);
- _processValue(series, "arg", arg, prevArg)
- }
- function calculateRangeMinValue(series, zoomArgs) {
- var data = series._rangeData.val,
- minVisible = data[MIN_VISIBLE],
- maxVisible = data[MAX_VISIBLE];
- zoomArgs = zoomArgs || {};
- if (data)
- if (series.valueAxisType !== "logarithmic" && series.valueType !== "datetime" && series.showZero !== false) {
- data[MIN_VISIBLE] = minVisible > (zoomArgs.minVal || 0) ? zoomArgs.minVal || 0 : minVisible;
- data[MAX_VISIBLE] = maxVisible < (zoomArgs.maxVal || 0) ? zoomArgs.maxVal || 0 : maxVisible;
- data.min = data.min > 0 ? 0 : data.min;
- data.max = data.max < 0 ? 0 : data.max
- }
- }
- function processFullStackedRange(series) {
- var data = series._rangeData.val,
- isRangeEmpty = _isEmptyObject(data);
- data.percentStick = true;
- !isRangeEmpty && (data.min = 0)
- }
- function _correctMinMaxByErrorBar(data, point, getMinMaxCorrector, minSelector, maxSelector) {
- if (!getMinMaxCorrector)
- return;
- var correctionData = getMinMaxCorrector(point),
- minError = _min.apply(undefined, correctionData),
- maxError = _max.apply(undefined, correctionData);
- if (_isFinite(minError) && data[minSelector] > minError)
- data[minSelector] = minError;
- if (_isFinite(maxError) && data[maxSelector] < maxError)
- data[maxSelector] = maxError
- }
- function processRange(series, point, prevPoint, getMinMaxCorrector) {
- var val = point.value,
- arg = point.argument,
- prevVal = prevPoint && prevPoint.value,
- prevArg = prevPoint && prevPoint.argument;
- point.hasValue() && _processValue(series, "val", val, prevVal);
- _processValue(series, "arg", arg, prevArg);
- _correctMinMaxByErrorBar(series._rangeData.val, point, getMinMaxCorrector, "min", "max")
- }
- function addLabelPaddings(series) {
- var labelOptions = series.getOptions().label,
- valueData;
- if (series.areLabelsVisible() && labelOptions && labelOptions.visible && labelOptions.position !== "inside") {
- valueData = series._rangeData.val;
- if (valueData.min < 0)
- valueData.minSpaceCorrection = true;
- if (valueData.max > 0)
- valueData.maxSpaceCorrection = true
- }
- }
- function addRangeSeriesLabelPaddings(series) {
- var data = series._rangeData.val;
- if (series.areLabelsVisible() && series._options.label.visible && series._options.label.position !== "inside")
- data.minSpaceCorrection = data.maxSpaceCorrection = true
- }
- function calculateRangeData(series, zoomArgs, calcIntervalFunction, maxValueName, minValueName) {
- var valueData = series._rangeData.val,
- isRangeSeries = !!maxValueName && !!minValueName,
- isDiscrete = series.argumentAxisType === DISCRETE;
- if (zoomArgs && _isDefined(zoomArgs.minArg) && _isDefined(zoomArgs.maxArg)) {
- if (!isDiscrete) {
- valueData[MIN_VISIBLE] = zoomArgs.minVal;
- valueData[MAX_VISIBLE] = zoomArgs.maxVal
- }
- _processZoomArgument(series, zoomArgs, isDiscrete);
- if (isRangeSeries)
- _processZoomRangeValue(series, zoomArgs, maxValueName, minValueName);
- else
- _processZoomValue(series, zoomArgs)
- }
- else if (!zoomArgs && calcIntervalFunction)
- _processNewInterval(series, calcIntervalFunction);
- _fillRangeData(series)
- }
- DX.viz.core.series.helpers.rangeDataCalculator = {
- processRange: processRange,
- calculateRangeData: calculateRangeData,
- addLabelPaddings: addLabelPaddings,
- addRangeSeriesLabelPaddings: addRangeSeriesLabelPaddings,
- processFullStackedRange: processFullStackedRange,
- calculateRangeMinValue: calculateRangeMinValue,
- processTwoValues: processTwoValues
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file scatterSeries.js */
- (function($, DX) {
- var series = DX.viz.core.series,
- rangeCalculator = series.helpers.rangeDataCalculator,
- chartSeries = series.mixins.chart,
- _each = $.each,
- _extend = $.extend,
- _map = $.map,
- _noop = $.noop,
- _utils = DX.utils,
- _isDefined = _utils.isDefined,
- _isString = _utils.isString,
- math = Math,
- _floor = math.floor,
- _abs = math.abs,
- _sqrt = math.sqrt,
- _min = math.min,
- _max = math.max,
- DEFAULT_SYMBOL_POINT_SIZE = 2,
- DEFAULT_TRACKER_WIDTH = 20,
- DEFAULT_DURATION = 400,
- HIGH_ERROR = "highError",
- LOW_ERROR = "lowError",
- ORIGINAL = "original",
- VARIANCE = "variance",
- STANDARD_DEVIATION = "stddeviation",
- STANDARD_ERROR = "stderror",
- PERCENT = "percent",
- FIXED = "fixed",
- UNDEFINED = "undefined",
- DISCRETE = "discrete",
- LOGARITHMIC = "logarithmic",
- DATETIME = "datetime";
- function sum(array) {
- var summa = 0;
- _each(array, function(_, value) {
- summa += value
- });
- return summa
- }
- function toLowerCase(value) {
- return value.toLowerCase()
- }
- function isErrorBarTypeCorrect(type) {
- return $.inArray(type, [FIXED, PERCENT, VARIANCE, STANDARD_DEVIATION, STANDARD_ERROR, UNDEFINED]) !== -1
- }
- function variance(array, expectedValue) {
- return sum($.map(array, function(value) {
- return (value - expectedValue) * (value - expectedValue)
- })) / array.length
- }
- var baseScatterMethods = {
- _defaultDuration: DEFAULT_DURATION,
- _defaultTrackerWidth: DEFAULT_TRACKER_WIDTH,
- _applyStyle: _noop,
- _updateOptions: _noop,
- _parseStyle: _noop,
- _prepareSegment: _noop,
- _drawSegment: _noop,
- _generateDefaultSegments: _noop,
- _prepareSeriesToDrawing: function() {
- var that = this;
- that._deleteOldAnimationMethods();
- that._firstDrawing && that._clearSeries();
- that._disposePoints(that._oldPoints);
- that._oldPoints = null
- },
- _createLegendState: function(styleOptions, defaultColor) {
- return {
- fill: styleOptions.color || defaultColor,
- hatching: styleOptions.hatching
- }
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options;
- options.valueField = that.getValueFields()[0] + that.name;
- options.tagField = that.getTagField() + that.name
- },
- _applyElementsClipRect: function(settings) {
- settings.clipId = this._paneClipRectID
- },
- _applyMarkerClipRect: function(settings) {
- settings.clipId = this._forceClipping ? this._paneClipRectID : null
- },
- _createGroup: function(groupName, parent, target, settings) {
- var group = parent[groupName] = parent[groupName] || this._renderer.g();
- group.attr(settings).append(target)
- },
- _applyClearingSettings: function(settings) {
- settings.opacity = null;
- settings.scale = null;
- if (this._options.rotated)
- settings.translateX = null;
- else
- settings.translateY = null
- },
- _createMarkerGroup: function() {
- var that = this,
- settings = that._getPointOptions().styles.normal;
- settings["class"] = "dxc-markers";
- settings.opacity = 1;
- that._applyMarkerClipRect(settings);
- that._createGroup("_markersGroup", that, that._group, settings)
- },
- _createLabelGroup: function() {
- var that = this,
- settings = {
- "class": "dxc-labels",
- visibility: that.getLabelVisibility() ? "visible" : "hidden"
- };
- that._applyElementsClipRect(settings);
- that._applyClearingSettings(settings);
- that._createGroup("_labelsGroup", that, that._extGroups.labelsGroup, settings)
- },
- areErrorBarsVisible: function() {
- var errorBarOptions = this._options.valueErrorBar || {};
- return this._errorBarsEnabled() && errorBarOptions.displayMode !== "none" && (isErrorBarTypeCorrect(toLowerCase(errorBarOptions.type + "")) || _isDefined(errorBarOptions.lowValueField) || _isDefined(errorBarOptions.highValueField))
- },
- _createErrorBarGroup: function(animationEnabled) {
- var that = this,
- errorBarOptions = that._options.valueErrorBar || {},
- settings;
- if (that.areErrorBarsVisible()) {
- settings = {
- "class": "dxc-error-bars",
- stroke: errorBarOptions.color,
- 'stroke-width': errorBarOptions.lineWidth,
- opacity: animationEnabled ? 0.001 : errorBarOptions.opacity || 1,
- "stroke-linecap": "square",
- sharp: true,
- clipId: that._forceClipping ? that._paneClipRectID : that._widePaneClipRectID
- };
- that._createGroup("_errorBarGroup", that, that._group, settings)
- }
- },
- _createGroups: function(animationEnabled) {
- var that = this;
- that._createMarkerGroup();
- that._createLabelGroup();
- that._createErrorBarGroup(animationEnabled);
- animationEnabled && that._labelsGroup && that._labelsGroup.attr({opacity: 0.001})
- },
- _getCreatingPointOptions: function() {
- var that = this,
- defaultPointOptions,
- creatingPointOptions = that._predefinedPointOptions,
- normalStyle;
- if (!creatingPointOptions) {
- defaultPointOptions = that._getPointOptions();
- that._predefinedPointOptions = creatingPointOptions = _extend(true, {styles: {}}, defaultPointOptions);
- normalStyle = defaultPointOptions.styles && defaultPointOptions.styles.normal || {};
- creatingPointOptions.styles = creatingPointOptions.styles || {};
- creatingPointOptions.styles.normal = {
- "stroke-width": normalStyle["stroke-width"],
- r: normalStyle.r,
- opacity: normalStyle.opacity
- }
- }
- return creatingPointOptions
- },
- _getSpecialColor: function(mainSeriesColor) {
- return mainSeriesColor
- },
- _getPointOptions: function() {
- return this._parsePointOptions(this._preparePointOptions(), this._options.label)
- },
- _preparePointOptions: function(customOptions) {
- var point = this._options.point;
- return customOptions ? _extend(true, {}, point, customOptions) : point
- },
- _parsePointStyle: function(style, defaultColor, defaultBorderColor) {
- var border = style.border || {};
- return {
- fill: style.color || defaultColor,
- stroke: border.color || defaultBorderColor,
- "stroke-width": border.visible ? border.width : 0,
- r: style.size / 2 + (border.visible && style.size !== 0 ? ~~(border.width / 2) || 0 : 0)
- }
- },
- _createPointStyles: function(pointOptions) {
- var that = this,
- mainPointColor = pointOptions.color || that._options.mainSeriesColor,
- containerColor = that._options.containerBackgroundColor,
- normalStyle = that._parsePointStyle(pointOptions, mainPointColor, mainPointColor);
- normalStyle.visibility = pointOptions.visible ? "visible" : "hidden";
- return {
- normal: normalStyle,
- hover: that._parsePointStyle(pointOptions.hoverStyle, containerColor, mainPointColor),
- selection: that._parsePointStyle(pointOptions.selectionStyle, containerColor, mainPointColor)
- }
- },
- _checkData: function(data) {
- return _isDefined(data.argument) && data.value !== undefined
- },
- _getRangeCorrector: function() {
- var errorBars = this.getOptions().valueErrorBar || {},
- mode = toLowerCase(errorBars.displayMode + "");
- return errorBars ? function(point) {
- var lowError = point.lowError,
- highError = point.highError;
- switch (mode) {
- case"low":
- return [lowError];
- case"high":
- return [highError];
- case"none":
- return [];
- default:
- return [lowError, highError]
- }
- } : undefined
- },
- _processRange: function(point, prevPoint, errorBarCorrector) {
- rangeCalculator.processRange(this, point, prevPoint, errorBarCorrector)
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- var pointData = {
- value: data[options.valueField || "val"],
- argument: data[options.argumentField || "arg"],
- tag: data[options.tagField || "tag"]
- };
- this._fillErrorBars(data, pointData, options);
- return pointData
- },
- _errorBarsEnabled: function() {
- return this.valueAxisType !== DISCRETE && this.valueAxisType !== LOGARITHMIC && this.valueType !== DATETIME
- },
- _fillErrorBars: function(data, pointData, options) {
- var errorBars = options.valueErrorBar || {};
- if (this._errorBarsEnabled()) {
- pointData.lowError = data[errorBars.lowValueField || LOW_ERROR];
- pointData.highError = data[errorBars.highValueField || HIGH_ERROR]
- }
- },
- _drawPoint: function(options) {
- var point = options.point;
- if (point.isInVisibleArea()) {
- point.clearVisibility();
- point.draw(this._renderer, options.groups, options.hasAnimation, options.firstDrawing);
- this._drawedPoints.push(point)
- }
- else
- point.setInvisibility()
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- params = {opacity: 0.001},
- options = {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- };
- that._labelsGroup && that._labelsGroup.animate(params, options, function() {
- that._markersGroup && that._markersGroup.animate(params, options, drawComplete)
- })
- },
- _animateComplete: function() {
- var that = this,
- animationSettings = {duration: that._defaultDuration};
- that._labelsGroup && that._labelsGroup.animate({opacity: 1}, animationSettings);
- that._errorBarGroup && that._errorBarGroup.animate({opacity: (that._options.valueErrorBar || {}).opacity || 1}, animationSettings)
- },
- _animate: function() {
- var that = this,
- lastPointIndex = that._drawedPoints.length - 1;
- _each(that._drawedPoints || [], function(i, p) {
- p.animate(i === lastPointIndex ? function() {
- that._animateComplete()
- } : undefined, {
- translateX: p.x,
- translateY: p.y
- })
- })
- },
- _getPointSize: function() {
- return this._options.point.visible ? this._options.point.size : DEFAULT_SYMBOL_POINT_SIZE
- },
- _calcMedianValue: function(fusionPoints, valueField) {
- var result,
- allValue = _map(fusionPoints, function(point) {
- return point[valueField]
- });
- allValue.sort(function(a, b) {
- return a - b
- });
- result = allValue[_floor(allValue.length / 2)];
- return _isDefined(result) ? result : null
- },
- _calcErrorBarValues: function(fusionPoints) {
- if (!fusionPoints.length)
- return {};
- var lowValue = fusionPoints[0].lowError,
- highValue = fusionPoints[0].highError,
- i = 1,
- length = fusionPoints.length,
- lowError,
- highError;
- for (i; i < length; i++) {
- lowError = fusionPoints[i].lowError;
- highError = fusionPoints[i].highError;
- if (_isDefined(lowError) && _isDefined(highError)) {
- lowValue = _min(lowError, lowValue);
- highValue = _max(highError, highValue)
- }
- }
- return {
- low: lowValue,
- high: highValue
- }
- },
- _fusionPoints: function(fusionPoints, tick, index) {
- var errorBarValues = this._calcErrorBarValues(fusionPoints);
- return {
- value: this._calcMedianValue(fusionPoints, "value"),
- argument: tick,
- tag: null,
- index: index,
- seriesName: this.name,
- lowError: errorBarValues.low,
- highError: errorBarValues.high
- }
- },
- _endUpdateData: function() {
- delete this._predefinedPointOptions
- },
- getArgumentField: function() {
- return this._options.argumentField || "arg"
- },
- getValueFields: function() {
- var options = this._options,
- errorBarsOptions = options.valueErrorBar || {},
- valueFields = [options.valueField || "val"],
- lowValueField = errorBarsOptions.lowValueField,
- highValueField = errorBarsOptions.highValueField;
- _isString(lowValueField) && valueFields.push(lowValueField);
- _isString(highValueField) && valueFields.push(highValueField);
- return valueFields
- },
- _calculateErrorBars: function(data) {
- var that = this,
- options = that._options,
- errorBarsOptions = options.valueErrorBar || {},
- errorBarType = toLowerCase(errorBarsOptions.type + ""),
- floatErrorValue = parseFloat(errorBarsOptions.value),
- valueField = that.getValueFields()[0],
- value,
- lowValueField = errorBarsOptions.lowValueField || LOW_ERROR,
- highValueField = errorBarsOptions.highValueField || HIGH_ERROR,
- valueArray,
- valueArrayLength,
- meanValue,
- processDataItem,
- addSubError = function(_i, item) {
- value = item[valueField];
- item[lowValueField] = value - floatErrorValue;
- item[highValueField] = value + floatErrorValue
- };
- if (!that._errorBarsEnabled() || !isErrorBarTypeCorrect(errorBarType))
- return;
- switch (errorBarType) {
- case FIXED:
- processDataItem = addSubError;
- break;
- case PERCENT:
- processDataItem = function(_, item) {
- value = item[valueField];
- var error = value * floatErrorValue / 100;
- item[lowValueField] = value - error;
- item[highValueField] = value + error
- };
- break;
- case UNDEFINED:
- processDataItem = function(_, item) {
- item[lowValueField] = item[ORIGINAL + lowValueField];
- item[highValueField] = item[ORIGINAL + highValueField]
- };
- break;
- default:
- valueArray = $.map(data, function(item) {
- return item[valueField]
- });
- valueArrayLength = valueArray.length;
- floatErrorValue = floatErrorValue || 1;
- switch (errorBarType) {
- case VARIANCE:
- floatErrorValue = variance(valueArray, sum(valueArray) / valueArrayLength) * floatErrorValue;
- processDataItem = addSubError;
- break;
- case STANDARD_DEVIATION:
- meanValue = sum(valueArray) / valueArrayLength;
- floatErrorValue = _sqrt(variance(valueArray, meanValue)) * floatErrorValue;
- processDataItem = function(_, item) {
- item[lowValueField] = meanValue - floatErrorValue;
- item[highValueField] = meanValue + floatErrorValue
- };
- break;
- case STANDARD_ERROR:
- floatErrorValue = _sqrt(variance(valueArray, sum(valueArray) / valueArrayLength) / valueArrayLength) * floatErrorValue;
- processDataItem = addSubError;
- break
- }
- }
- processDataItem && _each(data, processDataItem)
- },
- _beginUpdateData: function(data) {
- this._calculateErrorBars(data)
- }
- };
- chartSeries.scatter = _extend({}, baseScatterMethods, {
- drawTrackers: function() {
- var that = this,
- trackers,
- trackersGroup,
- segments = that._segments || [],
- rotated = that._options.rotated,
- cat = [];
- if (!that.isVisible())
- return;
- if (segments.length) {
- trackers = that._trackers = that._trackers || [];
- trackersGroup = that._trackersGroup = (that._trackersGroup || that._renderer.g().attr({
- fill: "gray",
- opacity: 0.001,
- stroke: "gray",
- "class": "dxc-trackers"
- })).attr({clipId: this._paneClipRectID || null}).append(that._group);
- _each(segments, function(i, segment) {
- if (!trackers[i])
- trackers[i] = that._drawTrackerElement(segment).data({series: that}).append(trackersGroup);
- else
- that._updateTrackerElement(segment, trackers[i])
- })
- }
- that._trackersTranslator = cat;
- _each(that.getVisiblePoints(), function(_, p) {
- var pointCoord = parseInt(rotated ? p.vy : p.vx);
- if (!cat[pointCoord])
- cat[pointCoord] = p;
- else
- $.isArray(cat[pointCoord]) ? cat[pointCoord].push(p) : cat[pointCoord] = [cat[pointCoord], p]
- })
- },
- getNeighborPoint: function(x, y) {
- var pCoord = this._options.rotated ? y : x,
- nCoord = pCoord,
- cat = this._trackersTranslator,
- point = null,
- minDistance,
- oppositeCoord = this._options.rotated ? x : y,
- opositeCoordName = this._options.rotated ? "vx" : "vy";
- if (this.isVisible() && cat) {
- point = cat[pCoord];
- do {
- point = cat[nCoord] || cat[pCoord];
- pCoord--;
- nCoord++
- } while ((pCoord >= 0 || nCoord < cat.length) && !point);
- if ($.isArray(point)) {
- minDistance = _abs(point[0][opositeCoordName] - oppositeCoord);
- _each(point, function(i, p) {
- var distance = _abs(p[opositeCoordName] - oppositeCoord);
- if (minDistance >= distance) {
- minDistance = distance;
- point = p
- }
- })
- }
- }
- return point
- }
- });
- series.mixins.polar.scatter = _extend({}, baseScatterMethods, {
- drawTrackers: function() {
- chartSeries.scatter.drawTrackers.call(this);
- var cat = this._trackersTranslator,
- index;
- if (!this.isVisible())
- return;
- _each(cat, function(i, category) {
- if (category) {
- index = i;
- return false
- }
- });
- cat[index + 360] = cat[index]
- },
- getNeighborPoint: function(x, y) {
- var pos = this.translators.untranslate(x, y);
- return chartSeries.scatter.getNeighborPoint.call(this, pos.phi, pos.r)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file lineSeries.js */
- (function($, DX) {
- var core = DX.viz.core,
- series = core.series,
- chartSeries = series.mixins.chart,
- polarSeries = series.mixins.polar,
- utils = DX.utils,
- scatterSeries = chartSeries.scatter,
- rangeCalculator = core.series.helpers.rangeDataCalculator,
- CANVAS_POSITION_START = "canvas_position_start",
- CANVAS_POSITION_TOP = "canvas_position_top",
- DISCRETE = "discrete",
- _extend = $.extend,
- _map = $.map,
- _each = $.each;
- function clonePoint(point, newX, newY, newAngle) {
- var p = utils.clone(point);
- p.x = newX;
- p.y = newY;
- p.angle = newAngle;
- return p
- }
- function getTangentPoint(point, prevPoint, centerPoint, tan, nextStepAngle) {
- var currectAngle = point.angle + nextStepAngle,
- cossin = utils.getCosAndSin(currectAngle),
- x = centerPoint.x + (point.radius + tan * nextStepAngle) * cossin.cos,
- y = centerPoint.y - (point.radius + tan * nextStepAngle) * cossin.sin;
- return clonePoint(prevPoint, x, y, currectAngle)
- }
- var lineMethods = {
- _createElementsGroup: function(elementsStyle) {
- var that = this,
- settings = _extend({"class": "dxc-elements"}, elementsStyle);
- that._applyElementsClipRect(settings);
- that._createGroup("_elementsGroup", that, that._group, settings)
- },
- _createBordersGroup: function(borderStyle) {
- var that = this,
- settings = _extend({"class": "dxc-borders"}, borderStyle);
- that._applyElementsClipRect(settings);
- that._createGroup("_bordersGroup", that, that._group, settings)
- },
- _createGroups: function(animationEnabled, style) {
- var that = this;
- style = style || that._styles.normal;
- that._createElementsGroup(style.elements);
- that._areBordersVisible() && that._createBordersGroup(style.border);
- scatterSeries._createGroups.call(that, animationEnabled, {});
- animationEnabled && that._markersGroup && that._markersGroup.attr({opacity: 0.001})
- },
- _areBordersVisible: function() {
- return false
- },
- _getDefaultSegment: function(segment) {
- return {line: _map(segment.line || [], function(pt) {
- return pt.getDefaultCoords()
- })}
- },
- _prepareSegment: function(points) {
- return {line: points}
- },
- _parseLineOptions: function(options, defaultColor) {
- return {
- stroke: options.color || defaultColor,
- "stroke-width": options.width,
- dashStyle: options.dashStyle || 'solid'
- }
- },
- _parseStyle: function(options, defaultColor) {
- return {elements: this._parseLineOptions(options, defaultColor)}
- },
- _applyStyle: function(style) {
- var that = this;
- that._elementsGroup && that._elementsGroup.attr(style.elements);
- _each(that._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.attr({'stroke-width': style.elements["stroke-width"]}).sharp()
- })
- },
- _drawElement: function(segment, group) {
- return {line: this._createMainElement(segment.line, {"stroke-width": this._styles.normal.elements["stroke-width"]}).append(group)}
- },
- _removeElement: function(element) {
- element.line.remove()
- },
- _generateDefaultSegments: function() {
- var that = this;
- return _map(that._segments || [], function(segment) {
- return that._getDefaultSegment(segment)
- })
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- var params = {points: segment.line},
- lineElement = element.line;
- animate ? lineElement.animate(params, animateParams, complete) : lineElement.attr(params)
- },
- _clearingAnimation: function(translator, drawComplete) {
- var that = this,
- lastIndex = that._graphics.length - 1,
- settings = {opacity: 0.001},
- options = {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- };
- that._labelsGroup && that._labelsGroup.animate(settings, options, function() {
- that._markersGroup && that._markersGroup.animate(settings, options, function() {
- _each(that._defaultSegments || [], function(i, segment) {
- that._oldUpdateElement(that._graphics[i], segment, true, {partitionDuration: 0.5}, i === lastIndex ? drawComplete : undefined)
- })
- })
- })
- },
- _animateComplete: function() {
- var that = this;
- scatterSeries._animateComplete.call(this);
- that._markersGroup && that._markersGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- },
- _animate: function() {
- var that = this,
- lastIndex = that._graphics.length - 1;
- _each(that._graphics || [], function(i, elem) {
- that._updateElement(elem, that._segments[i], true, {complete: i === lastIndex ? function() {
- that._animateComplete()
- } : undefined})
- })
- },
- _drawPoint: function(options) {
- scatterSeries._drawPoint.call(this, {
- point: options.point,
- groups: options.groups
- })
- },
- _createMainElement: function(points, settings) {
- return this._renderer.path(points, "line").attr(settings).sharp()
- },
- _drawSegment: function(points, animationEnabled, segmentCount, lastSegment) {
- var that = this,
- segment = that._prepareSegment(points, that._options.rotated, lastSegment);
- that._segments.push(segment);
- if (!that._graphics[segmentCount])
- that._graphics[segmentCount] = that._drawElement(animationEnabled ? that._getDefaultSegment(segment) : segment, that._elementsGroup);
- else if (!animationEnabled)
- that._updateElement(that._graphics[segmentCount], segment)
- },
- _getTrackerSettings: function() {
- var that = this,
- elements = that._styles.normal.elements;
- return {
- "stroke-width": elements["stroke-width"] > that._defaultTrackerWidth ? elements["stroke-width"] : that._defaultTrackerWidth,
- fill: "none"
- }
- },
- _getMainPointsFromSegment: function(segment) {
- return segment.line
- },
- _drawTrackerElement: function(segment) {
- return this._createMainElement(this._getMainPointsFromSegment(segment), this._getTrackerSettings(segment))
- },
- _updateTrackerElement: function(segment, element) {
- var settings = this._getTrackerSettings(segment);
- settings.points = this._getMainPointsFromSegment(segment);
- element.attr(settings)
- }
- };
- chartSeries.line = _extend({}, scatterSeries, lineMethods);
- chartSeries.stepline = _extend({}, chartSeries.line, {
- _calculateStepLinePoints: function(points) {
- var segment = [];
- _each(points, function(i, pt) {
- var stepY,
- point;
- if (!i) {
- segment.push(pt);
- return
- }
- stepY = segment[segment.length - 1].y;
- if (stepY !== pt.y) {
- point = utils.clone(pt);
- point.y = stepY;
- segment.push(point)
- }
- segment.push(pt)
- });
- return segment
- },
- _prepareSegment: function(points) {
- return chartSeries.line._prepareSegment(this._calculateStepLinePoints(points))
- }
- });
- chartSeries.stackedline = _extend({}, chartSeries.line, {});
- chartSeries.fullstackedline = _extend({}, chartSeries.line, {_getRangeData: function(zoomArgs, calcIntervalFunction) {
- var that = this;
- rangeCalculator.calculateRangeData(that, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(that);
- rangeCalculator.processFullStackedRange(that);
- return that._rangeData
- }});
- chartSeries.spline = _extend({}, chartSeries.line, {
- _calculateBezierPoints: function(src, rotated) {
- var bezierPoints = [],
- pointsCopy = src,
- checkExtr = function(otherPointCoord, pointCoord, controlCoord) {
- return otherPointCoord > pointCoord && controlCoord > otherPointCoord || otherPointCoord < pointCoord && controlCoord < otherPointCoord ? otherPointCoord : controlCoord
- };
- if (pointsCopy.length !== 1)
- _each(pointsCopy, function(i, curPoint) {
- var leftControlX,
- leftControlY,
- rightControlX,
- rightControlY,
- prevPoint,
- nextPoint,
- xCur,
- yCur,
- x1,
- x2,
- y1,
- y2,
- lambda = 0.5,
- curIsExtremum,
- leftPoint,
- rightPoint,
- a,
- b,
- c,
- xc,
- yc,
- shift;
- if (!i) {
- bezierPoints.push(curPoint);
- bezierPoints.push(curPoint);
- return
- }
- prevPoint = pointsCopy[i - 1];
- if (i < pointsCopy.length - 1) {
- nextPoint = pointsCopy[i + 1];
- xCur = curPoint.x;
- yCur = curPoint.y;
- x1 = prevPoint.x;
- x2 = nextPoint.x;
- y1 = prevPoint.y;
- y2 = nextPoint.y;
- curIsExtremum = !!(!rotated && (yCur <= prevPoint.y && yCur <= nextPoint.y || yCur >= prevPoint.y && yCur >= nextPoint.y) || rotated && (xCur <= prevPoint.x && xCur <= nextPoint.x || xCur >= prevPoint.x && xCur >= nextPoint.x));
- if (curIsExtremum)
- if (!rotated) {
- rightControlY = leftControlY = yCur;
- rightControlX = (xCur + nextPoint.x) / 2;
- leftControlX = (xCur + prevPoint.x) / 2
- }
- else {
- rightControlX = leftControlX = xCur;
- rightControlY = (yCur + nextPoint.y) / 2;
- leftControlY = (yCur + prevPoint.y) / 2
- }
- else {
- a = y2 - y1;
- b = x1 - x2;
- c = y1 * x2 - x1 * y2;
- if (!rotated) {
- xc = xCur;
- yc = -1 * (a * xc + c) / b;
- shift = yc - yCur || 0;
- y1 -= shift;
- y2 -= shift
- }
- else {
- yc = yCur;
- xc = -1 * (b * yc + c) / a;
- shift = xc - xCur || 0;
- x1 -= shift;
- x2 -= shift
- }
- rightControlX = (xCur + lambda * x2) / (1 + lambda);
- rightControlY = (yCur + lambda * y2) / (1 + lambda);
- leftControlX = (xCur + lambda * x1) / (1 + lambda);
- leftControlY = (yCur + lambda * y1) / (1 + lambda)
- }
- if (!rotated) {
- leftControlY = checkExtr(prevPoint.y, yCur, leftControlY);
- rightControlY = checkExtr(nextPoint.y, yCur, rightControlY)
- }
- else {
- leftControlX = checkExtr(prevPoint.x, xCur, leftControlX);
- rightControlX = checkExtr(nextPoint.x, xCur, rightControlX)
- }
- leftPoint = clonePoint(curPoint, leftControlX, leftControlY);
- rightPoint = clonePoint(curPoint, rightControlX, rightControlY);
- bezierPoints.push(leftPoint, curPoint, rightPoint)
- }
- else {
- bezierPoints.push(curPoint, curPoint);
- return
- }
- });
- else
- bezierPoints.push(pointsCopy[0]);
- return bezierPoints
- },
- _prepareSegment: function(points, rotated) {
- return chartSeries.line._prepareSegment(this._calculateBezierPoints(points, rotated))
- },
- _createMainElement: function(points, settings) {
- return this._renderer.path(points, "bezier").attr(settings).sharp()
- }
- });
- polarSeries.line = _extend({}, polarSeries.scatter, lineMethods, {
- _prepareSegment: function(points, rotated, lastSegment) {
- var preparedPoints = [],
- centerPoint = this.translators.translate(CANVAS_POSITION_START, CANVAS_POSITION_TOP),
- i;
- lastSegment && this._closeSegment(points);
- if (this.argumentAxisType !== DISCRETE && this.valueAxisType !== DISCRETE) {
- for (i = 1; i < points.length; i++)
- preparedPoints = preparedPoints.concat(this._getTangentPoints(points[i], points[i - 1], centerPoint));
- if (!preparedPoints.length)
- preparedPoints = points
- }
- else
- return chartSeries.line._prepareSegment.apply(this, arguments);
- return {line: preparedPoints}
- },
- _getRemainingAngle: function(angle) {
- var normAngle = utils.normalizeAngle(angle);
- return angle >= 0 ? 360 - normAngle : -normAngle
- },
- _closeSegment: function(points) {
- var point,
- differenceAngle;
- if (this._segments.length)
- point = this._segments[0].line[0];
- else
- point = clonePoint(points[0], points[0].x, points[0].y, points[0].angle);
- if (points[points.length - 1].angle !== point.angle) {
- if (utils.normalizeAngle(Math.round(points[points.length - 1].angle)) === utils.normalizeAngle(Math.round(point.angle)))
- point.angle = points[points.length - 1].angle;
- else {
- differenceAngle = points[points.length - 1].angle - point.angle;
- point.angle = points[points.length - 1].angle + this._getRemainingAngle(differenceAngle)
- }
- points.push(point)
- }
- },
- _getTangentPoints: function(point, prevPoint, centerPoint) {
- var tangentPoints = [],
- betweenAngle = Math.round(prevPoint.angle - point.angle),
- tan = (prevPoint.radius - point.radius) / betweenAngle,
- i;
- if (betweenAngle === 0)
- tangentPoints = [prevPoint, point];
- else if (betweenAngle > 0)
- for (i = betweenAngle; i >= 0; i--)
- tangentPoints.push(getTangentPoint(point, prevPoint, centerPoint, tan, i));
- else
- for (i = 0; i >= betweenAngle; i--)
- tangentPoints.push(getTangentPoint(point, prevPoint, centerPoint, tan, betweenAngle - i));
- return tangentPoints
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file areaSeries.js */
- (function($, DX) {
- var core = DX.viz.core,
- utils = DX.utils,
- series = core.series,
- chartSeries = series.mixins.chart,
- polarSeries = series.mixins.polar,
- lineSeries = chartSeries.line,
- rangeCalculator = core.series.helpers.rangeDataCalculator,
- _map = $.map,
- _extend = $.extend,
- HOVER_COLOR_HIGHLIGHTING = 20;
- var baseAreaMethods = {
- _createBorderElement: lineSeries._createMainElement,
- _createLegendState: function(styleOptions, defaultColor) {
- var legendState = chartSeries.scatter._createLegendState.call(this, styleOptions, defaultColor);
- legendState.opacity = styleOptions.opacity;
- return legendState
- },
- _getSpecialColor: function(color) {
- return this._options._IE8 ? new DX.Color(color).highlight(HOVER_COLOR_HIGHLIGHTING) : color
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(this);
- rangeCalculator.calculateRangeMinValue(this, zoomArgs);
- return this._rangeData
- },
- _getDefaultSegment: function(segment) {
- var defaultSegment = lineSeries._getDefaultSegment(segment);
- defaultSegment.area = defaultSegment.line.concat(defaultSegment.line.slice().reverse());
- return defaultSegment
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- var lineParams = {points: segment.line},
- areaParams = {points: segment.area},
- borderElement = element.line;
- if (animate) {
- borderElement && borderElement.animate(lineParams, animateParams);
- element.area.animate(areaParams, animateParams, complete)
- }
- else {
- borderElement && borderElement.attr(lineParams);
- element.area.attr(areaParams)
- }
- },
- _removeElement: function(element) {
- element.line && element.line.remove();
- element.area.remove()
- },
- _drawElement: function(segment) {
- return {
- line: this._bordersGroup && this._createBorderElement(segment.line, {"stroke-width": this._styles.normal.border["stroke-width"]}).append(this._bordersGroup),
- area: this._createMainElement(segment.area).append(this._elementsGroup)
- }
- },
- _applyStyle: function(style) {
- var that = this;
- that._elementsGroup && that._elementsGroup.attr(style.elements);
- that._bordersGroup && that._bordersGroup.attr(style.border);
- $.each(that._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.attr({'stroke-width': style.border["stroke-width"]}).sharp()
- })
- },
- _createPattern: function(color, hatching, custom) {
- if (hatching && utils.isObject(hatching)) {
- var pattern = this._renderer.pattern(color, hatching);
- pattern._custom = custom;
- this._patterns.push(pattern);
- return pattern.id
- }
- return color
- },
- _parseStyle: function(options, defaultColor, defaultBorderColor) {
- var borderOptions = options.border || {},
- borderStyle = lineSeries._parseLineOptions(borderOptions, defaultBorderColor);
- borderStyle["stroke-width"] = borderOptions.visible ? borderStyle["stroke-width"] : 0;
- return {
- border: borderStyle,
- elements: {
- stroke: "none",
- fill: this._createPattern(options.color || defaultColor, options.hatching),
- opacity: options.opacity
- }
- }
- },
- _areBordersVisible: function() {
- var options = this._options;
- return options.border.visible || options.hoverStyle.border.visible || options.selectionStyle.border.visible
- },
- _createMainElement: function(points, settings) {
- return this._renderer.path(points, "area").attr(settings)
- },
- _getTrackerSettings: function(segment) {
- return {"stroke-width": segment.singlePointSegment ? this._defaultTrackerWidth : 0}
- },
- _getMainPointsFromSegment: function(segment) {
- return segment.area
- }
- };
- chartSeries.area = _extend({}, lineSeries, baseAreaMethods, {
- _prepareSegment: function(points, rotated) {
- var processedPoints = this._processSinglePointsAreaSegment(points, rotated);
- return {
- line: processedPoints,
- area: _map(processedPoints, function(pt) {
- return pt.getCoords()
- }).concat(_map(processedPoints.slice().reverse(), function(pt) {
- return pt.getCoords(true)
- })),
- singlePointSegment: processedPoints !== points
- }
- },
- _processSinglePointsAreaSegment: function(points, rotated) {
- if (points.length === 1) {
- var p = points[0],
- p1 = utils.clone(p);
- p1[rotated ? "y" : "x"] += 1;
- p1.argument = null;
- return [p, p1]
- }
- return points
- }
- });
- polarSeries.area = _extend({}, polarSeries.line, baseAreaMethods, {
- _prepareSegment: function(points, rotated, lastSegment) {
- lastSegment && polarSeries.line._closeSegment.call(this, points);
- var preparedPoints = chartSeries.area._prepareSegment.call(this, points);
- return preparedPoints
- },
- _processSinglePointsAreaSegment: function(points) {
- return polarSeries.line._prepareSegment.call(this, points).line
- }
- });
- chartSeries.steparea = _extend({}, chartSeries.area, {_prepareSegment: function(points, rotated) {
- points = chartSeries.area._processSinglePointsAreaSegment(points, rotated);
- return chartSeries.area._prepareSegment.call(this, chartSeries.stepline._calculateStepLinePoints(points))
- }});
- chartSeries.splinearea = _extend({}, chartSeries.area, {
- _areaPointsToSplineAreaPoints: function(areaPoints) {
- var lastFwPoint = areaPoints[areaPoints.length / 2 - 1],
- firstBwPoint = areaPoints[areaPoints.length / 2];
- areaPoints.splice(areaPoints.length / 2, 0, {
- x: lastFwPoint.x,
- y: lastFwPoint.y
- }, {
- x: firstBwPoint.x,
- y: firstBwPoint.y
- });
- if (lastFwPoint.defaultCoords)
- areaPoints[areaPoints.length / 2].defaultCoords = true;
- if (firstBwPoint.defaultCoords)
- areaPoints[areaPoints.length / 2 - 1].defaultCoords = true
- },
- _prepareSegment: function(points, rotated) {
- var areaSeries = chartSeries.area,
- processedPoints = areaSeries._processSinglePointsAreaSegment(points, rotated),
- areaSegment = areaSeries._prepareSegment.call(this, chartSeries.spline._calculateBezierPoints(processedPoints, rotated));
- this._areaPointsToSplineAreaPoints(areaSegment.area);
- areaSegment.singlePointSegment = processedPoints !== points;
- return areaSegment
- },
- _getDefaultSegment: function(segment) {
- var areaDefaultSegment = chartSeries.area._getDefaultSegment(segment);
- this._areaPointsToSplineAreaPoints(areaDefaultSegment.area);
- return areaDefaultSegment
- },
- _createMainElement: function(points, settings) {
- return this._renderer.path(points, "bezierarea").attr(settings)
- },
- _createBorderElement: chartSeries.spline._createMainElement
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file barSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- series = viz.core.series,
- chartSeries = series.mixins.chart,
- polarSeries = series.mixins.polar,
- scatterSeries = chartSeries.scatter,
- areaSeries = chartSeries.area,
- _extend = $.extend,
- _each = $.each,
- DEFAULT_BAR_POINT_SIZE = 3;
- var baseBarSeriesMethods = {
- _getSpecialColor: areaSeries._getSpecialColor,
- _createPattern: areaSeries._createPattern,
- _updateOptions: function(options) {
- this._stackName = "axis_" + (options.axis || "default") + "_stack_" + (options.stack || "default")
- },
- _parsePointStyle: function(style, defaultColor, defaultBorderColor, isCustomPointOptions) {
- var color = this._createPattern(style.color || defaultColor, style.hatching, isCustomPointOptions),
- base = scatterSeries._parsePointStyle.call(this, style, color, defaultBorderColor);
- base.fill = color;
- base.dashStyle = style.border && style.border.dashStyle || "solid";
- delete base.r;
- return base
- },
- _applyMarkerClipRect: function(settings) {
- settings.clipId = null
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- settings = that._oldgetAffineCoordOptions(translators) || that._getAffineCoordOptions(translators);
- that._labelsGroup && that._labelsGroup.animate({opacity: 0.001}, {
- duration: that._defaultDuration,
- partitionDuration: 0.5
- }, function() {
- that._markersGroup.animate(settings, {partitionDuration: 0.5}, function() {
- that._markersGroup.attr({
- scaleX: null,
- scaleY: null,
- translateX: 0,
- translateY: 0
- });
- drawComplete()
- })
- })
- },
- _createGroups: function(animationEnabled, style, firstDrawing) {
- var that = this,
- settings = {};
- scatterSeries._createGroups.apply(that, arguments);
- if (animationEnabled && firstDrawing)
- settings = this._getAffineCoordOptions(that.translators, true);
- else if (!animationEnabled)
- settings = {
- scaleX: 1,
- scaleY: 1,
- translateX: 0,
- translateY: 0
- };
- that._markersGroup.attr(settings)
- },
- _drawPoint: function(options) {
- options.hasAnimation = options.hasAnimation && !options.firstDrawing;
- options.firstDrawing = false;
- scatterSeries._drawPoint.call(this, options)
- },
- _getMainColor: function() {
- return this._options.mainSeriesColor
- },
- _createPointStyles: function(pointOptions, isCustomPointOptions) {
- var that = this,
- mainColor = pointOptions.color || that._getMainColor(),
- specialMainColor = that._getSpecialColor(mainColor);
- return {
- normal: that._parsePointStyle(pointOptions, mainColor, mainColor, isCustomPointOptions),
- hover: that._parsePointStyle(pointOptions.hoverStyle || {}, specialMainColor, mainColor, isCustomPointOptions),
- selection: that._parsePointStyle(pointOptions.selectionStyle || {}, specialMainColor, mainColor, isCustomPointOptions)
- }
- },
- _updatePointsVisibility: function() {
- var visibility = this._options.visible;
- $.each(this._points, function(_, point) {
- point._options.visible = visibility
- })
- },
- _preparePointOptions: function(customOptions) {
- var options = this._options;
- return customOptions ? _extend(true, {}, options, customOptions) : options
- },
- _animate: function(firstDrawing) {
- var that = this,
- complete = function() {
- that._animateComplete()
- },
- animateFunc = function(drawedPoints, complete) {
- var lastPointIndex = drawedPoints.length - 1;
- _each(drawedPoints || [], function(i, point) {
- point.animate(i === lastPointIndex ? complete : undefined, point.getMarkerCoords())
- })
- };
- that._animatePoints(firstDrawing, complete, animateFunc)
- },
- _getPointSize: function() {
- return DEFAULT_BAR_POINT_SIZE
- },
- _beginUpdateData: function(data) {
- scatterSeries._beginUpdateData.call(this, data);
- this._patterns = $.map(this._patterns, function(pattern) {
- if (pattern._custom) {
- pattern.remove();
- return null
- }
- else
- return pattern
- })
- }
- };
- chartSeries.bar = _extend({}, scatterSeries, baseBarSeriesMethods, {
- _getAffineCoordOptions: function(translators) {
- var rotated = this._options.rotated,
- direction = rotated ? "x" : "y",
- settings = {
- scaleX: rotated ? 0.001 : 1,
- scaleY: rotated ? 1 : 0.001
- };
- settings["translate" + direction.toUpperCase()] = translators[direction].translate("canvas_position_default");
- return settings
- },
- _getRangeData: function() {
- var rangeData = areaSeries._getRangeData.apply(this, arguments);
- rangeData.arg.stick = false;
- return rangeData
- },
- _animatePoints: function(firstDrawing, complete, animateFunc) {
- var that = this;
- that._markersGroup.animate({
- scaleX: 1,
- scaleY: 1,
- translateY: 0,
- translateX: 0
- }, undefined, complete);
- if (!firstDrawing)
- animateFunc(that._drawedPoints, complete)
- }
- });
- polarSeries.bar = _extend({}, polarSeries.scatter, baseBarSeriesMethods, {
- _animatePoints: function(firstDrawing, complete, animateFunc) {
- animateFunc(this._drawedPoints, complete)
- },
- _createGroups: function() {
- scatterSeries._createGroups.apply(this, arguments)
- },
- _drawPoint: function(point, groups, animationEnabled) {
- scatterSeries._drawPoint.call(this, point, groups, animationEnabled)
- },
- _parsePointStyle: function(style) {
- var base = baseBarSeriesMethods._parsePointStyle.apply(this, arguments);
- base.opacity = style.opacity;
- return base
- },
- _createMarkerGroup: function() {
- var that = this,
- markersSettings = that._getPointOptions().styles.normal,
- groupSettings;
- markersSettings["class"] = "dxc-markers";
- that._applyMarkerClipRect(markersSettings);
- groupSettings = _extend({}, markersSettings);
- delete groupSettings.opacity;
- that._createGroup("_markersGroup", that, that._group, groupSettings)
- },
- _createLegendState: areaSeries._createLegendState,
- _getRangeData: areaSeries._getRangeData
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeSeries.js */
- (function($, DX) {
- var core = DX.viz.core,
- series = core.series.mixins.chart,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _noop = $.noop,
- rangeCalculator = core.series.helpers.rangeDataCalculator,
- areaSeries = series.area;
- var baseRangeSeries = {
- _beginUpdateData: _noop,
- areErrorBarsVisible: _noop,
- _createErrorBarGroup: _noop,
- _checkData: function(data) {
- return _isDefined(data.argument) && data.value !== undefined && data.minValue !== undefined
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.rangeValue1Field = valueFields[0] + name;
- options.rangeValue2Field = valueFields[1] + name;
- options.tagField = that.getTagField() + name
- },
- _processRange: function(point, prevPoint) {
- rangeCalculator.processTwoValues(this, point, prevPoint, "value", "minValue")
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction, "value", "minValue");
- rangeCalculator.addRangeSeriesLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- return {
- tag: data[options.tagField || "tag"],
- minValue: data[options.rangeValue1Field || "val1"],
- value: data[options.rangeValue2Field || "val2"],
- argument: data[options.argumentField || "arg"]
- }
- },
- _fusionPoints: function(fusionPoints, tick) {
- var calcMedianValue = series.scatter._calcMedianValue,
- value = calcMedianValue.call(this, fusionPoints, "value"),
- minValue = calcMedianValue.call(this, fusionPoints, "minValue");
- if (value === null || minValue === null)
- value = minValue = null;
- return {
- minValue: minValue,
- value: value,
- argument: tick,
- tag: null
- }
- },
- getValueFields: function() {
- return [this._options.rangeValue1Field || "val1", this._options.rangeValue2Field || "val2"]
- }
- };
- series.rangebar = _extend({}, series.bar, baseRangeSeries);
- series.rangearea = _extend({}, areaSeries, {
- _drawPoint: function(options) {
- var point = options.point;
- if (point.isInVisibleArea()) {
- point.clearVisibility();
- point.draw(this._renderer, options.groups);
- this._drawedPoints.push(point);
- if (!point.visibleTopMarker)
- point.hideMarker("top");
- if (!point.visibleBottomMarker)
- point.hideMarker("bottom")
- }
- else
- point.setInvisibility()
- },
- _prepareSegment: function(points, rotated) {
- var processedPoints = this._processSinglePointsAreaSegment(points, rotated),
- processedMinPointsCoords = $.map(processedPoints, function(pt) {
- return pt.getCoords(true)
- });
- return {
- line: processedPoints,
- bottomLine: processedMinPointsCoords,
- area: $.map(processedPoints, function(pt) {
- return pt.getCoords()
- }).concat(processedMinPointsCoords.slice().reverse()),
- singlePointSegment: processedPoints !== points
- }
- },
- _getDefaultSegment: function(segment) {
- var defaultSegment = areaSeries._getDefaultSegment.call(this, segment);
- defaultSegment.bottomLine = defaultSegment.line;
- return defaultSegment
- },
- _removeElement: function(element) {
- areaSeries._removeElement.call(this, element);
- element.bottomLine && element.bottomLine.remove()
- },
- _drawElement: function(segment, group) {
- var that = this,
- drawnElement = areaSeries._drawElement.call(that, segment, group);
- drawnElement.bottomLine = that._bordersGroup && that._createBorderElement(segment.bottomLine, {"stroke-width": that._styles.normal.border["stroke-width"]}).append(that._bordersGroup);
- return drawnElement
- },
- _applyStyle: function(style) {
- var that = this,
- elementsGroup = that._elementsGroup,
- bordersGroup = that._bordersGroup;
- elementsGroup && elementsGroup.attr(style.elements);
- bordersGroup && bordersGroup.attr(style.border);
- $.each(that._graphics || [], function(_, graphic) {
- graphic.line && graphic.line.attr({"stroke-width": style.border["stroke-width"]});
- graphic.bottomLine && graphic.bottomLine.attr({"stroke-width": style.border["stroke-width"]})
- })
- },
- _updateElement: function(element, segment, animate, animateParams, complete) {
- areaSeries._updateElement.call(this, element, segment, animate, animateParams, complete);
- var bottomLineParams = {points: segment.bottomLine},
- bottomBorderElement = element.bottomLine;
- if (bottomBorderElement)
- animate ? bottomBorderElement.animate(bottomLineParams, animateParams) : bottomBorderElement.attr(bottomLineParams)
- }
- }, baseRangeSeries)
- })(jQuery, DevExpress);
- /*! Module viz-core, file bubbleSeries.js */
- (function($, DX) {
- var mixins = DX.viz.core.series.mixins,
- series = mixins.chart,
- scatterSeries = series.scatter,
- barSeries = series.bar,
- _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop;
- series.bubble = _extend({}, scatterSeries, {
- _fillErrorBars: _noop,
- _getRangeCorrector: _noop,
- _calculateErrorBars: _noop,
- _getMainColor: barSeries._getMainColor,
- _createPointStyles: barSeries._createPointStyles,
- _createPattern: barSeries._createPattern,
- _updatePointsVisibility: barSeries._updatePointsVisibility,
- _preparePointOptions: barSeries._preparePointOptions,
- _getSpecialColor: barSeries._getSpecialColor,
- _applyMarkerClipRect: series.line._applyElementsClipRect,
- _parsePointStyle: mixins.polar.bar._parsePointStyle,
- _createLegendState: series.area._createLegendState,
- _createMarkerGroup: mixins.polar.bar._createMarkerGroup,
- areErrorBarsVisible: _noop,
- _createErrorBarGroup: _noop,
- _checkData: function(data) {
- return _isDefined(data.argument) && _isDefined(data.size) && data.value !== undefined
- },
- _getPointData: function(data, options) {
- var pointData = scatterSeries._getPointData.call(this, data, options);
- pointData.size = data[options.sizeField || "size"];
- return pointData
- },
- _fusionPoints: function(fusionPoints, tick) {
- var calcMedianValue = scatterSeries._calcMedianValue;
- return {
- size: calcMedianValue.call(this, fusionPoints, "size"),
- value: calcMedianValue.call(this, fusionPoints, "value"),
- argument: tick,
- tag: null
- }
- },
- getValueFields: function() {
- var options = this._options;
- return [options.valueField || "val", options.sizeField || "size"]
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.valueField = valueFields[0] + name;
- options.sizeField = valueFields[1] + name;
- options.tagField = that.getTagField() + name
- },
- _clearingAnimation: function(translators, drawComplete) {
- var that = this,
- partitionDuration = 0.5,
- lastPointIndex = that._drawedPoints.length - 1,
- labelsGroup = that._labelsGroup;
- labelsGroup && labelsGroup.animate({opacity: 0.001}, {
- duration: that._defaultDuration,
- partitionDuration: partitionDuration
- }, function() {
- _each(that._drawedPoints || [], function(i, p) {
- p.animate(i === lastPointIndex ? drawComplete : undefined, {r: 0}, partitionDuration)
- })
- })
- },
- _animate: function() {
- var that = this,
- lastPointIndex = that._drawedPoints.length - 1,
- labelsGroup = that._labelsGroup,
- labelAnimFunc = function() {
- labelsGroup && labelsGroup.animate({opacity: 1}, {duration: that._defaultDuration})
- };
- _each(that._drawedPoints || [], function(i, p) {
- p.animate(i === lastPointIndex ? labelAnimFunc : undefined, {
- r: p.bubbleSize,
- translateX: p.x,
- translateY: p.y
- })
- })
- },
- _beginUpdateData: barSeries._beginUpdateData
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file pieSeries.js */
- (function($, DX) {
- var mixins = DX.viz.core.series.mixins,
- pieSeries = mixins.pie,
- _utils = DX.utils,
- scatterSeries = mixins.chart.scatter,
- barSeries = mixins.chart.bar,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop,
- _map = $.map,
- _isFinite = isFinite,
- _max = Math.max;
- pieSeries.pie = _extend({}, barSeries, {
- _createLabelGroup: scatterSeries._createLabelGroup,
- _createGroups: scatterSeries._createGroups,
- _createErrorBarGroup: _noop,
- _drawPoint: function(options) {
- var point = options.point,
- legendCallback = options.legendCallback;
- scatterSeries._drawPoint.call(this, options);
- !point.isVisible() && point.setInvisibility();
- legendCallback && point.isSelected() && legendCallback(point)("applySelected")
- },
- adjustLabels: function() {
- var that = this,
- points = that._points || [],
- maxLabelLength,
- labelsBBoxes = [];
- _each(points, function(_, point) {
- if (point._label.isVisible() && point._label.getLayoutOptions().position !== "inside") {
- point.setLabelEllipsis();
- labelsBBoxes.push(point._label.getBoundingRect().width)
- }
- });
- if (labelsBBoxes.length)
- maxLabelLength = _max.apply(null, labelsBBoxes);
- _each(points, function(_, point) {
- if (point._label.isVisible() && point._label.getLayoutOptions().position !== "inside") {
- point._maxLabelLength = maxLabelLength;
- point.updateLabelCoord()
- }
- })
- },
- _processRange: _noop,
- _applyElementsClipRect: _noop,
- getColor: _noop,
- areErrorBarsVisible: _noop,
- _prepareSeriesToDrawing: _noop,
- _endUpdateData: scatterSeries._prepareSeriesToDrawing,
- resetLabelSetups: function() {
- _each(this._points || [], function(_, point) {
- point._label.clearVisibility()
- })
- },
- drawLabelsWOPoints: function(translators) {
- var that = this,
- options = that._options,
- points = that._points || [],
- labelsGroup;
- if (options.label.position === "inside")
- return false;
- that._createGroups();
- labelsGroup = that._labelsGroup;
- _each(points, function(_, point) {
- point.drawLabel(translators, that._renderer, labelsGroup)
- });
- return true
- },
- _getCreatingPointOptions: function() {
- return this._getPointOptions()
- },
- _updateOptions: function(options) {
- this.labelSpace = 0;
- this.innerRadius = this.type === "pie" ? 0 : options.innerRadius
- },
- _checkData: function(data) {
- var base = barSeries._checkData(data);
- return this._options.paintNullPoints ? base : base && data.value !== null
- },
- _createMarkerGroup: function() {
- var that = this;
- if (!that._markersGroup)
- that._markersGroup = that._renderer.g().attr({"class": "dxc-markers"}).append(that._group)
- },
- _getMainColor: function() {
- return this._options.mainSeriesColor()
- },
- _getPointOptions: function() {
- return this._parsePointOptions(this._preparePointOptions(), this._options.label)
- },
- _getRangeData: function() {
- return this._rangeData
- },
- _getArrangeTotal: function(points) {
- var total = 0;
- _each(points, function(_, point) {
- if (point.isVisible())
- total += point.initialValue
- });
- return total
- },
- _createPointStyles: function(pointOptions) {
- var that = this,
- mainColor = pointOptions.color || that._getMainColor(),
- specialMainColor = that._getSpecialColor(mainColor);
- return {
- normal: that._parsePointStyle(pointOptions, mainColor, mainColor),
- hover: that._parsePointStyle(pointOptions.hoverStyle, specialMainColor, mainColor),
- selection: that._parsePointStyle(pointOptions.selectionStyle, specialMainColor, mainColor),
- legendStyles: {
- normal: that._createLegendState(pointOptions, mainColor),
- hover: that._createLegendState(pointOptions.hoverStyle, specialMainColor),
- selection: that._createLegendState(pointOptions.selectionStyle, specialMainColor)
- }
- }
- },
- _getArrangeMinShownValue: function(points, total) {
- var minSegmentSize = this._options.minSegmentSize,
- totalMinSegmentSize = 0,
- totalNotMinValues = 0;
- total = total || points.length;
- _each(points, function(_, point) {
- if (point.isVisible())
- if (point.initialValue < minSegmentSize * total / 360)
- totalMinSegmentSize += minSegmentSize;
- else
- totalNotMinValues += point.initialValue
- });
- return totalMinSegmentSize < 360 ? minSegmentSize * totalNotMinValues / (360 - totalMinSegmentSize) : 0
- },
- _applyArrangeCorrection: function(points, minShownValue, total) {
- var options = this._options,
- isClockWise = options.segmentsDirection !== "anticlockwise",
- shiftedAngle = _isFinite(options.startAngle) ? _utils.normalizeAngle(options.startAngle) : 0,
- minSegmentSize = options.minSegmentSize,
- percent,
- correction = 0,
- zeroTotalCorrection = 0;
- if (total === 0) {
- total = points.length;
- zeroTotalCorrection = 1
- }
- _each(isClockWise ? points : points.concat([]).reverse(), function(_, point) {
- var val = point.isVisible() ? zeroTotalCorrection || point.initialValue : 0,
- updatedZeroValue;
- if (minSegmentSize && point.isVisible() && val < minShownValue)
- updatedZeroValue = minShownValue;
- percent = val / total;
- point.correctValue(correction, percent, zeroTotalCorrection + (updatedZeroValue || 0));
- point.shiftedAngle = shiftedAngle;
- correction = correction + (updatedZeroValue || val)
- });
- this._rangeData = {val: {
- min: 0,
- max: correction
- }}
- },
- arrangePoints: function() {
- var that = this,
- originalPoints = that._originalPoints || [],
- minSegmentSize = that._options.minSegmentSize,
- minShownValue,
- pointIndex = 0,
- total,
- isAllPointsNegative = _max.apply(null, _map(originalPoints, function(p) {
- return p.value
- })) <= 0,
- points = that._originalPoints = that._points = _map(originalPoints, function(point) {
- if (point.value === null || !isAllPointsNegative && point.value < 0 || point.value === 0 && !minSegmentSize) {
- point.dispose();
- return null
- }
- else {
- point.index = pointIndex++;
- return point
- }
- });
- total = that._getArrangeTotal(points);
- if (minSegmentSize)
- minShownValue = this._getArrangeMinShownValue(points, total);
- that._applyArrangeCorrection(points, minShownValue, total)
- },
- correctPosition: function(correction) {
- var debug = DX.utils.debug;
- debug.assert(correction, "correction was not passed");
- debug.assertParam(correction.centerX, "correction.centerX was not passed");
- debug.assertParam(correction.centerY, "correction.centerY was not passed");
- debug.assertParam(correction.radiusInner, "correction.radiusInner was not passed");
- debug.assertParam(correction.radiusOuter, "correction.radiusOuter was not passed");
- _each(this._points, function(_, point) {
- point.correctPosition(correction)
- });
- this._centerX = correction.centerX;
- this._centerY = correction.centerY;
- this._radiusOuter = correction.radiusOuter
- },
- _animate: function(firstDrawing) {
- var that = this,
- index = 0,
- timeThreshold = 0.2,
- points = that._points,
- pointsCount = points && points.length,
- duration = 1 / (timeThreshold * (pointsCount - 1) + 1),
- completeFunc = function() {
- that._animateComplete()
- },
- animateP = function() {
- points[index] && points[index].animate(index === pointsCount - 1 ? completeFunc : undefined, duration, stepFunc);
- index++
- },
- stepFunc = function(_, progress) {
- if (progress >= timeThreshold) {
- this.step = null;
- animateP()
- }
- };
- if (firstDrawing)
- animateP();
- else
- $.each(points, function(i, p) {
- p.animate(i === pointsCount - 1 ? completeFunc : undefined)
- })
- },
- getVisiblePoints: function() {
- return _map(this._points, function(p) {
- return p.isVisible() ? p : null
- })
- },
- getPointByCoord: function(x, y) {
- var points = this._points;
- for (var i = 0; i < points.length; i++)
- if (points[i].coordsIn(x, y))
- return points[i]
- },
- _beginUpdateData: function() {
- this._deletePatterns();
- this._patterns = []
- },
- getCenter: function() {
- return {
- x: this._centerX,
- y: this._centerY
- }
- }
- });
- pieSeries.doughnut = pieSeries.donut = pieSeries.pie
- })(jQuery, DevExpress);
- /*! Module viz-core, file financialSeries.js */
- (function($, DX) {
- var viz = DX.viz,
- seriesNS = viz.core.series,
- series = seriesNS.mixins.chart,
- scatterSeries = series.scatter,
- barSeries = series.bar,
- rangeCalculator = seriesNS.helpers.rangeDataCalculator,
- _isDefined = DX.utils.isDefined,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop,
- DEFAULT_FINANCIAL_POINT_SIZE = 10;
- series.stock = _extend({}, scatterSeries, {
- _animate: _noop,
- _applyMarkerClipRect: function(settings) {
- settings.clipId = this._forceClipping ? this._paneClipRectID : this._widePaneClipRectID
- },
- _updatePointsVisibility: barSeries._updatePointsVisibility,
- _preparePointOptions: barSeries._preparePointOptions,
- _getRangeCorrector: _noop,
- _createErrorBarGroup: _noop,
- areErrorBarsVisible: _noop,
- _createMarkerGroup: function() {
- var that = this,
- markersGroup,
- styles = that._getPointOptions().styles,
- defaultStyle = styles.normal,
- defaultPositiveStyle = styles.positive.normal,
- reductionStyle = styles.reduction.normal,
- reductionPositiveStyle = styles.reductionPositive.normal,
- markerSettings = {"class": "dxc-markers"};
- that._applyMarkerClipRect(markerSettings);
- defaultStyle["class"] = "default-markers";
- defaultPositiveStyle["class"] = "default-positive-markers";
- reductionStyle["class"] = "reduction-markers";
- reductionPositiveStyle["class"] = "reduction-positive-markers";
- that._createGroup("_markersGroup", that, that._group, markerSettings);
- markersGroup = that._markersGroup;
- that._createGroup("defaultMarkersGroup", markersGroup, markersGroup, defaultStyle);
- that._createGroup("reductionMarkersGroup", markersGroup, markersGroup, reductionStyle);
- that._createGroup("defaultPositiveMarkersGroup", markersGroup, markersGroup, defaultPositiveStyle);
- that._createGroup("reductionPositiveMarkersGroup", markersGroup, markersGroup, reductionPositiveStyle)
- },
- _createGroups: function() {
- scatterSeries._createGroups.call(this, false)
- },
- _clearingAnimation: function(translators, drawComplete) {
- drawComplete()
- },
- _getCreatingPointOptions: function() {
- var that = this,
- defaultPointOptions,
- creatingPointOptions = that._predefinedPointOptions;
- if (!creatingPointOptions) {
- defaultPointOptions = this._getPointOptions();
- that._predefinedPointOptions = creatingPointOptions = _extend(true, {styles: {}}, defaultPointOptions);
- creatingPointOptions.styles.normal = creatingPointOptions.styles.positive.normal = creatingPointOptions.styles.reduction.normal = creatingPointOptions.styles.reductionPositive.normal = {"stroke-width": defaultPointOptions.styles && defaultPointOptions.styles.normal && defaultPointOptions.styles.normal["stroke-width"]}
- }
- return creatingPointOptions
- },
- _checkData: function(data) {
- return _isDefined(data.argument) && data.highValue !== undefined && data.lowValue !== undefined && data.openValue !== undefined && data.closeValue !== undefined
- },
- _processRange: function(point, prevPoint) {
- rangeCalculator.processTwoValues(this, point, prevPoint, "highValue", "lowValue")
- },
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- rangeCalculator.calculateRangeData(this, zoomArgs, calcIntervalFunction, "highValue", "lowValue");
- rangeCalculator.addRangeSeriesLabelPaddings(this);
- return this._rangeData
- },
- _getPointData: function(data, options) {
- var that = this,
- level,
- openValueField = options.openValueField || "open",
- closeValueField = options.closeValueField || "close",
- highValueField = options.highValueField || "high",
- lowValueField = options.lowValueField || "low",
- reductionValue;
- that.level = options.reduction.level;
- switch ((that.level || "").toLowerCase()) {
- case"open":
- level = openValueField;
- break;
- case"high":
- level = highValueField;
- break;
- case"low":
- level = lowValueField;
- break;
- default:
- level = closeValueField;
- that.level = "close";
- break
- }
- reductionValue = data[level];
- return {
- argument: data[options.argumentField || "date"],
- highValue: data[highValueField],
- lowValue: data[lowValueField],
- closeValue: data[closeValueField],
- openValue: data[openValueField],
- reductionValue: reductionValue,
- tag: data[options.tagField || "tag"],
- isReduction: that._checkReduction(reductionValue)
- }
- },
- _parsePointStyle: function(style, defaultColor, innerColor) {
- return {
- stroke: style.color || defaultColor,
- "stroke-width": style.width,
- fill: style.color || innerColor
- }
- },
- updateTeamplateFieldNames: function() {
- var that = this,
- options = that._options,
- valueFields = that.getValueFields(),
- name = that.name;
- options.openValueField = valueFields[0] + name;
- options.highValueField = valueFields[1] + name;
- options.lowValueField = valueFields[2] + name;
- options.closeValueField = valueFields[3] + name;
- options.tagField = that.getTagField() + name
- },
- _getDefaultStyle: function(options, isCustomPointOptions) {
- var that = this,
- mainPointColor = options.color || that._options.mainSeriesColor;
- return {
- normal: that._parsePointStyle(options, mainPointColor, mainPointColor, isCustomPointOptions),
- hover: that._parsePointStyle(options.hoverStyle, mainPointColor, mainPointColor, isCustomPointOptions),
- selection: that._parsePointStyle(options.selectionStyle, mainPointColor, mainPointColor, isCustomPointOptions)
- }
- },
- _getReductionStyle: function(options, isCustomPointOptions) {
- var that = this,
- reductionColor = options.reduction.color;
- return {
- normal: that._parsePointStyle({
- color: reductionColor,
- width: options.width,
- hatching: options.hatching
- }, reductionColor, reductionColor, isCustomPointOptions),
- hover: that._parsePointStyle(options.hoverStyle, reductionColor, reductionColor, isCustomPointOptions),
- selection: that._parsePointStyle(options.selectionStyle, reductionColor, reductionColor, isCustomPointOptions)
- }
- },
- _createPointStyles: function(pointOptions, isCustomPointOptions) {
- var that = this,
- innerColor = that._options.innerColor,
- styles = that._getDefaultStyle(pointOptions, isCustomPointOptions),
- positiveStyle,
- reductionStyle,
- reductionPositiveStyle;
- positiveStyle = _extend(true, {}, styles);
- reductionStyle = that._getReductionStyle(pointOptions, isCustomPointOptions);
- reductionPositiveStyle = _extend(true, {}, reductionStyle);
- positiveStyle.normal.fill = positiveStyle.hover.fill = positiveStyle.selection.fill = innerColor;
- reductionPositiveStyle.normal.fill = reductionPositiveStyle.hover.fill = reductionPositiveStyle.selection.fill = innerColor;
- styles.positive = positiveStyle;
- styles.reduction = reductionStyle;
- styles.reductionPositive = reductionPositiveStyle;
- return styles
- },
- _endUpdateData: function() {
- delete this.prevLevelValue;
- delete this._predefinedPointOptions
- },
- _checkReduction: function(value) {
- var that = this,
- result = false;
- if (value !== null) {
- if (_isDefined(that.prevLevelValue))
- result = value < that.prevLevelValue;
- that.prevLevelValue = value
- }
- return result
- },
- _fusionPoints: function(fusionPoints, tick) {
- var fusedPointData = {},
- reductionLevel,
- highValue = -Infinity,
- lowValue = +Infinity,
- openValue,
- closeValue;
- if (!fusionPoints.length)
- return {};
- _each(fusionPoints, function(_, point) {
- if (!point.hasValue())
- return;
- highValue = Math.max(highValue, point.highValue);
- lowValue = Math.min(lowValue, point.lowValue);
- openValue = openValue !== undefined ? openValue : point.openValue;
- closeValue = point.closeValue !== undefined ? point.closeValue : closeValue
- });
- fusedPointData.argument = tick;
- fusedPointData.openValue = openValue;
- fusedPointData.closeValue = closeValue;
- fusedPointData.highValue = highValue;
- fusedPointData.lowValue = lowValue;
- fusedPointData.tag = null;
- switch ((this.level || "").toLowerCase()) {
- case"open":
- reductionLevel = openValue;
- break;
- case"high":
- reductionLevel = highValue;
- break;
- case"low":
- reductionLevel = lowValue;
- break;
- default:
- reductionLevel = closeValue;
- break
- }
- fusedPointData.reductionValue = reductionLevel;
- fusedPointData.isReduction = this._checkReduction(reductionLevel);
- return fusedPointData
- },
- _getPointSize: function() {
- return DEFAULT_FINANCIAL_POINT_SIZE
- },
- getValueFields: function() {
- var options = this._options;
- return [options.openValueField || "open", options.highValueField || "high", options.lowValueField || "low", options.closeValueField || "close"]
- },
- getArgumentField: function() {
- return this._options.argumentField || "date"
- },
- _beginUpdateData: _noop
- });
- series.candlestick = _extend({}, series.stock, {
- _createPattern: barSeries._createPattern,
- _beginUpdateData: barSeries._beginUpdateData,
- _parsePointStyle: function(style, defaultColor, innerColor, isCustomPointOptions) {
- var color = this._createPattern(style.color || innerColor, style.hatching, isCustomPointOptions),
- base = series.stock._parsePointStyle.call(this, style, defaultColor, color);
- base.fill = color;
- return base
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file stackedSeries.js */
- (function($, DX) {
- var core = DX.viz.core,
- series = core.series,
- chartSeries = series.mixins.chart,
- polarSeries = series.mixins.polar,
- areaSeries = chartSeries.area,
- barSeries = chartSeries.bar,
- lineSeries = chartSeries.line,
- rangeCalculator = core.series.helpers.rangeDataCalculator,
- _extend = $.extend,
- utils = DX.utils,
- _noop = $.noop,
- baseStackedSeries = {
- _processRange: _noop,
- _getRangeCorrector: _noop,
- _fillErrorBars: _noop,
- _calculateErrorBars: _noop,
- _processStackedRange: function() {
- var that = this,
- prevPoint;
- that._resetRangeData();
- $.each(that.getAllPoints(), function(i, p) {
- rangeCalculator.processRange(that, p, prevPoint);
- prevPoint = p
- })
- },
- _getRangeData: function() {
- this._processStackedRange();
- return areaSeries._getRangeData.apply(this, arguments)
- }
- },
- baseFullStackedSeries = _extend({}, baseStackedSeries, {
- _getRangeData: function(zoomArgs, calcIntervalFunction) {
- var that = this;
- that._processStackedRange();
- rangeCalculator.calculateRangeData(that, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(that);
- rangeCalculator.processFullStackedRange(that);
- rangeCalculator.calculateRangeMinValue(that, zoomArgs);
- return that._rangeData
- },
- isFullStackedSeries: function() {
- return true
- }
- });
- chartSeries.stackedline = _extend({}, lineSeries, baseStackedSeries, {_getRangeData: function() {
- this._processStackedRange();
- return lineSeries._getRangeData.apply(this, arguments)
- }});
- chartSeries.stackedspline = _extend({}, chartSeries.spline, baseStackedSeries, {_getRangeData: chartSeries.stackedline._getRangeData});
- chartSeries.fullstackedline = _extend({}, lineSeries, baseFullStackedSeries, {_getRangeData: function(zoomArgs, calcIntervalFunction) {
- var that = this;
- that._processStackedRange();
- rangeCalculator.calculateRangeData(that, zoomArgs, calcIntervalFunction);
- rangeCalculator.addLabelPaddings(that);
- rangeCalculator.processFullStackedRange(that);
- return that._rangeData
- }});
- chartSeries.fullstackedspline = _extend({}, chartSeries.spline, baseFullStackedSeries, {_getRangeData: chartSeries.fullstackedline._getRangeData});
- chartSeries.stackedbar = _extend({}, barSeries, baseStackedSeries, {_getRangeData: function() {
- this._processStackedRange();
- return barSeries._getRangeData.apply(this, arguments)
- }});
- chartSeries.fullstackedbar = _extend({}, barSeries, baseFullStackedSeries, {_getRangeData: function() {
- var rangeData = baseFullStackedSeries._getRangeData.apply(this, arguments);
- rangeData.arg.stick = false;
- return rangeData
- }});
- function clonePoint(point, value, minValue, position) {
- point = utils.clone(point);
- point.value = value;
- point.minValue = minValue;
- point.translate();
- point.argument = point.argument + position;
- return point
- }
- function preparePointsForStackedAreaSegment(points) {
- points = $.map(points, function(p) {
- var result = [p];
- if (p.leftHole)
- result = [clonePoint(p, p.leftHole, p.minLeftHole, "left"), p];
- if (p.rightHole)
- result.push(clonePoint(p, p.rightHole, p.minRightHole, "right"));
- return result
- });
- return points
- }
- chartSeries.stackedarea = _extend({}, areaSeries, baseStackedSeries, {_prepareSegment: function(points, rotated) {
- return areaSeries._prepareSegment.call(this, preparePointsForStackedAreaSegment(points, this._prevSeries), rotated)
- }});
- function getPointsByArgFromPrevSeries(prevSeries, argument) {
- var result;
- while (prevSeries) {
- result = prevSeries._segmentByArg[argument];
- if (result)
- break;
- prevSeries = prevSeries._prevSeries
- }
- return result
- }
- chartSeries.stackedsplinearea = _extend({}, chartSeries.splinearea, baseStackedSeries, {_prepareSegment: function(points, rotated) {
- var that = this,
- areaSegment;
- points = preparePointsForStackedAreaSegment(points, that._prevSeries);
- if (!this._prevSeries || points.length === 1)
- areaSegment = chartSeries.splinearea._prepareSegment.call(this, points, rotated);
- else {
- var fwPoints = chartSeries.spline._calculateBezierPoints(points, rotated),
- bwPoints = $.map(points, function(p) {
- var point = p.getCoords(true);
- point.argument = p.argument;
- return point
- }),
- prevSeriesFwPoints = $.map(that._prevSeries._segments, function(seg) {
- return seg.line
- }),
- pointByArg = {};
- $.each(prevSeriesFwPoints, function(_, p) {
- if (p.argument !== null) {
- var argument = p.argument.valueOf();
- if (!pointByArg[argument])
- pointByArg[argument] = [p];
- else
- pointByArg[argument].push(p)
- }
- });
- that._prevSeries._segmentByArg = pointByArg;
- bwPoints = chartSeries.spline._calculateBezierPoints(bwPoints, rotated);
- $.each(bwPoints, function(i, p) {
- var argument = p.argument.valueOf(),
- prevSeriesPoints;
- if (i % 3 === 0) {
- prevSeriesPoints = pointByArg[argument] || getPointsByArgFromPrevSeries(that._prevSeries, argument);
- if (prevSeriesPoints) {
- bwPoints[i - 1] && prevSeriesPoints[0] && (bwPoints[i - 1] = prevSeriesPoints[0]);
- bwPoints[i + 1] && (bwPoints[i + 1] = prevSeriesPoints[2] || p)
- }
- }
- });
- areaSegment = {
- line: fwPoints,
- area: fwPoints.concat(bwPoints.reverse())
- };
- that._areaPointsToSplineAreaPoints(areaSegment.area)
- }
- return areaSegment
- }});
- chartSeries.fullstackedarea = _extend({}, areaSeries, baseFullStackedSeries, {_prepareSegment: chartSeries.stackedarea._prepareSegment});
- chartSeries.fullstackedsplinearea = _extend({}, chartSeries.splinearea, baseFullStackedSeries, {_prepareSegment: chartSeries.stackedsplinearea._prepareSegment});
- polarSeries.stackedbar = _extend({}, polarSeries.bar, baseStackedSeries, {_getRangeData: function() {
- this._processStackedRange();
- return polarSeries.bar._getRangeData.apply(this, arguments)
- }})
- })(jQuery, DevExpress);
- /*! Module viz-core, file basePoint.js */
- (function($, DX) {
- var seriesNS = DX.viz.core.series,
- statesConsts = seriesNS.helpers.consts.states,
- _each = $.each,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- seiresMixins = seriesNS.mixins,
- _noop = $.noop;
- function Point() {
- this.ctor.apply(this, arguments)
- }
- seriesNS.points = {Point: Point};
- Point.prototype = {
- ctor: function(series, dataItem, options) {
- this.series = series;
- this.update(dataItem, options);
- this._emptySettings = {
- fill: null,
- stroke: null,
- dashStyle: null
- }
- },
- getColor: function() {
- return this._styles.normal.fill || this.series.getColor()
- },
- _getStyle: function() {
- var that = this,
- styles = that._styles,
- style;
- if (that.isSelected())
- style = styles.selection;
- else if (that.isHovered())
- style = styles.hover;
- else {
- that.fullState = statesConsts.normalMark;
- style = styles.normal
- }
- that._currentStyle = style;
- return style
- },
- update: function(dataItem, options) {
- this.updateOptions(options);
- this.updateData(dataItem)
- },
- updateData: function(dataItem) {
- var that = this;
- that.argument = that.initialArgument = that.originalArgument = dataItem.argument;
- that.tag = dataItem.tag;
- that.index = dataItem.index;
- that.lowError = dataItem.lowError;
- that.highError = dataItem.highError;
- that._updateData(dataItem);
- !that.hasValue() && that.setInvisibility();
- that._fillStyle();
- that._updateLabelData()
- },
- deleteMarker: function() {
- var that = this;
- if (that.graphic)
- that.graphic.dispose();
- that.graphic = null
- },
- _drawErrorBar: _noop,
- draw: function(renderer, groups, animationEnabled, firstDrawing) {
- var that = this;
- if (that._needDeletingOnDraw) {
- that.deleteMarker();
- that._needDeletingOnDraw = false
- }
- if (that._needClearingOnDraw) {
- that.clearMarker();
- that._needClearingOnDraw = false
- }
- if (!that._hasGraphic())
- that._getMarkerVisibility() && that._drawMarker(renderer, groups.markers, animationEnabled, firstDrawing);
- else
- that._updateMarker(animationEnabled, undefined, groups.markers);
- that._drawLabel(renderer, groups.labels);
- that._drawErrorBar(renderer, groups.errorBars, animationEnabled)
- },
- applyStyle: function(style) {
- var that = this;
- if (that.graphic) {
- if (style === "normal") {
- if (that.isHovered()) {
- that.applyStyle("hover");
- return
- }
- that.clearMarker()
- }
- else
- that.graphic.toForeground();
- that._currentStyle = that._styles[style];
- that._updateMarker(true, that._currentStyle)
- }
- },
- setHoverState: function() {
- this.series.setPointHoverState(this)
- },
- releaseHoverState: function(callback) {
- var that = this;
- that.series.releasePointHoverState(that, callback);
- if (that.graphic)
- !that.isSelected() && that.graphic.toBackground()
- },
- setSelectedState: function() {
- this.series.setPointSelectedState(this)
- },
- releaseSelectedState: function() {
- this.series.releasePointSelectedState(this)
- },
- select: function() {
- this.series.selectPoint(this)
- },
- clearSelection: function() {
- this.series.deselectPoint(this)
- },
- showTooltip: function() {
- this.series.showPointTooltip(this)
- },
- hideTooltip: function() {
- this.series.hidePointTooltip(this)
- },
- _checkLabelsChanging: function(oldType, newType) {
- if (oldType) {
- var isNewRange = ~newType.indexOf("range"),
- isOldRange = ~oldType.indexOf("range");
- return isOldRange && !isNewRange || !isOldRange && isNewRange
- }
- else
- return false
- },
- updateOptions: function(newOptions) {
- if (!_isDefined(newOptions))
- return;
- var that = this,
- oldOptions = that._options,
- widgetType = newOptions.widgetType,
- oldType = oldOptions && oldOptions.type,
- newType = newOptions.type;
- if (seiresMixins[widgetType].pointTypes[oldType] !== seiresMixins[widgetType].pointTypes[newType]) {
- that._needDeletingOnDraw = true;
- that._needClearingOnDraw = false;
- that._checkLabelsChanging(oldType, newType) && that.deleteLabel();
- that._resetType(oldType, widgetType);
- that._setType(newType, widgetType)
- }
- else {
- that._needDeletingOnDraw = that._checkSymbol(oldOptions, newOptions);
- that._needClearingOnDraw = that._checkCustomize(oldOptions, newOptions)
- }
- that._options = newOptions;
- that._fillStyle();
- that._updateLabelOptions(seiresMixins[widgetType].pointTypes[newType])
- },
- translate: function(translators) {
- var that = this;
- that.translators = translators || that.translators;
- that.translators && that.hasValue() && that._translate(that.translators)
- },
- _checkCustomize: function(oldOptions, newOptions) {
- return oldOptions.styles.usePointCustomOptions && !newOptions.styles.usePointCustomOptions
- },
- _getCustomLabelVisibility: function() {
- return this._styles.useLabelCustomOptions ? !!this._options.label.visible : null
- },
- getBoundingRect: function() {
- return this._getGraphicBbox()
- },
- _resetType: function(type, widgetType) {
- var that = this;
- if (type)
- _each(seriesNS.points.mixins[seiresMixins[widgetType].pointTypes[type]], function(methodName) {
- delete that[methodName]
- })
- },
- _setType: function(type, widgetType) {
- var that = this;
- _each(seriesNS.points.mixins[seiresMixins[widgetType].pointTypes[type]], function(methodName, method) {
- that[methodName] = method
- })
- },
- isInVisibleArea: function() {
- return this.inVisibleArea
- },
- isSelected: function() {
- return !!(this.fullState & statesConsts.selectedMark)
- },
- isHovered: function() {
- return !!(this.fullState & statesConsts.hoverMark)
- },
- getOptions: function() {
- return this._options
- },
- animate: function(complete, settings, partitionDuration) {
- if (!this.graphic) {
- complete && complete();
- return
- }
- this.graphic.animate(settings, {partitionDuration: partitionDuration}, complete)
- },
- getCoords: function(min) {
- var that = this;
- if (!min)
- return {
- x: that.x,
- y: that.y
- };
- if (!that._options.rotated)
- return {
- x: that.x,
- y: that.minY
- };
- return {
- x: that.minX,
- y: that.y
- }
- },
- getDefaultCoords: function() {
- var that = this;
- return !that._options.rotated ? {
- x: that.x,
- y: that.defaultY
- } : {
- x: that.defaultX,
- y: that.y
- }
- },
- _calculateVisibility: function(x, y, width, height) {
- var that = this,
- visibleAreaX,
- visibleAreaY,
- rotated = that._options.rotated;
- if (that.translators) {
- visibleAreaX = that.translators.x.getCanvasVisibleArea();
- visibleAreaY = that.translators.y.getCanvasVisibleArea();
- if (visibleAreaX.min > x + (width || 0) || visibleAreaX.max < x || visibleAreaY.min > y + (height || 0) || visibleAreaY.max < y || rotated && _isDefined(width) && width !== 0 && (visibleAreaX.min === x + width || visibleAreaX.max === x) || !rotated && _isDefined(height) && height !== 0 && (visibleAreaY.min === y + height || visibleAreaY.max === y))
- that.inVisibleArea = false;
- else
- that.inVisibleArea = true
- }
- },
- correctPosition: _noop,
- hasValue: function() {
- return this.value !== null && this.minValue !== null
- },
- getBoundaryCoords: function() {
- return this.getBoundingRect()
- },
- getCrosshairCoords: _noop,
- getPointRadius: _noop,
- _populatePointShape: _noop,
- _checkSymbol: _noop,
- getMarkerCoords: _noop,
- hide: _noop,
- show: _noop,
- hideMarker: _noop,
- setInvisibility: _noop,
- clearVisibility: _noop,
- isVisible: _noop,
- resetCorrection: _noop,
- correctValue: _noop,
- setPercentValue: _noop,
- correctCoordinates: _noop,
- coordsIn: _noop,
- getTooltipParams: _noop,
- setLabelEllipsis: _noop,
- updateLabelCoord: _noop,
- drawLabel: _noop,
- dispose: function() {
- var that = this;
- that.deleteMarker();
- that.deleteLabel();
- that._errorBar && this._errorBar.dispose();
- that._options = that._styles = that.series = that.translators = that._errorBar = null
- },
- getTooltipFormatObject: function(tooltip) {
- var that = this,
- tooltipFormatObject = that._getFormatObject(tooltip),
- sharedTooltipValuesArray = [],
- tooltipStackPointsFormatObject = [];
- if (that.stackPoints) {
- _each(that.stackPoints, function(_, point) {
- if (!point.isVisible())
- return;
- var formatObject = point._getFormatObject(tooltip);
- tooltipStackPointsFormatObject.push(formatObject);
- sharedTooltipValuesArray.push(formatObject.seriesName + ": " + formatObject.valueText)
- });
- _extend(tooltipFormatObject, {
- points: tooltipStackPointsFormatObject,
- valueText: sharedTooltipValuesArray.join("\n"),
- stackName: that.stackPoints.stackName
- })
- }
- return tooltipFormatObject
- },
- setHole: function(holeValue, position) {
- var that = this,
- minValue = isFinite(that.minValue) ? that.minValue : 0;
- if (_isDefined(holeValue))
- if (position === "left") {
- that.leftHole = that.value - holeValue;
- that.minLeftHole = minValue - holeValue
- }
- else {
- that.rightHole = that.value - holeValue;
- that.minRightHole = minValue - holeValue
- }
- },
- resetHoles: function() {
- this.leftHole = null;
- this.minLeftHole = null;
- this.rightHole = null;
- this.minRightHole = null
- },
- getLabel: function() {
- return this._label
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file label.js */
- (function(DX, $, undefined) {
- var _degreesToRadians = DX.utils.degreesToRadians,
- _patchFontOptions = DX.viz.core.utils.patchFontOptions,
- _round = Math.round,
- _abs = Math.abs,
- _min = Math.min,
- _max = Math.max,
- _ceil = Math.ceil,
- _getCosAndSin = DX.utils.getCosAndSin,
- _rotateBBox = DX.viz.renderers.rotateBBox,
- LABEL_BACKGROUND_PADDING_X = 8,
- LABEL_BACKGROUND_PADDING_Y = 4;
- function getClosestCoord(point, coords) {
- var closestDistase = Infinity,
- closestCoord;
- $.each(coords, function(_, coord) {
- var x = point[0] - coord[0],
- y = point[1] - coord[1],
- distance = x * x + y * y;
- if (distance < closestDistase) {
- closestDistase = distance;
- closestCoord = coord
- }
- });
- return closestCoord
- }
- var barPointStrategy = {
- isLabelInside: function(labelPoint, figure) {
- return labelPoint.x >= figure.x && labelPoint.x <= figure.x + figure.width && labelPoint.y >= figure.y && labelPoint.y <= figure.y + figure.height
- },
- prepareLabelPoints: function(points, center, angle, hasBackground) {
- return !hasBackground ? points : [center]
- },
- getFigureCenter: function(figure) {
- return [figure.x + figure.width / 2, figure.y + figure.height / 2]
- },
- findFigurePoint: function(figure, labelPoint) {
- var figureCenter = barPointStrategy.getFigureCenter(figure),
- point = getClosestCoord(labelPoint, [[figure.x, figureCenter[1]], [figureCenter[0], figure.y + figure.height], [figure.x + figure.width, figureCenter[1]], [figureCenter[0], figure.y]]);
- return [_round(point[0]), _round(point[1])]
- }
- };
- var symbolPointStrategy = {
- isLabelInside: function() {
- return false
- },
- prepareLabelPoints: barPointStrategy.prepareLabelPoints,
- getFigureCenter: function(figure) {
- return [figure.x, figure.y]
- },
- findFigurePoint: function(figure, labelPoint) {
- var angle = Math.atan2(figure.y - labelPoint[1], labelPoint[0] - figure.x);
- return [_round(figure.x + figure.r * Math.cos(angle)), _round(figure.y - figure.r * Math.sin(angle))]
- }
- };
- var piePointStrategy = {
- isLabelInside: function(_0, _1, isOutside) {
- return !isOutside
- },
- prepareLabelPoints: function(points, center, angle) {
- var rotatedPoints = [],
- x0 = center[0],
- y0 = center[1],
- cossin = _getCosAndSin(angle || 0);
- $.each(points, function(_, point) {
- rotatedPoints.push([_round((point[0] - x0) * cossin.cos + (point[1] - y0) * cossin.sin + x0), _round(-(point[0] - x0) * cossin.sin + (point[1] - y0) * cossin.cos + y0)])
- });
- return rotatedPoints
- },
- getFigureCenter: symbolPointStrategy.getFigureCenter,
- findFigurePoint: function(figure, labelPoint) {
- var x = figure.x + (figure.y - labelPoint[1]) / Math.tan(_degreesToRadians(figure.angle)),
- point = [figure.x, figure.y];
- if (figure.x <= x && x <= labelPoint[0] || figure.x >= x && x >= labelPoint[0])
- point.push(_round(x), labelPoint[1]);
- return point
- }
- };
- function selectStrategy(figure) {
- return figure.angle !== undefined && piePointStrategy || figure.r !== undefined && symbolPointStrategy || barPointStrategy
- }
- function disposeItem(obj, field) {
- obj[field] && obj[field].dispose();
- obj[field] = null
- }
- function checkBackground(background) {
- return background && (background.fill && background.fill !== "none" || background["stroke-width"] > 0 && background.stroke && background.stroke !== "none")
- }
- function checkConnector(connector) {
- return connector && connector["stroke-width"] > 0 && connector.stroke && connector.stroke !== "none"
- }
- function formatValue(value, format, precision) {
- return DX.formatHelper.format(value, format, precision)
- }
- function formatText(data, options) {
- var format = options.format,
- precision = options.precision;
- data.valueText = formatValue(data.value, format, precision);
- data.argumentText = formatValue(data.argument, options.argumentFormat, options.argumentPrecision);
- if (data.percent !== undefined)
- data.percentText = formatValue(data.percent, "percent", options.percentPrecision);
- if (data.total !== undefined)
- data.totalText = formatValue(data.total, format, precision);
- if (data.openValue !== undefined)
- data.openValueText = formatValue(data.openValue, format, precision);
- if (data.closeValue !== undefined)
- data.closeValueText = formatValue(data.closeValue, format, precision);
- if (data.lowValue !== undefined)
- data.lowValueText = formatValue(data.lowValue, format, precision);
- if (data.highValue !== undefined)
- data.highValueText = formatValue(data.highValue, format, precision);
- if (data.reductionValue !== undefined)
- data.reductionValueText = formatValue(data.reductionValue, format, precision);
- return options.customizeText ? options.customizeText.call(data, data) : data.valueText
- }
- function Label(){}
- Label.prototype = {
- constructor: Label,
- _setVisibility: function(value, state) {
- this._group && this._group.attr({visibility: value});
- this._visible = state
- },
- clearVisibility: function() {
- this._setVisibility(null, true)
- },
- hide: function() {
- this._setVisibility("hidden", false)
- },
- show: function() {
- this._setVisibility("visible", true)
- },
- isVisible: function() {
- return this._visible
- },
- setColor: function(color) {
- this._color = color
- },
- setOptions: function(options) {
- this._options = options
- },
- setData: function(data) {
- this._data = data
- },
- setDataField: function(fieldName, fieldValue) {
- this._data = this._data || {};
- this._data[fieldName] = fieldValue
- },
- getData: function() {
- return this._data
- },
- setFigureToDrawConnector: function(figure) {
- this._figure = figure
- },
- dispose: function() {
- var that = this;
- disposeItem(that, "_group");
- that._data = that._options = that._textContent = that._visible = that._insideGroup = that._text = that._background = that._connector = that._figure = null
- },
- draw: function(renderer, container, customVisibility) {
- var that = this,
- options = that._options || {},
- text = that._textContent = formatText(that._data, that._options) || null;
- that.clearVisibility();
- if (text) {
- if (!that._group) {
- that._group = renderer.g().append(container);
- that._insideGroup = renderer.g().append(that._group);
- that._text = renderer.text("", 0, 0).append(that._insideGroup)
- }
- that._text.css(options.attributes ? _patchFontOptions(options.attributes.font) : {});
- if (checkBackground(options.background)) {
- that._background = that._background || renderer.rect().append(that._insideGroup).toBackground();
- that._background.attr(options.background);
- that._color && that._background.attr({fill: that._color})
- }
- else
- disposeItem(that, "_background");
- if (checkConnector(options.connector)) {
- that._connector = that._connector || renderer.path([], "line").sharp().append(that._group).toBackground();
- that._connector.attr(options.connector);
- that._color && that._connector.attr({stroke: that._color})
- }
- else
- disposeItem(that, "_connector");
- that._updateText(text);
- if (customVisibility !== null)
- customVisibility ? that.show() : that.hide()
- }
- else
- that.hide();
- return that
- },
- _updateText: function(text) {
- var that = this,
- bbox = that._text.attr({text: text}).getBBox();
- that._textSize = [bbox.width, bbox.height];
- if (that._background) {
- bbox.x -= LABEL_BACKGROUND_PADDING_X;
- bbox.y -= LABEL_BACKGROUND_PADDING_Y;
- bbox.width += 2 * LABEL_BACKGROUND_PADDING_X;
- bbox.height += 2 * LABEL_BACKGROUND_PADDING_Y;
- that._background.attr(bbox)
- }
- that._labelSize = [bbox.width / 2, bbox.height / 2];
- if (that._options.rotationAngle) {
- that._insideGroup.rotate(that._options.rotationAngle, bbox.x + bbox.width / 2, bbox.y + bbox.height / 2);
- bbox = _rotateBBox(bbox, [bbox.x + bbox.width / 2, bbox.y + bbox.height / 2], -that._options.rotationAngle)
- }
- that._bbox = bbox
- },
- _getConnectorPoints: function() {
- var that = this,
- figure = that._figure,
- strategy = selectStrategy(figure),
- bbox = that.getBoundingRect(),
- labelPoint,
- figurePoint,
- xc,
- yc,
- points = [];
- if (!strategy.isLabelInside(bbox, figure, that._options.position !== "inside")) {
- xc = bbox.x + bbox.width / 2;
- yc = bbox.y + bbox.height / 2;
- points = strategy.prepareLabelPoints([[xc, yc - that._labelSize[1]], [xc + that._labelSize[0], yc], [xc, yc + that._labelSize[1]], [xc - that._labelSize[0], yc]], [xc, yc], -that._options.rotationAngle || 0, !!that._background);
- labelPoint = getClosestCoord(strategy.getFigureCenter(figure), points);
- labelPoint = [_round(labelPoint[0]), _round(labelPoint[1])];
- figurePoint = strategy.findFigurePoint(figure, labelPoint);
- points = figurePoint.concat(labelPoint)
- }
- return points
- },
- fit: function(size) {
- var that = this;
- if (!that._textContent)
- return that;
- var cossin = _getCosAndSin(-that._options.rotationAngle || 0),
- textSize = _min(_abs(that._textSize[0] / cossin.cos), _abs(that._textSize[1] / cossin.sin)),
- requiredTextSize = _min(_abs(size.width / cossin.cos), _abs(size.height / cossin.sin)),
- text = that._textContent,
- i,
- ii,
- line,
- lines,
- lineLength,
- requiredLineLength;
- if (textSize > requiredTextSize) {
- lines = text.split("<br/>");
- for (i = 0, ii = lines.length, lineLength = 0; i < ii; ++i) {
- line = lines[i] = lines[i].replace(/<[^>]+>/g, '');
- lineLength = _max(lineLength, line.length)
- }
- requiredLineLength = _ceil(lineLength * requiredTextSize / textSize);
- for (i = 0; i < ii; ++i)
- lines[i] = (line = lines[i]).length > requiredLineLength ? line.substr(0, requiredLineLength - 4) + "..." : line;
- text = lines.join("<br/>")
- }
- that._updateText(text);
- return that
- },
- shift: function(x, y) {
- var that = this;
- if (that._textContent) {
- that._insideGroup.attr({
- translateX: that._x = _round(x - that._bbox.x),
- translateY: that._y = _round(y - that._bbox.y)
- });
- if (that._connector)
- that._connector.attr({points: that._getConnectorPoints()})
- }
- return that
- },
- getBoundingRect: function() {
- var bbox = this._bbox;
- return this._textContent ? {
- x: bbox.x + this._x,
- y: bbox.y + this._y,
- width: bbox.width,
- height: bbox.height
- } : {}
- },
- getLayoutOptions: function() {
- var options = this._options;
- return {
- alignment: options.alignment,
- background: checkBackground(options.background),
- horizontalOffset: options.horizontalOffset,
- verticalOffset: options.verticalOffset,
- radialOffset: options.radialOffset,
- position: options.position
- }
- }
- };
- DX.viz.core.series.points.Label = Label;
- Label._DEBUG_formatText = formatText
- })(DevExpress, jQuery);
- /*! Module viz-core, file symbolPoint.js */
- (function($, DX) {
- var core = DX.viz.core,
- seriesNS = core.series,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _math = Math,
- _round = _math.round,
- _floor = _math.floor,
- _ceil = _math.ceil,
- _abs = _math.abs,
- DEFAULT_IMAGE_WIDTH = 20,
- DEFAULT_IMAGE_HEIGHT = 20,
- LABEL_OFFSET = 10,
- CANVAS_POSITION_DEFAULT = "canvas_position_default";
- function getSquareMarkerCoords(radius) {
- return [-radius, -radius, radius, -radius, radius, radius, -radius, radius, -radius, -radius]
- }
- function getPolygonMarkerCoords(radius) {
- var r = _ceil(radius);
- return [-r, 0, 0, -r, r, 0, 0, r, -r, 0]
- }
- function getCrossMarkerCoords(radius) {
- var r = _ceil(radius),
- floorHalfRadius = _floor(r / 2),
- ceilHalfRadius = _ceil(r / 2);
- return [-r, -floorHalfRadius, -floorHalfRadius, -r, 0, -ceilHalfRadius, floorHalfRadius, -r, r, -floorHalfRadius, ceilHalfRadius, 0, r, floorHalfRadius, floorHalfRadius, r, 0, ceilHalfRadius, -floorHalfRadius, r, -r, floorHalfRadius, -ceilHalfRadius, 0]
- }
- function getTriangleDownMarkerCoords(radius) {
- return [-radius, -radius, radius, -radius, 0, radius, -radius, -radius]
- }
- function getTriangleUpMarkerCoords(radius) {
- return [-radius, radius, radius, radius, 0, -radius, -radius, radius]
- }
- seriesNS.points.mixins = seriesNS.points.mixins || {};
- seriesNS.points.mixins.symbolPoint = {
- deleteLabel: function() {
- this._label.dispose();
- this._label = null
- },
- _hasGraphic: function() {
- return this.graphic
- },
- clearVisibility: function() {
- var that = this,
- graphic = that.graphic;
- if (graphic && graphic.attr("visibility"))
- graphic.attr({visibility: null});
- that._label.clearVisibility()
- },
- isVisible: function() {
- return this.inVisibleArea && this.series.isVisible()
- },
- setInvisibility: function() {
- var that = this,
- graphic = that.graphic;
- if (graphic && graphic.attr("visibility") !== "hidden")
- graphic.attr({visibility: "hidden"});
- that._errorBar && that._errorBar.attr({visibility: "hidden"});
- that._label.hide()
- },
- clearMarker: function() {
- var graphic = this.graphic;
- graphic && graphic.attr(this._emptySettings)
- },
- setAdjustSeriesLabels: function(adjustSeriesLabels) {
- this.adjustSeriesLabels = adjustSeriesLabels
- },
- _createLabel: function() {
- this._label = core.CoreFactory.createLabel()
- },
- _updateLabelData: function() {
- this._label.setData(this._getLabelFormatObject())
- },
- _updateLabelOptions: function() {
- !this._label && this._createLabel();
- this._label.setOptions(this._options.label)
- },
- _checkImage: function(image) {
- return _isDefined(image) && (typeof image === "string" || _isDefined(image.url))
- },
- _fillStyle: function() {
- this._styles = this._options.styles
- },
- _checkSymbol: function(oldOptions, newOptions) {
- var oldSymbol = oldOptions.symbol,
- newSymbol = newOptions.symbol,
- symbolChanged = oldSymbol === "circle" && newSymbol !== "circle" || oldSymbol !== "circle" && newSymbol === "circle",
- imageChanged = this._checkImage(oldOptions.image) !== this._checkImage(newOptions.image);
- return !!(symbolChanged || imageChanged)
- },
- _populatePointShape: function(symbol, radius) {
- switch (symbol) {
- case"square":
- return getSquareMarkerCoords(radius);
- case"polygon":
- return getPolygonMarkerCoords(radius);
- case"triangle":
- case"triangleDown":
- return getTriangleDownMarkerCoords(radius);
- case"triangleUp":
- return getTriangleUpMarkerCoords(radius);
- case"cross":
- return getCrossMarkerCoords(radius)
- }
- },
- correctValue: function(correction) {
- var that = this;
- if (that.hasValue()) {
- that.value = that.initialValue + correction;
- that.minValue = correction;
- that.translate()
- }
- },
- resetCorrection: function() {
- this.value = this.initialValue;
- this.minValue = CANVAS_POSITION_DEFAULT
- },
- _getTranslates: function(animationEnabled) {
- var translateX = this.x,
- translateY = this.y;
- if (animationEnabled)
- if (this._options.rotated)
- translateX = this.defaultX;
- else
- translateY = this.defaultY;
- return {
- x: translateX,
- y: translateY
- }
- },
- _createImageMarker: function(renderer, settings, options) {
- var width = options.width || DEFAULT_IMAGE_WIDTH,
- height = options.height || DEFAULT_IMAGE_HEIGHT;
- return renderer.image(-_round(width * 0.5), -_round(height * 0.5), width, height, options.url ? options.url.toString() : options.toString(), "center").attr({
- translateX: settings.translateX,
- translateY: settings.translateY,
- visibility: settings.visibility
- })
- },
- _createSymbolMarker: function(renderer, pointSettings) {
- var marker,
- options = this._options;
- switch (options.symbol) {
- case"circle":
- delete pointSettings.points;
- marker = renderer.circle().attr(pointSettings);
- break;
- case"square":
- case"polygon":
- case"triangle":
- case"triangleDown":
- case"triangleUp":
- case"cross":
- marker = renderer.path([], "area").attr(pointSettings).sharp();
- break
- }
- return marker
- },
- _createMarker: function(renderer, group, image, settings, animationEnabled) {
- var that = this,
- marker = that._checkImage(image) ? that._createImageMarker(renderer, settings, image) : that._createSymbolMarker(renderer, settings, animationEnabled);
- if (marker)
- marker.data({point: that}).append(group);
- return marker
- },
- _getSymbolBbox: function(x, y, r) {
- return {
- x: x - r,
- y: y - r,
- width: r * 2,
- height: r * 2
- }
- },
- _getImageBbox: function(x, y) {
- var image = this._options.image,
- width = image.width || DEFAULT_IMAGE_WIDTH,
- height = image.height || DEFAULT_IMAGE_HEIGHT;
- return {
- x: x - _round(width / 2),
- y: y - _round(height / 2),
- width: width,
- height: height
- }
- },
- _getGraphicBbox: function() {
- var that = this,
- options = that._options,
- x = that.x,
- y = that.y,
- bbox;
- if (options.visible)
- bbox = that._checkImage(options.image) ? that._getImageBbox(x, y) : that._getSymbolBbox(x, y, options.styles.normal.r);
- else
- bbox = {
- x: x,
- y: y,
- width: 0,
- height: 0
- };
- return bbox
- },
- _getVisibleArea: function() {
- var translators = this.translators,
- visibleX,
- visibleY;
- if (translators) {
- visibleX = translators.x.getCanvasVisibleArea();
- visibleY = translators.y.getCanvasVisibleArea();
- return {
- minX: visibleX.min,
- maxX: visibleX.max,
- minY: visibleY.min,
- maxY: visibleY.max
- }
- }
- },
- _isLabelInsidePoint: $.noop,
- _getShiftLabelCoords: function(label) {
- var coord = this._addLabelAlignmentAndOffset(label, this._getLabelCoords(label));
- return this._checkLabelPosition(label, coord)
- },
- _drawLabel: function(renderer, group) {
- var that = this,
- customVisibility = that._getCustomLabelVisibility(),
- coord,
- label = that._label;
- if ((that.series.getLabelVisibility() || customVisibility !== null) && that.hasValue() && that._showForZeroValues()) {
- label.draw(renderer, group, customVisibility);
- if (!that._isLabelInsidePoint(label)) {
- coord = that._getShiftLabelCoords(label);
- label.setFigureToDrawConnector(that._getLabelConnector());
- label.shift(_round(coord.x), _round(coord.y))
- }
- }
- else
- label.hide()
- },
- _showForZeroValues: function() {
- return true
- },
- _getLabelConnector: function() {
- var bbox = this._getGraphicBbox(),
- w2 = bbox.width / 2,
- h2 = bbox.height / 2;
- return {
- x: bbox.x + w2,
- y: bbox.y + h2,
- r: this._options.visible ? Math.max(w2, h2) : 0
- }
- },
- _getPositionFromLocation: function() {
- return {
- x: this.x,
- y: this.y
- }
- },
- _isPointInVisibleArea: function(visibleArea, graphicBbox) {
- return visibleArea.minX <= graphicBbox.x + graphicBbox.width && visibleArea.maxX >= graphicBbox.x && visibleArea.minY <= graphicBbox.y + graphicBbox.height && visibleArea.maxY >= graphicBbox.y
- },
- _checkLabelPosition: function(label, coord, pointPosition) {
- var that = this,
- visibleArea = that._getVisibleArea(),
- labelBbox = label.getBoundingRect(),
- graphicBbox = that._getGraphicBbox(pointPosition),
- offset = LABEL_OFFSET;
- if (that._isPointInVisibleArea(visibleArea, graphicBbox))
- if (!that._options.rotated) {
- if (visibleArea.minX > coord.x && that.adjustSeriesLabels)
- coord.x = visibleArea.minX;
- if (visibleArea.maxX < coord.x + labelBbox.width && that.adjustSeriesLabels)
- coord.x = visibleArea.maxX - labelBbox.width;
- if (visibleArea.minY > coord.y)
- coord.y = graphicBbox.y + graphicBbox.height + offset;
- if (visibleArea.maxY < coord.y + labelBbox.height)
- coord.y = graphicBbox.y - labelBbox.height - offset
- }
- else {
- if (visibleArea.minX > coord.x)
- coord.x = graphicBbox.x + graphicBbox.width + offset;
- if (visibleArea.maxX < coord.x + labelBbox.width)
- coord.x = graphicBbox.x - offset - labelBbox.width;
- if (visibleArea.minY > coord.y && that.adjustSeriesLabels)
- coord.y = visibleArea.minY;
- if (visibleArea.maxY < coord.y + labelBbox.height && that.adjustSeriesLabels)
- coord.y = visibleArea.maxY - labelBbox.height
- }
- return coord
- },
- _addLabelAlignmentAndOffset: function(label, coord) {
- var labelBBox = label.getBoundingRect(),
- labelOptions = label.getLayoutOptions();
- if (!this._options.rotated)
- if (labelOptions.alignment === "left")
- coord.x += labelBBox.width / 2;
- else if (labelOptions.alignment === "right")
- coord.x -= labelBBox.width / 2;
- coord.x += labelOptions.horizontalOffset;
- coord.y += labelOptions.verticalOffset;
- return coord
- },
- _getLabelCoords: function(label, pointPosition) {
- return this._getLabelCoordOfPosition(label, this._getLabelPosition(pointPosition), pointPosition)
- },
- _getLabelCoordOfPosition: function(label, position, pointPosition) {
- var that = this,
- labelBBox = label.getBoundingRect(),
- graphicBbox = that._getGraphicBbox(pointPosition),
- offset = LABEL_OFFSET,
- centerY = graphicBbox.height / 2 - labelBBox.height / 2,
- centerX = graphicBbox.width / 2 - labelBBox.width / 2,
- x = graphicBbox.x,
- y = graphicBbox.y;
- switch (position) {
- case"left":
- x -= labelBBox.width + offset;
- y += centerY;
- break;
- case"right":
- x += graphicBbox.width + offset;
- y += centerY;
- break;
- case"top":
- x += centerX;
- y -= labelBBox.height + offset;
- break;
- case"bottom":
- x += centerX;
- y += graphicBbox.height + offset;
- break;
- case"inside":
- x += centerX;
- y += centerY;
- break
- }
- return {
- x: x,
- y: y
- }
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var that = this,
- options = that._options,
- translates = that._getTranslates(animationEnabled),
- style = that._getStyle();
- that.graphic = that._createMarker(renderer, group, options.image, _extend({
- translateX: translates.x,
- translateY: translates.y,
- points: that._populatePointShape(options.symbol, style.r)
- }, style), animationEnabled)
- },
- _getErrorBarSettings: function() {
- return {visibility: "visible"}
- },
- _drawErrorBar: function(renderer, group) {
- var that = this,
- errorBarOptions = that._options.errorBars || {},
- points = [],
- settings,
- pos = that._errorBarPos,
- high = that._highErrorCoord,
- low = that._lowErrorCoord,
- displayMode = (errorBarOptions.displayMode + "").toLowerCase(),
- isHighDisplayMode = displayMode === "high",
- isLowDisplayMode = displayMode === "low",
- edgeLength = _floor(parseInt(errorBarOptions.edgeLength) / 2),
- highErrorOnly = (isHighDisplayMode || !_isDefined(low)) && _isDefined(high) && !isLowDisplayMode,
- lowErrorOnly = (isLowDisplayMode || !_isDefined(high)) && _isDefined(low) && !isHighDisplayMode;
- highErrorOnly && (low = that._baseErrorBarPos);
- lowErrorOnly && (high = that._baseErrorBarPos);
- if (displayMode !== "none" && _isDefined(high) && _isDefined(low) && _isDefined(pos)) {
- !lowErrorOnly && points.push([pos - edgeLength, high, pos + edgeLength, high]);
- points.push([pos, high, pos, low]);
- !highErrorOnly && points.push([pos + edgeLength, low, pos - edgeLength, low]);
- that._options.rotated && $.each(points, function(_, p) {
- p.reverse()
- });
- settings = that._getErrorBarSettings(errorBarOptions);
- if (!that._errorBar)
- that._errorBar = renderer.path(points, "line").attr(settings).append(group);
- else {
- settings.points = points;
- that._errorBar.attr(settings)
- }
- }
- else
- that._errorBar && that._errorBar.attr({visibility: "hidden"})
- },
- getTooltipParams: function() {
- var that = this,
- graphic = that.graphic;
- return {
- x: that.x,
- y: that.y,
- offset: graphic ? graphic.getBBox().height / 2 : 0
- }
- },
- hasValue: function() {
- return this.value !== null && this.minValue !== null
- },
- setPercentValue: function(total, fullStacked, leftHoleTotal, rightHoleTotal) {
- var that = this,
- valuePercent = _abs(that.value / total || 0),
- minValuePercent = _abs(that.minValue / total || 0),
- percent = valuePercent - minValuePercent;
- that._label.setDataField("percent", percent);
- that._label.setDataField("total", total);
- if (that.series.isFullStackedSeries() && that.hasValue()) {
- if (that.leftHole) {
- that.leftHole /= total - leftHoleTotal;
- that.minLeftHole /= total - leftHoleTotal
- }
- if (that.rightHole) {
- that.rightHole /= total - rightHoleTotal;
- that.minRightHole /= total - rightHoleTotal
- }
- that.value = valuePercent;
- that.minValue = !minValuePercent ? that.minValue : minValuePercent;
- that.translate()
- }
- },
- _storeTrackerR: function() {
- var that = this,
- navigator = window.navigator,
- r = that._options.styles.normal.r,
- minTrackerSize;
- navigator = that.__debug_navigator || navigator;
- that.__debug_browserNavigator = navigator;
- minTrackerSize = "ontouchstart" in window || navigator.msPointerEnabled && navigator.msMaxTouchPoints || navigator.pointerEnabled && navigator.maxTouchPoints ? 20 : 6;
- that._options.trackerR = r < minTrackerSize ? minTrackerSize : r;
- return that._options.trackerR
- },
- _translateErrorBars: function(valueTranslator) {
- var that = this,
- options = that._options,
- errorBars = options.errorBars || {};
- _isDefined(that.lowError) && (that._lowErrorCoord = valueTranslator.translate(that.lowError));
- _isDefined(that.highError) && (that._highErrorCoord = valueTranslator.translate(that.highError));
- that._errorBarPos = _floor(that._options.rotated ? that.vy : that.vx);
- that._baseErrorBarPos = errorBars.type === "stdDeviation" ? that._lowErrorCoord + (that._highErrorCoord - that._lowErrorCoord) / 2 : that._options.rotated ? that.vx : that.vy
- },
- _translate: function(translators) {
- var that = this,
- valueAxis = that._options.rotated ? "x" : "y",
- upperValueAxis = valueAxis.toUpperCase(),
- valueTranslator = translators[valueAxis],
- argumentAxis = that._options.rotated ? "y" : "x";
- that["v" + valueAxis] = that[valueAxis] = valueTranslator.translate(that.value);
- that["v" + argumentAxis] = that[argumentAxis] = translators[argumentAxis].translate(that.argument);
- that["min" + upperValueAxis] = valueTranslator.translate(that.minValue);
- that["default" + upperValueAxis] = valueTranslator.translate(CANVAS_POSITION_DEFAULT);
- that._translateErrorBars(valueTranslator);
- that._calculateVisibility(that.x, that.y)
- },
- _updateData: function(data) {
- var that = this;
- that.value = that.initialValue = that.originalValue = data.value;
- that.minValue = that.initialMinValue = that.originalMinValue = _isDefined(data.minValue) ? data.minValue : CANVAS_POSITION_DEFAULT
- },
- _getImageSettings: function(image) {
- return {
- href: image.url || image.toString(),
- width: image.width || DEFAULT_IMAGE_WIDTH,
- height: image.height || DEFAULT_IMAGE_HEIGHT
- }
- },
- getCrosshairCoords: function() {
- return {
- x: this.vx,
- y: this.vy
- }
- },
- getPointRadius: function() {
- var style = this._currentStyle || this._getStyle(),
- options = this._options,
- r = style.r,
- extraSpace,
- symbol = options.symbol,
- isSquare = symbol === "square",
- isTriangle = symbol === "triangle" || symbol === "triangleDown" || symbol === "triangleUp";
- if (options.visible && !options.image && r) {
- extraSpace = style["stroke-width"] / 2;
- return (isSquare || isTriangle ? 1.4 * r : r) + extraSpace
- }
- return 0
- },
- _updateMarker: function(animationEnabled, style) {
- var that = this,
- options = that._options,
- settings,
- image = options.image,
- visibility = !that.isVisible() ? {visibility: "hidden"} : {};
- style = style || that._getStyle();
- if (that._checkImage(image))
- settings = _extend({}, {visibility: style.visibility}, visibility, that._getImageSettings(image));
- else
- settings = _extend({}, style, visibility, {points: that._populatePointShape(options.symbol, style.r)});
- if (!animationEnabled) {
- settings.translateX = that.x;
- settings.translateY = that.y
- }
- that.graphic.attr(settings).sharp()
- },
- _getLabelFormatObject: function() {
- var that = this;
- return {
- argument: that.initialArgument,
- value: that.initialValue,
- originalArgument: that.originalArgument,
- originalValue: that.originalValue,
- seriesName: that.series.name,
- lowErrorValue: that.lowError,
- highErrorValue: that.highError,
- point: that
- }
- },
- _getLabelPosition: function() {
- var rotated = this._options.rotated;
- if (this.series.isFullStackedSeries() || this.initialValue > 0)
- return rotated ? "right" : "top";
- else
- return rotated ? "left" : "bottom"
- },
- _getFormatObject: function(tooltip) {
- var that = this,
- labelFormatObject = that._label.getData();
- return _extend({}, labelFormatObject, {
- argumentText: tooltip.formatValue(that.initialArgument, "argument"),
- valueText: tooltip.formatValue(that.initialValue)
- }, _isDefined(labelFormatObject.percent) ? {percentText: tooltip.formatValue(labelFormatObject.percent, "percent")} : {}, _isDefined(labelFormatObject.total) ? {totalText: tooltip.formatValue(labelFormatObject.total)} : {})
- },
- _getMarkerVisibility: function() {
- return this._options.visible
- },
- coordsIn: function(x, y) {
- var trackerRadius = this._storeTrackerR();
- return x >= this.x - trackerRadius && x <= this.x + trackerRadius && y >= this.y - trackerRadius && y <= this.y + trackerRadius
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file barPoint.js */
- (function($, DX) {
- var points = DX.viz.core.series.points.mixins,
- _extend = $.extend,
- _math = Math,
- _floor = _math.floor,
- _abs = _math.abs,
- _min = _math.min,
- CANVAS_POSITION_DEFAULT = "canvas_position_default",
- DEFAULT_BAR_TRACKER_SIZE = 9,
- CORRECTING_BAR_TRACKER_VALUE = 4,
- RIGHT = "right",
- LEFT = "left",
- TOP = "top",
- BOTTOM = "bottom";
- points.barPoint = _extend({}, points.symbolPoint, {
- correctCoordinates: function(correctOptions) {
- var correction = _floor(correctOptions.offset - correctOptions.width / 2),
- rotated = this._options.rotated,
- valueSelector = rotated ? "height" : "width",
- correctionSelector = (rotated ? "y" : "x") + "Correction";
- this[valueSelector] = correctOptions.width;
- this[correctionSelector] = correction
- },
- _getGraphicBbox: function() {
- var that = this,
- bbox = {};
- bbox.x = that.x;
- bbox.y = that.y;
- bbox.width = that.width;
- bbox.height = that.height;
- return bbox
- },
- _getLabelConnector: function() {
- return this._getGraphicBbox()
- },
- _getLabelPosition: function() {
- var that = this,
- position,
- translators = that.translators,
- initialValue = that.initialValue,
- invertX = translators.x.getBusinessRange().invert,
- invertY = translators.y.getBusinessRange().invert,
- isDiscreteValue = that.series.valueAxisType === "discrete",
- isFullStacked = that.series.isFullStackedSeries(),
- notVerticalInverted = !isDiscreteValue && (initialValue >= 0 && !invertY || initialValue < 0 && invertY) || isDiscreteValue && !invertY || isFullStacked,
- notHorizontalInverted = !isDiscreteValue && (initialValue >= 0 && !invertX || initialValue < 0 && invertX) || isDiscreteValue && !invertX || isFullStacked;
- if (!that._options.rotated)
- position = notVerticalInverted ? TOP : BOTTOM;
- else
- position = notHorizontalInverted ? RIGHT : LEFT;
- return position
- },
- _getLabelCoords: function(label) {
- var that = this,
- coords;
- if (that.initialValue === 0 && that.series.isFullStackedSeries())
- if (!this._options.rotated)
- coords = that._getLabelCoordOfPosition(label, TOP);
- else
- coords = that._getLabelCoordOfPosition(label, RIGHT);
- else if (label.getLayoutOptions().position === "inside")
- coords = that._getLabelCoordOfPosition(label, "inside");
- else
- coords = points.symbolPoint._getLabelCoords.call(this, label);
- return coords
- },
- _checkLabelPosition: function(label, coord) {
- var that = this,
- visibleArea = that._getVisibleArea(),
- rotated = that._options.rotated,
- graphicBbox = that._getGraphicBbox(),
- labelBbox = label.getBoundingRect();
- if (that._isPointInVisibleArea(visibleArea, graphicBbox))
- return that._moveLabelOnCanvas(coord, visibleArea, labelBbox, that.adjustSeriesLabels || rotated, that.adjustSeriesLabels || !rotated);
- return coord
- },
- _isLabelInsidePoint: function(label) {
- var that = this,
- graphicBbox = that._getGraphicBbox(),
- labelBbox = label.getBoundingRect();
- if (that._options.resolveLabelsOverlapping && label.getLayoutOptions().position === "inside")
- if (labelBbox.width > graphicBbox.width || labelBbox.height > graphicBbox.height) {
- label.hide();
- return true
- }
- return false
- },
- _moveLabelOnCanvas: function(coord, visibleArea, labelBbox, horizontalAdjust, verticalAdjust) {
- var x = coord.x,
- y = coord.y;
- if (visibleArea.minX > x && horizontalAdjust)
- x = visibleArea.minX;
- if (visibleArea.maxX < x + labelBbox.width && horizontalAdjust)
- x = visibleArea.maxX - labelBbox.width;
- if (visibleArea.minY > y && verticalAdjust)
- y = visibleArea.minY;
- if (visibleArea.maxY < y + labelBbox.height && verticalAdjust)
- y = visibleArea.maxY - labelBbox.height;
- return {
- x: x,
- y: y
- }
- },
- _showForZeroValues: function() {
- return this._options.label.showForZeroValues || this.initialValue
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var that = this,
- style = that._getStyle(),
- x = that.x,
- y = that.y,
- width = that.width,
- height = that.height,
- r = that._options.cornerRadius;
- if (animationEnabled)
- if (that._options.rotated) {
- width = 0;
- x = that.defaultX
- }
- else {
- height = 0;
- y = that.defaultY
- }
- that.graphic = renderer.rect(x, y, width, height).attr({
- rx: r,
- ry: r
- }).attr(style).data({point: that}).append(group)
- },
- _getSettingsForTracker: function() {
- var that = this,
- y = that.y,
- height = that.height,
- x = that.x,
- width = that.width;
- if (that._options.rotated) {
- if (width === 1) {
- width = DEFAULT_BAR_TRACKER_SIZE;
- x -= CORRECTING_BAR_TRACKER_VALUE
- }
- }
- else if (height === 1) {
- height = DEFAULT_BAR_TRACKER_SIZE;
- y -= CORRECTING_BAR_TRACKER_VALUE
- }
- return {
- x: x,
- y: y,
- width: width,
- height: height
- }
- },
- getGraphicSettings: function() {
- var graphic = this.graphic;
- return {
- x: graphic.attr("x"),
- y: graphic.attr("y"),
- height: graphic.attr("height"),
- width: graphic.attr("width")
- }
- },
- _getEdgeTooltipParams: function(x, y, width, height) {
- var isPositive = this.value >= 0,
- invertedY = this.translators.y.getBusinessRange().invert,
- invertedX = this.translators.x.getBusinessRange().invert,
- xCoord,
- yCoord;
- if (this._options.rotated) {
- yCoord = y + height / 2;
- if (invertedX)
- xCoord = isPositive ? x : x + width;
- else
- xCoord = isPositive ? x + width : x
- }
- else {
- xCoord = x + width / 2;
- if (invertedY)
- yCoord = isPositive ? y + height : y;
- else
- yCoord = isPositive ? y : y + height
- }
- return {
- x: xCoord,
- y: yCoord,
- offset: 0
- }
- },
- getTooltipParams: function(location) {
- var x = this.x,
- y = this.y,
- width = this.width,
- height = this.height;
- return location === 'edge' ? this._getEdgeTooltipParams(x, y, width, height) : {
- x: x + width / 2,
- y: y + height / 2,
- offset: 0
- }
- },
- _truncateCoord: function(coord, minBounce, maxBounce) {
- if (coord < minBounce)
- return minBounce;
- if (coord > maxBounce)
- return maxBounce;
- return coord
- },
- _translateErrorBars: function(valueTranslator, argVisibleArea) {
- points.symbolPoint._translateErrorBars.call(this, valueTranslator);
- if (this._errorBarPos < argVisibleArea.min || this._errorBarPos > argVisibleArea.max)
- this._errorBarPos = undefined
- },
- _translate: function(translators) {
- var that = this,
- rotated = that._options.rotated,
- valAxis = rotated ? "x" : "y",
- argAxis = rotated ? "y" : "x",
- valIntervalName = rotated ? "width" : "height",
- argIntervalName = rotated ? "height" : "width",
- argTranslator = translators[argAxis],
- valTranslator = translators[valAxis],
- argVisibleArea = argTranslator.getCanvasVisibleArea(),
- valVisibleArea = valTranslator.getCanvasVisibleArea(),
- arg,
- minArg,
- val,
- minVal;
- arg = minArg = argTranslator.translate(that.argument) + (that[argAxis + "Correction"] || 0);
- val = valTranslator.translate(that.value);
- minVal = valTranslator.translate(that.minValue);
- that["v" + valAxis] = val;
- that["v" + argAxis] = arg + that[argIntervalName] / 2;
- that[valIntervalName] = _abs(val - minVal);
- that._calculateVisibility(rotated ? _min(val, minVal) : _min(arg, minArg), rotated ? _min(arg, minArg) : _min(val, minVal), that.width, that.height);
- val = that._truncateCoord(val, valVisibleArea.min, valVisibleArea.max);
- minVal = that._truncateCoord(minVal, valVisibleArea.min, valVisibleArea.max);
- that[argAxis] = arg;
- that["min" + argAxis.toUpperCase()] = minArg;
- that[valIntervalName] = _abs(val - minVal);
- that[valAxis] = _min(val, minVal) + (that[valAxis + "Correction"] || 0);
- that["min" + valAxis.toUpperCase()] = minVal + (that[valAxis + "Correction"] || 0);
- that["default" + valAxis.toUpperCase()] = valTranslator.translate(CANVAS_POSITION_DEFAULT);
- that._translateErrorBars(valTranslator, argVisibleArea);
- if (that.inVisibleArea) {
- if (that[argAxis] < argVisibleArea.min) {
- that[argIntervalName] = that[argIntervalName] - (argVisibleArea.min - that[argAxis]);
- that[argAxis] = argVisibleArea.min;
- that["min" + argAxis.toUpperCase()] = argVisibleArea.min
- }
- if (that[argAxis] + that[argIntervalName] > argVisibleArea.max)
- that[argIntervalName] = argVisibleArea.max - that[argAxis]
- }
- },
- _updateMarker: function(animationEnabled, style) {
- this.graphic.attr(_extend({}, style || this._getStyle(), !animationEnabled ? this.getMarkerCoords() : {}))
- },
- getMarkerCoords: function() {
- return {
- x: this.x,
- y: this.y,
- width: this.width,
- height: this.height
- }
- },
- coordsIn: function(x, y) {
- var that = this;
- return x >= that.x && x <= that.x + that.width && y >= that.y && y <= that.y + that.height
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file bubblePoint.js */
- (function($, DX) {
- var points = DX.viz.core.series.points.mixins,
- _extend = $.extend,
- MIN_BUBBLE_HEIGHT = 20;
- points.bubblePoint = _extend({}, points.symbolPoint, {
- correctCoordinates: function(diameter) {
- this.bubbleSize = diameter / 2
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var that = this,
- attr = _extend({
- translateX: that.x,
- translateY: that.y
- }, that._getStyle());
- that.graphic = renderer.circle(0, 0, animationEnabled ? 0 : that.bubbleSize).attr(attr).data({point: that}).append(group)
- },
- getTooltipParams: function(location) {
- var that = this,
- graphic = that.graphic,
- height;
- if (!graphic)
- return;
- height = graphic.getBBox().height;
- return {
- x: that.x,
- y: height < MIN_BUBBLE_HEIGHT || location === 'edge' ? this.y - height / 2 : this.y,
- offset: 0
- }
- },
- _getLabelFormatObject: function() {
- var formatObject = points.symbolPoint._getLabelFormatObject.call(this);
- formatObject.size = this.initialSize;
- return formatObject
- },
- _updateData: function(data) {
- points.symbolPoint._updateData.call(this, data);
- this.size = this.initialSize = data.size
- },
- _getGraphicBbox: function() {
- var that = this;
- return that._getSymbolBbox(that.x, that.y, that.bubbleSize)
- },
- _updateMarker: function(animationEnabled, style) {
- var that = this;
- style = style || that._getStyle();
- if (!animationEnabled)
- style = $.extend({
- r: that.bubbleSize,
- translateX: that.x,
- translateY: that.y
- }, style);
- that.graphic.attr(style)
- },
- _getFormatObject: function(tooltip) {
- var formatObject = points.symbolPoint._getFormatObject.call(this, tooltip);
- formatObject.sizeText = tooltip.formatValue(this.initialSize);
- return formatObject
- },
- _storeTrackerR: function() {
- return this.bubbleSize
- },
- _getLabelCoords: function(label) {
- var coords;
- if (label.getLayoutOptions().position === "inside")
- coords = this._getLabelCoordOfPosition(label, "inside");
- else
- coords = points.symbolPoint._getLabelCoords.call(this, label);
- return coords
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file piePoint.js */
- (function($, DX) {
- var CONNECTOR_LENGTH = 20,
- series = DX.viz.core.series,
- points = series.points.mixins,
- _extend = $.extend,
- _round = Math.round,
- _sqrt = Math.sqrt,
- _acos = Math.acos,
- DEG = 180 / Math.PI,
- _abs = Math.abs,
- _normalizeAngle = DX.utils.normalizeAngle,
- _getCosAndSin = DX.utils.getCosAndSin,
- _isDefined = DX.utils.isDefined,
- INDENT_FROM_PIE = series.helpers.consts.pieLabelIndent;
- function getVerticallyShiftedAngularCoords(bbox, dy, center) {
- var isPositive = bbox.x + bbox.width / 2 >= center.x,
- dx1 = (isPositive ? bbox.x : bbox.x + bbox.width) - center.x,
- dy1 = bbox.y - center.y,
- dy2 = dy1 + dy,
- dx2 = _round(_sqrt(dx1 * dx1 + dy1 * dy1 - dy2 * dy2)),
- dx = (isPositive ? +dx2 : -dx2) || dx1;
- return {
- x: center.x + (isPositive ? dx : dx - bbox.width),
- y: bbox.y + dy
- }
- }
- DX.viz.core.utils.getVerticallyShiftedAngularCoords = getVerticallyShiftedAngularCoords;
- points.piePoint = _extend({}, points.symbolPoint, {
- _updateData: function(data) {
- var that = this;
- points.symbolPoint._updateData.call(this, data);
- that._visible = true;
- that.minValue = that.initialMinValue = that.originalMinValue = _isDefined(data.minValue) ? data.minValue : 0
- },
- animate: function(complete, duration, step) {
- var that = this;
- that.graphic.animate({
- x: that.centerX,
- y: that.centerY,
- outerRadius: that.radiusOuter,
- innerRadius: that.radiusInner,
- startAngle: that.toAngle,
- endAngle: that.fromAngle
- }, {
- partitionDuration: duration,
- step: step
- }, complete)
- },
- correctPosition: function(correction) {
- var that = this;
- that.radiusInner = correction.radiusInner;
- that.radiusOuter = correction.radiusOuter;
- that.centerX = correction.centerX;
- that.centerY = correction.centerY
- },
- correctValue: function(correction, percent, base) {
- var that = this;
- that.value = (base || that.initialValue) + correction;
- that.minValue = correction;
- that.percent = percent;
- that._label.setDataField("percent", percent)
- },
- _updateLabelData: function() {
- this._label.setData(this._getLabelFormatObject())
- },
- _updateLabelOptions: function() {
- var that = this;
- !that._label && that._createLabel();
- that._label.setOptions(that._options.label)
- },
- _getShiftLabelCoords: function() {
- var that = this,
- bbox = that._label.getBoundingRect(),
- coord = that._getLabelCoords(that._label),
- visibleArea = that._getVisibleArea();
- if (that._isLabelDrawingWithoutPoints)
- return that._checkLabelPosition(coord, bbox, visibleArea);
- else
- return that._getLabelExtraCoord(coord, that._checkVerticalLabelPosition(coord, bbox, visibleArea), bbox)
- },
- _getLabelPosition: function(options) {
- return options.position
- },
- _getLabelCoords: function(label) {
- var that = this,
- bbox = label.getBoundingRect(),
- options = label.getLayoutOptions(),
- angleFunctions = _getCosAndSin(that.middleAngle),
- position = that._getLabelPosition(options),
- radiusInner = that.radiusInner,
- radiusOuter = that.radiusOuter,
- rad,
- x;
- if (position === 'inside') {
- rad = radiusInner + (radiusOuter - radiusInner) / 2 + options.radialOffset;
- x = that.centerX + rad * angleFunctions.cos - bbox.width / 2
- }
- else {
- rad = radiusOuter + options.radialOffset + INDENT_FROM_PIE;
- if (angleFunctions.cos > 0.1)
- x = that.centerX + rad * angleFunctions.cos;
- else if (angleFunctions.cos < -0.1)
- x = that.centerX + rad * angleFunctions.cos - bbox.width;
- else
- x = that.centerX + rad * angleFunctions.cos - bbox.width / 2
- }
- return {
- x: x,
- y: _round(that.centerY - rad * angleFunctions.sin - bbox.height / 2)
- }
- },
- _getColumnsCoord: function(coord) {
- var that = this,
- label = that._label,
- bbox = label.getBoundingRect(),
- options = label.getLayoutOptions(),
- rad = that.radiusOuter + options.radialOffset,
- canvas = that.series.canvas,
- rightBorderX = canvas.width - canvas.right - bbox.width,
- leftBorderX = canvas.left,
- angleOfPoint = _normalizeAngle(that.middleAngle),
- x;
- if (options.position !== 'columns')
- return coord;
- rad += CONNECTOR_LENGTH;
- if (angleOfPoint < 90 || angleOfPoint >= 270) {
- x = that._maxLabelLength ? that.centerX + rad + that._maxLabelLength - bbox.width : rightBorderX;
- x = x > rightBorderX ? rightBorderX : x
- }
- else {
- x = that._maxLabelLength ? that.centerX - rad - that._maxLabelLength : leftBorderX;
- x = x < leftBorderX ? leftBorderX : x
- }
- coord.x = x;
- return coord
- },
- drawLabel: function(translators, renderer, group) {
- this.translate(translators);
- this._isLabelDrawingWithoutPoints = true;
- this._drawLabel(renderer, group);
- this._isLabelDrawingWithoutPoints = false
- },
- updateLabelCoord: function() {
- var that = this,
- bbox = that._label.getBoundingRect(),
- coord = that._getColumnsCoord(bbox);
- coord = that._checkHorizontalLabelPosition(coord, bbox, that._getVisibleArea());
- that._label.shift(_round(coord.x), _round(bbox.y))
- },
- _checkVerticalLabelPosition: function(coord, box, visibleArea) {
- var x = coord.x,
- y = coord.y;
- if (coord.y + box.height > visibleArea.maxY)
- y = visibleArea.maxY - box.height;
- else if (coord.y < visibleArea.minY)
- y = visibleArea.minY;
- return {
- x: x,
- y: y
- }
- },
- _getLabelExtraCoord: function(coord, shiftCoord, box) {
- return coord.y !== shiftCoord.y ? getVerticallyShiftedAngularCoords({
- x: coord.x,
- y: coord.y,
- width: box.width,
- height: box.height
- }, shiftCoord.y - coord.y, {
- x: this.centerX,
- y: this.centerY
- }) : coord
- },
- _checkHorizontalLabelPosition: function(coord, box, visibleArea) {
- var x = coord.x,
- y = coord.y;
- if (coord.x + box.width > visibleArea.maxX)
- x = visibleArea.maxX - box.width;
- else if (coord.x < visibleArea.minX)
- x = visibleArea.minX;
- return {
- x: x,
- y: y
- }
- },
- setLabelEllipsis: function() {
- var that = this,
- bbox = that._label.getBoundingRect(),
- coord = that._checkHorizontalLabelPosition(bbox, bbox, that._getVisibleArea());
- that._label.fit({
- width: bbox.width - _abs(coord.x - bbox.x),
- height: bbox.height - _abs(coord.y - bbox.y)
- })
- },
- _getVisibleArea: function() {
- var canvas = this.series.canvas;
- return {
- minX: canvas.left,
- maxX: canvas.width - canvas.right,
- minY: canvas.top,
- maxY: canvas.height - canvas.bottom
- }
- },
- _checkLabelPosition: function(coord, bbox, visibleArea) {
- coord = this._checkHorizontalLabelPosition(coord, bbox, visibleArea);
- return this._checkVerticalLabelPosition(coord, bbox, visibleArea)
- },
- getBoundaryCoords: function() {
- var that = this,
- rad = that.radiusOuter,
- seriesStyle = that._options.styles.normal,
- strokeWidthBy2 = seriesStyle["stroke-width"] / 2,
- borderWidth = that.series.getOptions().containerBackgroundColor === seriesStyle.stroke ? _round(strokeWidthBy2) : _round(-strokeWidthBy2),
- angleFunctions = _getCosAndSin(_round(that.middleAngle));
- return {
- x: _round(that.centerX + (rad - borderWidth) * angleFunctions.cos),
- y: _round(that.centerY - (rad - borderWidth) * angleFunctions.sin)
- }
- },
- _getLabelConnector: function() {
- var coords = this.getBoundaryCoords();
- coords.angle = this.middleAngle;
- return coords
- },
- _drawMarker: function(renderer, group, animationEnabled, firstDrawing) {
- var that = this,
- radiusOuter = that.radiusOuter,
- radiusInner = that.radiusInner,
- fromAngle = that.fromAngle,
- toAngle = that.toAngle;
- if (animationEnabled) {
- radiusInner = radiusOuter = 0;
- if (!firstDrawing)
- fromAngle = toAngle = that.shiftedAngle
- }
- that.graphic = renderer.arc(that.centerX, that.centerY, radiusInner, radiusOuter, toAngle, fromAngle).attr({"stroke-linejoin": "round"}).attr(that._getStyle()).data({point: that}).sharp().append(group)
- },
- getTooltipParams: function() {
- var that = this,
- angleFunctions = _getCosAndSin(that.middleAngle),
- radiusInner = that.radiusInner,
- radiusOuter = that.radiusOuter;
- return {
- x: that.centerX + (radiusInner + (radiusOuter - radiusInner) / 2) * angleFunctions.cos,
- y: that.centerY - (radiusInner + (radiusOuter - radiusInner) / 2) * angleFunctions.sin,
- offset: 0
- }
- },
- _translate: function(translator) {
- var that = this,
- angle = that.shiftedAngle || 0,
- value = that.value,
- minValue = that.minValue;
- that.fromAngle = translator.translate(minValue) + angle;
- that.toAngle = translator.translate(value) + angle;
- that.middleAngle = translator.translate((value - minValue) / 2 + minValue) + angle;
- if (!that.isVisible())
- that.middleAngle = that.toAngle = that.fromAngle = that.fromAngle || angle
- },
- _getMarkerVisibility: function() {
- return true
- },
- _updateMarker: function(animationEnabled, style) {
- var that = this;
- style = style || that._getStyle();
- if (!animationEnabled)
- style = _extend({
- x: that.centerX,
- y: that.centerY,
- outerRadius: that.radiusOuter,
- innerRadius: that.radiusInner,
- startAngle: that.toAngle,
- endAngle: that.fromAngle
- }, style);
- that.graphic.attr(style).sharp()
- },
- getLegendStyles: function() {
- return this._styles.legendStyles
- },
- isInVisibleArea: function() {
- return true
- },
- hide: function() {
- var that = this;
- if (that._visible) {
- that._visible = false;
- that.hideTooltip();
- that._options.visibilityChanged(that)
- }
- },
- show: function() {
- var that = this;
- if (!that._visible) {
- that._visible = true;
- that._options.visibilityChanged(that)
- }
- },
- setInvisibility: function() {
- this._label.hide()
- },
- isVisible: function() {
- return this._visible
- },
- _getFormatObject: function(tooltip) {
- var formatObject = points.symbolPoint._getFormatObject.call(this, tooltip),
- percent = this.percent;
- formatObject.percent = percent;
- formatObject.percentText = tooltip.formatValue(percent, "percent");
- return formatObject
- },
- getColor: function() {
- return this._styles.normal.fill
- },
- coordsIn: function(x, y) {
- var that = this,
- lx = x - that.centerX,
- ly = y - that.centerY,
- r = _sqrt(lx * lx + ly * ly),
- fromAngle = that.fromAngle % 360,
- toAngle = that.toAngle % 360,
- angle;
- if (r < that.radiusInner || r > that.radiusOuter || r === 0)
- return false;
- angle = _acos(lx / r) * DEG * (ly > 0 ? -1 : 1);
- if (angle < 0)
- angle += 360;
- if (fromAngle === toAngle && _abs(that.toAngle - that.fromAngle) > 1E-4)
- return true;
- else
- return fromAngle >= toAngle ? angle <= fromAngle && angle >= toAngle : !(angle >= fromAngle && angle <= toAngle)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeSymbolPoint.js */
- (function($, DX) {
- var core = DX.viz.core,
- points = core.series.points.mixins,
- _extend = $.extend,
- _isDefined = DX.utils.isDefined,
- _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _max = _math.max,
- _round = _math.round,
- DEFAULT_IMAGE_WIDTH = 20,
- DEFAULT_IMAGE_HEIGHT = 20;
- points.rangeSymbolPoint = _extend({}, points.symbolPoint, {
- deleteLabel: function() {
- var that = this;
- that._topLabel.dispose();
- that._topLabel = null;
- that._bottomLabel.dispose();
- that._bottomLabel = null
- },
- hideMarker: function(type) {
- var graphic = this.graphic,
- marker = graphic && graphic[type + "Marker"],
- label = this["_" + type + "Label"];
- if (marker && marker.attr("visibility") !== "hidden")
- marker.attr({visibility: "hidden"});
- label.hide()
- },
- setInvisibility: function() {
- this.hideMarker("top");
- this.hideMarker("bottom")
- },
- clearVisibility: function() {
- var that = this,
- graphic = that.graphic,
- topMarker = graphic && graphic.topMarker,
- bottomMarker = graphic && graphic.bottomMarker;
- if (topMarker && topMarker.attr("visibility"))
- topMarker.attr({visibility: null});
- if (bottomMarker && bottomMarker.attr("visibility"))
- bottomMarker.attr({visibility: null});
- that._topLabel.clearVisibility();
- that._bottomLabel.clearVisibility()
- },
- clearMarker: function() {
- var that = this,
- graphic = that.graphic,
- topMarker = graphic && graphic.topMarker,
- bottomMarker = graphic && graphic.bottomMarker,
- emptySettings = that._emptySettings;
- topMarker && topMarker.attr(emptySettings);
- bottomMarker && bottomMarker.attr(emptySettings)
- },
- _getLabelPosition: function(markerType) {
- var position,
- labelsInside = this._options.label.position === "inside";
- if (!this._options.rotated)
- position = markerType === "top" ^ labelsInside ? "top" : "bottom";
- else
- position = markerType === "top" ^ labelsInside ? "right" : "left";
- return position
- },
- _getLabelMinFormatObject: function() {
- var that = this;
- return {
- index: 0,
- argument: that.initialArgument,
- value: that.initialMinValue,
- seriesName: that.series.name,
- originalValue: that.originalMinValue,
- originalArgument: that.originalArgument,
- point: that
- }
- },
- _updateLabelData: function() {
- var maxFormatObject = this._getLabelFormatObject();
- maxFormatObject.index = 1;
- this._topLabel.setData(maxFormatObject);
- this._bottomLabel.setData(this._getLabelMinFormatObject())
- },
- _updateLabelOptions: function() {
- var that = this,
- options = this._options.label;
- (!that._topLabel || !that._bottomLabel) && that._createLabel();
- that._topLabel.setOptions(options);
- that._bottomLabel.setOptions(options)
- },
- _createLabel: function() {
- this._topLabel = core.CoreFactory.createLabel();
- this._bottomLabel = core.CoreFactory.createLabel()
- },
- _getGraphicBbox: function(location) {
- location = location || this._labelLocation;
- var options = this._options,
- images = this._getImage(options.image),
- image = location === "top" ? this._checkImage(images.top) : this._checkImage(images.bottom),
- bbox,
- coord = this._getPositionFromLocation(location);
- if (options.visible)
- bbox = image ? this._getImageBbox(coord.x, coord.y) : this._getSymbolBbox(coord.x, coord.y, options.styles.normal.r);
- else
- bbox = {
- x: coord.x,
- y: coord.y,
- width: 0,
- height: 0
- };
- return bbox
- },
- _getPositionFromLocation: function(location) {
- var x,
- y,
- isTop = location === "top";
- if (!this._options.rotated) {
- x = this.x;
- y = isTop ? _min(this.y, this.minY) : _max(this.y, this.minY)
- }
- else {
- x = isTop ? _max(this.x, this.minX) : _min(this.x, this.minX);
- y = this.y
- }
- return {
- x: x,
- y: y
- }
- },
- _checkOverlay: function(bottomCoord, topCoord, topValue) {
- return bottomCoord < topCoord + topValue
- },
- _getOverlayCorrections: function(type, topCoords, bottomCoords) {
- var isVertical = type === "vertical",
- coordSelector = isVertical ? "y" : "x",
- valueSelector = isVertical ? "height" : "width",
- visibleArea = this.translators[coordSelector].getCanvasVisibleArea(),
- minBound = visibleArea.min,
- maxBound = visibleArea.max,
- delta = _round((topCoords[coordSelector] + topCoords[valueSelector] - bottomCoords[coordSelector]) / 2),
- coord1 = topCoords[coordSelector] - delta,
- coord2 = bottomCoords[coordSelector] + delta;
- if (coord1 < minBound) {
- delta = minBound - topCoords[coordSelector];
- coord1 += delta;
- coord2 += delta
- }
- else if (coord2 + bottomCoords[valueSelector] > maxBound) {
- delta = -(bottomCoords[coordSelector] + bottomCoords[valueSelector] - maxBound);
- coord1 += delta;
- coord2 += delta
- }
- return {
- coord1: coord1,
- coord2: coord2
- }
- },
- _checkLabelsOverlay: function(topLocation) {
- var that = this,
- topCoords = that._topLabel.getBoundingRect(),
- bottomCoords = that._bottomLabel.getBoundingRect(),
- corrections = {};
- if (!that._options.rotated) {
- if (topLocation === "top") {
- if (this._checkOverlay(bottomCoords.y, topCoords.y, topCoords.height)) {
- corrections = this._getOverlayCorrections("vertical", topCoords, bottomCoords);
- that._topLabel.shift(topCoords.x, corrections.coord1);
- that._bottomLabel.shift(bottomCoords.x, corrections.coord2)
- }
- }
- else if (this._checkOverlay(topCoords.y, bottomCoords.y, bottomCoords.height)) {
- corrections = this._getOverlayCorrections("vertical", bottomCoords, topCoords);
- that._topLabel.shift(topCoords.x, corrections.coord2);
- that._bottomLabel.shift(bottomCoords.x, corrections.coord1)
- }
- }
- else if (topLocation === "top") {
- if (this._checkOverlay(topCoords.x, bottomCoords.x, bottomCoords.width)) {
- corrections = this._getOverlayCorrections("horizontal", bottomCoords, topCoords);
- that._topLabel.shift(corrections.coord2, topCoords.y);
- that._bottomLabel.shift(corrections.coord1, bottomCoords.y)
- }
- }
- else if (this._checkOverlay(bottomCoords.x, topCoords.x, topCoords.width)) {
- corrections = this._getOverlayCorrections("horizontal", topCoords, bottomCoords);
- that._topLabel.shift(corrections.coord1, topCoords.y);
- that._bottomLabel.shift(corrections.coord2, bottomCoords.y)
- }
- },
- _drawLabel: function(renderer, group) {
- var that = this,
- coord,
- labels = [],
- notInverted = that._options.rotated ? that.x >= that.minX : that.y < that.minY,
- customVisibility = that._getCustomLabelVisibility();
- that._topLabel.pointPosition = notInverted ? "top" : "bottom";
- that._bottomLabel.pointPosition = notInverted ? "bottom" : "top";
- if ((that.series.getLabelVisibility() || customVisibility !== null) && that.hasValue()) {
- that.visibleTopMarker !== false && labels.push(that._topLabel);
- that.visibleBottomMarker !== false && labels.push(that._bottomLabel);
- $.each(labels, function(_, label) {
- var pointPosition = label.pointPosition;
- label.draw(renderer, group, customVisibility);
- coord = that._addLabelAlignmentAndOffset(label, that._getLabelCoords(label, pointPosition));
- coord = that._checkLabelPosition(label, coord, pointPosition);
- that._labelLocation = label.pointPosition;
- label.setFigureToDrawConnector(that._getLabelConnector());
- that._labelLocation = null;
- label.shift(_round(coord.x), _round(coord.y))
- });
- that._checkLabelsOverlay(that._topLabel.pointPosition)
- }
- else {
- that._topLabel.hide();
- that._bottomLabel.hide()
- }
- },
- _getImage: function(imageOption) {
- var image = {};
- if (_isDefined(imageOption))
- if (typeof imageOption === "string")
- image.top = image.bottom = imageOption;
- else {
- image.top = {
- url: typeof imageOption.url === "string" ? imageOption.url : imageOption.url && imageOption.url.rangeMaxPoint,
- width: typeof imageOption.width === "number" ? imageOption.width : imageOption.width && imageOption.width.rangeMaxPoint,
- height: typeof imageOption.height === "number" ? imageOption.height : imageOption.height && imageOption.height.rangeMaxPoint
- };
- image.bottom = {
- url: typeof imageOption.url === "string" ? imageOption.url : imageOption.url && imageOption.url.rangeMinPoint,
- width: typeof imageOption.width === "number" ? imageOption.width : imageOption.width && imageOption.width.rangeMinPoint,
- height: typeof imageOption.height === "number" ? imageOption.height : imageOption.height && imageOption.height.rangeMinPoint
- }
- }
- return image
- },
- _checkSymbol: function(oldOptions, newOptions) {
- var that = this,
- oldSymbol = oldOptions.symbol,
- newSymbol = newOptions.symbol,
- symbolChanged = oldSymbol === "circle" && newSymbol !== "circle" || oldSymbol !== "circle" && newSymbol === "circle",
- oldImages = that._getImage(oldOptions.image),
- newImages = that._getImage(newOptions.image),
- topImageChanged = that._checkImage(oldImages.top) !== that._checkImage(newImages.top),
- bottomImageChanged = that._checkImage(oldImages.bottom) !== that._checkImage(newImages.bottom);
- return symbolChanged || topImageChanged || bottomImageChanged
- },
- _getSettingsForTwoMarkers: function(style) {
- var that = this,
- options = that._options,
- settings = {},
- x = options.rotated ? _min(that.x, that.minX) : that.x,
- y = options.rotated ? that.y : _min(that.y, that.minY),
- radius = style.r,
- points = that._populatePointShape(options.symbol, radius);
- settings.top = _extend({
- translateX: x + that.width,
- translateY: y,
- r: radius
- }, style);
- settings.bottom = _extend({
- translateX: x,
- translateY: y + that.height,
- r: radius
- }, style);
- if (points)
- settings.top.points = settings.bottom.points = points;
- return settings
- },
- _hasGraphic: function() {
- return this.graphic && this.graphic.topMarker && this.graphic.bottomMarker
- },
- _drawOneMarker: function(renderer, markerType, imageSettings, settings) {
- var that = this,
- graphic = that.graphic;
- if (graphic[markerType])
- that._updateOneMarker(markerType, settings);
- else
- graphic[markerType] = that._createMarker(renderer, graphic, imageSettings, settings)
- },
- _drawMarker: function(renderer, group, animationEnabled, firstDrawing, style) {
- var that = this,
- settings = that._getSettingsForTwoMarkers(style || that._getStyle()),
- image = that._getImage(that._options.image);
- if (that._checkImage(image.top))
- settings.top = that._getImageSettings(settings.top, image.top);
- if (that._checkImage(image.bottom))
- settings.bottom = that._getImageSettings(settings.bottom, image.bottom);
- that.graphic = that.graphic || renderer.g().append(group);
- that.visibleTopMarker && that._drawOneMarker(renderer, 'topMarker', image.top, settings.top);
- that.visibleBottomMarker && that._drawOneMarker(renderer, 'bottomMarker', image.bottom, settings.bottom)
- },
- _getSettingsForTracker: function(radius) {
- var that = this,
- rotated = that._options.rotated;
- return {
- translateX: rotated ? _min(that.x, that.minX) - radius : that.x - radius,
- translateY: rotated ? that.y - radius : _min(that.y, that.minY) - radius,
- width: that.width + 2 * radius,
- height: that.height + 2 * radius
- }
- },
- isInVisibleArea: function() {
- var that = this,
- rotated = that._options.rotated,
- argument = !rotated ? that.x : that.y,
- maxValue = !rotated ? _max(that.minY, that.y) : _max(that.minX, that.x),
- minValue = !rotated ? _min(that.minY, that.y) : _min(that.minX, that.x),
- translators = that.translators,
- notVisibleByArg,
- notVisibleByVal,
- tmp,
- visibleTopMarker = true,
- visibleBottomMarker = true,
- visibleRangeArea = true,
- visibleArgArea,
- visibleValArea;
- if (translators) {
- visibleArgArea = translators[!rotated ? "x" : "y"].getCanvasVisibleArea();
- visibleValArea = translators[!rotated ? "y" : "x"].getCanvasVisibleArea();
- notVisibleByArg = visibleArgArea.max < argument || visibleArgArea.min > argument;
- notVisibleByVal = visibleValArea.min > minValue && visibleValArea.min > maxValue || visibleValArea.max < minValue && visibleValArea.max < maxValue;
- if (notVisibleByArg || notVisibleByVal)
- visibleTopMarker = visibleBottomMarker = visibleRangeArea = false;
- else {
- visibleTopMarker = visibleValArea.min <= minValue && visibleValArea.max > minValue;
- visibleBottomMarker = visibleValArea.min < maxValue && visibleValArea.max >= maxValue;
- if (rotated) {
- tmp = visibleTopMarker;
- visibleTopMarker = visibleBottomMarker;
- visibleBottomMarker = tmp
- }
- }
- }
- that.visibleTopMarker = visibleTopMarker;
- that.visibleBottomMarker = visibleBottomMarker;
- return visibleRangeArea
- },
- getTooltipParams: function() {
- var that = this,
- x,
- y,
- min,
- max,
- minValue,
- translators = that.translators,
- visibleAreaX = translators.x.getCanvasVisibleArea(),
- visibleAreaY = translators.y.getCanvasVisibleArea();
- if (!that._options.rotated) {
- minValue = _min(that.y, that.minY);
- x = that.x;
- min = visibleAreaY.min > minValue ? visibleAreaY.min : minValue;
- max = visibleAreaY.max < minValue + that.height ? visibleAreaY.max : minValue + that.height;
- y = min + (max - min) / 2
- }
- else {
- minValue = _min(that.x, that.minX);
- y = that.y;
- min = visibleAreaX.min > minValue ? visibleAreaX.min : minValue;
- max = visibleAreaX.max < minValue + that.width ? visibleAreaX.max : minValue + that.width;
- x = min + (max - min) / 2
- }
- return {
- x: x,
- y: y,
- offset: 0
- }
- },
- _translate: function(translators) {
- var that = this,
- rotated = that._options.rotated;
- that.minX = that.minY = translators.y.translate(that.minValue);
- points.symbolPoint._translate.call(that, translators);
- that.height = rotated ? 0 : _abs(that.minY - that.y);
- that.width = rotated ? _abs(that.x - that.minX) : 0
- },
- _updateData: function(data) {
- var that = this;
- points.symbolPoint._updateData.call(that, data);
- that.minValue = that.initialMinValue = that.originalMinValue = data.minValue
- },
- _getImageSettings: function(settings, image) {
- return {
- href: image.url || image.toString(),
- width: image.width || DEFAULT_IMAGE_WIDTH,
- height: image.height || DEFAULT_IMAGE_HEIGHT,
- translateX: settings.translateX,
- translateY: settings.translateY
- }
- },
- getCrosshairCoords: function(x, y) {
- var coords;
- if (this._options.rotated)
- coords = {
- y: this.vy,
- x: Math.abs(this.vx - x) < Math.abs(this.minX - x) ? this.vx : this.minX
- };
- else
- coords = {
- x: this.vx,
- y: Math.abs(this.vy - y) < Math.abs(this.minY - y) ? this.vy : this.minY
- };
- return coords
- },
- _updateOneMarker: function(markerType, settings) {
- this.graphic && this.graphic[markerType] && this.graphic[markerType].attr(settings)
- },
- _updateMarker: function(animationEnabled, style) {
- this._drawMarker(undefined, undefined, false, false, style)
- },
- _getFormatObject: function(tooltip) {
- var that = this,
- initialMinValue = that.initialMinValue,
- initialValue = that.initialValue,
- initialArgument = that.initialArgument,
- minValue = tooltip.formatValue(initialMinValue),
- value = tooltip.formatValue(initialValue);
- return {
- argument: initialArgument,
- argumentText: tooltip.formatValue(initialArgument, "argument"),
- valueText: minValue + " - " + value,
- rangeValue1Text: minValue,
- rangeValue2Text: value,
- rangeValue1: initialMinValue,
- rangeValue2: initialValue,
- seriesName: that.series.name,
- point: that,
- originalMinValue: that.originalMinValue,
- originalValue: that.originalValue,
- originalArgument: that.originalArgument
- }
- },
- getLabel: function() {
- return [this._topLabel, this._bottomLabel]
- },
- getBoundingRect: $.noop,
- coordsIn: function(x, y) {
- var trackerRadius = this._storeTrackerR(),
- xCond = x >= this.x - trackerRadius && x <= this.x + trackerRadius,
- yCond = y >= this.y - trackerRadius && y <= this.y + trackerRadius;
- if (this._options.rotated)
- return yCond && (xCond || x >= this.minX - trackerRadius && x <= this.minX + trackerRadius);
- else
- return xCond && (yCond || y >= this.minY - trackerRadius && y <= this.minY + trackerRadius)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file rangeBarPoint.js */
- (function($, DX) {
- var points = DX.viz.core.series.points.mixins,
- rangeSymbolPointMethods = points.rangeSymbolPoint,
- _extend = $.extend;
- points.rangeBarPoint = _extend({}, points.barPoint, {
- deleteLabel: rangeSymbolPointMethods.deleteLabel,
- _getFormatObject: rangeSymbolPointMethods._getFormatObject,
- clearVisibility: function() {
- var graphic = this.graphic;
- if (graphic && graphic.attr("visibility"))
- graphic.attr({visibility: null});
- this._topLabel.clearVisibility();
- this._bottomLabel.clearVisibility()
- },
- setInvisibility: function() {
- var graphic = this.graphic;
- if (graphic && graphic.attr("visibility") !== "hidden")
- graphic.attr({visibility: "hidden"});
- this._topLabel.hide();
- this._bottomLabel.hide()
- },
- getTooltipParams: function(location) {
- var edgeLocation = location === 'edge',
- x,
- y;
- if (this._options.rotated) {
- x = edgeLocation ? this.x + this.width : this.x + this.width / 2;
- y = this.y + this.height / 2
- }
- else {
- x = this.x + this.width / 2;
- y = edgeLocation ? this.y : this.y + this.height / 2
- }
- return {
- x: x,
- y: y,
- offset: 0
- }
- },
- _translate: function(translator) {
- var that = this,
- barMethods = points.barPoint;
- barMethods._translate.call(that, translator);
- if (that._options.rotated)
- that.width = that.width || 1;
- else
- that.height = that.height || 1
- },
- _updateData: rangeSymbolPointMethods._updateData,
- _getLabelPosition: rangeSymbolPointMethods._getLabelPosition,
- _getLabelMinFormatObject: rangeSymbolPointMethods._getLabelMinFormatObject,
- _updateLabelData: rangeSymbolPointMethods._updateLabelData,
- _updateLabelOptions: rangeSymbolPointMethods._updateLabelOptions,
- getCrosshairCoords: rangeSymbolPointMethods.getCrosshairCoords,
- _createLabel: rangeSymbolPointMethods._createLabel,
- _checkOverlay: rangeSymbolPointMethods._checkOverlay,
- _checkLabelsOverlay: rangeSymbolPointMethods._checkLabelsOverlay,
- _getOverlayCorrections: rangeSymbolPointMethods._getOverlayCorrections,
- _drawLabel: rangeSymbolPointMethods._drawLabel,
- _getLabelCoords: rangeSymbolPointMethods._getLabelCoords,
- _getGraphicBbox: function(location) {
- location = location || this._labelLocation;
- var isTop = location === "top",
- bbox = points.barPoint._getGraphicBbox.call(this);
- if (!this._options.rotated) {
- bbox.y = isTop ? bbox.y : bbox.y + bbox.height;
- bbox.height = 0
- }
- else {
- bbox.x = isTop ? bbox.x + bbox.width : bbox.x;
- bbox.width = 0
- }
- return bbox
- },
- getLabel: rangeSymbolPointMethods.getLabel,
- getBoundingRect: $.noop
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file candlestickPoint.js */
- (function($, DX) {
- var viz = DX.viz,
- points = viz.core.series.points.mixins,
- _isNumeric = $.isNumeric,
- _extend = $.extend,
- _math = Math,
- _abs = _math.abs,
- _min = _math.min,
- _max = _math.max,
- _round = _math.round,
- DEFAULT_FINANCIAL_TRACKER_MARGIN = 2;
- points.candlestickPoint = _extend({}, points.barPoint, {
- _getContinuousPoints: function(minValueName, maxValueName) {
- var that = this,
- x = that.x,
- createPoint = that._options.rotated ? function(x, y) {
- return [y, x]
- } : function(x, y) {
- return [x, y]
- },
- width = that.width,
- min = that[minValueName],
- max = that[maxValueName],
- points;
- if (min === max)
- points = [].concat(createPoint(x, that.highY)).concat(createPoint(x, that.lowY)).concat(createPoint(x, that.closeY)).concat(createPoint(x - width / 2, that.closeY)).concat(createPoint(x + width / 2, that.closeY)).concat(createPoint(x, that.closeY));
- else
- points = [].concat(createPoint(x, that.highY)).concat(createPoint(x, max)).concat(createPoint(x + width / 2, max)).concat(createPoint(x + width / 2, min)).concat(createPoint(x, min)).concat(createPoint(x, that.lowY)).concat(createPoint(x, min)).concat(createPoint(x - width / 2, min)).concat(createPoint(x - width / 2, max)).concat(createPoint(x, max));
- return points
- },
- _getCategoryPoints: function(y) {
- var that = this,
- x = that.x,
- createPoint = that._options.rotated ? function(x, y) {
- return [y, x]
- } : function(x, y) {
- return [x, y]
- };
- return [].concat(createPoint(x, that.highY)).concat(createPoint(x, that.lowY)).concat(createPoint(x, y)).concat(createPoint(x - that.width / 2, y)).concat(createPoint(x + that.width / 2, y)).concat(createPoint(x, y))
- },
- _getPoints: function() {
- var that = this,
- points,
- minValueName,
- maxValueName,
- openValue = that.openValue,
- closeValue = that.closeValue;
- if (_isNumeric(openValue) && _isNumeric(closeValue)) {
- minValueName = openValue > closeValue ? "closeY" : "openY";
- maxValueName = openValue > closeValue ? "openY" : "closeY";
- points = that._getContinuousPoints(minValueName, maxValueName)
- }
- else if (openValue === closeValue)
- points = [that.x, that.highY, that.x, that.lowY];
- else
- points = that._getCategoryPoints(_isNumeric(openValue) ? that.openY : that.closeY);
- return points
- },
- getColor: function() {
- var that = this;
- return that._isReduction ? that._options.reduction.color : that._styles.normal.stroke || that.series.getColor()
- },
- _drawMarkerInGroup: function(group, attributes, renderer) {
- var that = this;
- that.graphic = renderer.path(that._getPoints(), "area").attr({"stroke-linecap": "square"}).attr(attributes).data({point: that}).sharp().append(group)
- },
- _fillStyle: function() {
- var that = this,
- styles = that._options.styles;
- if (that._isReduction && that._isPositive)
- that._styles = styles.reductionPositive;
- else if (that._isReduction)
- that._styles = styles.reduction;
- else if (that._isPositive)
- that._styles = styles.positive;
- else
- that._styles = styles
- },
- _getMinTrackerWidth: function() {
- return 2 + 2 * this._styles.normal['stroke-width']
- },
- correctCoordinates: function(correctOptions) {
- var minWidth = this._getMinTrackerWidth(),
- maxWidth = 10,
- width = correctOptions.width;
- width = width < minWidth ? minWidth : width > maxWidth ? maxWidth : width;
- this.width = width + width % 2;
- this.xCorrection = correctOptions.offset
- },
- _getMarkerGroup: function(group) {
- var that = this,
- markerGroup;
- if (that._isReduction && that._isPositive)
- markerGroup = group.reductionPositiveMarkersGroup;
- else if (that._isReduction)
- markerGroup = group.reductionMarkersGroup;
- else if (that._isPositive)
- markerGroup = group.defaultPositiveMarkersGroup;
- else
- markerGroup = group.defaultMarkersGroup;
- return markerGroup
- },
- _drawMarker: function(renderer, group) {
- this._drawMarkerInGroup(this._getMarkerGroup(group), this._getStyle(), renderer)
- },
- _getSettingsForTracker: function() {
- var that = this,
- highY = that.highY,
- lowY = that.lowY,
- rotated = that._options.rotated,
- x,
- y,
- width,
- height;
- if (highY === lowY) {
- highY = rotated ? highY + DEFAULT_FINANCIAL_TRACKER_MARGIN : highY - DEFAULT_FINANCIAL_TRACKER_MARGIN;
- lowY = rotated ? lowY - DEFAULT_FINANCIAL_TRACKER_MARGIN : lowY + DEFAULT_FINANCIAL_TRACKER_MARGIN
- }
- if (rotated) {
- x = _min(lowY, highY);
- y = that.x - that.width / 2;
- width = _abs(lowY - highY);
- height = that.width
- }
- else {
- x = that.x - that.width / 2;
- y = _min(lowY, highY);
- width = that.width;
- height = _abs(lowY - highY)
- }
- return {
- x: x,
- y: y,
- width: width,
- height: height
- }
- },
- _getGraphicBbox: function() {
- var that = this,
- rotated = that._options.rotated,
- x = that.x,
- width = that.width,
- lowY = that.lowY,
- highY = that.highY;
- return {
- x: !rotated ? x - _round(width / 2) : lowY,
- y: !rotated ? highY : x - _round(width / 2),
- width: !rotated ? width : highY - lowY,
- height: !rotated ? lowY - highY : width
- }
- },
- getTooltipParams: function(location) {
- var that = this;
- if (that.graphic) {
- var x,
- y,
- min,
- max,
- minValue = _min(that.lowY, that.highY),
- maxValue = _max(that.lowY, that.highY),
- visibleAreaX = that.translators.x.getCanvasVisibleArea(),
- visibleAreaY = that.translators.y.getCanvasVisibleArea(),
- edgeLocation = location === 'edge';
- if (!that._options.rotated) {
- min = _max(visibleAreaY.min, minValue);
- max = _min(visibleAreaY.max, maxValue);
- x = that.x;
- y = edgeLocation ? min : min + (max - min) / 2
- }
- else {
- min = _max(visibleAreaX.min, minValue);
- max = _min(visibleAreaX.max, maxValue);
- y = that.x;
- x = edgeLocation ? max : min + (max - min) / 2
- }
- return {
- x: x,
- y: y,
- offset: 0
- }
- }
- },
- hasValue: function() {
- return this.highValue !== null && this.lowValue !== null
- },
- _translate: function() {
- var that = this,
- rotated = that._options.rotated,
- translators = that.translators,
- argTranslator = rotated ? translators.y : translators.x,
- valTranslator = rotated ? translators.x : translators.y,
- centerValue,
- height;
- that.vx = that.vy = that.x = argTranslator.translate(that.argument) + (that.xCorrection || 0);
- that.openY = that.openValue !== null ? valTranslator.translate(that.openValue) : null;
- that.highY = valTranslator.translate(that.highValue);
- that.lowY = valTranslator.translate(that.lowValue);
- that.closeY = that.closeValue !== null ? valTranslator.translate(that.closeValue) : null;
- height = _abs(that.lowY - that.highY);
- centerValue = _min(that.lowY, that.highY) + _abs(that.lowY - that.highY) / 2;
- that._calculateVisibility(!rotated ? that.x : centerValue, !rotated ? centerValue : that.x)
- },
- getCrosshairCoords: function(x, y) {
- var coords,
- valueCoord = this._options.rotated ? x : y,
- value = Math.abs(this.lowY - valueCoord) < Math.abs(this.closeY - valueCoord) ? this.lowY : this.closeY;
- value = Math.abs(value - valueCoord) < Math.abs(this.openY - valueCoord) ? value : this.openY;
- value = Math.abs(value - valueCoord) < Math.abs(this.highY - valueCoord) ? value : this.highY;
- if (this._options.rotated)
- coords = {
- y: this.vy,
- x: value
- };
- else
- coords = {
- x: this.vx,
- y: value
- };
- return coords
- },
- _updateData: function(data) {
- var that = this,
- label = that._label,
- reductionColor = this._options.reduction.color;
- that.value = that.initialValue = data.reductionValue;
- that.originalValue = data.value;
- that.lowValue = that.originalLowValue = data.lowValue;
- that.highValue = that.originalHighValue = data.highValue;
- that.openValue = that.originalOpenValue = data.openValue;
- that.closeValue = that.originalCloseValue = data.closeValue;
- that._isPositive = data.openValue < data.closeValue;
- that._isReduction = data.isReduction;
- if (that._isReduction)
- label.setColor(reductionColor)
- },
- _updateMarker: function(animationEnabled, style, group) {
- var that = this,
- graphic = that.graphic;
- graphic.attr({points: that._getPoints()}).attr(style || that._getStyle()).sharp();
- group && graphic.append(that._getMarkerGroup(group))
- },
- _getLabelFormatObject: function() {
- var that = this;
- return {
- openValue: that.openValue,
- highValue: that.highValue,
- lowValue: that.lowValue,
- closeValue: that.closeValue,
- reductionValue: that.initialValue,
- argument: that.initialArgument,
- value: that.initialValue,
- seriesName: that.series.name,
- originalOpenValue: that.originalOpenValue,
- originalCloseValue: that.originalCloseValue,
- originalLowValue: that.originalLowValue,
- originalHighValue: that.originalHighValue,
- originalArgument: that.originalArgument,
- point: that
- }
- },
- _getFormatObject: function(tooltip) {
- var that = this,
- highValue = tooltip.formatValue(that.highValue),
- openValue = tooltip.formatValue(that.openValue),
- closeValue = tooltip.formatValue(that.closeValue),
- lowValue = tooltip.formatValue(that.lowValue),
- symbolMethods = points.symbolPoint,
- formatObject = symbolMethods._getFormatObject.call(that, tooltip);
- return _extend({}, formatObject, {
- valueText: "h: " + highValue + (openValue !== "" ? " o: " + openValue : "") + (closeValue !== "" ? " c: " + closeValue : "") + " l: " + lowValue,
- highValueText: highValue,
- openValueText: openValue,
- closeValueText: closeValue,
- lowValueText: lowValue
- })
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file stockPoint.js */
- (function($, DX) {
- var points = DX.viz.core.series.points.mixins,
- _extend = $.extend,
- _isNumeric = $.isNumeric;
- points.stockPoint = _extend({}, points.candlestickPoint, {
- _getPoints: function() {
- var that = this,
- createPoint = that._options.rotated ? function(x, y) {
- return [y, x]
- } : function(x, y) {
- return [x, y]
- },
- openYExist = _isNumeric(that.openY),
- closeYExist = _isNumeric(that.closeY),
- x = that.x,
- width = that.width,
- points;
- points = [].concat(createPoint(x, that.highY));
- openYExist && (points = points.concat(createPoint(x, that.openY)));
- openYExist && (points = points.concat(createPoint(x - width / 2, that.openY)));
- openYExist && (points = points.concat(createPoint(x, that.openY)));
- closeYExist && (points = points.concat(createPoint(x, that.closeY)));
- closeYExist && (points = points.concat(createPoint(x + width / 2, that.closeY)));
- closeYExist && (points = points.concat(createPoint(x, that.closeY)));
- points = points.concat(createPoint(x, that.lowY));
- return points
- },
- _drawMarkerInGroup: function(group, attributes, renderer) {
- this.graphic = renderer.path(this._getPoints(), "line").attr({"stroke-linecap": "square"}).attr(attributes).data({point: this}).sharp().append(group)
- },
- _getMinTrackerWidth: function() {
- var width = 2 + this._styles.normal['stroke-width'];
- return width + width % 2
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file polarPoint.js */
- (function($, DX, undefined) {
- var _extend = $.extend,
- viz = DX.viz,
- points = viz.core.series.points.mixins,
- utils = DX.utils,
- isDefined = utils.isDefined,
- normalizeAngle = utils.normalizeAngle,
- _math = Math,
- _max = _math.max,
- ERROR_BARS_ANGLE_OFFSET = 90,
- CANVAS_POSITION_START = "canvas_position_start",
- CANVAS_POSITION_TOP = "canvas_position_top",
- CANVAS_POSITION_END = "canvas_position_end",
- CANVAS_POSITION_DEFAULT = "canvas_position_default";
- points.polarSymbolPoint = _extend({}, points.symbolPoint, {
- _getLabelCoords: points.piePoint._getLabelCoords,
- _moveLabelOnCanvas: points.barPoint._moveLabelOnCanvas,
- _getLabelPosition: function() {
- return "outside"
- },
- _translate: function(translator) {
- var that = this,
- coord = translator.translate(that.argument, that.value),
- center = translator.translate(CANVAS_POSITION_START, CANVAS_POSITION_TOP);
- that.vx = normalizeAngle(coord.angle);
- that.vy = that.radiusOuter = coord.radius;
- that.radius = coord.radius;
- that.middleAngle = -coord.angle;
- that.angle = -coord.angle;
- that.x = coord.x;
- that.y = coord.y;
- that.defaultX = that.centerX = center.x;
- that.defaultY = that.centerY = center.y;
- that._translateErrorBars(translator);
- that.inVisibleArea = true
- },
- _translateErrorBars: function(translator) {
- var that = this;
- isDefined(that.lowError) && (that._lowErrorCoord = that.centerY - translator.translate(that.argument, that.lowError).radius);
- isDefined(that.highError) && (that._highErrorCoord = that.centerY - translator.translate(that.argument, that.highError).radius);
- that._errorBarPos = that.centerX;
- that._baseErrorBarPos = (that._options.errorBars || {}).type === "stdDeviation" ? that._lowErrorCoord + (that._highErrorCoord - that._lowErrorCoord) / 2 : that.centerY - that.radius
- },
- _getTranslates: function(animationEnabled) {
- return animationEnabled ? this.getDefaultCoords() : {
- x: this.x,
- y: this.y
- }
- },
- getDefaultCoords: function() {
- var cossin = utils.getCosAndSin(-this.angle),
- radius = this.translators.translate(CANVAS_POSITION_START, CANVAS_POSITION_DEFAULT).radius,
- x = this.defaultX + radius * cossin.cos,
- y = this.defaultY + radius * cossin.sin;
- return {
- x: x,
- y: y
- }
- },
- _addLabelAlignmentAndOffset: function(label, coord) {
- return coord
- },
- _getVisibleArea: function() {
- var canvas = this.translators.canvas;
- return {
- minX: canvas.left,
- maxX: canvas.width - canvas.right,
- minY: canvas.top,
- maxY: canvas.height - canvas.bottom
- }
- },
- _checkLabelPosition: function(label, coord) {
- var that = this,
- visibleArea = that._getVisibleArea(),
- graphicBbox = that._getGraphicBbox();
- if (that._isPointInVisibleArea(visibleArea, graphicBbox))
- coord = that._moveLabelOnCanvas(coord, visibleArea, label.getBoundingRect(), true, true);
- return coord
- },
- _getErrorBarSettings: function(errorBarOptions, animationEnabled) {
- var settings = points.symbolPoint._getErrorBarSettings.call(this, errorBarOptions, animationEnabled);
- settings.rotate = ERROR_BARS_ANGLE_OFFSET - this.angle;
- settings.rotateX = this.centerX;
- settings.rotateY = this.centerY;
- return settings
- },
- getCoords: function(min) {
- return min ? this.getDefaultCoords() : {
- x: this.x,
- y: this.y
- }
- }
- });
- points.polarBarPoint = _extend({}, points.barPoint, {
- _translateErrorBars: points.polarSymbolPoint._translateErrorBars,
- _getErrorBarSettings: points.polarSymbolPoint._getErrorBarSettings,
- _getVisibleArea: points.polarSymbolPoint._getVisibleArea,
- _moveLabelOnCanvas: points.barPoint._moveLabelOnCanvas,
- _getLabelCoords: points.piePoint._getLabelCoords,
- _getLabelConnector: points.piePoint._getLabelConnector,
- getBoundaryCoords: points.piePoint.getBoundaryCoords,
- getTooltipParams: points.piePoint.getTooltipParams,
- _getLabelPosition: points.piePoint._getLabelPosition,
- _translate: function(translator) {
- var that = this,
- maxRadius = translator.translate(CANVAS_POSITION_TOP, CANVAS_POSITION_END).radius;
- that.radiusInner = translator.translate(that.argument, that.minValue).radius;
- points.polarSymbolPoint._translate.call(that, translator);
- if (that.radiusInner === null)
- that.radiusInner = that.radius = maxRadius;
- else if (that.radius === null)
- this.radius = this.value >= 0 ? maxRadius : 0;
- that.radiusOuter = _max(that.radiusInner, that.radius);
- that.radiusInner = that.defaultRadius = _math.min(that.radiusInner, that.radius);
- that.middleAngle = that.angle = -utils.normalizeAngle(that.middleAngleCorrection - that.angle)
- },
- _checkVisibility: function(translator) {
- return translator.checkVisibility(this.radius, this.radiusInner)
- },
- getMarkerCoords: function() {
- return {
- x: this.centerX,
- y: this.centerY,
- outerRadius: this.radiusOuter,
- innerRadius: this.defaultRadius,
- startAngle: this.middleAngle - this.interval / 2,
- endAngle: this.middleAngle + this.interval / 2
- }
- },
- _drawMarker: function(renderer, group, animationEnabled) {
- var that = this,
- styles = that._getStyle(),
- coords = that.getMarkerCoords(),
- innerRadius = coords.innerRadius,
- outerRadius = coords.outerRadius,
- start = that.translators.translate(that.argument, CANVAS_POSITION_DEFAULT),
- x = coords.x,
- y = coords.y;
- if (animationEnabled) {
- innerRadius = 0;
- outerRadius = 0;
- x = start.x;
- y = start.y
- }
- that.graphic = renderer.arc(x, y, innerRadius, outerRadius, coords.startAngle, coords.endAngle).attr(styles).data({point: that}).append(group)
- },
- _checkLabelPosition: function(label, coord) {
- var that = this,
- visibleArea = that._getVisibleArea(),
- angleFunctions = utils.getCosAndSin(that.middleAngle),
- x = that.centerX + that.defaultRadius * angleFunctions.cos,
- y = that.centerY - that.defaultRadius * angleFunctions.sin;
- if (x > visibleArea.minX && x < visibleArea.maxX && y > visibleArea.minY && y < visibleArea.maxY)
- coord = that._moveLabelOnCanvas(coord, visibleArea, label.getBoundingRect(), true, true);
- return coord
- },
- _addLabelAlignmentAndOffset: function(label, coord) {
- return coord
- },
- correctCoordinates: function(correctOptions) {
- this.middleAngleCorrection = correctOptions.offset;
- this.interval = correctOptions.width
- },
- coordsIn: function(x, y) {
- var val = this.translators.untranslate(x, y),
- coords = this.getMarkerCoords(),
- isBetweenAngles = coords.startAngle < coords.endAngle ? -val.phi >= coords.startAngle && -val.phi <= coords.endAngle : -val.phi <= coords.startAngle && -val.phi >= coords.endAngle;
- return val.r >= coords.innerRadius && val.r <= coords.outerRadius && isBetweenAngles
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-core, file dataValidator.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- parseUtils = new viz.core.ParseUtils,
- STRING = "string",
- NUMERIC = "numeric",
- DATETIME = "datetime",
- DISCRETE = "discrete",
- CONTINUOUS = "continuous",
- LOGARITHMIC = "logarithmic",
- VALUE_TYPE = "valueType",
- ARGUMENT_TYPE = "argumentType",
- axisTypeParser = viz.core.utils.enumParser([STRING, NUMERIC, DATETIME]),
- utils = DX.utils,
- _each = $.each,
- _isDefined = utils.isDefined;
- function groupingValues(data, others, valueField, index) {
- if (!_isDefined(index) || index < 0)
- return;
- _each(data.slice(index), function(_, cell) {
- if (!_isDefined(cell[valueField]))
- return;
- others[valueField] += cell[valueField];
- cell[valueField] = undefined;
- cell["original" + valueField] = undefined
- })
- }
- function mergeSort(data, field) {
- function merge_sort(array, low, high, field) {
- if (low < high) {
- var mid = Math.floor((low + high) / 2);
- merge_sort(array, low, mid, field);
- merge_sort(array, mid + 1, high, field);
- merge(array, low, mid, high, field)
- }
- }
- var n = data.length;
- merge_sort(data, 0, n - 1, field);
- return data
- }
- function merge(array, low, mid, high, field) {
- var newArray = new Array(high - low + 1),
- countL = low,
- countR = mid + 1,
- k,
- i = 0;
- while (countL <= mid && countR <= high) {
- if (array[countL][field] <= array[countR][field] || !_isDefined(array[countR][field])) {
- newArray[i] = array[countL];
- countL++
- }
- else {
- newArray[i] = array[countR];
- countR++
- }
- i++
- }
- if (countL > mid)
- for (k = countR; k <= high; k++, i++)
- newArray[i] = array[k];
- else
- for (k = countL; k <= mid; k++, i++)
- newArray[i] = array[k];
- for (k = 0; k <= high - low; k++)
- array[k + low] = newArray[k];
- return array
- }
- function DataValidator(data, groups, incidentOccured, dataPrepareOptions) {
- var that = this;
- groups = groups || [[]];
- that._nullData = !data;
- that.groups = groups;
- that.data = data || [];
- that._parsers = {};
- that._errorShowList = {};
- that._skipFields = {};
- that.options = dataPrepareOptions || {};
- that.incidentOccured = incidentOccured;
- that.userArgumentCategories = that.groups.argumentOptions && that.groups.argumentOptions.categories || [];
- if (!incidentOccured)
- that.incidentOccured = $.noop
- }
- viz.core.DataValidator = DataValidator;
- DataValidator.prototype = {
- ctor: DataValidator,
- validate: function validate() {
- var that = this,
- dataLength;
- that._data = that.data;
- that.groups.argumentType = null;
- that.groups.argumentAxisType = null;
- _each(that.groups, function(_, group) {
- group.valueType = null;
- group.valueAxisType = null;
- _each(group, function(_, series) {
- series.updateDataType({})
- });
- group.valueAxis && group.valueAxis.resetTypes(VALUE_TYPE)
- });
- if (that.groups.argumentAxes)
- _each(that.groups.argumentAxes, function(_, axis) {
- axis.resetTypes(ARGUMENT_TYPE)
- });
- that._checkType();
- that._checkAxisType();
- if (!utils.isArray(that.data) || that._nullData)
- that._incorrectDataMessage();
- if (that.options.convertToAxisDataType) {
- that._createParser();
- that._parse()
- }
- that._groupData();
- that._sort();
- dataLength = that._data.length;
- _each(that._skipFields, function(field, fieldValue) {
- if (fieldValue === dataLength)
- that.incidentOccured("W2002", [field])
- });
- return that._data
- },
- _checkValueTypeOfGroup: function(group, cell) {
- var that = this;
- _each(group, function(_, series) {
- _each(series.getValueFields(), function(_, field) {
- group.valueType = that._getType(cell[field], group.valueType)
- })
- });
- return group.valueType
- },
- _checkArgumentTypeOfGroup: function(group, cell) {
- var that = this;
- _each(group, function(_, series) {
- that.groups.argumentType = that._getType(cell[series.getArgumentField()], that.groups.argumentType)
- });
- return that.groups.argumentType
- },
- _checkType: function _checkType() {
- var that = this,
- groupsWithUndefinedValueType = [],
- groupsWithUndefinedArgumentType = [],
- groups = that.groups,
- argumentTypeGroup = groups.argumentOptions && axisTypeParser(groups.argumentOptions.argumentType);
- _each(groups, function(_, group) {
- if (!group.length)
- return null;
- var valueTypeGroup = group.valueOptions && axisTypeParser(group.valueOptions.valueType);
- group.valueType = valueTypeGroup;
- groups.argumentType = argumentTypeGroup;
- !valueTypeGroup && groupsWithUndefinedValueType.push(group);
- !argumentTypeGroup && groupsWithUndefinedArgumentType.push(group)
- });
- if (groupsWithUndefinedValueType.length || groupsWithUndefinedArgumentType.length)
- _each(that.data, function(_, cell) {
- var defineVal,
- defineArg;
- if (!utils.isObject(cell))
- return;
- _each(groupsWithUndefinedValueType, function(_, group) {
- defineVal = that._checkValueTypeOfGroup(group, cell)
- });
- _each(groupsWithUndefinedArgumentType, function(_, group) {
- defineArg = that._checkArgumentTypeOfGroup(group, cell)
- });
- if (!that.options.checkTypeForAllData && defineVal && defineArg)
- return false
- })
- },
- _checkAxisType: function _checkAxisType() {
- var that = this,
- groups = that.groups,
- argumentOptions = groups.argumentOptions || {};
- _each(groups, function(_, group) {
- _each(group, function(_, series) {
- var optionsSeries = {},
- valueOptions = group.valueOptions || {},
- valueCategories = valueOptions.categories || [];
- optionsSeries.argumentAxisType = that._correctAxisType(groups.argumentType, argumentOptions.type, !!that.userArgumentCategories.length);
- optionsSeries.valueAxisType = that._correctAxisType(group.valueType, valueOptions.type, !!valueCategories.length);
- groups.argumentAxisType = groups.argumentAxisType || optionsSeries.argumentAxisType;
- group.valueAxisType = group.valueAxisType || optionsSeries.valueAxisType;
- optionsSeries.argumentType = groups.argumentType;
- optionsSeries.valueType = group.valueType;
- optionsSeries.showZero = valueOptions.showZero;
- series.updateDataType(optionsSeries)
- });
- if (group.valueAxis) {
- group.valueAxis.setTypes(group.valueAxisType, group.valueType, VALUE_TYPE);
- group.valueAxis.validate(false)
- }
- });
- if (that.groups.argumentAxes)
- _each(that.groups.argumentAxes, function(_, axis) {
- axis.setTypes(that.groups.argumentAxisType, that.groups.argumentType, ARGUMENT_TYPE);
- axis.validate(true)
- })
- },
- _createParser: function _createParser() {
- var that = this,
- groups = that.groups;
- _each(groups, function(_, group) {
- _each(group, function(_, series) {
- that._parsers[series.getArgumentField()] = that._createParserUnit(groups.argumentType, groups.argumentAxisType === LOGARITHMIC ? that._filterForLogAxis : null);
- _each(series.getValueFields(), function(_, field) {
- that._parsers[field] = that._createParserUnit(group.valueType, group.valueAxisType === LOGARITHMIC ? that._filterForLogAxis : null, series.getOptions().ignoreEmptyPoints)
- });
- if (series.getTagField())
- that._parsers[series.getTagField()] = null
- })
- })
- },
- _parse: function _parse() {
- var that = this,
- parsedData = [];
- _each(that.data, function(_, cell) {
- var parserObject = {};
- if (!utils.isObject(cell)) {
- cell && that._incorrectDataMessage();
- return
- }
- _each(that._parsers, function(field, parser) {
- parserObject[field] = parser ? parser(cell[field], field) : cell[field];
- parserObject["original" + field] = cell[field]
- });
- parsedData.push(parserObject)
- });
- this._data = parsedData
- },
- _groupMinSlices: function(argumentField, valueField, smallValuesGrouping) {
- smallValuesGrouping = smallValuesGrouping || {};
- var that = this,
- mode = smallValuesGrouping.mode,
- count = smallValuesGrouping.topCount,
- threshold = smallValuesGrouping.threshold,
- name = smallValuesGrouping.groupName || "others",
- others = {},
- data = that._data.slice(),
- index;
- if (!mode || mode === "none")
- return;
- others[argumentField] = name + "";
- others[valueField] = 0;
- data.sort(function(a, b) {
- if (_isDefined(b[valueField]) && _isDefined(a[valueField]))
- return b[valueField] - a[valueField];
- else if (!_isDefined(b[valueField]) && a[valueField])
- return -1;
- else if (!_isDefined(a[valueField]) && b[valueField])
- return 1
- });
- if (mode === "smallValueThreshold") {
- _each(data, function(i, cell) {
- if (_isDefined(index) || !_isDefined(cell[valueField]))
- return;
- if (threshold > cell[valueField])
- index = i
- });
- groupingValues(data, others, valueField, index)
- }
- else if (mode === "topN")
- groupingValues(data, others, valueField, count);
- others[valueField] && that._data.push(others)
- },
- _groupData: function() {
- var that = this,
- groups = that.groups,
- isPie = groups.length && groups[0].length && (groups[0][0].type === "pie" || groups[0][0].type === "doughnut" || groups[0][0].type === "donut"),
- argumentField,
- valueFields;
- if (!isPie)
- return;
- _each(groups, function(_, group) {
- _each(group, function(_, series) {
- argumentField = series.getArgumentField();
- valueFields = series.getValueFields();
- if (groups.argumentAxisType === DISCRETE)
- that._groupSameArguments(argumentField, valueFields);
- that._groupMinSlices(argumentField, valueFields[0], series.getOptions().smallValuesGrouping)
- })
- })
- },
- _groupSameArguments: function(argumentField, valueFields) {
- var that = this,
- argument,
- dataOfArguments = {},
- parsedData = that._data;
- _each(parsedData, function(i, cell) {
- if (!_isDefined(cell[argumentField]) || !_isDefined(cell[valueFields[0]]))
- return;
- argument = cell[argumentField];
- if (_isDefined(dataOfArguments[argument])) {
- var data = parsedData[dataOfArguments[argument]];
- _each(valueFields, function(_, field) {
- data[field] += cell[field];
- cell[field] = undefined;
- cell["original" + field] = undefined
- })
- }
- else
- dataOfArguments[argument] = i
- })
- },
- _getType: function _getType(unit, type) {
- if (type === STRING || utils.isString(unit))
- return STRING;
- if (type === DATETIME || utils.isDate(unit))
- return DATETIME;
- if (utils.isNumber(unit))
- return NUMERIC;
- return type
- },
- _correctAxisType: function _correctAxisType(type, axisType, hasCategories) {
- if (type === STRING && (axisType === CONTINUOUS || axisType === LOGARITHMIC))
- this.incidentOccured("E2002");
- if (axisType === LOGARITHMIC)
- return LOGARITHMIC;
- axisType = (hasCategories || axisType === DISCRETE || type === STRING) && DISCRETE;
- return axisType || CONTINUOUS
- },
- _filterForLogAxis: function(val, field) {
- if (val <= 0) {
- this.incidentOccured("E2004", [field]);
- return null
- }
- return val
- },
- _createParserUnit: function _createParserUnit(type, filter, ignoreEmptyPoints) {
- var that = this,
- parser = type ? parseUtils.getParser(type, undefined, true) : function(unit) {
- return unit
- };
- return function(unit, field) {
- var parseUnit = parser(unit);
- if (filter)
- parseUnit = filter.call(that, parseUnit, field);
- parseUnit === null && ignoreEmptyPoints && (parseUnit = undefined);
- if (parseUnit === undefined) {
- that._addSkipFields(field);
- that._validUnit(unit, field, type)
- }
- return parseUnit
- }
- },
- _validUnit: function _validUnit(unit, field) {
- if (!unit)
- return;
- if (!utils.isNumber(unit) && !utils.isDate(unit) && !utils.isString(unit)) {
- this.incidentOccured("E2003", [field]);
- return
- }
- this.incidentOccured("E2004", [field])
- },
- _sort: function _sort() {
- var that = this,
- sortingMethod = that.options.sortingMethod,
- data = that._data,
- groups = that.groups,
- hash = {},
- argumentField = groups.length && groups[0].length && groups[0][0].getArgumentField();
- if (utils.isFunction(sortingMethod))
- data.sort(sortingMethod);
- else if (that.userArgumentCategories.length) {
- _each(that.userArgumentCategories, function(index, value) {
- hash[value] = index
- });
- data.sort(function sortCat(a, b) {
- a = a[argumentField];
- b = b[argumentField];
- return hash[a] - hash[b]
- })
- }
- else if (sortingMethod === true && groups.argumentType !== STRING)
- mergeSort(data, argumentField)
- },
- _addSkipFields: function _addSkipFields(field) {
- this._skipFields[field] = (this._skipFields[field] || 0) + 1
- },
- _incorrectDataMessage: function() {
- if (this._erorrDataSource !== true) {
- this._erorrDataSource = true;
- this.incidentOccured("E2001")
- }
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-core, file default.js */
- (function(DX, undefined) {
- var WHITE = "#ffffff",
- BLACK = "#000000",
- LIGHT_GREY = "#d3d3d3",
- GREY_GREEN = "#303030",
- RED = "#ff0000";
- DX.viz.core.registerTheme({
- name: "generic.light",
- font: {
- color: '#767676',
- family: "'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana",
- weight: 400,
- size: 12,
- cursor: 'default'
- },
- redrawOnResize: true,
- backgroundColor: WHITE,
- primaryTitleColor: "#232323",
- secondaryTitleColor: "#767676",
- axisColor: LIGHT_GREY,
- axisLabelColor: "#a8a8a8",
- title: {font: {
- family: "'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana",
- weight: 200
- }},
- loadingIndicator: {text: "Loading..."},
- tooltip: {
- enabled: false,
- border: {
- width: 1,
- color: LIGHT_GREY,
- dashStyle: 'solid',
- visible: true
- },
- font: {color: '#232323'},
- color: WHITE,
- arrowLength: 10,
- paddingLeftRight: 18,
- paddingTopBottom: 15,
- shared: false,
- location: 'center',
- format: '',
- argumentFormat: '',
- precision: 0,
- argumentPrecision: 0,
- percentPrecision: 0,
- shadow: {
- opacity: 0.4,
- offsetX: 0,
- offsetY: 4,
- blur: 2,
- color: BLACK
- }
- },
- legend: {
- hoverMode: 'includePoints',
- verticalAlignment: 'top',
- horizontalAlignment: 'right',
- position: 'outside',
- visible: true,
- margin: 10,
- markerSize: 12,
- border: {
- visible: false,
- width: 1,
- cornerRadius: 0,
- dashStyle: 'solid'
- },
- paddingLeftRight: 20,
- paddingTopBottom: 15,
- columnCount: 0,
- rowCount: 0,
- columnItemSpacing: 20,
- rowItemSpacing: 8
- },
- "chart:common": {
- animation: {
- enabled: true,
- duration: 1000,
- easing: 'easeOutCubic',
- maxPointCountSupported: 300
- },
- commonSeriesSettings: {
- border: {
- visible: false,
- width: 2
- },
- showInLegend: true,
- visible: true,
- hoverMode: 'nearestPoint',
- selectionMode: 'includePoints',
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 2,
- step: 6,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 3
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 2,
- step: 6,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 3
- }
- },
- valueErrorBar: {
- displayMode: "auto",
- value: 1,
- color: BLACK,
- lineWidth: 2,
- edgeLength: 8
- },
- label: {
- visible: false,
- alignment: 'center',
- rotationAngle: 0,
- horizontalOffset: 0,
- verticalOffset: 0,
- radialOffset: 0,
- format: '',
- argumentFormat: '',
- precision: 0,
- argumentPrecision: 0,
- percentPrecision: 0,
- showForZeroValues: true,
- customizeText: undefined,
- maxLabelCount: undefined,
- position: 'outside',
- font: {color: WHITE},
- border: {
- visible: false,
- width: 1,
- color: LIGHT_GREY,
- dashStyle: 'solid'
- },
- connector: {
- visible: false,
- width: 1
- }
- }
- },
- seriesSelectionMode: 'single',
- pointSelectionMode: 'single',
- equalRowHeight: true,
- dataPrepareSettings: {
- checkTypeForAllData: false,
- convertToAxisDataType: true,
- sortingMethod: true
- },
- title: {
- font: {size: 28},
- margin: 10
- },
- adaptiveLayout: {
- width: 80,
- height: 80,
- keepLabels: true
- },
- _rtl: {legend: {itemTextPosition: 'left'}},
- resolveLabelOverlapping: "none"
- },
- "chart:common:axis": {
- visible: false,
- setTicksAtUnitBeginning: true,
- valueMarginsEnabled: true,
- placeholderSize: null,
- logarithmBase: 10,
- discreteAxisDivisionMode: 'betweenLabels',
- width: 1,
- label: {
- visible: true,
- precision: 0,
- format: ""
- },
- grid: {
- visible: false,
- width: 1
- },
- minorGrid: {
- visible: false,
- width: 1,
- opacity: 0.3
- },
- tick: {visible: false},
- minorTick: {
- visible: false,
- opacity: 0.3
- },
- stripStyle: {
- paddingLeftRight: 10,
- paddingTopBottom: 5
- },
- constantLineStyle: {
- width: 1,
- color: BLACK,
- dashStyle: "solid",
- label: {
- visible: true,
- position: "inside"
- }
- }
- },
- chart: {
- commonSeriesSettings: {
- type: 'line',
- stack: 'default',
- point: {
- visible: true,
- symbol: 'circle',
- size: 12,
- border: {
- visible: false,
- width: 1
- },
- hoverMode: 'onlyPoint',
- selectionMode: 'onlyPoint',
- hoverStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- },
- selectionStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- }
- },
- scatter: {},
- line: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- stackedline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- stackedspline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- fullstackedline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- fullstackedspline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- stepline: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- area: {
- point: {visible: false},
- opacity: 0.5
- },
- stackedarea: {
- point: {visible: false},
- opacity: 0.5
- },
- fullstackedarea: {
- point: {visible: false},
- opacity: 0.5
- },
- fullstackedsplinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- steparea: {
- border: {
- visible: true,
- width: 2
- },
- point: {visible: false},
- hoverStyle: {border: {
- visible: true,
- width: 3
- }},
- selectionStyle: {border: {
- visible: true,
- width: 3
- }},
- opacity: 0.5
- },
- spline: {
- width: 2,
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- splinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- stackedsplinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- bar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- stackedbar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- },
- label: {position: "inside"}
- },
- fullstackedbar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- },
- label: {position: "inside"}
- },
- rangebar: {
- cornerRadius: 0,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- rangearea: {
- point: {visible: false},
- opacity: 0.5
- },
- rangesplinearea: {
- point: {visible: false},
- opacity: 0.5
- },
- bubble: {
- opacity: 0.5,
- point: {
- hoverStyle: {border: {visible: false}},
- selectionStyle: {border: {visible: false}}
- }
- },
- candlestick: {
- width: 1,
- reduction: {color: RED},
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3},
- point: {border: {visible: true}}
- },
- stock: {
- width: 1,
- reduction: {color: RED},
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3},
- point: {border: {visible: true}}
- }
- },
- crosshair: {
- enabled: false,
- color: '#f78119',
- width: 1,
- dashStyle: 'solid',
- label: {
- visible: false,
- font: {
- color: WHITE,
- size: 12
- }
- },
- verticalLine: {visible: true},
- horizontalLine: {visible: true}
- },
- commonAxisSettings: {
- multipleAxesSpacing: 5,
- label: {
- overlappingBehavior: {
- mode: 'auto',
- rotationAngle: 90,
- staggeringSpacing: 5
- },
- indentFromAxis: 10
- },
- title: {
- font: {size: 16},
- margin: 6
- },
- constantLineStyle: {
- paddingLeftRight: 10,
- paddingTopBottom: 10
- }
- },
- horizontalAxis: {
- position: 'bottom',
- axisDivisionFactor: 50,
- label: {alignment: "center"},
- stripStyle: {label: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top'
- }},
- constantLineStyle: {label: {
- horizontalAlignment: 'right',
- verticalAlignment: 'top'
- }},
- constantLines: {}
- },
- verticalAxis: {
- position: 'left',
- axisDivisionFactor: 30,
- label: {
- alignment: 'right',
- overlappingBehavior: {mode: 'enlargeTickInterval'}
- },
- stripStyle: {label: {
- horizontalAlignment: 'left',
- verticalAlignment: 'center'
- }},
- constantLineStyle: {label: {
- horizontalAlignment: 'left',
- verticalAlignment: 'top'
- }},
- constantLines: {}
- },
- argumentAxis: {},
- valueAxis: {grid: {visible: true}},
- commonPaneSettings: {
- backgroundColor: 'none',
- border: {
- color: LIGHT_GREY,
- width: 1,
- visible: false,
- top: true,
- bottom: true,
- left: true,
- right: true,
- dashStyle: 'solid'
- }
- },
- scrollBar: {
- visible: false,
- offset: 5,
- color: "gray",
- width: 10
- },
- useAggregation: false,
- adjustOnZoom: true,
- rotated: false,
- zoomingMode: 'none',
- scrollingMode: 'none',
- synchronizeMultiAxes: true,
- equalBarWidth: true,
- minBubbleSize: 12,
- maxBubbleSize: 0.2
- },
- pie: {
- commonSeriesSettings: {
- type: 'pie',
- pie: {
- border: {
- visible: false,
- width: 2,
- color: WHITE
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- },
- doughnut: {
- innerRadius: 0.5,
- border: {
- visible: false,
- width: 2,
- color: WHITE
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- },
- donut: {
- innerRadius: 0.5,
- border: {
- visible: false,
- width: 2,
- color: WHITE
- },
- hoverStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.75
- },
- border: {
- visible: false,
- width: 2
- }
- },
- selectionStyle: {
- hatching: {
- direction: 'right',
- width: 4,
- step: 10,
- opacity: 0.5
- },
- border: {
- visible: false,
- width: 2
- }
- }
- }
- },
- legend: {
- hoverMode: 'markPoint',
- backgroundColor: "none"
- },
- adaptiveLayout: {keepLabels: false}
- },
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {
- visible: true,
- color: WHITE
- }},
- selectionStyle: {border: {
- visible: true,
- color: WHITE
- }}
- },
- donut: {
- hoverStyle: {border: {
- visible: true,
- color: WHITE
- }},
- selectionStyle: {border: {
- visible: true,
- color: WHITE
- }}
- },
- doughnut: {
- hoverStyle: {border: {
- visible: true,
- color: WHITE
- }},
- selectionStyle: {border: {
- visible: true,
- color: WHITE
- }}
- }
- }},
- gauge: {
- scale: {
- majorTick: {
- visible: true,
- length: 5,
- width: 2,
- showCalculatedTicks: true,
- useTicksAutoArrangement: true
- },
- minorTick: {
- visible: false,
- length: 3,
- width: 1,
- showCalculatedTicks: true
- },
- label: {visible: true}
- },
- rangeContainer: {
- offset: 0,
- width: 5,
- backgroundColor: '#808080'
- },
- valueIndicators: {
- _default: {color: '#c2c2c2'},
- rangebar: {
- space: 2,
- size: 10,
- color: '#cbc5cf',
- backgroundColor: 'none',
- text: {
- indent: 0,
- font: {
- size: 14,
- color: null
- }
- }
- },
- twocolorneedle: {secondColor: '#e18e92'},
- trianglemarker: {
- space: 2,
- length: 14,
- width: 13,
- color: '#8798a5'
- },
- textcloud: {
- arrowLength: 5,
- horizontalOffset: 6,
- verticalOffset: 3,
- color: '#679ec5',
- text: {font: {
- color: WHITE,
- size: 18
- }}
- }
- },
- title: {
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top',
- overlay: 0
- },
- font: {size: 16}
- },
- subtitle: {font: {size: 14}},
- indicator: {
- hasPositiveMeaning: true,
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'bottom',
- overlay: 0
- },
- text: {font: {size: 18}}
- },
- _circular: {
- scale: {
- orientation: 'outside',
- label: {indentFromTick: 10}
- },
- rangeContainer: {orientation: 'outside'},
- valueIndicatorType: 'rectangleneedle',
- subvalueIndicatorType: 'trianglemarker',
- valueIndicators: {
- _type: 'rectangleneedle',
- _default: {
- offset: 20,
- indentFromCenter: 0,
- width: 2,
- spindleSize: 14,
- spindleGapSize: 10
- },
- triangleneedle: {width: 4},
- twocolorneedle: {
- space: 2,
- secondFraction: 0.4
- },
- rangebar: {offset: 30},
- trianglemarker: {offset: 6},
- textcloud: {offset: -6}
- }
- },
- _linear: {
- scale: {
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom',
- label: {indentFromTick: -10}
- },
- rangeContainer: {
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom'
- },
- valueIndicatorType: 'rangebar',
- subvalueIndicatorType: 'trianglemarker',
- valueIndicators: {
- _type: 'rectangle',
- _default: {
- offset: 2.5,
- length: 15,
- width: 15
- },
- rectangle: {width: 10},
- rangebar: {
- offset: 10,
- horizontalOrientation: 'right',
- verticalOrientation: 'bottom'
- },
- trianglemarker: {
- offset: -1,
- horizontalOrientation: 'left',
- verticalOrientation: 'top'
- },
- textcloud: {
- offset: -1,
- horizontalOrientation: 'left',
- verticalOrientation: 'top'
- }
- }
- }
- },
- barGauge: {
- backgroundColor: '#e0e0e0',
- relativeInnerRadius: 0.3,
- barSpacing: 4,
- label: {
- indent: 20,
- connectorWidth: 2,
- font: {size: 16}
- },
- title: {
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'top',
- overlay: 0
- },
- font: {size: 16}
- },
- subtitle: {font: {size: 14}},
- indicator: {
- hasPositiveMeaning: true,
- layout: {
- horizontalAlignment: 'center',
- verticalAlignment: 'bottom',
- overlay: 0
- },
- text: {font: {size: 18}}
- }
- },
- rangeSelector: {
- scale: {
- showCustomBoundaryTicks: true,
- showMinorTicks: true,
- useTicksAutoArrangement: true,
- setTicksAtUnitBeginning: true,
- label: {
- visible: true,
- topIndent: 7,
- font: {size: 11}
- },
- tick: {
- width: 1,
- color: BLACK,
- opacity: 0.1
- },
- marker: {
- visible: true,
- separatorHeight: 33,
- topIndent: 10,
- textLeftIndent: 7,
- textTopIndent: 11,
- label: {}
- },
- logarithmBase: 10
- },
- selectedRangeColor: "#606060",
- sliderMarker: {
- visible: true,
- paddingTopBottom: 2,
- paddingLeftRight: 4,
- color: '#606060',
- invalidRangeColor: RED,
- font: {
- color: WHITE,
- size: 11
- }
- },
- sliderHandle: {
- width: 1,
- color: BLACK,
- opacity: 0.2
- },
- shutter: {opacity: 0.75},
- background: {
- color: "#c0bae1",
- visible: true,
- image: {location: 'full'}
- },
- behavior: {
- snapToTicks: true,
- animationEnabled: true,
- moveSelectedRangeByClick: true,
- manualRangeSelectionEnabled: true,
- allowSlidersSwap: true,
- callSelectedRangeChanged: "onMovingComplete"
- },
- redrawOnResize: true,
- chart: {
- useAggregation: false,
- equalBarWidth: true,
- minBubbleSize: 12,
- maxBubbleSize: 0.2,
- topIndent: 0.1,
- bottomIndent: 0,
- valueAxis: {
- inverted: false,
- logarithmBase: 10
- },
- commonSeriesSettings: {
- type: "area",
- point: {visible: false}
- }
- }
- },
- map: {
- background: {
- borderWidth: 1,
- borderColor: '#cacaca'
- },
- areaSettings: {
- borderWidth: 1,
- borderColor: WHITE,
- color: '#d2d2d2',
- hoveredBorderColor: GREY_GREEN,
- selectedBorderWidth: 2,
- selectedBorderColor: GREY_GREEN,
- label: {
- enabled: false,
- stroke: WHITE,
- 'stroke-width': 2,
- 'stroke-opacity': 0.5,
- font: {
- color: '#2b2b2b',
- size: 16,
- opacity: 0.5
- }
- }
- },
- markerSettings: {
- label: {
- enabled: true,
- stroke: WHITE,
- 'stroke-width': 1,
- 'stroke-opacity': 0.5,
- font: {
- color: '#2b2b2b',
- size: 12
- }
- },
- _dot: {
- borderWidth: 2,
- borderColor: WHITE,
- color: '#ba4d51',
- size: 8,
- selectedStep: 2,
- backStep: 18,
- backColor: WHITE,
- backOpacity: 0.32,
- shadow: true
- },
- _bubble: {
- minSize: 20,
- maxSize: 50,
- color: '#ba4d51',
- hoveredBorderWidth: 1,
- hoveredBorderColor: GREY_GREEN,
- selectedBorderWidth: 2,
- selectedBorderColor: GREY_GREEN
- },
- _pie: {
- size: 50,
- hoveredBorderWidth: 1,
- hoveredBorderColor: GREY_GREEN,
- selectedBorderWidth: 2,
- selectedBorderColor: GREY_GREEN
- },
- _image: {size: 20}
- },
- legend: {
- verticalAlignment: 'bottom',
- horizontalAlignment: 'right',
- position: 'inside',
- backgroundOpacity: 0.65,
- border: {
- visible: true,
- color: '#cacaca'
- },
- paddingLeftRight: 16,
- paddingTopBottom: 12,
- markerColor: '#ba4d51'
- },
- controlBar: {
- borderColor: '#5d5d5d',
- borderWidth: 3,
- color: WHITE,
- margin: 20,
- opacity: 0.3
- },
- _rtl: {legend: {itemTextPosition: 'left'}}
- },
- sparkline: {
- lineColor: '#666666',
- lineWidth: 2,
- areaOpacity: 0.2,
- minColor: '#e8c267',
- maxColor: '#e55253',
- barPositiveColor: '#a9a9a9',
- barNegativeColor: '#d7d7d7',
- winColor: '#a9a9a9',
- lossColor: '#d7d7d7',
- firstLastColor: '#666666',
- pointSymbol: 'circle',
- pointColor: WHITE,
- pointSize: 4,
- type: "line",
- argumentField: "arg",
- valueField: "val",
- winlossThreshold: 0,
- showFirstLast: true,
- showMinMax: false,
- tooltip: {enabled: true}
- },
- bullet: {
- color: '#e8c267',
- targetColor: '#666666',
- targetWidth: 4,
- showTarget: true,
- showZeroLevel: true,
- tooltip: {enabled: true}
- },
- polar: {
- commonSeriesSettings: {
- type: 'scatter',
- closed: true,
- point: {
- visible: true,
- symbol: 'circle',
- size: 12,
- border: {
- visible: false,
- width: 1
- },
- hoverMode: 'onlyPoint',
- selectionMode: 'onlyPoint',
- hoverStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- },
- selectionStyle: {
- border: {
- visible: true,
- width: 4
- },
- size: 12
- }
- },
- scatter: {},
- line: {
- width: 2,
- dashStyle: 'solid',
- hoverStyle: {
- width: 3,
- hatching: {direction: 'none'}
- },
- selectionStyle: {width: 3}
- },
- area: {
- point: {visible: false},
- opacity: 0.5
- },
- stackedline: {width: 2},
- bar: {opacity: 0.8},
- stackedbar: {opacity: 0.8}
- },
- adaptiveLayout: {
- width: 170,
- height: 170,
- keepLabels: true
- },
- equalBarWidth: true,
- commonAxisSettings: {
- visible: true,
- label: {
- overlappingBehavior: {mode: 'enlargeTickInterval'},
- indentFromAxis: 5
- },
- grid: {visible: true},
- minorGrid: {visible: true},
- tick: {visible: true},
- title: {
- font: {size: 16},
- margin: 10
- }
- },
- argumentAxis: {
- startAngle: 0,
- firstPointOnStartAngle: false,
- period: undefined
- },
- valueAxis: {tick: {visible: false}},
- horizontalAxis: {
- position: 'top',
- axisDivisionFactor: 50,
- label: {alignment: "center"}
- },
- verticalAxis: {
- position: 'top',
- axisDivisionFactor: 30,
- label: {alignment: "right"}
- }
- }
- });
- DX.viz.core.registerTheme({
- name: "generic.dark",
- font: {color: '#808080'},
- backgroundColor: GREY_GREEN,
- primaryTitleColor: "#dbdbdb",
- secondaryTitleColor: "#a3a3a3",
- axisColor: "#555555",
- axisLabelColor: "#707070",
- tooltip: {
- color: '#2b2b2b',
- border: {color: '#494949'},
- font: {color: '#929292'}
- },
- "chart:common": {commonSeriesSettings: {
- label: {border: {color: '#494949'}},
- valueErrorBar: {color: WHITE}
- }},
- "chart:common:axis": {constantLineStyle: {color: WHITE}},
- chart: {
- crosshair: {color: '#515151'},
- commonPaneSettings: {border: {color: '#494949'}}
- },
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- },
- donut: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#2b2b2b'}},
- selectionStyle: {border: {color: '#2b2b2b'}}
- }
- }},
- gauge: {
- rangeContainer: {backgroundColor: '#b5b5b5'},
- valueIndicators: {
- _default: {color: '#b5b5b5'},
- rangebar: {color: '#84788b'},
- twocolorneedle: {secondColor: '#ba544d'},
- trianglemarker: {color: '#b7918f'},
- textcloud: {color: '#ba544d'}
- }
- },
- barGauge: {backgroundColor: "#3c3c3c"},
- rangeSelector: {
- selectedRangeColor: '#b5b5b5',
- scale: {tick: {
- color: WHITE,
- opacity: 0.05
- }},
- sliderMarker: {
- color: '#b5b5b5',
- font: {color: GREY_GREEN}
- },
- sliderHandle: {
- color: WHITE,
- opacity: 0.2
- },
- shutter: {
- color: '#2b2b2b',
- opacity: 0.9
- }
- },
- map: {
- background: {borderColor: '#3f3f3f'},
- areaSettings: {
- borderColor: GREY_GREEN,
- color: '#686868',
- hoveredBorderColor: WHITE,
- selectedBorderColor: WHITE,
- label: {
- stroke: BLACK,
- font: {color: WHITE}
- }
- },
- markerSettings: {
- label: {
- stroke: BLACK,
- font: {color: WHITE}
- },
- _bubble: {
- hoveredBorderColor: WHITE,
- selectedBorderColor: WHITE
- },
- _pie: {
- hoveredBorderColor: WHITE,
- selectedBorderColor: WHITE
- }
- },
- legend: {
- border: {color: '#3f3f3f'},
- font: {color: WHITE}
- },
- controlBar: {
- borderColor: '#c7c7c7',
- color: GREY_GREEN
- }
- },
- sparkline: {
- lineColor: '#c7c7c7',
- firstLastColor: '#c7c7c7',
- barPositiveColor: '#b8b8b8',
- barNegativeColor: '#8e8e8e',
- winColor: '#b8b8b8',
- lossColor: '#8e8e8e',
- pointColor: GREY_GREEN
- },
- bullet: {targetColor: '#8e8e8e'}
- }, "generic.light");
- DX.viz.core.currentTheme("generic.light");
- DX.viz.core.registerThemeAlias("desktop.light", "generic.light");
- DX.viz.core.registerThemeAlias("desktop.dark", "generic.dark")
- })(DevExpress);
- /*! Module viz-core, file android.js */
- (function(DX) {
- var ANDROID5_LIGHT = "android5.light",
- registerThemeAlias = DX.viz.core.registerThemeAlias;
- DX.viz.core.registerTheme({
- name: ANDROID5_LIGHT,
- backgroundColor: "#ffffff",
- primaryTitleColor: "#232323",
- secondaryTitleColor: "#767676",
- axisColor: "#d3d3d3",
- axisLabelColor: "#a8a8a8",
- tooltip: {
- color: "#e8e8e8",
- font: {color: "#808080"}
- },
- legend: {font: {color: "#000000"}},
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- },
- donut: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- },
- doughnut: {
- hoverStyle: {border: {color: '#e8e8e8'}},
- selectionStyle: {border: {color: '#e8e8e8'}}
- }
- }}
- }, "generic.light");
- registerThemeAlias("android", ANDROID5_LIGHT);
- registerThemeAlias("android.holo-dark", ANDROID5_LIGHT);
- registerThemeAlias("android.holo-light", ANDROID5_LIGHT);
- registerThemeAlias("android.dark", ANDROID5_LIGHT);
- registerThemeAlias("android.light", ANDROID5_LIGHT)
- })(DevExpress);
- /*! Module viz-core, file ios.js */
- (function(DX) {
- var IOS7_DEFAULT = "ios7.default",
- core = DX.viz.core;
- core.registerTheme({
- name: IOS7_DEFAULT,
- backgroundColor: "#ffffff",
- primaryTitleColor: "#000000",
- secondaryTitleColor: "#767676",
- axisColor: "#ececec",
- axisLabelColor: "#b8b8b8",
- legend: {font: {color: '#000000'}},
- tooltip: {font: {color: '#808080'}},
- "chart:common": {commonSeriesSettings: {label: {border: {color: '#d3d3d3'}}}},
- chart: {commonPaneSettings: {border: {color: '#d3d3d3'}}}
- }, "generic.light");
- core.registerThemeAlias("ios", IOS7_DEFAULT)
- })(DevExpress);
- /*! Module viz-core, file win8.js */
- (function(DX) {
- var core = DX.viz.core,
- registerTheme = core.registerTheme,
- registerThemeSchemeAlias = core.registerThemeSchemeAlias,
- BLACK = "#000000",
- WHITE = "#ffffff";
- registerTheme({
- name: "win8.black",
- backgroundColor: BLACK,
- primaryTitleColor: WHITE,
- secondaryTitleColor: "#d8d8d8",
- axisColor: "#4c4c4c",
- axisLabelColor: "#a0a0a0",
- title: {font: {color: WHITE}},
- legend: {font: {color: WHITE}},
- tooltip: {
- color: BLACK,
- font: {color: WHITE}
- },
- "chart:common": {commonSeriesSettings: {label: {border: {color: '#454545'}}}},
- chart: {commonPaneSettings: {border: {color: '#454545'}}},
- pieIE8: {commonSeriesSettings: {
- pie: {
- hoverStyle: {border: {color: BLACK}},
- selectionStyle: {border: {color: BLACK}}
- },
- donut: {
- hoverStyle: {border: {color: BLACK}},
- selectionStyle: {border: {color: BLACK}}
- },
- doughnut: {
- hoverStyle: {border: {color: BLACK}},
- selectionStyle: {border: {color: BLACK}}
- }
- }},
- barGauge: {backgroundColor: "#2b3036"},
- rangeSelector: {scale: {tick: {opacity: 0.15}}}
- }, "generic.dark");
- registerTheme({
- name: "win8.white",
- backgroundColor: WHITE,
- primaryTitleColor: BLACK,
- secondaryTitleColor: "#767676",
- axisColor: "#ececec",
- axisLabelColor: "#b8b8b8",
- title: {font: {color: '#808080'}},
- legend: {font: {color: BLACK}},
- tooltip: {font: {color: '#808080'}}
- }, "generic.light");
- registerThemeSchemeAlias("win8.dark", "win8.black");
- registerThemeSchemeAlias("win8.light", "win8.white")
- })(DevExpress);
- /*! Module viz-core, file themeManager.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- Palette = viz.core.Palette,
- utils = DX.utils,
- _findTheme = DX.viz.core.findTheme,
- _isString = utils.isString,
- _isDefined = utils.isDefined,
- HOVER_COLOR_HIGHLIGHTING = 20,
- HIGHLIGHTING_STEP = 50,
- FONT = "font",
- COMMON_AXIS_SETTINGS = "commonAxisSettings",
- PIE_FONT_FIELDS = ["legend." + FONT, "title." + FONT, "tooltip." + FONT, "loadingIndicator." + FONT, "commonSeriesSettings.label." + FONT],
- POLAR_FONT_FIELDS = PIE_FONT_FIELDS.concat([COMMON_AXIS_SETTINGS + ".label." + FONT, COMMON_AXIS_SETTINGS + ".title." + FONT]),
- CHART_FONT_FIELDS = POLAR_FONT_FIELDS.concat(["crosshair.label." + FONT]),
- chartToFontFieldsMap = {
- pie: PIE_FONT_FIELDS,
- chart: CHART_FONT_FIELDS,
- polar: POLAR_FONT_FIELDS
- };
- viz.charts = viz.charts || {};
- viz.charts.ThemeManager = viz.core.BaseThemeManager.inherit(function() {
- var ctor = function(options, themeGroupName) {
- var that = this,
- themeObj;
- that.callBase.apply(that, arguments);
- options = options || {};
- that._userOptions = options;
- that._mergeAxisTitleOptions = [];
- that._themeSection = themeGroupName;
- that._fontFields = chartToFontFieldsMap[themeGroupName];
- that._IE8 = DX.browser.msie && DX.browser.version < 9;
- themeObj = options.theme && _findTheme(_isString(options.theme) ? options.theme : options.theme.name) || {};
- that.palette = new Palette(options.palette, {
- stepHighlight: HIGHLIGHTING_STEP,
- theme: themeObj.name
- });
- that._callback = $.noop
- };
- var dispose = function() {
- var that = this;
- that.palette.dispose();
- that.palette = that._userOptions = that._mergedSettings = null;
- return that.callBase.apply(that, arguments)
- };
- var resetPalette = function() {
- this.palette.reset()
- };
- var updatePalette = function(palette) {
- this.palette = new Palette(palette || this._theme.defaultPalette, {
- stepHighlight: HIGHLIGHTING_STEP,
- theme: this.themeName
- })
- };
- var processTitleOptions = function(options) {
- return _isString(options) ? {text: options} : options
- };
- var processAxisOptions = function(axisOptions) {
- if (!axisOptions)
- return;
- axisOptions = $.extend(true, {}, axisOptions);
- axisOptions.title = processTitleOptions(axisOptions.title);
- if (axisOptions.type === "logarithmic" && axisOptions.logarithmBase <= 0 || axisOptions.logarithmBase && !$.isNumeric(axisOptions.logarithmBase)) {
- axisOptions.logarithmBase = undefined;
- axisOptions.logarithmBaseError = true
- }
- if (axisOptions.label) {
- if (axisOptions.label.alignment)
- axisOptions.label["userAlignment"] = true;
- if (_isString(axisOptions.label.overlappingBehavior))
- axisOptions.label.overlappingBehavior = {mode: axisOptions.label.overlappingBehavior};
- if (!axisOptions.label.overlappingBehavior || !axisOptions.label.overlappingBehavior.mode)
- axisOptions.label.overlappingBehavior = axisOptions.label.overlappingBehavior || {}
- }
- return axisOptions
- };
- var applyParticularAxisOptions = function(name, userOptions, rotated) {
- var theme = this._theme,
- position = !(rotated ^ name === "valueAxis") ? "horizontalAxis" : "verticalAxis",
- commonAxisSettings = processAxisOptions(this._userOptions["commonAxisSettings"], name);
- return $.extend(true, {}, theme.commonAxisSettings, theme[position], theme[name], commonAxisSettings, processAxisOptions(userOptions, name))
- };
- var mergeOptions = function(name, userOptions) {
- userOptions = userOptions || this._userOptions[name];
- var theme = this._theme[name],
- result = this._mergedSettings[name];
- if (result)
- return result;
- if ($.isPlainObject(theme) && $.isPlainObject(userOptions))
- result = $.extend(true, {}, theme, userOptions);
- else
- result = _isDefined(userOptions) ? userOptions : theme;
- this._mergedSettings[name] = result;
- return result
- };
- var applyParticularTheme = {
- base: mergeOptions,
- argumentAxis: applyParticularAxisOptions,
- valueAxisRangeSelector: function() {
- return mergeOptions.call(this, "valueAxis")
- },
- valueAxis: applyParticularAxisOptions,
- title: function(name) {
- var userOptions = processTitleOptions(this._userOptions[name]);
- return mergeOptions.call(this, name, userOptions)
- },
- series: function(name, userOptions) {
- var theme = this._theme,
- userCommonSettings = this._userOptions.commonSeriesSettings || {},
- themeCommonSettings = theme.commonSeriesSettings,
- type = ((userOptions.type || userCommonSettings.type || themeCommonSettings.type) + "").toLowerCase(),
- settings,
- palette = this.palette,
- isBar = ~type.indexOf("bar"),
- isLine = ~type.indexOf("line"),
- isArea = ~type.indexOf("area"),
- isBubble = type === "bubble",
- mainSeriesColor,
- resolveLabelsOverlapping = this.getOptions("resolveLabelsOverlapping"),
- resolveLabelOverlapping = this.getOptions("resolveLabelOverlapping"),
- containerBackgroundColor = this.getOptions("containerBackgroundColor"),
- seriesVisibility;
- if (isBar || isBubble) {
- userOptions = $.extend(true, {}, userCommonSettings, userCommonSettings[type], userOptions);
- seriesVisibility = userOptions.visible;
- userCommonSettings = {type: {}};
- $.extend(true, userOptions, userOptions.point);
- userOptions.visible = seriesVisibility
- }
- settings = $.extend(true, {}, themeCommonSettings, themeCommonSettings[type], userCommonSettings, userCommonSettings[type], userOptions);
- settings.type = type;
- settings.widgetType = this._themeSection.split(".").slice(-1)[0];
- settings.containerBackgroundColor = containerBackgroundColor;
- if (settings.widgetType !== "pie")
- mainSeriesColor = settings.color || palette.getNextColor();
- else
- mainSeriesColor = function() {
- return palette.getNextColor()
- };
- settings.mainSeriesColor = mainSeriesColor;
- settings._IE8 = this._IE8;
- settings.resolveLabelOverlapping = resolveLabelOverlapping;
- settings.resolveLabelsOverlapping = resolveLabelsOverlapping;
- if (settings.label && (isLine || isArea && type !== "rangearea" || type === "scatter"))
- settings.label.position = "outside";
- return settings
- },
- pieSegment: function(name, seriesSettings, segmentSettings) {
- var settings = $.extend(true, {}, seriesSettings, segmentSettings),
- mainColor = new DX.Color(settings.color || this.palette.getNextColor());
- settings.color = mainColor.toHex();
- settings.border.color = settings.border.color || mainColor.toHex();
- settings.hoverStyle.color = settings.hoverStyle.color || this._IE8 && mainColor.highlight(HOVER_COLOR_HIGHLIGHTING) || mainColor.toHex();
- settings.hoverStyle.border.color = settings.hoverStyle.border.color || mainColor.toHex();
- settings.selectionStyle.color = settings.selectionStyle.color || this._IE8 && mainColor.highlight(HOVER_COLOR_HIGHLIGHTING) || mainColor.toHex();
- settings.selectionStyle.border.color = settings.selectionStyle.border.color || mainColor.toHex();
- return settings
- },
- animation: function(name) {
- var userOptions = this._userOptions[name];
- userOptions = $.isPlainObject(userOptions) ? userOptions : _isDefined(userOptions) ? {enabled: !!userOptions} : {};
- return mergeOptions.call(this, name, userOptions)
- }
- };
- return {
- _themeSection: "chart",
- ctor: ctor,
- dispose: dispose,
- resetPalette: resetPalette,
- getOptions: function(name) {
- return (applyParticularTheme[name] || applyParticularTheme.base).apply(this, arguments)
- },
- refresh: function() {
- this._mergedSettings = {};
- return this.callBase.apply(this, arguments)
- },
- resetOptions: function(name) {
- this._mergedSettings[name] = null
- },
- update: function(options) {
- this._userOptions = options
- },
- updatePalette: updatePalette
- }
- }())
- })(jQuery, DevExpress);
- /*! Module viz-core, file factory.js */
- (function($, DX) {
- var viz = DX.viz,
- charts = viz.charts,
- series = charts.series;
- charts.factory = function() {
- var createSeriesFamily = function(options) {
- return new series.SeriesFamily(options)
- };
- var createThemeManager = function(options, groupName) {
- return new charts.ThemeManager(options, groupName)
- };
- var createTracker = function(options, name) {
- return name === "dxPieChart" ? new charts.PieTracker(options) : new charts.ChartTracker(options)
- };
- var createTitle = function(renderer, options, group) {
- return new charts.ChartTitle(renderer, options, group)
- };
- var createChartLayoutManager = function(options) {
- return new charts.LayoutManager(options)
- };
- var createCrosshair = function(renderer, options, params, group) {
- return new charts.Crosshair(renderer, options, params, group)
- };
- return {
- createSeriesFamily: createSeriesFamily,
- createThemeManager: createThemeManager,
- createTracker: createTracker,
- createChartLayoutManager: createChartLayoutManager,
- createTitle: createTitle,
- createCrosshair: createCrosshair,
- createScrollBar: function(renderer, group) {
- return new DevExpress.viz.charts.ScrollBar(renderer, group)
- }
- }
- }()
- })(jQuery, DevExpress);
- /*! Module viz-core, file baseWidget.js */
- (function(DX, $, undefined) {
- var core = DX.viz.core,
- _windowResizeCallbacks = DX.utils.windowResizeCallbacks,
- _Number = Number,
- _stringFormat = DX.utils.stringFormat,
- _isFunction = DX.utils.isFunction,
- _parseScalar = core.utils.parseScalar,
- OPTION_RTL_ENABLED = "rtlEnabled",
- OPTION_LOADING_INDICATOR = "loadingIndicator";
- function defaultIncidentOccured(options) {
- var args = [options.id];
- args.push.apply(args, options.args || []);
- DX.log.apply(null, args)
- }
- function getTrue() {
- return true
- }
- function getFalse() {
- return false
- }
- function areCanvasesDifferent(canvas1, canvas2) {
- return !(canvas1.width === canvas2.width && canvas1.height === canvas2.height && canvas1.left === canvas2.left && canvas1.top === canvas2.top && canvas1.right === canvas2.right && canvas1.bottom === canvas2.bottom)
- }
- function createResizeHandler(callback) {
- var $window = $(window),
- width,
- height,
- timeout;
- handler.dispose = function() {
- clearTimeout(timeout);
- return this
- };
- return handler;
- function handler() {
- width = $window.width();
- height = $window.height();
- clearTimeout(timeout);
- timeout = setTimeout(trigger, 100)
- }
- function trigger() {
- $window.width() === width && $window.height() === height && callback()
- }
- }
- core.DEBUG_createResizeHandler = createResizeHandler;
- core.BaseWidget = DX.DOMComponent.inherit({
- _eventsMap: {
- onIncidentOccurred: {
- name: 'incidentOccured',
- deprecated: 'incidentOccured',
- deprecatedContext: $.noop,
- deprecatedArgs: function(arg) {
- return [arg.target]
- }
- },
- onDrawn: {
- name: 'drawn',
- deprecated: 'drawn',
- deprecatedContext: $.noop,
- deprecatedArgs: function(arg) {
- return [arg.component]
- }
- },
- incidentOccured: {newName: 'onIncidentOccurred'},
- drawn: {newName: 'onDrawn'},
- onTooltipShown: {name: 'tooltipShown'},
- onTooltipHidden: {name: 'tooltipHidden'},
- onLoadingIndicatorReady: {name: "loadingIndicatorReady"}
- },
- _setDeprecatedOptions: function() {
- this.callBase.apply(this, arguments);
- $.extend(this._deprecatedOptions, {
- incidentOccured: {
- since: '14.2',
- message: "Use the 'onIncidentOccurred' option instead"
- },
- drawn: {
- since: '14.2',
- message: "Use the 'onDrawn' option instead"
- }
- })
- },
- _setDefaultOptions: function() {
- this.callBase.apply(this, arguments);
- this.option({incidentOccured: defaultIncidentOccured})
- },
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._themeManager = that._createThemeManager();
- that._themeManager.setCallback(function() {
- that._handleThemeOptions()
- });
- that._renderer = new DX.viz.renderers.Renderer({cssClass: that._rootClassPrefix + " " + that._rootClass});
- that._initIncidentOccured();
- that._renderVisibilityChange();
- that._initEventTrigger();
- that._initTooltip();
- that._initCore();
- that._setThemeAndRtl();
- that._initSize();
- that._setupResizeHandler();
- that._initLoadingIndicator()
- },
- _initTooltip: function() {
- this._tooltip = new core.Tooltip({
- cssClass: this._rootClassPrefix + "-tooltip",
- eventTrigger: this._eventTrigger
- })
- },
- _getAnimationOptions: $.noop,
- _initSize: function() {
- var canvas = null;
- if (this._isContainerVisible()) {
- canvas = this._calculateCanvas();
- if (canvas)
- this._updateSize(canvas, true)
- }
- if (!canvas)
- this._setHiddenState()
- },
- _setHiddenState: function() {
- var that = this;
- that._clean = that._render = $.noop;
- that._canvas = null;
- that._incidentOccured('W2001', [that.NAME])
- },
- _setVisibleState: function() {
- delete this._clean;
- delete this._render
- },
- _updateSize: function(canvas, isDrawRequired) {
- var that = this;
- that._renderer.resize(canvas.width, canvas.height);
- isDrawRequired && that._renderer.draw(that._$element[0]);
- that._canvas = canvas;
- that._applySize();
- that._updateLoadingIndicatorCanvas()
- },
- _updateCanvasAndResize: function() {
- var that = this,
- canvas = that._calculateCanvas();
- if (canvas)
- if (areCanvasesDifferent(canvas, that._canvas) || that.__forceRender) {
- that._updateSize(canvas);
- that._resize()
- }
- return canvas
- },
- render: function() {
- var that = this,
- canvas,
- visible = that._isContainerVisible();
- if (that._canvas) {
- if (visible)
- canvas = that._updateCanvasAndResize();
- if (!canvas) {
- that._clean();
- that._renderer.clear();
- that._setHiddenState()
- }
- }
- else {
- if (visible) {
- canvas = that._calculateCanvas();
- if (canvas) {
- that._setVisibleState();
- that._updateSize(canvas, true);
- that._render()
- }
- }
- if (!canvas)
- that._setHiddenState()
- }
- },
- _handleResize: function() {
- if (this._canvas)
- this._updateCanvasAndResize()
- },
- _dispose: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._removeResizeHandler();
- that._eventTrigger.dispose();
- that._disposeCore();
- that._disposeLoadingIndicator();
- that._renderer.dispose();
- that._tooltip && that._tooltip.dispose();
- that._themeManager.dispose();
- that._themeManager = that._renderer = that._eventTrigger = that._tooltip = null
- },
- _initEventTrigger: function() {
- var that = this;
- that._eventTrigger = createEventTrigger(that._eventsMap, function(name, deprecatedName) {
- var data = {callback: that._createActionByOption(name)};
- that._suppressDeprecatedWarnings();
- if (that.option(name) === undefined)
- data.deprecatedCallback = that.option(deprecatedName);
- that._resumeDeprecatedWarnings();
- return data
- })
- },
- _isContainerVisible: function() {
- return this._$element.is(':visible')
- },
- _calculateCanvas: function() {
- var that = this,
- size = that.option('size') || {},
- margin = that.option('margin') || {},
- defaultCanvas = that._getDefaultSize() || {},
- canvas = {};
- if (size.width <= 0 || size.height <= 0)
- canvas = null;
- else {
- canvas.width = size.width > 0 ? _Number(size.width) : that._$element.width() || defaultCanvas.width;
- canvas.height = size.height > 0 ? _Number(size.height) : that._$element.height() || defaultCanvas.height;
- canvas.left = margin.left > 0 ? _Number(margin.left) : defaultCanvas.left || 0;
- canvas.top = margin.top > 0 ? _Number(margin.top) : defaultCanvas.top || 0;
- canvas.right = margin.right > 0 ? _Number(margin.right) : defaultCanvas.right || 0;
- canvas.bottom = margin.bottom > 0 ? _Number(margin.bottom) : defaultCanvas.bottom || 0;
- canvas = canvas.width - canvas.left - canvas.right > 0 && canvas.height - canvas.top - canvas.bottom > 0 ? canvas : null
- }
- return canvas
- },
- DEBUG_getCanvas: function() {
- return this._canvas
- },
- DEBUG_getEventTrigger: function() {
- return this._eventTrigger
- },
- _getOption: function(name, isScalar) {
- var theme = this._themeManager.theme(name),
- option = this.option(name);
- return isScalar ? option !== undefined ? option : theme : $.extend(true, {}, theme, option)
- },
- _setupResizeHandler: function() {
- if (_parseScalar(this._getOption('redrawOnResize', true), true))
- this._addResizeHandler();
- else
- this._removeResizeHandler()
- },
- _addResizeHandler: function() {
- var that = this;
- if (!that._resizeHandler) {
- that._resizeHandler = createResizeHandler(function() {
- that._handleResize()
- });
- _windowResizeCallbacks.add(that._resizeHandler)
- }
- },
- _removeResizeHandler: function() {
- if (this._resizeHandler) {
- _windowResizeCallbacks.remove(this._resizeHandler);
- this._resizeHandler.dispose();
- this._resizeHandler = null
- }
- },
- _optionChanged: function(args) {
- var that = this;
- if (!that._eventTrigger.update(args.name))
- switch (args.name) {
- case'size':
- case'margin':
- that.render();
- break;
- case'redrawOnResize':
- that._setupResizeHandler();
- break;
- case OPTION_LOADING_INDICATOR:
- that._handleLoadingIndicatorOptionChanged();
- break;
- case"theme":
- case OPTION_RTL_ENABLED:
- that._setThemeAndRtl();
- break;
- case"encodeHtml":
- case"pathModified":
- that._handleThemeOptions();
- break;
- case"tooltip":
- that._setTooltipOptions();
- break;
- default:
- that._invalidate();
- that.callBase.apply(that, arguments)
- }
- },
- _handleThemeOptions: function() {
- var that = this,
- options = {
- rtl: that.option(OPTION_RTL_ENABLED),
- encodeHtml: that.option("encodeHtml"),
- pathModified: that.option("pathModified"),
- animation: that._getAnimationOptions()
- };
- that._renderer.setOptions(options);
- that._setTooltipRendererOptions(options);
- that._setTooltipOptions();
- that._updateLoadingIndicatorOptions();
- that._handleThemeOptionsCore()
- },
- _handleThemeOptionsCore: function() {
- this._initialized && this._refresh()
- },
- _visibilityChanged: function() {
- this.render()
- },
- _initIncidentOccured: function() {
- var that = this;
- that._incidentOccured = function(errorOrWarningId, options) {
- that._eventTrigger('incidentOccured', {target: {
- id: errorOrWarningId,
- type: errorOrWarningId[0] === 'E' ? 'error' : 'warning',
- args: options,
- text: _stringFormat.apply(null, [DX.ERROR_MESSAGES[errorOrWarningId]].concat(options ? options.slice(0) : [])),
- widget: that.NAME,
- version: DX.VERSION
- }})
- }
- },
- _setThemeAndRtl: function() {
- this._themeManager.setTheme(this.option("theme"), this.option(OPTION_RTL_ENABLED))
- },
- _setTooltipRendererOptions: function(options) {
- this._tooltip.setRendererOptions(options)
- },
- _setTooltipOptions: function() {
- this._tooltip.update(this._getOption("tooltip"))
- },
- _initLoadingIndicator: function() {
- if (this._getOption(OPTION_LOADING_INDICATOR).show) {
- this.showLoadingIndicator();
- this._loadIndicator.forceShow()
- }
- },
- _handleLoadingIndicatorOptionChanged: function() {
- var that = this;
- if (!that._skipOptionChanged) {
- that._updateLoadingIndicatorOptions();
- if (that._getOption(OPTION_LOADING_INDICATOR).show)
- that.showLoadingIndicator();
- else
- that.hideLoadingIndicator()
- }
- },
- _updateLoadingIndicatorCanvas: function() {
- this._loadIndicator && this._canvas && this._loadIndicator.applyCanvas(this._canvas)
- },
- _updateLoadingIndicatorOptions: function() {
- this._loadIndicator && this._loadIndicator.applyOptions(this._getOption(OPTION_LOADING_INDICATOR))
- },
- _endLoading: function(complete) {
- if (this._loadIndicator) {
- this._resetIsReady();
- this._loadIndicator.endLoading(complete)
- }
- else
- complete && complete()
- },
- _reappendLoadingIndicator: function() {
- this._loadIndicator && this._loadIndicator.toForeground()
- },
- _disposeLoadingIndicator: function() {
- if (this._loadIndicator) {
- this._loadIndicator.dispose();
- this._loadIndicator = null
- }
- },
- _scheduleLoadingIndicatorHiding: function() {
- this._loadIndicator && this._loadIndicator.scheduleHiding()
- },
- _fulfillLoadingIndicatorHiding: function() {
- this._loadIndicator && this._loadIndicator.fulfillHiding() && this._toggleLoadingIndicatorState(false)
- },
- _normalizeHtml: function(html) {
- var re = /xmlns="[\s\S]*?"/gi,
- first = true;
- html = html.replace(re, function(match) {
- if (!first)
- return "";
- first = false;
- return match
- });
- return html.replace(/xmlns:NS1="[\s\S]*?"/gi, "").replace(/NS1:xmlns:xlink="([\s\S]*?)"/gi, 'xmlns:xlink="$1"')
- },
- _dataIsReady: getTrue,
- _resetIsReady: function() {
- this.isReady = getFalse
- },
- _drawn: function() {
- var that = this;
- that.isReady = getFalse;
- that._dataIsReady() && that._renderer.onEndAnimation(function() {
- that.isReady = getTrue
- });
- that._eventTrigger('drawn', {})
- },
- _toggleLoadingIndicatorState: function(state) {
- if (Boolean(this._getOption(OPTION_LOADING_INDICATOR).show) !== state) {
- this._skipOptionChanged = true;
- this.option(OPTION_LOADING_INDICATOR, {show: state});
- this._skipOptionChanged = false
- }
- },
- _handleLoadingIndicatorShown: function() {
- this._tooltip.hide()
- },
- showLoadingIndicator: function() {
- var that = this;
- if (!that._loadIndicator) {
- that._loadIndicator = new core.LoadIndicator({
- container: that._$element,
- eventTrigger: that._eventTrigger
- });
- that._updateLoadingIndicatorCanvas();
- that._updateLoadingIndicatorOptions()
- }
- that._toggleLoadingIndicatorState(true);
- that._loadIndicator.show();
- that._handleLoadingIndicatorShown()
- },
- hideLoadingIndicator: function() {
- var that = this;
- if (that._loadIndicator) {
- that._toggleLoadingIndicatorState(false);
- that._loadIndicator.hide()
- }
- },
- svg: function() {
- return this._normalizeHtml(this._renderer.svg())
- },
- isReady: getFalse
- });
- function createEventTrigger(eventsMap, callbackGetter) {
- var triggers = {},
- timers = {};
- $.each(eventsMap, function(name, info) {
- if (info.name)
- createItem(name)
- });
- trigger.update = function(name) {
- var eventInfo = eventsMap[name];
- if (eventInfo)
- createItem(eventInfo.newName || name);
- return !!eventInfo
- };
- trigger.dispose = function() {
- $.each(timers, function(timer) {
- clearTimeout(timer)
- });
- eventsMap = callbackGetter = triggers = timers = null
- };
- return trigger;
- function trigger(eventName, arg, complete) {
- triggers[eventName](arg, complete)
- }
- function createItem(name) {
- var eventInfo = eventsMap[name],
- data = callbackGetter(name, eventInfo.deprecated);
- triggers[eventInfo.name] = createCallback(data.callback, _isFunction(data.deprecatedCallback) && data.deprecatedCallback, eventInfo.deprecatedContext, eventInfo.deprecatedArgs)
- }
- function createCallback(callback, deprectatedCallback, deprecatedContext, deprecatedArgs) {
- return function(arg, complete) {
- var timer = setTimeout(function() {
- callback(arg);
- deprectatedCallback && deprectatedCallback.apply(deprecatedContext(arg), deprecatedArgs(arg));
- complete && complete();
- delete timers[timer]
- });
- timers[timer] = 1
- }
- }
- }
- core.DEBUG_createEventTrigger = createEventTrigger
- })(DevExpress, jQuery);
- /*! Module viz-core, file CoreFactory.js */
- (function(DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- seriesNS = core.series;
- core.CoreFactory = {
- createSeries: function(renderSettings, options) {
- return new seriesNS.Series(renderSettings, options)
- },
- createPoint: function(series, data, options) {
- return new seriesNS.points.Point(series, data, options)
- },
- createLabel: function() {
- return new core.series.points.Label
- },
- createTranslator1D: function(fromValue, toValue, fromAngle, toAngle) {
- return (new core.Translator1D).setDomain(fromValue, toValue).setCodomain(fromAngle, toAngle)
- },
- createTranslator2D: function(range, canvas, options) {
- return new core.Translator2D(range, canvas, options)
- },
- createTickManager: function(types, data, options) {
- return new core.tickManager.TickManager(types, data, options)
- },
- createLegend: function(settings) {
- return new core.Legend(settings)
- },
- createSeriesFamily: function(options) {
- return new seriesNS.helpers.SeriesFamily(options)
- },
- createDataValidator: function(data, groups, incidentOccured, dataPrepareOptions) {
- return new core.DataValidator(data, groups, incidentOccured, dataPrepareOptions)
- }
- }
- })(DevExpress);
- DevExpress.MOD_VIZ_CORE = true
- }
- if (!DevExpress.MOD_VIZ_CHARTS) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-charts, file chartTitle.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- vizUtils = viz.core.utils,
- isDefined = DX.utils.isDefined,
- DEFAULT_MARGIN = 10;
- function parseMargins(options) {
- options.margin = isDefined(options.margin) ? options.margin : {};
- if (typeof options.margin === 'number') {
- options.margin = options.margin >= 0 ? options.margin : DEFAULT_MARGIN;
- options.margin = {
- top: options.margin,
- bottom: options.margin,
- left: options.margin,
- right: options.margin
- }
- }
- else {
- options.margin.top = options.margin.top >= 0 ? options.margin.top : DEFAULT_MARGIN;
- options.margin.bottom = options.margin.bottom >= 0 ? options.margin.bottom : DEFAULT_MARGIN;
- options.margin.left = options.margin.left >= 0 ? options.margin.left : DEFAULT_MARGIN;
- options.margin.right = options.margin.right >= 0 ? options.margin.right : DEFAULT_MARGIN
- }
- }
- function parseAlignments(options) {
- options.verticalAlignment = (options.verticalAlignment || '').toLowerCase();
- options.horizontalAlignment = (options.horizontalAlignment || '').toLowerCase();
- if (options.verticalAlignment !== 'top' && options.verticalAlignment !== 'bottom')
- options.verticalAlignment = 'top';
- if (options.horizontalAlignment !== 'left' && options.horizontalAlignment !== 'center' && options.horizontalAlignment !== 'right')
- options.horizontalAlignment = 'center'
- }
- function ChartTitle(renderer, options, group) {
- var that = this;
- that.update(options);
- that.renderer = renderer;
- that.titleGroup = group
- }
- viz.charts.ChartTitle = ChartTitle;
- ChartTitle.prototype = {
- dispose: function() {
- var that = this;
- that.renderer = null;
- that.clipRect = null;
- that.title = null;
- that.innerTitleGroup = null;
- that.titleGroup = null;
- that.options = null
- },
- update: function(options) {
- var that = this;
- if (options) {
- parseAlignments(options);
- that.horizontalAlignment = options.horizontalAlignment;
- that.verticalAlignment = options.verticalAlignment;
- parseMargins(options);
- that.margin = options.margin;
- that.options = options
- }
- },
- _setBoundingRect: function() {
- var that = this,
- options = that.options,
- margin = that.changedMargin || that.margin,
- box;
- if (!that.innerTitleGroup)
- return;
- box = that.innerTitleGroup.getBBox();
- box.height += margin.top + margin.bottom;
- box.width += margin.left + margin.right;
- box.x -= margin.left;
- box.y -= margin.top;
- if (isDefined(options.placeholderSize))
- box.height = options.placeholderSize;
- that.boundingRect = box
- },
- draw: function(size) {
- var that = this,
- titleOptions = that.options,
- renderer = that.renderer;
- if (!titleOptions.text)
- return that;
- size && that.setSize(size);
- that.changedMargin = null;
- if (!that.innerTitleGroup) {
- that.innerTitleGroup = renderer.g();
- that.clipRect = that.createClipRect();
- that.titleGroup && that.clipRect && that.titleGroup.attr({clipId: that.clipRect.id})
- }
- else
- that.innerTitleGroup.clear();
- that.innerTitleGroup.append(that.titleGroup);
- that.title = renderer.text(titleOptions.text, 0, 0).css(vizUtils.patchFontOptions(titleOptions.font)).attr({align: that.horizontalAlignment}).append(that.innerTitleGroup);
- that.title.text = titleOptions.text;
- that._correctTitleLength();
- that._setClipRectSettings();
- return that
- },
- _correctTitleLength: function() {
- var that = this,
- text = that.title.text,
- lineLength,
- box;
- that.title.attr({text: text});
- that._setBoundingRect();
- box = that.getLayoutOptions();
- if (that._width > box.width || text.indexOf("<br/>") !== -1)
- return;
- lineLength = text.length * that._width / box.width;
- that.title.attr({text: text.substr(0, ~~lineLength - 1 - 3) + "..."});
- that.title.setTitle(text);
- that._setBoundingRect()
- },
- changeSize: function(size) {
- var that = this,
- margin = $.extend(true, {}, that.margin);
- if (margin.top + margin.bottom < size.height) {
- if (that.innerTitleGroup) {
- that.options._incidentOccured("W2103");
- that.innerTitleGroup.dispose();
- that.innerTitleGroup = null
- }
- if (that.clipRect) {
- that.clipRect.dispose();
- that.clipRect = null
- }
- }
- else if (size.height > 0) {
- vizUtils.decreaseGaps(margin, ["top", "bottom"], size.height);
- size.height && (that.changedMargin = margin)
- }
- that._correctTitleLength();
- that._setBoundingRect();
- that._setClipRectSettings();
- return that
- },
- getLayoutOptions: function() {
- var options = this.options,
- boundingRect = this.innerTitleGroup ? this.boundingRect : {
- width: 0,
- height: 0,
- x: 0,
- y: 0
- };
- boundingRect.verticalAlignment = options.verticalAlignment;
- boundingRect.horizontalAlignment = options.horizontalAlignment;
- boundingRect.cutLayoutSide = options.verticalAlignment;
- return boundingRect
- },
- getBBox: function() {
- var bbox = $.extend({}, this.getLayoutOptions());
- bbox.x = this._x;
- bbox.y = this._y;
- return bbox
- },
- setSize: function(size) {
- this._width = size.width || this._width;
- return this
- },
- shift: function(x, y) {
- var that = this,
- box = that.getLayoutOptions();
- that._x = x;
- that._y = y;
- x -= box.x;
- y -= box.y;
- that.innerTitleGroup && that.innerTitleGroup.move(x, y);
- that.clipRect && that.clipRect.attr({
- translateX: x,
- translateY: y
- });
- return that
- },
- createClipRect: function() {
- if (isDefined(this.options.placeholderSize))
- return this.renderer.clipRect(0, 0, 0, 0)
- },
- _setClipRectSettings: function() {
- var bbox = this.getLayoutOptions(),
- clipRect = this.clipRect;
- if (clipRect)
- clipRect.attr({
- x: bbox.x,
- y: bbox.y,
- width: bbox.width,
- height: bbox.height
- })
- }
- };
- DX.viz.charts.ChartTitle.__DEFAULT_MARGIN = DEFAULT_MARGIN
- })(jQuery, DevExpress);
- /*! Module viz-charts, file axesConstants.js */
- (function($, DX, undefined) {
- var _map = $.map;
- function getFormatObject(value, options, axisMinMax) {
- var formatObject = {
- value: value,
- valueText: DX.formatHelper.format(value, options.format, options.precision) || ""
- };
- if (axisMinMax) {
- formatObject.min = axisMinMax.min;
- formatObject.max = axisMinMax.max
- }
- return formatObject
- }
- DX.viz.charts.axes = {};
- DX.viz.charts.axes.constants = {
- logarithmic: "logarithmic",
- discrete: "discrete",
- numeric: "numeric",
- left: "left",
- right: "right",
- top: "top",
- bottom: "bottom",
- center: "center",
- canvasPositionPrefix: "canvas_position_",
- canvasPositionTop: "canvas_position_top",
- canvasPositionBottom: "canvas_position_bottom",
- canvasPositionLeft: "canvas_position_left",
- canvasPositionRight: "canvas_position_right",
- canvasPositionStart: "canvas_position_start",
- canvasPositionEnd: "canvas_position_end",
- horizontal: "horizontal",
- vertical: "vertical",
- halfTickLength: 4,
- convertTicksToValues: function(ticks) {
- return _map(ticks || [], function(item) {
- return item.value
- })
- },
- convertValuesToTicks: function(values) {
- return _map(values || [], function(item) {
- return {value: item}
- })
- },
- validateOverlappingMode: function(mode) {
- return mode !== "ignore" ? "enlargeTickInterval" : "ignore"
- },
- formatLabel: function(value, options, axisMinMax) {
- var formatObject = getFormatObject(value, options, axisMinMax);
- return $.isFunction(options.customizeText) ? options.customizeText.call(formatObject, formatObject) : formatObject.valueText
- },
- formatHint: function(value, options, axisMinMax) {
- var formatObject = getFormatObject(value, options, axisMinMax);
- return $.isFunction(options.customizeHint) ? options.customizeHint.call(formatObject, formatObject) : undefined
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-charts, file xyAxes.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- axes = viz.charts.axes,
- constants = axes.constants,
- _abs = Math.abs,
- _extend = $.extend,
- CANVAS_POSITION_PREFIX = constants.canvasPositionPrefix,
- TOP = constants.top,
- BOTTOM = constants.bottom,
- LEFT = constants.left,
- RIGHT = constants.right,
- CENTER = constants.center;
- axes.xyAxes = {};
- axes.xyAxes.linear = {
- _getSharpParam: function(oposite) {
- return this._isHorizontal ^ oposite ? "h" : "v"
- },
- _createAxisElement: function() {
- var axisCoord = this._axisPosition,
- canvas = this._getCanvasStartEnd(),
- points = this._isHorizontal ? [canvas.start, axisCoord, canvas.end, axisCoord] : [axisCoord, canvas.start, axisCoord, canvas.end];
- return this._renderer.path(points, "line")
- },
- _getTranslatedCoord: function(value, offset) {
- return this._translator.translate(value, offset)
- },
- _getCanvasStartEnd: function() {
- return {
- start: this._translator.translateSpecialCase(constants.canvasPositionStart),
- end: this._translator.translateSpecialCase(constants.canvasPositionEnd)
- }
- },
- _getScreenDelta: function() {
- return _abs(this._translator.translateSpecialCase(constants.canvasPositionStart) - this._translator.translateSpecialCase(constants.canvasPositionEnd))
- },
- _initAxisPositions: function() {
- var that = this,
- position = that._options.position,
- delta = 0;
- if (that.delta)
- delta = that.delta[position] || 0;
- that._axisPosition = that._additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + position) + delta
- },
- _drawTitle: function() {
- var that = this,
- options = that._options,
- titleOptions = options.title,
- attr = {
- opacity: titleOptions.opacity,
- align: CENTER
- };
- if (!titleOptions.text || !that._axisTitleGroup)
- return;
- that._title = that._renderer.text(titleOptions.text, 0, 0).css(core.utils.patchFontOptions(titleOptions.font)).attr(attr).append(that._axisTitleGroup)
- },
- _adjustConstantLineLabels: function() {
- var that = this,
- options = that._options,
- isHorizontal = that._isHorizontal,
- lines = that._constantLines,
- labels = that._constantLineLabels,
- label,
- line,
- lineBox,
- linesOptions,
- labelOptions,
- box,
- x,
- y,
- i,
- padding = isHorizontal ? {
- top: 0,
- bottom: 0
- } : {
- left: 0,
- right: 0
- },
- paddingTopBottom,
- paddingLeftRight,
- labelVerticalAlignment,
- labelHorizontalAlignment,
- labelIsInside,
- labelHeight,
- labelWidth,
- delta = 0;
- if (labels === undefined && lines === undefined)
- return;
- for (i = 0; i < labels.length; i++) {
- x = y = 0;
- linesOptions = options.constantLines[i];
- paddingTopBottom = linesOptions.paddingTopBottom;
- paddingLeftRight = linesOptions.paddingLeftRight;
- labelOptions = linesOptions.label;
- labelVerticalAlignment = labelOptions.verticalAlignment;
- labelHorizontalAlignment = labelOptions.horizontalAlignment;
- labelIsInside = labelOptions.position === "inside";
- label = labels[i];
- if (label !== null) {
- line = lines[i];
- box = label.getBBox();
- lineBox = line.getBBox();
- labelHeight = box.height;
- labelWidth = box.width;
- if (isHorizontal)
- if (labelIsInside) {
- if (labelHorizontalAlignment === LEFT)
- x -= paddingLeftRight;
- else
- x += paddingLeftRight;
- switch (labelVerticalAlignment) {
- case CENTER:
- y += lineBox.y + lineBox.height / 2 - box.y - labelHeight / 2;
- break;
- case BOTTOM:
- y += lineBox.y + lineBox.height - box.y - labelHeight - paddingTopBottom;
- break;
- default:
- y += lineBox.y - box.y + paddingTopBottom;
- break
- }
- }
- else if (labelVerticalAlignment === BOTTOM) {
- delta = that.delta && that.delta[BOTTOM] || 0;
- y += paddingTopBottom - box.y + that._additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + BOTTOM) + delta;
- if (padding[BOTTOM] < labelHeight + paddingTopBottom)
- padding[BOTTOM] = labelHeight + paddingTopBottom
- }
- else {
- delta = that.delta && that.delta[TOP] || 0;
- y -= paddingTopBottom + box.y + labelHeight - that._additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + TOP) - delta;
- if (padding[TOP] < paddingTopBottom + labelHeight)
- padding[TOP] = paddingTopBottom + labelHeight
- }
- else if (labelIsInside) {
- switch (labelHorizontalAlignment) {
- case CENTER:
- x += lineBox.x + labelWidth / 2 - box.x - labelWidth / 2;
- break;
- case RIGHT:
- x -= paddingLeftRight;
- break;
- default:
- x += paddingLeftRight;
- break
- }
- if (labelVerticalAlignment === BOTTOM)
- y += lineBox.y - box.y + paddingTopBottom;
- else
- y += lineBox.y - box.y - labelHeight - paddingTopBottom
- }
- else {
- y += lineBox.y + lineBox.height / 2 - box.y - labelHeight / 2;
- if (labelHorizontalAlignment === RIGHT) {
- x += paddingLeftRight;
- if (padding[RIGHT] < paddingLeftRight + labelWidth)
- padding[RIGHT] = paddingLeftRight + labelWidth
- }
- else {
- x -= paddingLeftRight;
- if (padding[LEFT] < paddingLeftRight + labelWidth)
- padding[LEFT] = paddingLeftRight + labelWidth
- }
- }
- label.move(x, y)
- }
- }
- that.padding = padding
- },
- _checkAlignmentConstantLineLabels: function(labelOptions) {
- var position = labelOptions.position,
- verticalAlignment = (labelOptions.verticalAlignment || "").toLowerCase(),
- horizontalAlignment = (labelOptions.horizontalAlignment || "").toLowerCase();
- if (this._isHorizontal)
- if (position === "outside") {
- verticalAlignment = verticalAlignment === BOTTOM ? BOTTOM : TOP;
- horizontalAlignment = CENTER
- }
- else {
- verticalAlignment = verticalAlignment === CENTER ? CENTER : verticalAlignment === BOTTOM ? BOTTOM : TOP;
- horizontalAlignment = horizontalAlignment === LEFT ? LEFT : RIGHT
- }
- else if (position === "outside") {
- verticalAlignment = CENTER;
- horizontalAlignment = horizontalAlignment === LEFT ? LEFT : RIGHT
- }
- else {
- verticalAlignment = verticalAlignment === BOTTOM ? BOTTOM : TOP;
- horizontalAlignment = horizontalAlignment === RIGHT ? RIGHT : horizontalAlignment === CENTER ? CENTER : LEFT
- }
- labelOptions.verticalAlignment = verticalAlignment;
- labelOptions.horizontalAlignment = horizontalAlignment
- },
- _getConstantLineLabelsCoords: function(value, lineLabelOptions) {
- var that = this,
- additionalTranslator = that._additionalTranslator,
- align = CENTER,
- x = value,
- y = value;
- if (that._isHorizontal)
- y = additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + lineLabelOptions.verticalAlignment);
- else
- x = additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + lineLabelOptions.horizontalAlignment);
- switch (lineLabelOptions.horizontalAlignment) {
- case LEFT:
- align = !that._isHorizontal && lineLabelOptions.position === "inside" ? LEFT : RIGHT;
- break;
- case CENTER:
- align = CENTER;
- break;
- case RIGHT:
- align = !that._isHorizontal && lineLabelOptions.position === "inside" ? RIGHT : LEFT;
- break
- }
- return {
- x: x,
- y: y,
- align: align
- }
- },
- _getAdjustedStripLabelCoords: function(stripOptions, label, rect) {
- var x = 0,
- y = 0,
- horizontalAlignment = stripOptions.label.horizontalAlignment,
- verticalAlignment = stripOptions.label.verticalAlignment,
- box = label.getBBox(),
- rectBox = rect.getBBox();
- if (horizontalAlignment === LEFT)
- x += stripOptions.paddingLeftRight;
- else if (horizontalAlignment === RIGHT)
- x -= stripOptions.paddingLeftRight;
- if (verticalAlignment === TOP)
- y += rectBox.y - box.y + stripOptions.paddingTopBottom;
- else if (verticalAlignment === CENTER)
- y += rectBox.y + rectBox.height / 2 - box.y - box.height / 2;
- else if (verticalAlignment === BOTTOM)
- y -= stripOptions.paddingTopBottom;
- return {
- x: x,
- y: y
- }
- },
- _adjustTitle: function() {
- var that = this,
- options = that._options,
- position = options.position,
- title = that._title,
- margin = options.title.margin,
- boxGroup,
- boxTitle,
- params,
- centerPosition = that._translator.translateSpecialCase(CANVAS_POSITION_PREFIX + CENTER),
- axisElementsGroup = that._axisElementsGroup,
- heightTitle,
- axisPosition = that._axisPosition,
- noLabels;
- if (!title || !axisElementsGroup)
- return;
- boxTitle = title.getBBox();
- boxGroup = axisElementsGroup.getBBox();
- noLabels = boxGroup.isEmpty;
- heightTitle = boxTitle.height;
- if (that._isHorizontal)
- if (position === BOTTOM)
- params = {
- y: (noLabels ? axisPosition : boxGroup.y + boxGroup.height) - boxTitle.y + margin,
- x: centerPosition
- };
- else
- params = {
- y: (noLabels ? axisPosition : boxGroup.y) - heightTitle - boxTitle.y - margin,
- x: centerPosition
- };
- else {
- if (position === LEFT)
- params = {
- x: (noLabels ? axisPosition : boxGroup.x) - heightTitle - boxTitle.y - margin,
- y: centerPosition
- };
- else
- params = {
- x: (noLabels ? axisPosition : boxGroup.x + boxGroup.width) + heightTitle + boxTitle.y + margin,
- y: centerPosition
- };
- params.rotate = options.position === LEFT ? 270 : 90
- }
- title.attr(params)
- },
- coordsIn: function(x, y) {
- var rect = this.getBoundingRect();
- return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height
- },
- _getTicksOptions: function() {
- var options = this._options;
- return {
- base: options.type === constants.logarithmic ? options.logarithmBase : undefined,
- tickInterval: this._translator.getBusinessRange().stubData ? null : options.tickInterval,
- gridSpacingFactor: options.axisDivisionFactor,
- incidentOccured: options.incidentOccured,
- setTicksAtUnitBeginning: options.setTicksAtUnitBeginning,
- showMinorTicks: options.minorTick.visible || options.minorGrid.visible,
- minorTickInterval: options.minorTickInterval,
- minorTickCount: options.minorTickCount
- }
- },
- _getOverlappingBehaviorOptions: function() {
- var that = this,
- options = that._options,
- getText = function() {
- return ""
- },
- overlappingBehavior = options.label.overlappingBehavior ? _extend({}, options.label.overlappingBehavior) : null;
- if (overlappingBehavior) {
- if (!that._isHorizontal)
- overlappingBehavior.mode = constants.validateOverlappingMode(overlappingBehavior.mode);
- if (overlappingBehavior.mode !== "rotate")
- overlappingBehavior.rotationAngle = 0
- }
- if (!that._translator.getBusinessRange().stubData)
- getText = function(value, labelOptions) {
- return constants.formatLabel(value, labelOptions, {
- min: options.min,
- max: options.max
- })
- };
- return {
- hasLabelFormat: that._hasLabelFormat,
- labelOptions: options.label,
- overlappingBehavior: overlappingBehavior,
- isHorizontal: that._isHorizontal,
- textOptions: that._textOptions,
- textFontStyles: that._textFontStyles,
- textSpacing: options.label.minSpacing,
- getText: getText,
- renderText: function(text, x, y, options) {
- return that._renderer.text(text, x, y, options).append(that._renderer.root)
- },
- translate: function(value, useAdditionalTranslator) {
- return useAdditionalTranslator ? that._additionalTranslator.translate(value) : that._translator.translate(value)
- },
- isInverted: that._translator.getBusinessRange().invert
- }
- },
- _getSpiderCategoryOption: $.noop,
- _getMinMax: function() {
- return {
- min: this._options.min,
- max: this._options.max
- }
- },
- _getStick: function() {
- return !this._options.valueMarginsEnabled
- },
- _getStripLabelCoords: function(stripLabelOptions, stripFrom, stripTo) {
- var that = this,
- additionalTranslator = that._additionalTranslator,
- isHorizontal = that._isHorizontal,
- align = isHorizontal ? CENTER : LEFT,
- x,
- y;
- if (isHorizontal) {
- if (stripLabelOptions.horizontalAlignment === CENTER) {
- x = stripFrom + (stripTo - stripFrom) / 2;
- align = CENTER
- }
- else if (stripLabelOptions.horizontalAlignment === LEFT) {
- x = stripFrom;
- align = LEFT
- }
- else if (stripLabelOptions.horizontalAlignment === RIGHT) {
- x = stripTo;
- align = RIGHT
- }
- y = additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + stripLabelOptions.verticalAlignment)
- }
- else {
- x = additionalTranslator.translateSpecialCase(CANVAS_POSITION_PREFIX + stripLabelOptions.horizontalAlignment);
- align = stripLabelOptions.horizontalAlignment;
- if (stripLabelOptions.verticalAlignment === TOP)
- y = stripFrom;
- else if (stripLabelOptions.verticalAlignment === CENTER)
- y = stripTo + (stripFrom - stripTo) / 2;
- else if (stripLabelOptions.verticalAlignment === BOTTOM)
- y = stripTo
- }
- return {
- x: x,
- y: y,
- align: align
- }
- },
- _getTranslatedValue: function(value, y, offset) {
- return {
- x: this._translator.translate(value, offset),
- y: y
- }
- },
- _getSkippedCategory: function() {
- var that = this,
- options = that._options,
- categories = that._translator.getVisibleCategories() || that._translator.getBusinessRange().categories,
- categoryToSkip;
- if (categories && !!that._tickOffset && !options.valueMarginsEnabled)
- categoryToSkip = options.inverted ? categories[0] : categories[categories.length - 1];
- return categoryToSkip
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-charts, file polarAxes.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- utils = DX.utils,
- constants = viz.charts.axes.constants,
- _math = Math,
- _abs = _math.abs,
- _round = _math.round,
- _extend = $.extend,
- _noop = $.noop,
- _map = $.map,
- HALF_PI_ANGLE = 90;
- viz.charts.axes.polarAxes = {};
- function getPolarQuarter(angle) {
- var quarter;
- angle = utils.normalizeAngle(angle);
- if (angle >= 315 && angle <= 360 || angle < 45 && angle >= 0)
- quarter = 1;
- else if (angle >= 45 && angle < 135)
- quarter = 2;
- else if (angle >= 135 && angle < 225)
- quarter = 3;
- else if (angle >= 225 && angle < 315)
- quarter = 4;
- return quarter
- }
- viz.charts.axes.polarAxes.circular = {
- _overlappingBehaviorType: "circular",
- _createAxisElement: function() {
- var additionalTranslator = this._additionalTranslator;
- return this._renderer.circle(additionalTranslator.getCenter().x, additionalTranslator.getCenter().y, additionalTranslator.getRadius())
- },
- _setBoundingRect: function() {
- this.boundingRect = {
- width: 0,
- height: 0
- }
- },
- _getTicksOptions: viz.charts.axes.xyAxes.linear._getTicksOptions,
- _getOverlappingBehaviorOptions: function() {
- var that = this,
- additionalTranslator = that._additionalTranslator,
- startAngle = additionalTranslator.getStartAngle(),
- options = viz.charts.axes.xyAxes.linear._getOverlappingBehaviorOptions.call(that),
- translator = that._translator,
- indentFromAxis = that._options.label.indentFromAxis || 0;
- if (options.overlappingBehavior)
- options.overlappingBehavior = {mode: constants.validateOverlappingMode(options.overlappingBehavior.mode)};
- options.translate = function(value) {
- return core.utils.convertPolarToXY(additionalTranslator.getCenter(), startAngle, translator.translate(value), additionalTranslator.translate(constants.canvasPositionBottom))
- };
- options.addMinMax = {min: true};
- options.isInverted = translator.getBusinessRange().invert;
- options.circularRadius = additionalTranslator.getRadius() + indentFromAxis;
- options.circularStartAngle = options.circularEndAngle = startAngle;
- options.isHorizontal = false;
- return options
- },
- _getSpiderCategoryOption: function() {
- return this._options.firstPointOnStartAngle
- },
- _getMinMax: function() {
- var options = this._options;
- return {
- min: undefined,
- max: utils.isNumber(options.period) && options.argumentType === constants.numeric ? options.period : undefined
- }
- },
- _getStick: function() {
- return this._options.firstPointOnStartAngle || this._options.type !== constants.discrete
- },
- measureLabels: function() {
- var that = this,
- options = that._options,
- indentFromAxis = options.label.indentFromAxis || 0,
- widthAxis = options.visible ? options.width : 0,
- maxLabelParams;
- if (!that._axisElementsGroup || !that._options.label.visible)
- return {
- height: widthAxis,
- width: widthAxis
- };
- that._updateTickManager();
- maxLabelParams = that._tickManager.getMaxLabelParams();
- return {
- height: maxLabelParams.height + indentFromAxis + constants.halfTickLength,
- width: maxLabelParams.width + indentFromAxis + constants.halfTickLength
- }
- },
- _getTranslatedCoord: function(value, offset) {
- return this._translator.translate(value, offset) - HALF_PI_ANGLE
- },
- _getCanvasStartEnd: function() {
- return {
- start: 0 - HALF_PI_ANGLE,
- end: 360 - HALF_PI_ANGLE
- }
- },
- _createStrip: function(fromAngle, toAngle, attr) {
- var center = this._additionalTranslator.getCenter(),
- r = this._additionalTranslator.getRadius();
- return this._renderer.arc(center.x, center.y, 0, r, -toAngle, -fromAngle).attr(attr)
- },
- _getStripLabelCoords: function(_, stripFrom, stripTo) {
- var that = this,
- angle = stripFrom + (stripTo - stripFrom) / 2,
- cossin = utils.getCosAndSin(-angle),
- halfRad = that._additionalTranslator.getRadius() / 2,
- center = that._additionalTranslator.getCenter(),
- x = _round(center.x + halfRad * cossin.cos),
- y = _round(center.y - halfRad * cossin.sin);
- return {
- x: x,
- y: y,
- align: constants.center
- }
- },
- _createConstantLine: function(value, attr) {
- var center = this._additionalTranslator.getCenter(),
- r = this._additionalTranslator.getRadius();
- return this._createPathElement([center.x, center.y, center.x + r, center.y], attr).rotate(value, center.x, center.y)
- },
- _getConstantLineLabelsCoords: function(value) {
- var that = this,
- cossin = utils.getCosAndSin(-value),
- halfRad = that._additionalTranslator.getRadius() / 2,
- center = that._additionalTranslator.getCenter(),
- x = _round(center.x + halfRad * cossin.cos),
- y = _round(center.y - halfRad * cossin.sin);
- return {
- x: x,
- y: y,
- align: constants.center
- }
- },
- _checkAlignmentConstantLineLabels: _noop,
- _getScreenDelta: function() {
- return 2 * Math.PI * this._additionalTranslator.getRadius()
- },
- _getTickCoord: function(tick) {
- var center = this._additionalTranslator.getCenter(),
- r = this._additionalTranslator.getRadius();
- return {
- x1: center.x + r - constants.halfTickLength,
- y1: center.y,
- x2: center.x + r + constants.halfTickLength,
- y2: center.y,
- angle: tick.angle
- }
- },
- _getLabelAdjustedCoord: function(tick) {
- var that = this,
- pos = tick.labelPos,
- cossin = utils.getCosAndSin(pos.angle),
- cos = cossin.cos,
- sin = cossin.sin,
- box = tick.label.getBBox(),
- halfWidth = box.width / 2,
- halfHeight = box.height / 2,
- indentFromAxis = that._options.label.indentFromAxis || 0,
- x = pos.x + indentFromAxis * cos,
- y = pos.y + (pos.y - box.y - halfHeight) + indentFromAxis * sin;
- switch (getPolarQuarter(pos.angle)) {
- case 1:
- x += halfWidth;
- y += halfHeight * sin;
- break;
- case 2:
- x += halfWidth * cos;
- y += halfHeight;
- break;
- case 3:
- x += -halfWidth;
- y += halfHeight * sin;
- break;
- case 4:
- x += halfWidth * cos;
- y += -halfHeight;
- break
- }
- return {
- x: x,
- y: y
- }
- },
- _getGridLineDrawer: function() {
- var that = this,
- r = that._additionalTranslator.getRadius(),
- center = that._additionalTranslator.getCenter();
- return function(tick) {
- return that._createPathElement([center.x, center.y, center.x + r, center.y], tick.gridStyle).rotate(tick.angle, center.x, center.y)
- }
- },
- _getTranslatedValue: function(value, _, offset) {
- var additionalTranslator = this._additionalTranslator,
- startAngle = additionalTranslator.getStartAngle(),
- angle = this._translator.translate(value, -offset),
- coords = core.utils.convertPolarToXY(additionalTranslator.getCenter(), startAngle, angle, additionalTranslator.translate(constants.canvasPositionBottom));
- return {
- x: coords.x,
- y: coords.y,
- angle: angle + startAngle - HALF_PI_ANGLE
- }
- },
- _getAdjustedStripLabelCoords: function(_, label) {
- var y,
- box = label.getBBox();
- y = label.attr("y") - box.y - box.height / 2;
- return {
- x: 0,
- y: y
- }
- },
- coordsIn: function(x, y) {
- return core.utils.convertXYToPolar(this._additionalTranslator.getCenter(), x, y).r > this._additionalTranslator.getRadius()
- },
- _rotateTick: function(tick, angle) {
- var center = this._additionalTranslator.getCenter();
- tick.graphic.rotate(angle, center.x, center.y)
- }
- };
- viz.charts.axes.polarAxes.circularSpider = _extend({}, viz.charts.axes.polarAxes.circular, {
- _createAxisElement: function() {
- var points = _map(this.getSpiderTicks(), function(tick) {
- return {
- x: tick.posX,
- y: tick.posY
- }
- });
- return this._renderer.path(points, "area")
- },
- _getStick: function() {
- return true
- },
- _getSpiderCategoryOption: function() {
- return true
- },
- getSpiderTicks: function() {
- var that = this;
- that._spiderTicks = constants.convertValuesToTicks(that._tickManager.getFullTicks());
- that._initTicks(that._spiderTicks, {}, {});
- return that._spiderTicks
- },
- _createStrip: function(fromAngle, toAngle, attr) {
- var center = this._additionalTranslator.getCenter(),
- spiderTicks = this.getSpiderTicks(),
- firstTick,
- lastTick,
- points = _map(spiderTicks, function(tick, i) {
- var result = [],
- nextTick;
- if (tick.angle >= fromAngle && tick.angle <= toAngle) {
- if (!firstTick) {
- firstTick = spiderTicks[i - 1] || spiderTicks[spiderTicks.length - 1];
- result.push((tick.posX + firstTick.posX) / 2, (tick.posY + firstTick.posY) / 2)
- }
- result.push(tick.posX, tick.posY);
- nextTick = spiderTicks[i + 1] || spiderTicks[0];
- lastTick = {
- x: (tick.posX + nextTick.posX) / 2,
- y: (tick.posY + nextTick.posY) / 2
- }
- }
- else
- result = null;
- return result
- });
- points.push(lastTick.x, lastTick.y);
- points.push(center.x, center.y);
- return this._renderer.path(points, "area").attr(attr)
- },
- _getTranslatedCoord: function(value, offset) {
- return this._translator.translate(value, offset) - HALF_PI_ANGLE
- },
- _setTickOffset: function() {
- this._tickOffset = false
- }
- });
- viz.charts.axes.polarAxes.linear = {
- _overlappingBehaviorType: "linear",
- _getMinMax: viz.charts.axes.polarAxes.circular._getMinMax,
- _getStick: viz.charts.axes.xyAxes.linear._getStick,
- _getTicksOptions: viz.charts.axes.xyAxes.linear._getTicksOptions,
- _getSpiderCategoryOption: $.noop,
- _createAxisElement: function() {
- var additionalTranslator = this._additionalTranslator,
- centerCoord = additionalTranslator.getCenter(),
- points = [centerCoord.x, centerCoord.y, centerCoord.x + additionalTranslator.getRadius(), centerCoord.y];
- return this._renderer.path(points, "line").rotate(additionalTranslator.getStartAngle() - HALF_PI_ANGLE, centerCoord.x, centerCoord.y)
- },
- _setBoundingRect: viz.charts.axes.polarAxes.circular._setBoundingRect,
- _getScreenDelta: function() {
- return this._additionalTranslator.getRadius()
- },
- _getTickCoord: function(tick) {
- return {
- x1: tick.posX - constants.halfTickLength,
- y1: tick.posY,
- x2: tick.posX + constants.halfTickLength,
- y2: tick.posY,
- angle: tick.angle + HALF_PI_ANGLE
- }
- },
- _getOverlappingBehaviorOptions: function() {
- var that = this,
- translator = that._translator,
- orthTranslator = that._additionalTranslator,
- options = viz.charts.axes.xyAxes.linear._getOverlappingBehaviorOptions.call(this),
- startAngle = utils.normalizeAngle(that._additionalTranslator.getStartAngle());
- if (options.overlappingBehavior)
- options.overlappingBehavior = {mode: constants.validateOverlappingMode(options.overlappingBehavior.mode)};
- options.isHorizontal = startAngle > 45 && startAngle < 135 || startAngle > 225 && startAngle < 315 ? true : false;
- options.isInverted = translator.getBusinessRange().invert;
- options.translate = function(value) {
- return core.utils.convertPolarToXY(orthTranslator.getCenter(), that._options.startAngle, orthTranslator.translate(constants.canvasPositionTop), translator.translate(value)).x
- };
- return options
- },
- _getLabelAdjustedCoord: function(tick) {
- var that = this,
- pos = tick.labelPos,
- cossin = utils.getCosAndSin(pos.angle),
- indentFromAxis = that._options.label.indentFromAxis || 0,
- box = tick.label.getBBox(),
- x,
- y;
- x = pos.x - _abs(indentFromAxis * cossin.sin) + _abs(box.width / 2 * cossin.cos);
- y = pos.y + (pos.y - box.y) - _abs(box.height / 2 * cossin.sin) + _abs(indentFromAxis * cossin.cos);
- return {
- x: x,
- y: y
- }
- },
- _getGridLineDrawer: function() {
- var that = this,
- pos = that._additionalTranslator.getCenter();
- return function(tick) {
- return that._renderer.circle(pos.x, pos.y, utils.getDistance(pos.x, pos.y, tick.posX, tick.posY)).attr(tick.gridStyle).sharp()
- }
- },
- _getTranslatedValue: function(value, _, offset) {
- var additionalTranslator = this._additionalTranslator,
- startAngle = additionalTranslator.getStartAngle(),
- angle = additionalTranslator.translate(constants.canvasPositionStart),
- xy = core.utils.convertPolarToXY(additionalTranslator.getCenter(), startAngle, angle, this._translator.translate(value, offset));
- return {
- x: xy.x,
- y: xy.y,
- angle: angle + startAngle - HALF_PI_ANGLE
- }
- },
- _getTranslatedCoord: function(value, offset) {
- return this._translator.translate(value, offset)
- },
- _getCanvasStartEnd: function() {
- return {
- start: 0,
- end: this._additionalTranslator.getRadius()
- }
- },
- _createStrip: function(fromPoint, toPoint, attr) {
- var center = this._additionalTranslator.getCenter();
- return this._renderer.arc(center.x, center.y, fromPoint, toPoint, 0, 360).attr(attr)
- },
- _getAdjustedStripLabelCoords: viz.charts.axes.polarAxes.circular._getAdjustedStripLabelCoords,
- _getStripLabelCoords: function(_, stripFrom, stripTo) {
- var that = this,
- labelPos = stripFrom + (stripTo - stripFrom) / 2,
- center = that._additionalTranslator.getCenter(),
- y = _round(center.y - labelPos);
- return {
- x: center.x,
- y: y,
- align: constants.center
- }
- },
- _createConstantLine: function(value, attr) {
- var center = this._additionalTranslator.getCenter();
- return this._renderer.circle(center.x, center.y, value).attr(attr).sharp()
- },
- _getConstantLineLabelsCoords: function(value) {
- var that = this,
- center = that._additionalTranslator.getCenter(),
- y = _round(center.y - value);
- return {
- x: center.x,
- y: y,
- align: constants.center
- }
- },
- _checkAlignmentConstantLineLabels: _noop,
- _rotateTick: function(tick, angle) {
- tick.graphic.rotate(angle, tick.posX, tick.posY)
- }
- };
- viz.charts.axes.polarAxes.linearSpider = _extend({}, viz.charts.axes.polarAxes.linear, {
- _createPathElement: function(points, attr) {
- return this._renderer.path(points, "area").attr(attr).sharp()
- },
- setSpiderTicks: function(ticks) {
- this._spiderTicks = ticks
- },
- _getGridLineDrawer: function() {
- var that = this,
- pos = that._additionalTranslator.getCenter();
- return function(tick) {
- var radius = utils.getDistance(pos.x, pos.y, tick.posX, tick.posY);
- return that._createPathElement(that._getGridPoints(pos, radius), tick.gridStyle)
- }
- },
- _getGridPoints: function(pos, radius) {
- return _map(this._spiderTicks, function(tick) {
- var cossin = utils.getCosAndSin(tick.angle);
- return {
- x: _round(pos.x + radius * cossin.cos),
- y: _round(pos.y + radius * cossin.sin)
- }
- })
- },
- _createStrip: function(fromPoint, toPoint, attr) {
- var center = this._additionalTranslator.getCenter(),
- innerPoints = this._getGridPoints(center, toPoint),
- outerPoints = this._getGridPoints(center, fromPoint);
- return this._renderer.path([outerPoints, innerPoints.reverse()], "area").attr(attr)
- },
- _createConstantLine: function(value, attr) {
- var center = this._additionalTranslator.getCenter(),
- points = this._getGridPoints(center, value);
- return this._createPathElement(points, attr)
- }
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file baseAxis.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- utils = DX.utils,
- constants = viz.charts.axes.constants,
- _isDefined = utils.isDefined,
- _isNumber = utils.isNumber,
- _getSignificantDigitPosition = utils.getSignificantDigitPosition,
- _roundValue = utils.roundValue,
- _math = Math,
- _abs = _math.abs,
- _round = _math.round,
- _extend = $.extend,
- _each = $.each,
- _noop = $.noop,
- WIDGET_CLASS = "dxc",
- DEFAULT_AXIS_LABEL_SPACING = 5,
- MAX_GRID_BORDER_ADHENSION = 4,
- LABEL_BACKGROUND_PADDING_X = 8,
- LABEL_BACKGROUND_PADDING_Y = 4,
- Axis;
- function validateAxisOptions(options, isHorizontal) {
- var labelOptions = options.label,
- position = options.position,
- defaultPosition = isHorizontal ? constants.bottom : constants.left,
- secondaryPosition = isHorizontal ? constants.top : constants.right;
- if (position !== defaultPosition && position !== secondaryPosition)
- position = defaultPosition;
- if (position === constants.right && !labelOptions.userAlignment)
- labelOptions.alignment = constants.left;
- options.position = position;
- options.hoverMode = options.hoverMode ? options.hoverMode.toLowerCase() : "none";
- labelOptions.minSpacing = _isDefined(labelOptions.minSpacing) ? labelOptions.minSpacing : DEFAULT_AXIS_LABEL_SPACING
- }
- Axis = DX.viz.charts.axes.Axis = function(renderSettings) {
- var that = this;
- that._renderer = renderSettings.renderer;
- that._isHorizontal = renderSettings.isHorizontal;
- that._incidentOccured = renderSettings.incidentOccured;
- that._stripsGroup = renderSettings.stripsGroup;
- that._labelAxesGroup = renderSettings.labelAxesGroup;
- that._constantLinesGroup = renderSettings.constantLinesGroup;
- that._axesContainerGroup = renderSettings.axesContainerGroup;
- that._gridContainerGroup = renderSettings.gridGroup;
- that._axisClass = renderSettings.axisClass;
- that._setType(renderSettings.axesType, renderSettings.drawingType);
- that._createAxisGroups();
- that._tickManager = that._createTickManager()
- };
- Axis.prototype = {
- constructor: Axis,
- dispose: function() {
- var that = this;
- that._axisElementsGroup && that._axisElementsGroup.dispose();
- that._stripLabels = that._strips = null;
- that._title = null;
- that._axisStripGroup = that._axisConstantLineGroup = that._axisLabelGroup = null;
- that._axisLineGroup = that._axisElementsGroup = that._axisGridGroup = null;
- that._axisGroup = that._axisTitleGroup = null;
- that._axesContainerGroup = that._stripsGroup = that._constantLinesGroup = null;
- that._renderer = that._options = that._textOptions = that._textFontStyles = null;
- that._translator = that._additionalTranslator = null;
- that._majorTicks = that._minorTicks = null;
- that._tickManager = null
- },
- getOptions: function() {
- return this._options
- },
- setPane: function(pane) {
- this.pane = pane;
- this._options.pane = pane
- },
- setTypes: function(type, axisType, typeSelector) {
- this._options.type = type || this._options.type;
- this._options[typeSelector] = axisType || this._options[typeSelector]
- },
- resetTypes: function(typeSelector) {
- this._options.type = this._initTypes.type;
- this._options[typeSelector] = this._initTypes[typeSelector]
- },
- getTranslator: function() {
- return this._translator
- },
- updateOptions: function(options) {
- var that = this,
- labelOpt = options.label;
- that._options = options;
- that._initTypes = {
- type: options.type,
- argumentType: options.argumentType,
- valueType: options.valueType
- };
- validateAxisOptions(options, that._isHorizontal);
- that._setTickOffset();
- that.pane = options.pane;
- that.name = options.name;
- that.priority = options.priority;
- that._virtual = options.virtual;
- that._hasLabelFormat = labelOpt.format !== "" && _isDefined(labelOpt.format);
- that._textOptions = {
- align: labelOpt.alignment,
- opacity: labelOpt.opacity
- };
- that._textFontStyles = core.utils.patchFontOptions(labelOpt.font);
- if (options.type === constants.logarithmic) {
- if (options.logarithmBaseError) {
- that._incidentOccured("E2104");
- delete options.logarithmBaseError
- }
- that.calcInterval = function(value, prevValue) {
- return utils.getLog(value / prevValue, options.logarithmBase)
- }
- }
- },
- updateSize: function(clearAxis) {
- var that = this,
- options = that._options,
- direction = that._isHorizontal ? "horizontal" : "vertical";
- if (options.title.text && that._axisTitleGroup) {
- that._incidentOccured("W2105", [direction]);
- that._axisTitleGroup.dispose();
- that._axisTitleGroup = null
- }
- if (clearAxis && that._axisElementsGroup && options.label.visible && !that._translator.getBusinessRange().stubData) {
- that._incidentOccured("W2106", [direction]);
- that._axisElementsGroup.dispose();
- that._axisElementsGroup = null
- }
- that._setBoundingRect()
- },
- _updateTranslatorInterval: function() {
- var that = this,
- i,
- majorTicks,
- majorTicksLength,
- translator = that._translator,
- businessRange = translator.getBusinessRange();
- if (!businessRange.categories && !businessRange.isSynchronized) {
- that.getMajorTicks(true);
- businessRange.addRange(that._tickManager.getTickBounds());
- translator.reinit()
- }
- that._majorTicks = majorTicks = that.getMajorTicks();
- if (!businessRange.categories) {
- majorTicksLength = majorTicks.length;
- for (i = 0; i < majorTicksLength - 1; i++)
- businessRange.addRange({interval: _abs(majorTicks[i].value - majorTicks[i + 1].value)})
- }
- that._decimatedTicks = businessRange.categories ? that.getDecimatedTicks() : [];
- that._minorTicks = that.getMinorTicks()
- },
- setTranslator: function(translator, additionalTranslator) {
- var that = this,
- range = translator.getBusinessRange();
- this._minBound = range.minVisible;
- this._maxBound = range.maxVisible;
- that._translator = translator;
- that._additionalTranslator = additionalTranslator;
- that.resetTicks();
- that._updateTranslatorInterval()
- },
- resetTicks: function() {
- this._deleteLabels();
- this._majorTicks = this._minorTicks = null
- },
- getCurrentLabelPos: function() {
- var that = this,
- options = that._options,
- position = options.position,
- labelOffset = options.label.indentFromAxis,
- axisPosition = that._axisPosition;
- return position === constants.top || position === constants.left ? axisPosition - labelOffset : axisPosition + labelOffset
- },
- getUntranslatedValue: function(pos) {
- var that = this,
- translator = that._translator,
- value = translator.untranslate(pos);
- if (_isDefined(value))
- return constants.formatLabel(_isNumber(value) ? _roundValue(value, _getSignificantDigitPosition(translator.getBusinessRange().interval)) : value, that._options.label);
- return null
- },
- _drawAxis: function() {
- var that = this,
- options = that._options,
- axis = that._createAxis({
- "stroke-width": options.width,
- stroke: options.color,
- "stroke-opacity": options.opacity
- });
- axis.append(that._axisLineGroup)
- },
- _correctMinForTicks: function(min, max, screenDelta) {
- var digitPosition = _getSignificantDigitPosition(_abs(max - min) / screenDelta),
- newMin = _roundValue(Number(min), digitPosition),
- correctingValue;
- if (newMin < min) {
- correctingValue = _math.pow(10, -digitPosition);
- newMin = utils.applyPrecisionByMinDelta(newMin, correctingValue, newMin + correctingValue)
- }
- if (newMin > max)
- newMin = min;
- return newMin
- },
- _getTickManagerData: function() {
- var that = this,
- options = that._options,
- screenDelta = that._getScreenDelta(),
- min = that._minBound,
- max = that._maxBound,
- categories = that._translator.getVisibleCategories() || that._translator.getBusinessRange().categories,
- customTicks = $.isArray(categories) ? categories : that._majorTicks && constants.convertTicksToValues(that._majorTicks),
- customMinorTicks = that._minorTicks && constants.convertTicksToValues(that._minorTicks);
- if (_isNumber(min) && options.type !== constants.logarithmic)
- min = that._correctMinForTicks(min, max, screenDelta);
- return {
- min: min,
- max: max,
- customTicks: customTicks,
- customMinorTicks: customMinorTicks,
- screenDelta: screenDelta
- }
- },
- _getTickManagerTypes: function() {
- return {
- axisType: this._options.type,
- dataType: this._options.dataType
- }
- },
- _createTickManager: function() {
- return DX.viz.core.CoreFactory.createTickManager({}, {}, {overlappingBehaviorType: this._overlappingBehaviorType})
- },
- _getMarginsOptions: function() {
- var range = this._translator.getBusinessRange();
- return {
- stick: range.stick,
- minStickValue: range.minStickValue,
- maxStickValue: range.maxStickValue,
- percentStick: range.percentStick,
- minValueMargin: this._options.minValueMargin,
- maxValueMargin: this._options.maxValueMargin,
- minSpaceCorrection: range.minSpaceCorrection,
- maxSpaceCorrection: range.maxSpaceCorrection
- }
- },
- _updateTickManager: function() {
- var overlappingOptions = this._getOverlappingBehaviorOptions(),
- options;
- options = _extend(true, {}, this._getMarginsOptions(), overlappingOptions, this._getTicksOptions());
- this._tickManager.update(this._getTickManagerTypes(), this._getTickManagerData(), options)
- },
- _correctLabelAlignment: function() {
- var that = this,
- labelOptions = that._options.label,
- overlappingBehavior = that._tickManager.getOverlappingBehavior();
- if (overlappingBehavior && overlappingBehavior.mode === "rotate") {
- that._textOptions.rotate = overlappingBehavior.rotationAngle;
- if (!labelOptions.userAlignment)
- that._textOptions.align = constants.left
- }
- else if (!labelOptions.userAlignment)
- that._textOptions.align = labelOptions.alignment
- },
- _correctLabelFormat: function() {
- this._options.label = this._tickManager.getOptions().labelOptions
- },
- getTicksValues: function() {
- return {
- majorTicksValues: constants.convertTicksToValues(this._majorTicks || this.getMajorTicks()),
- minorTicksValues: constants.convertTicksToValues(this._minorTicks || this.getMinorTicks())
- }
- },
- getMajorTicks: function(withoutOverlappingBehavior) {
- var that = this,
- majorTicks;
- that._updateTickManager();
- that._textOptions.rotate = 0;
- majorTicks = constants.convertValuesToTicks(that._tickManager.getTicks(withoutOverlappingBehavior));
- that._correctLabelAlignment();
- that._correctLabelFormat();
- return majorTicks
- },
- getMinorTicks: function() {
- return constants.convertValuesToTicks(this._tickManager.getMinorTicks())
- },
- getDecimatedTicks: function() {
- return constants.convertValuesToTicks(this._tickManager.getDecimatedTicks())
- },
- setTicks: function(ticks) {
- this.resetTicks();
- this._majorTicks = constants.convertValuesToTicks(ticks.majorTicks);
- this._minorTicks = constants.convertValuesToTicks(ticks.minorTicks)
- },
- _deleteLabels: function() {
- this._axisElementsGroup && this._axisElementsGroup.clear()
- },
- _drawTicks: function(ticks) {
- var that = this,
- group = that._axisLineGroup;
- _each(ticks || [], function(_, tick) {
- var coord = that._getTickCoord(tick),
- points;
- if (coord) {
- points = that._isHorizontal ? [coord.x1, coord.y1, coord.x2, coord.y2] : [coord.y1, coord.x1, coord.y2, coord.x2];
- tick.graphic = that._createPathElement(points, tick.tickStyle).append(group);
- coord.angle && that._rotateTick(tick, coord.angle)
- }
- })
- },
- _createPathElement: function(points, attr, oposite) {
- return this._renderer.path(points, "line").attr(attr).sharp(this._getSharpParam(oposite))
- },
- _createAxis: function(options) {
- return this._createAxisElement().attr(options).sharp(this._getSharpParam(true))
- },
- _getTickCoord: function(tick) {
- var coords;
- if (_isDefined(tick.posX) && _isDefined(tick.posY))
- coords = {
- x1: tick.posX,
- y1: tick.posY - constants.halfTickLength,
- x2: tick.posX,
- y2: tick.posY + constants.halfTickLength
- };
- else
- coords = null;
- return coords
- },
- setPercentLabelFormat: function() {
- if (!this._hasLabelFormat)
- this._options.label.format = "percent"
- },
- resetAutoLabelFormat: function() {
- if (!this._hasLabelFormat)
- delete this._options.label.format
- },
- _drawLabels: function() {
- var that = this,
- renderer = that._renderer,
- group = that._axisElementsGroup,
- emptyStrRegExp = /^\s+$/;
- _each(that._majorTicks, function(_, tick) {
- var text = tick.labelText,
- xCoord,
- yCoord;
- if (_isDefined(text) && text !== "" && !emptyStrRegExp.test(text)) {
- xCoord = that._isHorizontal ? tick.labelPos.x : tick.labelPos.y;
- yCoord = that._isHorizontal ? tick.labelPos.y : tick.labelPos.x;
- if (!tick.label)
- tick.label = renderer.text(text, xCoord, yCoord).css(tick.labelFontStyle).attr(tick.labelStyle).append(group);
- else
- tick.label.css(tick.labelFontStyle).attr(tick.labelStyle).attr({
- text: text,
- x: xCoord,
- y: yCoord
- });
- tick.label.data({argument: tick.value})
- }
- })
- },
- getMultipleAxesSpacing: function() {
- return this._options.multipleAxesSpacing || 0
- },
- _drawTitle: _noop,
- _getGridLineDrawer: function(borderOptions) {
- var that = this,
- translator = that._translator,
- additionalTranslator = that._additionalTranslator,
- isHorizontal = that._isHorizontal,
- canvasStart = isHorizontal ? constants.left : constants.top,
- canvasEnd = isHorizontal ? constants.right : constants.bottom,
- positionFrom = additionalTranslator.translateSpecialCase(constants.canvasPositionStart),
- positionTo = additionalTranslator.translateSpecialCase(constants.canvasPositionEnd),
- firstBorderLinePosition = borderOptions.visible && borderOptions[canvasStart] ? translator.translateSpecialCase(constants.canvasPositionPrefix + canvasStart) : undefined,
- lastBorderLinePosition = borderOptions.visible && borderOptions[canvasEnd] ? translator.translateSpecialCase(constants.canvasPositionPrefix + canvasEnd) : undefined,
- getPoints = isHorizontal ? function(tick) {
- return tick.posX !== null ? [tick.posX, positionFrom, tick.posX, positionTo] : null
- } : function(tick) {
- return tick.posX !== null ? [positionFrom, tick.posX, positionTo, tick.posX] : null
- };
- return function(tick) {
- var points;
- if (_abs(tick.posX - firstBorderLinePosition) < MAX_GRID_BORDER_ADHENSION || _abs(tick.posX - lastBorderLinePosition) < MAX_GRID_BORDER_ADHENSION)
- return;
- points = getPoints(tick);
- return points && that._createPathElement(points, tick.gridStyle)
- }
- },
- _drawGrids: function(ticks, borderOptions) {
- var that = this,
- group = that._axisGridGroup,
- drawLine = that._getGridLineDrawer(borderOptions || {visible: false});
- _each(ticks || [], function(_, tick) {
- tick.grid = drawLine(tick);
- tick.grid && tick.grid.append(group)
- })
- },
- _getConstantLinePos: function(lineValue, canvasStart, canvasEnd) {
- var parsedValue = this._validateUnit(lineValue, "E2105", "constantLine"),
- value = this._getTranslatedCoord(parsedValue);
- if (!_isDefined(value) || value < _math.min(canvasStart, canvasEnd) || value > _math.max(canvasStart, canvasEnd))
- return {};
- return {
- value: value,
- parsedValue: parsedValue
- }
- },
- _createConstantLine: function(value, attr) {
- var that = this,
- additionalTranslator = this._additionalTranslator,
- positionFrom = additionalTranslator.translateSpecialCase(constants.canvasPositionStart),
- positionTo = additionalTranslator.translateSpecialCase(constants.canvasPositionEnd),
- points = this._isHorizontal ? [value, positionTo, value, positionFrom] : [positionFrom, value, positionTo, value];
- return that._createPathElement(points, attr)
- },
- _drawConstantLinesAndLabels: function(lineOptions, canvasStart, canvasEnd) {
- if (!_isDefined(lineOptions.value))
- return;
- var that = this,
- pos = that._getConstantLinePos(lineOptions.value, canvasStart, canvasEnd),
- labelOptions = lineOptions.label || {},
- value = pos.value,
- attr = {
- stroke: lineOptions.color,
- "stroke-width": lineOptions.width,
- dashStyle: lineOptions.dashStyle
- };
- if (!_isDefined(value)) {
- that._constantLines.push(null);
- if (labelOptions.visible)
- that._constantLineLabels.push(null);
- return
- }
- that._constantLines.push(that._createConstantLine(value, attr).append(that._axisConstantLineGroup));
- that._constantLineLabels.push(labelOptions.visible ? that._drawConstantLineLabels(pos.parsedValue, labelOptions, value) : null)
- },
- _drawConstantLine: function() {
- var that = this,
- options = that._options,
- data = options.constantLines,
- canvas = that._getCanvasStartEnd();
- if (that._translator.getBusinessRange().stubData)
- return;
- that._constantLines = [];
- that._constantLineLabels = [];
- _each(data, function(_, dataItem) {
- that._drawConstantLinesAndLabels(dataItem, canvas.start, canvas.end)
- })
- },
- _drawConstantLineLabels: function(parsedValue, lineLabelOptions, value) {
- var that = this,
- text = lineLabelOptions.text,
- options = that._options,
- labelOptions = options.label,
- coords;
- that._checkAlignmentConstantLineLabels(lineLabelOptions);
- text = _isDefined(text) ? text : constants.formatLabel(parsedValue, labelOptions);
- coords = that._getConstantLineLabelsCoords(value, lineLabelOptions);
- return that._renderer.text(text, coords.x, coords.y).css(core.utils.patchFontOptions(_extend({}, labelOptions.font, lineLabelOptions.font))).attr({align: coords.align}).append(that._axisConstantLineGroup)
- },
- _adjustConstantLineLabels: _noop,
- _getStripPos: function(startValue, endValue, canvasStart, canvasEnd, range) {
- var isContinous = !!(range.minVisible || range.maxVisible),
- categories = range.categories || [],
- start,
- end,
- firstValue = startValue,
- lastValue = endValue,
- startCategoryIndex,
- endCategoryIndex,
- min = range.minVisible;
- if (!isContinous) {
- startCategoryIndex = $.inArray(startValue, categories);
- endCategoryIndex = $.inArray(endValue, categories);
- if (startCategoryIndex === -1 || endCategoryIndex === -1)
- return {
- stripFrom: 0,
- stripTo: 0
- };
- if (startCategoryIndex > endCategoryIndex) {
- firstValue = endValue;
- lastValue = startValue
- }
- }
- start = this._getTranslatedCoord(this._validateUnit(firstValue, "E2105", "strip"), -1);
- end = this._getTranslatedCoord(this._validateUnit(lastValue, "E2105", "strip"), 1);
- if (!_isDefined(start) && isContinous)
- start = startValue < min ? canvasStart : canvasEnd;
- if (!_isDefined(end) && isContinous)
- end = endValue < min ? canvasStart : canvasEnd;
- return start < end ? {
- stripFrom: start,
- stripTo: end
- } : {
- stripFrom: end,
- stripTo: start
- }
- },
- _createStrip: function(fromPoint, toPoint, attr) {
- var x,
- y,
- width,
- height,
- additionalTranslator = this._additionalTranslator,
- positionFrom = additionalTranslator.translateSpecialCase(constants.canvasPositionStart),
- positionTo = additionalTranslator.translateSpecialCase(constants.canvasPositionEnd);
- if (this._isHorizontal) {
- x = fromPoint;
- y = _math.min(positionFrom, positionTo);
- width = toPoint - fromPoint;
- height = _abs(positionFrom - positionTo)
- }
- else {
- x = _math.min(positionFrom, positionTo);
- y = fromPoint;
- width = _abs(positionFrom - positionTo);
- height = _abs(fromPoint - toPoint)
- }
- return this._renderer.rect(x, y, width, height).attr(attr)
- },
- _drawStrip: function() {
- var that = this,
- options = that._options,
- stripData = options.strips,
- canvas = this._getCanvasStartEnd(),
- i,
- stripOptions,
- stripPos,
- stripLabelOptions,
- attr,
- range = that._translator.getBusinessRange();
- if (range.stubData)
- return;
- that._strips = [];
- that._stripLabels = [];
- for (i = 0; i < stripData.length; i++) {
- stripOptions = stripData[i];
- stripLabelOptions = stripOptions.label || {};
- attr = {fill: stripOptions.color};
- if (_isDefined(stripOptions.startValue) && _isDefined(stripOptions.endValue) && _isDefined(stripOptions.color)) {
- stripPos = that._getStripPos(stripOptions.startValue, stripOptions.endValue, canvas.start, canvas.end, range);
- if (stripPos.stripTo - stripPos.stripFrom === 0 || !_isDefined(stripPos.stripTo) || !_isDefined(stripPos.stripFrom)) {
- that._strips.push(null);
- if (stripLabelOptions.text)
- that._stripLabels.push(null);
- continue
- }
- that._strips.push(that._createStrip(stripPos.stripFrom, stripPos.stripTo, attr).append(that._axisStripGroup));
- that._stripLabels.push(stripLabelOptions.text ? that._drawStripLabel(stripLabelOptions, stripPos.stripFrom, stripPos.stripTo) : null)
- }
- }
- },
- _drawStripLabel: function(stripLabelOptions, stripFrom, stripTo) {
- var that = this,
- options = that._options,
- coords = that._getStripLabelCoords(stripLabelOptions, stripFrom, stripTo);
- return that._renderer.text(stripLabelOptions.text, coords.x, coords.y).css(core.utils.patchFontOptions(_extend({}, options.label.font, stripLabelOptions.font))).attr({align: coords.align}).append(that._axisLabelGroup)
- },
- _adjustStripLabels: function() {
- var that = this,
- labels = that._stripLabels,
- rects = that._strips,
- i,
- coords;
- if (labels === undefined && rects === undefined)
- return;
- for (i = 0; i < labels.length; i++)
- if (labels[i] !== null) {
- coords = that._getAdjustedStripLabelCoords(that._options.strips[i], labels[i], rects[i]);
- labels[i].move(coords.x, coords.y)
- }
- },
- _initAxisPositions: _noop,
- _adjustLabels: function() {
- var that = this,
- options = that._options,
- majorTicks = that._majorTicks,
- majorTicksLength = majorTicks.length,
- isHorizontal = that._isHorizontal,
- overlappingBehavior = that._tickManager ? that._tickManager.getOverlappingBehavior() : options.label.overlappingBehavior,
- position = options.position,
- label,
- labelHeight,
- isNeedLabelAdjustment,
- staggeringSpacing,
- i,
- box,
- hasLabels = false,
- boxAxis = that._axisElementsGroup && that._axisElementsGroup.getBBox() || {};
- _each(majorTicks, function(_, tick) {
- if (tick.label) {
- tick.label.attr(that._getLabelAdjustedCoord(tick, boxAxis));
- hasLabels = true
- }
- });
- isNeedLabelAdjustment = hasLabels && isHorizontal && overlappingBehavior && overlappingBehavior.mode === "stagger";
- if (isNeedLabelAdjustment) {
- labelHeight = 0;
- for (i = 0; i < majorTicksLength; i = i + 2) {
- label = majorTicks[i].label;
- box = label && label.getBBox() || {};
- if (box.height > labelHeight)
- labelHeight = box.height
- }
- staggeringSpacing = overlappingBehavior.staggeringSpacing;
- labelHeight = _round(labelHeight) + staggeringSpacing;
- for (i = 1; i < majorTicksLength; i = i + 2) {
- label = majorTicks[i].label;
- if (label)
- if (position === constants.bottom)
- label.move(0, labelHeight);
- else if (position === constants.top)
- label.move(0, -labelHeight)
- }
- for (i = 0; i < majorTicksLength; i++)
- majorTicks[i].label && majorTicks[i].label.rotate(0)
- }
- },
- _getLabelAdjustedCoord: function(tick, boxAxis) {
- var that = this,
- options = that._options,
- box = tick.label.getBBox(),
- x,
- y,
- isHorizontal = that._isHorizontal,
- position = options.position,
- shift = that.padding && that.padding[position] || 0,
- textOptions = that._textOptions,
- labelSettingsY = tick.label.attr("y");
- if (isHorizontal && position === constants.bottom)
- y = 2 * labelSettingsY - box.y + shift;
- else if (!isHorizontal) {
- if (position === constants.left)
- if (textOptions.align === constants.right)
- x = box.x + box.width - shift;
- else if (textOptions.align === constants.center)
- x = box.x + box.width / 2 - shift - (boxAxis.width / 2 || 0);
- else
- x = box.x - shift - (boxAxis.width || 0);
- else if (textOptions.align === constants.center)
- x = box.x + box.width / 2 + (boxAxis.width / 2 || 0) + shift;
- else if (textOptions.align === constants.right)
- x = box.x + box.width + (boxAxis.width || 0) + shift;
- else
- x = box.x + shift;
- y = labelSettingsY + ~~(labelSettingsY - box.y - box.height / 2)
- }
- else if (isHorizontal && position === constants.top)
- y = 2 * labelSettingsY - box.y - box.height - shift;
- return {
- x: x,
- y: y
- }
- },
- _adjustTitle: _noop,
- _createAxisGroups: function() {
- var that = this,
- renderer = that._renderer,
- classSelector = WIDGET_CLASS + "-" + that._axisClass + "-";
- that._axisGroup = renderer.g().attr({"class": classSelector + "axis"});
- that._axisStripGroup = renderer.g().attr({"class": classSelector + "strips"});
- that._axisGridGroup = renderer.g().attr({"class": classSelector + "grid"});
- that._axisElementsGroup = renderer.g().attr({"class": classSelector + "elements"}).append(that._axisGroup);
- that._axisLineGroup = renderer.g().attr({"class": classSelector + "line"}).append(that._axisGroup);
- that._axisTitleGroup = renderer.g().attr({"class": classSelector + "title"}).append(that._axisGroup);
- that._axisConstantLineGroup = renderer.g().attr({"class": classSelector + "constant-lines"});
- that._axisLabelGroup = renderer.g().attr({"class": classSelector + "axis-labels"})
- },
- _clearAxisGroups: function(adjustAxis) {
- var that = this,
- classSelector = WIDGET_CLASS + "-" + that._axisClass + "-";
- that._axisGroup.remove();
- that._axisStripGroup.remove();
- that._axisLabelGroup.remove();
- that._axisConstantLineGroup.remove();
- that._axisGridGroup.remove();
- if (that._axisTitleGroup)
- that._axisTitleGroup.clear();
- else if (!adjustAxis)
- that._axisTitleGroup = that._renderer.g().attr({"class": classSelector + "title"}).append(that._axisGroup);
- if (that._axisElementsGroup)
- that._axisElementsGroup.clear();
- else if (!adjustAxis)
- that._axisElementsGroup = that._renderer.g().attr({"class": classSelector + "elements"}).append(that._axisGroup);
- that._axisLineGroup.clear();
- that._axisStripGroup.clear();
- that._axisGridGroup.clear();
- that._axisConstantLineGroup.clear();
- that._axisLabelGroup.clear()
- },
- _initTicks: function(ticks, tickOptions, gridOptions, withLabels) {
- var that = this,
- options = that._options,
- tickStyle = {
- stroke: tickOptions.color,
- "stroke-width": 1,
- "stroke-opacity": tickOptions.opacity
- },
- gridStyle = {
- stroke: gridOptions.color,
- "stroke-width": gridOptions.width,
- "stroke-opacity": gridOptions.opacity
- },
- currentLabelConst = that.getCurrentLabelPos(),
- categoryToSkip = that._getSkippedCategory();
- _each(ticks || [], function(_, tick) {
- var coord;
- if (!(categoryToSkip && categoryToSkip === tick.value)) {
- coord = that._getTranslatedValue(tick.value, that._axisPosition, that._tickOffset);
- tick.posX = coord.x;
- tick.posY = coord.y;
- tick.angle = coord.angle
- }
- tick.tickStyle = tickStyle;
- tick.gridStyle = gridStyle;
- if (withLabels) {
- tick.labelText = constants.formatLabel(tick.value, options.label, {
- min: that._minBound,
- max: that._maxBound
- });
- tick.labelPos = that._getTranslatedValue(tick.value, currentLabelConst);
- tick.labelStyle = that._textOptions;
- tick.labelFontStyle = that._textFontStyles;
- tick.labelHint = constants.formatHint(tick.value, options.label, {
- min: that._minBound,
- max: that._maxBound
- })
- }
- })
- },
- _setTickOffset: function() {
- var options = this._options,
- discreteAxisDivisionMode = options.discreteAxisDivisionMode;
- this._tickOffset = +(discreteAxisDivisionMode !== "crossLabels" || !discreteAxisDivisionMode)
- },
- drawGrids: function(borderOptions) {
- var that = this,
- options = that._options;
- borderOptions = borderOptions || {};
- that._axisGridGroup.append(that._gridContainerGroup);
- if (options.grid.visible)
- that._drawGrids(that._majorTicks.concat(that._decimatedTicks), borderOptions);
- options.minorGrid.visible && that._drawGrids(that._minorTicks, borderOptions)
- },
- draw: function(adjustAxis) {
- var that = this,
- options = that._options,
- areLabelsVisible;
- if (that._axisGroup)
- that._clearAxisGroups(adjustAxis);
- areLabelsVisible = options.label.visible && that._axisElementsGroup && !that._translator.getBusinessRange().stubData;
- that._updateTranslatorInterval();
- that._initAxisPositions();
- that._initTicks(that._majorTicks, options.tick, options.grid, areLabelsVisible);
- that._initTicks(that._decimatedTicks, options.tick, options.grid, false);
- that._initTicks(that._minorTicks, options.minorTick, options.minorGrid);
- if (!that._virtual) {
- options.visible && that._drawAxis();
- if (options.tick.visible) {
- that._drawTicks(that._majorTicks);
- that._drawTicks(that._decimatedTicks)
- }
- options.minorTick.visible && that._drawTicks(that._minorTicks);
- areLabelsVisible && that._drawLabels();
- that._drawTitle()
- }
- options.strips && that._drawStrip();
- options.constantLines && that._drawConstantLine();
- that._axisStripGroup.append(that._stripsGroup);
- that._axisConstantLineGroup.append(that._constantLinesGroup);
- that._axisGroup.append(that._axesContainerGroup);
- that._axisLabelGroup.append(that._labelAxesGroup);
- that._adjustConstantLineLabels();
- areLabelsVisible && that._adjustLabels();
- that._createHints();
- that._adjustStripLabels();
- that._adjustTitle();
- that._setBoundingRect()
- },
- _createHints: function() {
- var that = this;
- _each(that._majorTicks || [], function(_, tick) {
- var labelHint = tick.labelHint;
- if (_isDefined(labelHint) && labelHint !== "")
- tick.label.setTitle(labelHint)
- })
- },
- _setBoundingRect: function() {
- var that = this,
- options = that._options,
- axisBox = that._axisElementsGroup ? that._axisElementsGroup.getBBox() : {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- isEmpty: true
- },
- lineBox = that._axisLineGroup.getBBox(),
- placeholderSize = options.placeholderSize,
- start,
- isHorizontal = that._isHorizontal,
- coord = isHorizontal ? "y" : "x",
- side = isHorizontal ? "height" : "width",
- shiftCoords = options.crosshairEnabled ? isHorizontal ? LABEL_BACKGROUND_PADDING_Y : LABEL_BACKGROUND_PADDING_X : 0,
- axisTitleBox = that._title && that._axisTitleGroup ? that._axisTitleGroup.getBBox() : axisBox;
- if (axisBox.isEmpty && axisTitleBox.isEmpty && !placeholderSize) {
- that.boundingRect = axisBox;
- return
- }
- start = lineBox[coord] || that._axisPosition;
- if (options.position === (isHorizontal && constants.bottom || constants.right)) {
- axisBox[side] = placeholderSize || axisTitleBox[coord] + axisTitleBox[side] - start + shiftCoords;
- axisBox[coord] = start
- }
- else {
- axisBox[side] = placeholderSize || lineBox[side] + start - axisTitleBox[coord] + shiftCoords;
- axisBox[coord] = axisTitleBox.isEmpty ? start : axisTitleBox[coord] - shiftCoords
- }
- that.boundingRect = axisBox
- },
- getBoundingRect: function() {
- return this._axisElementsGroup ? this.boundingRect : {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }
- },
- shift: function(x, y) {
- var settings = {};
- if (x)
- settings.translateX = x;
- if (y)
- settings.translateY = y;
- this._axisGroup.attr(settings)
- },
- applyClipRects: function(elementsClipID, canvasClipID) {
- this._axisGroup.attr({clipId: canvasClipID});
- this._axisStripGroup.attr({clipId: elementsClipID})
- },
- validate: function(isArgumentAxis) {
- var that = this,
- options = that._options,
- parseUtils = new core.ParseUtils,
- dataType = isArgumentAxis ? options.argumentType : options.valueType,
- parser = dataType ? parseUtils.getParser(dataType, "axis") : function(unit) {
- return unit
- };
- that.parser = parser;
- options.dataType = dataType;
- if (options.min !== undefined)
- options.min = that._validateUnit(options.min, "E2106");
- if (options.max !== undefined)
- options.max = that._validateUnit(options.max, "E2106");
- if (that._minBound !== undefined)
- that._minBound = that._validateUnit(that._minBound);
- if (that._maxBound !== undefined)
- that._maxBound = that._validateUnit(that._maxBound)
- },
- _validateUnit: function(unit, idError, parameters) {
- var that = this;
- unit = that.parser(unit);
- if (unit === undefined && idError)
- that._incidentOccured(idError, [parameters]);
- return unit
- },
- zoom: function(min, max, skipAdjusting) {
- var that = this,
- minOpt = that._options.min,
- maxOpt = that._options.max;
- skipAdjusting = skipAdjusting || that._options.type === constants.discrete;
- min = that._validateUnit(min);
- max = that._validateUnit(max);
- if (!skipAdjusting) {
- if (minOpt !== undefined) {
- min = minOpt > min ? minOpt : min;
- max = minOpt > max ? minOpt : max
- }
- if (maxOpt !== undefined) {
- max = maxOpt < max ? maxOpt : max;
- min = maxOpt < min ? maxOpt : min
- }
- }
- that._zoomArgs = {
- min: min,
- max: max
- };
- return that._zoomArgs
- },
- resetZoom: function() {
- this._zoomArgs = null
- },
- getRangeData: function() {
- var that = this,
- options = that._options,
- minMax = that._getMinMax(),
- min = minMax.min,
- max = minMax.max,
- zoomArgs = that._zoomArgs || {},
- type = options.type,
- rangeMin,
- rangeMax,
- rangeMinVisible,
- rangeMaxVisible;
- if (type === constants.logarithmic) {
- min = min <= 0 ? undefined : min;
- max = max <= 0 ? undefined : max
- }
- if (type !== constants.discrete) {
- rangeMin = min;
- rangeMax = max;
- if (_isDefined(min) && _isDefined(max)) {
- rangeMin = min < max ? min : max;
- rangeMax = max > min ? max : min
- }
- rangeMinVisible = _isDefined(zoomArgs.min) ? zoomArgs.min : rangeMin;
- rangeMaxVisible = _isDefined(zoomArgs.max) ? zoomArgs.max : rangeMax
- }
- else {
- rangeMinVisible = _isDefined(zoomArgs.min) ? zoomArgs.min : min;
- rangeMaxVisible = _isDefined(zoomArgs.max) ? zoomArgs.max : max
- }
- return {
- min: rangeMin,
- max: rangeMax,
- stick: that._getStick(),
- categories: options.categories,
- dataType: options.dataType,
- axisType: type,
- base: options.logarithmBase,
- invert: options.inverted,
- addSpiderCategory: that._getSpiderCategoryOption(),
- minVisible: rangeMinVisible,
- maxVisible: rangeMaxVisible
- }
- },
- _setType: function(axesType, drawingType) {
- var that = this;
- _each(DX.viz.charts.axes[axesType][drawingType], function(methodName, method) {
- that[methodName] = method
- })
- },
- _getSharpParam: function() {
- return true
- },
- getSpiderTicks: _noop,
- setSpiderTicks: _noop,
- measureLabels: _noop,
- coordsIn: _noop,
- _getSkippedCategory: _noop
- }
- })(jQuery, DevExpress);
- /*! Module viz-charts, file scrollBar.js */
- (function($, DX, math) {
- var MIN_SCROLL_BAR_SIZE = 2,
- isDefined = DX.utils.isDefined,
- _min = math.min,
- _max = math.max;
- DX.viz.charts.ScrollBar = function(renderer, group) {
- this._translator = DX.viz.core.CoreFactory.createTranslator2D({}, {}, {});
- this._scroll = renderer.rect().append(group);
- this._addEvents()
- };
- function _getXCoord(canvas, pos, offset, width) {
- var x = 0;
- if (pos === "right")
- x = canvas.width - canvas.right + offset;
- else if (pos === "left")
- x = canvas.left - offset - width;
- return x
- }
- function _getYCoord(canvas, pos, offset, width) {
- var y = 0;
- if (pos === "top")
- y = canvas.top - offset;
- else if (pos === "bottom")
- y = canvas.height - canvas.bottom + width + offset;
- return y
- }
- DX.viz.charts.ScrollBar.prototype = {
- _addEvents: function() {
- var that = this,
- $scroll = $(that._scroll.element),
- startPosX = 0,
- startPosY = 0,
- scrollChangeHandler = function(e) {
- var dX = (startPosX - e.pageX) * that._scale,
- dY = (startPosY - e.pageY) * that._scale;
- $scroll.trigger(new $.Event("dxc-scroll-move", $.extend(e, {
- type: "dxc-scroll-move",
- pointers: [{
- pageX: startPosX + dX,
- pageY: startPosY + dY
- }]
- })))
- };
- $scroll.on("dxpointerdown", function(e) {
- startPosX = e.pageX;
- startPosY = e.pageY;
- $scroll.trigger(new $.Event("dxc-scroll-start", {pointers: [{
- pageX: startPosX,
- pageY: startPosY
- }]}));
- $(document).on("dxpointermove", scrollChangeHandler)
- });
- $(document).on("dxpointerup", function() {
- $(document).off("dxpointermove", scrollChangeHandler)
- })
- },
- update: function(options) {
- var that = this,
- position = options.position,
- isVertical = options.rotated,
- defaultPosition = isVertical ? "right" : "top",
- secondaryPosition = isVertical ? "left" : "bottom";
- if (position !== defaultPosition && position !== secondaryPosition)
- position = defaultPosition;
- that._scroll.attr({
- rotate: !options.rotated ? -90 : 0,
- rotateX: 0,
- rotateY: 0,
- fill: options.color,
- width: options.width,
- opacity: options.opacity
- });
- that._layoutOptions = {
- width: options.width,
- offset: options.offset,
- vertical: isVertical,
- position: position
- };
- return that
- },
- init: function(range, canvas) {
- var that = this;
- that._translateWithOffset = range.axisType === "discrete" && !range.stick && 1 || 0;
- that._translator.update($.extend({}, range, {
- minVisible: null,
- maxVisible: null,
- visibleCategories: null
- }), $.extend({}, canvas), {direction: that._layoutOptions.vertical ? "vertical" : "horizontal"});
- return that
- },
- getOptions: function() {
- return this._layoutOptions
- },
- shift: function(x, y) {
- this._scroll.attr({
- translateX: x,
- translateY: y
- })
- },
- setPane: function(panes) {
- var position = this._layoutOptions.position,
- pane;
- if (position === "left" || position === "top")
- pane = panes[0];
- else
- pane = panes[panes.length - 1];
- this.pane = pane.name;
- this._canvas = pane.canvas;
- return this
- },
- getMultipleAxesSpacing: function() {
- return 0
- },
- getBoundingRect: function() {
- var options = this._layoutOptions,
- isVertical = options.vertical,
- offset = options.offset,
- width = options.width,
- pos = options.position,
- size = width + offset,
- canvas = this._canvas;
- return isVertical ? {
- x: _getXCoord(canvas, pos, offset, width),
- y: canvas.top,
- width: size,
- height: canvas.height - canvas.top - canvas.bottom
- } : {
- x: canvas.left,
- y: _getYCoord(canvas, pos, offset, width),
- width: canvas.width - canvas.left - canvas.right,
- height: size
- }
- },
- applyLayout: function() {
- var canvas = this._canvas,
- options = this._layoutOptions,
- pos = options.position,
- offset = options.offset,
- width = options.width;
- this.shift(_getXCoord(canvas, pos, offset, width), _getYCoord(canvas, pos, offset, width))
- },
- setPosition: function(min, max) {
- var that = this,
- translator = that._translator,
- minPoint = isDefined(min) ? translator.translate(min, -that._translateWithOffset) : translator.translate("canvas_position_start"),
- maxPoint = isDefined(max) ? translator.translate(max, that._translateWithOffset) : translator.translate("canvas_position_end");
- that._offset = _min(minPoint, maxPoint);
- that._scale = translator.getScale(min, max);
- that._applyPosition(_min(minPoint, maxPoint), _max(minPoint, maxPoint))
- },
- transform: function(translate, scale) {
- var x = this._translator.getCanvasVisibleArea().min,
- dx = x - (x * scale - translate),
- lx = this._offset + dx / (this._scale * scale);
- this._applyPosition(lx, lx + this._translator.canvasLength / (this._scale * scale))
- },
- dispose: function() {
- this._scroll.dispose();
- this._scroll = this._translator = null
- },
- _applyPosition: function(x1, x2) {
- var that = this,
- visibleArea = that._translator.getCanvasVisibleArea(),
- height;
- x1 = _max(x1, visibleArea.min);
- x1 = _min(x1, visibleArea.max);
- x2 = _min(x2, visibleArea.max);
- x2 = _max(x2, visibleArea.min);
- height = math.abs(x2 - x1);
- that._scroll.attr({
- y: x1,
- height: height < MIN_SCROLL_BAR_SIZE ? MIN_SCROLL_BAR_SIZE : height
- })
- }
- }
- })(jQuery, DevExpress, Math);
- /*! Module viz-charts, file baseChart.js */
- (function($, DX, undefined) {
- var ui = DX.ui,
- charts = DX.viz.charts,
- utils = DX.utils,
- ACTIONS_BY_PRIORITY = ['reinit', '_reinitDataSource', '_dataInit', 'force_render', "_resize"],
- core = DX.viz.core,
- _each = $.each,
- _map = $.map,
- _extend = $.extend,
- DEFAULT_ANIMATION_OPTIONS = {asyncSeriesRendering: true},
- _isDefined = utils.isDefined,
- DEFAULT_OPACITY = 0.3;
- function createEventMapObject(name, deprecatedArgs) {
- return {
- name: name,
- deprecated: name,
- deprecatedContext: function(arg) {
- return arg.target
- },
- deprecatedArgs: deprecatedArgs || function(arg) {
- return [arg.target, arg.jQueryEvent]
- }
- }
- }
- function checkHeightLabelsInCanvas(points, canvas, isRotated) {
- var commonLabelSize = 0,
- canvasSize = canvas.end - canvas.start,
- label,
- bbox;
- for (var i = 0; i < points.length; i++) {
- label = points[i].getLabel();
- if (label.isVisible()) {
- bbox = label.getBoundingRect();
- commonLabelSize += isRotated ? bbox.width : bbox.height
- }
- else
- points[i] = null
- }
- if (canvasSize > 0)
- while (commonLabelSize > canvasSize)
- commonLabelSize -= killSmallValues(points, isRotated)
- }
- function killSmallValues(points, isRotated) {
- var smallestValuePoint = {originalValue: Infinity},
- label,
- bbox,
- indexOfPoint;
- _each(points, function(index, point) {
- if (point && smallestValuePoint.originalValue >= point.originalValue) {
- smallestValuePoint = point;
- indexOfPoint = index
- }
- });
- if (indexOfPoint !== null) {
- label = points[indexOfPoint].getLabel();
- bbox = label.getBoundingRect();
- label.hide();
- points[indexOfPoint] = null;
- return isRotated ? bbox.width : bbox.height
- }
- return 0
- }
- function resolveLabelOverlappingInOneDirection(points, canvas, isRotated, shiftFunction) {
- var stubCanvas = {
- start: isRotated ? canvas.left : canvas.top,
- end: isRotated ? canvas.width - canvas.right : canvas.height - canvas.bottom
- };
- checkHeightLabelsInCanvas(points, stubCanvas, isRotated);
- var rollingStocks = $.map(points, function(point) {
- return point && new RollingStock(point, isRotated, shiftFunction)
- });
- rollingStocks.sort(function(a, b) {
- return a.getPointPosition() - b.getPointPosition()
- });
- if (!checkStackOverlap(rollingStocks))
- return;
- rollingStocks.reverse();
- moveRollingStock(rollingStocks, stubCanvas)
- }
- function overlapRollingStock(firstRolling, secondRolling) {
- if (!firstRolling || !secondRolling)
- return;
- return firstRolling.getBoundingRect().end > secondRolling.getBoundingRect().start
- }
- function checkStackOverlap(rollingStocks) {
- var i,
- j,
- currentRollingStock,
- nextRollingStock,
- overlap;
- for (i = 0; i < rollingStocks.length; i++) {
- currentRollingStock = rollingStocks[i];
- for (j = i + 1; j < rollingStocks.length; j++) {
- nextRollingStock = rollingStocks[j];
- if (overlapRollingStock(currentRollingStock, nextRollingStock)) {
- currentRollingStock.toChain(nextRollingStock);
- overlap = true;
- rollingStocks[j] = null
- }
- }
- }
- return overlap
- }
- function moveRollingStock(rollingStocks, canvas) {
- var i,
- j,
- currentRollingStock,
- nextRollingStock,
- currentBBox,
- nextBBox;
- for (i = 0; i < rollingStocks.length; i++) {
- currentRollingStock = rollingStocks[i];
- if (rollingStocksIsOut(currentRollingStock, canvas)) {
- currentBBox = currentRollingStock.getBoundingRect();
- for (j = i + 1; j < rollingStocks.length; j++) {
- nextRollingStock = rollingStocks[j];
- if (!nextRollingStock)
- continue;
- nextBBox = nextRollingStock.getBoundingRect();
- if (nextBBox.end > currentBBox.start - (currentBBox.end - canvas.end)) {
- nextRollingStock.toChain(currentRollingStock);
- rollingStocks[i] = currentRollingStock = null;
- break
- }
- }
- }
- currentRollingStock && currentRollingStock.setRollingStockInCanvas(canvas)
- }
- }
- function rollingStocksIsOut(rollingStock, canvas) {
- return rollingStock && rollingStock.getBoundingRect().end > canvas.end
- }
- function RollingStock(point, isRotated, shiftFunction) {
- var label = point.getLabel(),
- bbox = label.getBoundingRect();
- this.labels = [label];
- this.points = [point];
- this.shiftFunction = shiftFunction;
- this._bbox = {
- start: isRotated ? bbox.x : bbox.y,
- width: isRotated ? bbox.width : bbox.height,
- end: isRotated ? bbox.x + bbox.width : bbox.y + bbox.height
- };
- this._pointPositionInitialize = isRotated ? point.getBoundaryCoords().x : point.getBoundaryCoords().y;
- return this
- }
- RollingStock.prototype = {
- toChain: function(nextRollingStock) {
- var nextRollingStockBBox = nextRollingStock.getBoundingRect();
- nextRollingStock.shift(nextRollingStockBBox.start - this._bbox.end);
- this._changeBoxWidth(nextRollingStockBBox.width);
- this.labels = this.labels.concat(nextRollingStock.labels);
- this.points = this.points.concat(nextRollingStock.points)
- },
- getBoundingRect: function() {
- return this._bbox
- },
- shift: function(shiftLength) {
- var shiftFunction = this.shiftFunction;
- _each(this.labels, function(index, label) {
- var bbox = label.getBoundingRect(),
- coords = shiftFunction(bbox, shiftLength, label);
- label.shift(coords.x, coords.y)
- });
- this._bbox.end -= shiftLength;
- this._bbox.start -= shiftLength
- },
- setRollingStockInCanvas: function(canvas) {
- if (this._bbox.end > canvas.end)
- this.shift(this._bbox.end - canvas.end)
- },
- getPointPosition: function() {
- return this._pointPositionInitialize
- },
- _changeBoxWidth: function(width) {
- this._bbox.end += width;
- this._bbox.width += width
- }
- };
- function getLegendFields(name) {
- return {
- nameField: name + 'Name',
- colorField: name + 'Color',
- indexField: name + 'Index'
- }
- }
- function getLegendSettings(legendDataField) {
- var formatObjectFields = getLegendFields(legendDataField);
- return {
- getFormatObject: function(data) {
- var res = {};
- res[formatObjectFields.indexField] = data.id;
- res[formatObjectFields.colorField] = data.states.normal.fill;
- res[formatObjectFields.nameField] = data.text;
- return res
- },
- textField: formatObjectFields.nameField
- }
- }
- function checkOverlapping(firstRect, secondRect) {
- return (firstRect.x <= secondRect.x && secondRect.x <= firstRect.x + firstRect.width || firstRect.x >= secondRect.x && firstRect.x <= secondRect.x + secondRect.width) && (firstRect.y <= secondRect.y && secondRect.y <= firstRect.y + firstRect.height || firstRect.y >= secondRect.y && firstRect.y <= secondRect.y + secondRect.height)
- }
- charts.overlapping = {resolveLabelOverlappingInOneDirection: resolveLabelOverlappingInOneDirection};
- charts.BaseChart = core.BaseWidget.inherit({
- _eventsMap: $.extend({}, core.BaseWidget.prototype._eventsMap, {
- onSeriesClick: createEventMapObject("seriesClick"),
- onPointClick: createEventMapObject("pointClick"),
- onArgumentAxisClick: createEventMapObject("argumentAxisClick", function(arg) {
- return [arg.target, arg.argument, arg.jQueryEvent]
- }),
- onLegendClick: createEventMapObject("legendClick"),
- onSeriesSelectionChanged: createEventMapObject('seriesSelectionChanged'),
- onPointSelectionChanged: createEventMapObject('pointSelectionChanged'),
- onSeriesHoverChanged: createEventMapObject('seriesHoverChanged'),
- onPointHoverChanged: createEventMapObject('pointHoverChanged'),
- onTooltipShown: createEventMapObject('tooltipShown'),
- onTooltipHidden: createEventMapObject('tooltipHidden'),
- onDone: createEventMapObject("done"),
- seriesClick: {newName: 'onSeriesClick'},
- pointClick: {newName: 'onPointClick'},
- argumentAxisClick: {newName: 'onArgumentAxisClick'},
- legendClick: {newName: 'onLegendClick'},
- pointHoverChanged: {newName: 'onPointHoverChanged'},
- seriesSelectionChanged: {newName: 'onSeriesSelectionChanged'},
- pointSelectionChanged: {newName: 'onPointSelectionChanged'},
- seriesHoverChanged: {newName: 'onSeriesHoverChanged'},
- tooltipShown: {newName: 'onTooltipShown'},
- tooltipHidden: {newName: 'onTooltipHidden'},
- done: {newName: 'onDone'}
- }),
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {
- seriesClick: {
- since: '14.2',
- message: "Use the 'onSeriesClick' option instead"
- },
- pointClick: {
- since: '14.2',
- message: "Use the 'onPointClick' option instead"
- },
- argumentAxisClick: {
- since: '14.2',
- message: "Use the 'onArgumentAxisClick' option instead"
- },
- legendClick: {
- since: '14.2',
- message: "Use the 'onLegendClick' option instead"
- },
- seriesSelectionChanged: {
- since: '14.2',
- message: "Use the 'onSeriesSelectionChanged' option instead"
- },
- pointSelectionChanged: {
- since: '14.2',
- message: "Use the 'onPointSelectionChanged' option instead"
- },
- seriesHoverChanged: {
- since: '14.2',
- message: "Use the 'onSeriesHoverChanged' option instead"
- },
- pointHoverChanged: {
- since: '14.2',
- message: "Use the 'onPointHoverChanged' option instead"
- },
- tooltipShown: {
- since: '14.2',
- message: "Use the 'onTooltipShown' option instead"
- },
- tooltipHidden: {
- since: '14.2',
- message: "Use the 'onTooltipHidden' option instead"
- },
- done: {
- since: '14.2',
- message: "Use the 'onDone' option instead"
- }
- })
- },
- _rootClassPrefix: "dxc",
- _rootClass: "dxc-chart",
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._reinit()
- },
- _createThemeManager: function() {
- var option = this.option(),
- themeManager = charts.factory.createThemeManager(option, this._chartType);
- themeManager.setTheme(option.theme, option.rtlEnabled);
- return themeManager
- },
- _initCore: function() {
- var that = this;
- that._canvasClipRect = that._renderer.clipRect();
- that._createHtmlStructure();
- that._createLegend();
- that._needHandleRenderComplete = true;
- that.layoutManager = charts.factory.createChartLayoutManager(that._layoutManagerOptions());
- that._createScrollBar();
- that._$element.on('contextmenu', function(event) {
- that.eventType = 'contextmenu';
- if (ui.events.isTouchEvent(event) || ui.events.isPointerEvent(event))
- event.preventDefault()
- }).on('MSHoldVisual', function(event) {
- that.eventType = 'MSHoldVisual';
- event.preventDefault()
- })
- },
- _layoutManagerOptions: function() {
- return this._themeManager.getOptions("adaptiveLayout")
- },
- _reinit: function(needRedraw) {
- var that = this;
- charts._setCanvasValues(that._canvas);
- that._createTracker();
- that._reinitAxes();
- that._reinitDataSource();
- if (!that.series)
- that._dataSpecificInit();
- that._correctAxes();
- needRedraw && that._endLoading(function() {
- that._render({force: true})
- })
- },
- _createHtmlStructure: function() {
- var that = this,
- renderer = that._renderer;
- that._backgroundRect = renderer.rect(0, 0, 0, 0).attr({
- fill: "gray",
- opacity: 0.0001
- });
- that._panesBackgroundGroup = renderer.g().attr({'class': 'dxc-background'});
- that._titleGroup = renderer.g().attr({'class': 'dxc-title'});
- that._legendGroup = renderer.g().attr({
- 'class': 'dxc-legend',
- clipId: that._getCanvasClipRectID()
- });
- that._stripsGroup = renderer.g().attr({'class': 'dxc-strips-group'});
- that._constantLinesGroup = renderer.g().attr({'class': 'dxc-constant-lines-group'});
- that._axesGroup = renderer.g().attr({'class': 'dxc-axes-group'});
- that._gridGroup = renderer.g().attr({'class': 'dxc-grids-group'});
- that._panesBorderGroup = renderer.g().attr({'class': 'dxc-border'});
- that._labelAxesGroup = renderer.g().attr({'class': 'dxc-strips-labels-group'});
- that._scrollBarGroup = renderer.g().attr({'class': 'dxc-scroll-bar'});
- that._seriesGroup = renderer.g().attr({'class': 'dxc-series-group'});
- that._labelsGroup = renderer.g().attr({'class': 'dxc-labels-group'});
- that._crosshairCursorGroup = renderer.g().attr({'class': 'dxc-crosshair-cursor'})
- },
- _disposeObjectsInArray: function(propName, fieldNames) {
- $.each(this[propName] || [], function(_, item) {
- if (fieldNames && item)
- $.each(fieldNames, function(_, field) {
- item[field] && item[field].dispose()
- });
- else
- item && item.dispose()
- });
- this[propName] = null
- },
- _disposeCore: function() {
- var that = this,
- disposeObject = function(propName) {
- if (that[propName]) {
- that[propName].dispose();
- that[propName] = null
- }
- },
- disposeObjectsInArray = this._disposeObjectsInArray;
- clearTimeout(that._delayedRedraw);
- that._renderer.stopAllAnimations();
- disposeObjectsInArray.call(that, "businessRanges", ["arg", "val"]);
- that.translators = null;
- disposeObjectsInArray.call(that, "series");
- disposeObject("layoutManager");
- disposeObject("tracker");
- disposeObject("chartTitle");
- disposeObject("_crosshair");
- that.paneAxis = null;
- that._userOptions = null;
- that._canvas = null;
- disposeObject("_canvasClipRect");
- disposeObject("_panesBackgroundGroup");
- disposeObject("_titleGroup");
- disposeObject("_scrollBarGroup");
- disposeObject("_legendGroup");
- disposeObject("_stripsGroup");
- disposeObject("_constantLinesGroup");
- disposeObject("_axesGroup");
- disposeObject("_gridGroup");
- disposeObject("_labelAxesGroup");
- disposeObject("_panesBorderGroup");
- disposeObject("_seriesGroup");
- disposeObject("_labelsGroup");
- disposeObject("_crosshairCursorGroup")
- },
- _getAnimationOptions: function() {
- return $.extend({}, DEFAULT_ANIMATION_OPTIONS, this._themeManager.getOptions("animation"))
- },
- _getDefaultSize: function() {
- return {
- width: 400,
- height: 400
- }
- },
- _getOption: function(name) {
- return this._themeManager.getOptions(name)
- },
- _reinitDataSource: function() {
- this._refreshDataSource()
- },
- _applySize: $.noop,
- _resize: function() {
- if (this._updateLockCount)
- this._processRefreshData("_resize");
- else
- this._render(this.__renderOptions || {
- animate: false,
- isResize: true,
- updateTracker: false
- })
- },
- _createTracker: function() {
- var that = this,
- themeManager = that._themeManager;
- if (that.tracker)
- that.tracker.dispose();
- that.tracker = charts.factory.createTracker({
- seriesSelectionMode: themeManager.getOptions('seriesSelectionMode'),
- pointSelectionMode: themeManager.getOptions('pointSelectionMode'),
- seriesGroup: that._seriesGroup,
- renderer: that._renderer,
- tooltip: that._tooltip,
- eventTrigger: that._eventTrigger
- }, that.NAME)
- },
- _getTrackerSettings: function() {
- var that = this;
- return {
- series: that.series,
- legend: that.legend,
- legendCallback: $.proxy(that.legend.getActionCallback, that.legend)
- }
- },
- _updateTracker: function() {
- this.tracker.update(this._getTrackerSettings())
- },
- _render: function(_options) {
- var that = this,
- drawOptions,
- originalCanvas;
- if (!that._initialized)
- return;
- if (!that._canvas)
- return;
- that._resetIsReady();
- drawOptions = that._prepareDrawOptions(_options);
- clearTimeout(that._delayedRedraw);
- originalCanvas = that._canvas;
- that._canvas = $.extend({}, that._canvas);
- if (drawOptions.recreateCanvas)
- that.__currentCanvas = that._canvas;
- else
- that._canvas = that.__currentCanvas;
- that.DEBUG_canvas = that._canvas;
- if (drawOptions.recreateCanvas) {
- that._reappendLoadingIndicator();
- that._updateCanvasClipRect()
- }
- that._renderer.stopAllAnimations(true);
- charts._setCanvasValues(that._canvas);
- that._cleanGroups(drawOptions);
- that._renderElements(drawOptions);
- that._canvas = originalCanvas
- },
- _renderElements: function(drawOptions) {
- var that = this,
- preparedOptions = that._prepareToRender(drawOptions),
- isRotated = that._isRotated(),
- isLegendInside = that._isLegendInside(),
- trackerCanvases = [],
- layoutTargets = that._getLayoutTargets(),
- dirtyCanvas = $.extend({}, that._canvas),
- argBusinessRange,
- zoomMinArg,
- zoomMaxArg;
- !drawOptions.isResize && that._scheduleLoadingIndicatorHiding();
- that.DEBUG_dirtyCanvas = dirtyCanvas;
- that._renderTitleAndLegend(drawOptions, isLegendInside);
- that._renderAxes(drawOptions, preparedOptions, isRotated);
- if (drawOptions.drawTitle && drawOptions.drawLegend && drawOptions.adjustAxes && that.layoutManager.needMoreSpaceForPanesCanvas(that._getLayoutTargets(), isRotated)) {
- that.layoutManager.updateDrawnElements(that._getAxesForTransform(isRotated), that._canvas, dirtyCanvas, that._getLayoutTargets(), isRotated);
- if (that.chartTitle)
- that.layoutManager.correctSizeElement(that.chartTitle, that._canvas);
- that._updateCanvasClipRect(dirtyCanvas);
- that._updateAxesLayout(drawOptions, preparedOptions, isRotated)
- }
- drawOptions.drawTitle && drawOptions.drawLegend && drawOptions.adjustAxes && that.layoutManager.placeDrawnElements(that._canvas);
- that._applyClipRects(preparedOptions);
- that._appendSeriesGroups();
- that._createCrosshairCursor();
- $.each(layoutTargets, function() {
- var canvas = this.canvas;
- trackerCanvases.push({
- left: canvas.left,
- right: canvas.width - canvas.right,
- top: canvas.top,
- bottom: canvas.height - canvas.bottom
- })
- });
- if (that._scrollBar) {
- argBusinessRange = that.businessRanges[0].arg;
- if (argBusinessRange.categories && argBusinessRange.categories.length <= 1)
- zoomMinArg = zoomMaxArg = undefined;
- else {
- zoomMinArg = argBusinessRange.minVisible;
- zoomMaxArg = argBusinessRange.maxVisible
- }
- that._scrollBar.init(argBusinessRange, layoutTargets[0].canvas).setPosition(zoomMinArg, zoomMaxArg)
- }
- drawOptions.updateTracker && that._updateTracker();
- that.tracker.setCanvases({
- left: 0,
- right: that._canvas.width,
- top: 0,
- bottom: that._canvas.height
- }, trackerCanvases);
- that._updateLegendPosition(drawOptions, isLegendInside);
- var timeout = that._getSeriesRenderTimeout(drawOptions);
- if (timeout >= 0)
- that._delayedRedraw = setTimeout(renderSeries, timeout);
- else
- renderSeries();
- function renderSeries() {
- that._renderSeries(drawOptions, isRotated, isLegendInside)
- }
- },
- _createCrosshairCursor: $.noop,
- _appendSeriesGroups: function() {
- var that = this,
- root = that._renderer.root;
- that._seriesGroup.append(root);
- that._labelsGroup.append(root);
- that._appendAdditionalSeriesGroups()
- },
- _renderSeries: function(drawOptions, isRotated, isLegendInside) {
- var that = this,
- themeManager = that._themeManager,
- resolveLabelOverlapping = themeManager.getOptions("resolveLabelOverlapping");
- drawOptions.hideLayoutLabels = that.layoutManager.needMoreSpaceForPanesCanvas(that._getLayoutTargets(), that._isRotated()) && !themeManager.getOptions("adaptiveLayout").keepLabels;
- that._drawSeries(drawOptions, isRotated);
- resolveLabelOverlapping !== "none" && that._resolveLabelOverlapping(resolveLabelOverlapping);
- that._adjustSeries();
- that._renderTrackers(isLegendInside);
- if (that._dataSource && that._dataSource.isLoaded())
- that._fulfillLoadingIndicatorHiding();
- that.tracker.repairTooltip();
- that._drawn();
- that._renderCompleteHandler()
- },
- _getAnimateOption: function(series, drawOptions) {
- return drawOptions.animate && series.getPoints().length <= drawOptions.animationPointsLimit && this._renderer.animationEnabled()
- },
- _resolveLabelOverlapping: function(resolveLabelOverlapping) {
- var func;
- switch (resolveLabelOverlapping) {
- case"stack":
- func = this._resolveLabelOverlappingStack;
- break;
- case"hide":
- func = this._resolveLabelOverlappingHide;
- break;
- case"shift":
- func = this._resolveLabelOverlappingShift;
- break
- }
- $.isFunction(func) && func.call(this)
- },
- _getVisibleSeries: function() {
- return $.grep(this.getAllSeries(), function(series) {
- return series.isVisible()
- })
- },
- _resolveLabelOverlappingHide: function() {
- var labels = $.map(this._getVisibleSeries(), function(series) {
- return $.map(series.getVisiblePoints(), function(point) {
- return point.getLabel()
- })
- }),
- currenctLabel,
- nextLabel,
- currenctLabelRect,
- nextLabelRect,
- i,
- j;
- for (i = 0; i < labels.length; i++) {
- currenctLabel = labels[i];
- currenctLabelRect = currenctLabel.getBoundingRect();
- if (!currenctLabel.isVisible())
- continue;
- for (j = i + 1; j < labels.length; j++) {
- nextLabel = labels[j];
- nextLabelRect = nextLabel.getBoundingRect();
- if (checkOverlapping(currenctLabelRect, nextLabelRect))
- nextLabel.hide()
- }
- }
- },
- _cleanGroups: function(drawOptions) {
- var that = this;
- that._stripsGroup.remove();
- that._constantLinesGroup.remove();
- that._axesGroup.remove();
- that._gridGroup.remove();
- that._labelAxesGroup.remove();
- that._labelsGroup.remove();
- that._crosshairCursorGroup.remove();
- if (!drawOptions || drawOptions.drawLegend)
- that._legendGroup.remove().clear();
- if (!drawOptions || drawOptions.drawTitle)
- that._titleGroup.remove().clear();
- that._stripsGroup.clear();
- that._constantLinesGroup.clear();
- that._axesGroup.clear();
- that._gridGroup.clear();
- that._labelAxesGroup.clear();
- that._labelsGroup.clear();
- that._crosshairCursorGroup.clear()
- },
- _drawTitle: function() {
- var that = this,
- options = that._themeManager.getOptions("title"),
- width = that._canvas.width - that._canvas.left - that._canvas.right;
- options._incidentOccured = that._incidentOccured;
- if (that.chartTitle)
- that.chartTitle.update(options, width);
- else
- that.chartTitle = charts.factory.createTitle(that._renderer, options, that._titleGroup)
- },
- _createLegend: function() {
- var legendSettings = getLegendSettings(this._legendDataField);
- this.legend = core.CoreFactory.createLegend({
- renderer: this._renderer,
- group: this._legendGroup,
- backgroundClass: 'dxc-border',
- itemGroupClass: 'dxc-item',
- textField: legendSettings.textField,
- getFormatObject: legendSettings.getFormatObject
- })
- },
- _updateLegend: function() {
- var that = this,
- themeManager = that._themeManager,
- legendOptions = themeManager.getOptions('legend'),
- legendData = that._getLegendData();
- legendOptions.containerBackgroundColor = themeManager.getOptions("containerBackgroundColor");
- legendOptions._incidentOccured = that._incidentOccured;
- that.legend.update(legendData, legendOptions)
- },
- _prepareDrawOptions: function(drawOptions) {
- var animationOptions = this._getAnimationOptions(),
- options;
- options = $.extend({}, {
- force: false,
- adjustAxes: true,
- drawLegend: true,
- drawTitle: true,
- adjustSeriesLabels: true,
- animate: animationOptions.enabled,
- animationPointsLimit: animationOptions.maxPointCountSupported,
- asyncSeriesRendering: animationOptions.asyncSeriesRendering,
- updateTracker: true
- }, drawOptions, this.__renderOptions);
- if (!_isDefined(options.recreateCanvas))
- options.recreateCanvas = options.adjustAxes && options.drawLegend && options.drawTitle;
- return options
- },
- _processRefreshData: function(newRefreshAction) {
- var currentRefreshActionPosition = $.inArray(this._currentRefreshData, ACTIONS_BY_PRIORITY),
- newRefreshActionPosition = $.inArray(newRefreshAction, ACTIONS_BY_PRIORITY);
- if (!this._currentRefreshData || currentRefreshActionPosition >= 0 && newRefreshActionPosition < currentRefreshActionPosition)
- this._currentRefreshData = newRefreshAction
- },
- _getLegendData: function() {
- var that = this;
- return _map(this._getLegendTargets(), function(item) {
- var style = item.getLegendStyles(),
- textOpacity,
- opacity = style.normal.opacity;
- if (!item.isVisible()) {
- if (!_isDefined(opacity) || opacity > DEFAULT_OPACITY)
- opacity = DEFAULT_OPACITY;
- textOpacity = DEFAULT_OPACITY
- }
- return {
- text: item[that._legendItemTextField],
- id: item.index,
- textOpacity: textOpacity,
- states: {
- hover: style.hover,
- selection: style.selection,
- normal: _extend({}, style.normal, {opacity: opacity})
- }
- }
- })
- },
- _seriesVisibilityChanged: function() {
- this._specialProcessSeries();
- this._populateBusinessRange();
- this._renderer.stopAllAnimations(true);
- this._updateLegend();
- this._render({
- force: true,
- asyncSeriesRendering: false,
- updateTracker: false
- })
- },
- _disposeSeries: function() {
- var that = this;
- $.each(that.series || [], function(_, series) {
- series.dispose()
- });
- that.series = null;
- $.each(that.seriesFamilies || [], function(_, family) {
- family.dispose()
- });
- that.seriesFamilies = null;
- that._needHandleRenderComplete = true
- },
- _optionChanged: function(args) {
- var that = this,
- themeManager = that._themeManager,
- name = args.name;
- themeManager.resetOptions(name);
- themeManager.update(that._options);
- that._scheduleLoadingIndicatorHiding();
- if (name === 'animation') {
- that._renderer.updateAnimationOptions(that._getAnimationOptions());
- return
- }
- switch (name) {
- case'size':
- case'margin':
- that._invalidate();
- break;
- case'dataSource':
- that._needHandleRenderComplete = true;
- that._processRefreshData('_reinitDataSource');
- break;
- case'palette':
- themeManager.updatePalette(that.option(name));
- that._refreshSeries('_dataInit');
- break;
- case'series':
- case'commonSeriesSettings':
- case'containerBackgroundColor':
- case'dataPrepareSettings':
- that._refreshSeries('_dataInit');
- break;
- case'legend':
- case'seriesTemplate':
- that._processRefreshData('_dataInit');
- break;
- case'title':
- that._processRefreshData('force_render');
- break;
- case'valueAxis':
- case'argumentAxis':
- case'commonAxisSettings':
- case'panes':
- case'defaultPane':
- that._refreshSeries('reinit');
- that.paneAxis = {};
- break;
- case'rotated':
- that._createScrollBar();
- that._refreshSeries('reinit');
- break;
- case'customizePoint':
- case'customizeLabel':
- that._refreshSeries('reinit');
- break;
- case'scrollBar':
- that._createScrollBar();
- that._processRefreshData('force_render');
- break;
- case'tooltip':
- that._organizeStackPoints();
- break;
- default:
- that._processRefreshData('reinit')
- }
- that.callBase.apply(that, arguments)
- },
- _handleThemeOptionsCore: function() {
- var that = this;
- if (that._initialized) {
- that._scheduleLoadingIndicatorHiding();
- that._refreshSeries('reinit');
- that.beginUpdate();
- that._invalidate();
- that.endUpdate()
- }
- },
- _refreshSeries: function(actionName) {
- this._disposeSeries();
- this._processRefreshData(actionName)
- },
- _refresh: function() {
- var that = this;
- that._renderer.stopAllAnimations(true);
- if (that._currentRefreshData) {
- switch (that._currentRefreshData) {
- case'force_render':
- that._render({force: true});
- break;
- case'reinit':
- that._reinit(true);
- break;
- default:
- that[that._currentRefreshData] && that[that._currentRefreshData]()
- }
- delete that._currentRefreshData
- }
- else
- that._render({force: true})
- },
- _dataSourceOptions: function() {
- return {paginate: false}
- },
- _updateCanvasClipRect: function(canvas) {
- var that = this,
- width,
- height;
- canvas = canvas || that._canvas;
- width = Math.max(canvas.width - canvas.left - canvas.right, 0);
- height = Math.max(canvas.height - canvas.top - canvas.bottom, 0);
- that._canvasClipRect.attr({
- x: canvas.left,
- y: canvas.top,
- width: width,
- height: height
- });
- that._backgroundRect.attr({
- x: canvas.left,
- y: canvas.top,
- width: width,
- height: height
- }).append(that._renderer.root).toBackground()
- },
- _getCanvasClipRectID: function() {
- return this._canvasClipRect.id
- },
- _dataSourceChangedHandler: function() {
- this._resetZoom();
- this._scheduleLoadingIndicatorHiding();
- this._dataInit()
- },
- _dataInit: function() {
- clearTimeout(this._delayedRedraw);
- this._dataSpecificInit(true)
- },
- _dataSpecificInit: function(needRedraw) {
- this.series = this.series || this._populateSeries();
- this._repopulateSeries();
- this._seriesPopulatedHandler(needRedraw)
- },
- _seriesPopulatedHandler: function(needRedraw) {
- var that = this;
- that._seriesPopulatedHandlerCore();
- that._populateBusinessRange();
- that._updateLegend();
- needRedraw && that._endLoading(function() {
- that._render({force: true})
- })
- },
- _repopulateSeries: function() {
- var that = this,
- parsedData,
- themeManager = that._themeManager,
- data = that._dataSource && that._dataSource.items(),
- dataValidatorOptions = themeManager.getOptions('dataPrepareSettings'),
- seriesTemplate = themeManager.getOptions('seriesTemplate');
- if (that._dataSource && seriesTemplate) {
- that._templatedSeries = utils.processSeriesTemplate(seriesTemplate, that._dataSource.items());
- that._populateSeries();
- delete that._templatedSeries;
- data = that.teamplateData || data
- }
- that._groupSeries();
- that._dataValidator = DX.viz.core.CoreFactory.createDataValidator(data, that._groupedSeries, that._incidentOccured, dataValidatorOptions);
- parsedData = that._dataValidator.validate();
- themeManager.resetPalette();
- $.each(that.series, function(_, singleSeries) {
- singleSeries.updateData(parsedData);
- that._processSingleSeries(singleSeries)
- });
- that._organizeStackPoints()
- },
- _organizeStackPoints: function() {
- var that = this,
- themeManager = that._themeManager,
- sharedTooltip = themeManager.getOptions("tooltip").shared,
- stackPoints = {};
- $.each(that.series || [], function(_, singleSeries) {
- that._resetStackPoints(singleSeries);
- sharedTooltip && that._prepareStackPoints(singleSeries, stackPoints, true)
- })
- },
- _renderCompleteHandler: function() {
- var that = this,
- allSeriesInited = true;
- if (that._needHandleRenderComplete) {
- $.each(that.series, function(_, s) {
- allSeriesInited = allSeriesInited && s.canRenderCompleteHandle()
- });
- if (allSeriesInited) {
- that._needHandleRenderComplete = false;
- that._eventTrigger("done", {target: that})
- }
- }
- },
- _renderTitleAndLegend: function(drawOptions, legendHasInsidePosition) {
- var that = this,
- titleOptions = that._themeManager.getOptions("title"),
- drawTitle = titleOptions.text && drawOptions.drawTitle,
- drawLegend = drawOptions.drawLegend && that.legend && !legendHasInsidePosition,
- drawElements = [];
- if (drawTitle) {
- that._titleGroup.append(that._renderer.root);
- that._drawTitle();
- drawElements.push(that.chartTitle)
- }
- if (drawLegend) {
- that._legendGroup.append(that._renderer.root);
- drawElements.push(that.legend)
- }
- drawElements.length && that.layoutManager.drawElements(drawElements, that._canvas);
- if (drawTitle)
- that.layoutManager.correctSizeElement(that.chartTitle, that._canvas)
- },
- _prepareStackPoints: $.noop,
- _resetStackPoints: $.noop,
- _resetZoom: $.noop,
- _dataIsReady: function() {
- return this._isDataSourceReady()
- },
- getAllSeries: function getAllSeries() {
- return this.series.slice()
- },
- getSeriesByName: function getSeriesByName(name) {
- var found = null;
- $.each(this.series, function(i, singleSeries) {
- if (singleSeries.name === name) {
- found = singleSeries;
- return false
- }
- });
- return found
- },
- getSeriesByPos: function getSeriesByPos(pos) {
- return this.series[pos]
- },
- clearSelection: function clearSelection() {
- this.tracker.clearSelection()
- },
- hideTooltip: function() {
- this.tracker._hideTooltip()
- },
- render: function(renderOptions) {
- var that = this;
- that.__renderOptions = renderOptions;
- that.__forceRender = renderOptions && renderOptions.force;
- that.callBase.apply(that, arguments);
- that.__renderOptions = that.__forceRender = null;
- return that
- },
- getSize: function() {
- var canvas = this._canvas || {};
- return {
- width: canvas.width,
- height: canvas.height
- }
- }
- }).include(ui.DataHelperMixin)
- })(jQuery, DevExpress);
- /*! Module viz-charts, file advancedChart.js */
- (function($, DX, undefined) {
- var charts = DX.viz.charts,
- utils = DX.utils,
- core = DX.viz.core,
- DEFAULT_AXIS_NAME = "defaultAxisName",
- _isArray = utils.isArray,
- _isDefined = utils.isDefined,
- _each = $.each,
- _extend = $.extend,
- _map = $.map,
- MIN = 'min',
- MAX = 'max';
- function prepareAxis(axisOptions) {
- return _isArray(axisOptions) ? axisOptions.length === 0 ? [{}] : axisOptions : [axisOptions]
- }
- function unique(array) {
- var values = {},
- i,
- len = array.length;
- for (i = 0; i < len; i++)
- values[array[i]] = true;
- return _map(values, function(_, key) {
- return key
- })
- }
- function prepareVisibleArea(visibleArea, axisRange, useAggregation, aggregationRange) {
- visibleArea.minVal = axisRange.min;
- visibleArea.maxVal = axisRange.max;
- if (useAggregation && !visibleArea.adjustOnZoom) {
- visibleArea.minVal = _isDefined(visibleArea.minVal) ? visibleArea.minVal : aggregationRange.val.min;
- visibleArea.maxVal = _isDefined(visibleArea.maxVal) ? visibleArea.maxVal : aggregationRange.val.max
- }
- }
- function setTemplateFields(data, templateData, series) {
- _each(data, function(_, data) {
- _each(series.getTeamplatedFields(), function(_, field) {
- data[field.teamplateField] = data[field.originalField]
- });
- templateData.push(data)
- });
- series.updateTeamplateFieldNames()
- }
- charts.AdvancedChart = charts.BaseChart.inherit({
- _dispose: function() {
- var that = this,
- disposeObjectsInArray = this._disposeObjectsInArray;
- that.callBase();
- that.panes = null;
- if (that.legend) {
- that.legend.dispose();
- that.legend = null
- }
- disposeObjectsInArray.call(that, "panesBackground");
- disposeObjectsInArray.call(that, "seriesFamilies");
- that._disposeAxes()
- },
- _reinitAxes: function() {
- this.translators = {};
- this.panes = this._createPanes();
- this._populateAxes()
- },
- _populateSeries: function() {
- var that = this,
- themeManager = that._themeManager,
- hasSeriesTemplate = !!themeManager.getOptions("seriesTemplate"),
- series = hasSeriesTemplate ? that._templatedSeries : that.option("series"),
- allSeriesOptions = _isArray(series) ? series : series ? [series] : [],
- data,
- extraOptions = that._getExtraOptions(),
- particularSeriesOptions,
- particularSeries,
- rotated = that._isRotated(),
- i;
- that.teamplateData = [];
- that._disposeSeries();
- that.series = [];
- themeManager.resetPalette();
- for (i = 0; i < allSeriesOptions.length; i++) {
- particularSeriesOptions = _extend(true, {}, allSeriesOptions[i], extraOptions);
- data = particularSeriesOptions.data;
- particularSeriesOptions.data = null;
- particularSeriesOptions.rotated = rotated;
- particularSeriesOptions.customizePoint = themeManager.getOptions("customizePoint");
- particularSeriesOptions.customizeLabel = themeManager.getOptions("customizeLabel");
- particularSeriesOptions.visibilityChanged = $.proxy(that._seriesVisibilityChanged, that);
- particularSeriesOptions.resolveLabelsOverlapping = themeManager.getOptions("resolveLabelsOverlapping");
- particularSeriesOptions.incidentOccured = that._incidentOccured;
- if (!particularSeriesOptions.name)
- particularSeriesOptions.name = "Series " + (i + 1).toString();
- var seriesTheme = themeManager.getOptions("series", particularSeriesOptions);
- if (!that._checkPaneName(seriesTheme))
- continue;
- particularSeries = core.CoreFactory.createSeries({
- renderer: that._renderer,
- seriesGroup: that._seriesGroup,
- labelsGroup: that._labelsGroup
- }, seriesTheme);
- if (!particularSeries.isUpdated)
- that._incidentOccured("E2101", [seriesTheme.type]);
- else {
- particularSeries.index = that.series.length;
- that.series.push(particularSeries);
- if (hasSeriesTemplate)
- setTemplateFields(data, that.teamplateData, particularSeries)
- }
- }
- return that.series
- },
- _populateAxes: function() {
- var that = this,
- valueAxes = [],
- argumentAxes,
- panes = that.panes,
- rotated = that._isRotated(),
- valueAxisOptions = that.option("valueAxis") || {},
- argumentOption = that.option("argumentAxis") || {},
- argumentAxesOptions = prepareAxis(argumentOption)[0],
- valueAxesOptions = prepareAxis(valueAxisOptions),
- axisNames = [],
- valueAxesCounter = 0,
- paneWithNonVirtualAxis,
- crosshairOptions = that._getOption("crosshair") || {},
- crosshairEnabled = crosshairOptions.enabled,
- horCrosshairEnabled = crosshairEnabled && crosshairOptions.horizontalLine.visible,
- verCrosshairEnabled = crosshairEnabled && crosshairOptions.verticalLine.visible;
- function getNextAxisName() {
- return DEFAULT_AXIS_NAME + valueAxesCounter++
- }
- that._disposeAxes();
- if (rotated)
- paneWithNonVirtualAxis = argumentAxesOptions.position === "right" ? panes[panes.length - 1].name : panes[0].name;
- else
- paneWithNonVirtualAxis = argumentAxesOptions.position === "top" ? panes[0].name : panes[panes.length - 1].name;
- argumentAxes = _map(panes, function(pane) {
- return that._createAxis("argumentAxis", argumentAxesOptions, {
- virtual: pane.name !== paneWithNonVirtualAxis,
- pane: pane.name,
- crosshairEnabled: rotated ? horCrosshairEnabled : verCrosshairEnabled
- }, rotated)
- });
- _each(valueAxesOptions, function(priority, axisOptions) {
- var axisPanes = [],
- name = axisOptions.name;
- if (name && $.inArray(name, axisNames) !== -1) {
- that._incidentOccured("E2102");
- return
- }
- name && axisNames.push(name);
- if (axisOptions.pane)
- axisPanes.push(axisOptions.pane);
- if (axisOptions.panes && axisOptions.panes.length)
- axisPanes = axisPanes.concat(axisOptions.panes.slice(0));
- axisPanes = unique(axisPanes);
- if (!axisPanes.length)
- axisPanes.push(undefined);
- _each(axisPanes, function(_, pane) {
- valueAxes.push(that._createAxis("valueAxis", axisOptions, {
- name: name || getNextAxisName(),
- pane: pane,
- priority: priority,
- crosshairEnabled: rotated ? verCrosshairEnabled : horCrosshairEnabled
- }, rotated))
- })
- });
- that._valueAxes = valueAxes;
- that._argumentAxes = argumentAxes
- },
- _prepareStackPoints: function(singleSeries, stackPoints, isSharedTooltip) {
- var points = singleSeries.getPoints(),
- stackName = singleSeries.getStackName();
- _each(points, function(_, point) {
- var argument = point.argument;
- if (!stackPoints[argument]) {
- stackPoints[argument] = {};
- stackPoints[argument][null] = []
- }
- if (stackName && !_isArray(stackPoints[argument][stackName])) {
- stackPoints[argument][stackName] = [];
- _each(stackPoints[argument][null], function(_, point) {
- if (!point.stackName)
- stackPoints[argument][stackName].push(point)
- })
- }
- if (stackName) {
- stackPoints[argument][stackName].push(point);
- stackPoints[argument][null].push(point)
- }
- else
- _each(stackPoints[argument], function(_, stack) {
- stack.push(point)
- });
- if (isSharedTooltip) {
- point.stackPoints = stackPoints[argument][stackName];
- point.stackName = stackName
- }
- })
- },
- _resetStackPoints: function(singleSeries) {
- _each(singleSeries.getPoints(), function(_, point) {
- point.stackPoints = null;
- point.stackName = null
- })
- },
- _disposeAxes: function() {
- var disposeObjectsInArray = this._disposeObjectsInArray;
- disposeObjectsInArray.call(this, "_argumentAxes");
- disposeObjectsInArray.call(this, "_valueAxes")
- },
- _drawAxes: function(panesBorderOptions, drawOptions, adjustUnits) {
- var that = this,
- drawAxes = function(axes) {
- _each(axes, function(_, axis) {
- axis.draw(adjustUnits)
- })
- },
- drawStaticAxisElements = function(axes) {
- _each(axes, function(_i, axis) {
- axis.drawGrids(panesBorderOptions[axis.pane])
- })
- };
- that._reinitTranslators();
- that._prepareAxesAndDraw(drawAxes, drawStaticAxisElements, drawOptions)
- },
- _appendAdditionalSeriesGroups: function() {
- var that = this,
- root = that._renderer.root;
- that._crosshairCursorGroup.append(root);
- that._legendGroup.append(root);
- that._scrollBar && that._scrollBarGroup.append(root)
- },
- _getLegendTargets: function() {
- return _map(this.series, function(item) {
- if (item.getOptions().showInLegend)
- return item
- })
- },
- _legendItemTextField: "name",
- _seriesPopulatedHandlerCore: function() {
- this._processSeriesFamilies();
- this._processValueAxisFormat()
- },
- _renderTrackers: function() {
- var that = this,
- i;
- for (i = 0; i < that.series.length; ++i)
- that.series[i].drawTrackers()
- },
- _specialProcessSeries: function() {
- this._processSeriesFamilies()
- },
- _processSeriesFamilies: function() {
- var that = this,
- types = [],
- families = [],
- paneSeries,
- themeManager = that._themeManager,
- familyOptions = {
- equalBarWidth: that._getEqualBarWidth(),
- minBubbleSize: themeManager.getOptions("minBubbleSize"),
- maxBubbleSize: themeManager.getOptions("maxBubbleSize")
- };
- if (that.seriesFamilies && that.seriesFamilies.length) {
- _each(that.seriesFamilies, function(_, family) {
- family.updateOptions(familyOptions);
- family.adjustSeriesValues()
- });
- return
- }
- _each(that.series, function(_, item) {
- if ($.inArray(item.type, types) === -1)
- types.push(item.type)
- });
- _each(that._getLayoutTargets(), function(_, pane) {
- paneSeries = that._getSeriesForPane(pane.name);
- _each(types, function(_, type) {
- var family = core.CoreFactory.createSeriesFamily({
- type: type,
- pane: pane.name,
- equalBarWidth: familyOptions.equalBarWidth,
- minBubbleSize: familyOptions.minBubbleSize,
- maxBubbleSize: familyOptions.maxBubbleSize
- });
- family.add(paneSeries);
- family.adjustSeriesValues();
- families.push(family)
- })
- });
- that.seriesFamilies = families
- },
- _appendAxesGroups: function() {
- var that = this,
- root = that._renderer.root;
- that._stripsGroup.append(root);
- that._gridGroup.append(root);
- that._axesGroup.append(root);
- that._constantLinesGroup.append(root);
- that._labelAxesGroup.append(root)
- },
- _updateAxesLayout: function(drawOptions, panesBorderOptions, rotated) {
- this.layoutManager.updatePanesCanvases(this._getLayoutTargets(), this._canvas, rotated);
- this._drawAxes(panesBorderOptions, drawOptions, true)
- },
- _populateBusinessRange: function(visibleArea) {
- var that = this,
- businessRanges = [],
- themeManager = that._themeManager,
- rotated = that._isRotated(),
- useAggregation = themeManager.getOptions('useAggregation'),
- argAxes = that._argumentAxes,
- lastArgAxis = argAxes[argAxes.length - 1],
- calcInterval = lastArgAxis.calcInterval,
- argRange = new core.Range({rotated: !!rotated}),
- argBusinessRange;
- that._disposeObjectsInArray("businessRanges", ["arg", "val"]);
- _each(argAxes, function(_, axis) {
- argRange.addRange(axis.getRangeData())
- });
- _each(that._groupedSeries, function(_, group) {
- var groupRange = new core.Range({
- rotated: !!rotated,
- isValueRange: true,
- pane: group.valueAxis.pane,
- axis: group.valueAxis.name
- }),
- groupAxisRange = group.valueAxis.getRangeData();
- groupRange.addRange(groupAxisRange);
- _each(group, function(_, series) {
- visibleArea && prepareVisibleArea(visibleArea, groupAxisRange, useAggregation, series._originalBusinessRange);
- var seriesRange = series.getRangeData(visibleArea, calcInterval);
- groupRange.addRange(seriesRange.val);
- argRange.addRange(seriesRange.arg)
- });
- if (!groupRange.isDefined())
- groupRange.setStubData(group.valueAxis.getOptions().valueType === 'datetime' ? 'datetime' : undefined);
- if (group.valueAxis.getOptions().showZero)
- groupRange.correctValueZeroLevel();
- groupRange.checkZeroStick();
- businessRanges.push({
- val: groupRange,
- arg: argRange
- })
- });
- if (!argRange.isDefined())
- argRange.setStubData(argAxes[0].getOptions().argumentType);
- if (visibleArea && visibleArea.notApplyMargins && argRange.axisType !== "discrete") {
- argBusinessRange = argAxes[0].getTranslator().getBusinessRange();
- argRange.addRange({
- min: argBusinessRange.min,
- max: argBusinessRange.max,
- stick: true
- })
- }
- that._correctBusinessRange(argRange, lastArgAxis);
- that.businessRanges = businessRanges
- },
- _correctBusinessRange: function(range, lastArgAxis) {
- var setTicksAtUnitBeginning = lastArgAxis.getOptions().setTicksAtUnitBeginning,
- tickIntervalRange = {},
- tickInterval = lastArgAxis.getOptions().tickInterval,
- originInterval = tickInterval;
- tickInterval = $.isNumeric(tickInterval) ? tickInterval : utils.dateToMilliseconds(tickInterval);
- if (tickInterval && _isDefined(range[MIN]) && _isDefined(range[MAX]) && tickInterval >= Math.abs(range[MAX] - range[MIN])) {
- if (utils.isDate(range[MIN])) {
- if (!$.isNumeric(originInterval)) {
- tickIntervalRange[MIN] = utils.addInterval(range[MIN], originInterval, true);
- tickIntervalRange[MAX] = utils.addInterval(range[MAX], originInterval, false)
- }
- else {
- tickIntervalRange[MIN] = new Date(range[MIN].valueOf() - tickInterval);
- tickIntervalRange[MAX] = new Date(range[MAX].valueOf() + tickInterval)
- }
- if (setTicksAtUnitBeginning) {
- utils.correctDateWithUnitBeginning(tickIntervalRange[MAX], originInterval);
- utils.correctDateWithUnitBeginning(tickIntervalRange[MIN], originInterval)
- }
- }
- else {
- tickIntervalRange[MIN] = range[MIN] - tickInterval;
- tickIntervalRange[MAX] = range[MAX] + tickInterval
- }
- range.addRange(tickIntervalRange)
- }
- },
- _getArgumentAxes: function() {
- return this._argumentAxes
- },
- _getValueAxes: function() {
- return this._valueAxes
- },
- _processValueAxisFormat: function() {
- var that = this,
- valueAxes = that._valueAxes,
- axesWithFullStackedFormat = [];
- _each(that.series, function() {
- if (this.isFullStackedSeries() && $.inArray(this.axis, axesWithFullStackedFormat) === -1)
- axesWithFullStackedFormat.push(this.axis)
- });
- _each(valueAxes, function() {
- if ($.inArray(this.name, axesWithFullStackedFormat) !== -1)
- this.setPercentLabelFormat();
- else
- this.resetAutoLabelFormat()
- })
- },
- _createAxis: function(typeSelector, userOptions, axisOptions, rotated) {
- var that = this,
- renderingSettings = _extend({
- renderer: that._renderer,
- incidentOccured: that._incidentOccured,
- axisClass: typeSelector === "argumentAxis" ? "arg" : "val",
- stripsGroup: that._stripsGroup,
- labelAxesGroup: that._labelAxesGroup,
- constantLinesGroup: that._constantLinesGroup,
- axesContainerGroup: that._axesGroup,
- gridGroup: that._gridGroup
- }, that._getAxisRenderingOptions(typeSelector, userOptions, rotated)),
- axis;
- userOptions = that._prepareStripsAndConstantLines(typeSelector, userOptions, rotated);
- axis = new charts.axes.Axis(renderingSettings);
- axis.updateOptions(_extend(true, {}, userOptions, axisOptions, that._prepareAxisOptions(typeSelector, userOptions)));
- return axis
- },
- _getTrackerSettings: function() {
- return _extend(this.callBase(), {argumentAxis: this._argumentAxes})
- },
- _prepareStripsAndConstantLines: function(typeSelector, userOptions, rotated) {
- userOptions = this._themeManager.getOptions(typeSelector, userOptions, rotated);
- if (userOptions.strips)
- _each(userOptions.strips, function(i) {
- userOptions.strips[i] = _extend(true, {}, userOptions.stripStyle, userOptions.strips[i])
- });
- if (userOptions.constantLines)
- _each(userOptions.constantLines, function(i, line) {
- userOptions.constantLines[i] = _extend(true, {}, userOptions.constantLineStyle, line)
- });
- return userOptions
- },
- _legendDataField: 'series',
- _adjustSeries: $.noop
- })
- })(jQuery, DevExpress);
- /*! Module viz-charts, file chart.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- charts = viz.charts,
- utils = DX.utils,
- MAX_ADJUSTMENT_ATTEMPTS = 5,
- DEFAULT_PANE_NAME = "default",
- ASYNC_SERIES_RENDERING_DELAY = 25,
- DEFAULT_PANES = [{
- name: DEFAULT_PANE_NAME,
- border: {}
- }],
- _map = $.map,
- _each = $.each,
- _extend = $.extend,
- _isArray = utils.isArray,
- _isDefined = utils.isDefined;
- function getFirstAxisNameForPane(axes, paneName) {
- var result;
- for (var i = 0; i < axes.length; i++)
- if (axes[i].pane === paneName) {
- result = axes[i].name;
- break
- }
- if (!result)
- result = axes[0].name;
- return result
- }
- function hideGridsOnNonFirstValueAxisForPane(valAxes, paneName, synchronizeMultiAxes) {
- var axesForPane = [],
- firstShownAxis;
- _each(valAxes, function(_, axis) {
- if (axis.pane === paneName)
- axesForPane.push(axis)
- });
- if (axesForPane.length > 1 && synchronizeMultiAxes)
- _each(axesForPane, function(_, axis) {
- var gridOpt = axis.getOptions().grid,
- minorGridOpt = axis.getOptions().minorGrid;
- if (firstShownAxis && gridOpt && gridOpt.visible) {
- gridOpt.visible = false;
- minorGridOpt && (minorGridOpt.visible = false)
- }
- else
- firstShownAxis = firstShownAxis ? firstShownAxis : gridOpt && gridOpt.visible
- })
- }
- function getPaneForAxis(paneAxis, axisNameWithoutPane) {
- var result;
- _each(paneAxis, function(paneName, pane) {
- _each(pane, function(axisName) {
- if (axisNameWithoutPane === axisName) {
- result = paneName;
- return false
- }
- })
- });
- return result
- }
- function findAxisOptions(valueAxes, valueAxesOptions, axisName) {
- var result,
- axInd;
- for (axInd = 0; axInd < valueAxesOptions.length; axInd++)
- if (valueAxesOptions[axInd].name === axisName) {
- result = valueAxesOptions[axInd];
- result.priority = axInd;
- break
- }
- if (!result)
- for (axInd = 0; axInd < valueAxes.length; axInd++)
- if (valueAxes[axInd].name === axisName) {
- result = valueAxes[axInd].getOptions();
- result.priority = valueAxes[axInd].priority;
- break
- }
- return result
- }
- function findAxis(paneName, axisName, axes) {
- var axis,
- i;
- for (i = 0; i < axes.length; i++) {
- axis = axes[i];
- if (axis.name === axisName && axis.pane === paneName)
- return axis
- }
- }
- function prepareSegmentRectPoints(left, top, width, height, borderOptions) {
- var maxSW = ~~((width < height ? width : height) / 2),
- sw = borderOptions.width || 0,
- newSW = sw < maxSW ? sw : maxSW;
- left = left + newSW / 2;
- top = top + newSW / 2;
- width = width - newSW;
- height = height - newSW;
- var right = left + width,
- bottom = top + height,
- points = [],
- segments = [],
- segmentSequence,
- visiblyOpt = 0,
- prevSegmentVisibility = 0;
- var allSegment = {
- top: [[left, top], [right, top]],
- right: [[right, top], [right, bottom]],
- bottom: [[right, bottom], [left, bottom]],
- left: [[left, bottom], [left, top]]
- };
- _each(allSegment, function(seg) {
- var visibility = !!borderOptions[seg];
- visiblyOpt = visiblyOpt * 2 + ~~visibility
- });
- switch (visiblyOpt) {
- case 13:
- case 9:
- segmentSequence = ['left', 'top', 'right', 'bottom'];
- break;
- case 11:
- segmentSequence = ['bottom', 'left', 'top', 'right'];
- break;
- default:
- segmentSequence = ['top', 'right', 'bottom', 'left']
- }
- _each(segmentSequence, function(_, seg) {
- var segmentVisibility = !!borderOptions[seg];
- if (!prevSegmentVisibility && segments.length) {
- points.push(segments);
- segments = []
- }
- if (segmentVisibility)
- _each(allSegment[seg].slice(prevSegmentVisibility), function(_, segment) {
- segments = segments.concat(segment)
- });
- prevSegmentVisibility = ~~segmentVisibility
- });
- segments.length && points.push(segments);
- points.length === 1 && (points = points[0]);
- return {
- points: points,
- pathType: visiblyOpt === 15 ? "area" : "line"
- }
- }
- function applyClipSettings(clipRects, settings) {
- _each(clipRects || [], function(_, c) {
- c && c.attr(settings)
- })
- }
- function reinitTranslators(translators) {
- _each(translators, function(_, axisTrans) {
- _each(axisTrans, function(_, translator) {
- translator.arg.reinit();
- translator.val.reinit()
- })
- })
- }
- charts._test_prepareSegmentRectPoints = function() {
- var original = prepareSegmentRectPoints.original || prepareSegmentRectPoints;
- if (arguments[0])
- prepareSegmentRectPoints = arguments[0];
- prepareSegmentRectPoints.original = original;
- prepareSegmentRectPoints.restore = function() {
- prepareSegmentRectPoints = original
- };
- return prepareSegmentRectPoints
- };
- DX.registerComponent("dxChart", viz.charts, charts.AdvancedChart.inherit({
- _chartType: "chart",
- _setDefaultOptions: function() {
- this.callBase();
- this.option({defaultPane: DEFAULT_PANE_NAME})
- },
- _initCore: function() {
- this.__ASYNC_SERIES_RENDERING_DELAY = ASYNC_SERIES_RENDERING_DELAY;
- this.paneAxis = {};
- this._panesClipRects = {};
- this.callBase()
- },
- _disposeCore: function() {
- var that = this,
- disposeObjectsInArray = this._disposeObjectsInArray,
- panesClipRects = that._panesClipRects;
- that.callBase();
- disposeObjectsInArray.call(panesClipRects, "fixed");
- disposeObjectsInArray.call(panesClipRects, "base");
- disposeObjectsInArray.call(panesClipRects, "wide");
- that._panesClipRects = null
- },
- _correctAxes: function() {
- this.series && this._correctValueAxes()
- },
- _getExtraOptions: $.noop,
- _processSingleSeries: $.noop,
- _groupSeries: function() {
- var that = this,
- panes = that.panes,
- valAxes = that._valueAxes,
- paneList = _map(panes, function(pane) {
- return pane.name
- }),
- series = that.series,
- paneAxis = that.paneAxis,
- synchronizeMultiAxes = that._themeManager.getOptions("synchronizeMultiAxes"),
- groupedSeries = that._groupedSeries = [];
- _each(series, function(i, particularSeries) {
- particularSeries.axis = particularSeries.axis || getFirstAxisNameForPane(valAxes, particularSeries.pane);
- if (particularSeries.axis) {
- paneAxis[particularSeries.pane] = paneAxis[particularSeries.pane] || {};
- paneAxis[particularSeries.pane][particularSeries.axis] = true
- }
- });
- _each(valAxes, function(_, axis) {
- if (axis.name && axis.pane && $.inArray(axis.pane, paneList) !== -1) {
- paneAxis[axis.pane] = paneAxis[axis.pane] || {};
- paneAxis[axis.pane][axis.name] = true
- }
- });
- that._correctValueAxes();
- _each(paneAxis, function(paneName, pane) {
- hideGridsOnNonFirstValueAxisForPane(valAxes, paneName, synchronizeMultiAxes);
- _each(pane, function(axisName) {
- var group = [];
- _each(series, function(_, particularSeries) {
- if (particularSeries.pane === paneName && particularSeries.axis === axisName)
- group.push(particularSeries)
- });
- groupedSeries.push(group);
- group.valueAxis = findAxis(paneName, axisName, valAxes);
- group.valueOptions = group.valueAxis.getOptions()
- })
- });
- groupedSeries.argumentAxes = that._argumentAxes;
- groupedSeries.argumentOptions = groupedSeries.argumentAxes[0].getOptions()
- },
- _cleanPanesClipRects: function(clipArrayName) {
- var that = this,
- clipArray = that._panesClipRects[clipArrayName];
- _each(clipArray || [], function(_, clipRect) {
- clipRect && clipRect.dispose()
- });
- that._panesClipRects[clipArrayName] = []
- },
- _createPanes: function() {
- var that = this,
- panes = that.option("panes"),
- panesNameCounter = 0,
- bottomPaneName;
- if (panes && _isArray(panes) && !panes.length || $.isEmptyObject(panes))
- panes = DEFAULT_PANES;
- that._cleanPanesClipRects("fixed");
- that._cleanPanesClipRects("base");
- that._cleanPanesClipRects("wide");
- that.defaultPane = that.option("defaultPane");
- panes = _extend(true, [], _isArray(panes) ? panes : panes ? [panes] : []);
- _each(panes, function(_, pane) {
- pane.name = !_isDefined(pane.name) ? DEFAULT_PANE_NAME + panesNameCounter++ : pane.name
- });
- if (!that._doesPaneExists(panes, that.defaultPane) && panes.length > 0) {
- bottomPaneName = panes[panes.length - 1].name;
- that._incidentOccured("W2101", [that.defaultPane, bottomPaneName]);
- that.defaultPane = bottomPaneName
- }
- panes = that._isRotated() ? panes.reverse() : panes;
- return panes
- },
- _doesPaneExists: function(panes, paneName) {
- var found = false;
- _each(panes, function(_, pane) {
- if (pane.name === paneName) {
- found = true;
- return false
- }
- });
- return found
- },
- _getAxisRenderingOptions: function(typeSelector, axisOptions, rotated) {
- return {
- axesType: "xyAxes",
- drawingType: "linear",
- isHorizontal: typeSelector === "argumentAxis" ? !rotated : rotated
- }
- },
- _prepareAxisOptions: $.noop,
- _checkPaneName: function(seriesTheme) {
- var paneList = _map(this.panes, function(pane) {
- return pane.name
- });
- seriesTheme.pane = seriesTheme.pane || this.defaultPane;
- return $.inArray(seriesTheme.pane, paneList) !== -1
- },
- _correctValueAxes: function() {
- var that = this,
- rotated = that._isRotated(),
- valueAxisOptions = that.option("valueAxis") || {},
- valueAxesOptions = _isArray(valueAxisOptions) ? valueAxisOptions : [valueAxisOptions],
- valueAxes = that._valueAxes || [],
- defaultAxisName = valueAxes[0].name,
- paneAxis = that.paneAxis || {},
- panes = that.panes,
- i,
- neededAxis = {};
- _each(valueAxes, function(_, axis) {
- if (axis.pane)
- return;
- var pane = getPaneForAxis(that.paneAxis, axis.name);
- if (!pane) {
- pane = that.defaultPane;
- paneAxis[pane] = paneAxis[pane] || {};
- paneAxis[pane][axis.name] = true
- }
- axis.setPane(pane)
- });
- for (i = 0; i < panes.length; i++)
- if (!paneAxis[panes[i].name]) {
- paneAxis[panes[i].name] = {};
- paneAxis[panes[i].name][defaultAxisName] = true
- }
- _each(that.paneAxis, function(paneName, axisNames) {
- _each(axisNames, function(axisName) {
- neededAxis[axisName + "-" + paneName] = true;
- if (!findAxis(paneName, axisName, valueAxes)) {
- var axisOptions = findAxisOptions(valueAxes, valueAxesOptions, axisName);
- if (!axisOptions) {
- that._incidentOccured("W2102", [axisName]);
- axisOptions = {
- name: axisName,
- priority: valueAxes.length
- }
- }
- valueAxes.push(that._createAxis("valueAxis", axisOptions, {
- pane: paneName,
- name: axisName
- }, rotated))
- }
- })
- });
- valueAxes = $.grep(valueAxes, function(elem) {
- return !!neededAxis[elem.name + "-" + elem.pane]
- });
- valueAxes.sort(function(a, b) {
- return a.priority - b.priority
- });
- that._valueAxes = valueAxes
- },
- _getSeriesForPane: function(paneName) {
- var paneSeries = [];
- _each(this.series, function(_, oneSeries) {
- if (oneSeries.pane === paneName)
- paneSeries.push(oneSeries)
- });
- return paneSeries
- },
- _createTranslator: function(range, canvas, options) {
- return core.CoreFactory.createTranslator2D(range, canvas, options)
- },
- _createPanesBorderOptions: function() {
- var commonBorderOptions = this._themeManager.getOptions("commonPaneSettings").border,
- panesBorderOptions = {};
- _each(this.panes, function(_, pane) {
- panesBorderOptions[pane.name] = _extend(true, {}, commonBorderOptions, pane.border)
- });
- return panesBorderOptions
- },
- _createScrollBar: function() {
- var that = this,
- scrollBarOptions = that._themeManager.getOptions("scrollBar") || {},
- scrollBarGroup = that._scrollBarGroup;
- if (scrollBarOptions.visible) {
- scrollBarOptions.rotated = that._isRotated();
- that._scrollBar = (that._scrollBar || charts.factory.createScrollBar(that._renderer, scrollBarGroup)).update(scrollBarOptions)
- }
- else {
- scrollBarGroup.remove();
- that._scrollBar && that._scrollBar.dispose();
- that._scrollBar = null
- }
- },
- _prepareToRender: function(drawOptions) {
- var that = this,
- panesBorderOptions = that._createPanesBorderOptions();
- that._createPanesBackground();
- that._appendAxesGroups();
- that._transformed && that._resetTransform();
- that._createTranslators(drawOptions);
- that._options.useAggregation && _each(that.series, function(_, series) {
- series._originalBusinessRange = series._originalBusinessRange || series.getRangeData();
- series.resamplePoints(that._getTranslator(series.pane, series.axis).arg, that._zoomMinArg, that._zoomMaxArg)
- });
- if (_isDefined(that._zoomMinArg) || _isDefined(that._zoomMaxArg))
- that._populateBusinessRange({
- adjustOnZoom: that._themeManager.getOptions("adjustOnZoom"),
- minArg: that._zoomMinArg,
- maxArg: that._zoomMaxArg,
- notApplyMargins: that._notApplyMargins
- });
- if (that._options.useAggregation || _isDefined(that._zoomMinArg) || _isDefined(that._zoomMaxArg))
- that._updateTranslators();
- return panesBorderOptions
- },
- _isLegendInside: function() {
- return this.legend && this.legend.getPosition() === "inside"
- },
- _renderAxes: function(drawOptions, panesBorderOptions, rotated) {
- if (drawOptions && drawOptions.recreateCanvas)
- this.layoutManager.updatePanesCanvases(this.panes, this._canvas, rotated);
- this._drawAxes(panesBorderOptions, drawOptions)
- },
- _isRotated: function() {
- return this._themeManager.getOptions("rotated")
- },
- _getLayoutTargets: function() {
- return this.panes
- },
- _applyClipRects: function(panesBorderOptions) {
- var that = this,
- canvasClipRectID = that._getCanvasClipRectID(),
- i;
- that._drawPanesBorders(panesBorderOptions);
- that._createClipRectsForPanes();
- for (i = 0; i < that._argumentAxes.length; i++)
- that._argumentAxes[i].applyClipRects(that._getElementsClipRectID(that._argumentAxes[i].pane), canvasClipRectID);
- for (i = 0; i < that._valueAxes.length; i++)
- that._valueAxes[i].applyClipRects(that._getElementsClipRectID(that._valueAxes[i].pane), canvasClipRectID);
- that._fillPanesBackground()
- },
- _getSeriesRenderTimeout: function(drawOptions) {
- return drawOptions.asyncSeriesRendering ? ASYNC_SERIES_RENDERING_DELAY : undefined
- },
- _updateLegendPosition: function(drawOptions, legendHasInsidePosition) {
- var that = this;
- if (drawOptions.drawLegend && that.legend && legendHasInsidePosition) {
- var panes = that.panes,
- newCanvas = _extend({}, panes[0].canvas),
- layoutManager = charts.factory.createChartLayoutManager();
- newCanvas.right = panes[panes.length - 1].canvas.right;
- newCanvas.bottom = panes[panes.length - 1].canvas.bottom;
- that._legendGroup.append(that._renderer.root);
- layoutManager.drawElements([that.legend], newCanvas);
- layoutManager.placeDrawnElements(newCanvas)
- }
- },
- _drawSeries: function(drawOptions, rotated) {
- var that = this;
- _each(that.seriesFamilies || [], function(_, seriesFamily) {
- var translators = that._getTranslator(seriesFamily.pane) || {};
- seriesFamily.updateSeriesValues(translators);
- seriesFamily.adjustSeriesDimensions(translators)
- });
- _each(that.series, function(_, particularSeries) {
- that._applyPaneClipRect(particularSeries);
- particularSeries.setAdjustSeriesLabels(drawOptions.adjustSeriesLabels);
- var tr = that._getTranslator(particularSeries.pane, particularSeries.axis),
- translators = {};
- translators[rotated ? "x" : "y"] = tr.val;
- translators[rotated ? "y" : "x"] = tr.arg;
- particularSeries.draw(translators, that._getAnimateOption(particularSeries, drawOptions), drawOptions.hideLayoutLabels, that.legend && that.legend.getActionCallback(particularSeries))
- })
- },
- _applyPaneClipRect: function(seriesOptions) {
- var that = this,
- paneIndex = that._getPaneIndex(seriesOptions.pane),
- panesClipRects = that._panesClipRects,
- wideClipRect = panesClipRects.wide[paneIndex];
- seriesOptions.setClippingParams(panesClipRects.base[paneIndex].id, wideClipRect && wideClipRect.id, that._getPaneBorderVisibility(paneIndex))
- },
- _createTranslators: function(drawOptions) {
- var that = this,
- rotated = that._isRotated(),
- translators;
- if (!drawOptions.recreateCanvas)
- return;
- that.translators = translators = {};
- that.layoutManager.updatePanesCanvases(that.panes, that._canvas, rotated);
- _each(that.paneAxis, function(paneName, pane) {
- translators[paneName] = translators[paneName] || {};
- _each(pane, function(axisName) {
- var translator = that._createTranslator(new core.Range(that._getBusinessRange(paneName, axisName).val), that._getCanvasForPane(paneName), rotated ? {direction: "horizontal"} : {});
- translator.pane = paneName;
- translator.axis = axisName;
- translators[paneName][axisName] = {val: translator}
- })
- });
- _each(that._argumentAxes, function(_, axis) {
- var translator = that._createTranslator(new core.Range(that._getBusinessRange(axis.pane).arg), that._getCanvasForPane(axis.pane), !rotated ? {direction: "horizontal"} : {});
- _each(translators[axis.pane], function(valAxis, paneAxisTran) {
- paneAxisTran.arg = translator
- })
- })
- },
- _updateTranslators: function() {
- var that = this;
- _each(that.translators, function(pane, axisTrans) {
- _each(axisTrans, function(axis, translator) {
- translator.arg.updateBusinessRange(new core.Range(that._getBusinessRange(pane).arg));
- delete translator.arg._originalBusinessRange;
- translator.val.updateBusinessRange(new core.Range(that._getBusinessRange(pane, axis).val));
- delete translator.val._originalBusinessRange
- })
- })
- },
- _getAxesForTransform: function(rotated) {
- return {
- verticalAxes: !rotated ? this._getValueAxes() : this._getArgumentAxes(),
- horizontalAxes: !rotated ? this._getArgumentAxes() : this._getValueAxes()
- }
- },
- _reinitTranslators: function() {
- var that = this;
- _each(that._argumentAxes, function(_, axis) {
- var translator = that._getTranslator(axis.pane);
- if (translator) {
- translator.arg.reinit();
- axis.setTranslator(translator.arg, translator.val)
- }
- });
- _each(that._valueAxes, function(_, axis) {
- var translator = that._getTranslator(axis.pane, axis.name);
- if (translator) {
- translator.val.reinit();
- axis.setTranslator(translator.val, translator.arg)
- }
- })
- },
- _prepareAxesAndDraw: function(drawAxes, drawStaticAxisElements, drawOptions) {
- var that = this,
- i = 0,
- layoutManager = that.layoutManager,
- rotated = that._isRotated(),
- adjustmentCounter = 0,
- synchronizeMultiAxes = that._themeManager.getOptions('synchronizeMultiAxes'),
- layoutTargets = that._getLayoutTargets(),
- verticalAxes = rotated ? that._argumentAxes : that._valueAxes,
- horizontalAxes = rotated ? that._valueAxes : that._argumentAxes,
- hElements = horizontalAxes,
- vElements = verticalAxes;
- if (that._scrollBar) {
- that._scrollBar.setPane(layoutTargets);
- if (rotated)
- vElements = [that._scrollBar].concat(vElements);
- else
- hElements = hElements.concat([that._scrollBar])
- }
- do {
- for (i = 0; i < that._argumentAxes.length; i++)
- that._argumentAxes[i].resetTicks();
- for (i = 0; i < that._valueAxes.length; i++)
- that._valueAxes[i].resetTicks();
- if (synchronizeMultiAxes)
- charts.multiAxesSynchronizer.synchronize(that._valueAxes);
- drawAxes(horizontalAxes);
- layoutManager.requireAxesRedraw = false;
- if (drawOptions.adjustAxes) {
- layoutManager.applyHorizontalAxesLayout(hElements, layoutTargets, rotated);
- !layoutManager.stopDrawAxes && reinitTranslators(that.translators)
- }
- drawAxes(verticalAxes);
- if (drawOptions.adjustAxes && !layoutManager.stopDrawAxes) {
- layoutManager.applyVerticalAxesLayout(vElements, layoutTargets, rotated);
- !layoutManager.stopDrawAxes && reinitTranslators(that.translators)
- }
- adjustmentCounter = adjustmentCounter + 1
- } while (!layoutManager.stopDrawAxes && layoutManager.requireAxesRedraw && adjustmentCounter < MAX_ADJUSTMENT_ATTEMPTS);
- drawStaticAxisElements(verticalAxes);
- drawStaticAxisElements(horizontalAxes);
- that._scrollBar && that._scrollBar.applyLayout();
- that.__axisAdjustmentsCount = adjustmentCounter
- },
- _getPanesParameters: function() {
- var that = this,
- panes = that.panes,
- i,
- params = [];
- for (i = 0; i < panes.length; i++)
- if (that._getPaneBorderVisibility(i))
- params.push({
- coords: panes[i].borderCoords,
- clipRect: that._panesClipRects.fixed[i]
- });
- return params
- },
- _createCrosshairCursor: function() {
- var that = this,
- options = that._themeManager.getOptions("crosshair") || {},
- axes = !that._isRotated() ? [that._argumentAxes, that._valueAxes] : [that._valueAxes, that._argumentAxes],
- parameters = {
- canvas: that._getCommonCanvas(),
- panes: that._getPanesParameters(),
- axes: axes
- };
- if (!options || !options.enabled)
- return;
- if (!that._crosshair)
- that._crosshair = charts.factory.createCrosshair(that._renderer, options, parameters, that._crosshairCursorGroup);
- else
- that._crosshair.update(options, parameters);
- that._crosshair.render()
- },
- _getCommonCanvas: function() {
- var i,
- canvas,
- commonCanvas,
- panes = this.panes;
- for (i = 0; i < panes.length; i++) {
- canvas = panes[i].canvas;
- if (!commonCanvas)
- commonCanvas = _extend({}, canvas);
- else {
- commonCanvas.right = canvas.right;
- commonCanvas.bottom = canvas.bottom
- }
- }
- return commonCanvas
- },
- _createPanesBackground: function() {
- var that = this,
- defaultBackgroundColor = that._themeManager.getOptions("commonPaneSettings").backgroundColor,
- backgroundColor,
- renderer = that._renderer,
- rect,
- i,
- rects = [];
- that._panesBackgroundGroup && that._panesBackgroundGroup.clear();
- for (i = 0; i < that.panes.length; i++) {
- backgroundColor = that.panes[i].backgroundColor || defaultBackgroundColor;
- if (!backgroundColor || backgroundColor === "none") {
- rects.push(null);
- continue
- }
- rect = renderer.rect(0, 0, 0, 0).attr({
- fill: backgroundColor,
- "stroke-width": 0
- }).append(that._panesBackgroundGroup);
- rects.push(rect)
- }
- that.panesBackground = rects;
- that._panesBackgroundGroup.append(renderer.root)
- },
- _fillPanesBackground: function() {
- var that = this,
- bc;
- _each(that.panes, function(i, pane) {
- bc = pane.borderCoords;
- if (that.panesBackground[i] !== null)
- that.panesBackground[i].attr({
- x: bc.left,
- y: bc.top,
- width: bc.width,
- height: bc.height
- })
- })
- },
- _calcPaneBorderCoords: function(pane) {
- var canvas = pane.canvas,
- bc = pane.borderCoords = pane.borderCoords || {};
- bc.left = canvas.left;
- bc.top = canvas.top;
- bc.right = canvas.width - canvas.right;
- bc.bottom = canvas.height - canvas.bottom;
- bc.width = Math.max(bc.right - bc.left, 0);
- bc.height = Math.max(bc.bottom - bc.top, 0)
- },
- _drawPanesBorders: function(panesBorderOptions) {
- var that = this,
- rotated = that._isRotated();
- that._panesBorderGroup && that._panesBorderGroup.remove().clear();
- _each(that.panes, function(i, pane) {
- var bc,
- borderOptions = panesBorderOptions[pane.name],
- segmentRectParams,
- attr = {
- fill: "none",
- stroke: borderOptions.color,
- "stroke-opacity": borderOptions.opacity,
- "stroke-width": borderOptions.width,
- dashStyle: borderOptions.dashStyle,
- "stroke-linecap": "square"
- };
- that._calcPaneBorderCoords(pane, rotated);
- if (!borderOptions.visible)
- return;
- bc = pane.borderCoords;
- segmentRectParams = prepareSegmentRectPoints(bc.left, bc.top, bc.width, bc.height, borderOptions);
- that._renderer.path(segmentRectParams.points, segmentRectParams.pathType).attr(attr).append(that._panesBorderGroup)
- });
- that._panesBorderGroup.append(that._renderer.root)
- },
- _createClipRect: function(clipArray, index, left, top, width, height) {
- var that = this,
- clipRect = clipArray[index];
- if (!clipRect) {
- clipRect = that._renderer.clipRect(left, top, width, height);
- clipArray[index] = clipRect
- }
- else
- clipRect.attr({
- x: left,
- y: top,
- width: width,
- height: height
- })
- },
- _createClipRectsForPanes: function() {
- var that = this,
- canvas = that._canvas;
- _each(that.panes, function(i, pane) {
- var needWideClipRect = false,
- bc = pane.borderCoords,
- left = bc.left,
- top = bc.top,
- width = bc.width,
- height = bc.height,
- panesClipRects = that._panesClipRects;
- that._createClipRect(panesClipRects.fixed, i, left, top, width, height);
- that._createClipRect(panesClipRects.base, i, left, top, width, height);
- _each(that.series, function(_, series) {
- if (series.pane === pane.name && (series.isFinancialSeries() || series.areErrorBarsVisible()))
- needWideClipRect = true
- });
- if (needWideClipRect) {
- if (that._isRotated()) {
- top = 0;
- height = canvas.height
- }
- else {
- left = 0;
- width = canvas.width
- }
- that._createClipRect(panesClipRects.wide, i, left, top, width, height)
- }
- else
- panesClipRects.wide.push(null)
- })
- },
- _getPaneIndex: function(paneName) {
- var paneIndex;
- _each(this.panes, function(index, pane) {
- if (pane.name === paneName) {
- paneIndex = index;
- return false
- }
- });
- return paneIndex
- },
- _getPaneBorderVisibility: function(paneIndex) {
- var commonPaneBorderVisible = this._themeManager.getOptions("commonPaneSettings").border.visible,
- pane = this.panes[paneIndex] || {},
- paneBorder = pane.border || {};
- return "visible" in paneBorder ? paneBorder.visible : commonPaneBorderVisible
- },
- _getElementsClipRectID: function(paneName) {
- return this._panesClipRects.fixed[this._getPaneIndex(paneName)].id
- },
- _getTranslator: function(paneName, axisName) {
- var paneTrans = this.translators[paneName],
- foundTranslator = null;
- if (!paneTrans)
- return foundTranslator;
- foundTranslator = paneTrans[axisName];
- if (!foundTranslator)
- _each(paneTrans, function(axis, trans) {
- foundTranslator = trans;
- return false
- });
- return foundTranslator
- },
- _getCanvasForPane: function(paneName) {
- var panes = this.panes,
- panesNumber = panes.length,
- i;
- for (i = 0; i < panesNumber; i++)
- if (panes[i].name === paneName)
- return panes[i].canvas
- },
- _getBusinessRange: function(paneName, axisName) {
- var ranges = this.businessRanges || [],
- rangesNumber = ranges.length,
- foundRange,
- i;
- for (i = 0; i < rangesNumber; i++)
- if (ranges[i].val.pane === paneName && ranges[i].val.axis === axisName) {
- foundRange = ranges[i];
- break
- }
- if (!foundRange)
- for (i = 0; i < rangesNumber; i++)
- if (ranges[i].val.pane === paneName) {
- foundRange = ranges[i];
- break
- }
- return foundRange
- },
- _transformArgument: function(translate, scale) {
- var that = this,
- rotated = that._isRotated(),
- settings,
- clipSettings,
- panesClipRects = that._panesClipRects;
- if (!that._transformed) {
- that._transformed = true;
- that._labelsGroup.remove();
- that._resetIsReady();
- _each(that.series || [], function(i, s) {
- s.applyClip()
- })
- }
- if (rotated) {
- settings = {
- translateY: translate,
- scaleY: scale
- };
- clipSettings = {
- translateY: -translate / scale,
- scaleY: 1 / scale
- }
- }
- else {
- settings = {
- translateX: translate,
- scaleX: scale
- };
- clipSettings = {
- translateX: -translate / scale,
- scaleX: 1 / scale
- }
- }
- applyClipSettings(panesClipRects.base, clipSettings);
- applyClipSettings(panesClipRects.wide, clipSettings);
- that._seriesGroup.attr(settings);
- that._scrollBar && that._scrollBar.transform(-translate, scale)
- },
- _resetTransform: function() {
- var that = this,
- settings = {
- translateX: 0,
- translateY: 0,
- scaleX: null,
- scaleY: null
- },
- panesClipRects = that._panesClipRects;
- applyClipSettings(panesClipRects.base, settings);
- applyClipSettings(panesClipRects.wide, settings);
- that._seriesGroup.attr(settings);
- _each(that.series || [], function(i, s) {
- s.resetClip()
- });
- that._transformed = false
- },
- _getTrackerSettings: function() {
- var that = this,
- themeManager = that._themeManager;
- return _extend(this.callBase(), {
- chart: that,
- zoomingMode: themeManager.getOptions("zoomingMode"),
- scrollingMode: themeManager.getOptions("scrollingMode"),
- rotated: that._isRotated(),
- crosshair: that._crosshair
- })
- },
- _resolveLabelOverlappingStack: function() {
- var that = this,
- stackPoints = {},
- isRotated = that._isRotated(),
- shiftDirection = isRotated ? function(box, length) {
- return {
- x: box.x - length,
- y: box.y
- }
- } : function(box, length) {
- return {
- x: box.x,
- y: box.y - length
- }
- };
- _each(this._getVisibleSeries(), function(_, particularSeries) {
- that._prepareStackPoints(particularSeries, stackPoints)
- });
- _each(stackPoints, function(_, stacks) {
- _each(stacks, function(_, points) {
- charts.overlapping.resolveLabelOverlappingInOneDirection(points, that._getCommonCanvas(), isRotated, shiftDirection)
- })
- })
- },
- _getEqualBarWidth: function() {
- return this._themeManager.getOptions("equalBarWidth")
- },
- zoomArgument: function(min, max, gesturesUsed) {
- var that = this,
- zoomArg;
- if (!_isDefined(min) && !_isDefined(max))
- return;
- zoomArg = that._argumentAxes[0].zoom(min, max, gesturesUsed);
- that._zoomMinArg = zoomArg.min;
- that._zoomMaxArg = zoomArg.max;
- that._notApplyMargins = gesturesUsed;
- that._render({
- force: true,
- drawTitle: false,
- drawLegend: false,
- adjustAxes: false,
- animate: false,
- adjustSeriesLabels: false,
- asyncSeriesRendering: false,
- updateTracker: false
- })
- },
- _resetZoom: function() {
- var that = this;
- that._zoomMinArg = that._zoomMaxArg = undefined;
- that._argumentAxes[0] && that._argumentAxes[0].resetZoom()
- },
- getVisibleArgumentBounds: function() {
- var range = this._argumentAxes[0].getTranslator().getBusinessRange(),
- isDiscrete = range.axisType === "discrete",
- categories = range.categories;
- return {
- minVisible: isDiscrete ? range.minVisible || categories[0] : range.minVisible,
- maxVisible: isDiscrete ? range.maxVisible || categories[categories.length - 1] : range.maxVisible
- }
- }
- }))
- })(jQuery, DevExpress);
- /*! Module viz-charts, file pieChart.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- charts = viz.charts,
- utils = DX.utils,
- _extend = $.extend,
- _noop = $.noop,
- _getVerticallyShiftedAngularCoords = DX.viz.core.utils.getVerticallyShiftedAngularCoords;
- DX.registerComponent("dxPieChart", viz.charts, charts.BaseChart.inherit({
- _chartType: 'pie',
- _reinitAxes: _noop,
- _correctAxes: _noop,
- _layoutManagerOptions: function() {
- var diameter = this._themeManager.getOptions('diameter');
- if (utils.isNumber(diameter)) {
- if (diameter > 1)
- diameter = 1;
- else if (diameter < 0)
- diameter = 0
- }
- else
- diameter = undefined;
- return _extend(true, {}, this.callBase(), {piePercentage: diameter})
- },
- _groupSeries: function() {
- this.series.valueOptions = {valueType: "numeric"};
- this._groupedSeries = [this.series];
- this._groupedSeries.argumentOptions = this.series[0] && this.series[0].getOptions()
- },
- _populateBusinessRange: function() {
- var businessRanges = [],
- series = this.series,
- singleSeries = series[0],
- range = new core.Range,
- singleSeriesRange;
- this._disposeObjectsInArray("businessRanges");
- if (singleSeries) {
- singleSeriesRange = singleSeries.getRangeData();
- range.addRange(singleSeriesRange.val);
- if (!range.isDefined())
- range.setStubData();
- businessRanges.push(range)
- }
- this.businessRanges = businessRanges
- },
- _specialProcessSeries: function() {
- this.series[0].arrangePoints()
- },
- _createTranslator: function(range) {
- return core.CoreFactory.createTranslator1D(range.min, range.max, 360, 0)
- },
- _populateSeries: function() {
- var that = this,
- themeManager = that._themeManager,
- hasSeriesTemplate = !!themeManager.getOptions("seriesTemplate"),
- seriesOptions = hasSeriesTemplate ? that._templatedSeries : that.option("series"),
- allSeriesOptions = $.isArray(seriesOptions) ? seriesOptions : seriesOptions ? [seriesOptions] : [],
- data,
- particularSeriesOptions,
- particularSeries,
- seriesTheme;
- that._disposeSeries();
- that.series = [];
- themeManager.resetPalette();
- if (allSeriesOptions.length) {
- particularSeriesOptions = _extend(true, {}, allSeriesOptions[0]);
- if (particularSeriesOptions.type && !utils.isString(particularSeriesOptions.type))
- particularSeriesOptions.type = "";
- data = particularSeriesOptions.data;
- particularSeriesOptions.data = null;
- particularSeriesOptions.incidentOccured = that._incidentOccured;
- seriesTheme = themeManager.getOptions("series", particularSeriesOptions, true);
- seriesTheme.visibilityChanged = $.proxy(that._seriesVisibilityChanged, that);
- seriesTheme.customizePoint = themeManager.getOptions("customizePoint");
- seriesTheme.customizeLabel = themeManager.getOptions("customizeLabel");
- particularSeries = core.CoreFactory.createSeries({
- renderer: that._renderer,
- seriesGroup: that._seriesGroup,
- labelsGroup: that._labelsGroup
- }, seriesTheme);
- if (!particularSeries.isUpdated)
- that._incidentOccured("E2101", [seriesTheme.type]);
- else {
- that._processSingleSeries(particularSeries);
- that.series.push(particularSeries)
- }
- particularSeriesOptions.data = data
- }
- return that.series
- },
- _processSingleSeries: function(singleSeries) {
- singleSeries.arrangePoints()
- },
- _seriesPopulatedHandlerCore: _noop,
- _getLegendTargets: function() {
- return this.series[0] ? this.series[0].getPoints() : []
- },
- _legendItemTextField: "argument",
- _prepareToRender: _noop,
- _isLegendInside: _noop,
- _renderAxes: _noop,
- _isRotated: _noop,
- _getLayoutTargets: function() {
- return [{canvas: this._canvas}]
- },
- _getAxesForTransform: function() {
- return {
- verticalAxes: [],
- horizontalAxes: []
- }
- },
- _updateAxesLayout: _noop,
- _applyClipRects: _noop,
- _appendAdditionalSeriesGroups: _noop,
- _getSeriesRenderTimeout: _noop,
- _drawSeries: function(drawOptions) {
- var that = this,
- singleSeries = that.getSeries(),
- legend = that.legend,
- getActionCallbackProxy = $.proxy(legend.getActionCallback, legend);
- if (singleSeries) {
- that.layoutManager.applyPieChartSeriesLayout(that._canvas, singleSeries, true);
- singleSeries.canvas = that._canvas;
- singleSeries.resetLabelSetups();
- if (singleSeries.drawLabelsWOPoints(that._createTranslator(that.businessRanges[0], that._canvas)))
- that.layoutManager.applyPieChartSeriesLayout(that._canvas, singleSeries, drawOptions.hideLayoutLabels);
- singleSeries.draw(that._createTranslator(that.businessRanges[0], that._canvas), that._getAnimateOption(singleSeries, drawOptions), drawOptions.hideLayoutLabels, getActionCallbackProxy)
- }
- },
- _adjustSeries: function() {
- var singleSeries = this.getSeries();
- singleSeries && singleSeries.adjustLabels()
- },
- _updateLegendPosition: _noop,
- _renderTrackers: _noop,
- _createScrollBar: _noop,
- _resolveLabelOverlappingShift: function() {
- var series = this.series[0],
- center = series.getCenter(),
- lPoints = [],
- rPoints = [];
- $.each(series.getVisiblePoints(), function(_, point) {
- var angle = utils.normalizeAngle(point.middleAngle);
- (angle <= 90 || angle >= 270 ? rPoints : lPoints).push(point)
- });
- charts.overlapping.resolveLabelOverlappingInOneDirection(lPoints, this._canvas, false, shiftFunction);
- charts.overlapping.resolveLabelOverlappingInOneDirection(rPoints, this._canvas, false, shiftFunction);
- function shiftFunction(box, length) {
- return _getVerticallyShiftedAngularCoords(box, -length, center)
- }
- },
- getSeries: function getSeries() {
- return this.series && this.series[0]
- },
- _legendDataField: 'point'
- }))
- })(jQuery, DevExpress);
- /*! Module viz-charts, file polarChart.js */
- (function($, DX, undefined) {
- var charts = DX.viz.charts,
- core = DX.viz.core,
- DEFAULT_PANE_NAME = 'default';
- var PolarChart = charts.AdvancedChart.inherit({
- _chartType: 'polar',
- _createPanes: function() {
- return [{name: DEFAULT_PANE_NAME}]
- },
- _checkPaneName: function() {
- return true
- },
- _getAxisRenderingOptions: function(typeSelector) {
- var isArgumentAxis = typeSelector === "argumentAxis",
- type = isArgumentAxis ? "circular" : "linear",
- useSpiderWeb = this.option("useSpiderWeb");
- if (useSpiderWeb)
- type += "Spider";
- return {
- axesType: "polarAxes",
- drawingType: type,
- isHorizontal: true
- }
- },
- _prepareAxisOptions: function(typeSelector, axisOptions) {
- return {type: this.option("useSpiderWeb") && typeSelector === "argumentAxis" ? "discrete" : axisOptions.type}
- },
- _getExtraOptions: function() {
- return {spiderWidget: this.option("useSpiderWeb")}
- },
- _correctAxes: $.noop,
- _groupSeries: function() {
- this._groupedSeries = [this.series];
- this._groupedSeries[0].valueAxis = this._valueAxes[0];
- this._groupedSeries[0].valueOptions = this._valueAxes[0].getOptions();
- this._groupedSeries.argumentAxes = this._argumentAxes;
- this._groupedSeries.argumentOptions = this._argumentAxes[0].getOptions()
- },
- _processSingleSeries: $.noop,
- _prepareToRender: function() {
- this._appendAxesGroups();
- return {}
- },
- _isLegendInside: $.noop,
- _renderAxes: function(drawOptions) {
- this._drawAxes({}, drawOptions)
- },
- _reinitTranslators: function() {
- var that = this,
- valueAxes = that._valueAxes,
- argumentAxes = that._argumentAxes,
- translator = that._createTranslator({
- arg: new core.Range(that.businessRanges[0].arg),
- val: new core.Range(that.businessRanges[0].val)
- }),
- argTranslator = translator.getComponent("arg"),
- valTranslator = translator.getComponent("val"),
- i = 0;
- that.translator = translator;
- argumentAxes[0].setTranslator(argTranslator, valTranslator);
- for (i; i < valueAxes.length; i++)
- valueAxes[i].setTranslator(valTranslator, argTranslator)
- },
- _prepareAxesAndDraw: function(drawAxes, drawStaticAxisElements) {
- var that = this,
- valueAxes = that._valueAxes,
- argAxes = that._argumentAxes,
- argumentAxis = argAxes[0];
- that._calcCanvas(argumentAxis.measureLabels());
- that.translator.reinit();
- drawAxes(argAxes);
- $.each(valueAxes, function(_, valAxis) {
- valAxis.setSpiderTicks(argumentAxis.getSpiderTicks())
- });
- drawAxes(valueAxes);
- drawStaticAxisElements(argAxes);
- drawStaticAxisElements(valueAxes)
- },
- _calcCanvas: function(measure) {
- var canvas = this.translator.canvas;
- canvas.left += measure.width;
- canvas.right += measure.width;
- canvas.top += measure.height;
- canvas.bottom += measure.height
- },
- _isRotated: $.noop,
- _getLayoutTargets: function() {
- return [{canvas: this._canvas}]
- },
- _getAxesForTransform: function() {
- var argAxes = this._getArgumentAxes();
- return {
- verticalAxes: argAxes,
- horizontalAxes: argAxes
- }
- },
- _applyClipRects: $.noop,
- _getSeriesRenderTimeout: $.noop,
- _drawSeries: function(drawOptions) {
- var that = this,
- i,
- seriesFamilies = that.seriesFamilies || [],
- series = that.series;
- if (!series.length)
- return;
- for (i = 0; i < seriesFamilies.length; i++) {
- var translators = {};
- translators.val = that.translator;
- translators.arg = that.translator;
- seriesFamilies[i].updateSeriesValues(translators);
- seriesFamilies[i].adjustSeriesDimensions(translators)
- }
- for (i = 0; i < series.length; i++)
- series[i].draw(that.translator, that._getAnimateOption(series[i], drawOptions), drawOptions.hideLayoutLabels, that.legend && that.legend.getActionCallback(series[i]))
- },
- _updateLegendPosition: $.noop,
- _createScrollBar: $.noop,
- _createTranslator: function(br) {
- var themeManager = this._themeManager,
- axisUserOptions = this.option("argumentAxis"),
- axisOptions = themeManager.getOptions("argumentAxis", axisUserOptions) || {};
- return new core.PolarTranslator(br, $.extend(true, {}, this._canvas), {startAngle: axisOptions.startAngle})
- },
- _getSeriesForPane: function() {
- return this.series
- },
- _getEqualBarWidth: function() {
- return !!this._themeManager.getOptions("equalBarWidth")
- }
- });
- DX.registerComponent('dxPolarChart', charts, PolarChart)
- })(jQuery, DevExpress);
- /*! Module viz-charts, file layoutManager.js */
- (function($, DX, undefined) {
- var _isNumber = DX.utils.isNumber,
- _decreaseGaps = DX.viz.core.utils.decreaseGaps,
- _round = Math.round,
- _min = Math.min,
- _max = Math.max,
- _floor = Math.floor,
- _sqrt = Math.sqrt,
- _each = $.each,
- _extend = $.extend;
- function correctElementsPosition(elements, direction, canvas) {
- _each(elements, function(_, element) {
- var options = element.getLayoutOptions(),
- side = options.cutLayoutSide;
- canvas[side] -= options[direction]
- })
- }
- function placeElementAndCutCanvas(elements, canvas) {
- _each(elements, function(_, element) {
- var shiftX,
- shiftY,
- options = element.getLayoutOptions(),
- length = getLength(options.cutLayoutSide);
- if (!options.width)
- return;
- switch (options.horizontalAlignment) {
- case"left":
- shiftX = canvas.left;
- break;
- case"center":
- shiftX = (canvas.width - canvas.left - canvas.right - options.width) / 2 + canvas.left;
- break;
- case"right":
- shiftX = canvas.width - canvas.right - options.width;
- break
- }
- switch (options.verticalAlignment) {
- case"top":
- shiftY = canvas.top;
- break;
- case"bottom":
- shiftY = canvas.height - canvas.bottom - options.height;
- break
- }
- element.shift(_round(shiftX), _round(shiftY));
- canvas[options.cutLayoutSide] += options[length];
- setCanvasValues(canvas)
- })
- }
- function getLength(side) {
- return side === 'left' || side === 'right' ? 'width' : 'height'
- }
- function setCanvasValues(canvas) {
- if (canvas) {
- canvas.originalTop = canvas.top;
- canvas.originalBottom = canvas.bottom;
- canvas.originalLeft = canvas.left;
- canvas.originalRight = canvas.right
- }
- }
- function updateElements(elements, length, otherLength, dirtyCanvas, canvas, needRemoveSpace) {
- _each(elements, function(_, element) {
- var options = element.getLayoutOptions(),
- side = options.cutLayoutSide,
- freeSpaceWidth = dirtyCanvas.width - dirtyCanvas.left - dirtyCanvas.right,
- freeSpaceHeight = dirtyCanvas.height - dirtyCanvas.top - dirtyCanvas.bottom,
- updateObject = {};
- element.setSize({
- width: freeSpaceWidth,
- height: freeSpaceHeight
- });
- updateObject[otherLength] = 0;
- updateObject[length] = needRemoveSpace[length];
- element.changeSize(updateObject);
- canvas[side] -= options[length] - element.getLayoutOptions()[length];
- needRemoveSpace[length] -= options[length] - element.getLayoutOptions()[length]
- })
- }
- function updateAxis(axes, side, needRemoveSpace) {
- if (axes && needRemoveSpace[side] > 0) {
- _each(axes, function(i, axis) {
- var bbox = axis.getBoundingRect();
- axis.updateSize();
- needRemoveSpace[side] -= bbox[side] - axis.getBoundingRect()[side]
- });
- if (needRemoveSpace[side] > 0)
- _each(axes, function(_, axis) {
- axis.updateSize(true)
- })
- }
- }
- function getNearestCoord(firstCoord, secondCoord, pointCenterCoord) {
- var nearestCoord;
- if (pointCenterCoord < firstCoord)
- nearestCoord = firstCoord;
- else if (secondCoord < pointCenterCoord)
- nearestCoord = secondCoord;
- else
- nearestCoord = pointCenterCoord;
- return nearestCoord
- }
- function getLengthFromCenter(x, y, paneCenterX, paneCenterY) {
- return _sqrt((x - paneCenterX) * (x - paneCenterX) + (y - paneCenterY) * (y - paneCenterY))
- }
- function getInnerRadius(series) {
- var innerRadius;
- if (series.type === "pie")
- innerRadius = 0;
- else {
- innerRadius = _isNumber(series.innerRadius) ? Number(series.innerRadius) : 0.5;
- innerRadius = innerRadius < 0.2 ? 0.2 : innerRadius;
- innerRadius = innerRadius > 0.8 ? 0.8 : innerRadius
- }
- return innerRadius
- }
- function isValidBox(box) {
- return !!(box.x || box.y || box.width || box.height)
- }
- function correctDeltaMarginValue(panes, marginSides) {
- var canvas,
- deltaSide,
- requireAxesRedraw = false;
- _each(panes, function(_, pane) {
- canvas = pane.canvas;
- _each(marginSides, function(_, side) {
- deltaSide = "delta" + side;
- canvas[deltaSide] = _max(canvas[deltaSide] - (canvas[side.toLowerCase()] - canvas["original" + side]), 0);
- if (canvas[deltaSide] > 0)
- requireAxesRedraw = true
- })
- });
- return requireAxesRedraw
- }
- function getPane(name, panes) {
- var findPane = panes[0];
- _each(panes, function(_, pane) {
- if (name === pane.name)
- findPane = pane
- });
- return findPane
- }
- function applyFoundExceedings(panes, rotated) {
- var stopDrawAxes = false,
- maxLeft = 0,
- maxRight = 0,
- maxTop = 0,
- maxBottom = 0;
- _each(panes, function(_, pane) {
- maxLeft = _max(maxLeft, pane.canvas.deltaLeft);
- maxRight = _max(maxRight, pane.canvas.deltaRight);
- maxTop = _max(maxTop, pane.canvas.deltaTop);
- maxBottom = _max(maxBottom, pane.canvas.deltaBottom)
- });
- if (rotated)
- _each(panes, function(_, pane) {
- pane.canvas.top += maxTop;
- pane.canvas.bottom += maxBottom;
- pane.canvas.right += pane.canvas.deltaRight;
- pane.canvas.left += pane.canvas.deltaLeft
- });
- else
- _each(panes, function(_, pane) {
- pane.canvas.top += pane.canvas.deltaTop;
- pane.canvas.bottom += pane.canvas.deltaBottom;
- pane.canvas.right += maxRight;
- pane.canvas.left += maxLeft
- });
- _each(panes, function(_, pane) {
- if (pane.canvas.top + pane.canvas.bottom > pane.canvas.height)
- stopDrawAxes = true;
- if (pane.canvas.left + pane.canvas.right > pane.canvas.width)
- stopDrawAxes = true
- });
- return stopDrawAxes
- }
- function LayoutManager(options) {
- this._verticalElements = [];
- this._horizontalElements = [];
- this._options = options
- }
- LayoutManager.prototype = {
- constructor: LayoutManager,
- dispose: function() {
- this._verticalElements = this._horizontalElements = this._options = null
- },
- drawElements: function(elements, canvas) {
- var horizontalElements = [],
- verticalElements = [];
- _each(elements, function(_, element) {
- var options,
- length;
- element.setSize({
- width: canvas.width - canvas.left - canvas.right,
- height: canvas.height - canvas.top - canvas.bottom
- });
- element.draw();
- options = element.getLayoutOptions();
- if (options) {
- length = getLength(options.cutLayoutSide);
- (length === 'width' ? horizontalElements : verticalElements).push(element);
- canvas[options.cutLayoutSide] += options[length];
- setCanvasValues(canvas)
- }
- });
- this._horizontalElements = horizontalElements;
- this._verticalElements = verticalElements;
- return this
- },
- placeDrawnElements: function(canvas) {
- correctElementsPosition(this._horizontalElements, 'width', canvas);
- placeElementAndCutCanvas(this._horizontalElements, canvas);
- correctElementsPosition(this._verticalElements, 'height', canvas);
- placeElementAndCutCanvas(this._verticalElements, canvas);
- return this
- },
- updatePanesCanvases: function(panes, canvas, rotated) {
- var weightSum = 0;
- _each(panes, function(_, pane) {
- pane.weight = pane.weight || 1;
- weightSum += pane.weight
- });
- var distributedSpace = 0,
- padding = panes.padding || 10,
- paneSpace = rotated ? canvas.width - canvas.left - canvas.right : canvas.height - canvas.top - canvas.bottom,
- oneWeight = (paneSpace - padding * (panes.length - 1)) / weightSum,
- startName = rotated ? "left" : "top",
- endName = rotated ? "right" : "bottom";
- _each(panes, function(_, pane) {
- var calcLength = _round(pane.weight * oneWeight);
- pane.canvas = pane.canvas || {};
- _extend(pane.canvas, {
- deltaLeft: 0,
- deltaRight: 0,
- deltaTop: 0,
- deltaBottom: 0
- }, canvas);
- pane.canvas[startName] = canvas[startName] + distributedSpace;
- pane.canvas[endName] = canvas[endName] + (paneSpace - calcLength - distributedSpace);
- distributedSpace = distributedSpace + calcLength + padding;
- setCanvasValues(pane.canvas)
- })
- },
- applyVerticalAxesLayout: function(axes, panes, rotated) {
- this._applyAxesLayout(axes, panes, rotated)
- },
- applyHorizontalAxesLayout: function(axes, panes, rotated) {
- axes.reverse();
- this._applyAxesLayout(axes, panes, rotated);
- axes.reverse()
- },
- _applyAxesLayout: function(axes, panes, rotated) {
- var that = this,
- canvas,
- axisPosition,
- box,
- delta,
- axis,
- axisLength,
- direction,
- directionMultiplier,
- someDirection = [],
- pane,
- i;
- _each(panes, function(_, pane) {
- _extend(pane.canvas, {
- deltaLeft: 0,
- deltaRight: 0,
- deltaTop: 0,
- deltaBottom: 0
- })
- });
- for (i = 0; i < axes.length; i++) {
- axis = axes[i];
- axisPosition = axis.getOptions().position || "left";
- axis.delta = {};
- box = axis.getBoundingRect();
- pane = getPane(axis.pane, panes);
- canvas = pane.canvas;
- if (!isValidBox(box))
- continue;
- direction = "delta" + axisPosition.slice(0, 1).toUpperCase() + axisPosition.slice(1);
- switch (axisPosition) {
- case"right":
- directionMultiplier = 1;
- canvas.deltaLeft += axis.padding ? axis.padding.left : 0;
- break;
- case"left":
- directionMultiplier = -1;
- canvas.deltaRight += axis.padding ? axis.padding.right : 0;
- break;
- case"top":
- directionMultiplier = -1;
- canvas.deltaBottom += axis.padding ? axis.padding.bottom : 0;
- break;
- case"bottom":
- directionMultiplier = 1;
- canvas.deltaTop += axis.padding ? axis.padding.top : 0;
- break
- }
- switch (axisPosition) {
- case"right":
- case"left":
- if (!box.isEmpty) {
- delta = box.y + box.height - (canvas.height - canvas.originalBottom);
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaBottom += delta
- }
- delta = canvas.originalTop - box.y;
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaTop += delta
- }
- }
- axisLength = box.width;
- someDirection = ["Left", "Right"];
- break;
- case"top":
- case"bottom":
- if (!box.isEmpty) {
- delta = box.x + box.width - (canvas.width - canvas.originalRight);
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaRight += delta
- }
- delta = canvas.originalLeft - box.x;
- if (delta > 0) {
- that.requireAxesRedraw = true;
- canvas.deltaLeft += delta
- }
- }
- someDirection = ["Bottom", "Top"];
- axisLength = box.height;
- break
- }
- if (!axis.delta[axisPosition] && canvas[direction] > 0)
- canvas[direction] += axis.getMultipleAxesSpacing();
- axis.delta[axisPosition] = axis.delta[axisPosition] || 0;
- axis.delta[axisPosition] += canvas[direction] * directionMultiplier;
- canvas[direction] += axisLength
- }
- that.requireAxesRedraw = correctDeltaMarginValue(panes, someDirection) || that.requireAxesRedraw;
- that.stopDrawAxes = applyFoundExceedings(panes, rotated)
- },
- applyPieChartSeriesLayout: function(canvas, singleSeries, hideLayoutLabels) {
- var paneSpaceHeight = canvas.height - canvas.top - canvas.bottom,
- paneSpaceWidth = canvas.width - canvas.left - canvas.right,
- paneCenterX = paneSpaceWidth / 2 + canvas.left,
- paneCenterY = paneSpaceHeight / 2 + canvas.top,
- piePercentage = this._options.piePercentage,
- accessibleRadius = _isNumber(piePercentage) ? piePercentage * _min(canvas.height, canvas.width) / 2 : _min(paneSpaceWidth, paneSpaceHeight) / 2,
- minR = 0.7 * accessibleRadius,
- innerRadius = getInnerRadius(singleSeries);
- if (!hideLayoutLabels && !_isNumber(piePercentage))
- _each(singleSeries.getPoints(), function(_, point) {
- if (point._label.isVisible() && point.isVisible()) {
- var labelBBox = point._label.getBoundingRect(),
- nearestX = getNearestCoord(labelBBox.x, labelBBox.x + labelBBox.width, paneCenterX),
- nearestY = getNearestCoord(labelBBox.y, labelBBox.y + labelBBox.height, paneCenterY),
- minRadiusWithLabels = _max(getLengthFromCenter(nearestX, nearestY, paneCenterX, paneCenterY) - DX.viz.core.series.helpers.consts.pieLabelIndent, minR);
- accessibleRadius = _min(accessibleRadius, minRadiusWithLabels)
- }
- });
- singleSeries.correctPosition({
- centerX: _floor(paneCenterX),
- centerY: _floor(paneCenterY),
- radiusInner: _floor(accessibleRadius * innerRadius),
- radiusOuter: _floor(accessibleRadius)
- })
- },
- updateDrawnElements: function(axes, canvas, dirtyCanvas, panes, rotated) {
- var needRemoveSpace,
- saveDirtyCanvas = _extend({}, dirtyCanvas);
- needRemoveSpace = this.needMoreSpaceForPanesCanvas(panes, rotated);
- if (!needRemoveSpace)
- return;
- needRemoveSpace.height = _decreaseGaps(dirtyCanvas, ["top", "bottom"], needRemoveSpace.height);
- needRemoveSpace.width = _decreaseGaps(dirtyCanvas, ["left", "right"], needRemoveSpace.width);
- canvas.top -= saveDirtyCanvas.top - dirtyCanvas.top;
- canvas.bottom -= saveDirtyCanvas.bottom - dirtyCanvas.bottom;
- canvas.left -= saveDirtyCanvas.left - dirtyCanvas.left;
- canvas.right -= saveDirtyCanvas.right - dirtyCanvas.right;
- updateElements(this._horizontalElements, "width", "height", dirtyCanvas, canvas, needRemoveSpace);
- updateElements(this._verticalElements, "height", "width", dirtyCanvas, canvas, needRemoveSpace);
- updateAxis(axes.verticalAxes, "width", needRemoveSpace);
- updateAxis(axes.horizontalAxes, "height", needRemoveSpace)
- },
- needMoreSpaceForPanesCanvas: function(panes, rotated) {
- var options = this._options,
- width = options.width,
- height = options.height,
- piePercentage = options.piePercentage,
- percentageIsValid = _isNumber(piePercentage),
- needHorizontalSpace = 0,
- needVerticalSpace = 0;
- _each(panes, function(_, pane) {
- var paneCanvas = pane.canvas,
- minSize = percentageIsValid ? _min(paneCanvas.width, paneCanvas.height) * piePercentage : undefined,
- needPaneHorizonralSpace = (percentageIsValid ? minSize : width) - (paneCanvas.width - paneCanvas.left - paneCanvas.right),
- needPaneVerticalSpace = (percentageIsValid ? minSize : height) - (paneCanvas.height - paneCanvas.top - paneCanvas.bottom);
- if (rotated) {
- needHorizontalSpace += needPaneHorizonralSpace > 0 ? needPaneHorizonralSpace : 0;
- needVerticalSpace = _max(needPaneVerticalSpace > 0 ? needPaneVerticalSpace : 0, needVerticalSpace)
- }
- else {
- needHorizontalSpace = _max(needPaneHorizonralSpace > 0 ? needPaneHorizonralSpace : 0, needHorizontalSpace);
- needVerticalSpace += needPaneVerticalSpace > 0 ? needPaneVerticalSpace : 0
- }
- });
- return needHorizontalSpace > 0 || needVerticalSpace > 0 ? {
- width: needHorizontalSpace,
- height: needVerticalSpace
- } : false
- },
- correctSizeElement: function(element, canvas) {
- element.setSize({
- width: canvas.width - canvas.right - canvas.left,
- height: canvas.width - canvas.right - canvas.left
- });
- element.changeSize({
- width: 0,
- height: 0
- })
- }
- };
- DX.viz.charts._setCanvasValues = setCanvasValues;
- DX.viz.charts.LayoutManager = LayoutManager
- })(jQuery, DevExpress);
- /*! Module viz-charts, file multiAxesSynchronizer.js */
- (function($, DX, undefined) {
- var Range = DX.viz.core.Range,
- utils = DX.utils,
- _adjustValue = utils.adjustValue,
- _applyPrecisionByMinDelta = utils.applyPrecisionByMinDelta,
- _isDefined = utils.isDefined,
- _math = Math,
- _floor = _math.floor,
- _max = _math.max,
- _each = $.each,
- MIN_RANGE_FOR_ADJUST_BOUNDS = 0.1;
- var getValueAxesPerPanes = function(valueAxes) {
- var result = {};
- _each(valueAxes, function(_, axis) {
- var pane = axis.pane;
- if (!result[pane])
- result[pane] = [];
- result[pane].push(axis)
- });
- return result
- };
- var restoreOriginalBusinessRange = function(axis) {
- var businessRange,
- translator = axis.getTranslator();
- if (!translator._originalBusinessRange)
- translator._originalBusinessRange = new Range(translator.getBusinessRange());
- else {
- businessRange = new Range(translator._originalBusinessRange);
- translator.updateBusinessRange(businessRange)
- }
- };
- var linearConvertor = {
- transform: function(v, b) {
- return utils.getLog(v, b)
- },
- addInterval: function(v, i) {
- return v + i
- },
- getInterval: function(base, tickInterval) {
- return tickInterval
- },
- adjustValue: _floor
- };
- var logConvertor = {
- transform: function(v, b) {
- return utils.raiseTo(v, b)
- },
- addInterval: function(v, i) {
- return v * i
- },
- getInterval: function(base, tickInterval) {
- return _math.pow(base, tickInterval)
- },
- adjustValue: _adjustValue
- };
- var convertAxisInfo = function(axisInfo, convertor) {
- if (!axisInfo.isLogarithmic)
- return;
- var base = axisInfo.logarithmicBase,
- tickValues = axisInfo.tickValues,
- tick,
- ticks = [],
- interval,
- i;
- axisInfo.minValue = convertor.transform(axisInfo.minValue, base);
- axisInfo.oldMinValue = convertor.transform(axisInfo.oldMinValue, base);
- axisInfo.maxValue = convertor.transform(axisInfo.maxValue, base);
- axisInfo.oldMaxValue = convertor.transform(axisInfo.oldMaxValue, base);
- axisInfo.tickInterval = _math.round(axisInfo.tickInterval);
- if (axisInfo.tickInterval < 1)
- axisInfo.tickInterval = 1;
- interval = convertor.getInterval(base, axisInfo.tickInterval);
- tick = convertor.transform(tickValues[0], base);
- for (i = 0; i < tickValues.length; i++) {
- ticks.push(convertor.adjustValue(tick));
- tick = convertor.addInterval(tick, interval)
- }
- ticks.tickInterval = axisInfo.tickInterval;
- axisInfo.tickValues = ticks
- };
- var populateAxesInfo = function(axes) {
- return $.map(axes, function(axis) {
- restoreOriginalBusinessRange(axis);
- var ticksValues = axis.getTicksValues(),
- majorTicks = ticksValues.majorTicksValues,
- options = axis.getOptions(),
- minValue,
- maxValue,
- axisInfo = null,
- businessRange,
- tickInterval,
- synchronizedValue;
- if (majorTicks && majorTicks.length > 0 && utils.isNumber(majorTicks[0]) && options.type !== "discrete") {
- businessRange = axis.getTranslator().getBusinessRange();
- tickInterval = axis._tickManager.getTickInterval();
- minValue = businessRange.minVisible;
- maxValue = businessRange.maxVisible;
- synchronizedValue = options.synchronizedValue;
- if (minValue === maxValue && _isDefined(synchronizedValue)) {
- minValue = majorTicks[0] - 1;
- maxValue = majorTicks[0] + 1;
- tickInterval = 1
- }
- axisInfo = {
- axis: axis,
- isLogarithmic: options.type === "logarithmic",
- logarithmicBase: businessRange.base,
- tickValues: majorTicks,
- minorValues: ticksValues.minorTicksValues,
- minValue: minValue,
- oldMinValue: minValue,
- maxValue: maxValue,
- oldMaxValue: maxValue,
- inverted: businessRange.invert,
- tickInterval: tickInterval,
- synchronizedValue: synchronizedValue
- };
- if (businessRange.stubData) {
- axisInfo.stubData = true;
- axisInfo.tickInterval = axisInfo.tickInterval || options.tickInterval;
- axisInfo.isLogarithmic = false
- }
- convertAxisInfo(axisInfo, linearConvertor);
- DX.utils.debug.assert(axisInfo.tickInterval !== undefined && axisInfo.tickInterval !== null, "tickInterval was not provided")
- }
- return axisInfo
- })
- };
- var updateTickValues = function(axesInfo) {
- var maxTicksCount = 0;
- _each(axesInfo, function(_, axisInfo) {
- maxTicksCount = _max(maxTicksCount, axisInfo.tickValues.length)
- });
- _each(axesInfo, function(_, axisInfo) {
- var ticksMultiplier,
- ticksCount,
- additionalStartTicksCount = 0,
- synchronizedValue = axisInfo.synchronizedValue,
- tickValues = axisInfo.tickValues,
- tickInterval = axisInfo.tickInterval;
- if (_isDefined(synchronizedValue)) {
- axisInfo.baseTickValue = axisInfo.invertedBaseTickValue = synchronizedValue;
- axisInfo.tickValues = [axisInfo.baseTickValue]
- }
- else {
- if (tickValues.length > 1 && tickInterval) {
- ticksMultiplier = _floor((maxTicksCount + 1) / tickValues.length);
- ticksCount = ticksMultiplier > 1 ? _floor((maxTicksCount + 1) / ticksMultiplier) : maxTicksCount;
- additionalStartTicksCount = _floor((ticksCount - tickValues.length) / 2);
- while (additionalStartTicksCount > 0 && tickValues[0] !== 0) {
- tickValues.unshift(_applyPrecisionByMinDelta(tickValues[0], tickInterval, tickValues[0] - tickInterval));
- additionalStartTicksCount--
- }
- while (tickValues.length < ticksCount)
- tickValues.push(_applyPrecisionByMinDelta(tickValues[0], tickInterval, tickValues[tickValues.length - 1] + tickInterval));
- axisInfo.tickInterval = tickInterval / ticksMultiplier
- }
- axisInfo.baseTickValue = tickValues[0];
- axisInfo.invertedBaseTickValue = tickValues[tickValues.length - 1]
- }
- })
- };
- var getAxisRange = function(axisInfo) {
- return axisInfo.maxValue - axisInfo.minValue || 1
- };
- var getMainAxisInfo = function(axesInfo) {
- for (var i = 0; i < axesInfo.length; i++)
- if (!axesInfo[i].stubData)
- return axesInfo[i];
- return null
- };
- var correctMinMaxValues = function(axesInfo) {
- var mainAxisInfo = getMainAxisInfo(axesInfo),
- mainAxisInfoTickInterval = mainAxisInfo.tickInterval;
- _each(axesInfo, function(_, axisInfo) {
- var scale,
- move,
- mainAxisBaseValueOffset,
- valueFromAxisInfo;
- if (axisInfo !== mainAxisInfo) {
- if (mainAxisInfoTickInterval && axisInfo.tickInterval) {
- if (axisInfo.stubData && _isDefined(axisInfo.synchronizedValue)) {
- axisInfo.oldMinValue = axisInfo.minValue = axisInfo.baseTickValue - (mainAxisInfo.baseTickValue - mainAxisInfo.minValue) / mainAxisInfoTickInterval * axisInfo.tickInterval;
- axisInfo.oldMaxValue = axisInfo.maxValue = axisInfo.baseTickValue - (mainAxisInfo.baseTickValue - mainAxisInfo.maxValue) / mainAxisInfoTickInterval * axisInfo.tickInterval
- }
- scale = mainAxisInfoTickInterval / getAxisRange(mainAxisInfo) / axisInfo.tickInterval * getAxisRange(axisInfo);
- axisInfo.maxValue = axisInfo.minValue + getAxisRange(axisInfo) / scale
- }
- if (mainAxisInfo.inverted && !axisInfo.inverted || !mainAxisInfo.inverted && axisInfo.inverted)
- mainAxisBaseValueOffset = mainAxisInfo.maxValue - mainAxisInfo.invertedBaseTickValue;
- else
- mainAxisBaseValueOffset = mainAxisInfo.baseTickValue - mainAxisInfo.minValue;
- valueFromAxisInfo = getAxisRange(axisInfo);
- move = (mainAxisBaseValueOffset / getAxisRange(mainAxisInfo) - (axisInfo.baseTickValue - axisInfo.minValue) / valueFromAxisInfo) * valueFromAxisInfo;
- axisInfo.minValue -= move;
- axisInfo.maxValue -= move
- }
- })
- };
- var calculatePaddings = function(axesInfo) {
- var minPadding,
- maxPadding,
- startPadding = 0,
- endPadding = 0;
- _each(axesInfo, function(_, axisInfo) {
- var inverted = axisInfo.inverted;
- minPadding = axisInfo.minValue > axisInfo.oldMinValue ? (axisInfo.minValue - axisInfo.oldMinValue) / getAxisRange(axisInfo) : 0;
- maxPadding = axisInfo.maxValue < axisInfo.oldMaxValue ? (axisInfo.oldMaxValue - axisInfo.maxValue) / getAxisRange(axisInfo) : 0;
- startPadding = _max(startPadding, inverted ? maxPadding : minPadding);
- endPadding = _max(endPadding, inverted ? minPadding : maxPadding)
- });
- return {
- start: startPadding,
- end: endPadding
- }
- };
- var correctMinMaxValuesByPaddings = function(axesInfo, paddings) {
- _each(axesInfo, function(_, info) {
- var range = getAxisRange(info),
- inverted = info.inverted;
- info.minValue -= paddings[inverted ? "end" : "start"] * range;
- info.maxValue += paddings[inverted ? "start" : "end"] * range;
- if (range > MIN_RANGE_FOR_ADJUST_BOUNDS) {
- info.minValue = _math.min(info.minValue, _adjustValue(info.minValue));
- info.maxValue = _max(info.maxValue, _adjustValue(info.maxValue))
- }
- })
- };
- var updateTickValuesIfSyncronizedValueUsed = function(axesInfo) {
- var hasSyncronizedValue = false;
- _each(axesInfo, function(_, info) {
- hasSyncronizedValue = hasSyncronizedValue || _isDefined(info.synchronizedValue)
- });
- _each(axesInfo, function(_, info) {
- var lastTickValue,
- tickInterval = info.tickInterval,
- tickValues = info.tickValues,
- maxValue = info.maxValue,
- minValue = info.minValue;
- if (hasSyncronizedValue && tickInterval) {
- while (tickValues[0] - tickInterval >= minValue)
- tickValues.unshift(_adjustValue(tickValues[0] - tickInterval));
- lastTickValue = tickValues[tickValues.length - 1];
- while ((lastTickValue = lastTickValue + tickInterval) <= maxValue)
- tickValues.push(utils.isExponential(lastTickValue) ? _adjustValue(lastTickValue) : _applyPrecisionByMinDelta(minValue, tickInterval, lastTickValue))
- }
- while (tickValues[0] < minValue)
- tickValues.shift();
- while (tickValues[tickValues.length - 1] > maxValue)
- tickValues.pop()
- })
- };
- var applyMinMaxValues = function(axesInfo) {
- _each(axesInfo, function(_, info) {
- var axis = info.axis,
- range = axis.getTranslator().getBusinessRange();
- if (range.min === range.minVisible)
- range.min = info.minValue;
- if (range.max === range.maxVisible)
- range.max = info.maxValue;
- range.minVisible = info.minValue;
- range.maxVisible = info.maxValue;
- if (_isDefined(info.stubData))
- range.stubData = info.stubData;
- if (range.min > range.minVisible)
- range.min = range.minVisible;
- if (range.max < range.maxVisible)
- range.max = range.maxVisible;
- range.isSynchronized = true;
- axis.getTranslator().updateBusinessRange(range);
- axis.setTicks({
- majorTicks: info.tickValues,
- minorTicks: info.minorValues
- })
- })
- };
- var correctAfterSynchronize = function(axesInfo) {
- var invalidAxisInfo = [],
- correctValue,
- validAxisInfo;
- _each(axesInfo, function(i, info) {
- if (info.oldMaxValue - info.oldMinValue === 0)
- invalidAxisInfo.push(info);
- else if (!_isDefined(correctValue) && !_isDefined(info.synchronizedValue)) {
- correctValue = _math.abs((info.maxValue - info.minValue) / (info.tickValues[_floor(info.tickValues.length / 2)] || info.maxValue));
- validAxisInfo = info
- }
- });
- if (!_isDefined(correctValue))
- return;
- _each(invalidAxisInfo, function(i, info) {
- var firstTick = info.tickValues[0],
- correctedTick = firstTick * correctValue,
- tickValues = validAxisInfo.tickValues,
- centralTick = tickValues[_floor(tickValues.length / 2)];
- if (firstTick > 0) {
- info.maxValue = correctedTick;
- info.minValue = 0
- }
- else if (firstTick < 0) {
- info.minValue = correctedTick;
- info.maxValue = 0
- }
- else if (firstTick === 0) {
- info.maxValue = validAxisInfo.maxValue - centralTick;
- info.minValue = validAxisInfo.minValue - centralTick
- }
- })
- };
- DX.viz.charts.multiAxesSynchronizer = {synchronize: function(valueAxes) {
- _each(getValueAxesPerPanes(valueAxes), function(_, axes) {
- var axesInfo,
- paddings;
- if (axes.length > 1) {
- axesInfo = populateAxesInfo(axes);
- if (axesInfo.length === 0 || !getMainAxisInfo(axesInfo))
- return;
- updateTickValues(axesInfo);
- correctMinMaxValues(axesInfo);
- paddings = calculatePaddings(axesInfo);
- correctMinMaxValuesByPaddings(axesInfo, paddings);
- correctAfterSynchronize(axesInfo);
- updateTickValuesIfSyncronizedValueUsed(axesInfo);
- _each(axesInfo, function() {
- convertAxisInfo(this, logConvertor)
- });
- applyMinMaxValues(axesInfo)
- }
- })
- }}
- })(jQuery, DevExpress);
- /*! Module viz-charts, file tracker.js */
- (function($, DX, math) {
- var charts = DX.viz.charts,
- eventsConsts = DX.viz.core.series.helpers.consts.events,
- utils = DX.utils,
- isDefined = utils.isDefined,
- _floor = math.floor,
- _each = $.each,
- MULTIPLE_MODE = 'multiple',
- ALL_ARGUMENTS_POINTS_MODE = 'allargumentpoints',
- ALL_SERIES_POINTS_MODE = 'allseriespoints',
- NONE_MODE = 'none',
- POINTER_ACTION = "dxpointerdown dxpointermove",
- POINT_SELECTION_CHANGED = "pointSelectionChanged",
- LEGEND_CLICK = "legendClick",
- SERIES_CLICK = "seriesClick",
- POINT_CLICK = "pointClick",
- RELEASE_POINT_SELECTED_STATE = "releasePointSelectedState",
- SET_POINT_SELECTED_STATE = "setPointSelectedState",
- DELAY = 100;
- function processMode(mode) {
- return (mode + "").toLowerCase()
- }
- function getNonVirtualAxis(axisArray) {
- var axis;
- _each(axisArray, function(_, a) {
- if (!a._virtual) {
- axis = a;
- return false
- }
- });
- return axis
- }
- function eventCanceled(event, target) {
- return event.cancel || !target.getOptions()
- }
- var baseTrackerPrototype = {
- ctor: function(options) {
- var that = this,
- data = {tracker: that};
- if (processMode(options.pointSelectionMode) === MULTIPLE_MODE) {
- that._setSelectedPoint = that._selectPointMultipleMode;
- that._releaseSelectedPoint = that._releaseSelectedPointMultipleMode
- }
- else {
- that._setSelectedPoint = that._selectPointSingleMode;
- that._releaseSelectedPoint = that._releaseSelectedPointSingleMode
- }
- if (processMode(options.seriesSelectionMode) === MULTIPLE_MODE) {
- that._releaseSelectedSeries = that._releaseSelectedSeriesMultipleMode;
- that._setSelectedSeries = that._setSelectedSeriesMultipleMode
- }
- else {
- that._releaseSelectedSeries = that._releaseSelectedSeriesSingleMode;
- that._setSelectedSeries = that._setSelectedSeriesSingleMode
- }
- that._renderer = options.renderer;
- that._tooltip = options.tooltip;
- that._eventTrigger = options.eventTrigger;
- options.seriesGroup.off().on(eventsConsts.selectSeries, data, that._selectSeries).on(eventsConsts.deselectSeries, data, that._deselectSeries).on(eventsConsts.selectPoint, data, that._selectPoint).on(eventsConsts.deselectPoint, data, that._deselectPoint).on(eventsConsts.showPointTooltip, data, that._showPointTooltip).on(eventsConsts.hidePointTooltip, data, that._hidePointTooltip);
- that._renderer.root.off(POINTER_ACTION).off("dxclick dxhold").on(POINTER_ACTION, data, that._pointerHandler).on("dxclick", data, that._clickHandler).on("dxhold", {timeout: 300}, $.noop)
- },
- update: function(options) {
- var that = this;
- if (that._storedSeries !== options.series) {
- that._storedSeries = options.series || [];
- that._clean()
- }
- else {
- that._hideTooltip(that.pointAtShownTooltip);
- that._clearHover();
- that.clearSelection()
- }
- that._legend = options.legend;
- that.legendCallback = options.legendCallback;
- that._prepare(that._renderer.root)
- },
- setCanvases: function(mainCanvas, paneCanvases) {
- this._mainCanvas = mainCanvas;
- this._canvases = paneCanvases
- },
- repairTooltip: function() {
- var point = this.pointAtShownTooltip;
- if (point && !point.isVisible())
- this._hideTooltip(point, true);
- else
- this._showTooltip(point)
- },
- _prepare: function(root) {
- root.off("dxmousewheel").on("dxmousewheel", {tracker: this}, function(e) {
- e.data.tracker._pointerOut()
- })
- },
- _selectPointMultipleMode: function(point) {
- var that = this;
- that._selectedPoint = that._selectedPoint || [];
- if ($.inArray(point, that._selectedPoint) < 0) {
- that._selectedPoint.push(point);
- that._setPointState(point, SET_POINT_SELECTED_STATE, processMode(point.getOptions().selectionMode), POINT_SELECTION_CHANGED, that.legendCallback(point))
- }
- },
- _releaseSelectedPointMultipleMode: function(point) {
- var that = this,
- points = that._selectedPoint || [],
- pointIndex = $.inArray(point, points);
- if (pointIndex >= 0) {
- that._setPointState(point, RELEASE_POINT_SELECTED_STATE, processMode(point.getOptions().selectionMode), POINT_SELECTION_CHANGED, that.legendCallback(point));
- points.splice(pointIndex, 1)
- }
- else if (!point)
- _each(points, function(_, point) {
- that._releaseSelectedPoint(point)
- })
- },
- _selectPointSingleMode: function(point) {
- var that = this;
- if (that._selectedPoint !== point) {
- that._releaseSelectedPoint();
- that._selectedPoint = point;
- that._setPointState(point, SET_POINT_SELECTED_STATE, processMode(point.getOptions().selectionMode), POINT_SELECTION_CHANGED, that.legendCallback(point))
- }
- },
- _releaseSelectedPointSingleMode: function() {
- var that = this,
- point = that._selectedPoint;
- if (point) {
- that._setPointState(point, RELEASE_POINT_SELECTED_STATE, processMode(point.getOptions().selectionMode), POINT_SELECTION_CHANGED, that.legendCallback(point));
- that._selectedPoint = null
- }
- },
- _setPointState: function(point, action, mode, eventName, legendCallback) {
- var that = this;
- switch (mode) {
- case ALL_ARGUMENTS_POINTS_MODE:
- that._toAllArgumentPoints(point.argument, action, eventName);
- break;
- case ALL_SERIES_POINTS_MODE:
- _each(point.series.getPoints(), function(_, point) {
- point.series[action](point);
- that._eventTrigger(eventName, {target: point})
- });
- break;
- case NONE_MODE:
- break;
- default:
- point.series[action](point, legendCallback);
- that._eventTrigger(eventName, {target: point})
- }
- },
- _toAllArgumentPoints: function(argument, func, eventName) {
- var that = this;
- _each(that._storedSeries, function(_, series) {
- var neighborPoints = series.getPointsByArg(argument);
- _each(neighborPoints || [], function(_, point) {
- series[func](point);
- eventName && that._eventTrigger(eventName, {target: point})
- })
- })
- },
- _setHoveredPoint: function(point, mode) {
- var that = this;
- var debug = DX.utils.debug;
- debug.assert(point.series, 'series was not assigned to point or empty');
- if (that.hoveredPoint === point || !point.series)
- return;
- that._releaseHoveredPoint();
- if (point && point.getOptions() && mode !== NONE_MODE) {
- that.hoveredPoint = point;
- that._setPointState(point, 'setPointHoverState', mode || processMode(point.getOptions().hoverMode), "pointHoverChanged", that.legendCallback(point))
- }
- },
- _releaseHoveredPoint: function() {
- var that = this,
- point = that.hoveredPoint,
- mode;
- if (!point || !point.getOptions())
- return;
- mode = processMode(point.getOptions().hoverMode);
- if (mode === ALL_SERIES_POINTS_MODE)
- _each(point.series.getPoints(), function(_, point) {
- point.series.releasePointHoverState(point);
- that._eventTrigger("pointHoverChanged", {target: point})
- });
- else if (mode === ALL_ARGUMENTS_POINTS_MODE)
- that._toAllArgumentPoints(point.argument, 'releasePointHoverState', "pointHoverChanged");
- else {
- point.releaseHoverState(that.legendCallback(point));
- that._eventTrigger("pointHoverChanged", {target: point})
- }
- if (that._tooltip.isEnabled())
- that._hideTooltip(point);
- that.hoveredPoint = null
- },
- _setSelectedSeriesMultipleMode: function(series, mode) {
- var that = this;
- that._selectedSeries = that._selectedSeries || [];
- if ($.inArray(series, that._selectedSeries) < 0) {
- that._selectedSeries.push(series);
- series.setSelectedState(true, mode, that.legendCallback(series));
- that._eventTrigger("seriesSelectionChanged", {target: series})
- }
- },
- _setSelectedSeriesSingleMode: function(series, mode) {
- var that = this;
- if (series !== that._selectedSeries || series.lastSelectionMode !== mode) {
- this._releaseSelectedSeries();
- that._selectedSeries = series;
- series.setSelectedState(true, mode, that.legendCallback(series));
- that._eventTrigger("seriesSelectionChanged", {target: series})
- }
- },
- _releaseSelectedSeriesMultipleMode: function(series) {
- var that = this,
- selectedSeries = that._selectedSeries || [],
- seriesIndex = $.inArray(series, selectedSeries);
- if (seriesIndex >= 0) {
- series.setSelectedState(false, undefined, that.legendCallback(series));
- that._eventTrigger("seriesSelectionChanged", {target: series});
- selectedSeries.splice(seriesIndex, 1)
- }
- else if (!series)
- _each(selectedSeries, function(_, series) {
- that._releaseSelectedSeries(series)
- })
- },
- _releaseSelectedSeriesSingleMode: function() {
- var that = this,
- series = that._selectedSeries;
- if (series) {
- series.setSelectedState(false, undefined, that.legendCallback(series));
- that._eventTrigger("seriesSelectionChanged", {target: series});
- that._selectedSeries = null
- }
- },
- _setHoveredSeries: function(series, mode) {
- var that = this;
- if (mode !== NONE_MODE && that.hoveredSeries !== series || series.lastHoverMode !== mode) {
- that._clearHover();
- series.setHoverState(true, mode, that.legendCallback(series));
- that._eventTrigger("seriesHoverChanged", {target: series})
- }
- that.hoveredSeries = series;
- if (mode === NONE_MODE)
- $(series).trigger('NoneMode')
- },
- _releaseHoveredSeries: function() {
- var that = this;
- if (that.hoveredSeries) {
- that.hoveredSeries.setHoverState(false, undefined, that.legendCallback(that.hoveredSeries));
- that._eventTrigger("seriesHoverChanged", {target: that.hoveredSeries});
- that.hoveredSeries = null
- }
- },
- _selectSeries: function(event, mode) {
- event.data.tracker._setSelectedSeries(event.target, mode)
- },
- _deselectSeries: function(event, mode) {
- event.data.tracker._releaseSelectedSeries(event.target, mode)
- },
- _selectPoint: function(event, point) {
- event.data.tracker._setSelectedPoint(point)
- },
- _deselectPoint: function(event, point) {
- event.data.tracker._releaseSelectedPoint(point)
- },
- clearSelection: function() {
- this._releaseSelectedPoint();
- this._releaseSelectedSeries()
- },
- _clean: function() {
- var that = this;
- that._selectedPoint = that._selectedSeries = that.hoveredPoint = that.hoveredSeries = null;
- that._hideTooltip(that.pointAtShownTooltip)
- },
- _clearHover: function() {
- this._releaseHoveredSeries();
- this._releaseHoveredPoint()
- },
- _hideTooltip: function(point, silent) {
- var that = this;
- if (!that._tooltip || point && that.pointAtShownTooltip !== point)
- return;
- if (!silent && that.pointAtShownTooltip)
- that.pointAtShownTooltip = null;
- that._tooltip.hide()
- },
- _showTooltip: function(point) {
- var that = this,
- tooltipFormatObject,
- eventData;
- if (point && point.getOptions()) {
- tooltipFormatObject = point.getTooltipFormatObject(that._tooltip);
- if (!isDefined(tooltipFormatObject.valueText) && !tooltipFormatObject.points || !point.isVisible())
- return;
- if (!that.pointAtShownTooltip || that.pointAtShownTooltip !== point)
- eventData = {target: point};
- var coords = point.getTooltipParams(that._tooltip.getLocation()),
- rootOffset = that._renderer.getRootOffset();
- coords.x += rootOffset.left;
- coords.y += rootOffset.top;
- if (!that._tooltip.show(tooltipFormatObject, coords, eventData))
- return;
- that.pointAtShownTooltip = point
- }
- },
- _showPointTooltip: function(event, point) {
- var that = event.data.tracker,
- pointWithTooltip = that.pointAtShownTooltip;
- if (pointWithTooltip && pointWithTooltip !== point)
- that._hideTooltip(pointWithTooltip);
- that._showTooltip(point)
- },
- _hidePointTooltip: function(event, point) {
- event.data.tracker._hideTooltip(point)
- },
- _enableOutHandler: function() {
- if (this._outHandler)
- return;
- var that = this,
- handler = function(e) {
- var rootOffset = that._renderer.getRootOffset(),
- x = _floor(e.pageX - rootOffset.left),
- y = _floor(e.pageY - rootOffset.top);
- if (!that._inCanvas(that._mainCanvas, x, y)) {
- that._pointerOut();
- that._disableOutHandler()
- }
- };
- $(document).on(POINTER_ACTION, handler);
- this._outHandler = handler
- },
- _disableOutHandler: function() {
- this._outHandler && $(document).off(POINTER_ACTION, this._outHandler);
- this._outHandler = null
- },
- _pointerOut: function() {
- this._clearHover();
- this._tooltip.isEnabled() && this._hideTooltip(this.pointAtShownTooltip)
- },
- _inCanvas: function(canvas, x, y) {
- return x >= canvas.left && x <= canvas.right && y >= canvas.top && y <= canvas.bottom
- },
- dispose: function() {
- var that = this;
- that._disableOutHandler();
- _each(that, function(k) {
- that[k] = null
- })
- }
- };
- charts.ChartTracker = function(options) {
- this.ctor(options)
- };
- $.extend(charts.ChartTracker.prototype, baseTrackerPrototype, {
- ctor: function(options) {
- var that = this;
- baseTrackerPrototype.ctor.call(that, options)
- },
- _pointClick: function(point, event) {
- var that = this,
- eventTrigger = that._eventTrigger,
- series = point.series;
- eventTrigger(POINT_CLICK, {
- target: point,
- jQueryEvent: event
- }, function() {
- !eventCanceled(event, series) && eventTrigger(SERIES_CLICK, {
- target: series,
- jQueryEvent: event
- })
- })
- },
- __trackerDelay: DELAY,
- _legendClick: function(series, event) {
- var that = this,
- evetArgs = {
- target: series,
- jQueryEvent: event
- },
- eventTrigger = that._eventTrigger;
- eventTrigger(LEGEND_CLICK, evetArgs, function() {
- !eventCanceled(event, series) && eventTrigger(SERIES_CLICK, evetArgs)
- })
- },
- update: function(options) {
- var that = this;
- that._zoomingMode = (options.zoomingMode + '').toLowerCase();
- that._scrollingMode = (options.scrollingMode + '').toLowerCase();
- baseTrackerPrototype.update.call(this, options);
- that._argumentAxis = getNonVirtualAxis(options.argumentAxis || []);
- that._axisHoverEnabled = that._argumentAxis && processMode(that._argumentAxis.getOptions().hoverMode) === ALL_ARGUMENTS_POINTS_MODE;
- that._chart = options.chart;
- that._rotated = options.rotated;
- that._crosshair = options.crosshair
- },
- _getAxisArgument: function(event) {
- var $target = $(event.target);
- return event.target.tagName === "tspan" ? $target.parent().data('argument') : $target.data('argument')
- },
- _getCanvas: function(x, y) {
- var that = this,
- canvases = that._canvases || [];
- for (var i = 0; i < canvases.length; i++) {
- var c = canvases[i];
- if (that._inCanvas(c, x, y))
- return c
- }
- return null
- },
- _focusOnCanvas: function(canvas) {
- if (!canvas && this._stickedSeries)
- this._pointerOut()
- },
- _resetHoveredArgument: function() {
- if (isDefined(this.hoveredArgument)) {
- this._toAllArgumentPoints(this.hoveredArgument, 'releasePointHoverState');
- this.hoveredArgument = null
- }
- },
- _hideCrosshair: function() {
- this._crosshair && this._crosshair.hide()
- },
- _moveCrosshair: function(point, x, y) {
- if (point && this._crosshair && point.isVisible()) {
- var coords = point.getCrosshairCoords(x, y),
- r = point.getPointRadius();
- this._crosshair.shift(coords.x, coords.y, r)
- }
- },
- _prepare: function(root) {
- var that = this,
- touchScrollingEnabled = that._scrollingMode === 'all' || that._scrollingMode === 'touch',
- touchZoomingEnabled = that._zoomingMode === 'all' || that._zoomingMode === 'touch',
- cssValue = (!touchScrollingEnabled ? "pan-x pan-y " : '') + (!touchZoomingEnabled ? "pinch-zoom" : '') || "none",
- rootStyles = {
- 'touch-action': cssValue,
- '-ms-touch-action': cssValue
- },
- wheelzoomingEnabled = that._zoomingMode === "all" || that._zoomingMode === "mouse";
- root.off("dxmousewheel dxc-scroll-start dxc-scroll-move");
- baseTrackerPrototype._prepare.call(that, root);
- if (!that._gestureEndHandler) {
- that._gestureEndHandler = function() {
- that._gestureEnd && that._gestureEnd()
- };
- $(document).on("dxpointerup", that._gestureEndHandler)
- }
- wheelzoomingEnabled && root.on("dxmousewheel", function(e) {
- var rootOffset = that._renderer.getRootOffset(),
- x = that._rotated ? e.pageY - rootOffset.top : e.pageX - rootOffset.left,
- scale = that._argumentAxis.getTranslator().getMinScale(e.delta > 0),
- translate = x - x * scale,
- zoom = that._argumentAxis.getTranslator().zoom(-translate, scale);
- that._pointerOut();
- that._chart.zoomArgument(zoom.min, zoom.max, true);
- e.preventDefault();
- e.stopPropagation()
- });
- root.on("dxc-scroll-start", function(e) {
- that._gestureStart(that._getGestureParams(e, {
- left: 0,
- top: 0
- }))
- }).on("dxc-scroll-move", function(e) {
- that._gestureChange(that._getGestureParams(e, {
- left: 0,
- top: 0
- })) && e.preventDefault()
- });
- root.css(rootStyles)
- },
- _getGestureParams: function(e, offset) {
- var that = this,
- x1,
- x2,
- touches = e.pointers.length,
- left,
- right,
- eventCoordField = that._rotated ? "pageY" : "pageX";
- offset = that._rotated ? offset.top : offset.left;
- if (touches === 2)
- x1 = e.pointers[0][eventCoordField] - offset,
- x2 = e.pointers[1][eventCoordField] - offset;
- else if (touches === 1)
- x1 = x2 = e.pointers[0][eventCoordField] - offset;
- left = math.min(x1, x2);
- right = math.max(x1, x2);
- return {
- center: left + (right - left) / 2,
- distance: right - left,
- touches: touches,
- scale: 1,
- pointerType: e.pointerType
- }
- },
- _gestureStart: function(gestureParams) {
- var that = this;
- that._startGesture = that._startGesture || gestureParams;
- if (that._startGesture.touches !== gestureParams.touches)
- that._startGesture = gestureParams
- },
- _gestureChange: function(gestureParams) {
- var that = this,
- startGesture = that._startGesture,
- gestureChanged = false,
- scrollingEnabled = that._scrollingMode === 'all' || that._scrollingMode !== 'none' && that._scrollingMode === gestureParams.pointerType,
- zoommingEnabled = that._zoomingMode === 'all' || that._zoomingMode === 'touch';
- if (!startGesture)
- return gestureChanged;
- if (startGesture.touches === 1 && math.abs(startGesture.center - gestureParams.center) < 3) {
- that._gestureStart(gestureParams);
- return gestureChanged
- }
- if (startGesture.touches === 2 && zoommingEnabled) {
- gestureChanged = true;
- startGesture.scale = gestureParams.distance / startGesture.distance;
- startGesture.scroll = gestureParams.center - startGesture.center + (startGesture.center - startGesture.center * startGesture.scale)
- }
- else if (startGesture.touches === 1 && scrollingEnabled) {
- gestureChanged = true;
- startGesture.scroll = gestureParams.center - startGesture.center
- }
- if (gestureChanged) {
- startGesture.changed = gestureChanged;
- that._chart._transformArgument(startGesture.scroll, startGesture.scale)
- }
- return gestureChanged
- },
- _gestureEnd: function() {
- var that = this,
- startGesture = that._startGesture,
- zoom,
- renderer = that._renderer;
- that._startGesture = null;
- function complete() {
- that._chart.zoomArgument(zoom.min, zoom.max, true)
- }
- if (startGesture && startGesture.changed) {
- zoom = that._argumentAxis._translator.zoom(-startGesture.scroll, startGesture.scale);
- if (renderer.animationEnabled() && (-startGesture.scroll !== zoom.translate || startGesture.scale !== zoom.scale)) {
- var translateDelta = -(startGesture.scroll + zoom.translate),
- scaleDelta = startGesture.scale - zoom.scale;
- renderer.root.animate({_: 0}, {
- step: function(pos) {
- var translateValue = -startGesture.scroll - translateDelta * pos;
- var scaleValue = startGesture.scale - scaleDelta * pos;
- that._chart._transformArgument(-translateValue, scaleValue)
- },
- complete: complete,
- duration: 250
- })
- }
- else
- complete()
- }
- },
- _clean: function() {
- var that = this;
- baseTrackerPrototype._clean.call(that);
- that._resetTimer();
- that._stickedSeries = null
- },
- _getSeriesForShared: function(x, y) {
- var that = this,
- points = [],
- point = null,
- distance = Infinity;
- if (that._tooltip.isShared() && !that.hoveredSeries) {
- _each(that._storedSeries, function(_, series) {
- var point = series.getNeighborPoint(x, y);
- point && points.push(point)
- });
- _each(points, function(_, p) {
- var coords = p.getCrosshairCoords(x, y),
- d = math.sqrt((x - coords.x) * (x - coords.x) + (y - coords.y) * (y - coords.y));
- if (d < distance) {
- point = p;
- distance = d
- }
- })
- }
- return point && point.series
- },
- _setTimeout: function(callback, keeper) {
- var that = this;
- if (that._timeoutKeeper !== keeper) {
- that._resetTimer();
- that._hoverTimeout = setTimeout(function() {
- callback();
- that._timeoutKeeper = null
- }, DELAY);
- that._timeoutKeeper = keeper
- }
- },
- _resetTimer: function() {
- clearTimeout(this._hoverTimeout);
- this._timeoutKeeper = this._hoverTimeout = null
- },
- _pointerHandler: function(e) {
- var that = e.data.tracker,
- rootOffset = that._renderer.getRootOffset(),
- x = _floor(e.pageX - rootOffset.left),
- y = _floor(e.pageY - rootOffset.top),
- canvas = that._getCanvas(x, y),
- series = $(e.target).data("series"),
- point = $(e.target).data("point") || series && series.getPointByCoord(x, y);
- that._enableOutHandler();
- that._x = x;
- that._y = y;
- if (e.type === "dxpointerdown")
- canvas && that._gestureStart(that._getGestureParams(e, rootOffset));
- else if (that._startGesture && canvas)
- if (that._gestureChange(that._getGestureParams(e, rootOffset))) {
- that._pointerOut();
- e.preventDefault();
- return
- }
- if (that._legend.coordsIn(x, y)) {
- var item = that._legend.getItemByCoord(x, y);
- if (item) {
- series = that._storedSeries[item.id];
- that._setHoveredSeries(series, that._legend._options.hoverMode);
- that._stickedSeries = series
- }
- else
- that._clearHover();
- that._hideCrosshair();
- return
- }
- if (that._axisHoverEnabled && that._argumentAxis.coordsIn(x, y)) {
- var argument = that._getAxisArgument(e),
- argumentDefined = isDefined(argument);
- if (argumentDefined && that.hoveredArgument !== argument) {
- that._clearHover();
- that._resetHoveredArgument();
- that._toAllArgumentPoints(argument, "setPointHoverState");
- that.hoveredArgument = argument
- }
- else if (!argumentDefined)
- that._resetHoveredArgument();
- return
- }
- that._resetHoveredArgument();
- that._focusOnCanvas(canvas);
- if (!canvas && !point)
- return;
- if (!series && !point)
- that._stickedSeries = that._stickedSeries || that._getSeriesForShared(x, y);
- if (series && !point) {
- point = series.getNeighborPoint(x, y);
- if (series !== that.hoveredSeries) {
- that._setTimeout(function() {
- that._setHoveredSeries(series, series.getOptions().hoverMode);
- that._stickedSeries = series;
- that._pointerComplete(point)
- }, series);
- return
- }
- }
- else if (point) {
- if (that.hoveredSeries)
- that._setTimeout(function() {
- that._pointerOnPoint(point)
- }, point);
- else
- that._pointerOnPoint(point);
- return
- }
- else if (that._stickedSeries) {
- series = that._stickedSeries;
- point = series.getNeighborPoint(x, y);
- that.hoveredSeries && that._releaseHoveredSeries();
- point && that._setHoveredPoint(point)
- }
- that._pointerComplete(point)
- },
- _pointerOnPoint: function(point) {
- var that = this;
- that._stickedSeries = point.series;
- that._setHoveredPoint(point);
- that.hoveredSeries && that._releaseHoveredSeries();
- that._pointerComplete(point)
- },
- _pointerComplete: function(point) {
- var that = this;
- that.hoveredSeries && that.hoveredSeries.updateHover(that._x, that._y);
- that._resetTimer();
- that._moveCrosshair(point, that._x, that._y);
- that.pointAtShownTooltip !== point && that._tooltip.isEnabled() && that._showTooltip(point)
- },
- _pointerOut: function() {
- var that = this;
- that._stickedSeries = null;
- that._hideCrosshair();
- that._resetHoveredArgument();
- that._resetTimer();
- baseTrackerPrototype._pointerOut.call(that)
- },
- _clickHandler: function(e) {
- var that = e.data.tracker,
- rootOffset = that._renderer.getRootOffset(),
- x = _floor(e.pageX - rootOffset.left),
- y = _floor(e.pageY - rootOffset.top),
- point = $(e.target).data("point"),
- series = that._stickedSeries || $(e.target).data("series") || point && point.series,
- axis = that._argumentAxis;
- if (that._legend.coordsIn(x, y)) {
- var item = that._legend.getItemByCoord(x, y);
- if (item) {
- series = that._storedSeries[item.id];
- that._legendClick(series, e)
- }
- return
- }
- if (axis && axis.coordsIn(x, y)) {
- var argument = that._getAxisArgument(e);
- if (isDefined(argument)) {
- that._eventTrigger("argumentAxisClick", {
- argument: argument,
- jQueryEvent: e
- });
- return
- }
- }
- if (series) {
- point = point || series.getPointByCoord(x, y);
- if (point)
- that._pointClick(point, e);
- else
- $(e.target).data("series") && that._eventTrigger(SERIES_CLICK, {
- target: series,
- jQueryEvent: e
- })
- }
- },
- dispose: function() {
- this._gestureEndHandler && $(document).off("dxpointerup", this._gestureEndHandler);
- this._resetTimer();
- baseTrackerPrototype.dispose.call(this)
- }
- });
- charts.PieTracker = function(options) {
- this.ctor(options)
- };
- $.extend(charts.PieTracker.prototype, baseTrackerPrototype, {
- _legendClick: function(point, event) {
- var that = this,
- eventArg = {
- target: point,
- jQueryEvent: event
- },
- eventTrigger = that._eventTrigger;
- eventTrigger(LEGEND_CLICK, eventArg, function() {
- !eventCanceled(event, point) && eventTrigger(POINT_CLICK, eventArg)
- })
- },
- _pointerHandler: function(e) {
- var that = e.data.tracker,
- rootOffset = that._renderer.getRootOffset(),
- x = _floor(e.pageX - rootOffset.left),
- y = _floor(e.pageY - rootOffset.top),
- series = that._storedSeries[0],
- point = $(e.target).data("point") || series && series.getPointByCoord(x, y),
- item,
- mode;
- that._enableOutHandler();
- if (that._legend.coordsIn(x, y)) {
- item = that._legend.getItemByCoord(x, y);
- if (item) {
- point = series.getPoints()[item.id];
- mode = that._legend._options.hoverMode
- }
- }
- if (point && point !== that.hoveredPoint) {
- that._tooltip.isEnabled() && that._showTooltip(point);
- that._setHoveredPoint(point, mode)
- }
- else if (!point)
- that._pointerOut()
- },
- _clickHandler: function(e) {
- var that = e.data.tracker,
- rootOffset = that._renderer.getRootOffset(),
- x = _floor(e.pageX - rootOffset.left),
- y = _floor(e.pageY - rootOffset.top),
- storedSeries = that._storedSeries[0],
- point;
- if (that._legend.coordsIn(x, y)) {
- var item = that._legend.getItemByCoord(x, y);
- if (item) {
- point = storedSeries.getPoints()[item.id];
- that._legendClick(point, e)
- }
- }
- else {
- point = $(e.target).data("point") || storedSeries && storedSeries.getPointByCoord(x, y);
- point && that._eventTrigger(POINT_CLICK, {
- target: point,
- jQueryEvent: e
- })
- }
- }
- })
- })(jQuery, DevExpress, Math);
- /*! Module viz-charts, file crosshair.js */
- (function($, DX, undefined) {
- var _math = Math,
- mathAbs = _math.abs,
- mathMin = _math.min,
- mathMax = _math.max,
- _round = _math.round,
- HORIZONTAL = "horizontal",
- VERTICAL = "vertical",
- LABEL_BACKGROUND_PADDING_X = 8,
- LABEL_BACKGROUND_PADDING_Y = 4,
- CENTER = "center",
- RIGHT = "right",
- LEFT = "left",
- TOP = "top",
- BOTTOM = "bottom",
- _isDefined = DX.utils.isDefined;
- function Crosshair() {
- this.ctor.apply(this, arguments)
- }
- DX.viz.charts.Crosshair = Crosshair;
- Crosshair.prototype = {
- ctor: function(renderer, options, params, group) {
- var that = this;
- that._renderer = renderer;
- that._crosshairGroup = group;
- that._options = {};
- that._init(options, params)
- },
- update: function(options, params) {
- this._init(options, params)
- },
- dispose: function() {
- var that = this;
- that._renderer = null;
- that._crosshairGroup = null;
- that._options = null;
- that._axes = null;
- that._canvas = null;
- that._horizontalGroup = null;
- that._verticalGroup = null;
- that._horizontal = null;
- that._vertical = null;
- that._circle = null;
- that._panes = null
- },
- _init: function(options, params) {
- var that = this,
- canvas = params.canvas;
- that._canvas = {
- top: canvas.top,
- bottom: canvas.height - canvas.bottom,
- left: canvas.left,
- right: canvas.width - canvas.right,
- width: canvas.width,
- height: canvas.height
- };
- that._axes = params.axes;
- that._panes = params.panes;
- that._prepareOptions(options, HORIZONTAL);
- that._prepareOptions(options, VERTICAL)
- },
- _prepareOptions: function(options, direction) {
- this._options[direction] = {
- visible: options[direction + "Line"].visible,
- line: {
- stroke: options[direction + "Line"].color || options.color,
- "stroke-width": options[direction + "Line"].width || options.width,
- dashStyle: options[direction + "Line"].dashStyle || options.dashStyle,
- opacity: options[direction + "Line"].opacity || options.opacity,
- "stroke-linecap": "butt"
- },
- label: $.extend(true, {}, options.label, options[direction + "Line"].label)
- }
- },
- _createLines: function(options, sharpParam, group) {
- var lines = [],
- canvas = this._canvas,
- points = [canvas.left, canvas.top, canvas.left, canvas.top];
- for (var i = 0; i < 2; i++)
- lines.push(this._renderer.path(points, "line").attr(options).sharp(sharpParam).append(group));
- return lines
- },
- render: function() {
- var that = this,
- renderer = that._renderer,
- options = that._options,
- verticalOptions = options.vertical,
- horizontalOptions = options.horizontal,
- extraOptions = horizontalOptions.visible ? horizontalOptions.line : verticalOptions.line,
- circleOptions = {
- stroke: extraOptions.stroke,
- "stroke-width": extraOptions["stroke-width"],
- dashStyle: extraOptions.dashStyle,
- opacity: extraOptions.opacity
- },
- canvas = that._canvas;
- that._horizontal = {};
- that._vertical = {};
- that._horizontalGroup = renderer.g().append(that._crosshairGroup);
- that._verticalGroup = renderer.g().append(that._crosshairGroup);
- if (verticalOptions.visible) {
- that._vertical.lines = that._createLines(verticalOptions.line, "h", that._verticalGroup);
- that._vertical.labels = that._createLabels(that._axes[0], verticalOptions, false, that._verticalGroup)
- }
- if (horizontalOptions.visible) {
- that._horizontal.lines = that._createLines(horizontalOptions.line, "v", that._horizontalGroup);
- that._horizontal.labels = that._createLabels(that._axes[1], horizontalOptions, true, that._horizontalGroup)
- }
- that._circle = renderer.circle(canvas.left, canvas.top, 0).attr(circleOptions).append(that._crosshairGroup)
- },
- _createLabels: function(axes, options, isHorizontal, group) {
- var that = this,
- canvas = that._canvas,
- renderer = that._renderer,
- x,
- y,
- text,
- labels = [],
- background,
- curentLabelPos,
- bbox;
- if (!options.label || !options.label.visible)
- return;
- $.each(axes, function(_, axis) {
- var axisOptions = axis.getOptions(),
- position = axisOptions.position;
- if (axis._virtual || axisOptions.stubData)
- return;
- curentLabelPos = axis.getCurrentLabelPos();
- if (isHorizontal) {
- y = canvas.top;
- x = curentLabelPos
- }
- else {
- x = canvas.left;
- y = curentLabelPos
- }
- text = renderer.text("0", x, y).css(DX.viz.core.utils.patchFontOptions(options.label.font)).attr({align: position === TOP || position === BOTTOM ? CENTER : position === RIGHT ? LEFT : RIGHT}).append(group);
- bbox = text.getBBox();
- text.attr({y: isHorizontal ? 2 * y - bbox.y - bbox.height / 2 : position === BOTTOM ? 2 * y - bbox.y : 2 * y - (bbox.y + bbox.height)});
- background = renderer.rect(0, 0, 0, 0).attr({fill: options.label.backgroundColor || options.line.stroke}).append(group).toBackground();
- labels.push({
- text: text,
- background: background,
- axis: axis,
- pos: {
- coord: curentLabelPos,
- side: position
- }
- })
- });
- return labels
- },
- _updateText: function(coord, labels) {
- var that = this,
- bbox,
- text,
- textElement,
- backgroundElement;
- if (!labels)
- return;
- $.each(labels, function(i, label) {
- textElement = label.text;
- backgroundElement = label.background;
- if (!textElement)
- return;
- text = label.axis.getUntranslatedValue(coord);
- if (_isDefined(text)) {
- textElement.attr({text: text});
- bbox = textElement.getBBox();
- that._updateLinesCanvas(label.pos.side, label.pos.coord);
- backgroundElement.attr({
- x: bbox.x - LABEL_BACKGROUND_PADDING_X,
- y: bbox.y - LABEL_BACKGROUND_PADDING_Y,
- width: bbox.width + LABEL_BACKGROUND_PADDING_X * 2,
- height: bbox.height + LABEL_BACKGROUND_PADDING_Y * 2
- })
- }
- else {
- textElement.attr({text: ""});
- backgroundElement.attr({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- })
- }
- })
- },
- show: function() {
- this._crosshairGroup.attr({visibility: "visible"})
- },
- hide: function() {
- this._crosshairGroup.attr({visibility: "hidden"})
- },
- _updateLinesCanvas: function(position, labelPosition) {
- var coords = this._linesCanvas,
- canvas = this._canvas;
- coords[position] = coords[position] !== canvas[position] && mathAbs(coords[position] - canvas[position]) < mathAbs(labelPosition - canvas[position]) ? coords[position] : labelPosition
- },
- _updateLines: function(lines, x, y, r, isHorizontal) {
- var coords = this._linesCanvas,
- canvas = this._canvas,
- points = isHorizontal ? [[mathMin(x - r, coords.left), canvas.top, x - r, canvas.top], [x + r, canvas.top, mathMax(coords.right, x + r), canvas.top]] : [[canvas.left, mathMin(coords.top, y - r), canvas.left, y - r], [canvas.left, y + r, canvas.left, mathMax(coords.bottom, y + r)]];
- for (var i = 0; i < 2; i++)
- lines[i].attr({points: points[i]})
- },
- _resetLinesCanvas: function() {
- var canvas = this._canvas;
- this._linesCanvas = {
- left: canvas.left,
- right: canvas.right,
- top: canvas.top,
- bottom: canvas.bottom
- }
- },
- _getClipRectForPane: function(x, y) {
- var panes = this._panes,
- i,
- coords;
- for (i = 0; i < panes.length; i++) {
- coords = panes[i].coords;
- if (coords.left <= x && coords.right >= x && coords.top <= y && coords.bottom >= y)
- return panes[i].clipRect
- }
- return {id: null}
- },
- shift: function(x, y, r) {
- var that = this,
- horizontal = that._horizontal,
- vertical = that._vertical,
- clipRect,
- rad = !r ? 0 : r + 3,
- canvas = that._canvas;
- x = _round(x);
- y = _round(y);
- if (x >= canvas.left && x <= canvas.right && y >= canvas.top && y <= canvas.bottom) {
- that.show();
- that._resetLinesCanvas();
- clipRect = that._getClipRectForPane(x, y);
- that._circle.attr({
- cx: x,
- cy: y,
- r: rad,
- clipId: clipRect.id
- });
- if (horizontal.lines) {
- that._updateText(y, horizontal.labels);
- that._updateLines(horizontal.lines, x, y, rad, true);
- that._horizontalGroup.attr({translateY: y - canvas.top})
- }
- if (vertical.lines) {
- that._updateText(x, vertical.labels);
- that._updateLines(vertical.lines, x, y, rad, false);
- that._verticalGroup.attr({translateX: x - canvas.left})
- }
- }
- else
- that.hide()
- }
- }
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_CHARTS = true
- }
- if (!DevExpress.MOD_VIZ_GAUGES) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-gauges, file namespaces.js */
- (function(DX) {
- DX.viz.gauges = {__internals: {
- circularNeedles: {},
- circularMarkers: {},
- linearNeedles: {},
- linearMarkers: {}
- }};
- DX.viz.gauges.__tests = {}
- })(DevExpress);
- /*! Module viz-gauges, file factory.js */
- (function(DX, $, undefined) {
- var internals = DX.viz.gauges.__internals,
- circularNeedles = internals.circularNeedles,
- circularMarkers = internals.circularMarkers,
- linearNeedles = internals.linearNeedles,
- linearMarkers = internals.linearMarkers,
- _String = String;
- DX.viz.gauges.__factory = {
- createCircularIndicator: function(parameters, type, _strict) {
- var indicatorType;
- switch (_String(type).toLowerCase()) {
- case'rectangleneedle':
- indicatorType = circularNeedles.RectangleNeedle;
- break;
- case'triangleneedle':
- indicatorType = circularNeedles.TriangleNeedle;
- break;
- case'twocolorneedle':
- indicatorType = circularNeedles.TwoColorRectangleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.CircularRangeBar;
- break;
- case'trianglemarker':
- indicatorType = circularMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = circularMarkers.TextCloudMarker;
- break;
- default:
- indicatorType = _strict ? null : circularNeedles.RectangleNeedle;
- break
- }
- return indicatorType ? new indicatorType(parameters) : null
- },
- createLinearIndicator: function(parameters, type, _strict) {
- var indicatorType = internals.LinearRangeBar;
- switch (_String(type).toLowerCase()) {
- case'rectangle':
- indicatorType = linearNeedles.RectangleNeedle;
- break;
- case'rhombus':
- indicatorType = linearNeedles.RhombusNeedle;
- break;
- case'circle':
- indicatorType = linearNeedles.CircleNeedle;
- break;
- case'rangebar':
- indicatorType = internals.LinearRangeBar;
- break;
- case'trianglemarker':
- indicatorType = linearMarkers.TriangleMarker;
- break;
- case'textcloud':
- indicatorType = linearMarkers.TextCloudMarker;
- break;
- default:
- indicatorType = _strict ? null : internals.LinearRangeBar;
- break
- }
- return indicatorType ? new indicatorType(parameters) : null
- },
- createCircularScale: function(parameters) {
- return new internals.CircularScale(parameters)
- },
- createLinearScale: function(parameters) {
- return new internals.LinearScale(parameters)
- },
- createCircularRangeContainer: function(parameters) {
- return new internals.CircularRangeContainer(parameters)
- },
- createLinearRangeContainer: function(parameters) {
- return new internals.LinearRangeContainer(parameters)
- },
- createTitle: function(parameters) {
- return new internals.Title(parameters)
- },
- createIndicator: function() {
- return internals.Indicator && new internals.Indicator || null
- },
- createLayoutManager: function() {
- return new internals.LayoutManager
- },
- createThemeManager: function(options) {
- return new internals.ThemeManager(options)
- },
- createTracker: function(parameters) {
- return new internals.Tracker(parameters)
- }
- };
- var _isFunction = DX.utils.isFunction,
- _extend = $.extend;
- var _formatHelper = DX.formatHelper;
- internals.formatValue = function(value, options, extra) {
- options = options || {};
- var text = _formatHelper.format(value, options.format, options.precision),
- context;
- if (_isFunction(options.customizeText)) {
- context = _extend({
- value: value,
- valueText: text
- }, extra);
- return _String(options.customizeText.call(context, context))
- }
- return text
- };
- internals.getSampleText = function(translator, options) {
- var text1 = internals.formatValue(translator.getDomainStart(), options),
- text2 = internals.formatValue(translator.getDomainEnd(), options);
- return text1.length >= text2.length ? text1 : text2
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file baseIndicator.js */
- (function(DX, $, undefined) {
- var _isFinite = isFinite,
- _Number = Number;
- DX.viz.gauges.__internals.BaseElement = DX.Class.inherit({
- ctor: function(parameters) {
- var that = this;
- $.each(parameters, function(name, value) {
- that["_" + name] = value
- });
- that._init()
- },
- dispose: function() {
- var that = this;
- $.each(that, function(name) {
- that[name] = null
- });
- return that
- },
- getOffset: function() {
- return _Number(this._options.offset) || 0
- }
- });
- DX.viz.gauges.__internals.BaseIndicator = DX.viz.gauges.__internals.BaseElement.inherit({
- _init: function() {
- this._rootElement = this._createRoot();
- this._trackerElement = this._createTracker()
- },
- _setupAnimation: function() {
- var that = this;
- if (that._options.animation)
- that._animation = {
- step: function(pos) {
- that._actualValue = that._animation.start + that._animation.delta * pos;
- that._actualPosition = that._translator.translate(that._actualValue);
- that._move()
- },
- duration: that._options.animation.duration > 0 ? _Number(that._options.animation.duration) : 0,
- easing: that._options.animation.easing
- }
- },
- _runAnimation: function(value, notifyReady) {
- var that = this,
- animation = that._animation;
- animation.start = that._actualValue;
- animation.delta = value - that._actualValue;
- that._rootElement.animate({_: 0}, {
- step: animation.step,
- duration: animation.duration,
- easing: animation.easing,
- complete: notifyReady
- })
- },
- _createRoot: function() {
- return this._renderer.g().attr({'class': this._className})
- },
- _createTracker: function() {
- return this._renderer.path([], "area")
- },
- _getTrackerSettings: $.noop,
- clean: function() {
- var that = this;
- that._animation && that._rootElement.stopAnimation();
- that._rootElement.remove();
- that._rootElement.clear();
- that._clear();
- that._tracker.detach(that._trackerElement);
- that._options = that.enabled = that._animation = null;
- return that
- },
- render: function(options) {
- var that = this;
- that.type = options.type;
- that._options = options;
- that._actualValue = that._currentValue = that._translator.adjust(that._options.currentValue);
- that.enabled = that._isEnabled();
- if (that.enabled) {
- that._setupAnimation();
- that._rootElement.attr({fill: that._options.color}).append(that._owner);
- that._tracker.attach(that._trackerElement, that, that._trackerInfo)
- }
- return that
- },
- resize: function(layout) {
- var that = this;
- that._rootElement.clear();
- that._clear();
- that.visible = that._isVisible(layout);
- if (that.visible) {
- $.extend(that._options, layout);
- that._actualPosition = that._translator.translate(that._actualValue);
- that._render();
- that._trackerElement.attr(that._getTrackerSettings());
- that._move()
- }
- return that
- },
- value: function(arg, _noAnimation) {
- var that = this,
- immediateReady = true,
- val;
- if (arg !== undefined) {
- val = that._translator.adjust(arg);
- that._notifiers.dirty();
- if (that._currentValue !== val && _isFinite(val)) {
- that._currentValue = val;
- if (that.visible)
- if (that._animation && !_noAnimation) {
- immediateReady = false;
- that._runAnimation(val, that._notifiers.ready)
- }
- else {
- that._actualValue = val;
- that._actualPosition = that._translator.translate(val);
- that._move()
- }
- }
- immediateReady && that._notifiers.ready();
- return that
- }
- return that._currentValue
- },
- _isEnabled: null,
- _isVisible: null,
- _render: null,
- _clear: null,
- _move: null
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file baseMarker.js */
- (function(DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- _min = Math.min,
- _round = Math.round,
- _formatValue = viz.gauges.__internals.formatValue,
- _getSampleText = viz.gauges.__internals.getSampleText,
- COEFFICIENTS_MAP = {};
- COEFFICIENTS_MAP['right-bottom'] = COEFFICIENTS_MAP['rb'] = [0, -1, -1, 0, 0, 1, 1, 0];
- COEFFICIENTS_MAP['bottom-right'] = COEFFICIENTS_MAP['br'] = [-1, 0, 0, -1, 1, 0, 0, 1];
- COEFFICIENTS_MAP['left-bottom'] = COEFFICIENTS_MAP['lb'] = [0, -1, 1, 0, 0, 1, -1, 0];
- COEFFICIENTS_MAP['bottom-left'] = COEFFICIENTS_MAP['bl'] = [1, 0, 0, -1, -1, 0, 0, 1];
- COEFFICIENTS_MAP['left-top'] = COEFFICIENTS_MAP['lt'] = [0, 1, 1, 0, 0, -1, -1, 0];
- COEFFICIENTS_MAP['top-left'] = COEFFICIENTS_MAP['tl'] = [1, 0, 0, 1, -1, 0, 0, -1];
- COEFFICIENTS_MAP['right-top'] = COEFFICIENTS_MAP['rt'] = [0, 1, -1, 0, 0, -1, 1, 0];
- COEFFICIENTS_MAP['top-right'] = COEFFICIENTS_MAP['tr'] = [-1, 0, 0, 1, 1, 0, 0, -1];
- function getTextCloudInfo(options) {
- var x = options.x,
- y = options.y,
- type = COEFFICIENTS_MAP[options.type],
- cloudWidth = options.textWidth + 2 * options.horMargin,
- cloudHeight = options.textHeight + 2 * options.verMargin,
- tailWidth,
- tailHeight,
- cx = x,
- cy = y;
- tailWidth = tailHeight = options.tailLength;
- if (type[0] & 1)
- tailHeight = _min(tailHeight, cloudHeight / 3);
- else
- tailWidth = _min(tailWidth, cloudWidth / 3);
- return {
- cx: _round(cx + type[0] * tailWidth + (type[0] + type[2]) * cloudWidth / 2),
- cy: _round(cy + type[1] * tailHeight + (type[1] + type[3]) * cloudHeight / 2),
- points: [_round(x), _round(y), _round(x += type[0] * (cloudWidth + tailWidth)), _round(y += type[1] * (cloudHeight + tailHeight)), _round(x += type[2] * cloudWidth), _round(y += type[3] * cloudHeight), _round(x += type[4] * cloudWidth), _round(y += type[5] * cloudHeight), _round(x += type[6] * (cloudWidth - tailWidth)), _round(y += type[7] * (cloudHeight - tailHeight))]
- }
- }
- viz.gauges.__tests.getTextCloudInfo = getTextCloudInfo;
- viz.gauges.__internals.BaseTextCloudMarker = viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- bbox,
- info,
- textCloudOptions = that._getTextCloudOptions();
- that._text.attr({text: _formatValue(that._actualValue, that._options.text)});
- bbox = that._text.getBBox();
- info = getTextCloudInfo({
- x: textCloudOptions.x,
- y: textCloudOptions.y,
- textWidth: bbox.width,
- textHeight: bbox.height,
- horMargin: that._options.horizontalOffset,
- verMargin: that._options.verticalOffset,
- tailLength: that._options.arrowLength,
- type: textCloudOptions.type
- });
- that._text.attr({
- x: info.cx,
- y: info.cy + that._textVerticalOffset
- });
- that._cloud.attr({points: info.points});
- that._trackerElement && that._trackerElement.attr({points: info.points})
- },
- _measureText: function() {
- var that = this,
- root,
- text,
- bbox;
- if (!that._textVerticalOffset) {
- root = that._createRoot().append(that._owner);
- text = that._renderer.text(_getSampleText(that._translator, that._options.text), 0, 0).attr({align: "center"}).css(core.utils.patchFontOptions(that._options.text.font)).append(root);
- bbox = text.getBBox();
- root.remove();
- that._textVerticalOffset = -bbox.y - bbox.height / 2;
- that._textWidth = bbox.width;
- that._textHeight = bbox.height;
- that._textFullWidth = that._textWidth + 2 * that._options.horizontalOffset;
- that._textFullHeight = that._textHeight + 2 * that._options.verticalOffset
- }
- },
- _render: function() {
- var that = this;
- that._measureText();
- that._cloud = that._cloud || that._renderer.path([], "area").append(that._rootElement);
- that._text = that._text || that._renderer.text().append(that._rootElement);
- that._text.attr({align: "center"}).css(core.utils.patchFontOptions(that._options.text.font))
- },
- _clear: function() {
- delete this._cloud;
- delete this._text
- },
- getTooltipParameters: function() {
- var position = this._getTextCloudOptions();
- return {
- x: position.x,
- y: position.y,
- value: this._currentValue,
- color: this._options.color
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file baseRangeBar.js */
- (function(DX, $, undefined) {
- var viz = DX.viz,
- core = viz.core,
- $extend = $.extend,
- formatValue = viz.gauges.__internals.formatValue,
- getSampleText = viz.gauges.__internals.getSampleText;
- viz.gauges.__internals.BaseRangeBar = viz.gauges.__internals.BaseIndicator.inherit({
- _measureText: function() {
- var that = this,
- root,
- text,
- bbox;
- that._hasText = that._isTextVisible();
- if (that._hasText && !that._textVerticalOffset) {
- root = that._createRoot().append(that._owner);
- text = that._renderer.text(getSampleText(that._translator, that._options.text), 0, 0).attr({
- 'class': 'dxg-text',
- align: 'center'
- }).css(core.utils.patchFontOptions(that._options.text.font)).append(root);
- bbox = text.getBBox();
- root.remove();
- that._textVerticalOffset = -bbox.y - bbox.height / 2;
- that._textWidth = bbox.width;
- that._textHeight = bbox.height
- }
- },
- _move: function() {
- var that = this;
- that._updateBarItemsPositions();
- if (that._hasText) {
- that._text.attr({text: formatValue(that._actualValue, that._options.text)});
- that._updateTextPosition();
- that._updateLinePosition()
- }
- },
- _updateBarItems: function() {
- var that = this,
- options = that._options,
- backgroundColor,
- spaceColor,
- translator = that._translator;
- that._setBarSides();
- that._startPosition = translator.translate(translator.getDomainStart());
- that._endPosition = translator.translate(translator.getDomainEnd());
- that._basePosition = translator.translate(options.baseValue);
- that._space = that._getSpace();
- backgroundColor = options.backgroundColor || 'none';
- if (backgroundColor !== 'none' && that._space > 0)
- spaceColor = options.containerBackgroundColor || 'none';
- else {
- that._space = 0;
- spaceColor = 'none'
- }
- that._backItem1.attr({fill: backgroundColor});
- that._backItem2.attr({fill: backgroundColor});
- that._spaceItem1.attr({fill: spaceColor});
- that._spaceItem2.attr({fill: spaceColor})
- },
- _getSpace: function() {
- return 0
- },
- _updateTextItems: function() {
- var that = this;
- if (that._hasText) {
- that._line = that._line || that._renderer.path([], "line").attr({
- 'class': 'dxg-main-bar',
- "stroke-linecap": "square"
- }).append(that._rootElement);
- that._text = that._text || that._renderer.text('', 0, 0).attr({'class': 'dxg-text'}).append(that._rootElement);
- that._text.attr({align: that._getTextAlign()}).css(that._getFontOptions());
- that._setTextItemsSides()
- }
- else {
- if (that._line) {
- that._line.remove();
- delete that._line
- }
- if (that._text) {
- that._text.remove();
- delete that._text
- }
- }
- },
- _isTextVisible: function() {
- return false
- },
- _getTextAlign: function() {
- return 'center'
- },
- _getFontOptions: function() {
- var options = this._options,
- font = options.text.font;
- if (!font || !font.color)
- font = $extend({}, font, {color: options.color});
- return core.utils.patchFontOptions(font)
- },
- _updateBarItemsPositions: function() {
- var that = this,
- positions = that._getPositions();
- that._backItem1.attr(that._buildItemSettings(positions.start, positions.back1));
- that._backItem2.attr(that._buildItemSettings(positions.back2, positions.end));
- that._spaceItem1.attr(that._buildItemSettings(positions.back1, positions.main1));
- that._spaceItem2.attr(that._buildItemSettings(positions.main2, positions.back2));
- that._mainItem.attr(that._buildItemSettings(positions.main1, positions.main2));
- that._trackerElement && that._trackerElement.attr(that._buildItemSettings(positions.main1, positions.main2))
- },
- _render: function() {
- var that = this;
- that._measureText();
- if (!that._backItem1) {
- that._backItem1 = that._createBarItem();
- that._backItem1.attr({'class': 'dxg-back-bar'})
- }
- if (!that._backItem2) {
- that._backItem2 = that._createBarItem();
- that._backItem2.attr({'class': 'dxg-back-bar'})
- }
- if (!that._spaceItem1) {
- that._spaceItem1 = that._createBarItem();
- that._spaceItem1.attr({'class': 'dxg-space-bar'})
- }
- if (!that._spaceItem2) {
- that._spaceItem2 = that._createBarItem();
- that._spaceItem2.attr({'class': 'dxg-space-bar'})
- }
- if (!that._mainItem) {
- that._mainItem = that._createBarItem();
- that._mainItem.attr({'class': 'dxg-main-bar'})
- }
- that._updateBarItems();
- that._updateTextItems()
- },
- _clear: function() {
- var that = this;
- delete that._backItem1;
- delete that._backItem2;
- delete that._spaceItem1;
- delete that._spaceItem2;
- delete that._mainItem;
- delete that._hasText;
- delete that._line;
- delete that._text
- },
- getTooltipParameters: function() {
- var position = this._getTooltipPosition();
- return {
- x: position.x,
- y: position.y,
- value: this._currentValue,
- color: this._options.color,
- offset: 0
- }
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file circularNeedle.js */
- (function(DX, undefined) {
- var circularNeedles = DX.viz.gauges.__internals.circularNeedles,
- _Number = Number;
- circularNeedles.SimpleIndicator = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- options = that._options,
- angle = DX.utils.convertAngleToRendererSpace(that._actualPosition);
- that._rootElement.rotate(angle, options.x, options.y);
- that._trackerElement && that._trackerElement.rotate(angle, options.x, options.y)
- },
- _isEnabled: function() {
- return this._options.width > 0
- },
- _isVisible: function(layout) {
- return layout.radius - _Number(this._options.indentFromCenter) > 0
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x = options.x,
- y = options.y - (options.radius + _Number(options.indentFromCenter)) / 2,
- width = options.width / 2,
- length = (options.radius - _Number(options.indentFromCenter)) / 2;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- return {points: [x - width, y - length, x - width, y + length, x + width, y + length, x + width, y - length]}
- },
- _renderSpindle: function() {
- var that = this,
- options = that._options,
- gapSize;
- if (options.spindleSize > 0) {
- gapSize = _Number(options.spindleGapSize) || 0;
- if (gapSize > 0)
- gapSize = gapSize <= options.spindleSize ? gapSize : _Number(options.spindleSize);
- that._spindleOuter = that._spindleOuter || that._renderer.circle().append(that._rootElement);
- that._spindleInner = that._spindleInner || that._renderer.circle().append(that._rootElement);
- that._spindleOuter.attr({
- 'class': 'dxg-spindle-border',
- cx: options.x,
- cy: options.y,
- r: options.spindleSize / 2
- });
- that._spindleInner.attr({
- 'class': 'dxg-spindle-hole',
- cx: options.x,
- cy: options.y,
- r: gapSize / 2,
- fill: options.containerBackgroundColor
- })
- }
- },
- _render: function() {
- var that = this;
- that._renderPointer();
- that._renderSpindle()
- },
- _clearSpindle: function() {
- delete this._spindleOuter;
- delete this._spindleInner
- },
- _clearPointer: function() {
- delete this._element
- },
- _clear: function() {
- this._clearPointer();
- this._clearSpindle()
- },
- measure: function(layout) {
- var result = {max: layout.radius};
- if (this._options.indentFromCenter < 0)
- result.inverseHorizontalOffset = result.inverseVerticalOffset = -_Number(this._options.indentFromCenter);
- return result
- },
- getTooltipParameters: function() {
- var options = this._options,
- cossin = DX.utils.getCosAndSin(this._actualPosition),
- r = (options.radius + _Number(options.indentFromCenter)) / 2;
- return {
- x: options.x + cossin.cos * r,
- y: options.y - cossin.sin * r,
- value: this._currentValue,
- color: options.color,
- offset: options.width / 2
- }
- }
- });
- circularNeedles.RectangleNeedle = circularNeedles.SimpleIndicator.inherit({_renderPointer: function() {
- var that = this,
- options = that._options,
- y2 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- x1 = options.x - options.width / 2,
- x2 = x1 + _Number(options.width);
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- that._element.attr({points: [x1, y1, x1, y2, x2, y2, x2, y1]})
- }});
- circularNeedles.TriangleNeedle = circularNeedles.SimpleIndicator.inherit({_renderPointer: function() {
- var that = this,
- options = that._options,
- y2 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- x1 = options.x - options.width / 2,
- x2 = options.x + options.width / 2;
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- that._element.attr({points: [x1, y1, options.x, y2, x2, y1]})
- }});
- circularNeedles.TwoColorRectangleNeedle = circularNeedles.SimpleIndicator.inherit({
- _renderPointer: function() {
- var that = this,
- options = that._options,
- x1 = options.x - options.width / 2,
- x2 = options.x + options.width / 2,
- y4 = options.y - options.radius,
- y1 = options.y - _Number(options.indentFromCenter),
- fraction = _Number(options.secondFraction) || 0,
- y2,
- y3;
- if (fraction >= 1)
- y2 = y3 = y1;
- else if (fraction <= 0)
- y2 = y3 = y4;
- else {
- y3 = y4 + (y1 - y4) * fraction;
- y2 = y3 + _Number(options.space)
- }
- that._firstElement = that._firstElement || that._renderer.path([], "area").append(that._rootElement);
- that._spaceElement = that._spaceElement || that._renderer.path([], "area").append(that._rootElement);
- that._secondElement = that._secondElement || that._renderer.path([], "area").append(that._rootElement);
- that._firstElement.attr({points: [x1, y1, x1, y2, x2, y2, x2, y1]});
- that._spaceElement.attr({
- points: [x1, y2, x1, y3, x2, y3, x2, y2],
- 'class': 'dxg-hole',
- fill: options.containerBackgroundColor
- });
- that._secondElement.attr({
- points: [x1, y3, x1, y4, x2, y4, x2, y3],
- 'class': 'dxg-part',
- fill: options.secondColor
- })
- },
- _clearPointer: function() {
- delete this._firstElement;
- delete this._secondElement;
- delete this._spaceElement
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearNeedle.js */
- (function(DX, undefined) {
- var linearNeedles = DX.viz.gauges.__internals.linearNeedles;
- linearNeedles.SimpleIndicator = DX.viz.gauges.__internals.BaseIndicator.inherit({
- _move: function() {
- var that = this,
- delta = that._actualPosition - that._zeroPosition;
- that._rootElement.move(that.vertical ? 0 : delta, that.vertical ? delta : 0);
- that._trackerElement && that._trackerElement.move(that.vertical ? 0 : delta, that.vertical ? delta : 0)
- },
- _isEnabled: function() {
- this.vertical = this._options.vertical;
- return this._options.length > 0 && this._options.width > 0
- },
- _isVisible: function() {
- return true
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x1,
- x2,
- y1,
- y2,
- width = options.width / 2,
- length = options.length / 2,
- p = this._zeroPosition;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- if (this.vertical) {
- x1 = options.x - length;
- x2 = options.x + length;
- y1 = p + width;
- y2 = p - width
- }
- else {
- x1 = p - width;
- x2 = p + width;
- y1 = options.y + length;
- y2 = options.y - length
- }
- return {points: [x1, y1, x1, y2, x2, y2, x2, y1]}
- },
- _render: function() {
- var that = this;
- that._zeroPosition = that._translator.getCodomainStart()
- },
- _clear: function() {
- delete this._element
- },
- measure: function(layout) {
- var p = this.vertical ? layout.x : layout.y;
- return {
- min: p - this._options.length / 2,
- max: p + this._options.length / 2
- }
- },
- getTooltipParameters: function() {
- var that = this,
- options = that._options,
- p = that._actualPosition,
- parameters = {
- x: p,
- y: p,
- value: that._currentValue,
- color: options.color,
- offset: options.width / 2
- };
- that.vertical ? parameters.x = options.x : parameters.y = options.y;
- return parameters
- }
- });
- linearNeedles.RectangleNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- p,
- x1,
- x2,
- y1,
- y2;
- that.callBase();
- p = that._zeroPosition;
- if (that.vertical) {
- x1 = options.x - options.length / 2;
- x2 = options.x + options.length / 2;
- y1 = p + options.width / 2;
- y2 = p - options.width / 2
- }
- else {
- x1 = p - options.width / 2;
- x2 = p + options.width / 2;
- y1 = options.y + options.length / 2;
- y2 = options.y - options.length / 2
- }
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- that._element.attr({points: [x1, y1, x1, y2, x2, y2, x2, y1]})
- }});
- linearNeedles.RhombusNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- x,
- y,
- dx,
- dy;
- that.callBase();
- if (that.vertical) {
- x = options.x;
- y = that._zeroPosition;
- dx = options.length / 2 || 0;
- dy = options.width / 2 || 0
- }
- else {
- x = that._zeroPosition;
- y = options.y;
- dx = options.width / 2 || 0;
- dy = options.length / 2 || 0
- }
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- that._element.attr({points: [x - dx, y, x, y - dy, x + dx, y, x, y + dy]})
- }});
- linearNeedles.CircleNeedle = linearNeedles.SimpleIndicator.inherit({_render: function() {
- var that = this,
- options = that._options,
- x,
- y,
- r;
- that.callBase();
- if (that.vertical) {
- x = options.x;
- y = that._zeroPosition
- }
- else {
- x = that._zeroPosition;
- y = options.y
- }
- r = options.length / 2 || 0;
- that._element = that._element || that._renderer.circle().append(that._rootElement);
- that._element.attr({
- cx: x,
- cy: y,
- r: r
- })
- }})
- })(DevExpress);
- /*! Module viz-gauges, file circularMarker.js */
- (function(DX, undefined) {
- var circularMarkers = DX.viz.gauges.__internals.circularMarkers,
- _Number = Number;
- circularMarkers.TriangleMarker = DX.viz.gauges.__internals.circularNeedles.SimpleIndicator.inherit({
- _isEnabled: function() {
- return this._options.length > 0 && this._options.width > 0
- },
- _isVisible: function(layout) {
- return layout.radius > 0
- },
- _render: function() {
- var that = this,
- options = that._options,
- x = options.x,
- y1 = options.y - options.radius,
- dx = options.width / 2 || 0,
- y2 = y1 - _Number(options.length),
- settings;
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- settings = {
- points: [x, y1, x - dx, y2, x + dx, y2],
- stroke: "none",
- "stroke-width": 0,
- "stroke-linecap": "square"
- };
- if (options.space > 0) {
- settings["stroke-width"] = Math.min(options.space, options.width / 4) || 0;
- settings.stroke = settings["stroke-width"] > 0 ? options.containerBackgroundColor || "none" : "none"
- }
- that._element.attr(settings).sharp()
- },
- _clear: function() {
- delete this._element
- },
- _getTrackerSettings: function() {
- var options = this._options,
- x = options.x,
- y = options.y - options.radius - options.length / 2,
- width = options.width / 2,
- length = options.length / 2;
- width > 10 || (width = 10);
- length > 10 || (length = 10);
- return {points: [x - width, y - length, x - width, y + length, x + width, y + length, x + width, y - length]}
- },
- measure: function(layout) {
- return {
- min: layout.radius,
- max: layout.radius + _Number(this._options.length)
- }
- },
- getTooltipParameters: function() {
- var options = this._options,
- cossin = DX.utils.getCosAndSin(this._actualPosition),
- r = options.radius + options.length / 2,
- parameters = this.callBase();
- parameters.x = options.x + cossin.cos * r;
- parameters.y = options.y - cossin.sin * r;
- parameters.offset = options.length / 2;
- return parameters
- }
- });
- circularMarkers.TextCloudMarker = DX.viz.gauges.__internals.BaseTextCloudMarker.inherit({
- _isEnabled: function() {
- return true
- },
- _isVisible: function(layout) {
- return layout.radius > 0
- },
- _getTextCloudOptions: function() {
- var that = this,
- cossin = DX.utils.getCosAndSin(that._actualPosition),
- nangle = DX.utils.normalizeAngle(that._actualPosition);
- return {
- x: that._options.x + cossin.cos * that._options.radius,
- y: that._options.y - cossin.sin * that._options.radius,
- type: nangle > 270 ? "left-top" : nangle > 180 ? "top-right" : nangle > 90 ? "right-bottom" : "bottom-left"
- }
- },
- measure: function(layout) {
- var that = this,
- arrowLength = _Number(that._options.arrowLength) || 0,
- verticalOffset,
- horizontalOffset;
- that._measureText();
- verticalOffset = that._textFullHeight + arrowLength;
- horizontalOffset = that._textFullWidth + arrowLength;
- return {
- min: layout.radius,
- max: layout.radius,
- horizontalOffset: horizontalOffset,
- verticalOffset: verticalOffset,
- inverseHorizontalOffset: horizontalOffset,
- inverseVerticalOffset: verticalOffset
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearMarker.js */
- (function(DX, undefined) {
- var linearMarkers = DX.viz.gauges.__internals.linearMarkers,
- _Number = Number,
- _String = String;
- linearMarkers.TriangleMarker = DX.viz.gauges.__internals.linearNeedles.SimpleIndicator.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return that._options.length > 0 && that._options.width > 0
- },
- _isVisible: function() {
- return true
- },
- _render: function() {
- var that = this,
- options = that._options,
- x1,
- x2,
- y1,
- y2,
- settings = {
- stroke: 'none',
- "stroke-width": 0,
- "stroke-linecap": "square"
- };
- that.callBase();
- if (that.vertical) {
- x1 = options.x;
- y1 = that._zeroPosition;
- x2 = x1 + _Number(that._inverted ? options.length : -options.length);
- settings.points = [x1, y1, x2, y1 - options.width / 2, x2, y1 + options.width / 2]
- }
- else {
- y1 = options.y;
- x1 = that._zeroPosition;
- y2 = y1 + _Number(that._inverted ? options.length : -options.length);
- settings.points = [x1, y1, x1 - options.width / 2, y2, x1 + options.width / 2, y2]
- }
- if (options.space > 0) {
- settings["stroke-width"] = Math.min(options.space, options.width / 4) || 0;
- settings.stroke = settings["stroke-width"] > 0 ? options.containerBackgroundColor || 'none' : 'none'
- }
- that._element = that._element || that._renderer.path([], "area").append(that._rootElement);
- that._element.attr(settings).sharp()
- },
- _getTrackerSettings: function() {
- var that = this,
- options = that._options,
- width = options.width / 2,
- length = _Number(options.length),
- x1,
- x2,
- y1,
- y2,
- result;
- width > 10 || (width = 10);
- length > 20 || (length = 20);
- if (that.vertical) {
- x1 = x2 = options.x;
- x2 = x1 + (that._inverted ? length : -length);
- y1 = that._zeroPosition + width;
- y2 = that._zeroPosition - width;
- result = [x1, y1, x2, y1, x2, y2, x1, y2]
- }
- else {
- y1 = options.y;
- y2 = y1 + (that._inverted ? length : -length);
- x1 = that._zeroPosition - width;
- x2 = that._zeroPosition + width;
- result = [x1, y1, x1, y2, x2, y2, x2, y1]
- }
- return {points: result}
- },
- measure: function(layout) {
- var that = this,
- length = _Number(that._options.length),
- minbound,
- maxbound;
- if (that.vertical) {
- minbound = maxbound = layout.x;
- if (that._inverted)
- maxbound = minbound + length;
- else
- minbound = maxbound - length
- }
- else {
- minbound = maxbound = layout.y;
- if (that._inverted)
- maxbound = minbound + length;
- else
- minbound = maxbound - length
- }
- return {
- min: minbound,
- max: maxbound,
- indent: that._options.width / 2
- }
- },
- getTooltipParameters: function() {
- var that = this,
- options = that._options,
- s = (that._inverted ? options.length : -options.length) / 2,
- parameters = that.callBase();
- that.vertical ? parameters.x += s : parameters.y += s;
- parameters.offset = options.length / 2;
- return parameters
- }
- });
- linearMarkers.TextCloudMarker = DX.viz.gauges.__internals.BaseTextCloudMarker.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return true
- },
- _isVisible: function() {
- return true
- },
- _getTextCloudOptions: function() {
- var that = this,
- x = that._actualPosition,
- y = that._actualPosition,
- type;
- if (that.vertical) {
- x = that._options.x;
- type = that._inverted ? 'top-left' : 'top-right'
- }
- else {
- y = that._options.y;
- type = that._inverted ? 'right-top' : 'right-bottom'
- }
- return {
- x: x,
- y: y,
- type: type
- }
- },
- measure: function(layout) {
- var that = this,
- minbound,
- maxbound,
- arrowLength = _Number(that._options.arrowLength) || 0,
- indent;
- that._measureText();
- if (that.vertical) {
- indent = that._textFullHeight;
- if (that._inverted) {
- minbound = layout.x;
- maxbound = layout.x + arrowLength + that._textFullWidth
- }
- else {
- minbound = layout.x - arrowLength - that._textFullWidth;
- maxbound = layout.x
- }
- }
- else {
- indent = that._textFullWidth;
- if (that._inverted) {
- minbound = layout.y;
- maxbound = layout.y + arrowLength + that._textFullHeight
- }
- else {
- minbound = layout.y - arrowLength - that._textFullHeight;
- maxbound = layout.y
- }
- }
- return {
- min: minbound,
- max: maxbound,
- indent: indent
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file circularRangeBar.js */
- (function(DX, undefined) {
- var _Number = Number,
- getCosAndSin = DX.utils.getCosAndSin,
- convertAngleToRendererSpace = DX.utils.convertAngleToRendererSpace,
- max = Math.max,
- min = Math.min;
- DX.viz.gauges.__internals.CircularRangeBar = DX.viz.gauges.__internals.BaseRangeBar.inherit({
- _isEnabled: function() {
- return this._options.size > 0
- },
- _isVisible: function(layout) {
- return layout.radius - _Number(this._options.size) > 0
- },
- _createBarItem: function() {
- return this._renderer.arc().attr({"stroke-linejoin": "round"}).append(this._rootElement)
- },
- _createTracker: function() {
- return this._renderer.arc().attr({"stroke-linejoin": "round"})
- },
- _setBarSides: function() {
- var that = this;
- that._maxSide = that._options.radius;
- that._minSide = that._maxSide - _Number(that._options.size)
- },
- _getSpace: function() {
- var options = this._options;
- return options.space > 0 ? options.space * 180 / options.radius / Math.PI : 0
- },
- _isTextVisible: function() {
- var options = this._options.text || {};
- return options.indent > 0
- },
- _setTextItemsSides: function() {
- var that = this,
- options = that._options,
- indent = _Number(options.text.indent);
- that._lineFrom = options.y - options.radius;
- that._lineTo = that._lineFrom - indent;
- that._textRadius = options.radius + indent
- },
- _getPositions: function() {
- var that = this,
- basePosition = that._basePosition,
- actualPosition = that._actualPosition,
- mainPosition1,
- mainPosition2;
- if (basePosition >= actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- return {
- start: that._startPosition,
- end: that._endPosition,
- main1: mainPosition1,
- main2: mainPosition2,
- back1: min(mainPosition1 + that._space, that._startPosition),
- back2: max(mainPosition2 - that._space, that._endPosition)
- }
- },
- _buildItemSettings: function(from, to) {
- var that = this;
- return {
- x: that._options.x,
- y: that._options.y,
- innerRadius: that._minSide,
- outerRadius: that._maxSide,
- startAngle: to,
- endAngle: from
- }
- },
- _updateTextPosition: function() {
- var that = this,
- cossin = getCosAndSin(that._actualPosition),
- x = that._options.x + that._textRadius * cossin.cos,
- y = that._options.y - that._textRadius * cossin.sin;
- x += cossin.cos * that._textWidth * 0.6;
- y -= cossin.sin * that._textHeight * 0.6;
- that._text.attr({
- x: x,
- y: y + that._textVerticalOffset
- })
- },
- _updateLinePosition: function() {
- var that = this,
- x = that._options.x,
- x1,
- x2;
- if (that._basePosition > that._actualPosition) {
- x1 = x - 2;
- x2 = x
- }
- else if (that._basePosition < that._actualPosition) {
- x1 = x;
- x2 = x + 2
- }
- else {
- x1 = x - 1;
- x2 = x + 1
- }
- that._line.attr({points: [x1, that._lineFrom, x1, that._lineTo, x2, that._lineTo, x2, that._lineFrom]}).rotate(convertAngleToRendererSpace(that._actualPosition), x, that._options.y).sharp()
- },
- _getTooltipPosition: function() {
- var that = this,
- cossin = getCosAndSin((that._basePosition + that._actualPosition) / 2),
- r = (that._minSide + that._maxSide) / 2;
- return {
- x: that._options.x + cossin.cos * r,
- y: that._options.y - cossin.sin * r
- }
- },
- measure: function(layout) {
- var that = this,
- result = {
- min: layout.radius - _Number(that._options.size),
- max: layout.radius
- };
- that._measureText();
- if (that._hasText) {
- result.max += _Number(that._options.text.indent);
- result.horizontalOffset = that._textWidth;
- result.verticalOffset = that._textHeight
- }
- return result
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file linearRangeBar.js */
- (function(DX, undefined) {
- var _Number = Number,
- _String = String;
- DX.viz.gauges.__internals.LinearRangeBar = DX.viz.gauges.__internals.BaseRangeBar.inherit({
- _isEnabled: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inverted = that.vertical ? _String(that._options.horizontalOrientation).toLowerCase() === 'right' : _String(that._options.verticalOrientation).toLowerCase() === 'bottom';
- return that._options.size > 0
- },
- _isVisible: function() {
- return true
- },
- _createBarItem: function() {
- return this._renderer.path([], "area").append(this._rootElement)
- },
- _createTracker: function() {
- return this._renderer.path([], "area")
- },
- _setBarSides: function() {
- var that = this,
- options = that._options,
- size = _Number(options.size),
- minSide,
- maxSide;
- if (that.vertical)
- if (that._inverted) {
- minSide = options.x;
- maxSide = options.x + size
- }
- else {
- minSide = options.x - size;
- maxSide = options.x
- }
- else if (that._inverted) {
- minSide = options.y;
- maxSide = options.y + size
- }
- else {
- minSide = options.y - size;
- maxSide = options.y
- }
- that._minSide = minSide;
- that._maxSide = maxSide;
- that._minBound = minSide;
- that._maxBound = maxSide
- },
- _getSpace: function() {
- var options = this._options;
- return options.space > 0 ? _Number(options.space) : 0
- },
- _isTextVisible: function() {
- var textOptions = this._options.text || {};
- return textOptions.indent > 0 || textOptions.indent < 0
- },
- _getTextAlign: function() {
- return this.vertical ? this._options.text.indent > 0 ? 'left' : 'right' : 'center'
- },
- _setTextItemsSides: function() {
- var that = this,
- indent = _Number(that._options.text.indent);
- if (indent > 0) {
- that._lineStart = that._maxSide;
- that._lineEnd = that._maxSide + indent;
- that._textPosition = that._lineEnd + (that.vertical ? 2 : that._textHeight / 2);
- that._maxBound = that._textPosition + (that.vertical ? that._textWidth : that._textHeight / 2)
- }
- else if (indent < 0) {
- that._lineStart = that._minSide;
- that._lineEnd = that._minSide + indent;
- that._textPosition = that._lineEnd - (that.vertical ? 2 : that._textHeight / 2);
- that._minBound = that._textPosition - (that.vertical ? that._textWidth : that._textHeight / 2)
- }
- },
- _getPositions: function() {
- var that = this,
- startPosition = that._startPosition,
- endPosition = that._endPosition,
- space = that._space,
- basePosition = that._basePosition,
- actualPosition = that._actualPosition,
- mainPosition1,
- mainPosition2,
- backPosition1,
- backPosition2;
- if (startPosition < endPosition) {
- if (basePosition < actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- backPosition1 = mainPosition1 - space;
- backPosition2 = mainPosition2 + space
- }
- else {
- if (basePosition > actualPosition) {
- mainPosition1 = basePosition;
- mainPosition2 = actualPosition
- }
- else {
- mainPosition1 = actualPosition;
- mainPosition2 = basePosition
- }
- backPosition1 = mainPosition1 + space;
- backPosition2 = mainPosition2 - space
- }
- return {
- start: startPosition,
- end: endPosition,
- main1: mainPosition1,
- main2: mainPosition2,
- back1: backPosition1,
- back2: backPosition2
- }
- },
- _buildItemSettings: function(from, to) {
- var that = this,
- side1 = that._minSide,
- side2 = that._maxSide,
- points = that.vertical ? [side1, from, side1, to, side2, to, side2, from] : [from, side1, from, side2, to, side2, to, side1];
- return {points: points}
- },
- _updateTextPosition: function() {
- var that = this;
- that._text.attr(that.vertical ? {
- x: that._textPosition,
- y: that._actualPosition + that._textVerticalOffset
- } : {
- x: that._actualPosition,
- y: that._textPosition + that._textVerticalOffset
- })
- },
- _updateLinePosition: function() {
- var that = this,
- actualPosition = that._actualPosition,
- side1,
- side2,
- points;
- if (that.vertical) {
- if (that._basePosition >= actualPosition) {
- side1 = actualPosition;
- side2 = actualPosition + 2
- }
- else {
- side1 = actualPosition - 2;
- side2 = actualPosition
- }
- points = [that._lineStart, side1, that._lineStart, side2, that._lineEnd, side2, that._lineEnd, side1]
- }
- else {
- if (that._basePosition <= actualPosition) {
- side1 = actualPosition - 2;
- side2 = actualPosition
- }
- else {
- side1 = actualPosition;
- side2 = actualPosition + 2
- }
- points = [side1, that._lineStart, side1, that._lineEnd, side2, that._lineEnd, side2, that._lineStart]
- }
- that._line.attr({points: points}).sharp()
- },
- _getTooltipPosition: function() {
- var that = this,
- crossCenter = (that._minSide + that._maxSide) / 2,
- alongCenter = (that._basePosition + that._actualPosition) / 2;
- return that.vertical ? {
- x: crossCenter,
- y: alongCenter
- } : {
- x: alongCenter,
- y: crossCenter
- }
- },
- measure: function(layout) {
- var that = this,
- size = _Number(that._options.size),
- textIndent = _Number(that._options.text.indent),
- minbound,
- maxbound,
- indent;
- that._measureText();
- if (that.vertical) {
- minbound = maxbound = layout.x;
- if (that._inverted)
- maxbound = maxbound + size;
- else
- minbound = minbound - size;
- if (that._hasText) {
- indent = that._textHeight / 2;
- if (textIndent > 0)
- maxbound += textIndent + that._textWidth;
- if (textIndent < 0)
- minbound += textIndent - that._textWidth
- }
- }
- else {
- minbound = maxbound = layout.y;
- if (that._inverted)
- maxbound = maxbound + size;
- else
- minbound = minbound - size;
- if (that._hasText) {
- indent = that._textWidth / 2;
- if (textIndent > 0)
- maxbound += textIndent + that._textHeight;
- if (textIndent < 0)
- minbound += textIndent - that._textHeight
- }
- }
- return {
- min: minbound,
- max: maxbound,
- indent: indent
- }
- }
- })
- })(DevExpress);
- /*! Module viz-gauges, file scale.js */
- (function(DX, $, undefined) {
- var viz = DX.viz,
- core = viz.core,
- _Number = Number,
- _String = String,
- _isFinite = isFinite,
- _math = Math,
- _min = _math.min,
- _max = _math.max,
- _abs = _math.abs,
- PI_DIV_180 = _math.PI / 180,
- utils = DX.utils,
- _isFunction = utils.isFunction,
- _isArray = utils.isArray,
- _getCosAndSin = utils.getCosAndSin,
- _convertAngleToRendererSpace = utils.convertAngleToRendererSpace,
- _map = $.map,
- _formatHelper = DX.formatHelper,
- _createTickManager = core.CoreFactory.createTickManager;
- function binarySearch(x, list) {
- var a = 0,
- b = list.length - 1,
- flag = list[a] - list[b] < 0,
- c,
- k = -1;
- if (list[a] === x)
- k = a;
- if (list[b] === x)
- k = b;
- while (k < 0 && a <= b) {
- c = ~~((a + b) / 2);
- if (list[c] === x)
- k = c;
- else if (list[c] - x < 0 === flag)
- a = c + 1;
- else
- b = c - 1
- }
- return k
- }
- function sortAsc(x, y) {
- return x - y
- }
- viz.gauges.__internals.BaseScale = viz.gauges.__internals.BaseElement.inherit({
- _init: function() {
- var that = this;
- that._root = that._renderer.g().attr({'class': 'dxg-scale'});
- that._majorTicks = that._renderer.g().attr({'class': 'dxg-major-ticks'});
- that._minorTicks = that._renderer.g().attr({'class': 'dxg-minor-ticks'});
- that._labels = that._renderer.g().attr({'class': 'dxg-labels'})
- },
- clean: function() {
- var that = this;
- that._root.remove();
- that._majorTicks.remove().clear();
- that._minorTicks.remove().clear();
- that._labels.remove().clear();
- that._majorTicksEnabled = that._minorTicksEnabled = that._labelsEnabled = that._options = that.enabled = null;
- return that
- },
- render: function(options) {
- var that = this;
- that._options = options;
- that._processOptions(options);
- if (that._majorTicksEnabled || that._minorTicksEnabled || that._labelsEnabled) {
- that.enabled = true;
- that._root.append(that._container);
- if (that._majorTicksEnabled)
- that._majorTicks.append(that._root);
- if (that._minorTicksEnabled)
- that._minorTicks.append(that._root);
- if (that._labelsEnabled) {
- that._labels.append(that._root);
- that._measureText()
- }
- }
- return that
- },
- _processOptions: function(options) {
- var that = this;
- that._majorTicksEnabled = options.majorTick.visible && options.majorTick.length > 0 && options.majorTick.width > 0;
- that._minorTicksEnabled = options.minorTick.visible && options.minorTick.length > 0 && options.minorTick.width > 0;
- that._labelsEnabled = options.label.visible && _Number(options.label.indentFromTick) !== 0;
- that._setupOrientation()
- },
- _measureText: function() {
- var that = this,
- domain = that._translator.getDomain(),
- options = that._options,
- tickManager = _createTickManager({}, {
- min: domain[0],
- max: domain[1],
- screenDelta: options.approximateScreenDelta
- }, {
- tickInterval: options.majorTick.tickInterval > 0 ? _Number(options.majorTick.tickInterval) : undefined,
- stick: true,
- textFontStyles: core.utils.patchFontOptions(options.label.font),
- gridSpacingFactor: that._getGridSpacingFactor().majorTicks,
- renderText: function(text, x, y, options) {
- return that._renderer.text(text, x, y, options).append(that._renderer.root)
- },
- getText: function(value) {
- return that._formatValue(value)
- },
- overlappingBehaviorType: that._overlappingBehaviorType
- }),
- maxTextParams = tickManager.getMaxLabelParams();
- that._textVerticalOffset = -maxTextParams.y - maxTextParams.height / 2;
- that._textWidth = maxTextParams.width;
- that._textHeight = maxTextParams.height;
- that._textLength = maxTextParams.length
- },
- _formatValue: function(value) {
- var options = this._options.label,
- text = _formatHelper.format(value, options.format, options.precision);
- if (_isFunction(options.customizeText)) {
- text = {
- value: value,
- valueText: text
- };
- text = _String(options.customizeText.call(text, text))
- }
- return text
- },
- _setupOrientation: null,
- _getCustomValues: function(values, compare) {
- var translator = this._translator,
- result = [];
- if (_isArray(values)) {
- result = _map(values, function(x) {
- return _isFinite(translator.translate(x)) ? _Number(x) : null
- }).sort(compare);
- result = _map(result, function(x, i) {
- return x !== result[i - 1] ? x : null
- })
- }
- return result
- },
- _getLabelPosition: function(layout) {
- return this._getAxisLabelPosition(_Number(this._options.majorTick.length), _Number(this._options.label.indentFromTick), layout)
- },
- _generateTicks: function(layout) {
- var that = this,
- scaleOptions = that._options,
- translatorDomains = that._translator.getDomain(),
- data = {
- min: translatorDomains[0],
- max: translatorDomains[1],
- screenDelta: that._getScreenDelta(layout)
- },
- gridSpacingFactors = that._getGridSpacingFactor(),
- options = {
- tickInterval: scaleOptions.majorTick.tickInterval > 0 ? _Number(scaleOptions.majorTick.tickInterval) : undefined,
- minorTickInterval: scaleOptions.minorTick.tickInterval > 0 ? _Number(scaleOptions.minorTick.tickInterval) : undefined,
- gridSpacingFactor: gridSpacingFactors.majorTicks,
- minorGridSpacingFactor: gridSpacingFactors.minorTicks,
- numberMultipliers: [1, 2, 5],
- textFontStyles: core.utils.patchFontOptions(scaleOptions.label.font),
- labelOptions: scaleOptions.label,
- getText: function(value) {
- return that._formatValue(value)
- },
- isHorizontal: !that.vertical,
- stick: true,
- showMinorTicks: true
- },
- tickManager;
- if (scaleOptions.majorTick.useTicksAutoArrangement) {
- options.useTicksAutoArrangement = true;
- options.renderText = function(text, x, y, options) {
- return that._renderer.text(text, x, y, options).append(that._renderer.root)
- };
- options.translate = that._getTranslateFunction(layout);
- that._applyOverlappingOptions(options, layout)
- }
- tickManager = _createTickManager({}, data, options);
- return {
- majorTicks: tickManager.getTicks(true),
- minorTicks: tickManager.getMinorTicks()
- }
- },
- _getTicks: function(layout) {
- var that = this,
- options = that._options,
- info = that._generateTicks(layout),
- majorValues = options.majorTick.showCalculatedTicks ? info.majorTicks : [],
- customMajorValues = _map(that._getCustomValues(options.majorTick.customTickValues, sortAsc), function(value) {
- return binarySearch(value, majorValues) === -1 ? value : null
- }),
- minorValues = _map(options.minorTick.showCalculatedTicks ? info.minorTicks : [], function(value) {
- return binarySearch(value, customMajorValues) === -1 ? value : null
- }),
- customMinorValues = that._getCustomValues(options.minorTick.customTickValues, sortAsc),
- list = majorValues.concat(minorValues, customMajorValues).sort(sortAsc);
- customMinorValues = _map(customMinorValues, function(value) {
- return binarySearch(value, list) === -1 ? value : null
- });
- return {
- major: _map(majorValues.concat(customMajorValues), function(value) {
- return {
- value: value,
- position: that._translator.translate(value)
- }
- }),
- minor: _map(minorValues.concat(customMinorValues), function(value) {
- return {
- value: value,
- position: that._translator.translate(value)
- }
- })
- }
- },
- _createMajorTicks: function(ticks, layout) {
- var that = this,
- points,
- i = 0,
- ii = ticks.length,
- element;
- that._majorTicks.clear().attr({fill: that._options.majorTick.color});
- points = that._getTickPoints(_Number(that._options.majorTick.length), _Number(that._options.majorTick.width), layout);
- if (points) {
- that._options.hideFirstTick && ++i;
- that._options.hideLastTick && --ii;
- for (; i < ii; ++i) {
- element = that._renderer.path(points, "area");
- that._moveTick(element, ticks[i], layout);
- element.append(that._majorTicks)
- }
- }
- },
- _createMinorTicks: function(ticks, layout) {
- var that = this,
- points,
- i = 0,
- ii = ticks.length,
- element;
- that._minorTicks.clear().attr({fill: that._options.minorTick.color});
- points = that._getTickPoints(_Number(that._options.minorTick.length), _Number(that._options.minorTick.width), layout);
- if (points)
- for (; i < ii; ++i) {
- element = that._renderer.path(points, "area");
- that._moveTick(element, ticks[i], layout);
- element.append(that._minorTicks)
- }
- },
- _createLabels: function(ticks, layout) {
- var that = this,
- indentFromTick = _Number(that._options.label.indentFromTick),
- textPosition,
- i = 0,
- ii = ticks.length,
- points,
- text,
- fontStyles = {},
- rangeContainer;
- that._labels.clear().attr({align: that._getLabelAlign(indentFromTick)}).css(core.utils.patchFontOptions(that._options.label.font));
- textPosition = that._getLabelPosition(layout);
- if (textPosition) {
- rangeContainer = that._options.label.useRangeColors ? that._options.rangeContainer : null;
- that._options.hideFirstLabel && ++i;
- that._options.hideLastLabel && --ii;
- for (; i < ii; ++i) {
- text = that._formatValue(ticks[i].value);
- fontStyles.fill = rangeContainer ? rangeContainer.getColorForValue(ticks[i].value) : null;
- points = that._getLabelOptions(text, textPosition, indentFromTick, ticks[i], layout);
- that._renderer.text(text, points.x, points.y + that._textVerticalOffset).css(fontStyles).append(that._labels)
- }
- }
- },
- resize: function(layout) {
- var that = this,
- ticks = that._getTicks(layout);
- if (that._majorTicksEnabled)
- that._createMajorTicks(ticks.major, layout);
- if (that._minorTicksEnabled)
- that._createMinorTicks(ticks.minor, layout);
- if (that._labelsEnabled)
- that._createLabels(ticks.major, layout);
- return that
- }
- });
- viz.gauges.__internals.CircularScale = viz.gauges.__internals.BaseScale.inherit({
- _getGridSpacingFactor: function() {
- return {
- majorTicks: 17,
- minorTicks: 5
- }
- },
- _getTranslateFunction: function(layout) {
- var that = this,
- indent = _Number(that._options.label.indentFromTick),
- translator = this._translator;
- layout = layout || {
- x: 0,
- y: 0,
- radius: 0
- };
- return function(value) {
- var position = that._getLabelPosition(layout),
- text = that._formatValue(value);
- return that._getLabelOptions(text, position, indent, {position: translator.translate(value)}, layout)
- }
- },
- _overlappingBehaviorType: "circular",
- _getScreenDelta: function(layout) {
- return (this._translator.getCodomainStart() - this._translator.getCodomainEnd()) * layout.radius * PI_DIV_180
- },
- _setupOrientation: function() {
- var that = this;
- that._inner = that._outer = 0;
- switch (that._options.orientation) {
- case'inside':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _getTickPoints: function(length, width, layout) {
- var x1 = layout.x - width / 2,
- x2 = layout.x + width / 2,
- y1 = layout.y - layout.radius - length * this._outer,
- y2 = layout.y - layout.radius + length * this._inner;
- return y1 > 0 && y2 > 0 ? [x1, y1, x2, y1, x2, y2, x1, y2] : null
- },
- _moveTick: function(element, tick, layout) {
- element.rotate(_convertAngleToRendererSpace(tick.position), layout.x, layout.y)
- },
- _getAxisLabelPosition: function(tickLength, textIndent, layout) {
- var position = layout.radius + tickLength * (textIndent >= 0 ? this._outer : -this._inner) + textIndent;
- return position > 0 ? position : null
- },
- _getLabelAlign: function() {
- return 'center'
- },
- _applyOverlappingOptions: function(options, layout) {
- options.circularRadius = this._getLabelPosition(layout);
- options.circularStartAngle = this._translator.getCodomainStart();
- options.circularEndAngle = this._translator.getCodomainEnd();
- options.overlappingBehaviorType = "circular"
- },
- _getLabelOptions: function(textValue, textPosition, textIndent, tick, layout) {
- var cossin = _getCosAndSin(tick.position),
- x = layout.x + cossin.cos * textPosition,
- y = layout.y - cossin.sin * textPosition,
- dx = cossin.cos * (textValue.length / this._textLength) * this._textWidth / 2,
- dy = cossin.sin * this._textHeight / 2;
- if (textIndent > 0) {
- x += dx;
- y -= dy
- }
- else {
- x -= dx;
- y += dy
- }
- return {
- x: x,
- y: y
- }
- },
- measure: function(layout) {
- var that = this,
- result = {
- min: layout.radius,
- max: layout.radius
- };
- if (that._majorTicksEnabled) {
- result.min = _min(result.min, layout.radius - that._inner * that._options.majorTick.length);
- result.max = _max(result.max, layout.radius + that._outer * that._options.majorTick.length)
- }
- if (that._minorTicksEnabled) {
- result.min = _min(result.min, layout.radius - that._inner * that._options.minorTick.length);
- result.max = _max(result.max, layout.radius + that._outer * that._options.minorTick.length)
- }
- if (that._labelsEnabled) {
- if (that._options.label.indentFromTick > 0) {
- result.horizontalOffset = _Number(that._options.label.indentFromTick) + that._textWidth;
- result.verticalOffset = _Number(that._options.label.indentFromTick) + that._textHeight
- }
- else {
- result.horizontalOffset = result.verticalOffset = 0;
- result.min -= -_Number(that._options.label.indentFromTick) + _max(that._textWidth, that._textHeight)
- }
- result.inverseHorizontalOffset = that._textWidth / 2;
- result.inverseVerticalOffset = that._textHeight / 2
- }
- return result
- }
- });
- viz.gauges.__internals.LinearScale = viz.gauges.__internals.BaseScale.inherit({
- _getGridSpacingFactor: function() {
- return {
- majorTicks: 25,
- minorTicks: 5
- }
- },
- _getTranslateFunction: function() {
- var tr = this._translator;
- return function(value) {
- return tr.translate(value)
- }
- },
- _overlappingBehaviorType: "linear",
- _getScreenDelta: function() {
- return _abs(this._translator.getCodomainEnd() - this._translator.getCodomainStart())
- },
- _setupOrientation: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inner = that._outer = 0;
- if (that.vertical)
- switch (that._options.horizontalOrientation) {
- case'left':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- else
- switch (that._options.verticalOrientation) {
- case'top':
- that._inner = 1;
- break;
- case'middle':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _getTickPoints: function(length, width, layout) {
- var that = this,
- x1,
- x2,
- y1,
- y2;
- if (that.vertical) {
- x1 = layout.x - length * that._inner;
- x2 = layout.x + length * that._outer;
- y1 = -width / 2;
- y2 = +width / 2
- }
- else {
- x1 = -width / 2;
- x2 = +width / 2;
- y1 = layout.y - length * that._inner;
- y2 = layout.y + length * that._outer
- }
- return [x1, y1, x2, y1, x2, y2, x1, y2]
- },
- _moveTick: function(element, tick) {
- var x = 0,
- y = 0;
- if (this.vertical)
- y = tick.position;
- else
- x = tick.position;
- element.move(x, y)
- },
- _getAxisLabelPosition: function(tickLength, textIndent, layout) {
- var position = tickLength * (textIndent >= 0 ? this._outer : -this._inner) + textIndent;
- if (this.vertical)
- position += layout.x;
- else
- position += layout.y + (textIndent >= 0 ? 1 : -1) * (this._textVerticalOffset || 0);
- return position
- },
- _getLabelAlign: function(textIndent) {
- return this.vertical ? textIndent > 0 ? 'left' : 'right' : 'center'
- },
- _applyOverlappingOptions: function(options) {
- options.overlappingBehaviorType = "linear"
- },
- _getLabelOptions: function(textValue, textPosition, textIndent, tick) {
- var x,
- y;
- if (this.vertical) {
- x = textPosition;
- y = tick.position
- }
- else {
- x = tick.position;
- y = textPosition
- }
- return {
- x: x,
- y: y
- }
- },
- measure: function(layout) {
- var that = this,
- p = layout[that.vertical ? 'x' : 'y'],
- result = {
- min: p,
- max: p
- };
- if (that._majorTicksEnabled) {
- result.min = _min(result.min, p - that._inner * that._options.majorTick.length);
- result.max = _max(result.max, p + that._outer * that._options.majorTick.length)
- }
- if (that._minorTicksEnabled) {
- result.min = _min(result.min, p - that._inner * that._options.minorTick.length);
- result.max = _max(result.max, p + that._outer * that._options.minorTick.length)
- }
- if (that._labelsEnabled) {
- if (that._options.label.indentFromTick > 0)
- result.max += +_Number(that._options.label.indentFromTick) + that[that.vertical ? '_textWidth' : '_textHeight'];
- else
- result.min -= -_Number(that._options.label.indentFromTick) + that[that.vertical ? '_textWidth' : '_textHeight'];
- result.indent = that[that.vertical ? '_textHeight' : '_textWidth'] / 2
- }
- return result
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file rangeContainer.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _max = Math.max,
- _abs = Math.abs,
- _isString = DX.utils.isString,
- _isArray = DX.utils.isArray,
- _isFinite = isFinite,
- _each = $.each,
- _map = $.map,
- _Palette = DX.viz.core.Palette;
- DX.viz.gauges.__internals.BaseRangeContainer = DX.viz.gauges.__internals.BaseElement.inherit({
- _init: function() {
- this._root = this._renderer.g().attr({'class': 'dxg-range-container'})
- },
- clean: function() {
- this._root.remove().clear();
- this._options = this.enabled = null;
- return this
- },
- _getRanges: function() {
- var that = this,
- options = that._options,
- translator = that._translator,
- totalStart = translator.getDomain()[0],
- totalEnd = translator.getDomain()[1],
- totalDelta = totalEnd - totalStart,
- isNotEmptySegment = totalDelta >= 0 ? isNotEmptySegmentAsc : isNotEmptySegmentDes,
- subtractSegment = totalDelta >= 0 ? subtractSegmentAsc : subtractSegmentDes,
- list = [],
- ranges = [],
- backgroundRanges = [{
- start: totalStart,
- end: totalEnd
- }],
- threshold = _abs(totalDelta) / 1E4,
- palette = new _Palette(options.palette, {
- type: 'indicatingSet',
- theme: options.themeName
- }),
- backgroundColor = _isString(options.backgroundColor) ? options.backgroundColor : 'none',
- width = options.width || {},
- startWidth = _Number(width > 0 ? width : width.start),
- endWidth = _Number(width > 0 ? width : width.end),
- deltaWidth = endWidth - startWidth;
- if (options.ranges !== undefined && !_isArray(options.ranges))
- return null;
- if (!(startWidth >= 0 && endWidth >= 0 && startWidth + endWidth > 0))
- return null;
- list = _map(_isArray(options.ranges) ? options.ranges : [], function(rangeOptions, i) {
- rangeOptions = rangeOptions || {};
- var start = translator.adjust(rangeOptions.startValue),
- end = translator.adjust(rangeOptions.endValue);
- return _isFinite(start) && _isFinite(end) && isNotEmptySegment(start, end, threshold) ? {
- start: start,
- end: end,
- color: rangeOptions.color,
- classIndex: i
- } : null
- });
- _each(list, function(i, item) {
- var paletteColor = palette.getNextColor();
- item.color = _isString(item.color) && item.color || paletteColor || 'none';
- item.className = 'dxg-range dxg-range-' + item.classIndex;
- delete item.classIndex
- });
- _each(list, function(_, item) {
- var i,
- ii,
- sub,
- subs,
- range,
- newRanges = [],
- newBackgroundRanges = [];
- for (i = 0, ii = ranges.length; i < ii; ++i) {
- range = ranges[i];
- subs = subtractSegment(range.start, range.end, item.start, item.end);
- (sub = subs[0]) && (sub.color = range.color) && (sub.className = range.className) && newRanges.push(sub);
- (sub = subs[1]) && (sub.color = range.color) && (sub.className = range.className) && newRanges.push(sub)
- }
- newRanges.push(item);
- ranges = newRanges;
- for (i = 0, ii = backgroundRanges.length; i < ii; ++i) {
- range = backgroundRanges[i];
- subs = subtractSegment(range.start, range.end, item.start, item.end);
- (sub = subs[0]) && newBackgroundRanges.push(sub);
- (sub = subs[1]) && newBackgroundRanges.push(sub)
- }
- backgroundRanges = newBackgroundRanges
- });
- _each(backgroundRanges, function(_, range) {
- range.color = backgroundColor;
- range.className = 'dxg-range dxg-background-range';
- ranges.push(range)
- });
- _each(ranges, function(_, range) {
- range.startWidth = (range.start - totalStart) / totalDelta * deltaWidth + startWidth;
- range.endWidth = (range.end - totalStart) / totalDelta * deltaWidth + startWidth
- });
- return ranges
- },
- render: function(options) {
- var that = this;
- that._options = options;
- that._processOptions();
- that._ranges = that._getRanges();
- if (that._ranges) {
- that.enabled = true;
- that._root.append(that._container)
- }
- return that
- },
- resize: function(layout) {
- var that = this;
- that._root.clear();
- if (that._isVisible(layout))
- _each(that._ranges, function(_, range) {
- that._createRange(range, layout).attr({
- fill: range.color,
- 'class': range.className
- }).append(that._root)
- });
- return that
- },
- _processOptions: null,
- _isVisible: null,
- _createRange: null,
- getColorForValue: function(value) {
- var color = null;
- _each(this._ranges, function(_, range) {
- if (range.start <= value && value <= range.end || range.start >= value && value >= range.end) {
- color = range.color;
- return false
- }
- });
- return color
- }
- });
- function subtractSegmentAsc(segmentStart, segmentEnd, otherStart, otherEnd) {
- var result;
- if (otherStart > segmentStart && otherEnd < segmentEnd)
- result = [{
- start: segmentStart,
- end: otherStart
- }, {
- start: otherEnd,
- end: segmentEnd
- }];
- else if (otherStart >= segmentEnd || otherEnd <= segmentStart)
- result = [{
- start: segmentStart,
- end: segmentEnd
- }];
- else if (otherStart <= segmentStart && otherEnd >= segmentEnd)
- result = [];
- else if (otherStart > segmentStart)
- result = [{
- start: segmentStart,
- end: otherStart
- }];
- else if (otherEnd < segmentEnd)
- result = [{
- start: otherEnd,
- end: segmentEnd
- }];
- return result
- }
- function subtractSegmentDes(segmentStart, segmentEnd, otherStart, otherEnd) {
- var result;
- if (otherStart < segmentStart && otherEnd > segmentEnd)
- result = [{
- start: segmentStart,
- end: otherStart
- }, {
- start: otherEnd,
- end: segmentEnd
- }];
- else if (otherStart <= segmentEnd || otherEnd >= segmentStart)
- result = [{
- start: segmentStart,
- end: segmentEnd
- }];
- else if (otherStart >= segmentStart && otherEnd <= segmentEnd)
- result = [];
- else if (otherStart < segmentStart)
- result = [{
- start: segmentStart,
- end: otherStart
- }];
- else if (otherEnd > segmentEnd)
- result = [{
- start: otherEnd,
- end: segmentEnd
- }];
- return result
- }
- function isNotEmptySegmentAsc(start, end, threshold) {
- return end - start >= threshold
- }
- function isNotEmptySegmentDes(start, end, threshold) {
- return start - end >= threshold
- }
- DX.viz.gauges.__internals.CircularRangeContainer = DX.viz.gauges.__internals.BaseRangeContainer.inherit({
- _processOptions: function() {
- var that = this;
- that._inner = that._outer = 0;
- switch (_String(that._options.orientation).toLowerCase()) {
- case'inside':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _isVisible: function(layout) {
- var width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- return layout.radius - this._inner * width > 0
- },
- _createRange: function(range, layout) {
- var that = this,
- width = (range.startWidth + range.endWidth) / 2;
- return that._renderer.arc(layout.x, layout.y, layout.radius - that._inner * width, layout.radius + that._outer * width, that._translator.translate(range.end), that._translator.translate(range.start)).attr({"stroke-linejoin": "round"})
- },
- measure: function(layout) {
- var width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- return {
- min: layout.radius - this._inner * width,
- max: layout.radius + this._outer * width
- }
- }
- });
- DX.viz.gauges.__internals.LinearRangeContainer = DX.viz.gauges.__internals.BaseRangeContainer.inherit({
- _processOptions: function() {
- var that = this;
- that.vertical = that._options.vertical;
- that._inner = that._outer = 0;
- if (that.vertical)
- switch (_String(that._options.horizontalOrientation).toLowerCase()) {
- case'left':
- that._inner = 1;
- break;
- case'center':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- else
- switch (_String(that._options.verticalOrientation).toLowerCase()) {
- case'top':
- that._inner = 1;
- break;
- case'middle':
- that._inner = that._outer = 0.5;
- break;
- default:
- that._outer = 1;
- break
- }
- },
- _isVisible: function() {
- return true
- },
- _createRange: function(range, layout) {
- var that = this,
- inner = that._inner,
- outer = that._outer,
- startPosition = that._translator.translate(range.start),
- endPosition = that._translator.translate(range.end),
- points,
- x = layout.x,
- y = layout.y,
- startWidth = range.startWidth,
- endWidth = range.endWidth;
- if (that.vertical)
- points = [x - startWidth * inner, startPosition, x - endWidth * inner, endPosition, x + endWidth * outer, endPosition, x + startWidth * outer, startPosition];
- else
- points = [startPosition, y + startWidth * outer, startPosition, y - startWidth * inner, endPosition, y - endWidth * inner, endPosition, y + endWidth * outer];
- return that._renderer.path(points, "area")
- },
- measure: function(layout) {
- var result = {},
- width;
- result.min = result.max = layout[this.vertical ? 'x' : 'y'];
- width = this._options.width;
- width = _Number(width) || _max(_Number(width.start), _Number(width.end));
- result.min -= this._inner * width;
- result.max += this._outer * width;
- return result
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file title.js */
- (function(DX, $, undefined) {
- var viz = DX.viz,
- core = viz.core,
- _isString = DX.utils.isString,
- _max = Math.max,
- _extend = $.extend;
- viz.gauges.__internals.Title = DX.Class.inherit({
- ctor: function(parameters) {
- this._renderer = parameters.renderer;
- this._container = parameters.container
- },
- dispose: function() {
- this._renderer = this._container = null;
- return this
- },
- clean: function() {
- var that = this;
- if (that._root) {
- that._root.remove().clear();
- that._root = that._layout = null
- }
- return that
- },
- render: function(titleOptions, subtitleOptions) {
- var that = this,
- hasTitle = _isString(titleOptions.text) && titleOptions.text.length > 0,
- hasSubtitle = _isString(subtitleOptions.text) && subtitleOptions.text.length > 0,
- element,
- bbox,
- totalWidth = 0,
- totalHeight = 0,
- y = 0;
- if (!hasTitle && !hasSubtitle)
- return that;
- that._root = that._renderer.g().attr({'class': 'dxg-title'}).append(that._container);
- if (hasTitle) {
- element = that._renderer.text(titleOptions.text, 0, 0).attr({align: 'center'}).css(core.utils.patchFontOptions(titleOptions.font)).append(that._root);
- bbox = element.getBBox();
- y += -bbox.y;
- element.attr({y: y});
- y += bbox.height + bbox.y;
- totalWidth = _max(totalWidth, bbox.width);
- totalHeight += bbox.height
- }
- if (hasSubtitle) {
- element = that._renderer.text(subtitleOptions.text, 0, 0).attr({align: 'center'}).css(core.utils.patchFontOptions(subtitleOptions.font)).append(that._root);
- bbox = element.getBBox();
- y += -bbox.y;
- element.attr({y: y});
- totalWidth = _max(totalWidth, bbox.width);
- totalHeight += bbox.height
- }
- that._layout = _extend({
- position: titleOptions.position,
- width: totalWidth,
- height: totalHeight
- }, titleOptions.layout);
- return that
- },
- getLayoutOptions: function() {
- return this._layout
- },
- locate: function(left, top) {
- this._root.attr({
- translateX: left + this._layout.width / 2,
- translateY: top
- });
- return this
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file layoutManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _max = Math.max,
- _each = $.each;
- function patchLayoutOptions(options) {
- if (options.position) {
- var position = _String(options.position).toLowerCase().split('-');
- options.verticalAlignment = position[0];
- options.horizontalAlignment = position[1]
- }
- }
- DX.viz.gauges.__internals.LayoutManager = DX.Class.inherit({
- setRect: function(rect) {
- this._currentRect = rect.clone();
- return this
- },
- getRect: function() {
- return this._currentRect.clone()
- },
- beginLayout: function(rect) {
- this._rootRect = rect.clone();
- this._currentRect = rect.clone();
- this._cache = [];
- return this
- },
- applyLayout: function(target) {
- var options = target.getLayoutOptions(),
- currentRect,
- verticalOverlay;
- if (!options)
- return this;
- currentRect = this._currentRect;
- verticalOverlay = _Number(options.overlay) || 0;
- patchLayoutOptions(options);
- switch (_String(options.verticalAlignment).toLowerCase()) {
- case'bottom':
- currentRect.bottom -= _max(options.height - verticalOverlay, 0);
- break;
- default:
- currentRect.top += _max(options.height - verticalOverlay, 0);
- break
- }
- this._cache.push({
- target: target,
- options: options
- });
- return this
- },
- endLayout: function() {
- var that = this,
- rootRect = that._rootRect,
- currentRect = that._currentRect;
- _each(that._cache, function(_, cacheItem) {
- var options = cacheItem.options,
- left,
- top,
- verticalOverlay = _Number(options.overlay) || 0;
- switch (_String(options.verticalAlignment).toLowerCase()) {
- case'bottom':
- top = currentRect.bottom - verticalOverlay;
- currentRect.bottom += _max(options.height - verticalOverlay, 0);
- break;
- default:
- top = currentRect.top - options.height + verticalOverlay;
- currentRect.top -= _max(options.height - verticalOverlay, 0);
- break
- }
- switch (_String(options.horizontalAlignment).toLowerCase()) {
- case'left':
- left = rootRect.left;
- break;
- case'right':
- left = rootRect.right - options.width;
- break;
- default:
- left = rootRect.horizontalMiddle() - options.width / 2;
- break
- }
- cacheItem.target.locate(left, top)
- });
- that._cache = null;
- return that
- },
- selectRectByAspectRatio: function(aspectRatio, margins) {
- var rect = this._currentRect.clone(),
- selfAspectRatio,
- width = 0,
- height = 0;
- margins = margins || {};
- if (aspectRatio > 0) {
- rect.left += margins.left || 0;
- rect.right -= margins.right || 0;
- rect.top += margins.top || 0;
- rect.bottom -= margins.bottom || 0;
- if (rect.width() > 0 && rect.height() > 0) {
- selfAspectRatio = rect.height() / rect.width();
- if (selfAspectRatio > 1)
- aspectRatio < selfAspectRatio ? width = rect.width() : height = rect.height();
- else
- aspectRatio > selfAspectRatio ? height = rect.height() : width = rect.width();
- width > 0 || (width = height / aspectRatio);
- height > 0 || (height = width * aspectRatio);
- width = (rect.width() - width) / 2;
- height = (rect.height() - height) / 2;
- rect.left += width;
- rect.right -= width;
- rect.top += height;
- rect.bottom -= height
- }
- else {
- rect.left = rect.right = rect.horizontalMiddle();
- rect.top = rect.bottom = rect.verticalMiddle()
- }
- }
- return rect
- },
- selectRectBySizes: function(sizes, margins) {
- var rect = this._currentRect.clone(),
- step;
- margins = margins || {};
- if (sizes) {
- rect.left += margins.left || 0;
- rect.right -= margins.right || 0;
- rect.top += margins.top || 0;
- rect.bottom -= margins.bottom || 0;
- if (sizes.width > 0) {
- step = (rect.width() - sizes.width) / 2;
- if (step > 0) {
- rect.left += step;
- rect.right -= step
- }
- }
- if (sizes.height > 0) {
- step = (rect.height() - sizes.height) / 2;
- if (step > 0) {
- rect.top += step;
- rect.bottom -= step
- }
- }
- }
- return rect
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file themeManager.js */
- (function(DX, $, undefined) {
- var _extend = $.extend;
- DX.viz.gauges.__internals.ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: 'gauge',
- _fontFields: ['scale.label.font', 'valueIndicators.rangebar.text.font', 'valueIndicators.textcloud.text.font', 'title.font', 'subtitle.font', 'tooltip.font', 'indicator.text.font', 'loadingIndicator.font'],
- _initializeTheme: function() {
- var that = this,
- subTheme;
- if (that._subTheme) {
- subTheme = _extend(true, {}, that._theme[that._subTheme], that._theme);
- _extend(true, that._theme, subTheme)
- }
- that.callBase.apply(that, arguments)
- }
- })
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file baseGauge.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _isString = DX.utils.isString,
- _getAppropriateFormat = DX.utils.getAppropriateFormat,
- _extend = $.extend,
- _each = $.each;
- DX.viz.gauges.dxBaseGauge = DX.viz.core.BaseWidget.inherit({
- _rootClassPrefix: "dxg",
- _createThemeManager: function() {
- return this._factory.createThemeManager()
- },
- _initCore: function() {
- var that = this;
- that._root = that._renderer.root;
- that._translator = that._factory.createTranslator();
- that._initNotifiers();
- that._tracker = that._factory.createTracker({
- renderer: that._renderer,
- container: that._root
- });
- that._layoutManager = that._factory.createLayoutManager();
- that._title = that._factory.createTitle({
- renderer: that._renderer,
- container: that._root
- });
- that._deltaIndicator = that._factory.createDeltaIndicator({
- renderer: that._renderer,
- container: that._root
- });
- that._setupDomain();
- that._setTrackerCallbacks()
- },
- _setTrackerCallbacks: function() {
- var that = this,
- renderer = that._renderer,
- tooltip = that._tooltip;
- that._tracker.setCallbacks({
- 'tooltip-show': function(target, info) {
- var tooltipParameters = target.getTooltipParameters(),
- offset = renderer.getRootOffset(),
- formatObject = _extend({
- value: tooltipParameters.value,
- valueText: tooltip.formatValue(tooltipParameters.value),
- color: tooltipParameters.color
- }, info);
- return tooltip.show(formatObject, {
- x: tooltipParameters.x + offset.left,
- y: tooltipParameters.y + offset.top,
- offset: tooltipParameters.offset
- }, {target: info})
- },
- 'tooltip-hide': function() {
- return tooltip.hide()
- }
- });
- that._resetTrackerCallbacks = function() {
- that._resetTrackerCallbacks = that = renderer = tooltip = null
- }
- },
- _initNotifiers: function() {
- var that = this,
- counter = 0;
- that._notifiers = {
- dirty: function() {
- that._resetIsReady();
- ++counter
- },
- ready: function() {
- if (--counter === 0)
- that._drawn()
- }
- }
- },
- _disposeCore: function() {
- var that = this;
- that._themeManager.dispose();
- that._tracker.dispose();
- that._title.dispose();
- that._deltaIndicator && that._deltaIndicator.dispose();
- that._root = that._translator = that._notifiers = that._tracker = that._layoutManager = that._title = null
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- _clean: function() {
- this._cleanCore()
- },
- _render: function() {
- var that = this;
- that._setupCodomain();
- that._setupAnimationSettings();
- that._setupDefaultFormat();
- that._renderCore()
- },
- _cleanCore: function() {
- var that = this;
- that._title.clean();
- that._deltaIndicator && that._deltaIndicator.clean();
- that._tracker.deactivate();
- that._cleanContent()
- },
- _renderCore: function() {
- var that = this;
- if (!that._isValidDomain)
- return;
- var theme = that._themeManager.theme(),
- titleTheme = _extend(true, {}, theme.title, processTitleOptions(that.option("title"))),
- subTitleTheme = _extend(true, {}, theme.subtitle, processTitleOptions(that.option("subtitle")));
- that._title.render(titleTheme, subTitleTheme);
- that._deltaIndicator && that._deltaIndicator.render(_extend(true, {}, theme.indicator, that.option("indicator")));
- that._layoutManager.beginLayout(that._rootRect);
- _each([that._deltaIndicator, that._title], function(_, item) {
- item && that._layoutManager.applyLayout(item)
- });
- that._mainRect = that._layoutManager.getRect();
- that._renderContent();
- that._layoutManager.endLayout();
- that._tracker.setTooltipState(that._tooltip.isEnabled());
- that._tracker.activate();
- that._noAnimation = null;
- that.option("debugMode") === true && that._renderDebugInfo();
- that._debug_rendered && that._debug_rendered()
- },
- _setTooltipOptions: function() {
- var that = this;
- that.callBase();
- that._tracker && that._tracker.setTooltipState(that._tooltip.isEnabled())
- },
- _renderDebugInfo: function() {
- var that = this,
- group = that._debugGroup || that._renderer.g().attr({"class": "debug-info"}).append(that._renderer.root),
- rect;
- group.clear();
- rect = that._rootRect;
- that._renderer.rect(rect.left, rect.top, rect.width(), rect.height()).attr({
- stroke: "#000000",
- "stroke-width": 1,
- fill: "none"
- }).append(group);
- rect = that._mainRect;
- that._renderer.rect(rect.left, rect.top, rect.width(), rect.height()).attr({
- stroke: "#0000FF",
- "stroke-width": 1,
- fill: "none"
- }).append(group);
- rect = that._layoutManager.getRect();
- rect && that._renderer.rect(rect.left, rect.top, rect.width(), rect.height()).attr({
- stroke: "#FF0000",
- "stroke-width": 1,
- fill: "none"
- }).append(group);
- rect = that._title.getLayoutOptions() ? that._title._root.getBBox() : null;
- rect && that._renderer.rect(rect.x, rect.y, rect.width, rect.height).attr({
- stroke: "#00FF00",
- "stroke-width": 1,
- fill: "none"
- }).append(group);
- rect = that._deltaIndicator && that._deltaIndicator.getLayoutOptions() ? that._deltaIndicator._root.getBBox() : null;
- rect && that._renderer.rect(rect.x, rect.y, rect.width, rect.height).attr({
- stroke: "#00FF00",
- "stroke-width": 1,
- fill: "none"
- }).append(group)
- },
- _applySize: function() {
- var canvas = this._canvas;
- this._rootRect = new DX.viz.core.Rectangle({
- left: canvas.left,
- top: canvas.top,
- right: canvas.width - canvas.right,
- bottom: canvas.height - canvas.bottom
- });
- this._width = canvas.width;
- this._height = canvas.height
- },
- _resize: function() {
- var that = this;
- that._resizing = that._noAnimation = true;
- that._cleanCore();
- that._renderCore();
- that._resizing = null
- },
- _optionChanged: function(args) {
- var that = this;
- switch (args.name) {
- case"startValue":
- case"endValue":
- that._setupDomain();
- that._invalidate();
- break;
- default:
- that.callBase(args);
- break
- }
- },
- _setupDomain: function() {
- var that = this;
- that._setupDomainCore();
- that._isValidDomain = isFinite(1 / (that._translator.getDomain()[1] - that._translator.getDomain()[0]));
- if (!that._isValidDomain)
- that._incidentOccured("W2301")
- },
- _setupAnimationSettings: function() {
- var that = this,
- option = that.option("animation");
- that._animationSettings = null;
- if (option === undefined || option) {
- option = _extend({
- enabled: true,
- duration: 1000,
- easing: "easeOutCubic"
- }, option);
- if (option.enabled && option.duration > 0)
- that._animationSettings = {
- duration: _Number(option.duration),
- easing: option.easing
- }
- }
- that._containerBackgroundColor = that.option("containerBackgroundColor") || that._themeManager.theme().containerBackgroundColor
- },
- _setupDefaultFormat: function() {
- var domain = this._translator.getDomain();
- this._defaultFormatOptions = _getAppropriateFormat(domain[0], domain[1], this._getApproximateScreenRange())
- },
- _setupDomainCore: null,
- _calculateSize: null,
- _cleanContent: null,
- _renderContent: null,
- _setupCodomain: null,
- _getApproximateScreenRange: null,
- _factory: {
- createTranslator: function() {
- return new DX.viz.core.Translator1D
- },
- createTracker: function(parameters) {
- return new DX.viz.gauges.__internals.Tracker(parameters)
- },
- createLayoutManager: function() {
- return new DX.viz.gauges.__internals.LayoutManager
- },
- createTitle: function(parameters) {
- return new DX.viz.gauges.__internals.Title(parameters)
- },
- createDeltaIndicator: function(parameters) {
- return DX.viz.gauges.__internals.DeltaIndicator ? new DX.viz.gauges.__internals.DeltaIndicator(parameters) : null
- }
- }
- });
- function processTitleOptions(options) {
- return _isString(options) ? {text: options} : options || {}
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file gauge.js */
- (function(DX, $, undefined) {
- var _isDefined = DX.utils.isDefined,
- _isArray = DX.utils.isArray,
- _isNumber = DX.utils.isNumber,
- _isFinite = isFinite,
- _Number = Number,
- _String = String,
- _abs = Math.abs,
- _extend = $.extend,
- _each = $.each,
- _map = $.map,
- _noop = $.noop,
- _factory = DX.viz.gauges.__factory,
- OPTION_VALUE = 'value',
- OPTION_SUBVALUES = 'subvalues';
- function processValue(value, fallbackValue) {
- return _isFinite(value) ? _Number(value) : fallbackValue
- }
- function parseArrayOfNumbers(arg) {
- return _isArray(arg) ? arg : _isNumber(arg) ? [arg] : null
- }
- DX.viz.gauges.dxGauge = DX.viz.gauges.dxBaseGauge.inherit({
- _initCore: function() {
- var that = this;
- that._setupValue(that.option(OPTION_VALUE));
- that.__subvalues = parseArrayOfNumbers(that.option(OPTION_SUBVALUES));
- that._setupSubvalues(that.__subvalues);
- selectMode(that);
- that.callBase.apply(that, arguments);
- that._scale = that._createScale({
- renderer: that._renderer,
- container: that._root,
- translator: that._translator
- });
- that._rangeContainer = that._createRangeContainer({
- renderer: that._renderer,
- container: that._root,
- translator: that._translator
- })
- },
- _disposeCore: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._scale.dispose();
- that._rangeContainer.dispose();
- that._disposeValueIndicators();
- that._scale = that._rangeContainer = null
- },
- _disposeValueIndicators: function() {
- var that = this;
- that._valueIndicator && that._valueIndicator.dispose();
- that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.dispose();
- that._valueIndicator = that._subvalueIndicatorsSet = null
- },
- _setupDomainCore: function() {
- var that = this,
- scaleOption = that.option('scale') || {},
- startValue = that.option('startValue'),
- endValue = that.option('endValue');
- startValue = _isNumber(startValue) ? _Number(startValue) : _isNumber(scaleOption.startValue) ? _Number(scaleOption.startValue) : 0;
- endValue = _isNumber(endValue) ? _Number(endValue) : _isNumber(scaleOption.endValue) ? _Number(scaleOption.endValue) : 100;
- that._baseValue = startValue < endValue ? startValue : endValue;
- that._translator.setDomain(startValue, endValue)
- },
- _cleanContent: function() {
- var that = this;
- that._rangeContainer.clean();
- that._scale.clean();
- that._cleanValueIndicators()
- },
- _renderContent: function() {
- var that = this,
- elements;
- that._rangeContainer.render(_extend(that._getOption("rangeContainer"), {
- themeName: that._themeManager.themeName(),
- vertical: that._area.vertical
- }));
- that._scale.render(_extend(that._getOption("scale"), {
- rangeContainer: that._rangeContainer.enabled ? that._rangeContainer : null,
- approximateScreenDelta: that._getApproximateScreenRange(),
- offset: 0,
- vertical: that._area.vertical
- }));
- elements = _map([that._scale, that._rangeContainer].concat(that._prepareValueIndicators()), function(element) {
- return element && element.enabled ? element : null
- });
- that._applyMainLayout(elements);
- _each(elements, function(_, element) {
- element.resize(that._getElementLayout(element.getOffset()))
- });
- that._updateActiveElements()
- },
- _updateIndicatorSettings: function(settings) {
- var that = this;
- settings.currentValue = settings.baseValue = _isFinite(that._translator.translate(settings.baseValue)) ? _Number(settings.baseValue) : that._baseValue;
- settings.vertical = that._area.vertical;
- if (settings.text && !settings.text.format && !settings.text.precision) {
- settings.text.format = that._defaultFormatOptions.format;
- settings.text.precision = that._defaultFormatOptions.precision
- }
- },
- _prepareIndicatorSettings: function(options, defaultTypeField) {
- var that = this,
- theme = that._themeManager.theme("valueIndicators"),
- type = _String(options.type || that._themeManager.theme(defaultTypeField)).toLowerCase(),
- settings = _extend(true, {}, theme._default, theme[type], options);
- settings.type = type;
- settings.animation = that._animationSettings;
- settings.containerBackgroundColor = that._containerBackgroundColor;
- that._updateIndicatorSettings(settings);
- return settings
- },
- _cleanValueIndicators: function() {
- this._valueIndicator && this._valueIndicator.clean();
- this._subvalueIndicatorsSet && this._subvalueIndicatorsSet.clean()
- },
- _prepareValueIndicators: function() {
- var that = this;
- that._prepareValueIndicator();
- that.__subvalues !== null && that._prepareSubvalueIndicators();
- return [that._valueIndicator, that._subvalueIndicatorsSet]
- },
- _updateActiveElements: function() {
- this._updateValueIndicator();
- this._updateSubvalueIndicators()
- },
- _prepareValueIndicator: function() {
- var that = this,
- target = that._valueIndicator,
- settings = that._prepareIndicatorSettings(that.option("valueIndicator") || {}, 'valueIndicatorType');
- if (target && target.type !== settings.type) {
- target.dispose();
- target = null
- }
- if (!target)
- target = that._valueIndicator = that._createIndicator(settings.type, that._root, 'dxg-value-indicator', 'value-indicator');
- target.render(settings)
- },
- _createSubvalueIndicatorsSet: function() {
- var that = this,
- owner = that._renderer.g().attr({'class': 'dxg-subvalue-indicators'});
- return new ValueIndicatorsSet({
- root: owner,
- container: that._root,
- createIndicator: function(type, i) {
- return that._createIndicator(type, owner, 'dxg-subvalue-indicator', 'subvalue-indicator', i)
- }
- })
- },
- _prepareSubvalueIndicators: function() {
- var that = this,
- target = that._subvalueIndicatorsSet,
- settings = that._prepareIndicatorSettings(that.option("subvalueIndicator") || {}, 'subvalueIndicatorType'),
- isRecreate;
- if (!target)
- target = that._subvalueIndicatorsSet = that._createSubvalueIndicatorsSet();
- isRecreate = settings.type !== target.type;
- target.type = settings.type;
- if (that._createIndicator(settings.type))
- target.render(settings, isRecreate)
- },
- _setupValue: function(value) {
- this.__value = processValue(value, this.__value)
- },
- _setupSubvalues: function(subvalues) {
- var vals = subvalues === undefined ? this.__subvalues : parseArrayOfNumbers(subvalues),
- i,
- ii,
- list;
- if (vals === null)
- return;
- for (i = 0, ii = vals.length, list = []; i < ii; ++i)
- list.push(processValue(vals[i], this.__subvalues[i]));
- this.__subvalues = list
- },
- _updateValueIndicator: function() {
- var that = this;
- that._valueIndicator && that._valueIndicator.value(that.__value, that._noAnimation);
- that._resizing || that.hideLoadingIndicator()
- },
- _updateSubvalueIndicators: function() {
- var that = this;
- that._subvalueIndicatorsSet && that._subvalueIndicatorsSet.values(that.__subvalues, that._noAnimation);
- that._resizing || that.hideLoadingIndicator()
- },
- value: function(arg) {
- var that = this;
- if (arg !== undefined) {
- that._setupValue(arg);
- that._updateValueIndicator();
- that.option(OPTION_VALUE, that.__value);
- return that
- }
- return that.__value
- },
- subvalues: function(arg) {
- var that = this;
- if (arg !== undefined) {
- if (that.__subvalues !== null) {
- that._setupSubvalues(arg);
- that._updateSubvalueIndicators();
- that.option(OPTION_SUBVALUES, that.__subvalues)
- }
- return that
- }
- return that.__subvalues !== null ? that.__subvalues.slice() : undefined
- },
- _valueChangedHandler: function(name, val) {
- var that = this;
- switch (name) {
- case OPTION_VALUE:
- that._setupValue(val);
- that._updateValueIndicator();
- that.option(OPTION_VALUE, that.__value);
- return true;
- case OPTION_SUBVALUES:
- if (that.__subvalues !== null) {
- that._setupSubvalues(val);
- that._updateSubvalueIndicators();
- that.option(OPTION_SUBVALUES, that.__subvalues);
- return true
- }
- return false;
- default:
- return false
- }
- },
- _optionChanged: function(args) {
- var that = this;
- if (that._valueChangedHandler(args.name, args.value, args.previousValue))
- return;
- if (args.name === "scale") {
- that._setupDomain();
- that._invalidate()
- }
- else
- that.callBase.apply(that, arguments)
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- var result;
- switch (name) {
- case OPTION_VALUE:
- result = oldValue === newValue;
- break;
- case OPTION_SUBVALUES:
- result = compareArrays(oldValue, newValue);
- break;
- default:
- result = this.callBase.apply(this, arguments);
- break
- }
- return result
- },
- _applyMainLayout: null,
- _getElementLayout: null,
- _createScale: function(parameters) {
- return _factory[this._factoryMethods.scale](parameters)
- },
- _createRangeContainer: function(parameters) {
- return _factory[this._factoryMethods.rangeContainer](parameters)
- },
- _createIndicator: function(type, owner, className, trackerType, trackerIndex, _strict) {
- var that = this,
- indicator = _factory[that._factoryMethods.indicator]({
- renderer: that._renderer,
- translator: that._translator,
- notifiers: that._notifiers,
- owner: owner,
- tracker: that._tracker,
- className: className
- }, type, _strict);
- if (indicator) {
- indicator.type = type;
- indicator._trackerInfo = {
- type: trackerType,
- index: trackerIndex
- }
- }
- return indicator
- },
- _getApproximateScreenRange: null
- });
- DX.viz.gauges.dxGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.dxBaseGauge.prototype._factory);
- DX.viz.gauges.dxGauge.prototype._factory.createThemeManager = function() {
- return new DX.viz.gauges.__internals.ThemeManager
- };
- function valueGetter(arg) {
- return arg ? arg.value : NaN
- }
- function setupValues(that, fieldName, optionItems) {
- var currentValues = that[fieldName],
- newValues = _isArray(optionItems) ? _map(optionItems, valueGetter) : [],
- i = 0,
- ii = newValues.length,
- list = [];
- for (; i < ii; ++i)
- list.push(processValue(newValues[i], currentValues[i]));
- that[fieldName] = list
- }
- function selectMode(gauge) {
- if (gauge.option(OPTION_VALUE) === undefined && gauge.option(OPTION_SUBVALUES) === undefined)
- if (gauge.option('valueIndicators') !== undefined) {
- disableDefaultMode(gauge);
- selectHardMode(gauge)
- }
- }
- function disableDefaultMode(that) {
- that.value = that.subvalues = _noop;
- that._setupValue = that._setupSubvalues = that._updateValueIndicator = that._updateSubvalueIndicators = null
- }
- function selectHardMode(that) {
- that._indicatorValues = [];
- setupValues(that, '_indicatorValues', that.option('valueIndicators'));
- that._valueIndicators = [];
- that._valueChangedHandler = valueChangedHandler_hardMode;
- that._updateActiveElements = updateActiveElements_hardMode;
- that._prepareValueIndicators = prepareValueIndicators_hardMode;
- that._disposeValueIndicators = disposeValueIndicators_hardMode;
- that._cleanValueIndicators = cleanValueIndicators_hardMode;
- that.indicatorValue = indicatorValue_hardMode
- }
- function valueChangedHandler_hardMode(name, val) {
- if (name === 'valueIndicators') {
- setupValues(this, '_indicatorValues', val);
- this._invalidate();
- return true
- }
- return false
- }
- function updateActiveElements_hardMode() {
- var that = this;
- _each(that._valueIndicators, function(_, valueIndicator) {
- valueIndicator.value(that._indicatorValues[valueIndicator.index], that._noAnimation)
- });
- that._resizing || that.hideLoadingIndicator()
- }
- function prepareValueIndicators_hardMode() {
- var that = this,
- valueIndicators = that._valueIndicators || [],
- userOptions = that.option('valueIndicators'),
- optionList = [],
- i = 0,
- ii;
- for (ii = _isArray(userOptions) ? userOptions.length : 0; i < ii; ++i)
- optionList.push(userOptions[i]);
- for (ii = valueIndicators.length; i < ii; ++i)
- optionList.push(null);
- var newValueIndicators = [];
- _each(optionList, function(i, userSettings) {
- var valueIndicator = valueIndicators[i];
- if (!userSettings) {
- valueIndicator && valueIndicator.dispose();
- return
- }
- var settings = that._prepareIndicatorSettings(userSettings, "valueIndicatorType");
- if (valueIndicator && valueIndicator.type !== settings.type) {
- valueIndicator.dispose();
- valueIndicator = null
- }
- if (!valueIndicator)
- valueIndicator = that._createIndicator(settings.type, that._root, 'dxg-value-indicator', 'value-indicator', i, true);
- if (valueIndicator) {
- valueIndicator.index = i;
- valueIndicator.render(settings);
- newValueIndicators.push(valueIndicator)
- }
- });
- that._valueIndicators = newValueIndicators;
- return that._valueIndicators
- }
- function disposeValueIndicators_hardMode() {
- _each(this._valueIndicators, function(_, valueIndicator) {
- valueIndicator.dispose()
- });
- this._valueIndicators = null
- }
- function cleanValueIndicators_hardMode() {
- _each(this._valueIndicators, function(_, valueIndicator) {
- valueIndicator.clean()
- })
- }
- function indicatorValue_hardMode(index, value) {
- return accessPointerValue(this, this._valueIndicators, this._indicatorValues, index, value)
- }
- function accessPointerValue(that, pointers, values, index, value) {
- if (value !== undefined) {
- if (values[index] !== undefined) {
- values[index] = processValue(value, values[index]);
- pointers[index] && pointers[index].value(values[index]);
- that._resizing || that.hideLoadingIndicator()
- }
- return that
- }
- else
- return values[index]
- }
- function compareArrays(array1, array2) {
- var i,
- ii;
- if (array1 === array2)
- return true;
- if (_isArray(array1) && _isArray(array2) && array1.length === array2.length) {
- for (i = 0, ii = array1.length; i < ii; ++i)
- if (_abs(array1[i] - array2[i]) > 1E-8)
- return false;
- return true
- }
- return false
- }
- function ValueIndicatorsSet(parameters) {
- this._parameters = parameters;
- this._indicators = []
- }
- ValueIndicatorsSet.prototype = {
- costructor: ValueIndicatorsSet,
- dispose: function() {
- var that = this;
- _each(that._indicators, function(_, indicator) {
- indicator.dispose()
- });
- that._parameters = that._options = that._indicators = that._colorPalette = that._palette = null;
- return that
- },
- clean: function() {
- var that = this;
- that._parameters.root.remove();
- that._sample && that._sample.clean().dispose();
- _each(that._indicators, function(_, indicator) {
- indicator.clean()
- });
- that._sample = that._options = that._palette = null;
- return that
- },
- render: function(options, isRecreate) {
- var that = this;
- that._options = options;
- that._sample = that._parameters.createIndicator(that.type);
- that._sample.render(options);
- that.enabled = that._sample.enabled;
- that._palette = _isDefined(options.palette) ? new DX.viz.core.Palette(options.palette) : null;
- if (that.enabled) {
- that._parameters.root.append(that._parameters.container);
- that._generatePalette(that._indicators.length);
- that._indicators = _map(that._indicators, function(indicator, i) {
- if (isRecreate) {
- indicator.dispose();
- indicator = that._parameters.createIndicator(that.type, i)
- }
- indicator.render(that._getIndicatorOptions(i));
- return indicator
- })
- }
- return that
- },
- getOffset: function() {
- return _Number(this._options.offset) || 0
- },
- resize: function(layout) {
- var that = this;
- that._layout = layout;
- _each(that._indicators, function(_, indicator) {
- indicator.resize(layout)
- });
- return that
- },
- measure: function(layout) {
- return this._sample.measure(layout)
- },
- _getIndicatorOptions: function(index) {
- var result = this._options;
- if (this._colorPalette)
- result = _extend({}, result, {color: this._colorPalette[index]});
- return result
- },
- _generatePalette: function(count) {
- var that = this,
- colors = null;
- if (that._palette) {
- colors = [];
- that._palette.reset();
- var i = 0;
- for (; i < count; ++i)
- colors.push(that._palette.getNextColor())
- }
- that._colorPalette = colors
- },
- _adjustIndicatorsCount: function(count) {
- var that = this,
- indicators = that._indicators,
- i,
- ii,
- indicator,
- indicatorsLen = indicators.length;
- if (indicatorsLen > count) {
- for (i = count, ii = indicatorsLen; i < ii; ++i)
- indicators[i].clean().dispose();
- that._indicators = indicators.slice(0, count);
- that._generatePalette(indicators.length)
- }
- else if (indicatorsLen < count) {
- that._generatePalette(count);
- for (i = indicatorsLen, ii = count; i < ii; ++i) {
- indicator = that._parameters.createIndicator(that.type, i);
- indicator.render(that._getIndicatorOptions(i)).resize(that._layout);
- indicators.push(indicator)
- }
- }
- },
- values: function(arg, _noAnimation) {
- var that = this;
- if (!that.enabled)
- return;
- if (arg !== undefined) {
- if (!_isArray(arg))
- arg = _isFinite(arg) ? [Number(arg)] : null;
- if (arg) {
- that._adjustIndicatorsCount(arg.length);
- _each(that._indicators, function(i, indicator) {
- indicator.value(arg[i], _noAnimation)
- })
- }
- return that
- }
- return _map(that._indicators, function(indicator) {
- return indicator.value()
- })
- }
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file circularGauge.js */
- (function(DX, $, undefined) {
- var _isFinite = isFinite,
- _Number = Number,
- _normalizeAngle = DX.utils.normalizeAngle,
- _getCosAndSin = DX.utils.getCosAndSin,
- _abs = Math.abs,
- _max = Math.max,
- _min = Math.min,
- _round = Math.round,
- _each = $.each,
- PI = Math.PI;
- function getSides(startAngle, endAngle) {
- var startCosSin = _getCosAndSin(startAngle),
- endCosSin = _getCosAndSin(endAngle),
- startCos = startCosSin.cos,
- startSin = startCosSin.sin,
- endCos = endCosSin.cos,
- endSin = endCosSin.sin;
- return {
- left: startSin <= 0 && endSin >= 0 || startSin <= 0 && endSin <= 0 && startCos <= endCos || startSin >= 0 && endSin >= 0 && startCos >= endCos ? -1 : _min(startCos, endCos, 0),
- right: startSin >= 0 && endSin <= 0 || startSin >= 0 && endSin >= 0 && startCos >= endCos || startSin <= 0 && endSin <= 0 && startCos <= endCos ? 1 : _max(startCos, endCos, 0),
- up: startCos <= 0 && endCos >= 0 || startCos <= 0 && endCos <= 0 && startSin >= endSin || startCos >= 0 && endCos >= 0 && startSin <= endSin ? -1 : -_max(startSin, endSin, 0),
- down: startCos >= 0 && endCos <= 0 || startCos >= 0 && endCos >= 0 && startSin <= endSin || startCos <= 0 && endCos <= 0 && startSin >= endSin ? 1 : -_min(startSin, endSin, 0)
- }
- }
- DX.registerComponent("dxCircularGauge", DX.viz.gauges, DX.viz.gauges.dxGauge.inherit({
- _rootClass: "dxg-circular-gauge",
- _factoryMethods: {
- scale: 'createCircularScale',
- rangeContainer: 'createCircularRangeContainer',
- indicator: 'createCircularIndicator'
- },
- _setupCodomain: function() {
- var that = this,
- geometry = that.option("geometry") || {},
- startAngle = geometry.startAngle,
- endAngle = geometry.endAngle,
- sides;
- startAngle = _isFinite(startAngle) ? _normalizeAngle(startAngle) : 225;
- endAngle = _isFinite(endAngle) ? _normalizeAngle(endAngle) : -45;
- if (_abs(startAngle - endAngle) < 1) {
- endAngle -= 360;
- sides = {
- left: -1,
- up: -1,
- right: 1,
- down: 1
- }
- }
- else {
- startAngle < endAngle && (endAngle -= 360);
- sides = getSides(startAngle, endAngle)
- }
- that._area = {
- x: 0,
- y: 0,
- radius: 100,
- startCoord: startAngle,
- endCoord: endAngle,
- scaleRadius: geometry.scaleRadius > 0 ? _Number(geometry.scaleRadius) : undefined,
- sides: sides
- };
- that._translator.setCodomain(startAngle, endAngle)
- },
- _measureMainElements: function(elements) {
- var that = this,
- radius = that._area.radius,
- maxRadius = 0,
- minRadius = Infinity,
- maxHorizontalOffset = 0,
- maxVerticalOffset = 0,
- maxInverseHorizontalOffset = 0,
- maxInverseVerticalOffset = 0;
- _each(elements, function(_, element) {
- var bounds = element.measure({radius: radius - element.getOffset()});
- bounds.min > 0 && (minRadius = _min(minRadius, bounds.min));
- bounds.max > 0 && (maxRadius = _max(maxRadius, bounds.max));
- bounds.horizontalOffset > 0 && (maxHorizontalOffset = _max(maxHorizontalOffset, bounds.max + bounds.horizontalOffset));
- bounds.verticalOffset > 0 && (maxVerticalOffset = _max(maxVerticalOffset, bounds.max + bounds.verticalOffset));
- bounds.inverseHorizontalOffset > 0 && (maxInverseHorizontalOffset = _max(maxInverseHorizontalOffset, bounds.inverseHorizontalOffset));
- bounds.inverseVerticalOffset > 0 && (maxInverseVerticalOffset = _max(maxInverseVerticalOffset, bounds.inverseVerticalOffset))
- });
- maxHorizontalOffset = _max(maxHorizontalOffset - maxRadius, 0);
- maxVerticalOffset = _max(maxVerticalOffset - maxRadius, 0);
- return {
- minRadius: minRadius,
- maxRadius: maxRadius,
- horizontalMargin: maxHorizontalOffset,
- verticalMargin: maxVerticalOffset,
- inverseHorizontalMargin: maxInverseHorizontalOffset,
- inverseVerticalMargin: maxInverseVerticalOffset
- }
- },
- _applyMainLayout: function(elements) {
- var that = this,
- measurements = that._measureMainElements(elements),
- area = that._area,
- sides = area.sides,
- margins = {
- left: (sides.left < -0.1 ? measurements.horizontalMargin : measurements.inverseHorizontalMargin) || 0,
- right: (sides.right > 0.1 ? measurements.horizontalMargin : measurements.inverseHorizontalMargin) || 0,
- top: (sides.up < -0.1 ? measurements.verticalMargin : measurements.inverseVerticalMargin) || 0,
- bottom: (sides.down > 0.1 ? measurements.verticalMargin : measurements.inverseVerticalMargin) || 0
- },
- rect = that._layoutManager.selectRectByAspectRatio((sides.down - sides.up) / (sides.right - sides.left), margins),
- radius = _min(rect.width() / (sides.right - sides.left), rect.height() / (sides.down - sides.up)),
- x,
- y,
- scaler = (measurements.maxRadius - area.radius + area.scaleRadius) / radius;
- if (0 < scaler && scaler < 1) {
- rect = rect.scale(scaler);
- radius *= scaler
- }
- radius = radius - measurements.maxRadius + area.radius;
- x = rect.left - rect.width() * sides.left / (sides.right - sides.left);
- y = rect.top - rect.height() * sides.up / (sides.down - sides.up);
- area.x = _round(x);
- area.y = _round(y);
- area.radius = radius;
- rect.left -= margins.left;
- rect.right += margins.right;
- rect.top -= margins.top;
- rect.bottom += margins.bottom;
- that._layoutManager.setRect(rect)
- },
- _getElementLayout: function(offset) {
- return {
- x: this._area.x,
- y: this._area.y,
- radius: _round(this._area.radius - offset)
- }
- },
- _getApproximateScreenRange: function() {
- var that = this,
- area = that._area,
- r = _min(that._canvas.width / (area.sides.right - area.sides.left), that._canvas.height / (area.sides.down - area.sides.up));
- r > area.totalRadius && (r = area.totalRadius);
- r = 0.8 * r;
- return -that._translator.getCodomainRange() * r * PI / 180
- },
- _getDefaultSize: function() {
- return {
- width: 300,
- height: 300
- }
- }
- }));
- DX.viz.gauges.dxCircularGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.dxBaseGauge.prototype._factory);
- DX.viz.gauges.dxCircularGauge.prototype._factory.createThemeManager = function() {
- var themeManager = new DX.viz.gauges.__internals.ThemeManager;
- themeManager._subTheme = "_circular";
- return themeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file linearGauge.js */
- (function(DX, $, undefined) {
- var _String = String,
- _Number = Number,
- _max = Math.max,
- _min = Math.min,
- _round = Math.round,
- _each = $.each;
- DX.registerComponent("dxLinearGauge", DX.viz.gauges, DX.viz.gauges.dxGauge.inherit({
- _rootClass: 'dxg-linear-gauge',
- _factoryMethods: {
- scale: 'createLinearScale',
- rangeContainer: 'createLinearRangeContainer',
- indicator: 'createLinearIndicator'
- },
- _setupCodomain: function() {
- var that = this,
- geometry = that.option('geometry') || {},
- vertical = _String(geometry.orientation).toLowerCase() === 'vertical';
- that._area = {
- vertical: vertical,
- x: 0,
- y: 0,
- startCoord: -100,
- endCoord: 100,
- scaleSize: geometry.scaleSize > 0 ? _Number(geometry.scaleSize) : undefined
- };
- that._scale.vertical = vertical;
- that._rangeContainer.vertical = vertical
- },
- _measureMainElements: function(elements) {
- var that = this,
- x = that._area.x,
- y = that._area.y,
- minBound = 1000,
- maxBound = 0,
- indent = 0;
- _each(elements, function(_, element) {
- var bounds = element.measure({
- x: x + element.getOffset(),
- y: y + element.getOffset()
- });
- maxBound = _max(maxBound, bounds.max);
- minBound = _min(minBound, bounds.min);
- bounds.indent > 0 && (indent = _max(indent, bounds.indent))
- });
- return {
- minBound: minBound,
- maxBound: maxBound,
- indent: indent
- }
- },
- _applyMainLayout: function(elements) {
- var that = this,
- measurements = that._measureMainElements(elements),
- area = that._area,
- rect,
- offset,
- counterSize = area.scaleSize + 2 * measurements.indent;
- if (area.vertical) {
- rect = that._layoutManager.selectRectBySizes({
- width: measurements.maxBound - measurements.minBound,
- height: counterSize
- });
- offset = rect.horizontalMiddle() - (measurements.minBound + measurements.maxBound) / 2;
- area.startCoord = rect.bottom - measurements.indent;
- area.endCoord = rect.top + measurements.indent;
- area.x = _round(area.x + offset)
- }
- else {
- rect = that._layoutManager.selectRectBySizes({
- height: measurements.maxBound - measurements.minBound,
- width: counterSize
- });
- offset = rect.verticalMiddle() - (measurements.minBound + measurements.maxBound) / 2;
- area.startCoord = rect.left + measurements.indent;
- area.endCoord = rect.right - measurements.indent;
- area.y = _round(area.y + offset)
- }
- that._translator.setCodomain(area.startCoord, area.endCoord);
- that._layoutManager.setRect(rect)
- },
- _getElementLayout: function(offset) {
- return {
- x: _round(this._area.x + offset),
- y: _round(this._area.y + offset)
- }
- },
- _getApproximateScreenRange: function() {
- var that = this,
- area = that._area,
- s = area.vertical ? that._canvas.height : that._canvas.width;
- s > area.totalSize && (s = area.totalSize);
- s = s * 0.8;
- return s
- },
- _getDefaultSize: function() {
- var geometry = this.option('geometry') || {};
- if (geometry.orientation === 'vertical')
- return {
- width: 100,
- height: 300
- };
- else
- return {
- width: 300,
- height: 100
- }
- }
- }));
- DX.viz.gauges.dxLinearGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.dxBaseGauge.prototype._factory);
- DX.viz.gauges.dxLinearGauge.prototype._factory.createThemeManager = function() {
- var themeManager = new DX.viz.gauges.__internals.ThemeManager;
- themeManager._subTheme = '_linear';
- return themeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file barGauge.js */
- (function(DX, $, undefined) {
- var PI_DIV_180 = Math.PI / 180,
- _abs = Math.abs,
- _round = Math.round,
- _floor = Math.floor,
- _min = Math.min,
- _max = Math.max,
- _isArray = DX.utils.isArray,
- _convertAngleToRendererSpace = DX.utils.convertAngleToRendererSpace,
- _getCosAndSin = DX.utils.getCosAndSin,
- _patchFontOptions = DX.viz.core.utils.patchFontOptions,
- _Number = Number,
- _isFinite = isFinite,
- _noop = $.noop,
- _extend = $.extend,
- _getSampleText = DX.viz.gauges.__internals.getSampleText,
- _formatValue = DX.viz.gauges.__internals.formatValue,
- _Palette = DX.viz.core.Palette,
- OPTION_VALUES = "values";
- var dxBarGauge = DX.viz.gauges.dxBaseGauge.inherit({
- _rootClass: "dxbg-bar-gauge",
- _initCore: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._barsGroup = that._renderer.g().attr({"class": "dxbg-bars"});
- that._values = [];
- that._context = {
- renderer: that._renderer,
- translator: that._translator,
- tracker: that._tracker,
- group: that._barsGroup
- };
- that._animateStep = function(pos) {
- var bars = that._bars,
- i,
- ii;
- for (i = 0, ii = bars.length; i < ii; ++i)
- bars[i].animate(pos)
- };
- that._animateComplete = function() {
- var bars = that._bars,
- i,
- ii;
- for (i = 0, ii = bars.length; i < ii; ++i)
- bars[i].endAnimation();
- that._notifiers.ready()
- }
- },
- _disposeCore: function() {
- var that = this;
- that._barsGroup = that._values = that._context = that._animateStep = that._animateComplete = null;
- that.callBase.apply(that, arguments)
- },
- _setupDomainCore: function() {
- var that = this,
- startValue = that.option("startValue"),
- endValue = that.option("endValue");
- _isFinite(startValue) || (startValue = 0);
- _isFinite(endValue) || (endValue = 100);
- that._translator.setDomain(startValue, endValue);
- that._baseValue = that._translator.adjust(that.option("baseValue"));
- _isFinite(that._baseValue) || (that._baseValue = startValue < endValue ? startValue : endValue)
- },
- _getDefaultSize: function() {
- return {
- width: 300,
- height: 300
- }
- },
- _setupCodomain: DX.viz.gauges.dxCircularGauge.prototype._setupCodomain,
- _getApproximateScreenRange: function() {
- var that = this,
- sides = that._area.sides,
- width = that._canvas.width / (sides.right - sides.left),
- height = that._canvas.height / (sides.down - sides.up),
- r = width < height ? width : height;
- return -that._translator.getCodomainRange() * r * PI_DIV_180
- },
- _setupAnimationSettings: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- if (that._animationSettings) {
- that._animationSettings.step = that._animateStep;
- that._animationSettings.complete = that._animateComplete
- }
- },
- _cleanContent: function() {
- var that = this,
- i,
- ii;
- that._barsGroup.remove();
- that._animationSettings && that._barsGroup.stopAnimation();
- for (i = 0, ii = that._bars ? that._bars.length : 0; i < ii; ++i)
- that._bars[i].dispose();
- that._palette = that._bars = null
- },
- _renderContent: function() {
- var that = this,
- labelOptions = that.option("label"),
- text,
- bbox,
- context = that._context;
- that._barsGroup.append(that._root);
- context.textEnabled = labelOptions === undefined || labelOptions && (!("visible" in labelOptions) || labelOptions.visible);
- if (context.textEnabled) {
- context.textColor = labelOptions && labelOptions.font && labelOptions.font.color || null;
- labelOptions = _extend(true, {}, that._themeManager.theme().label, labelOptions);
- context.formatOptions = {
- format: labelOptions.format !== undefined || labelOptions.precision !== undefined ? labelOptions.format : that._defaultFormatOptions.format,
- precision: labelOptions.format !== undefined || labelOptions.precision !== undefined ? labelOptions.precision : that._defaultFormatOptions.precision,
- customizeText: labelOptions.customizeText
- };
- context.textOptions = {align: "center"};
- context.fontStyles = _patchFontOptions(_extend({}, that._themeManager.theme().label.font, labelOptions.font, {color: null}));
- that._textIndent = labelOptions.indent > 0 ? _Number(labelOptions.indent) : 0;
- context.lineWidth = labelOptions.connectorWidth > 0 ? _Number(labelOptions.connectorWidth) : 0;
- context.lineColor = labelOptions.connectorColor || null;
- text = that._renderer.text(_getSampleText(that._translator, context.formatOptions), 0, 0).attr(context.textOptions).css(context.fontStyles).append(that._barsGroup);
- bbox = text.getBBox();
- text.remove();
- context.textVerticalOffset = -bbox.y - bbox.height / 2;
- context.textWidth = bbox.width;
- context.textHeight = bbox.height
- }
- DX.viz.gauges.dxCircularGauge.prototype._applyMainLayout.call(that);
- that._renderBars()
- },
- _measureMainElements: function() {
- var result = {maxRadius: this._area.radius};
- if (this._context.textEnabled) {
- result.horizontalMargin = this._context.textWidth;
- result.verticalMargin = this._context.textHeight
- }
- return result
- },
- _renderBars: function() {
- var that = this,
- options = _extend({}, that._themeManager.theme(), that.option()),
- relativeInnerRadius,
- radius,
- area = that._area;
- that._palette = new _Palette(options.palette, {
- stepHighlight: 50,
- theme: that._themeManager.themeName()
- });
- relativeInnerRadius = options.relativeInnerRadius > 0 && options.relativeInnerRadius < 1 ? _Number(options.relativeInnerRadius) : 0.1;
- radius = area.radius;
- if (that._context.textEnabled) {
- that._textIndent = _round(_min(that._textIndent, radius / 2));
- radius -= that._textIndent
- }
- that._outerRadius = _floor(radius);
- that._innerRadius = _floor(radius * relativeInnerRadius);
- that._barSpacing = options.barSpacing > 0 ? _Number(options.barSpacing) : 0;
- _extend(that._context, {
- backgroundColor: options.backgroundColor,
- x: area.x,
- y: area.y,
- startAngle: area.startCoord,
- endAngle: area.endCoord,
- baseAngle: that._translator.translate(that._baseValue)
- });
- that._bars = [];
- that._updateValues(that.option(OPTION_VALUES))
- },
- _arrangeBars: function(count) {
- var that = this,
- radius = that._outerRadius - that._innerRadius,
- context = that._context,
- spacing,
- _count,
- unitOffset,
- i;
- context.barSize = count > 0 ? _max((radius - (count - 1) * that._barSpacing) / count, 1) : 0;
- spacing = count > 1 ? _max(_min((radius - count * context.barSize) / (count - 1), that._barSpacing), 0) : 0;
- _count = _min(_floor((radius + spacing) / context.barSize), count);
- that._setBarsCount(_count);
- radius = that._outerRadius;
- context.textRadius = radius + that._textIndent;
- that._palette.reset();
- unitOffset = context.barSize + spacing;
- for (i = 0; i < _count; ++i, radius -= unitOffset)
- that._bars[i].arrange({
- radius: radius,
- color: that._palette.getNextColor()
- })
- },
- _setBarsCount: function(count) {
- var that = this,
- i,
- ii;
- if (that._bars.length > count) {
- for (i = count, ii = that._bars.length; i < ii; ++i)
- that._bars[i].dispose();
- that._bars.splice(count, ii - count)
- }
- else if (that._bars.length < count)
- for (i = that._bars.length, ii = count; i < ii; ++i)
- that._bars.push(new BarWrapper(i, that._context));
- if (that._bars.length > 0) {
- if (that._dummyBackground) {
- that._dummyBackground.dispose();
- that._dummyBackground = null
- }
- }
- else {
- if (!that._dummyBackground)
- that._dummyBackground = that._renderer.arc().attr({"stroke-linejoin": "round"}).append(that._barsGroup);
- that._dummyBackground.attr({
- x: that._context.x,
- y: that._context.y,
- outerRadius: that._outerRadius,
- innerRadius: that._innerRadius,
- startAngle: that._context.endAngle,
- endAngle: that._context.startAngle,
- fill: that._context.backgroundColor
- })
- }
- },
- _updateBars: function(values) {
- var that = this,
- i,
- ii;
- for (i = 0, ii = that._bars.length; i < ii; ++i)
- that._bars[i].setValue(values[i])
- },
- _animateBars: function(values) {
- var that = this,
- i,
- ii = that._bars.length;
- if (ii > 0) {
- for (i = 0; i < ii; ++i)
- that._bars[i].beginAnimation(values[i]);
- that._barsGroup.animate({_: 0}, that._animationSettings)
- }
- },
- _updateValues: function(values) {
- var that = this,
- list = _isArray(values) && values || _isFinite(values) && [values] || [],
- i,
- ii = list.length,
- value,
- barValues = [],
- immediateReady = true;
- that._values.length = ii;
- for (i = 0; i < ii; ++i) {
- value = list[i];
- that._values[i] = value = _Number(_isFinite(value) ? value : that._values[i]);
- if (_isFinite(value))
- barValues.push(value)
- }
- that._notifiers.dirty();
- that._animationSettings && that._barsGroup.stopAnimation();
- if (that._bars) {
- that._arrangeBars(barValues.length);
- if (that._animationSettings && !that._noAnimation) {
- immediateReady = false;
- that._animateBars(barValues)
- }
- else
- that._updateBars(barValues)
- }
- immediateReady && that._notifiers.ready();
- if (!that._resizing) {
- that.option(OPTION_VALUES, that._values);
- that.hideLoadingIndicator()
- }
- },
- values: function(arg) {
- if (arg !== undefined) {
- this._updateValues(arg);
- return this
- }
- else
- return this._values.slice(0)
- },
- _optionChanged: function(args) {
- if (args.name === OPTION_VALUES)
- this._updateValues(args.value);
- else
- this.callBase.apply(this, arguments)
- },
- _optionValuesEqual: function(name, oldValue, newValue) {
- if (name === OPTION_VALUES)
- return compareArrays(oldValue, newValue);
- else
- return this.callBase.apply(this, arguments)
- }
- });
- DX.registerComponent("dxBarGauge", DX.viz.gauges, dxBarGauge);
- var ThemeManager = DX.viz.gauges.__internals.ThemeManager.inherit({
- _themeSection: "barGauge",
- _fontFields: ["label.font", "title.font", "tooltip.font", "loadingIndicator.font"]
- });
- dxBarGauge.prototype._factory = DX.utils.clone(DX.viz.gauges.dxBaseGauge.prototype._factory);
- dxBarGauge.prototype._factory.createThemeManager = function() {
- return new ThemeManager
- };
- var BarWrapper = function(index, context) {
- var that = this;
- that._context = context;
- that._background = context.renderer.arc().attr({
- "stroke-linejoin": "round",
- fill: context.backgroundColor
- }).append(context.group);
- that._bar = context.renderer.arc().attr({"stroke-linejoin": "round"}).append(context.group);
- if (context.textEnabled) {
- that._line = context.renderer.path([], "line").attr({"stroke-width": context.lineWidth}).append(context.group);
- that._text = context.renderer.text("", 0, 0).css(context.fontStyles).attr(context.textOptions).append(context.group)
- }
- that._tracker = context.renderer.arc().attr({"stroke-linejoin": "round"});
- context.tracker.attach(that._tracker, that, {index: index});
- that._index = index;
- that._angle = context.baseAngle;
- that._settings = {
- x: context.x,
- y: context.y,
- startAngle: context.baseAngle,
- endAngle: context.baseAngle
- }
- };
- _extend(BarWrapper.prototype, {
- dispose: function() {
- var that = this;
- that._background.dispose();
- that._bar.dispose();
- if (that._context.textEnabled) {
- that._line.dispose();
- that._text.dispose()
- }
- that._context.tracker.detach(that._tracker);
- that._context = that._settings = that._background = that._bar = that._line = that._text = that._tracker = null;
- return that
- },
- arrange: function(options) {
- var that = this,
- context = that._context;
- that._settings.outerRadius = options.radius;
- that._settings.innerRadius = options.radius - context.barSize;
- that._background.attr(_extend({}, that._settings, {
- startAngle: context.endAngle,
- endAngle: context.startAngle
- }));
- that._bar.attr(that._settings);
- that._tracker.attr(that._settings);
- that._color = options.color;
- that._bar.attr({fill: options.color});
- if (context.textEnabled) {
- that._line.attr({
- points: [context.x, context.y - that._settings.innerRadius, context.x, context.y - context.textRadius],
- stroke: context.lineColor || options.color
- }).sharp();
- that._text.css({fill: context.textColor || options.color})
- }
- return that
- },
- getTooltipParameters: function() {
- var that = this,
- cossin = _getCosAndSin((that._angle + that._context.baseAngle) / 2);
- return {
- x: _round(that._context.x + (that._settings.outerRadius + that._settings.innerRadius) / 2 * cossin.cos),
- y: _round(that._context.y - (that._settings.outerRadius + that._settings.innerRadius) / 2 * cossin.sin),
- offset: 0,
- color: that._color,
- value: that._value
- }
- },
- setAngle: function(angle) {
- var that = this,
- cossin;
- that._angle = angle;
- setAngles(that._settings, that._context.baseAngle, that._angle);
- that._bar.attr(that._settings);
- that._tracker.attr(that._settings);
- if (that._context.textEnabled) {
- that._line.rotate(_convertAngleToRendererSpace(that._angle), that._context.x, that._context.y);
- cossin = _getCosAndSin(that._angle);
- that._text.attr({
- text: _formatValue(that._value, that._context.formatOptions, {index: that._index}),
- x: that._context.x + (that._context.textRadius + that._context.textWidth * 0.6) * cossin.cos,
- y: that._context.y - (that._context.textRadius + that._context.textHeight * 0.6) * cossin.sin + that._context.textVerticalOffset
- })
- }
- return that
- },
- _processValue: function(value) {
- this._value = this._context.translator.adjust(value);
- return this._context.translator.translate(this._value)
- },
- setValue: function(value) {
- return this.setAngle(this._processValue(value))
- },
- beginAnimation: function(value) {
- var that = this,
- angle = this._processValue(value);
- if (!compareFloats(that._angle, angle)) {
- that._start = that._angle;
- that._delta = angle - that._angle;
- that._tracker.attr({visibility: "hidden"});
- if (that._context.textEnabled) {
- that._line.attr({visibility: "hidden"});
- that._text.attr({visibility: "hidden"})
- }
- }
- else {
- that.animate = _noop;
- that.setAngle(that._angle)
- }
- },
- animate: function(pos) {
- var that = this;
- that._angle = that._start + that._delta * pos;
- setAngles(that._settings, that._context.baseAngle, that._angle);
- that._bar.attr(that._settings)
- },
- endAnimation: function() {
- var that = this;
- if (that._delta !== undefined) {
- if (compareFloats(that._angle, that._start + that._delta)) {
- that._tracker.attr({visibility: null});
- if (that._context.textEnabled) {
- that._line.attr({visibility: null});
- that._text.attr({visibility: null})
- }
- that.setAngle(that._angle)
- }
- }
- else
- delete that.animate;
- delete that._start;
- delete that._delta
- }
- });
- function setAngles(target, angle1, angle2) {
- target.startAngle = angle1 < angle2 ? angle1 : angle2;
- target.endAngle = angle1 < angle2 ? angle2 : angle1
- }
- function compareFloats(value1, value2) {
- return _abs(value1 - value2) < 0.0001
- }
- function compareArrays(array1, array2) {
- if (array1 === array2)
- return true;
- if (_isArray(array1) && _isArray(array2) && array1.length === array2.length) {
- for (var i = 0, ii = array1.length; i < ii; ++i)
- if (!compareFloats(array1[i], array2[i]))
- return false;
- return true
- }
- return false
- }
- var __BarWrapper = BarWrapper;
- DX.viz.gauges.__tests.BarWrapper = __BarWrapper;
- DX.viz.gauges.__tests.stubBarWrapper = function(barWrapperType) {
- BarWrapper = barWrapperType
- };
- DX.viz.gauges.__tests.restoreBarWrapper = function() {
- BarWrapper = __BarWrapper
- }
- })(DevExpress, jQuery);
- /*! Module viz-gauges, file tracker.js */
- (function(DX, $, undefined) {
- var _abs = Math.abs,
- TOOLTIP_SHOW_DELAY = 300,
- TOOLTIP_HIDE_DELAY = 300,
- TOOLTIP_TOUCH_SHOW_DELAY = 400,
- TOOLTIP_TOUCH_HIDE_DELAY = 300;
- DX.viz.gauges.__internals.Tracker = DX.Class.inherit({
- ctor: function(parameters) {
- DX.utils.debug.assertParam(parameters, 'parameters');
- DX.utils.debug.assertParam(parameters.renderer, 'parameters.renderer');
- DX.utils.debug.assertParam(parameters.container, 'parameters.container');
- var that = this;
- that._container = parameters.container;
- that._element = parameters.renderer.g().attr({
- 'class': 'dxg-tracker',
- stroke: 'none',
- "stroke-width": 0,
- fill: '#000000',
- opacity: 0.0001
- });
- that._showTooltipCallback = function() {
- that._showTooltipTimeout = null;
- var target = that._tooltipEvent.target,
- data = $(target).data();
- that._targetEvent = null;
- if (that._tooltipTarget !== target && that._callbacks['tooltip-show'](data.target, data.info))
- that._tooltipTarget = target
- };
- that._hideTooltipCallback = function() {
- that._hideTooltipTimeout = null;
- that._targetEvent = null;
- if (that._tooltipTarget) {
- that._callbacks['tooltip-hide']();
- that._tooltipTarget = null
- }
- };
- that._dispose = function() {
- clearTimeout(that._showTooltipTimeout);
- clearTimeout(that._hideTooltipTimeout);
- that._showTooltipCallback = that._hideTooltipCallback = that._dispose = null
- };
- that._DEBUG_showTooltipTimeoutSet = that._DEBUG_showTooltipTimeoutCleared = that._DEBUG_hideTooltipTimeoutSet = that._DEBUG_hideTooltipTimeoutCleared = 0;
- that.TOOLTIP_SHOW_DELAY = TOOLTIP_SHOW_DELAY;
- that.TOOLTIP_HIDE_DELAY = TOOLTIP_HIDE_DELAY;
- that.TOOLTIP_TOUCH_SHOW_DELAY = TOOLTIP_TOUCH_SHOW_DELAY;
- that.TOOLTIP_TOUCH_HIDE_DELAY = TOOLTIP_TOUCH_HIDE_DELAY
- },
- dispose: function() {
- var that = this;
- that._dispose();
- that.deactivate();
- that._element.remove();
- that._container = that._element = that._context = that._callbacks = null;
- return that
- },
- activate: function() {
- this._element.append(this._container);
- return this
- },
- deactivate: function() {
- this._element.remove().clear();
- return this
- },
- attach: function(element, target, info) {
- element.data({
- target: target,
- info: info
- }).append(this._element);
- return this
- },
- detach: function(element) {
- element.remove();
- return this
- },
- setTooltipState: function(state) {
- var that = this,
- data;
- that._element.off(tooltipMouseEvents).off(tooltipTouchEvents).off(tooltipMouseWheelEvents);
- if (state) {
- data = {tracker: that};
- that._element.on(tooltipMouseEvents, data).on(tooltipTouchEvents, data).on(tooltipMouseWheelEvents, data)
- }
- return that
- },
- setCallbacks: function(callbacks) {
- this._callbacks = callbacks;
- return this
- },
- _showTooltip: function(event, delay) {
- var that = this;
- that._hideTooltipTimeout && ++that._DEBUG_hideTooltipTimeoutCleared;
- clearTimeout(that._hideTooltipTimeout);
- that._hideTooltipTimeout = null;
- if (that._tooltipTarget === event.target)
- return;
- clearTimeout(that._showTooltipTimeout);
- that._tooltipEvent = event;
- ++that._DEBUG_showTooltipTimeoutSet;
- that._showTooltipTimeout = setTimeout(that._showTooltipCallback, delay)
- },
- _hideTooltip: function(delay) {
- var that = this;
- that._showTooltipTimeout && ++that._DEBUG_showTooltipTimeoutCleared;
- clearTimeout(that._showTooltipTimeout);
- that._showTooltipTimeout = null;
- clearTimeout(that._hideTooltipTimeout);
- if (delay) {
- ++that._DEBUG_hideTooltipTimeoutSet;
- that._hideTooltipTimeout = setTimeout(that._hideTooltipCallback, delay)
- }
- else
- that._hideTooltipCallback()
- }
- });
- var tooltipMouseEvents = {
- 'mouseover.gauge-tooltip': handleTooltipMouseOver,
- 'mouseout.gauge-tooltip': handleTooltipMouseOut
- };
- var tooltipMouseMoveEvents = {'mousemove.gauge-tooltip': handleTooltipMouseMove};
- var tooltipMouseWheelEvents = {'dxmousewheel.gauge-tooltip': handleTooltipMouseWheel};
- var tooltipTouchEvents = {'touchstart.gauge-tooltip': handleTooltipTouchStart};
- function handleTooltipMouseOver(event) {
- var tracker = event.data.tracker;
- tracker._x = event.pageX;
- tracker._y = event.pageY;
- tracker._element.off(tooltipMouseMoveEvents).on(tooltipMouseMoveEvents, event.data);
- tracker._showTooltip(event, TOOLTIP_SHOW_DELAY)
- }
- function handleTooltipMouseMove(event) {
- var tracker = event.data.tracker;
- if (tracker._showTooltipTimeout && _abs(event.pageX - tracker._x) > 4 || _abs(event.pageY - tracker._y) > 4) {
- tracker._x = event.pageX;
- tracker._y = event.pageY;
- tracker._showTooltip(event, TOOLTIP_SHOW_DELAY)
- }
- }
- function handleTooltipMouseOut(event) {
- var tracker = event.data.tracker;
- tracker._element.off(tooltipMouseMoveEvents);
- tracker._hideTooltip(TOOLTIP_HIDE_DELAY)
- }
- function handleTooltipMouseWheel(event) {
- event.data.tracker._hideTooltip()
- }
- var active_touch_tooltip_tracker = null;
- DX.viz.gauges.__internals.Tracker._DEBUG_reset = function() {
- active_touch_tooltip_tracker = null
- };
- function handleTooltipTouchStart(event) {
- event.preventDefault();
- var tracker = active_touch_tooltip_tracker;
- if (tracker && tracker !== event.data.tracker)
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- tracker = active_touch_tooltip_tracker = event.data.tracker;
- tracker._showTooltip(event, TOOLTIP_TOUCH_SHOW_DELAY);
- tracker._touch = true
- }
- function handleTooltipDocumentTouchStart() {
- var tracker = active_touch_tooltip_tracker;
- if (tracker) {
- if (!tracker._touch) {
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- active_touch_tooltip_tracker = null
- }
- tracker._touch = null
- }
- }
- function handleTooltipDocumentTouchEnd() {
- var tracker = active_touch_tooltip_tracker;
- if (tracker)
- if (tracker._showTooltipTimeout) {
- tracker._hideTooltip(TOOLTIP_TOUCH_HIDE_DELAY);
- active_touch_tooltip_tracker = null
- }
- }
- $(window.document).on({
- 'touchstart.gauge-tooltip': handleTooltipDocumentTouchStart,
- 'touchend.gauge-tooltip': handleTooltipDocumentTouchEnd
- })
- })(DevExpress, jQuery);
- DevExpress.MOD_VIZ_GAUGES = true
- }
- if (!DevExpress.MOD_VIZ_RANGESELECTOR) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-rangeselector, file namespaces.js */
- (function(DevExpress) {
- DevExpress.viz.rangeSelector = {}
- })(DevExpress);
- /*! Module viz-rangeselector, file utils.js */
- (function($, DX, undefined) {
- var dxUtils = DX.utils;
- var findLessOrEqualValueIndex = function(values, value) {
- if (!values || values.length === 0)
- return -1;
- var minIndex = 0,
- maxIndex = values.length - 1;
- while (maxIndex - minIndex > 1) {
- var index = minIndex + maxIndex >> 1;
- if (values[index] > value)
- maxIndex = index;
- else
- minIndex = index
- }
- return values[maxIndex] <= value ? maxIndex : minIndex
- };
- var findLessOrEqualValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length)
- return values[index];
- return value
- };
- var findNearValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length) {
- if (index + 1 < values.length)
- if (dxUtils.isDate(value)) {
- if (values[index + 1].getTime() - value.getTime() < value.getTime() - values[index].getTime())
- index++
- }
- else if (values[index + 1] - value < value - values[index])
- index++;
- return values[index]
- }
- return value
- };
- var findGreaterOrEqualValue = function(values, value) {
- var index = findLessOrEqualValueIndex(values, value);
- if (values && index >= 0 && index < values.length) {
- if (values[index] < value && index + 1 < values.length)
- index++;
- return values[index]
- }
- return value
- };
- var getEventPageX = function(eventArgs) {
- var result = 0;
- if (eventArgs.pageX)
- result = eventArgs.pageX;
- else if (eventArgs.originalEvent && eventArgs.originalEvent.pageX)
- result = eventArgs.originalEvent.pageX;
- if (eventArgs.originalEvent && eventArgs.originalEvent.touches)
- if (eventArgs.originalEvent.touches.length > 0)
- result = eventArgs.originalEvent.touches[0].pageX;
- else if (eventArgs.originalEvent.changedTouches.length > 0)
- result = eventArgs.originalEvent.changedTouches[0].pageX;
- return result
- };
- var truncateSelectedRange = function(value, scaleOptions) {
- var isDiscrete = scaleOptions.type === 'discrete',
- categories = isDiscrete ? scaleOptions._categoriesInfo.categories : undefined,
- startValue = scaleOptions.startValue,
- endValue = scaleOptions.endValue,
- min,
- max,
- valueIndex;
- if (isDiscrete) {
- valueIndex = $.inArray(value, categories);
- return valueIndex < 0 ? startValue : value
- }
- else
- min = startValue > endValue ? endValue : startValue,
- max = startValue > endValue ? startValue : endValue;
- if (value < min)
- value = min;
- if (value > max)
- value = max;
- return value
- };
- DX.viz.rangeSelector.utils = {
- findLessOrEqualValue: findLessOrEqualValue,
- findNearValue: findNearValue,
- findGreaterOrEqualValue: findGreaterOrEqualValue,
- getEventPageX: getEventPageX,
- truncateSelectedRange: truncateSelectedRange,
- trackerSettings: {
- fill: 'grey',
- stroke: 'grey',
- opacity: 0.0001
- },
- animationSettings: {duration: 250}
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file baseVisualElementMethods.js */
- (function(DX) {
- DX.viz.rangeSelector.baseVisualElementMethods = {
- init: function(renderer) {
- this._renderer = renderer;
- this._isDrawn = false
- },
- applyOptions: function(options) {
- this._options = options || {};
- this._applyOptions(this._options)
- },
- _applyOptions: function(){},
- redraw: function(group) {
- var that = this;
- if (!that._isDrawn) {
- that._isDrawn = that._draw(group || that._group) !== false;
- if (group)
- that._group = group
- }
- else
- that._update(group || that._group)
- },
- isDrawn: function() {
- return !!this._isDrawn
- },
- isInitialized: function() {
- return !!this._options
- },
- _draw: function(){},
- _update: function(group) {
- group.clear();
- this._draw(group)
- }
- }
- })(DevExpress);
- /*! Module viz-rangeselector, file rangeSelector.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils,
- core = DX.viz.core,
- patchFontOptions = core.utils.patchFontOptions,
- ParseUtils = core.ParseUtils,
- formatHelper = DX.formatHelper,
- SCALE_TEXT_SPACING = 5,
- HEIGHT_COMPACT_MODE = 24,
- POINTER_SIZE = 4,
- EMPTY_SLIDER_MARKER_TEXT = '. . .',
- _isDefined = utils.isDefined,
- _isNumber = utils.isNumber,
- _isDate = utils.isDate,
- _max = Math.max,
- _ceil = Math.ceil,
- START_VALUE = 'startValue',
- END_VALUE = 'endValue',
- DATETIME = 'datetime',
- SELECTED_RANGE = 'selectedRange',
- DISCRETE = 'discrete',
- STRING = 'string',
- SELECTED_RANGE_CHANGED = SELECTED_RANGE + 'Changed',
- CONTAINER_BACKGROUND_COLOR = "containerBackgroundColor",
- SLIDER_MARKER = "sliderMarker",
- BACKGROUND = "background",
- LOGARITHMIC = "logarithmic",
- INVISIBLE_POS = -1000,
- logarithmBase = 10;
- rangeSelector.consts = {
- emptySliderMarkerText: EMPTY_SLIDER_MARKER_TEXT,
- pointerSize: POINTER_SIZE
- };
- rangeSelector.HEIGHT_COMPACT_MODE = HEIGHT_COMPACT_MODE;
- rangeSelector.__getTextBBox = getTextBBox;
- function cloneSelectedRange(arg) {
- return {
- startValue: arg.startValue,
- endValue: arg.endValue
- }
- }
- var formatValue = rangeSelector.formatValue = function(value, formatOptions) {
- var formatObject = {
- value: value,
- valueText: formatHelper.format(value, formatOptions.format, formatOptions.precision)
- };
- return String(utils.isFunction(formatOptions.customizeText) ? formatOptions.customizeText.call(formatObject, formatObject) : formatObject.valueText)
- };
- var createRangeContainer = function(rangeContainerOptions) {
- return rangeSelector.rangeSelectorFactory.createRangeContainer(rangeContainerOptions)
- };
- var createTranslator = function(range, canvas) {
- return {
- x: core.CoreFactory.createTranslator2D(range.arg, canvas, {direction: "horizontal"}),
- y: core.CoreFactory.createTranslator2D(range.val, canvas)
- }
- };
- var createTranslatorCanvas = function(sizeOptions, rangeContainerCanvas, scaleLabelsAreaHeight) {
- return {
- left: rangeContainerCanvas.left,
- top: rangeContainerCanvas.top,
- right: sizeOptions.width - rangeContainerCanvas.width - rangeContainerCanvas.left,
- bottom: sizeOptions.height - rangeContainerCanvas.height - rangeContainerCanvas.top + scaleLabelsAreaHeight,
- width: sizeOptions.width,
- height: sizeOptions.height
- }
- };
- var calculateMarkerHeight = function(renderer, value, sliderMarkerOptions) {
- var formattedText = value === undefined ? EMPTY_SLIDER_MARKER_TEXT : formatValue(value, sliderMarkerOptions),
- textBBox = getTextBBox(renderer, formattedText, sliderMarkerOptions.font);
- return _ceil(textBBox.height) + 2 * sliderMarkerOptions.paddingTopBottom + POINTER_SIZE
- };
- var calculateScaleLabelHalfWidth = function(renderer, value, scaleOptions) {
- var formattedText = formatValue(value, scaleOptions.label),
- textBBox = getTextBBox(renderer, formattedText, scaleOptions.label.font);
- return _ceil(textBBox.width / 2)
- };
- var calculateRangeContainerCanvas = function(size, indents, scaleLabelsAreaHeight, isCompactMode) {
- var canvas = {
- left: size.left + indents.left,
- top: size.top + indents.top,
- width: size.width - size.left - size.right - indents.left - indents.right,
- height: !isCompactMode ? size.height - size.top - size.bottom - indents.top : HEIGHT_COMPACT_MODE + scaleLabelsAreaHeight
- };
- if (canvas.width <= 0)
- canvas.width = 1;
- return canvas
- };
- var parseSliderMarkersPlaceholderSize = function(placeholderSize) {
- var placeholderWidthLeft,
- placeholderWidthRight,
- placeholderHeight;
- if (_isNumber(placeholderSize))
- placeholderWidthLeft = placeholderWidthRight = placeholderHeight = placeholderSize;
- else if (placeholderSize) {
- if (_isNumber(placeholderSize.height))
- placeholderHeight = placeholderSize.height;
- if (_isNumber(placeholderSize.width))
- placeholderWidthLeft = placeholderWidthRight = placeholderSize.width;
- else if (placeholderSize.width) {
- if (_isNumber(placeholderSize.width.left))
- placeholderWidthLeft = placeholderSize.width.left;
- if (_isNumber(placeholderSize.width.right))
- placeholderWidthRight = placeholderSize.width.right
- }
- }
- else
- return null;
- return {
- widthLeft: placeholderWidthLeft,
- widthRight: placeholderWidthRight,
- height: placeholderHeight
- }
- };
- var calculateIndents = function(renderer, size, scale, sliderMarkerOptions, indentOptions) {
- var leftMarkerHeight,
- leftScaleLabelWidth = 0,
- rightScaleLabelWidth = 0,
- rightMarkerHeight,
- placeholderWidthLeft = 0,
- placeholderWidthRight = 0,
- placeholderHeight,
- parsedPlaceholderSize;
- indentOptions = indentOptions || {};
- parsedPlaceholderSize = parseSliderMarkersPlaceholderSize(sliderMarkerOptions.placeholderSize);
- if (parsedPlaceholderSize && indentOptions.left === undefined && indentOptions.right === undefined) {
- placeholderWidthLeft = parsedPlaceholderSize.widthLeft;
- placeholderWidthRight = parsedPlaceholderSize.widthRight
- }
- else {
- placeholderWidthLeft = indentOptions.left;
- placeholderWidthRight = indentOptions.right
- }
- if (parsedPlaceholderSize && sliderMarkerOptions.placeholderHeight === undefined)
- placeholderHeight = parsedPlaceholderSize.height;
- else
- placeholderHeight = sliderMarkerOptions.placeholderHeight;
- if (sliderMarkerOptions.visible) {
- leftMarkerHeight = calculateMarkerHeight(renderer, scale.startValue, sliderMarkerOptions);
- rightMarkerHeight = calculateMarkerHeight(renderer, scale.endValue, sliderMarkerOptions);
- if (placeholderHeight === undefined)
- placeholderHeight = _max(leftMarkerHeight, rightMarkerHeight)
- }
- if (scale.label.visible) {
- leftScaleLabelWidth = calculateScaleLabelHalfWidth(renderer, scale.startValue, scale);
- rightScaleLabelWidth = calculateScaleLabelHalfWidth(renderer, scale.endValue, scale)
- }
- placeholderWidthLeft = placeholderWidthLeft !== undefined ? placeholderWidthLeft : leftScaleLabelWidth;
- placeholderWidthRight = (placeholderWidthRight !== undefined ? placeholderWidthRight : rightScaleLabelWidth) || 1;
- return {
- left: placeholderWidthLeft,
- right: placeholderWidthRight,
- top: placeholderHeight || 0,
- bottom: 0
- }
- };
- var calculateValueType = function(firstValue, secondValue) {
- var typeFirstValue = $.type(firstValue),
- typeSecondValue = $.type(secondValue),
- validType = function(type) {
- return typeFirstValue === type || typeSecondValue === type
- };
- return validType('date') ? DATETIME : validType('number') ? 'numeric' : validType(STRING) ? STRING : ''
- };
- var showScaleMarkers = function(scaleOptions) {
- return scaleOptions.valueType === DATETIME && scaleOptions.marker.visible
- };
- var updateTranslatorRangeInterval = function(translatorRange, scaleOptions) {
- var intervalX = scaleOptions.minorTickInterval || scaleOptions.majorTickInterval;
- if (scaleOptions.valueType === "datetime")
- intervalX = utils.dateToMilliseconds(intervalX);
- translatorRange = translatorRange.arg.addRange({interval: intervalX})
- };
- var createRange = function(options) {
- return new core.Range(options)
- };
- var checkLogarithmicOptions = function(options, defaultLogarithmBase, incidentOccured) {
- var logarithmBase;
- if (!options)
- return;
- logarithmBase = options.logarithmBase;
- if (options.type === LOGARITHMIC && logarithmBase <= 0 || logarithmBase && !_isNumber(logarithmBase)) {
- options.logarithmBase = defaultLogarithmBase;
- incidentOccured('E2104')
- }
- else if (options.type !== LOGARITHMIC)
- options.logarithmBase = undefined
- };
- var calculateScaleAreaHeight = function(renderer, scaleOptions, visibleMarkers) {
- var textBBox,
- value = "0",
- formatObject = {
- value: 0,
- valueText: value
- },
- labelScaleOptions = scaleOptions.label,
- markerScaleOPtions = scaleOptions.marker,
- customizeText = labelScaleOptions.customizeText,
- placeholderHeight = scaleOptions.placeholderHeight,
- text = utils.isFunction(customizeText) ? customizeText.call(formatObject, formatObject) : value,
- visibleLabels = labelScaleOptions.visible;
- if (placeholderHeight)
- return placeholderHeight;
- else {
- textBBox = getTextBBox(renderer, text, labelScaleOptions.font);
- return (visibleLabels ? labelScaleOptions.topIndent + textBBox.height : 0) + (visibleMarkers ? markerScaleOPtions.topIndent + markerScaleOPtions.separatorHeight : 0)
- }
- };
- var updateTickIntervals = function(scaleOptions, screenDelta, incidentOccured, stick, min, max) {
- var categoriesInfo = scaleOptions._categoriesInfo,
- tickManager = core.CoreFactory.createTickManager({
- axisType: scaleOptions.type,
- dataType: scaleOptions.valueType
- }, {
- min: min,
- max: max,
- screenDelta: screenDelta,
- customTicks: categoriesInfo && categoriesInfo.categories
- }, {
- labelOptions: {},
- boundCoef: 1,
- minorTickInterval: scaleOptions.minorTickInterval,
- tickInterval: scaleOptions.majorTickInterval,
- incidentOccured: incidentOccured,
- base: scaleOptions.logarithmBase,
- showMinorTicks: true,
- withMinorCorrection: true,
- stick: stick !== false
- });
- tickManager.getTicks(true);
- return {
- majorTickInterval: tickManager.getTickInterval(),
- minorTickInterval: tickManager.getMinorTickInterval(),
- bounds: tickManager.getTickBounds()
- }
- };
- var calculateTranslatorRange = function(seriesDataSource, scaleOptions) {
- var minValue,
- maxValue,
- inverted = false,
- isEqualDates,
- startValue = scaleOptions.startValue,
- endValue = scaleOptions.endValue,
- categories,
- categoriesInfo,
- translatorRange = seriesDataSource ? seriesDataSource.getBoundRange() : {
- arg: createRange(),
- val: createRange({isValueRange: true})
- },
- rangeForCategories;
- if (scaleOptions.type === DISCRETE) {
- rangeForCategories = createRange({
- categories: scaleOptions.categories || (!seriesDataSource && startValue && endValue ? [startValue, endValue] : undefined),
- minVisible: startValue,
- maxVisible: endValue
- });
- rangeForCategories.addRange(translatorRange.arg);
- translatorRange.arg = rangeForCategories;
- categories = rangeForCategories.categories || [];
- scaleOptions._categoriesInfo = categoriesInfo = utils.getCategoriesInfo(categories, startValue || categories[0], endValue || categories[categories.length - 1])
- }
- if (_isDefined(startValue) && _isDefined(endValue)) {
- inverted = scaleOptions.inverted = categoriesInfo ? categoriesInfo.inverted : startValue > endValue;
- minValue = categoriesInfo ? categoriesInfo.start : inverted ? endValue : startValue;
- maxValue = categoriesInfo ? categoriesInfo.end : inverted ? startValue : endValue
- }
- else if (_isDefined(startValue) || _isDefined(endValue)) {
- minValue = startValue;
- maxValue = endValue
- }
- else if (categoriesInfo) {
- minValue = categoriesInfo.start;
- maxValue = categoriesInfo.end
- }
- isEqualDates = _isDate(minValue) && _isDate(maxValue) && minValue.getTime() === maxValue.getTime();
- if (minValue !== maxValue && !isEqualDates)
- translatorRange.arg.addRange({
- invert: inverted,
- min: minValue,
- max: maxValue,
- minVisible: minValue,
- maxVisible: maxValue,
- dataType: scaleOptions.valueType
- });
- translatorRange.arg.addRange({
- base: scaleOptions.logarithmBase,
- axisType: scaleOptions.type
- });
- if (!translatorRange.arg.isDefined()) {
- if (isEqualDates)
- scaleOptions.valueType = 'numeric';
- translatorRange.arg.setStubData(scaleOptions.valueType)
- }
- return translatorRange
- };
- var startEndNotDefined = function(start, end) {
- return !_isDefined(start) || !_isDefined(end)
- };
- function getTextBBox(renderer, text, fontOptions) {
- var textElement = renderer.text(text, INVISIBLE_POS, INVISIBLE_POS).css(patchFontOptions(fontOptions)).append(renderer.root);
- var textBBox = textElement.getBBox();
- textElement.remove();
- return textBBox
- }
- function processValue(selectedRangeOptions, scaleOptions, entity, incidentOccured) {
- var parsedValue,
- value = selectedRangeOptions[entity],
- parser = scaleOptions.parser || function() {
- return null
- },
- resultValue = scaleOptions[entity];
- if (_isDefined(value))
- parsedValue = parser(value);
- if (!_isDefined(parsedValue))
- incidentOccured("E2203", [entity]);
- else
- resultValue = parsedValue;
- return rangeSelector.utils.truncateSelectedRange(resultValue, scaleOptions)
- }
- DX.registerComponent("dxRangeSelector", rangeSelector, core.BaseWidget.inherit({
- _eventsMap: $.extend({}, core.BaseWidget.prototype._eventsMap, {
- onSelectedRangeChanged: {
- name: SELECTED_RANGE_CHANGED,
- deprecated: SELECTED_RANGE_CHANGED,
- deprecatedContext: function() {
- return null
- },
- deprecatedArgs: function(arg) {
- return [cloneSelectedRange(arg)]
- }
- },
- selectedRangeChanged: {newName: "onSelectedRangeChanged"}
- }),
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {
- selectedRangeChanged: {
- since: "14.2",
- message: "Use the 'onSelectedRangeChanged' option instead"
- },
- "sliderMarker.padding": {
- since: "15.1",
- message: "Use the 'paddingTopBottom' and 'paddingLeftRight' options instead"
- },
- "sliderMarker.placeholderSize": {
- since: "15.1",
- message: "Use the 'placeholderHeight' and 'indent' options instead"
- }
- })
- },
- _rootClassPrefix: "dxrs",
- _rootClass: "dxrs-range-selector",
- _dataSourceOptions: function() {
- return {paginate: false}
- },
- _dataIsReady: function() {
- return this._isDataSourceReady()
- },
- _initCore: function() {
- var that = this;
- that.rangeContainer = createRangeContainer(that._renderer);
- that._reinitDataSource();
- that._renderer.root.css({
- "touch-action": "pan-y",
- "-ms-touch-action": "pan-y"
- })
- },
- _initTooltip: $.noop,
- _setTooltipRendererOptions: $.noop,
- _setTooltipOptions: $.noop,
- _getDefaultSize: function() {
- return {
- width: 400,
- height: 160
- }
- },
- _handleLoadingIndicatorShown: $.noop,
- _reinitDataSource: function() {
- this._refreshDataSource()
- },
- _disposeCore: function() {
- var that = this,
- disposeObject = function(propName) {
- that[propName] && that[propName].dispose(),
- that[propName] = null
- };
- that.callBase();
- disposeObject("renderer");
- that.translators = null;
- disposeObject("rangeContainer")
- },
- _createThemeManager: function() {
- return rangeSelector.rangeSelectorFactory.createThemeManager()
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- _render: function(isResizing) {
- var that = this,
- currentAnimationEnabled,
- renderer = that._renderer;
- isResizing = isResizing || that.__isResizing;
- that._applyOptions();
- if (isResizing) {
- currentAnimationEnabled = renderer.animationEnabled();
- renderer.updateAnimationOptions({enabled: false});
- that.rangeContainer.redraw();
- renderer.updateAnimationOptions({enabled: currentAnimationEnabled})
- }
- else
- that.rangeContainer.redraw();
- !isResizing && (!that._dataSource || that._dataSource && that._dataSource.isLoaded()) && that.hideLoadingIndicator();
- that._drawn();
- that.__rendered && that.__rendered()
- },
- _optionChanged: function(args) {
- var that = this,
- name = args.name;
- if (name === "dataSource")
- that._reinitDataSource();
- else if (name === SELECTED_RANGE)
- that.setSelectedRange(that.option(SELECTED_RANGE));
- else
- that.callBase(args)
- },
- _applySize: $.noop,
- _resize: function() {
- this._render(true)
- },
- _dataSourceChangedHandler: function() {
- var that = this;
- that._endLoading(function() {
- if (that._renderer.drawn)
- that._render()
- })
- },
- _applyOptions: function() {
- var that = this,
- rangeContainerCanvas,
- seriesDataSource,
- translatorRange,
- scaleLabelsAreaHeight,
- sizeOptions = that._canvas,
- indents,
- sliderMarkerOptions,
- selectedRange,
- chartOptions = that.option('chart'),
- shutterOptions = that._getOption("shutter"),
- background = that._getOption(BACKGROUND),
- isCompactMode,
- scaleOptions,
- chartThemeManager;
- that._isUpdating = true;
- seriesDataSource = that._createSeriesDataSource(chartOptions);
- isCompactMode = !(seriesDataSource && seriesDataSource.isShowChart() || background && background.image && background.image.url);
- if (seriesDataSource) {
- chartThemeManager = seriesDataSource.getThemeManager();
- checkLogarithmicOptions(chartOptions && chartOptions.valueAxis, chartThemeManager.getOptions("valueAxis").logarithmBase, that._incidentOccured)
- }
- scaleOptions = that._scaleOptions = that._prepareScaleOptions(seriesDataSource);
- translatorRange = calculateTranslatorRange(seriesDataSource, scaleOptions);
- that._updateScaleOptions(seriesDataSource, translatorRange.arg, sizeOptions.width);
- updateTranslatorRangeInterval(translatorRange, scaleOptions);
- sliderMarkerOptions = that._prepareSliderMarkersOptions(sizeOptions.width);
- selectedRange = that._initSelection();
- indents = calculateIndents(that._renderer, sizeOptions, scaleOptions, sliderMarkerOptions, that.option("indent"));
- scaleLabelsAreaHeight = calculateScaleAreaHeight(that._renderer, scaleOptions, showScaleMarkers(scaleOptions));
- rangeContainerCanvas = calculateRangeContainerCanvas(sizeOptions, indents, scaleLabelsAreaHeight, isCompactMode);
- that.translators = createTranslator(translatorRange, createTranslatorCanvas(sizeOptions, rangeContainerCanvas, scaleLabelsAreaHeight));
- scaleOptions.ticksInfo = that._getTicksInfo(rangeContainerCanvas.width);
- that._testTicksInfo = scaleOptions.ticksInfo;
- that._selectedRange = selectedRange;
- if (seriesDataSource)
- seriesDataSource.adjustSeriesDimensions(that.translators);
- shutterOptions.color = shutterOptions.color || that._getOption(CONTAINER_BACKGROUND_COLOR, true);
- that.rangeContainer.applyOptions({
- canvas: rangeContainerCanvas,
- isCompactMode: isCompactMode,
- scaleLabelsAreaHeight: scaleLabelsAreaHeight,
- indents: indents,
- translators: that.translators,
- selectedRange: selectedRange,
- scale: scaleOptions,
- behavior: that._getOption('behavior'),
- background: background,
- chart: chartOptions,
- seriesDataSource: seriesDataSource,
- sliderMarker: sliderMarkerOptions,
- sliderHandle: that._getOption('sliderHandle'),
- shutter: shutterOptions,
- selectedRangeColor: that._getOption("selectedRangeColor", true),
- selectedRangeChanged: function(selectedRange, blockSelectedRangeChanged) {
- that.option(SELECTED_RANGE, selectedRange);
- if (!blockSelectedRangeChanged)
- that._eventTrigger(SELECTED_RANGE_CHANGED, cloneSelectedRange(selectedRange))
- },
- setSelectedRange: function(selectedRange) {
- that.setSelectedRange(selectedRange)
- }
- });
- that._isUpdating = false;
- chartThemeManager && chartThemeManager.dispose()
- },
- _initSelection: function() {
- var that = this,
- scaleOptions = that._scaleOptions,
- selectedRangeOptions = that.option(SELECTED_RANGE),
- incidentOccured = that._incidentOccured;
- if (!selectedRangeOptions)
- return cloneSelectedRange(scaleOptions);
- else
- return {
- startValue: processValue(selectedRangeOptions, scaleOptions, START_VALUE, incidentOccured),
- endValue: processValue(selectedRangeOptions, scaleOptions, END_VALUE, incidentOccured)
- }
- },
- _createSeriesDataSource: function(chartOptions) {
- var that = this,
- seriesDataSource,
- dataSource = that._dataSource && that._dataSource.items(),
- scaleOptions = that._getOption('scale'),
- valueType = scaleOptions.valueType,
- backgroundOption = that.option(BACKGROUND);
- if (!valueType)
- valueType = calculateValueType(scaleOptions.startValue, scaleOptions.endValue);
- if (dataSource || chartOptions && chartOptions.series) {
- chartOptions = $.extend({}, chartOptions, {theme: that.option("theme")});
- seriesDataSource = new rangeSelector.SeriesDataSource({
- renderer: that._renderer,
- dataSource: dataSource,
- valueType: (valueType || '').toLowerCase(),
- axisType: scaleOptions.type,
- chart: chartOptions,
- dataSourceField: that.option('dataSourceField'),
- backgroundColor: backgroundOption && backgroundOption.color,
- incidentOccured: that._incidentOccured,
- categories: scaleOptions.categories
- })
- }
- return seriesDataSource
- },
- _prepareScaleOptions: function(seriesDataSource) {
- var that = this,
- scaleOptions = that._getOption('scale'),
- parsedValue = 0,
- parseUtils = new ParseUtils,
- valueType = parseUtils.correctValueType((scaleOptions.valueType || '').toLowerCase()),
- parser,
- validateStartEndValues = function(field, parser) {
- var messageToIncidentOccured = field === START_VALUE ? 'start' : 'end';
- if (_isDefined(scaleOptions[field])) {
- parsedValue = parser(scaleOptions[field]);
- if (_isDefined(parsedValue))
- scaleOptions[field] = parsedValue;
- else {
- scaleOptions[field] = undefined;
- that._incidentOccured("E2202", [messageToIncidentOccured])
- }
- }
- };
- if (seriesDataSource)
- valueType = seriesDataSource.getCalculatedValueType() || valueType;
- if (!valueType)
- valueType = calculateValueType(scaleOptions.startValue, scaleOptions.endValue) || 'numeric';
- if (valueType === STRING || scaleOptions.categories) {
- scaleOptions.type = DISCRETE;
- valueType = STRING
- }
- scaleOptions.valueType = valueType;
- parser = parseUtils.getParser(valueType, 'scale');
- validateStartEndValues(START_VALUE, parser);
- validateStartEndValues(END_VALUE, parser);
- checkLogarithmicOptions(scaleOptions, logarithmBase, that._incidentOccured);
- if (!scaleOptions.type)
- scaleOptions.type = 'continuous';
- scaleOptions.parser = parser;
- return scaleOptions
- },
- _prepareSliderMarkersOptions: function(screenDelta) {
- var that = this,
- scaleOptions = that._scaleOptions,
- minorTickInterval = scaleOptions.minorTickInterval,
- majorTickInterval = scaleOptions.majorTickInterval,
- endValue = scaleOptions.endValue,
- startValue = scaleOptions.startValue,
- sliderMarkerOptions = that._getOption(SLIDER_MARKER),
- businessInterval,
- sliderMarkerUserOption = that.option(SLIDER_MARKER) || {};
- sliderMarkerOptions.borderColor = that._getOption(CONTAINER_BACKGROUND_COLOR, true);
- if (!sliderMarkerOptions.format) {
- if (!that._getOption('behavior').snapToTicks && _isNumber(scaleOptions.startValue)) {
- businessInterval = Math.abs(endValue - startValue);
- sliderMarkerOptions.format = 'fixedPoint';
- sliderMarkerOptions.precision = utils.getSignificantDigitPosition(businessInterval / screenDelta)
- }
- if (scaleOptions.valueType === DATETIME)
- if (!scaleOptions.marker.visible) {
- if (_isDefined(startValue) && _isDefined(endValue))
- sliderMarkerOptions.format = formatHelper.getDateFormatByTickInterval(startValue, endValue, minorTickInterval !== 0 ? minorTickInterval : majorTickInterval)
- }
- else
- sliderMarkerOptions.format = utils.getDateUnitInterval(_isDefined(minorTickInterval) && minorTickInterval !== 0 ? minorTickInterval : majorTickInterval)
- }
- if (sliderMarkerUserOption.padding !== undefined && sliderMarkerUserOption.paddingLeftRight === undefined && sliderMarkerUserOption.paddingTopBottom === undefined)
- sliderMarkerOptions.paddingLeftRight = sliderMarkerOptions.paddingTopBottom = sliderMarkerUserOption.padding;
- return sliderMarkerOptions
- },
- _updateScaleOptions: function(seriesDataSource, translatorRange, screenDelta) {
- var scaleOptions = this._scaleOptions,
- min = _isDefined(translatorRange.minVisible) ? translatorRange.minVisible : translatorRange.min,
- max = _isDefined(translatorRange.maxVisible) ? translatorRange.maxVisible : translatorRange.max,
- tickIntervalsInfo = updateTickIntervals(scaleOptions, screenDelta, this._incidentOccured, translatorRange.stick, min, max),
- bounds,
- isEmptyInterval,
- categoriesInfo = scaleOptions._categoriesInfo;
- if (seriesDataSource && !seriesDataSource.isEmpty() && !translatorRange.stubData) {
- bounds = tickIntervalsInfo.bounds;
- translatorRange.addRange(bounds);
- scaleOptions.startValue = scaleOptions.inverted ? bounds.maxVisible : bounds.minVisible;
- scaleOptions.endValue = scaleOptions.inverted ? bounds.minVisible : bounds.maxVisible
- }
- if (categoriesInfo) {
- scaleOptions.startValue = categoriesInfo.start;
- scaleOptions.endValue = categoriesInfo.end
- }
- isEmptyInterval = _isDate(scaleOptions.startValue) && _isDate(scaleOptions.endValue) && scaleOptions.startValue.getTime() === scaleOptions.endValue.getTime() || scaleOptions.startValue === scaleOptions.endValue;
- scaleOptions.isEmpty = startEndNotDefined(scaleOptions.startValue, scaleOptions.endValue) || isEmptyInterval;
- if (scaleOptions.isEmpty)
- scaleOptions.startValue = scaleOptions.endValue = undefined;
- else {
- scaleOptions.minorTickInterval = tickIntervalsInfo.minorTickInterval;
- scaleOptions.majorTickInterval = tickIntervalsInfo.majorTickInterval;
- if (scaleOptions.valueType === DATETIME && !_isDefined(scaleOptions.label.format))
- if (!scaleOptions.marker.visible)
- scaleOptions.label.format = formatHelper.getDateFormatByTickInterval(scaleOptions.startValue, scaleOptions.endValue, scaleOptions.majorTickInterval);
- else
- scaleOptions.label.format = utils.getDateUnitInterval(scaleOptions.majorTickInterval)
- }
- },
- _getStubTicks: function(scaleOptions) {
- scaleOptions.isEmpty = true;
- return ["canvas_position_left", "canvas_position_center", "canvas_position_right"]
- },
- _getTickManagerOptions: function(scaleOptions, isEmpty, startValue, endValue) {
- var that = this;
- return {
- labelOptions: {},
- minorTickInterval: isEmpty ? 0 : that._getOption('scale').minorTickInterval,
- tickInterval: scaleOptions.majorTickInterval,
- addMinMax: scaleOptions.showCustomBoundaryTicks ? {
- min: true,
- max: true
- } : undefined,
- minorTickCount: scaleOptions.minorTickCount,
- textOptions: {
- align: 'center',
- font: scaleOptions.label.font
- },
- textFontStyles: patchFontOptions(scaleOptions.label.font),
- incidentOccured: that._incidentOccured,
- isHorizontal: true,
- renderText: function(text, x, y, options) {
- return that._renderer.text(text, x, y, options).append(that._renderer.root)
- },
- getText: startEndNotDefined(startValue, endValue) ? function(value) {
- return value
- } : function(value) {
- return formatValue(value, scaleOptions.label)
- },
- translate: function(value) {
- return that.translators.x.translate(value)
- },
- textSpacing: SCALE_TEXT_SPACING,
- setTicksAtUnitBeginning: scaleOptions.setTicksAtUnitBeginning,
- useTicksAutoArrangement: scaleOptions.useTicksAutoArrangement,
- base: scaleOptions.logarithmBase,
- stick: true,
- showMinorTicks: true,
- withMinorCorrection: true
- }
- },
- _getTicksInfo: function(screenDelta) {
- var that = this,
- scaleOptions = that._scaleOptions,
- translators = that.translators,
- isEmpty = scaleOptions.isEmpty,
- businessRange = translators.x.getBusinessRange(),
- categoriesInfo = scaleOptions._categoriesInfo,
- tickManagerTypes = {
- axisType: scaleOptions.type,
- dataType: scaleOptions.valueType
- },
- tickManagerData,
- startValue = scaleOptions.startValue,
- endValue = scaleOptions.endValue,
- tickManagerOptions = that._getTickManagerOptions(scaleOptions, isEmpty, startValue, endValue),
- majorTicks,
- customBoundaryTicks,
- tickManager,
- fullTicks,
- noInfoFromMinMax;
- tickManagerData = {
- min: isEmpty ? businessRange.min : startValue,
- max: isEmpty ? businessRange.max : endValue,
- screenDelta: screenDelta,
- customTicks: categoriesInfo && categoriesInfo.categories
- };
- tickManager = core.CoreFactory.createTickManager(tickManagerTypes, tickManagerData, tickManagerOptions);
- if (scaleOptions.type === DISCRETE)
- noInfoFromMinMax = !_isDefined(tickManagerData.min) || !_isDefined(tickManagerData.max);
- else
- noInfoFromMinMax = !_isDefined(tickManagerData.min) && !_isDefined(tickManagerData.max);
- majorTicks = noInfoFromMinMax && !_isDefined(tickManagerData.customTicks) ? that._getStubTicks(scaleOptions) : tickManager.getTicks(true);
- customBoundaryTicks = tickManager.getBoundaryTicks();
- fullTicks = tickManager.getFullTicks();
- if (customBoundaryTicks.length) {
- if (majorTicks[0].valueOf() === customBoundaryTicks[0].valueOf())
- majorTicks.splice(0, 1);
- if (majorTicks[majorTicks.length - 1].valueOf() === customBoundaryTicks[customBoundaryTicks.length - 1].valueOf())
- majorTicks.pop()
- }
- return {
- majorTicks: majorTicks,
- minorTicks: tickManager.getMinorTicks(),
- majorTickInterval: tickManager.getTickInterval(),
- fullTicks: fullTicks,
- customBoundaryTicks: customBoundaryTicks
- }
- },
- getSelectedRange: function() {
- return cloneSelectedRange(this.rangeContainer.slidersContainer.getSelectedRange())
- },
- setSelectedRange: function(selectedRange) {
- var that = this;
- if (that._isUpdating || !selectedRange)
- return;
- var oldSelectedRange = that.rangeContainer.slidersContainer.getSelectedRange();
- if (oldSelectedRange && oldSelectedRange.startValue === selectedRange.startValue && oldSelectedRange.endValue === selectedRange.endValue)
- return;
- that.rangeContainer.slidersContainer.setSelectedRange(selectedRange)
- },
- resetSelectedRange: function(blockSelectedRangeChanged) {
- var data = cloneSelectedRange(this._scaleOptions);
- data.blockSelectedRangeChanged = blockSelectedRangeChanged;
- this.setSelectedRange(data)
- },
- render: function(isResizing) {
- var that = this;
- that.__isResizing = isResizing;
- that.callBase.apply(that, arguments);
- that.__isResizing = null;
- return that
- }
- }).include(DX.ui.DataHelperMixin))
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeContainer.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- baseVisualElementMethods = rangeSelector.baseVisualElementMethods,
- RangeContainer;
- var createSlidersContainer = function(options) {
- return rangeSelector.rangeSelectorFactory.createSlidersContainer(options)
- };
- var createScale = function(options) {
- return rangeSelector.rangeSelectorFactory.createScale(options)
- };
- var createRangeView = function(options) {
- return rangeSelector.rangeSelectorFactory.createRangeView(options)
- };
- var _createClipRectCanvas = function(canvas, indents) {
- return {
- left: canvas.left - indents.left,
- top: canvas.top - indents.top,
- width: canvas.width + indents.right + indents.left,
- height: canvas.height + indents.bottom + indents.top
- }
- };
- function canvasOptionsToRenderOptions(canvasOptions) {
- return {
- x: canvasOptions.left,
- y: canvasOptions.top,
- width: canvasOptions.width,
- height: canvasOptions.height
- }
- }
- RangeContainer = function(renderer) {
- baseVisualElementMethods.init.apply(this, arguments);
- this.slidersContainer = createSlidersContainer(renderer);
- this.rangeView = createRangeView(renderer);
- this.scale = createScale(renderer)
- };
- RangeContainer.prototype = $.extend({}, baseVisualElementMethods, {
- constructor: RangeContainer,
- dispose: function() {
- this.slidersContainer.dispose();
- this.slidersContainer = null
- },
- _applyOptions: function(options) {
- var that = this,
- scaleLabelsAreaHeight = options.scaleLabelsAreaHeight,
- canvas = options.canvas,
- isCompactMode = options.isCompactMode,
- viewCanvas = {
- left: canvas.left,
- top: canvas.top,
- width: canvas.width,
- height: canvas.height >= scaleLabelsAreaHeight ? canvas.height - scaleLabelsAreaHeight : 0
- };
- that._viewCanvas = viewCanvas;
- that.slidersContainer.applyOptions({
- isCompactMode: isCompactMode,
- canvas: viewCanvas,
- selectedRangeColor: options.selectedRangeColor,
- translator: options.translators.x,
- scale: options.scale,
- selectedRange: options.selectedRange,
- sliderMarker: options.sliderMarker,
- sliderHandle: options.sliderHandle,
- shutter: options.shutter,
- behavior: options.behavior,
- selectedRangeChanged: options.selectedRangeChanged
- });
- that.rangeView.applyOptions({
- isCompactMode: isCompactMode,
- canvas: viewCanvas,
- translators: options.translators,
- background: options.background,
- chart: options.chart,
- seriesDataSource: options.seriesDataSource,
- behavior: options.behavior,
- isEmpty: options.scale.isEmpty
- });
- that.scale.applyOptions({
- isCompactMode: isCompactMode,
- canvas: canvas,
- translator: options.translators.x,
- scale: options.scale,
- scaleLabelsAreaHeight: scaleLabelsAreaHeight,
- setSelectedRange: options.setSelectedRange
- })
- },
- _draw: function() {
- var that = this,
- containerGroup,
- rangeViewGroup,
- slidersContainerGroup,
- scaleGroup,
- trackersGroup,
- options = that._options,
- clipRectCanvas = _createClipRectCanvas(options.canvas, options.indents),
- viewCanvas = that._viewCanvas,
- renderer = that._renderer,
- slidersContainer = that.slidersContainer;
- that._clipRect = renderer.clipRect(clipRectCanvas.left, clipRectCanvas.top, clipRectCanvas.width, clipRectCanvas.height);
- that._viewClipRect = renderer.clipRect(viewCanvas.left, viewCanvas.top, viewCanvas.width, viewCanvas.height);
- containerGroup = renderer.g().attr({
- 'class': 'rangeContainer',
- clipId: that._clipRect.id
- }).append(renderer.root);
- rangeViewGroup = renderer.g().attr({
- 'class': 'view',
- clipId: that._viewClipRect.id
- });
- that._slidersGroup = slidersContainerGroup = renderer.g().attr({'class': 'slidersContainer'});
- scaleGroup = renderer.g().attr({'class': 'scale'});
- trackersGroup = renderer.g().attr({'class': 'trackers'});
- rangeViewGroup.append(containerGroup);
- if (!options.isCompactMode) {
- slidersContainerGroup.append(containerGroup);
- scaleGroup.append(containerGroup)
- }
- else {
- scaleGroup.append(containerGroup);
- slidersContainerGroup.append(containerGroup)
- }
- trackersGroup.append(containerGroup);
- that.rangeView.redraw(rangeViewGroup);
- slidersContainer.redraw(slidersContainerGroup);
- that.scale.redraw(scaleGroup);
- that._trackersGroup = trackersGroup;
- slidersContainer.appendTrackers(trackersGroup)
- },
- _update: function() {
- var that = this,
- options = that._options,
- slidersContainer = that.slidersContainer;
- that._clipRect.attr(canvasOptionsToRenderOptions(_createClipRectCanvas(options.canvas, options.indents)));
- that._viewClipRect.attr(canvasOptionsToRenderOptions(that._viewCanvas));
- that.rangeView.redraw();
- slidersContainer.redraw(that._slidersGroup);
- slidersContainer.appendTrackers(that._trackersGroup);
- that.scale.redraw()
- },
- createSlidersContainer: createSlidersContainer,
- createScale: createScale
- });
- rangeSelector.RangeContainer = RangeContainer
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file scale.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- rangeSelector = viz.rangeSelector,
- formatHelper = DX.formatHelper,
- rangeSelectorUtils = rangeSelector.utils,
- utils = DX.utils,
- _isDefined = utils.isDefined,
- HALF_TICK_LENGTH = 6,
- MINOR_TICK_OPACITY_COEF = 0.6,
- Scale,
- baseVisualElementMethods = rangeSelector.baseVisualElementMethods,
- _extend = $.extend;
- function calculateRangeByMarkerPosition(posX, markerDatePositions, scaleOptions) {
- var selectedRange = {},
- position,
- i;
- for (i = 0; i < markerDatePositions.length; i++) {
- position = markerDatePositions[i];
- if (!scaleOptions.inverted) {
- if (posX >= position.posX)
- selectedRange.startValue = position.date;
- else if (!selectedRange.endValue)
- selectedRange.endValue = position.date
- }
- else if (posX < position.posX)
- selectedRange.endValue = position.date;
- else if (!selectedRange.startValue)
- selectedRange.startValue = position.date
- }
- selectedRange.startValue = selectedRange.startValue || scaleOptions.startValue;
- selectedRange.endValue = selectedRange.endValue || scaleOptions.endValue;
- return selectedRange
- }
- var dateSetters = {};
- dateSetters.millisecond = function(date) {
- date.setMilliseconds(0)
- };
- dateSetters.second = function(date) {
- date.setSeconds(0, 0)
- };
- dateSetters.minute = function(date) {
- date.setMinutes(0, 0, 0)
- };
- dateSetters.hour = function(date) {
- date.setHours(0, 0, 0, 0)
- };
- dateSetters.week = dateSetters.day = function(date) {
- date.setDate(1);
- dateSetters.hour(date)
- };
- dateSetters.month = function(date) {
- date.setMonth(0);
- dateSetters.day(date)
- };
- dateSetters.quarter = function(date) {
- date.setMonth(formatHelper.getFirstQuarterMonth(date.getMonth()));
- dateSetters.day(date)
- };
- function getMarkerDate(date, tickInterval) {
- var markerDate = new Date(date.getTime()),
- setter = dateSetters[tickInterval];
- setter && setter(markerDate);
- return markerDate
- }
- function prepareDatesDifferences(datesDifferences, tickInterval) {
- var deleteDifferent = tickInterval,
- dateUnitInterval,
- i;
- if (deleteDifferent === 'week')
- deleteDifferent = 'day';
- if (deleteDifferent === 'quarter')
- deleteDifferent = 'month';
- if (datesDifferences[deleteDifferent])
- for (i = 0; i < utils.dateUnitIntervals.length; i++) {
- dateUnitInterval = utils.dateUnitIntervals[i];
- if (datesDifferences[dateUnitInterval]) {
- datesDifferences[dateUnitInterval] = false;
- datesDifferences.count--
- }
- if (dateUnitInterval === deleteDifferent)
- break
- }
- }
- function getLabel(value, options) {
- var formatObject = {
- value: value,
- valueText: formatHelper.format(value, options.format, options.precision)
- };
- return String(utils.isFunction(options.customizeText) ? options.customizeText.call(formatObject, formatObject) : formatObject.valueText)
- }
- Scale = function() {
- baseVisualElementMethods.init.apply(this, arguments)
- };
- Scale.prototype = _extend({}, baseVisualElementMethods, {
- constructor: Scale,
- _setupDateUnitInterval: function(scaleOptions) {
- var key,
- millisecTickInterval,
- majorTickInterval = scaleOptions.ticksInfo.majorTickInterval,
- majorTicks = scaleOptions.ticksInfo.majorTicks;
- if (scaleOptions.valueType === 'datetime') {
- if (majorTicks && majorTicks.autoArrangementStep > 1) {
- if (utils.isString(majorTickInterval))
- majorTickInterval = utils.getDateIntervalByString(majorTickInterval);
- for (key in majorTickInterval)
- if (majorTickInterval.hasOwnProperty(key)) {
- majorTickInterval[key] *= majorTicks.autoArrangementStep;
- millisecTickInterval = utils.dateToMilliseconds(majorTickInterval)
- }
- majorTickInterval = utils.convertMillisecondsToDateUnits(millisecTickInterval)
- }
- this.dateUnitInterval = utils.getDateUnitInterval(majorTickInterval)
- }
- },
- _getDrawnDateMarker: function(date, options) {
- var that = this,
- labelPosX,
- labelPosY,
- scaleOptions = that._options.scale,
- textElement,
- textElementWidth,
- textIndent,
- pathElement;
- if (options.x === null)
- return;
- that.textOptions.align = "left";
- pathElement = that._renderer.path([options.x, options.y, options.x, options.y + scaleOptions.marker.separatorHeight], "line").attr(that._majorTickStyle).append(options.group);
- textElement = that._renderer.text(getLabel(date, options.label), 0, 0).attr(that.textOptions).css(that.fontOptions).append(options.group);
- textElementWidth = textElement.getBBox().width;
- textIndent = scaleOptions.tick.width + scaleOptions.marker.textLeftIndent;
- labelPosX = scaleOptions.inverted ? options.x - textIndent - textElementWidth : options.x + textIndent;
- labelPosY = options.y + scaleOptions.marker.textTopIndent + that.fontOptions["font-size"];
- textElement.move(labelPosX, labelPosY);
- return {
- x1: labelPosX,
- x2: labelPosX + textElementWidth,
- path: pathElement,
- text: textElement
- }
- },
- _deleteDrawnDateMarker: function(marker) {
- marker.path.dispose();
- marker.path = null;
- marker.text.dispose();
- marker.text = null
- },
- _drawDateMarkers: function(dates, group) {
- var that = this,
- i,
- options = that._options,
- datesLength = dates.length,
- datesDifferences,
- markerDate,
- posX,
- markerDatePositions = [],
- prevDateMarker,
- dateMarker;
- if (options.scale.valueType !== 'datetime' || !that.visibleMarkers)
- return;
- if (dates.length > 1) {
- for (i = 1; i < datesLength; i++) {
- datesDifferences = utils.getDatesDifferences(dates[i - 1], dates[i]);
- prepareDatesDifferences(datesDifferences, that.dateUnitInterval);
- if (datesDifferences.count > 0) {
- markerDate = getMarkerDate(dates[i], that.dateUnitInterval);
- that.markerDates = that.markerDates || [];
- that.markerDates.push(markerDate);
- posX = that.translator.translate(markerDate);
- dateMarker = that._getDrawnDateMarker(markerDate, {
- group: group,
- y: options.canvas.top + options.canvas.height - that.markersAreaHeight + options.scale.marker.topIndent,
- x: posX,
- label: that._getLabelFormatOptions(formatHelper.getDateFormatByDifferences(datesDifferences))
- });
- if (prevDateMarker === undefined || dateMarker.x1 > prevDateMarker.x2 || dateMarker.x2 < prevDateMarker.x1) {
- posX !== null && markerDatePositions.push({
- date: markerDate,
- posX: posX
- });
- prevDateMarker = dateMarker
- }
- else
- that._deleteDrawnDateMarker(dateMarker)
- }
- }
- that._initializeMarkersEvents(markerDatePositions, group)
- }
- },
- _getLabelFormatOptions: function(formatString) {
- if (!_isDefined(this._options.scale.marker.label.format))
- return _extend({}, this._options.scale.marker.label, {format: formatString});
- return this._options.scale.marker.label
- },
- _initializeMarkersEvents: function(markerDatePositions, group) {
- var that = this,
- options = that._options,
- markersAreaTop = options.canvas.top + options.canvas.height - this.markersAreaHeight + options.scale.marker.topIndent,
- markersTracker,
- svgOffsetLeft,
- posX,
- selectedRange;
- if (markerDatePositions.length > 0) {
- markersTracker = that._renderer.rect(options.canvas.left, markersAreaTop, options.canvas.width, options.scale.marker.separatorHeight).attr(rangeSelectorUtils.trackerSettings).append(group);
- markersTracker.on(rangeSelector.events.start, function(e) {
- svgOffsetLeft = that._renderer.getRootOffset().left;
- posX = rangeSelectorUtils.getEventPageX(e) - svgOffsetLeft;
- selectedRange = calculateRangeByMarkerPosition(posX, markerDatePositions, options.scale);
- options.setSelectedRange(selectedRange)
- });
- that._markersTracker = markersTracker
- }
- },
- _drawLabel: function(text, group) {
- var that = this,
- options = that._options,
- canvas = options.canvas,
- textY = canvas.top + canvas.height - that.markersAreaHeight,
- textElements = that._renderer.text(getLabel(text, options.scale.label), that.translator.translate(text), textY).attr(that.textOptions).css(that.fontOptions).append(group);
- that.textElements = that.textElements || [];
- that.textElements.push(textElements)
- },
- _drawTicks: function(ticks, group, directionOffset, coords, style, labelsGroup) {
- var that = this,
- i,
- posX,
- tickElement;
- for (i = 0; i < ticks.length; i++) {
- if (labelsGroup)
- that._drawLabel(ticks[i], labelsGroup);
- posX = that.translator.translate(ticks[i], directionOffset);
- tickElement = that._createLine([posX, coords[0], posX, coords[1]], group, style);
- that.tickElements = that.tickElements || [];
- that.tickElements.push(tickElement)
- }
- },
- _createLine: function(points, group, options) {
- return this._renderer.path(points, "line").attr(options).append(group)
- },
- _redraw: function(group) {
- var that = this,
- options = that._options,
- scaleOptions = options.scale,
- renderer = that._renderer,
- labelsGroup = renderer.g().append(group),
- ticksGroup = renderer.g(),
- ticksInfo = scaleOptions.ticksInfo,
- majorTicks = ticksInfo.majorTicks,
- minorTicks = ticksInfo.minorTicks,
- customBoundaryTicks = ticksInfo.customBoundaryTicks,
- hideLabels = scaleOptions.isEmpty || !scaleOptions.label.visible,
- isDiscrete = scaleOptions.type === "discrete",
- directionOffset = isDiscrete ? -1 : 0,
- isCompactMode = options.isCompactMode,
- canvas = options.canvas,
- bottom = canvas.top + canvas.height - that.scaleLabelsAreaHeight,
- center = canvas.top + (bottom - canvas.top) / 2,
- coords = isCompactMode ? [center - HALF_TICK_LENGTH, center + HALF_TICK_LENGTH] : [canvas.top, bottom],
- categoriesInfo = scaleOptions._categoriesInfo,
- majorTickStyle = that._majorTickStyle;
- that._drawTicks(majorTicks, ticksGroup, directionOffset, coords, majorTickStyle, !hideLabels && labelsGroup);
- if (scaleOptions.showMinorTicks || isDiscrete)
- that._drawTicks(minorTicks, ticksGroup, directionOffset, coords, that._minorTickStyle);
- that._drawTicks(customBoundaryTicks, ticksGroup, 0, coords, majorTickStyle);
- isDiscrete && categoriesInfo && _isDefined(categoriesInfo.end) && that._drawTicks([categoriesInfo.end], ticksGroup, 1, coords, majorTickStyle);
- if (isCompactMode)
- that._createLine([canvas.left, center, canvas.width + canvas.left, center], group, _extend({}, majorTickStyle, {sharp: "v"}));
- ticksGroup.append(group);
- that._drawDateMarkers(majorTicks, labelsGroup)
- },
- _applyOptions: function(options) {
- var that = this,
- scaleOptions = options.scale,
- labelsAreaHeight,
- tick = scaleOptions.tick;
- that.textOptions = {align: 'center'};
- that.fontOptions = viz.core.utils.patchFontOptions(scaleOptions.label.font);
- that._majorTickStyle = {
- "stroke-width": tick.width,
- stroke: tick.color,
- "stroke-opacity": tick.opacity,
- sharp: "h"
- };
- that._minorTickStyle = _extend({}, that._majorTickStyle, {"stroke-opacity": tick.opacity * MINOR_TICK_OPACITY_COEF});
- that._setupDateUnitInterval(scaleOptions);
- that.visibleMarkers = scaleOptions.marker.visible === undefined ? true : scaleOptions.marker.visible;
- labelsAreaHeight = scaleOptions.label.visible ? scaleOptions.label.topIndent + that.fontOptions["font-size"] : 0;
- that.scaleLabelsAreaHeight = options.scaleLabelsAreaHeight;
- that.markersAreaHeight = that.scaleLabelsAreaHeight - labelsAreaHeight;
- that.translator = options.translator
- },
- _draw: function(group) {
- this._redraw(group)
- },
- _update: function() {
- if (this._markersTracker)
- this._markersTracker.off(rangeSelector.events.start, '**');
- baseVisualElementMethods._update.apply(this, arguments)
- }
- });
- Scale.prototype._calculateRangeByMarkerPosition = calculateRangeByMarkerPosition;
- Scale.prototype._prepareDatesDifferences = prepareDatesDifferences;
- rangeSelector.Scale = Scale
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeFactory.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector;
- rangeSelector.rangeSelectorFactory = function() {
- return {
- createRangeContainer: function(rangeContainerOptions) {
- return new rangeSelector.RangeContainer(rangeContainerOptions)
- },
- createSlidersContainer: function(options) {
- return new rangeSelector.SlidersContainer(options)
- },
- createScale: function(options) {
- return new rangeSelector.Scale(options)
- },
- createSliderMarker: function(options) {
- return new rangeSelector.SliderMarker(options)
- },
- createRangeView: function(options) {
- return new rangeSelector.RangeView(options)
- },
- createThemeManager: function(options) {
- return new rangeSelector.ThemeManager(options)
- },
- createSlider: function(renderer, sliderIndex) {
- return new rangeSelector.Slider(renderer, sliderIndex)
- },
- createSlidersEventsManager: function(renderer, slidersController, processSelectionChanged) {
- return new rangeSelector.SlidersEventsManager(renderer, slidersController, processSelectionChanged)
- },
- createSlidersController: function(sliders) {
- return new rangeSelector.SlidersController(sliders)
- }
- }
- }()
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersContainer.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils,
- msPointerEnabled = DX.support.pointer,
- isNumber = utils.isNumber,
- isDate = utils.isDate,
- isString = utils.isString,
- rangeSelectorUtils = rangeSelector.utils,
- baseVisualElementMethods = rangeSelector.baseVisualElementMethods,
- rangeSelectorFactory = rangeSelector.rangeSelectorFactory,
- trackerAttributes = rangeSelectorUtils.trackerSettings;
- function SlidersContainer() {
- var that = this;
- baseVisualElementMethods.init.apply(that, arguments);
- that._controller = rangeSelectorFactory.createSlidersController(that._renderer);
- that._eventsManager = rangeSelectorFactory.createSlidersEventsManager(that._renderer, that._controller, function(moving) {
- that._processSelectionChanged(moving)
- });
- that._lastSelectedRange = {}
- }
- SlidersContainer.prototype = $.extend({}, baseVisualElementMethods, {
- constructor: SlidersContainer,
- _drawAreaTracker: function(group) {
- var that = this,
- areaTracker,
- selectedAreaTracker,
- canvas = that._options.canvas,
- renderer = that._renderer;
- areaTracker = renderer.rect(canvas.left, canvas.top, canvas.width, canvas.height).attr(trackerAttributes).append(group);
- selectedAreaTracker = renderer.rect(canvas.left, canvas.top, canvas.width, canvas.height).attr(trackerAttributes).css({cursor: 'pointer'}).append(group);
- that._controller.setAreaTrackers(areaTracker, selectedAreaTracker)
- },
- dispose: function() {
- this._eventsManager.dispose();
- this._controller.dispose();
- this._eventManager = null
- },
- _processSelectionChanged: function(moving, blockSelectedRangeChanged) {
- var that = this,
- equalLastSelectedRange = function(selectedRange) {
- return selectedRange && that._lastSelectedRange.startValue === selectedRange.startValue && that._lastSelectedRange.endValue === selectedRange.endValue
- },
- selectedRange = that.getSelectedRange();
- if ((!moving || (that._options.behavior.callSelectedRangeChanged || '').toLowerCase() === "onmoving") && that._options.selectedRangeChanged && !equalLastSelectedRange(selectedRange)) {
- that._updateLastSelectedRange(selectedRange);
- if (utils.isFunction(that._options.selectedRangeChanged))
- that._options.selectedRangeChanged.call(null, selectedRange, blockSelectedRangeChanged);
- if (!moving && !equalLastSelectedRange(selectedRange))
- that.setSelectedRange(selectedRange)
- }
- },
- _updateLastSelectedRange: function(selectedRange) {
- selectedRange = selectedRange || this._options.selectedRange;
- this._lastSelectedRange = {
- startValue: selectedRange.startValue,
- endValue: selectedRange.endValue
- }
- },
- getSelectedRange: function() {
- return this._controller.getSelectedRange()
- },
- setSelectedRange: function(selectedRange) {
- var that = this,
- scale = that._options.scale,
- startValue,
- endValue,
- currentSelectedRange = that._options.selectedRange,
- checkTypes = function(valueName, value) {
- var valueFromScale = scale[valueName];
- if (isNumber(valueFromScale) && isNumber(value) || isDate(valueFromScale) && isDate(value) || isString(valueFromScale) && isString(value))
- currentSelectedRange[valueName] = value
- };
- if (selectedRange) {
- startValue = selectedRange.startValue;
- endValue = selectedRange.endValue
- }
- checkTypes('startValue', startValue);
- checkTypes('endValue', endValue);
- currentSelectedRange.startValue = rangeSelectorUtils.truncateSelectedRange(currentSelectedRange.startValue, scale);
- currentSelectedRange.endValue = rangeSelectorUtils.truncateSelectedRange(currentSelectedRange.endValue, scale);
- that._controller.applySelectedRange(currentSelectedRange);
- that._controller.applyPosition();
- that._processSelectionChanged(false, selectedRange && selectedRange.blockSelectedRangeChanged)
- },
- appendTrackers: function(group) {
- this._controller.appendTrackers(group)
- },
- _applyOptions: function(options) {
- var that = this;
- that._controller.applyOptions({
- isCompactMode: options.isCompactMode,
- translator: options.translator,
- canvas: options.canvas,
- sliderMarker: options.sliderMarker,
- sliderHandle: options.sliderHandle,
- shutter: options.shutter,
- scale: options.scale,
- behavior: options.behavior
- });
- that._eventsManager.applyOptions({behavior: options.behavior})
- },
- _draw: function(group) {
- var that = this,
- rootElement;
- if (msPointerEnabled) {
- rootElement = that._renderer.root;
- rootElement && rootElement.css({msTouchAction: "pinch-zoom"})
- }
- that._controller.redraw(group);
- that._drawAreaTracker(group);
- that._eventsManager.initialize();
- that._update(group)
- },
- _updateSelectedView: function(group) {
- var that = this,
- options = that._options,
- canvas = options.canvas,
- lineOptions = {
- "stroke-width": 3,
- stroke: options.selectedRangeColor,
- sharp: "v"
- },
- center = canvas.top + canvas.height / 2,
- selectedView = that._selectedView,
- selectedViewAppended = that._selectedViewAppended,
- controller = that._controller;
- if (!options.isCompactMode) {
- if (selectedView && selectedViewAppended) {
- selectedView.remove();
- that._selectedViewAppended = false
- }
- controller.createShutters()
- }
- else {
- if (!selectedView) {
- that._selectedView = selectedView = that._renderer.path([canvas.left, center, canvas.left, center], "line").attr(lineOptions);
- controller.setSelectedView(selectedView)
- }
- else
- selectedView.attr(lineOptions);
- if (!selectedViewAppended) {
- selectedView.append(group);
- controller.removeShutters();
- that._selectedViewAppended = true
- }
- }
- },
- _update: function(group) {
- var that = this,
- isEmpty = that._options.scale.isEmpty,
- controller = that._controller;
- that._eventsManager.setEnabled(!isEmpty);
- !isEmpty && that._updateSelectedView(group);
- controller.applySelectedRange(isEmpty ? {} : that._options.selectedRange);
- controller.applyPosition(that.isDrawn());
- that._updateLastSelectedRange();
- controller.redraw()
- },
- getController: function() {
- return this._controller
- }
- });
- rangeSelector.SlidersContainer = SlidersContainer
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersController.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- createSlider = rangeSelector.rangeSelectorFactory.createSlider,
- utils = DX.utils,
- rangeSelectorUtils = rangeSelector.utils,
- _SliderController,
- START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1,
- DISCRETE = 'discrete';
- _SliderController = rangeSelector.SlidersController = function(renderer) {
- var sliders = [createSlider(renderer, START_VALUE_INDEX), createSlider(renderer, END_VALUE_INDEX)];
- sliders[START_VALUE_INDEX].setAnotherSlider(sliders[END_VALUE_INDEX]);
- sliders[END_VALUE_INDEX].setAnotherSlider(sliders[START_VALUE_INDEX]);
- this._sliders = sliders
- };
- _SliderController.prototype = {
- constructor: _SliderController,
- setAreaTrackers: function(areaTracker, selectedAreaTracker) {
- this._areaTracker = areaTracker;
- this._selectedAreaTracker = selectedAreaTracker
- },
- applyOptions: function(options) {
- var that = this,
- values = null,
- startSlider = that.getSlider(START_VALUE_INDEX),
- endSlider = that.getSlider(END_VALUE_INDEX),
- scaleOptions = options.scale;
- that._options = options;
- startSlider.applyOptions(options);
- endSlider.applyOptions(options);
- if (options.behavior.snapToTicks && scaleOptions.type !== DISCRETE) {
- values = scaleOptions.ticksInfo.fullTicks;
- if (values.length > 1 && values[0] > values[values.length - 1])
- values = values.reverse()
- }
- startSlider.setAvailableValues(values);
- endSlider.setAvailableValues(values)
- },
- processDocking: function(sliderIndex) {
- var that = this;
- if (sliderIndex !== undefined)
- that.getSlider(sliderIndex).processDocking();
- else {
- that.getSlider(START_VALUE_INDEX).processDocking();
- that.getSlider(END_VALUE_INDEX).processDocking()
- }
- that.setTrackersCursorStyle('default');
- that.applyAreaTrackersPosition();
- that._applySelectedRangePosition()
- },
- _applySelectedRangePosition: function(disableAnimation) {
- var that = this,
- options = that._options,
- canvas = options.canvas,
- center = canvas.top + canvas.height / 2,
- isAnimation = options.behavior.animationEnabled && !disableAnimation,
- startSliderPos = that.getSlider(START_VALUE_INDEX).getPosition(),
- interval = that.getSelectedRangeInterval(),
- points = [startSliderPos, center, startSliderPos + interval, center],
- selectedView = that._selectedView;
- if (!selectedView || !options.isCompactMode)
- return;
- if (isAnimation)
- selectedView.animate({points: points}, rangeSelectorUtils.animationSettings);
- else
- selectedView.stopAnimation().attr({points: points})
- },
- setSelectedView: function(selectedView) {
- this._selectedView = selectedView
- },
- getSelectedRangeInterval: function() {
- var that = this;
- return that.getSlider(END_VALUE_INDEX).getPosition() - that.getSlider(START_VALUE_INDEX).getPosition()
- },
- moveSliders: function(postitionDelta, selectedRangeInterval) {
- var startSlider = this.getSlider(START_VALUE_INDEX);
- startSlider.setPosition(startSlider.getPosition() + postitionDelta, false, selectedRangeInterval);
- this.applyPosition(true)
- },
- moveSlider: function(sliderIndex, fastSwap, position, offsetPosition, startOffsetPosition, startOffsetPositionChangedCallback) {
- var that = this,
- slider = that.getSlider(sliderIndex),
- anotherSlider = slider.getAnotherSlider(),
- anotherSliderPosition = anotherSlider.getPosition(),
- doSwap;
- if (slider.canSwap())
- if (sliderIndex === START_VALUE_INDEX ? position > anotherSliderPosition : position < anotherSliderPosition) {
- doSwap = fastSwap;
- if (!fastSwap)
- if (Math.abs(offsetPosition) >= Math.abs(startOffsetPosition)) {
- doSwap = true;
- if (offsetPosition * startOffsetPosition < 0) {
- position += 2 * startOffsetPosition;
- startOffsetPositionChangedCallback(-startOffsetPosition)
- }
- else {
- position -= 2 * startOffsetPosition;
- startOffsetPositionChangedCallback(startOffsetPosition)
- }
- }
- if (doSwap) {
- that.swapSliders();
- anotherSlider.applyPosition(true)
- }
- }
- slider.setPosition(position, true);
- slider.applyPosition(true);
- that.applyAreaTrackersPosition();
- that._applySelectedRangePosition(true);
- that.setTrackersCursorStyle('w-resize')
- },
- applySelectedAreaCenterPosition: function(pos) {
- var that = this,
- startSlider = that.getSlider(START_VALUE_INDEX),
- slidersContainerHalfWidth = (that.getSlider(END_VALUE_INDEX).getPosition() - startSlider.getPosition()) / 2,
- selectedRangeInterval = that.getSelectedRangeInterval();
- startSlider.setPosition(pos - slidersContainerHalfWidth, false, selectedRangeInterval);
- that.applyPosition();
- that.processDocking()
- },
- endSelection: function() {
- var startSlider = this.getSlider(START_VALUE_INDEX),
- endSlider = this.getSlider(END_VALUE_INDEX),
- cloudSpacing = startSlider.getCloudBorder() - endSlider.getCloudBorder(),
- overlappedState;
- if (cloudSpacing > 0)
- overlappedState = true;
- else
- overlappedState = false;
- startSlider.setOverlapped(overlappedState);
- endSlider.setOverlapped(overlappedState)
- },
- processManualSelection: function(startPosition, endPosition, eventArgs) {
- var that = this,
- animateSliderIndex,
- movingSliderIndex,
- positionRange = [Math.min(startPosition, endPosition), Math.max(startPosition, endPosition)],
- movingSlider,
- animatedSlider;
- animateSliderIndex = startPosition < endPosition ? START_VALUE_INDEX : END_VALUE_INDEX;
- movingSliderIndex = startPosition < endPosition ? END_VALUE_INDEX : START_VALUE_INDEX;
- movingSlider = that.getSlider(movingSliderIndex);
- animatedSlider = that.getSlider(animateSliderIndex);
- movingSlider.setPosition(positionRange[movingSliderIndex]);
- animatedSlider.setPosition(positionRange[animateSliderIndex]);
- movingSlider.setPosition(positionRange[movingSliderIndex], true);
- movingSlider.startEventHandler(eventArgs);
- animatedSlider.processDocking();
- movingSlider.applyPosition(true)
- },
- applySelectedRange: function(selectedRange) {
- utils.debug.assertParam(selectedRange, 'selectedRange not passed');
- var that = this,
- scaleoptions = that._options.scale,
- inverted = scaleoptions.inverted,
- startSlider = that.getSlider(START_VALUE_INDEX),
- endSlider = that.getSlider(END_VALUE_INDEX),
- startValue = selectedRange.startValue,
- endValue = selectedRange.endValue,
- categoriesInfo,
- setValues = function(startValue, endValue, isInverted) {
- (isInverted ? endSlider : startSlider).setValue(startValue);
- (isInverted ? startSlider : endSlider).setValue(endValue)
- };
- if (scaleoptions.type !== DISCRETE)
- if (!inverted && startValue > endValue || inverted && startValue < endValue)
- setValues(startValue, endValue, true);
- else
- setValues(startValue, endValue);
- else {
- categoriesInfo = utils.getCategoriesInfo(scaleoptions._categoriesInfo.categories, startValue, endValue);
- setValues(categoriesInfo.start, categoriesInfo.end, categoriesInfo.inverted ^ scaleoptions.inverted)
- }
- },
- getSelectedRange: function() {
- return {
- startValue: this.getSlider(START_VALUE_INDEX).getValue(),
- endValue: this.getSlider(END_VALUE_INDEX).getValue()
- }
- },
- swapSliders: function() {
- var that = this;
- that._sliders.reverse();
- that.getSlider(START_VALUE_INDEX).changeLocation();
- that.getSlider(END_VALUE_INDEX).changeLocation()
- },
- applyAreaTrackersPosition: function() {
- var that = this,
- selectedRange = that.getSelectedRange(),
- canvas = that._options.canvas,
- scaleOptions = that._options.scale,
- startSlider = that.getSlider(START_VALUE_INDEX),
- width = that.getSlider(END_VALUE_INDEX).getPosition() - startSlider.getPosition(),
- options = {
- x: startSlider.getPosition(),
- width: width < 0 ? 0 : width,
- y: canvas.top,
- height: canvas.height
- },
- style = {cursor: scaleOptions.endValue - scaleOptions.startValue === selectedRange.endValue - selectedRange.startValue ? 'default' : 'pointer'};
- that._selectedAreaTracker.attr(options).css(style);
- that._areaTracker.attr({
- x: canvas.left,
- width: canvas.width,
- y: canvas.top,
- height: canvas.height
- })
- },
- applyPosition: function(disableAnimation) {
- var that = this;
- that.getSlider(START_VALUE_INDEX).applyPosition(disableAnimation);
- that.getSlider(END_VALUE_INDEX).applyPosition(disableAnimation);
- that.applyAreaTrackersPosition();
- that._applySelectedRangePosition(disableAnimation)
- },
- redraw: function(group) {
- var that = this;
- that.getSlider(START_VALUE_INDEX).redraw(group);
- that.getSlider(END_VALUE_INDEX).redraw(group);
- that._foregroundSliderIndex = END_VALUE_INDEX
- },
- toForeground: function(slider) {
- var that = this,
- sliderIndex = slider.getIndex();
- if (that._foregroundSliderIndex !== sliderIndex) {
- slider.toForeground();
- that._foregroundSliderIndex = sliderIndex
- }
- },
- appendTrackers: function(group) {
- var that = this;
- if (that._areaTracker && that._selectedAreaTracker) {
- that._areaTracker.append(group);
- that._selectedAreaTracker.append(group)
- }
- that.getSlider(START_VALUE_INDEX).appendTrackers(group);
- that.getSlider(END_VALUE_INDEX).appendTrackers(group)
- },
- getSlider: function(sliderIndex) {
- return this._sliders[sliderIndex]
- },
- getAreaTracker: function() {
- return this._areaTracker
- },
- getSelectedAreaTracker: function() {
- return this._selectedAreaTracker
- },
- setTrackersCursorStyle: function(style) {
- var that = this;
- that._selectedAreaTracker.css({cursor: style});
- that._areaTracker.css({cursor: style})
- },
- createShutters: function() {
- var sliders = this._sliders;
- sliders[0].createShutter();
- sliders[1].createShutter()
- },
- removeShutters: function() {
- var sliders = this._sliders;
- sliders[0].removeShutter();
- sliders[1].removeShutter()
- },
- dispose: function() {
- var sliders = this._sliders;
- sliders[0].dispose();
- sliders[1].dispose()
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slidersEventsManager.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- MIN_MANUAL_SELECTING_WIDTH = 10,
- START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1,
- addNamespace = DX.ui.events.addNamespace,
- _SlidersEventManager,
- rangeSelectorUtils = rangeSelector.utils,
- getEventPageX = rangeSelectorUtils.getEventPageX,
- rangeSelectorCount = 0;
- rangeSelector.events = {
- start: "dxpointerdown",
- move: "dxpointermove",
- end: "dxpointerup"
- };
- var isLeftButtonPressed = function(event) {
- var e = event || window.event,
- originalEvent = e.originalEvent,
- touches = e.touches,
- pointerType = originalEvent ? originalEvent.pointerType : false,
- eventTouches = originalEvent ? originalEvent.touches : false,
- isIE8LeftClick = e.which === undefined && e.button === 1,
- isMSPointerLeftClick = originalEvent && pointerType !== undefined && (pointerType === (originalEvent.MSPOINTER_TYPE_TOUCH || 'touch') || pointerType === (originalEvent.MSPOINTER_TYPE_MOUSE || 'mouse') && originalEvent.buttons === 1),
- isLeftClick = isIE8LeftClick || e.which === 1,
- isTouches = touches && touches.length > 0 || eventTouches && eventTouches.length > 0;
- return isLeftClick || isMSPointerLeftClick || isTouches
- };
- var isMultiTouches = function(event) {
- var originalEvent = event.originalEvent,
- touches = event.touches,
- eventTouches = originalEvent ? originalEvent.touches : false;
- return touches && touches.length > 1 || eventTouches && eventTouches.length > 1 || null
- };
- var isTouchEventArgs = function(e) {
- return e && e.type && e.type.indexOf('touch') === 0
- };
- _SlidersEventManager = rangeSelector.SlidersEventsManager = function(renderer, slidersController, processSelectionChanged) {
- var that = this,
- uniqueNS = that._uniqueNS = 'dx-range-selector_' + rangeSelectorCount++,
- rangeSelectorEvents = rangeSelector.events;
- that._renderer = renderer;
- that._slidersController = slidersController;
- that._processSelectionChanged = processSelectionChanged;
- that._enabled = true;
- that._eventsNames = {
- start: addNamespace(rangeSelectorEvents.start, uniqueNS),
- move: addNamespace(rangeSelectorEvents.move, uniqueNS),
- end: addNamespace(rangeSelectorEvents.end, uniqueNS)
- }
- };
- _SlidersEventManager.prototype = {
- constructor: _SlidersEventManager,
- _initializeSliderEvents: function(sliderIndex) {
- var that = this,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- slider = slidersController.getSlider(sliderIndex),
- fastSwap,
- startOffsetPosition,
- splitterMoving,
- sliderEndHandler = function() {
- if (splitterMoving) {
- splitterMoving = false;
- slidersController.endSelection();
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- },
- sliderMoveHandler = function(e) {
- var pageX,
- offsetPosition,
- svgOffsetLeft = that._renderer.getRootOffset().left,
- position,
- sliderIndex = slider.getIndex();
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (!isLeftButtonPressed(e, true) && splitterMoving) {
- splitterMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- else if (splitterMoving) {
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.preventDefault()
- }
- pageX = getEventPageX(e);
- position = pageX - startOffsetPosition - svgOffsetLeft;
- offsetPosition = pageX - slider.getPosition() - svgOffsetLeft;
- slidersController.moveSlider(sliderIndex, fastSwap, position, offsetPosition, startOffsetPosition, function(newStartOffsetPosition) {
- startOffsetPosition = newStartOffsetPosition
- });
- processSelectionChanged(true)
- }
- slidersController.endSelection()
- },
- eventsNames = that._eventsNames;
- slider.startEventHandler = function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || splitterMoving)
- return;
- fastSwap = this === slider.getSliderTracker().element;
- splitterMoving = true;
- isTouchEvent = isTouchEventArgs(e);
- startOffsetPosition = getEventPageX(e) - slider.getPosition() - that._renderer.getRootOffset().left;
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.stopPropagation();
- e.preventDefault()
- }
- };
- slider.on(eventsNames.move, function() {
- slidersController.toForeground(slider)
- });
- slider.on(eventsNames.start, slider.startEventHandler);
- $(document).on(eventsNames.end, sliderEndHandler).on(eventsNames.move, sliderMoveHandler);
- slider.__moveEventHandler = sliderMoveHandler
- },
- _initializeAreaEvents: function() {
- var that = this,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- areaTracker = slidersController.getAreaTracker(),
- unselectedAreaProcessing = false,
- startPageX,
- areaEndHandler = function(e) {
- var pageX;
- if (unselectedAreaProcessing) {
- pageX = getEventPageX(e);
- if (that._options.behavior.moveSelectedRangeByClick && Math.abs(startPageX - pageX) < MIN_MANUAL_SELECTING_WIDTH)
- slidersController.applySelectedAreaCenterPosition(pageX - that._renderer.getRootOffset().left);
- unselectedAreaProcessing = false;
- slidersController.endSelection();
- processSelectionChanged(false)
- }
- },
- areaMoveHandler = function(e) {
- var pageX,
- startPosition,
- endPosition,
- svgOffsetLeft = that._renderer.getRootOffset().left;
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (unselectedAreaProcessing && !isLeftButtonPressed(e)) {
- unselectedAreaProcessing = false;
- processSelectionChanged(false)
- }
- if (unselectedAreaProcessing) {
- pageX = getEventPageX(e);
- if (that._options.behavior.manualRangeSelectionEnabled && Math.abs(startPageX - pageX) >= MIN_MANUAL_SELECTING_WIDTH) {
- startPosition = startPageX - svgOffsetLeft;
- endPosition = pageX - svgOffsetLeft;
- slidersController.processManualSelection(startPosition, endPosition, e);
- unselectedAreaProcessing = false;
- processSelectionChanged(true)
- }
- }
- },
- eventsNames = that._eventsNames;
- areaTracker.on(eventsNames.start, function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || unselectedAreaProcessing)
- return;
- unselectedAreaProcessing = true;
- isTouchEvent = isTouchEventArgs(e);
- startPageX = getEventPageX(e)
- });
- $(document).on(eventsNames.end, areaEndHandler).on(eventsNames.move, areaMoveHandler);
- that.__areaMoveEventHandler = areaMoveHandler
- },
- _initializeSelectedAreaEvents: function() {
- var that = this,
- isTouchEvent,
- slidersController = that._slidersController,
- processSelectionChanged = that._processSelectionChanged,
- selectedAreaTracker = slidersController.getSelectedAreaTracker(),
- selectedAreaMoving = false,
- offsetStartPosition,
- selectedRangeInterval,
- selectedAreaEndHandler = function() {
- if (selectedAreaMoving) {
- selectedAreaMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- },
- selectedAreaMoveHandler = function(e) {
- var positionDelta,
- pageX;
- if (isTouchEvent !== isTouchEventArgs(e))
- return;
- if (selectedAreaMoving && !isLeftButtonPressed(e)) {
- selectedAreaMoving = false;
- slidersController.processDocking();
- processSelectionChanged(false)
- }
- if (selectedAreaMoving) {
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.preventDefault()
- }
- pageX = getEventPageX(e);
- positionDelta = pageX - slidersController.getSlider(START_VALUE_INDEX).getPosition() - offsetStartPosition;
- slidersController.moveSliders(positionDelta, selectedRangeInterval);
- processSelectionChanged(true)
- }
- slidersController.endSelection()
- },
- eventsNames = that._eventsNames;
- selectedAreaTracker.on(eventsNames.start, function(e) {
- if (!that._enabled || !isLeftButtonPressed(e) || selectedAreaMoving)
- return;
- selectedAreaMoving = true;
- isTouchEvent = isTouchEventArgs(e);
- offsetStartPosition = getEventPageX(e) - slidersController.getSlider(START_VALUE_INDEX).getPosition();
- selectedRangeInterval = slidersController.getSelectedRangeInterval();
- if (!isMultiTouches(e)) {
- this.preventedDefault = true;
- e.stopPropagation();
- e.preventDefault()
- }
- });
- $(document).on(eventsNames.end, selectedAreaEndHandler).on(eventsNames.move, selectedAreaMoveHandler);
- that.__selectedAreaMoveEventHandler = selectedAreaMoveHandler
- },
- applyOptions: function(options) {
- this._options = options
- },
- dispose: function() {
- $(document).off('.' + this._uniqueNS)
- },
- initialize: function() {
- var that = this;
- that._initializeSelectedAreaEvents(that);
- that._initializeAreaEvents();
- that._initializeSliderEvents(START_VALUE_INDEX);
- that._initializeSliderEvents(END_VALUE_INDEX)
- },
- setEnabled: function(enabled) {
- this._enabled = enabled
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file slider.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- utils = DX.utils,
- rangeSelectorUtils = rangeSelector.utils,
- _inArray = $.inArray,
- dxSupport = DX.support,
- touchSupport = dxSupport.touchEvents,
- msPointerEnabled = dxSupport.pointer,
- SPLITTER_WIDTH = 8,
- TOUCH_SPLITTER_WIDTH = 20,
- START_VALUE_INDEX = 0,
- END_VALUE_INDEX = 1,
- DISCRETE = 'discrete',
- baseVisualElementMethods = rangeSelector.baseVisualElementMethods;
- function checkItemsSpacing(firstSliderPosition, secondSliderPosition, distance) {
- return Math.abs(secondSliderPosition - firstSliderPosition) < distance
- }
- function getValidCategories(categories, curValue, anotherSliderValue, offset) {
- var curValueindex = _inArray(curValue, categories);
- if (curValueindex === 0 || curValueindex === categories.length - 1)
- return anotherSliderValue;
- return categories[curValueindex - offset]
- }
- function Slider(renderer, index) {
- baseVisualElementMethods.init.apply(this, arguments);
- this._index = index
- }
- Slider.prototype = $.extend({}, baseVisualElementMethods, {
- getText: function() {
- if (this._marker)
- return this._marker.getText()
- },
- getAvailableValues: function() {
- return this._values
- },
- getShutter: function() {
- return this._shutter
- },
- getMarker: function() {
- return this._marker
- },
- constructor: Slider,
- _createSlider: function(group) {
- var that = this,
- sliderHandle,
- sliderGroup,
- sliderHandleOptions = that._options.sliderHandle,
- canvas = that._options.canvas,
- renderer = that._renderer;
- sliderGroup = renderer.g().attr({
- 'class': 'slider',
- translateX: canvas.left,
- translateY: canvas.top
- }).append(group);
- sliderHandle = renderer.path([0, 0, 0, canvas.height], "line").attr({
- "stroke-width": sliderHandleOptions.width,
- stroke: sliderHandleOptions.color,
- "stroke-opacity": sliderHandleOptions.opacity,
- sharp: "h"
- }).append(sliderGroup);
- sliderGroup.setValid = function(correct) {
- sliderHandle.attr({stroke: correct ? that._options.sliderHandle.color : that._options.sliderMarker.invalidRangeColor})
- };
- sliderGroup.updateHeight = function() {
- sliderHandle.attr({points: [0, 0, 0, that._options.canvas.height]})
- };
- sliderGroup.applyOptions = function(options) {
- sliderHandle.attr(options)
- };
- sliderGroup.__line = sliderHandle;
- return sliderGroup
- },
- _createSliderTracker: function(group) {
- var that = this,
- sliderHandleWidth = that._options.sliderHandle.width,
- splitterWidth = SPLITTER_WIDTH < sliderHandleWidth ? sliderHandleWidth : SPLITTER_WIDTH,
- sliderWidth = touchSupport || msPointerEnabled ? TOUCH_SPLITTER_WIDTH : splitterWidth,
- sliderTracker,
- canvas = that._options.canvas,
- renderer = that._renderer,
- sliderTrackerGroup = renderer.g().attr({
- 'class': 'sliderTracker',
- translateX: 0,
- translateY: canvas.top
- }).append(group);
- sliderTracker = renderer.rect(-sliderWidth / 2, 0, sliderWidth, canvas.height).attr(rangeSelectorUtils.trackerSettings).css({cursor: 'w-resize'}).append(sliderTrackerGroup);
- sliderTrackerGroup.updateHeight = function() {
- sliderTracker.attr({height: that._options.canvas.height})
- };
- sliderTrackerGroup.__rect = sliderTracker;
- return sliderTrackerGroup
- },
- _setPosition: function(position, correctByMinMaxRange) {
- var that = this,
- correctedPosition = that._correctPosition(position),
- value = that._options.translator.untranslate(correctedPosition, that._getValueDirection());
- that.setValue(value, correctByMinMaxRange, false);
- that._position = correctedPosition
- },
- _getValueDirection: function() {
- return this._options.scale.type === DISCRETE ? this.getIndex() === START_VALUE_INDEX ? -1 : 1 : 0
- },
- _setPositionForBothSliders: function(startPosition, interval) {
- var that = this,
- anotherSlider = that.getAnotherSlider(),
- startValue,
- endValue,
- endPosition,
- options = that._options,
- scale = options.scale,
- canvas = options.canvas,
- rightBorderCoords = canvas.left + canvas.width,
- translator = options.translator,
- valueDirection = that._getValueDirection(),
- valueDirectionAnotherSlider = anotherSlider._getValueDirection(),
- getNextValue = function(value, isNegative, reverseValueDirection) {
- var curValueDirection = !reverseValueDirection ? valueDirection : valueDirectionAnotherSlider,
- curAnotherValueDirection = reverseValueDirection ? valueDirection : valueDirectionAnotherSlider;
- return translator.untranslate(that._correctBounds(utils.addInterval(translator.translate(value, curValueDirection), interval, isNegative)), curAnotherValueDirection)
- };
- startPosition = that._correctBounds(startPosition);
- startValue = translator.untranslate(startPosition, valueDirection);
- endValue = getNextValue(startValue);
- endPosition = startPosition + interval;
- if (endPosition > rightBorderCoords) {
- endValue = scale.endValue;
- endPosition = rightBorderCoords;
- startValue = getNextValue(endValue, true, true);
- startPosition = that._correctBounds(endPosition - interval)
- }
- else
- endPosition = that._correctBounds(endPosition);
- if (that._values)
- if (!scale.inverted ? startValue < that._values[0] : startValue > that._values[that._values.length - 1]) {
- startValue = that._correctByAvailableValues(startValue, false);
- endValue = getNextValue(startValue)
- }
- else {
- endValue = that._correctByAvailableValues(endValue, false);
- startValue = getNextValue(endValue, true)
- }
- anotherSlider.setValue(endValue, undefined, false);
- that.setValue(startValue, undefined, false);
- that._position = startPosition;
- anotherSlider._position = endPosition
- },
- _correctPosition: function(position) {
- return this._correctBounds(this._correctInversion(position))
- },
- _correctInversion: function(position) {
- var that = this,
- correctedPosition = position,
- anotherSliderPosition = that.getAnotherSlider().getPosition(),
- slidersInverted = that.getIndex() === START_VALUE_INDEX ? position > anotherSliderPosition : position < anotherSliderPosition;
- if (slidersInverted)
- correctedPosition = anotherSliderPosition;
- return correctedPosition
- },
- _correctBounds: function(position) {
- var that = this,
- correctedPosition = position,
- canvas = that._options.canvas;
- if (position < canvas.left)
- correctedPosition = canvas.left;
- if (position > canvas.left + canvas.width)
- correctedPosition = canvas.left + canvas.width;
- return correctedPosition
- },
- _correctValue: function(businessValue, correctByMinMaxRange, skipCorrection) {
- var that = this,
- result = that._correctByAvailableValues(businessValue, skipCorrection);
- if (correctByMinMaxRange)
- result = that._correctByMinMaxRange(result);
- if (that._options.scale.type !== DISCRETE)
- result = that.correctByMinRange(result);
- return result
- },
- _correctByAvailableValues: function(businessValue, skipCorrection) {
- var values = this._values;
- if (!skipCorrection && values)
- return rangeSelectorUtils.findNearValue(values, businessValue);
- return businessValue
- },
- _correctByMinMaxRange: function(businessValue) {
- var that = this,
- result = businessValue,
- scale = that._options.scale,
- values = that._values,
- sliderIndex = that.getIndex(),
- anotherSlider = that.getAnotherSlider(),
- anotherBusinessValue = anotherSlider.getValue(),
- isValid = true,
- minValue,
- maxValue,
- maxRange = scale.maxRange,
- minRange = scale.minRange,
- categoriesInfo;
- if (scale.type === DISCRETE) {
- categoriesInfo = scale._categoriesInfo;
- if (checkItemsSpacing(that.getPosition(), anotherSlider.getPosition(), that._options.translator.getInterval() / 2)) {
- isValid = false;
- result = getValidCategories(categoriesInfo.categories, businessValue, anotherSlider.getValue(), sliderIndex === START_VALUE_INDEX ? 1 : -1)
- }
- }
- else {
- if (!scale.inverted && sliderIndex === START_VALUE_INDEX || scale.inverted && sliderIndex === END_VALUE_INDEX) {
- if (maxRange)
- minValue = that._addInterval(anotherBusinessValue, maxRange, true);
- if (minRange)
- maxValue = that._addInterval(anotherBusinessValue, minRange, true)
- }
- else {
- if (maxRange)
- maxValue = that._addInterval(anotherBusinessValue, maxRange);
- if (minRange)
- minValue = that._addInterval(anotherBusinessValue, minRange)
- }
- if (maxValue !== undefined && result > maxValue) {
- result = values ? rangeSelectorUtils.findLessOrEqualValue(values, maxValue) : maxValue;
- isValid = false
- }
- else if (minValue !== undefined && result < minValue) {
- result = values ? rangeSelectorUtils.findGreaterOrEqualValue(values, minValue) : minValue;
- isValid = false
- }
- }
- that._setValid(isValid);
- return result
- },
- _addInterval: function(value, interval, isNegative) {
- var result,
- type = this._options.scale.type,
- base = type === "logarithmic" && this._options.scale.logarithmBase,
- power;
- if (base) {
- power = utils.addInterval(utils.getLog(value, base), interval, isNegative);
- result = Math.pow(base, power)
- }
- else
- result = utils.addInterval(value, interval, isNegative);
- return result
- },
- correctByMinRange: function(businessValue) {
- var that = this,
- startValue,
- endValue,
- scale = that._options.scale,
- result = businessValue;
- if (scale.minRange)
- if (that.getIndex() === END_VALUE_INDEX) {
- startValue = that._addInterval(scale.startValue, scale.minRange, scale.inverted);
- if (!scale.inverted && result < startValue || scale.inverted && result > startValue)
- result = startValue
- }
- else if (that.getIndex() === START_VALUE_INDEX) {
- endValue = that._addInterval(scale.endValue, scale.minRange, !scale.inverted);
- if (!scale.inverted && result > endValue || scale.inverted && result < endValue)
- result = endValue
- }
- return result
- },
- _applySliderPosition: function(position, disableAnimation) {
- var that = this,
- options = that._options,
- isAnimation = options.behavior.animationEnabled && !disableAnimation,
- slider = that._slider,
- sliderTracker = that._sliderTracker,
- attrs = {
- translateX: position,
- translateY: options.canvas.top
- },
- animationSettings = rangeSelectorUtils.animationSettings;
- that._marker && that._marker.setPosition(position);
- if (isAnimation) {
- slider.animate(attrs, animationSettings);
- sliderTracker.animate(attrs, animationSettings)
- }
- else {
- slider.stopAnimation().attr(attrs);
- sliderTracker.stopAnimation().attr(attrs)
- }
- sliderTracker.updateHeight();
- slider.updateHeight()
- },
- _applyShutterPosition: function(position, disableAnimation) {
- var that = this,
- shutterSettings,
- options = that._options,
- shutter = that._shutter,
- isAnimation = options.behavior.animationEnabled && !disableAnimation,
- sliderIndex = that.getIndex(),
- canvas = options.canvas,
- halfSliderHandleWidth = options.sliderHandle.width / 2,
- width;
- if (!shutter)
- return;
- if (sliderIndex === START_VALUE_INDEX) {
- width = position - canvas.left - Math.floor(halfSliderHandleWidth);
- if (width < 0)
- width = 0;
- shutterSettings = {
- x: canvas.left,
- y: canvas.top,
- width: width,
- height: canvas.height
- }
- }
- else if (sliderIndex === END_VALUE_INDEX)
- shutterSettings = {
- x: position + Math.ceil(halfSliderHandleWidth),
- y: canvas.top,
- width: canvas.left + canvas.width - position,
- height: canvas.height
- };
- if (isAnimation)
- shutter.animate(shutterSettings, rangeSelectorUtils.animationSettings);
- else
- shutter.stopAnimation().attr(shutterSettings)
- },
- _setValid: function(isValid) {
- this._marker && this._marker.setValid(isValid);
- this._slider.setValid(isValid)
- },
- _setText: function(text) {
- this._marker && this._marker.setText(text)
- },
- _update: function() {
- var that = this,
- options = that._options,
- shutterOptions = options.shutter,
- sliderHandleOptions = options.sliderHandle,
- marker = that._marker;
- if (marker) {
- marker.applyOptions(options.sliderMarker);
- marker.setCanvas(that._options.canvas)
- }
- that._shutter && that._shutter.attr({
- fill: shutterOptions.color,
- "fill-opacity": shutterOptions.opacity
- });
- that._slider && that._slider.applyOptions({
- "stroke-width": sliderHandleOptions.width,
- stroke: sliderHandleOptions.color,
- "stroke-opacity": sliderHandleOptions.opacity
- })
- },
- _draw: function(group) {
- var that = this,
- slider,
- marker,
- sliderAreaGroup,
- options = that._options,
- renderer = that._renderer;
- that._container = sliderAreaGroup = renderer.g().attr({'class': 'sliderArea'}).append(group);
- slider = that._createSlider(sliderAreaGroup);
- if (options.sliderMarker.visible) {
- marker = rangeSelector.rangeSelectorFactory.createSliderMarker({
- renderer: renderer,
- isLeftPointer: that.getIndex() === END_VALUE_INDEX,
- sliderMarkerOptions: options.sliderMarker
- });
- marker.setCanvas(options.canvas);
- marker.draw(slider)
- }
- that._slider = slider;
- that._marker = marker;
- that._sliderTracker = that._createSliderTracker(group)
- },
- toForeground: function() {
- this._container.toForeground()
- },
- _applyOptions: function() {
- this._lastPosition = null
- },
- getIndex: function() {
- return this._index
- },
- setAvailableValues: function(values) {
- this._values = values
- },
- setAnotherSlider: function(slider) {
- this._anotherSlider = slider
- },
- getAnotherSlider: function() {
- return this._anotherSlider
- },
- appendTrackers: function(group) {
- this._sliderTracker && this._sliderTracker.append(group)
- },
- getSliderTracker: function() {
- return this._sliderTracker
- },
- changeLocation: function() {
- var that = this;
- that._marker && that._marker.changeLocation();
- that._index = that._index === START_VALUE_INDEX ? END_VALUE_INDEX : START_VALUE_INDEX;
- if (that._options.scale.type === DISCRETE)
- that.setPosition(that._position);
- that._lastPosition = null
- },
- setPosition: function(position, correctByMinMaxRange, selectedRangeInterval) {
- var that = this,
- slider;
- if (selectedRangeInterval !== undefined) {
- slider = that.getIndex() === START_VALUE_INDEX ? that : that.getAnotherSlider();
- slider._setPositionForBothSliders(position, selectedRangeInterval)
- }
- else
- that._setPosition(position, correctByMinMaxRange)
- },
- getPosition: function() {
- return this._position
- },
- setValue: function(value, correctByMinMaxRange, skipCorrection) {
- var that = this,
- options = that._options,
- canvas = options.canvas,
- position,
- text;
- if (value === undefined) {
- that._value = undefined;
- position = that.getIndex() === START_VALUE_INDEX ? canvas.left : canvas.left + canvas.width;
- text = rangeSelector.consts.emptySliderMarkerText
- }
- else {
- that._value = that._correctValue(value, correctByMinMaxRange, utils.isDefined(skipCorrection) ? !!skipCorrection : true);
- position = options.translator.translate(that._value, that._getValueDirection());
- text = rangeSelector.formatValue(that._value, options.sliderMarker)
- }
- that._setText(text);
- that._valuePosition = that._position = position
- },
- setOverlapped: function(isOverlapped) {
- this._marker && this._marker.setOverlapped(isOverlapped)
- },
- getValue: function() {
- return this._value
- },
- canSwap: function() {
- var that = this,
- scale = that._options.scale,
- startValue,
- endValue,
- anotherSliderValue;
- if (that._options.behavior.allowSlidersSwap) {
- if (scale.minRange) {
- anotherSliderValue = that.getAnotherSlider().getValue();
- if (that.getIndex() === START_VALUE_INDEX) {
- endValue = that._addInterval(scale.endValue, scale.minRange, !scale.inverted);
- if (!scale.inverted && anotherSliderValue > endValue || scale.inverted && anotherSliderValue < endValue)
- return false
- }
- else {
- startValue = that._addInterval(scale.startValue, scale.minRange, scale.inverted);
- if (!scale.inverted && anotherSliderValue < startValue || scale.inverted && anotherSliderValue > startValue)
- return false
- }
- }
- return true
- }
- return false
- },
- processDocking: function() {
- var that = this;
- that._position = that._valuePosition;
- that.applyPosition(false);
- that._setValid(true)
- },
- applyPosition: function(disableAnimation) {
- var that = this,
- position = that.getPosition();
- if (that._lastPosition !== position) {
- that._applySliderPosition(position, disableAnimation);
- that._applyShutterPosition(position, disableAnimation);
- that._lastPosition = position
- }
- },
- on: function(event, handler) {
- var that = this,
- marker = that._marker,
- tracker = marker && marker.getTracker(),
- sliderTracker = that._sliderTracker;
- sliderTracker && sliderTracker.on(event, handler);
- tracker && tracker.on(event, handler)
- },
- createShutter: function() {
- var that = this,
- index = that.getIndex(),
- canvas = that._options.canvas,
- renderer = that._renderer,
- shutter = that._shutter;
- if (!shutter) {
- if (index === START_VALUE_INDEX)
- shutter = renderer.rect(canvas.left, canvas.top, 0, canvas.height);
- else if (index === END_VALUE_INDEX)
- shutter = renderer.rect(canvas.left, canvas.top, canvas.width, canvas.height);
- that._shutter = shutter
- }
- shutter.append(that._container)
- },
- removeShutter: function() {
- var shutter = this._shutter;
- shutter && shutter.remove()
- },
- getCloudBorder: function() {
- return this._marker ? this._marker.getBorderPosition() : 0
- },
- dispose: function() {
- var marker = this._marker;
- marker && marker.dispose()
- }
- });
- rangeSelector.Slider = Slider
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file sliderMarker.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- rangeSelector = viz.rangeSelector,
- SliderMarker,
- SLIDER_MARKER_UPDATE_DELAY = 75,
- POINTER_SIZE = rangeSelector.consts.pointerSize;
- var getRectSize = function(that, textSize) {
- var options = that._options;
- return {
- width: Math.round(2 * options.paddingLeftRight + textSize.width),
- height: Math.round(2 * options.paddingTopBottom + textSize.height)
- }
- };
- var getAreaPointsInfo = function(that, textSize) {
- var rectSize = getRectSize(that, textSize),
- rectWidth = rectSize.width,
- rectHeight = rectSize.height,
- rectLeftBorder = -rectWidth,
- rectRightBorder = 0,
- pointerRightPoint = POINTER_SIZE,
- pointerCenterPoint = 0,
- pointerLeftPoint = -POINTER_SIZE,
- position = that._position,
- canvas = that._canvas,
- isLeft = that._isLeftPointer,
- correctCloudBorders = function() {
- rectLeftBorder++;
- rectRightBorder++;
- pointerRightPoint++;
- pointerCenterPoint++;
- pointerLeftPoint++
- },
- checkPointerBorders = function() {
- if (pointerRightPoint > rectRightBorder)
- pointerRightPoint = rectRightBorder;
- else if (pointerLeftPoint < rectLeftBorder)
- pointerLeftPoint = rectLeftBorder;
- isLeft && correctCloudBorders()
- },
- borderPosition = position;
- if (isLeft)
- if (position > canvas.left + canvas.width - rectWidth) {
- rectRightBorder = -position + (canvas.left + canvas.width);
- rectLeftBorder = rectRightBorder - rectWidth;
- checkPointerBorders();
- borderPosition += rectLeftBorder
- }
- else {
- rectLeftBorder = pointerLeftPoint = 0;
- rectRightBorder = rectWidth
- }
- else if (position - canvas.left < rectWidth) {
- rectLeftBorder = -(position - canvas.left);
- rectRightBorder = rectLeftBorder + rectWidth;
- checkPointerBorders();
- borderPosition += rectRightBorder
- }
- else {
- pointerRightPoint = 0;
- correctCloudBorders()
- }
- that._borderPosition = borderPosition;
- return {
- offset: rectLeftBorder,
- isCutted: (!isLeft || pointerCenterPoint !== pointerLeftPoint) && (isLeft || pointerCenterPoint !== pointerRightPoint),
- points: [rectLeftBorder, 0, rectRightBorder, 0, rectRightBorder, rectHeight, pointerRightPoint, rectHeight, pointerCenterPoint, rectHeight + POINTER_SIZE, pointerLeftPoint, rectHeight, rectLeftBorder, rectHeight]
- }
- };
- var getTextSize = function(that) {
- var textSize = that._label.getBBox();
- if (!that._textHeight && isFinite(textSize.height))
- that._textHeight = textSize.height;
- return {
- width: textSize.width,
- height: that._textHeight,
- y: textSize.y
- }
- };
- SliderMarker = rangeSelector.SliderMarker = function(options) {
- var that = this;
- that._renderer = options.renderer;
- that._text = options.text;
- that._isLeftPointer = options.isLeftPointer;
- that._options = $.extend(true, {}, options.sliderMarkerOptions);
- that._options.textFontStyles = core.utils.patchFontOptions(that._options.font);
- that._isValid = true;
- that._isOverlapped = false
- };
- SliderMarker.prototype = {
- constructor: SliderMarker,
- draw: function(group) {
- var that = this,
- options = that._options,
- sliderMarkerGroup = that._sliderMarkerGroup = that._renderer.g().attr({'class': 'sliderMarker'}).append(group);
- that._area = that._renderer.path([], "area").attr({fill: options.color}).append(sliderMarkerGroup);
- that._label = that._renderer.text(that._text, 0, 0).attr({align: 'left'}).css(options.textFontStyles).append(sliderMarkerGroup);
- that._tracker = that._renderer.rect(0, 0, 2 * options.paddingLeftRight, 2 * options.paddingTopBottom + POINTER_SIZE).attr(rangeSelector.utils.trackerSettings).css({cursor: 'pointer'}).append(sliderMarkerGroup);
- that._border = that._renderer.rect(0, 0, 1, 0).attr({fill: options.borderColor});
- that._drawn = true;
- that._update()
- },
- _update: function() {
- var that = this,
- textSize,
- options = that._options,
- currentTextSize,
- rectSize;
- clearTimeout(that._timeout);
- if (!that._drawn)
- return;
- that._label.attr({text: that._text || ""});
- currentTextSize = getTextSize(that);
- rectSize = getRectSize(that, currentTextSize);
- textSize = that._textSize || currentTextSize;
- textSize = that._textSize = currentTextSize.width > textSize.width || currentTextSize.height > textSize.height ? currentTextSize : textSize;
- that._timeout = setTimeout(function() {
- updateSliderMarker(currentTextSize, rectSize);
- that._textSize = currentTextSize
- }, SLIDER_MARKER_UPDATE_DELAY);
- function updateSliderMarker(size, rectSize) {
- var points,
- pointsData,
- offset;
- rectSize = rectSize || getRectSize(that, size);
- that._sliderMarkerGroup.attr({translateY: -(rectSize.height + POINTER_SIZE)});
- pointsData = getAreaPointsInfo(that, size);
- points = pointsData.points;
- offset = pointsData.offset;
- that._area.attr({points: points});
- that._border.attr({
- x: that._isLeftPointer ? points[0] - 1 : points[2],
- height: pointsData.isCutted ? rectSize.height : rectSize.height + POINTER_SIZE
- });
- that._tracker.attr({
- translateX: offset,
- width: rectSize.width,
- height: rectSize.height + POINTER_SIZE
- });
- that._label.attr({
- translateX: options.paddingLeftRight + offset,
- translateY: rectSize.height / 2 - (size.y + size.height / 2)
- })
- }
- updateSliderMarker(textSize)
- },
- setText: function(value) {
- var that = this;
- if (that._text !== value)
- that._text = value
- },
- setPosition: function(position) {
- this._position = position;
- this._update()
- },
- changeLocation: function() {
- var that = this;
- that._isLeftPointer = !that._isLeftPointer;
- that._update()
- },
- applyOptions: function(options) {
- var that = this,
- fontSyles,
- opt = that._options = $.extend(true, {}, options);
- fontSyles = opt.textFontStyles = core.utils.patchFontOptions(opt.font);
- that._textHeight = null;
- that._area.attr({fill: options.color});
- that._border.attr({fill: options.borderColor});
- that._label.css(fontSyles);
- that._update()
- },
- getTracker: function() {
- return this._tracker
- },
- setValid: function(isValid) {
- var that = this,
- options = that._options;
- if (that._isValid !== isValid) {
- that._isValid = isValid;
- that._area.attr({fill: isValid ? options.color : options.invalidRangeColor})
- }
- },
- dispose: function() {
- clearTimeout(this._timeout)
- },
- setOverlapped: function(isOverlapped) {
- var border = this._border,
- currentOverlappedState = this._isOverlapped;
- if (currentOverlappedState === isOverlapped)
- return;
- if (isOverlapped)
- border.append(this._sliderMarkerGroup);
- else
- this._isOverlapped && border.remove();
- this._isOverlapped = isOverlapped
- },
- getBorderPosition: function() {
- return this._borderPosition
- },
- setCanvas: function(canvas) {
- this._canvas = canvas
- }
- };
- SliderMarker.prototype.updateDelay = SLIDER_MARKER_UPDATE_DELAY;
- SliderMarker.prototype.getText = function() {
- return this._text
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file rangeView.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- RangeView,
- baseVisualElementMethods = rangeSelector.baseVisualElementMethods;
- RangeView = function() {
- baseVisualElementMethods.init.apply(this, arguments)
- };
- RangeView.prototype = $.extend({}, baseVisualElementMethods, {
- constructor: RangeView,
- _draw: function(group) {
- var that = this,
- series,
- i,
- options = that._options,
- isCompactMode = options.isCompactMode,
- canvas = options.canvas,
- isEmpty = options.isEmpty,
- renderer = that._renderer,
- seriesDataSource = options.seriesDataSource,
- showChart = seriesDataSource && seriesDataSource.isShowChart() && !isEmpty,
- background = options.background,
- backgroundColor = showChart ? seriesDataSource.getBackgroundColor() : background.color,
- backgroundImage = background.image,
- backgroundIsVisible = background.visible;
- if (isCompactMode)
- return;
- if (backgroundIsVisible && !isEmpty && backgroundColor)
- renderer.rect(canvas.left, canvas.top, canvas.width + 1, canvas.height).attr({
- fill: backgroundColor,
- 'class': 'dx-range-selector-background'
- }).append(group);
- if (backgroundIsVisible && backgroundImage && backgroundImage.url)
- renderer.image(canvas.left, canvas.top, canvas.width + 1, canvas.height, backgroundImage.url, backgroundImage.location).append(group);
- if (showChart) {
- series = seriesDataSource.getSeries();
- seriesDataSource.adjustSeriesDimensions(options.translators, options.chart.useAggregation);
- for (i = 0; i < series.length; i++) {
- series[i]._extGroups.seriesGroup = group;
- series[i]._extGroups.labelsGroup = group;
- series[i].draw(options.translators, options.behavior && options.behavior.animationEnabled && renderer.animationEnabled())
- }
- }
- }
- });
- rangeSelector.RangeView = RangeView
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file seriesDataSource.js */
- (function($, DX, undefined) {
- var rangeSelector = DX.viz.rangeSelector,
- charts = DX.viz.charts,
- core = DX.viz.core,
- coreFactory = core.CoreFactory,
- utils = DX.utils,
- _SeriesDatasource;
- var createThemeManager = function(chartOptions) {
- return charts.factory.createThemeManager(chartOptions, 'rangeSelector.chart')
- };
- var isArrayOfSimpleTypes = function(data) {
- return $.isArray(data) && data.length > 0 && (utils.isNumber(data[0]) || utils.isDate(data[0]))
- };
- var convertToArrayOfObjects = function(data) {
- return $.map(data, function(item, i) {
- return {
- arg: item,
- val: i
- }
- })
- };
- var processSeriesFamilies = function(series, equalBarWidth, minBubbleSize, maxBubbleSize) {
- var families = [],
- types = [];
- $.each(series, function(i, item) {
- if ($.inArray(item.type, types) === -1)
- types.push(item.type)
- });
- $.each(types, function(_, type) {
- var family = new coreFactory.createSeriesFamily({
- type: type,
- equalBarWidth: equalBarWidth,
- minBubbleSize: minBubbleSize,
- maxBubbleSize: maxBubbleSize
- });
- family.add(series);
- family.adjustSeriesValues();
- families.push(family)
- });
- return families
- };
- var isStickType = function(type) {
- var nonStickTypes = ["bar", "candlestick", "stock", "bubble"],
- stickType = true;
- type = type.toLowerCase();
- $.each(nonStickTypes, function(_, item) {
- if (type.indexOf(item) !== -1) {
- stickType = false;
- return false
- }
- });
- return stickType
- };
- function setTemplateFields(data, templateData, series) {
- $.each(data, function(_, data) {
- $.each(series.getTeamplatedFields(), function(_, field) {
- data[field.teamplateField] = data[field.originalField]
- });
- templateData.push(data)
- });
- series.updateTeamplateFieldNames()
- }
- _SeriesDatasource = rangeSelector.SeriesDataSource = function(options) {
- var that = this,
- templatedSeries,
- seriesTemplate,
- themeManager = that._themeManager = createThemeManager(options.chart),
- topIndent,
- bottomIndent;
- themeManager._fontFields = ["commonSeriesSettings.label.font"];
- themeManager.setTheme(options.chart.theme);
- topIndent = themeManager.getOptions('topIndent');
- bottomIndent = themeManager.getOptions('bottomIndent');
- that._indent = {
- top: topIndent >= 0 && topIndent < 1 ? topIndent : 0,
- bottom: bottomIndent >= 0 && bottomIndent < 1 ? bottomIndent : 0
- };
- that._valueAxis = themeManager.getOptions('valueAxisRangeSelector') || {};
- that._hideChart = false;
- seriesTemplate = themeManager.getOptions('seriesTemplate');
- if (options.dataSource && seriesTemplate)
- templatedSeries = utils.processSeriesTemplate(seriesTemplate, options.dataSource);
- that._series = that._calculateSeries(options, templatedSeries);
- that._seriesFamilies = processSeriesFamilies(that._series, themeManager.getOptions('equalBarWidth'), themeManager.getOptions('minBubbleSize'), themeManager.getOptions('maxBubbleSize'))
- };
- _SeriesDatasource.prototype = {
- constructor: _SeriesDatasource,
- _calculateSeries: function(options, templatedSeries) {
- var that = this,
- series = [],
- particularSeriesOptions,
- seriesTheme,
- data,
- groupSeries,
- parsedData,
- chartThemeManager = that._themeManager,
- hasSeriesTemplate = !!chartThemeManager.getOptions('seriesTemplate'),
- allSeriesOptions = hasSeriesTemplate ? templatedSeries : options.chart.series,
- seriesValueType = options.chart.valueAxis && options.chart.valueAxis.valueType,
- dataSourceField,
- i,
- newSeries,
- particularSeries;
- that.teamplateData = [];
- if (options.dataSource && !allSeriesOptions) {
- if (isArrayOfSimpleTypes(options.dataSource))
- options.dataSource = convertToArrayOfObjects(options.dataSource);
- dataSourceField = options.dataSourceField || 'arg';
- allSeriesOptions = {
- argumentField: dataSourceField,
- valueField: dataSourceField
- };
- that._hideChart = true
- }
- allSeriesOptions = $.isArray(allSeriesOptions) ? allSeriesOptions : allSeriesOptions ? [allSeriesOptions] : [];
- that._backgroundColor = options.backgroundColor;
- for (i = 0; i < allSeriesOptions.length; i++) {
- particularSeriesOptions = $.extend(true, {incidentOccured: options.incidentOccured}, allSeriesOptions[i]);
- particularSeriesOptions.rotated = false;
- data = particularSeriesOptions.data || options.dataSource;
- seriesTheme = chartThemeManager.getOptions("series", particularSeriesOptions);
- seriesTheme.argumentField = seriesTheme.argumentField || options.dataSourceField;
- if (data && data.length > 0) {
- newSeries = coreFactory.createSeries({renderer: options.renderer}, seriesTheme);
- series.push(newSeries)
- }
- if (hasSeriesTemplate)
- setTemplateFields(data, that.teamplateData, newSeries)
- }
- data = hasSeriesTemplate ? that.teamplateData : data;
- groupSeries = [series];
- groupSeries.argumentOptions = {
- categories: options.categories,
- argumentType: options.valueType,
- type: options.axisType
- };
- groupSeries[0].valueOptions = {valueType: dataSourceField ? options.valueType : seriesValueType};
- that._dataValidator = core.CoreFactory.createDataValidator(data, groupSeries, options.incidentOccured, chartThemeManager.getOptions("dataPrepareSettings"));
- parsedData = that._dataValidator.validate();
- for (i = 0; i < series.length; i++) {
- particularSeries = series[i];
- particularSeries.updateData(parsedData)
- }
- return series
- },
- adjustSeriesDimensions: function(translators, useAggregation) {
- var that = this;
- if (useAggregation)
- $.each(that._series || [], function(_, s) {
- s.resamplePoints(translators.x)
- });
- $.each(that._seriesFamilies, function(_, family) {
- family.adjustSeriesDimensions({
- arg: translators.x,
- val: translators.y
- })
- })
- },
- getBoundRange: function() {
- var that = this,
- rangeData,
- valueAxisMin = that._valueAxis.min,
- valueAxisMax = that._valueAxis.max,
- valRange = new core.Range({
- isValueRange: true,
- min: valueAxisMin,
- minVisible: valueAxisMin,
- max: valueAxisMax,
- maxVisible: valueAxisMax,
- axisType: that._valueAxis.type,
- base: that._valueAxis.logarithmBase
- }),
- argRange = new core.Range({}),
- rangeYSize,
- rangeVisibleSizeY,
- minIndent,
- maxIndent;
- $.each(that._series, function(_, series) {
- rangeData = series.getRangeData();
- valRange.addRange(rangeData.val);
- argRange.addRange(rangeData.arg);
- if (!isStickType(series.type))
- argRange.addRange({stick: false})
- });
- if (valRange.isDefined() && argRange.isDefined()) {
- minIndent = that._valueAxis.inverted ? that._indent.top : that._indent.bottom;
- maxIndent = that._valueAxis.inverted ? that._indent.bottom : that._indent.top;
- rangeYSize = valRange.max - valRange.min;
- rangeVisibleSizeY = ($.isNumeric(valRange.maxVisible) ? valRange.maxVisible : valRange.max) - ($.isNumeric(valRange.minVisible) ? valRange.minVisible : valRange.min);
- if (utils.isDate(valRange.min))
- valRange.min = new Date(valRange.min.valueOf() - rangeYSize * minIndent);
- else
- valRange.min -= rangeYSize * minIndent;
- if (utils.isDate(valRange.max))
- valRange.max = new Date(valRange.max.valueOf() + rangeYSize * maxIndent);
- else
- valRange.max += rangeYSize * maxIndent;
- if ($.isNumeric(rangeVisibleSizeY)) {
- valRange.maxVisible = valRange.maxVisible ? valRange.maxVisible + rangeVisibleSizeY * maxIndent : undefined;
- valRange.minVisible = valRange.minVisible ? valRange.minVisible - rangeVisibleSizeY * minIndent : undefined
- }
- valRange.invert = that._valueAxis.inverted
- }
- return {
- arg: argRange,
- val: valRange
- }
- },
- getSeries: function() {
- var that = this;
- return that._series
- },
- getBackgroundColor: function() {
- return this._backgroundColor
- },
- isEmpty: function() {
- var that = this;
- return that.getSeries().length === 0
- },
- isShowChart: function() {
- var that = this;
- return !that.isEmpty() && !that._hideChart
- },
- getCalculatedValueType: function() {
- var that = this,
- result;
- if (that._series.length)
- result = that._series[0].argumentType;
- return result
- },
- getThemeManager: function() {
- return this._themeManager
- }
- }
- })(jQuery, DevExpress);
- /*! Module viz-rangeselector, file themeManager.js */
- (function($, DX, undefined) {
- DX.viz.rangeSelector.ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: 'rangeSelector',
- _fontFields: ['scale.label.font', 'sliderMarker.font', 'loadingIndicator.font']
- })
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_RANGESELECTOR = true
- }
- if (!DevExpress.MOD_VIZ_VECTORMAP) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-vectormap, file map.js */
- (function(DX, $, undefined) {
- DX.viz.map = {};
- var _parseScalar = DX.viz.core.utils.parseScalar,
- DEFAULT_WIDTH = 800,
- DEFAULT_HEIGHT = 400,
- TOOLTIP_OFFSET = 12,
- _extend = $.extend,
- nextDataKey = 1;
- function generateDataKey() {
- return "vectormap-data-" + nextDataKey++
- }
- var Map = DX.viz.core.BaseWidget.inherit({
- _eventsMap: _extend({}, DX.viz.core.BaseWidget.prototype._eventsMap, {
- onClick: {
- name: "click",
- deprecated: "click",
- deprecatedContext: function(arg) {
- return arg.component
- },
- deprecatedArgs: function(arg) {
- return [arg.jQueryEvent]
- }
- },
- click: {newName: "onClick"},
- onCenterChanged: {
- name: "centerChanged",
- deprecated: "centerChanged",
- deprecatedContext: function(arg) {
- return arg.component
- },
- deprecatedArgs: function(arg) {
- return [arg.center]
- }
- },
- centerChanged: {newName: "onCenterChanged"},
- onZoomFactorChanged: {
- name: "zoomFactorChanged",
- deprecated: "zoomFactorChanged",
- deprecatedContext: function(arg) {
- return arg.component
- },
- deprecatedArgs: function(arg) {
- return [arg.zoomFactor]
- }
- },
- zoomFactorChanged: {newName: "onZoomFactorChanged"},
- onAreaClick: {
- name: "areaClick",
- deprecated: "areaSettings.click",
- deprecatedContext: function(arg) {
- return arg.target
- },
- deprecatedArgs: function(arg) {
- return [arg.target, arg.jQueryEvent]
- }
- },
- onAreaHoverChanged: {name: "areaHoverChanged"},
- onAreaSelectionChanged: {
- name: "areaSelectionChanged",
- deprecated: "areaSettings.selectionChanged",
- deprecatedContext: function(arg) {
- return arg.target
- },
- deprecatedArgs: function(arg) {
- return [arg.target]
- }
- },
- onMarkerClick: {
- name: "markerClick",
- deprecated: "markerSettings.click",
- deprecatedContext: function(arg) {
- return arg.target
- },
- deprecatedArgs: function(arg) {
- return [arg.target, arg.jQueryEvent]
- }
- },
- onMarkerHoverChanged: {name: "markerHoverChanged"},
- onMarkerSelectionChanged: {
- name: "markerSelectionChanged",
- deprecated: "markerSettings.selectionChanged",
- deprecatedContext: function(arg) {
- return arg.target
- },
- deprecatedArgs: function(arg) {
- return [arg.target]
- }
- }
- }),
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {
- click: {
- since: "14.2",
- message: 'Use the "onClick" option instead'
- },
- centerChanged: {
- since: "14.2",
- message: 'Use the "onCenterChanged" option instead'
- },
- zoomFactorChanged: {
- since: "14.2",
- message: 'Use the "onZoomFactorChanged" option instead'
- },
- "areaSettings.click": {
- since: "14.2",
- message: 'Use the "onAreaClick" option instead'
- },
- "areaSettings.selectionChanged": {
- since: "14.2",
- message: 'Use the "onAreaSelectionChanged" option instead'
- },
- "markerSettings.click": {
- since: "14.2",
- message: 'Use the "onMarkerClick" option instead'
- },
- "markerSettings.selectionChanged": {
- since: "14.2",
- message: 'Use the "onMarkerSelectionChanged" option instead'
- },
- "markerSettings.font": {
- since: "14.2",
- message: 'Use the "label.font" option instead'
- }
- })
- },
- _rootClassPrefix: "dxm",
- _rootClass: "dxm-vector-map",
- _createThemeManager: function() {
- return this._factory.createThemeManager()
- },
- _initBackground: function(dataKey) {
- this._background = this._renderer.rect(0, 0, 0, 0).attr({"class": "dxm-background"}).data(dataKey, {type: "background"})
- },
- _initAreasManager: function(dataKey, notifyDirty, notifyReady) {
- var that = this;
- that._areasManager = that._factory.createAreasManager({
- container: that._root,
- renderer: that._renderer,
- projection: that._projection,
- themeManager: that._themeManager,
- tracker: that._tracker,
- dataKey: dataKey,
- eventTrigger: that._eventTrigger,
- dataExchanger: that._dataExchanger,
- notifyDirty: notifyDirty,
- notifyReady: notifyReady
- })
- },
- _initMarkersManager: function(dataKey, notifyDirty, notifyReady) {
- var that = this;
- that._markersManager = that._factory.createMarkersManager({
- container: that._root,
- renderer: that._renderer,
- projection: that._projection,
- themeManager: that._themeManager,
- tracker: that._tracker,
- eventTrigger: that._eventTrigger,
- dataExchanger: that._dataExchanger,
- dataKey: dataKey,
- notifyDirty: notifyDirty,
- notifyReady: notifyReady
- })
- },
- _initLegendsControl: function() {
- var that = this;
- that._legendsControl = that._factory.createLegendsControl({
- container: that._root,
- renderer: that._renderer,
- layoutControl: that._layoutControl,
- dataExchanger: that._dataExchanger
- })
- },
- _initControlBar: function(dataKey) {
- var that = this;
- that._controlBar = that._factory.createControlBar({
- container: that._root,
- renderer: that._renderer,
- layoutControl: that._layoutControl,
- projection: that._projection,
- dataKey: dataKey
- })
- },
- _initElements: function() {
- var that = this,
- dataKey = generateDataKey(),
- notifyCounter = 0;
- that._dataExchanger = new DataExchanger;
- that._initCenterHandler();
- that._projection = that._factory.createProjection();
- that._tracker = that._factory.createTracker({
- root: that._root,
- projection: that._projection,
- dataKey: dataKey
- });
- that._layoutControl = that._factory.createLayoutControl();
- that._initBackground(dataKey);
- that._initAreasManager(dataKey, notifyDirty, notifyReady);
- that._initMarkersManager(dataKey, notifyDirty, notifyReady);
- that._initLegendsControl();
- that._initControlBar(dataKey);
- function notifyDirty() {
- that._resetIsReady();
- ++notifyCounter
- }
- function notifyReady() {
- if (--notifyCounter === 0) {
- that._drawn();
- that.hideLoadingIndicator()
- }
- }
- },
- _initCore: function() {
- var that = this;
- that._root = that._renderer.root;
- that._root.attr({
- align: 'center',
- cursor: 'default'
- });
- that._initElements();
- that._projection.setBounds(that.option("bounds")).setMaxZoom(that.option("maxZoomFactor")).setZoom(that.option("zoomFactor"), true).setCenter(that.option("center"), true);
- that._setTrackerCallbacks();
- that._setControlBarCallbacks();
- that._setProjectionCallbacks()
- },
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._areasManager.setData(that.option("mapData"));
- that._markersManager.setData(that.option("markers"))
- },
- _disposeCore: function() {
- var that = this;
- that._resetProjectionCallbacks();
- that._resetTrackerCallbacks();
- that._resetControlBarCallbacks();
- that._tracker.dispose();
- that._legendsControl.dispose();
- that._areasManager.dispose();
- that._markersManager.dispose();
- that._controlBar.dispose();
- that._layoutControl.dispose();
- that._disposeCenterHandler();
- that._dataExchanger.dispose();
- that._projection.dispose();
- that._dataExchanger = that._projection = that._tracker = that._layoutControl = that._root = that._background = that._areasManager = that._markersManager = that._controlBar = that._legendsControl = null
- },
- _initCenterHandler: function() {
- var that = this,
- xdrag,
- ydrag,
- isCursorChanged = false;
- that._centerHandler = {
- processStart: function(arg) {
- if (that._centeringEnabled) {
- xdrag = arg.x;
- ydrag = arg.y;
- that._noCenterChanged = true
- }
- },
- processMove: function(arg) {
- if (that._centeringEnabled) {
- if (!isCursorChanged) {
- that._root.attr({cursor: "move"});
- isCursorChanged = true
- }
- that._projection.moveCenter(xdrag - arg.x, ydrag - arg.y);
- xdrag = arg.x;
- ydrag = arg.y
- }
- },
- processEnd: function() {
- if (that._centeringEnabled) {
- that._root.attr({cursor: "default"});
- that._noCenterChanged = null;
- isCursorChanged && that._raiseCenterChanged();
- isCursorChanged = false
- }
- }
- }
- },
- _disposeCenterHandler: function() {
- this._centerHandler = null
- },
- _setProjectionCallbacks: function() {
- var that = this;
- that._projection.on({
- center: function() {
- that._raiseCenterChanged()
- },
- zoom: function() {
- that._raiseZoomFactorChanged()
- }
- });
- that._resetProjectionCallbacks = function() {
- that._resetProjectionCallbacks = that = null
- }
- },
- _setTrackerCallbacks: function() {
- var that = this,
- centerHandler = that._centerHandler,
- renderer = that._renderer,
- managers = {
- area: that._areasManager,
- marker: that._markersManager
- },
- controlBar = that._controlBar,
- tooltip = that._tooltip,
- isControlDrag = false;
- that._tracker.setCallbacks({
- click: function(arg) {
- var offset = renderer.getRootOffset(),
- manager;
- arg.$event.x = arg.x - offset.left;
- arg.$event.y = arg.y - offset.top;
- manager = managers[arg.data.type];
- if (manager)
- manager.raiseClick(arg.data.index, arg.$event);
- if (manager || arg.data.type === "background")
- that._eventTrigger("click", {jQueryEvent: arg.$event})
- },
- start: function(arg) {
- isControlDrag = arg.data.type === "control-bar";
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processStart(arg)
- }
- else
- centerHandler.processStart(arg)
- },
- move: function(arg) {
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processMove(arg)
- }
- else
- centerHandler.processMove(arg)
- },
- end: function(arg) {
- if (isControlDrag) {
- arg.data = arg.data.index;
- controlBar.processEnd(arg);
- isControlDrag = false
- }
- else
- centerHandler.processEnd()
- },
- zoom: function(arg) {
- controlBar.processZoom(arg)
- },
- "hover-on": function(arg) {
- var manager = managers[arg.data.type];
- if (manager)
- manager.hoverItem(arg.data.index, true)
- },
- "hover-off": function(arg) {
- var manager = managers[arg.data.type];
- if (manager)
- manager.hoverItem(arg.data.index, false)
- },
- "focus-on": function(arg, done) {
- var result = false,
- proxy;
- if (tooltip.isEnabled()) {
- proxy = managers[arg.data.type] ? managers[arg.data.type].getProxyItem(arg.data.index) : null;
- if (proxy && tooltip.show(proxy, {
- x: 0,
- y: 0,
- offset: 0
- }, {target: proxy})) {
- tooltip.move(arg.x, arg.y, TOOLTIP_OFFSET);
- result = true
- }
- }
- done(result)
- },
- "focus-move": function(arg) {
- tooltip.move(arg.x, arg.y, TOOLTIP_OFFSET)
- },
- "focus-off": function() {
- tooltip.hide()
- }
- });
- that._resetTrackerCallbacks = function() {
- that._resetTrackerCallbacks = that = centerHandler = renderer = managers = controlBar = tooltip = null
- }
- },
- _setControlBarCallbacks: function() {
- var that = this,
- projection = that._projection,
- isZoomChanged;
- that._projection.on({zoom: function() {
- isZoomChanged = true
- }});
- that._controlBar.setCallbacks({
- reset: function(isCenter, isZoom) {
- if (isCenter)
- projection.setCenter(null);
- if (isZoom)
- projection.setZoom(null)
- },
- beginMove: function() {
- that._noCenterChanged = true
- },
- endMove: function() {
- that._noCenterChanged = null;
- that._raiseCenterChanged()
- },
- move: function(dx, dy) {
- projection.moveCenter(dx, dy)
- },
- zoom: function(zoom, center) {
- var coords,
- screenPosition;
- if (center) {
- screenPosition = that._renderer.getRootOffset();
- screenPosition = [center[0] - screenPosition.left, center[1] - screenPosition.top];
- coords = projection.fromScreenPoint(screenPosition[0], screenPosition[1])
- }
- isZoomChanged = false;
- projection.setScaledZoom(zoom);
- if (isZoomChanged && center)
- projection.setCenterByPoint(coords, screenPosition)
- }
- });
- that._resetControlBarCallbacks = function() {
- that._resetControlBarCallbacks = that = projection = null
- }
- },
- _setupInteraction: function() {
- var that = this;
- that._centerHandler.processEnd();
- that._centeringEnabled = !!_parseScalar(this._getOption("panningEnabled", true), true);
- that._zoomingEnabled = !!_parseScalar(this._getOption("zoomingEnabled", true), true);
- that._controlBar.setInteraction({
- centeringEnabled: that._centeringEnabled,
- zoomingEnabled: that._zoomingEnabled
- })
- },
- _getDefaultSize: function() {
- return {
- width: DEFAULT_WIDTH,
- height: DEFAULT_HEIGHT
- }
- },
- _applySize: function() {
- var that = this,
- width = that._canvas.width,
- height = that._canvas.height;
- that._projection.setSize(width, height);
- that._layoutControl.setSize(width, height);
- that._background.attr({
- x: 0,
- y: 0,
- width: width,
- height: height
- })
- },
- _resize: $.noop,
- _clean: function() {
- var that = this;
- that._tracker.reset();
- that._layoutControl.stop();
- that._background.remove();
- that._areasManager.clean();
- that._markersManager.clean();
- that._controlBar.clean();
- that._legendsControl.clean()
- },
- _render: function() {
- var that = this;
- that._background.append(that._root);
- that._areasManager.render();
- that._markersManager.render();
- that._controlBar.render();
- that._legendsControl.render();
- that._layoutControl.start()
- },
- _optionChanged: function(args) {
- var that = this,
- value = args.value;
- switch (args.name) {
- case"mapData":
- that._areasManager.setData(value);
- break;
- case"markers":
- that._markersManager.setData(value);
- break;
- case"bounds":
- that._projection.setBounds(value);
- break;
- case"maxZoomFactor":
- that._projection.setMaxZoom(value);
- break;
- case"zoomFactor":
- that._projection.setZoom(value);
- break;
- case"center":
- that._projection.setCenter(value);
- break;
- case"background":
- that._setBackgroundOptions();
- break;
- case"areaSettings":
- that._setAreasManagerOptions();
- break;
- case"markerSettings":
- that._setMarkersManagerOptions();
- break;
- case"controlBar":
- that._setControlBarOptions();
- break;
- case"legends":
- that._setLegendsOptions();
- break;
- case"touchEnabled":
- case"wheelEnabled":
- that._setTrackerOptions();
- break;
- case"panningEnabled":
- case"zoomingEnabled":
- that._setupInteraction();
- break;
- default:
- that.callBase.apply(that, arguments);
- break
- }
- },
- _handleThemeOptionsCore: function() {
- var that = this;
- that._setBackgroundOptions();
- that._setAreasManagerOptions();
- that._setMarkersManagerOptions();
- that._setControlBarOptions();
- that._setLegendsOptions();
- that._setTrackerOptions();
- that._setupInteraction()
- },
- _setBackgroundOptions: function() {
- var settings = this._getOption("background");
- this._background.attr({
- "stroke-width": settings.borderWidth,
- stroke: settings.borderColor,
- fill: settings.color
- })
- },
- _setAreasManagerOptions: function() {
- this._areasManager.setOptions(this.option("areaSettings"));
- this._eventTrigger.update("onAreaClick");
- this._eventTrigger.update("onAreaSelectionChanged")
- },
- _setMarkersManagerOptions: function() {
- this._markersManager.setOptions(this.option("markerSettings"));
- this._eventTrigger.update("onMarkerClick");
- this._eventTrigger.update("onMarkerSelectionChanged")
- },
- _setControlBarOptions: function() {
- this._controlBar.setOptions(this._getOption("controlBar"))
- },
- _setLegendsOptions: function() {
- this._legendsControl.setOptions(this.option("legends"), this._themeManager.theme("legend"))
- },
- _setTrackerOptions: function() {
- this._tracker.setOptions({
- touchEnabled: this._getOption("touchEnabled", true),
- wheelEnabled: this._getOption("wheelEnabled", true)
- })
- },
- _raiseCenterChanged: function() {
- !this._noCenterChanged && this._eventTrigger("centerChanged", {center: this._projection.getCenter()})
- },
- _raiseZoomFactorChanged: function() {
- !this._noZoomFactorChanged && this._eventTrigger("zoomFactorChanged", {zoomFactor: this._projection.getZoom()})
- },
- _refresh: function() {
- var that = this,
- callBase = that.callBase;
- that._endLoading(function() {
- callBase.call(that)
- })
- },
- getAreas: function() {
- return this._areasManager.getProxyItems()
- },
- getMarkers: function() {
- return this._markersManager.getProxyItems()
- },
- clearAreaSelection: function(_noEvent) {
- this._areasManager.clearSelection(_noEvent);
- return this
- },
- clearMarkerSelection: function(_noEvent) {
- this._markersManager.clearSelection(_noEvent);
- return this
- },
- clearSelection: function(_noEvent) {
- return this.clearAreaSelection(_noEvent).clearMarkerSelection(_noEvent)
- },
- center: function(value, _noEvent) {
- var that = this;
- if (value === undefined)
- return that._projection.getCenter();
- else {
- that._noCenterChanged = _noEvent;
- that._projection.setCenter(value);
- that._noCenterChanged = null;
- return that
- }
- },
- zoomFactor: function(value, _noEvent) {
- var that = this;
- if (value === undefined)
- return that._projection.getZoom();
- else {
- that._noZoomFactorChanged = _noEvent;
- that._projection.setZoom(value);
- that._noZoomFactorChanged = null;
- return that
- }
- },
- viewport: function(value, _noEvent) {
- var that = this;
- if (value === undefined)
- return that._projection.getViewport();
- else {
- that._noCenterChanged = that._noZoomFactorChanged = _noEvent;
- that._projection.setViewport(value);
- that._noCenterChanged = that._noZoomFactorChanged = null;
- return that
- }
- },
- convertCoordinates: function(x, y) {
- return this._projection.fromScreenPoint(x, y)
- },
- _factory: {}
- });
- var DataExchanger = function() {
- this._store = {}
- };
- DataExchanger.prototype = {
- constructor: DataExchanger,
- dispose: function() {
- this._store = null;
- return this
- },
- _get: function(category, name) {
- var store = this._store[category] || (this._store[category] = {});
- return store[name] || (store[name] = {})
- },
- set: function(category, name, data) {
- var item = this._get(category, name);
- item.data = data;
- item.callback && item.callback(data);
- return this
- },
- bind: function(category, name, callback) {
- var item = this._get(category, name);
- item.callback = callback;
- item.data && callback(item.data);
- return this
- },
- unbind: function(category, name) {
- var item = this._get(category, name);
- item.data = item.callback = null;
- return this
- }
- };
- DX.registerComponent("dxVectorMap", DX.viz.map, Map);
- DX.viz.map._internal = {};
- DX.viz.map.sources = {};
- DX.viz.map._tests = {};
- DX.viz.map._tests.DataExchanger = DataExchanger;
- DX.viz.map._tests.stubDataExchanger = function(stub) {
- DataExchanger = stub
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file projection.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _isArray = DX.utils.isArray,
- _math = Math,
- _min = _math.min,
- _max = _math.max,
- _abs = _math.abs,
- _tan = _math.tan,
- _atan = _math.atan,
- _exp = _math.exp,
- _round = _math.round,
- _ln = _math.log,
- _pow = _math.pow,
- PI = _math.PI,
- QUARTER_PI = PI / 4,
- PI_TO_360 = PI / 360,
- TWO_TO_LN2 = 2 / _math.LN2,
- MIN_BOUNDS_RANGE = 1 / 3600 / 180 / 10,
- DEFAULT_MIN_ZOOM = 1,
- DEFAULT_MAX_ZOOM = 1 << 8,
- MERCATOR_MIN_LON = -180,
- MERCATOR_MAX_LON = 180,
- MERCATOR_MIN_LAT = -85.0511,
- MERCATOR_MAX_LAT = 85.0511;
- var mercator = {
- aspectRatio: 1,
- project: function(coordinates) {
- var lon = coordinates[0],
- lat = coordinates[1];
- return [lon <= MERCATOR_MIN_LON ? -1 : lon >= MERCATOR_MAX_LON ? +1 : lon / 180, lat <= MERCATOR_MIN_LAT ? +1 : lat >= MERCATOR_MAX_LAT ? -1 : -_ln(_tan(QUARTER_PI + lat * PI_TO_360)) / PI]
- },
- unproject: function(coordinates) {
- var x = coordinates[0],
- y = coordinates[1];
- return [x <= -1 ? MERCATOR_MIN_LON : x >= +1 ? MERCATOR_MAX_LON : 180 * x, y <= -1 ? MERCATOR_MAX_LAT : y >= +1 ? MERCATOR_MIN_LAT : (_atan(_exp(-PI * coordinates[1])) - QUARTER_PI) / PI_TO_360]
- }
- };
- function createProjectUnprojectMethods(p1, p2, delta) {
- var x0 = (p1[0] + p2[0]) / 2 - delta / 2,
- y0 = (p1[1] + p2[1]) / 2 - delta / 2,
- k = 2 / delta;
- return {
- project: function(coordinates) {
- var p = mercator.project(coordinates);
- return [-1 + (p[0] - x0) * k, -1 + (p[1] - y0) * k]
- },
- unproject: function(coordinates) {
- var p = [x0 + (coordinates[0] + 1) / k, y0 + (coordinates[1] + 1) / k];
- return mercator.unproject(p)
- }
- }
- }
- function floatsEqual(f1, f2) {
- return _abs(f1 - f2) < 1E-8
- }
- function truncate(value, min, max, fallback) {
- var _value = _Number(value);
- if (_value < min)
- _value = min;
- else if (_value > max)
- _value = max;
- else if (!(min <= _value && _value <= max))
- _value = fallback;
- return _value
- }
- function truncateQuad(quad, min, max) {
- return {
- lt: [truncate(quad[0], min[0], max[0], min[0]), truncate(quad[1], min[1], max[1], min[1])],
- rb: [truncate(quad[2], min[0], max[0], max[0]), truncate(quad[3], min[1], max[1], max[1])]
- }
- }
- function parseBounds(bounds) {
- var p1 = mercator.unproject([-1, -1]),
- p2 = mercator.unproject([+1, +1]),
- min = [_min(p1[0], p2[0]), _min(p1[1], p2[1])],
- max = [_max(p1[0], p2[0]), _max(p1[1], p2[1])],
- quad = bounds;
- if (quad)
- quad = truncateQuad(quad, min, max);
- return {
- min: quad ? [_min(quad.lt[0], quad.rb[0]), _min(quad.lt[1], quad.rb[1])] : min,
- max: quad ? [_max(quad.lt[0], quad.rb[0]), _max(quad.lt[1], quad.rb[1])] : max
- }
- }
- function selectCenterValue(value1, value2, center1, center2) {
- var result;
- if (value1 > -1 && value2 >= +1)
- result = center1;
- else if (value1 <= -1 && value2 < +1)
- result = center2;
- else
- result = (center1 + center2) / 2;
- return result
- }
- function Projection() {
- this._events = {
- project: $.Callbacks(),
- transform: $.Callbacks(),
- center: $.Callbacks(),
- zoom: $.Callbacks(),
- "max-zoom": $.Callbacks()
- };
- this.setBounds(null)
- }
- Projection.prototype = {
- constructor: Projection,
- _minZoom: DEFAULT_MIN_ZOOM,
- _maxZoom: DEFAULT_MAX_ZOOM,
- _zoom: DEFAULT_MIN_ZOOM,
- _center: [NaN, NaN],
- dispose: function() {
- this._events = null;
- return this
- },
- setSize: function(width, height) {
- var that = this;
- that._x0 = width / 2;
- that._y0 = height / 2;
- if (width / height <= mercator.aspectRatio) {
- that._xradius = width / 2;
- that._yradius = width / 2 / mercator.aspectRatio
- }
- else {
- that._xradius = height / 2 * mercator.aspectRatio;
- that._yradius = height / 2
- }
- that._events["transform"].fire(that.getTransform());
- return that
- },
- setBounds: function(bounds) {
- var that = this,
- _bounds = parseBounds(bounds),
- p1,
- p2,
- delta,
- methods;
- that._minBound = _bounds.min;
- that._maxBound = _bounds.max;
- p1 = mercator.project(_bounds.min);
- p2 = mercator.project(_bounds.max);
- delta = [_abs(p2[0] - p1[0]), _abs(p2[1] - p1[1])];
- delta = _min(delta[0] > MIN_BOUNDS_RANGE ? delta[0] : 2, delta[1] > MIN_BOUNDS_RANGE ? delta[1] : 2);
- methods = delta < 2 ? createProjectUnprojectMethods(p1, p2, delta) : mercator;
- that._project = methods.project;
- that._unproject = methods.unproject;
- that._defaultCenter = that._unproject([0, 0]);
- that.setCenter(that._defaultCenter);
- that._events.project.fire();
- return that
- },
- _toScreen: function(coordinates) {
- return [this._x0 + this._xradius * coordinates[0], this._y0 + this._yradius * coordinates[1]]
- },
- _fromScreen: function(coordinates) {
- return [(coordinates[0] - this._x0) / this._xradius, (coordinates[1] - this._y0) / this._yradius]
- },
- _toTransformed: function(coordinates) {
- return [coordinates[0] * this._zoom + this._dxcenter, coordinates[1] * this._zoom + this._dycenter]
- },
- _toTransformedFast: function(coordinates) {
- return [coordinates[0] * this._zoom, coordinates[1] * this._zoom]
- },
- _fromTransformed: function(coordinates) {
- return [(coordinates[0] - this._dxcenter) / this._zoom, (coordinates[1] - this._dycenter) / this._zoom]
- },
- _adjustCenter: function() {
- var that = this,
- center = that._project(that._center);
- that._dxcenter = -center[0] * that._zoom;
- that._dycenter = -center[1] * that._zoom
- },
- projectArea: function(coordinates) {
- var i = 0,
- ii = _isArray(coordinates) ? coordinates.length : 0,
- subcoords,
- j,
- jj,
- subresult,
- result = [];
- for (; i < ii; ++i) {
- subcoords = coordinates[i];
- subresult = [];
- for (j = 0, jj = _isArray(subcoords) ? subcoords.length : 0; j < jj; ++j)
- subresult.push(this._project(subcoords[j]));
- result.push(subresult)
- }
- return result
- },
- projectPoint: function(coordinates) {
- return coordinates ? this._project(coordinates) : []
- },
- getAreaCoordinates: function(data) {
- var k = 0,
- kk = data.length,
- partialData,
- i,
- ii,
- list = [],
- partialPath,
- point;
- for (; k < kk; ++k) {
- partialData = data[k];
- partialPath = [];
- for (i = 0, ii = partialData.length; i < ii; ++i) {
- point = this._toScreen(this._toTransformedFast(partialData[i]));
- partialPath.push(point[0], point[1])
- }
- list.push(partialPath)
- }
- return list
- },
- getPointCoordinates: function(data) {
- var point = this._toScreen(this._toTransformedFast(data));
- return {
- x: _round(point[0]),
- y: _round(point[1])
- }
- },
- getSquareSize: function(size) {
- return [size[0] * this._zoom * this._xradius, size[1] * this._zoom * this._yradius]
- },
- getZoom: function() {
- return this._zoom
- },
- setZoom: function(zoom, _forceEvent) {
- var that = this,
- zoom__ = that._zoom;
- that._zoom = truncate(zoom, that._minZoom, that._maxZoom, that._minZoom);
- that._adjustCenter();
- if (!floatsEqual(zoom__, that._zoom) || _forceEvent)
- that._events.zoom.fire(that.getZoom(), that.getTransform());
- return that
- },
- getScaledZoom: function() {
- return _round((this._scale.length - 1) * _ln(this._zoom) / _ln(this._maxZoom))
- },
- setScaledZoom: function(scaledZoom) {
- return this.setZoom(this._scale[_round(scaledZoom)])
- },
- getZoomScalePartition: function() {
- return this._scale.length - 1
- },
- _setupScaling: function() {
- var that = this,
- k = _round(TWO_TO_LN2 * _ln(that._maxZoom)),
- step,
- zoom,
- i = 1;
- k = k > 4 ? k : 4;
- step = _pow(that._maxZoom, 1 / k);
- zoom = that._minZoom;
- that._scale = [zoom];
- for (; i <= k; ++i)
- that._scale.push(zoom *= step)
- },
- setMaxZoom: function(maxZoom) {
- var that = this;
- that._minZoom = DEFAULT_MIN_ZOOM;
- that._maxZoom = truncate(maxZoom, that._minZoom, _Number.MAX_VALUE, DEFAULT_MAX_ZOOM);
- that._setupScaling();
- if (that._zoom > that._maxZoom)
- that.setZoom(that._maxZoom);
- that._events["max-zoom"].fire(that._maxZoom);
- return that
- },
- getMinZoom: function() {
- return this._minZoom
- },
- getMaxZoom: function() {
- return this._maxZoom
- },
- getCenter: function() {
- return [this._center[0], this._center[1]]
- },
- setCenter: function(center, _forceEvent) {
- var that = this,
- _center = _isArray(center) ? center : [],
- center__ = that._center;
- that._center = [truncate(_center[0], that._minBound[0], that._maxBound[0], that._defaultCenter[0]), truncate(_center[1], that._minBound[1], that._maxBound[1], that._defaultCenter[1])];
- that._adjustCenter();
- if (!floatsEqual(center__[0], that._center[0]) || !floatsEqual(center__[1], that._center[1]) || _forceEvent)
- that._events.center.fire(that.getCenter(), that.getTransform());
- return that
- },
- setCenterByPoint: function(coordinates, screenPosition) {
- var that = this,
- p = that._project(coordinates),
- q = that._fromScreen(screenPosition);
- return that.setCenter(that._unproject([-q[0] / that._zoom + p[0], -q[1] / that._zoom + p[1]]))
- },
- moveCenter: function(screenDx, screenDy) {
- var that = this,
- current = that._toScreen(that._toTransformed(that._project(that._center))),
- center = that._unproject(that._fromTransformed(that._fromScreen([current[0] + screenDx, current[1] + screenDy])));
- return that.setCenter(center)
- },
- getViewport: function() {
- var p1 = this._unproject(this._fromTransformed([-1, -1])),
- p2 = this._unproject(this._fromTransformed([+1, +1]));
- return [p1[0], p1[1], p2[0], p2[1]]
- },
- setViewport: function(viewport) {
- var that = this;
- if (!_isArray(viewport))
- return that.setZoom(that._minZoom).setCenter(that._defaultCenter);
- var _viewport = truncateQuad(viewport, that._minBound, that._maxBound),
- lt = that._project(_viewport.lt),
- rb = that._project(_viewport.rb),
- l = _min(lt[0], rb[0]),
- t = _min(lt[1], rb[1]),
- r = _max(lt[0], rb[0]),
- b = _max(lt[1], rb[1]),
- zoom = 2 / _max(r - l, b - t),
- xc = selectCenterValue(l, r, -1 - zoom * l, +1 - zoom * r),
- yc = selectCenterValue(t, b, -1 - zoom * t, +1 - zoom * b);
- return that.setZoom(zoom).setCenter(that._unproject([-xc / zoom, -yc / zoom]))
- },
- getTransform: function() {
- return {
- translateX: this._dxcenter * this._xradius,
- translateY: this._dycenter * this._yradius
- }
- },
- fromScreenPoint: function(x, y) {
- return this._unproject(this._fromTransformed(this._fromScreen([x, y])))
- },
- on: function(obj) {
- $.each(this._events, function(name, list) {
- obj[name] && list.add(obj[name])
- });
- return this
- }
- };
- DX.viz.map._tests.Projection = Projection;
- DX.viz.map._tests.mercator = mercator;
- DX.viz.map._tests._DEBUG_stubMercator = function(stub) {
- mercator = stub
- };
- DX.viz.map._tests._DEBUG_restoreMercator = function() {
- mercator = DX.viz.map._tests.mercator
- };
- DX.viz.map.dxVectorMap.prototype._factory.createProjection = function() {
- return new Projection
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file controlBar.js */
- (function(DX, undefined) {
- var _Number = Number,
- _math = Math,
- _round = _math.round,
- _floor = _math.floor,
- _pow = _math.pow,
- _ln = _math.log,
- _LN2 = _math.LN2,
- utils = DX.viz.core.utils,
- _parseScalar = utils.parseScalar,
- parseHorizontalAlignment = utils.enumParser(["left", "center", "right"]),
- parseVerticalAlignment = utils.enumParser(["top", "bottom"]),
- COMMAND_RESET = "command-reset",
- COMMAND_MOVE_UP = "command-move-up",
- COMMAND_MOVE_RIGHT = "command-move-right",
- COMMAND_MOVE_DOWN = "command-move-down",
- COMMAND_MOVE_LEFT = "command-move-left",
- COMMAND_ZOOM_IN = "command-zoom-in",
- COMMAND_ZOOM_OUT = "command-zoom-out",
- COMMAND_ZOOM_DRAG_LINE = "command-zoom-drag-line",
- COMMAND_ZOOM_DRAG = "command-zoom-drag",
- EVENT_TARGET_TYPE = "control-bar",
- FLAG_CENTERING = 1,
- FLAG_ZOOMING = 2,
- SIZE_OPTIONS = {
- bigCircleSize: 58,
- smallCircleSize: 28,
- buttonSize: 10,
- arrowButtonOffset: 20,
- incdecButtonSize: 11,
- incButtonOffset: 66,
- decButtonOffset: 227,
- sliderLineStartOffset: 88.5,
- sliderLineEndOffset: 205.5,
- sliderLength: 20,
- sliderWidth: 8,
- trackerGap: 4
- },
- OFFSET_X = 30.5,
- OFFSET_Y = 30.5,
- TOTAL_WIDTH = 61,
- TOTAL_HEIGHT = 274,
- COMMAND_TO_TYPE_MAP = {};
- COMMAND_TO_TYPE_MAP[COMMAND_RESET] = ResetCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_MOVE_UP] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_RIGHT] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_DOWN] = COMMAND_TO_TYPE_MAP[COMMAND_MOVE_LEFT] = MoveCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_IN] = COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_OUT] = ZoomCommand;
- COMMAND_TO_TYPE_MAP[COMMAND_ZOOM_DRAG] = ZoomDragCommand;
- var ControlBar = DX.Class.inherit({
- _flags: 0,
- ctor: function(parameters) {
- var that = this;
- that._params = parameters;
- that._createElements(parameters.renderer, parameters.dataKey);
- parameters.layoutControl.addItem(that);
- that._subscribeToProjection(parameters.projection);
- that._setVisibility(false)
- },
- setCallbacks: function(callbacks) {
- this._callbacks = callbacks;
- return this
- },
- _createElements: function(renderer, dataKey) {
- var that = this,
- buttonsGroups,
- trackersGroup;
- that._root = renderer.g().attr({"class": "dxm-control-bar"});
- buttonsGroups = that._buttonsGroup = renderer.g().attr({"class": "dxm-control-buttons"}).append(that._root);
- trackersGroup = renderer.g().attr({
- stroke: "none",
- "stroke-width": 0,
- fill: "#000000",
- opacity: 0.0001
- }).css({cursor: "pointer"}).append(that._root);
- that._createButtons(renderer, dataKey, buttonsGroups);
- that._createTrackers(renderer, dataKey, trackersGroup)
- },
- _createButtons: function(renderer, dataKey, group) {
- var that = this,
- options = SIZE_OPTIONS,
- size = options.buttonSize / 2,
- offset1 = options.arrowButtonOffset - size,
- offset2 = options.arrowButtonOffset,
- incdecButtonSize = options.incdecButtonSize / 2,
- directionOptions = {
- "stroke-linecap": "square",
- fill: "none"
- },
- line = "line";
- renderer.circle(0, 0, options.bigCircleSize / 2).append(group);
- renderer.circle(0, 0, size).attr({fill: "none"}).append(group);
- renderer.path([-size, -offset1, 0, -offset2, size, -offset1], line).attr(directionOptions).append(group);
- renderer.path([offset1, -size, offset2, 0, offset1, size], line).attr(directionOptions).append(group);
- renderer.path([size, offset1, 0, offset2, -size, offset1], line).attr(directionOptions).append(group);
- renderer.path([-offset1, size, -offset2, 0, -offset1, -size], line).attr(directionOptions).append(group);
- renderer.circle(0, options.incButtonOffset, options.smallCircleSize / 2).append(group);
- renderer.path([[-incdecButtonSize, options.incButtonOffset, incdecButtonSize, options.incButtonOffset], [0, options.incButtonOffset - incdecButtonSize, 0, options.incButtonOffset + incdecButtonSize]], "area").append(group);
- renderer.circle(0, options.decButtonOffset, options.smallCircleSize / 2).append(group);
- renderer.path([-incdecButtonSize, options.decButtonOffset, incdecButtonSize, options.decButtonOffset], "area").append(group);
- that._progressBar = renderer.path([], "area").append(group);
- that._zoomDrag = renderer.rect(_floor(-options.sliderLength / 2), _floor(options.sliderLineEndOffset - options.sliderWidth / 2), options.sliderLength, options.sliderWidth).append(group);
- that._sliderLineLength = options.sliderLineEndOffset - options.sliderLineStartOffset
- },
- _createTrackers: function(renderer, dataKey, group) {
- var options = SIZE_OPTIONS,
- size = _round((options.arrowButtonOffset - options.trackerGap) / 2),
- offset1 = options.arrowButtonOffset - size,
- offset2 = _round(_pow(options.bigCircleSize * options.bigCircleSize / 4 - size * size, 0.5)),
- size2 = offset2 - offset1;
- renderer.rect(-size, -size, size * 2, size * 2).data(dataKey, {
- index: COMMAND_RESET,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.rect(-size, -offset2, size * 2, size2).data(dataKey, {
- index: COMMAND_MOVE_UP,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.rect(offset1, -size, size2, size * 2).data(dataKey, {
- index: COMMAND_MOVE_RIGHT,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.rect(-size, offset1, size * 2, size2).data(dataKey, {
- index: COMMAND_MOVE_DOWN,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.rect(-offset2, -size, size2, size * 2).data(dataKey, {
- index: COMMAND_MOVE_LEFT,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.circle(0, options.incButtonOffset, options.smallCircleSize / 2).data(dataKey, {
- index: COMMAND_ZOOM_IN,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.circle(0, options.decButtonOffset, options.smallCircleSize / 2).data(dataKey, {
- index: COMMAND_ZOOM_OUT,
- type: EVENT_TARGET_TYPE
- }).append(group);
- renderer.rect(-2, options.sliderLineStartOffset - 2, 4, options.sliderLineEndOffset - options.sliderLineStartOffset + 4).css({cursor: "default"}).data(dataKey, {
- index: COMMAND_ZOOM_DRAG_LINE,
- type: EVENT_TARGET_TYPE
- }).append(group);
- this._zoomDragCover = renderer.rect(-options.sliderLength / 2, options.sliderLineEndOffset - options.sliderWidth / 2, options.sliderLength, options.sliderWidth).data(dataKey, {
- index: COMMAND_ZOOM_DRAG,
- type: EVENT_TARGET_TYPE
- }).append(group)
- },
- _subscribeToProjection: function(projection) {
- var that = this;
- projection.on({
- zoom: function() {
- that._adjustZoom(projection.getScaledZoom())
- },
- "max-zoom": function() {
- that._zoomPartition = projection.getZoomScalePartition();
- that._sliderUnitLength = that._sliderLineLength / that._zoomPartition;
- that._adjustZoom(projection.getScaledZoom())
- }
- })
- },
- dispose: function() {
- var that = this;
- that._params.layoutControl.removeItem(that);
- that._root.clear();
- that._params = that._callbacks = that._root = that._buttonsGroup = that._zoomDrag = that._zoomDragCover = that._progressBar = null;
- return that
- },
- resize: function(size) {
- this._setVisibility(size !== null && this._options.enabled && this._flags);
- return this
- },
- _setVisibility: function(state) {
- this._root.attr({visibility: state ? null : "hidden"})
- },
- getLayoutOptions: function() {
- var options = this._options;
- return this._rendered && options.enabled && this._flags ? {
- width: 2 * options.margin + TOTAL_WIDTH,
- height: 2 * options.margin + TOTAL_HEIGHT,
- horizontalAlignment: options.horizontalAlignment,
- verticalAlignment: options.verticalAlignment
- } : null
- },
- locate: function(x, y) {
- this._root.attr({
- translateX: x + this._options.margin + OFFSET_X,
- translateY: y + this._options.margin + OFFSET_Y
- });
- return this
- },
- setInteraction: function(interaction) {
- var that = this;
- that.processEnd();
- if (_parseScalar(interaction.centeringEnabled, true))
- that._flags |= FLAG_CENTERING;
- else
- that._flags &= ~FLAG_CENTERING;
- if (_parseScalar(interaction.zoomingEnabled, true))
- that._flags |= FLAG_ZOOMING;
- else
- that._flags &= ~FLAG_ZOOMING;
- if (that._rendered)
- that._refresh();
- return that
- },
- setOptions: function(options) {
- var that = this;
- that.processEnd();
- that._buttonsGroup.attr({
- "stroke-width": options.borderWidth,
- stroke: options.borderColor,
- fill: options.color,
- "fill-opacity": options.opacity
- });
- that._options = {
- enabled: !!_parseScalar(options.enabled, true),
- margin: options.margin > 0 ? _Number(options.margin) : 0,
- horizontalAlignment: parseHorizontalAlignment(options.horizontalAlignment, "left"),
- verticalAlignment: parseVerticalAlignment(options.verticalAlignment, "top")
- };
- that._rendered && that._refresh();
- return that
- },
- _refresh: function() {
- var isVisible = this._flags && this._options.enabled;
- this._setVisibility(isVisible);
- if (isVisible)
- this.updateLayout()
- },
- clean: function() {
- var that = this;
- that._rendered = null;
- that._root.remove();
- return that
- },
- render: function() {
- var that = this;
- that._rendered = true;
- that._root.append(that._params.container);
- that._refresh();
- return that
- },
- _adjustZoom: function(zoom) {
- var that = this,
- transform,
- y,
- start = SIZE_OPTIONS.sliderLineStartOffset,
- end = SIZE_OPTIONS.sliderLineEndOffset,
- h = SIZE_OPTIONS.sliderWidth;
- that._zoomFactor = _round(zoom);
- that._zoomFactor >= 0 || (that._zoomFactor = 0);
- that._zoomFactor <= that._zoomPartition || (that._zoomFactor = that._zoomPartition);
- transform = {translateY: -that._zoomFactor * that._sliderUnitLength};
- y = end - h / 2 + transform.translateY;
- that._progressBar.attr({points: [[0, start, 0, _math.max(start, y)], [0, _math.min(end, y + h), 0, end]]});
- that._zoomDrag.attr(transform);
- that._zoomDragCover.attr(transform)
- },
- _applyZoom: function(center) {
- this._callbacks.zoom(this._zoomFactor, this._flags & FLAG_CENTERING ? center : undefined)
- },
- processStart: function(arg) {
- var commandType = COMMAND_TO_TYPE_MAP[arg.data];
- this._command = commandType && this._options.enabled && commandType.flags & this._flags ? new commandType(this, arg) : null;
- return this
- },
- processMove: function(arg) {
- this._command && this._command.update(arg);
- return this
- },
- processEnd: function() {
- this._command && this._command.finish();
- this._command = null;
- return this
- },
- processZoom: function(arg) {
- var that = this,
- zoomFactor;
- if (that._flags & FLAG_ZOOMING) {
- if (arg.delta)
- zoomFactor = arg.delta;
- else if (arg.ratio)
- zoomFactor = _ln(arg.ratio) / _LN2;
- that._adjustZoom(that._zoomFactor + zoomFactor);
- that._applyZoom([arg.x, arg.y])
- }
- return that
- }
- });
- function disposeCommand(command) {
- delete command._owner;
- command.update = function(){};
- command.finish = function(){}
- }
- function ResetCommand(owner, arg) {
- this._owner = owner;
- this._command = arg.data
- }
- ResetCommand.flags = FLAG_CENTERING | FLAG_ZOOMING;
- ResetCommand.prototype.update = function(arg) {
- arg.data !== this._command && disposeCommand(this)
- };
- ResetCommand.prototype.finish = function() {
- var flags = this._owner._flags;
- this._owner._callbacks.reset(!!(flags & FLAG_CENTERING), !!(flags & FLAG_ZOOMING));
- if (flags & FLAG_ZOOMING)
- this._owner._adjustZoom(0);
- disposeCommand(this)
- };
- function MoveCommand(owner, arg) {
- this._command = arg.data;
- var timeout = null,
- interval = 100,
- dx = 0,
- dy = 0;
- switch (this._command) {
- case COMMAND_MOVE_UP:
- dy = -10;
- break;
- case COMMAND_MOVE_RIGHT:
- dx = 10;
- break;
- case COMMAND_MOVE_DOWN:
- dy = 10;
- break;
- case COMMAND_MOVE_LEFT:
- dx = -10;
- break
- }
- function callback() {
- owner._callbacks.move(dx, dy);
- timeout = setTimeout(callback, interval)
- }
- this._stop = function() {
- clearTimeout(timeout);
- owner._callbacks.endMove();
- this._stop = owner = null;
- return this
- };
- arg = null;
- owner._callbacks.beginMove();
- callback()
- }
- MoveCommand.flags = FLAG_CENTERING;
- MoveCommand.prototype.update = function(arg) {
- this._command !== arg.data && this.finish()
- };
- MoveCommand.prototype.finish = function() {
- disposeCommand(this._stop())
- };
- function ZoomCommand(owner, arg) {
- this._owner = owner;
- this._command = arg.data;
- var timeout = null,
- interval = 150,
- dzoom = this._command === COMMAND_ZOOM_IN ? 1 : -1;
- function callback() {
- owner._adjustZoom(owner._zoomFactor + dzoom);
- timeout = setTimeout(callback, interval)
- }
- this._stop = function() {
- clearTimeout(timeout);
- this._stop = owner = null;
- return this
- };
- arg = null;
- callback()
- }
- ZoomCommand.flags = FLAG_ZOOMING;
- ZoomCommand.prototype.update = function(arg) {
- this._command !== arg.data && this.finish()
- };
- ZoomCommand.prototype.finish = function() {
- this._owner._applyZoom();
- disposeCommand(this._stop())
- };
- function ZoomDragCommand(owner, arg) {
- this._owner = owner;
- this._zoomFactor = owner._zoomFactor;
- this._pos = arg.y
- }
- ZoomDragCommand.flags = FLAG_ZOOMING;
- ZoomDragCommand.prototype.update = function(arg) {
- var owner = this._owner;
- owner._adjustZoom(this._zoomFactor + owner._zoomPartition * (this._pos - arg.y) / owner._sliderLineLength)
- };
- ZoomDragCommand.prototype.finish = function() {
- this._owner._applyZoom();
- disposeCommand(this)
- };
- DX.viz.map._tests.ControlBar = ControlBar;
- var COMMAND_TO_TYPE_MAP__ORIGINAL = COMMAND_TO_TYPE_MAP;
- DX.viz.map._tests.stubCommandToTypeMap = function(map) {
- COMMAND_TO_TYPE_MAP = map
- };
- DX.viz.map._tests.restoreCommandToTypeMap = function() {
- COMMAND_TO_TYPE_MAP = COMMAND_TO_TYPE_MAP__ORIGINAL
- };
- DX.viz.map.dxVectorMap.prototype._factory.createControlBar = function(parameters) {
- return new ControlBar(parameters)
- }
- })(DevExpress);
- /*! Module viz-vectormap, file tracker.js */
- (function(DX, $, undefined) {
- var _math = Math,
- _abs = _math.abs,
- _sqrt = _math.sqrt,
- _round = _math.round,
- _addNamespace = DX.ui.events.addNamespace,
- _parseScalar = DX.viz.core.utils.parseScalar,
- _now = $.now,
- _NAME = DX.viz.map.dxVectorMap.prototype.NAME,
- EVENTS = {};
- setupEvents();
- var EVENT_START = "start",
- EVENT_MOVE = "move",
- EVENT_END = "end",
- EVENT_ZOOM = "zoom",
- EVENT_HOVER_ON = "hover-on",
- EVENT_HOVER_OFF = "hover-off",
- EVENT_CLICK = "click",
- EVENT_FOCUS_ON = "focus-on",
- EVENT_FOCUS_MOVE = "focus-move",
- EVENT_FOCUS_OFF = "focus-off",
- CLICK_TIME_THRESHOLD = 500,
- CLICK_COORD_THRESHOLD_MOUSE = 5,
- CLICK_COORD_THRESHOLD_TOUCH = 20,
- DRAG_COORD_THRESHOLD_MOUSE = 5,
- DRAG_COORD_THRESHOLD_TOUCH = 10,
- FOCUS_ON_DELAY_MOUSE = 300,
- FOCUS_OFF_DELAY_MOUSE = 300,
- FOCUS_ON_DELAY_TOUCH = 300,
- FOCUS_OFF_DELAY_TOUCH = 400,
- FOCUS_COORD_THRESHOLD_MOUSE = 5,
- WHEEL_COOLDOWN = 50,
- WHEEL_DIRECTION_COOLDOWN = 300;
- function Tracker(parameters) {
- var that = this;
- that._root = parameters.root;
- that._callbacks = {};
- that._createEventHandlers(parameters.dataKey);
- that._createProjectionHandlers(parameters.projection);
- that._focus = new Focus(that._callbacks);
- that._attachHandlers()
- }
- Tracker.prototype = {
- constructor: Tracker,
- dispose: function() {
- var that = this;
- that._detachHandlers();
- that._focus.dispose();
- that._root = that._callbacks = that._focus = that._docHandlers = that._rootHandlers = null;
- return that
- },
- _startClick: function(event, data) {
- if (!data)
- return;
- var coords = getEventCoords(event);
- this._clickState = {
- x: coords.x,
- y: coords.y,
- threshold: isTouchEvent(event) ? CLICK_COORD_THRESHOLD_TOUCH : CLICK_COORD_THRESHOLD_MOUSE,
- time: _now()
- }
- },
- _endClick: function(event, data) {
- var state = this._clickState,
- threshold,
- coords;
- if (!state)
- return;
- if (_now() - state.time <= CLICK_TIME_THRESHOLD) {
- threshold = state.threshold;
- coords = getEventCoords(event);
- if (_abs(coords.x - state.x) <= threshold && _abs(coords.y - state.y) <= threshold)
- this._callbacks[EVENT_CLICK]({
- data: data,
- x: coords.x,
- y: coords.y,
- $event: event
- })
- }
- this._clickState = null
- },
- _startDrag: function(event, data) {
- if (!data)
- return;
- var coords = getEventCoords(event),
- state = this._dragState = {
- x: coords.x,
- y: coords.y,
- data: data
- };
- this._callbacks[EVENT_START]({
- x: state.x,
- y: state.y,
- data: state.data
- })
- },
- _moveDrag: function(event, data) {
- var state = this._dragState,
- coords,
- threshold;
- if (!state)
- return;
- coords = getEventCoords(event);
- threshold = isTouchEvent(event) ? DRAG_COORD_THRESHOLD_TOUCH : DRAG_COORD_THRESHOLD_MOUSE;
- if (state.active || _abs(coords.x - state.x) > threshold || _abs(coords.y - state.y) > threshold) {
- state.x = coords.x;
- state.y = coords.y;
- state.active = true;
- state.data = data || {};
- this._callbacks[EVENT_MOVE]({
- x: state.x,
- y: state.y,
- data: state.data
- })
- }
- },
- _endDrag: function() {
- var state = this._dragState;
- if (!state)
- return;
- this._dragState = null;
- this._callbacks[EVENT_END]({
- x: state.x,
- y: state.y,
- data: state.data
- })
- },
- _wheelZoom: function(event, data) {
- if (!data)
- return;
- var that = this,
- lock = that._wheelLock,
- time = _now(),
- delta,
- coords;
- if (time - lock.time <= WHEEL_COOLDOWN)
- return;
- if (time - lock.dirTime > WHEEL_DIRECTION_COOLDOWN)
- lock.dir = 0;
- delta = adjustWheelDelta(event.originalEvent.wheelDelta / 120 || event.originalEvent.detail / -3 || 0, lock);
- if (delta === 0)
- return;
- coords = getEventCoords(event);
- that._callbacks[EVENT_ZOOM]({
- delta: delta,
- x: coords.x,
- y: coords.y
- });
- lock.time = lock.dirTime = time
- },
- _startZoom: function(event, data) {
- if (!isTouchEvent(event) || !data)
- return;
- var state = this._zoomState = this._zoomState || {},
- coords,
- pointer2;
- if (state.pointer1 && state.pointer2)
- return;
- if (state.pointer1 === undefined) {
- state.pointer1 = getPointerId(event) || 0;
- coords = getMultitouchEventCoords(event, state.pointer1);
- state.x1 = state.x1_0 = coords.x;
- state.y1 = state.y1_0 = coords.y
- }
- if (state.pointer2 === undefined) {
- pointer2 = getPointerId(event) || 1;
- if (pointer2 !== state.pointer1) {
- coords = getMultitouchEventCoords(event, pointer2);
- if (coords) {
- state.x2 = state.x2_0 = coords.x;
- state.y2 = state.y2_0 = coords.y;
- state.pointer2 = pointer2;
- state.ready = true;
- this._endDrag()
- }
- }
- }
- },
- _moveZoom: function(event) {
- var state = this._zoomState,
- coords;
- if (!state || !isTouchEvent(event))
- return;
- if (state.pointer1 !== undefined) {
- coords = getMultitouchEventCoords(event, state.pointer1);
- if (coords) {
- state.x1 = coords.x;
- state.y1 = coords.y
- }
- }
- if (state.pointer2 !== undefined) {
- coords = getMultitouchEventCoords(event, state.pointer2);
- if (coords) {
- state.x2 = coords.x;
- state.y2 = coords.y
- }
- }
- },
- _endZoom: function(event) {
- var state = this._zoomState,
- startDistance,
- currentDistance;
- if (!state || !isTouchEvent(event))
- return;
- if (state.ready) {
- startDistance = getDistance(state.x1_0, state.y1_0, state.x2_0, state.y2_0);
- currentDistance = getDistance(state.x1, state.y1, state.x2, state.y2);
- this._callbacks[EVENT_ZOOM]({
- ratio: currentDistance / startDistance,
- x: (state.x1_0 + state.x2_0) / 2,
- y: (state.y1_0 + state.y2_0) / 2
- })
- }
- this._zoomState = null
- },
- _startHover: function(event, data) {
- this._doHover(event, data, true)
- },
- _moveHover: function(event, data) {
- this._doHover(event, data, false)
- },
- _doHover: function(event, data, isTouch) {
- var that = this;
- if (that._dragState && that._dragState.active || that._zoomState && that._zoomState.ready) {
- that._cancelHover();
- return
- }
- if (isTouchEvent(event) !== isTouch || that._hoverTarget === event.target || that._hoverState && that._hoverState.data === data)
- return;
- that._cancelHover();
- if (data) {
- that._hoverState = {data: data};
- that._callbacks[EVENT_HOVER_ON]({data: data})
- }
- that._hoverTarget = event.target
- },
- _cancelHover: function() {
- var state = this._hoverState;
- this._hoverState = this._hoverTarget = null;
- if (state)
- this._callbacks[EVENT_HOVER_OFF]({data: state.data})
- },
- _startFocus: function(event, data) {
- this._doFocus(event, data, true)
- },
- _moveFocus: function(event, data) {
- this._doFocus(event, data, false)
- },
- _doFocus: function(event, data, isTouch) {
- var that = this;
- if (that._dragState && that._dragState.active || that._zoomState && that._zoomState.ready) {
- that._cancelFocus();
- return
- }
- if (isTouchEvent(event) !== isTouch)
- return;
- that._focus.turnOff(isTouch ? FOCUS_OFF_DELAY_TOUCH : FOCUS_OFF_DELAY_MOUSE);
- data && that._focus.turnOn(data, getEventCoords(event), isTouch ? FOCUS_ON_DELAY_TOUCH : FOCUS_ON_DELAY_MOUSE, isTouch)
- },
- _endFocus: function(event) {
- if (!isTouchEvent(event))
- return;
- this._focus.cancelOn()
- },
- _cancelFocus: function() {
- this._focus.cancel()
- },
- _createEventHandlers: function(DATA_KEY) {
- var that = this;
- that._docHandlers = {};
- that._rootHandlers = {};
- that._docHandlers[EVENTS.start] = function(event) {
- var isTouch = isTouchEvent(event),
- data = $(event.target).data(DATA_KEY);
- if (isTouch && !that._isTouchEnabled)
- return;
- data && event.preventDefault();
- that._startClick(event, data);
- that._startDrag(event, data);
- that._startZoom(event, data);
- that._startHover(event, data);
- that._startFocus(event, data)
- };
- that._docHandlers[EVENTS.move] = function(event) {
- var isTouch = isTouchEvent(event),
- data = $(event.target).data(DATA_KEY);
- if (isTouch && !that._isTouchEnabled)
- return;
- that._moveDrag(event, data);
- that._moveZoom(event, data);
- that._moveHover(event, data);
- that._moveFocus(event, data)
- };
- that._docHandlers[EVENTS.end] = function(event) {
- var isTouch = isTouchEvent(event),
- data = $(event.target).data(DATA_KEY);
- if (isTouch && !that._isTouchEnabled)
- return;
- that._endClick(event, data);
- that._endDrag(event, data);
- that._endZoom(event, data);
- that._endFocus(event, data)
- };
- that._rootHandlers[EVENTS.wheel] = function(event) {
- that._cancelFocus();
- if (!that._isWheelEnabled)
- return;
- var data = $(event.target).data(DATA_KEY);
- if (data) {
- event.preventDefault();
- event.stopPropagation();
- that._wheelZoom(event, data)
- }
- };
- that._wheelLock = {dir: 0}
- },
- _createProjectionHandlers: function(projection) {
- var that = this;
- projection.on({
- center: handler,
- zoom: handler
- });
- function handler() {
- that._cancelFocus()
- }
- },
- reset: function() {
- var that = this;
- that._clickState = null;
- that._endDrag();
- that._cancelHover();
- that._cancelFocus();
- return that
- },
- setCallbacks: function(callbacks) {
- $.extend(this._callbacks, callbacks);
- return this
- },
- setOptions: function(options) {
- var that = this;
- that.reset();
- that._detachHandlers();
- that._isTouchEnabled = !!_parseScalar(options.touchEnabled, true);
- that._isWheelEnabled = !!_parseScalar(options.wheelEnabled, true);
- that._attachHandlers();
- return that
- },
- _detachHandlers: function() {
- var that = this;
- if (that._isTouchEnabled)
- that._root.css({
- "touch-action": "",
- "-ms-touch-action": "",
- "-webkit-user-select": ""
- }).off(_addNamespace("MSHoldVisual", _NAME)).off(_addNamespace("contextmenu", _NAME));
- $(document).off(that._docHandlers);
- that._root.off(that._rootHandlers)
- },
- _attachHandlers: function() {
- var that = this;
- if (that._isTouchEnabled)
- that._root.css({
- "touch-action": "none",
- "-ms-touch-action": "none",
- "-webkit-user-select": "none"
- }).on(_addNamespace("MSHoldVisual", _NAME), function(event) {
- event.preventDefault()
- }).on(_addNamespace("contextmenu", _NAME), function(event) {
- isTouchEvent(event) && event.preventDefault()
- });
- $(document).on(that._docHandlers);
- that._root.on(that._rootHandlers)
- }
- };
- var Focus = function(callbacks) {
- var that = this,
- _activeData = null,
- _data = null,
- _disabled = false,
- _onTimer = null,
- _offTimer = null,
- _x,
- _y;
- that.dispose = function() {
- clearTimeout(_onTimer);
- clearTimeout(_offTimer);
- that.turnOn = that.turnOff = that.cancel = that.cancelOn = that.dispose = that = callbacks = _activeData = _data = _onTimer = _offTimer = null
- };
- that.turnOn = function(data, coords, timeout, forceTimeout) {
- if (data === _data && _disabled)
- return;
- _disabled = false;
- _data = data;
- if (_activeData) {
- _x = coords.x;
- _y = coords.y;
- clearTimeout(_onTimer);
- _onTimer = setTimeout(function() {
- _onTimer = null;
- if (_data === _activeData) {
- callbacks[EVENT_FOCUS_MOVE]({
- data: _data,
- x: _x,
- y: _y
- });
- onCheck(true)
- }
- else
- callbacks[EVENT_FOCUS_ON]({
- data: _data,
- x: _x,
- y: _y
- }, onCheck)
- }, forceTimeout ? timeout : 0)
- }
- else if (!_onTimer || _abs(coords.x - _x) > FOCUS_COORD_THRESHOLD_MOUSE || _abs(coords.y - _y) > FOCUS_COORD_THRESHOLD_MOUSE || forceTimeout) {
- _x = coords.x;
- _y = coords.y;
- clearTimeout(_onTimer);
- _onTimer = setTimeout(function() {
- _onTimer = null;
- callbacks[EVENT_FOCUS_ON]({
- data: _data,
- x: _x,
- y: _y
- }, onCheck)
- }, timeout)
- }
- function onCheck(result) {
- _disabled = !result;
- if (result) {
- _activeData = _data;
- clearTimeout(_offTimer);
- _offTimer = null
- }
- }
- };
- that.turnOff = function(timeout) {
- clearTimeout(_onTimer);
- _onTimer = null;
- _data = null;
- if (_activeData && !_disabled)
- _offTimer = _offTimer || setTimeout(function() {
- _offTimer = null;
- callbacks[EVENT_FOCUS_OFF]({data: _activeData});
- _activeData = null
- }, timeout)
- };
- that.cancel = function() {
- clearTimeout(_onTimer);
- clearTimeout(_offTimer);
- if (_activeData)
- callbacks[EVENT_FOCUS_OFF]({data: _activeData});
- _activeData = _data = _onTimer = _offTimer = null
- };
- that.cancelOn = function() {
- clearTimeout(_onTimer);
- _onTimer = null
- }
- };
- DX.viz.map._tests.Tracker = Tracker;
- DX.viz.map._tests._DEBUG_forceEventMode = function(mode) {
- setupEvents(mode)
- };
- DX.viz.map._tests.Focus = Focus;
- DX.viz.map._tests._DEBUG_stubFocusType = function(focusType) {
- Focus = focusType
- };
- DX.viz.map._tests._DEBUG_restoreFocusType = function() {
- Focus = DX.viz.map._tests.Focus
- };
- DX.viz.map.dxVectorMap.prototype._factory.createTracker = function(parameters) {
- return new Tracker(parameters)
- };
- function getDistance(x1, y1, x2, y2) {
- return _sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
- }
- function isTouchEvent(event) {
- var type = event.originalEvent.type,
- pointerType = event.originalEvent.pointerType;
- return /^touch/.test(type) || /^MSPointer/.test(type) && pointerType !== 4 || /^pointer/.test(type) && pointerType !== "mouse"
- }
- function selectItem(flags, items) {
- var i = 0,
- ii = flags.length,
- item;
- for (; i < ii; ++i)
- if (flags[i]) {
- item = items[i];
- break
- }
- return _addNamespace(item || items[i], _NAME)
- }
- function setupEvents() {
- var flags = [navigator.pointerEnabled, navigator.msPointerEnabled, "ontouchstart" in window];
- if (arguments.length)
- flags = [arguments[0] === "pointer", arguments[0] === "MSPointer", arguments[0] === "touch"];
- EVENTS = {
- start: selectItem(flags, ["pointerdown", "MSPointerDown", "touchstart mousedown", "mousedown"]),
- move: selectItem(flags, ["pointermove", "MSPointerMove", "touchmove mousemove", "mousemove"]),
- end: selectItem(flags, ["pointerup", "MSPointerUp", "touchend mouseup", "mouseup"]),
- wheel: selectItem([], ["mousewheel DOMMouseScroll"])
- }
- }
- function getEventCoords(event) {
- var originalEvent = event.originalEvent,
- touch = originalEvent.touches && originalEvent.touches[0] || {};
- return {
- x: touch.pageX || originalEvent.pageX || event.pageX,
- y: touch.pageY || originalEvent.pageY || event.pageY
- }
- }
- function getPointerId(event) {
- return event.originalEvent.pointerId
- }
- function getMultitouchEventCoords(event, pointerId) {
- var originalEvent = event.originalEvent;
- if (originalEvent.pointerId !== undefined)
- originalEvent = originalEvent.pointerId === pointerId ? originalEvent : null;
- else
- originalEvent = originalEvent.touches[pointerId];
- return originalEvent ? {
- x: originalEvent.pageX || event.pageX,
- y: originalEvent.pageY || event.pageY
- } : null
- }
- function adjustWheelDelta(delta, lock) {
- if (delta === 0)
- return 0;
- var _delta = _abs(delta),
- sign = _round(delta / _delta);
- if (lock.dir && sign !== lock.dir)
- return 0;
- lock.dir = sign;
- if (_delta < 0.1)
- _delta = 0;
- else if (_delta < 1)
- _delta = 1;
- else if (_delta > 4)
- _delta = 4;
- else
- _delta = _round(_delta);
- return sign * _delta
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file themeManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _extend = $.extend,
- _each = $.each;
- var ThemeManager = DX.viz.core.BaseThemeManager.inherit({
- _themeSection: "map",
- _fontFields: ["areaSettings.label.font", "markerSettings.label.font", "tooltip.font", "legend.font", "loadingIndicator.font"],
- getCommonAreaSettings: function(options) {
- var settings = _extend(true, {}, this._theme.areaSettings, options),
- palette,
- i,
- colors;
- if (settings.paletteSize > 0) {
- palette = new DX.viz.core.GradientPalette(settings.palette, settings.paletteSize);
- for (i = 0, colors = []; i < settings.paletteSize; ++i)
- colors.push(palette.getColor(i));
- settings._colors = colors
- }
- return settings
- },
- getAreaSettings: function(commonSettings, options) {
- var settings = _extend(true, {}, commonSettings, options);
- settings.borderWidth = _Number(settings.borderWidth) || 0;
- settings.borderColor = settings.borderColor || null;
- if (options.color === undefined && options.paletteIndex >= 0)
- settings.color = commonSettings._colors[options.paletteIndex];
- settings.color = settings.color || null;
- settings.hoveredBorderWidth = _Number(settings.hoveredBorderWidth) || settings.borderWidth;
- settings.hoveredBorderColor = settings.hoveredBorderColor || settings.borderColor;
- settings.hoveredColor = settings.hoveredColor || settings.color;
- settings.selectedBorderWidth = _Number(settings.selectedBorderWidth) || settings.borderWidth;
- settings.selectedBorderColor = settings.selectedBorderColor || settings.borderColor;
- settings.selectedColor = settings.selectedColor || settings.color;
- return settings
- },
- getCommonMarkerSettings: function(options) {
- options && !options.label && options.font && (options.label = {font: options.font}) && (options.font = undefined);
- var theme = _extend({}, this._theme.markerSettings),
- _options = _extend({}, options),
- themeParts = {},
- optionsParts = {},
- settings;
- _each(theme, function(name, themePart) {
- if (name[0] === "_") {
- themeParts[name] = themePart;
- optionsParts[name] = _options[name];
- theme[name] = _options[name] = undefined
- }
- });
- settings = _extend(true, {}, theme, _options);
- _each(themeParts, function(name, themePart) {
- settings[name] = _extend(true, {}, theme, themePart, _options, optionsParts[name])
- });
- return settings
- },
- getMarkerSettings: function(commonSettings, options, type) {
- var settings = _extend(true, {}, commonSettings["_" + type], options);
- settings.borderWidth = _Number(settings.borderWidth) || 0;
- settings.borderColor = settings.borderColor || null;
- settings.color = settings.color || null;
- settings.opacity = settings.opacity || null;
- settings.hoveredBorderWidth = _Number(settings.hoveredBorderWidth) || settings.borderWidth;
- settings.hoveredBorderColor = settings.hoveredBorderColor || settings.borderColor;
- settings.hoveredColor = settings.hoveredColor || settings.color;
- settings.hoveredOpacity = settings.hoveredOpacity || settings.opacity;
- settings.selectedBorderWidth = _Number(settings.selectedBorderWidth) || settings.borderWidth;
- settings.selectedBorderColor = settings.selectedBorderColor || settings.borderColor;
- settings.selectedColor = settings.selectedColor || settings.color;
- settings.selectedOpacity = settings.selectedOpacity || settings.opacity;
- return settings
- },
- getPieColors: function(commonSettings, count) {
- var colors = commonSettings._pie._colors || [],
- palette,
- i,
- _count = count > 8 ? count : 8;
- if (colors.length < _count) {
- palette = new DX.viz.core.Palette(commonSettings._pie.palette, {
- stepHighlight: 50,
- theme: this.themeName()
- });
- for (i = 0, colors = []; i < _count; ++i)
- colors.push(palette.getNextColor());
- commonSettings._pie._colors = colors
- }
- return colors
- }
- });
- DX.viz.map._tests.ThemeManager = ThemeManager;
- DX.viz.map.dxVectorMap.prototype._factory.createThemeManager = function() {
- return new ThemeManager
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file legend.js */
- (function(DX, $, undefined) {
- var _String = String,
- _isArray = DX.utils.isArray,
- _extend = $.extend,
- _each = $.each,
- _BaseLegend = DX.viz.core.Legend;
- function Legend(parameters) {
- var that = this;
- that._params = parameters;
- that._root = parameters.renderer.g().attr({"class": "dxm-legend"});
- parameters.layoutControl.addItem(that);
- _BaseLegend.apply(that, [{
- renderer: parameters.renderer,
- group: that._root,
- backgroundClass: null,
- itemsGroupClass: null,
- textField: "text",
- getFormatObject: function(data) {
- return data
- }
- }]);
- that._onDataChanged = function(items) {
- var itemsForUpdate = $.map(items, function(item) {
- return _extend(true, {states: {normal: {fill: item.color}}}, item)
- });
- that.update(itemsForUpdate, that._options);
- that._refresh()
- }
- }
- var legendPrototype = Legend.prototype = DX.utils.clone(_BaseLegend.prototype);
- legendPrototype.constructor = Legend;
- legendPrototype.dispose = function() {
- var that = this;
- that._params.layoutControl.removeItem(that);
- that._unbindData();
- that._params = that._root = that._onDataChanged = null;
- return _BaseLegend.prototype.dispose.apply(that, arguments)
- };
- legendPrototype.clean = function() {
- this._rendered = false;
- this._root.remove();
- return this
- };
- legendPrototype.render = function() {
- var that = this;
- that._root.append(that._params.container);
- that._rendered = true;
- that._refresh();
- return that
- };
- legendPrototype.resize = function(size) {
- if (size === null)
- this.erase();
- else
- this.setSize(size).draw();
- return this
- };
- legendPrototype.locate = _BaseLegend.prototype.shift;
- legendPrototype._unbindData = function() {
- if (this._dataCategory)
- this._params.dataExchanger.unbind(this._dataCategory, this._dataName)
- };
- legendPrototype._bindData = function(info) {
- this._params.dataExchanger.bind(this._dataCategory = info.category, this._dataName = info.name, this._onDataChanged)
- };
- var sourceMap = {
- areacolorgroups: {
- category: "areas",
- name: "color"
- },
- markercolorgroups: {
- category: "markers",
- name: "color"
- },
- markersizegroups: {
- category: "markers",
- name: "size"
- }
- };
- var unknownSource = {
- category: "UNKNOWN",
- name: "UNKNOWN"
- };
- legendPrototype.setOptions = function(options) {
- var that = this;
- that.update(that._data, options);
- that._unbindData();
- that._bindData(sourceMap[_String(options.source).toLowerCase()] || unknownSource);
- that._refresh();
- return that
- };
- legendPrototype._refresh = function() {
- if (this._rendered)
- this.updateLayout()
- };
- function LegendsControl(parameters) {
- this._parameters = parameters;
- this._items = []
- }
- LegendsControl.prototype = {
- constructor: LegendsControl,
- dispose: function() {
- _each(this._items, function(_, item) {
- item.dispose()
- });
- this._parameters = this._items = null;
- return this
- },
- setOptions: function(options, theme) {
- var optionList = _isArray(options) ? options : [],
- i = 0,
- ii = optionList.length,
- item,
- newItems = [],
- items = this._items;
- for (; i < ii; ++i) {
- item = (items[i] || new Legend(this._parameters)).setOptions(_extend(true, {}, theme, optionList[i]));
- newItems.push(item)
- }
- for (ii = items.length; i < ii; ++i)
- items[i].clean().dispose();
- this._items = newItems
- },
- clean: function() {
- _each(this._items, function(_, item) {
- item.clean()
- });
- return this
- },
- render: function() {
- _each(this._items, function(_, item) {
- item.render()
- });
- return this
- }
- };
- DX.viz.map.dxVectorMap.prototype._factory.createLegendsControl = function(parameters) {
- return new LegendsControl(parameters)
- };
- DX.viz.map._tests.Legend = Legend;
- DX.viz.map._tests.LegendsControl = LegendsControl;
- DX.viz.map._tests.stubLegendType = function(stub) {
- Legend = stub
- };
- DX.viz.map._tests.restoreLegendType = function() {
- Legend = DX.viz.map._tests.Legend
- };
- DX.viz.map._tests.extendLegendSourceMap = function(name, value) {
- sourceMap[name] = value
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file layout.js */
- (function(DX, $, undefined) {
- var _round = Math.round,
- _min = Math.min,
- _max = Math.max,
- _each = $.each,
- _inArray = $.inArray,
- horizontalAlignmentMap = {
- left: 0,
- center: 1,
- right: 2
- },
- verticalAlignmentMap = {
- top: 0,
- bottom: 1
- };
- function getCellIndex(options) {
- return verticalAlignmentMap[options.verticalAlignment] * 3 + horizontalAlignmentMap[options.horizontalAlignment]
- }
- function createCells(canvas, items) {
- var hstep = (canvas.right - canvas.left) / 3,
- vstep = (canvas.bottom - canvas.top) / 2,
- h1 = canvas.left,
- h2 = _round(h1 + hstep),
- h3 = _round(h1 + hstep + hstep),
- h4 = canvas.right,
- v1 = canvas.top,
- v2 = _round(v1 + vstep),
- v3 = canvas.bottom,
- cells = [{rect: [h1, v1, h2, v2]}, {
- rect: [h2, v1, h3, v2],
- center: true
- }, {
- rect: [h3, v1, h4, v2],
- horInv: true
- }, {
- rect: [h1, v2, h2, v3],
- verInv: true
- }, {
- rect: [h2, v2, h3, v3],
- center: true,
- verInv: true
- }, {
- rect: [h3, v2, h4, v3],
- horInv: true,
- verInv: true
- }],
- itemsList = [[], [], [], [], [], []];
- _each(items, function(_, item) {
- var options = item.getLayoutOptions();
- if (options)
- itemsList[getCellIndex(options)].push({
- item: item,
- width: options.width,
- height: options.height
- })
- });
- _each(cells, function(i, cell) {
- if (itemsList[i].length)
- cell.items = itemsList[i];
- else {
- if (cell.center)
- cell.rect[0] = cell.rect[2] = (cell.rect[0] + cell.rect[2]) / 2;
- else
- cell.rect[cell.horInv ? 0 : 2] = cell.rect[cell.horInv ? 2 : 0];
- cell.rect[cell.verInv ? 1 : 3] = cell.rect[cell.verInv ? 3 : 1]
- }
- });
- return cells
- }
- function adjustCellSizes(cells) {
- _each([0, 1, 2, 3, 4, 5], function(_, index) {
- var cell = cells[index],
- otherCell = cells[(index + 3) % 6];
- if (cell.items)
- if (!otherCell.items) {
- cell.rect[1] = _min(cell.rect[1], otherCell.rect[3]);
- cell.rect[3] = _max(cell.rect[3], otherCell.rect[1])
- }
- });
- _each([1, 4], function(_, index) {
- var cell = cells[index],
- otherCell1 = cells[index - 1],
- otherCell2 = cells[index + 1],
- size1,
- size2;
- if (cell.items) {
- if (!otherCell1.items && !otherCell2.items) {
- size1 = cell.rect[0] - otherCell1.rect[2];
- size2 = otherCell2.rect[0] - cell.rect[2];
- if (size1 > size2)
- if (size1 / size2 >= 2) {
- cell.rect[0] -= size1;
- cell.right = true
- }
- else {
- cell.rect[0] -= size2;
- cell.rect[2] += size2
- }
- else if (size2 / size1 >= 2) {
- cell.rect[2] += size2;
- cell.center = null
- }
- else {
- cell.rect[0] -= size1;
- cell.rect[2] += size1
- }
- }
- }
- else {
- if (otherCell1.items)
- otherCell1.rect[2] = (cell.rect[0] + cell.rect[2]) / 2;
- if (otherCell2.items)
- otherCell2.rect[0] = (cell.rect[0] + cell.rect[2]) / 2
- }
- })
- }
- function adjustCellsAndApplyLayout(cells, forceMode) {
- var hasHiddenItems = false;
- adjustCellSizes(cells);
- _each(cells, function(_, cell) {
- if (cell.items)
- hasHiddenItems = applyCellLayout(cell, forceMode) || hasHiddenItems
- });
- return hasHiddenItems
- }
- function applyCellLayout(cell, forceMode) {
- var cellRect = cell.rect,
- cellWidth = cellRect[2] - cellRect[0],
- cellHeight = cellRect[3] - cellRect[1],
- xoffset = 0,
- yoffset = 0,
- currentHeight = 0,
- totalL = cellRect[2],
- totalT = cellRect[3],
- totalR = cellRect[0],
- totalB = cellRect[1],
- moves = [],
- hasHiddenItems = false;
- _each(cell.items, function(_, item) {
- if (item.width > cellWidth || item.height > cellHeight) {
- moves.push(null);
- hasHiddenItems = true;
- return forceMode || false
- }
- if (xoffset + item.width > cellWidth) {
- yoffset += currentHeight;
- xoffset = currentHeight = 0
- }
- if (yoffset + item.height > cellHeight) {
- moves.push(null);
- hasHiddenItems = true;
- return forceMode || false
- }
- currentHeight = _max(currentHeight, item.height);
- var dx = cell.horInv ? cellRect[2] - item.width - xoffset : cellRect[0] + xoffset,
- dy = cell.verInv ? cellRect[3] - item.height - yoffset : cellRect[1] + yoffset;
- xoffset += item.width;
- totalL = _min(totalL, dx);
- totalT = _min(totalT, dy);
- totalR = _max(totalR, dx + item.width);
- totalB = _max(totalB, dy + item.height);
- moves.push([dx, dy])
- });
- if (forceMode || !hasHiddenItems) {
- xoffset = 0;
- if (cell.right)
- xoffset = cellRect[2] - cellRect[0] - totalR + totalL;
- else if (cell.center)
- xoffset = _round((cellRect[2] - cellRect[0] - totalR + totalL) / 2);
- _each(cell.items, function(i, item) {
- var move = moves[i];
- if (move)
- item.item.locate(move[0] + xoffset, move[1]);
- else
- item.item.resize(null)
- });
- cell.rect = [totalL, totalT, totalR, totalB];
- cell.items = null
- }
- return hasHiddenItems
- }
- function applyLayout(canvas, items) {
- var cells = createCells(canvas, items);
- if (adjustCellsAndApplyLayout(cells))
- adjustCellsAndApplyLayout(cells, true)
- }
- function LayoutControl() {
- var that = this;
- that._items = [];
- that._suspended = true;
- that._updateLayout = function() {
- that._update()
- }
- }
- LayoutControl.prototype = {
- constructor: LayoutControl,
- dispose: function() {
- this._items = this._updateLayout = null;
- return this
- },
- setSize: function(width, height) {
- this._size = {
- width: width,
- height: height
- };
- this._update();
- return this
- },
- stop: function() {
- this._suspended = true;
- return this
- },
- start: function() {
- this._suspended = null;
- this._update();
- return this
- },
- addItem: function(item) {
- this._items.push(item);
- item.updateLayout = this._updateLayout;
- return this
- },
- removeItem: function(item) {
- this._items.splice(_inArray(item, this._items), 1);
- item.updateLayout = null;
- return this
- },
- _update: function() {
- if (this._suspended)
- return;
- var size = this._size;
- _each(this._items, function(_, item) {
- item.resize(size)
- });
- applyLayout({
- left: 0,
- top: 0,
- right: size.width,
- bottom: size.height
- }, this._items)
- }
- };
- DX.viz.map.dxVectorMap.prototype._factory.createLayoutControl = function() {
- return new LayoutControl
- };
- DX.viz.map._tests.LayoutControl = LayoutControl
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file mapItemsManager.js */
- (function(DX, $, undefined) {
- var _isFinite = isFinite,
- _utils = DX.utils,
- _coreUtils = DX.viz.core.utils,
- _isString = _utils.isString,
- _isArray = _utils.isArray,
- _isFunction = _utils.isFunction,
- _patchFontOptions = _coreUtils.patchFontOptions,
- _parseScalar = _coreUtils.parseScalar,
- _extend = $.extend,
- _each = $.each,
- _map = $.map;
- var SELECTIONS = {
- none: null,
- single: -1,
- multiple: NaN
- };
- function getSelection(selectionMode) {
- var selection = String(selectionMode).toLowerCase();
- selection = selection in SELECTIONS ? SELECTIONS[selection] : SELECTIONS.single;
- if (selection !== null)
- selection = {
- state: {},
- single: selection || null
- };
- return selection
- }
- function createEventTriggers(context, trigger, names) {
- context.raiseHoverChanged = function(handle, state) {
- trigger(names.hoverChanged, {
- target: handle.proxy,
- state: state
- })
- };
- context.raiseSelectionChanged = function(handle) {
- trigger(names.selectionChanged, {target: handle.proxy})
- }
- }
- var MapItemsManager = DX.Class.inherit({
- _rootClass: null,
- ctor: function(parameters) {
- var that = this;
- that._params = parameters;
- that._init();
- parameters.projection.on({
- project: function() {
- that._reproject()
- },
- transform: function(transform) {
- that._transform(transform);
- that._relocate()
- },
- center: function(_, transform) {
- that._transform(transform)
- },
- zoom: function(_, transform) {
- that._transform(transform);
- that._relocate()
- }
- })
- },
- _init: function() {
- var that = this;
- that._context = {
- renderer: that._params.renderer,
- projection: that._params.projection,
- dataKey: that._params.dataKey,
- selection: null,
- getItemSettings: that._createItemSettingsBuilder()
- };
- that._initRoot();
- createEventTriggers(that._context, that._params.eventTrigger, that._eventNames)
- },
- _createItemSettingsBuilder: function() {
- var that = this;
- return function(proxy, settings) {
- var result = {};
- _each(that._grouping, function(settingField, grouping) {
- var value,
- index;
- if (_isFinite(value = grouping.callback(proxy)) && (index = findGroupPosition(value, grouping.groups)) >= 0)
- result[settingField] = grouping.groups[index][settingField]
- });
- return that._getItemSettings(proxy, _extend({}, settings, result))
- }
- },
- _initRoot: function() {
- this._context.root = this._root = this._params.renderer.g().attr({"class": this._rootClass})
- },
- dispose: function() {
- var that = this;
- that._destroyHandles();
- that._params = that._context = that._grouping = null;
- that._disposeRoot();
- return that
- },
- _disposeRoot: function() {
- this._root = null
- },
- clean: function() {
- var that = this;
- that._destroyItems();
- that._removeRoot();
- that._rendered = false;
- return that
- },
- _removeRoot: function() {
- this._root.remove()
- },
- setOptions: function(options) {
- var that = this;
- that._processOptions(options || {});
- that._params.notifyDirty();
- that._destroyItems();
- that._createItems(that._params.notifyReady);
- return that
- },
- render: function() {
- var that = this;
- that._rendered = true;
- that._params.notifyDirty();
- that._appendRoot();
- that._createItems(that._params.notifyReady, true);
- return that
- },
- _processOptions: function(options) {
- var that = this,
- settings = that._commonSettings = that._getCommonSettings(options),
- context = that._context;
- that._customizeCallback = _isFunction(settings.customize) ? settings.customize : $.noop;
- context.hover = !!_parseScalar(settings.hoverEnabled, true);
- if (context.selection)
- _each(context.selection.state, function(_, handle) {
- handle && handle.resetSelected()
- });
- context.selection = getSelection(settings.selectionMode);
- that._grouping = {};
- that._updateGrouping()
- },
- _appendRoot: function() {
- this._root.append(this._params.container)
- },
- _destroyItems: function() {
- var that = this;
- that._clearRoot();
- clearTimeout(that._labelsTimeout);
- that._rendered && that._handles && _each(that._handles, function(_, handle) {
- if (handle.item) {
- handle.item.dispose();
- handle.item = null
- }
- })
- },
- _clearRoot: function() {
- this._root.clear()
- },
- _destroyHandles: function() {
- this._handles && _each(this._handles, function(_, handle) {
- handle.dispose()
- });
- this._handles = null
- },
- _createHandles: function(source) {
- var that = this;
- if (_isArray(source))
- that._handles = _map(source, function(dataItem, i) {
- dataItem = dataItem || {};
- var handle = new MapItemHandle(that._context, that._getItemCoordinates(dataItem), that._getItemAttributes(dataItem), i, that._itemType),
- proxy = handle.proxy;
- that._initProxy(proxy, dataItem);
- handle.settings = that._customizeCallback.call(proxy, proxy) || {};
- if (handle.settings.isSelected)
- proxy.selected(true);
- return handle
- })
- },
- _createItems: function(notifyReady) {
- var that = this,
- selectedItems = [],
- immediateReady = true;
- if (that._rendered && that._handles) {
- _each(that._handles, function(_, handle) {
- handle.item = that._createItem(handle.proxy).init(that._context, handle.proxy).project().update(handle.settings).locate();
- if (handle.proxy.selected())
- selectedItems.push(handle.item)
- });
- _each(selectedItems, function(_, item) {
- item.setSelectedState()
- });
- that._arrangeItems();
- if (that._commonSettings.label.enabled) {
- immediateReady = false;
- clearTimeout(that._labelsTimeout);
- that._labelsTimeout = setTimeout(function() {
- _each(that._handles, function(_, handle) {
- handle.item.createLabel()
- });
- notifyReady()
- })
- }
- }
- immediateReady && notifyReady()
- },
- _processSource: null,
- setData: function(data) {
- var that = this;
- that._params.notifyDirty();
- if (_isString(data))
- $.getJSON(data).done(updateSource).fail(function() {
- updateSource(null)
- });
- else
- updateSource(data);
- return that;
- function updateSource(source) {
- if (that._rendered)
- that._params.tracker.reset();
- that._destroyItems();
- that._destroyHandles();
- that._createHandles(that._processSource(source));
- that._createItems(that._params.notifyReady)
- }
- },
- _transform: function(transform) {
- this._root.attr(transform)
- },
- _reproject: function() {
- this._rendered && this._handles && _each(this._handles, function(_, handle) {
- handle.item.project().locate()
- })
- },
- _relocate: function() {
- this._rendered && this._handles && _each(this._handles, function(_, handle) {
- handle.item.locate()
- })
- },
- hoverItem: function(index, state) {
- this._handles[index].setHovered(state);
- return this
- },
- selectItem: function(index, state, noCallback) {
- this._handles[index].setSelected(state, noCallback);
- return this
- },
- clearSelection: function() {
- var selection = this._context.selection;
- if (selection)
- _each(selection.state, function(_, handle) {
- handle && handle.setSelected(false)
- });
- return this
- },
- raiseClick: function(index, $event) {
- this._params.eventTrigger(this._eventNames.click, {
- target: this._handles[index].proxy,
- jQueryEvent: $event
- });
- return this
- },
- getProxyItems: function() {
- return _map(this._handles, function(handle) {
- return handle.proxy
- })
- },
- getProxyItem: function(index) {
- return this._handles[index].proxy
- },
- _performGrouping: function(partition, settingField, valueCallback, valuesCallback) {
- var groups = createGroups(partition),
- values;
- if (groups) {
- values = valuesCallback(groups.length);
- _each(groups, function(i, group) {
- group.index = i;
- group[settingField] = values[i]
- });
- this._grouping[settingField] = {
- callback: valueCallback,
- groups: groups
- }
- }
- else {
- delete this._grouping[settingField];
- groups = []
- }
- this._params.dataExchanger.set(this._dataCategory, settingField, groups)
- },
- _groupByColor: function(colorGroups, palette, valueCallback) {
- this._performGrouping(colorGroups, "color", valueCallback, function(count) {
- var _palette = new DX.viz.core.GradientPalette(palette, count),
- i = 0,
- list = [];
- for (; i < count; ++i)
- list.push(_palette.getColor(i));
- return list
- })
- }
- });
- MapItemsManager.prototype.TEST_getContext = function() {
- return this._context
- };
- MapItemsManager.prototype.TEST_performGrouping = MapItemsManager.prototype._performGrouping;
- MapItemsManager.prototype.TEST_groupByColor = MapItemsManager.prototype._groupByColor;
- DX.viz.map._internal.mapItemBehavior = {
- init: function(ctx, proxy) {
- var that = this;
- that._ctx = ctx;
- that._data = {
- index: proxy.index,
- type: proxy.type
- };
- that._proxy = proxy;
- that._root = that._createRoot().append(that._ctx.root);
- return that
- },
- dispose: function() {
- disposeItem(this);
- return this
- },
- project: function() {
- var that = this;
- that._coords = that._project(that._ctx.projection, that._proxy.coordinates());
- return this
- },
- locate: function() {
- var that = this;
- that._locate(that._transform(that._ctx.projection, that._coords));
- that._label && that._label.value && that._locateLabel();
- return that
- },
- update: function(settings) {
- var that = this;
- that._settings = that._ctx.getItemSettings(that._proxy, settings);
- that._update(that._settings);
- that._label && that._updateLabel();
- return that
- },
- createLabel: function() {
- var that = this;
- that._label = {
- root: that._createLabelRoot(),
- text: that._ctx.renderer.text(),
- tracker: that._ctx.renderer.rect().attr({
- stroke: "none",
- "stroke-width": 0,
- fill: "#000000",
- opacity: 0.0001
- }).data(that._ctx.dataKey, that._data)
- };
- that._updateLabel();
- return that
- },
- _updateLabel: function() {
- var that = this,
- settings = that._settings.label;
- that._label.value = String(this._proxy.text || this._proxy.attribute(this._settings.label.dataField) || "");
- if (that._label.value) {
- that._label.text.attr({
- text: that._label.value,
- x: 0,
- y: 0
- }).css(_patchFontOptions(settings.font)).attr({
- align: "center",
- stroke: settings.stroke,
- "stroke-width": settings["stroke-width"],
- "stroke-opacity": settings["stroke-opacity"]
- }).append(that._label.root);
- that._label.tracker.append(that._label.root);
- that._adjustLabel();
- that._locateLabel()
- }
- }
- };
- var MapItemHandle = function(context, coordinates, attributes, index, type) {
- var handle = this;
- handle._ctx = context;
- handle._idx = index;
- handle._hovered = handle._selected = false;
- attributes = _extend({}, attributes);
- handle.proxy = {
- index: index,
- type: type,
- coordinates: function() {
- return coordinates
- },
- attribute: function(name, value) {
- if (arguments.length > 1) {
- attributes[name] = value;
- return this
- }
- else
- return arguments.length > 0 ? attributes[name] : attributes
- },
- selected: function(state, _noEvent) {
- if (arguments.length > 0) {
- handle.setSelected(!!state, _noEvent);
- return this
- }
- else
- return handle._selected
- },
- applySettings: function(settings) {
- _extend(true, handle.settings, settings);
- handle.item && handle.item.update(handle.settings);
- return this
- }
- }
- };
- MapItemHandle.prototype = {
- constructor: MapItemHandle,
- dispose: function() {
- disposeItem(this.proxy);
- disposeItem(this);
- return this
- },
- setHovered: function(state) {
- state = !!state;
- var that = this;
- if (that._ctx.hover && that._hovered !== state) {
- that._hovered = state;
- if (that.item) {
- if (that._hovered)
- that.item.onHover();
- if (!that._selected) {
- that.item[that._hovered ? "setHoveredState" : "setDefaultState"]();
- that._ctx.raiseHoverChanged(that, that._hovered)
- }
- }
- }
- return that
- },
- resetSelected: function() {
- this._selected = false;
- return this
- },
- setSelected: function(state, _noEvent) {
- state = !!state;
- var that = this,
- context = that._ctx,
- selection = that._ctx.selection,
- tmp;
- if (selection && that._selected !== state) {
- that._selected = state;
- tmp = selection.state[selection.single];
- selection.state[selection.single] = null;
- if (tmp)
- tmp.setSelected(false);
- selection.state[selection.single || that._idx] = state ? that : null;
- if (that.item) {
- that.item[state ? "setSelectedState" : that._hovered ? "setHoveredState" : "setDefaultState"]();
- if (!_noEvent)
- context.raiseSelectionChanged(that)
- }
- }
- return that
- }
- };
- function disposeItem(item) {
- _each(item, function(name) {
- item[name] = null
- })
- }
- function createGroups(partition) {
- var i,
- ii,
- groups = null;
- if (_isArray(partition) && partition.length > 1) {
- groups = [];
- for (i = 0, ii = partition.length - 1; i < ii; ++i)
- groups.push({
- start: Number(partition[i]),
- end: Number(partition[i + 1])
- })
- }
- return groups
- }
- function findGroupPosition(value, groups) {
- var i = 0,
- ii = groups.length;
- for (; i < ii; ++i)
- if (groups[i].start <= value && value <= groups[i].end)
- return i;
- return -1
- }
- _extend(DX.viz.map._tests, {
- MapItemsManager: MapItemsManager,
- MapItemHandle: MapItemHandle,
- stubMapItemHandle: function(mapItemHandleType) {
- MapItemHandle = mapItemHandleType
- },
- restoreMapItemHandle: function() {
- MapItemHandle = DX.viz.map._tests.MapItemHandle
- }
- });
- DX.viz.map.dxVectorMap.prototype._factory.MapItemsManager = MapItemsManager
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file areasManager.js */
- (function(DX, $, undefined) {
- var _abs = Math.abs,
- _sqrt = Math.sqrt,
- _noop = $.noop,
- TOLERANCE = 1;
- var AreasManager = DX.viz.map.dxVectorMap.prototype._factory.MapItemsManager.inherit({
- _rootClass: "dxm-areas",
- _dataCategory: "areas",
- _eventNames: {
- click: "areaClick",
- hoverChanged: "areaHoverChanged",
- selectionChanged: "areaSelectionChanged"
- },
- _initRoot: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._context.labelRoot = that._labelRoot = that._params.renderer.g().attr({"class": "dxm-area-labels"})
- },
- _disposeRoot: function() {
- this.callBase.apply(this, arguments);
- this._labelRoot = null
- },
- _processSource: function(source) {
- var isGeoJson = source && source.type === "FeatureCollection";
- this._getItemCoordinates = isGeoJson ? getCoordinatesGeoJson : getCoordinatesDefault;
- this._getItemAttributes = isGeoJson ? getAttributesGeoJson : getAttributesDefault;
- return isGeoJson ? source.features : source
- },
- _getCommonSettings: function(options) {
- return this._params.themeManager.getCommonAreaSettings(options)
- },
- _initProxy: _noop,
- _itemType: "area",
- _removeRoot: function() {
- this.callBase.apply(this, arguments);
- this._labelRoot.remove()
- },
- _appendRoot: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- if (that._commonSettings.label.enabled)
- that._labelRoot.append(that._params.container)
- },
- _clearRoot: function() {
- this.callBase.apply(this, arguments);
- this._labelRoot.clear()
- },
- _getItemSettings: function(_, options) {
- return this._params.themeManager.getAreaSettings(this._commonSettings, options)
- },
- _transform: function(transform) {
- this.callBase.apply(this, arguments);
- this._labelRoot.attr(transform)
- },
- _createItem: function() {
- return new Area
- },
- _updateGrouping: function() {
- var commonSettings = this._commonSettings,
- attributeName = commonSettings.colorGroupingField;
- this._groupByColor(commonSettings.colorGroups, commonSettings.palette, function(proxy) {
- return proxy.attribute(attributeName)
- })
- },
- _arrangeItems: _noop
- });
- function getCoordinatesDefault(dataItem) {
- return dataItem.coordinates
- }
- function getCoordinatesGeoJson(dataItem) {
- var coordinates,
- type;
- if (dataItem.geometry) {
- type = dataItem.geometry.type;
- coordinates = dataItem.geometry.coordinates;
- if (coordinates && (type === "Polygon" || type === "MultiPolygon"))
- type === "MultiPolygon" && (coordinates = [].concat.apply([], coordinates));
- else
- coordinates = undefined
- }
- return coordinates
- }
- function getAttributesDefault(dataItem) {
- return dataItem.attributes
- }
- function getAttributesGeoJson(dataItem) {
- return dataItem.properties
- }
- function Area(){}
- $.extend(Area.prototype, DX.viz.map._internal.mapItemBehavior, {
- _project: function(projection, coords) {
- return projection.projectArea(coords)
- },
- _createRoot: function() {
- return this._ctx.renderer.path([], "area").data(this._ctx.dataKey, this._data)
- },
- _update: function(settings) {
- this._styles = {
- normal: {
- "class": "dxm-area",
- stroke: settings.borderColor,
- "stroke-width": settings.borderWidth,
- fill: settings.color
- },
- hovered: {
- "class": "dxm-area dxm-area-hovered",
- stroke: settings.hoveredBorderColor,
- "stroke-width": settings.hoveredBorderWidth,
- fill: settings.hoveredColor
- },
- selected: {
- "class": "dxm-area dxm-area-selected",
- stroke: settings.selectedBorderColor,
- "stroke-width": settings.selectedBorderWidth,
- fill: settings.selectedColor
- }
- };
- this._root.attr(this._styles.normal);
- return this
- },
- _transform: function(projection, coords) {
- return projection.getAreaCoordinates(coords)
- },
- _locate: function(coords) {
- this._root.attr({points: coords})
- },
- onHover: _noop,
- setDefaultState: function() {
- this._root.attr(this._styles.normal).toBackground()
- },
- setHoveredState: function() {
- this._root.attr(this._styles.hovered).toForeground()
- },
- setSelectedState: function() {
- this._root.attr(this._styles.selected).toForeground()
- },
- _createLabelRoot: function() {
- return this._ctx.renderer.g().attr({"class": "dxm-area-label"}).append(this._ctx.labelRoot)
- },
- _adjustLabel: function() {
- var that = this,
- centroid = calculateAreaCentroid(that._coords),
- bbox = that._label.text.getBBox(),
- offset = -bbox.y - bbox.height / 2;
- that._centroid = centroid.coords;
- that._areaSize = _sqrt(centroid.area);
- that._labelSize = [bbox.width, bbox.height];
- that._label.text.attr({y: offset});
- that._label.tracker.attr({
- x: bbox.x,
- y: bbox.y + offset,
- width: bbox.width,
- height: bbox.height
- })
- },
- _locateLabel: function() {
- var that = this,
- coords = that._ctx.projection.getPointCoordinates(that._centroid),
- size = that._ctx.projection.getSquareSize([that._areaSize, that._areaSize]);
- that._label.root.attr({
- translateX: coords.x,
- translateY: coords.y,
- visibility: that._labelSize[0] / size[0] < TOLERANCE && that._labelSize[1] / size[1] < TOLERANCE ? null : "hidden"
- })
- }
- });
- function calculatePolygonCentroid(coordinates) {
- var i = 0,
- ii = coordinates.length,
- v1,
- v2 = coordinates[ii - 1],
- cross,
- cx = 0,
- cy = 0,
- area = 0;
- for (; i < ii; ++i) {
- v1 = v2;
- v2 = coordinates[i];
- cross = v1[0] * v2[1] - v2[0] * v1[1];
- area += cross;
- cx += (v1[0] + v2[0]) * cross;
- cy += (v1[1] + v2[1]) * cross
- }
- area /= 2;
- cx /= 6 * area;
- cy /= 6 * area;
- return {
- coords: [cx, cy],
- area: _abs(area)
- }
- }
- function calculateAreaCentroid(coordinates) {
- var i = 0,
- ii = coordinates.length,
- centroid,
- resultCentroid,
- maxArea = 0;
- for (; i < ii; ++i) {
- centroid = calculatePolygonCentroid(coordinates[i]);
- if (centroid.area > maxArea) {
- maxArea = centroid.area;
- resultCentroid = centroid
- }
- }
- return resultCentroid
- }
- DX.viz.map._internal.AreasManager = AreasManager;
- DX.viz.map._internal.Area = Area;
- DX.viz.map._tests.AreasManager = AreasManager;
- DX.viz.map._tests.Area = Area;
- DX.viz.map.dxVectorMap.prototype._factory.createAreasManager = function(parameters) {
- return new AreasManager(parameters)
- }
- })(DevExpress, jQuery);
- /*! Module viz-vectormap, file markersManager.js */
- (function(DX, $, undefined) {
- var _Number = Number,
- _String = String,
- _isFinite = isFinite,
- _math = Math,
- _round = _math.round,
- _max = _math.max,
- _min = _math.min,
- _extend = $.extend,
- _each = $.each,
- _isArray = DX.utils.isArray,
- CLASS_DEFAULT = "dxm-marker",
- CLASS_HOVERED = "dxm-marker dxm-marker-hovered",
- CLASS_SELECTED = "dxm-marker dxm-marker-selected",
- DOT = "dot",
- BUBBLE = "bubble",
- PIE = "pie",
- IMAGE = "image",
- DEFAULT_MARKER_TYPE = null,
- MARKER_TYPES = {};
- var MarkersManager = DX.viz.map.dxVectorMap.prototype._factory.MapItemsManager.inherit({
- _rootClass: "dxm-markers",
- _dataCategory: "markers",
- _eventNames: {
- click: "markerClick",
- hoverChanged: "markerHoverChanged",
- selectionChanged: "markerSelectionChanged"
- },
- _init: function() {
- var that = this;
- that.callBase.apply(that, arguments);
- that._context.getPieColors = function(count) {
- return that._params.themeManager.getPieColors(that._commonSettings, count)
- };
- that._filter = that._params.renderer.shadowFilter("-40%", "-40%", "180%", "200%", 0, 1, 1, "#000000", 0.2)
- },
- _dispose: function() {
- this.callBase.apply(this, arguments);
- this._filter.dispose();
- this._filter = null
- },
- _getItemCoordinates: function(dataItem) {
- return dataItem.coordinates
- },
- _getItemAttributes: function(dataItem) {
- return dataItem.attributes
- },
- _processSource: function(source) {
- return source
- },
- _getCommonSettings: function(options) {
- return this._params.themeManager.getCommonMarkerSettings(options)
- },
- _processOptions: function(options) {
- var that = this;
- that._commonType = parseMarkerType(options && options.type, DEFAULT_MARKER_TYPE);
- that.callBase.apply(that, arguments);
- that._commonSettings._filter = that._filter.ref
- },
- _arrangeBubbles: function() {
- var markers = this._handles,
- bubbles = [],
- i,
- ii = markers.length,
- marker,
- values = [],
- minValue,
- maxValue,
- deltaValue;
- if (this._commonSettings._bubble.sizeGroups)
- return;
- for (i = 0; i < ii; ++i) {
- marker = markers[i];
- if (marker.item.type === BUBBLE) {
- bubbles.push(marker);
- if (_isFinite(marker.proxy.value))
- values.push(marker.proxy.value)
- }
- }
- minValue = _min.apply(null, values);
- maxValue = _max.apply(null, values);
- deltaValue = maxValue - minValue || 1;
- for (i = 0, ii = bubbles.length; i < ii; ++i) {
- marker = bubbles[i];
- marker.item.setSize(_isFinite(marker.proxy.value) ? (marker.proxy.value - minValue) / deltaValue : 0)
- }
- },
- _itemType: "marker",
- _initProxy: function(proxy, dataItem) {
- _each(dataItem, function(name, value) {
- if (proxy[name] === undefined)
- proxy[name] = value
- });
- proxy._TYPE = parseMarkerType(dataItem.type, null)
- },
- _getItemSettings: function(proxy, options) {
- var type = proxy._TYPE || this._commonType,
- settings = this._params.themeManager.getMarkerSettings(this._commonSettings, _extend({}, proxy.style, options), type);
- proxy.text = proxy.text || settings.text;
- return settings
- },
- _createItem: function(proxy) {
- return new MARKER_TYPES[proxy._TYPE || this._commonType]
- },
- _updateGrouping: function() {
- var that = this,
- markerType = that._commonType,
- colorDataField,
- sizeDataField,
- commonSettings = that._commonSettings["_" + markerType];
- if (markerType === DOT || markerType === BUBBLE) {
- colorDataField = commonSettings.colorGroupingField;
- that._groupByColor(commonSettings.colorGroups, commonSettings.palette, function(proxy) {
- return !proxy._TYPE || proxy._TYPE === markerType ? proxy.attribute(colorDataField) : NaN
- })
- }
- sizeDataField = commonSettings.sizeGroupingField;
- that._performGrouping(commonSettings.sizeGroups, "size", function(proxy) {
- return !proxy._TYPE || proxy._TYPE === markerType ? proxy.value || proxy.attribute(sizeDataField) : NaN
- }, function(count) {
- var minSize = commonSettings.minSize > 0 ? _Number(commonSettings.minSize) : 0,
- maxSize = commonSettings.maxSize >= minSize ? _Number(commonSettings.maxSize) : 0,
- i = 0,
- sizes = [];
- for (i = 0; i < count; ++i)
- sizes.push((minSize * (count - i - 1) + maxSize * i) / (count - 1));
- return sizes
- })
- },
- _updateLegendForPies: function() {
- var count = 0;
- _each(this._handles, function(_, handle) {
- var proxy = handle.proxy,
- values;
- if (!proxy._TYPE || proxy._TYPE === PIE) {
- values = proxy.values;
- if (values && values.length > count)
- count = values.length
- }
- });
- if (count > 0)
- this._params.dataExchanger.set(this._dataCategory, "color", $.map(this._context.getPieColors(count).slice(0, count), function(color, i) {
- return {
- index: i,
- color: color
- }
- }))
- },
- _arrangeItems: function() {
- this._arrangeBubbles();
- this._updateLegendForPies()
- }
- });
- var baseMarkerBehavior = _extend({}, DX.viz.map._internal.mapItemBehavior, {
- _project: function(projection, coords) {
- return projection.projectPoint(coords)
- },
- _createRoot: function() {
- return this._ctx.renderer.g()
- },
- _update: function(settings) {
- var that = this;
- that._root.attr({"class": CLASS_DEFAULT}).clear();
- that._create(settings, that._ctx.renderer, that._root);
- return that
- },
- _transform: function(projection, coords) {
- return projection.getPointCoordinates(coords)
- },
- _locate: function(coords) {
- this._root.attr({
- translateX: coords.x,
- translateY: coords.y
- })
- },
- onHover: function() {
- this._root.toForeground()
- },
- setDefaultState: function() {
- this._root.attr({"class": CLASS_DEFAULT}).toBackground();
- this._applyDefault()
- },
- setHoveredState: function() {
- this._root.attr({"class": CLASS_HOVERED});
- this._applyHovered()
- },
- setSelectedState: function() {
- this._root.attr({"class": CLASS_SELECTED}).toForeground();
- this._applySelected()
- },
- _createLabelRoot: function() {
- return this._root
- },
- _adjustLabel: function() {
- var bbox = this._label.text.getBBox(),
- x = _round(-bbox.x + this._size / 2) + 2,
- y = _round(-bbox.y - bbox.height / 2) - 1;
- this._label.text.attr({
- x: x,
- y: y
- });
- this._label.tracker.attr({
- x: x + bbox.x - 1,
- y: y + bbox.y - 1,
- width: bbox.width + 2,
- height: bbox.height + 2
- })
- },
- _locateLabel: $.noop
- });
- function DotMarker(){}
- _extend(DotMarker.prototype, baseMarkerBehavior, {
- type: DOT,
- _create: function(style, renderer, root) {
- var that = this,
- size = that._size = style.size > 0 ? _Number(style.size) : 0,
- hoveredSize = size,
- selectedSize = size + (style.selectedStep > 0 ? _Number(style.selectedStep) : 0),
- hoveredBackSize = hoveredSize + (style.backStep > 0 ? _Number(style.backStep) : 0),
- selectedBackSize = selectedSize + (style.backStep > 0 ? _Number(style.backStep) : 0),
- r = size / 2;
- that._dotDefault = {
- cx: 0,
- cy: 0,
- r: r,
- stroke: style.borderColor,
- "stroke-width": style.borderWidth,
- fill: style.color,
- filter: style.shadow ? style._filter : null
- };
- that._dotHovered = {
- cx: 0,
- cy: 0,
- r: hoveredSize / 2,
- stroke: style.hoveredBorderColor,
- "stroke-width": style.hoveredBorderWidth,
- fill: style.hoveredColor
- };
- that._dotSelected = {
- cx: 0,
- cy: 0,
- r: selectedSize / 2,
- stroke: style.selectedBorderColor,
- "stroke-width": style.selectedBorderWidth,
- fill: style.selectedColor
- };
- that._backDefault = {
- cx: 0,
- cy: 0,
- r: r,
- stroke: "none",
- "stroke-width": 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._backHovered = {
- cx: 0,
- cy: 0,
- r: hoveredBackSize / 2,
- stroke: "none",
- "stroke-width": 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._backSelected = {
- cx: 0,
- cy: 0,
- r: selectedBackSize / 2,
- stroke: "none",
- "stroke-width": 0,
- fill: style.backColor,
- opacity: style.backOpacity
- };
- that._back = renderer.circle().sharp().attr(that._backDefault).data(that._ctx.dataKey, that._data).append(root);
- that._dot = renderer.circle().sharp().attr(that._dotDefault).data(that._ctx.dataKey, that._data).append(root)
- },
- _destroy: function() {
- this._back = this._dot = null
- },
- _applyDefault: function() {
- this._back.attr(this._backDefault);
- this._dot.attr(this._dotDefault)
- },
- _applyHovered: function() {
- this._back.attr(this._backHovered);
- this._dot.attr(this._dotHovered)
- },
- _applySelected: function() {
- this._back.attr(this._backSelected);
- this._dot.attr(this._dotSelected)
- }
- });
- function BubbleMarker(){}
- _extend(BubbleMarker.prototype, baseMarkerBehavior, {
- type: BUBBLE,
- _create: function(style, renderer, root) {
- var that = this;
- that._minSize = style.minSize > 0 ? _Number(style.minSize) : 0;
- that._maxSize = style.maxSize > that._minSize ? _Number(style.maxSize) : that._minSize;
- that.value = _isFinite(that._proxy.value) ? _Number(that._proxy.value) : null;
- that._default = {
- stroke: style.borderColor,
- "stroke-width": style.borderWidth,
- fill: style.color,
- opacity: style.opacity
- };
- that._hovered = {
- stroke: style.hoveredBorderColor,
- "stroke-width": style.hoveredBorderWidth,
- fill: style.hoveredColor,
- opacity: style.hoveredOpacity
- };
- that._selected = {
- stroke: style.selectedBorderColor,
- "stroke-width": style.selectedBorderWidth,
- fill: style.selectedColor,
- opacity: style.selectedOpacity
- };
- that._bubble = renderer.circle(0, 0, 0).sharp().attr(that._default).data(that._ctx.dataKey, that._data).append(root);
- that.setSize(style.size / that._maxSize || 1)
- },
- _applyDefault: function() {
- this._bubble.attr(this._default)
- },
- _applyHovered: function() {
- this._bubble.attr(this._hovered)
- },
- _applySelected: function() {
- this._bubble.attr(this._selected)
- },
- setSize: function(ratio) {
- var that = this,
- r = (that._minSize + ratio * (that._maxSize - that._minSize)) / 2;
- that._default.r = that._hovered.r = that._selected.r = r;
- that._size = 2 * r;
- that._bubble.attr({r: r});
- return that
- }
- });
- function PieMarker(){}
- _extend(PieMarker.prototype, baseMarkerBehavior, {
- type: PIE,
- _create: function(style, renderer, root) {
- var that = this,
- r = (style.size > 0 ? _Number(style.size) : 0) / 2,
- srcValues,
- i = 0,
- ii,
- values,
- value,
- sum = 0,
- translator,
- startAngle,
- endAngle,
- colors;
- that._size = 2 * r;
- that._pieDefault = {opacity: style.opacity};
- that._pieHovered = {opacity: style.hoveredOpacity};
- that._pieSelected = {opacity: style.selectedOpacity};
- that._borderDefault = {
- stroke: style.borderColor,
- "stroke-width": style.borderWidth
- };
- that._borderHovered = {
- stroke: style.hoveredBorderColor,
- "stroke-width": style.hoveredBorderWidth
- };
- that._borderSelected = {
- stroke: style.selectedBorderColor,
- "stroke-width": style.selectedBorderWidth
- };
- srcValues = that._proxy.values;
- ii = _isArray(srcValues) ? srcValues.length : 0;
- values = [];
- for (; i < ii; ++i) {
- value = _Number(srcValues[i]);
- if (_isFinite(value)) {
- values.push(value);
- sum += value
- }
- }
- that._pie = renderer.g().attr(that._pieDefault);
- translator = new DX.viz.core.Translator1D(0, sum, 90, 450);
- startAngle = translator.translate(0);
- colors = that._ctx.getPieColors(values.length);
- for (value = 0, i = 0, ii = values.length; i < ii; ++i) {
- value += values[i];
- endAngle = translator.translate(value);
- renderer.arc(0, 0, 0, r, startAngle, endAngle).attr({
- "stroke-linejoin": "round",
- fill: colors[i]
- }).data(that._ctx.dataKey, that._data).append(that._pie);
- startAngle = endAngle
- }
- that._pie.append(root);
- that._border = renderer.circle(0, 0, r).sharp().attr(that._borderDefault).data(that._ctx.dataKey, that._data).append(root)
- },
- _applyDefault: function() {
- this._pie.attr(this._pieDefault);
- this._border.attr(this._borderDefault)
- },
- _applyHovered: function() {
- this._pie.attr(this._pieHovered);
- this._border.attr(this._borderHovered)
- },
- _applySelected: function() {
- this._pie.attr(this._pieSelected);
- this._border.attr(this._borderSelected)
- }
- });
- function ImageMarker(){}
- _extend(ImageMarker.prototype, baseMarkerBehavior, {
- type: IMAGE,
- _create: function(style, renderer, root) {
- var that = this,
- size = that._size = style.size > 0 ? _Number(style.size) : 0,
- hoveredSize = size + (style.hoveredStep > 0 ? _Number(style.hoveredStep) : 0),
- selectedSize = size + (style.selectedStep > 0 ? _Number(style.selectedStep) : 0);
- that._default = {
- x: -size / 2,
- y: -size / 2,
- width: size,
- height: size
- };
- that._hovered = {
- x: -hoveredSize / 2,
- y: -hoveredSize / 2,
- width: hoveredSize,
- height: hoveredSize
- };
- that._selected = {
- x: -selectedSize / 2,
- y: -selectedSize / 2,
- width: selectedSize,
- height: selectedSize
- };
- that._image = renderer.image().attr(that._default).attr({
- href: that._proxy.url,
- location: "center"
- }).append(root);
- that._tracker = renderer.rect().attr(that._default).attr({
- stroke: "none",
- "stroke-width": 0,
- fill: "#000000",
- opacity: 0.0001
- }).data(that._ctx.dataKey, that._data).append(root)
- },
- _applyDefault: function() {
- this._image.attr(this._default);
- this._tracker.attr(this._default)
- },
- _applyHovered: function() {
- this._image.attr(this._hovered);
- this._tracker.attr(this._hovered)
- },
- _applySelected: function() {
- this._image.attr(this._selected);
- this._tracker.attr(this._selected)
- }
- });
- _each([DotMarker, BubbleMarker, PieMarker, ImageMarker], function(_, markerType) {
- DEFAULT_MARKER_TYPE = DEFAULT_MARKER_TYPE || markerType.prototype.type;
- MARKER_TYPES[markerType.prototype.type] = markerType
- });
- function parseMarkerType(type, defaultType) {
- var _type = _String(type).toLowerCase();
- return MARKER_TYPES[_type] ? _type : defaultType
- }
- var __originalDefaultMarkerType = DEFAULT_MARKER_TYPE,
- __originalMarkerTypes = _extend({}, MARKER_TYPES);
- DX.viz.map._tests.stubMarkerTypes = function(markerTypes, defaultMarkerType) {
- DEFAULT_MARKER_TYPE = defaultMarkerType;
- MARKER_TYPES = markerTypes
- };
- DX.viz.map._tests.restoreMarkerTypes = function() {
- DEFAULT_MARKER_TYPE = __originalDefaultMarkerType;
- MARKER_TYPES = __originalMarkerTypes
- };
- DX.viz.map._tests.baseMarkerBehavior = baseMarkerBehavior;
- DX.viz.map._tests.MarkersManager = MarkersManager;
- DX.viz.map._tests.DotMarker = DotMarker;
- DX.viz.map._tests.BubbleMarker = BubbleMarker;
- DX.viz.map._tests.PieMarker = PieMarker;
- DX.viz.map._tests.ImageMarker = ImageMarker;
- DX.viz.map.dxVectorMap.prototype._factory.createMarkersManager = function(parameters) {
- return new MarkersManager(parameters)
- }
- })(DevExpress, jQuery);
- DevExpress.MOD_VIZ_VECTORMAP = true
- }
- if (!DevExpress.MOD_VIZ_SPARKLINES) {
- if (!DevExpress.MOD_VIZ_CORE)
- throw Error('Required module is not referenced: viz-core');
- /*! Module viz-sparklines, file baseSparkline.js */
- (function($, DX, undefined) {
- var DEFAULT_LINE_SPACING = 2,
- DEFAULT_EVENTS_DELAY = 200,
- TOUCH_EVENTS_DELAY = 1000,
- _extend = $.extend,
- _abs = Math.abs,
- core = DX.viz.core;
- function generateDefaultCustomizeTooltipCallback(fontOptions, rtlEnabled) {
- var lineSpacing = fontOptions.lineSpacing,
- lineHeight = (lineSpacing !== undefined && lineSpacing !== null ? lineSpacing : DEFAULT_LINE_SPACING) + fontOptions.size;
- DX.viz.sparklines.generated_customize_tooltip = function() {
- return {
- lineHeight: lineHeight,
- rtlEnabled: rtlEnabled
- }
- };
- return function(customizeObject) {
- var html = "",
- vt = customizeObject.valueText;
- for (var i = 0; i < vt.length; i += 2)
- html += "<tr><td>" + vt[i] + "</td><td style='width: 15px'></td><td style='text-align: " + (rtlEnabled ? "left" : "right") + "'>" + vt[i + 1] + "</td></tr>";
- return {html: "<table style='border-spacing:0px; line-height: " + lineHeight + "px'>" + html + "</table>"}
- }
- }
- DX.viz.sparklines = {};
- DX.viz.sparklines.BaseSparkline = core.BaseWidget.inherit({
- _setDeprecatedOptions: function() {
- this.callBase();
- $.extend(this._deprecatedOptions, {
- "tooltip.verticalAlignment": {
- since: "15.1",
- message: "Now tootips are aligned automatically"
- },
- "tooltip.horizontalAlignment": {
- since: "15.1",
- message: "Now tootips are aligned automatically"
- }
- })
- },
- _clean: function() {
- var that = this;
- if (that._tooltipShown) {
- that._tooltipShown = false;
- that._tooltip.hide()
- }
- that._cleanWidgetElements();
- that._cleanTranslators()
- },
- _initCore: function() {
- var that = this;
- that._tooltipTracker = that._renderer.root;
- that._tooltipTracker.attr({"pointer-events": "visible"});
- that._createHtmlElements();
- that._initTooltipEvents()
- },
- _initTooltip: function() {
- this._initTooltipBase = this.callBase;
- return
- },
- _getDefaultSize: function() {
- return this._defaultSize
- },
- _isContainerVisible: function() {
- return true
- },
- _disposeCore: function() {
- this._disposeWidgetElements();
- this._disposeTooltipEvents();
- this._ranges = null
- },
- _render: function() {
- this._prepareOptions();
- this._updateWidgetElements();
- this._drawWidgetElements()
- },
- _updateWidgetElements: function() {
- this._updateRange();
- this._updateTranslator()
- },
- _applySize: function() {
- if (this._allOptions)
- this._allOptions.size = {
- width: this._canvas.width,
- height: this._canvas.height
- }
- },
- _cleanTranslators: function() {
- this._translatorX = null;
- this._translatorY = null
- },
- _setupResizeHandler: $.noop,
- _resize: function() {
- var that = this;
- that._redrawWidgetElements();
- if (that._tooltipShown) {
- that._tooltipShown = false;
- that._tooltip.hide()
- }
- that._drawn()
- },
- _prepareOptions: function() {
- return _extend(true, {}, this._themeManager.theme(), this.option())
- },
- _createThemeManager: function() {
- var themeManager = new DX.viz.core.BaseThemeManager;
- themeManager._themeSection = this._widgetType;
- themeManager._fontFields = ["tooltip.font"];
- return themeManager
- },
- _getTooltipCoords: function() {
- var canvas = this._canvas,
- rootOffset = this._renderer.getRootOffset();
- return {
- x: canvas.width / 2 + rootOffset.left,
- y: canvas.height / 2 + rootOffset.top
- }
- },
- _initTooltipEvents: function() {
- var that = this,
- data = {widget: that};
- that._showTooltipCallback = function() {
- var tooltip;
- that._showTooltipTimeout = null;
- if (!that._tooltipShown) {
- that._tooltipShown = true;
- tooltip = that._getTooltip();
- tooltip.isEnabled() && that._tooltip.show(that._getTooltipData(), that._getTooltipCoords(), {})
- }
- that._DEBUG_showCallback && that._DEBUG_showCallback()
- };
- that._hideTooltipCallback = function() {
- var tooltipWasShown = that._tooltipShown;
- that._hideTooltipTimeout = null;
- if (that._tooltipShown) {
- that._tooltipShown = false;
- that._tooltip.hide()
- }
- that._DEBUG_hideCallback && that._DEBUG_hideCallback(tooltipWasShown)
- };
- that._disposeCallbacks = function() {
- that = that._showTooltipCallback = that._hideTooltipCallback = that._disposeCallbacks = null
- };
- that._tooltipTracker.on(mouseEvents, data).on(touchEvents, data).on(mouseWheelEvents, data);
- that._tooltipTracker.on(menuEvents)
- },
- _disposeTooltipEvents: function() {
- var that = this;
- clearTimeout(that._showTooltipTimeout);
- clearTimeout(that._hideTooltipTimeout);
- that._tooltipTracker.off();
- that._disposeCallbacks()
- },
- _updateTranslator: function() {
- var that = this,
- canvas = this._canvas,
- ranges = this._ranges;
- that._translatorX = new core.Translator2D(ranges.arg, canvas, {direction: "horizontal"});
- that._translatorY = new core.Translator2D(ranges.val, canvas)
- },
- _getTooltip: function() {
- var that = this;
- if (!that._tooltip) {
- that._initTooltipBase();
- that._setTooltipRendererOptions(that._tooltipRendererOptions);
- that._tooltipRendererOptions = null;
- that._setTooltipOptions()
- }
- return that._tooltip
- },
- _setTooltipRendererOptions: function(options) {
- if (this._tooltip)
- this._tooltip.setRendererOptions(options);
- else
- this._tooltipRendererOptions = options
- },
- _setTooltipOptions: function() {
- var tooltip = this._tooltip,
- options = tooltip && this._getOption("tooltip");
- tooltip && tooltip.update($.extend({}, options, {
- customizeTooltip: !$.isFunction(options.customizeTooltip) ? generateDefaultCustomizeTooltipCallback(options.font, this.option("rtlEnabled")) : options.customizeTooltip,
- enabled: options.enabled && this._isTooltipEnabled()
- }))
- },
- _showTooltip: function(delay) {
- var that = this;
- ++that._DEBUG_clearHideTooltipTimeout;
- clearTimeout(that._hideTooltipTimeout);
- that._hideTooltipTimeout = null;
- clearTimeout(that._showTooltipTimeout);
- ++that._DEBUG_showTooltipTimeoutSet;
- that._showTooltipTimeout = setTimeout(that._showTooltipCallback, delay)
- },
- _hideTooltip: function(delay) {
- var that = this;
- ++that._DEBUG_clearShowTooltipTimeout;
- clearTimeout(that._showTooltipTimeout);
- that._showTooltipTimeout = null;
- clearTimeout(that._hideTooltipTimeout);
- if (delay) {
- ++that._DEBUG_hideTooltipTimeoutSet;
- that._hideTooltipTimeout = setTimeout(that._hideTooltipCallback, delay)
- }
- else
- that._hideTooltipCallback()
- },
- _initLoadingIndicator: $.noop,
- _disposeLoadingIndicator: $.noop,
- _handleLoadingIndicatorOptionChanged: $.noop,
- showLoadingIndicator: $.noop,
- hideLoadingIndicator: $.noop
- });
- var menuEvents = {
- "contextmenu.sparkline-tooltip": function(event) {
- if (DX.ui.events.isTouchEvent(event) || DX.ui.events.isPointerEvent(event))
- event.preventDefault()
- },
- "MSHoldVisual.sparkline-tooltip": function(event) {
- event.preventDefault()
- }
- };
- var mouseEvents = {
- "mouseover.sparkline-tooltip": function(event) {
- isPointerDownCalled = false;
- var widget = event.data.widget;
- widget._x = event.pageX;
- widget._y = event.pageY;
- widget._tooltipTracker.off(mouseMoveEvents).on(mouseMoveEvents, event.data);
- widget._showTooltip(DEFAULT_EVENTS_DELAY)
- },
- "mouseout.sparkline-tooltip": function(event) {
- if (isPointerDownCalled)
- return;
- var widget = event.data.widget;
- widget._tooltipTracker.off(mouseMoveEvents);
- widget._hideTooltip(DEFAULT_EVENTS_DELAY)
- }
- };
- var mouseWheelEvents = {"dxmousewheel.sparkline-tooltip": function(event) {
- event.data.widget._hideTooltip()
- }};
- var mouseMoveEvents = {"mousemove.sparkline-tooltip": function(event) {
- var widget = event.data.widget;
- if (widget._showTooltipTimeout && (_abs(widget._x - event.pageX) > 3 || _abs(widget._y - event.pageY) > 3)) {
- widget._x = event.pageX;
- widget._y = event.pageY;
- widget._showTooltip(DEFAULT_EVENTS_DELAY)
- }
- }};
- var active_touch_tooltip_widget = null,
- touchstartTooltipProcessing = function(event) {
- event.preventDefault();
- var widget = active_touch_tooltip_widget;
- if (widget && widget !== event.data.widget)
- widget._hideTooltip(DEFAULT_EVENTS_DELAY);
- widget = active_touch_tooltip_widget = event.data.widget;
- widget._showTooltip(TOUCH_EVENTS_DELAY);
- widget._touch = true
- },
- touchstartDocumentProcessing = function() {
- var widget = active_touch_tooltip_widget;
- if (widget) {
- if (!widget._touch) {
- widget._hideTooltip(DEFAULT_EVENTS_DELAY);
- active_touch_tooltip_widget = null
- }
- widget._touch = null
- }
- },
- touchendDocumentProcessing = function() {
- var widget = active_touch_tooltip_widget;
- if (widget)
- if (widget._showTooltipTimeout) {
- widget._hideTooltip(DEFAULT_EVENTS_DELAY);
- active_touch_tooltip_widget = null
- }
- },
- isPointerDownCalled = false;
- var touchEvents = {
- "pointerdown.sparkline-tooltip": touchstartTooltipProcessing,
- "touchstart.sparkline-tooltip": touchstartTooltipProcessing
- };
- $(document).on({
- "pointerdown.sparkline-tooltip": function() {
- isPointerDownCalled = true;
- touchstartDocumentProcessing()
- },
- "touchstart.sparkline-tooltip": touchstartDocumentProcessing,
- "pointerup.sparkline-tooltip": touchendDocumentProcessing,
- "touchend.sparkline-tooltip": touchendDocumentProcessing
- });
- DX.viz.sparklines.BaseSparkline._DEBUG_reset = function() {
- active_touch_tooltip_widget = null
- }
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file sparkline.js */
- (function($, DX, undefined) {
- var viz = DX.viz,
- core = viz.core,
- MIN_BAR_WIDTH = 1,
- MAX_BAR_WIDTH = 50,
- DEFAULT_BAR_INTERVAL = 4,
- DEFAULT_CANVAS_WIDTH = 250,
- DEFAULT_CANVAS_HEIGHT = 30,
- DEFAULT_HORIZONTAL_MARGIN = 5,
- DEFAULT_VERTICAL_MARGIN = 3,
- ALLOWED_TYPES = {
- line: true,
- spline: true,
- stepline: true,
- area: true,
- steparea: true,
- splinearea: true,
- bar: true,
- winloss: true
- },
- _map = $.map,
- _math = Math,
- _abs = _math.abs,
- _round = _math.round,
- _max = _math.max,
- _min = _math.min,
- _isFinite = isFinite,
- _isDefined = DX.utils.isDefined,
- _Number = Number,
- _String = String;
- DX.registerComponent("dxSparkline", viz.sparklines, viz.sparklines.BaseSparkline.inherit({
- _rootClassPrefix: "dxsl",
- _rootClass: "dxsl-sparkline",
- _widgetType: "sparkline",
- _defaultSize: {
- width: DEFAULT_CANVAS_WIDTH,
- height: DEFAULT_CANVAS_HEIGHT,
- left: DEFAULT_HORIZONTAL_MARGIN,
- right: DEFAULT_HORIZONTAL_MARGIN,
- top: DEFAULT_VERTICAL_MARGIN,
- bottom: DEFAULT_VERTICAL_MARGIN
- },
- _initCore: function() {
- this.callBase();
- this._refreshDataSource();
- this._createSeries()
- },
- _dataSourceChangedHandler: function() {
- if (this._initialized) {
- this._clean();
- this._updateWidgetElements();
- this._drawWidgetElements()
- }
- },
- _updateWidgetElements: function() {
- this._updateSeries();
- this.callBase()
- },
- _dataSourceOptions: function() {
- return {paginate: false}
- },
- _redrawWidgetElements: function() {
- this._updateTranslator();
- this._correctPoints();
- this._series.draw({
- x: this._translatorX,
- y: this._translatorY
- });
- this._seriesGroup.append(this._renderer.root)
- },
- _disposeWidgetElements: function() {
- var that = this;
- delete that._seriesGroup;
- delete that._seriesLabelGroup;
- that._series && that._series.dispose();
- that._series = null
- },
- _cleanWidgetElements: function() {
- this._seriesGroup.remove();
- this._seriesLabelGroup.remove();
- this._seriesGroup.clear();
- this._seriesLabelGroup.clear()
- },
- _drawWidgetElements: function() {
- if (this._isDataSourceReady()) {
- this._drawSeries();
- this._drawn()
- }
- },
- _prepareOptions: function() {
- this._allOptions = this.callBase();
- this._allOptions.type = _String(this._allOptions.type).toLowerCase();
- if (!ALLOWED_TYPES[this._allOptions.type])
- this._allOptions.type = "line"
- },
- _createHtmlElements: function() {
- this._seriesGroup = this._renderer.g().attr({"class": "dxsl-series"});
- this._seriesLabelGroup = this._renderer.g().attr({"class": "dxsl-series-labels"})
- },
- _createSeries: function() {
- this._series = new core.series.Series({
- renderer: this._renderer,
- seriesGroup: this._seriesGroup,
- labelsGroup: this._seriesLabelGroup
- }, {
- widgetType: "chart",
- type: "line"
- })
- },
- getSeriesOptions: function() {
- return this._series.getOptions()
- },
- _updateSeries: function() {
- var that = this,
- groupSeries,
- dataValidator,
- seriesOptions;
- that._prepareDataSource();
- seriesOptions = that._prepareSeriesOptions();
- that._series.updateOptions(seriesOptions);
- groupSeries = [[that._series]];
- groupSeries.argumentOptions = {type: seriesOptions.type === "bar" ? "discrete" : undefined};
- dataValidator = new core.DataValidator(that._simpleDataSource, groupSeries, that._incidentOccured, {
- checkTypeForAllData: false,
- convertToAxisDataType: true,
- sortingMethod: true
- });
- that._simpleDataSource = dataValidator.validate();
- that._series.updateData(that._simpleDataSource)
- },
- _optionChanged: function(args) {
- if (args.name === "dataSource" && this._allOptions)
- this._refreshDataSource();
- else
- this.callBase.apply(this, arguments)
- },
- _parseNumericDataSource: function(data, argField, valField) {
- var ignoreEmptyPoints = this.option("ignoreEmptyPoints");
- return _map(data, function(dataItem, index) {
- var item = null,
- isDataNumber,
- value;
- if (dataItem !== undefined) {
- item = {};
- isDataNumber = _isFinite(dataItem);
- item[argField] = isDataNumber ? _String(index) : dataItem[argField];
- value = isDataNumber ? dataItem : dataItem[valField];
- item[valField] = value === null ? ignoreEmptyPoints ? undefined : value : _Number(value);
- item = item[argField] !== undefined && item[valField] !== undefined ? item : null
- }
- return item
- })
- },
- _parseWinlossDataSource: function(data, argField, valField) {
- var lowBarValue = -1,
- zeroBarValue = 0,
- highBarValue = 1,
- delta = 0.0001,
- target = this._allOptions.winlossThreshold;
- return _map(data, function(dataItem) {
- var item = {};
- item[argField] = dataItem[argField];
- if (_abs(dataItem[valField] - target) < delta)
- item[valField] = zeroBarValue;
- else if (dataItem[valField] > target)
- item[valField] = highBarValue;
- else
- item[valField] = lowBarValue;
- return item
- })
- },
- _prepareDataSource: function() {
- var that = this,
- options = that._allOptions,
- argField = options.argumentField,
- valField = options.valueField,
- dataSource = that._dataSource ? that._dataSource.items() : [],
- data = that._parseNumericDataSource(dataSource, argField, valField);
- if (options.type === "winloss") {
- that._winlossDataSource = data;
- that._simpleDataSource = that._parseWinlossDataSource(data, argField, valField)
- }
- else
- that._simpleDataSource = data
- },
- _prepareSeriesOptions: function() {
- var that = this,
- options = that._allOptions,
- type = options.type === "winloss" ? "bar" : options.type;
- return {
- visible: true,
- argumentField: options.argumentField,
- valueField: options.valueField,
- color: options.lineColor,
- width: options.lineWidth,
- widgetType: "chart",
- type: type,
- opacity: type.indexOf("area") !== -1 ? that._allOptions.areaOpacity : undefined,
- customizePoint: that._getCustomizeFunction(),
- point: {
- size: options.pointSize,
- symbol: options.pointSymbol,
- border: {
- visible: true,
- width: 2
- },
- color: options.pointColor,
- visible: false,
- hoverStyle: {border: {}},
- selectionStyle: {border: {}}
- },
- border: {
- color: options.lineColor,
- width: options.lineWidth,
- visible: type !== "bar"
- }
- }
- },
- _createBarCustomizeFunction: function(pointIndexes) {
- var that = this,
- options = that._allOptions,
- winlossData = that._winlossDataSource;
- return function() {
- var index = this.index,
- isWinloss = options.type === "winloss",
- target = isWinloss ? options.winlossThreshold : 0,
- value = isWinloss ? winlossData[index][options.valueField] : this.value,
- positiveColor = isWinloss ? options.winColor : options.barPositiveColor,
- negativeColor = isWinloss ? options.lossColor : options.barNegativeColor,
- color;
- if (value >= target)
- color = positiveColor;
- else
- color = negativeColor;
- if (index === pointIndexes.first || index === pointIndexes.last)
- color = options.firstLastColor;
- if (index === pointIndexes.min)
- color = options.minColor;
- if (index === pointIndexes.max)
- color = options.maxColor;
- return {color: color}
- }
- },
- _createLineCustomizeFunction: function(pointIndexes) {
- var that = this,
- options = that._allOptions;
- return function() {
- var color,
- index = this.index;
- if (index === pointIndexes.first || index === pointIndexes.last)
- color = options.firstLastColor;
- if (index === pointIndexes.min)
- color = options.minColor;
- if (index === pointIndexes.max)
- color = options.maxColor;
- return color ? {
- visible: true,
- border: {color: color}
- } : {}
- }
- },
- _getCustomizeFunction: function() {
- var that = this,
- options = that._allOptions,
- dataSource = that._winlossDataSource || that._simpleDataSource,
- drawnPointIndexes = that._getExtremumPointsIndexes(dataSource),
- customizeFunction;
- if (options.type === "winloss" || options.type === "bar")
- customizeFunction = that._createBarCustomizeFunction(drawnPointIndexes);
- else
- customizeFunction = that._createLineCustomizeFunction(drawnPointIndexes);
- return customizeFunction
- },
- _getExtremumPointsIndexes: function(data) {
- var that = this,
- options = that._allOptions,
- lastIndex = data.length - 1,
- indexes = {};
- that._minMaxIndexes = that._findMinMax(data);
- if (options.showFirstLast) {
- indexes.first = 0;
- indexes.last = lastIndex
- }
- if (options.showMinMax) {
- indexes.min = that._minMaxIndexes.minIndex;
- indexes.max = that._minMaxIndexes.maxIndex
- }
- return indexes
- },
- _findMinMax: function(data) {
- var that = this,
- valField = that._allOptions.valueField,
- firstItem = data[0] || {},
- firstValue = firstItem[valField] || 0,
- min = firstValue,
- max = firstValue,
- minIndex = 0,
- maxIndex = 0,
- dataLength = data.length,
- value,
- i;
- for (i = 1; i < dataLength; i++) {
- value = data[i][valField];
- if (value < min) {
- min = value;
- minIndex = i
- }
- if (value > max) {
- max = value;
- maxIndex = i
- }
- }
- return {
- minIndex: minIndex,
- maxIndex: maxIndex
- }
- },
- _updateRange: function() {
- var that = this,
- series = that._series,
- type = series.type,
- isBarType = type === "bar",
- isWinlossType = type === "winloss",
- DEFAULT_VALUE_RANGE_MARGIN = 0.15,
- DEFAULT_ARGUMENT_RANGE_MARGIN = 0.1,
- WINLOSS_MAX_RANGE = 1,
- WINLOSS_MIN_RANGE = -1,
- rangeData = series.getRangeData(),
- minValue = that._allOptions.minValue,
- hasMinY = _isDefined(minValue) && _isFinite(minValue),
- maxValue = that._allOptions.maxValue,
- hasMaxY = _isDefined(maxValue) && _isFinite(maxValue),
- valCoef,
- argCoef;
- valCoef = (rangeData.val.max - rangeData.val.min) * DEFAULT_VALUE_RANGE_MARGIN;
- if (isBarType || isWinlossType || type === "area") {
- if (rangeData.val.min !== 0)
- rangeData.val.min -= valCoef;
- if (rangeData.val.max !== 0)
- rangeData.val.max += valCoef
- }
- else {
- rangeData.val.min -= valCoef;
- rangeData.val.max += valCoef
- }
- if (hasMinY || hasMaxY) {
- if (hasMinY && hasMaxY) {
- rangeData.val.minVisible = _min(minValue, maxValue);
- rangeData.val.maxVisible = _max(minValue, maxValue)
- }
- else {
- rangeData.val.minVisible = hasMinY ? _Number(minValue) : undefined;
- rangeData.val.maxVisible = hasMaxY ? _Number(maxValue) : undefined
- }
- if (isWinlossType) {
- rangeData.val.minVisible = hasMinY ? _max(rangeData.val.minVisible, WINLOSS_MIN_RANGE) : undefined;
- rangeData.val.maxVisible = hasMaxY ? _min(rangeData.val.maxVisible, WINLOSS_MAX_RANGE) : undefined
- }
- }
- if (series.getPoints().length > 1)
- if (isBarType) {
- argCoef = (rangeData.arg.max - rangeData.arg.min) * DEFAULT_ARGUMENT_RANGE_MARGIN;
- rangeData.arg.min = rangeData.arg.min - argCoef;
- rangeData.arg.max = rangeData.arg.max + argCoef
- }
- else
- rangeData.arg.stick = true;
- that._ranges = rangeData
- },
- _getBarWidth: function(pointsCount) {
- var that = this,
- canvas = that._canvas,
- intervalWidth = pointsCount * DEFAULT_BAR_INTERVAL,
- rangeWidth = canvas.width - canvas.left - canvas.right - intervalWidth,
- width = _round(rangeWidth / pointsCount);
- if (width < MIN_BAR_WIDTH)
- width = MIN_BAR_WIDTH;
- if (width > MAX_BAR_WIDTH)
- width = MAX_BAR_WIDTH;
- return width
- },
- _correctPoints: function() {
- var that = this,
- seriesType = that._allOptions.type,
- seriesPoints = that._series.getPoints(),
- pointsLength = seriesPoints.length,
- barWidth,
- i;
- if (seriesType === "bar" || seriesType === "winloss") {
- barWidth = that._getBarWidth(pointsLength);
- for (i = 0; i < pointsLength; i++)
- seriesPoints[i].correctCoordinates({
- width: barWidth,
- offset: 0
- })
- }
- },
- _drawSeries: function() {
- var that = this;
- if (that._simpleDataSource.length > 0) {
- that._correctPoints();
- that._series.draw({
- x: that._translatorX,
- y: that._translatorY
- });
- that._seriesGroup.append(that._renderer.root)
- }
- },
- _isTooltipEnabled: function() {
- return !!this._simpleDataSource.length
- },
- _getTooltipData: function() {
- var that = this,
- options = that._allOptions,
- dataSource = that._winlossDataSource || that._simpleDataSource,
- tooltip = that._tooltip;
- if (dataSource.length === 0)
- return {};
- var minMax = that._minMaxIndexes,
- valueField = options.valueField,
- first = dataSource[0][valueField],
- last = dataSource[dataSource.length - 1][valueField],
- min = dataSource[minMax.minIndex][valueField],
- max = dataSource[minMax.maxIndex][valueField],
- formattedFirst = tooltip.formatValue(first),
- formattedLast = tooltip.formatValue(last),
- formattedMin = tooltip.formatValue(min),
- formattedMax = tooltip.formatValue(max),
- customizeObject = {
- firstValue: formattedFirst,
- lastValue: formattedLast,
- minValue: formattedMin,
- maxValue: formattedMax,
- originalFirstValue: first,
- originalLastValue: last,
- originalMinValue: min,
- originalMaxValue: max,
- valueText: ["Start:", formattedFirst, "End:", formattedLast, "Min:", formattedMin, "Max:", formattedMax]
- };
- if (options.type === "winloss") {
- customizeObject.originalThresholdValue = options.winlossThreshold;
- customizeObject.thresholdValue = tooltip.formatValue(options.winlossThreshold)
- }
- return customizeObject
- }
- }).include(DX.ui.DataHelperMixin))
- })(jQuery, DevExpress);
- /*! Module viz-sparklines, file bullet.js */
- (function($, DX, undefined) {
- var TARGET_MIN_Y = 0.02,
- TARGET_MAX_Y = 0.98,
- BAR_VALUE_MIN_Y = 0.1,
- BAR_VALUE_MAX_Y = 0.9,
- DEFAULT_CANVAS_WIDTH = 300,
- DEFAULT_CANVAS_HEIGHT = 30,
- DEFAULT_HORIZONTAL_MARGIN = 1,
- DEFAULT_VERTICAL_MARGIN = 2,
- _Number = Number,
- _isFinite = isFinite;
- DX.registerComponent("dxBullet", DX.viz.sparklines, DX.viz.sparklines.BaseSparkline.inherit({
- _rootClassPrefix: "dxb",
- _rootClass: "dxb-bullet",
- _widgetType: "bullet",
- _defaultSize: {
- width: DEFAULT_CANVAS_WIDTH,
- height: DEFAULT_CANVAS_HEIGHT,
- left: DEFAULT_HORIZONTAL_MARGIN,
- right: DEFAULT_HORIZONTAL_MARGIN,
- top: DEFAULT_VERTICAL_MARGIN,
- bottom: DEFAULT_VERTICAL_MARGIN
- },
- _disposeWidgetElements: function() {
- delete this._zeroLevelPath;
- delete this._targetPath;
- delete this._barValuePath
- },
- _redrawWidgetElements: function() {
- this._updateTranslator();
- this._drawBarValue();
- this._drawTarget();
- this._drawZeroLevel()
- },
- _cleanWidgetElements: function() {
- this._zeroLevelPath.remove();
- this._targetPath.remove();
- this._barValuePath.remove()
- },
- _drawWidgetElements: function() {
- this._drawBullet();
- this._drawn()
- },
- _createHtmlElements: function() {
- var renderer = this._renderer;
- this._zeroLevelPath = renderer.path(undefined, "line").attr({
- "class": "dxb-zero-level",
- "stroke-linecap": "square"
- });
- this._targetPath = renderer.path(undefined, "line").attr({
- "class": "dxb-target",
- "stroke-linecap": "square"
- });
- this._barValuePath = renderer.path(undefined, "line").attr({
- "class": "dxb-bar-value",
- "stroke-linecap": "square"
- })
- },
- _prepareOptions: function() {
- var that = this,
- options,
- startScaleValue,
- endScaleValue,
- level,
- value,
- target,
- isValueUndefined,
- isTargetUndefined;
- that._allOptions = options = that.callBase();
- isValueUndefined = that._allOptions.value === undefined;
- isTargetUndefined = that._allOptions.target === undefined;
- that._tooltipEnabled = !(isValueUndefined && isTargetUndefined);
- if (isValueUndefined)
- that._allOptions.value = 0;
- if (isTargetUndefined)
- that._allOptions.target = 0;
- options.value = value = _Number(options.value);
- options.target = target = _Number(options.target);
- if (that._allOptions.startScaleValue === undefined) {
- that._allOptions.startScaleValue = target < value ? target : value;
- that._allOptions.startScaleValue = that._allOptions.startScaleValue < 0 ? that._allOptions.startScaleValue : 0
- }
- if (that._allOptions.endScaleValue === undefined)
- that._allOptions.endScaleValue = target > value ? target : value;
- options.startScaleValue = startScaleValue = _Number(options.startScaleValue);
- options.endScaleValue = endScaleValue = _Number(options.endScaleValue);
- if (endScaleValue < startScaleValue) {
- level = endScaleValue;
- that._allOptions.endScaleValue = startScaleValue;
- that._allOptions.startScaleValue = level;
- that._allOptions.inverted = true
- }
- },
- _updateRange: function() {
- var that = this,
- options = that._allOptions;
- that._ranges = {
- arg: {
- invert: options.inverted,
- min: options.startScaleValue,
- max: options.endScaleValue,
- axisType: "continuous",
- dataType: "numeric"
- },
- val: {
- min: 0,
- max: 1,
- axisType: "continuous",
- dataType: "numeric"
- }
- }
- },
- _drawBullet: function() {
- var that = this,
- options = that._allOptions,
- isValidBounds = options.startScaleValue !== options.endScaleValue,
- isValidMin = _isFinite(options.startScaleValue),
- isValidMax = _isFinite(options.endScaleValue),
- isValidValue = _isFinite(options.value),
- isValidTarget = _isFinite(options.target);
- if (isValidBounds && isValidMax && isValidMin && isValidTarget && isValidValue) {
- this._drawBarValue();
- this._drawTarget();
- this._drawZeroLevel()
- }
- },
- _getTargetParams: function() {
- var that = this,
- options = that._allOptions,
- translatorY = that._translatorY,
- x = that._translatorX.translate(options.target);
- return {
- points: [x, translatorY.translate(TARGET_MIN_Y), x, translatorY.translate(TARGET_MAX_Y)],
- stroke: options.targetColor,
- "stroke-width": options.targetWidth
- }
- },
- _getBarValueParams: function() {
- var that = this,
- options = that._allOptions,
- translatorX = that._translatorX,
- translatorY = that._translatorY,
- startLevel = options.startScaleValue,
- endLevel = options.endScaleValue,
- value = options.value,
- y2 = translatorY.translate(BAR_VALUE_MIN_Y),
- y1 = translatorY.translate(BAR_VALUE_MAX_Y),
- x1,
- x2;
- if (value > 0) {
- x1 = startLevel <= 0 ? 0 : startLevel;
- x2 = value >= endLevel ? endLevel : value < x1 ? x1 : value
- }
- else {
- x1 = endLevel >= 0 ? 0 : endLevel;
- x2 = value < startLevel ? startLevel : value > x1 ? x1 : value
- }
- x1 = translatorX.translate(x1);
- x2 = translatorX.translate(x2);
- return {
- points: [x1, y1, x2, y1, x2, y2, x1, y2],
- fill: options.color
- }
- },
- _getZeroLevelParams: function() {
- var that = this,
- translatorY = that._translatorY,
- x = that._translatorX.translate(0);
- return {
- points: [x, translatorY.translate(TARGET_MIN_Y), x, translatorY.translate(TARGET_MAX_Y)],
- stroke: that._allOptions.targetColor,
- "stroke-width": 1
- }
- },
- _drawZeroLevel: function() {
- var that = this,
- options = that._allOptions;
- if (0 > options.endScaleValue || 0 < options.startScaleValue || !options.showZeroLevel)
- return;
- that._zeroLevelPath.attr(that._getZeroLevelParams()).sharp().append(that._renderer.root)
- },
- _drawTarget: function() {
- var that = this,
- options = that._allOptions,
- target = options.target;
- if (target > options.endScaleValue || target < options.startScaleValue || !options.showTarget)
- return;
- that._targetPath.attr(that._getTargetParams()).sharp().append(that._renderer.root)
- },
- _drawBarValue: function() {
- this._barValuePath.attr(this._getBarValueParams()).append(this._renderer.root)
- },
- _getTooltipCoords: function() {
- var canvas = this._canvas,
- rootOffset = this._renderer.getRootOffset(),
- bbox = this._barValuePath.getBBox();
- return {
- x: bbox.x + bbox.width / 2 + rootOffset.left,
- y: canvas.height / 2 + rootOffset.top
- }
- },
- _getTooltipData: function() {
- var that = this,
- tooltip = that._tooltip,
- options = that._allOptions,
- value = options.value,
- target = options.target;
- return {
- originalValue: value,
- originalTarget: target,
- value: tooltip.formatValue(value),
- target: tooltip.formatValue(target),
- valueText: ["Actual Value:", value, "Target Value:", target]
- }
- },
- _isTooltipEnabled: function() {
- return this._tooltipEnabled
- }
- }))
- })(jQuery, DevExpress);
- DevExpress.MOD_VIZ_SPARKLINES = true
- }
|