charts-debug.js 688 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047
  1. var $jscomp = $jscomp || {};
  2. $jscomp.scope = {};
  3. $jscomp.ASSUME_ES5 = false;
  4. $jscomp.ASSUME_NO_NATIVE_MAP = false;
  5. $jscomp.ASSUME_NO_NATIVE_SET = false;
  6. $jscomp.defineProperty = $jscomp.ASSUME_ES5 || typeof Object.defineProperties == 'function' ? Object.defineProperty : function(target, property, descriptor) {
  7. descriptor = descriptor;
  8. if (target == Array.prototype || target == Object.prototype) {
  9. return;
  10. }
  11. target[property] = descriptor.value;
  12. };
  13. $jscomp.getGlobal = function(maybeGlobal) {
  14. return typeof window != 'undefined' && window === maybeGlobal ? maybeGlobal : typeof global != 'undefined' && global != null ? global : maybeGlobal;
  15. };
  16. $jscomp.global = $jscomp.getGlobal(this);
  17. $jscomp.polyfill = function(target, polyfill, fromLang, toLang) {
  18. if (!polyfill) {
  19. return;
  20. }
  21. var obj = $jscomp.global;
  22. var split = target.split('.');
  23. for (var i = 0; i < split.length - 1; i++) {
  24. var key = split[i];
  25. if (!(key in obj)) {
  26. obj[key] = {};
  27. }
  28. obj = obj[key];
  29. }
  30. var property = split[split.length - 1];
  31. var orig = obj[property];
  32. var impl = polyfill(orig);
  33. if (impl == orig || impl == null) {
  34. return;
  35. }
  36. $jscomp.defineProperty(obj, property, {configurable:true, writable:true, value:impl});
  37. };
  38. $jscomp.polyfill('Array.prototype.copyWithin', function(orig) {
  39. if (orig) {
  40. return orig;
  41. }
  42. var polyfill = function(target, start, opt_end) {
  43. var len = this.length;
  44. target = Number(target);
  45. start = Number(start);
  46. opt_end = Number(opt_end != null ? opt_end : len);
  47. if (target < start) {
  48. opt_end = Math.min(opt_end, len);
  49. while (start < opt_end) {
  50. if (start in this) {
  51. this[target++] = this[start++];
  52. } else {
  53. delete this[target++];
  54. start++;
  55. }
  56. }
  57. } else {
  58. opt_end = Math.min(opt_end, len + start - target);
  59. target += opt_end - start;
  60. while (opt_end > start) {
  61. if (--opt_end in this) {
  62. this[--target] = this[opt_end];
  63. } else {
  64. delete this[target];
  65. }
  66. }
  67. }
  68. return this;
  69. };
  70. return polyfill;
  71. }, 'es6', 'es3');
  72. $jscomp.SYMBOL_PREFIX = 'jscomp_symbol_';
  73. $jscomp.initSymbol = function() {
  74. $jscomp.initSymbol = function() {
  75. };
  76. if (!$jscomp.global['Symbol']) {
  77. $jscomp.global['Symbol'] = $jscomp.Symbol;
  78. }
  79. };
  80. $jscomp.Symbol = function() {
  81. var counter = 0;
  82. function Symbol(opt_description) {
  83. return $jscomp.SYMBOL_PREFIX + (opt_description || '') + counter++;
  84. }
  85. return Symbol;
  86. }();
  87. $jscomp.initSymbolIterator = function() {
  88. $jscomp.initSymbol();
  89. var symbolIterator = $jscomp.global['Symbol'].iterator;
  90. if (!symbolIterator) {
  91. symbolIterator = $jscomp.global['Symbol'].iterator = $jscomp.global['Symbol']('iterator');
  92. }
  93. if (typeof Array.prototype[symbolIterator] != 'function') {
  94. $jscomp.defineProperty(Array.prototype, symbolIterator, {configurable:true, writable:true, value:function() {
  95. return $jscomp.arrayIterator(this);
  96. }});
  97. }
  98. $jscomp.initSymbolIterator = function() {
  99. };
  100. };
  101. $jscomp.arrayIterator = function(array) {
  102. var index = 0;
  103. return $jscomp.iteratorPrototype(function() {
  104. if (index < array.length) {
  105. return {done:false, value:array[index++]};
  106. } else {
  107. return {done:true};
  108. }
  109. });
  110. };
  111. $jscomp.iteratorPrototype = function(next) {
  112. $jscomp.initSymbolIterator();
  113. var iterator = {next:next};
  114. iterator[$jscomp.global['Symbol'].iterator] = function() {
  115. return this;
  116. };
  117. return iterator;
  118. };
  119. $jscomp.iteratorFromArray = function(array, transform) {
  120. $jscomp.initSymbolIterator();
  121. if (array instanceof String) {
  122. array = array + '';
  123. }
  124. var i = 0;
  125. var iter = {next:function() {
  126. if (i < array.length) {
  127. var index = i++;
  128. return {value:transform(index, array[index]), done:false};
  129. }
  130. iter.next = function() {
  131. return {done:true, value:void 0};
  132. };
  133. return iter.next();
  134. }};
  135. $jscomp.initSymbol();
  136. $jscomp.initSymbolIterator();
  137. iter[Symbol.iterator] = function() {
  138. return iter;
  139. };
  140. return iter;
  141. };
  142. $jscomp.polyfill('Array.prototype.entries', function(orig) {
  143. if (orig) {
  144. return orig;
  145. }
  146. var polyfill = function() {
  147. return $jscomp.iteratorFromArray(this, function(i, v) {
  148. return [i, v];
  149. });
  150. };
  151. return polyfill;
  152. }, 'es6', 'es3');
  153. $jscomp.polyfill('Array.prototype.fill', function(orig) {
  154. if (orig) {
  155. return orig;
  156. }
  157. var polyfill = function(value, opt_start, opt_end) {
  158. var length = this.length || 0;
  159. if (opt_start < 0) {
  160. opt_start = Math.max(0, length + opt_start);
  161. }
  162. if (opt_end == null || opt_end > length) {
  163. opt_end = length;
  164. }
  165. opt_end = Number(opt_end);
  166. if (opt_end < 0) {
  167. opt_end = Math.max(0, length + opt_end);
  168. }
  169. for (var i = Number(opt_start || 0); i < opt_end; i++) {
  170. this[i] = value;
  171. }
  172. return this;
  173. };
  174. return polyfill;
  175. }, 'es6', 'es3');
  176. $jscomp.findInternal = function(array, callback, thisArg) {
  177. if (array instanceof String) {
  178. array = String(array);
  179. }
  180. var len = array.length;
  181. for (var i = 0; i < len; i++) {
  182. var value = array[i];
  183. if (callback.call(thisArg, value, i, array)) {
  184. return {i:i, v:value};
  185. }
  186. }
  187. return {i:-1, v:void 0};
  188. };
  189. $jscomp.polyfill('Array.prototype.find', function(orig) {
  190. if (orig) {
  191. return orig;
  192. }
  193. var polyfill = function(callback, opt_thisArg) {
  194. return $jscomp.findInternal(this, callback, opt_thisArg).v;
  195. };
  196. return polyfill;
  197. }, 'es6', 'es3');
  198. $jscomp.polyfill('Array.prototype.findIndex', function(orig) {
  199. if (orig) {
  200. return orig;
  201. }
  202. var polyfill = function(callback, opt_thisArg) {
  203. return $jscomp.findInternal(this, callback, opt_thisArg).i;
  204. };
  205. return polyfill;
  206. }, 'es6', 'es3');
  207. $jscomp.polyfill('Array.from', function(orig) {
  208. if (orig) {
  209. return orig;
  210. }
  211. var polyfill = function(arrayLike, opt_mapFn, opt_thisArg) {
  212. $jscomp.initSymbolIterator();
  213. opt_mapFn = opt_mapFn != null ? opt_mapFn : function(x) {
  214. return x;
  215. };
  216. var result = [];
  217. $jscomp.initSymbol();
  218. $jscomp.initSymbolIterator();
  219. var iteratorFunction = arrayLike[Symbol.iterator];
  220. if (typeof iteratorFunction == 'function') {
  221. arrayLike = iteratorFunction.call(arrayLike);
  222. var next;
  223. var k = 0;
  224. while (!(next = arrayLike.next()).done) {
  225. result.push(opt_mapFn.call(opt_thisArg, next.value, k++));
  226. }
  227. } else {
  228. var len = arrayLike.length;
  229. for (var i = 0; i < len; i++) {
  230. result.push(opt_mapFn.call(opt_thisArg, arrayLike[i], i));
  231. }
  232. }
  233. return result;
  234. };
  235. return polyfill;
  236. }, 'es6', 'es3');
  237. $jscomp.polyfill('Object.is', function(orig) {
  238. if (orig) {
  239. return orig;
  240. }
  241. var polyfill = function(left, right) {
  242. if (left === right) {
  243. return left !== 0 || 1 / left === 1 / right;
  244. } else {
  245. return left !== left && right !== right;
  246. }
  247. };
  248. return polyfill;
  249. }, 'es6', 'es3');
  250. $jscomp.polyfill('Array.prototype.includes', function(orig) {
  251. if (orig) {
  252. return orig;
  253. }
  254. var includes = function(searchElement, opt_fromIndex) {
  255. var array = this;
  256. if (array instanceof String) {
  257. array = String(array);
  258. }
  259. var len = array.length;
  260. var i = opt_fromIndex || 0;
  261. if (i < 0) {
  262. i = Math.max(i + len, 0);
  263. }
  264. for (; i < len; i++) {
  265. var element = array[i];
  266. if (element === searchElement || Object.is(element, searchElement)) {
  267. return true;
  268. }
  269. }
  270. return false;
  271. };
  272. return includes;
  273. }, 'es7', 'es3');
  274. $jscomp.polyfill('Array.prototype.keys', function(orig) {
  275. if (orig) {
  276. return orig;
  277. }
  278. var polyfill = function() {
  279. return $jscomp.iteratorFromArray(this, function(i) {
  280. return i;
  281. });
  282. };
  283. return polyfill;
  284. }, 'es6', 'es3');
  285. $jscomp.polyfill('Array.of', function(orig) {
  286. if (orig) {
  287. return orig;
  288. }
  289. var polyfill = function(var_args) {
  290. return Array.from(arguments);
  291. };
  292. return polyfill;
  293. }, 'es6', 'es3');
  294. $jscomp.polyfill('Array.prototype.values', function(orig) {
  295. if (orig) {
  296. return orig;
  297. }
  298. var polyfill = function() {
  299. return $jscomp.iteratorFromArray(this, function(k, v) {
  300. return v;
  301. });
  302. };
  303. return polyfill;
  304. }, 'es8', 'es3');
  305. $jscomp.makeIterator = function(iterable) {
  306. $jscomp.initSymbolIterator();
  307. $jscomp.initSymbol();
  308. $jscomp.initSymbolIterator();
  309. var iteratorFunction = iterable[Symbol.iterator];
  310. return iteratorFunction ? iteratorFunction.call(iterable) : $jscomp.arrayIterator(iterable);
  311. };
  312. $jscomp.FORCE_POLYFILL_PROMISE = false;
  313. $jscomp.polyfill('Promise', function(NativePromise) {
  314. if (NativePromise && !$jscomp.FORCE_POLYFILL_PROMISE) {
  315. return NativePromise;
  316. }
  317. function AsyncExecutor() {
  318. this.batch_ = null;
  319. }
  320. AsyncExecutor.prototype.asyncExecute = function(f) {
  321. if (this.batch_ == null) {
  322. this.batch_ = [];
  323. this.asyncExecuteBatch_();
  324. }
  325. this.batch_.push(f);
  326. return this;
  327. };
  328. AsyncExecutor.prototype.asyncExecuteBatch_ = function() {
  329. var self = this;
  330. this.asyncExecuteFunction(function() {
  331. self.executeBatch_();
  332. });
  333. };
  334. var nativeSetTimeout = $jscomp.global['setTimeout'];
  335. AsyncExecutor.prototype.asyncExecuteFunction = function(f) {
  336. nativeSetTimeout(f, 0);
  337. };
  338. AsyncExecutor.prototype.executeBatch_ = function() {
  339. while (this.batch_ && this.batch_.length) {
  340. var executingBatch = this.batch_;
  341. this.batch_ = [];
  342. for (var i = 0; i < executingBatch.length; ++i) {
  343. var f = executingBatch[i];
  344. executingBatch[i] = null;
  345. try {
  346. f();
  347. } catch (error) {
  348. this.asyncThrow_(error);
  349. }
  350. }
  351. }
  352. this.batch_ = null;
  353. };
  354. AsyncExecutor.prototype.asyncThrow_ = function(exception) {
  355. this.asyncExecuteFunction(function() {
  356. throw exception;
  357. });
  358. };
  359. var PromiseState = {PENDING:0, FULFILLED:1, REJECTED:2};
  360. var PolyfillPromise = function(executor) {
  361. this.state_ = PromiseState.PENDING;
  362. this.result_ = undefined;
  363. this.onSettledCallbacks_ = [];
  364. var resolveAndReject = this.createResolveAndReject_();
  365. try {
  366. executor(resolveAndReject.resolve, resolveAndReject.reject);
  367. } catch (e) {
  368. resolveAndReject.reject(e);
  369. }
  370. };
  371. PolyfillPromise.prototype.createResolveAndReject_ = function() {
  372. var thisPromise = this;
  373. var alreadyCalled = false;
  374. function firstCallWins(method) {
  375. return function(x) {
  376. if (!alreadyCalled) {
  377. alreadyCalled = true;
  378. method.call(thisPromise, x);
  379. }
  380. };
  381. }
  382. return {resolve:firstCallWins(this.resolveTo_), reject:firstCallWins(this.reject_)};
  383. };
  384. PolyfillPromise.prototype.resolveTo_ = function(value) {
  385. if (value === this) {
  386. this.reject_(new TypeError('A Promise cannot resolve to itself'));
  387. } else {
  388. if (value instanceof PolyfillPromise) {
  389. this.settleSameAsPromise_(value);
  390. } else {
  391. if (isObject(value)) {
  392. this.resolveToNonPromiseObj_(value);
  393. } else {
  394. this.fulfill_(value);
  395. }
  396. }
  397. }
  398. };
  399. PolyfillPromise.prototype.resolveToNonPromiseObj_ = function(obj) {
  400. var thenMethod = undefined;
  401. try {
  402. thenMethod = obj.then;
  403. } catch (error) {
  404. this.reject_(error);
  405. return;
  406. }
  407. if (typeof thenMethod == 'function') {
  408. this.settleSameAsThenable_(thenMethod, obj);
  409. } else {
  410. this.fulfill_(obj);
  411. }
  412. };
  413. function isObject(value) {
  414. switch(typeof value) {
  415. case 'object':
  416. return value != null;
  417. case 'function':
  418. return true;
  419. default:
  420. return false;
  421. }
  422. }
  423. PolyfillPromise.prototype.reject_ = function(reason) {
  424. this.settle_(PromiseState.REJECTED, reason);
  425. };
  426. PolyfillPromise.prototype.fulfill_ = function(value) {
  427. this.settle_(PromiseState.FULFILLED, value);
  428. };
  429. PolyfillPromise.prototype.settle_ = function(settledState, valueOrReason) {
  430. if (this.state_ != PromiseState.PENDING) {
  431. throw new Error('Cannot settle(' + settledState + ', ' + valueOrReason + '): Promise already settled in state' + this.state_);
  432. }
  433. this.state_ = settledState;
  434. this.result_ = valueOrReason;
  435. this.executeOnSettledCallbacks_();
  436. };
  437. PolyfillPromise.prototype.executeOnSettledCallbacks_ = function() {
  438. if (this.onSettledCallbacks_ != null) {
  439. for (var i = 0; i < this.onSettledCallbacks_.length; ++i) {
  440. asyncExecutor.asyncExecute(this.onSettledCallbacks_[i]);
  441. }
  442. this.onSettledCallbacks_ = null;
  443. }
  444. };
  445. var asyncExecutor = new AsyncExecutor;
  446. PolyfillPromise.prototype.settleSameAsPromise_ = function(promise) {
  447. var methods = this.createResolveAndReject_();
  448. promise.callWhenSettled_(methods.resolve, methods.reject);
  449. };
  450. PolyfillPromise.prototype.settleSameAsThenable_ = function(thenMethod, thenable) {
  451. var methods = this.createResolveAndReject_();
  452. try {
  453. thenMethod.call(thenable, methods.resolve, methods.reject);
  454. } catch (error) {
  455. methods.reject(error);
  456. }
  457. };
  458. PolyfillPromise.prototype.then = function(onFulfilled, onRejected) {
  459. var resolveChild;
  460. var rejectChild;
  461. var childPromise = new PolyfillPromise(function(resolve, reject) {
  462. resolveChild = resolve;
  463. rejectChild = reject;
  464. });
  465. function createCallback(paramF, defaultF) {
  466. if (typeof paramF == 'function') {
  467. return function(x) {
  468. try {
  469. resolveChild(paramF(x));
  470. } catch (error) {
  471. rejectChild(error);
  472. }
  473. };
  474. } else {
  475. return defaultF;
  476. }
  477. }
  478. this.callWhenSettled_(createCallback(onFulfilled, resolveChild), createCallback(onRejected, rejectChild));
  479. return childPromise;
  480. };
  481. PolyfillPromise.prototype['catch'] = function(onRejected) {
  482. return this.then(undefined, onRejected);
  483. };
  484. PolyfillPromise.prototype.callWhenSettled_ = function(onFulfilled, onRejected) {
  485. var thisPromise = this;
  486. function callback() {
  487. switch(thisPromise.state_) {
  488. case PromiseState.FULFILLED:
  489. onFulfilled(thisPromise.result_);
  490. break;
  491. case PromiseState.REJECTED:
  492. onRejected(thisPromise.result_);
  493. break;
  494. default:
  495. throw new Error('Unexpected state: ' + thisPromise.state_);
  496. }
  497. }
  498. if (this.onSettledCallbacks_ == null) {
  499. asyncExecutor.asyncExecute(callback);
  500. } else {
  501. this.onSettledCallbacks_.push(callback);
  502. }
  503. };
  504. function resolvingPromise(opt_value) {
  505. if (opt_value instanceof PolyfillPromise) {
  506. return opt_value;
  507. } else {
  508. return new PolyfillPromise(function(resolve, reject) {
  509. resolve(opt_value);
  510. });
  511. }
  512. }
  513. PolyfillPromise['resolve'] = resolvingPromise;
  514. PolyfillPromise['reject'] = function(opt_reason) {
  515. return new PolyfillPromise(function(resolve, reject) {
  516. reject(opt_reason);
  517. });
  518. };
  519. PolyfillPromise['race'] = function(thenablesOrValues) {
  520. return new PolyfillPromise(function(resolve, reject) {
  521. var iterator = $jscomp.makeIterator(thenablesOrValues);
  522. for (var iterRec = iterator.next(); !iterRec.done; iterRec = iterator.next()) {
  523. resolvingPromise(iterRec.value).callWhenSettled_(resolve, reject);
  524. }
  525. });
  526. };
  527. PolyfillPromise['all'] = function(thenablesOrValues) {
  528. var iterator = $jscomp.makeIterator(thenablesOrValues);
  529. var iterRec = iterator.next();
  530. if (iterRec.done) {
  531. return resolvingPromise([]);
  532. } else {
  533. return new PolyfillPromise(function(resolveAll, rejectAll) {
  534. var resultsArray = [];
  535. var unresolvedCount = 0;
  536. function onFulfilled(i) {
  537. return function(ithResult) {
  538. resultsArray[i] = ithResult;
  539. unresolvedCount--;
  540. if (unresolvedCount == 0) {
  541. resolveAll(resultsArray);
  542. }
  543. };
  544. }
  545. do {
  546. resultsArray.push(undefined);
  547. unresolvedCount++;
  548. resolvingPromise(iterRec.value).callWhenSettled_(onFulfilled(resultsArray.length - 1), rejectAll);
  549. iterRec = iterator.next();
  550. } while (!iterRec.done);
  551. });
  552. }
  553. };
  554. return PolyfillPromise;
  555. }, 'es6', 'es3');
  556. $jscomp.polyfill('Promise.prototype.finally', function(orig) {
  557. if (orig) {
  558. return orig;
  559. }
  560. var polyfill = function(onFinally) {
  561. return this.then(function(value) {
  562. var promise = Promise.resolve(onFinally());
  563. return promise.then(function() {
  564. return value;
  565. });
  566. }, function(reason) {
  567. var promise = Promise.resolve(onFinally());
  568. return promise.then(function() {
  569. throw reason;
  570. });
  571. });
  572. };
  573. return polyfill;
  574. }, 'es9', 'es3');
  575. $jscomp.underscoreProtoCanBeSet = function() {
  576. var x = {a:true};
  577. var y = {};
  578. try {
  579. y.__proto__ = x;
  580. return y.a;
  581. } catch (e) {
  582. }
  583. return false;
  584. };
  585. $jscomp.setPrototypeOf = typeof Object.setPrototypeOf == 'function' ? Object.setPrototypeOf : $jscomp.underscoreProtoCanBeSet() ? function(target, proto) {
  586. target.__proto__ = proto;
  587. if (target.__proto__ !== proto) {
  588. throw new TypeError(target + ' is not extensible');
  589. }
  590. return target;
  591. } : null;
  592. $jscomp.generator = {};
  593. $jscomp.generator.ensureIteratorResultIsObject_ = function(result) {
  594. if (result instanceof Object) {
  595. return;
  596. }
  597. throw new TypeError('Iterator result ' + result + ' is not an object');
  598. };
  599. $jscomp.generator.Context = function() {
  600. this.isRunning_ = false;
  601. this.yieldAllIterator_ = null;
  602. this.yieldResult = undefined;
  603. this.nextAddress = 1;
  604. this.catchAddress_ = 0;
  605. this.finallyAddress_ = 0;
  606. this.abruptCompletion_ = null;
  607. this.finallyContexts_ = null;
  608. };
  609. $jscomp.generator.Context.prototype.start_ = function() {
  610. if (this.isRunning_) {
  611. throw new TypeError('Generator is already running');
  612. }
  613. this.isRunning_ = true;
  614. };
  615. $jscomp.generator.Context.prototype.stop_ = function() {
  616. this.isRunning_ = false;
  617. };
  618. $jscomp.generator.Context.prototype.jumpToErrorHandler_ = function() {
  619. this.nextAddress = this.catchAddress_ || this.finallyAddress_;
  620. };
  621. $jscomp.generator.Context.prototype.next_ = function(value) {
  622. this.yieldResult = value;
  623. };
  624. $jscomp.generator.Context.prototype.throw_ = function(e) {
  625. this.abruptCompletion_ = {exception:e, isException:true};
  626. this.jumpToErrorHandler_();
  627. };
  628. $jscomp.generator.Context.prototype['return'] = function(value) {
  629. this.abruptCompletion_ = {'return':value};
  630. this.nextAddress = this.finallyAddress_;
  631. };
  632. $jscomp.generator.Context.prototype.jumpThroughFinallyBlocks = function(nextAddress) {
  633. this.abruptCompletion_ = {jumpTo:nextAddress};
  634. this.nextAddress = this.finallyAddress_;
  635. };
  636. $jscomp.generator.Context.prototype.yield = function(value, resumeAddress) {
  637. this.nextAddress = resumeAddress;
  638. return {value:value};
  639. };
  640. $jscomp.generator.Context.prototype.yieldAll = function(iterable, resumeAddress) {
  641. var iterator = $jscomp.makeIterator(iterable);
  642. var result = iterator.next();
  643. $jscomp.generator.ensureIteratorResultIsObject_(result);
  644. if (result.done) {
  645. this.yieldResult = result.value;
  646. this.nextAddress = resumeAddress;
  647. return;
  648. }
  649. this.yieldAllIterator_ = iterator;
  650. return this.yield(result.value, resumeAddress);
  651. };
  652. $jscomp.generator.Context.prototype.jumpTo = function(nextAddress) {
  653. this.nextAddress = nextAddress;
  654. };
  655. $jscomp.generator.Context.prototype.jumpToEnd = function() {
  656. this.nextAddress = 0;
  657. };
  658. $jscomp.generator.Context.prototype.setCatchFinallyBlocks = function(catchAddress, finallyAddress) {
  659. this.catchAddress_ = catchAddress;
  660. if (finallyAddress != undefined) {
  661. this.finallyAddress_ = finallyAddress;
  662. }
  663. };
  664. $jscomp.generator.Context.prototype.setFinallyBlock = function(finallyAddress) {
  665. this.catchAddress_ = 0;
  666. this.finallyAddress_ = finallyAddress || 0;
  667. };
  668. $jscomp.generator.Context.prototype.leaveTryBlock = function(nextAddress, catchAddress) {
  669. this.nextAddress = nextAddress;
  670. this.catchAddress_ = catchAddress || 0;
  671. };
  672. $jscomp.generator.Context.prototype.enterCatchBlock = function(nextCatchBlockAddress) {
  673. this.catchAddress_ = nextCatchBlockAddress || 0;
  674. var exception = this.abruptCompletion_.exception;
  675. this.abruptCompletion_ = null;
  676. return exception;
  677. };
  678. $jscomp.generator.Context.prototype.enterFinallyBlock = function(nextCatchAddress, nextFinallyAddress, finallyDepth) {
  679. if (!finallyDepth) {
  680. this.finallyContexts_ = [this.abruptCompletion_];
  681. } else {
  682. this.finallyContexts_[finallyDepth] = this.abruptCompletion_;
  683. }
  684. this.catchAddress_ = nextCatchAddress || 0;
  685. this.finallyAddress_ = nextFinallyAddress || 0;
  686. };
  687. $jscomp.generator.Context.prototype.leaveFinallyBlock = function(nextAddress, finallyDepth) {
  688. var preservedContext = this.finallyContexts_.splice(finallyDepth || 0)[0];
  689. var abruptCompletion = this.abruptCompletion_ = this.abruptCompletion_ || preservedContext;
  690. if (abruptCompletion) {
  691. if (abruptCompletion.isException) {
  692. return this.jumpToErrorHandler_();
  693. }
  694. if (abruptCompletion.jumpTo != undefined && this.finallyAddress_ < abruptCompletion.jumpTo) {
  695. this.nextAddress = abruptCompletion.jumpTo;
  696. this.abruptCompletion_ = null;
  697. } else {
  698. this.nextAddress = this.finallyAddress_;
  699. }
  700. } else {
  701. this.nextAddress = nextAddress;
  702. }
  703. };
  704. $jscomp.generator.Context.prototype.forIn = function(object) {
  705. return new $jscomp.generator.Context.PropertyIterator(object);
  706. };
  707. $jscomp.generator.Context.PropertyIterator = function(object) {
  708. this.object_ = object;
  709. this.properties_ = [];
  710. for (var property in object) {
  711. this.properties_.push(property);
  712. }
  713. this.properties_.reverse();
  714. };
  715. $jscomp.generator.Context.PropertyIterator.prototype.getNext = function() {
  716. while (this.properties_.length > 0) {
  717. var property = this.properties_.pop();
  718. if (property in this.object_) {
  719. return property;
  720. }
  721. }
  722. return null;
  723. };
  724. $jscomp.generator.Engine_ = function(program) {
  725. this.context_ = new $jscomp.generator.Context;
  726. this.program_ = program;
  727. };
  728. $jscomp.generator.Engine_.prototype.next_ = function(value) {
  729. this.context_.start_();
  730. if (this.context_.yieldAllIterator_) {
  731. return this.yieldAllStep_(this.context_.yieldAllIterator_.next, value, this.context_.next_);
  732. }
  733. this.context_.next_(value);
  734. return this.nextStep_();
  735. };
  736. $jscomp.generator.Engine_.prototype.return_ = function(value) {
  737. this.context_.start_();
  738. var yieldAllIterator = this.context_.yieldAllIterator_;
  739. if (yieldAllIterator) {
  740. var returnFunction = 'return' in yieldAllIterator ? yieldAllIterator['return'] : function(v) {
  741. return {value:v, done:true};
  742. };
  743. return this.yieldAllStep_(returnFunction, value, this.context_['return']);
  744. }
  745. this.context_['return'](value);
  746. return this.nextStep_();
  747. };
  748. $jscomp.generator.Engine_.prototype.throw_ = function(exception) {
  749. this.context_.start_();
  750. if (this.context_.yieldAllIterator_) {
  751. return this.yieldAllStep_(this.context_.yieldAllIterator_['throw'], exception, this.context_.next_);
  752. }
  753. this.context_.throw_(exception);
  754. return this.nextStep_();
  755. };
  756. $jscomp.generator.Engine_.prototype.yieldAllStep_ = function(action, value, nextAction) {
  757. try {
  758. var result = action.call(this.context_.yieldAllIterator_, value);
  759. $jscomp.generator.ensureIteratorResultIsObject_(result);
  760. if (!result.done) {
  761. this.context_.stop_();
  762. return result;
  763. }
  764. var resultValue = result.value;
  765. } catch (e) {
  766. this.context_.yieldAllIterator_ = null;
  767. this.context_.throw_(e);
  768. return this.nextStep_();
  769. }
  770. this.context_.yieldAllIterator_ = null;
  771. nextAction.call(this.context_, resultValue);
  772. return this.nextStep_();
  773. };
  774. $jscomp.generator.Engine_.prototype.nextStep_ = function() {
  775. while (this.context_.nextAddress) {
  776. try {
  777. var yieldValue = this.program_(this.context_);
  778. if (yieldValue) {
  779. this.context_.stop_();
  780. return {value:yieldValue.value, done:false};
  781. }
  782. } catch (e) {
  783. this.context_.yieldResult = undefined;
  784. this.context_.throw_(e);
  785. }
  786. }
  787. this.context_.stop_();
  788. if (this.context_.abruptCompletion_) {
  789. var abruptCompletion = this.context_.abruptCompletion_;
  790. this.context_.abruptCompletion_ = null;
  791. if (abruptCompletion.isException) {
  792. throw abruptCompletion.exception;
  793. }
  794. return {value:abruptCompletion['return'], done:true};
  795. }
  796. return {value:undefined, done:true};
  797. };
  798. $jscomp.generator.Generator_ = function(engine) {
  799. this.next = function(opt_value) {
  800. return engine.next_(opt_value);
  801. };
  802. this['throw'] = function(exception) {
  803. return engine.throw_(exception);
  804. };
  805. this['return'] = function(value) {
  806. return engine.return_(value);
  807. };
  808. $jscomp.initSymbolIterator();
  809. $jscomp.initSymbol();
  810. $jscomp.initSymbolIterator();
  811. this[Symbol.iterator] = function() {
  812. return this;
  813. };
  814. };
  815. $jscomp.generator.createGenerator = function(generator, program) {
  816. var result = new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(program));
  817. if ($jscomp.setPrototypeOf) {
  818. $jscomp.setPrototypeOf(result, generator.prototype);
  819. }
  820. return result;
  821. };
  822. $jscomp.asyncExecutePromiseGenerator = function(generator) {
  823. function passValueToGenerator(value) {
  824. return generator.next(value);
  825. }
  826. function passErrorToGenerator(error) {
  827. return generator['throw'](error);
  828. }
  829. return new Promise(function(resolve, reject) {
  830. function handleGeneratorRecord(genRec) {
  831. if (genRec.done) {
  832. resolve(genRec.value);
  833. } else {
  834. Promise.resolve(genRec.value).then(passValueToGenerator, passErrorToGenerator).then(handleGeneratorRecord, reject);
  835. }
  836. }
  837. handleGeneratorRecord(generator.next());
  838. });
  839. };
  840. $jscomp.asyncExecutePromiseGeneratorFunction = function(generatorFunction) {
  841. return $jscomp.asyncExecutePromiseGenerator(generatorFunction());
  842. };
  843. $jscomp.asyncExecutePromiseGeneratorProgram = function(program) {
  844. return $jscomp.asyncExecutePromiseGenerator(new $jscomp.generator.Generator_(new $jscomp.generator.Engine_(program)));
  845. };
  846. $jscomp.checkEs6ConformanceViaProxy = function() {
  847. try {
  848. var proxied = {};
  849. var proxy = Object.create(new $jscomp.global['Proxy'](proxied, {'get':function(target, key, receiver) {
  850. return target == proxied && key == 'q' && receiver == proxy;
  851. }}));
  852. return proxy['q'] === true;
  853. } catch (err) {
  854. return false;
  855. }
  856. };
  857. $jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS = false;
  858. $jscomp.ES6_CONFORMANCE = $jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS && $jscomp.checkEs6ConformanceViaProxy();
  859. $jscomp.owns = function(obj, prop) {
  860. return Object.prototype.hasOwnProperty.call(obj, prop);
  861. };
  862. $jscomp.polyfill('WeakMap', function(NativeWeakMap) {
  863. function isConformant() {
  864. if (!NativeWeakMap || !Object.seal) {
  865. return false;
  866. }
  867. try {
  868. var x = Object.seal({});
  869. var y = Object.seal({});
  870. var map = new NativeWeakMap([[x, 2], [y, 3]]);
  871. if (map.get(x) != 2 || map.get(y) != 3) {
  872. return false;
  873. }
  874. map['delete'](x);
  875. map.set(y, 4);
  876. return !map.has(x) && map.get(y) == 4;
  877. } catch (err) {
  878. return false;
  879. }
  880. }
  881. if ($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS) {
  882. if (NativeWeakMap && $jscomp.ES6_CONFORMANCE) {
  883. return NativeWeakMap;
  884. }
  885. } else {
  886. if (isConformant()) {
  887. return NativeWeakMap;
  888. }
  889. }
  890. var prop = '$jscomp_hidden_' + Math.random();
  891. function insert(target) {
  892. if (!$jscomp.owns(target, prop)) {
  893. var obj = {};
  894. $jscomp.defineProperty(target, prop, {value:obj});
  895. }
  896. }
  897. function patch(name) {
  898. var prev = Object[name];
  899. if (prev) {
  900. Object[name] = function(target) {
  901. insert(target);
  902. return prev(target);
  903. };
  904. }
  905. }
  906. patch('freeze');
  907. patch('preventExtensions');
  908. patch('seal');
  909. var index = 0;
  910. var PolyfillWeakMap = function(opt_iterable) {
  911. this.id_ = (index += Math.random() + 1).toString();
  912. if (opt_iterable) {
  913. $jscomp.initSymbol();
  914. $jscomp.initSymbolIterator();
  915. var iter = $jscomp.makeIterator(opt_iterable);
  916. var entry;
  917. while (!(entry = iter.next()).done) {
  918. var item = entry.value;
  919. this.set(item[0], item[1]);
  920. }
  921. }
  922. };
  923. PolyfillWeakMap.prototype.set = function(key, value) {
  924. insert(key);
  925. if (!$jscomp.owns(key, prop)) {
  926. throw new Error('WeakMap key fail: ' + key);
  927. }
  928. key[prop][this.id_] = value;
  929. return this;
  930. };
  931. PolyfillWeakMap.prototype.get = function(key) {
  932. return $jscomp.owns(key, prop) ? key[prop][this.id_] : undefined;
  933. };
  934. PolyfillWeakMap.prototype.has = function(key) {
  935. return $jscomp.owns(key, prop) && $jscomp.owns(key[prop], this.id_);
  936. };
  937. PolyfillWeakMap.prototype['delete'] = function(key) {
  938. if (!$jscomp.owns(key, prop) || !$jscomp.owns(key[prop], this.id_)) {
  939. return false;
  940. }
  941. return delete key[prop][this.id_];
  942. };
  943. return PolyfillWeakMap;
  944. }, 'es6', 'es3');
  945. $jscomp.MapEntry = function() {
  946. this.previous;
  947. this.next;
  948. this.head;
  949. this.key;
  950. this.value;
  951. };
  952. $jscomp.polyfill('Map', function(NativeMap) {
  953. function isConformant() {
  954. if ($jscomp.ASSUME_NO_NATIVE_MAP || !NativeMap || typeof NativeMap != 'function' || !NativeMap.prototype.entries || typeof Object.seal != 'function') {
  955. return false;
  956. }
  957. try {
  958. NativeMap = NativeMap;
  959. var key = Object.seal({x:4});
  960. var map = new NativeMap($jscomp.makeIterator([[key, 's']]));
  961. if (map.get(key) != 's' || map.size != 1 || map.get({x:4}) || map.set({x:4}, 't') != map || map.size != 2) {
  962. return false;
  963. }
  964. var iter = map.entries();
  965. var item = iter.next();
  966. if (item.done || item.value[0] != key || item.value[1] != 's') {
  967. return false;
  968. }
  969. item = iter.next();
  970. if (item.done || item.value[0].x != 4 || item.value[1] != 't' || !iter.next().done) {
  971. return false;
  972. }
  973. return true;
  974. } catch (err) {
  975. return false;
  976. }
  977. }
  978. if ($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS) {
  979. if (NativeMap && $jscomp.ES6_CONFORMANCE) {
  980. return NativeMap;
  981. }
  982. } else {
  983. if (isConformant()) {
  984. return NativeMap;
  985. }
  986. }
  987. $jscomp.initSymbol();
  988. $jscomp.initSymbolIterator();
  989. var idMap = new WeakMap;
  990. var PolyfillMap = function(opt_iterable) {
  991. this.data_ = {};
  992. this.head_ = createHead();
  993. this.size = 0;
  994. if (opt_iterable) {
  995. var iter = $jscomp.makeIterator(opt_iterable);
  996. var entry;
  997. while (!(entry = iter.next()).done) {
  998. var item = entry.value;
  999. this.set(item[0], item[1]);
  1000. }
  1001. }
  1002. };
  1003. PolyfillMap.prototype.set = function(key, value) {
  1004. key = key === 0 ? 0 : key;
  1005. var r = maybeGetEntry(this, key);
  1006. if (!r.list) {
  1007. r.list = this.data_[r.id] = [];
  1008. }
  1009. if (!r.entry) {
  1010. r.entry = {next:this.head_, previous:this.head_.previous, head:this.head_, key:key, value:value};
  1011. r.list.push(r.entry);
  1012. this.head_.previous.next = r.entry;
  1013. this.head_.previous = r.entry;
  1014. this.size++;
  1015. } else {
  1016. r.entry.value = value;
  1017. }
  1018. return this;
  1019. };
  1020. PolyfillMap.prototype['delete'] = function(key) {
  1021. var r = maybeGetEntry(this, key);
  1022. if (r.entry && r.list) {
  1023. r.list.splice(r.index, 1);
  1024. if (!r.list.length) {
  1025. delete this.data_[r.id];
  1026. }
  1027. r.entry.previous.next = r.entry.next;
  1028. r.entry.next.previous = r.entry.previous;
  1029. r.entry.head = null;
  1030. this.size--;
  1031. return true;
  1032. }
  1033. return false;
  1034. };
  1035. PolyfillMap.prototype.clear = function() {
  1036. this.data_ = {};
  1037. this.head_ = this.head_.previous = createHead();
  1038. this.size = 0;
  1039. };
  1040. PolyfillMap.prototype.has = function(key) {
  1041. return !!maybeGetEntry(this, key).entry;
  1042. };
  1043. PolyfillMap.prototype.get = function(key) {
  1044. var entry = maybeGetEntry(this, key).entry;
  1045. return entry && entry.value;
  1046. };
  1047. PolyfillMap.prototype.entries = function() {
  1048. return makeIterator(this, function(entry) {
  1049. return [entry.key, entry.value];
  1050. });
  1051. };
  1052. PolyfillMap.prototype.keys = function() {
  1053. return makeIterator(this, function(entry) {
  1054. return entry.key;
  1055. });
  1056. };
  1057. PolyfillMap.prototype.values = function() {
  1058. return makeIterator(this, function(entry) {
  1059. return entry.value;
  1060. });
  1061. };
  1062. PolyfillMap.prototype.forEach = function(callback, opt_thisArg) {
  1063. var iter = this.entries();
  1064. var item;
  1065. while (!(item = iter.next()).done) {
  1066. var entry = item.value;
  1067. callback.call(opt_thisArg, entry[1], entry[0], this);
  1068. }
  1069. };
  1070. $jscomp.initSymbol();
  1071. $jscomp.initSymbolIterator();
  1072. PolyfillMap.prototype[Symbol.iterator] = PolyfillMap.prototype.entries;
  1073. var maybeGetEntry = function(map, key) {
  1074. var id = getId(key);
  1075. var list = map.data_[id];
  1076. if (list && $jscomp.owns(map.data_, id)) {
  1077. for (var index = 0; index < list.length; index++) {
  1078. var entry = list[index];
  1079. if (key !== key && entry.key !== entry.key || key === entry.key) {
  1080. return {id:id, list:list, index:index, entry:entry};
  1081. }
  1082. }
  1083. }
  1084. return {id:id, list:list, index:-1, entry:undefined};
  1085. };
  1086. var makeIterator = function(map, func) {
  1087. var entry = map.head_;
  1088. return $jscomp.iteratorPrototype(function() {
  1089. if (entry) {
  1090. while (entry.head != map.head_) {
  1091. entry = entry.previous;
  1092. }
  1093. while (entry.next != entry.head) {
  1094. entry = entry.next;
  1095. return {done:false, value:func(entry)};
  1096. }
  1097. entry = null;
  1098. }
  1099. return {done:true, value:void 0};
  1100. });
  1101. };
  1102. var createHead = function() {
  1103. var head = {};
  1104. head.previous = head.next = head.head = head;
  1105. return head;
  1106. };
  1107. var mapIndex = 0;
  1108. var getId = function(obj) {
  1109. var type = obj && typeof obj;
  1110. if (type == 'object' || type == 'function') {
  1111. obj = obj;
  1112. if (!idMap.has(obj)) {
  1113. var id = '' + ++mapIndex;
  1114. idMap.set(obj, id);
  1115. return id;
  1116. }
  1117. return idMap.get(obj);
  1118. }
  1119. return 'p_' + obj;
  1120. };
  1121. return PolyfillMap;
  1122. }, 'es6', 'es3');
  1123. $jscomp.polyfill('Math.acosh', function(orig) {
  1124. if (orig) {
  1125. return orig;
  1126. }
  1127. var polyfill = function(x) {
  1128. x = Number(x);
  1129. return Math.log(x + Math.sqrt(x * x - 1));
  1130. };
  1131. return polyfill;
  1132. }, 'es6', 'es3');
  1133. $jscomp.polyfill('Math.asinh', function(orig) {
  1134. if (orig) {
  1135. return orig;
  1136. }
  1137. var polyfill = function(x) {
  1138. x = Number(x);
  1139. if (x === 0) {
  1140. return x;
  1141. }
  1142. var y = Math.log(Math.abs(x) + Math.sqrt(x * x + 1));
  1143. return x < 0 ? -y : y;
  1144. };
  1145. return polyfill;
  1146. }, 'es6', 'es3');
  1147. $jscomp.polyfill('Math.log1p', function(orig) {
  1148. if (orig) {
  1149. return orig;
  1150. }
  1151. var polyfill = function(x) {
  1152. x = Number(x);
  1153. if (x < 0.25 && x > -0.25) {
  1154. var y = x;
  1155. var d = 1;
  1156. var z = x;
  1157. var zPrev = 0;
  1158. var s = 1;
  1159. while (zPrev != z) {
  1160. y *= x;
  1161. s *= -1;
  1162. z = (zPrev = z) + s * y / ++d;
  1163. }
  1164. return z;
  1165. }
  1166. return Math.log(1 + x);
  1167. };
  1168. return polyfill;
  1169. }, 'es6', 'es3');
  1170. $jscomp.polyfill('Math.atanh', function(orig) {
  1171. if (orig) {
  1172. return orig;
  1173. }
  1174. var log1p = Math.log1p;
  1175. var polyfill = function(x) {
  1176. x = Number(x);
  1177. return (log1p(x) - log1p(-x)) / 2;
  1178. };
  1179. return polyfill;
  1180. }, 'es6', 'es3');
  1181. $jscomp.polyfill('Math.cbrt', function(orig) {
  1182. if (orig) {
  1183. return orig;
  1184. }
  1185. var polyfill = function(x) {
  1186. if (x === 0) {
  1187. return x;
  1188. }
  1189. x = Number(x);
  1190. var y = Math.pow(Math.abs(x), 1 / 3);
  1191. return x < 0 ? -y : y;
  1192. };
  1193. return polyfill;
  1194. }, 'es6', 'es3');
  1195. $jscomp.polyfill('Math.clz32', function(orig) {
  1196. if (orig) {
  1197. return orig;
  1198. }
  1199. var polyfill = function(x) {
  1200. x = Number(x) >>> 0;
  1201. if (x === 0) {
  1202. return 32;
  1203. }
  1204. var result = 0;
  1205. if ((x & 4294901760) === 0) {
  1206. x <<= 16;
  1207. result += 16;
  1208. }
  1209. if ((x & 4278190080) === 0) {
  1210. x <<= 8;
  1211. result += 8;
  1212. }
  1213. if ((x & 4026531840) === 0) {
  1214. x <<= 4;
  1215. result += 4;
  1216. }
  1217. if ((x & 3221225472) === 0) {
  1218. x <<= 2;
  1219. result += 2;
  1220. }
  1221. if ((x & 2147483648) === 0) {
  1222. result++;
  1223. }
  1224. return result;
  1225. };
  1226. return polyfill;
  1227. }, 'es6', 'es3');
  1228. $jscomp.polyfill('Math.cosh', function(orig) {
  1229. if (orig) {
  1230. return orig;
  1231. }
  1232. var exp = Math.exp;
  1233. var polyfill = function(x) {
  1234. x = Number(x);
  1235. return (exp(x) + exp(-x)) / 2;
  1236. };
  1237. return polyfill;
  1238. }, 'es6', 'es3');
  1239. $jscomp.polyfill('Math.expm1', function(orig) {
  1240. if (orig) {
  1241. return orig;
  1242. }
  1243. var polyfill = function(x) {
  1244. x = Number(x);
  1245. if (x < .25 && x > -.25) {
  1246. var y = x;
  1247. var d = 1;
  1248. var z = x;
  1249. var zPrev = 0;
  1250. while (zPrev != z) {
  1251. y *= x / ++d;
  1252. z = (zPrev = z) + y;
  1253. }
  1254. return z;
  1255. }
  1256. return Math.exp(x) - 1;
  1257. };
  1258. return polyfill;
  1259. }, 'es6', 'es3');
  1260. $jscomp.polyfill('Math.hypot', function(orig) {
  1261. if (orig) {
  1262. return orig;
  1263. }
  1264. var polyfill = function(x, y, var_args) {
  1265. x = Number(x);
  1266. y = Number(y);
  1267. var i, z, sum;
  1268. var max = Math.max(Math.abs(x), Math.abs(y));
  1269. for (i = 2; i < arguments.length; i++) {
  1270. max = Math.max(max, Math.abs(arguments[i]));
  1271. }
  1272. if (max > 1e100 || max < 1e-100) {
  1273. if (!max) {
  1274. return max;
  1275. }
  1276. x = x / max;
  1277. y = y / max;
  1278. sum = x * x + y * y;
  1279. for (i = 2; i < arguments.length; i++) {
  1280. z = Number(arguments[i]) / max;
  1281. sum += z * z;
  1282. }
  1283. return Math.sqrt(sum) * max;
  1284. } else {
  1285. sum = x * x + y * y;
  1286. for (i = 2; i < arguments.length; i++) {
  1287. z = Number(arguments[i]);
  1288. sum += z * z;
  1289. }
  1290. return Math.sqrt(sum);
  1291. }
  1292. };
  1293. return polyfill;
  1294. }, 'es6', 'es3');
  1295. $jscomp.polyfill('Math.imul', function(orig) {
  1296. if (orig) {
  1297. return orig;
  1298. }
  1299. var polyfill = function(a, b) {
  1300. a = Number(a);
  1301. b = Number(b);
  1302. var ah = a >>> 16 & 65535;
  1303. var al = a & 65535;
  1304. var bh = b >>> 16 & 65535;
  1305. var bl = b & 65535;
  1306. var lh = ah * bl + al * bh << 16 >>> 0;
  1307. return al * bl + lh | 0;
  1308. };
  1309. return polyfill;
  1310. }, 'es6', 'es3');
  1311. $jscomp.polyfill('Math.log10', function(orig) {
  1312. if (orig) {
  1313. return orig;
  1314. }
  1315. var polyfill = function(x) {
  1316. return Math.log(x) / Math.LN10;
  1317. };
  1318. return polyfill;
  1319. }, 'es6', 'es3');
  1320. $jscomp.polyfill('Math.log2', function(orig) {
  1321. if (orig) {
  1322. return orig;
  1323. }
  1324. var polyfill = function(x) {
  1325. return Math.log(x) / Math.LN2;
  1326. };
  1327. return polyfill;
  1328. }, 'es6', 'es3');
  1329. $jscomp.polyfill('Math.sign', function(orig) {
  1330. if (orig) {
  1331. return orig;
  1332. }
  1333. var polyfill = function(x) {
  1334. x = Number(x);
  1335. return x === 0 || isNaN(x) ? x : x > 0 ? 1 : -1;
  1336. };
  1337. return polyfill;
  1338. }, 'es6', 'es3');
  1339. $jscomp.polyfill('Math.sinh', function(orig) {
  1340. if (orig) {
  1341. return orig;
  1342. }
  1343. var exp = Math.exp;
  1344. var polyfill = function(x) {
  1345. x = Number(x);
  1346. if (x === 0) {
  1347. return x;
  1348. }
  1349. return (exp(x) - exp(-x)) / 2;
  1350. };
  1351. return polyfill;
  1352. }, 'es6', 'es3');
  1353. $jscomp.polyfill('Math.tanh', function(orig) {
  1354. if (orig) {
  1355. return orig;
  1356. }
  1357. var polyfill = function(x) {
  1358. x = Number(x);
  1359. if (x === 0) {
  1360. return x;
  1361. }
  1362. var y = Math.exp(-2 * Math.abs(x));
  1363. var z = (1 - y) / (1 + y);
  1364. return x < 0 ? -z : z;
  1365. };
  1366. return polyfill;
  1367. }, 'es6', 'es3');
  1368. $jscomp.polyfill('Math.trunc', function(orig) {
  1369. if (orig) {
  1370. return orig;
  1371. }
  1372. var polyfill = function(x) {
  1373. x = Number(x);
  1374. if (isNaN(x) || x === Infinity || x === -Infinity || x === 0) {
  1375. return x;
  1376. }
  1377. var y = Math.floor(Math.abs(x));
  1378. return x < 0 ? -y : y;
  1379. };
  1380. return polyfill;
  1381. }, 'es6', 'es3');
  1382. $jscomp.polyfill('Number.EPSILON', function(orig) {
  1383. return Math.pow(2, -52);
  1384. }, 'es6', 'es3');
  1385. $jscomp.polyfill('Number.MAX_SAFE_INTEGER', function() {
  1386. return 9007199254740991;
  1387. }, 'es6', 'es3');
  1388. $jscomp.polyfill('Number.MIN_SAFE_INTEGER', function() {
  1389. return -9007199254740991;
  1390. }, 'es6', 'es3');
  1391. $jscomp.polyfill('Number.isFinite', function(orig) {
  1392. if (orig) {
  1393. return orig;
  1394. }
  1395. var polyfill = function(x) {
  1396. if (typeof x !== 'number') {
  1397. return false;
  1398. }
  1399. return !isNaN(x) && x !== Infinity && x !== -Infinity;
  1400. };
  1401. return polyfill;
  1402. }, 'es6', 'es3');
  1403. $jscomp.polyfill('Number.isInteger', function(orig) {
  1404. if (orig) {
  1405. return orig;
  1406. }
  1407. var polyfill = function(x) {
  1408. if (!Number.isFinite(x)) {
  1409. return false;
  1410. }
  1411. return x === Math.floor(x);
  1412. };
  1413. return polyfill;
  1414. }, 'es6', 'es3');
  1415. $jscomp.polyfill('Number.isNaN', function(orig) {
  1416. if (orig) {
  1417. return orig;
  1418. }
  1419. var polyfill = function(x) {
  1420. return typeof x === 'number' && isNaN(x);
  1421. };
  1422. return polyfill;
  1423. }, 'es6', 'es3');
  1424. $jscomp.polyfill('Number.isSafeInteger', function(orig) {
  1425. if (orig) {
  1426. return orig;
  1427. }
  1428. var polyfill = function(x) {
  1429. return Number.isInteger(x) && Math.abs(x) <= Number.MAX_SAFE_INTEGER;
  1430. };
  1431. return polyfill;
  1432. }, 'es6', 'es3');
  1433. $jscomp.polyfill('Number.parseFloat', function(orig) {
  1434. return orig || parseFloat;
  1435. }, 'es6', 'es3');
  1436. $jscomp.polyfill('Number.parseInt', function(orig) {
  1437. return orig || parseInt;
  1438. }, 'es6', 'es3');
  1439. $jscomp.assign = typeof Object.assign == 'function' ? Object.assign : function(target, var_args) {
  1440. for (var i = 1; i < arguments.length; i++) {
  1441. var source = arguments[i];
  1442. if (!source) {
  1443. continue;
  1444. }
  1445. for (var key in source) {
  1446. if ($jscomp.owns(source, key)) {
  1447. target[key] = source[key];
  1448. }
  1449. }
  1450. }
  1451. return target;
  1452. };
  1453. $jscomp.polyfill('Object.assign', function(orig) {
  1454. return orig || $jscomp.assign;
  1455. }, 'es6', 'es3');
  1456. $jscomp.polyfill('Object.entries', function(orig) {
  1457. if (orig) {
  1458. return orig;
  1459. }
  1460. var entries = function(obj) {
  1461. var result = [];
  1462. for (var key in obj) {
  1463. if ($jscomp.owns(obj, key)) {
  1464. result.push([key, obj[key]]);
  1465. }
  1466. }
  1467. return result;
  1468. };
  1469. return entries;
  1470. }, 'es8', 'es3');
  1471. $jscomp.polyfill('Object.getOwnPropertySymbols', function(orig) {
  1472. if (orig) {
  1473. return orig;
  1474. }
  1475. return function() {
  1476. return [];
  1477. };
  1478. }, 'es6', 'es5');
  1479. $jscomp.polyfill('Reflect.ownKeys', function(orig) {
  1480. if (orig) {
  1481. return orig;
  1482. }
  1483. var symbolPrefix = 'jscomp_symbol_';
  1484. function isSymbol(key) {
  1485. return key.substring(0, symbolPrefix.length) == symbolPrefix;
  1486. }
  1487. var polyfill = function(target) {
  1488. var keys = [];
  1489. var names = Object.getOwnPropertyNames(target);
  1490. var symbols = Object.getOwnPropertySymbols(target);
  1491. for (var i = 0; i < names.length; i++) {
  1492. (isSymbol(names[i]) ? symbols : keys).push(names[i]);
  1493. }
  1494. return keys.concat(symbols);
  1495. };
  1496. return polyfill;
  1497. }, 'es6', 'es5');
  1498. $jscomp.polyfill('Object.getOwnPropertyDescriptors', function(orig) {
  1499. if (orig) {
  1500. return orig;
  1501. }
  1502. var getOwnPropertyDescriptors = function(obj) {
  1503. var result = {};
  1504. var keys = Reflect.ownKeys(obj);
  1505. for (var i = 0; i < keys.length; i++) {
  1506. result[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
  1507. }
  1508. return result;
  1509. };
  1510. return getOwnPropertyDescriptors;
  1511. }, 'es8', 'es5');
  1512. $jscomp.polyfill('Object.setPrototypeOf', function(orig) {
  1513. return orig || $jscomp.setPrototypeOf;
  1514. }, 'es6', 'es5');
  1515. $jscomp.polyfill('Object.values', function(orig) {
  1516. if (orig) {
  1517. return orig;
  1518. }
  1519. var values = function(obj) {
  1520. var result = [];
  1521. for (var key in obj) {
  1522. if ($jscomp.owns(obj, key)) {
  1523. result.push(obj[key]);
  1524. }
  1525. }
  1526. return result;
  1527. };
  1528. return values;
  1529. }, 'es8', 'es3');
  1530. $jscomp.polyfill('Reflect.apply', function(orig) {
  1531. if (orig) {
  1532. return orig;
  1533. }
  1534. var apply = Function.prototype.apply;
  1535. var polyfill = function(target, thisArg, argList) {
  1536. return apply.call(target, thisArg, argList);
  1537. };
  1538. return polyfill;
  1539. }, 'es6', 'es3');
  1540. $jscomp.objectCreate = $jscomp.ASSUME_ES5 || typeof Object.create == 'function' ? Object.create : function(prototype) {
  1541. var ctor = function() {
  1542. };
  1543. ctor.prototype = prototype;
  1544. return new ctor;
  1545. };
  1546. $jscomp.construct = function() {
  1547. function reflectConstructWorks() {
  1548. function Base() {
  1549. }
  1550. function Derived() {
  1551. }
  1552. new Base;
  1553. Reflect.construct(Base, [], Derived);
  1554. return new Base instanceof Base;
  1555. }
  1556. if (typeof Reflect != 'undefined' && Reflect.construct) {
  1557. if (reflectConstructWorks()) {
  1558. return Reflect.construct;
  1559. }
  1560. var brokenConstruct = Reflect.construct;
  1561. var patchedConstruct = function(target, argList, opt_newTarget) {
  1562. var out = brokenConstruct(target, argList);
  1563. if (opt_newTarget) {
  1564. Reflect.setPrototypeOf(out, opt_newTarget.prototype);
  1565. }
  1566. return out;
  1567. };
  1568. return patchedConstruct;
  1569. }
  1570. function construct(target, argList, opt_newTarget) {
  1571. if (opt_newTarget === undefined) {
  1572. opt_newTarget = target;
  1573. }
  1574. var proto = opt_newTarget.prototype || Object.prototype;
  1575. var obj = $jscomp.objectCreate(proto);
  1576. var apply = Function.prototype.apply;
  1577. var out = apply.call(target, obj, argList);
  1578. return out || obj;
  1579. }
  1580. return construct;
  1581. }();
  1582. $jscomp.polyfill('Reflect.construct', function(orig) {
  1583. return $jscomp.construct;
  1584. }, 'es6', 'es3');
  1585. $jscomp.polyfill('Reflect.defineProperty', function(orig) {
  1586. if (orig) {
  1587. return orig;
  1588. }
  1589. var polyfill = function(target, propertyKey, attributes) {
  1590. try {
  1591. Object.defineProperty(target, propertyKey, attributes);
  1592. var desc = Object.getOwnPropertyDescriptor(target, propertyKey);
  1593. if (!desc) {
  1594. return false;
  1595. }
  1596. return desc.configurable === (attributes.configurable || false) && desc.enumerable === (attributes.enumerable || false) && ('value' in desc ? desc.value === attributes.value && desc.writable === (attributes.writable || false) : desc.get === attributes.get && desc.set === attributes.set);
  1597. } catch (err) {
  1598. return false;
  1599. }
  1600. };
  1601. return polyfill;
  1602. }, 'es6', 'es5');
  1603. $jscomp.polyfill('Reflect.deleteProperty', function(orig) {
  1604. if (orig) {
  1605. return orig;
  1606. }
  1607. var polyfill = function(target, propertyKey) {
  1608. if (!$jscomp.owns(target, propertyKey)) {
  1609. return true;
  1610. }
  1611. try {
  1612. return delete target[propertyKey];
  1613. } catch (err) {
  1614. return false;
  1615. }
  1616. };
  1617. return polyfill;
  1618. }, 'es6', 'es3');
  1619. $jscomp.polyfill('Reflect.getOwnPropertyDescriptor', function(orig) {
  1620. return orig || Object.getOwnPropertyDescriptor;
  1621. }, 'es6', 'es5');
  1622. $jscomp.polyfill('Reflect.getPrototypeOf', function(orig) {
  1623. return orig || Object.getPrototypeOf;
  1624. }, 'es6', 'es5');
  1625. $jscomp.findDescriptor = function(target, propertyKey) {
  1626. var obj = target;
  1627. while (obj) {
  1628. var property = Reflect.getOwnPropertyDescriptor(obj, propertyKey);
  1629. if (property) {
  1630. return property;
  1631. }
  1632. obj = Reflect.getPrototypeOf(obj);
  1633. }
  1634. return undefined;
  1635. };
  1636. $jscomp.polyfill('Reflect.get', function(orig) {
  1637. if (orig) {
  1638. return orig;
  1639. }
  1640. var polyfill = function(target, propertyKey, opt_receiver) {
  1641. if (arguments.length <= 2) {
  1642. return target[propertyKey];
  1643. }
  1644. var property = $jscomp.findDescriptor(target, propertyKey);
  1645. if (property) {
  1646. return property.get ? property.get.call(opt_receiver) : property.value;
  1647. }
  1648. return undefined;
  1649. };
  1650. return polyfill;
  1651. }, 'es6', 'es5');
  1652. $jscomp.polyfill('Reflect.has', function(orig) {
  1653. if (orig) {
  1654. return orig;
  1655. }
  1656. var polyfill = function(target, propertyKey) {
  1657. return propertyKey in target;
  1658. };
  1659. return polyfill;
  1660. }, 'es6', 'es3');
  1661. $jscomp.polyfill('Reflect.isExtensible', function(orig) {
  1662. if (orig) {
  1663. return orig;
  1664. }
  1665. if ($jscomp.ASSUME_ES5 || typeof Object.isExtensible == 'function') {
  1666. return Object.isExtensible;
  1667. }
  1668. return function() {
  1669. return true;
  1670. };
  1671. }, 'es6', 'es3');
  1672. $jscomp.polyfill('Reflect.preventExtensions', function(orig) {
  1673. if (orig) {
  1674. return orig;
  1675. }
  1676. if (!($jscomp.ASSUME_ES5 || typeof Object.preventExtensions == 'function')) {
  1677. return function() {
  1678. return false;
  1679. };
  1680. }
  1681. var polyfill = function(target) {
  1682. Object.preventExtensions(target);
  1683. return !Object.isExtensible(target);
  1684. };
  1685. return polyfill;
  1686. }, 'es6', 'es3');
  1687. $jscomp.polyfill('Reflect.set', function(orig) {
  1688. if (orig) {
  1689. return orig;
  1690. }
  1691. var polyfill = function(target, propertyKey, value, opt_receiver) {
  1692. var property = $jscomp.findDescriptor(target, propertyKey);
  1693. if (!property) {
  1694. if (Reflect.isExtensible(target)) {
  1695. target[propertyKey] = value;
  1696. return true;
  1697. }
  1698. return false;
  1699. }
  1700. if (property.set) {
  1701. property.set.call(arguments.length > 3 ? opt_receiver : target, value);
  1702. return true;
  1703. } else {
  1704. if (property.writable && !Object.isFrozen(target)) {
  1705. target[propertyKey] = value;
  1706. return true;
  1707. }
  1708. }
  1709. return false;
  1710. };
  1711. return polyfill;
  1712. }, 'es6', 'es5');
  1713. $jscomp.polyfill('Reflect.setPrototypeOf', function(orig) {
  1714. if (orig) {
  1715. return orig;
  1716. } else {
  1717. if ($jscomp.setPrototypeOf) {
  1718. var setPrototypeOf = $jscomp.setPrototypeOf;
  1719. var polyfill = function(target, proto) {
  1720. try {
  1721. setPrototypeOf(target, proto);
  1722. return true;
  1723. } catch (e) {
  1724. return false;
  1725. }
  1726. };
  1727. return polyfill;
  1728. } else {
  1729. return null;
  1730. }
  1731. }
  1732. }, 'es6', 'es5');
  1733. $jscomp.polyfill('Set', function(NativeSet) {
  1734. function isConformant() {
  1735. if ($jscomp.ASSUME_NO_NATIVE_SET || !NativeSet || typeof NativeSet != 'function' || !NativeSet.prototype.entries || typeof Object.seal != 'function') {
  1736. return false;
  1737. }
  1738. try {
  1739. NativeSet = NativeSet;
  1740. var value = Object.seal({x:4});
  1741. var set = new NativeSet($jscomp.makeIterator([value]));
  1742. if (!set.has(value) || set.size != 1 || set.add(value) != set || set.size != 1 || set.add({x:4}) != set || set.size != 2) {
  1743. return false;
  1744. }
  1745. var iter = set.entries();
  1746. var item = iter.next();
  1747. if (item.done || item.value[0] != value || item.value[1] != value) {
  1748. return false;
  1749. }
  1750. item = iter.next();
  1751. if (item.done || item.value[0] == value || item.value[0].x != 4 || item.value[1] != item.value[0]) {
  1752. return false;
  1753. }
  1754. return iter.next().done;
  1755. } catch (err) {
  1756. return false;
  1757. }
  1758. }
  1759. if ($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS) {
  1760. if (NativeSet && $jscomp.ES6_CONFORMANCE) {
  1761. return NativeSet;
  1762. }
  1763. } else {
  1764. if (isConformant()) {
  1765. return NativeSet;
  1766. }
  1767. }
  1768. $jscomp.initSymbol();
  1769. $jscomp.initSymbolIterator();
  1770. var PolyfillSet = function(opt_iterable) {
  1771. this.map_ = new Map;
  1772. if (opt_iterable) {
  1773. var iter = $jscomp.makeIterator(opt_iterable);
  1774. var entry;
  1775. while (!(entry = iter.next()).done) {
  1776. var item = entry.value;
  1777. this.add(item);
  1778. }
  1779. }
  1780. this.size = this.map_.size;
  1781. };
  1782. PolyfillSet.prototype.add = function(value) {
  1783. value = value === 0 ? 0 : value;
  1784. this.map_.set(value, value);
  1785. this.size = this.map_.size;
  1786. return this;
  1787. };
  1788. PolyfillSet.prototype['delete'] = function(value) {
  1789. var result = this.map_['delete'](value);
  1790. this.size = this.map_.size;
  1791. return result;
  1792. };
  1793. PolyfillSet.prototype.clear = function() {
  1794. this.map_.clear();
  1795. this.size = 0;
  1796. };
  1797. PolyfillSet.prototype.has = function(value) {
  1798. return this.map_.has(value);
  1799. };
  1800. PolyfillSet.prototype.entries = function() {
  1801. return this.map_.entries();
  1802. };
  1803. PolyfillSet.prototype.values = function() {
  1804. return this.map_.values();
  1805. };
  1806. PolyfillSet.prototype.keys = PolyfillSet.prototype.values;
  1807. $jscomp.initSymbol();
  1808. $jscomp.initSymbolIterator();
  1809. PolyfillSet.prototype[Symbol.iterator] = PolyfillSet.prototype.values;
  1810. PolyfillSet.prototype.forEach = function(callback, opt_thisArg) {
  1811. var set = this;
  1812. this.map_.forEach(function(value) {
  1813. return callback.call(opt_thisArg, value, value, set);
  1814. });
  1815. };
  1816. return PolyfillSet;
  1817. }, 'es6', 'es3');
  1818. $jscomp.checkStringArgs = function(thisArg, arg, func) {
  1819. if (thisArg == null) {
  1820. throw new TypeError("The 'this' value for String.prototype." + func + ' must not be null or undefined');
  1821. }
  1822. if (arg instanceof RegExp) {
  1823. throw new TypeError('First argument to String.prototype.' + func + ' must not be a regular expression');
  1824. }
  1825. return thisArg + '';
  1826. };
  1827. $jscomp.polyfill('String.prototype.codePointAt', function(orig) {
  1828. if (orig) {
  1829. return orig;
  1830. }
  1831. var polyfill = function(position) {
  1832. var string = $jscomp.checkStringArgs(this, null, 'codePointAt');
  1833. var size = string.length;
  1834. position = Number(position) || 0;
  1835. if (!(position >= 0 && position < size)) {
  1836. return void 0;
  1837. }
  1838. position = position | 0;
  1839. var first = string.charCodeAt(position);
  1840. if (first < 55296 || first > 56319 || position + 1 === size) {
  1841. return first;
  1842. }
  1843. var second = string.charCodeAt(position + 1);
  1844. if (second < 56320 || second > 57343) {
  1845. return first;
  1846. }
  1847. return (first - 55296) * 1024 + second + 9216;
  1848. };
  1849. return polyfill;
  1850. }, 'es6', 'es3');
  1851. $jscomp.polyfill('String.prototype.endsWith', function(orig) {
  1852. if (orig) {
  1853. return orig;
  1854. }
  1855. var polyfill = function(searchString, opt_position) {
  1856. var string = $jscomp.checkStringArgs(this, searchString, 'endsWith');
  1857. searchString = searchString + '';
  1858. if (opt_position === void 0) {
  1859. opt_position = string.length;
  1860. }
  1861. var i = Math.max(0, Math.min(opt_position | 0, string.length));
  1862. var j = searchString.length;
  1863. while (j > 0 && i > 0) {
  1864. if (string[--i] != searchString[--j]) {
  1865. return false;
  1866. }
  1867. }
  1868. return j <= 0;
  1869. };
  1870. return polyfill;
  1871. }, 'es6', 'es3');
  1872. $jscomp.polyfill('String.fromCodePoint', function(orig) {
  1873. if (orig) {
  1874. return orig;
  1875. }
  1876. var polyfill = function(var_args) {
  1877. var result = '';
  1878. for (var i = 0; i < arguments.length; i++) {
  1879. var code = Number(arguments[i]);
  1880. if (code < 0 || code > 1114111 || code !== Math.floor(code)) {
  1881. throw new RangeError('invalid_code_point ' + code);
  1882. }
  1883. if (code <= 65535) {
  1884. result += String.fromCharCode(code);
  1885. } else {
  1886. code -= 65536;
  1887. result += String.fromCharCode(code >>> 10 & 1023 | 55296);
  1888. result += String.fromCharCode(code & 1023 | 56320);
  1889. }
  1890. }
  1891. return result;
  1892. };
  1893. return polyfill;
  1894. }, 'es6', 'es3');
  1895. $jscomp.polyfill('String.prototype.includes', function(orig) {
  1896. if (orig) {
  1897. return orig;
  1898. }
  1899. var polyfill = function(searchString, opt_position) {
  1900. var string = $jscomp.checkStringArgs(this, searchString, 'includes');
  1901. return string.indexOf(searchString, opt_position || 0) !== -1;
  1902. };
  1903. return polyfill;
  1904. }, 'es6', 'es3');
  1905. $jscomp.polyfill('String.prototype.repeat', function(orig) {
  1906. if (orig) {
  1907. return orig;
  1908. }
  1909. var polyfill = function(copies) {
  1910. var string = $jscomp.checkStringArgs(this, null, 'repeat');
  1911. if (copies < 0 || copies > 1342177279) {
  1912. throw new RangeError('Invalid count value');
  1913. }
  1914. copies = copies | 0;
  1915. var result = '';
  1916. while (copies) {
  1917. if (copies & 1) {
  1918. result += string;
  1919. }
  1920. if (copies >>>= 1) {
  1921. string += string;
  1922. }
  1923. }
  1924. return result;
  1925. };
  1926. return polyfill;
  1927. }, 'es6', 'es3');
  1928. $jscomp.stringPadding = function(padString, padLength) {
  1929. var padding = padString !== undefined ? String(padString) : ' ';
  1930. if (!(padLength > 0) || !padding) {
  1931. return '';
  1932. }
  1933. var repeats = Math.ceil(padLength / padding.length);
  1934. return padding.repeat(repeats).substring(0, padLength);
  1935. };
  1936. $jscomp.polyfill('String.prototype.padEnd', function(orig) {
  1937. if (orig) {
  1938. return orig;
  1939. }
  1940. var padEnd = function(targetLength, opt_padString) {
  1941. var string = $jscomp.checkStringArgs(this, null, 'padStart');
  1942. var padLength = targetLength - string.length;
  1943. return string + $jscomp.stringPadding(opt_padString, padLength);
  1944. };
  1945. return padEnd;
  1946. }, 'es8', 'es3');
  1947. $jscomp.polyfill('String.prototype.padStart', function(orig) {
  1948. if (orig) {
  1949. return orig;
  1950. }
  1951. var padStart = function(targetLength, opt_padString) {
  1952. var string = $jscomp.checkStringArgs(this, null, 'padStart');
  1953. var padLength = targetLength - string.length;
  1954. return $jscomp.stringPadding(opt_padString, padLength) + string;
  1955. };
  1956. return padStart;
  1957. }, 'es8', 'es3');
  1958. $jscomp.polyfill('String.prototype.startsWith', function(orig) {
  1959. if (orig) {
  1960. return orig;
  1961. }
  1962. var polyfill = function(searchString, opt_position) {
  1963. var string = $jscomp.checkStringArgs(this, searchString, 'startsWith');
  1964. searchString = searchString + '';
  1965. var strLen = string.length;
  1966. var searchLen = searchString.length;
  1967. var i = Math.max(0, Math.min(opt_position | 0, string.length));
  1968. var j = 0;
  1969. while (j < searchLen && i < strLen) {
  1970. if (string[i++] != searchString[j++]) {
  1971. return false;
  1972. }
  1973. }
  1974. return j >= searchLen;
  1975. };
  1976. return polyfill;
  1977. }, 'es6', 'es3');
  1978. $jscomp.arrayFromIterator = function(iterator) {
  1979. var i;
  1980. var arr = [];
  1981. while (!(i = iterator.next()).done) {
  1982. arr.push(i.value);
  1983. }
  1984. return arr;
  1985. };
  1986. $jscomp.arrayFromIterable = function(iterable) {
  1987. if (iterable instanceof Array) {
  1988. return iterable;
  1989. } else {
  1990. return $jscomp.arrayFromIterator($jscomp.makeIterator(iterable));
  1991. }
  1992. };
  1993. $jscomp.inherits = function(childCtor, parentCtor) {
  1994. childCtor.prototype = $jscomp.objectCreate(parentCtor.prototype);
  1995. childCtor.prototype.constructor = childCtor;
  1996. if ($jscomp.setPrototypeOf) {
  1997. var setPrototypeOf = $jscomp.setPrototypeOf;
  1998. setPrototypeOf(childCtor, parentCtor);
  1999. } else {
  2000. for (var p in parentCtor) {
  2001. if (p == 'prototype') {
  2002. continue;
  2003. }
  2004. if (Object.defineProperties) {
  2005. var descriptor = Object.getOwnPropertyDescriptor(parentCtor, p);
  2006. if (descriptor) {
  2007. Object.defineProperty(childCtor, p, descriptor);
  2008. }
  2009. } else {
  2010. childCtor[p] = parentCtor[p];
  2011. }
  2012. }
  2013. }
  2014. childCtor.superClass_ = parentCtor.prototype;
  2015. };
  2016. $jscomp.polyfill('WeakSet', function(NativeWeakSet) {
  2017. function isConformant() {
  2018. if (!NativeWeakSet || !Object.seal) {
  2019. return false;
  2020. }
  2021. try {
  2022. var x = Object.seal({});
  2023. var y = Object.seal({});
  2024. var set = new NativeWeakSet([x]);
  2025. if (!set.has(x) || set.has(y)) {
  2026. return false;
  2027. }
  2028. set['delete'](x);
  2029. set.add(y);
  2030. return !set.has(x) && set.has(y);
  2031. } catch (err) {
  2032. return false;
  2033. }
  2034. }
  2035. if ($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS) {
  2036. if (NativeWeakSet && $jscomp.ES6_CONFORMANCE) {
  2037. return NativeWeakSet;
  2038. }
  2039. } else {
  2040. if (isConformant()) {
  2041. return NativeWeakSet;
  2042. }
  2043. }
  2044. var PolyfillWeakSet = function(opt_iterable) {
  2045. this.map_ = new WeakMap;
  2046. if (opt_iterable) {
  2047. $jscomp.initSymbol();
  2048. $jscomp.initSymbolIterator();
  2049. var iter = $jscomp.makeIterator(opt_iterable);
  2050. var entry;
  2051. while (!(entry = iter.next()).done) {
  2052. var item = entry.value;
  2053. this.add(item);
  2054. }
  2055. }
  2056. };
  2057. PolyfillWeakSet.prototype.add = function(elem) {
  2058. this.map_.set(elem, true);
  2059. return this;
  2060. };
  2061. PolyfillWeakSet.prototype.has = function(elem) {
  2062. return this.map_.has(elem);
  2063. };
  2064. PolyfillWeakSet.prototype['delete'] = function(elem) {
  2065. return this.map_['delete'](elem);
  2066. };
  2067. return PolyfillWeakSet;
  2068. }, 'es6', 'es3');
  2069. try {
  2070. if (Array.prototype.values.toString().indexOf('[native code]') == -1) {
  2071. delete Array.prototype.values;
  2072. }
  2073. } catch (e) {
  2074. }
  2075. Ext.define('Ext.draw.ContainerBase', {extend:'Ext.Container', constructor:function(config) {
  2076. this.callParent([config]);
  2077. this.initAnimator();
  2078. }, onResize:function(width, height, oldWidth, oldHeight) {
  2079. this.handleResize({width:width, height:height}, true);
  2080. }, addElementListener:function() {
  2081. var el = this.element;
  2082. el.on.apply(el, arguments);
  2083. }, removeElementListener:function() {
  2084. var el = this.element;
  2085. el.un.apply(el, arguments);
  2086. }, preview:function(image) {
  2087. var item;
  2088. image = image || this.getImage();
  2089. if (image.type === 'svg-markup') {
  2090. item = {xtype:'container', html:image.data};
  2091. } else {
  2092. item = {xtype:'image', mode:'img', imageCls:'', cls:Ext.baseCSSPrefix + 'chart-preview', src:image.data};
  2093. }
  2094. Ext.Viewport.add({xtype:'panel', layout:'fit', modal:true, border:1, shadow:true, width:'90%', height:'90%', hideOnMaskTap:true, centered:true, floated:true, scrollable:false, closable:true, closeAction:'hide', items:[item], listeners:{hide:function() {
  2095. this.destroy();
  2096. }}}).show();
  2097. }});
  2098. Ext.define('Ext.draw.SurfaceBase', {extend:'Ext.Widget', getOwnerBody:function() {
  2099. return this.getRefOwner().bodyElement;
  2100. }});
  2101. Ext.define('Ext.draw.sprite.AnimationParser', function() {
  2102. function compute(from, to, delta) {
  2103. return from + (to - from) * delta;
  2104. }
  2105. return {singleton:true, attributeRe:/^url\(#([a-zA-Z-]+)\)$/, requires:['Ext.draw.Color'], color:{parseInitial:function(color1, color2) {
  2106. if (Ext.isString(color1)) {
  2107. color1 = Ext.util.Color.create(color1);
  2108. }
  2109. if (Ext.isString(color2)) {
  2110. color2 = Ext.util.Color.create(color2);
  2111. }
  2112. if (color1 && color1.isColor && (color2 && color2.isColor)) {
  2113. return [[color1.r, color1.g, color1.b, color1.a], [color2.r, color2.g, color2.b, color2.a]];
  2114. } else {
  2115. return [color1 || color2, color2 || color1];
  2116. }
  2117. }, compute:function(from, to, delta) {
  2118. if (!Ext.isArray(from) || !Ext.isArray(to)) {
  2119. return to || from;
  2120. } else {
  2121. return [compute(from[0], to[0], delta), compute(from[1], to[1], delta), compute(from[2], to[2], delta), compute(from[3], to[3], delta)];
  2122. }
  2123. }, serve:function(array) {
  2124. var color = Ext.util.Color.fly(array[0], array[1], array[2], array[3]);
  2125. return color.toString();
  2126. }}, number:{parse:function(n) {
  2127. return n === null ? null : +n;
  2128. }, compute:function(from, to, delta) {
  2129. if (!Ext.isNumber(from) || !Ext.isNumber(to)) {
  2130. return to || from;
  2131. } else {
  2132. return compute(from, to, delta);
  2133. }
  2134. }}, angle:{parseInitial:function(from, to) {
  2135. if (to - from > Math.PI) {
  2136. to -= Math.PI * 2;
  2137. } else {
  2138. if (to - from < -Math.PI) {
  2139. to += Math.PI * 2;
  2140. }
  2141. }
  2142. return [from, to];
  2143. }, compute:function(from, to, delta) {
  2144. if (!Ext.isNumber(from) || !Ext.isNumber(to)) {
  2145. return to || from;
  2146. } else {
  2147. return compute(from, to, delta);
  2148. }
  2149. }}, path:{parseInitial:function(from, to) {
  2150. var fromStripes = from.toStripes(), toStripes = to.toStripes(), i, j, fromLength = fromStripes.length, toLength = toStripes.length, fromStripe, toStripe, length, lastStripe = toStripes[toLength - 1], endPoint = [lastStripe[lastStripe.length - 2], lastStripe[lastStripe.length - 1]];
  2151. for (i = fromLength; i < toLength; i++) {
  2152. fromStripes.push(fromStripes[fromLength - 1].slice(0));
  2153. }
  2154. for (i = toLength; i < fromLength; i++) {
  2155. toStripes.push(endPoint.slice(0));
  2156. }
  2157. length = fromStripes.length;
  2158. toStripes.path = to;
  2159. toStripes.temp = new Ext.draw.Path;
  2160. for (i = 0; i < length; i++) {
  2161. fromStripe = fromStripes[i];
  2162. toStripe = toStripes[i];
  2163. fromLength = fromStripe.length;
  2164. toLength = toStripe.length;
  2165. toStripes.temp.commands.push('M');
  2166. for (j = toLength; j < fromLength; j += 6) {
  2167. toStripe.push(endPoint[0], endPoint[1], endPoint[0], endPoint[1], endPoint[0], endPoint[1]);
  2168. }
  2169. lastStripe = toStripes[toStripes.length - 1];
  2170. endPoint = [lastStripe[lastStripe.length - 2], lastStripe[lastStripe.length - 1]];
  2171. for (j = fromLength; j < toLength; j += 6) {
  2172. fromStripe.push(endPoint[0], endPoint[1], endPoint[0], endPoint[1], endPoint[0], endPoint[1]);
  2173. }
  2174. for (i = 0; i < toStripe.length; i++) {
  2175. toStripe[i] -= fromStripe[i];
  2176. }
  2177. for (i = 2; i < toStripe.length; i += 6) {
  2178. toStripes.temp.commands.push('C');
  2179. }
  2180. }
  2181. return [fromStripes, toStripes];
  2182. }, compute:function(fromStripes, toStripes, delta) {
  2183. if (delta >= 1) {
  2184. return toStripes.path;
  2185. }
  2186. var i = 0, ln = fromStripes.length, j = 0, ln2, from, to, temp = toStripes.temp.params, pos = 0;
  2187. for (; i < ln; i++) {
  2188. from = fromStripes[i];
  2189. to = toStripes[i];
  2190. ln2 = from.length;
  2191. for (j = 0; j < ln2; j++) {
  2192. temp[pos++] = to[j] * delta + from[j];
  2193. }
  2194. }
  2195. return toStripes.temp;
  2196. }}, data:{compute:function(from, to, delta, target) {
  2197. var iMaxFrom = from.length - 1, iMaxTo = to.length - 1, iMax = Math.max(iMaxFrom, iMaxTo), i, start, end;
  2198. if (!target || target === from) {
  2199. target = [];
  2200. }
  2201. target.length = iMax + 1;
  2202. for (i = 0; i <= iMax; i++) {
  2203. start = from[Math.min(i, iMaxFrom)];
  2204. end = to[Math.min(i, iMaxTo)];
  2205. if (Ext.isNumber(start)) {
  2206. if (!Ext.isNumber(end)) {
  2207. end = 0;
  2208. }
  2209. target[i] = start + (end - start) * delta;
  2210. } else {
  2211. target[i] = end;
  2212. }
  2213. }
  2214. return target;
  2215. }}, text:{compute:function(from, to, delta) {
  2216. return from.substr(0, Math.round(from.length * (1 - delta))) + to.substr(Math.round(to.length * (1 - delta)));
  2217. }}, limited:'number', limited01:'number'};
  2218. });
  2219. (function() {
  2220. if (!Ext.global.Float32Array) {
  2221. var Float32Array = function(array) {
  2222. var i, len;
  2223. if (typeof array === 'number') {
  2224. this.length = array;
  2225. } else {
  2226. if ('length' in array) {
  2227. this.length = array.length;
  2228. for (i = 0, len = array.length; i < len; i++) {
  2229. this[i] = +array[i];
  2230. }
  2231. }
  2232. }
  2233. };
  2234. Float32Array.prototype = [];
  2235. Ext.global.Float32Array = Float32Array;
  2236. }
  2237. })();
  2238. Ext.define('Ext.draw.Draw', {singleton:true, radian:Math.PI / 180, pi2:Math.PI * 2, reflectFn:function(a) {
  2239. return a;
  2240. }, rad:function(degrees) {
  2241. return degrees % 360 * this.radian;
  2242. }, degrees:function(radian) {
  2243. return radian / this.radian % 360;
  2244. }, isBBoxIntersect:function(bbox1, bbox2, padding) {
  2245. padding = padding || 0;
  2246. return Math.max(bbox1.x, bbox2.x) - padding > Math.min(bbox1.x + bbox1.width, bbox2.x + bbox2.width) || Math.max(bbox1.y, bbox2.y) - padding > Math.min(bbox1.y + bbox1.height, bbox2.y + bbox2.height);
  2247. }, isPointInBBox:function(x, y, bbox) {
  2248. return !!bbox && x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
  2249. }, naturalSpline:function(points) {
  2250. var i, j, ln = points.length, nd, d, y, ny, r = 0, zs = new Float32Array(points.length), result = new Float32Array(points.length * 3 - 2);
  2251. zs[0] = 0;
  2252. zs[ln - 1] = 0;
  2253. for (i = 1; i < ln - 1; i++) {
  2254. zs[i] = points[i + 1] + points[i - 1] - 2 * points[i] - zs[i - 1];
  2255. r = 1 / (4 - r);
  2256. zs[i] *= r;
  2257. }
  2258. for (i = ln - 2; i > 0; i--) {
  2259. r = 3.732050807568877 + 48.248711305964385 / (-13.928203230275537 + Math.pow(0.07179676972449123, i));
  2260. zs[i] -= zs[i + 1] * r;
  2261. }
  2262. ny = points[0];
  2263. nd = ny - zs[0];
  2264. for (i = 0, j = 0; i < ln - 1; j += 3) {
  2265. y = ny;
  2266. d = nd;
  2267. i++;
  2268. ny = points[i];
  2269. nd = ny - zs[i];
  2270. result[j] = y;
  2271. result[j + 1] = (nd + 2 * d) / 3;
  2272. result[j + 2] = (nd * 2 + d) / 3;
  2273. }
  2274. result[j] = ny;
  2275. return result;
  2276. }, spline:function(points) {
  2277. return this.naturalSpline(points);
  2278. }, cardinalToBezier:function(P1, P2, P3, P4, tension) {
  2279. return [P2, P2 + (P3 - P1) / 6 * tension, P3 - (P4 - P2) / 6 * tension, P3];
  2280. }, cardinalSpline:function(P, tension) {
  2281. var n = P.length, result = new Float32Array(n * 3 - 2), i, bezier;
  2282. if (tension === undefined) {
  2283. tension = 0.5;
  2284. }
  2285. bezier = this.cardinalToBezier(P[0], P[0], P[1], P[2], tension);
  2286. result[0] = bezier[0];
  2287. result[1] = bezier[1];
  2288. result[2] = bezier[2];
  2289. result[3] = bezier[3];
  2290. for (i = 0; i < n - 3; i++) {
  2291. bezier = this.cardinalToBezier(P[i], P[i + 1], P[i + 2], P[i + 3], tension);
  2292. result[4 + i * 3] = bezier[1];
  2293. result[4 + i * 3 + 1] = bezier[2];
  2294. result[4 + i * 3 + 2] = bezier[3];
  2295. }
  2296. bezier = this.cardinalToBezier(P[n - 3], P[n - 2], P[n - 1], P[n - 1], tension);
  2297. result[4 + i * 3] = bezier[1];
  2298. result[4 + i * 3 + 1] = bezier[2];
  2299. result[4 + i * 3 + 2] = bezier[3];
  2300. return result;
  2301. }, getAnchors:function(prevX, prevY, curX, curY, nextX, nextY, value) {
  2302. var PI = Math.PI, halfPI = PI / 2, abs = Math.abs, sin = Math.sin, cos = Math.cos, atan = Math.atan, control1Length, control2Length, control1Angle, control2Angle, control1X, control1Y, control2X, control2Y, alpha;
  2303. value = value || 4;
  2304. control1Length = (curX - prevX) / value;
  2305. control2Length = (nextX - curX) / value;
  2306. if (curY >= prevY && curY >= nextY || curY <= prevY && curY <= nextY) {
  2307. control1Angle = control2Angle = halfPI;
  2308. } else {
  2309. control1Angle = atan((curX - prevX) / abs(curY - prevY));
  2310. if (prevY < curY) {
  2311. control1Angle = PI - control1Angle;
  2312. }
  2313. control2Angle = atan((nextX - curX) / abs(curY - nextY));
  2314. if (nextY < curY) {
  2315. control2Angle = PI - control2Angle;
  2316. }
  2317. }
  2318. alpha = halfPI - (control1Angle + control2Angle) % (PI * 2) / 2;
  2319. if (alpha > halfPI) {
  2320. alpha -= PI;
  2321. }
  2322. control1Angle += alpha;
  2323. control2Angle += alpha;
  2324. control1X = curX - control1Length * sin(control1Angle);
  2325. control1Y = curY + control1Length * cos(control1Angle);
  2326. control2X = curX + control2Length * sin(control2Angle);
  2327. control2Y = curY + control2Length * cos(control2Angle);
  2328. if (curY > prevY && control1Y < prevY || curY < prevY && control1Y > prevY) {
  2329. control1X += abs(prevY - control1Y) * (control1X - curX) / (control1Y - curY);
  2330. control1Y = prevY;
  2331. }
  2332. if (curY > nextY && control2Y < nextY || curY < nextY && control2Y > nextY) {
  2333. control2X -= abs(nextY - control2Y) * (control2X - curX) / (control2Y - curY);
  2334. control2Y = nextY;
  2335. }
  2336. return {x1:control1X, y1:control1Y, x2:control2X, y2:control2Y};
  2337. }, smooth:function(dataX, dataY, value) {
  2338. var ln = dataX.length, prevX, prevY, curX, curY, nextX, nextY, x, y, smoothX = [], smoothY = [], i, anchors;
  2339. for (i = 0; i < ln - 1; i++) {
  2340. prevX = dataX[i];
  2341. prevY = dataY[i];
  2342. if (i === 0) {
  2343. x = prevX;
  2344. y = prevY;
  2345. smoothX.push(x);
  2346. smoothY.push(y);
  2347. if (ln === 1) {
  2348. break;
  2349. }
  2350. }
  2351. curX = dataX[i + 1];
  2352. curY = dataY[i + 1];
  2353. nextX = dataX[i + 2];
  2354. nextY = dataY[i + 2];
  2355. if (!(Ext.isNumber(nextX) && Ext.isNumber(nextY))) {
  2356. smoothX.push(x, curX, curX);
  2357. smoothY.push(y, curY, curY);
  2358. break;
  2359. }
  2360. anchors = this.getAnchors(prevX, prevY, curX, curY, nextX, nextY, value);
  2361. smoothX.push(x, anchors.x1, curX);
  2362. smoothY.push(y, anchors.y1, curY);
  2363. x = anchors.x2;
  2364. y = anchors.y2;
  2365. }
  2366. return {smoothX:smoothX, smoothY:smoothY};
  2367. }, beginUpdateIOS:Ext.os.is.iOS ? function() {
  2368. this.iosUpdateEl = Ext.getBody().createChild({'data-sticky':true, style:'position: absolute; top: 0px; bottom: 0px; left: 0px; right: 0px; ' + 'background: rgba(0,0,0,0.001); z-index: 100000'});
  2369. } : Ext.emptyFn, endUpdateIOS:function() {
  2370. this.iosUpdateEl = Ext.destroy(this.iosUpdateEl);
  2371. }});
  2372. Ext.define('Ext.draw.gradient.Gradient', {requires:['Ext.draw.Color'], isGradient:true, config:{stops:[]}, applyStops:function(newStops) {
  2373. var stops = [], ln = newStops.length, i, stop, color;
  2374. for (i = 0; i < ln; i++) {
  2375. stop = newStops[i];
  2376. color = stop.color;
  2377. if (!(color && color.isColor)) {
  2378. color = Ext.util.Color.fly(color || Ext.util.Color.NONE);
  2379. }
  2380. stops.push({offset:Math.min(1, Math.max(0, 'offset' in stop ? stop.offset : stop.position || 0)), color:color.toString()});
  2381. }
  2382. stops.sort(function(a, b) {
  2383. return a.offset - b.offset;
  2384. });
  2385. return stops;
  2386. }, onClassExtended:function(subClass, member) {
  2387. if (!member.alias && member.type) {
  2388. member.alias = 'gradient.' + member.type;
  2389. }
  2390. }, constructor:function(config) {
  2391. this.initConfig(config);
  2392. }, generateGradient:Ext.emptyFn});
  2393. Ext.define('Ext.draw.gradient.GradientDefinition', {singleton:true, urlStringRe:/^url\(#([\w-]+)\)$/, gradients:{}, add:function(gradients) {
  2394. var store = this.gradients, i, n, gradient;
  2395. for (i = 0, n = gradients.length; i < n; i++) {
  2396. gradient = gradients[i];
  2397. if (Ext.isString(gradient.id)) {
  2398. store[gradient.id] = gradient;
  2399. }
  2400. }
  2401. }, get:function(str) {
  2402. var store = this.gradients, match = str.match(this.urlStringRe), gradient;
  2403. if (match && match[1] && (gradient = store[match[1]])) {
  2404. return gradient || str;
  2405. }
  2406. return str;
  2407. }});
  2408. Ext.define('Ext.draw.sprite.AttributeParser', {singleton:true, attributeRe:/^url\(#([a-zA-Z-]+)\)$/, requires:['Ext.draw.Color', 'Ext.draw.gradient.GradientDefinition'], 'default':Ext.identityFn, string:function(n) {
  2409. return String(n);
  2410. }, number:function(n) {
  2411. if (Ext.isNumber(+n)) {
  2412. return n;
  2413. }
  2414. }, angle:function(n) {
  2415. if (Ext.isNumber(n)) {
  2416. n %= Math.PI * 2;
  2417. if (n < -Math.PI) {
  2418. n += Math.PI * 2;
  2419. } else {
  2420. if (n >= Math.PI) {
  2421. n -= Math.PI * 2;
  2422. }
  2423. }
  2424. return n;
  2425. }
  2426. }, data:function(n) {
  2427. if (Ext.isArray(n)) {
  2428. return n.slice();
  2429. } else {
  2430. if (n instanceof Float32Array) {
  2431. return new Float32Array(n);
  2432. }
  2433. }
  2434. }, bool:function(n) {
  2435. return !!n;
  2436. }, color:function(n) {
  2437. if (n && n.isColor) {
  2438. return n.toString();
  2439. } else {
  2440. if (n && n.isGradient) {
  2441. return n;
  2442. } else {
  2443. if (!n) {
  2444. return Ext.util.Color.NONE;
  2445. } else {
  2446. if (Ext.isString(n)) {
  2447. if (n.substr(0, 3) === 'url') {
  2448. n = Ext.draw.gradient.GradientDefinition.get(n);
  2449. if (Ext.isString(n)) {
  2450. return n;
  2451. }
  2452. } else {
  2453. return Ext.util.Color.fly(n).toString();
  2454. }
  2455. }
  2456. }
  2457. }
  2458. }
  2459. if (n.type === 'linear') {
  2460. return Ext.create('Ext.draw.gradient.Linear', n);
  2461. } else {
  2462. if (n.type === 'radial') {
  2463. return Ext.create('Ext.draw.gradient.Radial', n);
  2464. } else {
  2465. if (n.type === 'pattern') {
  2466. return Ext.create('Ext.draw.gradient.Pattern', n);
  2467. } else {
  2468. return Ext.util.Color.NONE;
  2469. }
  2470. }
  2471. }
  2472. }, limited:function(low, hi) {
  2473. return function(n) {
  2474. n = +n;
  2475. return Ext.isNumber(n) ? Math.min(Math.max(n, low), hi) : undefined;
  2476. };
  2477. }, limited01:function(n) {
  2478. n = +n;
  2479. return Ext.isNumber(n) ? Math.min(Math.max(n, 0), 1) : undefined;
  2480. }, enums:function() {
  2481. var enums = {}, args = Array.prototype.slice.call(arguments, 0), i, ln;
  2482. for (i = 0, ln = args.length; i < ln; i++) {
  2483. enums[args[i]] = true;
  2484. }
  2485. return function(n) {
  2486. return n in enums ? n : undefined;
  2487. };
  2488. }});
  2489. Ext.define('Ext.draw.sprite.AttributeDefinition', {requires:['Ext.draw.sprite.AttributeParser', 'Ext.draw.sprite.AnimationParser'], config:{defaults:{$value:{}, lazy:true}, aliases:{}, animationProcessors:{}, processors:{$value:{}, lazy:true}, dirtyTriggers:{}, triggers:{}, updaters:{}}, inheritableStatics:{processorFactoryRe:/^(\w+)\(([\w\-,]*)\)$/}, spriteClass:null, constructor:function(config) {
  2490. var me = this;
  2491. me.initConfig(config);
  2492. }, applyDefaults:function(defaults, oldDefaults) {
  2493. oldDefaults = Ext.apply(oldDefaults || {}, this.normalize(defaults));
  2494. return oldDefaults;
  2495. }, applyAliases:function(aliases, oldAliases) {
  2496. return Ext.apply(oldAliases || {}, aliases);
  2497. }, applyProcessors:function(processors, oldProcessors) {
  2498. this.getAnimationProcessors();
  2499. var result = oldProcessors || {}, defaultProcessor = Ext.draw.sprite.AttributeParser, processorFactoryRe = this.self.processorFactoryRe, animationProcessors = {}, anyAnimationProcessors, name, match, fn;
  2500. for (name in processors) {
  2501. fn = processors[name];
  2502. if (typeof fn === 'string') {
  2503. match = fn.match(processorFactoryRe);
  2504. if (match) {
  2505. fn = defaultProcessor[match[1]].apply(defaultProcessor, match[2].split(','));
  2506. } else {
  2507. if (defaultProcessor[fn]) {
  2508. animationProcessors[name] = fn;
  2509. anyAnimationProcessors = true;
  2510. fn = defaultProcessor[fn];
  2511. }
  2512. }
  2513. }
  2514. if (!Ext.isFunction(fn)) {
  2515. Ext.raise(this.spriteClass.$className + ": processor '" + name + "' has not been found.");
  2516. }
  2517. result[name] = fn;
  2518. }
  2519. if (anyAnimationProcessors) {
  2520. this.setAnimationProcessors(animationProcessors);
  2521. }
  2522. return result;
  2523. }, applyAnimationProcessors:function(animationProcessors, oldAnimationProcessors) {
  2524. var parser = Ext.draw.sprite.AnimationParser, name, item;
  2525. if (!oldAnimationProcessors) {
  2526. oldAnimationProcessors = {};
  2527. }
  2528. for (name in animationProcessors) {
  2529. item = animationProcessors[name];
  2530. if (item === 'none') {
  2531. oldAnimationProcessors[name] = null;
  2532. } else {
  2533. if (Ext.isString(item) && !(name in oldAnimationProcessors)) {
  2534. if (item in parser) {
  2535. while (Ext.isString(parser[item])) {
  2536. item = parser[item];
  2537. }
  2538. oldAnimationProcessors[name] = parser[item];
  2539. }
  2540. } else {
  2541. if (Ext.isObject(item)) {
  2542. oldAnimationProcessors[name] = item;
  2543. }
  2544. }
  2545. }
  2546. }
  2547. return oldAnimationProcessors;
  2548. }, updateDirtyTriggers:function(dirtyTriggers) {
  2549. this.setTriggers(dirtyTriggers);
  2550. }, applyTriggers:function(triggers, oldTriggers) {
  2551. var name;
  2552. if (!oldTriggers) {
  2553. oldTriggers = {};
  2554. }
  2555. for (name in triggers) {
  2556. oldTriggers[name] = triggers[name].split(',');
  2557. }
  2558. return oldTriggers;
  2559. }, applyUpdaters:function(updaters, oldUpdaters) {
  2560. return Ext.apply(oldUpdaters || {}, updaters);
  2561. }, batchedNormalize:function(batchedChanges, keepUnrecognized) {
  2562. if (!batchedChanges) {
  2563. return {};
  2564. }
  2565. var processors = this.getProcessors(), aliases = this.getAliases(), translation = batchedChanges.translation || batchedChanges.translate, normalized = {}, i, ln, name, val, rotation, scaling, matrix, subVal, split;
  2566. if ('rotation' in batchedChanges) {
  2567. rotation = batchedChanges.rotation;
  2568. } else {
  2569. rotation = 'rotate' in batchedChanges ? batchedChanges.rotate : undefined;
  2570. }
  2571. if ('scaling' in batchedChanges) {
  2572. scaling = batchedChanges.scaling;
  2573. } else {
  2574. scaling = 'scale' in batchedChanges ? batchedChanges.scale : undefined;
  2575. }
  2576. if (typeof scaling !== 'undefined') {
  2577. if (Ext.isNumber(scaling)) {
  2578. normalized.scalingX = scaling;
  2579. normalized.scalingY = scaling;
  2580. } else {
  2581. if ('x' in scaling) {
  2582. normalized.scalingX = scaling.x;
  2583. }
  2584. if ('y' in scaling) {
  2585. normalized.scalingY = scaling.y;
  2586. }
  2587. if ('centerX' in scaling) {
  2588. normalized.scalingCenterX = scaling.centerX;
  2589. }
  2590. if ('centerY' in scaling) {
  2591. normalized.scalingCenterY = scaling.centerY;
  2592. }
  2593. }
  2594. }
  2595. if (typeof rotation !== 'undefined') {
  2596. if (Ext.isNumber(rotation)) {
  2597. rotation = Ext.draw.Draw.rad(rotation);
  2598. normalized.rotationRads = rotation;
  2599. } else {
  2600. if ('rads' in rotation) {
  2601. normalized.rotationRads = rotation.rads;
  2602. } else {
  2603. if ('degrees' in rotation) {
  2604. if (Ext.isArray(rotation.degrees)) {
  2605. normalized.rotationRads = Ext.Array.map(rotation.degrees, function(deg) {
  2606. return Ext.draw.Draw.rad(deg);
  2607. });
  2608. } else {
  2609. normalized.rotationRads = Ext.draw.Draw.rad(rotation.degrees);
  2610. }
  2611. }
  2612. }
  2613. if ('centerX' in rotation) {
  2614. normalized.rotationCenterX = rotation.centerX;
  2615. }
  2616. if ('centerY' in rotation) {
  2617. normalized.rotationCenterY = rotation.centerY;
  2618. }
  2619. }
  2620. }
  2621. if (typeof translation !== 'undefined') {
  2622. if ('x' in translation) {
  2623. normalized.translationX = translation.x;
  2624. }
  2625. if ('y' in translation) {
  2626. normalized.translationY = translation.y;
  2627. }
  2628. }
  2629. if ('matrix' in batchedChanges) {
  2630. matrix = Ext.draw.Matrix.create(batchedChanges.matrix);
  2631. split = matrix.split();
  2632. normalized.matrix = matrix;
  2633. normalized.rotationRads = split.rotation;
  2634. normalized.rotationCenterX = 0;
  2635. normalized.rotationCenterY = 0;
  2636. normalized.scalingX = split.scaleX;
  2637. normalized.scalingY = split.scaleY;
  2638. normalized.scalingCenterX = 0;
  2639. normalized.scalingCenterY = 0;
  2640. normalized.translationX = split.translateX;
  2641. normalized.translationY = split.translateY;
  2642. }
  2643. for (name in batchedChanges) {
  2644. val = batchedChanges[name];
  2645. if (typeof val === 'undefined') {
  2646. continue;
  2647. } else {
  2648. if (Ext.isArray(val)) {
  2649. if (name in aliases) {
  2650. name = aliases[name];
  2651. }
  2652. if (name in processors) {
  2653. normalized[name] = [];
  2654. for (i = 0, ln = val.length; i < ln; i++) {
  2655. subVal = processors[name].call(this, val[i]);
  2656. if (typeof subVal !== 'undefined') {
  2657. normalized[name][i] = subVal;
  2658. }
  2659. }
  2660. } else {
  2661. if (keepUnrecognized) {
  2662. normalized[name] = val;
  2663. }
  2664. }
  2665. } else {
  2666. if (name in aliases) {
  2667. name = aliases[name];
  2668. }
  2669. if (name in processors) {
  2670. val = processors[name].call(this, val);
  2671. if (typeof val !== 'undefined') {
  2672. normalized[name] = val;
  2673. }
  2674. } else {
  2675. if (keepUnrecognized) {
  2676. normalized[name] = val;
  2677. }
  2678. }
  2679. }
  2680. }
  2681. }
  2682. return normalized;
  2683. }, normalize:function(changes, keepUnrecognized) {
  2684. if (!changes) {
  2685. return {};
  2686. }
  2687. var processors = this.getProcessors(), aliases = this.getAliases(), translation = changes.translation || changes.translate, normalized = {}, name, val, rotation, scaling, matrix, split;
  2688. if ('rotation' in changes) {
  2689. rotation = changes.rotation;
  2690. } else {
  2691. rotation = 'rotate' in changes ? changes.rotate : undefined;
  2692. }
  2693. if ('scaling' in changes) {
  2694. scaling = changes.scaling;
  2695. } else {
  2696. scaling = 'scale' in changes ? changes.scale : undefined;
  2697. }
  2698. if (translation) {
  2699. if ('x' in translation) {
  2700. normalized.translationX = translation.x;
  2701. }
  2702. if ('y' in translation) {
  2703. normalized.translationY = translation.y;
  2704. }
  2705. }
  2706. if (typeof scaling !== 'undefined') {
  2707. if (Ext.isNumber(scaling)) {
  2708. normalized.scalingX = scaling;
  2709. normalized.scalingY = scaling;
  2710. } else {
  2711. if ('x' in scaling) {
  2712. normalized.scalingX = scaling.x;
  2713. }
  2714. if ('y' in scaling) {
  2715. normalized.scalingY = scaling.y;
  2716. }
  2717. if ('centerX' in scaling) {
  2718. normalized.scalingCenterX = scaling.centerX;
  2719. }
  2720. if ('centerY' in scaling) {
  2721. normalized.scalingCenterY = scaling.centerY;
  2722. }
  2723. }
  2724. }
  2725. if (typeof rotation !== 'undefined') {
  2726. if (Ext.isNumber(rotation)) {
  2727. rotation = Ext.draw.Draw.rad(rotation);
  2728. normalized.rotationRads = rotation;
  2729. } else {
  2730. if ('rads' in rotation) {
  2731. normalized.rotationRads = rotation.rads;
  2732. } else {
  2733. if ('degrees' in rotation) {
  2734. normalized.rotationRads = Ext.draw.Draw.rad(rotation.degrees);
  2735. }
  2736. }
  2737. if ('centerX' in rotation) {
  2738. normalized.rotationCenterX = rotation.centerX;
  2739. }
  2740. if ('centerY' in rotation) {
  2741. normalized.rotationCenterY = rotation.centerY;
  2742. }
  2743. }
  2744. }
  2745. if ('matrix' in changes) {
  2746. matrix = Ext.draw.Matrix.create(changes.matrix);
  2747. split = matrix.split();
  2748. normalized.matrix = matrix;
  2749. normalized.rotationRads = split.rotation;
  2750. normalized.rotationCenterX = 0;
  2751. normalized.rotationCenterY = 0;
  2752. normalized.scalingX = split.scaleX;
  2753. normalized.scalingY = split.scaleY;
  2754. normalized.scalingCenterX = 0;
  2755. normalized.scalingCenterY = 0;
  2756. normalized.translationX = split.translateX;
  2757. normalized.translationY = split.translateY;
  2758. }
  2759. for (name in changes) {
  2760. val = changes[name];
  2761. if (typeof val === 'undefined') {
  2762. continue;
  2763. }
  2764. if (name in aliases) {
  2765. name = aliases[name];
  2766. }
  2767. if (name in processors) {
  2768. val = processors[name].call(this, val);
  2769. if (typeof val !== 'undefined') {
  2770. normalized[name] = val;
  2771. }
  2772. } else {
  2773. if (keepUnrecognized) {
  2774. normalized[name] = val;
  2775. }
  2776. }
  2777. }
  2778. return normalized;
  2779. }, setBypassingNormalization:function(attr, modifierStack, changes) {
  2780. return modifierStack.pushDown(attr, changes);
  2781. }, set:function(attr, modifierStack, changes) {
  2782. changes = this.normalize(changes);
  2783. return this.setBypassingNormalization(attr, modifierStack, changes);
  2784. }});
  2785. Ext.define('Ext.draw.Matrix', {isMatrix:true, statics:{createAffineMatrixFromTwoPair:function(x0, y0, x1, y1, x0p, y0p, x1p, y1p) {
  2786. var dx = x1 - x0, dy = y1 - y0, dxp = x1p - x0p, dyp = y1p - y0p, r = 1 / (dx * dx + dy * dy), a = dx * dxp + dy * dyp, b = dxp * dy - dx * dyp, c = -a * x0 - b * y0, f = b * x0 - a * y0;
  2787. return new this(a * r, -b * r, b * r, a * r, c * r + x0p, f * r + y0p);
  2788. }, createPanZoomFromTwoPair:function(x0, y0, x1, y1, x0p, y0p, x1p, y1p) {
  2789. if (arguments.length === 2) {
  2790. return this.createPanZoomFromTwoPair.apply(this, x0.concat(y0));
  2791. }
  2792. var dx = x1 - x0, dy = y1 - y0, cx = (x0 + x1) * 0.5, cy = (y0 + y1) * 0.5, dxp = x1p - x0p, dyp = y1p - y0p, cxp = (x0p + x1p) * 0.5, cyp = (y0p + y1p) * 0.5, r = dx * dx + dy * dy, rp = dxp * dxp + dyp * dyp, scale = Math.sqrt(rp / r);
  2793. return new this(scale, 0, 0, scale, cxp - scale * cx, cyp - scale * cy);
  2794. }, fly:function() {
  2795. var flyMatrix = null, simplefly = function(elements) {
  2796. flyMatrix.elements = elements;
  2797. return flyMatrix;
  2798. };
  2799. return function(elements) {
  2800. if (!flyMatrix) {
  2801. flyMatrix = new Ext.draw.Matrix;
  2802. }
  2803. flyMatrix.elements = elements;
  2804. Ext.draw.Matrix.fly = simplefly;
  2805. return flyMatrix;
  2806. };
  2807. }(), create:function(mat) {
  2808. if (mat instanceof this) {
  2809. return mat;
  2810. }
  2811. return new this(mat);
  2812. }}, constructor:function(xx, xy, yx, yy, dx, dy) {
  2813. if (xx && xx.length === 6) {
  2814. this.elements = xx.slice();
  2815. } else {
  2816. if (xx !== undefined) {
  2817. this.elements = [xx, xy, yx, yy, dx, dy];
  2818. } else {
  2819. this.elements = [1, 0, 0, 1, 0, 0];
  2820. }
  2821. }
  2822. }, prepend:function(xx, xy, yx, yy, dx, dy) {
  2823. var elements = this.elements, xx0 = elements[0], xy0 = elements[1], yx0 = elements[2], yy0 = elements[3], dx0 = elements[4], dy0 = elements[5];
  2824. elements[0] = xx * xx0 + yx * xy0;
  2825. elements[1] = xy * xx0 + yy * xy0;
  2826. elements[2] = xx * yx0 + yx * yy0;
  2827. elements[3] = xy * yx0 + yy * yy0;
  2828. elements[4] = xx * dx0 + yx * dy0 + dx;
  2829. elements[5] = xy * dx0 + yy * dy0 + dy;
  2830. return this;
  2831. }, prependMatrix:function(matrix) {
  2832. return this.prepend.apply(this, matrix.elements);
  2833. }, append:function(xx, xy, yx, yy, dx, dy) {
  2834. var elements = this.elements, xx0 = elements[0], xy0 = elements[1], yx0 = elements[2], yy0 = elements[3], dx0 = elements[4], dy0 = elements[5];
  2835. elements[0] = xx * xx0 + xy * yx0;
  2836. elements[1] = xx * xy0 + xy * yy0;
  2837. elements[2] = yx * xx0 + yy * yx0;
  2838. elements[3] = yx * xy0 + yy * yy0;
  2839. elements[4] = dx * xx0 + dy * yx0 + dx0;
  2840. elements[5] = dx * xy0 + dy * yy0 + dy0;
  2841. return this;
  2842. }, appendMatrix:function(matrix) {
  2843. return this.append.apply(this, matrix.elements);
  2844. }, set:function(xx, xy, yx, yy, dx, dy) {
  2845. var elements = this.elements;
  2846. elements[0] = xx;
  2847. elements[1] = xy;
  2848. elements[2] = yx;
  2849. elements[3] = yy;
  2850. elements[4] = dx;
  2851. elements[5] = dy;
  2852. return this;
  2853. }, inverse:function(target) {
  2854. var elements = this.elements, a = elements[0], b = elements[1], c = elements[2], d = elements[3], e = elements[4], f = elements[5], rDim = 1 / (a * d - b * c);
  2855. a *= rDim;
  2856. b *= rDim;
  2857. c *= rDim;
  2858. d *= rDim;
  2859. if (target) {
  2860. target.set(d, -b, -c, a, c * f - d * e, b * e - a * f);
  2861. return target;
  2862. } else {
  2863. return new Ext.draw.Matrix(d, -b, -c, a, c * f - d * e, b * e - a * f);
  2864. }
  2865. }, translate:function(x, y, prepend) {
  2866. if (prepend) {
  2867. return this.prepend(1, 0, 0, 1, x, y);
  2868. } else {
  2869. return this.append(1, 0, 0, 1, x, y);
  2870. }
  2871. }, scale:function(sx, sy, scx, scy, prepend) {
  2872. var me = this;
  2873. if (sy == null) {
  2874. sy = sx;
  2875. }
  2876. if (scx === undefined) {
  2877. scx = 0;
  2878. }
  2879. if (scy === undefined) {
  2880. scy = 0;
  2881. }
  2882. if (prepend) {
  2883. return me.prepend(sx, 0, 0, sy, scx - scx * sx, scy - scy * sy);
  2884. } else {
  2885. return me.append(sx, 0, 0, sy, scx - scx * sx, scy - scy * sy);
  2886. }
  2887. }, rotate:function(angle, rcx, rcy, prepend) {
  2888. var me = this, cos = Math.cos(angle), sin = Math.sin(angle);
  2889. rcx = rcx || 0;
  2890. rcy = rcy || 0;
  2891. if (prepend) {
  2892. return me.prepend(cos, sin, -sin, cos, rcx - cos * rcx + rcy * sin, rcy - cos * rcy - rcx * sin);
  2893. } else {
  2894. return me.append(cos, sin, -sin, cos, rcx - cos * rcx + rcy * sin, rcy - cos * rcy - rcx * sin);
  2895. }
  2896. }, rotateFromVector:function(x, y, prepend) {
  2897. var me = this, d = Math.sqrt(x * x + y * y), cos = x / d, sin = y / d;
  2898. if (prepend) {
  2899. return me.prepend(cos, sin, -sin, cos, 0, 0);
  2900. } else {
  2901. return me.append(cos, sin, -sin, cos, 0, 0);
  2902. }
  2903. }, clone:function() {
  2904. return new Ext.draw.Matrix(this.elements);
  2905. }, flipX:function() {
  2906. return this.append(-1, 0, 0, 1, 0, 0);
  2907. }, flipY:function() {
  2908. return this.append(1, 0, 0, -1, 0, 0);
  2909. }, skewX:function(angle) {
  2910. return this.append(1, 0, Math.tan(angle), 1, 0, 0);
  2911. }, skewY:function(angle) {
  2912. return this.append(1, Math.tan(angle), 0, 1, 0, 0);
  2913. }, shearX:function(factor) {
  2914. return this.append(1, 0, factor, 1, 0, 0);
  2915. }, shearY:function(factor) {
  2916. return this.append(1, factor, 0, 1, 0, 0);
  2917. }, reset:function() {
  2918. return this.set(1, 0, 0, 1, 0, 0);
  2919. }, precisionCompensate:function(devicePixelRatio, comp) {
  2920. var elements = this.elements, x2x = elements[0], x2y = elements[1], y2x = elements[2], y2y = elements[3], newDx = elements[4], newDy = elements[5], r = x2y * y2x - x2x * y2y;
  2921. comp.b = devicePixelRatio * x2y / x2x;
  2922. comp.c = devicePixelRatio * y2x / y2y;
  2923. comp.d = devicePixelRatio;
  2924. comp.xx = x2x / devicePixelRatio;
  2925. comp.yy = y2y / devicePixelRatio;
  2926. comp.dx = (newDy * x2x * y2x - newDx * x2x * y2y) / r / devicePixelRatio;
  2927. comp.dy = (newDx * x2y * y2y - newDy * x2x * y2y) / r / devicePixelRatio;
  2928. }, precisionCompensateRect:function(devicePixelRatio, comp) {
  2929. var elements = this.elements, x2x = elements[0], x2y = elements[1], y2x = elements[2], y2y = elements[3], newDx = elements[4], newDy = elements[5], yxOnXx = y2x / x2x;
  2930. comp.b = devicePixelRatio * x2y / x2x;
  2931. comp.c = devicePixelRatio * yxOnXx;
  2932. comp.d = devicePixelRatio * y2y / x2x;
  2933. comp.xx = x2x / devicePixelRatio;
  2934. comp.yy = x2x / devicePixelRatio;
  2935. comp.dx = (newDy * y2x - newDx * y2y) / (x2y * yxOnXx - y2y) / devicePixelRatio;
  2936. comp.dy = -(newDy * x2x - newDx * x2y) / (x2y * yxOnXx - y2y) / devicePixelRatio;
  2937. }, x:function(x, y) {
  2938. var elements = this.elements;
  2939. return x * elements[0] + y * elements[2] + elements[4];
  2940. }, y:function(x, y) {
  2941. var elements = this.elements;
  2942. return x * elements[1] + y * elements[3] + elements[5];
  2943. }, get:function(i, j) {
  2944. return +this.elements[i + j * 2].toFixed(4);
  2945. }, transformPoint:function(point) {
  2946. var elements = this.elements, x, y;
  2947. if (point.isPoint) {
  2948. x = point.x;
  2949. y = point.y;
  2950. } else {
  2951. x = point[0];
  2952. y = point[1];
  2953. }
  2954. return [x * elements[0] + y * elements[2] + elements[4], x * elements[1] + y * elements[3] + elements[5]];
  2955. }, transformBBox:function(bbox, radius, target) {
  2956. var elements = this.elements, l = bbox.x, t = bbox.y, w0 = bbox.width * 0.5, h0 = bbox.height * 0.5, xx = elements[0], xy = elements[1], yx = elements[2], yy = elements[3], cx = l + w0, cy = t + h0, w, h, scales;
  2957. if (radius) {
  2958. w0 -= radius;
  2959. h0 -= radius;
  2960. scales = [Math.sqrt(elements[0] * elements[0] + elements[2] * elements[2]), Math.sqrt(elements[1] * elements[1] + elements[3] * elements[3])];
  2961. w = Math.abs(w0 * xx) + Math.abs(h0 * yx) + Math.abs(scales[0] * radius);
  2962. h = Math.abs(w0 * xy) + Math.abs(h0 * yy) + Math.abs(scales[1] * radius);
  2963. } else {
  2964. w = Math.abs(w0 * xx) + Math.abs(h0 * yx);
  2965. h = Math.abs(w0 * xy) + Math.abs(h0 * yy);
  2966. }
  2967. if (!target) {
  2968. target = {};
  2969. }
  2970. target.x = cx * xx + cy * yx + elements[4] - w;
  2971. target.y = cx * xy + cy * yy + elements[5] - h;
  2972. target.width = w + w;
  2973. target.height = h + h;
  2974. return target;
  2975. }, transformList:function(list) {
  2976. var elements = this.elements, xx = elements[0], yx = elements[2], dx = elements[4], xy = elements[1], yy = elements[3], dy = elements[5], ln = list.length, p, i;
  2977. for (i = 0; i < ln; i++) {
  2978. p = list[i];
  2979. list[i] = [p[0] * xx + p[1] * yx + dx, p[0] * xy + p[1] * yy + dy];
  2980. }
  2981. return list;
  2982. }, isIdentity:function() {
  2983. var elements = this.elements;
  2984. return elements[0] === 1 && elements[1] === 0 && elements[2] === 0 && elements[3] === 1 && elements[4] === 0 && elements[5] === 0;
  2985. }, isEqual:function(matrix) {
  2986. var elements = matrix && matrix.isMatrix ? matrix.elements : matrix, myElements = this.elements;
  2987. return myElements[0] === elements[0] && myElements[1] === elements[1] && myElements[2] === elements[2] && myElements[3] === elements[3] && myElements[4] === elements[4] && myElements[5] === elements[5];
  2988. }, equals:function(matrix) {
  2989. return this.isEqual(matrix);
  2990. }, toArray:function() {
  2991. var elements = this.elements;
  2992. return [elements[0], elements[2], elements[4], elements[1], elements[3], elements[5]];
  2993. }, toVerticalArray:function() {
  2994. return this.elements.slice();
  2995. }, toString:function() {
  2996. var me = this;
  2997. return [me.get(0, 0), me.get(0, 1), me.get(1, 0), me.get(1, 1), me.get(2, 0), me.get(2, 1)].join(',');
  2998. }, toContext:function(ctx) {
  2999. ctx.transform.apply(ctx, this.elements);
  3000. return this;
  3001. }, toSvg:function() {
  3002. var elements = this.elements;
  3003. return 'matrix(' + elements[0].toFixed(9) + ',' + elements[1].toFixed(9) + ',' + elements[2].toFixed(9) + ',' + elements[3].toFixed(9) + ',' + elements[4].toFixed(9) + ',' + elements[5].toFixed(9) + ')';
  3004. }, getScaleX:function() {
  3005. var elements = this.elements;
  3006. return Math.sqrt(elements[0] * elements[0] + elements[2] * elements[2]);
  3007. }, getScaleY:function() {
  3008. var elements = this.elements;
  3009. return Math.sqrt(elements[1] * elements[1] + elements[3] * elements[3]);
  3010. }, getXX:function() {
  3011. return this.elements[0];
  3012. }, getXY:function() {
  3013. return this.elements[1];
  3014. }, getYX:function() {
  3015. return this.elements[2];
  3016. }, getYY:function() {
  3017. return this.elements[3];
  3018. }, getDX:function() {
  3019. return this.elements[4];
  3020. }, getDY:function() {
  3021. return this.elements[5];
  3022. }, split:function() {
  3023. var el = this.elements, xx = el[0], xy = el[1], yy = el[3], out = {translateX:el[4], translateY:el[5]};
  3024. out.rotate = out.rotation = Math.atan2(xy, xx);
  3025. out.scaleX = xx / Math.cos(out.rotate);
  3026. out.scaleY = yy / xx * out.scaleX;
  3027. return out;
  3028. }}, function() {
  3029. function registerName(properties, name, i) {
  3030. properties[name] = {get:function() {
  3031. return this.elements[i];
  3032. }, set:function(val) {
  3033. this.elements[i] = val;
  3034. }};
  3035. }
  3036. if (Object.defineProperties) {
  3037. var properties = {};
  3038. registerName(properties, 'a', 0);
  3039. registerName(properties, 'b', 1);
  3040. registerName(properties, 'c', 2);
  3041. registerName(properties, 'd', 3);
  3042. registerName(properties, 'e', 4);
  3043. registerName(properties, 'f', 5);
  3044. Object.defineProperties(this.prototype, properties);
  3045. }
  3046. this.prototype.multiply = this.prototype.appendMatrix;
  3047. });
  3048. Ext.define('Ext.draw.modifier.Modifier', {isModifier:true, mixins:{observable:'Ext.mixin.Observable'}, config:{lower:null, upper:null, sprite:null}, constructor:function(config) {
  3049. this.mixins.observable.constructor.call(this, config);
  3050. }, updateUpper:function(upper) {
  3051. if (upper) {
  3052. upper.setLower(this);
  3053. }
  3054. }, updateLower:function(lower) {
  3055. if (lower) {
  3056. lower.setUpper(this);
  3057. }
  3058. }, prepareAttributes:function(attr) {
  3059. if (this._lower) {
  3060. this._lower.prepareAttributes(attr);
  3061. }
  3062. }, popUp:function(attr, changes) {
  3063. if (this._upper) {
  3064. this._upper.popUp(attr, changes);
  3065. } else {
  3066. Ext.apply(attr, changes);
  3067. }
  3068. }, filterChanges:function(attr, changes, receiver) {
  3069. var targets = attr.targets, name, value;
  3070. if (receiver) {
  3071. for (name in changes) {
  3072. value = changes[name];
  3073. if (value !== attr[name] || targets && value !== targets[name]) {
  3074. receiver[name] = value;
  3075. }
  3076. }
  3077. } else {
  3078. for (name in changes) {
  3079. value = changes[name];
  3080. if (value === attr[name] && (!targets || value === targets[name])) {
  3081. delete changes[name];
  3082. }
  3083. }
  3084. }
  3085. return receiver || changes;
  3086. }, pushDown:function(attr, changes) {
  3087. return this._lower ? this._lower.pushDown(attr, changes) : this.filterChanges(attr, changes);
  3088. }});
  3089. Ext.define('Ext.draw.modifier.Target', {requires:['Ext.draw.Matrix'], extend:'Ext.draw.modifier.Modifier', alias:'modifier.target', statics:{uniqueId:0}, prepareAttributes:function(attr) {
  3090. if (this._lower) {
  3091. this._lower.prepareAttributes(attr);
  3092. }
  3093. attr.attributeId = 'attribute-' + Ext.draw.modifier.Target.uniqueId++;
  3094. if (!attr.hasOwnProperty('canvasAttributes')) {
  3095. attr.bbox = {plain:{dirty:true}, transform:{dirty:true}};
  3096. attr.dirty = true;
  3097. attr.pendingUpdaters = {};
  3098. attr.canvasAttributes = {};
  3099. attr.matrix = new Ext.draw.Matrix;
  3100. attr.inverseMatrix = new Ext.draw.Matrix;
  3101. }
  3102. }, applyChanges:function(attr, changes) {
  3103. Ext.apply(attr, changes);
  3104. var sprite = this.getSprite(), pendingUpdaters = attr.pendingUpdaters, triggers = sprite.self.def.getTriggers(), updaters, instances, instance, name, hasChanges, canvasAttributes, i, j, ln;
  3105. for (name in changes) {
  3106. hasChanges = true;
  3107. if (updaters = triggers[name]) {
  3108. sprite.scheduleUpdaters(attr, updaters, [name]);
  3109. }
  3110. if (attr.template && changes.removeFromInstance && changes.removeFromInstance[name]) {
  3111. delete attr[name];
  3112. }
  3113. }
  3114. if (!hasChanges) {
  3115. return;
  3116. }
  3117. if (pendingUpdaters.canvas) {
  3118. canvasAttributes = pendingUpdaters.canvas;
  3119. delete pendingUpdaters.canvas;
  3120. for (i = 0, ln = canvasAttributes.length; i < ln; i++) {
  3121. name = canvasAttributes[i];
  3122. attr.canvasAttributes[name] = attr[name];
  3123. }
  3124. }
  3125. if (attr.hasOwnProperty('children')) {
  3126. instances = attr.children;
  3127. for (i = 0, ln = instances.length; i < ln; i++) {
  3128. instance = instances[i];
  3129. Ext.apply(instance.pendingUpdaters, pendingUpdaters);
  3130. if (canvasAttributes) {
  3131. for (j = 0; j < canvasAttributes.length; j++) {
  3132. name = canvasAttributes[j];
  3133. instance.canvasAttributes[name] = instance[name];
  3134. }
  3135. }
  3136. sprite.callUpdaters(instance);
  3137. }
  3138. }
  3139. sprite.setDirty(true);
  3140. sprite.callUpdaters(attr);
  3141. }, popUp:function(attr, changes) {
  3142. this.applyChanges(attr, changes);
  3143. }, pushDown:function(attr, changes) {
  3144. if (this._lower) {
  3145. changes = this._lower.pushDown(attr, changes);
  3146. }
  3147. this.applyChanges(attr, changes);
  3148. return changes;
  3149. }});
  3150. Ext.define('Ext.draw.TimingFunctions', function() {
  3151. var pow = Math.pow, sin = Math.sin, cos = Math.cos, sqrt = Math.sqrt, pi = Math.PI, poly = ['quad', 'cube', 'quart', 'quint'], easings = {pow:function(p, x) {
  3152. return pow(p, x || 6);
  3153. }, expo:function(p) {
  3154. return pow(2, 8 * (p - 1));
  3155. }, circ:function(p) {
  3156. return 1 - sqrt(1 - p * p);
  3157. }, sine:function(p) {
  3158. return 1 - sin((1 - p) * pi / 2);
  3159. }, back:function(p, n) {
  3160. n = n || 1.616;
  3161. return p * p * ((n + 1) * p - n);
  3162. }, bounce:function(p) {
  3163. var a, b;
  3164. for (a = 0, b = 1; 1; a += b, b /= 2) {
  3165. if (p >= (7 - 4 * a) / 11) {
  3166. return b * b - pow((11 - 6 * a - 11 * p) / 4, 2);
  3167. }
  3168. }
  3169. }, elastic:function(p, x) {
  3170. return pow(2, 10 * --p) * cos(20 * p * pi * (x || 1) / 3);
  3171. }}, easingsMap = {}, name, len, i;
  3172. function createPoly(times) {
  3173. return function(p) {
  3174. return pow(p, times);
  3175. };
  3176. }
  3177. function addEasing(name, easing) {
  3178. easingsMap[name + 'In'] = function(pos) {
  3179. return easing(pos);
  3180. };
  3181. easingsMap[name + 'Out'] = function(pos) {
  3182. return 1 - easing(1 - pos);
  3183. };
  3184. easingsMap[name + 'InOut'] = function(pos) {
  3185. return pos <= 0.5 ? easing(2 * pos) / 2 : (2 - easing(2 * (1 - pos))) / 2;
  3186. };
  3187. }
  3188. for (i = 0, len = poly.length; i < len; ++i) {
  3189. easings[poly[i]] = createPoly(i + 2);
  3190. }
  3191. for (name in easings) {
  3192. addEasing(name, easings[name]);
  3193. }
  3194. easingsMap.linear = Ext.identityFn;
  3195. easingsMap.easeIn = easingsMap.quadIn;
  3196. easingsMap.easeOut = easingsMap.quadOut;
  3197. easingsMap.easeInOut = easingsMap.quadInOut;
  3198. return {singleton:true, easingMap:easingsMap};
  3199. }, function(Cls) {
  3200. Ext.apply(Cls, Cls.easingMap);
  3201. });
  3202. Ext.define('Ext.draw.Animator', {uses:['Ext.draw.Draw'], singleton:true, frameCallbacks:{}, frameCallbackId:0, scheduled:0, frameStartTimeOffset:Ext.now(), animations:[], running:false, animationTime:function() {
  3203. return Ext.AnimationQueue.frameStartTime - this.frameStartTimeOffset;
  3204. }, add:function(animation) {
  3205. var me = this;
  3206. if (!me.contains(animation)) {
  3207. me.animations.push(animation);
  3208. me.ignite();
  3209. if ('fireEvent' in animation) {
  3210. animation.fireEvent('animationstart', animation);
  3211. }
  3212. }
  3213. }, remove:function(animation) {
  3214. var me = this, animations = me.animations, i = 0, l = animations.length;
  3215. for (; i < l; ++i) {
  3216. if (animations[i] === animation) {
  3217. animations.splice(i, 1);
  3218. if ('fireEvent' in animation) {
  3219. animation.fireEvent('animationend', animation);
  3220. }
  3221. return;
  3222. }
  3223. }
  3224. }, contains:function(animation) {
  3225. return Ext.Array.indexOf(this.animations, animation) > -1;
  3226. }, empty:function() {
  3227. return this.animations.length === 0;
  3228. }, idle:function() {
  3229. return this.scheduled === 0 && this.animations.length === 0;
  3230. }, step:function(frameTime) {
  3231. var me = this, animations = me.animations, animation, i = 0, ln = animations.length;
  3232. for (; i < ln; i++) {
  3233. animation = animations[i];
  3234. animation.step(frameTime);
  3235. if (!animation.animating) {
  3236. animations.splice(i, 1);
  3237. i--;
  3238. ln--;
  3239. if (animation.fireEvent) {
  3240. animation.fireEvent('animationend', animation);
  3241. }
  3242. }
  3243. }
  3244. }, schedule:function(callback, scope) {
  3245. var id = 'frameCallback' + this.frameCallbackId++;
  3246. scope = scope || this;
  3247. if (Ext.isString(callback)) {
  3248. callback = scope[callback];
  3249. }
  3250. Ext.draw.Animator.frameCallbacks[id] = {fn:callback, scope:scope, once:true};
  3251. this.scheduled++;
  3252. Ext.draw.Animator.ignite();
  3253. return id;
  3254. }, scheduleIf:function(callback, scope) {
  3255. var frameCallbacks = Ext.draw.Animator.frameCallbacks, cb, id;
  3256. scope = scope || this;
  3257. if (Ext.isString(callback)) {
  3258. callback = scope[callback];
  3259. }
  3260. for (id in frameCallbacks) {
  3261. cb = frameCallbacks[id];
  3262. if (cb.once && cb.fn === callback && cb.scope === scope) {
  3263. return null;
  3264. }
  3265. }
  3266. return this.schedule(callback, scope);
  3267. }, cancel:function(id) {
  3268. if (Ext.draw.Animator.frameCallbacks[id] && Ext.draw.Animator.frameCallbacks[id].once) {
  3269. this.scheduled = Math.max(--this.scheduled, 0);
  3270. delete Ext.draw.Animator.frameCallbacks[id];
  3271. Ext.draw.Draw.endUpdateIOS();
  3272. }
  3273. if (this.idle()) {
  3274. this.extinguish();
  3275. }
  3276. }, clear:function() {
  3277. this.animations.length = 0;
  3278. Ext.draw.Animator.frameCallbacks = {};
  3279. this.extinguish();
  3280. }, addFrameCallback:function(callback, scope) {
  3281. var id = 'frameCallback' + this.frameCallbackId++;
  3282. scope = scope || this;
  3283. if (Ext.isString(callback)) {
  3284. callback = scope[callback];
  3285. }
  3286. Ext.draw.Animator.frameCallbacks[id] = {fn:callback, scope:scope};
  3287. return id;
  3288. }, removeFrameCallback:function(id) {
  3289. delete Ext.draw.Animator.frameCallbacks[id];
  3290. if (this.idle()) {
  3291. this.extinguish();
  3292. }
  3293. }, fireFrameCallbacks:function() {
  3294. var callbacks = this.frameCallbacks, id, fn, cb;
  3295. for (id in callbacks) {
  3296. cb = callbacks[id];
  3297. fn = cb.fn;
  3298. if (Ext.isString(fn)) {
  3299. fn = cb.scope[fn];
  3300. }
  3301. fn.call(cb.scope);
  3302. if (callbacks[id] && cb.once) {
  3303. this.scheduled = Math.max(--this.scheduled, 0);
  3304. delete callbacks[id];
  3305. }
  3306. }
  3307. }, handleFrame:function() {
  3308. var me = this;
  3309. me.step(me.animationTime());
  3310. me.fireFrameCallbacks();
  3311. if (me.idle()) {
  3312. me.extinguish();
  3313. }
  3314. }, ignite:function() {
  3315. if (!this.running) {
  3316. this.running = true;
  3317. Ext.AnimationQueue.start(this.handleFrame, this);
  3318. Ext.draw.Draw.beginUpdateIOS();
  3319. }
  3320. }, extinguish:function() {
  3321. this.running = false;
  3322. Ext.AnimationQueue.stop(this.handleFrame, this);
  3323. Ext.draw.Draw.endUpdateIOS();
  3324. }});
  3325. Ext.define('Ext.draw.modifier.Animation', {extend:'Ext.draw.modifier.Modifier', alias:'modifier.animation', requires:['Ext.draw.TimingFunctions', 'Ext.draw.Animator'], config:{easing:Ext.identityFn, duration:0, customEasings:{}, customDurations:{}}, constructor:function(config) {
  3326. var me = this;
  3327. me.anyAnimation = me.anySpecialAnimations = false;
  3328. me.animating = 0;
  3329. me.animatingPool = [];
  3330. me.callParent([config]);
  3331. }, prepareAttributes:function(attr) {
  3332. if (!attr.hasOwnProperty('timers')) {
  3333. attr.animating = false;
  3334. attr.timers = {};
  3335. attr.targets = Ext.Object.chain(attr);
  3336. attr.targets.prototype = attr;
  3337. }
  3338. if (this._lower) {
  3339. this._lower.prepareAttributes(attr.targets);
  3340. }
  3341. }, updateSprite:function(sprite) {
  3342. this.setConfig(sprite.config.animation);
  3343. }, updateDuration:function(duration) {
  3344. this.anyAnimation = duration > 0;
  3345. }, applyEasing:function(easing) {
  3346. if (typeof easing === 'string') {
  3347. easing = Ext.draw.TimingFunctions.easingMap[easing];
  3348. }
  3349. return easing;
  3350. }, applyCustomEasings:function(newEasings, oldEasings) {
  3351. var any, key, attrs, easing, i, ln;
  3352. oldEasings = oldEasings || {};
  3353. for (key in newEasings) {
  3354. any = true;
  3355. easing = newEasings[key];
  3356. attrs = key.split(',');
  3357. if (typeof easing === 'string') {
  3358. easing = Ext.draw.TimingFunctions.easingMap[easing];
  3359. }
  3360. for (i = 0, ln = attrs.length; i < ln; i++) {
  3361. oldEasings[attrs[i]] = easing;
  3362. }
  3363. }
  3364. if (any) {
  3365. this.anySpecialAnimations = any;
  3366. }
  3367. return oldEasings;
  3368. }, setEasingOn:function(attrs, easing) {
  3369. var customEasings = {}, i, ln;
  3370. attrs = Ext.Array.from(attrs).slice();
  3371. for (i = 0, ln = attrs.length; i < ln; i++) {
  3372. customEasings[attrs[i]] = easing;
  3373. }
  3374. this.setCustomEasings(customEasings);
  3375. }, clearEasingOn:function(attrs) {
  3376. var i, ln;
  3377. attrs = Ext.Array.from(attrs, true);
  3378. for (i = 0, ln = attrs.length; i < ln; i++) {
  3379. delete this._customEasings[attrs[i]];
  3380. }
  3381. }, applyCustomDurations:function(newDurations, oldDurations) {
  3382. var any, key, duration, attrs, i, ln;
  3383. oldDurations = oldDurations || {};
  3384. for (key in newDurations) {
  3385. any = true;
  3386. duration = newDurations[key];
  3387. attrs = key.split(',');
  3388. for (i = 0, ln = attrs.length; i < ln; i++) {
  3389. oldDurations[attrs[i]] = duration;
  3390. }
  3391. }
  3392. if (any) {
  3393. this.anySpecialAnimations = any;
  3394. }
  3395. return oldDurations;
  3396. }, setDurationOn:function(attrs, duration) {
  3397. var customDurations = {}, i, ln;
  3398. attrs = Ext.Array.from(attrs).slice();
  3399. for (i = 0, ln = attrs.length; i < ln; i++) {
  3400. customDurations[attrs[i]] = duration;
  3401. }
  3402. this.setCustomDurations(customDurations);
  3403. }, clearDurationOn:function(attrs) {
  3404. var i, ln;
  3405. attrs = Ext.Array.from(attrs, true);
  3406. for (i = 0, ln = attrs.length; i < ln; i++) {
  3407. delete this._customDurations[attrs[i]];
  3408. }
  3409. }, setAnimating:function(attr, animating) {
  3410. var me = this, pool = me.animatingPool, i;
  3411. if (attr.animating !== animating) {
  3412. attr.animating = animating;
  3413. if (animating) {
  3414. pool.push(attr);
  3415. if (me.animating === 0) {
  3416. Ext.draw.Animator.add(me);
  3417. }
  3418. me.animating++;
  3419. } else {
  3420. for (i = pool.length; i--;) {
  3421. if (pool[i] === attr) {
  3422. pool.splice(i, 1);
  3423. }
  3424. }
  3425. me.animating = pool.length;
  3426. }
  3427. }
  3428. }, setAttrs:function(attr, changes) {
  3429. var me = this, timers = attr.timers, parsers = me._sprite.self.def._animationProcessors, defaultEasing = me._easing, defaultDuration = me._duration, customDurations = me._customDurations, customEasings = me._customEasings, anySpecial = me.anySpecialAnimations, any = me.anyAnimation || anySpecial, targets = attr.targets, ignite = false, timer, name, newValue, startValue, parser, easing, duration, initial;
  3430. if (!any) {
  3431. for (name in changes) {
  3432. if (attr[name] === changes[name]) {
  3433. delete changes[name];
  3434. } else {
  3435. attr[name] = changes[name];
  3436. }
  3437. delete targets[name];
  3438. delete timers[name];
  3439. }
  3440. return changes;
  3441. } else {
  3442. for (name in changes) {
  3443. newValue = changes[name];
  3444. startValue = attr[name];
  3445. if (newValue !== startValue && startValue !== undefined && startValue !== null && (parser = parsers[name])) {
  3446. easing = defaultEasing;
  3447. duration = defaultDuration;
  3448. if (anySpecial) {
  3449. if (name in customEasings) {
  3450. easing = customEasings[name];
  3451. }
  3452. if (name in customDurations) {
  3453. duration = customDurations[name];
  3454. }
  3455. }
  3456. if (startValue && startValue.isGradient || newValue && newValue.isGradient) {
  3457. duration = 0;
  3458. }
  3459. if (duration) {
  3460. if (!timers[name]) {
  3461. timers[name] = {};
  3462. }
  3463. timer = timers[name];
  3464. timer.start = 0;
  3465. timer.easing = easing;
  3466. timer.duration = duration;
  3467. timer.compute = parser.compute;
  3468. timer.serve = parser.serve || Ext.identityFn;
  3469. timer.remove = changes.removeFromInstance && changes.removeFromInstance[name];
  3470. if (parser.parseInitial) {
  3471. initial = parser.parseInitial(startValue, newValue);
  3472. timer.source = initial[0];
  3473. timer.target = initial[1];
  3474. } else {
  3475. if (parser.parse) {
  3476. timer.source = parser.parse(startValue);
  3477. timer.target = parser.parse(newValue);
  3478. } else {
  3479. timer.source = startValue;
  3480. timer.target = newValue;
  3481. }
  3482. }
  3483. targets[name] = newValue;
  3484. delete changes[name];
  3485. ignite = true;
  3486. continue;
  3487. } else {
  3488. delete targets[name];
  3489. }
  3490. } else {
  3491. delete targets[name];
  3492. }
  3493. delete timers[name];
  3494. }
  3495. }
  3496. if (ignite && !attr.animating) {
  3497. me.setAnimating(attr, true);
  3498. }
  3499. return changes;
  3500. }, updateAttributes:function(attr) {
  3501. if (!attr.animating) {
  3502. return {};
  3503. }
  3504. var changes = {}, any = false, timers = attr.timers, targets = attr.targets, now = Ext.draw.Animator.animationTime(), name, timer, delta;
  3505. if (attr.lastUpdate === now) {
  3506. return null;
  3507. }
  3508. for (name in timers) {
  3509. timer = timers[name];
  3510. if (!timer.start) {
  3511. timer.start = now;
  3512. delta = 0;
  3513. } else {
  3514. delta = (now - timer.start) / timer.duration;
  3515. }
  3516. if (delta >= 1) {
  3517. changes[name] = targets[name];
  3518. delete targets[name];
  3519. if (timers[name].remove) {
  3520. changes.removeFromInstance = changes.removeFromInstance || {};
  3521. changes.removeFromInstance[name] = true;
  3522. }
  3523. delete timers[name];
  3524. } else {
  3525. changes[name] = timer.serve(timer.compute(timer.source, timer.target, timer.easing(delta), attr[name]));
  3526. any = true;
  3527. }
  3528. }
  3529. attr.lastUpdate = now;
  3530. this.setAnimating(attr, any);
  3531. return changes;
  3532. }, pushDown:function(attr, changes) {
  3533. changes = this.callParent([attr.targets, changes]);
  3534. return this.setAttrs(attr, changes);
  3535. }, popUp:function(attr, changes) {
  3536. attr = attr.prototype;
  3537. changes = this.setAttrs(attr, changes);
  3538. if (this._upper) {
  3539. return this._upper.popUp(attr, changes);
  3540. } else {
  3541. return Ext.apply(attr, changes);
  3542. }
  3543. }, step:function(frameTime) {
  3544. var me = this, pool = me.animatingPool.slice(), ln = pool.length, i = 0, attr, changes;
  3545. for (; i < ln; i++) {
  3546. attr = pool[i];
  3547. changes = me.updateAttributes(attr);
  3548. if (changes && me._upper) {
  3549. me._upper.popUp(attr, changes);
  3550. }
  3551. }
  3552. }, stop:function() {
  3553. var me = this, pool = me.animatingPool, i, ln;
  3554. this.step();
  3555. for (i = 0, ln = pool.length; i < ln; i++) {
  3556. pool[i].animating = false;
  3557. }
  3558. me.animatingPool.length = 0;
  3559. me.animating = 0;
  3560. Ext.draw.Animator.remove(me);
  3561. }, destroy:function() {
  3562. Ext.draw.Animator.remove(this);
  3563. this.callParent();
  3564. }});
  3565. Ext.define('Ext.draw.modifier.Highlight', {extend:'Ext.draw.modifier.Modifier', alias:'modifier.highlight', config:{enabled:false, style:null}, preFx:true, applyStyle:function(style, oldStyle) {
  3566. oldStyle = oldStyle || {};
  3567. if (this.getSprite()) {
  3568. Ext.apply(oldStyle, this.getSprite().self.def.normalize(style));
  3569. } else {
  3570. Ext.apply(oldStyle, style);
  3571. }
  3572. return oldStyle;
  3573. }, prepareAttributes:function(attr) {
  3574. if (!attr.hasOwnProperty('highlightOriginal')) {
  3575. attr.highlighted = false;
  3576. attr.highlightOriginal = Ext.Object.chain(attr);
  3577. attr.highlightOriginal.prototype = attr;
  3578. attr.highlightOriginal.removeFromInstance = {};
  3579. }
  3580. if (this._lower) {
  3581. this._lower.prepareAttributes(attr.highlightOriginal);
  3582. }
  3583. }, updateSprite:function(sprite, oldSprite) {
  3584. var me = this, style = me.getStyle(), attributeDefinitions;
  3585. if (sprite) {
  3586. attributeDefinitions = sprite.self.def;
  3587. if (style) {
  3588. me._style = attributeDefinitions.normalize(style);
  3589. }
  3590. me.setStyle(sprite.config.highlight);
  3591. attributeDefinitions.setConfig({defaults:{highlighted:false}, processors:{highlighted:'bool'}});
  3592. }
  3593. this.setSprite(sprite);
  3594. }, filterChanges:function(attr, changes) {
  3595. var me = this, highlightOriginal = attr.highlightOriginal, style = me.getStyle(), name;
  3596. if (attr.highlighted) {
  3597. for (name in changes) {
  3598. if (style.hasOwnProperty(name)) {
  3599. highlightOriginal[name] = changes[name];
  3600. delete changes[name];
  3601. }
  3602. }
  3603. }
  3604. return changes;
  3605. }, pushDown:function(attr, changes) {
  3606. var style = this.getStyle(), highlightOriginal = attr.highlightOriginal, removeFromInstance = highlightOriginal.removeFromInstance, highlighted, name, tplAttr, timer;
  3607. if (changes.hasOwnProperty('highlighted')) {
  3608. highlighted = changes.highlighted;
  3609. delete changes.highlighted;
  3610. if (this._lower) {
  3611. changes = this._lower.pushDown(highlightOriginal, changes);
  3612. }
  3613. changes = this.filterChanges(attr, changes);
  3614. if (highlighted !== attr.highlighted) {
  3615. if (highlighted) {
  3616. for (name in style) {
  3617. if (name in changes) {
  3618. highlightOriginal[name] = changes[name];
  3619. } else {
  3620. tplAttr = attr.template && attr.template.ownAttr;
  3621. if (tplAttr && !attr.prototype.hasOwnProperty(name)) {
  3622. removeFromInstance[name] = true;
  3623. highlightOriginal[name] = tplAttr.targets[name];
  3624. } else {
  3625. timer = highlightOriginal.timers[name];
  3626. if (timer && timer.remove) {
  3627. removeFromInstance[name] = true;
  3628. }
  3629. highlightOriginal[name] = attr[name];
  3630. }
  3631. }
  3632. if (highlightOriginal[name] !== style[name]) {
  3633. changes[name] = style[name];
  3634. }
  3635. }
  3636. } else {
  3637. for (name in style) {
  3638. if (!(name in changes)) {
  3639. changes[name] = highlightOriginal[name];
  3640. }
  3641. delete highlightOriginal[name];
  3642. }
  3643. changes.removeFromInstance = changes.removeFromInstance || {};
  3644. Ext.apply(changes.removeFromInstance, removeFromInstance);
  3645. highlightOriginal.removeFromInstance = {};
  3646. }
  3647. changes.highlighted = highlighted;
  3648. }
  3649. } else {
  3650. if (this._lower) {
  3651. changes = this._lower.pushDown(highlightOriginal, changes);
  3652. }
  3653. changes = this.filterChanges(attr, changes);
  3654. }
  3655. return changes;
  3656. }, popUp:function(attr, changes) {
  3657. changes = this.filterChanges(attr, changes);
  3658. this.callParent([attr, changes]);
  3659. }});
  3660. Ext.define('Ext.draw.sprite.Sprite', {alias:'sprite.sprite', mixins:{observable:'Ext.mixin.Observable'}, requires:['Ext.draw.Draw', 'Ext.draw.gradient.Gradient', 'Ext.draw.sprite.AttributeDefinition', 'Ext.draw.modifier.Target', 'Ext.draw.modifier.Animation', 'Ext.draw.modifier.Highlight'], isSprite:true, $configStrict:false, statics:{debug:false, defaultHitTestOptions:{fill:true, stroke:true}}, inheritableStatics:{def:{processors:{debug:'default', strokeStyle:'color', fillStyle:'color', strokeOpacity:'limited01',
  3661. fillOpacity:'limited01', lineWidth:'number', lineCap:'enums(butt,round,square)', lineJoin:'enums(round,bevel,miter)', lineDash:'data', lineDashOffset:'number', miterLimit:'number', shadowColor:'color', shadowOffsetX:'number', shadowOffsetY:'number', shadowBlur:'number', globalAlpha:'limited01', globalCompositeOperation:'enums(source-over,destination-over,source-in,destination-in,source-out,destination-out,source-atop,destination-atop,lighter,xor,copy)', hidden:'bool', transformFillStroke:'bool',
  3662. zIndex:'number', translationX:'number', translationY:'number', rotationRads:'number', rotationCenterX:'number', rotationCenterY:'number', scalingX:'number', scalingY:'number', scalingCenterX:'number', scalingCenterY:'number', constrainGradients:'bool'}, aliases:{'stroke':'strokeStyle', 'fill':'fillStyle', 'color':'fillStyle', 'stroke-width':'lineWidth', 'stroke-linecap':'lineCap', 'stroke-linejoin':'lineJoin', 'stroke-miterlimit':'miterLimit', 'text-anchor':'textAlign', 'opacity':'globalAlpha', translateX:'translationX',
  3663. translateY:'translationY', rotateRads:'rotationRads', rotateCenterX:'rotationCenterX', rotateCenterY:'rotationCenterY', scaleX:'scalingX', scaleY:'scalingY', scaleCenterX:'scalingCenterX', scaleCenterY:'scalingCenterY'}, defaults:{hidden:false, zIndex:0, strokeStyle:'none', fillStyle:'none', lineWidth:1, lineDash:[], lineDashOffset:0, lineCap:'butt', lineJoin:'miter', miterLimit:10, shadowColor:'none', shadowOffsetX:0, shadowOffsetY:0, shadowBlur:0, globalAlpha:1, strokeOpacity:1, fillOpacity:1,
  3664. transformFillStroke:false, translationX:0, translationY:0, rotationRads:0, rotationCenterX:null, rotationCenterY:null, scalingX:1, scalingY:1, scalingCenterX:null, scalingCenterY:null, constrainGradients:false}, triggers:{zIndex:'zIndex', globalAlpha:'canvas', globalCompositeOperation:'canvas', transformFillStroke:'canvas', strokeStyle:'canvas', fillStyle:'canvas', strokeOpacity:'canvas', fillOpacity:'canvas', lineWidth:'canvas', lineCap:'canvas', lineJoin:'canvas', lineDash:'canvas', lineDashOffset:'canvas',
  3665. miterLimit:'canvas', shadowColor:'canvas', shadowOffsetX:'canvas', shadowOffsetY:'canvas', shadowBlur:'canvas', translationX:'transform', translationY:'transform', rotationRads:'transform', rotationCenterX:'transform', rotationCenterY:'transform', scalingX:'transform', scalingY:'transform', scalingCenterX:'transform', scalingCenterY:'transform', constrainGradients:'canvas'}, updaters:{bbox:'bboxUpdater', zIndex:function(attr) {
  3666. attr.dirtyZIndex = true;
  3667. }, transform:function(attr) {
  3668. attr.dirtyTransform = true;
  3669. attr.bbox.transform.dirty = true;
  3670. }}}}, config:{parent:null, surface:null}, onClassExtended:function(subClass, data) {
  3671. var superclassCfg = subClass.superclass.self.def.initialConfig, ownCfg = data.inheritableStatics && data.inheritableStatics.def, cfg;
  3672. if (ownCfg) {
  3673. cfg = Ext.Object.merge({}, superclassCfg, ownCfg);
  3674. subClass.def = new Ext.draw.sprite.AttributeDefinition(cfg);
  3675. delete data.inheritableStatics.def;
  3676. } else {
  3677. subClass.def = new Ext.draw.sprite.AttributeDefinition(superclassCfg);
  3678. }
  3679. subClass.def.spriteClass = subClass;
  3680. }, constructor:function(config) {
  3681. if (Ext.getClassName(this) === 'Ext.draw.sprite.Sprite') {
  3682. throw 'Ext.draw.sprite.Sprite is an abstract class';
  3683. }
  3684. var me = this, attributeDefinition = me.self.def, defaults = attributeDefinition.getDefaults(), processors = attributeDefinition.getProcessors(), modifiers, name;
  3685. config = Ext.isObject(config) ? config : {};
  3686. me.id = config.id || Ext.id(null, 'ext-sprite-');
  3687. me.attr = {};
  3688. me.mixins.observable.constructor.apply(me, arguments);
  3689. modifiers = Ext.Array.from(config.modifiers, true);
  3690. me.createModifiers(modifiers);
  3691. me.initializeAttributes();
  3692. me.setAttributes(defaults, true);
  3693. for (name in config) {
  3694. if (name in processors && me['get' + name.charAt(0).toUpperCase() + name.substr(1)]) {
  3695. Ext.raise('The ' + me.$className + ' sprite has both a config and an attribute with the same name: ' + name + '.');
  3696. }
  3697. }
  3698. me.setAttributes(config);
  3699. }, updateSurface:function(surface, oldSurface) {
  3700. if (oldSurface) {
  3701. oldSurface.remove(this);
  3702. }
  3703. }, getDirty:function() {
  3704. return this.attr.dirty;
  3705. }, setDirty:function(dirty) {
  3706. var parent;
  3707. this.attr.dirty = dirty;
  3708. if (dirty) {
  3709. parent = this.getParent();
  3710. if (parent) {
  3711. parent.setDirty(true);
  3712. }
  3713. }
  3714. }, addModifier:function(modifier, reinitializeAttributes) {
  3715. var me = this, mods = me.modifiers, animation = mods.animation, target = mods.target, type;
  3716. if (!(modifier instanceof Ext.draw.modifier.Modifier)) {
  3717. type = typeof modifier === 'string' ? modifier : modifier.type;
  3718. if (type && !mods[type]) {
  3719. mods[type] = modifier = Ext.factory(modifier, null, null, 'modifier');
  3720. }
  3721. }
  3722. modifier.setSprite(me);
  3723. if (modifier.preFx || modifier.config && modifier.config.preFx) {
  3724. if (animation._lower) {
  3725. animation._lower.setUpper(modifier);
  3726. }
  3727. modifier.setUpper(animation);
  3728. } else {
  3729. target._lower.setUpper(modifier);
  3730. modifier.setUpper(target);
  3731. }
  3732. if (reinitializeAttributes) {
  3733. me.initializeAttributes();
  3734. }
  3735. return modifier;
  3736. }, createModifiers:function(modifiers) {
  3737. var me = this, Modifier = Ext.draw.modifier, animation = me.getInitialConfig().animation, mods, i, ln;
  3738. me.modifiers = mods = {target:new Modifier.Target({sprite:me}), animation:new Modifier.Animation(Ext.apply({sprite:me}, animation))};
  3739. mods.animation.setUpper(mods.target);
  3740. for (i = 0, ln = modifiers.length; i < ln; i++) {
  3741. me.addModifier(modifiers[i], false);
  3742. }
  3743. return mods;
  3744. }, getAnimation:function() {
  3745. return this.modifiers.animation;
  3746. }, setAnimation:function(config) {
  3747. if (!this.isConfiguring) {
  3748. this.modifiers.animation.setConfig(config || {duration:0});
  3749. }
  3750. }, initializeAttributes:function() {
  3751. this.modifiers.target.prepareAttributes(this.attr);
  3752. }, callUpdaters:function(attr) {
  3753. var me = this, updaters = me.self.def.getUpdaters(), any = false, dirty = false, pendingUpdaters, flags, updater, fn;
  3754. attr = attr || this.attr;
  3755. pendingUpdaters = attr.pendingUpdaters;
  3756. me.callUpdaters = Ext.emptyFn;
  3757. do {
  3758. any = false;
  3759. for (updater in pendingUpdaters) {
  3760. any = true;
  3761. flags = pendingUpdaters[updater];
  3762. delete pendingUpdaters[updater];
  3763. fn = updaters[updater];
  3764. if (typeof fn === 'string') {
  3765. fn = me[fn];
  3766. }
  3767. if (fn) {
  3768. fn.call(me, attr, flags);
  3769. }
  3770. }
  3771. dirty = dirty || any;
  3772. } while (any);
  3773. delete me.callUpdaters;
  3774. if (dirty) {
  3775. me.setDirty(true);
  3776. }
  3777. }, callUpdater:function(attr, updater, triggers) {
  3778. this.scheduleUpdater(attr, updater, triggers);
  3779. this.callUpdaters(attr);
  3780. }, scheduleUpdaters:function(attr, updaters, triggers) {
  3781. var updater, i, ln;
  3782. attr = attr || this.attr;
  3783. if (triggers) {
  3784. for (i = 0, ln = updaters.length; i < ln; i++) {
  3785. updater = updaters[i];
  3786. this.scheduleUpdater(attr, updater, triggers);
  3787. }
  3788. } else {
  3789. for (updater in updaters) {
  3790. triggers = updaters[updater];
  3791. this.scheduleUpdater(attr, updater, triggers);
  3792. }
  3793. }
  3794. }, scheduleUpdater:function(attr, updater, triggers) {
  3795. var pendingUpdaters;
  3796. triggers = triggers || [];
  3797. attr = attr || this.attr;
  3798. pendingUpdaters = attr.pendingUpdaters;
  3799. if (updater in pendingUpdaters) {
  3800. if (triggers.length) {
  3801. pendingUpdaters[updater] = Ext.Array.merge(pendingUpdaters[updater], triggers);
  3802. }
  3803. } else {
  3804. pendingUpdaters[updater] = triggers;
  3805. }
  3806. }, setAttributes:function(changes, bypassNormalization, avoidCopy) {
  3807. var me = this, changesToPush;
  3808. if (me.destroyed) {
  3809. Ext.Error.raise('Setting attributes of a destroyed sprite.');
  3810. }
  3811. if (bypassNormalization) {
  3812. if (avoidCopy) {
  3813. changesToPush = changes;
  3814. } else {
  3815. changesToPush = Ext.apply({}, changes);
  3816. }
  3817. } else {
  3818. changesToPush = me.self.def.normalize(changes);
  3819. }
  3820. me.modifiers.target.pushDown(me.attr, changesToPush);
  3821. }, setAttributesBypassingNormalization:function(changes, avoidCopy) {
  3822. return this.setAttributes(changes, true, avoidCopy);
  3823. }, bboxUpdater:function(attr) {
  3824. var hasRotation = attr.rotationRads !== 0, hasScaling = attr.scalingX !== 1 || attr.scalingY !== 1, noRotationCenter = attr.rotationCenterX === null || attr.rotationCenterY === null, noScalingCenter = attr.scalingCenterX === null || attr.scalingCenterY === null;
  3825. attr.bbox.plain.dirty = true;
  3826. attr.bbox.transform.dirty = true;
  3827. if (hasRotation && noRotationCenter || hasScaling && noScalingCenter) {
  3828. this.scheduleUpdater(attr, 'transform');
  3829. }
  3830. }, getBBox:function(isWithoutTransform) {
  3831. var me = this, attr = me.attr, bbox = attr.bbox, plain = bbox.plain, transform = bbox.transform;
  3832. if (plain.dirty) {
  3833. me.updatePlainBBox(plain);
  3834. plain.dirty = false;
  3835. }
  3836. if (!isWithoutTransform) {
  3837. me.applyTransformations();
  3838. if (transform.dirty) {
  3839. me.updateTransformedBBox(transform, plain);
  3840. transform.dirty = false;
  3841. }
  3842. return transform;
  3843. }
  3844. return plain;
  3845. }, updatePlainBBox:Ext.emptyFn, updateTransformedBBox:function(transform, plain) {
  3846. this.attr.matrix.transformBBox(plain, 0, transform);
  3847. }, getBBoxCenter:function(isWithoutTransform) {
  3848. var bbox = this.getBBox(isWithoutTransform);
  3849. if (bbox) {
  3850. return [bbox.x + bbox.width * 0.5, bbox.y + bbox.height * 0.5];
  3851. } else {
  3852. return [0, 0];
  3853. }
  3854. }, hide:function() {
  3855. this.attr.hidden = true;
  3856. this.setDirty(true);
  3857. return this;
  3858. }, show:function() {
  3859. this.attr.hidden = false;
  3860. this.setDirty(true);
  3861. return this;
  3862. }, useAttributes:function(ctx, rect) {
  3863. this.applyTransformations(this.isSpriteInstance);
  3864. var attr = this.attr, canvasAttributes = attr.canvasAttributes, strokeStyle = canvasAttributes.strokeStyle, fillStyle = canvasAttributes.fillStyle, lineDash = canvasAttributes.lineDash, lineDashOffset = canvasAttributes.lineDashOffset, id;
  3865. if (strokeStyle) {
  3866. if (strokeStyle.isGradient) {
  3867. ctx.strokeStyle = 'black';
  3868. ctx.strokeGradient = strokeStyle;
  3869. } else {
  3870. ctx.strokeGradient = false;
  3871. }
  3872. }
  3873. if (fillStyle) {
  3874. if (fillStyle.isGradient) {
  3875. ctx.fillStyle = 'black';
  3876. ctx.fillGradient = fillStyle;
  3877. } else {
  3878. ctx.fillGradient = false;
  3879. }
  3880. }
  3881. if (lineDash) {
  3882. ctx.setLineDash(lineDash);
  3883. }
  3884. if (Ext.isNumber(lineDashOffset) && Ext.isNumber(ctx.lineDashOffset)) {
  3885. ctx.lineDashOffset = lineDashOffset;
  3886. }
  3887. for (id in canvasAttributes) {
  3888. if (canvasAttributes[id] !== undefined && canvasAttributes[id] !== ctx[id]) {
  3889. ctx[id] = canvasAttributes[id];
  3890. }
  3891. }
  3892. this.setGradientBBox(ctx, rect);
  3893. }, setGradientBBox:function(ctx, rect) {
  3894. var attr = this.attr;
  3895. if (attr.constrainGradients) {
  3896. ctx.setGradientBBox({x:rect[0], y:rect[1], width:rect[2], height:rect[3]});
  3897. } else {
  3898. ctx.setGradientBBox(this.getBBox(attr.transformFillStroke));
  3899. }
  3900. }, applyTransformations:function(force) {
  3901. if (!force && !this.attr.dirtyTransform) {
  3902. return;
  3903. }
  3904. var me = this, attr = me.attr, center = me.getBBoxCenter(true), centerX = center[0], centerY = center[1], tx = attr.translationX, ty = attr.translationY, sx = attr.scalingX, sy = attr.scalingY === null ? attr.scalingX : attr.scalingY, scx = attr.scalingCenterX === null ? centerX : attr.scalingCenterX, scy = attr.scalingCenterY === null ? centerY : attr.scalingCenterY, rad = attr.rotationRads, rcx = attr.rotationCenterX === null ? centerX : attr.rotationCenterX, rcy = attr.rotationCenterY === null ?
  3905. centerY : attr.rotationCenterY, cos = Math.cos(rad), sin = Math.sin(rad), tx_4, ty_4;
  3906. if (sx === 1 && sy === 1) {
  3907. scx = 0;
  3908. scy = 0;
  3909. }
  3910. if (rad === 0) {
  3911. rcx = 0;
  3912. rcy = 0;
  3913. }
  3914. tx_4 = scx * (1 - sx) - rcx;
  3915. ty_4 = scy * (1 - sy) - rcy;
  3916. attr.matrix.elements = [cos * sx, sin * sx, -sin * sy, cos * sy, cos * tx_4 - sin * ty_4 + rcx + tx, sin * tx_4 + cos * ty_4 + rcy + ty];
  3917. attr.matrix.inverse(attr.inverseMatrix);
  3918. attr.dirtyTransform = false;
  3919. attr.bbox.transform.dirty = true;
  3920. }, transform:function(matrix, isSplit) {
  3921. var attr = this.attr, spriteMatrix = attr.matrix, elements;
  3922. if (matrix && matrix.isMatrix) {
  3923. elements = matrix.elements;
  3924. } else {
  3925. elements = matrix;
  3926. }
  3927. if (!(Ext.isArray(elements) && elements.length === 6)) {
  3928. Ext.raise('An instance of Ext.draw.Matrix or an array of 6 numbers is expected.');
  3929. }
  3930. spriteMatrix.prepend.apply(spriteMatrix, elements.slice());
  3931. spriteMatrix.inverse(attr.inverseMatrix);
  3932. if (isSplit) {
  3933. this.updateTransformAttributes();
  3934. }
  3935. attr.dirtyTransform = false;
  3936. attr.bbox.transform.dirty = true;
  3937. this.setDirty(true);
  3938. return this;
  3939. }, updateTransformAttributes:function() {
  3940. var attr = this.attr, split = attr.matrix.split();
  3941. attr.rotationRads = split.rotate;
  3942. attr.rotationCenterX = 0;
  3943. attr.rotationCenterY = 0;
  3944. attr.scalingX = split.scaleX;
  3945. attr.scalingY = split.scaleY;
  3946. attr.scalingCenterX = 0;
  3947. attr.scalingCenterY = 0;
  3948. attr.translationX = split.translateX;
  3949. attr.translationY = split.translateY;
  3950. }, resetTransform:function(isSplit) {
  3951. var attr = this.attr;
  3952. attr.matrix.reset();
  3953. attr.inverseMatrix.reset();
  3954. if (!isSplit) {
  3955. this.updateTransformAttributes();
  3956. }
  3957. attr.dirtyTransform = false;
  3958. attr.bbox.transform.dirty = true;
  3959. this.setDirty(true);
  3960. return this;
  3961. }, setTransform:function(matrix, isSplit) {
  3962. this.resetTransform(true);
  3963. this.transform.call(this, matrix, isSplit);
  3964. return this;
  3965. }, preRender:Ext.emptyFn, render:Ext.emptyFn, renderBBox:function(surface, ctx) {
  3966. var bbox = this.getBBox();
  3967. ctx.beginPath();
  3968. ctx.moveTo(bbox.x, bbox.y);
  3969. ctx.lineTo(bbox.x + bbox.width, bbox.y);
  3970. ctx.lineTo(bbox.x + bbox.width, bbox.y + bbox.height);
  3971. ctx.lineTo(bbox.x, bbox.y + bbox.height);
  3972. ctx.closePath();
  3973. ctx.strokeStyle = 'red';
  3974. ctx.strokeOpacity = 1;
  3975. ctx.lineWidth = 0.5;
  3976. ctx.stroke();
  3977. }, hitTest:function(point, options) {
  3978. var x, y, bbox, isBBoxHit;
  3979. if (this.isVisible()) {
  3980. x = point[0];
  3981. y = point[1];
  3982. bbox = this.getBBox();
  3983. isBBoxHit = bbox && x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
  3984. if (isBBoxHit) {
  3985. return {sprite:this};
  3986. }
  3987. }
  3988. return null;
  3989. }, isVisible:function() {
  3990. var attr = this.attr, parent = this.getParent(), hasParent = parent && (parent.isSurface || parent.isVisible()), isSeen = hasParent && !attr.hidden && attr.globalAlpha, none1 = Ext.util.Color.NONE, none2 = Ext.util.Color.RGBA_NONE, hasFill = attr.fillOpacity && attr.fillStyle !== none1 && attr.fillStyle !== none2, hasStroke = attr.strokeOpacity && attr.strokeStyle !== none1 && attr.strokeStyle !== none2, result = isSeen && (hasFill || hasStroke);
  3991. return !!result;
  3992. }, repaint:function() {
  3993. var surface = this.getSurface();
  3994. if (surface) {
  3995. surface.renderFrame();
  3996. }
  3997. }, remove:function() {
  3998. var surface = this.getSurface();
  3999. if (surface && surface.isSurface) {
  4000. return surface.remove(this);
  4001. }
  4002. return null;
  4003. }, destroy:function() {
  4004. var me = this, modifier = me.modifiers.target, currentModifier;
  4005. while (modifier) {
  4006. currentModifier = modifier;
  4007. modifier = modifier._lower;
  4008. currentModifier.destroy();
  4009. }
  4010. delete me.attr;
  4011. me.remove();
  4012. if (me.fireEvent('beforedestroy', me) !== false) {
  4013. me.fireEvent('destroy', me);
  4014. }
  4015. me.callParent();
  4016. }}, function() {
  4017. this.def = new Ext.draw.sprite.AttributeDefinition(this.def);
  4018. this.def.spriteClass = this;
  4019. });
  4020. Ext.define('Ext.draw.Path', {requires:['Ext.draw.Draw'], statics:{pathRe:/,?([achlmqrstvxz]),?/gi, pathRe2:/-/gi, pathSplitRe:/\s|,/g}, svgString:'', constructor:function(pathString) {
  4021. var me = this;
  4022. me.commands = [];
  4023. me.params = [];
  4024. me.cursor = null;
  4025. me.startX = 0;
  4026. me.startY = 0;
  4027. if (pathString) {
  4028. me.fromSvgString(pathString);
  4029. }
  4030. }, clear:function() {
  4031. var me = this;
  4032. me.params.length = 0;
  4033. me.commands.length = 0;
  4034. me.cursor = null;
  4035. me.startX = 0;
  4036. me.startY = 0;
  4037. me.dirt();
  4038. }, dirt:function() {
  4039. this.svgString = '';
  4040. }, moveTo:function(x, y) {
  4041. var me = this;
  4042. if (!me.cursor) {
  4043. me.cursor = [x, y];
  4044. }
  4045. me.params.push(x, y);
  4046. me.commands.push('M');
  4047. me.startX = x;
  4048. me.startY = y;
  4049. me.cursor[0] = x;
  4050. me.cursor[1] = y;
  4051. me.dirt();
  4052. }, lineTo:function(x, y) {
  4053. var me = this;
  4054. if (!me.cursor) {
  4055. me.cursor = [x, y];
  4056. me.params.push(x, y);
  4057. me.commands.push('M');
  4058. } else {
  4059. me.params.push(x, y);
  4060. me.commands.push('L');
  4061. }
  4062. me.cursor[0] = x;
  4063. me.cursor[1] = y;
  4064. me.dirt();
  4065. }, bezierCurveTo:function(cx1, cy1, cx2, cy2, x, y) {
  4066. var me = this;
  4067. if (!me.cursor) {
  4068. me.moveTo(cx1, cy1);
  4069. }
  4070. me.params.push(cx1, cy1, cx2, cy2, x, y);
  4071. me.commands.push('C');
  4072. me.cursor[0] = x;
  4073. me.cursor[1] = y;
  4074. me.dirt();
  4075. }, quadraticCurveTo:function(cx, cy, x, y) {
  4076. var me = this;
  4077. if (!me.cursor) {
  4078. me.moveTo(cx, cy);
  4079. }
  4080. me.bezierCurveTo((2 * cx + me.cursor[0]) / 3, (2 * cy + me.cursor[1]) / 3, (2 * cx + x) / 3, (2 * cy + y) / 3, x, y);
  4081. }, closePath:function() {
  4082. var me = this;
  4083. if (me.cursor) {
  4084. me.cursor = null;
  4085. me.commands.push('Z');
  4086. me.dirt();
  4087. }
  4088. }, arcTo:function(x1, y1, x2, y2, rx, ry, rotation) {
  4089. var me = this;
  4090. if (ry === undefined) {
  4091. ry = rx;
  4092. }
  4093. if (rotation === undefined) {
  4094. rotation = 0;
  4095. }
  4096. if (!me.cursor) {
  4097. me.moveTo(x1, y1);
  4098. return;
  4099. }
  4100. if (rx === 0 || ry === 0) {
  4101. me.lineTo(x1, y1);
  4102. return;
  4103. }
  4104. x2 -= x1;
  4105. y2 -= y1;
  4106. var x0 = me.cursor[0] - x1, y0 = me.cursor[1] - y1, area = x2 * y0 - y2 * x0, cos, sin, xx, yx, xy, yy, l0 = Math.sqrt(x0 * x0 + y0 * y0), l2 = Math.sqrt(x2 * x2 + y2 * y2), dist, cx, cy, temp;
  4107. if (area === 0) {
  4108. me.lineTo(x1, y1);
  4109. return;
  4110. }
  4111. if (ry !== rx) {
  4112. cos = Math.cos(rotation);
  4113. sin = Math.sin(rotation);
  4114. xx = cos / rx;
  4115. yx = sin / ry;
  4116. xy = -sin / rx;
  4117. yy = cos / ry;
  4118. temp = xx * x0 + yx * y0;
  4119. y0 = xy * x0 + yy * y0;
  4120. x0 = temp;
  4121. temp = xx * x2 + yx * y2;
  4122. y2 = xy * x2 + yy * y2;
  4123. x2 = temp;
  4124. } else {
  4125. x0 /= rx;
  4126. y0 /= ry;
  4127. x2 /= rx;
  4128. y2 /= ry;
  4129. }
  4130. cx = x0 * l2 + x2 * l0;
  4131. cy = y0 * l2 + y2 * l0;
  4132. dist = 1 / (Math.sin(Math.asin(Math.abs(area) / (l0 * l2)) * 0.5) * Math.sqrt(cx * cx + cy * cy));
  4133. cx *= dist;
  4134. cy *= dist;
  4135. var k0 = (cx * x0 + cy * y0) / (x0 * x0 + y0 * y0), k2 = (cx * x2 + cy * y2) / (x2 * x2 + y2 * y2), cosStart = x0 * k0 - cx, sinStart = y0 * k0 - cy, cosEnd = x2 * k2 - cx, sinEnd = y2 * k2 - cy, startAngle = Math.atan2(sinStart, cosStart), endAngle = Math.atan2(sinEnd, cosEnd);
  4136. if (area > 0) {
  4137. if (endAngle < startAngle) {
  4138. endAngle += Math.PI * 2;
  4139. }
  4140. } else {
  4141. if (startAngle < endAngle) {
  4142. startAngle += Math.PI * 2;
  4143. }
  4144. }
  4145. if (ry !== rx) {
  4146. cx = cos * cx * rx - sin * cy * ry + x1;
  4147. cy = sin * cy * ry + cos * cy * ry + y1;
  4148. me.lineTo(cos * rx * cosStart - sin * ry * sinStart + cx, sin * rx * cosStart + cos * ry * sinStart + cy);
  4149. me.ellipse(cx, cy, rx, ry, rotation, startAngle, endAngle, area < 0);
  4150. } else {
  4151. cx = cx * rx + x1;
  4152. cy = cy * ry + y1;
  4153. me.lineTo(rx * cosStart + cx, ry * sinStart + cy);
  4154. me.ellipse(cx, cy, rx, ry, rotation, startAngle, endAngle, area < 0);
  4155. }
  4156. }, ellipse:function(cx, cy, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
  4157. var me = this, params = me.params, start = params.length, count, temp, i, j;
  4158. if (endAngle - startAngle >= Math.PI * 2) {
  4159. me.ellipse(cx, cy, radiusX, radiusY, rotation, startAngle, startAngle + Math.PI, anticlockwise);
  4160. me.ellipse(cx, cy, radiusX, radiusY, rotation, startAngle + Math.PI, endAngle, anticlockwise);
  4161. return;
  4162. }
  4163. if (!anticlockwise) {
  4164. if (endAngle < startAngle) {
  4165. endAngle += Math.PI * 2;
  4166. }
  4167. count = me.approximateArc(params, cx, cy, radiusX, radiusY, rotation, startAngle, endAngle);
  4168. } else {
  4169. if (startAngle < endAngle) {
  4170. startAngle += Math.PI * 2;
  4171. }
  4172. count = me.approximateArc(params, cx, cy, radiusX, radiusY, rotation, endAngle, startAngle);
  4173. for (i = start, j = params.length - 2; i < j; i += 2, j -= 2) {
  4174. temp = params[i];
  4175. params[i] = params[j];
  4176. params[j] = temp;
  4177. temp = params[i + 1];
  4178. params[i + 1] = params[j + 1];
  4179. params[j + 1] = temp;
  4180. }
  4181. }
  4182. if (!me.cursor) {
  4183. me.cursor = [params[params.length - 2], params[params.length - 1]];
  4184. me.commands.push('M');
  4185. } else {
  4186. me.cursor[0] = params[params.length - 2];
  4187. me.cursor[1] = params[params.length - 1];
  4188. me.commands.push('L');
  4189. }
  4190. for (i = 2; i < count; i += 6) {
  4191. me.commands.push('C');
  4192. }
  4193. me.dirt();
  4194. }, arc:function(x, y, radius, startAngle, endAngle, anticlockwise) {
  4195. this.ellipse(x, y, radius, radius, 0, startAngle, endAngle, anticlockwise);
  4196. }, rect:function(x, y, width, height) {
  4197. var me = this;
  4198. if (width === 0 || height === 0) {
  4199. return;
  4200. }
  4201. me.moveTo(x, y);
  4202. me.lineTo(x + width, y);
  4203. me.lineTo(x + width, y + height);
  4204. me.lineTo(x, y + height);
  4205. me.closePath();
  4206. }, approximateArc:function(result, cx, cy, rx, ry, phi, theta1, theta2) {
  4207. var cosPhi = Math.cos(phi), sinPhi = Math.sin(phi), cosTheta1 = Math.cos(theta1), sinTheta1 = Math.sin(theta1), xx = cosPhi * cosTheta1 * rx - sinPhi * sinTheta1 * ry, yx = -cosPhi * sinTheta1 * rx - sinPhi * cosTheta1 * ry, xy = sinPhi * cosTheta1 * rx + cosPhi * sinTheta1 * ry, yy = -sinPhi * sinTheta1 * rx + cosPhi * cosTheta1 * ry, rightAngle = Math.PI / 2, count = 2, exx = xx, eyx = yx, exy = xy, eyy = yy, rho = 0.547443256150549, temp, y1, x3, y3, x2, y2;
  4208. theta2 -= theta1;
  4209. if (theta2 < 0) {
  4210. theta2 += Math.PI * 2;
  4211. }
  4212. result.push(xx + cx, xy + cy);
  4213. while (theta2 >= rightAngle) {
  4214. result.push(exx + eyx * rho + cx, exy + eyy * rho + cy, exx * rho + eyx + cx, exy * rho + eyy + cy, eyx + cx, eyy + cy);
  4215. count += 6;
  4216. theta2 -= rightAngle;
  4217. temp = exx;
  4218. exx = eyx;
  4219. eyx = -temp;
  4220. temp = exy;
  4221. exy = eyy;
  4222. eyy = -temp;
  4223. }
  4224. if (theta2) {
  4225. y1 = (0.3294738052815987 + 0.012120855841304373 * theta2) * theta2;
  4226. x3 = Math.cos(theta2);
  4227. y3 = Math.sin(theta2);
  4228. x2 = x3 + y1 * y3;
  4229. y2 = y3 - y1 * x3;
  4230. result.push(exx + eyx * y1 + cx, exy + eyy * y1 + cy, exx * x2 + eyx * y2 + cx, exy * x2 + eyy * y2 + cy, exx * x3 + eyx * y3 + cx, exy * x3 + eyy * y3 + cy);
  4231. count += 6;
  4232. }
  4233. return count;
  4234. }, arcSvg:function(rx, ry, rotation, fA, fS, x2, y2) {
  4235. if (rx < 0) {
  4236. rx = -rx;
  4237. }
  4238. if (ry < 0) {
  4239. ry = -ry;
  4240. }
  4241. var me = this, x1 = me.cursor[0], y1 = me.cursor[1], hdx = (x1 - x2) / 2, hdy = (y1 - y2) / 2, cosPhi = Math.cos(rotation), sinPhi = Math.sin(rotation), xp = hdx * cosPhi + hdy * sinPhi, yp = -hdx * sinPhi + hdy * cosPhi, ratX = xp / rx, ratY = yp / ry, lambda = ratX * ratX + ratY * ratY, cx = (x1 + x2) * 0.5, cy = (y1 + y2) * 0.5, cpx = 0, cpy = 0, theta1, deltaTheta;
  4242. if (lambda >= 1) {
  4243. lambda = Math.sqrt(lambda);
  4244. rx *= lambda;
  4245. ry *= lambda;
  4246. } else {
  4247. lambda = Math.sqrt(1 / lambda - 1);
  4248. if (fA === fS) {
  4249. lambda = -lambda;
  4250. }
  4251. cpx = lambda * rx * ratY;
  4252. cpy = -lambda * ry * ratX;
  4253. cx += cosPhi * cpx - sinPhi * cpy;
  4254. cy += sinPhi * cpx + cosPhi * cpy;
  4255. }
  4256. theta1 = Math.atan2((yp - cpy) / ry, (xp - cpx) / rx);
  4257. deltaTheta = Math.atan2((-yp - cpy) / ry, (-xp - cpx) / rx) - theta1;
  4258. if (fS) {
  4259. if (deltaTheta <= 0) {
  4260. deltaTheta += Math.PI * 2;
  4261. }
  4262. } else {
  4263. if (deltaTheta >= 0) {
  4264. deltaTheta -= Math.PI * 2;
  4265. }
  4266. }
  4267. me.ellipse(cx, cy, rx, ry, rotation, theta1, theta1 + deltaTheta, 1 - fS);
  4268. }, fromSvgString:function(pathString) {
  4269. if (!pathString) {
  4270. return;
  4271. }
  4272. var me = this, parts, paramCounts = {a:7, c:6, h:1, l:2, m:2, q:4, s:4, t:2, v:1, z:0, A:7, C:6, H:1, L:2, M:2, Q:4, S:4, T:2, V:1, Z:0}, lastCommand = '', lastControlX, lastControlY, lastX = 0, lastY = 0, part = false, i, partLength;
  4273. if (Ext.isString(pathString)) {
  4274. parts = pathString.replace(Ext.draw.Path.pathRe, ' $1 ').replace(Ext.draw.Path.pathRe2, ' -').split(Ext.draw.Path.pathSplitRe);
  4275. } else {
  4276. if (Ext.isArray(pathString)) {
  4277. parts = pathString.join(',').split(Ext.draw.Path.pathSplitRe);
  4278. }
  4279. }
  4280. for (i = 0, partLength = 0; i < parts.length; i++) {
  4281. if (parts[i] !== '') {
  4282. parts[partLength++] = parts[i];
  4283. }
  4284. }
  4285. parts.length = partLength;
  4286. me.clear();
  4287. for (i = 0; i < parts.length;) {
  4288. lastCommand = part;
  4289. part = parts[i];
  4290. i++;
  4291. switch(part) {
  4292. case 'M':
  4293. me.moveTo(lastX = +parts[i], lastY = +parts[i + 1]);
  4294. i += 2;
  4295. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4296. me.lineTo(lastX = +parts[i], lastY = +parts[i + 1]);
  4297. i += 2;
  4298. }
  4299. break;
  4300. case 'L':
  4301. me.lineTo(lastX = +parts[i], lastY = +parts[i + 1]);
  4302. i += 2;
  4303. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4304. me.lineTo(lastX = +parts[i], lastY = +parts[i + 1]);
  4305. i += 2;
  4306. }
  4307. break;
  4308. case 'A':
  4309. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4310. me.arcSvg(+parts[i], +parts[i + 1], +parts[i + 2] * Math.PI / 180, +parts[i + 3], +parts[i + 4], lastX = +parts[i + 5], lastY = +parts[i + 6]);
  4311. i += 7;
  4312. }
  4313. break;
  4314. case 'C':
  4315. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4316. me.bezierCurveTo(+parts[i], +parts[i + 1], lastControlX = +parts[i + 2], lastControlY = +parts[i + 3], lastX = +parts[i + 4], lastY = +parts[i + 5]);
  4317. i += 6;
  4318. }
  4319. break;
  4320. case 'Z':
  4321. me.closePath();
  4322. break;
  4323. case 'm':
  4324. me.moveTo(lastX += +parts[i], lastY += +parts[i + 1]);
  4325. i += 2;
  4326. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4327. me.lineTo(lastX += +parts[i], lastY += +parts[i + 1]);
  4328. i += 2;
  4329. }
  4330. break;
  4331. case 'l':
  4332. me.lineTo(lastX += +parts[i], lastY += +parts[i + 1]);
  4333. i += 2;
  4334. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4335. me.lineTo(lastX += +parts[i], lastY += +parts[i + 1]);
  4336. i += 2;
  4337. }
  4338. break;
  4339. case 'a':
  4340. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4341. me.arcSvg(+parts[i], +parts[i + 1], +parts[i + 2] * Math.PI / 180, +parts[i + 3], +parts[i + 4], lastX += +parts[i + 5], lastY += +parts[i + 6]);
  4342. i += 7;
  4343. }
  4344. break;
  4345. case 'c':
  4346. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4347. me.bezierCurveTo(lastX + +parts[i], lastY + +parts[i + 1], lastControlX = lastX + +parts[i + 2], lastControlY = lastY + +parts[i + 3], lastX += +parts[i + 4], lastY += +parts[i + 5]);
  4348. i += 6;
  4349. }
  4350. break;
  4351. case 'z':
  4352. me.closePath();
  4353. break;
  4354. case 's':
  4355. if (!(lastCommand === 'c' || lastCommand === 'C' || lastCommand === 's' || lastCommand === 'S')) {
  4356. lastControlX = lastX;
  4357. lastControlY = lastY;
  4358. }
  4359. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4360. me.bezierCurveTo(lastX + lastX - lastControlX, lastY + lastY - lastControlY, lastControlX = lastX + +parts[i], lastControlY = lastY + +parts[i + 1], lastX += +parts[i + 2], lastY += +parts[i + 3]);
  4361. i += 4;
  4362. }
  4363. break;
  4364. case 'S':
  4365. if (!(lastCommand === 'c' || lastCommand === 'C' || lastCommand === 's' || lastCommand === 'S')) {
  4366. lastControlX = lastX;
  4367. lastControlY = lastY;
  4368. }
  4369. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4370. me.bezierCurveTo(lastX + lastX - lastControlX, lastY + lastY - lastControlY, lastControlX = +parts[i], lastControlY = +parts[i + 1], lastX = +parts[i + 2], lastY = +parts[i + 3]);
  4371. i += 4;
  4372. }
  4373. break;
  4374. case 'q':
  4375. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4376. me.quadraticCurveTo(lastControlX = lastX + +parts[i], lastControlY = lastY + +parts[i + 1], lastX += +parts[i + 2], lastY += +parts[i + 3]);
  4377. i += 4;
  4378. }
  4379. break;
  4380. case 'Q':
  4381. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4382. me.quadraticCurveTo(lastControlX = +parts[i], lastControlY = +parts[i + 1], lastX = +parts[i + 2], lastY = +parts[i + 3]);
  4383. i += 4;
  4384. }
  4385. break;
  4386. case 't':
  4387. if (!(lastCommand === 'q' || lastCommand === 'Q' || lastCommand === 't' || lastCommand === 'T')) {
  4388. lastControlX = lastX;
  4389. lastControlY = lastY;
  4390. }
  4391. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4392. me.quadraticCurveTo(lastControlX = lastX + lastX - lastControlX, lastControlY = lastY + lastY - lastControlY, lastX += +parts[i + 1], lastY += +parts[i + 2]);
  4393. i += 2;
  4394. }
  4395. break;
  4396. case 'T':
  4397. if (!(lastCommand === 'q' || lastCommand === 'Q' || lastCommand === 't' || lastCommand === 'T')) {
  4398. lastControlX = lastX;
  4399. lastControlY = lastY;
  4400. }
  4401. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4402. me.quadraticCurveTo(lastControlX = lastX + lastX - lastControlX, lastControlY = lastY + lastY - lastControlY, lastX = +parts[i + 1], lastY = +parts[i + 2]);
  4403. i += 2;
  4404. }
  4405. break;
  4406. case 'h':
  4407. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4408. me.lineTo(lastX += +parts[i], lastY);
  4409. i++;
  4410. }
  4411. break;
  4412. case 'H':
  4413. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4414. me.lineTo(lastX = +parts[i], lastY);
  4415. i++;
  4416. }
  4417. break;
  4418. case 'v':
  4419. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4420. me.lineTo(lastX, lastY += +parts[i]);
  4421. i++;
  4422. }
  4423. break;
  4424. case 'V':
  4425. while (i < partLength && !paramCounts.hasOwnProperty(parts[i])) {
  4426. me.lineTo(lastX, lastY = +parts[i]);
  4427. i++;
  4428. }
  4429. break;
  4430. }
  4431. }
  4432. }, clone:function() {
  4433. var me = this, path = new Ext.draw.Path;
  4434. path.params = me.params.slice(0);
  4435. path.commands = me.commands.slice(0);
  4436. path.cursor = me.cursor ? me.cursor.slice(0) : null;
  4437. path.startX = me.startX;
  4438. path.startY = me.startY;
  4439. path.svgString = me.svgString;
  4440. return path;
  4441. }, transform:function(matrix) {
  4442. if (matrix.isIdentity()) {
  4443. return;
  4444. }
  4445. var xx = matrix.getXX(), yx = matrix.getYX(), dx = matrix.getDX(), xy = matrix.getXY(), yy = matrix.getYY(), dy = matrix.getDY(), params = this.params, i = 0, ln = params.length, x, y;
  4446. for (; i < ln; i += 2) {
  4447. x = params[i];
  4448. y = params[i + 1];
  4449. params[i] = x * xx + y * yx + dx;
  4450. params[i + 1] = x * xy + y * yy + dy;
  4451. }
  4452. this.dirt();
  4453. }, getDimension:function(target) {
  4454. if (!target) {
  4455. target = {};
  4456. }
  4457. if (!this.commands || !this.commands.length) {
  4458. target.x = 0;
  4459. target.y = 0;
  4460. target.width = 0;
  4461. target.height = 0;
  4462. return target;
  4463. }
  4464. target.left = Infinity;
  4465. target.top = Infinity;
  4466. target.right = -Infinity;
  4467. target.bottom = -Infinity;
  4468. var i = 0, j = 0, commands = this.commands, params = this.params, ln = commands.length, x, y;
  4469. for (; i < ln; i++) {
  4470. switch(commands[i]) {
  4471. case 'M':
  4472. case 'L':
  4473. x = params[j];
  4474. y = params[j + 1];
  4475. target.left = Math.min(x, target.left);
  4476. target.top = Math.min(y, target.top);
  4477. target.right = Math.max(x, target.right);
  4478. target.bottom = Math.max(y, target.bottom);
  4479. j += 2;
  4480. break;
  4481. case 'C':
  4482. this.expandDimension(target, x, y, params[j], params[j + 1], params[j + 2], params[j + 3], x = params[j + 4], y = params[j + 5]);
  4483. j += 6;
  4484. break;
  4485. }
  4486. }
  4487. target.x = target.left;
  4488. target.y = target.top;
  4489. target.width = target.right - target.left;
  4490. target.height = target.bottom - target.top;
  4491. return target;
  4492. }, getDimensionWithTransform:function(matrix, target) {
  4493. if (!this.commands || !this.commands.length) {
  4494. if (!target) {
  4495. target = {};
  4496. }
  4497. target.x = 0;
  4498. target.y = 0;
  4499. target.width = 0;
  4500. target.height = 0;
  4501. return target;
  4502. }
  4503. target.left = Infinity;
  4504. target.top = Infinity;
  4505. target.right = -Infinity;
  4506. target.bottom = -Infinity;
  4507. var xx = matrix.getXX(), yx = matrix.getYX(), dx = matrix.getDX(), xy = matrix.getXY(), yy = matrix.getYY(), dy = matrix.getDY(), i = 0, j = 0, commands = this.commands, params = this.params, ln = commands.length, x, y;
  4508. for (; i < ln; i++) {
  4509. switch(commands[i]) {
  4510. case 'M':
  4511. case 'L':
  4512. x = params[j] * xx + params[j + 1] * yx + dx;
  4513. y = params[j] * xy + params[j + 1] * yy + dy;
  4514. target.left = Math.min(x, target.left);
  4515. target.top = Math.min(y, target.top);
  4516. target.right = Math.max(x, target.right);
  4517. target.bottom = Math.max(y, target.bottom);
  4518. j += 2;
  4519. break;
  4520. case 'C':
  4521. this.expandDimension(target, x, y, params[j] * xx + params[j + 1] * yx + dx, params[j] * xy + params[j + 1] * yy + dy, params[j + 2] * xx + params[j + 3] * yx + dx, params[j + 2] * xy + params[j + 3] * yy + dy, x = params[j + 4] * xx + params[j + 5] * yx + dx, y = params[j + 4] * xy + params[j + 5] * yy + dy);
  4522. j += 6;
  4523. break;
  4524. }
  4525. }
  4526. if (!target) {
  4527. target = {};
  4528. }
  4529. target.x = target.left;
  4530. target.y = target.top;
  4531. target.width = target.right - target.left;
  4532. target.height = target.bottom - target.top;
  4533. return target;
  4534. }, expandDimension:function(target, x1, y1, cx1, cy1, cx2, cy2, x2, y2) {
  4535. var me = this, l = target.left, r = target.right, t = target.top, b = target.bottom, dim = me.dim || (me.dim = []);
  4536. me.curveDimension(x1, cx1, cx2, x2, dim);
  4537. l = Math.min(l, dim[0]);
  4538. r = Math.max(r, dim[1]);
  4539. me.curveDimension(y1, cy1, cy2, y2, dim);
  4540. t = Math.min(t, dim[0]);
  4541. b = Math.max(b, dim[1]);
  4542. target.left = l;
  4543. target.right = r;
  4544. target.top = t;
  4545. target.bottom = b;
  4546. }, curveDimension:function(a, b, c, d, dim) {
  4547. var qa = 3 * (-a + 3 * (b - c) + d), qb = 6 * (a - 2 * b + c), qc = -3 * (a - b), x, y, min = Math.min(a, d), max = Math.max(a, d), delta;
  4548. if (qa === 0) {
  4549. if (qb === 0) {
  4550. dim[0] = min;
  4551. dim[1] = max;
  4552. return;
  4553. } else {
  4554. x = -qc / qb;
  4555. if (0 < x && x < 1) {
  4556. y = this.interpolate(a, b, c, d, x);
  4557. min = Math.min(min, y);
  4558. max = Math.max(max, y);
  4559. }
  4560. }
  4561. } else {
  4562. delta = qb * qb - 4 * qa * qc;
  4563. if (delta >= 0) {
  4564. delta = Math.sqrt(delta);
  4565. x = (delta - qb) / 2 / qa;
  4566. if (0 < x && x < 1) {
  4567. y = this.interpolate(a, b, c, d, x);
  4568. min = Math.min(min, y);
  4569. max = Math.max(max, y);
  4570. }
  4571. if (delta > 0) {
  4572. x -= delta / qa;
  4573. if (0 < x && x < 1) {
  4574. y = this.interpolate(a, b, c, d, x);
  4575. min = Math.min(min, y);
  4576. max = Math.max(max, y);
  4577. }
  4578. }
  4579. }
  4580. }
  4581. dim[0] = min;
  4582. dim[1] = max;
  4583. }, interpolate:function(a, b, c, d, t) {
  4584. var rate;
  4585. if (t === 0) {
  4586. return a;
  4587. }
  4588. if (t === 1) {
  4589. return d;
  4590. }
  4591. rate = (1 - t) / t;
  4592. return t * t * t * (d + rate * (3 * c + rate * (3 * b + rate * a)));
  4593. }, fromStripes:function(stripes) {
  4594. var me = this, i = 0, ln = stripes.length, j, ln2, stripe;
  4595. me.clear();
  4596. for (; i < ln; i++) {
  4597. stripe = stripes[i];
  4598. me.params.push.apply(me.params, stripe);
  4599. me.commands.push('M');
  4600. for (j = 2, ln2 = stripe.length; j < ln2; j += 6) {
  4601. me.commands.push('C');
  4602. }
  4603. }
  4604. if (!me.cursor) {
  4605. me.cursor = [];
  4606. }
  4607. me.cursor[0] = me.params[me.params.length - 2];
  4608. me.cursor[1] = me.params[me.params.length - 1];
  4609. me.dirt();
  4610. }, toStripes:function(target) {
  4611. var stripes = target || [], curr, x, y, lastX, lastY, startX, startY, i, j, commands = this.commands, params = this.params, ln = commands.length;
  4612. for (i = 0, j = 0; i < ln; i++) {
  4613. switch(commands[i]) {
  4614. case 'M':
  4615. curr = [startX = lastX = params[j++], startY = lastY = params[j++]];
  4616. stripes.push(curr);
  4617. break;
  4618. case 'L':
  4619. x = params[j++];
  4620. y = params[j++];
  4621. curr.push((lastX + lastX + x) / 3, (lastY + lastY + y) / 3, (lastX + x + x) / 3, (lastY + y + y) / 3, lastX = x, lastY = y);
  4622. break;
  4623. case 'C':
  4624. curr.push(params[j++], params[j++], params[j++], params[j++], lastX = params[j++], lastY = params[j++]);
  4625. break;
  4626. case 'Z':
  4627. x = startX;
  4628. y = startY;
  4629. curr.push((lastX + lastX + x) / 3, (lastY + lastY + y) / 3, (lastX + x + x) / 3, (lastY + y + y) / 3, lastX = x, lastY = y);
  4630. break;
  4631. }
  4632. }
  4633. return stripes;
  4634. }, updateSvgString:function() {
  4635. var result = [], commands = this.commands, params = this.params, ln = commands.length, i = 0, j = 0;
  4636. for (; i < ln; i++) {
  4637. switch(commands[i]) {
  4638. case 'M':
  4639. result.push('M' + params[j] + ',' + params[j + 1]);
  4640. j += 2;
  4641. break;
  4642. case 'L':
  4643. result.push('L' + params[j] + ',' + params[j + 1]);
  4644. j += 2;
  4645. break;
  4646. case 'C':
  4647. result.push('C' + params[j] + ',' + params[j + 1] + ' ' + params[j + 2] + ',' + params[j + 3] + ' ' + params[j + 4] + ',' + params[j + 5]);
  4648. j += 6;
  4649. break;
  4650. case 'Z':
  4651. result.push('Z');
  4652. break;
  4653. }
  4654. }
  4655. this.svgString = result.join('');
  4656. }, toString:function() {
  4657. if (!this.svgString) {
  4658. this.updateSvgString();
  4659. }
  4660. return this.svgString;
  4661. }});
  4662. Ext.define('Ext.draw.overrides.hittest.Path', {override:'Ext.draw.Path', rayOrigin:{x:-10000, y:-10000}, isPointInPath:function(x, y) {
  4663. var me = this, commands = me.commands, solver = Ext.draw.PathUtil, origin = me.rayOrigin, params = me.params, ln = commands.length, firstX = null, firstY = null, lastX = 0, lastY = 0, count = 0, i, j;
  4664. for (i = 0, j = 0; i < ln; i++) {
  4665. switch(commands[i]) {
  4666. case 'M':
  4667. if (firstX !== null) {
  4668. if (solver.linesIntersection(firstX, firstY, lastX, lastY, origin.x, origin.y, x, y)) {
  4669. count += 1;
  4670. }
  4671. }
  4672. firstX = lastX = params[j];
  4673. firstY = lastY = params[j + 1];
  4674. j += 2;
  4675. break;
  4676. case 'L':
  4677. if (solver.linesIntersection(lastX, lastY, params[j], params[j + 1], origin.x, origin.y, x, y)) {
  4678. count += 1;
  4679. }
  4680. lastX = params[j];
  4681. lastY = params[j + 1];
  4682. j += 2;
  4683. break;
  4684. case 'C':
  4685. count += solver.cubicLineIntersections(lastX, params[j], params[j + 2], params[j + 4], lastY, params[j + 1], params[j + 3], params[j + 5], origin.x, origin.y, x, y).length;
  4686. lastX = params[j + 4];
  4687. lastY = params[j + 5];
  4688. j += 6;
  4689. break;
  4690. case 'Z':
  4691. if (firstX !== null) {
  4692. if (solver.linesIntersection(firstX, firstY, lastX, lastY, origin.x, origin.y, x, y)) {
  4693. count += 1;
  4694. }
  4695. }
  4696. break;
  4697. }
  4698. }
  4699. return count % 2 === 1;
  4700. }, isPointOnPath:function(x, y) {
  4701. var me = this, commands = me.commands, solver = Ext.draw.PathUtil, params = me.params, ln = commands.length, firstX = null, firstY = null, lastX = 0, lastY = 0, i, j;
  4702. for (i = 0, j = 0; i < ln; i++) {
  4703. switch(commands[i]) {
  4704. case 'M':
  4705. if (firstX !== null) {
  4706. if (solver.pointOnLine(firstX, firstY, lastX, lastY, x, y)) {
  4707. return true;
  4708. }
  4709. }
  4710. firstX = lastX = params[j];
  4711. firstY = lastY = params[j + 1];
  4712. j += 2;
  4713. break;
  4714. case 'L':
  4715. if (solver.pointOnLine(lastX, lastY, params[j], params[j + 1], x, y)) {
  4716. return true;
  4717. }
  4718. lastX = params[j];
  4719. lastY = params[j + 1];
  4720. j += 2;
  4721. break;
  4722. case 'C':
  4723. if (solver.pointOnCubic(lastX, params[j], params[j + 2], params[j + 4], lastY, params[j + 1], params[j + 3], params[j + 5], x, y)) {
  4724. return true;
  4725. }
  4726. lastX = params[j + 4];
  4727. lastY = params[j + 5];
  4728. j += 6;
  4729. break;
  4730. case 'Z':
  4731. if (firstX !== null) {
  4732. if (solver.pointOnLine(firstX, firstY, lastX, lastY, x, y)) {
  4733. return true;
  4734. }
  4735. }
  4736. break;
  4737. }
  4738. }
  4739. return false;
  4740. }, getSegmentIntersections:function(x1, y1, x2, y2, x3, y3, x4, y4) {
  4741. var me = this, count = arguments.length, solver = Ext.draw.PathUtil, commands = me.commands, params = me.params, ln = commands.length, firstX = null, firstY = null, lastX = 0, lastY = 0, intersections = [], i, j, points;
  4742. for (i = 0, j = 0; i < ln; i++) {
  4743. switch(commands[i]) {
  4744. case 'M':
  4745. if (firstX !== null) {
  4746. switch(count) {
  4747. case 4:
  4748. points = solver.linesIntersection(firstX, firstY, lastX, lastY, x1, y1, x2, y2);
  4749. if (points) {
  4750. intersections.push(points);
  4751. }
  4752. break;
  4753. case 8:
  4754. points = solver.cubicLineIntersections(x1, x2, x3, x4, y1, y2, y3, y4, firstX, firstY, lastX, lastY);
  4755. intersections.push.apply(intersections, points);
  4756. break;
  4757. }
  4758. }
  4759. firstX = lastX = params[j];
  4760. firstY = lastY = params[j + 1];
  4761. j += 2;
  4762. break;
  4763. case 'L':
  4764. switch(count) {
  4765. case 4:
  4766. points = solver.linesIntersection(lastX, lastY, params[j], params[j + 1], x1, y1, x2, y2);
  4767. if (points) {
  4768. intersections.push(points);
  4769. }
  4770. break;
  4771. case 8:
  4772. points = solver.cubicLineIntersections(x1, x2, x3, x4, y1, y2, y3, y4, lastX, lastY, params[j], params[j + 1]);
  4773. intersections.push.apply(intersections, points);
  4774. break;
  4775. }lastX = params[j];
  4776. lastY = params[j + 1];
  4777. j += 2;
  4778. break;
  4779. case 'C':
  4780. switch(count) {
  4781. case 4:
  4782. points = solver.cubicLineIntersections(lastX, params[j], params[j + 2], params[j + 4], lastY, params[j + 1], params[j + 3], params[j + 5], x1, y1, x2, y2);
  4783. intersections.push.apply(intersections, points);
  4784. break;
  4785. case 8:
  4786. points = solver.cubicsIntersections(lastX, params[j], params[j + 2], params[j + 4], lastY, params[j + 1], params[j + 3], params[j + 5], x1, x2, x3, x4, y1, y2, y3, y4);
  4787. intersections.push.apply(intersections, points);
  4788. break;
  4789. }lastX = params[j + 4];
  4790. lastY = params[j + 5];
  4791. j += 6;
  4792. break;
  4793. case 'Z':
  4794. if (firstX !== null) {
  4795. switch(count) {
  4796. case 4:
  4797. points = solver.linesIntersection(firstX, firstY, lastX, lastY, x1, y1, x2, y2);
  4798. if (points) {
  4799. intersections.push(points);
  4800. }
  4801. break;
  4802. case 8:
  4803. points = solver.cubicLineIntersections(x1, x2, x3, x4, y1, y2, y3, y4, firstX, firstY, lastX, lastY);
  4804. intersections.push.apply(intersections, points);
  4805. break;
  4806. }
  4807. }
  4808. break;
  4809. }
  4810. }
  4811. return intersections;
  4812. }, getIntersections:function(path) {
  4813. var me = this, commands = me.commands, params = me.params, ln = commands.length, firstX = null, firstY = null, lastX = 0, lastY = 0, intersections = [], i, j, points;
  4814. for (i = 0, j = 0; i < ln; i++) {
  4815. switch(commands[i]) {
  4816. case 'M':
  4817. if (firstX !== null) {
  4818. points = path.getSegmentIntersections.call(path, firstX, firstY, lastX, lastY);
  4819. intersections.push.apply(intersections, points);
  4820. }
  4821. firstX = lastX = params[j];
  4822. firstY = lastY = params[j + 1];
  4823. j += 2;
  4824. break;
  4825. case 'L':
  4826. points = path.getSegmentIntersections.call(path, lastX, lastY, params[j], params[j + 1]);
  4827. intersections.push.apply(intersections, points);
  4828. lastX = params[j];
  4829. lastY = params[j + 1];
  4830. j += 2;
  4831. break;
  4832. case 'C':
  4833. points = path.getSegmentIntersections.call(path, lastX, lastY, params[j], params[j + 1], params[j + 2], params[j + 3], params[j + 4], params[j + 5]);
  4834. intersections.push.apply(intersections, points);
  4835. lastX = params[j + 4];
  4836. lastY = params[j + 5];
  4837. j += 6;
  4838. break;
  4839. case 'Z':
  4840. if (firstX !== null) {
  4841. points = path.getSegmentIntersections.call(path, firstX, firstY, lastX, lastY);
  4842. intersections.push.apply(intersections, points);
  4843. }
  4844. break;
  4845. }
  4846. }
  4847. return intersections;
  4848. }});
  4849. Ext.define('Ext.draw.sprite.Path', {extend:'Ext.draw.sprite.Sprite', requires:['Ext.draw.Draw', 'Ext.draw.Path'], alias:['sprite.path', 'Ext.draw.Sprite'], type:'path', isPath:true, inheritableStatics:{def:{processors:{path:function(n, o) {
  4850. if (!(n instanceof Ext.draw.Path)) {
  4851. n = new Ext.draw.Path(n);
  4852. }
  4853. return n;
  4854. }}, aliases:{d:'path'}, triggers:{path:'bbox'}, updaters:{path:function(attr) {
  4855. var path = attr.path;
  4856. if (!path || path.bindAttr !== attr) {
  4857. path = new Ext.draw.Path;
  4858. path.bindAttr = attr;
  4859. attr.path = path;
  4860. }
  4861. path.clear();
  4862. this.updatePath(path, attr);
  4863. this.scheduleUpdater(attr, 'bbox', ['path']);
  4864. }}}}, updatePlainBBox:function(plain) {
  4865. if (this.attr.path) {
  4866. this.attr.path.getDimension(plain);
  4867. }
  4868. }, updateTransformedBBox:function(transform) {
  4869. if (this.attr.path) {
  4870. this.attr.path.getDimensionWithTransform(this.attr.matrix, transform);
  4871. }
  4872. }, render:function(surface, ctx) {
  4873. var mat = this.attr.matrix, attr = this.attr;
  4874. if (!attr.path || attr.path.params.length === 0) {
  4875. return;
  4876. }
  4877. mat.toContext(ctx);
  4878. ctx.appendPath(attr.path);
  4879. ctx.fillStroke(attr);
  4880. var debug = attr.debug || this.statics().debug || Ext.draw.sprite.Sprite.debug;
  4881. if (debug) {
  4882. if (debug.bbox) {
  4883. this.renderBBox(surface, ctx);
  4884. }
  4885. if (debug.xray) {
  4886. this.renderXRay(surface, ctx);
  4887. }
  4888. }
  4889. }, renderXRay:function(surface, ctx) {
  4890. var attr = this.attr, mat = attr.matrix, imat = attr.inverseMatrix, path = attr.path, commands = path.commands, params = path.params, ln = commands.length, twoPi = Math.PI * 2, size = 2, i, j;
  4891. mat.toContext(ctx);
  4892. ctx.beginPath();
  4893. for (i = 0, j = 0; i < ln; i++) {
  4894. switch(commands[i]) {
  4895. case 'M':
  4896. ctx.moveTo(params[j] - size, params[j + 1] - size);
  4897. ctx.rect(params[j] - size, params[j + 1] - size, size * 2, size * 2);
  4898. j += 2;
  4899. break;
  4900. case 'L':
  4901. ctx.moveTo(params[j] - size, params[j + 1] - size);
  4902. ctx.rect(params[j] - size, params[j + 1] - size, size * 2, size * 2);
  4903. j += 2;
  4904. break;
  4905. case 'C':
  4906. ctx.moveTo(params[j] + size, params[j + 1]);
  4907. ctx.arc(params[j], params[j + 1], size, 0, twoPi, true);
  4908. j += 2;
  4909. ctx.moveTo(params[j] + size, params[j + 1]);
  4910. ctx.arc(params[j], params[j + 1], size, 0, twoPi, true);
  4911. j += 2;
  4912. ctx.moveTo(params[j] + size * 2, params[j + 1]);
  4913. ctx.rect(params[j] - size, params[j + 1] - size, size * 2, size * 2);
  4914. j += 2;
  4915. break;
  4916. default:
  4917. }
  4918. }
  4919. imat.toContext(ctx);
  4920. ctx.strokeStyle = 'black';
  4921. ctx.strokeOpacity = 1;
  4922. ctx.lineWidth = 1;
  4923. ctx.stroke();
  4924. mat.toContext(ctx);
  4925. ctx.beginPath();
  4926. for (i = 0, j = 0; i < ln; i++) {
  4927. switch(commands[i]) {
  4928. case 'M':
  4929. ctx.moveTo(params[j], params[j + 1]);
  4930. j += 2;
  4931. break;
  4932. case 'L':
  4933. ctx.moveTo(params[j], params[j + 1]);
  4934. j += 2;
  4935. break;
  4936. case 'C':
  4937. ctx.lineTo(params[j], params[j + 1]);
  4938. j += 2;
  4939. ctx.moveTo(params[j], params[j + 1]);
  4940. j += 2;
  4941. ctx.lineTo(params[j], params[j + 1]);
  4942. j += 2;
  4943. break;
  4944. default:
  4945. }
  4946. }
  4947. imat.toContext(ctx);
  4948. ctx.lineWidth = 0.5;
  4949. ctx.stroke();
  4950. }, updatePath:function(path, attr) {
  4951. }});
  4952. Ext.define('Ext.draw.overrides.hittest.sprite.Path', {override:'Ext.draw.sprite.Path', requires:['Ext.draw.Color'], isPointInPath:function(x, y) {
  4953. var attr = this.attr, path, matrix, params, result;
  4954. if (attr.fillStyle === Ext.util.Color.RGBA_NONE) {
  4955. return this.isPointOnPath(x, y);
  4956. }
  4957. path = attr.path;
  4958. matrix = attr.matrix;
  4959. if (!matrix.isIdentity()) {
  4960. params = path.params.slice(0);
  4961. path.transform(attr.matrix);
  4962. }
  4963. result = path.isPointInPath(x, y);
  4964. if (params) {
  4965. path.params = params;
  4966. }
  4967. return result;
  4968. }, isPointOnPath:function(x, y) {
  4969. var attr = this.attr, path = attr.path, matrix = attr.matrix, params, result;
  4970. if (!matrix.isIdentity()) {
  4971. params = path.params.slice(0);
  4972. path.transform(attr.matrix);
  4973. }
  4974. result = path.isPointOnPath(x, y);
  4975. if (params) {
  4976. path.params = params;
  4977. }
  4978. return result;
  4979. }, hitTest:function(point, options) {
  4980. var me = this, attr = me.attr, path = attr.path, matrix = attr.matrix, x = point[0], y = point[1], parentResult = me.callParent([point, options]), result = null, params, isFilled;
  4981. if (!parentResult) {
  4982. return result;
  4983. }
  4984. options = options || Ext.draw.sprite.Sprite.defaultHitTestOptions;
  4985. if (!matrix.isIdentity()) {
  4986. params = path.params.slice(0);
  4987. path.transform(attr.matrix);
  4988. }
  4989. if (options.fill && options.stroke) {
  4990. isFilled = attr.fillStyle !== Ext.util.Color.NONE && attr.fillStyle !== Ext.util.Color.RGBA_NONE;
  4991. if (isFilled) {
  4992. if (path.isPointInPath(x, y)) {
  4993. result = {sprite:me};
  4994. }
  4995. } else {
  4996. if (path.isPointInPath(x, y) || path.isPointOnPath(x, y)) {
  4997. result = {sprite:me};
  4998. }
  4999. }
  5000. } else {
  5001. if (options.stroke && !options.fill) {
  5002. if (path.isPointOnPath(x, y)) {
  5003. result = {sprite:me};
  5004. }
  5005. } else {
  5006. if (options.fill && !options.stroke) {
  5007. if (path.isPointInPath(x, y)) {
  5008. result = {sprite:me};
  5009. }
  5010. }
  5011. }
  5012. }
  5013. if (params) {
  5014. path.params = params;
  5015. }
  5016. return result;
  5017. }, getIntersections:function(path) {
  5018. if (!(path.isSprite && path.isPath)) {
  5019. return [];
  5020. }
  5021. var aAttr = this.attr, bAttr = path.attr, aPath = aAttr.path, bPath = bAttr.path, aMatrix = aAttr.matrix, bMatrix = bAttr.matrix, aParams, bParams, intersections;
  5022. if (!aMatrix.isIdentity()) {
  5023. aParams = aPath.params.slice(0);
  5024. aPath.transform(aAttr.matrix);
  5025. }
  5026. if (!bMatrix.isIdentity()) {
  5027. bParams = bPath.params.slice(0);
  5028. bPath.transform(bAttr.matrix);
  5029. }
  5030. intersections = aPath.getIntersections(bPath);
  5031. if (aParams) {
  5032. aPath.params = aParams;
  5033. }
  5034. if (bParams) {
  5035. bPath.params = bParams;
  5036. }
  5037. return intersections;
  5038. }});
  5039. Ext.define('Ext.draw.sprite.Circle', {extend:'Ext.draw.sprite.Path', alias:'sprite.circle', type:'circle', inheritableStatics:{def:{processors:{cx:'number', cy:'number', r:'number'}, aliases:{radius:'r', x:'cx', y:'cy', centerX:'cx', centerY:'cy'}, defaults:{cx:0, cy:0, r:4}, triggers:{cx:'path', cy:'path', r:'path'}}}, updatePlainBBox:function(plain) {
  5040. var attr = this.attr, cx = attr.cx, cy = attr.cy, r = attr.r;
  5041. plain.x = cx - r;
  5042. plain.y = cy - r;
  5043. plain.width = r + r;
  5044. plain.height = r + r;
  5045. }, updateTransformedBBox:function(transform) {
  5046. var attr = this.attr, cx = attr.cx, cy = attr.cy, r = attr.r, matrix = attr.matrix, scaleX = matrix.getScaleX(), scaleY = matrix.getScaleY(), rx, ry;
  5047. rx = scaleX * r;
  5048. ry = scaleY * r;
  5049. transform.x = matrix.x(cx, cy) - rx;
  5050. transform.y = matrix.y(cx, cy) - ry;
  5051. transform.width = rx + rx;
  5052. transform.height = ry + ry;
  5053. }, updatePath:function(path, attr) {
  5054. path.arc(attr.cx, attr.cy, attr.r, 0, Math.PI * 2, false);
  5055. }});
  5056. Ext.define('Ext.draw.sprite.Arc', {extend:'Ext.draw.sprite.Circle', alias:'sprite.arc', type:'arc', inheritableStatics:{def:{processors:{startAngle:'number', endAngle:'number', anticlockwise:'bool'}, aliases:{from:'startAngle', to:'endAngle', start:'startAngle', end:'endAngle'}, defaults:{startAngle:0, endAngle:Math.PI * 2, anticlockwise:false}, triggers:{startAngle:'path', endAngle:'path', anticlockwise:'path'}}}, updatePath:function(path, attr) {
  5057. path.arc(attr.cx, attr.cy, attr.r, attr.startAngle, attr.endAngle, attr.anticlockwise);
  5058. }});
  5059. Ext.define('Ext.draw.sprite.Arrow', {extend:'Ext.draw.sprite.Path', alias:'sprite.arrow', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'path'}}}, updatePath:function(path, attr) {
  5060. var s = attr.size * 1.5, x = attr.x - attr.lineWidth / 2, y = attr.y;
  5061. path.fromSvgString('M'.concat(x - s * 0.7, ',', y - s * 0.4, 'l', [s * 0.6, 0, 0, -s * 0.4, s, s * 0.8, -s, s * 0.8, 0, -s * 0.4, -s * 0.6, 0], 'z'));
  5062. }});
  5063. Ext.define('Ext.draw.sprite.Composite', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.composite', type:'composite', isComposite:true, config:{sprites:[]}, constructor:function(config) {
  5064. this.sprites = [];
  5065. this.map = {};
  5066. this.callParent([config]);
  5067. }, addSprite:function(sprite) {
  5068. var i = 0, attr, results, oldTransformations;
  5069. if (Ext.isArray(sprite)) {
  5070. results = [];
  5071. while (i < sprite.length) {
  5072. results.push(this.addSprite(sprite[i++]));
  5073. }
  5074. return results;
  5075. }
  5076. if (sprite && sprite.type && !sprite.isSprite) {
  5077. sprite = Ext.create('sprite.' + sprite.type, sprite);
  5078. }
  5079. if (!sprite || !sprite.isSprite || sprite.isComposite) {
  5080. return null;
  5081. }
  5082. sprite.setSurface(null);
  5083. sprite.setParent(this);
  5084. attr = this.attr;
  5085. oldTransformations = sprite.applyTransformations;
  5086. sprite.applyTransformations = function(force) {
  5087. if (sprite.attr.dirtyTransform) {
  5088. attr.dirtyTransform = true;
  5089. attr.bbox.plain.dirty = true;
  5090. attr.bbox.transform.dirty = true;
  5091. }
  5092. oldTransformations.call(sprite, force);
  5093. };
  5094. this.sprites.push(sprite);
  5095. this.map[sprite.id] = sprite.getId();
  5096. attr.bbox.plain.dirty = true;
  5097. attr.bbox.transform.dirty = true;
  5098. return sprite;
  5099. }, add:function(sprite) {
  5100. return this.addSprite(sprite);
  5101. }, removeSprite:function(sprite, isDestroy) {
  5102. var me = this, id, isOwnSprite;
  5103. if (sprite) {
  5104. if (sprite.charAt) {
  5105. sprite = me.map[sprite];
  5106. }
  5107. if (!sprite || !sprite.isSprite) {
  5108. return null;
  5109. }
  5110. if (sprite.destroyed || sprite.destroying) {
  5111. return sprite;
  5112. }
  5113. id = sprite.getId();
  5114. isOwnSprite = me.map[id];
  5115. delete me.map[id];
  5116. if (isDestroy) {
  5117. sprite.destroy();
  5118. }
  5119. if (!isOwnSprite) {
  5120. return sprite;
  5121. }
  5122. sprite.setParent(null);
  5123. Ext.Array.remove(me.sprites, sprite);
  5124. me.dirtyZIndex = true;
  5125. me.setDirty(true);
  5126. }
  5127. return sprite || null;
  5128. }, addAll:function(sprites) {
  5129. var i = 0;
  5130. if (sprites.isSprite || sprites.type) {
  5131. this.add(sprites);
  5132. } else {
  5133. if (Ext.isArray(sprites)) {
  5134. while (i < sprites.length) {
  5135. this.add(sprites[i++]);
  5136. }
  5137. }
  5138. }
  5139. }, updatePlainBBox:function(plain) {
  5140. var me = this, left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity, sprite, bbox, i, ln;
  5141. for (i = 0, ln = me.sprites.length; i < ln; i++) {
  5142. sprite = me.sprites[i];
  5143. sprite.applyTransformations();
  5144. bbox = sprite.getBBox();
  5145. if (left > bbox.x) {
  5146. left = bbox.x;
  5147. }
  5148. if (right < bbox.x + bbox.width) {
  5149. right = bbox.x + bbox.width;
  5150. }
  5151. if (top > bbox.y) {
  5152. top = bbox.y;
  5153. }
  5154. if (bottom < bbox.y + bbox.height) {
  5155. bottom = bbox.y + bbox.height;
  5156. }
  5157. }
  5158. plain.x = left;
  5159. plain.y = top;
  5160. plain.width = right - left;
  5161. plain.height = bottom - top;
  5162. }, isVisible:function() {
  5163. var attr = this.attr, parent = this.getParent(), hasParent = parent && (parent.isSurface || parent.isVisible()), isSeen = hasParent && !attr.hidden && attr.globalAlpha;
  5164. return !!isSeen;
  5165. }, render:function(surface, ctx, rect) {
  5166. var me = this, attr = me.attr, mat = me.attr.matrix, sprites = me.sprites, ln = sprites.length, i = 0;
  5167. mat.toContext(ctx);
  5168. for (; i < ln; i++) {
  5169. surface.renderSprite(sprites[i], rect);
  5170. }
  5171. var debug = attr.debug || me.statics().debug || Ext.draw.sprite.Sprite.debug;
  5172. if (debug) {
  5173. attr.inverseMatrix.toContext(ctx);
  5174. if (debug.bbox) {
  5175. me.renderBBox(surface, ctx);
  5176. }
  5177. }
  5178. }, destroy:function() {
  5179. var me = this, sprites = me.sprites, ln = sprites.length, i;
  5180. for (i = 0; i < ln; i++) {
  5181. sprites[i].destroy();
  5182. }
  5183. sprites.length = 0;
  5184. me.callParent();
  5185. }});
  5186. Ext.define('Ext.draw.sprite.Cross', {extend:'Ext.draw.sprite.Path', alias:'sprite.cross', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'path'}}}, updatePath:function(path, attr) {
  5187. var s = attr.size / 1.7, x = attr.x - attr.lineWidth / 2, y = attr.y;
  5188. path.fromSvgString('M'.concat(x - s, ',', y, 'l', [-s, -s, s, -s, s, s, s, -s, s, s, -s, s, s, s, -s, s, -s, -s, -s, s, -s, -s, 'z']));
  5189. }});
  5190. Ext.define('Ext.draw.sprite.Diamond', {extend:'Ext.draw.sprite.Path', alias:'sprite.diamond', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'path'}}}, updatePath:function(path, attr) {
  5191. var s = attr.size * 1.25, x = attr.x - attr.lineWidth / 2, y = attr.y;
  5192. path.fromSvgString(['M', x, y - s, 'l', s, s, -s, s, -s, -s, s, -s, 'z']);
  5193. }});
  5194. Ext.define('Ext.draw.sprite.Ellipse', {extend:'Ext.draw.sprite.Path', alias:'sprite.ellipse', type:'ellipse', inheritableStatics:{def:{processors:{cx:'number', cy:'number', rx:'number', ry:'number', axisRotation:'number'}, aliases:{radius:'r', x:'cx', y:'cy', centerX:'cx', centerY:'cy', radiusX:'rx', radiusY:'ry'}, defaults:{cx:0, cy:0, rx:1, ry:1, axisRotation:0}, triggers:{cx:'path', cy:'path', rx:'path', ry:'path', axisRotation:'path'}}}, updatePlainBBox:function(plain) {
  5195. var attr = this.attr, cx = attr.cx, cy = attr.cy, rx = attr.rx, ry = attr.ry;
  5196. plain.x = cx - rx;
  5197. plain.y = cy - ry;
  5198. plain.width = rx + rx;
  5199. plain.height = ry + ry;
  5200. }, updateTransformedBBox:function(transform) {
  5201. var attr = this.attr, cx = attr.cx, cy = attr.cy, rx = attr.rx, ry = attr.ry, rxy = ry / rx, matrix = attr.matrix.clone(), xx, xy, yx, yy, dx, dy, w, h;
  5202. matrix.append(1, 0, 0, rxy, 0, cy * (1 - rxy));
  5203. xx = matrix.getXX();
  5204. yx = matrix.getYX();
  5205. dx = matrix.getDX();
  5206. xy = matrix.getXY();
  5207. yy = matrix.getYY();
  5208. dy = matrix.getDY();
  5209. w = Math.sqrt(xx * xx + yx * yx) * rx;
  5210. h = Math.sqrt(xy * xy + yy * yy) * rx;
  5211. transform.x = cx * xx + cy * yx + dx - w;
  5212. transform.y = cx * xy + cy * yy + dy - h;
  5213. transform.width = w + w;
  5214. transform.height = h + h;
  5215. }, updatePath:function(path, attr) {
  5216. path.ellipse(attr.cx, attr.cy, attr.rx, attr.ry, attr.axisRotation, 0, Math.PI * 2, false);
  5217. }});
  5218. Ext.define('Ext.draw.sprite.EllipticalArc', {extend:'Ext.draw.sprite.Ellipse', alias:'sprite.ellipticalArc', type:'ellipticalArc', inheritableStatics:{def:{processors:{startAngle:'number', endAngle:'number', anticlockwise:'bool'}, aliases:{from:'startAngle', to:'endAngle', start:'startAngle', end:'endAngle'}, defaults:{startAngle:0, endAngle:Math.PI * 2, anticlockwise:false}, triggers:{startAngle:'path', endAngle:'path', anticlockwise:'path'}}}, updatePath:function(path, attr) {
  5219. path.ellipse(attr.cx, attr.cy, attr.rx, attr.ry, attr.axisRotation, attr.startAngle, attr.endAngle, attr.anticlockwise);
  5220. }});
  5221. Ext.define('Ext.draw.sprite.Rect', {extend:'Ext.draw.sprite.Path', alias:'sprite.rect', type:'rect', inheritableStatics:{def:{processors:{x:'number', y:'number', width:'number', height:'number', radius:'number'}, aliases:{}, triggers:{x:'path', y:'path', width:'path', height:'path', radius:'path'}, defaults:{x:0, y:0, width:8, height:8, radius:0}}}, updatePlainBBox:function(plain) {
  5222. var attr = this.attr;
  5223. plain.x = attr.x;
  5224. plain.y = attr.y;
  5225. plain.width = attr.width;
  5226. plain.height = attr.height;
  5227. }, updateTransformedBBox:function(transform, plain) {
  5228. this.attr.matrix.transformBBox(plain, this.attr.radius, transform);
  5229. }, updatePath:function(path, attr) {
  5230. var x = attr.x, y = attr.y, width = attr.width, height = attr.height, radius = Math.min(attr.radius, Math.abs(height) * 0.5, Math.abs(width) * 0.5);
  5231. if (radius === 0) {
  5232. path.rect(x, y, width, height);
  5233. } else {
  5234. path.moveTo(x + radius, y);
  5235. path.arcTo(x + width, y, x + width, y + height, radius);
  5236. path.arcTo(x + width, y + height, x, y + height, radius);
  5237. path.arcTo(x, y + height, x, y, radius);
  5238. path.arcTo(x, y, x + radius, y, radius);
  5239. path.closePath();
  5240. }
  5241. }});
  5242. Ext.define('Ext.draw.sprite.Image', {extend:'Ext.draw.sprite.Rect', alias:'sprite.image', type:'image', statics:{imageLoaders:{}}, inheritableStatics:{def:{processors:{src:'string'}, triggers:{src:'src'}, updaters:{src:'updateSource'}, defaults:{src:'', width:null, height:null}}}, updateSurface:function(surface) {
  5243. if (surface) {
  5244. this.updateSource(this.attr);
  5245. }
  5246. }, updateSource:function(attr) {
  5247. var me = this, src = attr.src, surface = me.getSurface(), loadingStub = Ext.draw.sprite.Image.imageLoaders[src], width = attr.width, height = attr.height, imageLoader, i;
  5248. if (!surface) {
  5249. return;
  5250. }
  5251. if (!loadingStub) {
  5252. imageLoader = new Image;
  5253. loadingStub = Ext.draw.sprite.Image.imageLoaders[src] = {image:imageLoader, done:false, pendingSprites:[me], pendingSurfaces:[surface]};
  5254. imageLoader.width = width;
  5255. imageLoader.height = height;
  5256. imageLoader.onload = function() {
  5257. var item;
  5258. if (!loadingStub.done) {
  5259. loadingStub.done = true;
  5260. for (i = 0; i < loadingStub.pendingSprites.length; i++) {
  5261. item = loadingStub.pendingSprites[i];
  5262. if (!item.destroyed) {
  5263. item.setDirty(true);
  5264. }
  5265. }
  5266. for (i = 0; i < loadingStub.pendingSurfaces.length; i++) {
  5267. item = loadingStub.pendingSurfaces[i];
  5268. if (!item.destroyed) {
  5269. item.renderFrame();
  5270. }
  5271. }
  5272. }
  5273. };
  5274. imageLoader.src = src;
  5275. } else {
  5276. Ext.Array.include(loadingStub.pendingSprites, me);
  5277. Ext.Array.include(loadingStub.pendingSurfaces, surface);
  5278. }
  5279. }, render:function(surface, ctx) {
  5280. var me = this, attr = me.attr, mat = attr.matrix, src = attr.src, x = attr.x, y = attr.y, width = attr.width, height = attr.height, loadingStub = Ext.draw.sprite.Image.imageLoaders[src], image;
  5281. if (loadingStub && loadingStub.done) {
  5282. mat.toContext(ctx);
  5283. image = loadingStub.image;
  5284. ctx.drawImage(image, x, y, width || (image.naturalWidth || image.width) / surface.devicePixelRatio, height || (image.naturalHeight || image.height) / surface.devicePixelRatio);
  5285. }
  5286. var debug = attr.debug || this.statics().debug || Ext.draw.sprite.Sprite.debug;
  5287. if (debug && debug.bbox) {
  5288. this.renderBBox(surface, ctx);
  5289. }
  5290. }, isVisible:function() {
  5291. var attr = this.attr, parent = this.getParent(), hasParent = parent && (parent.isSurface || parent.isVisible()), isSeen = hasParent && !attr.hidden && attr.globalAlpha;
  5292. return !!isSeen;
  5293. }});
  5294. Ext.define('Ext.draw.sprite.Instancing', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.instancing', type:'instancing', isInstancing:true, config:{template:null, instances:null}, instances:null, applyTemplate:function(template) {
  5295. var surface;
  5296. if (!Ext.isObject(template)) {
  5297. Ext.raise('A template of an instancing sprite must either be ' + 'a sprite instance or a valid config object from which a template ' + 'sprite will be created.');
  5298. } else {
  5299. if (template.isInstancing || template.isComposite) {
  5300. Ext.raise("Can't use an instancing or composite sprite " + 'as a template for an instancing sprite.');
  5301. }
  5302. }
  5303. if (!template.isSprite) {
  5304. if (!template.xclass && !template.type) {
  5305. template.type = 'circle';
  5306. }
  5307. template = Ext.create(template.xclass || 'sprite.' + template.type, template);
  5308. }
  5309. surface = template.getSurface();
  5310. if (surface) {
  5311. surface.remove(template);
  5312. }
  5313. template.setParent(this);
  5314. return template;
  5315. }, updateTemplate:function(template, oldTemplate) {
  5316. if (oldTemplate) {
  5317. delete oldTemplate.ownAttr;
  5318. }
  5319. template.setSurface(this.getSurface());
  5320. template.ownAttr = template.attr;
  5321. this.clearAll();
  5322. this.setDirty(true);
  5323. }, updateInstances:function(instances) {
  5324. var i, ln;
  5325. this.clearAll();
  5326. if (Ext.isArray(instances)) {
  5327. for (i = 0, ln = instances.length; i < ln; i++) {
  5328. this.add(instances[i]);
  5329. }
  5330. }
  5331. }, updateSurface:function(surface) {
  5332. var template = this.getTemplate();
  5333. if (template && !template.destroyed) {
  5334. template.setSurface(surface);
  5335. }
  5336. }, get:function(index) {
  5337. return this.instances[index];
  5338. }, getCount:function() {
  5339. return this.instances.length;
  5340. }, clearAll:function() {
  5341. var template = this.getTemplate();
  5342. template.attr.children = this.instances = [];
  5343. this.position = 0;
  5344. }, createInstance:function(config, bypassNormalization, avoidCopy) {
  5345. return this.add(config, bypassNormalization, avoidCopy);
  5346. }, add:function(config, bypassNormalization, avoidCopy) {
  5347. var me = this, template = me.getTemplate(), originalAttr = template.attr, attr = Ext.Object.chain(originalAttr);
  5348. template.modifiers.target.prepareAttributes(attr);
  5349. template.attr = attr;
  5350. template.setAttributes(config, bypassNormalization, avoidCopy);
  5351. attr.template = template;
  5352. me.instances.push(attr);
  5353. template.attr = originalAttr;
  5354. me.position++;
  5355. return attr;
  5356. }, getBBox:function() {
  5357. return null;
  5358. }, getBBoxFor:function(index, isWithoutTransform) {
  5359. var template = this.getTemplate(), originalAttr = template.attr, bbox;
  5360. template.attr = this.instances[index];
  5361. bbox = template.getBBox(isWithoutTransform);
  5362. template.attr = originalAttr;
  5363. return bbox;
  5364. }, isVisible:function() {
  5365. var attr = this.attr, parent = this.getParent(), result;
  5366. result = parent && parent.isSurface && !attr.hidden && attr.globalAlpha;
  5367. return !!result;
  5368. }, isInstanceVisible:function(index) {
  5369. var me = this, template = me.getTemplate(), originalAttr = template.attr, instances = me.instances, result = false;
  5370. if (!Ext.isNumber(index) || index < 0 || index >= instances.length || !me.isVisible()) {
  5371. return result;
  5372. }
  5373. template.attr = instances[index];
  5374. result = template.isVisible(point, options);
  5375. template.attr = originalAttr;
  5376. return result;
  5377. }, render:function(surface, ctx, rect) {
  5378. if (!this.getTemplate()) {
  5379. Ext.raise('An instancing sprite must have a template.');
  5380. }
  5381. var me = this, template = me.getTemplate(), surfaceRect = surface.getRect(), mat = me.attr.matrix, originalAttr = template.attr, instances = me.instances, ln = me.position, i;
  5382. mat.toContext(ctx);
  5383. template.preRender(surface, ctx, rect);
  5384. template.useAttributes(ctx, surfaceRect);
  5385. template.isSpriteInstance = true;
  5386. for (i = 0; i < ln; i++) {
  5387. if (instances[i].hidden) {
  5388. continue;
  5389. }
  5390. ctx.save();
  5391. template.attr = instances[i];
  5392. template.useAttributes(ctx, surfaceRect);
  5393. template.render(surface, ctx, rect);
  5394. ctx.restore();
  5395. }
  5396. template.isSpriteInstance = false;
  5397. template.attr = originalAttr;
  5398. }, setAttributesFor:function(index, changes, bypassNormalization) {
  5399. var template = this.getTemplate(), originalAttr = template.attr, attr = this.instances[index];
  5400. if (!attr) {
  5401. return;
  5402. }
  5403. template.attr = attr;
  5404. if (bypassNormalization) {
  5405. changes = Ext.apply({}, changes);
  5406. } else {
  5407. changes = template.self.def.normalize(changes);
  5408. }
  5409. template.modifiers.target.pushDown(attr, changes);
  5410. template.attr = originalAttr;
  5411. }, destroy:function() {
  5412. var me = this, template = me.getTemplate();
  5413. me.instances = null;
  5414. if (template) {
  5415. template.destroy();
  5416. }
  5417. me.callParent();
  5418. }});
  5419. Ext.define('Ext.draw.overrides.hittest.sprite.Instancing', {override:'Ext.draw.sprite.Instancing', hitTest:function(point, options) {
  5420. var me = this, template = me.getTemplate(), originalAttr = template.attr, instances = me.instances, ln = instances.length, i = 0, result = null;
  5421. if (!me.isVisible()) {
  5422. return result;
  5423. }
  5424. for (; i < ln; i++) {
  5425. template.attr = instances[i];
  5426. result = template.hitTest(point, options);
  5427. if (result) {
  5428. result.isInstance = true;
  5429. result.template = result.sprite;
  5430. result.sprite = this;
  5431. result.instance = instances[i];
  5432. result.index = i;
  5433. return result;
  5434. }
  5435. }
  5436. template.attr = originalAttr;
  5437. return result;
  5438. }});
  5439. Ext.define('Ext.draw.sprite.Line', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.line', type:'line', inheritableStatics:{def:{processors:{fromX:'number', fromY:'number', toX:'number', toY:'number', crisp:'bool'}, defaults:{fromX:0, fromY:0, toX:1, toY:1, crisp:false, strokeStyle:'black'}, aliases:{x1:'fromX', y1:'fromY', x2:'toX', y2:'toY'}, triggers:{crisp:'bbox'}}}, updateLineBBox:function(bbox, isTransform, x1, y1, x2, y2) {
  5440. var attr = this.attr, matrix = attr.matrix, halfLineWidth = attr.lineWidth / 2, fromX, fromY, toX, toY, p, angle, sin, cos, dx, dy;
  5441. if (attr.crisp) {
  5442. x1 = this.align(x1);
  5443. x2 = this.align(x2);
  5444. y1 = this.align(y1);
  5445. y2 = this.align(y2);
  5446. }
  5447. if (isTransform) {
  5448. p = matrix.transformPoint([x1, y1]);
  5449. x1 = p[0];
  5450. y1 = p[1];
  5451. p = matrix.transformPoint([x2, y2]);
  5452. x2 = p[0];
  5453. y2 = p[1];
  5454. }
  5455. fromX = Math.min(x1, x2);
  5456. toX = Math.max(x1, x2);
  5457. fromY = Math.min(y1, y2);
  5458. toY = Math.max(y1, y2);
  5459. angle = Math.atan2(toX - fromX, toY - fromY);
  5460. sin = Math.sin(angle);
  5461. cos = Math.cos(angle);
  5462. dx = halfLineWidth * cos;
  5463. dy = halfLineWidth * sin;
  5464. fromX -= dx;
  5465. fromY -= dy;
  5466. toX += dx;
  5467. toY += dy;
  5468. bbox.x = fromX;
  5469. bbox.y = fromY;
  5470. bbox.width = toX - fromX;
  5471. bbox.height = toY - fromY;
  5472. }, updatePlainBBox:function(plain) {
  5473. var attr = this.attr;
  5474. this.updateLineBBox(plain, false, attr.fromX, attr.fromY, attr.toX, attr.toY);
  5475. }, updateTransformedBBox:function(transform, plain) {
  5476. var attr = this.attr;
  5477. this.updateLineBBox(transform, true, attr.fromX, attr.fromY, attr.toX, attr.toY);
  5478. }, align:function(x) {
  5479. return Math.round(x) - 0.5;
  5480. }, render:function(surface, ctx) {
  5481. var me = this, attr = me.attr, matrix = attr.matrix;
  5482. matrix.toContext(ctx);
  5483. ctx.beginPath();
  5484. if (attr.crisp) {
  5485. ctx.moveTo(me.align(attr.fromX), me.align(attr.fromY));
  5486. ctx.lineTo(me.align(attr.toX), me.align(attr.toY));
  5487. } else {
  5488. ctx.moveTo(attr.fromX, attr.fromY);
  5489. ctx.lineTo(attr.toX, attr.toY);
  5490. }
  5491. ctx.stroke();
  5492. var debug = attr.debug || this.statics().debug || Ext.draw.sprite.Sprite.debug;
  5493. if (debug) {
  5494. this.attr.inverseMatrix.toContext(ctx);
  5495. if (debug.bbox) {
  5496. this.renderBBox(surface, ctx);
  5497. }
  5498. }
  5499. }});
  5500. Ext.define('Ext.draw.sprite.Plus', {extend:'Ext.draw.sprite.Path', alias:'sprite.plus', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'path'}}}, updatePath:function(path, attr) {
  5501. var s = attr.size / 1.3, x = attr.x - attr.lineWidth / 2, y = attr.y;
  5502. path.fromSvgString('M'.concat(x - s / 2, ',', y - s / 2, 'l', [0, -s, s, 0, 0, s, s, 0, 0, s, -s, 0, 0, s, -s, 0, 0, -s, -s, 0, 0, -s, 'z']));
  5503. }});
  5504. Ext.define('Ext.draw.sprite.Sector', {extend:'Ext.draw.sprite.Path', alias:'sprite.sector', type:'sector', inheritableStatics:{def:{processors:{centerX:'number', centerY:'number', startAngle:'number', endAngle:'number', startRho:'number', endRho:'number', margin:'number'}, aliases:{rho:'endRho'}, triggers:{centerX:'path,bbox', centerY:'path,bbox', startAngle:'path,bbox', endAngle:'path,bbox', startRho:'path,bbox', endRho:'path,bbox', margin:'path,bbox'}, defaults:{centerX:0, centerY:0, startAngle:0,
  5505. endAngle:0, startRho:0, endRho:150, margin:0, path:'M 0,0'}}}, getMidAngle:function() {
  5506. return this.midAngle || 0;
  5507. }, updatePath:function(path, attr) {
  5508. var startAngle = Math.min(attr.startAngle, attr.endAngle), endAngle = Math.max(attr.startAngle, attr.endAngle), midAngle = this.midAngle = (startAngle + endAngle) * 0.5, fullPie = Ext.Number.isEqual(Math.abs(endAngle - startAngle), Ext.draw.Draw.pi2, 1.0E-10), margin = attr.margin, centerX = attr.centerX, centerY = attr.centerY, startRho = Math.min(attr.startRho, attr.endRho), endRho = Math.max(attr.startRho, attr.endRho);
  5509. if (margin) {
  5510. centerX += margin * Math.cos(midAngle);
  5511. centerY += margin * Math.sin(midAngle);
  5512. }
  5513. if (!fullPie) {
  5514. path.moveTo(centerX + startRho * Math.cos(startAngle), centerY + startRho * Math.sin(startAngle));
  5515. path.lineTo(centerX + endRho * Math.cos(startAngle), centerY + endRho * Math.sin(startAngle));
  5516. }
  5517. path.arc(centerX, centerY, endRho, startAngle, endAngle, false);
  5518. path[fullPie ? 'moveTo' : 'lineTo'](centerX + startRho * Math.cos(endAngle), centerY + startRho * Math.sin(endAngle));
  5519. path.arc(centerX, centerY, startRho, endAngle, startAngle, true);
  5520. }});
  5521. Ext.define('Ext.draw.sprite.Square', {extend:'Ext.draw.sprite.Path', alias:'sprite.square', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'size'}}}, updatePath:function(path, attr) {
  5522. var size = attr.size * 1.2, s = size * 2, x = attr.x - attr.lineWidth / 2, y = attr.y;
  5523. path.fromSvgString('M'.concat(x - size, ',', y - size, 'l', [s, 0, 0, s, -s, 0, 0, -s, 'z']));
  5524. }});
  5525. Ext.define('Ext.draw.TextMeasurer', {singleton:true, requires:['Ext.util.TextMetrics'], measureDiv:null, measureCache:{}, precise:Ext.isIE8, measureDivTpl:{id:'ext-draw-text-measurer', tag:'div', style:{overflow:'hidden', position:'relative', 'float':'left', width:0, height:0}, 'data-sticky':true, children:{tag:'div', style:{display:'block', position:'absolute', x:-100000, y:-100000, padding:0, margin:0, 'z-index':-100000, 'white-space':'nowrap'}}}, actualMeasureText:function(text, font) {
  5526. var me = Ext.draw.TextMeasurer, measureDiv = me.measureDiv, FARAWAY = 100000, size, parent;
  5527. if (!measureDiv) {
  5528. parent = Ext.Element.create({'data-sticky':true, style:{'overflow':'hidden', 'position':'relative', 'float':'left', 'width':0, 'height':0}});
  5529. me.measureDiv = measureDiv = Ext.Element.create({style:{'position':'absolute', 'x':FARAWAY, 'y':FARAWAY, 'z-index':-FARAWAY, 'white-space':'nowrap', 'display':'block', 'padding':0, 'margin':0}});
  5530. Ext.getBody().appendChild(parent);
  5531. parent.appendChild(measureDiv);
  5532. }
  5533. if (font) {
  5534. measureDiv.setStyle({font:font, lineHeight:'normal'});
  5535. }
  5536. measureDiv.setText('(' + text + ')');
  5537. size = measureDiv.getSize();
  5538. measureDiv.setText('()');
  5539. size.width -= measureDiv.getSize().width;
  5540. return size;
  5541. }, measureTextSingleLine:function(text, font) {
  5542. var width = 0, height = 0, cache, cachedItem, chars, charactor, i, ln, size;
  5543. if (this.precise) {
  5544. return this.preciseMeasureTextSingleLine(text, font);
  5545. }
  5546. text = text.toString();
  5547. cache = this.measureCache;
  5548. chars = text.split('');
  5549. if (!cache[font]) {
  5550. cache[font] = {};
  5551. }
  5552. cache = cache[font];
  5553. if (cache[text]) {
  5554. return cache[text];
  5555. }
  5556. for (i = 0, ln = chars.length; i < ln; i++) {
  5557. charactor = chars[i];
  5558. if (!(cachedItem = cache[charactor])) {
  5559. size = this.actualMeasureText(charactor, font);
  5560. cachedItem = cache[charactor] = size;
  5561. }
  5562. width += cachedItem.width;
  5563. height = Math.max(height, cachedItem.height);
  5564. }
  5565. return cache[text] = {width:width, height:height};
  5566. }, preciseMeasureTextSingleLine:function(text, font) {
  5567. var measureDiv;
  5568. text = text.toString();
  5569. measureDiv = this.measureDiv || (this.measureDiv = Ext.getBody().createChild(this.measureDivTpl).down('div'));
  5570. measureDiv.setStyle({font:font || ''});
  5571. return Ext.util.TextMetrics.measure(measureDiv, text);
  5572. }, measureText:function(text, font) {
  5573. var lines = text.split('\n'), ln = lines.length, height = 0, width = 0, line, i, sizes;
  5574. if (ln === 1) {
  5575. return this.measureTextSingleLine(text, font);
  5576. }
  5577. sizes = [];
  5578. for (i = 0; i < ln; i++) {
  5579. line = this.measureTextSingleLine(lines[i], font);
  5580. sizes.push(line);
  5581. height += line.height;
  5582. width = Math.max(width, line.width);
  5583. }
  5584. return {width:width, height:height, sizes:sizes};
  5585. }});
  5586. Ext.define('Ext.draw.sprite.Text', function() {
  5587. var fontSizes = {'xx-small':true, 'x-small':true, 'small':true, 'medium':true, 'large':true, 'x-large':true, 'xx-large':true}, fontWeights = {normal:true, bold:true, bolder:true, lighter:true, 100:true, 200:true, 300:true, 400:true, 500:true, 600:true, 700:true, 800:true, 900:true}, textAlignments = {start:'start', left:'start', center:'center', middle:'center', end:'end', right:'end'}, textBaselines = {top:'top', hanging:'hanging', middle:'middle', center:'middle', alphabetic:'alphabetic', ideographic:'ideographic',
  5588. bottom:'bottom'};
  5589. return {extend:'Ext.draw.sprite.Sprite', requires:['Ext.draw.TextMeasurer', 'Ext.draw.Color'], alias:'sprite.text', type:'text', lineBreakRe:/\r?\n/g, statics:{debug:false, fontSizes:fontSizes, fontWeights:fontWeights, textAlignments:textAlignments, textBaselines:textBaselines}, inheritableStatics:{def:{animationProcessors:{text:'text'}, processors:{x:'number', y:'number', text:'string', fontSize:function(n) {
  5590. if (Ext.isNumber(+n)) {
  5591. return n + 'px';
  5592. } else {
  5593. if (n.match(Ext.dom.Element.unitRe)) {
  5594. return n;
  5595. } else {
  5596. if (n in fontSizes) {
  5597. return n;
  5598. }
  5599. }
  5600. }
  5601. }, fontStyle:'enums(,italic,oblique)', fontVariant:'enums(,small-caps)', fontWeight:function(n) {
  5602. if (n in fontWeights) {
  5603. return String(n);
  5604. } else {
  5605. return '';
  5606. }
  5607. }, fontFamily:'string', textAlign:function(n) {
  5608. return textAlignments[n] || 'center';
  5609. }, textBaseline:function(n) {
  5610. return textBaselines[n] || 'alphabetic';
  5611. }, debug:'default', font:'string'}, aliases:{'font-size':'fontSize', 'font-family':'fontFamily', 'font-weight':'fontWeight', 'font-variant':'fontVariant', 'text-anchor':'textAlign', 'dominant-baseline':'textBaseline'}, defaults:{fontStyle:'', fontVariant:'', fontWeight:'', fontSize:'10px', fontFamily:'sans-serif', font:'10px sans-serif', textBaseline:'alphabetic', textAlign:'start', strokeStyle:'rgba(0, 0, 0, 0)', fillStyle:'#000', x:0, y:0, text:''}, triggers:{fontStyle:'fontX,bbox', fontVariant:'fontX,bbox',
  5612. fontWeight:'fontX,bbox', fontSize:'fontX,bbox', fontFamily:'fontX,bbox', font:'font,bbox,canvas', textBaseline:'bbox', textAlign:'bbox', x:'bbox', y:'bbox', text:'bbox'}, updaters:{fontX:'makeFontShorthand', font:'parseFontShorthand'}}}, config:{preciseMeasurement:undefined}, constructor:function(config) {
  5613. var key;
  5614. if (config && config.font) {
  5615. config = Ext.clone(config);
  5616. for (key in config) {
  5617. if (key !== 'font' && key.indexOf('font') === 0) {
  5618. delete config[key];
  5619. }
  5620. }
  5621. }
  5622. Ext.draw.sprite.Sprite.prototype.constructor.call(this, config);
  5623. }, fontValuesMap:{'italic':'fontStyle', 'oblique':'fontStyle', 'small-caps':'fontVariant', 'bold':'fontWeight', 'bolder':'fontWeight', 'lighter':'fontWeight', 100:'fontWeight', 200:'fontWeight', 300:'fontWeight', 400:'fontWeight', 500:'fontWeight', 600:'fontWeight', 700:'fontWeight', 800:'fontWeight', 900:'fontWeight', 'xx-small':'fontSize', 'x-small':'fontSize', 'small':'fontSize', 'medium':'fontSize', 'large':'fontSize', 'x-large':'fontSize', 'xx-large':'fontSize'}, makeFontShorthand:function(attr) {
  5624. var parts = [];
  5625. if (attr.fontStyle) {
  5626. parts.push(attr.fontStyle);
  5627. }
  5628. if (attr.fontVariant) {
  5629. parts.push(attr.fontVariant);
  5630. }
  5631. if (attr.fontWeight) {
  5632. parts.push(attr.fontWeight);
  5633. }
  5634. if (attr.fontSize) {
  5635. parts.push(attr.fontSize);
  5636. }
  5637. if (attr.fontFamily) {
  5638. parts.push(attr.fontFamily);
  5639. }
  5640. this.setAttributes({font:parts.join(' ')}, true);
  5641. }, parseFontShorthand:function(attr) {
  5642. var value = attr.font, ln = value.length, changes = {}, dispatcher = this.fontValuesMap, start = 0, end, slashIndex, part, fontProperty;
  5643. while (start < ln && end !== -1) {
  5644. end = value.indexOf(' ', start);
  5645. if (end < 0) {
  5646. part = value.substr(start);
  5647. } else {
  5648. if (end > start) {
  5649. part = value.substr(start, end - start);
  5650. } else {
  5651. continue;
  5652. }
  5653. }
  5654. slashIndex = part.indexOf('/');
  5655. if (slashIndex > 0) {
  5656. part = part.substr(0, slashIndex);
  5657. } else {
  5658. if (slashIndex === 0) {
  5659. continue;
  5660. }
  5661. }
  5662. if (part !== 'normal' && part !== 'inherit') {
  5663. fontProperty = dispatcher[part];
  5664. if (fontProperty) {
  5665. changes[fontProperty] = part;
  5666. } else {
  5667. if (part.match(Ext.dom.Element.unitRe)) {
  5668. changes.fontSize = part;
  5669. } else {
  5670. changes.fontFamily = value.substr(start);
  5671. break;
  5672. }
  5673. }
  5674. }
  5675. start = end + 1;
  5676. }
  5677. if (!changes.fontStyle) {
  5678. changes.fontStyle = '';
  5679. }
  5680. if (!changes.fontVariant) {
  5681. changes.fontVariant = '';
  5682. }
  5683. if (!changes.fontWeight) {
  5684. changes.fontWeight = '';
  5685. }
  5686. this.setAttributes(changes, true);
  5687. }, fontProperties:{fontStyle:true, fontVariant:true, fontWeight:true, fontSize:true, fontFamily:true}, setAttributes:function(changes, bypassNormalization, avoidCopy) {
  5688. var key, obj;
  5689. if (changes && changes.font) {
  5690. obj = {};
  5691. for (key in changes) {
  5692. if (!(key in this.fontProperties)) {
  5693. obj[key] = changes[key];
  5694. }
  5695. }
  5696. changes = obj;
  5697. }
  5698. this.callParent([changes, bypassNormalization, avoidCopy]);
  5699. }, getBBox:function(isWithoutTransform) {
  5700. var me = this, plain = me.attr.bbox.plain, surface = me.getSurface();
  5701. if (plain.dirty) {
  5702. me.updatePlainBBox(plain);
  5703. plain.dirty = false;
  5704. }
  5705. if (surface && surface.getInherited().rtl && surface.getFlipRtlText()) {
  5706. me.updatePlainBBox(plain, true);
  5707. }
  5708. return me.callParent([isWithoutTransform]);
  5709. }, rtlAlignments:{start:'end', center:'center', end:'start'}, updatePlainBBox:function(plain, useOldSize) {
  5710. var me = this, attr = me.attr, x = attr.x, y = attr.y, dx = [], font = attr.font, text = attr.text, baseline = attr.textBaseline, alignment = attr.textAlign, precise = me.getPreciseMeasurement(), size, textMeasurerPrecision;
  5711. if (useOldSize && me.oldSize) {
  5712. size = me.oldSize;
  5713. } else {
  5714. textMeasurerPrecision = Ext.draw.TextMeasurer.precise;
  5715. if (Ext.isBoolean(precise)) {
  5716. Ext.draw.TextMeasurer.precise = precise;
  5717. }
  5718. size = me.oldSize = Ext.draw.TextMeasurer.measureText(text, font);
  5719. Ext.draw.TextMeasurer.precise = textMeasurerPrecision;
  5720. }
  5721. var surface = me.getSurface(), isRtl = surface && surface.getInherited().rtl || false, flipRtlText = isRtl && surface.getFlipRtlText(), sizes = size.sizes, blockHeight = size.height, blockWidth = size.width, ln = sizes ? sizes.length : 0, lineWidth, rect, i = 0;
  5722. switch(baseline) {
  5723. case 'hanging':
  5724. case 'top':
  5725. break;
  5726. case 'ideographic':
  5727. case 'bottom':
  5728. y -= blockHeight;
  5729. break;
  5730. case 'alphabetic':
  5731. y -= blockHeight * 0.8;
  5732. break;
  5733. case 'middle':
  5734. y -= blockHeight * 0.5;
  5735. break;
  5736. }
  5737. if (flipRtlText) {
  5738. rect = surface.getRect();
  5739. x = rect[2] - rect[0] - x;
  5740. alignment = me.rtlAlignments[alignment];
  5741. }
  5742. switch(alignment) {
  5743. case 'start':
  5744. if (isRtl) {
  5745. for (; i < ln; i++) {
  5746. lineWidth = sizes[i].width;
  5747. dx.push(-(blockWidth - lineWidth));
  5748. }
  5749. }
  5750. break;
  5751. case 'end':
  5752. x -= blockWidth;
  5753. if (isRtl) {
  5754. break;
  5755. }
  5756. for (; i < ln; i++) {
  5757. lineWidth = sizes[i].width;
  5758. dx.push(blockWidth - lineWidth);
  5759. }
  5760. break;
  5761. case 'center':
  5762. x -= blockWidth * 0.5;
  5763. for (; i < ln; i++) {
  5764. lineWidth = sizes[i].width;
  5765. dx.push((isRtl ? -1 : 1) * (blockWidth - lineWidth) * 0.5);
  5766. }
  5767. break;
  5768. }
  5769. attr.textAlignOffsets = dx;
  5770. plain.x = x;
  5771. plain.y = y;
  5772. plain.width = blockWidth;
  5773. plain.height = blockHeight;
  5774. }, setText:function(text) {
  5775. this.setAttributes({text:text}, true);
  5776. }, render:function(surface, ctx, rect) {
  5777. var me = this, attr = me.attr, mat = Ext.draw.Matrix.fly(attr.matrix.elements.slice(0)), bbox = me.getBBox(true), dx = attr.textAlignOffsets, none = Ext.util.Color.RGBA_NONE, x, y, i, lines, lineHeight;
  5778. if (attr.text.length === 0) {
  5779. return;
  5780. }
  5781. lines = attr.text.split(me.lineBreakRe);
  5782. lineHeight = bbox.height / lines.length;
  5783. x = attr.bbox.plain.x;
  5784. y = attr.bbox.plain.y + lineHeight * 0.78;
  5785. mat.toContext(ctx);
  5786. if (surface.getInherited().rtl) {
  5787. x += attr.bbox.plain.width;
  5788. }
  5789. for (i = 0; i < lines.length; i++) {
  5790. if (ctx.fillStyle !== none) {
  5791. ctx.fillText(lines[i], x + (dx[i] || 0), y + lineHeight * i);
  5792. }
  5793. if (ctx.strokeStyle !== none) {
  5794. ctx.strokeText(lines[i], x + (dx[i] || 0), y + lineHeight * i);
  5795. }
  5796. }
  5797. var debug = attr.debug || this.statics().debug || Ext.draw.sprite.Sprite.debug;
  5798. if (debug) {
  5799. this.attr.inverseMatrix.toContext(ctx);
  5800. if (debug.bbox) {
  5801. me.renderBBox(surface, ctx);
  5802. }
  5803. }
  5804. }};
  5805. });
  5806. Ext.define('Ext.draw.sprite.Tick', {extend:'Ext.draw.sprite.Line', alias:'sprite.tick', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'tick', y:'tick', size:'tick'}, updaters:{tick:function(attr) {
  5807. var size = attr.size * 1.5, halfLineWidth = attr.lineWidth / 2, x = attr.x, y = attr.y;
  5808. this.setAttributes({fromX:x - halfLineWidth, fromY:y - size, toX:x - halfLineWidth, toY:y + size});
  5809. }}}}});
  5810. Ext.define('Ext.draw.sprite.Triangle', {extend:'Ext.draw.sprite.Path', alias:'sprite.triangle', inheritableStatics:{def:{processors:{x:'number', y:'number', size:'number'}, defaults:{x:0, y:0, size:4}, triggers:{x:'path', y:'path', size:'path'}}}, updatePath:function(path, attr) {
  5811. var s = attr.size * 2.2, x = attr.x, y = attr.y;
  5812. path.fromSvgString('M'.concat(x, ',', y, 'm0-', s * 0.48, 'l', s * 0.5, ',', s * 0.87, '-', s, ',0z'));
  5813. }});
  5814. Ext.define('Ext.draw.gradient.Linear', {extend:'Ext.draw.gradient.Gradient', requires:['Ext.draw.Color'], type:'linear', config:{degrees:0, radians:0}, applyRadians:function(radians, oldRadians) {
  5815. if (Ext.isNumber(radians)) {
  5816. return radians;
  5817. }
  5818. return oldRadians;
  5819. }, applyDegrees:function(degrees, oldDegrees) {
  5820. if (Ext.isNumber(degrees)) {
  5821. return degrees;
  5822. }
  5823. return oldDegrees;
  5824. }, updateRadians:function(radians) {
  5825. this.setDegrees(Ext.draw.Draw.degrees(radians));
  5826. }, updateDegrees:function(degrees) {
  5827. this.setRadians(Ext.draw.Draw.rad(degrees));
  5828. }, generateGradient:function(ctx, bbox) {
  5829. var angle = this.getRadians(), cos = Math.cos(angle), sin = Math.sin(angle), w = bbox.width, h = bbox.height, cx = bbox.x + w * 0.5, cy = bbox.y + h * 0.5, stops = this.getStops(), ln = stops.length, gradient, l, i;
  5830. if (Ext.isNumber(cx) && Ext.isNumber(cy) && h > 0 && w > 0) {
  5831. l = Math.sqrt(h * h + w * w) * Math.abs(Math.cos(angle - Math.atan(h / w))) / 2;
  5832. gradient = ctx.createLinearGradient(cx + cos * l, cy + sin * l, cx - cos * l, cy - sin * l);
  5833. for (i = 0; i < ln; i++) {
  5834. gradient.addColorStop(stops[i].offset, stops[i].color);
  5835. }
  5836. return gradient;
  5837. }
  5838. return Ext.util.Color.NONE;
  5839. }});
  5840. Ext.define('Ext.draw.gradient.Radial', {extend:'Ext.draw.gradient.Gradient', type:'radial', config:{start:{x:0, y:0, r:0}, end:{x:0, y:0, r:1}}, applyStart:function(newStart, oldStart) {
  5841. var circle;
  5842. if (!oldStart) {
  5843. return newStart;
  5844. }
  5845. circle = {x:oldStart.x, y:oldStart.y, r:oldStart.r};
  5846. if ('x' in newStart) {
  5847. circle.x = newStart.x;
  5848. } else {
  5849. if ('centerX' in newStart) {
  5850. circle.x = newStart.centerX;
  5851. }
  5852. }
  5853. if ('y' in newStart) {
  5854. circle.y = newStart.y;
  5855. } else {
  5856. if ('centerY' in newStart) {
  5857. circle.y = newStart.centerY;
  5858. }
  5859. }
  5860. if ('r' in newStart) {
  5861. circle.r = newStart.r;
  5862. } else {
  5863. if ('radius' in newStart) {
  5864. circle.r = newStart.radius;
  5865. }
  5866. }
  5867. return circle;
  5868. }, applyEnd:function(newEnd, oldEnd) {
  5869. var circle;
  5870. if (!oldEnd) {
  5871. return newEnd;
  5872. }
  5873. circle = {x:oldEnd.x, y:oldEnd.y, r:oldEnd.r};
  5874. if ('x' in newEnd) {
  5875. circle.x = newEnd.x;
  5876. } else {
  5877. if ('centerX' in newEnd) {
  5878. circle.x = newEnd.centerX;
  5879. }
  5880. }
  5881. if ('y' in newEnd) {
  5882. circle.y = newEnd.y;
  5883. } else {
  5884. if ('centerY' in newEnd) {
  5885. circle.y = newEnd.centerY;
  5886. }
  5887. }
  5888. if ('r' in newEnd) {
  5889. circle.r = newEnd.r;
  5890. } else {
  5891. if ('radius' in newEnd) {
  5892. circle.r = newEnd.radius;
  5893. }
  5894. }
  5895. return circle;
  5896. }, generateGradient:function(ctx, bbox) {
  5897. var start = this.getStart(), end = this.getEnd(), w = bbox.width * 0.5, h = bbox.height * 0.5, x = bbox.x + w, y = bbox.y + h, gradient = ctx.createRadialGradient(x + start.x * w, y + start.y * h, start.r * Math.max(w, h), x + end.x * w, y + end.y * h, end.r * Math.max(w, h)), stops = this.getStops(), ln = stops.length, i;
  5898. for (i = 0; i < ln; i++) {
  5899. gradient.addColorStop(stops[i].offset, stops[i].color);
  5900. }
  5901. return gradient;
  5902. }});
  5903. Ext.define('Ext.draw.Surface', {extend:'Ext.draw.SurfaceBase', xtype:'surface', requires:['Ext.draw.sprite.*', 'Ext.draw.gradient.*', 'Ext.draw.sprite.AttributeDefinition', 'Ext.draw.Matrix', 'Ext.draw.Draw'], uses:['Ext.draw.engine.Canvas'], devicePixelRatio:window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI, deprecated:{'5.1.0':{statics:{methods:{stableSort:function(list) {
  5904. return Ext.Array.sort(list, function(a, b) {
  5905. return a.attr.zIndex - b.attr.zIndex;
  5906. });
  5907. }}}}}, cls:Ext.baseCSSPrefix + 'surface', config:{rect:null, background:null, items:[], dirty:false, flipRtlText:false}, isSurface:true, isPendingRenderFrame:false, dirtyPredecessorCount:0, emptyRect:[0, 0, 0, 0], constructor:function(config) {
  5908. var me = this;
  5909. me.predecessors = [];
  5910. me.successors = [];
  5911. me.map = {};
  5912. me.callParent([config]);
  5913. me.matrix = new Ext.draw.Matrix;
  5914. me.inverseMatrix = me.matrix.inverse();
  5915. }, roundPixel:function(num) {
  5916. return Math.round(this.devicePixelRatio * num) / this.devicePixelRatio;
  5917. }, waitFor:function(surface) {
  5918. var me = this, predecessors = me.predecessors;
  5919. if (!Ext.Array.contains(predecessors, surface)) {
  5920. predecessors.push(surface);
  5921. surface.successors.push(me);
  5922. if (surface.getDirty()) {
  5923. me.dirtyPredecessorCount++;
  5924. }
  5925. }
  5926. }, updateDirty:function(dirty) {
  5927. var successors = this.successors, ln = successors.length, i = 0, successor;
  5928. for (; i < ln; i++) {
  5929. successor = successors[i];
  5930. if (dirty) {
  5931. successor.dirtyPredecessorCount++;
  5932. successor.setDirty(true);
  5933. } else {
  5934. successor.dirtyPredecessorCount--;
  5935. if (successor.dirtyPredecessorCount === 0 && successor.isPendingRenderFrame) {
  5936. successor.renderFrame();
  5937. }
  5938. }
  5939. }
  5940. }, applyBackground:function(background, oldBackground) {
  5941. this.setDirty(true);
  5942. if (Ext.isString(background)) {
  5943. background = {fillStyle:background};
  5944. }
  5945. return Ext.factory(background, Ext.draw.sprite.Rect, oldBackground);
  5946. }, applyRect:function(rect, oldRect) {
  5947. if (oldRect && rect[0] === oldRect[0] && rect[1] === oldRect[1] && rect[2] === oldRect[2] && rect[3] === oldRect[3]) {
  5948. return oldRect;
  5949. }
  5950. if (Ext.isArray(rect)) {
  5951. return [rect[0], rect[1], rect[2], rect[3]];
  5952. } else {
  5953. if (Ext.isObject(rect)) {
  5954. return [rect.x || rect.left, rect.y || rect.top, rect.width || rect.right - rect.left, rect.height || rect.bottom - rect.top];
  5955. }
  5956. }
  5957. }, updateRect:function(rect) {
  5958. var me = this, l = rect[0], t = rect[1], r = l + rect[2], b = t + rect[3], background = me.getBackground(), element = me.element;
  5959. element.setLocalXY(Math.floor(l), Math.floor(t));
  5960. element.setSize(Math.ceil(r - Math.floor(l)), Math.ceil(b - Math.floor(t)));
  5961. if (background) {
  5962. background.setAttributes({x:0, y:0, width:Math.ceil(r - Math.floor(l)), height:Math.ceil(b - Math.floor(t))});
  5963. }
  5964. me.setDirty(true);
  5965. }, resetTransform:function() {
  5966. this.matrix.set(1, 0, 0, 1, 0, 0);
  5967. this.inverseMatrix.set(1, 0, 0, 1, 0, 0);
  5968. this.setDirty(true);
  5969. }, get:function(id) {
  5970. return this.map[id] || this.getItems()[id];
  5971. }, add:function() {
  5972. var me = this, args = Array.prototype.slice.call(arguments), argIsArray = Ext.isArray(args[0]), map = me.map, results = [], items, item, sprite, oldSurface, i, ln;
  5973. items = Ext.Array.clean(argIsArray ? args[0] : args);
  5974. if (!items.length) {
  5975. return results;
  5976. }
  5977. for (i = 0, ln = items.length; i < ln; i++) {
  5978. item = items[i];
  5979. if (!item || item.destroyed) {
  5980. continue;
  5981. }
  5982. sprite = null;
  5983. if (item.isSprite && !map[item.getId()]) {
  5984. sprite = item;
  5985. } else {
  5986. if (!map[item.id]) {
  5987. sprite = this.createItem(item);
  5988. }
  5989. }
  5990. if (sprite) {
  5991. map[sprite.getId()] = sprite;
  5992. results.push(sprite);
  5993. oldSurface = sprite.getSurface();
  5994. if (oldSurface && oldSurface.isSurface) {
  5995. oldSurface.remove(sprite);
  5996. }
  5997. sprite.setParent(me);
  5998. sprite.setSurface(me);
  5999. me.onAdd(sprite);
  6000. }
  6001. }
  6002. items = me.getItems();
  6003. if (items) {
  6004. items.push.apply(items, results);
  6005. }
  6006. me.dirtyZIndex = true;
  6007. me.setDirty(true);
  6008. if (!argIsArray && results.length === 1) {
  6009. return results[0];
  6010. } else {
  6011. return results;
  6012. }
  6013. }, onAdd:Ext.emptyFn, remove:function(sprite, isDestroy) {
  6014. var me = this, destroying = me.clearing, id, isOwnSprite;
  6015. if (sprite) {
  6016. if (sprite.charAt) {
  6017. sprite = me.map[sprite];
  6018. }
  6019. if (!sprite || !sprite.isSprite) {
  6020. return null;
  6021. }
  6022. id = sprite.id;
  6023. isOwnSprite = me.map[id];
  6024. delete me.map[id];
  6025. if (sprite.destroyed || sprite.destroying) {
  6026. if (isOwnSprite && !destroying) {
  6027. Ext.Array.remove(me.getItems(), sprite);
  6028. }
  6029. return sprite;
  6030. }
  6031. if (!isOwnSprite) {
  6032. if (isDestroy) {
  6033. sprite.destroy();
  6034. }
  6035. return sprite;
  6036. }
  6037. sprite.setParent(null);
  6038. sprite.setSurface(null);
  6039. if (isDestroy) {
  6040. sprite.destroy();
  6041. }
  6042. if (!destroying) {
  6043. Ext.Array.remove(me.getItems(), sprite);
  6044. me.dirtyZIndex = true;
  6045. me.setDirty(true);
  6046. }
  6047. }
  6048. return sprite || null;
  6049. }, removeAll:function(isDestroy) {
  6050. var me = this, items = me.getItems(), item, i;
  6051. me.clearing = !!isDestroy;
  6052. for (i = items.length - 1; i >= 0; i--) {
  6053. item = items[i];
  6054. if (isDestroy) {
  6055. item.destroy();
  6056. } else {
  6057. item.setParent(null);
  6058. item.setSurface(null);
  6059. }
  6060. }
  6061. me.clearing = false;
  6062. items.length = 0;
  6063. me.map = {};
  6064. me.dirtyZIndex = true;
  6065. if (!me.destroying) {
  6066. me.setDirty(true);
  6067. }
  6068. }, applyItems:function(items) {
  6069. if (this.getItems()) {
  6070. this.removeAll(true);
  6071. }
  6072. return Ext.Array.from(this.add(items));
  6073. }, createItem:function(config) {
  6074. return Ext.create(config.xclass || 'sprite.' + config.type, config);
  6075. }, getBBox:function(sprites, isWithoutTransform) {
  6076. var left = Infinity, right = -Infinity, top = Infinity, bottom = -Infinity, sprite, bbox, i, ln;
  6077. sprites = Ext.Array.from(sprites);
  6078. for (i = 0, ln = sprites.length; i < ln; i++) {
  6079. sprite = sprites[i];
  6080. bbox = sprite.getBBox(isWithoutTransform);
  6081. if (left > bbox.x) {
  6082. left = bbox.x;
  6083. }
  6084. if (right < bbox.x + bbox.width) {
  6085. right = bbox.x + bbox.width;
  6086. }
  6087. if (top > bbox.y) {
  6088. top = bbox.y;
  6089. }
  6090. if (bottom < bbox.y + bbox.height) {
  6091. bottom = bbox.y + bbox.height;
  6092. }
  6093. }
  6094. return {x:left, y:top, width:right - left, height:bottom - top};
  6095. }, getEventXY:function(e) {
  6096. var me = this, isRtl = me.getInherited().rtl, pageXY = e.getXY(), container = me.getOwnerBody(), xy = container.getXY(), rect = me.getRect() || me.emptyRect, result = [], width;
  6097. if (isRtl) {
  6098. width = container.getWidth();
  6099. result[0] = xy[0] - pageXY[0] - rect[0] + width;
  6100. } else {
  6101. result[0] = pageXY[0] - xy[0] - rect[0];
  6102. }
  6103. result[1] = pageXY[1] - xy[1] - rect[1];
  6104. return result;
  6105. }, clear:Ext.emptyFn, orderByZIndex:function() {
  6106. var me = this, items = me.getItems(), dirtyZIndex = false, i, ln;
  6107. if (me.getDirty()) {
  6108. for (i = 0, ln = items.length; i < ln; i++) {
  6109. if (items[i].attr.dirtyZIndex) {
  6110. dirtyZIndex = true;
  6111. break;
  6112. }
  6113. }
  6114. if (dirtyZIndex) {
  6115. Ext.Array.sort(items, function(a, b) {
  6116. return a.attr.zIndex - b.attr.zIndex;
  6117. });
  6118. this.setDirty(true);
  6119. }
  6120. for (i = 0, ln = items.length; i < ln; i++) {
  6121. items[i].attr.dirtyZIndex = false;
  6122. }
  6123. }
  6124. }, repaint:function() {
  6125. var me = this;
  6126. me.repaint = Ext.emptyFn;
  6127. Ext.defer(function() {
  6128. delete me.repaint;
  6129. me.element.repaint();
  6130. }, 1);
  6131. }, renderFrame:function() {
  6132. var me = this, background, items, item, i, ln;
  6133. if (!(me.element && me.getDirty() && me.getRect())) {
  6134. return;
  6135. }
  6136. if (me.dirtyPredecessorCount > 0) {
  6137. me.isPendingRenderFrame = true;
  6138. return;
  6139. }
  6140. background = me.getBackground();
  6141. items = me.getItems();
  6142. me.orderByZIndex();
  6143. if (me.getDirty()) {
  6144. me.clear();
  6145. me.clearTransform();
  6146. if (background) {
  6147. me.renderSprite(background);
  6148. }
  6149. for (i = 0, ln = items.length; i < ln; i++) {
  6150. item = items[i];
  6151. if (me.renderSprite(item) === false) {
  6152. return;
  6153. }
  6154. item.attr.textPositionCount = me.textPosition;
  6155. }
  6156. me.setDirty(false);
  6157. }
  6158. }, renderSprite:Ext.emptyFn, clearTransform:Ext.emptyFn, destroy:function() {
  6159. var me = this;
  6160. me.destroying = true;
  6161. me.removeAll(true);
  6162. me.destroying = false;
  6163. me.predecessors = me.successors = null;
  6164. if (me.hasListeners.destroy) {
  6165. me.fireEvent('destroy', me);
  6166. }
  6167. me.callParent();
  6168. }});
  6169. Ext.define('Ext.draw.overrides.hittest.Surface', {override:'Ext.draw.Surface', hitTest:function(point, options) {
  6170. var me = this, sprites = me.getItems(), i, sprite, result;
  6171. options = options || Ext.draw.sprite.Sprite.defaultHitTestOptions;
  6172. for (i = sprites.length - 1; i >= 0; i--) {
  6173. sprite = sprites[i];
  6174. if (sprite.hitTest) {
  6175. result = sprite.hitTest(point, options);
  6176. if (result) {
  6177. return result;
  6178. }
  6179. }
  6180. }
  6181. return null;
  6182. }, hitTestEvent:function(event, options) {
  6183. var xy = this.getEventXY(event);
  6184. return this.hitTest(xy, options);
  6185. }});
  6186. Ext.define('Ext.draw.engine.SvgContext', {requires:['Ext.draw.Color'], toSave:['strokeOpacity', 'strokeStyle', 'fillOpacity', 'fillStyle', 'globalAlpha', 'lineWidth', 'lineCap', 'lineJoin', 'lineDash', 'lineDashOffset', 'miterLimit', 'shadowOffsetX', 'shadowOffsetY', 'shadowBlur', 'shadowColor', 'globalCompositeOperation', 'position', 'fillGradient', 'strokeGradient'], strokeOpacity:1, strokeStyle:'none', fillOpacity:1, fillStyle:'none', lineDas:[], lineDashOffset:0, globalAlpha:1, lineWidth:1, lineCap:'butt',
  6187. lineJoin:'miter', miterLimit:10, shadowOffsetX:0, shadowOffsetY:0, shadowBlur:0, shadowColor:'none', globalCompositeOperation:'src', urlStringRe:/^url\(#([\w-]+)\)$/, constructor:function(SvgSurface) {
  6188. var me = this;
  6189. me.surface = SvgSurface;
  6190. me.state = [];
  6191. me.matrix = new Ext.draw.Matrix;
  6192. me.path = null;
  6193. me.clear();
  6194. }, clear:function() {
  6195. this.group = this.surface.mainGroup;
  6196. this.position = 0;
  6197. this.path = null;
  6198. }, getElement:function(tag) {
  6199. return this.surface.getSvgElement(this.group, tag, this.position++);
  6200. }, save:function() {
  6201. var toSave = this.toSave, obj = {}, group = this.getElement('g'), key, i;
  6202. for (i = 0; i < toSave.length; i++) {
  6203. key = toSave[i];
  6204. if (key in this) {
  6205. obj[key] = this[key];
  6206. }
  6207. }
  6208. this.position = 0;
  6209. obj.matrix = this.matrix.clone();
  6210. this.state.push(obj);
  6211. this.group = group;
  6212. return group;
  6213. }, restore:function() {
  6214. var toSave = this.toSave, obj = this.state.pop(), group = this.group, children = group.dom.childNodes, key, i;
  6215. while (children.length > this.position) {
  6216. group.last().destroy();
  6217. }
  6218. for (i = 0; i < toSave.length; i++) {
  6219. key = toSave[i];
  6220. if (key in obj) {
  6221. this[key] = obj[key];
  6222. } else {
  6223. delete this[key];
  6224. }
  6225. }
  6226. this.setTransform.apply(this, obj.matrix.elements);
  6227. this.group = group.getParent();
  6228. }, transform:function(xx, yx, xy, yy, dx, dy) {
  6229. var inv;
  6230. if (this.path) {
  6231. inv = Ext.draw.Matrix.fly([xx, yx, xy, yy, dx, dy]).inverse();
  6232. this.path.transform(inv);
  6233. }
  6234. this.matrix.append(xx, yx, xy, yy, dx, dy);
  6235. }, setTransform:function(xx, yx, xy, yy, dx, dy) {
  6236. if (this.path) {
  6237. this.path.transform(this.matrix);
  6238. }
  6239. this.matrix.reset();
  6240. this.transform(xx, yx, xy, yy, dx, dy);
  6241. }, scale:function(x, y) {
  6242. this.transform(x, 0, 0, y, 0, 0);
  6243. }, rotate:function(angle) {
  6244. var xx = Math.cos(angle), yx = Math.sin(angle), xy = -Math.sin(angle), yy = Math.cos(angle);
  6245. this.transform(xx, yx, xy, yy, 0, 0);
  6246. }, translate:function(x, y) {
  6247. this.transform(1, 0, 0, 1, x, y);
  6248. }, setGradientBBox:function(bbox) {
  6249. this.bbox = bbox;
  6250. }, beginPath:function() {
  6251. this.path = new Ext.draw.Path;
  6252. }, moveTo:function(x, y) {
  6253. if (!this.path) {
  6254. this.beginPath();
  6255. }
  6256. this.path.moveTo(x, y);
  6257. this.path.element = null;
  6258. }, lineTo:function(x, y) {
  6259. if (!this.path) {
  6260. this.beginPath();
  6261. }
  6262. this.path.lineTo(x, y);
  6263. this.path.element = null;
  6264. }, rect:function(x, y, width, height) {
  6265. this.moveTo(x, y);
  6266. this.lineTo(x + width, y);
  6267. this.lineTo(x + width, y + height);
  6268. this.lineTo(x, y + height);
  6269. this.closePath();
  6270. }, strokeRect:function(x, y, width, height) {
  6271. this.beginPath();
  6272. this.rect(x, y, width, height);
  6273. this.stroke();
  6274. }, fillRect:function(x, y, width, height) {
  6275. this.beginPath();
  6276. this.rect(x, y, width, height);
  6277. this.fill();
  6278. }, closePath:function() {
  6279. if (!this.path) {
  6280. this.beginPath();
  6281. }
  6282. this.path.closePath();
  6283. this.path.element = null;
  6284. }, arcSvg:function(r1, r2, rotation, large, swipe, x2, y2) {
  6285. if (!this.path) {
  6286. this.beginPath();
  6287. }
  6288. this.path.arcSvg(r1, r2, rotation, large, swipe, x2, y2);
  6289. this.path.element = null;
  6290. }, arc:function(x, y, radius, startAngle, endAngle, anticlockwise) {
  6291. if (!this.path) {
  6292. this.beginPath();
  6293. }
  6294. this.path.arc(x, y, radius, startAngle, endAngle, anticlockwise);
  6295. this.path.element = null;
  6296. }, ellipse:function(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise) {
  6297. if (!this.path) {
  6298. this.beginPath();
  6299. }
  6300. this.path.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, anticlockwise);
  6301. this.path.element = null;
  6302. }, arcTo:function(x1, y1, x2, y2, radiusX, radiusY, rotation) {
  6303. if (!this.path) {
  6304. this.beginPath();
  6305. }
  6306. this.path.arcTo(x1, y1, x2, y2, radiusX, radiusY, rotation);
  6307. this.path.element = null;
  6308. }, bezierCurveTo:function(x1, y1, x2, y2, x3, y3) {
  6309. if (!this.path) {
  6310. this.beginPath();
  6311. }
  6312. this.path.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  6313. this.path.element = null;
  6314. }, strokeText:function(text, x, y) {
  6315. var element, tspan;
  6316. text = String(text);
  6317. if (this.strokeStyle) {
  6318. element = this.getElement('text');
  6319. tspan = this.surface.getSvgElement(element, 'tspan', 0);
  6320. this.surface.setElementAttributes(element, {'x':x, 'y':y, 'transform':this.matrix.toSvg(), 'stroke':this.strokeStyle, 'fill':'none', 'opacity':this.globalAlpha, 'stroke-opacity':this.strokeOpacity, 'style':'font: ' + this.font, 'stroke-dasharray':this.lineDash.join(','), 'stroke-dashoffset':this.lineDashOffset});
  6321. if (this.lineDash.length) {
  6322. this.surface.setElementAttributes(element, {'stroke-dasharray':this.lineDash.join(','), 'stroke-dashoffset':this.lineDashOffset});
  6323. }
  6324. if (tspan.dom.firstChild) {
  6325. tspan.dom.removeChild(tspan.dom.firstChild);
  6326. }
  6327. this.surface.setElementAttributes(tspan, {'alignment-baseline':'alphabetic'});
  6328. tspan.dom.appendChild(document.createTextNode(Ext.String.htmlDecode(text)));
  6329. }
  6330. }, fillText:function(text, x, y) {
  6331. var element, tspan;
  6332. text = String(text);
  6333. if (this.fillStyle) {
  6334. element = this.getElement('text');
  6335. tspan = this.surface.getSvgElement(element, 'tspan', 0);
  6336. this.surface.setElementAttributes(element, {'x':x, 'y':y, 'transform':this.matrix.toSvg(), 'fill':this.fillStyle, 'opacity':this.globalAlpha, 'fill-opacity':this.fillOpacity, 'style':'font: ' + this.font});
  6337. if (tspan.dom.firstChild) {
  6338. tspan.dom.removeChild(tspan.dom.firstChild);
  6339. }
  6340. this.surface.setElementAttributes(tspan, {'alignment-baseline':'alphabetic'});
  6341. tspan.dom.appendChild(document.createTextNode(Ext.String.htmlDecode(text)));
  6342. }
  6343. }, drawImage:function(image, sx, sy, sw, sh, dx, dy, dw, dh) {
  6344. var me = this, element = me.getElement('image'), x = sx, y = sy, width = typeof sw === 'undefined' ? image.width : sw, height = typeof sh === 'undefined' ? image.height : sh, viewBox = null;
  6345. if (typeof dh !== 'undefined') {
  6346. viewBox = sx + ' ' + sy + ' ' + sw + ' ' + sh;
  6347. x = dx;
  6348. y = dy;
  6349. width = dw;
  6350. height = dh;
  6351. }
  6352. element.dom.setAttributeNS('http:/' + '/www.w3.org/1999/xlink', 'href', image.src);
  6353. me.surface.setElementAttributes(element, {viewBox:viewBox, x:x, y:y, width:width, height:height, opacity:me.globalAlpha, transform:me.matrix.toSvg()});
  6354. }, fill:function() {
  6355. var me = this, path, fillGradient, element, bbox, fill;
  6356. if (!me.path) {
  6357. return;
  6358. }
  6359. if (me.fillStyle) {
  6360. fillGradient = me.fillGradient;
  6361. element = me.path.element;
  6362. bbox = me.bbox;
  6363. if (!element) {
  6364. path = me.path.toString();
  6365. element = me.path.element = me.getElement('path');
  6366. me.surface.setElementAttributes(element, {'d':path, 'transform':me.matrix.toSvg()});
  6367. }
  6368. if (fillGradient && bbox) {
  6369. fill = fillGradient.generateGradient(me, bbox);
  6370. } else {
  6371. fill = me.fillStyle;
  6372. }
  6373. me.surface.setElementAttributes(element, {'fill':fill, 'fill-opacity':me.fillOpacity * me.globalAlpha});
  6374. }
  6375. }, stroke:function() {
  6376. var me = this, path, strokeGradient, element, bbox, stroke;
  6377. if (!me.path) {
  6378. return;
  6379. }
  6380. if (me.strokeStyle) {
  6381. strokeGradient = me.strokeGradient;
  6382. element = me.path.element;
  6383. bbox = me.bbox;
  6384. if (!element || !me.path.svgString) {
  6385. path = me.path.toString();
  6386. if (!path) {
  6387. return;
  6388. }
  6389. element = me.path.element = me.getElement('path');
  6390. me.surface.setElementAttributes(element, {'fill':'none', 'd':path, 'transform':me.matrix.toSvg()});
  6391. }
  6392. if (strokeGradient && bbox) {
  6393. stroke = strokeGradient.generateGradient(me, bbox);
  6394. } else {
  6395. stroke = me.strokeStyle;
  6396. }
  6397. me.surface.setElementAttributes(element, {'stroke':stroke, 'stroke-linecap':me.lineCap, 'stroke-linejoin':me.lineJoin, 'stroke-width':me.lineWidth, 'stroke-opacity':me.strokeOpacity * me.globalAlpha, 'stroke-dasharray':me.lineDash.join(','), 'stroke-dashoffset':me.lineDashOffset});
  6398. if (me.lineDash.length) {
  6399. me.surface.setElementAttributes(element, {'stroke-dasharray':me.lineDash.join(','), 'stroke-dashoffset':me.lineDashOffset});
  6400. }
  6401. }
  6402. }, fillStroke:function(attr, transformFillStroke) {
  6403. var ctx = this, fillStyle = ctx.fillStyle, strokeStyle = ctx.strokeStyle, fillOpacity = ctx.fillOpacity, strokeOpacity = ctx.strokeOpacity;
  6404. if (transformFillStroke === undefined) {
  6405. transformFillStroke = attr.transformFillStroke;
  6406. }
  6407. if (!transformFillStroke) {
  6408. attr.inverseMatrix.toContext(ctx);
  6409. }
  6410. if (fillStyle && fillOpacity !== 0) {
  6411. ctx.fill();
  6412. }
  6413. if (strokeStyle && strokeOpacity !== 0) {
  6414. ctx.stroke();
  6415. }
  6416. }, appendPath:function(path) {
  6417. this.path = path.clone();
  6418. }, setLineDash:function(lineDash) {
  6419. this.lineDash = lineDash;
  6420. }, getLineDash:function() {
  6421. return this.lineDash;
  6422. }, createLinearGradient:function(x0, y0, x1, y1) {
  6423. var me = this, element = me.surface.getNextDef('linearGradient'), gradient;
  6424. me.surface.setElementAttributes(element, {'x1':x0, 'y1':y0, 'x2':x1, 'y2':y1, 'gradientUnits':'userSpaceOnUse'});
  6425. gradient = new Ext.draw.engine.SvgContext.Gradient(me, me.surface, element);
  6426. return gradient;
  6427. }, createRadialGradient:function(x0, y0, r0, x1, y1, r1) {
  6428. var me = this, element = me.surface.getNextDef('radialGradient'), gradient;
  6429. me.surface.setElementAttributes(element, {fx:x0, fy:y0, cx:x1, cy:y1, r:r1, gradientUnits:'userSpaceOnUse'});
  6430. gradient = new Ext.draw.engine.SvgContext.Gradient(me, me.surface, element, r0 / r1);
  6431. return gradient;
  6432. }});
  6433. Ext.define('Ext.draw.engine.SvgContext.Gradient', {isGradient:true, constructor:function(ctx, surface, element, compression) {
  6434. var me = this;
  6435. me.ctx = ctx;
  6436. me.surface = surface;
  6437. me.element = element;
  6438. me.position = 0;
  6439. me.compression = compression || 0;
  6440. }, addColorStop:function(offset, color) {
  6441. var me = this, stop = me.surface.getSvgElement(me.element, 'stop', me.position++), compression = me.compression;
  6442. me.surface.setElementAttributes(stop, {'offset':(((1 - compression) * offset + compression) * 100).toFixed(2) + '%', 'stop-color':color, 'stop-opacity':Ext.util.Color.fly(color).a.toFixed(15)});
  6443. }, toString:function() {
  6444. var children = this.element.dom.childNodes;
  6445. while (children.length > this.position) {
  6446. Ext.fly(children[children.length - 1]).destroy();
  6447. }
  6448. return 'url(#' + this.element.getId() + ')';
  6449. }});
  6450. Ext.define('Ext.draw.engine.Svg', {extend:'Ext.draw.Surface', requires:['Ext.draw.engine.SvgContext'], isSVG:true, config:{highPrecision:false}, getElementConfig:function() {
  6451. return {reference:'element', style:{position:'absolute'}, children:[{reference:'bodyElement', style:{width:'100%', height:'100%', position:'relative'}, children:[{tag:'svg', reference:'svgElement', namespace:'http://www.w3.org/2000/svg', width:'100%', height:'100%', version:1.1}]}]};
  6452. }, constructor:function(config) {
  6453. var me = this;
  6454. me.callParent([config]);
  6455. me.mainGroup = me.createSvgNode('g');
  6456. me.defsElement = me.createSvgNode('defs');
  6457. me.svgElement.appendChild(me.mainGroup);
  6458. me.svgElement.appendChild(me.defsElement);
  6459. me.ctx = new Ext.draw.engine.SvgContext(me);
  6460. }, createSvgNode:function(type) {
  6461. var node = document.createElementNS('http://www.w3.org/2000/svg', type);
  6462. return Ext.get(node);
  6463. }, getSvgElement:function(group, tag, position) {
  6464. var childNodes = group.dom.childNodes, length = childNodes.length, element;
  6465. if (position < length) {
  6466. element = childNodes[position];
  6467. if (element.tagName === tag) {
  6468. return Ext.get(element);
  6469. } else {
  6470. Ext.destroy(element);
  6471. }
  6472. } else {
  6473. if (position > length) {
  6474. Ext.raise('Invalid position.');
  6475. }
  6476. }
  6477. element = Ext.get(this.createSvgNode(tag));
  6478. if (position === 0) {
  6479. group.insertFirst(element);
  6480. } else {
  6481. element.insertAfter(Ext.fly(childNodes[position - 1]));
  6482. }
  6483. element.cache = {};
  6484. return element;
  6485. }, setElementAttributes:function(element, attributes) {
  6486. var dom = element.dom, cache = element.cache, name, value;
  6487. for (name in attributes) {
  6488. value = attributes[name];
  6489. if (cache[name] !== value) {
  6490. cache[name] = value;
  6491. dom.setAttribute(name, value);
  6492. }
  6493. }
  6494. }, getNextDef:function(tagName) {
  6495. return this.getSvgElement(this.defsElement, tagName, this.defsPosition++);
  6496. }, clearTransform:function() {
  6497. var me = this;
  6498. me.mainGroup.set({transform:me.matrix.toSvg()});
  6499. }, clear:function() {
  6500. this.ctx.clear();
  6501. this.removeSurplusDefs();
  6502. this.defsPosition = 0;
  6503. }, removeSurplusDefs:function() {
  6504. var defsElement = this.defsElement, defs = defsElement.dom.childNodes, ln = defs.length, i;
  6505. for (i = ln - 1; i > this.defsPosition; i--) {
  6506. defsElement.removeChild(defs[i]);
  6507. }
  6508. }, renderSprite:function(sprite) {
  6509. var me = this, rect = me.getRect(), ctx = me.ctx;
  6510. if (sprite.attr.hidden || sprite.attr.globalAlpha === 0) {
  6511. ctx.save();
  6512. ctx.restore();
  6513. return;
  6514. }
  6515. sprite.element = ctx.save();
  6516. sprite.preRender(this);
  6517. sprite.useAttributes(ctx, rect);
  6518. if (false === sprite.render(this, ctx, [0, 0, rect[2], rect[3]])) {
  6519. return false;
  6520. }
  6521. sprite.setDirty(false);
  6522. ctx.restore();
  6523. }, toSVG:function(size, surfaces) {
  6524. var className = Ext.getClassName(this), svg, surface, rect, i;
  6525. svg = '\x3csvg version\x3d"1.1" baseProfile\x3d"full" xmlns\x3d"http://www.w3.org/2000/svg"' + ' width\x3d"' + size.width + '"' + ' height\x3d"' + size.height + '"\x3e';
  6526. for (i = 0; i < surfaces.length; i++) {
  6527. surface = surfaces[i];
  6528. if (Ext.getClassName(surface) !== className) {
  6529. continue;
  6530. }
  6531. rect = surface.getRect();
  6532. svg += '\x3cg transform\x3d"translate(' + rect[0] + ',' + rect[1] + ')"\x3e';
  6533. svg += this.serializeNode(surface.svgElement.dom);
  6534. svg += '\x3c/g\x3e';
  6535. }
  6536. svg += '\x3c/svg\x3e';
  6537. return svg;
  6538. }, b64EncodeUnicode:function(str) {
  6539. return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
  6540. return String.fromCharCode('0x' + p1);
  6541. }));
  6542. }, flatten:function(size, surfaces) {
  6543. var svg = '\x3c?xml version\x3d"1.0" standalone\x3d"yes"?\x3e';
  6544. svg += this.toSVG(size, surfaces);
  6545. return {data:'data:image/svg+xml;base64,' + this.b64EncodeUnicode(svg), type:'svg'};
  6546. }, serializeNode:function(node) {
  6547. var result = '', i, n, attr, child;
  6548. if (node.nodeType === document.TEXT_NODE) {
  6549. return node.nodeValue;
  6550. }
  6551. result += '\x3c' + node.nodeName;
  6552. if (node.attributes.length) {
  6553. for (i = 0, n = node.attributes.length; i < n; i++) {
  6554. attr = node.attributes[i];
  6555. result += ' ' + attr.name + '\x3d"' + Ext.String.htmlEncode(attr.value) + '"';
  6556. }
  6557. }
  6558. result += '\x3e';
  6559. if (node.childNodes && node.childNodes.length) {
  6560. for (i = 0, n = node.childNodes.length; i < n; i++) {
  6561. child = node.childNodes[i];
  6562. result += this.serializeNode(child);
  6563. }
  6564. }
  6565. result += '\x3c/' + node.nodeName + '\x3e';
  6566. return result;
  6567. }, destroy:function() {
  6568. var me = this;
  6569. me.ctx.destroy();
  6570. me.mainGroup.destroy();
  6571. me.defsElement.destroy();
  6572. delete me.mainGroup;
  6573. delete me.defsElement;
  6574. delete me.ctx;
  6575. me.callParent();
  6576. }, remove:function(sprite, destroySprite) {
  6577. if (sprite && sprite.element) {
  6578. sprite.element.destroy();
  6579. sprite.element = null;
  6580. }
  6581. this.callParent(arguments);
  6582. }});
  6583. if (!Ext.draw) {
  6584. Ext.draw = {};
  6585. }
  6586. if (!Ext.draw.engine) {
  6587. Ext.draw.engine = {};
  6588. }
  6589. Ext.draw.engine.excanvas = true;
  6590. if (!document.createElement('canvas').getContext) {
  6591. (function() {
  6592. var m = Math;
  6593. var mr = m.round;
  6594. var ms = m.sin;
  6595. var mc = m.cos;
  6596. var abs = m.abs;
  6597. var sqrt = m.sqrt;
  6598. var Z = 10;
  6599. var Z2 = Z / 2;
  6600. var IE_VERSION = +navigator.userAgent.match(/MSIE ([\d.]+)?/)[1];
  6601. function getContext() {
  6602. return this.context_ || (this.context_ = new CanvasRenderingContext2D_(this));
  6603. }
  6604. var slice = Array.prototype.slice;
  6605. function bind(f, obj, var_args) {
  6606. var a = slice.call(arguments, 2);
  6607. return function() {
  6608. return f.apply(obj, a.concat(slice.call(arguments)));
  6609. };
  6610. }
  6611. function encodeHtmlAttribute(s) {
  6612. return String(s).replace(/&/g, '\x26amp;').replace(/"/g, '\x26quot;');
  6613. }
  6614. function addNamespace(doc, prefix, urn) {
  6615. Ext.onReady(function() {
  6616. if (!doc.namespaces[prefix]) {
  6617. doc.namespaces.add(prefix, urn, '#default#VML');
  6618. }
  6619. });
  6620. }
  6621. function addNamespacesAndStylesheet(doc) {
  6622. addNamespace(doc, 'g_vml_', 'urn:schemas-microsoft-com:vml');
  6623. addNamespace(doc, 'g_o_', 'urn:schemas-microsoft-com:office:office');
  6624. if (!doc.styleSheets['ex_canvas_']) {
  6625. var ss = doc.createStyleSheet();
  6626. ss.owningElement.id = 'ex_canvas_';
  6627. ss.cssText = 'canvas{display:inline-block;overflow:hidden;' + 'text-align:left;width:300px;height:150px}';
  6628. }
  6629. }
  6630. addNamespacesAndStylesheet(document);
  6631. var G_vmlCanvasManager_ = {init:function(opt_doc) {
  6632. var doc = opt_doc || document;
  6633. doc.createElement('canvas');
  6634. doc.attachEvent('onreadystatechange', bind(this.init_, this, doc));
  6635. }, init_:function(doc) {
  6636. var els = doc.getElementsByTagName('canvas');
  6637. for (var i = 0; i < els.length; i++) {
  6638. this.initElement(els[i]);
  6639. }
  6640. }, initElement:function(el) {
  6641. if (!el.getContext) {
  6642. el.getContext = getContext;
  6643. addNamespacesAndStylesheet(el.ownerDocument);
  6644. el.innerHTML = '';
  6645. el.attachEvent('onpropertychange', onPropertyChange);
  6646. el.attachEvent('onresize', onResize);
  6647. var attrs = el.attributes;
  6648. if (attrs.width && attrs.width.specified) {
  6649. el.style.width = attrs.width.nodeValue + 'px';
  6650. } else {
  6651. el.width = el.clientWidth;
  6652. }
  6653. if (attrs.height && attrs.height.specified) {
  6654. el.style.height = attrs.height.nodeValue + 'px';
  6655. } else {
  6656. el.height = el.clientHeight;
  6657. }
  6658. }
  6659. return el;
  6660. }};
  6661. function onPropertyChange(e) {
  6662. var el = e.srcElement;
  6663. switch(e.propertyName) {
  6664. case 'width':
  6665. el.getContext().clearRect();
  6666. el.style.width = el.attributes.width.nodeValue + 'px';
  6667. el.firstChild.style.width = el.clientWidth + 'px';
  6668. break;
  6669. case 'height':
  6670. el.getContext().clearRect();
  6671. el.style.height = el.attributes.height.nodeValue + 'px';
  6672. el.firstChild.style.height = el.clientHeight + 'px';
  6673. break;
  6674. }
  6675. }
  6676. function onResize(e) {
  6677. var el = e.srcElement;
  6678. if (el.firstChild) {
  6679. el.firstChild.style.width = el.clientWidth + 'px';
  6680. el.firstChild.style.height = el.clientHeight + 'px';
  6681. }
  6682. }
  6683. G_vmlCanvasManager_.init();
  6684. var decToHex = [];
  6685. for (var i = 0; i < 16; i++) {
  6686. for (var j = 0; j < 16; j++) {
  6687. decToHex[i * 16 + j] = i.toString(16) + j.toString(16);
  6688. }
  6689. }
  6690. function createMatrixIdentity() {
  6691. return [[1, 0, 0], [0, 1, 0], [0, 0, 1]];
  6692. }
  6693. function matrixMultiply(m1, m2) {
  6694. var result = createMatrixIdentity();
  6695. for (var x = 0; x < 3; x++) {
  6696. for (var y = 0; y < 3; y++) {
  6697. var sum = 0;
  6698. for (var z = 0; z < 3; z++) {
  6699. sum += m1[x][z] * m2[z][y];
  6700. }
  6701. result[x][y] = sum;
  6702. }
  6703. }
  6704. return result;
  6705. }
  6706. function copyState(o1, o2) {
  6707. o2.fillStyle = o1.fillStyle;
  6708. o2.lineCap = o1.lineCap;
  6709. o2.lineJoin = o1.lineJoin;
  6710. o2.lineDash = o1.lineDash;
  6711. o2.lineWidth = o1.lineWidth;
  6712. o2.miterLimit = o1.miterLimit;
  6713. o2.shadowBlur = o1.shadowBlur;
  6714. o2.shadowColor = o1.shadowColor;
  6715. o2.shadowOffsetX = o1.shadowOffsetX;
  6716. o2.shadowOffsetY = o1.shadowOffsetY;
  6717. o2.strokeStyle = o1.strokeStyle;
  6718. o2.globalAlpha = o1.globalAlpha;
  6719. o2.font = o1.font;
  6720. o2.textAlign = o1.textAlign;
  6721. o2.textBaseline = o1.textBaseline;
  6722. o2.arcScaleX_ = o1.arcScaleX_;
  6723. o2.arcScaleY_ = o1.arcScaleY_;
  6724. o2.lineScale_ = o1.lineScale_;
  6725. }
  6726. var colorData = {aliceblue:'#F0F8FF', antiquewhite:'#FAEBD7', aquamarine:'#7FFFD4', azure:'#F0FFFF', beige:'#F5F5DC', bisque:'#FFE4C4', black:'#000000', blanchedalmond:'#FFEBCD', 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',
  6727. darkgrey:'#A9A9A9', darkkhaki:'#BDB76B', darkmagenta:'#8B008B', darkolivegreen:'#556B2F', darkorange:'#FF8C00', darkorchid:'#9932CC', darkred:'#8B0000', darksalmon:'#E9967A', darkseagreen:'#8FBC8F', darkslateblue:'#483D8B', darkslategray:'#2F4F4F', darkslategrey:'#2F4F4F', darkturquoise:'#00CED1', darkviolet:'#9400D3', deeppink:'#FF1493', deepskyblue:'#00BFFF', dimgray:'#696969', dimgrey:'#696969', dodgerblue:'#1E90FF', firebrick:'#B22222', floralwhite:'#FFFAF0', forestgreen:'#228B22', gainsboro:'#DCDCDC',
  6728. ghostwhite:'#F8F8FF', gold:'#FFD700', goldenrod:'#DAA520', grey:'#808080', 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', lightgreen:'#90EE90', lightgrey:'#D3D3D3', lightpink:'#FFB6C1', lightsalmon:'#FFA07A', lightseagreen:'#20B2AA',
  6729. lightskyblue:'#87CEFA', lightslategray:'#778899', lightslategrey:'#778899', lightsteelblue:'#B0C4DE', lightyellow:'#FFFFE0', limegreen:'#32CD32', linen:'#FAF0E6', magenta:'#FF00FF', mediumaquamarine:'#66CDAA', mediumblue:'#0000CD', mediumorchid:'#BA55D3', mediumpurple:'#9370DB', mediumseagreen:'#3CB371', mediumslateblue:'#7B68EE', mediumspringgreen:'#00FA9A', mediumturquoise:'#48D1CC', mediumvioletred:'#C71585', midnightblue:'#191970', mintcream:'#F5FFFA', mistyrose:'#FFE4E1', moccasin:'#FFE4B5',
  6730. navajowhite:'#FFDEAD', oldlace:'#FDF5E6', olivedrab:'#6B8E23', orange:'#FFA500', orangered:'#FF4500', orchid:'#DA70D6', palegoldenrod:'#EEE8AA', palegreen:'#98FB98', paleturquoise:'#AFEEEE', palevioletred:'#DB7093', papayawhip:'#FFEFD5', peachpuff:'#FFDAB9', peru:'#CD853F', pink:'#FFC0CB', plum:'#DDA0DD', powderblue:'#B0E0E6', rosybrown:'#BC8F8F', royalblue:'#4169E1', saddlebrown:'#8B4513', salmon:'#FA8072', sandybrown:'#F4A460', seagreen:'#2E8B57', seashell:'#FFF5EE', sienna:'#A0522D', skyblue:'#87CEEB',
  6731. slateblue:'#6A5ACD', slategray:'#708090', slategrey:'#708090', snow:'#FFFAFA', springgreen:'#00FF7F', steelblue:'#4682B4', tan:'#D2B48C', thistle:'#D8BFD8', tomato:'#FF6347', turquoise:'#40E0D0', violet:'#EE82EE', wheat:'#F5DEB3', whitesmoke:'#F5F5F5', yellowgreen:'#9ACD32'};
  6732. function getRgbHslContent(styleString) {
  6733. var start = styleString.indexOf('(', 3);
  6734. var end = styleString.indexOf(')', start + 1);
  6735. var parts = styleString.substring(start + 1, end).split(',');
  6736. if (parts.length != 4 || styleString.charAt(3) != 'a') {
  6737. parts[3] = 1;
  6738. }
  6739. return parts;
  6740. }
  6741. function percent(s) {
  6742. return parseFloat(s) / 100;
  6743. }
  6744. function clamp(v, min, max) {
  6745. return Math.min(max, Math.max(min, v));
  6746. }
  6747. function hslToRgb(parts) {
  6748. var r, g, b, h, s, l;
  6749. h = parseFloat(parts[0]) / 360 % 360;
  6750. if (h < 0) {
  6751. h++;
  6752. }
  6753. s = clamp(percent(parts[1]), 0, 1);
  6754. l = clamp(percent(parts[2]), 0, 1);
  6755. if (s == 0) {
  6756. r = g = b = l;
  6757. } else {
  6758. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  6759. var p = 2 * l - q;
  6760. r = hueToRgb(p, q, h + 1 / 3);
  6761. g = hueToRgb(p, q, h);
  6762. b = hueToRgb(p, q, h - 1 / 3);
  6763. }
  6764. return '#' + decToHex[Math.floor(r * 255)] + decToHex[Math.floor(g * 255)] + decToHex[Math.floor(b * 255)];
  6765. }
  6766. function hueToRgb(m1, m2, h) {
  6767. if (h < 0) {
  6768. h++;
  6769. }
  6770. if (h > 1) {
  6771. h--;
  6772. }
  6773. if (6 * h < 1) {
  6774. return m1 + (m2 - m1) * 6 * h;
  6775. } else {
  6776. if (2 * h < 1) {
  6777. return m2;
  6778. } else {
  6779. if (3 * h < 2) {
  6780. return m1 + (m2 - m1) * (2 / 3 - h) * 6;
  6781. } else {
  6782. return m1;
  6783. }
  6784. }
  6785. }
  6786. }
  6787. var processStyleCache = {};
  6788. function processStyle(styleString) {
  6789. if (styleString in processStyleCache) {
  6790. return processStyleCache[styleString];
  6791. }
  6792. var str, alpha = 1;
  6793. styleString = String(styleString);
  6794. if (styleString.charAt(0) == '#') {
  6795. str = styleString;
  6796. } else {
  6797. if (/^rgb/.test(styleString)) {
  6798. var parts = getRgbHslContent(styleString);
  6799. var str = '#', n;
  6800. for (var i = 0; i < 3; i++) {
  6801. if (parts[i].indexOf('%') != -1) {
  6802. n = Math.floor(percent(parts[i]) * 255);
  6803. } else {
  6804. n = +parts[i];
  6805. }
  6806. str += decToHex[clamp(n, 0, 255)];
  6807. }
  6808. alpha = +parts[3];
  6809. } else {
  6810. if (/^hsl/.test(styleString)) {
  6811. var parts = getRgbHslContent(styleString);
  6812. str = hslToRgb(parts);
  6813. alpha = parts[3];
  6814. } else {
  6815. str = colorData[styleString] || styleString;
  6816. }
  6817. }
  6818. }
  6819. return processStyleCache[styleString] = {color:str, alpha:alpha};
  6820. }
  6821. var DEFAULT_STYLE = {style:'normal', variant:'normal', weight:'normal', size:10, family:'sans-serif'};
  6822. var fontStyleCache = {};
  6823. function processFontStyle(styleString) {
  6824. if (fontStyleCache[styleString]) {
  6825. return fontStyleCache[styleString];
  6826. }
  6827. var el = document.createElement('div');
  6828. var style = el.style;
  6829. try {
  6830. style.font = styleString;
  6831. } catch (ex) {
  6832. }
  6833. return fontStyleCache[styleString] = {style:style.fontStyle || DEFAULT_STYLE.style, variant:style.fontVariant || DEFAULT_STYLE.variant, weight:style.fontWeight || DEFAULT_STYLE.weight, size:style.fontSize || DEFAULT_STYLE.size, family:style.fontFamily || DEFAULT_STYLE.family};
  6834. }
  6835. function getComputedStyle(style, element) {
  6836. var computedStyle = {};
  6837. for (var p in style) {
  6838. computedStyle[p] = style[p];
  6839. }
  6840. var canvasFontSize = parseFloat(element.currentStyle.fontSize), fontSize = parseFloat(style.size);
  6841. if (typeof style.size == 'number') {
  6842. computedStyle.size = style.size;
  6843. } else {
  6844. if (style.size.indexOf('px') != -1) {
  6845. computedStyle.size = fontSize;
  6846. } else {
  6847. if (style.size.indexOf('em') != -1) {
  6848. computedStyle.size = canvasFontSize * fontSize;
  6849. } else {
  6850. if (style.size.indexOf('%') != -1) {
  6851. computedStyle.size = canvasFontSize / 100 * fontSize;
  6852. } else {
  6853. if (style.size.indexOf('pt') != -1) {
  6854. computedStyle.size = fontSize / 0.75;
  6855. } else {
  6856. computedStyle.size = canvasFontSize;
  6857. }
  6858. }
  6859. }
  6860. }
  6861. }
  6862. computedStyle.size *= 0.981;
  6863. return computedStyle;
  6864. }
  6865. function buildStyle(style) {
  6866. return style.style + ' ' + style.variant + ' ' + style.weight + ' ' + style.size + 'px ' + style.family;
  6867. }
  6868. var lineCapMap = {'butt':'flat', 'round':'round'};
  6869. function processLineCap(lineCap) {
  6870. return lineCapMap[lineCap] || 'square';
  6871. }
  6872. function CanvasRenderingContext2D_(canvasElement) {
  6873. this.m_ = createMatrixIdentity();
  6874. this.mStack_ = [];
  6875. this.aStack_ = [];
  6876. this.currentPath_ = [];
  6877. this.strokeStyle = '#000';
  6878. this.fillStyle = '#000';
  6879. this.lineWidth = 1;
  6880. this.lineJoin = 'miter';
  6881. this.lineDash = [];
  6882. this.lineCap = 'butt';
  6883. this.miterLimit = Z * 1;
  6884. this.globalAlpha = 1;
  6885. this.font = '10px sans-serif';
  6886. this.textAlign = 'left';
  6887. this.textBaseline = 'alphabetic';
  6888. this.canvas = canvasElement;
  6889. var cssText = 'width:' + canvasElement.clientWidth + 'px;height:' + canvasElement.clientHeight + 'px;overflow:hidden;position:absolute';
  6890. var el = canvasElement.ownerDocument.createElement('div');
  6891. el.style.cssText = cssText;
  6892. canvasElement.appendChild(el);
  6893. var overlayEl = el.cloneNode(false);
  6894. overlayEl.style.backgroundColor = 'red';
  6895. overlayEl.style.filter = 'alpha(opacity\x3d0)';
  6896. canvasElement.appendChild(overlayEl);
  6897. this.element_ = el;
  6898. this.arcScaleX_ = 1;
  6899. this.arcScaleY_ = 1;
  6900. this.lineScale_ = 1;
  6901. }
  6902. var contextPrototype = CanvasRenderingContext2D_.prototype;
  6903. contextPrototype.clearRect = function() {
  6904. if (this.textMeasureEl_) {
  6905. this.textMeasureEl_.removeNode(true);
  6906. this.textMeasureEl_ = null;
  6907. }
  6908. this.element_.innerHTML = '';
  6909. };
  6910. contextPrototype.beginPath = function() {
  6911. this.currentPath_ = [];
  6912. };
  6913. contextPrototype.moveTo = function(aX, aY) {
  6914. var p = getCoords(this, aX, aY);
  6915. this.currentPath_.push({type:'moveTo', x:p.x, y:p.y});
  6916. this.currentX_ = p.x;
  6917. this.currentY_ = p.y;
  6918. };
  6919. contextPrototype.lineTo = function(aX, aY) {
  6920. var p = getCoords(this, aX, aY);
  6921. this.currentPath_.push({type:'lineTo', x:p.x, y:p.y});
  6922. this.currentX_ = p.x;
  6923. this.currentY_ = p.y;
  6924. };
  6925. contextPrototype.bezierCurveTo = function(aCP1x, aCP1y, aCP2x, aCP2y, aX, aY) {
  6926. var p = getCoords(this, aX, aY);
  6927. var cp1 = getCoords(this, aCP1x, aCP1y);
  6928. var cp2 = getCoords(this, aCP2x, aCP2y);
  6929. bezierCurveTo(this, cp1, cp2, p);
  6930. };
  6931. function bezierCurveTo(self, cp1, cp2, p) {
  6932. self.currentPath_.push({type:'bezierCurveTo', cp1x:cp1.x, cp1y:cp1.y, cp2x:cp2.x, cp2y:cp2.y, x:p.x, y:p.y});
  6933. self.currentX_ = p.x;
  6934. self.currentY_ = p.y;
  6935. }
  6936. contextPrototype.quadraticCurveTo = function(aCPx, aCPy, aX, aY) {
  6937. var cp = getCoords(this, aCPx, aCPy);
  6938. var p = getCoords(this, aX, aY);
  6939. var cp1 = {x:this.currentX_ + 2 / 3 * (cp.x - this.currentX_), y:this.currentY_ + 2 / 3 * (cp.y - this.currentY_)};
  6940. var cp2 = {x:cp1.x + (p.x - this.currentX_) / 3, y:cp1.y + (p.y - this.currentY_) / 3};
  6941. bezierCurveTo(this, cp1, cp2, p);
  6942. };
  6943. contextPrototype.arc = function(aX, aY, aRadius, aStartAngle, aEndAngle, aClockwise) {
  6944. aRadius *= Z;
  6945. var arcType = aClockwise ? 'at' : 'wa';
  6946. var xStart = aX + mc(aStartAngle) * aRadius - Z2;
  6947. var yStart = aY + ms(aStartAngle) * aRadius - Z2;
  6948. var xEnd = aX + mc(aEndAngle) * aRadius - Z2;
  6949. var yEnd = aY + ms(aEndAngle) * aRadius - Z2;
  6950. if (xStart == xEnd && !aClockwise) {
  6951. xStart += 0.125;
  6952. }
  6953. var p = getCoords(this, aX, aY);
  6954. var pStart = getCoords(this, xStart, yStart);
  6955. var pEnd = getCoords(this, xEnd, yEnd);
  6956. this.currentPath_.push({type:arcType, x:p.x, y:p.y, radius:aRadius, xStart:pStart.x, yStart:pStart.y, xEnd:pEnd.x, yEnd:pEnd.y});
  6957. };
  6958. contextPrototype.rect = function(aX, aY, aWidth, aHeight) {
  6959. this.moveTo(aX, aY);
  6960. this.lineTo(aX + aWidth, aY);
  6961. this.lineTo(aX + aWidth, aY + aHeight);
  6962. this.lineTo(aX, aY + aHeight);
  6963. this.closePath();
  6964. };
  6965. contextPrototype.strokeRect = function(aX, aY, aWidth, aHeight) {
  6966. var oldPath = this.currentPath_;
  6967. this.beginPath();
  6968. this.moveTo(aX, aY);
  6969. this.lineTo(aX + aWidth, aY);
  6970. this.lineTo(aX + aWidth, aY + aHeight);
  6971. this.lineTo(aX, aY + aHeight);
  6972. this.closePath();
  6973. this.stroke();
  6974. this.currentPath_ = oldPath;
  6975. };
  6976. contextPrototype.fillRect = function(aX, aY, aWidth, aHeight) {
  6977. var oldPath = this.currentPath_;
  6978. this.beginPath();
  6979. this.moveTo(aX, aY);
  6980. this.lineTo(aX + aWidth, aY);
  6981. this.lineTo(aX + aWidth, aY + aHeight);
  6982. this.lineTo(aX, aY + aHeight);
  6983. this.closePath();
  6984. this.fill();
  6985. this.currentPath_ = oldPath;
  6986. };
  6987. contextPrototype.createLinearGradient = function(aX0, aY0, aX1, aY1) {
  6988. var gradient = new CanvasGradient_('gradient');
  6989. gradient.x0_ = aX0;
  6990. gradient.y0_ = aY0;
  6991. gradient.x1_ = aX1;
  6992. gradient.y1_ = aY1;
  6993. return gradient;
  6994. };
  6995. contextPrototype.createRadialGradient = function(aX0, aY0, aR0, aX1, aY1, aR1) {
  6996. var gradient = new CanvasGradient_('gradientradial');
  6997. gradient.x0_ = aX0;
  6998. gradient.y0_ = aY0;
  6999. gradient.r0_ = aR0;
  7000. gradient.x1_ = aX1;
  7001. gradient.y1_ = aY1;
  7002. gradient.r1_ = aR1;
  7003. return gradient;
  7004. };
  7005. contextPrototype.drawImage = function(image, var_args) {
  7006. var dx, dy, dw, dh, sx, sy, sw, sh;
  7007. var oldRuntimeWidth = image.runtimeStyle.width;
  7008. var oldRuntimeHeight = image.runtimeStyle.height;
  7009. image.runtimeStyle.width = 'auto';
  7010. image.runtimeStyle.height = 'auto';
  7011. var w = image.width;
  7012. var h = image.height;
  7013. image.runtimeStyle.width = oldRuntimeWidth;
  7014. image.runtimeStyle.height = oldRuntimeHeight;
  7015. if (arguments.length == 3) {
  7016. dx = arguments[1];
  7017. dy = arguments[2];
  7018. sx = sy = 0;
  7019. sw = dw = w;
  7020. sh = dh = h;
  7021. } else {
  7022. if (arguments.length == 5) {
  7023. dx = arguments[1];
  7024. dy = arguments[2];
  7025. dw = arguments[3];
  7026. dh = arguments[4];
  7027. sx = sy = 0;
  7028. sw = w;
  7029. sh = h;
  7030. } else {
  7031. if (arguments.length == 9) {
  7032. sx = arguments[1];
  7033. sy = arguments[2];
  7034. sw = arguments[3];
  7035. sh = arguments[4];
  7036. dx = arguments[5];
  7037. dy = arguments[6];
  7038. dw = arguments[7];
  7039. dh = arguments[8];
  7040. } else {
  7041. throw Error('Invalid number of arguments');
  7042. }
  7043. }
  7044. }
  7045. var d = getCoords(this, dx, dy);
  7046. var vmlStr = [];
  7047. var W = 10;
  7048. var H = 10;
  7049. var m = this.m_;
  7050. vmlStr.push(' \x3cg_vml_:group', ' coordsize\x3d"', Z * W, ',', Z * H, '"', ' coordorigin\x3d"0,0"', ' style\x3d"width:', mr(W * m[0][0]), 'px;height:', mr(H * m[1][1]), 'px;position:absolute;', 'top:', mr(d.y / Z), 'px;left:', mr(d.x / Z), 'px; rotation:', mr(Math.atan(m[0][1] / m[1][1]) * 180 / Math.PI), ';');
  7051. vmlStr.push('" \x3e', '\x3cg_vml_:image src\x3d"', image.src, '"', ' style\x3d"width:', Z * dw, 'px;', ' height:', Z * dh, 'px"', ' cropleft\x3d"', sx / w, '"', ' croptop\x3d"', sy / h, '"', ' cropright\x3d"', (w - sx - sw) / w, '"', ' cropbottom\x3d"', (h - sy - sh) / h, '"', ' /\x3e', '\x3c/g_vml_:group\x3e');
  7052. this.element_.insertAdjacentHTML('BeforeEnd', vmlStr.join(''));
  7053. };
  7054. contextPrototype.setLineDash = function(lineDash) {
  7055. if (lineDash.length === 1) {
  7056. lineDash = lineDash.slice();
  7057. lineDash[1] = lineDash[0];
  7058. }
  7059. this.lineDash = lineDash;
  7060. };
  7061. contextPrototype.getLineDash = function() {
  7062. return this.lineDash;
  7063. };
  7064. contextPrototype.stroke = function(aFill) {
  7065. var lineStr = [];
  7066. var W = 10;
  7067. var H = 10;
  7068. lineStr.push('\x3cg_vml_:shape', ' filled\x3d"', !!aFill, '"', ' style\x3d"position:absolute;width:', W, 'px;height:', H, 'px;left:0px;top:0px;"', ' coordorigin\x3d"0,0"', ' coordsize\x3d"', Z * W, ',', Z * H, '"', ' stroked\x3d"', !aFill, '"', ' path\x3d"');
  7069. var min = {x:null, y:null};
  7070. var max = {x:null, y:null};
  7071. for (var i = 0; i < this.currentPath_.length; i++) {
  7072. var p = this.currentPath_[i];
  7073. var c;
  7074. switch(p.type) {
  7075. case 'moveTo':
  7076. c = p;
  7077. lineStr.push(' m ', mr(p.x), ',', mr(p.y));
  7078. break;
  7079. case 'lineTo':
  7080. lineStr.push(' l ', mr(p.x), ',', mr(p.y));
  7081. break;
  7082. case 'close':
  7083. lineStr.push(' x ');
  7084. p = null;
  7085. break;
  7086. case 'bezierCurveTo':
  7087. lineStr.push(' c ', mr(p.cp1x), ',', mr(p.cp1y), ',', mr(p.cp2x), ',', mr(p.cp2y), ',', mr(p.x), ',', mr(p.y));
  7088. break;
  7089. case 'at':
  7090. case 'wa':
  7091. lineStr.push(' ', p.type, ' ', mr(p.x - this.arcScaleX_ * p.radius), ',', mr(p.y - this.arcScaleY_ * p.radius), ' ', mr(p.x + this.arcScaleX_ * p.radius), ',', mr(p.y + this.arcScaleY_ * p.radius), ' ', mr(p.xStart), ',', mr(p.yStart), ' ', mr(p.xEnd), ',', mr(p.yEnd));
  7092. break;
  7093. }
  7094. if (p) {
  7095. if (min.x == null || p.x < min.x) {
  7096. min.x = p.x;
  7097. }
  7098. if (max.x == null || p.x > max.x) {
  7099. max.x = p.x;
  7100. }
  7101. if (min.y == null || p.y < min.y) {
  7102. min.y = p.y;
  7103. }
  7104. if (max.y == null || p.y > max.y) {
  7105. max.y = p.y;
  7106. }
  7107. }
  7108. }
  7109. lineStr.push(' "\x3e');
  7110. if (!aFill) {
  7111. appendStroke(this, lineStr);
  7112. } else {
  7113. appendFill(this, lineStr, min, max);
  7114. }
  7115. lineStr.push('\x3c/g_vml_:shape\x3e');
  7116. this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
  7117. };
  7118. function appendStroke(ctx, lineStr) {
  7119. var a = processStyle(ctx.strokeStyle);
  7120. var color = a.color;
  7121. var opacity = a.alpha * ctx.globalAlpha;
  7122. var lineWidth = ctx.lineScale_ * ctx.lineWidth;
  7123. if (lineWidth < 1) {
  7124. opacity *= lineWidth;
  7125. }
  7126. lineStr.push('\x3cg_vml_:stroke', ' opacity\x3d"', opacity, '"', ' joinstyle\x3d"', ctx.lineJoin, '"', ' dashstyle\x3d"', ctx.lineDash.join(' '), '"', ' miterlimit\x3d"', ctx.miterLimit, '"', ' endcap\x3d"', processLineCap(ctx.lineCap), '"', ' weight\x3d"', lineWidth, 'px"', ' color\x3d"', color, '" /\x3e');
  7127. }
  7128. function appendFill(ctx, lineStr, min, max) {
  7129. var fillStyle = ctx.fillStyle;
  7130. var arcScaleX = ctx.arcScaleX_;
  7131. var arcScaleY = ctx.arcScaleY_;
  7132. var width = max.x - min.x;
  7133. var height = max.y - min.y;
  7134. if (fillStyle instanceof CanvasGradient_) {
  7135. var angle = 0;
  7136. var focus = {x:0, y:0};
  7137. var shift = 0;
  7138. var expansion = 1;
  7139. if (fillStyle.type_ == 'gradient') {
  7140. var x0 = fillStyle.x0_ / arcScaleX;
  7141. var y0 = fillStyle.y0_ / arcScaleY;
  7142. var x1 = fillStyle.x1_ / arcScaleX;
  7143. var y1 = fillStyle.y1_ / arcScaleY;
  7144. var p0 = getCoords(ctx, x0, y0);
  7145. var p1 = getCoords(ctx, x1, y1);
  7146. var dx = p1.x - p0.x;
  7147. var dy = p1.y - p0.y;
  7148. angle = Math.atan2(dx, dy) * 180 / Math.PI;
  7149. if (angle < 0) {
  7150. angle += 360;
  7151. }
  7152. if (angle < 1.0E-6) {
  7153. angle = 0;
  7154. }
  7155. } else {
  7156. var p0 = getCoords(ctx, fillStyle.x0_, fillStyle.y0_);
  7157. focus = {x:(p0.x - min.x) / width, y:(p0.y - min.y) / height};
  7158. width /= arcScaleX * Z;
  7159. height /= arcScaleY * Z;
  7160. var dimension = m.max(width, height);
  7161. shift = 2 * fillStyle.r0_ / dimension;
  7162. expansion = 2 * fillStyle.r1_ / dimension - shift;
  7163. }
  7164. var stops = fillStyle.colors_;
  7165. stops.sort(function(cs1, cs2) {
  7166. return cs1.offset - cs2.offset;
  7167. });
  7168. var length = stops.length;
  7169. var color1 = stops[0].color;
  7170. var color2 = stops[length - 1].color;
  7171. var opacity1 = stops[0].alpha * ctx.globalAlpha;
  7172. var opacity2 = stops[length - 1].alpha * ctx.globalAlpha;
  7173. var colors = [];
  7174. for (var i = 0; i < length; i++) {
  7175. var stop = stops[i];
  7176. colors.push(stop.offset * expansion + shift + ' ' + stop.color);
  7177. }
  7178. lineStr.push('\x3cg_vml_:fill type\x3d"', fillStyle.type_, '"', ' method\x3d"none" focus\x3d"100%"', ' color\x3d"', color1, '"', ' color2\x3d"', color2, '"', ' colors\x3d"', colors.join(','), '"', ' opacity\x3d"', opacity2, '"', ' g_o_:opacity2\x3d"', opacity1, '"', ' angle\x3d"', angle, '"', ' focusposition\x3d"', focus.x, ',', focus.y, '" /\x3e');
  7179. } else {
  7180. if (fillStyle instanceof CanvasPattern_) {
  7181. if (width && height) {
  7182. var deltaLeft = -min.x;
  7183. var deltaTop = -min.y;
  7184. lineStr.push('\x3cg_vml_:fill', ' position\x3d"', deltaLeft / width * arcScaleX * arcScaleX, ',', deltaTop / height * arcScaleY * arcScaleY, '"', ' type\x3d"tile"', ' src\x3d"', fillStyle.src_, '" /\x3e');
  7185. }
  7186. } else {
  7187. var a = processStyle(ctx.fillStyle);
  7188. var color = a.color;
  7189. var opacity = a.alpha * ctx.globalAlpha;
  7190. lineStr.push('\x3cg_vml_:fill color\x3d"', color, '" opacity\x3d"', opacity, '" /\x3e');
  7191. }
  7192. }
  7193. }
  7194. contextPrototype.fill = function() {
  7195. this.$stroke(true);
  7196. };
  7197. contextPrototype.closePath = function() {
  7198. this.currentPath_.push({type:'close'});
  7199. };
  7200. function getCoords(ctx, aX, aY) {
  7201. var m = ctx.m_;
  7202. return {x:Z * (aX * m[0][0] + aY * m[1][0] + m[2][0]) - Z2, y:Z * (aX * m[0][1] + aY * m[1][1] + m[2][1]) - Z2};
  7203. }
  7204. contextPrototype.save = function() {
  7205. var o = {};
  7206. copyState(this, o);
  7207. this.aStack_.push(o);
  7208. this.mStack_.push(this.m_);
  7209. };
  7210. contextPrototype.restore = function() {
  7211. if (this.aStack_.length) {
  7212. copyState(this.aStack_.pop(), this);
  7213. this.m_ = this.mStack_.pop();
  7214. }
  7215. };
  7216. function matrixIsFinite(m) {
  7217. return isFinite(m[0][0]) && isFinite(m[0][1]) && isFinite(m[1][0]) && isFinite(m[1][1]) && isFinite(m[2][0]) && isFinite(m[2][1]);
  7218. }
  7219. function setM(ctx, m, updateLineScale) {
  7220. if (!matrixIsFinite(m)) {
  7221. return;
  7222. }
  7223. ctx.m_ = m;
  7224. if (updateLineScale) {
  7225. var det = m[0][0] * m[1][1] - m[0][1] * m[1][0];
  7226. ctx.lineScale_ = sqrt(abs(det));
  7227. }
  7228. }
  7229. contextPrototype.translate = function(aX, aY) {
  7230. var m1 = [[1, 0, 0], [0, 1, 0], [aX, aY, 1]];
  7231. setM(this, matrixMultiply(m1, this.m_), false);
  7232. };
  7233. contextPrototype.rotate = function(aRot) {
  7234. var c = mc(aRot);
  7235. var s = ms(aRot);
  7236. var m1 = [[c, s, 0], [-s, c, 0], [0, 0, 1]];
  7237. setM(this, matrixMultiply(m1, this.m_), false);
  7238. };
  7239. contextPrototype.scale = function(aX, aY) {
  7240. this.arcScaleX_ *= aX;
  7241. this.arcScaleY_ *= aY;
  7242. var m1 = [[aX, 0, 0], [0, aY, 0], [0, 0, 1]];
  7243. setM(this, matrixMultiply(m1, this.m_), true);
  7244. };
  7245. contextPrototype.transform = function(m11, m12, m21, m22, dx, dy) {
  7246. var m1 = [[m11, m12, 0], [m21, m22, 0], [dx, dy, 1]];
  7247. setM(this, matrixMultiply(m1, this.m_), true);
  7248. };
  7249. contextPrototype.setTransform = function(m11, m12, m21, m22, dx, dy) {
  7250. var m = [[m11, m12, 0], [m21, m22, 0], [dx, dy, 1]];
  7251. setM(this, m, true);
  7252. };
  7253. contextPrototype.drawText_ = function(text, x, y, maxWidth, stroke) {
  7254. var m = this.m_, delta = 1000, left = 0, right = delta, offset = {x:0, y:0}, lineStr = [];
  7255. var fontStyle = getComputedStyle(processFontStyle(this.font), this.element_);
  7256. var fontStyleString = buildStyle(fontStyle);
  7257. var elementStyle = this.element_.currentStyle;
  7258. var textAlign = this.textAlign.toLowerCase();
  7259. switch(textAlign) {
  7260. case 'left':
  7261. case 'center':
  7262. case 'right':
  7263. break;
  7264. case 'end':
  7265. textAlign = elementStyle.direction == 'ltr' ? 'right' : 'left';
  7266. break;
  7267. case 'start':
  7268. textAlign = elementStyle.direction == 'rtl' ? 'right' : 'left';
  7269. break;
  7270. default:
  7271. textAlign = 'left';
  7272. }
  7273. switch(this.textBaseline) {
  7274. case 'hanging':
  7275. case 'top':
  7276. offset.y = fontStyle.size / 1.75;
  7277. break;
  7278. case 'middle':
  7279. break;
  7280. default:
  7281. case null:
  7282. case 'alphabetic':
  7283. case 'ideographic':
  7284. case 'bottom':
  7285. offset.y = -fontStyle.size / 3;
  7286. break;
  7287. }
  7288. switch(textAlign) {
  7289. case 'right':
  7290. left = delta;
  7291. right = 0.05;
  7292. break;
  7293. case 'center':
  7294. left = right = delta / 2;
  7295. break;
  7296. }
  7297. var d = getCoords(this, x + offset.x, y + offset.y);
  7298. lineStr.push('\x3cg_vml_:line from\x3d"', -left, ' 0" to\x3d"', right, ' 0.05" ', ' coordsize\x3d"100 100" coordorigin\x3d"0 0"', ' filled\x3d"', !stroke, '" stroked\x3d"', !!stroke, '" style\x3d"position:absolute;width:1px;height:1px;left:0px;top:0px;"\x3e');
  7299. if (stroke) {
  7300. appendStroke(this, lineStr);
  7301. } else {
  7302. appendFill(this, lineStr, {x:-left, y:0}, {x:right, y:fontStyle.size});
  7303. }
  7304. var skewM = m[0][0].toFixed(3) + ',' + m[1][0].toFixed(3) + ',' + m[0][1].toFixed(3) + ',' + m[1][1].toFixed(3) + ',0,0';
  7305. var skewOffset = mr(d.x / Z) + ',' + mr(d.y / Z);
  7306. lineStr.push('\x3cg_vml_:skew on\x3d"t" matrix\x3d"', skewM, '" ', ' offset\x3d"', skewOffset, '" origin\x3d"', left, ' 0" /\x3e', '\x3cg_vml_:path textpathok\x3d"true" /\x3e', '\x3cg_vml_:textpath on\x3d"true" string\x3d"', encodeHtmlAttribute(text), '" style\x3d"v-text-align:', textAlign, ';font:', encodeHtmlAttribute(fontStyleString), '" /\x3e\x3c/g_vml_:line\x3e');
  7307. this.element_.insertAdjacentHTML('beforeEnd', lineStr.join(''));
  7308. };
  7309. contextPrototype.fillText = function(text, x, y, maxWidth) {
  7310. this.drawText_(text, x, y, maxWidth, false);
  7311. };
  7312. contextPrototype.strokeText = function(text, x, y, maxWidth) {
  7313. this.drawText_(text, x, y, maxWidth, true);
  7314. };
  7315. contextPrototype.measureText = function(text) {
  7316. if (!this.textMeasureEl_) {
  7317. var s = '\x3cspan style\x3d"position:absolute;' + 'top:-20000px;left:0;padding:0;margin:0;border:none;' + 'white-space:pre;"\x3e\x3c/span\x3e';
  7318. this.element_.insertAdjacentHTML('beforeEnd', s);
  7319. this.textMeasureEl_ = this.element_.lastChild;
  7320. }
  7321. var doc = this.element_.ownerDocument;
  7322. this.textMeasureEl_.innerHTML = '';
  7323. this.textMeasureEl_.style.font = this.font;
  7324. this.textMeasureEl_.appendChild(doc.createTextNode(text));
  7325. return {width:this.textMeasureEl_.offsetWidth};
  7326. };
  7327. contextPrototype.clip = function() {
  7328. };
  7329. contextPrototype.arcTo = function() {
  7330. };
  7331. contextPrototype.createPattern = function(image, repetition) {
  7332. return new CanvasPattern_(image, repetition);
  7333. };
  7334. function CanvasGradient_(aType) {
  7335. this.type_ = aType;
  7336. this.x0_ = 0;
  7337. this.y0_ = 0;
  7338. this.r0_ = 0;
  7339. this.x1_ = 0;
  7340. this.y1_ = 0;
  7341. this.r1_ = 0;
  7342. this.colors_ = [];
  7343. }
  7344. CanvasGradient_.prototype.addColorStop = function(aOffset, aColor) {
  7345. aColor = processStyle(aColor);
  7346. this.colors_.push({offset:aOffset, color:aColor.color, alpha:aColor.alpha});
  7347. };
  7348. function CanvasPattern_(image, repetition) {
  7349. assertImageIsValid(image);
  7350. switch(repetition) {
  7351. case 'repeat':
  7352. case null:
  7353. case '':
  7354. this.repetition_ = 'repeat';
  7355. break;
  7356. case 'repeat-x':
  7357. case 'repeat-y':
  7358. case 'no-repeat':
  7359. this.repetition_ = repetition;
  7360. break;
  7361. default:
  7362. throwException('SYNTAX_ERR');
  7363. }
  7364. this.src_ = image.src;
  7365. this.width_ = image.width;
  7366. this.height_ = image.height;
  7367. }
  7368. function throwException(s) {
  7369. throw new DOMException_(s);
  7370. }
  7371. function assertImageIsValid(img) {
  7372. if (!img || img.nodeType != 1 || img.tagName != 'IMG') {
  7373. throwException('TYPE_MISMATCH_ERR');
  7374. }
  7375. if (img.readyState != 'complete') {
  7376. throwException('INVALID_STATE_ERR');
  7377. }
  7378. }
  7379. function DOMException_(s) {
  7380. this.code = this[s];
  7381. this.message = s + ': DOM Exception ' + this.code;
  7382. }
  7383. var p = DOMException_.prototype = new Error;
  7384. p.INDEX_SIZE_ERR = 1;
  7385. p.DOMSTRING_SIZE_ERR = 2;
  7386. p.HIERARCHY_REQUEST_ERR = 3;
  7387. p.WRONG_DOCUMENT_ERR = 4;
  7388. p.INVALID_CHARACTER_ERR = 5;
  7389. p.NO_DATA_ALLOWED_ERR = 6;
  7390. p.NO_MODIFICATION_ALLOWED_ERR = 7;
  7391. p.NOT_FOUND_ERR = 8;
  7392. p.NOT_SUPPORTED_ERR = 9;
  7393. p.INUSE_ATTRIBUTE_ERR = 10;
  7394. p.INVALID_STATE_ERR = 11;
  7395. p.SYNTAX_ERR = 12;
  7396. p.INVALID_MODIFICATION_ERR = 13;
  7397. p.NAMESPACE_ERR = 14;
  7398. p.INVALID_ACCESS_ERR = 15;
  7399. p.VALIDATION_ERR = 16;
  7400. p.TYPE_MISMATCH_ERR = 17;
  7401. G_vmlCanvasManager = G_vmlCanvasManager_;
  7402. CanvasRenderingContext2D = CanvasRenderingContext2D_;
  7403. CanvasGradient = CanvasGradient_;
  7404. CanvasPattern = CanvasPattern_;
  7405. DOMException = DOMException_;
  7406. })();
  7407. }
  7408. Ext.define('Ext.draw.engine.Canvas', {extend:'Ext.draw.Surface', isCanvas:true, requires:['Ext.draw.engine.excanvas', 'Ext.draw.Animator', 'Ext.draw.Color'], config:{highPrecision:false}, statics:{contextOverrides:{setGradientBBox:function(bbox) {
  7409. this.bbox = bbox;
  7410. }, fill:function() {
  7411. var fillStyle = this.fillStyle, fillGradient = this.fillGradient, fillOpacity = this.fillOpacity, alpha = this.globalAlpha, bbox = this.bbox;
  7412. if (fillStyle !== Ext.util.Color.RGBA_NONE && fillOpacity !== 0) {
  7413. if (fillGradient && bbox) {
  7414. this.fillStyle = fillGradient.generateGradient(this, bbox);
  7415. }
  7416. if (fillOpacity !== 1) {
  7417. this.globalAlpha = alpha * fillOpacity;
  7418. }
  7419. this.$fill();
  7420. if (fillOpacity !== 1) {
  7421. this.globalAlpha = alpha;
  7422. }
  7423. if (fillGradient && bbox) {
  7424. this.fillStyle = fillStyle;
  7425. }
  7426. }
  7427. }, stroke:function() {
  7428. var strokeStyle = this.strokeStyle, strokeGradient = this.strokeGradient, strokeOpacity = this.strokeOpacity, alpha = this.globalAlpha, bbox = this.bbox;
  7429. if (strokeStyle !== Ext.util.Color.RGBA_NONE && strokeOpacity !== 0) {
  7430. if (strokeGradient && bbox) {
  7431. this.strokeStyle = strokeGradient.generateGradient(this, bbox);
  7432. }
  7433. if (strokeOpacity !== 1) {
  7434. this.globalAlpha = alpha * strokeOpacity;
  7435. }
  7436. this.$stroke();
  7437. if (strokeOpacity !== 1) {
  7438. this.globalAlpha = alpha;
  7439. }
  7440. if (strokeGradient && bbox) {
  7441. this.strokeStyle = strokeStyle;
  7442. }
  7443. }
  7444. }, fillStroke:function(attr, transformFillStroke) {
  7445. var ctx = this, fillStyle = this.fillStyle, fillOpacity = this.fillOpacity, strokeStyle = this.strokeStyle, strokeOpacity = this.strokeOpacity, shadowColor = ctx.shadowColor, shadowBlur = ctx.shadowBlur, none = Ext.util.Color.RGBA_NONE;
  7446. if (transformFillStroke === undefined) {
  7447. transformFillStroke = attr.transformFillStroke;
  7448. }
  7449. if (!transformFillStroke) {
  7450. attr.inverseMatrix.toContext(ctx);
  7451. }
  7452. if (fillStyle !== none && fillOpacity !== 0) {
  7453. ctx.fill();
  7454. ctx.shadowColor = none;
  7455. ctx.shadowBlur = 0;
  7456. }
  7457. if (strokeStyle !== none && strokeOpacity !== 0) {
  7458. ctx.stroke();
  7459. }
  7460. ctx.shadowColor = shadowColor;
  7461. ctx.shadowBlur = shadowBlur;
  7462. }, setLineDash:function(dashList) {
  7463. if (this.$setLineDash) {
  7464. this.$setLineDash(dashList);
  7465. }
  7466. }, getLineDash:function() {
  7467. if (this.$getLineDash) {
  7468. return this.$getLineDash();
  7469. }
  7470. }, ellipse:function(cx, cy, rx, ry, rotation, start, end, anticlockwise) {
  7471. var cos = Math.cos(rotation), sin = Math.sin(rotation);
  7472. this.transform(cos * rx, sin * rx, -sin * ry, cos * ry, cx, cy);
  7473. this.arc(0, 0, 1, start, end, anticlockwise);
  7474. this.transform(cos / rx, -sin / ry, sin / rx, cos / ry, -(cos * cx + sin * cy) / rx, (sin * cx - cos * cy) / ry);
  7475. }, appendPath:function(path) {
  7476. var me = this, i = 0, j = 0, commands = path.commands, params = path.params, ln = commands.length;
  7477. me.beginPath();
  7478. for (; i < ln; i++) {
  7479. switch(commands[i]) {
  7480. case 'M':
  7481. me.moveTo(params[j], params[j + 1]);
  7482. j += 2;
  7483. break;
  7484. case 'L':
  7485. me.lineTo(params[j], params[j + 1]);
  7486. j += 2;
  7487. break;
  7488. case 'C':
  7489. me.bezierCurveTo(params[j], params[j + 1], params[j + 2], params[j + 3], params[j + 4], params[j + 5]);
  7490. j += 6;
  7491. break;
  7492. case 'Z':
  7493. me.closePath();
  7494. break;
  7495. }
  7496. }
  7497. }, save:function() {
  7498. var toSave = this.toSave, ln = toSave.length, obj = ln && {}, i = 0, key;
  7499. for (; i < ln; i++) {
  7500. key = toSave[i];
  7501. if (key in this) {
  7502. obj[key] = this[key];
  7503. }
  7504. }
  7505. this.state.push(obj);
  7506. this.$save();
  7507. }, restore:function() {
  7508. var obj = this.state.pop(), key;
  7509. if (obj) {
  7510. for (key in obj) {
  7511. this[key] = obj[key];
  7512. }
  7513. }
  7514. this.$restore();
  7515. }}}, splitThreshold:3000, toSave:['fillGradient', 'strokeGradient'], element:{reference:'element', children:[{reference:'bodyElement', style:{width:'100%', height:'100%', position:'relative'}}]}, createCanvas:function() {
  7516. var canvas, overrides, ctx, name;
  7517. canvas = Ext.Element.create({tag:'canvas', cls:Ext.baseCSSPrefix + 'surface-canvas'});
  7518. if (window.G_vmlCanvasManager) {
  7519. G_vmlCanvasManager.initElement(canvas.dom);
  7520. this.isVML = true;
  7521. }
  7522. overrides = Ext.draw.engine.Canvas.contextOverrides;
  7523. ctx = canvas.dom.getContext('2d');
  7524. if (ctx.ellipse) {
  7525. delete overrides.ellipse;
  7526. }
  7527. ctx.state = [];
  7528. ctx.toSave = this.toSave;
  7529. for (name in overrides) {
  7530. ctx['$' + name] = ctx[name];
  7531. }
  7532. Ext.apply(ctx, overrides);
  7533. if (this.getHighPrecision()) {
  7534. this.enablePrecisionCompensation(ctx);
  7535. } else {
  7536. this.disablePrecisionCompensation(ctx);
  7537. }
  7538. this.bodyElement.appendChild(canvas);
  7539. this.canvases.push(canvas);
  7540. this.contexts.push(ctx);
  7541. }, updateHighPrecision:function(highPrecision) {
  7542. var contexts = this.contexts, ln = contexts.length, i, context;
  7543. for (i = 0; i < ln; i++) {
  7544. context = contexts[i];
  7545. if (highPrecision) {
  7546. this.enablePrecisionCompensation(context);
  7547. } else {
  7548. this.disablePrecisionCompensation(context);
  7549. }
  7550. }
  7551. }, precisionNames:['rect', 'fillRect', 'strokeRect', 'clearRect', 'moveTo', 'lineTo', 'arc', 'arcTo', 'save', 'restore', 'updatePrecisionCompensate', 'setTransform', 'transform', 'scale', 'translate', 'rotate', 'quadraticCurveTo', 'bezierCurveTo', 'createLinearGradient', 'createRadialGradient', 'fillText', 'strokeText', 'drawImage'], disablePrecisionCompensation:function(ctx) {
  7552. var regularOverrides = Ext.draw.engine.Canvas.contextOverrides, precisionOverrides = this.precisionNames, ln = precisionOverrides.length, i, name;
  7553. for (i = 0; i < ln; i++) {
  7554. name = precisionOverrides[i];
  7555. if (!(name in regularOverrides)) {
  7556. delete ctx[name];
  7557. }
  7558. }
  7559. this.setDirty(true);
  7560. }, enablePrecisionCompensation:function(ctx) {
  7561. var surface = this, xx = 1, yy = 1, dx = 0, dy = 0, matrix = new Ext.draw.Matrix, transStack = [], comp = {}, regularOverrides = Ext.draw.engine.Canvas.contextOverrides, originalCtx = ctx.constructor.prototype, precisionOverrides = {toSave:surface.toSave, rect:function(x, y, w, h) {
  7562. return originalCtx.rect.call(this, x * xx + dx, y * yy + dy, w * xx, h * yy);
  7563. }, fillRect:function(x, y, w, h) {
  7564. this.updatePrecisionCompensateRect();
  7565. originalCtx.fillRect.call(this, x * xx + dx, y * yy + dy, w * xx, h * yy);
  7566. this.updatePrecisionCompensate();
  7567. }, strokeRect:function(x, y, w, h) {
  7568. this.updatePrecisionCompensateRect();
  7569. originalCtx.strokeRect.call(this, x * xx + dx, y * yy + dy, w * xx, h * yy);
  7570. this.updatePrecisionCompensate();
  7571. }, clearRect:function(x, y, w, h) {
  7572. return originalCtx.clearRect.call(this, x * xx + dx, y * yy + dy, w * xx, h * yy);
  7573. }, moveTo:function(x, y) {
  7574. return originalCtx.moveTo.call(this, x * xx + dx, y * yy + dy);
  7575. }, lineTo:function(x, y) {
  7576. return originalCtx.lineTo.call(this, x * xx + dx, y * yy + dy);
  7577. }, arc:function(x, y, radius, startAngle, endAngle, anticlockwise) {
  7578. this.updatePrecisionCompensateRect();
  7579. originalCtx.arc.call(this, x * xx + dx, y * xx + dy, radius * xx, startAngle, endAngle, anticlockwise);
  7580. this.updatePrecisionCompensate();
  7581. }, arcTo:function(x1, y1, x2, y2, radius) {
  7582. this.updatePrecisionCompensateRect();
  7583. originalCtx.arcTo.call(this, x1 * xx + dx, y1 * yy + dy, x2 * xx + dx, y2 * yy + dy, radius * xx);
  7584. this.updatePrecisionCompensate();
  7585. }, save:function() {
  7586. transStack.push(matrix);
  7587. matrix = matrix.clone();
  7588. regularOverrides.save.call(this);
  7589. originalCtx.save.call(this);
  7590. }, restore:function() {
  7591. matrix = transStack.pop();
  7592. regularOverrides.restore.call(this);
  7593. originalCtx.restore.call(this);
  7594. this.updatePrecisionCompensate();
  7595. }, updatePrecisionCompensate:function() {
  7596. matrix.precisionCompensate(surface.devicePixelRatio, comp);
  7597. xx = comp.xx;
  7598. yy = comp.yy;
  7599. dx = comp.dx;
  7600. dy = comp.dy;
  7601. originalCtx.setTransform.call(this, surface.devicePixelRatio, comp.b, comp.c, comp.d, 0, 0);
  7602. }, updatePrecisionCompensateRect:function() {
  7603. matrix.precisionCompensateRect(surface.devicePixelRatio, comp);
  7604. xx = comp.xx;
  7605. yy = comp.yy;
  7606. dx = comp.dx;
  7607. dy = comp.dy;
  7608. originalCtx.setTransform.call(this, surface.devicePixelRatio, comp.b, comp.c, comp.d, 0, 0);
  7609. }, setTransform:function(x2x, x2y, y2x, y2y, newDx, newDy) {
  7610. matrix.set(x2x, x2y, y2x, y2y, newDx, newDy);
  7611. this.updatePrecisionCompensate();
  7612. }, transform:function(x2x, x2y, y2x, y2y, newDx, newDy) {
  7613. matrix.append(x2x, x2y, y2x, y2y, newDx, newDy);
  7614. this.updatePrecisionCompensate();
  7615. }, scale:function(sx, sy) {
  7616. this.transform(sx, 0, 0, sy, 0, 0);
  7617. }, translate:function(dx, dy) {
  7618. this.transform(1, 0, 0, 1, dx, dy);
  7619. }, rotate:function(radians) {
  7620. var cos = Math.cos(radians), sin = Math.sin(radians);
  7621. this.transform(cos, sin, -sin, cos, 0, 0);
  7622. }, quadraticCurveTo:function(cx, cy, x, y) {
  7623. originalCtx.quadraticCurveTo.call(this, cx * xx + dx, cy * yy + dy, x * xx + dx, y * yy + dy);
  7624. }, bezierCurveTo:function(c1x, c1y, c2x, c2y, x, y) {
  7625. originalCtx.bezierCurveTo.call(this, c1x * xx + dx, c1y * yy + dy, c2x * xx + dx, c2y * yy + dy, x * xx + dx, y * yy + dy);
  7626. }, createLinearGradient:function(x0, y0, x1, y1) {
  7627. var grad;
  7628. this.updatePrecisionCompensateRect();
  7629. grad = originalCtx.createLinearGradient.call(this, x0 * xx + dx, y0 * yy + dy, x1 * xx + dx, y1 * yy + dy);
  7630. this.updatePrecisionCompensate();
  7631. return grad;
  7632. }, createRadialGradient:function(x0, y0, r0, x1, y1, r1) {
  7633. var grad;
  7634. this.updatePrecisionCompensateRect();
  7635. grad = originalCtx.createLinearGradient.call(this, x0 * xx + dx, y0 * xx + dy, r0 * xx, x1 * xx + dx, y1 * xx + dy, r1 * xx);
  7636. this.updatePrecisionCompensate();
  7637. return grad;
  7638. }, fillText:function(text, x, y, maxWidth) {
  7639. originalCtx.setTransform.apply(this, matrix.elements);
  7640. if (typeof maxWidth === 'undefined') {
  7641. originalCtx.fillText.call(this, text, x, y);
  7642. } else {
  7643. originalCtx.fillText.call(this, text, x, y, maxWidth);
  7644. }
  7645. this.updatePrecisionCompensate();
  7646. }, strokeText:function(text, x, y, maxWidth) {
  7647. originalCtx.setTransform.apply(this, matrix.elements);
  7648. if (typeof maxWidth === 'undefined') {
  7649. originalCtx.strokeText.call(this, text, x, y);
  7650. } else {
  7651. originalCtx.strokeText.call(this, text, x, y, maxWidth);
  7652. }
  7653. this.updatePrecisionCompensate();
  7654. }, fill:function() {
  7655. var fillGradient = this.fillGradient, bbox = this.bbox;
  7656. this.updatePrecisionCompensateRect();
  7657. if (fillGradient && bbox) {
  7658. this.fillStyle = fillGradient.generateGradient(this, bbox);
  7659. }
  7660. originalCtx.fill.call(this);
  7661. this.updatePrecisionCompensate();
  7662. }, stroke:function() {
  7663. var strokeGradient = this.strokeGradient, bbox = this.bbox;
  7664. this.updatePrecisionCompensateRect();
  7665. if (strokeGradient && bbox) {
  7666. this.strokeStyle = strokeGradient.generateGradient(this, bbox);
  7667. }
  7668. originalCtx.stroke.call(this);
  7669. this.updatePrecisionCompensate();
  7670. }, drawImage:function(img_elem, arg1, arg2, arg3, arg4, dst_x, dst_y, dw, dh) {
  7671. switch(arguments.length) {
  7672. case 3:
  7673. return originalCtx.drawImage.call(this, img_elem, arg1 * xx + dx, arg2 * yy + dy);
  7674. case 5:
  7675. return originalCtx.drawImage.call(this, img_elem, arg1 * xx + dx, arg2 * yy + dy, arg3 * xx, arg4 * yy);
  7676. case 9:
  7677. return originalCtx.drawImage.call(this, img_elem, arg1, arg2, arg3, arg4, dst_x * xx + dx, dst_y * yy * dy, dw * xx, dh * yy);
  7678. }
  7679. }};
  7680. Ext.apply(ctx, precisionOverrides);
  7681. this.setDirty(true);
  7682. }, updateRect:function(rect) {
  7683. this.callParent([rect]);
  7684. var me = this, l = Math.floor(rect[0]), t = Math.floor(rect[1]), r = Math.ceil(rect[0] + rect[2]), b = Math.ceil(rect[1] + rect[3]), devicePixelRatio = me.devicePixelRatio, canvases = me.canvases, w = r - l, h = b - t, splitThreshold = Math.round(me.splitThreshold / devicePixelRatio), xSplits = me.xSplits = Math.ceil(w / splitThreshold), ySplits = me.ySplits = Math.ceil(h / splitThreshold), i, j, k, offsetX, offsetY, dom, width, height;
  7685. for (j = 0, offsetY = 0; j < ySplits; j++, offsetY += splitThreshold) {
  7686. for (i = 0, offsetX = 0; i < xSplits; i++, offsetX += splitThreshold) {
  7687. k = j * xSplits + i;
  7688. if (k >= canvases.length) {
  7689. me.createCanvas();
  7690. }
  7691. dom = canvases[k].dom;
  7692. dom.style.left = offsetX + 'px';
  7693. dom.style.top = offsetY + 'px';
  7694. height = Math.min(splitThreshold, h - offsetY);
  7695. if (height * devicePixelRatio !== dom.height) {
  7696. dom.height = height * devicePixelRatio;
  7697. dom.style.height = height + 'px';
  7698. }
  7699. width = Math.min(splitThreshold, w - offsetX);
  7700. if (width * devicePixelRatio !== dom.width) {
  7701. dom.width = width * devicePixelRatio;
  7702. dom.style.width = width + 'px';
  7703. }
  7704. me.applyDefaults(me.contexts[k]);
  7705. }
  7706. }
  7707. me.activeCanvases = k = xSplits * ySplits;
  7708. while (canvases.length > k) {
  7709. canvases.pop().destroy();
  7710. }
  7711. me.clear();
  7712. }, clearTransform:function() {
  7713. var me = this, xSplits = me.xSplits, ySplits = me.ySplits, contexts = me.contexts, splitThreshold = me.splitThreshold, devicePixelRatio = me.devicePixelRatio, i, j, k, ctx;
  7714. for (i = 0; i < xSplits; i++) {
  7715. for (j = 0; j < ySplits; j++) {
  7716. k = j * xSplits + i;
  7717. ctx = contexts[k];
  7718. ctx.translate(-splitThreshold * i, -splitThreshold * j);
  7719. ctx.scale(devicePixelRatio, devicePixelRatio);
  7720. me.matrix.toContext(ctx);
  7721. }
  7722. }
  7723. }, renderSprite:function(sprite) {
  7724. var me = this, rect = me.getRect(), surfaceMatrix = me.matrix, parent = sprite.getParent(), matrix = Ext.draw.Matrix.fly([1, 0, 0, 1, 0, 0]), splitThreshold = me.splitThreshold / me.devicePixelRatio, xSplits = me.xSplits, ySplits = me.ySplits, offsetX, offsetY, ctx, bbox, width, height, left = 0, right, top = 0, bottom, w = rect[2], h = rect[3], i, j, k;
  7725. while (parent && parent.isSprite) {
  7726. matrix.prependMatrix(parent.matrix || parent.attr && parent.attr.matrix);
  7727. parent = parent.getParent();
  7728. }
  7729. matrix.prependMatrix(surfaceMatrix);
  7730. bbox = sprite.getBBox();
  7731. if (bbox) {
  7732. bbox = matrix.transformBBox(bbox);
  7733. }
  7734. sprite.preRender(me);
  7735. if (sprite.attr.hidden || sprite.attr.globalAlpha === 0) {
  7736. sprite.setDirty(false);
  7737. return;
  7738. }
  7739. for (j = 0, offsetY = 0; j < ySplits; j++, offsetY += splitThreshold) {
  7740. for (i = 0, offsetX = 0; i < xSplits; i++, offsetX += splitThreshold) {
  7741. k = j * xSplits + i;
  7742. ctx = me.contexts[k];
  7743. width = Math.min(splitThreshold, w - offsetX);
  7744. height = Math.min(splitThreshold, h - offsetY);
  7745. left = offsetX;
  7746. right = left + width;
  7747. top = offsetY;
  7748. bottom = top + height;
  7749. if (bbox) {
  7750. if (bbox.x > right || bbox.x + bbox.width < left || bbox.y > bottom || bbox.y + bbox.height < top) {
  7751. continue;
  7752. }
  7753. }
  7754. ctx.save();
  7755. sprite.useAttributes(ctx, rect);
  7756. if (false === sprite.render(me, ctx, [left, top, width, height])) {
  7757. return false;
  7758. }
  7759. ctx.restore();
  7760. }
  7761. }
  7762. sprite.setDirty(false);
  7763. }, flatten:function(size, surfaces) {
  7764. var targetCanvas = document.createElement('canvas'), className = Ext.getClassName(this), ratio = this.devicePixelRatio, ctx = targetCanvas.getContext('2d'), surface, canvas, rect, i, j, xy;
  7765. targetCanvas.width = Math.ceil(size.width * ratio);
  7766. targetCanvas.height = Math.ceil(size.height * ratio);
  7767. for (i = 0; i < surfaces.length; i++) {
  7768. surface = surfaces[i];
  7769. if (Ext.getClassName(surface) !== className) {
  7770. continue;
  7771. }
  7772. rect = surface.getRect();
  7773. for (j = 0; j < surface.canvases.length; j++) {
  7774. canvas = surface.canvases[j];
  7775. xy = canvas.getOffsetsTo(canvas.getParent());
  7776. ctx.drawImage(canvas.dom, (rect[0] + xy[0]) * ratio, (rect[1] + xy[1]) * ratio);
  7777. }
  7778. }
  7779. return {data:targetCanvas.toDataURL(), type:'png'};
  7780. }, applyDefaults:function(ctx) {
  7781. var none = Ext.util.Color.RGBA_NONE;
  7782. ctx.strokeStyle = none;
  7783. ctx.fillStyle = none;
  7784. ctx.textAlign = 'start';
  7785. ctx.textBaseline = 'alphabetic';
  7786. ctx.miterLimit = 1;
  7787. }, clear:function() {
  7788. var me = this, activeCanvases = me.activeCanvases, i, canvas, ctx;
  7789. for (i = 0; i < activeCanvases; i++) {
  7790. canvas = me.canvases[i].dom;
  7791. ctx = me.contexts[i];
  7792. ctx.setTransform(1, 0, 0, 1, 0, 0);
  7793. ctx.clearRect(0, 0, canvas.width, canvas.height);
  7794. }
  7795. me.setDirty(true);
  7796. }, destroy:function() {
  7797. var me = this, canvases = me.canvases, ln = canvases.length, i;
  7798. for (i = 0; i < ln; i++) {
  7799. me.contexts[i] = null;
  7800. canvases[i].destroy();
  7801. canvases[i] = null;
  7802. }
  7803. me.contexts = me.canvases = null;
  7804. me.callParent();
  7805. }, privates:{initElement:function() {
  7806. var me = this;
  7807. me.callParent();
  7808. me.canvases = [];
  7809. me.contexts = [];
  7810. me.activeCanvases = me.xSplits = me.ySplits = 0;
  7811. }}}, function() {
  7812. var me = this, proto = me.prototype, splitThreshold = 1.0E10;
  7813. if (Ext.os.is.Android4 && Ext.browser.is.Chrome) {
  7814. splitThreshold = 3000;
  7815. } else {
  7816. if (Ext.is.iOS) {
  7817. splitThreshold = 2200;
  7818. }
  7819. }
  7820. proto.splitThreshold = splitThreshold;
  7821. });
  7822. Ext.define('Ext.draw.Container', {extend:'Ext.draw.ContainerBase', alternateClassName:'Ext.draw.Component', xtype:'draw', defaultType:'surface', isDrawContainer:true, requires:['Ext.draw.Surface', 'Ext.draw.engine.Svg', 'Ext.draw.engine.Canvas', 'Ext.draw.gradient.GradientDefinition'], engine:'Ext.draw.engine.Canvas', config:{cls:[Ext.baseCSSPrefix + 'draw-container', Ext.baseCSSPrefix + 'unselectable'], resizeHandler:null, sprites:null, gradients:[], downloadServerUrl:undefined, touchAction:{panX:false,
  7823. panY:false, pinchZoom:false, doubleTapZoom:false}, surfaceZIndexes:{main:1}}, defaultDownloadServerUrl:'http://svg.sencha.io', supportedFormats:['png', 'pdf', 'jpeg', 'gif'], supportedOptions:{version:Ext.isNumber, data:Ext.isString, format:function(format) {
  7824. return Ext.Array.indexOf(this.supportedFormats, format) >= 0;
  7825. }, filename:Ext.isString, width:Ext.isNumber, height:Ext.isNumber, scale:Ext.isNumber, pdf:Ext.isObject, jpeg:Ext.isObject}, initAnimator:function() {
  7826. this.frameCallbackId = Ext.draw.Animator.addFrameCallback('renderFrame', this);
  7827. }, applyDownloadServerUrl:function(url) {
  7828. var defaultUrl = this.defaultDownloadServerUrl;
  7829. if (!url) {
  7830. url = defaultUrl;
  7831. if (!window.jasmine) {
  7832. Ext.log.warn("Using Sencha's download server could expose your data and pose " + 'a security risk. Please see Ext.draw.Container#download method ' + 'docs for more info. (component id\x3d' + this.getId() + ')');
  7833. }
  7834. }
  7835. return url;
  7836. }, applyGradients:function(gradients) {
  7837. var result = [], i, n, gradient, offset;
  7838. if (!Ext.isArray(gradients)) {
  7839. return result;
  7840. }
  7841. for (i = 0, n = gradients.length; i < n; i++) {
  7842. gradient = gradients[i];
  7843. if (!Ext.isObject(gradient)) {
  7844. continue;
  7845. }
  7846. if (typeof gradient.type !== 'string') {
  7847. gradient.type = 'linear';
  7848. }
  7849. if (gradient.angle) {
  7850. gradient.degrees = gradient.angle;
  7851. delete gradient.angle;
  7852. }
  7853. if (Ext.isObject(gradient.stops)) {
  7854. gradient.stops = function(stops) {
  7855. var result = [], stop;
  7856. for (offset in stops) {
  7857. stop = stops[offset];
  7858. stop.offset = offset / 100;
  7859. result.push(stop);
  7860. }
  7861. return result;
  7862. }(gradient.stops);
  7863. }
  7864. result.push(gradient);
  7865. }
  7866. Ext.draw.gradient.GradientDefinition.add(result);
  7867. return result;
  7868. }, applySprites:function(sprites) {
  7869. var result, surface, sprite, i, ln;
  7870. if (!sprites) {
  7871. return;
  7872. }
  7873. sprites = Ext.Array.from(sprites);
  7874. result = [];
  7875. for (i = 0, ln = sprites.length; i < ln; i++) {
  7876. sprite = sprites[i];
  7877. surface = sprite.surface;
  7878. if (!(surface && surface.isSurface)) {
  7879. if (Ext.isString(surface)) {
  7880. surface = this.getSurface(surface);
  7881. delete sprite.surface;
  7882. } else {
  7883. surface = this.getSurface('main');
  7884. }
  7885. }
  7886. sprite = surface.add(sprite);
  7887. result.push(sprite);
  7888. }
  7889. return result;
  7890. }, resizeDelay:500, resizeTimerId:0, lastResizeTime:null, size:null, handleResize:function(size, instantly) {
  7891. var me = this, el = me.element, resizeHandler = me.getResizeHandler() || me.defaultResizeHandler, resizeDelay = me.resizeDelay, lastResizeTime = me.lastResizeTime, defer, result;
  7892. if (!el) {
  7893. return;
  7894. }
  7895. size = size || el.getSize();
  7896. if (!(size.width && size.height)) {
  7897. return;
  7898. }
  7899. me.size = size;
  7900. me.stopResizeTimer();
  7901. defer = !instantly && lastResizeTime && Ext.Date.now() - lastResizeTime < resizeDelay;
  7902. if (defer) {
  7903. me.resizeTimerId = Ext.defer(me.handleResize, resizeDelay, me, [size, true]);
  7904. return;
  7905. }
  7906. me.fireEvent('bodyresize', me, size);
  7907. Ext.callback(resizeHandler, null, [size], 0, me);
  7908. if (result !== false) {
  7909. me.renderFrame();
  7910. }
  7911. me.lastResizeTime = Ext.Date.now();
  7912. }, stopResizeTimer:function() {
  7913. if (this.resizeTimerId) {
  7914. Ext.undefer(this.resizeTimerId);
  7915. this.resizeTimerId = 0;
  7916. }
  7917. }, defaultResizeHandler:function(size) {
  7918. this.getItems().each(function(surface) {
  7919. surface.setRect([0, 0, size.width, size.height]);
  7920. });
  7921. }, getSurface:function(id, type) {
  7922. var me = this, surfaces = me.getItems(), oldCount = surfaces.getCount(), zIndexes = me.getSurfaceZIndexes(), surface;
  7923. id = id || 'main';
  7924. type = type || id;
  7925. surface = me.createSurface(id);
  7926. if (type in zIndexes) {
  7927. surface.element.setStyle('zIndex', zIndexes[type]);
  7928. }
  7929. if (surfaces.getCount() > oldCount) {
  7930. me.handleResize(null, true);
  7931. }
  7932. return surface;
  7933. }, createSurface:function(id) {
  7934. var me = this, surfaces = me.getItems(), surface;
  7935. id = this.getId() + '-' + (id || 'main');
  7936. surface = surfaces.get(id);
  7937. if (!surface) {
  7938. surface = me.add({xclass:me.engine, id:id});
  7939. }
  7940. return surface;
  7941. }, renderFrame:function() {
  7942. var me = this, surfaces = me.getItems(), i, ln, item;
  7943. for (i = 0, ln = surfaces.length; i < ln; i++) {
  7944. item = surfaces.items[i];
  7945. if (item.isSurface) {
  7946. item.renderFrame();
  7947. }
  7948. }
  7949. }, getSurfaces:function(sort) {
  7950. var surfaces = Array.prototype.slice.call(this.items.items), zIndexes = this.getSurfaceZIndexes(), i, j, surface, zIndex;
  7951. if (sort) {
  7952. for (j = 1; j < surfaces.length; j++) {
  7953. surface = surfaces[j];
  7954. zIndex = zIndexes[surface.type];
  7955. i = j - 1;
  7956. while (i >= 0 && zIndexes[surfaces[i].type] > zIndex) {
  7957. surfaces[i + 1] = surfaces[i];
  7958. i--;
  7959. }
  7960. surfaces[i + 1] = surface;
  7961. }
  7962. }
  7963. return surfaces;
  7964. }, getImage:function(format) {
  7965. var size = this.bodyElement.getSize(), surfaces = this.getSurfaces(true), surface = surfaces[0], image, imageElement;
  7966. if ((Ext.isIE || Ext.isEdge) && surface.isSVG) {
  7967. image = {data:surface.toSVG(size, surfaces), type:'svg-markup'};
  7968. } else {
  7969. image = surface.flatten(size, surfaces);
  7970. if (format === 'image') {
  7971. imageElement = new Image;
  7972. imageElement.src = image.data;
  7973. image.data = imageElement;
  7974. return image;
  7975. }
  7976. if (format === 'stream') {
  7977. image.data = image.data.replace(/^data:image\/[^;]+/, 'data:application/octet-stream');
  7978. return image;
  7979. }
  7980. }
  7981. return image;
  7982. }, download:function(config) {
  7983. var me = this, inputs = [], markup, name, value;
  7984. if (Ext.isIE8) {
  7985. return false;
  7986. }
  7987. config = config || {};
  7988. config.version = 2;
  7989. if (!config.data) {
  7990. config.data = me.getImage().data;
  7991. }
  7992. for (name in config) {
  7993. if (config.hasOwnProperty(name)) {
  7994. value = config[name];
  7995. if (name in me.supportedOptions) {
  7996. if (me.supportedOptions[name].call(me, value)) {
  7997. inputs.push({tag:'input', type:'hidden', name:name, value:Ext.String.htmlEncode(Ext.isObject(value) ? Ext.JSON.encode(value) : value)});
  7998. } else {
  7999. Ext.log.error('Invalid value for image download option "' + name + '": ' + value);
  8000. }
  8001. } else {
  8002. Ext.log.error('Invalid image download option: "' + name + '"');
  8003. }
  8004. }
  8005. }
  8006. markup = Ext.dom.Helper.markup({tag:'html', children:[{tag:'head'}, {tag:'body', children:[{tag:'form', method:'POST', action:config.url || me.getDownloadServerUrl(), children:inputs}, {tag:'script', type:'text/javascript', children:'document.getElementsByTagName("form")[0].submit();'}]}]});
  8007. window.open('', 'ImageDownload_' + Date.now()).document.write(markup);
  8008. }, doDestroy:function() {
  8009. var me = this, callbackId = me.frameCallbackId;
  8010. if (callbackId) {
  8011. Ext.draw.Animator.removeFrameCallback(callbackId);
  8012. }
  8013. me.stopResizeTimer();
  8014. me.callParent();
  8015. }}, function() {
  8016. if (location.search.match('svg')) {
  8017. Ext.draw.Container.prototype.engine = 'Ext.draw.engine.Svg';
  8018. } else {
  8019. if (Ext.os.is.BlackBerry && Ext.os.version.getMajor() === 10 || Ext.browser.is.AndroidStock4 && (Ext.os.version.getMinor() === 1 || Ext.os.version.getMinor() === 2 || Ext.os.version.getMinor() === 3)) {
  8020. Ext.draw.Container.prototype.engine = 'Ext.draw.engine.Svg';
  8021. }
  8022. }
  8023. });
  8024. Ext.define('Ext.chart.theme.BaseTheme', {defaultsDivCls:'x-root'});
  8025. Ext.define('Ext.chart.theme.Base', {extend:'Ext.chart.theme.BaseTheme', mixins:{factoryable:'Ext.mixin.Factoryable'}, requires:['Ext.draw.Color'], factoryConfig:{type:'chart.theme'}, isTheme:true, isBase:true, config:{baseColor:null, colors:undefined, gradients:null, chart:{defaults:{captions:{title:{docked:'top', padding:5, style:{textAlign:'center', fontFamily:'default', fontWeight:'500', fillStyle:'black', fontSize:'default*1.6'}}, subtitle:{docked:'top', style:{textAlign:'center', fontFamily:'default',
  8026. fontWeight:'normal', fillStyle:'black', fontSize:'default*1.3'}}, credits:{docked:'bottom', padding:5, style:{textAlign:'left', fontFamily:'default', fontWeight:'lighter', fillStyle:'black', fontSize:'default'}}}, background:'white'}}, axis:{defaults:{label:{x:0, y:0, textBaseline:'middle', textAlign:'center', fontSize:'default', fontFamily:'default', fontWeight:'default', fillStyle:'black'}, title:{fillStyle:'black', fontSize:'default*1.23', fontFamily:'default', fontWeight:'default'}, style:{strokeStyle:'black'},
  8027. grid:{strokeStyle:'rgb(221, 221, 221)'}}, top:{style:{textPadding:5}}, bottom:{style:{textPadding:5}}}, series:{defaults:{label:{fillStyle:'black', strokeStyle:'none', fontFamily:'default', fontWeight:'default', fontSize:'default*1.077', textBaseline:'middle', textAlign:'center'}, labelOverflowPadding:5}}, sprites:{text:{fontSize:'default', fontWeight:'default', fontFamily:'default', fillStyle:'black'}}, legend:{label:{fontSize:14, fontWeight:'default', fontFamily:'default', fillStyle:'black'}, border:{lineWidth:1,
  8028. radius:4, fillStyle:'none', strokeStyle:'gray'}, background:'white'}, seriesThemes:undefined, markerThemes:{type:['circle', 'cross', 'plus', 'square', 'triangle', 'diamond']}, useGradients:false, background:null}, colorDefaults:['#94ae0a', '#115fa6', '#a61120', '#ff8809', '#ffd13e', '#a61187', '#24ad9a', '#7c7474', '#a66111'], constructor:function(config) {
  8029. this.initConfig(config);
  8030. this.resolveDefaults();
  8031. }, defaultRegEx:/^default([+\-/*]\d+(?:\.\d+)?)?$/, defaultOperators:{'*':function(v1, v2) {
  8032. return v1 * v2;
  8033. }, '+':function(v1, v2) {
  8034. return v1 + v2;
  8035. }, '-':function(v1, v2) {
  8036. return v1 - v2;
  8037. }}, resolveChartDefaults:function() {
  8038. var chart = Ext.clone(this.getChart()), chartType, captionName, chartConfig, captionConfig;
  8039. for (chartType in chart) {
  8040. chartConfig = chart[chartType];
  8041. if ('captions' in chartConfig) {
  8042. for (captionName in chartConfig.captions) {
  8043. captionConfig = chartConfig.captions[captionName];
  8044. if (captionConfig) {
  8045. this.replaceDefaults(captionConfig.style);
  8046. }
  8047. }
  8048. }
  8049. }
  8050. this.setChart(chart);
  8051. }, resolveDefaults:function() {
  8052. var me = this;
  8053. Ext.onInternalReady(function() {
  8054. var sprites = Ext.clone(me.getSprites()), legend = Ext.clone(me.getLegend()), axis = Ext.clone(me.getAxis()), series = Ext.clone(me.getSeries()), div, key, config;
  8055. if (!me.superclass.defaults) {
  8056. div = Ext.getBody().createChild({tag:'div', cls:me.defaultsDivCls});
  8057. me.superclass.defaults = {fontFamily:div.getStyle('fontFamily'), fontWeight:div.getStyle('fontWeight'), fontSize:parseFloat(div.getStyle('fontSize')), fontVariant:div.getStyle('fontVariant'), fontStyle:div.getStyle('fontStyle')};
  8058. div.destroy();
  8059. }
  8060. me.resolveChartDefaults();
  8061. me.replaceDefaults(sprites.text);
  8062. me.setSprites(sprites);
  8063. me.replaceDefaults(legend.label);
  8064. me.setLegend(legend);
  8065. for (key in axis) {
  8066. config = axis[key];
  8067. me.replaceDefaults(config.label);
  8068. me.replaceDefaults(config.title);
  8069. }
  8070. me.setAxis(axis);
  8071. for (key in series) {
  8072. config = series[key];
  8073. me.replaceDefaults(config.label);
  8074. }
  8075. me.setSeries(series);
  8076. });
  8077. }, replaceDefaults:function(target) {
  8078. var me = this, defaults = me.superclass.defaults, defaultRegEx = me.defaultRegEx, key, value, match, binaryFn;
  8079. if (Ext.isObject(target)) {
  8080. for (key in defaults) {
  8081. match = defaultRegEx.exec(target[key]);
  8082. if (match) {
  8083. value = defaults[key];
  8084. match = match[1];
  8085. if (match) {
  8086. binaryFn = me.defaultOperators[match.charAt(0)];
  8087. value = Math.round(binaryFn(value, parseFloat(match.substr(1))));
  8088. }
  8089. target[key] = value;
  8090. }
  8091. }
  8092. }
  8093. }, applyBaseColor:function(baseColor) {
  8094. var midColor, midL;
  8095. if (baseColor) {
  8096. midColor = baseColor.isColor ? baseColor : Ext.util.Color.fromString(baseColor);
  8097. midL = midColor.getHSL()[2];
  8098. if (midL < 0.15) {
  8099. midColor = midColor.createLighter(0.3);
  8100. } else {
  8101. if (midL < 0.3) {
  8102. midColor = midColor.createLighter(0.15);
  8103. } else {
  8104. if (midL > 0.85) {
  8105. midColor = midColor.createDarker(0.3);
  8106. } else {
  8107. if (midL > 0.7) {
  8108. midColor = midColor.createDarker(0.15);
  8109. }
  8110. }
  8111. }
  8112. }
  8113. this.setColors([midColor.createDarker(0.3).toString(), midColor.createDarker(0.15).toString(), midColor.toString(), midColor.createLighter(0.12).toString(), midColor.createLighter(0.24).toString(), midColor.createLighter(0.31).toString()]);
  8114. }
  8115. return baseColor;
  8116. }, applyColors:function(newColors) {
  8117. return newColors || this.colorDefaults;
  8118. }, updateUseGradients:function(useGradients) {
  8119. if (useGradients) {
  8120. this.updateGradients({type:'linear', degrees:90});
  8121. }
  8122. }, updateBackground:function(background) {
  8123. var chart;
  8124. if (background) {
  8125. chart = this.getChart();
  8126. chart.defaults.background = background;
  8127. this.setChart(chart);
  8128. }
  8129. }, updateGradients:function(gradients) {
  8130. var colors = this.getColors(), items = [], gradient, midColor, color, i, ln;
  8131. if (Ext.isObject(gradients)) {
  8132. for (i = 0, ln = colors && colors.length || 0; i < ln; i++) {
  8133. midColor = Ext.util.Color.fromString(colors[i]);
  8134. if (midColor) {
  8135. color = midColor.createLighter(0.15).toString();
  8136. gradient = Ext.apply(Ext.Object.chain(gradients), {stops:[{offset:1, color:midColor.toString()}, {offset:0, color:color.toString()}]});
  8137. items.push(gradient);
  8138. }
  8139. }
  8140. this.setColors(items);
  8141. }
  8142. }, applySeriesThemes:function(newSeriesThemes) {
  8143. var colors, color;
  8144. this.getBaseColor();
  8145. this.getUseGradients();
  8146. this.getGradients();
  8147. colors = this.getColors();
  8148. if (!newSeriesThemes) {
  8149. newSeriesThemes = {fillStyle:Ext.Array.clone(colors), strokeStyle:Ext.Array.map(colors, function(value) {
  8150. color = Ext.util.Color.fromString(value.stops ? value.stops[0].color : value);
  8151. return color.createDarker(0.15).toString();
  8152. })};
  8153. }
  8154. return newSeriesThemes;
  8155. }});
  8156. Ext.define('Ext.chart.theme.Default', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.default', 'chart.theme.Default', 'chart.theme.Base']});
  8157. Ext.define('Ext.chart.Util', {singleton:true, expandRange:function(range, data) {
  8158. var length = data.length, min = range[0], max = range[1], i, value;
  8159. for (i = 0; i < length; i++) {
  8160. value = data[i];
  8161. if (value == null || !isFinite(value)) {
  8162. continue;
  8163. }
  8164. if (value < min || !isFinite(min)) {
  8165. min = value;
  8166. }
  8167. if (value > max || !isFinite(max)) {
  8168. max = value;
  8169. }
  8170. }
  8171. range[0] = min;
  8172. range[1] = max;
  8173. }, defaultRange:[0, 1], validateRange:function(range, defaultRange, padding) {
  8174. var isFin0, isFin1;
  8175. defaultRange = defaultRange || this.defaultRange.slice();
  8176. if (!(padding === 0 || padding > 0)) {
  8177. padding = 0.5;
  8178. }
  8179. if (!range || range.length !== 2) {
  8180. return defaultRange;
  8181. }
  8182. range = [range[0], range[1]];
  8183. if (!range[0]) {
  8184. range[0] = 0;
  8185. }
  8186. if (!range[1]) {
  8187. range[1] = 0;
  8188. }
  8189. if (padding && range[0] === range[1]) {
  8190. range = [range[0] - padding, range[0] + padding];
  8191. if (range[0] === range[1]) {
  8192. return defaultRange;
  8193. }
  8194. }
  8195. isFin0 = isFinite(range[0]);
  8196. isFin1 = isFinite(range[1]);
  8197. if (!isFin0 && !isFin1) {
  8198. return defaultRange;
  8199. }
  8200. if (isFin0 && !isFin1) {
  8201. range[1] = range[0] + Ext.Number.sign(range[1]) * (defaultRange[1] - defaultRange[0]);
  8202. } else {
  8203. if (isFin1 && !isFin0) {
  8204. range[0] = range[1] + Ext.Number.sign(range[0]) * (defaultRange[1] - defaultRange[0]);
  8205. }
  8206. }
  8207. return [Math.min(range[0], range[1]), Math.max(range[0], range[1])];
  8208. }, applyAnimation:function(animation, oldAnimation) {
  8209. if (!animation) {
  8210. animation = {duration:0};
  8211. } else {
  8212. if (animation === true) {
  8213. animation = {easing:'easeInOut', duration:500};
  8214. }
  8215. }
  8216. return oldAnimation ? Ext.apply({}, animation, oldAnimation) : animation;
  8217. }});
  8218. Ext.define('Ext.chart.Markers', {extend:'Ext.draw.sprite.Instancing', isMarkers:true, defaultCategory:'default', constructor:function() {
  8219. this.callParent(arguments);
  8220. this.categories = {};
  8221. this.revisions = {};
  8222. }, destroy:function() {
  8223. this.categories = null;
  8224. this.revisions = null;
  8225. this.callParent();
  8226. }, getMarkerFor:function(category, index) {
  8227. var categoryInstances;
  8228. if (category in this.categories) {
  8229. categoryInstances = this.categories[category];
  8230. if (index in categoryInstances) {
  8231. return this.get(categoryInstances[index]);
  8232. }
  8233. }
  8234. }, clear:function(category) {
  8235. category = category || this.defaultCategory;
  8236. if (!(category in this.revisions)) {
  8237. this.revisions[category] = 1;
  8238. } else {
  8239. this.revisions[category]++;
  8240. }
  8241. }, clearAll:function() {
  8242. this.callParent();
  8243. this.categories = {};
  8244. this.revisions = {};
  8245. }, putMarkerFor:function(category, attr, index, bypassNormalization, keepRevision) {
  8246. var me = this, categoryInstances, instance;
  8247. category = category || this.defaultCategory;
  8248. categoryInstances = me.categories[category] || (me.categories[category] = {});
  8249. if (index in categoryInstances) {
  8250. me.setAttributesFor(categoryInstances[index], attr, bypassNormalization);
  8251. } else {
  8252. categoryInstances[index] = me.getCount();
  8253. me.add(attr, bypassNormalization);
  8254. }
  8255. instance = me.get(categoryInstances[index]);
  8256. if (instance) {
  8257. instance.category = category;
  8258. if (!keepRevision) {
  8259. instance.revision = me.revisions[category] || (me.revisions[category] = 1);
  8260. }
  8261. }
  8262. }, getMarkerBBoxFor:function(category, index, isWithoutTransform) {
  8263. var categoryInstances;
  8264. if (category in this.categories) {
  8265. categoryInstances = this.categories[category];
  8266. if (index in categoryInstances) {
  8267. return this.getBBoxFor(categoryInstances[index], isWithoutTransform);
  8268. }
  8269. }
  8270. }, getBBox:function() {
  8271. return null;
  8272. }, render:function(surface, ctx, rect) {
  8273. var me = this, surfaceRect = surface.getRect(), revisions = me.revisions, mat = me.attr.matrix, template = me.getTemplate(), templateAttr = template.attr, ln = me.instances.length, instance, i;
  8274. mat.toContext(ctx);
  8275. template.preRender(surface, ctx, rect);
  8276. template.useAttributes(ctx, surfaceRect);
  8277. for (i = 0; i < ln; i++) {
  8278. instance = me.get(i);
  8279. if (instance.hidden || instance.revision !== revisions[instance.category]) {
  8280. continue;
  8281. }
  8282. ctx.save();
  8283. template.attr = instance;
  8284. template.useAttributes(ctx, surfaceRect);
  8285. template.render(surface, ctx, rect);
  8286. ctx.restore();
  8287. }
  8288. template.attr = templateAttr;
  8289. }});
  8290. Ext.define('Ext.chart.modifier.Callout', {extend:'Ext.draw.modifier.Modifier', alternateClassName:'Ext.chart.label.Callout', prepareAttributes:function(attr) {
  8291. if (!attr.hasOwnProperty('calloutOriginal')) {
  8292. attr.calloutOriginal = Ext.Object.chain(attr);
  8293. attr.calloutOriginal.prototype = attr;
  8294. }
  8295. if (this._lower) {
  8296. this._lower.prepareAttributes(attr.calloutOriginal);
  8297. }
  8298. }, setAttrs:function(attr, changes) {
  8299. var callout = attr.callout, origin = attr.calloutOriginal, bbox = attr.bbox.plain, width = (bbox.width || 0) + attr.labelOverflowPadding, height = (bbox.height || 0) + attr.labelOverflowPadding, dx, dy, rotationRads, x, y, calloutPlaceX, calloutPlaceY, calloutVertical, temp;
  8300. if ('callout' in changes) {
  8301. callout = changes.callout;
  8302. }
  8303. if ('callout' in changes || 'calloutPlaceX' in changes || 'calloutPlaceY' in changes || 'x' in changes || 'y' in changes) {
  8304. rotationRads = 'rotationRads' in changes ? origin.rotationRads = changes.rotationRads : origin.rotationRads;
  8305. x = 'x' in changes ? origin.x = changes.x : origin.x;
  8306. y = 'y' in changes ? origin.y = changes.y : origin.y;
  8307. calloutPlaceX = 'calloutPlaceX' in changes ? changes.calloutPlaceX : attr.calloutPlaceX;
  8308. calloutPlaceY = 'calloutPlaceY' in changes ? changes.calloutPlaceY : attr.calloutPlaceY;
  8309. calloutVertical = 'calloutVertical' in changes ? changes.calloutVertical : attr.calloutVertical;
  8310. rotationRads %= Math.PI * 2;
  8311. if (Math.cos(rotationRads) < 0) {
  8312. rotationRads = (rotationRads + Math.PI) % (Math.PI * 2);
  8313. }
  8314. if (rotationRads > Math.PI) {
  8315. rotationRads -= Math.PI * 2;
  8316. }
  8317. if (calloutVertical) {
  8318. rotationRads = rotationRads * (1 - callout) - Math.PI / 2 * callout;
  8319. temp = width;
  8320. width = height;
  8321. height = temp;
  8322. } else {
  8323. rotationRads = rotationRads * (1 - callout);
  8324. }
  8325. changes.rotationRads = rotationRads;
  8326. changes.x = x * (1 - callout) + calloutPlaceX * callout;
  8327. changes.y = y * (1 - callout) + calloutPlaceY * callout;
  8328. dx = calloutPlaceX - x;
  8329. dy = calloutPlaceY - y;
  8330. if (Math.abs(dy * width) > Math.abs(dx * height)) {
  8331. if (dy > 0) {
  8332. changes.calloutEndX = changes.x - height / 2 * (dx / dy) * callout;
  8333. changes.calloutEndY = changes.y - height / 2 * callout;
  8334. } else {
  8335. changes.calloutEndX = changes.x + height / 2 * (dx / dy) * callout;
  8336. changes.calloutEndY = changes.y + height / 2 * callout;
  8337. }
  8338. } else {
  8339. if (dx > 0) {
  8340. changes.calloutEndX = changes.x - width / 2;
  8341. changes.calloutEndY = changes.y - width / 2 * (dy / dx) * callout;
  8342. } else {
  8343. changes.calloutEndX = changes.x + width / 2;
  8344. changes.calloutEndY = changes.y + width / 2 * (dy / dx) * callout;
  8345. }
  8346. }
  8347. if (changes.calloutStartX && changes.calloutStartY) {
  8348. changes.calloutHasLine = dx > 0 && changes.calloutStartX < changes.calloutEndX || dx <= 0 && changes.calloutStartX > changes.calloutEndX || dy > 0 && changes.calloutStartY < changes.calloutEndY || dy <= 0 && changes.calloutStartY > changes.calloutEndY;
  8349. } else {
  8350. changes.calloutHasLine = true;
  8351. }
  8352. }
  8353. return changes;
  8354. }, pushDown:function(attr, changes) {
  8355. changes = this.callParent([attr.calloutOriginal, changes]);
  8356. return this.setAttrs(attr, changes);
  8357. }, popUp:function(attr, changes) {
  8358. attr = attr.prototype;
  8359. changes = this.setAttrs(attr, changes);
  8360. if (this._upper) {
  8361. return this._upper.popUp(attr, changes);
  8362. } else {
  8363. return Ext.apply(attr, changes);
  8364. }
  8365. }});
  8366. Ext.define('Ext.chart.sprite.Label', {extend:'Ext.draw.sprite.Text', alternateClassName:'Ext.chart.label.Label', requires:['Ext.chart.modifier.Callout'], inheritableStatics:{def:{processors:{callout:'limited01', calloutHasLine:'bool', calloutPlaceX:'number', calloutPlaceY:'number', calloutStartX:'number', calloutStartY:'number', calloutEndX:'number', calloutEndY:'number', calloutColor:'color', calloutWidth:'number', calloutVertical:'bool', labelOverflowPadding:'number', display:'enums(none,under,over,rotate,insideStart,insideEnd,inside,outside)',
  8367. orientation:'enums(horizontal,vertical)', renderer:'default'}, defaults:{callout:0, calloutHasLine:true, calloutPlaceX:0, calloutPlaceY:0, calloutStartX:0, calloutStartY:0, calloutEndX:0, calloutEndY:0, calloutWidth:1, calloutVertical:false, calloutColor:'black', labelOverflowPadding:5, display:'none', orientation:'', renderer:null}, triggers:{callout:'transform', calloutPlaceX:'transform', calloutPlaceY:'transform', labelOverflowPadding:'transform', calloutRotation:'transform', display:'hidden'},
  8368. updaters:{hidden:function(attr) {
  8369. attr.hidden = attr.display === 'none';
  8370. }}}}, config:{animation:{customDurations:{callout:200}}, field:null, calloutLine:true, hideLessThan:20}, applyCalloutLine:function(calloutLine) {
  8371. if (calloutLine) {
  8372. return Ext.apply({}, calloutLine);
  8373. }
  8374. return calloutLine;
  8375. }, createModifiers:function() {
  8376. var me = this, mods = me.callParent(arguments);
  8377. mods.callout = new Ext.chart.modifier.Callout({sprite:me});
  8378. mods.animation.setUpper(mods.callout);
  8379. mods.callout.setUpper(mods.target);
  8380. }, render:function(surface, ctx) {
  8381. var me = this, attr = me.attr, calloutColor = attr.calloutColor;
  8382. ctx.save();
  8383. ctx.globalAlpha *= attr.callout;
  8384. if (ctx.globalAlpha > 0 && attr.calloutHasLine) {
  8385. if (calloutColor && calloutColor.isGradient) {
  8386. calloutColor = calloutColor.getStops()[0].color;
  8387. }
  8388. ctx.strokeStyle = calloutColor;
  8389. ctx.fillStyle = calloutColor;
  8390. ctx.lineWidth = attr.calloutWidth;
  8391. ctx.beginPath();
  8392. ctx.moveTo(me.attr.calloutStartX, me.attr.calloutStartY);
  8393. ctx.lineTo(me.attr.calloutEndX, me.attr.calloutEndY);
  8394. ctx.stroke();
  8395. ctx.beginPath();
  8396. ctx.arc(me.attr.calloutStartX, me.attr.calloutStartY, 1 * attr.calloutWidth, 0, 2 * Math.PI, true);
  8397. ctx.fill();
  8398. ctx.beginPath();
  8399. ctx.arc(me.attr.calloutEndX, me.attr.calloutEndY, 1 * attr.calloutWidth, 0, 2 * Math.PI, true);
  8400. ctx.fill();
  8401. }
  8402. ctx.restore();
  8403. Ext.draw.sprite.Text.prototype.render.apply(me, arguments);
  8404. }});
  8405. Ext.define('Ext.chart.series.Series', {requires:['Ext.chart.Util', 'Ext.chart.Markers', 'Ext.chart.sprite.Label', 'Ext.tip.ToolTip'], mixins:['Ext.mixin.Observable', 'Ext.mixin.Bindable'], isSeries:true, defaultBindProperty:'store', type:null, seriesType:'sprite', identifiablePrefix:'ext-line-', observableType:'series', darkerStrokeRatio:0.15, config:{chart:null, title:null, renderer:null, showInLegend:true, triggerAfterDraw:false, theme:null, style:{}, subStyle:{}, themeStyle:{}, colors:null, useDarkerStrokeColor:true,
  8406. store:null, label:null, labelOverflowPadding:null, showMarkers:true, marker:null, markerSubStyle:null, itemInstancing:null, background:null, surface:null, overlaySurface:null, hidden:false, highlight:false, highlightCfg:{merge:function(value) {
  8407. return value;
  8408. }, $value:{fillStyle:'yellow', strokeStyle:'red'}}, animation:null, tooltip:null}, directions:[], sprites:null, themeColorCount:function() {
  8409. return 1;
  8410. }, isStoreDependantColorCount:false, themeMarkerCount:function() {
  8411. return 0;
  8412. }, getFields:function(fieldCategory) {
  8413. var me = this, fields = [], ln = fieldCategory.length, i, field;
  8414. for (i = 0; i < ln; i++) {
  8415. field = me['get' + fieldCategory[i] + 'Field']();
  8416. if (Ext.isArray(field)) {
  8417. fields.push.apply(fields, field);
  8418. } else {
  8419. fields.push(field);
  8420. }
  8421. }
  8422. return fields;
  8423. }, applyAnimation:function(animation, oldAnimation) {
  8424. var chart = this.getChart();
  8425. if (!chart.isSettingSeriesAnimation) {
  8426. this.isUserAnimation = true;
  8427. }
  8428. return Ext.chart.Util.applyAnimation(animation, oldAnimation);
  8429. }, updateAnimation:function(animation) {
  8430. var sprites = this.getSprites(), itemsMarker, markersMarker, i, ln, sprite;
  8431. for (i = 0, ln = sprites.length; i < ln; i++) {
  8432. sprite = sprites[i];
  8433. if (sprite.isMarkerHolder) {
  8434. itemsMarker = sprite.getMarker('items');
  8435. if (itemsMarker) {
  8436. itemsMarker.getTemplate().setAnimation(animation);
  8437. }
  8438. markersMarker = sprite.getMarker('markers');
  8439. if (markersMarker) {
  8440. markersMarker.getTemplate().setAnimation(animation);
  8441. }
  8442. }
  8443. sprite.setAnimation(animation);
  8444. }
  8445. }, getAnimation:function() {
  8446. var chart = this.getChart(), animation;
  8447. if (chart && chart.animationSuspendCount) {
  8448. animation = {duration:0};
  8449. } else {
  8450. if (this.isUserAnimation) {
  8451. animation = this.callParent();
  8452. } else {
  8453. animation = chart.getAnimation();
  8454. }
  8455. }
  8456. return animation;
  8457. }, updateTitle:function() {
  8458. var me = this, chart = me.getChart();
  8459. if (chart && !chart.isInitializing) {
  8460. chart.refreshLegendStore();
  8461. }
  8462. }, applyHighlight:function(highlight, oldHighlight) {
  8463. var me = this, highlightCfg = me.getHighlightCfg();
  8464. if (Ext.isObject(highlight)) {
  8465. highlight = Ext.merge({}, highlightCfg, highlight);
  8466. } else {
  8467. if (highlight === true) {
  8468. highlight = highlightCfg;
  8469. }
  8470. }
  8471. if (highlight) {
  8472. highlight.type = 'highlight';
  8473. }
  8474. return highlight && Ext.merge({}, oldHighlight, highlight);
  8475. }, updateHighlight:function(highlight) {
  8476. var me = this, sprites = me.sprites, highlightCfg = me.getHighlightCfg(), i, ln, sprite, items, markers;
  8477. me.getStyle();
  8478. me.getMarker();
  8479. if (!Ext.Object.isEmpty(highlight)) {
  8480. me.addItemHighlight();
  8481. for (i = 0, ln = sprites.length; i < ln; i++) {
  8482. sprite = sprites[i];
  8483. if (sprite.isMarkerHolder) {
  8484. items = sprite.getMarker('items');
  8485. if (items) {
  8486. items.getTemplate().modifiers.highlight.setStyle(highlight);
  8487. }
  8488. markers = sprite.getMarker('markers');
  8489. if (markers) {
  8490. markers.getTemplate().modifiers.highlight.setStyle(highlight);
  8491. }
  8492. }
  8493. }
  8494. } else {
  8495. if (!Ext.Object.equals(highlightCfg, this.defaultConfig.highlightCfg)) {
  8496. this.addItemHighlight();
  8497. }
  8498. }
  8499. }, updateHighlightCfg:function(highlightCfg) {
  8500. if (!this.isConfiguring && !Ext.Object.equals(highlightCfg, this.defaultConfig.highlightCfg)) {
  8501. this.addItemHighlight();
  8502. }
  8503. }, applyItemInstancing:function(config, oldConfig) {
  8504. if (config && oldConfig && (!config.type || config.type === oldConfig.type)) {
  8505. config = Ext.merge({}, oldConfig, config);
  8506. }
  8507. if (config && !config.type) {
  8508. config = null;
  8509. }
  8510. return config;
  8511. }, setAttributesForItem:function(item, change) {
  8512. var sprite = item && item.sprite, i;
  8513. if (sprite) {
  8514. if (sprite.isMarkerHolder && item.category === 'items') {
  8515. sprite.putMarker(item.category, change, item.index, false, true);
  8516. }
  8517. if (sprite.isMarkerHolder && item.category === 'markers') {
  8518. sprite.putMarker(item.category, change, item.index, false, true);
  8519. } else {
  8520. if (sprite.isInstancing) {
  8521. sprite.setAttributesFor(item.index, change);
  8522. } else {
  8523. if (Ext.isArray(sprite)) {
  8524. for (i = 0; i < sprite.length; i++) {
  8525. sprite[i].setAttributes(change);
  8526. }
  8527. } else {
  8528. sprite.setAttributes(change);
  8529. }
  8530. }
  8531. }
  8532. }
  8533. }, getBBoxForItem:function(item) {
  8534. var sprite = item && item.sprite, result = null;
  8535. if (sprite) {
  8536. if (sprite.getMarker('items') && item.category === 'items') {
  8537. result = sprite.getMarkerBBox(item.category, item.index);
  8538. } else {
  8539. if (sprite instanceof Ext.draw.sprite.Instancing) {
  8540. result = sprite.getBBoxFor(item.index);
  8541. } else {
  8542. result = sprite.getBBox();
  8543. }
  8544. }
  8545. }
  8546. return result;
  8547. }, dataRange:null, constructor:function(config) {
  8548. var me = this, id;
  8549. config = config || {};
  8550. if (config.tips) {
  8551. config = Ext.apply({tooltip:config.tips}, config);
  8552. }
  8553. if (config.highlightCfg) {
  8554. config = Ext.apply({highlight:config.highlightCfg}, config);
  8555. }
  8556. if ('id' in config) {
  8557. id = config.id;
  8558. } else {
  8559. if ('id' in me.config) {
  8560. id = me.config.id;
  8561. } else {
  8562. id = me.getId();
  8563. }
  8564. }
  8565. me.setId(id);
  8566. me.sprites = [];
  8567. me.dataRange = [];
  8568. me.mixins.observable.constructor.call(me, config);
  8569. me.initBindable();
  8570. }, lookupViewModel:function(skipThis) {
  8571. var chart = this.getChart();
  8572. return chart ? chart.lookupViewModel(skipThis) : null;
  8573. }, applyTooltip:function(tooltip, oldTooltip) {
  8574. var config = Ext.apply({xtype:'tooltip', renderer:Ext.emptyFn, constrainPosition:true, shrinkWrapDock:true, autoHide:true, hideDelay:200, mouseOffset:[20, 20], trackMouse:true}, tooltip);
  8575. return Ext.create(config);
  8576. }, updateTooltip:function() {
  8577. this.addItemHighlight();
  8578. }, addItemHighlight:function() {
  8579. var chart = this.getChart(), interactions, interaction, hasRequiredInteraction, i;
  8580. if (!chart) {
  8581. return;
  8582. }
  8583. interactions = chart.getInteractions();
  8584. for (i = 0; i < interactions.length; i++) {
  8585. interaction = interactions[i];
  8586. if (interaction.isItemHighlight || interaction.isItemEdit) {
  8587. hasRequiredInteraction = true;
  8588. break;
  8589. }
  8590. }
  8591. if (!hasRequiredInteraction) {
  8592. interactions.push('itemhighlight');
  8593. chart.setInteractions(interactions);
  8594. }
  8595. }, showTooltip:function(item, event) {
  8596. var me = this, tooltip = me.getTooltip();
  8597. if (!tooltip) {
  8598. return;
  8599. }
  8600. Ext.callback(tooltip.renderer, tooltip.scope, [tooltip, item.record, item], 0, me);
  8601. tooltip.showBy(event);
  8602. }, showTooltipAt:function(item, x, y) {
  8603. var me = this, tooltip = me.getTooltip(), mouseOffset = tooltip.config.mouseOffset;
  8604. if (!tooltip || !tooltip.showAt) {
  8605. return;
  8606. }
  8607. if (mouseOffset) {
  8608. x += mouseOffset[0];
  8609. y += mouseOffset[1];
  8610. }
  8611. Ext.callback(tooltip.renderer, tooltip.scope, [tooltip, item.record, item], 0, me);
  8612. tooltip.showAt([x, y]);
  8613. }, hideTooltip:function(item, immediate) {
  8614. var me = this, tooltip = me.getTooltip();
  8615. if (!tooltip) {
  8616. return;
  8617. }
  8618. if (immediate) {
  8619. tooltip.hide();
  8620. } else {
  8621. tooltip.delayHide();
  8622. }
  8623. }, applyStore:function(store) {
  8624. return store && Ext.StoreManager.lookup(store);
  8625. }, getStore:function() {
  8626. return this._store || this.getChart() && this.getChart().getStore();
  8627. }, updateStore:function(newStore, oldStore) {
  8628. var me = this, chart = me.getChart(), chartStore = chart && chart.getStore(), sprites, sprite, len, i;
  8629. oldStore = oldStore || chartStore;
  8630. if (oldStore && oldStore !== newStore) {
  8631. oldStore.un({datachanged:'onDataChanged', update:'onDataChanged', scope:me});
  8632. }
  8633. if (newStore) {
  8634. newStore.on({datachanged:'onDataChanged', update:'onDataChanged', scope:me});
  8635. sprites = me.getSprites();
  8636. for (i = 0, len = sprites.length; i < len; i++) {
  8637. sprite = sprites[i];
  8638. if (sprite.setStore) {
  8639. sprite.setStore(newStore);
  8640. }
  8641. }
  8642. me.onDataChanged();
  8643. }
  8644. me.fireEvent('storechange', me, newStore, oldStore);
  8645. }, onStoreChange:function(chart, newStore, oldStore) {
  8646. if (!this._store) {
  8647. this.updateStore(newStore, oldStore);
  8648. }
  8649. }, defaultRange:[0, 1], coordinate:function(direction, directionOffset, directionCount) {
  8650. var me = this, store = me.getStore(), hidden = me.getHidden(), items = store.getData().items, axis = me['get' + direction + 'Axis'](), dataRange = [NaN, NaN], fieldCategory = me['fieldCategory' + direction] || [direction], fields = me.getFields(fieldCategory), i, field, data, style = {}, sprites = me.getSprites(), axisRange;
  8651. if (sprites.length && !Ext.isBoolean(hidden) || !hidden) {
  8652. for (i = 0; i < fieldCategory.length; i++) {
  8653. field = fields[i];
  8654. data = me.coordinateData(items, field, axis);
  8655. Ext.chart.Util.expandRange(dataRange, data);
  8656. style['data' + fieldCategory[i]] = data;
  8657. }
  8658. dataRange = Ext.chart.Util.validateRange(dataRange, me.defaultRange, 0);
  8659. me.dataRange[directionOffset] = dataRange[0];
  8660. me.dataRange[directionOffset + directionCount] = dataRange[1];
  8661. style['dataMin' + direction] = dataRange[0];
  8662. style['dataMax' + direction] = dataRange[1];
  8663. if (axis) {
  8664. axisRange = axis.getRange(true);
  8665. axis.setBoundSeriesRange(axisRange);
  8666. }
  8667. for (i = 0; i < sprites.length; i++) {
  8668. sprites[i].setAttributes(style);
  8669. }
  8670. }
  8671. }, coordinateData:function(items, field, axis) {
  8672. var data = [], length = items.length, layout = axis && axis.getLayout(), i, x;
  8673. for (i = 0; i < length; i++) {
  8674. x = items[i].data[field];
  8675. if (!Ext.isEmpty(x, true)) {
  8676. if (layout) {
  8677. data[i] = layout.getCoordFor(x, field, i, items);
  8678. } else {
  8679. x = +x;
  8680. data[i] = Ext.isNumber(x) ? x : i;
  8681. }
  8682. } else {
  8683. data[i] = x;
  8684. }
  8685. }
  8686. return data;
  8687. }, updateLabelData:function() {
  8688. var label = this.getLabel();
  8689. if (!label) {
  8690. return;
  8691. }
  8692. var store = this.getStore(), items = store.getData().items, sprites = this.getSprites(), labelTpl = label.getTemplate(), labelFields = Ext.Array.from(labelTpl.getField()), i, j, ln, labels, sprite, field;
  8693. if (!sprites.length || !labelFields.length) {
  8694. return;
  8695. }
  8696. for (i = 0; i < sprites.length; i++) {
  8697. sprite = sprites[i];
  8698. if (!sprite.getField) {
  8699. continue;
  8700. }
  8701. labels = [];
  8702. field = sprite.getField();
  8703. if (Ext.Array.indexOf(labelFields, field) < 0) {
  8704. field = labelFields[i];
  8705. }
  8706. for (j = 0, ln = items.length; j < ln; j++) {
  8707. labels.push(items[j].get(field));
  8708. }
  8709. sprite.setAttributes({labels:labels});
  8710. }
  8711. }, processData:function() {
  8712. var me = this, directions = me.directions, direction, axis, name, i, ln;
  8713. if (me.isProcessingData || !me.getStore()) {
  8714. return;
  8715. }
  8716. me.isProcessingData = true;
  8717. for (i = 0, ln = directions.length; i < ln; i++) {
  8718. direction = directions[i];
  8719. axis = me['get' + direction + 'Axis']();
  8720. if (axis) {
  8721. axis.processData(me);
  8722. continue;
  8723. }
  8724. name = 'coordinate' + direction;
  8725. if (me[name]) {
  8726. me[name]();
  8727. }
  8728. }
  8729. me.updateLabelData();
  8730. me.isProcessingData = false;
  8731. }, applyBackground:function(background) {
  8732. var surface, result;
  8733. if (this.getChart()) {
  8734. surface = this.getSurface();
  8735. surface.setBackground(background);
  8736. result = surface.getBackground();
  8737. } else {
  8738. result = background;
  8739. }
  8740. return result;
  8741. }, updateChart:function(newChart, oldChart) {
  8742. var me = this, store = me._store;
  8743. if (oldChart) {
  8744. oldChart.un('axeschange', 'onAxesChange', me);
  8745. me.clearSprites();
  8746. me.setSurface(null);
  8747. me.setOverlaySurface(null);
  8748. oldChart.unregister(me);
  8749. me.onChartDetached(oldChart);
  8750. if (!store) {
  8751. me.updateStore(null);
  8752. }
  8753. }
  8754. if (newChart) {
  8755. me.setSurface(newChart.getSurface('series'));
  8756. me.setOverlaySurface(newChart.getSurface('overlay'));
  8757. newChart.on('axeschange', 'onAxesChange', me);
  8758. if (newChart.getAxes()) {
  8759. me.onAxesChange(newChart);
  8760. }
  8761. me.onChartAttached(newChart);
  8762. newChart.register(me);
  8763. if (!store) {
  8764. me.updateStore(newChart.getStore());
  8765. }
  8766. }
  8767. }, onAxesChange:function(chart, force) {
  8768. if (chart.destroying || chart.destroyed) {
  8769. return;
  8770. }
  8771. var me = this, axes = chart.getAxes(), axis, directionToAxesMap = {}, directionToFieldsMap = {}, needHighPrecision = false, directions = this.directions, direction, i, ln;
  8772. for (i = 0, ln = directions.length; i < ln; i++) {
  8773. direction = directions[i];
  8774. directionToFieldsMap[direction] = me.getFields(me['fieldCategory' + direction]);
  8775. }
  8776. for (i = 0, ln = axes.length; i < ln; i++) {
  8777. axis = axes[i];
  8778. direction = axis.getDirection();
  8779. if (!directionToAxesMap[direction]) {
  8780. directionToAxesMap[direction] = [axis];
  8781. } else {
  8782. directionToAxesMap[direction].push(axis);
  8783. }
  8784. }
  8785. for (i = 0, ln = directions.length; i < ln; i++) {
  8786. direction = directions[i];
  8787. if (!force && me['get' + direction + 'Axis']()) {
  8788. continue;
  8789. }
  8790. if (directionToAxesMap[direction]) {
  8791. axis = me.findMatchingAxis(directionToAxesMap[direction], directionToFieldsMap[direction]);
  8792. if (axis) {
  8793. me['set' + direction + 'Axis'](axis);
  8794. if (axis.getNeedHighPrecision()) {
  8795. needHighPrecision = true;
  8796. }
  8797. }
  8798. }
  8799. }
  8800. this.getSurface().setHighPrecision(needHighPrecision);
  8801. }, findMatchingAxis:function(directionAxes, directionFields) {
  8802. var axis, axisFields, i, j;
  8803. for (i = 0; i < directionAxes.length; i++) {
  8804. axis = directionAxes[i];
  8805. axisFields = axis.getFields();
  8806. if (!axisFields.length) {
  8807. return axis;
  8808. } else {
  8809. if (directionFields) {
  8810. for (j = 0; j < directionFields.length; j++) {
  8811. if (Ext.Array.indexOf(axisFields, directionFields[j]) >= 0) {
  8812. return axis;
  8813. }
  8814. }
  8815. }
  8816. }
  8817. }
  8818. }, onChartDetached:function(oldChart) {
  8819. var me = this;
  8820. me.fireEvent('chartdetached', oldChart, me);
  8821. oldChart.un('storechange', 'onStoreChange', me);
  8822. }, onChartAttached:function(chart) {
  8823. var me = this;
  8824. me.fireEvent('chartattached', chart, me);
  8825. chart.on('storechange', 'onStoreChange', me);
  8826. me.processData();
  8827. }, updateOverlaySurface:function(overlaySurface) {
  8828. var label = this.getLabel();
  8829. if (overlaySurface && label) {
  8830. overlaySurface.add(label);
  8831. }
  8832. }, getLabel:function() {
  8833. return this.labelMarker;
  8834. }, setLabel:function(label) {
  8835. var me = this, chart = me.getChart(), marker = me.labelMarker, template;
  8836. if (!label && marker) {
  8837. marker.getTemplate().destroy();
  8838. marker.destroy();
  8839. me.labelMarker = marker = null;
  8840. }
  8841. if (label) {
  8842. if (!marker) {
  8843. marker = me.labelMarker = new Ext.chart.Markers({zIndex:10});
  8844. marker.setTemplate(new Ext.chart.sprite.Label);
  8845. me.getOverlaySurface().add(marker);
  8846. }
  8847. template = marker.getTemplate();
  8848. template.setAttributes(label);
  8849. template.setConfig(label);
  8850. if (label.field) {
  8851. template.setField(label.field);
  8852. }
  8853. if (label.display) {
  8854. marker.setAttributes({hidden:label.display === 'none'});
  8855. }
  8856. marker.setDirty(true);
  8857. }
  8858. me.updateLabelData();
  8859. if (chart && !chart.isInitializing && !me.isConfiguring) {
  8860. chart.redraw();
  8861. }
  8862. }, createItemInstancingSprite:function(sprite, itemInstancing) {
  8863. var me = this, markers = new Ext.chart.Markers, config = Ext.apply({modifiers:'highlight'}, itemInstancing), style = me.getStyle(), template, animation;
  8864. markers.setAttributes({zIndex:Number.MAX_VALUE});
  8865. markers.setTemplate(config);
  8866. template = markers.getTemplate();
  8867. template.setAttributes(style);
  8868. animation = template.getAnimation();
  8869. animation.on('animationstart', 'onSpriteAnimationStart', this);
  8870. animation.on('animationend', 'onSpriteAnimationEnd', this);
  8871. sprite.bindMarker('items', markers);
  8872. me.getSurface().add(markers);
  8873. return markers;
  8874. }, getDefaultSpriteConfig:function() {
  8875. return {type:this.seriesType, renderer:this.getRenderer()};
  8876. }, updateRenderer:function(renderer) {
  8877. var me = this, chart = me.getChart();
  8878. if (chart && chart.isInitializing) {
  8879. return;
  8880. }
  8881. if (me.sprites.length) {
  8882. me.sprites[0].setAttributes({renderer:renderer || null});
  8883. if (chart && !chart.isInitializing) {
  8884. chart.redraw();
  8885. }
  8886. }
  8887. }, updateShowMarkers:function(showMarkers) {
  8888. var sprite = this.getSprite(), markers = sprite && sprite.getMarker('markers');
  8889. if (markers) {
  8890. markers.getTemplate().setAttributes({hidden:!showMarkers});
  8891. }
  8892. }, createSprite:function() {
  8893. var me = this, surface = me.getSurface(), itemInstancing = me.getItemInstancing(), sprite = surface.add(me.getDefaultSpriteConfig()), animation, label;
  8894. sprite.setAttributes(me.getStyle());
  8895. sprite.setSeries(me);
  8896. if (itemInstancing) {
  8897. me.createItemInstancingSprite(sprite, itemInstancing);
  8898. }
  8899. if (sprite.isMarkerHolder) {
  8900. label = me.getLabel();
  8901. if (label && label.getTemplate().getField()) {
  8902. sprite.bindMarker('labels', label);
  8903. }
  8904. }
  8905. if (sprite.setStore) {
  8906. sprite.setStore(me.getStore());
  8907. }
  8908. animation = sprite.getAnimation();
  8909. animation.on('animationstart', 'onSpriteAnimationStart', me);
  8910. animation.on('animationend', 'onSpriteAnimationEnd', me);
  8911. me.sprites.push(sprite);
  8912. return sprite;
  8913. }, getSprites:null, getSprite:function() {
  8914. var sprites = this.getSprites();
  8915. return sprites && sprites[0];
  8916. }, withSprite:function(fn) {
  8917. var sprite = this.getSprite();
  8918. return sprite && fn(sprite) || undefined;
  8919. }, forEachSprite:function(fn) {
  8920. var sprites = this.getSprites(), i, ln;
  8921. for (i = 0, ln = sprites.length; i < ln; i++) {
  8922. fn(sprites[i]);
  8923. }
  8924. }, onDataChanged:function() {
  8925. var me = this, chart = me.getChart(), chartStore = chart && chart.getStore(), seriesStore = me.getStore();
  8926. if (seriesStore !== chartStore) {
  8927. me.processData();
  8928. }
  8929. }, isXType:function(xtype) {
  8930. return xtype === 'series';
  8931. }, getItemId:function() {
  8932. return this.getId();
  8933. }, applyThemeStyle:function(theme, oldTheme) {
  8934. var me = this, fill, stroke;
  8935. fill = theme && theme.subStyle && theme.subStyle.fillStyle;
  8936. stroke = fill && theme.subStyle.strokeStyle;
  8937. if (fill && !stroke) {
  8938. theme.subStyle.strokeStyle = me.getStrokeColorsFromFillColors(fill);
  8939. }
  8940. fill = theme && theme.markerSubStyle && theme.markerSubStyle.fillStyle;
  8941. stroke = fill && theme.markerSubStyle.strokeStyle;
  8942. if (fill && !stroke) {
  8943. theme.markerSubStyle.strokeStyle = me.getStrokeColorsFromFillColors(fill);
  8944. }
  8945. return Ext.apply(oldTheme || {}, theme);
  8946. }, applyStyle:function(style, oldStyle) {
  8947. return Ext.apply({}, style, oldStyle);
  8948. }, applySubStyle:function(subStyle, oldSubStyle) {
  8949. var name = Ext.ClassManager.getNameByAlias('sprite.' + this.seriesType), cls = Ext.ClassManager.get(name);
  8950. if (cls && cls.def) {
  8951. subStyle = cls.def.batchedNormalize(subStyle, true);
  8952. }
  8953. return Ext.merge({}, oldSubStyle, subStyle);
  8954. }, applyMarker:function(marker, oldMarker) {
  8955. var type, cls;
  8956. if (marker) {
  8957. if (!Ext.isObject(marker)) {
  8958. marker = {};
  8959. }
  8960. type = marker.type || 'circle';
  8961. if (oldMarker && type === oldMarker.type) {
  8962. marker = Ext.merge({}, oldMarker, marker);
  8963. }
  8964. }
  8965. if (type) {
  8966. cls = Ext.ClassManager.get(Ext.ClassManager.getNameByAlias('sprite.' + type));
  8967. }
  8968. if (cls && cls.def) {
  8969. marker = cls.def.normalize(marker, true);
  8970. marker.type = type;
  8971. } else {
  8972. marker = null;
  8973. Ext.log.warn('Invalid series marker type: ' + type);
  8974. }
  8975. return marker;
  8976. }, updateMarker:function(marker) {
  8977. var me = this, sprites = me.getSprites(), seriesSprite, markerSprite, markerTplConfig, i, ln;
  8978. for (i = 0, ln = sprites.length; i < ln; i++) {
  8979. seriesSprite = sprites[i];
  8980. if (!seriesSprite.isMarkerHolder) {
  8981. continue;
  8982. }
  8983. markerSprite = seriesSprite.getMarker('markers');
  8984. if (marker) {
  8985. if (!markerSprite) {
  8986. markerSprite = new Ext.chart.Markers;
  8987. seriesSprite.bindMarker('markers', markerSprite);
  8988. me.getOverlaySurface().add(markerSprite);
  8989. }
  8990. markerTplConfig = Ext.Object.merge({modifiers:'highlight'}, marker);
  8991. markerSprite.setTemplate(markerTplConfig);
  8992. markerSprite.getTemplate().getAnimation().setCustomDurations({translationX:0, translationY:0});
  8993. } else {
  8994. if (markerSprite) {
  8995. seriesSprite.releaseMarker('markers');
  8996. me.getOverlaySurface().remove(markerSprite, true);
  8997. }
  8998. }
  8999. seriesSprite.setDirty(true);
  9000. }
  9001. if (!me.isConfiguring) {
  9002. me.doUpdateStyles();
  9003. me.updateHighlight(me.getHighlight());
  9004. }
  9005. }, applyMarkerSubStyle:function(marker, oldMarker) {
  9006. var type = marker && marker.type || oldMarker && oldMarker.type || 'circle', cls = Ext.ClassManager.get(Ext.ClassManager.getNameByAlias('sprite.' + type));
  9007. if (cls && cls.def) {
  9008. marker = cls.def.batchedNormalize(marker, true);
  9009. }
  9010. return Ext.merge(oldMarker || {}, marker);
  9011. }, updateHidden:function(hidden) {
  9012. var me = this;
  9013. me.getColors();
  9014. me.getSubStyle();
  9015. me.setSubStyle({hidden:hidden});
  9016. me.processData();
  9017. me.doUpdateStyles();
  9018. if (!Ext.isArray(hidden)) {
  9019. me.updateLegendStore(hidden);
  9020. }
  9021. }, updateLegendStore:function(hidden, index) {
  9022. var me = this, chart = me.getChart(), legendStore = chart && chart.getLegendStore(), id = me.getId(), record;
  9023. if (legendStore) {
  9024. if (arguments.length > 1) {
  9025. record = legendStore.findBy(function(rec) {
  9026. return rec.get('series') === id && rec.get('index') === index;
  9027. });
  9028. if (record !== -1) {
  9029. record = legendStore.getAt(record);
  9030. }
  9031. } else {
  9032. record = legendStore.findRecord('series', id);
  9033. }
  9034. if (record && record.get('disabled') !== hidden) {
  9035. record.set('disabled', hidden);
  9036. }
  9037. }
  9038. }, setHiddenByIndex:function(index, value) {
  9039. var me = this;
  9040. if (Ext.isArray(me.getHidden())) {
  9041. me.getHidden()[index] = value;
  9042. me.updateHidden(me.getHidden());
  9043. me.updateLegendStore(value, index);
  9044. } else {
  9045. me.setHidden(value);
  9046. }
  9047. }, getStrokeColorsFromFillColors:function(colors) {
  9048. var me = this, darker = me.getUseDarkerStrokeColor(), darkerRatio = Ext.isNumber(darker) ? darker : me.darkerStrokeRatio, strokeColors;
  9049. if (darker) {
  9050. strokeColors = Ext.Array.map(colors, function(color) {
  9051. color = Ext.isString(color) ? color : color.stops[0].color;
  9052. color = Ext.util.Color.fromString(color);
  9053. return color.createDarker(darkerRatio).toString();
  9054. });
  9055. } else {
  9056. strokeColors = Ext.Array.clone(colors);
  9057. }
  9058. return strokeColors;
  9059. }, updateThemeColors:function(colors) {
  9060. var me = this, theme = me.getThemeStyle(), fillColors = Ext.Array.clone(colors), strokeColors = me.getStrokeColorsFromFillColors(colors), newSubStyle = {fillStyle:fillColors, strokeStyle:strokeColors};
  9061. theme.subStyle = Ext.apply(theme.subStyle || {}, newSubStyle);
  9062. theme.markerSubStyle = Ext.apply(theme.markerSubStyle || {}, newSubStyle);
  9063. me.doUpdateStyles();
  9064. if (!me.isConfiguring) {
  9065. me.getChart().refreshLegendStore();
  9066. }
  9067. }, themeOnlyIfConfigured:{}, updateTheme:function(theme) {
  9068. var me = this, seriesTheme = theme.getSeries(), initialConfig = me.getInitialConfig(), defaultConfig = me.defaultConfig, configs = me.self.getConfigurator().configs, genericSeriesTheme = seriesTheme.defaults, specificSeriesTheme = seriesTheme[me.type], themeOnlyIfConfigured = me.themeOnlyIfConfigured, key, value, isObjValue, isUnusedConfig, initialValue, cfg;
  9069. seriesTheme = Ext.merge({}, genericSeriesTheme, specificSeriesTheme);
  9070. for (key in seriesTheme) {
  9071. value = seriesTheme[key];
  9072. cfg = configs[key];
  9073. if (value !== null && value !== undefined && cfg) {
  9074. initialValue = initialConfig[key];
  9075. isObjValue = Ext.isObject(value);
  9076. isUnusedConfig = initialValue === defaultConfig[key];
  9077. if (isObjValue) {
  9078. if (isUnusedConfig && themeOnlyIfConfigured[key]) {
  9079. continue;
  9080. }
  9081. value = Ext.merge({}, value, initialValue);
  9082. }
  9083. if (isUnusedConfig || isObjValue) {
  9084. me[cfg.names.set](value);
  9085. }
  9086. }
  9087. }
  9088. }, updateChartColors:function(colors) {
  9089. var me = this;
  9090. if (!me.getColors()) {
  9091. me.updateThemeColors(colors);
  9092. }
  9093. }, updateColors:function(colors) {
  9094. var chart;
  9095. this.updateThemeColors(colors);
  9096. if (!this.isConfiguring) {
  9097. chart = this.getChart();
  9098. if (chart) {
  9099. chart.refreshLegendStore();
  9100. }
  9101. }
  9102. }, updateStyle:function() {
  9103. this.doUpdateStyles();
  9104. }, updateSubStyle:function() {
  9105. this.doUpdateStyles();
  9106. }, updateThemeStyle:function() {
  9107. this.doUpdateStyles();
  9108. }, doUpdateStyles:function() {
  9109. var me = this, sprites = me.sprites, itemInstancing = me.getItemInstancing(), ln = sprites && sprites.length, showMarkers = me.getConfig('showMarkers', true), style, sprite, marker, i;
  9110. for (i = 0; i < ln; i++) {
  9111. sprite = sprites[i];
  9112. style = me.getStyleByIndex(i);
  9113. if (itemInstancing) {
  9114. sprite.getMarker('items').getTemplate().setAttributes(style);
  9115. }
  9116. sprite.setAttributes(style);
  9117. marker = sprite.isMarkerHolder && sprite.getMarker('markers');
  9118. if (marker) {
  9119. marker.getTemplate().setAttributes(me.getMarkerStyleByIndex(i));
  9120. }
  9121. }
  9122. }, getStyleWithTheme:function() {
  9123. var me = this, theme = me.getThemeStyle(), style = Ext.clone(me.getStyle());
  9124. if (theme && theme.style) {
  9125. Ext.applyIf(style, theme.style);
  9126. }
  9127. return style;
  9128. }, getSubStyleWithTheme:function() {
  9129. var me = this, theme = me.getThemeStyle(), subStyle = Ext.clone(me.getSubStyle());
  9130. if (theme && theme.subStyle) {
  9131. Ext.applyIf(subStyle, theme.subStyle);
  9132. }
  9133. return subStyle;
  9134. }, getStyleByIndex:function(i) {
  9135. var me = this, theme = me.getThemeStyle(), style, themeStyle, subStyle, themeSubStyle, result = {};
  9136. style = me.getStyle();
  9137. themeStyle = theme && theme.style || {};
  9138. subStyle = me.styleDataForIndex(me.getSubStyle(), i);
  9139. themeSubStyle = me.styleDataForIndex(theme && theme.subStyle, i);
  9140. Ext.apply(result, themeStyle);
  9141. Ext.apply(result, themeSubStyle);
  9142. Ext.apply(result, style);
  9143. Ext.apply(result, subStyle);
  9144. return result;
  9145. }, getMarkerStyleByIndex:function(i) {
  9146. var me = this, theme = me.getThemeStyle(), style, themeStyle, subStyle, themeSubStyle, markerStyle, themeMarkerStyle, markerSubStyle, themeMarkerSubStyle, result = {};
  9147. style = me.getStyle();
  9148. themeStyle = theme && theme.style || {};
  9149. subStyle = me.styleDataForIndex(me.getSubStyle(), i);
  9150. if (subStyle.hasOwnProperty('hidden')) {
  9151. subStyle.hidden = subStyle.hidden || !this.getConfig('showMarkers', true);
  9152. }
  9153. themeSubStyle = me.styleDataForIndex(theme && theme.subStyle, i);
  9154. markerStyle = me.getMarker();
  9155. themeMarkerStyle = theme && theme.marker || {};
  9156. markerSubStyle = me.getMarkerSubStyle();
  9157. themeMarkerSubStyle = me.styleDataForIndex(theme && theme.markerSubStyle, i);
  9158. Ext.apply(result, themeStyle);
  9159. Ext.apply(result, themeSubStyle);
  9160. Ext.apply(result, themeMarkerStyle);
  9161. Ext.apply(result, themeMarkerSubStyle);
  9162. Ext.apply(result, style);
  9163. Ext.apply(result, subStyle);
  9164. Ext.apply(result, markerStyle);
  9165. Ext.apply(result, markerSubStyle);
  9166. return result;
  9167. }, styleDataForIndex:function(style, i) {
  9168. var value, name, result = {};
  9169. if (style) {
  9170. for (name in style) {
  9171. value = style[name];
  9172. if (Ext.isArray(value)) {
  9173. result[name] = value[i % value.length];
  9174. } else {
  9175. result[name] = value;
  9176. }
  9177. }
  9178. }
  9179. return result;
  9180. }, getItemForPoint:Ext.emptyFn, getItemByIndex:function(index, category) {
  9181. var me = this, sprites = me.getSprites(), sprite = sprites && sprites[0], item;
  9182. if (!sprite) {
  9183. return;
  9184. }
  9185. if (category === undefined && sprite.isMarkerHolder) {
  9186. category = me.getItemInstancing() ? 'items' : 'markers';
  9187. } else {
  9188. if (!category || category === '' || category === 'sprites') {
  9189. sprite = sprites[index];
  9190. }
  9191. }
  9192. if (sprite) {
  9193. item = {series:me, category:category, index:index, record:me.getStore().getData().items[index], field:me.getYField(), sprite:sprite};
  9194. return item;
  9195. }
  9196. }, onSpriteAnimationStart:function(sprite) {
  9197. this.fireEvent('animationstart', this, sprite);
  9198. }, onSpriteAnimationEnd:function(sprite) {
  9199. this.fireEvent('animationend', this, sprite);
  9200. }, resolveListenerScope:function(defaultScope) {
  9201. var me = this, namedScope = Ext._namedScopes[defaultScope], chart = me.getChart(), scope;
  9202. if (!namedScope) {
  9203. scope = chart ? chart.resolveListenerScope(defaultScope, false) : defaultScope || me;
  9204. } else {
  9205. if (namedScope.isThis) {
  9206. scope = me;
  9207. } else {
  9208. if (namedScope.isController) {
  9209. scope = chart ? chart.resolveListenerScope(defaultScope, false) : me;
  9210. } else {
  9211. if (namedScope.isSelf) {
  9212. scope = chart ? chart.resolveListenerScope(defaultScope, false) : me;
  9213. if (scope === chart && !chart.getInheritedConfig('defaultListenerScope')) {
  9214. scope = me;
  9215. }
  9216. }
  9217. }
  9218. }
  9219. }
  9220. return scope;
  9221. }, provideLegendInfo:function(target) {
  9222. var me = this, style = me.getSubStyleWithTheme(), fill = style.fillStyle;
  9223. if (Ext.isArray(fill)) {
  9224. fill = fill[0];
  9225. }
  9226. target.push({name:me.getTitle() || me.getYField() || me.getId(), mark:(Ext.isObject(fill) ? fill.stops && fill.stops[0].color : fill) || style.strokeStyle || 'black', disabled:me.getHidden(), series:me.getId(), index:0});
  9227. }, clearSprites:function() {
  9228. var sprites = this.sprites, sprite, i, ln;
  9229. for (i = 0, ln = sprites.length; i < ln; i++) {
  9230. sprite = sprites[i];
  9231. if (sprite && sprite.isSprite) {
  9232. sprite.destroy();
  9233. }
  9234. }
  9235. this.sprites = [];
  9236. }, destroy:function() {
  9237. var me = this, store = me._store, tooltip = me.getConfig('tooltip', true);
  9238. if (store && store.getAutoDestroy()) {
  9239. Ext.destroy(store);
  9240. }
  9241. me.setChart(null);
  9242. me.clearListeners();
  9243. if (tooltip) {
  9244. Ext.destroy(tooltip);
  9245. }
  9246. me.callParent();
  9247. }});
  9248. Ext.define('Ext.chart.interactions.Abstract', {xtype:'interaction', mixins:{observable:'Ext.mixin.Observable'}, config:{gestures:{tap:'onGesture'}, chart:null, enabled:true}, throttleGap:0, stopAnimationBeforeSync:false, constructor:function(config) {
  9249. var me = this, id;
  9250. config = config || {};
  9251. if ('id' in config) {
  9252. id = config.id;
  9253. } else {
  9254. if ('id' in me.config) {
  9255. id = me.config.id;
  9256. } else {
  9257. id = me.getId();
  9258. }
  9259. }
  9260. me.setId(id);
  9261. me.mixins.observable.constructor.call(me, config);
  9262. }, updateChart:function(newChart, oldChart) {
  9263. var me = this;
  9264. if (oldChart === newChart) {
  9265. return;
  9266. }
  9267. if (oldChart) {
  9268. oldChart.unregister(me);
  9269. me.removeChartListener(oldChart);
  9270. }
  9271. if (newChart) {
  9272. newChart.register(me);
  9273. me.addChartListener();
  9274. }
  9275. }, updateEnabled:function(enabled) {
  9276. var me = this, chart = me.getChart();
  9277. if (chart) {
  9278. if (enabled) {
  9279. me.addChartListener();
  9280. } else {
  9281. me.removeChartListener(chart);
  9282. }
  9283. }
  9284. }, onGesture:Ext.emptyFn, getItemForEvent:function(e) {
  9285. var me = this, chart = me.getChart(), chartXY = chart.getEventXY(e);
  9286. return chart.getItemForPoint(chartXY[0], chartXY[1]);
  9287. }, getItemsForEvent:function(e) {
  9288. var me = this, chart = me.getChart(), chartXY = chart.getEventXY(e);
  9289. return chart.getItemsForPoint(chartXY[0], chartXY[1]);
  9290. }, addChartListener:function() {
  9291. var me = this, chart = me.getChart(), gestures = me.getGestures(), gesture;
  9292. if (!me.getEnabled()) {
  9293. return;
  9294. }
  9295. function insertGesture(name, fn) {
  9296. chart.addElementListener(name, me.listeners[name] = function(e) {
  9297. var locks = me.getLocks(), result;
  9298. if (me.getEnabled() && (!(name in locks) || locks[name] === me)) {
  9299. result = (Ext.isFunction(fn) ? fn : me[fn]).apply(this, arguments);
  9300. if (result === false && e && e.stopPropagation) {
  9301. e.stopPropagation();
  9302. }
  9303. return result;
  9304. }
  9305. }, me);
  9306. }
  9307. me.listeners = me.listeners || {};
  9308. for (gesture in gestures) {
  9309. insertGesture(gesture, gestures[gesture]);
  9310. }
  9311. }, removeChartListener:function(chart) {
  9312. var me = this, gestures = me.getGestures(), gesture;
  9313. function removeGesture(name) {
  9314. var fn = me.listeners[name];
  9315. if (fn) {
  9316. chart.removeElementListener(name, fn);
  9317. delete me.listeners[name];
  9318. }
  9319. }
  9320. if (me.listeners) {
  9321. for (gesture in gestures) {
  9322. removeGesture(gesture);
  9323. }
  9324. }
  9325. }, lockEvents:function() {
  9326. var me = this, locks = me.getLocks(), args = Array.prototype.slice.call(arguments), i = args.length;
  9327. while (i--) {
  9328. locks[args[i]] = me;
  9329. }
  9330. }, unlockEvents:function() {
  9331. var locks = this.getLocks(), args = Array.prototype.slice.call(arguments), i = args.length;
  9332. while (i--) {
  9333. delete locks[args[i]];
  9334. }
  9335. }, getLocks:function() {
  9336. var chart = this.getChart();
  9337. return chart.lockedEvents || (chart.lockedEvents = {});
  9338. }, doSync:function() {
  9339. var me = this, chart = me.getChart();
  9340. if (me.syncTimer) {
  9341. Ext.undefer(me.syncTimer);
  9342. me.syncTimer = null;
  9343. }
  9344. if (me.stopAnimationBeforeSync) {
  9345. chart.animationSuspendCount++;
  9346. }
  9347. chart.redraw();
  9348. if (me.stopAnimationBeforeSync) {
  9349. chart.animationSuspendCount--;
  9350. }
  9351. me.syncThrottle = Date.now() + me.throttleGap;
  9352. }, sync:function() {
  9353. var me = this;
  9354. if (me.throttleGap && Ext.frameStartTime < me.syncThrottle) {
  9355. if (me.syncTimer) {
  9356. return;
  9357. }
  9358. me.syncTimer = Ext.defer(function() {
  9359. me.doSync();
  9360. }, me.throttleGap);
  9361. } else {
  9362. me.doSync();
  9363. }
  9364. }, getItemId:function() {
  9365. return this.getId();
  9366. }, isXType:function(xtype) {
  9367. return xtype === 'interaction';
  9368. }, destroy:function() {
  9369. var me = this;
  9370. me.setChart(null);
  9371. delete me.listeners;
  9372. me.callParent();
  9373. }}, function() {
  9374. if (Ext.os.is.Android4) {
  9375. this.prototype.throttleGap = 40;
  9376. }
  9377. });
  9378. Ext.define('Ext.chart.MarkerHolder', {extend:'Ext.Mixin', requires:['Ext.chart.Markers'], mixinConfig:{id:'markerHolder', after:{constructor:'constructor', preRender:'preRender'}, before:{destroy:'destroy'}}, isMarkerHolder:true, surfaceMatrix:null, inverseSurfaceMatrix:null, deprecated:{6:{methods:{getBoundMarker:{message:"Please use the 'getMarker' method instead.", fn:function(name) {
  9379. var marker = this.boundMarkers[name];
  9380. return marker ? [marker] : marker;
  9381. }}}}}, constructor:function() {
  9382. this.boundMarkers = {};
  9383. this.cleanRedraw = false;
  9384. }, bindMarker:function(name, marker) {
  9385. var me = this, markers = me.boundMarkers;
  9386. if (marker && marker.isMarkers) {
  9387. if (markers[name] && markers[name] === marker) {
  9388. Ext.log.warn(me.getId(), " (MarkerHolder): the Markers instance '", marker.getId(), "' is already bound under the name '", name, "'.");
  9389. }
  9390. me.releaseMarker(name);
  9391. markers[name] = marker;
  9392. marker.on('destroy', me.onMarkerDestroy, me);
  9393. }
  9394. }, onMarkerDestroy:function(marker) {
  9395. this.releaseMarker(marker);
  9396. }, releaseMarker:function(marker) {
  9397. var markers = this.boundMarkers, name;
  9398. if (marker && marker.isMarkers) {
  9399. for (name in markers) {
  9400. if (markers[name] === marker) {
  9401. delete markers[name];
  9402. break;
  9403. }
  9404. }
  9405. } else {
  9406. name = marker;
  9407. marker = markers[name];
  9408. delete markers[name];
  9409. }
  9410. return marker || null;
  9411. }, getMarker:function(name) {
  9412. return this.boundMarkers[name] || null;
  9413. }, preRender:function(surface, ctx, rect) {
  9414. var me = this, id = me.getId(), boundMarkers = me.boundMarkers, parent = me.getParent(), name, marker, matrix;
  9415. if (me.surfaceMatrix) {
  9416. matrix = me.surfaceMatrix.set(1, 0, 0, 1, 0, 0);
  9417. } else {
  9418. matrix = me.surfaceMatrix = new Ext.draw.Matrix;
  9419. }
  9420. me.cleanRedraw = !me.attr.dirty;
  9421. if (!me.cleanRedraw) {
  9422. for (name in boundMarkers) {
  9423. marker = boundMarkers[name];
  9424. if (marker) {
  9425. marker.clear(id);
  9426. }
  9427. }
  9428. }
  9429. while (parent && parent.attr && parent.attr.matrix) {
  9430. matrix.prependMatrix(parent.attr.matrix);
  9431. parent = parent.getParent();
  9432. }
  9433. matrix.prependMatrix(parent.matrix);
  9434. me.surfaceMatrix = matrix;
  9435. me.inverseSurfaceMatrix = matrix.inverse(me.inverseSurfaceMatrix);
  9436. }, putMarker:function(name, attr, index, bypassNormalization, keepRevision) {
  9437. var marker = this.boundMarkers[name];
  9438. if (marker) {
  9439. marker.putMarkerFor(this.getId(), attr, index, bypassNormalization, keepRevision);
  9440. }
  9441. }, getMarkerBBox:function(name, index, isWithoutTransform) {
  9442. var marker = this.boundMarkers[name];
  9443. if (marker) {
  9444. return marker.getMarkerBBoxFor(this.getId(), index, isWithoutTransform);
  9445. }
  9446. }, destroy:function() {
  9447. var boundMarkers = this.boundMarkers, name, marker;
  9448. for (name in boundMarkers) {
  9449. marker = boundMarkers[name];
  9450. marker.destroy();
  9451. }
  9452. }});
  9453. Ext.define('Ext.chart.axis.sprite.Axis', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.axis', type:'axis', mixins:{markerHolder:'Ext.chart.MarkerHolder'}, requires:['Ext.draw.sprite.Text'], inheritableStatics:{def:{processors:{grid:'bool', axisLine:'bool', minorTicks:'bool', minorTickSize:'number', majorTicks:'bool', majorTickSize:'number', length:'number', startGap:'number', endGap:'number', dataMin:'number', dataMax:'number', visibleMin:'number', visibleMax:'number', position:'enums(left,right,top,bottom,angular,radial,gauge)',
  9454. minStepSize:'number', estStepSize:'number', titleOffset:'number', textPadding:'number', min:'number', max:'number', centerX:'number', centerY:'number', radius:'number', totalAngle:'number', baseRotation:'number', data:'default', enlargeEstStepSizeByText:'bool'}, defaults:{grid:false, axisLine:true, minorTicks:false, minorTickSize:3, majorTicks:true, majorTickSize:5, length:0, startGap:0, endGap:0, visibleMin:0, visibleMax:1, dataMin:0, dataMax:1, position:'', minStepSize:0, estStepSize:20, min:0,
  9455. max:1, centerX:0, centerY:0, radius:1, baseRotation:0, data:null, titleOffset:0, textPadding:0, scalingCenterY:0, scalingCenterX:0, strokeStyle:'black', enlargeEstStepSizeByText:false}, triggers:{minorTickSize:'bbox', majorTickSize:'bbox', position:'bbox,layout', axisLine:'bbox,layout', minorTicks:'layout', min:'layout', max:'layout', length:'layout', minStepSize:'layout', estStepSize:'layout', data:'layout', dataMin:'layout', dataMax:'layout', visibleMin:'layout', visibleMax:'layout', enlargeEstStepSizeByText:'layout'},
  9456. updaters:{layout:'layoutUpdater'}}}, config:{label:null, labelOffset:10, layout:null, segmenter:null, renderer:null, layoutContext:null, axis:null}, thickness:0, stepSize:0, getBBox:function() {
  9457. return null;
  9458. }, defaultRenderer:function(v) {
  9459. return this.segmenter.renderer(v, this);
  9460. }, layoutUpdater:function() {
  9461. var me = this, chart = me.getAxis().getChart();
  9462. if (chart.isInitializing) {
  9463. return;
  9464. }
  9465. var attr = me.attr, layout = me.getLayout(), isRtl = chart.getInherited().rtl, dataRange = attr.dataMax - attr.dataMin, min = attr.dataMin + dataRange * attr.visibleMin, max = attr.dataMin + dataRange * attr.visibleMax, range = max - min, position = attr.position, context = {attr:attr, segmenter:me.getSegmenter(), renderer:me.defaultRenderer};
  9466. if (position === 'left' || position === 'right') {
  9467. attr.translationX = 0;
  9468. attr.translationY = max * attr.length / range;
  9469. attr.scalingX = 1;
  9470. attr.scalingY = -attr.length / range;
  9471. attr.scalingCenterY = 0;
  9472. attr.scalingCenterX = 0;
  9473. me.applyTransformations(true);
  9474. } else {
  9475. if (position === 'top' || position === 'bottom') {
  9476. if (isRtl) {
  9477. attr.translationX = attr.length + min * attr.length / range + 1;
  9478. } else {
  9479. attr.translationX = -min * attr.length / range;
  9480. }
  9481. attr.translationY = 0;
  9482. attr.scalingX = (isRtl ? -1 : 1) * attr.length / range;
  9483. attr.scalingY = 1;
  9484. attr.scalingCenterY = 0;
  9485. attr.scalingCenterX = 0;
  9486. me.applyTransformations(true);
  9487. }
  9488. }
  9489. if (layout) {
  9490. layout.calculateLayout(context);
  9491. me.setLayoutContext(context);
  9492. }
  9493. }, iterate:function(snaps, fn) {
  9494. var i, position, id, axis, floatingAxes, floatingValues, some = Ext.Array.some, abs = Math.abs, threshold, isTickVisible;
  9495. if (snaps.getLabel) {
  9496. if (snaps.min < snaps.from) {
  9497. fn.call(this, snaps.min, snaps.getLabel(snaps.min), -1, snaps);
  9498. }
  9499. for (i = 0; i <= snaps.steps; i++) {
  9500. fn.call(this, snaps.get(i), snaps.getLabel(i), i, snaps);
  9501. }
  9502. if (snaps.max > snaps.to) {
  9503. fn.call(this, snaps.max, snaps.getLabel(snaps.max), snaps.steps + 1, snaps);
  9504. }
  9505. } else {
  9506. axis = this.getAxis();
  9507. floatingAxes = axis.floatingAxes;
  9508. floatingValues = [];
  9509. threshold = (snaps.to - snaps.from) / (snaps.steps + 1);
  9510. if (axis.getFloating()) {
  9511. for (id in floatingAxes) {
  9512. floatingValues.push(floatingAxes[id]);
  9513. }
  9514. }
  9515. isTickVisible = function(position) {
  9516. return !floatingValues.length || some(floatingValues, function(value) {
  9517. return abs(value - position) > threshold;
  9518. });
  9519. };
  9520. if (snaps.min < snaps.from && isTickVisible(snaps.min)) {
  9521. fn.call(this, snaps.min, snaps.min, -1, snaps);
  9522. }
  9523. for (i = 0; i <= snaps.steps; i++) {
  9524. position = snaps.get(i);
  9525. if (isTickVisible(position)) {
  9526. fn.call(this, position, position, i, snaps);
  9527. }
  9528. }
  9529. if (snaps.max > snaps.to && isTickVisible(snaps.max)) {
  9530. fn.call(this, snaps.max, snaps.max, snaps.steps + 1, snaps);
  9531. }
  9532. }
  9533. }, renderTicks:function(surface, ctx, layout, clipRect) {
  9534. var me = this, attr = me.attr, docked = attr.position, matrix = attr.matrix, halfLineWidth = 0.5 * attr.lineWidth, xx = matrix.getXX(), dx = matrix.getDX(), yy = matrix.getYY(), dy = matrix.getDY(), majorTicks = layout.majorTicks, majorTickSize = attr.majorTickSize, minorTicks = layout.minorTicks, minorTickSize = attr.minorTickSize, gaugeAngles;
  9535. if (majorTicks) {
  9536. switch(docked) {
  9537. case 'right':
  9538. var getRightTickFn = function(size) {
  9539. return function(position, labelText, i) {
  9540. position = surface.roundPixel(position * yy + dy) + halfLineWidth;
  9541. ctx.moveTo(0, position);
  9542. ctx.lineTo(size, position);
  9543. };
  9544. };
  9545. me.iterate(majorTicks, getRightTickFn(majorTickSize));
  9546. if (minorTicks) {
  9547. me.iterate(minorTicks, getRightTickFn(minorTickSize));
  9548. }
  9549. break;
  9550. case 'left':
  9551. var getLeftTickFn = function(size) {
  9552. return function(position, labelText, i) {
  9553. position = surface.roundPixel(position * yy + dy) + halfLineWidth;
  9554. ctx.moveTo(clipRect[2] - size, position);
  9555. ctx.lineTo(clipRect[2], position);
  9556. };
  9557. };
  9558. me.iterate(majorTicks, getLeftTickFn(majorTickSize));
  9559. if (minorTicks) {
  9560. me.iterate(minorTicks, getLeftTickFn(minorTickSize));
  9561. }
  9562. break;
  9563. case 'bottom':
  9564. var getBottomTickFn = function(size) {
  9565. return function(position, labelText, i) {
  9566. position = surface.roundPixel(position * xx + dx) - halfLineWidth;
  9567. ctx.moveTo(position, 0);
  9568. ctx.lineTo(position, size);
  9569. };
  9570. };
  9571. me.iterate(majorTicks, getBottomTickFn(majorTickSize));
  9572. if (minorTicks) {
  9573. me.iterate(minorTicks, getBottomTickFn(minorTickSize));
  9574. }
  9575. break;
  9576. case 'top':
  9577. var getTopTickFn = function(size) {
  9578. return function(position, labelText, i) {
  9579. position = surface.roundPixel(position * xx + dx) - halfLineWidth;
  9580. ctx.moveTo(position, clipRect[3]);
  9581. ctx.lineTo(position, clipRect[3] - size);
  9582. };
  9583. };
  9584. me.iterate(majorTicks, getTopTickFn(majorTickSize));
  9585. if (minorTicks) {
  9586. me.iterate(minorTicks, getTopTickFn(minorTickSize));
  9587. }
  9588. break;
  9589. case 'angular':
  9590. me.iterate(majorTicks, function(position, labelText, i) {
  9591. position = position / (attr.max + 1) * Math.PI * 2 + attr.baseRotation;
  9592. ctx.moveTo(attr.centerX + attr.length * Math.cos(position), attr.centerY + attr.length * Math.sin(position));
  9593. ctx.lineTo(attr.centerX + (attr.length + majorTickSize) * Math.cos(position), attr.centerY + (attr.length + majorTickSize) * Math.sin(position));
  9594. });
  9595. break;
  9596. case 'gauge':
  9597. gaugeAngles = me.getGaugeAngles();
  9598. me.iterate(majorTicks, function(position, labelText, i) {
  9599. position = (position - attr.min) / (attr.max - attr.min) * attr.totalAngle - attr.totalAngle + gaugeAngles.start;
  9600. ctx.moveTo(attr.centerX + attr.length * Math.cos(position), attr.centerY + attr.length * Math.sin(position));
  9601. ctx.lineTo(attr.centerX + (attr.length + majorTickSize) * Math.cos(position), attr.centerY + (attr.length + majorTickSize) * Math.sin(position));
  9602. });
  9603. break;
  9604. }
  9605. }
  9606. }, renderLabels:function(surface, ctx, layoutContext, clipRect) {
  9607. var me = this, attr = me.attr, halfLineWidth = 0.5 * attr.lineWidth, docked = attr.position, matrix = attr.matrix, textPadding = attr.textPadding, xx = matrix.getXX(), dx = matrix.getDX(), yy = matrix.getYY(), dy = matrix.getDY(), thickness = 0, majorTicks = layoutContext.majorTicks, tickPadding = Math.max(attr.majorTickSize, attr.minorTickSize) + attr.lineWidth, isBBoxIntersect = Ext.draw.Draw.isBBoxIntersect, label = me.getLabel(), font, labelOffset = me.getLabelOffset(), lastLabelText = null,
  9608. textSize = 0, textCount = 0, segmenter = layoutContext.segmenter, renderer = me.getRenderer(), axis = me.getAxis(), title = axis.getTitle(), titleBBox = title && title.attr.text !== '' && title.getBBox(), labelInverseMatrix, lastBBox = null, bbox, fly, text, titlePadding, translation, gaugeAngles, angle;
  9609. if (majorTicks && label && !label.attr.hidden) {
  9610. font = label.attr.font;
  9611. if (ctx.font !== font) {
  9612. ctx.font = font;
  9613. }
  9614. label.setAttributes({translationX:0, translationY:0}, true);
  9615. label.applyTransformations();
  9616. labelInverseMatrix = label.attr.inverseMatrix.elements.slice(0);
  9617. switch(docked) {
  9618. case 'left':
  9619. titlePadding = titleBBox ? titleBBox.x + titleBBox.width : 0;
  9620. switch(label.attr.textAlign) {
  9621. case 'start':
  9622. translation = surface.roundPixel(titlePadding + dx) - halfLineWidth;
  9623. break;
  9624. case 'end':
  9625. translation = surface.roundPixel(clipRect[2] - tickPadding + dx) - halfLineWidth;
  9626. break;
  9627. default:
  9628. translation = surface.roundPixel(titlePadding + (clipRect[2] - titlePadding - tickPadding) / 2 + dx) - halfLineWidth;
  9629. }label.setAttributes({translationX:translation}, true);
  9630. break;
  9631. case 'right':
  9632. titlePadding = titleBBox ? clipRect[2] - titleBBox.x : 0;
  9633. switch(label.attr.textAlign) {
  9634. case 'start':
  9635. translation = surface.roundPixel(tickPadding + dx) + halfLineWidth;
  9636. break;
  9637. case 'end':
  9638. translation = surface.roundPixel(clipRect[2] - titlePadding + dx) + halfLineWidth;
  9639. break;
  9640. default:
  9641. translation = surface.roundPixel(tickPadding + (clipRect[2] - tickPadding - titlePadding) / 2 + dx) + halfLineWidth;
  9642. }label.setAttributes({translationX:translation}, true);
  9643. break;
  9644. case 'top':
  9645. titlePadding = titleBBox ? titleBBox.y + titleBBox.height : 0;
  9646. label.setAttributes({translationY:surface.roundPixel(titlePadding + (clipRect[3] - titlePadding - tickPadding) / 2) - halfLineWidth}, true);
  9647. break;
  9648. case 'bottom':
  9649. titlePadding = titleBBox ? clipRect[3] - titleBBox.y : 0;
  9650. label.setAttributes({translationY:surface.roundPixel(tickPadding + (clipRect[3] - tickPadding - titlePadding) / 2) + halfLineWidth}, true);
  9651. break;
  9652. case 'radial':
  9653. label.setAttributes({translationX:attr.centerX}, true);
  9654. break;
  9655. case 'angular':
  9656. label.setAttributes({translationY:attr.centerY}, true);
  9657. break;
  9658. case 'gauge':
  9659. label.setAttributes({translationY:attr.centerY}, true);
  9660. break;
  9661. }
  9662. if (docked === 'left' || docked === 'right') {
  9663. me.iterate(majorTicks, function(position, labelText, i) {
  9664. if (labelText === undefined) {
  9665. return;
  9666. }
  9667. if (renderer) {
  9668. text = Ext.callback(renderer, null, [axis, labelText, layoutContext, lastLabelText], 0, axis);
  9669. } else {
  9670. text = segmenter.renderer(labelText, layoutContext, lastLabelText);
  9671. }
  9672. lastLabelText = labelText;
  9673. label.setAttributes({text:String(text), translationY:surface.roundPixel(position * yy + dy)}, true);
  9674. label.applyTransformations();
  9675. thickness = Math.max(thickness, label.getBBox().width + tickPadding);
  9676. fly = Ext.draw.Matrix.fly(label.attr.matrix.elements.slice(0));
  9677. bbox = fly.prepend.apply(fly, labelInverseMatrix).transformBBox(label.getBBox(true));
  9678. if (lastBBox && !isBBoxIntersect(bbox, lastBBox, textPadding)) {
  9679. return;
  9680. }
  9681. surface.renderSprite(label);
  9682. lastBBox = bbox;
  9683. textSize += bbox.height;
  9684. textCount++;
  9685. });
  9686. } else {
  9687. if (docked === 'top' || docked === 'bottom') {
  9688. me.iterate(majorTicks, function(position, labelText, i) {
  9689. if (labelText === undefined) {
  9690. return;
  9691. }
  9692. if (renderer) {
  9693. text = Ext.callback(renderer, null, [axis, labelText, layoutContext, lastLabelText], 0, axis);
  9694. } else {
  9695. text = segmenter.renderer(labelText, layoutContext, lastLabelText);
  9696. }
  9697. lastLabelText = labelText;
  9698. label.setAttributes({text:String(text), translationX:surface.roundPixel(position * xx + dx)}, true);
  9699. label.applyTransformations();
  9700. thickness = Math.max(thickness, label.getBBox().height + tickPadding);
  9701. fly = Ext.draw.Matrix.fly(label.attr.matrix.elements.slice(0));
  9702. bbox = fly.prepend.apply(fly, labelInverseMatrix).transformBBox(label.getBBox(true));
  9703. if (lastBBox && !isBBoxIntersect(bbox, lastBBox, textPadding)) {
  9704. return;
  9705. }
  9706. surface.renderSprite(label);
  9707. lastBBox = bbox;
  9708. textSize += bbox.width;
  9709. textCount++;
  9710. });
  9711. } else {
  9712. if (docked === 'radial') {
  9713. me.iterate(majorTicks, function(position, labelText, i) {
  9714. if (labelText === undefined) {
  9715. return;
  9716. }
  9717. if (renderer) {
  9718. text = Ext.callback(renderer, null, [axis, labelText, layoutContext, lastLabelText], 0, axis);
  9719. } else {
  9720. text = segmenter.renderer(labelText, layoutContext, lastLabelText);
  9721. }
  9722. lastLabelText = labelText;
  9723. if (typeof text !== 'undefined') {
  9724. label.setAttributes({text:String(text), translationX:attr.centerX - surface.roundPixel(position) / attr.max * attr.length * Math.cos(attr.baseRotation + Math.PI / 2), translationY:attr.centerY - surface.roundPixel(position) / attr.max * attr.length * Math.sin(attr.baseRotation + Math.PI / 2)}, true);
  9725. label.applyTransformations();
  9726. bbox = label.attr.matrix.transformBBox(label.getBBox(true));
  9727. if (lastBBox && !isBBoxIntersect(bbox, lastBBox)) {
  9728. return;
  9729. }
  9730. surface.renderSprite(label);
  9731. lastBBox = bbox;
  9732. textSize += bbox.width;
  9733. textCount++;
  9734. }
  9735. });
  9736. } else {
  9737. if (docked === 'angular') {
  9738. labelOffset += attr.majorTickSize + attr.lineWidth * 0.5;
  9739. me.iterate(majorTicks, function(position, labelText, i) {
  9740. if (labelText === undefined) {
  9741. return;
  9742. }
  9743. if (renderer) {
  9744. text = Ext.callback(renderer, null, [axis, labelText, layoutContext, lastLabelText], 0, axis);
  9745. } else {
  9746. text = segmenter.renderer(labelText, layoutContext, lastLabelText);
  9747. }
  9748. lastLabelText = labelText;
  9749. thickness = Math.max(thickness, Math.max(attr.majorTickSize, attr.minorTickSize) + (attr.lineCap !== 'butt' ? attr.lineWidth * 0.5 : 0));
  9750. if (typeof text !== 'undefined') {
  9751. angle = position / (attr.max + 1) * Math.PI * 2 + attr.baseRotation;
  9752. label.setAttributes({text:String(text), translationX:attr.centerX + (attr.length + labelOffset) * Math.cos(angle), translationY:attr.centerY + (attr.length + labelOffset) * Math.sin(angle)}, true);
  9753. label.applyTransformations();
  9754. bbox = label.attr.matrix.transformBBox(label.getBBox(true));
  9755. if (lastBBox && !isBBoxIntersect(bbox, lastBBox)) {
  9756. return;
  9757. }
  9758. surface.renderSprite(label);
  9759. lastBBox = bbox;
  9760. textSize += bbox.width;
  9761. textCount++;
  9762. }
  9763. });
  9764. } else {
  9765. if (docked === 'gauge') {
  9766. gaugeAngles = me.getGaugeAngles();
  9767. labelOffset += attr.majorTickSize + attr.lineWidth * 0.5;
  9768. me.iterate(majorTicks, function(position, labelText, i) {
  9769. if (labelText === undefined) {
  9770. return;
  9771. }
  9772. if (renderer) {
  9773. text = Ext.callback(renderer, null, [axis, labelText, layoutContext, lastLabelText], 0, axis);
  9774. } else {
  9775. text = segmenter.renderer(labelText, layoutContext, lastLabelText);
  9776. }
  9777. lastLabelText = labelText;
  9778. if (typeof text !== 'undefined') {
  9779. angle = (position - attr.min) / (attr.max - attr.min) * attr.totalAngle - attr.totalAngle + gaugeAngles.start;
  9780. label.setAttributes({text:String(text), translationX:attr.centerX + (attr.length + labelOffset) * Math.cos(angle), translationY:attr.centerY + (attr.length + labelOffset) * Math.sin(angle)}, true);
  9781. label.applyTransformations();
  9782. bbox = label.attr.matrix.transformBBox(label.getBBox(true));
  9783. if (lastBBox && !isBBoxIntersect(bbox, lastBBox)) {
  9784. return;
  9785. }
  9786. surface.renderSprite(label);
  9787. lastBBox = bbox;
  9788. textSize += bbox.width;
  9789. textCount++;
  9790. }
  9791. });
  9792. }
  9793. }
  9794. }
  9795. }
  9796. }
  9797. if (attr.enlargeEstStepSizeByText && textCount) {
  9798. textSize /= textCount;
  9799. textSize += tickPadding;
  9800. textSize *= 2;
  9801. if (attr.estStepSize < textSize) {
  9802. attr.estStepSize = textSize;
  9803. }
  9804. }
  9805. if (Math.abs(me.thickness - thickness) > 1) {
  9806. me.thickness = thickness;
  9807. attr.bbox.plain.dirty = true;
  9808. attr.bbox.transform.dirty = true;
  9809. me.doThicknessChanged();
  9810. return false;
  9811. }
  9812. }
  9813. }, renderAxisLine:function(surface, ctx, layout, clipRect) {
  9814. var me = this, attr = me.attr, halfLineWidth = attr.lineWidth * 0.5, docked = attr.position, position, gaugeAngles;
  9815. if (attr.axisLine && attr.length) {
  9816. switch(docked) {
  9817. case 'left':
  9818. position = surface.roundPixel(clipRect[2]) - halfLineWidth;
  9819. ctx.moveTo(position, -attr.endGap);
  9820. ctx.lineTo(position, attr.length + attr.startGap + 1);
  9821. break;
  9822. case 'right':
  9823. ctx.moveTo(halfLineWidth, -attr.endGap);
  9824. ctx.lineTo(halfLineWidth, attr.length + attr.startGap + 1);
  9825. break;
  9826. case 'bottom':
  9827. ctx.moveTo(-attr.startGap, halfLineWidth);
  9828. ctx.lineTo(attr.length + attr.endGap, halfLineWidth);
  9829. break;
  9830. case 'top':
  9831. position = surface.roundPixel(clipRect[3]) - halfLineWidth;
  9832. ctx.moveTo(-attr.startGap, position);
  9833. ctx.lineTo(attr.length + attr.endGap, position);
  9834. break;
  9835. case 'angular':
  9836. ctx.moveTo(attr.centerX + attr.length, attr.centerY);
  9837. ctx.arc(attr.centerX, attr.centerY, attr.length, 0, Math.PI * 2, true);
  9838. break;
  9839. case 'gauge':
  9840. gaugeAngles = me.getGaugeAngles();
  9841. ctx.moveTo(attr.centerX + Math.cos(gaugeAngles.start) * attr.length, attr.centerY + Math.sin(gaugeAngles.start) * attr.length);
  9842. ctx.arc(attr.centerX, attr.centerY, attr.length, gaugeAngles.start, gaugeAngles.end, true);
  9843. break;
  9844. }
  9845. }
  9846. }, getGaugeAngles:function() {
  9847. var me = this, angle = me.attr.totalAngle, offset;
  9848. if (angle <= Math.PI) {
  9849. offset = (Math.PI - angle) * 0.5;
  9850. } else {
  9851. offset = -(Math.PI * 2 - angle) * 0.5;
  9852. }
  9853. offset = Math.PI * 2 - offset;
  9854. return {start:offset, end:offset - angle};
  9855. }, renderGridLines:function(surface, ctx, layout, clipRect) {
  9856. var me = this, axis = me.getAxis(), attr = me.attr, matrix = attr.matrix, startGap = attr.startGap, endGap = attr.endGap, xx = matrix.getXX(), yy = matrix.getYY(), dx = matrix.getDX(), dy = matrix.getDY(), position = attr.position, alignment = axis.getGridAlignment(), majorTicks = layout.majorTicks, anchor, j, lastAnchor;
  9857. if (attr.grid) {
  9858. if (majorTicks) {
  9859. if (position === 'left' || position === 'right') {
  9860. lastAnchor = attr.min * yy + dy + endGap + startGap;
  9861. me.iterate(majorTicks, function(position, labelText, i) {
  9862. anchor = position * yy + dy + endGap;
  9863. me.putMarker(alignment + '-' + (i % 2 ? 'odd' : 'even'), {y:anchor, height:lastAnchor - anchor}, j = i, true);
  9864. lastAnchor = anchor;
  9865. });
  9866. j++;
  9867. anchor = 0;
  9868. me.putMarker(alignment + '-' + (j % 2 ? 'odd' : 'even'), {y:anchor, height:lastAnchor - anchor}, j, true);
  9869. } else {
  9870. if (position === 'top' || position === 'bottom') {
  9871. lastAnchor = attr.min * xx + dx + startGap;
  9872. if (startGap) {
  9873. me.putMarker(alignment + '-even', {x:0, width:lastAnchor}, -1, true);
  9874. }
  9875. me.iterate(majorTicks, function(position, labelText, i) {
  9876. anchor = position * xx + dx + startGap;
  9877. me.putMarker(alignment + '-' + (i % 2 ? 'odd' : 'even'), {x:anchor, width:lastAnchor - anchor}, j = i, true);
  9878. lastAnchor = anchor;
  9879. });
  9880. j++;
  9881. anchor = attr.length + attr.startGap + attr.endGap;
  9882. me.putMarker(alignment + '-' + (j % 2 ? 'odd' : 'even'), {x:anchor, width:lastAnchor - anchor}, j, true);
  9883. } else {
  9884. if (position === 'radial') {
  9885. me.iterate(majorTicks, function(position, labelText, i) {
  9886. if (!position) {
  9887. return;
  9888. }
  9889. anchor = position / attr.max * attr.length;
  9890. me.putMarker(alignment + '-' + (i % 2 ? 'odd' : 'even'), {scalingX:anchor, scalingY:anchor}, i, true);
  9891. lastAnchor = anchor;
  9892. });
  9893. } else {
  9894. if (position === 'angular') {
  9895. me.iterate(majorTicks, function(position, labelText, i) {
  9896. if (!attr.length) {
  9897. return;
  9898. }
  9899. anchor = position / (attr.max + 1) * Math.PI * 2 + attr.baseRotation;
  9900. me.putMarker(alignment + '-' + (i % 2 ? 'odd' : 'even'), {rotationRads:anchor, rotationCenterX:0, rotationCenterY:0, scalingX:attr.length, scalingY:attr.length}, i, true);
  9901. lastAnchor = anchor;
  9902. });
  9903. }
  9904. }
  9905. }
  9906. }
  9907. }
  9908. }
  9909. }, renderLimits:function(clipRect) {
  9910. var me = this, attr = me.attr, axis = me.getAxis(), limits = Ext.Array.from(axis.getLimits());
  9911. if (!limits.length || attr.dataMin === attr.dataMax) {
  9912. if (axis.limits) {
  9913. axis.limits.titles.attr.hidden = true;
  9914. }
  9915. return;
  9916. }
  9917. var chart = axis.getChart(), innerPadding = chart.getInnerPadding(), limitsRect = axis.limits.surface.getRect(), matrix = attr.matrix, position = attr.position, chain = Ext.Object.chain, titles = axis.limits.titles, titleBBox, titlePosition, titleFlip, limit, value, i, ln, x, y;
  9918. titles.attr.hidden = false;
  9919. titles.instances = [];
  9920. titles.position = 0;
  9921. if (position === 'left' || position === 'right') {
  9922. for (i = 0, ln = limits.length; i < ln; i++) {
  9923. limit = chain(limits[i]);
  9924. if (!limit.line) {
  9925. limit.line = {};
  9926. }
  9927. value = Ext.isString(limit.value) ? axis.getCoordFor(limit.value) : limit.value;
  9928. value = value * matrix.getYY() + matrix.getDY();
  9929. limit.line.y = value + innerPadding.top;
  9930. limit.line.strokeStyle = limit.line.strokeStyle || attr.strokeStyle;
  9931. me.putMarker('horizontal-limit-lines', limit.line, i, true);
  9932. if (limit.line.title) {
  9933. titles.add(limit.line.title);
  9934. titleBBox = titles.getBBoxFor(titles.position - 1);
  9935. titlePosition = limit.line.title.position || (position === 'left' ? 'start' : 'end');
  9936. switch(titlePosition) {
  9937. case 'start':
  9938. x = 10;
  9939. break;
  9940. case 'end':
  9941. x = limitsRect[2] - 10;
  9942. break;
  9943. case 'middle':
  9944. x = limitsRect[2] / 2;
  9945. break;
  9946. }
  9947. titles.setAttributesFor(titles.position - 1, {x:x, y:limit.line.y - titleBBox.height / 2, textAlign:titlePosition, fillStyle:limit.line.title.fillStyle || limit.line.strokeStyle});
  9948. }
  9949. }
  9950. } else {
  9951. if (position === 'top' || position === 'bottom') {
  9952. for (i = 0, ln = limits.length; i < ln; i++) {
  9953. limit = chain(limits[i]);
  9954. if (!limit.line) {
  9955. limit.line = {};
  9956. }
  9957. value = Ext.isString(limit.value) ? axis.getCoordFor(limit.value) : limit.value;
  9958. value = value * matrix.getXX() + matrix.getDX();
  9959. limit.line.x = value + innerPadding.left;
  9960. limit.line.strokeStyle = limit.line.strokeStyle || attr.strokeStyle;
  9961. me.putMarker('vertical-limit-lines', limit.line, i, true);
  9962. if (limit.line.title) {
  9963. titles.add(limit.line.title);
  9964. titleBBox = titles.getBBoxFor(titles.position - 1);
  9965. titlePosition = limit.line.title.position || (position === 'top' ? 'end' : 'start');
  9966. switch(titlePosition) {
  9967. case 'start':
  9968. y = limitsRect[3] - titleBBox.width / 2 - 10;
  9969. break;
  9970. case 'end':
  9971. y = titleBBox.width / 2 + 10;
  9972. break;
  9973. case 'middle':
  9974. y = limitsRect[3] / 2;
  9975. break;
  9976. }
  9977. titles.setAttributesFor(titles.position - 1, {x:limit.line.x + titleBBox.height / 2, y:y, fillStyle:limit.line.title.fillStyle || limit.line.strokeStyle, rotationRads:Math.PI / 2});
  9978. }
  9979. }
  9980. } else {
  9981. if (position === 'radial') {
  9982. for (i = 0, ln = limits.length; i < ln; i++) {
  9983. limit = chain(limits[i]);
  9984. if (!limit.line) {
  9985. limit.line = {};
  9986. }
  9987. value = Ext.isString(limit.value) ? axis.getCoordFor(limit.value) : limit.value;
  9988. if (value > attr.max) {
  9989. continue;
  9990. }
  9991. value = value / attr.max * attr.length;
  9992. limit.line.cx = attr.centerX;
  9993. limit.line.cy = attr.centerY;
  9994. limit.line.scalingX = value;
  9995. limit.line.scalingY = value;
  9996. limit.line.strokeStyle = limit.line.strokeStyle || attr.strokeStyle;
  9997. me.putMarker('circular-limit-lines', limit.line, i, true);
  9998. if (limit.line.title) {
  9999. titles.add(limit.line.title);
  10000. titleBBox = titles.getBBoxFor(titles.position - 1);
  10001. titles.setAttributesFor(titles.position - 1, {x:attr.centerX, y:attr.centerY - value - titleBBox.height / 2, fillStyle:limit.line.title.fillStyle || limit.line.strokeStyle});
  10002. }
  10003. }
  10004. } else {
  10005. if (position === 'angular') {
  10006. for (i = 0, ln = limits.length; i < ln; i++) {
  10007. limit = chain(limits[i]);
  10008. if (!limit.line) {
  10009. limit.line = {};
  10010. }
  10011. value = Ext.isString(limit.value) ? axis.getCoordFor(limit.value) : limit.value;
  10012. value = value / (attr.max + 1) * Math.PI * 2 + attr.baseRotation;
  10013. limit.line.translationX = attr.centerX;
  10014. limit.line.translationY = attr.centerY;
  10015. limit.line.rotationRads = value;
  10016. limit.line.rotationCenterX = 0;
  10017. limit.line.rotationCenterY = 0;
  10018. limit.line.scalingX = attr.length;
  10019. limit.line.scalingY = attr.length;
  10020. limit.line.strokeStyle = limit.line.strokeStyle || attr.strokeStyle;
  10021. me.putMarker('radial-limit-lines', limit.line, i, true);
  10022. if (limit.line.title) {
  10023. titles.add(limit.line.title);
  10024. titleBBox = titles.getBBoxFor(titles.position - 1);
  10025. titleFlip = value > -0.5 * Math.PI && value < 0.5 * Math.PI || value > 1.5 * Math.PI && value < 2 * Math.PI ? 1 : -1;
  10026. titles.setAttributesFor(titles.position - 1, {x:attr.centerX + 0.5 * attr.length * Math.cos(value) + titleFlip * titleBBox.height / 2 * Math.sin(value), y:attr.centerY + 0.5 * attr.length * Math.sin(value) - titleFlip * titleBBox.height / 2 * Math.cos(value), rotationRads:titleFlip === 1 ? value : value - Math.PI, fillStyle:limit.line.title.fillStyle || limit.line.strokeStyle});
  10027. }
  10028. }
  10029. } else {
  10030. if (position === 'gauge') {
  10031. }
  10032. }
  10033. }
  10034. }
  10035. }
  10036. }, doThicknessChanged:function() {
  10037. var axis = this.getAxis();
  10038. if (axis) {
  10039. axis.onThicknessChanged();
  10040. }
  10041. }, render:function(surface, ctx, rect) {
  10042. var me = this, layoutContext = me.getLayoutContext();
  10043. if (layoutContext) {
  10044. if (me.renderLabels(surface, ctx, layoutContext, rect) === false) {
  10045. return false;
  10046. }
  10047. ctx.beginPath();
  10048. me.renderTicks(surface, ctx, layoutContext, rect);
  10049. me.renderAxisLine(surface, ctx, layoutContext, rect);
  10050. me.renderGridLines(surface, ctx, layoutContext, rect);
  10051. me.renderLimits(rect);
  10052. ctx.stroke();
  10053. }
  10054. }});
  10055. Ext.define('Ext.chart.axis.segmenter.Segmenter', {config:{axis:null}, constructor:function(config) {
  10056. this.initConfig(config);
  10057. }, renderer:function(value, context) {
  10058. return String(value);
  10059. }, from:function(value) {
  10060. return value;
  10061. }, diff:Ext.emptyFn, align:Ext.emptyFn, add:Ext.emptyFn, preferredStep:Ext.emptyFn});
  10062. Ext.define('Ext.chart.axis.segmenter.Names', {extend:'Ext.chart.axis.segmenter.Segmenter', alias:'segmenter.names', renderer:function(value, context) {
  10063. return value;
  10064. }, diff:function(min, max, unit) {
  10065. return Math.floor(max - min);
  10066. }, align:function(value, step, unit) {
  10067. return Math.floor(value);
  10068. }, add:function(value, step, unit) {
  10069. return value + step;
  10070. }, preferredStep:function(min, estStepSize, minIdx, data) {
  10071. return {unit:1, step:1};
  10072. }});
  10073. Ext.define('Ext.chart.axis.segmenter.Numeric', {extend:'Ext.chart.axis.segmenter.Segmenter', alias:'segmenter.numeric', isNumeric:true, renderer:function(value, context) {
  10074. return value.toFixed(Math.max(0, context.majorTicks.unit.fixes));
  10075. }, diff:function(min, max, unit) {
  10076. return Math.floor((max - min) / unit.scale);
  10077. }, align:function(value, step, unit) {
  10078. var scaledStep = unit.scale * step;
  10079. return Math.floor(value / scaledStep) * scaledStep;
  10080. }, add:function(value, step, unit) {
  10081. return value + step * unit.scale;
  10082. }, preferredStep:function(min, estStepSize) {
  10083. var order = Math.floor(Math.log(estStepSize) * Math.LOG10E), scale = Math.pow(10, order);
  10084. estStepSize /= scale;
  10085. if (estStepSize < 2) {
  10086. estStepSize = 2;
  10087. } else {
  10088. if (estStepSize < 5) {
  10089. estStepSize = 5;
  10090. } else {
  10091. if (estStepSize < 10) {
  10092. estStepSize = 10;
  10093. order++;
  10094. }
  10095. }
  10096. }
  10097. return {unit:{fixes:-order, scale:scale}, step:estStepSize};
  10098. }, leadingZeros:function(n) {
  10099. return -Math.floor(Ext.Number.log10(Math.abs(n)));
  10100. }, exactStep:function(min, estStepSize) {
  10101. var stepZeros = this.leadingZeros(estStepSize), scale = Math.pow(10, stepZeros);
  10102. return {unit:{fixes:stepZeros + (estStepSize % scale === 0 ? 0 : 1), scale:estStepSize < 1 ? estStepSize : 1}, step:estStepSize < 1 ? 1 : estStepSize};
  10103. }, adjustByMajorUnit:function(step, scale, range) {
  10104. var min = range[0], max = range[1], increment = step * scale, remainder, multiplier;
  10105. multiplier = Math.max(1 / (min || 1), 1 / (increment || 1));
  10106. multiplier = multiplier > 1 ? multiplier : 1;
  10107. remainder = min * multiplier % (increment * multiplier) / multiplier;
  10108. if (remainder !== 0) {
  10109. range[0] = min - remainder + (min < 0 ? -increment : 0);
  10110. }
  10111. multiplier = Math.max(1 / (max || 1), 1 / (increment || 1));
  10112. multiplier = multiplier > 1 ? multiplier : 1;
  10113. remainder = max * multiplier % (increment * multiplier) / multiplier;
  10114. if (remainder !== 0) {
  10115. range[1] = max - remainder + (max > 0 ? increment : 0);
  10116. }
  10117. }});
  10118. Ext.define('Ext.chart.axis.segmenter.Time', {extend:'Ext.chart.axis.segmenter.Segmenter', alias:'segmenter.time', config:{step:null}, renderer:function(value, context) {
  10119. var ExtDate = Ext.Date;
  10120. switch(context.majorTicks.unit) {
  10121. case 'y':
  10122. return ExtDate.format(value, 'Y');
  10123. case 'mo':
  10124. return ExtDate.format(value, 'Y-m');
  10125. case 'd':
  10126. return ExtDate.format(value, 'Y-m-d');
  10127. }
  10128. return ExtDate.format(value, 'Y-m-d\nH:i:s');
  10129. }, from:function(value) {
  10130. return new Date(value);
  10131. }, diff:function(min, max, unit) {
  10132. if (isFinite(min)) {
  10133. min = new Date(min);
  10134. }
  10135. if (isFinite(max)) {
  10136. max = new Date(max);
  10137. }
  10138. return Ext.Date.diff(min, max, unit);
  10139. }, updateStep:function() {
  10140. var axis = this.getAxis();
  10141. if (axis && !this.isConfiguring) {
  10142. axis.performLayout();
  10143. }
  10144. }, align:function(date, step, unit) {
  10145. if (unit === 'd' && step >= 7) {
  10146. date = Ext.Date.align(date, 'd', step);
  10147. date.setDate(date.getDate() - date.getDay() + 1);
  10148. return date;
  10149. } else {
  10150. return Ext.Date.align(date, unit, step);
  10151. }
  10152. }, add:function(value, step, unit) {
  10153. return Ext.Date.add(new Date(value), unit, step);
  10154. }, timeBuckets:[{unit:Ext.Date.YEAR, steps:[1, 2, 5, 10, 20, 50, 100, 200, 500]}, {unit:Ext.Date.MONTH, steps:[1, 3, 6]}, {unit:Ext.Date.DAY, steps:[1, 7, 14]}, {unit:Ext.Date.HOUR, steps:[1, 6, 12]}, {unit:Ext.Date.MINUTE, steps:[1, 5, 15, 30]}, {unit:Ext.Date.SECOND, steps:[1, 5, 15, 30]}, {unit:Ext.Date.MILLI, steps:[1, 2, 5, 10, 20, 50, 100, 200, 500]}], getTimeBucket:function(min, max) {
  10155. var buckets = this.timeBuckets, unit, unitCount, steps, step, result, i, j;
  10156. for (i = 0; i < buckets.length; i++) {
  10157. unit = buckets[i].unit;
  10158. unitCount = this.diff(min, max, unit);
  10159. if (unitCount > 0) {
  10160. steps = buckets[i].steps;
  10161. for (j = 0; j < steps.length; j++) {
  10162. step = steps[j];
  10163. if (unitCount <= step) {
  10164. break;
  10165. }
  10166. }
  10167. result = {unit:unit, step:step};
  10168. break;
  10169. }
  10170. }
  10171. if (!result) {
  10172. result = {unit:Ext.Date.MILLI, step:1};
  10173. }
  10174. return result;
  10175. }, preferredStep:function(min, estStepSize) {
  10176. var step = this.getStep();
  10177. return step ? step : this.getTimeBucket(new Date(+min), new Date(+min + Math.ceil(estStepSize)));
  10178. }});
  10179. Ext.define('Ext.chart.axis.layout.Layout', {mixins:{observable:'Ext.mixin.Observable'}, config:{axis:null}, constructor:function(config) {
  10180. this.mixins.observable.constructor.call(this, config);
  10181. }, processData:function(series) {
  10182. var me = this, axis = me.getAxis(), direction = axis.getDirection(), boundSeries = axis.boundSeries, i, ln;
  10183. if (series) {
  10184. series['coordinate' + direction]();
  10185. } else {
  10186. for (i = 0, ln = boundSeries.length; i < ln; i++) {
  10187. boundSeries[i]['coordinate' + direction]();
  10188. }
  10189. }
  10190. }, calculateMajorTicks:function(context) {
  10191. var me = this, attr = context.attr, range = attr.max - attr.min, zoom = range / Math.max(1, attr.length) * (attr.visibleMax - attr.visibleMin), viewMin = attr.min + range * attr.visibleMin, viewMax = attr.min + range * attr.visibleMax, estStepSize = attr.estStepSize * zoom, majorTicks = me.snapEnds(context, attr.min, attr.max, estStepSize);
  10192. if (majorTicks) {
  10193. me.trimByRange(context, majorTicks, viewMin, viewMax);
  10194. context.majorTicks = majorTicks;
  10195. }
  10196. }, calculateMinorTicks:function(context) {
  10197. if (this.snapMinorEnds) {
  10198. context.minorTicks = this.snapMinorEnds(context);
  10199. }
  10200. }, calculateLayout:function(context) {
  10201. var me = this, attr = context.attr;
  10202. if (attr.length === 0) {
  10203. return null;
  10204. }
  10205. if (attr.majorTicks) {
  10206. me.calculateMajorTicks(context);
  10207. if (attr.minorTicks) {
  10208. me.calculateMinorTicks(context);
  10209. }
  10210. }
  10211. }, snapEnds:Ext.emptyFn, trimByRange:function(context, ticks, trimMin, trimMax) {
  10212. var segmenter = context.segmenter, unit = ticks.unit, beginIdx = segmenter.diff(ticks.from, trimMin, unit), endIdx = segmenter.diff(ticks.from, trimMax, unit), begin = Math.max(0, Math.ceil(beginIdx / ticks.step)), end = Math.min(ticks.steps, Math.floor(endIdx / ticks.step));
  10213. if (end < ticks.steps) {
  10214. ticks.to = segmenter.add(ticks.from, end * ticks.step, unit);
  10215. }
  10216. if (ticks.max > trimMax) {
  10217. ticks.max = ticks.to;
  10218. }
  10219. if (ticks.from < trimMin) {
  10220. ticks.from = segmenter.add(ticks.from, begin * ticks.step, unit);
  10221. while (ticks.from < trimMin) {
  10222. begin++;
  10223. ticks.from = segmenter.add(ticks.from, ticks.step, unit);
  10224. }
  10225. }
  10226. if (ticks.min < trimMin) {
  10227. ticks.min = ticks.from;
  10228. }
  10229. ticks.steps = end - begin;
  10230. }});
  10231. Ext.define('Ext.chart.axis.layout.Discrete', {extend:'Ext.chart.axis.layout.Layout', alias:'axisLayout.discrete', isDiscrete:true, processData:function() {
  10232. var me = this, axis = me.getAxis(), seriesList = axis.boundSeries, direction = axis.getDirection(), i, ln, series;
  10233. me.labels = [];
  10234. me.labelMap = {};
  10235. for (i = 0, ln = seriesList.length; i < ln; i++) {
  10236. series = seriesList[i];
  10237. if (series['get' + direction + 'Axis']() === axis) {
  10238. series['coordinate' + direction]();
  10239. }
  10240. }
  10241. axis.getSprites()[0].setAttributes({data:me.labels});
  10242. me.fireEvent('datachange', me.labels);
  10243. }, calculateLayout:function(context) {
  10244. context.data = this.labels;
  10245. this.callParent([context]);
  10246. }, calculateMajorTicks:function(context) {
  10247. var me = this, attr = context.attr, data = context.data, range = attr.max - attr.min, viewMin = attr.min + range * attr.visibleMin, viewMax = attr.min + range * attr.visibleMax, out;
  10248. out = me.snapEnds(context, Math.max(0, attr.min), Math.min(attr.max, data.length - 1), 1);
  10249. if (out) {
  10250. me.trimByRange(context, out, viewMin, viewMax);
  10251. context.majorTicks = out;
  10252. }
  10253. }, snapEnds:function(context, min, max, estStepSize) {
  10254. var data = context.data, steps;
  10255. estStepSize = Math.ceil(estStepSize);
  10256. steps = Math.floor((max - min) / estStepSize);
  10257. return {min:min, max:max, from:min, to:steps * estStepSize + min, step:estStepSize, steps:steps, unit:1, getLabel:function(currentStep) {
  10258. return data[this.from + this.step * currentStep];
  10259. }, get:function(currentStep) {
  10260. return this.from + this.step * currentStep;
  10261. }};
  10262. }, trimByRange:function(context, out, trimMin, trimMax) {
  10263. var unit = out.unit, beginIdx = Math.ceil((trimMin - out.from) / unit) * unit, endIdx = Math.floor((trimMax - out.from) / unit) * unit, begin = Math.max(0, Math.ceil(beginIdx / out.step)), end = Math.min(out.steps, Math.floor(endIdx / out.step));
  10264. if (end < out.steps) {
  10265. out.to = end;
  10266. }
  10267. if (out.max > trimMax) {
  10268. out.max = out.to;
  10269. }
  10270. if (out.from < trimMin && out.step > 0) {
  10271. out.from = out.from + begin * out.step * unit;
  10272. while (out.from < trimMin) {
  10273. begin++;
  10274. out.from += out.step * unit;
  10275. }
  10276. }
  10277. if (out.min < trimMin) {
  10278. out.min = out.from;
  10279. }
  10280. out.steps = end - begin;
  10281. }, getCoordFor:function(value, field, idx, items) {
  10282. this.labels.push(value);
  10283. return this.labels.length - 1;
  10284. }});
  10285. Ext.define('Ext.chart.axis.layout.CombineByIndex', {extend:'Ext.chart.axis.layout.Discrete', alias:'axisLayout.combineByIndex', getCoordFor:function(value, field, idx, items) {
  10286. var labels = this.labels, result = idx;
  10287. if (labels[idx] !== value) {
  10288. result = labels.push(value) - 1;
  10289. }
  10290. return result;
  10291. }});
  10292. Ext.define('Ext.chart.axis.layout.CombineDuplicate', {extend:'Ext.chart.axis.layout.Discrete', alias:'axisLayout.combineDuplicate', getCoordFor:function(value, field, idx, items) {
  10293. var result;
  10294. if (!(value in this.labelMap)) {
  10295. result = this.labelMap[value] = this.labels.length;
  10296. this.labels.push(value);
  10297. return result;
  10298. }
  10299. return this.labelMap[value];
  10300. }});
  10301. Ext.define('Ext.chart.axis.layout.Continuous', {extend:'Ext.chart.axis.layout.Layout', alias:'axisLayout.continuous', isContinuous:true, config:{adjustMinimumByMajorUnit:false, adjustMaximumByMajorUnit:false}, getCoordFor:function(value, field, idx, items) {
  10302. return +value;
  10303. }, snapEnds:function(context, min, max, estStepSize) {
  10304. var segmenter = context.segmenter, axis = this.getAxis(), noAnimation = !axis.spriteAnimationCount, majorTickSteps = axis.getMajorTickSteps(), bucket = majorTickSteps && segmenter.exactStep ? segmenter.exactStep(min, (max - min) / majorTickSteps) : segmenter.preferredStep(min, estStepSize), unit = bucket.unit, step = bucket.step, diffSteps = segmenter.diff(min, max, unit), steps = (majorTickSteps || diffSteps) + 1, from;
  10305. if (majorTickSteps || noAnimation && +segmenter.add(min, diffSteps, unit) === max) {
  10306. from = min;
  10307. } else {
  10308. from = segmenter.align(min, step, unit);
  10309. }
  10310. return {min:segmenter.from(min), max:segmenter.from(max), from:from, to:segmenter.add(from, steps, unit), step:step, steps:steps, unit:unit, get:function(currentStep) {
  10311. return segmenter.add(this.from, this.step * currentStep, this.unit);
  10312. }};
  10313. }, snapMinorEnds:function(context) {
  10314. var majorTicks = context.majorTicks, minorTickSteps = this.getAxis().getMinorTickSteps(), segmenter = context.segmenter, min = majorTicks.min, max = majorTicks.max, from = majorTicks.from, unit = majorTicks.unit, step = majorTicks.step / minorTickSteps, scaledStep = step * unit.scale, fromMargin = from - min, offset = Math.floor(fromMargin / scaledStep), extraSteps = offset + Math.floor((max - majorTicks.to) / scaledStep) + 1, steps = majorTicks.steps * minorTickSteps + extraSteps;
  10315. return {min:min, max:max, from:min + fromMargin % scaledStep, to:segmenter.add(from, steps * step, unit), step:step, steps:steps, unit:unit, get:function(current) {
  10316. return current % minorTickSteps + offset + 1 !== 0 ? segmenter.add(this.from, this.step * current, unit) : null;
  10317. }};
  10318. }});
  10319. Ext.define('Ext.chart.axis.Axis', {xtype:'axis', mixins:{observable:'Ext.mixin.Observable'}, requires:['Ext.chart.axis.sprite.Axis', 'Ext.chart.axis.segmenter.*', 'Ext.chart.axis.layout.*', 'Ext.chart.Util'], isAxis:true, config:{position:'bottom', fields:[], label:undefined, grid:false, limits:null, renderer:null, chart:null, style:null, margin:0, titleMargin:4, background:null, minimum:NaN, maximum:NaN, reconcileRange:false, minZoom:1, maxZoom:10000, layout:'continuous', segmenter:'numeric', hidden:false,
  10320. majorTickSteps:0, minorTickSteps:0, adjustByMajorUnit:true, title:null, expandRangeBy:0, length:0, center:null, radius:null, totalAngle:Math.PI, rotation:null, visibleRange:[0, 1], needHighPrecision:false, linkedTo:null, floating:null}, titleOffset:0, spriteAnimationCount:0, boundSeries:[], sprites:null, surface:null, range:null, defaultRange:[0, 1], rangePadding:0.5, xValues:[], yValues:[], masterAxis:null, applyRotation:function(rotation) {
  10321. var twoPie = Math.PI * 2;
  10322. return (rotation % twoPie + Math.PI) % twoPie - Math.PI;
  10323. }, updateRotation:function(rotation) {
  10324. var sprites = this.getSprites(), position = this.getPosition();
  10325. if (!this.getHidden() && position === 'angular' && sprites[0]) {
  10326. sprites[0].setAttributes({baseRotation:rotation});
  10327. }
  10328. }, applyTitle:function(title, oldTitle) {
  10329. var surface;
  10330. if (Ext.isString(title)) {
  10331. title = {text:title};
  10332. }
  10333. if (!oldTitle) {
  10334. oldTitle = Ext.create('sprite.text', title);
  10335. if (surface = this.getSurface()) {
  10336. surface.add(oldTitle);
  10337. }
  10338. } else {
  10339. oldTitle.setAttributes(title);
  10340. }
  10341. return oldTitle;
  10342. }, getAdjustByMajorUnit:function() {
  10343. return !this.getHidden() && this.callParent();
  10344. }, applyFloating:function(floating, oldFloating) {
  10345. if (floating === null) {
  10346. floating = {value:null, alongAxis:null};
  10347. } else {
  10348. if (Ext.isNumber(floating)) {
  10349. floating = {value:floating, alongAxis:null};
  10350. }
  10351. }
  10352. if (Ext.isObject(floating)) {
  10353. if (oldFloating && oldFloating.alongAxis) {
  10354. delete this.getChart().getAxis(oldFloating.alongAxis).floatingAxes[this.getId()];
  10355. }
  10356. return floating;
  10357. }
  10358. return oldFloating;
  10359. }, constructor:function(config) {
  10360. var me = this, id;
  10361. me.sprites = [];
  10362. me.labels = [];
  10363. me.floatingAxes = {};
  10364. config = config || {};
  10365. if (config.position === 'angular') {
  10366. config.style = config.style || {};
  10367. config.style.estStepSize = 1;
  10368. }
  10369. if ('id' in config) {
  10370. id = config.id;
  10371. } else {
  10372. if ('id' in me.config) {
  10373. id = me.config.id;
  10374. } else {
  10375. id = me.getId();
  10376. }
  10377. }
  10378. me.setId(id);
  10379. me.mixins.observable.constructor.apply(me, arguments);
  10380. }, getAlignment:function() {
  10381. switch(this.getPosition()) {
  10382. case 'left':
  10383. case 'right':
  10384. return 'vertical';
  10385. case 'top':
  10386. case 'bottom':
  10387. return 'horizontal';
  10388. case 'radial':
  10389. return 'radial';
  10390. case 'angular':
  10391. return 'angular';
  10392. }
  10393. }, getGridAlignment:function() {
  10394. switch(this.getPosition()) {
  10395. case 'left':
  10396. case 'right':
  10397. return 'horizontal';
  10398. case 'top':
  10399. case 'bottom':
  10400. return 'vertical';
  10401. case 'radial':
  10402. return 'circular';
  10403. case 'angular':
  10404. return 'radial';
  10405. }
  10406. }, getSurface:function() {
  10407. var me = this, chart = me.getChart(), surface, gridSurface;
  10408. if (chart && !me.surface) {
  10409. surface = me.surface = chart.getSurface(me.getId(), 'axis');
  10410. gridSurface = me.gridSurface = chart.getSurface('main');
  10411. gridSurface.waitFor(surface);
  10412. me.getGrid();
  10413. me.createLimits();
  10414. }
  10415. return me.surface;
  10416. }, createLimits:function() {
  10417. var me = this, chart = me.getChart(), axisSprite = me.getSprites()[0], gridAlignment = me.getGridAlignment(), limits;
  10418. if (me.getLimits() && gridAlignment) {
  10419. gridAlignment = gridAlignment.replace('3d', '');
  10420. me.limits = limits = {surface:chart.getSurface('overlay'), lines:new Ext.chart.Markers, titles:new Ext.draw.sprite.Instancing};
  10421. limits.lines.setTemplate({xclass:'grid.' + gridAlignment});
  10422. limits.lines.getTemplate().setAttributes({strokeStyle:'black'}, true);
  10423. limits.surface.add(limits.lines);
  10424. axisSprite.bindMarker(gridAlignment + '-limit-lines', me.limits.lines);
  10425. me.limitTitleTpl = new Ext.draw.sprite.Text;
  10426. limits.titles.setTemplate(me.limitTitleTpl);
  10427. limits.surface.add(limits.titles);
  10428. }
  10429. }, applyGrid:function(grid) {
  10430. if (grid === true) {
  10431. return {};
  10432. }
  10433. return grid;
  10434. }, updateGrid:function(grid) {
  10435. var me = this, chart = me.getChart(), gridSurface = me.gridSurface, axisSprite, gridAlignment, gridSprite;
  10436. if (!chart) {
  10437. me.on({chartattached:Ext.bind(me.updateGrid, me, [grid]), single:true});
  10438. return;
  10439. }
  10440. axisSprite = me.getSprites()[0];
  10441. gridAlignment = me.getGridAlignment();
  10442. if (grid) {
  10443. gridSprite = me.gridSpriteEven;
  10444. if (!gridSprite) {
  10445. gridSprite = me.gridSpriteEven = new Ext.chart.Markers;
  10446. gridSprite.setTemplate({xclass:'grid.' + gridAlignment});
  10447. gridSurface.add(gridSprite);
  10448. axisSprite.bindMarker(gridAlignment + '-even', gridSprite);
  10449. }
  10450. if (Ext.isObject(grid)) {
  10451. gridSprite.getTemplate().setAttributes(grid);
  10452. if (Ext.isObject(grid.even)) {
  10453. gridSprite.getTemplate().setAttributes(grid.even);
  10454. }
  10455. }
  10456. gridSprite = me.gridSpriteOdd;
  10457. if (!gridSprite) {
  10458. gridSprite = me.gridSpriteOdd = new Ext.chart.Markers;
  10459. gridSprite.setTemplate({xclass:'grid.' + gridAlignment});
  10460. gridSurface.add(gridSprite);
  10461. axisSprite.bindMarker(gridAlignment + '-odd', gridSprite);
  10462. }
  10463. if (Ext.isObject(grid)) {
  10464. gridSprite.getTemplate().setAttributes(grid);
  10465. if (Ext.isObject(grid.odd)) {
  10466. gridSprite.getTemplate().setAttributes(grid.odd);
  10467. }
  10468. }
  10469. }
  10470. }, updateMinorTickSteps:function(minorTickSteps) {
  10471. var me = this, sprites = me.getSprites(), axisSprite = sprites && sprites[0], surface;
  10472. if (axisSprite) {
  10473. axisSprite.setAttributes({minorTicks:!!minorTickSteps});
  10474. surface = me.getSurface();
  10475. if (!me.isConfiguring && surface) {
  10476. surface.renderFrame();
  10477. }
  10478. }
  10479. }, getCoordFor:function(value, field, idx, items) {
  10480. return this.getLayout().getCoordFor(value, field, idx, items);
  10481. }, applyPosition:function(pos) {
  10482. return pos.toLowerCase();
  10483. }, applyLength:function(length, oldLength) {
  10484. return length > 0 ? length : oldLength;
  10485. }, applyLabel:function(label, oldLabel) {
  10486. if (!oldLabel) {
  10487. oldLabel = new Ext.draw.sprite.Text({});
  10488. }
  10489. if (label) {
  10490. if (this.limitTitleTpl) {
  10491. this.limitTitleTpl.setAttributes(label);
  10492. }
  10493. oldLabel.setAttributes(label);
  10494. }
  10495. return oldLabel;
  10496. }, applyLayout:function(layout, oldLayout) {
  10497. layout = Ext.factory(layout, null, oldLayout, 'axisLayout');
  10498. layout.setAxis(this);
  10499. return layout;
  10500. }, applySegmenter:function(segmenter, oldSegmenter) {
  10501. segmenter = Ext.factory(segmenter, null, oldSegmenter, 'segmenter');
  10502. segmenter.setAxis(this);
  10503. return segmenter;
  10504. }, updateMinimum:function() {
  10505. this.range = null;
  10506. }, updateMaximum:function() {
  10507. this.range = null;
  10508. }, hideLabels:function() {
  10509. this.getSprites()[0].setDirty(true);
  10510. this.setLabel({hidden:true});
  10511. }, showLabels:function() {
  10512. this.getSprites()[0].setDirty(true);
  10513. this.setLabel({hidden:false});
  10514. }, renderFrame:function() {
  10515. this.getSurface().renderFrame();
  10516. }, updateChart:function(newChart, oldChart) {
  10517. var me = this, surface;
  10518. if (oldChart) {
  10519. oldChart.unregister(me);
  10520. oldChart.un('serieschange', me.onSeriesChange, me);
  10521. me.linkAxis();
  10522. me.fireEvent('chartdetached', oldChart, me);
  10523. }
  10524. if (newChart) {
  10525. newChart.on('serieschange', me.onSeriesChange, me);
  10526. me.surface = null;
  10527. surface = me.getSurface();
  10528. me.getLabel().setSurface(surface);
  10529. surface.add(me.getSprites());
  10530. surface.add(me.getTitle());
  10531. newChart.register(me);
  10532. me.fireEvent('chartattached', newChart, me);
  10533. }
  10534. }, applyBackground:function(background) {
  10535. var rect = Ext.ClassManager.getByAlias('sprite.rect');
  10536. return rect.def.normalize(background);
  10537. }, processData:function() {
  10538. this.getLayout().processData();
  10539. this.range = null;
  10540. }, getDirection:function() {
  10541. return this.getChart().getDirectionForAxis(this.getPosition());
  10542. }, isSide:function() {
  10543. var position = this.getPosition();
  10544. return position === 'left' || position === 'right';
  10545. }, applyFields:function(fields) {
  10546. return Ext.Array.from(fields);
  10547. }, applyVisibleRange:function(visibleRange, oldVisibleRange) {
  10548. var temp;
  10549. this.getChart();
  10550. if (visibleRange[0] > visibleRange[1]) {
  10551. temp = visibleRange[0];
  10552. visibleRange[0] = visibleRange[1];
  10553. visibleRange[0] = temp;
  10554. }
  10555. if (visibleRange[1] === visibleRange[0]) {
  10556. visibleRange[1] += 1 / this.getMaxZoom();
  10557. }
  10558. if (visibleRange[1] > visibleRange[0] + 1) {
  10559. visibleRange[0] = 0;
  10560. visibleRange[1] = 1;
  10561. } else {
  10562. if (visibleRange[0] < 0) {
  10563. visibleRange[1] -= visibleRange[0];
  10564. visibleRange[0] = 0;
  10565. } else {
  10566. if (visibleRange[1] > 1) {
  10567. visibleRange[0] -= visibleRange[1] - 1;
  10568. visibleRange[1] = 1;
  10569. }
  10570. }
  10571. }
  10572. if (oldVisibleRange && visibleRange[0] === oldVisibleRange[0] && visibleRange[1] === oldVisibleRange[1]) {
  10573. return undefined;
  10574. }
  10575. return visibleRange;
  10576. }, updateVisibleRange:function(visibleRange) {
  10577. this.fireEvent('visiblerangechange', this, visibleRange);
  10578. }, onSeriesChange:function(chart) {
  10579. var me = this, series = chart.getSeries(), boundSeries = [], linkedTo, masterAxis, getAxisMethod, i, ln;
  10580. if (series) {
  10581. getAxisMethod = 'get' + me.getDirection() + 'Axis';
  10582. for (i = 0, ln = series.length; i < ln; i++) {
  10583. if (this === series[i][getAxisMethod]()) {
  10584. boundSeries.push(series[i]);
  10585. }
  10586. }
  10587. }
  10588. me.boundSeries = boundSeries;
  10589. linkedTo = me.getLinkedTo();
  10590. masterAxis = !Ext.isEmpty(linkedTo) && chart.getAxis(linkedTo);
  10591. if (masterAxis) {
  10592. me.linkAxis(masterAxis);
  10593. } else {
  10594. me.getLayout().processData();
  10595. }
  10596. }, linkAxis:function(masterAxis) {
  10597. var me = this;
  10598. function link(action, slave, master) {
  10599. master.getLayout()[action]('datachange', 'onDataChange', slave);
  10600. master[action]('rangechange', 'onMasterAxisRangeChange', slave);
  10601. }
  10602. if (me.masterAxis) {
  10603. if (!me.masterAxis.destroyed) {
  10604. link('un', me, me.masterAxis);
  10605. }
  10606. me.masterAxis = null;
  10607. }
  10608. if (masterAxis) {
  10609. if (masterAxis.type !== this.type) {
  10610. Ext.Error.raise('Linked axes must be of the same type.');
  10611. }
  10612. link('on', me, masterAxis);
  10613. me.onDataChange(masterAxis.getLayout().labels);
  10614. me.onMasterAxisRangeChange(masterAxis, masterAxis.range);
  10615. me.setStyle(Ext.apply({}, me.config.style, masterAxis.config.style));
  10616. me.setTitle(Ext.apply({}, me.config.title, masterAxis.config.title));
  10617. me.setLabel(Ext.apply({}, me.config.label, masterAxis.config.label));
  10618. me.masterAxis = masterAxis;
  10619. }
  10620. }, onDataChange:function(data) {
  10621. this.getLayout().labels = data;
  10622. }, onMasterAxisRangeChange:function(masterAxis, range) {
  10623. this.range = range;
  10624. }, applyRange:function(newRange) {
  10625. if (!newRange) {
  10626. return this.dataRange.slice(0);
  10627. } else {
  10628. return [newRange[0] === null ? this.dataRange[0] : newRange[0], newRange[1] === null ? this.dataRange[1] : newRange[1]];
  10629. }
  10630. }, setBoundSeriesRange:function(range) {
  10631. var boundSeries = this.boundSeries, style = {}, series, i, sprites, j, ln;
  10632. style['range' + this.getDirection()] = range;
  10633. for (i = 0, ln = boundSeries.length; i < ln; i++) {
  10634. series = boundSeries[i];
  10635. if (series.getHidden() === true) {
  10636. continue;
  10637. }
  10638. sprites = series.getSprites();
  10639. for (j = 0; j < sprites.length; j++) {
  10640. sprites[j].setAttributes(style);
  10641. }
  10642. }
  10643. }, getRange:function(recalculate) {
  10644. var me = this, range = recalculate ? null : me.range, oldRange = me.oldRange, minimum, maximum;
  10645. if (!range) {
  10646. if (me.masterAxis) {
  10647. range = me.masterAxis.range;
  10648. } else {
  10649. minimum = me.getMinimum();
  10650. maximum = me.getMaximum();
  10651. if (Ext.isNumber(minimum) && Ext.isNumber(maximum)) {
  10652. range = [minimum, maximum];
  10653. } else {
  10654. range = me.calculateRange();
  10655. }
  10656. me.range = range;
  10657. }
  10658. }
  10659. if (range && (!oldRange || range[0] !== oldRange[0] || range[1] !== oldRange[1])) {
  10660. me.fireEvent('rangechange', me, range, oldRange);
  10661. me.oldRange = range;
  10662. }
  10663. return range;
  10664. }, isSingleDataPoint:function(range) {
  10665. return range[0] + this.rangePadding === 0 && range[1] - this.rangePadding === 0;
  10666. }, calculateRange:function() {
  10667. var me = this, boundSeries = me.boundSeries, layout = me.getLayout(), segmenter = me.getSegmenter(), minimum = me.getMinimum(), maximum = me.getMaximum(), visibleRange = me.getVisibleRange(), getRangeMethod = 'get' + me.getDirection() + 'Range', expandRangeBy = me.getExpandRangeBy(), context, attr, majorTicks, series, i, ln, seriesRange, range = [NaN, NaN];
  10668. for (i = 0, ln = boundSeries.length; i < ln; i++) {
  10669. series = boundSeries[i];
  10670. if (series.getHidden() === true) {
  10671. continue;
  10672. }
  10673. seriesRange = series[getRangeMethod]();
  10674. if (seriesRange) {
  10675. Ext.chart.Util.expandRange(range, seriesRange);
  10676. }
  10677. }
  10678. range = Ext.chart.Util.validateRange(range, me.defaultRange, me.rangePadding);
  10679. if (expandRangeBy && !me.isSingleDataPoint(range)) {
  10680. range[0] -= expandRangeBy;
  10681. range[1] += expandRangeBy;
  10682. }
  10683. if (isFinite(minimum)) {
  10684. range[0] = minimum;
  10685. }
  10686. if (isFinite(maximum)) {
  10687. range[1] = maximum;
  10688. }
  10689. range[0] = Ext.Number.correctFloat(range[0]);
  10690. range[1] = Ext.Number.correctFloat(range[1]);
  10691. me.range = range;
  10692. if (me.getReconcileRange()) {
  10693. me.reconcileRange();
  10694. }
  10695. if (range[0] !== range[1] && me.getAdjustByMajorUnit() && segmenter.adjustByMajorUnit && !me.getMajorTickSteps()) {
  10696. attr = Ext.Object.chain(me.getSprites()[0].attr);
  10697. attr.min = range[0];
  10698. attr.max = range[1];
  10699. attr.visibleMin = visibleRange[0];
  10700. attr.visibleMax = visibleRange[1];
  10701. context = {attr:attr, segmenter:segmenter};
  10702. layout.calculateLayout(context);
  10703. majorTicks = context.majorTicks;
  10704. if (majorTicks) {
  10705. segmenter.adjustByMajorUnit(majorTicks.step, majorTicks.unit.scale, range);
  10706. attr.min = range[0];
  10707. attr.max = range[1];
  10708. context.majorTicks = null;
  10709. layout.calculateLayout(context);
  10710. majorTicks = context.majorTicks;
  10711. segmenter.adjustByMajorUnit(majorTicks.step, majorTicks.unit.scale, range);
  10712. } else {
  10713. if (!me.hasClearRangePending) {
  10714. me.hasClearRangePending = true;
  10715. me.getChart().on('layout', 'clearRange', me);
  10716. }
  10717. }
  10718. }
  10719. return range;
  10720. }, clearRange:function() {
  10721. this.hasClearRangePending = null;
  10722. this.range = null;
  10723. }, reconcileRange:function() {
  10724. var me = this, axes = me.getChart().getAxes(), direction = me.getDirection(), i, ln, axis, range;
  10725. if (!axes) {
  10726. return;
  10727. }
  10728. for (i = 0, ln = axes.length; i < ln; i++) {
  10729. axis = axes[i];
  10730. range = axis.getRange();
  10731. if (axis === me || axis.getDirection() !== direction || !range || !axis.getReconcileRange()) {
  10732. continue;
  10733. }
  10734. if (range[0] < me.range[0]) {
  10735. me.range[0] = range[0];
  10736. }
  10737. if (range[1] > me.range[1]) {
  10738. me.range[1] = range[1];
  10739. }
  10740. }
  10741. }, applyStyle:function(style, oldStyle) {
  10742. var cls = Ext.ClassManager.getByAlias('sprite.' + this.seriesType);
  10743. if (cls && cls.def) {
  10744. style = cls.def.normalize(style);
  10745. }
  10746. oldStyle = Ext.apply(oldStyle || {}, style);
  10747. return oldStyle;
  10748. }, themeOnlyIfConfigured:{grid:true}, updateTheme:function(theme) {
  10749. var me = this, axisTheme = theme.getAxis(), position = me.getPosition(), initialConfig = me.getInitialConfig(), defaultConfig = me.defaultConfig, configs = me.self.getConfigurator().configs, genericAxisTheme = axisTheme.defaults, specificAxisTheme = axisTheme[position], themeOnlyIfConfigured = me.themeOnlyIfConfigured, key, value, isObjValue, isUnusedConfig, initialValue, cfg;
  10750. axisTheme = Ext.merge({}, genericAxisTheme, specificAxisTheme);
  10751. for (key in axisTheme) {
  10752. value = axisTheme[key];
  10753. cfg = configs[key];
  10754. if (value !== null && value !== undefined && cfg) {
  10755. initialValue = initialConfig[key];
  10756. isObjValue = Ext.isObject(value);
  10757. isUnusedConfig = initialValue === defaultConfig[key];
  10758. if (isObjValue) {
  10759. if (isUnusedConfig && themeOnlyIfConfigured[key]) {
  10760. continue;
  10761. }
  10762. value = Ext.merge({}, value, initialValue);
  10763. }
  10764. if (isUnusedConfig || isObjValue) {
  10765. me[cfg.names.set](value);
  10766. }
  10767. }
  10768. }
  10769. }, updateCenter:function(center) {
  10770. var me = this, sprites = me.getSprites(), axisSprite = sprites[0], centerX = center[0], centerY = center[1];
  10771. if (axisSprite) {
  10772. axisSprite.setAttributes({centerX:centerX, centerY:centerY});
  10773. }
  10774. if (me.gridSpriteEven) {
  10775. me.gridSpriteEven.getTemplate().setAttributes({translationX:centerX, translationY:centerY, rotationCenterX:centerX, rotationCenterY:centerY});
  10776. }
  10777. if (me.gridSpriteOdd) {
  10778. me.gridSpriteOdd.getTemplate().setAttributes({translationX:centerX, translationY:centerY, rotationCenterX:centerX, rotationCenterY:centerY});
  10779. }
  10780. }, getSprites:function() {
  10781. if (!this.getChart()) {
  10782. return;
  10783. }
  10784. var me = this, range = me.getRange(), position = me.getPosition(), chart = me.getChart(), animation = chart.getAnimation(), length = me.getLength(), axisClass = me.superclass, mainSprite, style, animationModifier;
  10785. if (animation === false) {
  10786. animation = {duration:0};
  10787. }
  10788. style = Ext.applyIf({position:position, axis:me, length:length, grid:me.getGrid(), hidden:me.getHidden(), titleOffset:me.titleOffset, layout:me.getLayout(), segmenter:me.getSegmenter(), totalAngle:me.getTotalAngle(), label:me.getLabel()}, me.getStyle());
  10789. if (range) {
  10790. style.min = range[0];
  10791. style.max = range[1];
  10792. }
  10793. if (!me.sprites.length) {
  10794. while (!axisClass.xtype) {
  10795. axisClass = axisClass.superclass;
  10796. }
  10797. mainSprite = Ext.create('sprite.' + axisClass.xtype, style);
  10798. animationModifier = mainSprite.getAnimation();
  10799. animationModifier.setCustomDurations({baseRotation:0});
  10800. animationModifier.on('animationstart', 'onAnimationStart', me);
  10801. animationModifier.on('animationend', 'onAnimationEnd', me);
  10802. mainSprite.setLayout(me.getLayout());
  10803. mainSprite.setSegmenter(me.getSegmenter());
  10804. mainSprite.setLabel(me.getLabel());
  10805. me.sprites.push(mainSprite);
  10806. me.updateTitleSprite();
  10807. } else {
  10808. mainSprite = me.sprites[0];
  10809. mainSprite.setAnimation(animation);
  10810. mainSprite.setAttributes(style);
  10811. }
  10812. if (me.getRenderer()) {
  10813. mainSprite.setRenderer(me.getRenderer());
  10814. }
  10815. return me.sprites;
  10816. }, performLayout:function() {
  10817. if (this.isConfiguring) {
  10818. return;
  10819. }
  10820. var me = this, sprites = me.getSprites(), surface = me.getSurface(), chart = me.getChart(), sprite = sprites && sprites[0];
  10821. if (chart && surface && sprite) {
  10822. sprite.callUpdater(null, 'layout');
  10823. chart.scheduleLayout();
  10824. }
  10825. }, updateTitleSprite:function() {
  10826. var me = this, length = me.getLength(), surface, thickness, title, position, margin, titleMargin, anchor;
  10827. if (!me.sprites[0] || !Ext.isNumber(length)) {
  10828. return;
  10829. }
  10830. thickness = this.sprites[0].thickness;
  10831. surface = me.getSurface();
  10832. title = me.getTitle();
  10833. position = me.getPosition();
  10834. margin = me.getMargin();
  10835. titleMargin = me.getTitleMargin();
  10836. anchor = surface.roundPixel(length / 2);
  10837. if (title) {
  10838. switch(position) {
  10839. case 'top':
  10840. title.setAttributes({x:anchor, y:margin + titleMargin / 2, textBaseline:'top', textAlign:'center'}, true);
  10841. title.applyTransformations();
  10842. me.titleOffset = title.getBBox().height + titleMargin;
  10843. break;
  10844. case 'bottom':
  10845. title.setAttributes({x:anchor, y:thickness + titleMargin / 2, textBaseline:'top', textAlign:'center'}, true);
  10846. title.applyTransformations();
  10847. me.titleOffset = title.getBBox().height + titleMargin;
  10848. break;
  10849. case 'left':
  10850. title.setAttributes({x:margin + titleMargin / 2, y:anchor, textBaseline:'top', textAlign:'center', rotationCenterX:margin + titleMargin / 2, rotationCenterY:anchor, rotationRads:-Math.PI / 2}, true);
  10851. title.applyTransformations();
  10852. me.titleOffset = title.getBBox().width + titleMargin;
  10853. break;
  10854. case 'right':
  10855. title.setAttributes({x:thickness - margin + titleMargin / 2, y:anchor, textBaseline:'bottom', textAlign:'center', rotationCenterX:thickness + titleMargin / 2, rotationCenterY:anchor, rotationRads:Math.PI / 2}, true);
  10856. title.applyTransformations();
  10857. me.titleOffset = title.getBBox().width + titleMargin;
  10858. break;
  10859. }
  10860. }
  10861. }, onThicknessChanged:function() {
  10862. this.getChart().onThicknessChanged();
  10863. }, getThickness:function() {
  10864. if (this.getHidden()) {
  10865. return 0;
  10866. }
  10867. return (this.sprites[0] && this.sprites[0].thickness || 1) + this.titleOffset + this.getMargin();
  10868. }, onAnimationStart:function() {
  10869. this.spriteAnimationCount++;
  10870. if (this.spriteAnimationCount === 1) {
  10871. this.fireEvent('animationstart', this);
  10872. }
  10873. }, onAnimationEnd:function() {
  10874. this.spriteAnimationCount--;
  10875. if (this.spriteAnimationCount === 0) {
  10876. this.fireEvent('animationend', this);
  10877. }
  10878. }, getItemId:function() {
  10879. return this.getId();
  10880. }, getAncestorIds:function() {
  10881. return [this.getChart().getId()];
  10882. }, isXType:function(xtype) {
  10883. return xtype === 'axis';
  10884. }, resolveListenerScope:function(defaultScope) {
  10885. var me = this, namedScope = Ext._namedScopes[defaultScope], chart = me.getChart(), scope;
  10886. if (!namedScope) {
  10887. scope = chart ? chart.resolveListenerScope(defaultScope, false) : defaultScope || me;
  10888. } else {
  10889. if (namedScope.isThis) {
  10890. scope = me;
  10891. } else {
  10892. if (namedScope.isController) {
  10893. scope = chart ? chart.resolveListenerScope(defaultScope, false) : me;
  10894. } else {
  10895. if (namedScope.isSelf) {
  10896. scope = chart ? chart.resolveListenerScope(defaultScope, false) : me;
  10897. if (scope === chart && !chart.getInheritedConfig('defaultListenerScope')) {
  10898. scope = me;
  10899. }
  10900. }
  10901. }
  10902. }
  10903. }
  10904. return scope;
  10905. }, destroy:function() {
  10906. var me = this;
  10907. me.setChart(null);
  10908. me.surface.destroy();
  10909. me.surface = null;
  10910. me.callParent();
  10911. }});
  10912. Ext.define('Ext.chart.legend.LegendBase', {extend:'Ext.dataview.DataView', config:{itemTpl:['\x3cspan class\x3d"', Ext.baseCSSPrefix, "legend-item-marker {[ values.disabled ? Ext.baseCSSPrefix + 'legend-item-inactive' : '' ]}\" style\x3d\"background:{mark};\"\x3e\x3c/span\x3e{name}"], inline:true, scrollable:false}, constructor:function(config) {
  10913. var scroller, onDrag;
  10914. this.callParent([config]);
  10915. scroller = this.getScrollable();
  10916. onDrag = scroller.onDrag;
  10917. scroller.onDrag = function(e) {
  10918. e.stopPropagation();
  10919. onDrag.call(this, e);
  10920. };
  10921. }, updateDocked:function(docked, oldDocked) {
  10922. var me = this, el = me.el;
  10923. me.callParent([docked, oldDocked]);
  10924. switch(docked) {
  10925. case 'top':
  10926. case 'bottom':
  10927. el.addCls(me.horizontalCls);
  10928. el.removeCls(me.verticalCls);
  10929. break;
  10930. case 'left':
  10931. case 'right':
  10932. el.addCls(me.verticalCls);
  10933. el.removeCls(me.horizontalCls);
  10934. break;
  10935. }
  10936. }, onChildTap:function(context) {
  10937. this.callParent([context]);
  10938. this.toggleItem(context.viewIndex);
  10939. }});
  10940. Ext.define('Ext.chart.legend.Legend', {extend:'Ext.chart.legend.LegendBase', alternateClassName:'Ext.chart.Legend', xtype:'legend', alias:'legend.dom', type:'dom', isLegend:true, isDomLegend:true, config:{rect:null, toggleable:true}, baseCls:Ext.baseCSSPrefix + 'legend', horizontalCls:Ext.baseCSSPrefix + 'legend-horizontal', verticalCls:Ext.baseCSSPrefix + 'legend-vertical', toggleItem:function(index) {
  10941. var disabledCount = 0, canToggle = true, disabled, store, count, record, i;
  10942. if (!this.getToggleable()) {
  10943. return;
  10944. }
  10945. store = this.getStore();
  10946. if (store) {
  10947. count = store.getCount();
  10948. for (i = 0; i < count; i++) {
  10949. record = store.getAt(i);
  10950. if (record.get('disabled')) {
  10951. disabledCount++;
  10952. }
  10953. }
  10954. canToggle = count - disabledCount > 1;
  10955. record = store.getAt(index);
  10956. if (record) {
  10957. disabled = record.get('disabled');
  10958. if (disabled || canToggle) {
  10959. record.set('disabled', !disabled);
  10960. }
  10961. }
  10962. }
  10963. }, onResize:function(width, height, oldWidth, oldHeight) {
  10964. var me = this, chart = me.chart;
  10965. if (!me.isConfiguring) {
  10966. if (chart) {
  10967. chart.scheduleLayout();
  10968. }
  10969. }
  10970. }});
  10971. Ext.define('Ext.chart.legend.sprite.Item', {extend:'Ext.draw.sprite.Composite', alias:'sprite.legenditem', type:'legenditem', isLegendItem:true, requires:['Ext.draw.sprite.Text', 'Ext.draw.sprite.Circle'], inheritableStatics:{def:{processors:{enabled:'limited01', markerLabelGap:'number'}, animationProcessors:{enabled:null, markerLabelGap:null}, defaults:{enabled:true, markerLabelGap:5}, triggers:{enabled:'enabled', markerLabelGap:'layout'}, updaters:{layout:'layoutUpdater', enabled:'enabledUpdater'}}},
  10972. config:{label:{$value:{type:'text'}, lazy:true}, marker:{$value:{type:'circle'}, lazy:true}, legend:null, store:null, record:null, series:null}, applyLabel:function(label, oldLabel) {
  10973. var sprite;
  10974. if (label) {
  10975. if (label.isSprite && label.type === 'text') {
  10976. sprite = label;
  10977. } else {
  10978. if (oldLabel && label.type === oldLabel.type) {
  10979. oldLabel.setConfig(label);
  10980. sprite = oldLabel;
  10981. this.scheduleUpdater(this.attr, 'layout');
  10982. } else {
  10983. sprite = new Ext.draw.sprite.Text(label);
  10984. }
  10985. }
  10986. }
  10987. return sprite;
  10988. }, defaultMarkerSize:10, updateLabel:function(label, oldLabel) {
  10989. var me = this;
  10990. me.removeSprite(oldLabel);
  10991. label.setAttributes({textBaseline:'middle'});
  10992. me.addSprite(label);
  10993. me.scheduleUpdater(me.attr, 'layout');
  10994. }, applyMarker:function(config) {
  10995. var marker;
  10996. if (config) {
  10997. if (config.isSprite) {
  10998. marker = config;
  10999. } else {
  11000. marker = this.createMarker(config);
  11001. }
  11002. }
  11003. marker = this.resetMarker(marker, config);
  11004. return marker;
  11005. }, createMarker:function(config) {
  11006. var marker;
  11007. delete config.animation;
  11008. if (config.type === 'image') {
  11009. delete config.width;
  11010. delete config.height;
  11011. }
  11012. marker = Ext.create('sprite.' + config.type, config);
  11013. return marker;
  11014. }, resetMarker:function(sprite, config) {
  11015. var size = config.size || this.defaultMarkerSize, bbox, max, scale;
  11016. sprite.setTransform([1, 0, 0, 1, 0, 0], true);
  11017. if (config.type === 'image') {
  11018. sprite.setAttributes({width:size, height:size});
  11019. } else {
  11020. bbox = sprite.getBBox();
  11021. max = Math.max(bbox.width, bbox.height);
  11022. scale = size / max;
  11023. sprite.setAttributes({scalingX:scale, scalingY:scale});
  11024. }
  11025. return sprite;
  11026. }, updateMarker:function(marker, oldMarker) {
  11027. var me = this;
  11028. me.removeSprite(oldMarker);
  11029. me.addSprite(marker);
  11030. me.scheduleUpdater(me.attr, 'layout');
  11031. }, updateSurface:function(surface, oldSurface) {
  11032. var me = this;
  11033. me.callParent([surface, oldSurface]);
  11034. if (surface) {
  11035. me.scheduleUpdater(me.attr, 'layout');
  11036. }
  11037. }, enabledUpdater:function(attr) {
  11038. var marker = this.getMarker();
  11039. if (marker) {
  11040. marker.setAttributes({globalAlpha:attr.enabled ? 1 : 0.3});
  11041. }
  11042. }, layoutUpdater:function() {
  11043. var me = this, attr = me.attr, label = me.getLabel(), marker = me.getMarker(), labelBBox, markerBBox, totalHeight;
  11044. markerBBox = marker.getBBox();
  11045. labelBBox = label.getBBox();
  11046. totalHeight = Math.max(markerBBox.height, labelBBox.height);
  11047. marker.transform([1, 0, 0, 1, -markerBBox.x, -markerBBox.y + (totalHeight - markerBBox.height) / 2], true);
  11048. label.transform([1, 0, 0, 1, -labelBBox.x + markerBBox.width + attr.markerLabelGap, -labelBBox.y + (totalHeight - labelBBox.height) / 2], true);
  11049. me.bboxUpdater(attr);
  11050. }});
  11051. Ext.define('Ext.chart.legend.sprite.Border', {extend:'Ext.draw.sprite.Rect', alias:'sprite.legendborder', type:'legendborder', isLegendBorder:true});
  11052. Ext.define('Ext.draw.PathUtil', function() {
  11053. var abs = Math.abs, pow = Math.pow, cos = Math.cos, acos = Math.acos, sqrt = Math.sqrt, PI = Math.PI;
  11054. return {singleton:true, requires:['Ext.draw.overrides.hittest.Path', 'Ext.draw.overrides.hittest.sprite.Path'], cubicRoots:function(P) {
  11055. var a = P[0], b = P[1], c = P[2], d = P[3];
  11056. if (a === 0) {
  11057. return this.quadraticRoots(b, c, d);
  11058. }
  11059. var A = b / a, B = c / a, C = d / a, Q = (3 * B - pow(A, 2)) / 9, R = (9 * A * B - 27 * C - 2 * pow(A, 3)) / 54, D = pow(Q, 3) + pow(R, 2), t = [], S, T, Im, th, i, sign = Ext.Number.sign;
  11060. if (D >= 0) {
  11061. S = sign(R + sqrt(D)) * pow(abs(R + sqrt(D)), 1 / 3);
  11062. T = sign(R - sqrt(D)) * pow(abs(R - sqrt(D)), 1 / 3);
  11063. t[0] = -A / 3 + (S + T);
  11064. t[1] = -A / 3 - (S + T) / 2;
  11065. t[2] = t[1];
  11066. Im = abs(sqrt(3) * (S - T) / 2);
  11067. if (Im !== 0) {
  11068. t[1] = -1;
  11069. t[2] = -1;
  11070. }
  11071. } else {
  11072. th = acos(R / sqrt(-pow(Q, 3)));
  11073. t[0] = 2 * sqrt(-Q) * cos(th / 3) - A / 3;
  11074. t[1] = 2 * sqrt(-Q) * cos((th + 2 * PI) / 3) - A / 3;
  11075. t[2] = 2 * sqrt(-Q) * cos((th + 4 * PI) / 3) - A / 3;
  11076. }
  11077. for (i = 0; i < 3; i++) {
  11078. if (t[i] < 0 || t[i] > 1) {
  11079. t[i] = -1;
  11080. }
  11081. }
  11082. return t;
  11083. }, quadraticRoots:function(a, b, c) {
  11084. var D, rD, t, i;
  11085. if (a === 0) {
  11086. return this.linearRoot(b, c);
  11087. }
  11088. D = b * b - 4 * a * c;
  11089. if (D === 0) {
  11090. t = [-b / (2 * a)];
  11091. } else {
  11092. if (D > 0) {
  11093. rD = sqrt(D);
  11094. t = [(-b - rD) / (2 * a), (-b + rD) / (2 * a)];
  11095. } else {
  11096. return [];
  11097. }
  11098. }
  11099. for (i = 0; i < t.length; i++) {
  11100. if (t[i] < 0 || t[i] > 1) {
  11101. t[i] = -1;
  11102. }
  11103. }
  11104. return t;
  11105. }, linearRoot:function(a, b) {
  11106. var t = -b / a;
  11107. if (a === 0 || t < 0 || t > 1) {
  11108. return [];
  11109. }
  11110. return [t];
  11111. }, bezierCoeffs:function(P0, P1, P2, P3) {
  11112. var Z = [];
  11113. Z[0] = -P0 + 3 * P1 - 3 * P2 + P3;
  11114. Z[1] = 3 * P0 - 6 * P1 + 3 * P2;
  11115. Z[2] = -3 * P0 + 3 * P1;
  11116. Z[3] = P0;
  11117. return Z;
  11118. }, cubicLineIntersections:function(px1, px2, px3, px4, py1, py2, py3, py4, x1, y1, x2, y2) {
  11119. var P = [], intersections = [], A = y1 - y2, B = x2 - x1, C = x1 * (y2 - y1) - y1 * (x2 - x1), bx = this.bezierCoeffs(px1, px2, px3, px4), by = this.bezierCoeffs(py1, py2, py3, py4), i, r, s, t, tt, ttt, cx, cy;
  11120. P[0] = A * bx[0] + B * by[0];
  11121. P[1] = A * bx[1] + B * by[1];
  11122. P[2] = A * bx[2] + B * by[2];
  11123. P[3] = A * bx[3] + B * by[3] + C;
  11124. r = this.cubicRoots(P);
  11125. for (i = 0; i < r.length; i++) {
  11126. t = r[i];
  11127. if (t < 0 || t > 1) {
  11128. continue;
  11129. }
  11130. tt = t * t;
  11131. ttt = tt * t;
  11132. cx = bx[0] * ttt + bx[1] * tt + bx[2] * t + bx[3];
  11133. cy = by[0] * ttt + by[1] * tt + by[2] * t + by[3];
  11134. if (x2 - x1 !== 0) {
  11135. s = (cx - x1) / (x2 - x1);
  11136. } else {
  11137. s = (cy - y1) / (y2 - y1);
  11138. }
  11139. if (!(s < 0 || s > 1)) {
  11140. intersections.push([cx, cy]);
  11141. }
  11142. }
  11143. return intersections;
  11144. }, splitCubic:function(P1, P2, P3, P4, z) {
  11145. var zz = z * z, zzz = z * zz, iz = z - 1, izz = iz * iz, izzz = iz * izz, P = zzz * P4 - 3 * zz * iz * P3 + 3 * z * izz * P2 - izzz * P1;
  11146. return [[P1, z * P2 - iz * P1, zz * P3 - 2 * z * iz * P2 + izz * P1, P], [P, zz * P4 - 2 * z * iz * P3 + izz * P2, z * P4 - iz * P3, P4]];
  11147. }, cubicDimension:function(a, b, c, d) {
  11148. var qa = 3 * (-a + 3 * (b - c) + d), qb = 6 * (a - 2 * b + c), qc = -3 * (a - b), x, y, min = Math.min(a, d), max = Math.max(a, d), delta;
  11149. if (qa === 0) {
  11150. if (qb === 0) {
  11151. return [min, max];
  11152. } else {
  11153. x = -qc / qb;
  11154. if (0 < x && x < 1) {
  11155. y = this.interpolateCubic(a, b, c, d, x);
  11156. min = Math.min(min, y);
  11157. max = Math.max(max, y);
  11158. }
  11159. }
  11160. } else {
  11161. delta = qb * qb - 4 * qa * qc;
  11162. if (delta >= 0) {
  11163. delta = sqrt(delta);
  11164. x = (delta - qb) / 2 / qa;
  11165. if (0 < x && x < 1) {
  11166. y = this.interpolateCubic(a, b, c, d, x);
  11167. min = Math.min(min, y);
  11168. max = Math.max(max, y);
  11169. }
  11170. if (delta > 0) {
  11171. x -= delta / qa;
  11172. if (0 < x && x < 1) {
  11173. y = this.interpolateCubic(a, b, c, d, x);
  11174. min = Math.min(min, y);
  11175. max = Math.max(max, y);
  11176. }
  11177. }
  11178. }
  11179. }
  11180. return [min, max];
  11181. }, interpolateCubic:function(a, b, c, d, t) {
  11182. var rate;
  11183. if (t === 0) {
  11184. return a;
  11185. }
  11186. if (t === 1) {
  11187. return d;
  11188. }
  11189. rate = (1 - t) / t;
  11190. return t * t * t * (d + rate * (3 * c + rate * (3 * b + rate * a)));
  11191. }, cubicsIntersections:function(ax1, ax2, ax3, ax4, ay1, ay2, ay3, ay4, bx1, bx2, bx3, bx4, by1, by2, by3, by4) {
  11192. var me = this, axDim = me.cubicDimension(ax1, ax2, ax3, ax4), ayDim = me.cubicDimension(ay1, ay2, ay3, ay4), bxDim = me.cubicDimension(bx1, bx2, bx3, bx4), byDim = me.cubicDimension(by1, by2, by3, by4), splitAx, splitAy, splitBx, splitBy, points = [];
  11193. if (axDim[0] > bxDim[1] || axDim[1] < bxDim[0] || ayDim[0] > byDim[1] || ayDim[1] < byDim[0]) {
  11194. return [];
  11195. }
  11196. if (abs(ay1 - ay2) < 1 && abs(ay3 - ay4) < 1 && abs(ax1 - ax4) < 1 && abs(ax2 - ax3) < 1 && abs(by1 - by2) < 1 && abs(by3 - by4) < 1 && abs(bx1 - bx4) < 1 && abs(bx2 - bx3) < 1) {
  11197. return [[(ax1 + ax4) * 0.5, (ay1 + ay2) * 0.5]];
  11198. }
  11199. splitAx = me.splitCubic(ax1, ax2, ax3, ax4, 0.5);
  11200. splitAy = me.splitCubic(ay1, ay2, ay3, ay4, 0.5);
  11201. splitBx = me.splitCubic(bx1, bx2, bx3, bx4, 0.5);
  11202. splitBy = me.splitCubic(by1, by2, by3, by4, 0.5);
  11203. points.push.apply(points, me.cubicsIntersections.apply(me, splitAx[0].concat(splitAy[0], splitBx[0], splitBy[0])));
  11204. points.push.apply(points, me.cubicsIntersections.apply(me, splitAx[0].concat(splitAy[0], splitBx[1], splitBy[1])));
  11205. points.push.apply(points, me.cubicsIntersections.apply(me, splitAx[1].concat(splitAy[1], splitBx[0], splitBy[0])));
  11206. points.push.apply(points, me.cubicsIntersections.apply(me, splitAx[1].concat(splitAy[1], splitBx[1], splitBy[1])));
  11207. return points;
  11208. }, linesIntersection:function(x1, y1, x2, y2, x3, y3, x4, y4) {
  11209. var d = (x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3), ua, ub;
  11210. if (d === 0) {
  11211. return null;
  11212. }
  11213. ua = ((x4 - x3) * (y1 - y3) - (x1 - x3) * (y4 - y3)) / d;
  11214. ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / d;
  11215. if (ua >= 0 && ua <= 1 && ub >= 0 && ub <= 1) {
  11216. return [x1 + ua * (x2 - x1), y1 + ua * (y2 - y1)];
  11217. }
  11218. return null;
  11219. }, pointOnLine:function(x1, y1, x2, y2, x, y) {
  11220. var t, _;
  11221. if (abs(x2 - x1) < abs(y2 - y1)) {
  11222. _ = x1;
  11223. x1 = y1;
  11224. y1 = _;
  11225. _ = x2;
  11226. x2 = y2;
  11227. y2 = _;
  11228. _ = x;
  11229. x = y;
  11230. y = _;
  11231. }
  11232. t = (x - x1) / (x2 - x1);
  11233. if (t < 0 || t > 1) {
  11234. return false;
  11235. }
  11236. return abs(y1 + t * (y2 - y1) - y) < 4;
  11237. }, pointOnCubic:function(px1, px2, px3, px4, py1, py2, py3, py4, x, y) {
  11238. var me = this, bx = me.bezierCoeffs(px1, px2, px3, px4), by = me.bezierCoeffs(py1, py2, py3, py4), i, j, rx, ry, t;
  11239. bx[3] -= x;
  11240. by[3] -= y;
  11241. rx = me.cubicRoots(bx);
  11242. ry = me.cubicRoots(by);
  11243. for (i = 0; i < rx.length; i++) {
  11244. t = rx[i];
  11245. for (j = 0; j < ry.length; j++) {
  11246. if (t >= 0 && t <= 1 && abs(t - ry[j]) < 0.05) {
  11247. return true;
  11248. }
  11249. }
  11250. }
  11251. return false;
  11252. }};
  11253. });
  11254. Ext.define('Ext.draw.overrides.hittest.All', {requires:['Ext.draw.PathUtil', 'Ext.draw.overrides.hittest.sprite.Instancing', 'Ext.draw.overrides.hittest.Surface']});
  11255. Ext.define('Ext.chart.legend.SpriteLegend', {alias:'legend.sprite', type:'sprite', isLegend:true, isSpriteLegend:true, mixins:['Ext.mixin.Observable'], requires:['Ext.chart.legend.sprite.Item', 'Ext.chart.legend.sprite.Border', 'Ext.draw.overrides.hittest.All', 'Ext.draw.Animator'], config:{docked:'bottom', store:null, chart:null, surface:null, size:{width:0, height:0}, toggleable:true, padding:10, label:{preciseMeasurement:true}, marker:{}, border:{$value:{type:'legendborder'}, lazy:true}, background:null,
  11256. hidden:false}, sprites:null, spriteZIndexes:{background:0, border:1, item:2}, dockedValues:{left:true, right:true, top:true, bottom:true}, constructor:function(config) {
  11257. var me = this;
  11258. me.oldSize = {width:0, height:0};
  11259. me.getId();
  11260. me.mixins.observable.constructor.call(me, config);
  11261. }, isXType:function(xtype) {
  11262. return xtype === 'sprite';
  11263. }, applyStore:function(store) {
  11264. return store && Ext.StoreManager.lookup(store);
  11265. }, updateStore:function(store, oldStore) {
  11266. var me = this;
  11267. if (oldStore) {
  11268. oldStore.un('datachanged', me.onDataChanged, me);
  11269. oldStore.un('update', me.onDataUpdate, me);
  11270. }
  11271. if (store) {
  11272. store.on('datachanged', me.onDataChanged, me);
  11273. store.on('update', me.onDataUpdate, me);
  11274. me.onDataChanged(store);
  11275. }
  11276. me.performLayout();
  11277. }, applyDocked:function(docked) {
  11278. if (!(docked in this.dockedValues)) {
  11279. Ext.raise("Invalid 'docked' config value.");
  11280. }
  11281. return docked;
  11282. }, updateDocked:function(docked) {
  11283. this.isTop = docked === 'top';
  11284. if (!this.isConfiguring) {
  11285. this.layoutChart();
  11286. }
  11287. }, updateHidden:function(hidden) {
  11288. var surface;
  11289. this.getChart();
  11290. surface = this.getSurface();
  11291. if (surface) {
  11292. surface.setHidden(hidden);
  11293. }
  11294. if (!this.isConfiguring) {
  11295. this.layoutChart();
  11296. }
  11297. }, layoutChart:function() {
  11298. var chart;
  11299. if (!this.isConfiguring) {
  11300. chart = this.getChart();
  11301. if (chart) {
  11302. chart.scheduleLayout();
  11303. }
  11304. }
  11305. }, computeRect:function(chartRect) {
  11306. var rect, docked, size, height, width;
  11307. if (this.getHidden()) {
  11308. return null;
  11309. }
  11310. rect = [0, 0, 0, 0];
  11311. docked = this.getDocked();
  11312. size = this.getSize();
  11313. height = size.height;
  11314. width = size.width;
  11315. switch(docked) {
  11316. case 'top':
  11317. rect[1] = chartRect[1];
  11318. rect[2] = chartRect[2];
  11319. rect[3] = height;
  11320. chartRect[1] += height;
  11321. chartRect[3] -= height;
  11322. break;
  11323. case 'bottom':
  11324. chartRect[3] -= height;
  11325. rect[1] = chartRect[3];
  11326. rect[2] = chartRect[2];
  11327. rect[3] = height;
  11328. break;
  11329. case 'left':
  11330. chartRect[0] += width;
  11331. chartRect[2] -= width;
  11332. rect[2] = width;
  11333. rect[3] = chartRect[3];
  11334. break;
  11335. case 'right':
  11336. chartRect[2] -= width;
  11337. rect[0] = chartRect[2];
  11338. rect[2] = width;
  11339. rect[3] = chartRect[3];
  11340. break;
  11341. }
  11342. return rect;
  11343. }, applyBorder:function(config) {
  11344. var border;
  11345. if (config) {
  11346. if (config.isSprite) {
  11347. border = config;
  11348. } else {
  11349. border = Ext.create('sprite.' + config.type, config);
  11350. }
  11351. }
  11352. if (border) {
  11353. border.isLegendBorder = true;
  11354. border.setAttributes({zIndex:this.spriteZIndexes.border});
  11355. }
  11356. return border;
  11357. }, updateBorder:function(border, oldBorder) {
  11358. var surface = this.getSurface();
  11359. this.borderSprite = null;
  11360. if (surface) {
  11361. if (oldBorder) {
  11362. surface.remove(oldBorder);
  11363. }
  11364. if (border) {
  11365. this.borderSprite = surface.add(border);
  11366. }
  11367. }
  11368. }, scheduleLayout:function() {
  11369. if (!this.scheduledLayoutId) {
  11370. this.scheduledLayoutId = Ext.draw.Animator.schedule('performLayout', this);
  11371. }
  11372. }, cancelLayout:function() {
  11373. Ext.draw.Animator.cancel(this.scheduledLayoutId);
  11374. this.scheduledLayoutId = null;
  11375. }, performLayout:function() {
  11376. var me = this, size = me.getSize(), gap = me.getPadding(), sprites = me.getSprites(), surface = me.getSurface(), background = me.getBackground(), surfaceRect = surface.getRect(), store = me.getStore(), ln = sprites && sprites.length || 0, i, sprite;
  11377. if (!surface || !surfaceRect || !store) {
  11378. return false;
  11379. }
  11380. me.cancelLayout();
  11381. var docked = me.getDocked(), surfaceWidth = surfaceRect[2], surfaceHeight = surfaceRect[3], border = me.borderSprite, bboxes = [], startX, startY, columnSize, columnCount, columnWidth, itemsWidth, itemsHeight, paddedItemsWidth, paddedItemsHeight, paddedBorderWidth, paddedBorderHeight, itemHeight, bbox, x, y;
  11382. for (i = 0; i < ln; i++) {
  11383. sprite = sprites[i];
  11384. bbox = sprite.getBBox();
  11385. bboxes.push(bbox);
  11386. }
  11387. if (bbox) {
  11388. itemHeight = bbox.height;
  11389. }
  11390. switch(docked) {
  11391. case 'bottom':
  11392. case 'top':
  11393. if (!surfaceWidth) {
  11394. return false;
  11395. }
  11396. columnSize = 0;
  11397. do {
  11398. itemsWidth = 0;
  11399. columnWidth = 0;
  11400. columnCount = 0;
  11401. columnSize++;
  11402. for (i = 0; i < ln; i++) {
  11403. bbox = bboxes[i];
  11404. if (bbox.width > columnWidth) {
  11405. columnWidth = bbox.width;
  11406. columnWidth = Math.min(columnWidth, surfaceWidth - gap * 4);
  11407. }
  11408. if ((i + 1) % columnSize === 0) {
  11409. itemsWidth += columnWidth;
  11410. columnWidth = 0;
  11411. columnCount++;
  11412. }
  11413. }
  11414. if (i % columnSize !== 0) {
  11415. itemsWidth += columnWidth;
  11416. columnCount++;
  11417. }
  11418. paddedItemsWidth = itemsWidth + (columnCount - 1) * gap;
  11419. paddedBorderWidth = paddedItemsWidth + gap * 4;
  11420. } while (paddedBorderWidth > surfaceWidth);
  11421. paddedItemsHeight = itemHeight * columnSize + (columnSize - 1) * gap;
  11422. break;
  11423. case 'right':
  11424. case 'left':
  11425. if (!surfaceHeight) {
  11426. return false;
  11427. }
  11428. columnSize = ln * 2;
  11429. do {
  11430. columnSize = (columnSize >> 1) + columnSize % 2;
  11431. itemsWidth = 0;
  11432. itemsHeight = 0;
  11433. columnWidth = 0;
  11434. columnCount = 0;
  11435. for (i = 0; i < ln; i++) {
  11436. bbox = bboxes[i];
  11437. if (!columnCount) {
  11438. itemsHeight += bbox.height;
  11439. }
  11440. if (bbox.width > columnWidth) {
  11441. columnWidth = bbox.width;
  11442. }
  11443. if ((i + 1) % columnSize === 0) {
  11444. itemsWidth += columnWidth;
  11445. columnWidth = 0;
  11446. columnCount++;
  11447. }
  11448. }
  11449. if (i % columnSize !== 0) {
  11450. itemsWidth += columnWidth;
  11451. columnCount++;
  11452. }
  11453. paddedItemsWidth = itemsWidth + (columnCount - 1) * gap;
  11454. paddedItemsHeight = itemsHeight + (columnSize - 1) * gap;
  11455. paddedBorderWidth = paddedItemsWidth + gap * 4;
  11456. paddedBorderHeight = paddedItemsHeight + gap * 4;
  11457. } while (paddedItemsHeight > surfaceHeight);
  11458. break;
  11459. }
  11460. startX = (surfaceWidth - paddedItemsWidth) / 2;
  11461. startY = (surfaceHeight - paddedItemsHeight) / 2;
  11462. x = 0;
  11463. y = 0;
  11464. columnWidth = 0;
  11465. for (i = 0; i < ln; i++) {
  11466. sprite = sprites[i];
  11467. bbox = bboxes[i];
  11468. sprite.setAttributes({translationX:startX + x, translationY:startY + y});
  11469. if (bbox.width > columnWidth) {
  11470. columnWidth = bbox.width;
  11471. }
  11472. if ((i + 1) % columnSize === 0) {
  11473. x += columnWidth + gap;
  11474. y = 0;
  11475. columnWidth = 0;
  11476. } else {
  11477. y += bbox.height + gap;
  11478. }
  11479. }
  11480. if (border) {
  11481. border.setAttributes({hidden:!ln, x:startX - gap, y:startY - gap, width:paddedItemsWidth + gap * 2, height:paddedItemsHeight + gap * 2});
  11482. }
  11483. size.width = border.attr.width + gap * 2;
  11484. size.height = border.attr.height + gap * 2;
  11485. if (size.width !== me.oldSize.width || size.height !== me.oldSize.height) {
  11486. Ext.apply(me.oldSize, size);
  11487. me.getChart().scheduleLayout();
  11488. return false;
  11489. }
  11490. if (background) {
  11491. me.resizeBackground(surface, background);
  11492. }
  11493. surface.renderFrame();
  11494. return true;
  11495. }, getSprites:function() {
  11496. this.updateSprites();
  11497. return this.sprites;
  11498. }, createSprite:function(surface, record) {
  11499. var me = this, data = record.data, chart = me.getChart(), series = chart.get(data.series), seriesMarker = series.getMarker(), sprite = null, markerConfig, labelConfig, legendItemConfig;
  11500. if (surface) {
  11501. markerConfig = series.getMarkerStyleByIndex(data.index);
  11502. markerConfig.fillStyle = data.mark;
  11503. markerConfig.hidden = false;
  11504. if (seriesMarker && seriesMarker.type) {
  11505. markerConfig.type = seriesMarker.type;
  11506. }
  11507. Ext.apply(markerConfig, me.getMarker());
  11508. markerConfig.surface = surface;
  11509. labelConfig = me.getLabel();
  11510. legendItemConfig = {type:'legenditem', zIndex:me.spriteZIndexes.item, text:data.name, enabled:!data.disabled, marker:markerConfig, label:labelConfig, series:data.series, record:record};
  11511. sprite = surface.add(legendItemConfig);
  11512. }
  11513. return sprite;
  11514. }, updateSprites:function() {
  11515. var me = this, chart = me.getChart(), store = me.getStore(), surface = me.getSurface(), item, items, itemSprite, i, ln, sprites, unusedSprites, border;
  11516. if (!(chart && store && surface)) {
  11517. return;
  11518. }
  11519. me.sprites = sprites = me.sprites || [];
  11520. items = store.getData().items;
  11521. ln = items.length;
  11522. for (i = 0; i < ln; i++) {
  11523. item = items[i];
  11524. itemSprite = sprites[i];
  11525. if (itemSprite) {
  11526. me.updateSprite(itemSprite, item);
  11527. } else {
  11528. itemSprite = me.createSprite(surface, item);
  11529. surface.add(itemSprite);
  11530. sprites.push(itemSprite);
  11531. }
  11532. }
  11533. unusedSprites = Ext.Array.splice(sprites, i, sprites.length);
  11534. for (i = 0, ln = unusedSprites.length; i < ln; i++) {
  11535. itemSprite = unusedSprites[i];
  11536. itemSprite.destroy();
  11537. }
  11538. border = me.getBorder();
  11539. if (border) {
  11540. me.borderSprite = border;
  11541. }
  11542. me.updateTheme(chart.getTheme());
  11543. }, updateSprite:function(sprite, record) {
  11544. var data = record.data, chart = this.getChart(), series = chart.get(data.series), marker, label, markerConfig;
  11545. if (sprite) {
  11546. label = sprite.getLabel();
  11547. label.setAttributes({text:data.name});
  11548. sprite.setAttributes({enabled:!data.disabled});
  11549. sprite.setConfig({series:data.series, record:record});
  11550. markerConfig = series.getMarkerStyleByIndex(data.index);
  11551. markerConfig.fillStyle = data.mark;
  11552. markerConfig.hidden = false;
  11553. Ext.apply(markerConfig, this.getMarker());
  11554. marker = sprite.getMarker();
  11555. marker.setAttributes({fillStyle:markerConfig.fillStyle, strokeStyle:markerConfig.strokeStyle});
  11556. sprite.layoutUpdater(sprite.attr);
  11557. }
  11558. }, updateChart:function(newChart, oldChart) {
  11559. var me = this;
  11560. if (oldChart) {
  11561. me.setSurface(null);
  11562. }
  11563. if (newChart) {
  11564. me.setSurface(newChart.getSurface('legend'));
  11565. }
  11566. }, updateSurface:function(surface, oldSurface) {
  11567. if (oldSurface) {
  11568. oldSurface.el.un('click', 'onClick', this);
  11569. oldSurface.removeAll(true);
  11570. }
  11571. if (surface) {
  11572. surface.isLegendSurface = true;
  11573. surface.el.on('click', 'onClick', this);
  11574. }
  11575. }, onClick:function(event) {
  11576. var chart = this.getChart(), surface = this.getSurface(), result, point;
  11577. if (chart && chart.hasFirstLayout && surface) {
  11578. point = surface.getEventXY(event);
  11579. result = surface.hitTest(point);
  11580. if (result && result.sprite) {
  11581. this.toggleItem(result.sprite);
  11582. }
  11583. }
  11584. }, applyBackground:function(newBackground, oldBackground) {
  11585. var me = this, chart = me.getChart(), surface = me.getSurface(), background;
  11586. background = chart.refreshBackground(surface, newBackground, oldBackground);
  11587. if (background) {
  11588. background.setAttributes({zIndex:me.spriteZIndexes.background});
  11589. }
  11590. return background;
  11591. }, resizeBackground:function(surface, background) {
  11592. var width = background.attr.width, height = background.attr.height, surfaceRect = surface.getRect();
  11593. if (surfaceRect && (width !== surfaceRect[2] || height !== surfaceRect[3])) {
  11594. background.setAttributes({width:surfaceRect[2], height:surfaceRect[3]});
  11595. }
  11596. }, themeableConfigs:{background:true}, updateTheme:function(theme) {
  11597. var me = this, surface = me.getSurface(), sprites = surface.getItems(), legendTheme = theme.getLegend(), labelConfig = me.getLabel(), configs = me.self.getConfigurator().configs, themeableConfigs = me.themeableConfigs, themeOnlyIfConfigured = me.themeOnlyIfConfigured, initialConfig = me.getInitialConfig(), defaultConfig = me.defaultConfig, value, cfg, isObjValue, isUnusedConfig, initialValue, sprite, style, labelSprite, key, attr, i, ln;
  11598. for (i = 0, ln = sprites.length; i < ln; i++) {
  11599. sprite = sprites[i];
  11600. if (sprite.isLegendItem) {
  11601. style = legendTheme.label;
  11602. if (style) {
  11603. attr = null;
  11604. for (key in style) {
  11605. if (!(key in labelConfig)) {
  11606. attr = attr || {};
  11607. attr[key] = style[key];
  11608. }
  11609. }
  11610. if (attr) {
  11611. labelSprite = sprite.getLabel();
  11612. labelSprite.setAttributes(attr);
  11613. }
  11614. }
  11615. continue;
  11616. } else {
  11617. if (sprite.isLegendBorder) {
  11618. style = legendTheme.border;
  11619. } else {
  11620. continue;
  11621. }
  11622. }
  11623. if (style) {
  11624. attr = {};
  11625. for (key in style) {
  11626. if (!(key in sprite.config)) {
  11627. attr[key] = style[key];
  11628. }
  11629. }
  11630. sprite.setAttributes(attr);
  11631. }
  11632. }
  11633. value = legendTheme.background;
  11634. cfg = configs.background;
  11635. if (value !== null && value !== undefined && cfg) {
  11636. }
  11637. for (key in legendTheme) {
  11638. if (!(key in themeableConfigs)) {
  11639. continue;
  11640. }
  11641. value = legendTheme[key];
  11642. cfg = configs[key];
  11643. if (value !== null && value !== undefined && cfg) {
  11644. initialValue = initialConfig[key];
  11645. isObjValue = Ext.isObject(value);
  11646. isUnusedConfig = initialValue === defaultConfig[key];
  11647. if (isObjValue) {
  11648. if (isUnusedConfig && themeOnlyIfConfigured[key]) {
  11649. continue;
  11650. }
  11651. value = Ext.merge({}, value, initialValue);
  11652. }
  11653. if (isUnusedConfig || isObjValue) {
  11654. me[cfg.names.set](value);
  11655. }
  11656. }
  11657. }
  11658. }, onDataChanged:function(store) {
  11659. this.updateSprites();
  11660. this.scheduleLayout();
  11661. }, onDataUpdate:function(store, record) {
  11662. var me = this, sprites = me.sprites, ln = sprites.length, i = 0, sprite, spriteRecord, match;
  11663. for (; i < ln; i++) {
  11664. sprite = sprites[i];
  11665. spriteRecord = sprite.getRecord();
  11666. if (spriteRecord === record) {
  11667. match = sprite;
  11668. break;
  11669. }
  11670. }
  11671. if (match) {
  11672. me.updateSprite(match, record);
  11673. me.scheduleLayout();
  11674. }
  11675. }, toggleItem:function(sprite) {
  11676. var disabledCount = 0, canToggle = true, store, i, count, record, disabled;
  11677. if (!this.getToggleable() || !sprite.isLegendItem) {
  11678. return;
  11679. }
  11680. store = this.getStore();
  11681. if (store) {
  11682. count = store.getCount();
  11683. for (i = 0; i < count; i++) {
  11684. record = store.getAt(i);
  11685. if (record.get('disabled')) {
  11686. disabledCount++;
  11687. }
  11688. }
  11689. canToggle = count - disabledCount > 1;
  11690. record = sprite.getRecord();
  11691. if (record) {
  11692. disabled = record.get('disabled');
  11693. if (disabled || canToggle) {
  11694. record.set('disabled', !disabled);
  11695. sprite.setAttributes({enabled:disabled});
  11696. }
  11697. }
  11698. }
  11699. }, destroy:function() {
  11700. var me = this;
  11701. me.destroying = true;
  11702. me.cancelLayout();
  11703. me.setChart(null);
  11704. me.callParent();
  11705. }});
  11706. Ext.define('Ext.chart.Caption', {mixins:['Ext.mixin.Observable', 'Ext.mixin.Bindable'], isCaption:true, config:{weight:0, text:'', align:'center', alignTo:'series', padding:0, hidden:false, docked:'top', style:{fontSize:'14px', fontWeight:'bold', fontFamily:'Verdana, Aria, sans-serif'}, chart:null, sprite:{type:'text', preciseMeasurement:true, zIndex:10}, debug:false, rect:null}, surfaceName:'caption', constructor:function(config) {
  11707. var me = this, id;
  11708. if ('id' in config) {
  11709. id = config.id;
  11710. } else {
  11711. if ('id' in me.config) {
  11712. id = me.config.id;
  11713. } else {
  11714. id = me.getId();
  11715. }
  11716. }
  11717. me.setId(id);
  11718. me.mixins.observable.constructor.call(me, config);
  11719. me.initBindable();
  11720. }, updateChart:function() {
  11721. if (!this.isConfiguring) {
  11722. this.setSprite({type:'text'});
  11723. }
  11724. }, applySprite:function(sprite) {
  11725. var me = this, chart = me.getChart(), surface = me.surface = chart.getSurface(me.surfaceName);
  11726. me.rectSprite = surface.add({type:'rect', fillStyle:'yellow', strokeStyle:'red'});
  11727. return sprite && surface.add(sprite);
  11728. }, updateSprite:function(sprite, oldSprite) {
  11729. if (oldSprite) {
  11730. oldSprite.destroy();
  11731. }
  11732. }, updateText:function(text) {
  11733. this.getSprite().setAttributes({text:text});
  11734. }, updateStyle:function(style) {
  11735. this.getSprite().setAttributes(style);
  11736. }, updateDebug:function(debug) {
  11737. var me = this, sprite = me.getSprite();
  11738. if (debug && !me.rectSprite) {
  11739. me.rectSprite = me.surface.add({type:'rect', fillStyle:'yellow', strokeStyle:'red'});
  11740. }
  11741. if (sprite) {
  11742. sprite.setAttributes({debug:debug ? {bbox:true} : null});
  11743. }
  11744. if (me.rectSprite) {
  11745. me.rectSprite.setAttributes({hidden:!debug});
  11746. }
  11747. if (!me.isConfiguring) {
  11748. me.surface.renderFrame();
  11749. }
  11750. }, updateRect:function(rect) {
  11751. if (this.rectSprite) {
  11752. this.rectSprite.setAttributes({x:rect[0], y:rect[1], width:rect[2], height:rect[3]});
  11753. }
  11754. }, updateDocked:function() {
  11755. var chart = this.getChart();
  11756. if (chart && !this.isConfiguring) {
  11757. chart.scheduleLayout();
  11758. }
  11759. }, computeRect:function(chartRect, shrinkRect) {
  11760. if (this.getHidden()) {
  11761. return null;
  11762. }
  11763. var rect = [0, 0, chartRect[2], 0], docked = this.getDocked(), padding = this.getPadding(), textSize = this.getSprite().getBBox(), height = textSize.height + padding * 2;
  11764. switch(docked) {
  11765. case 'top':
  11766. rect[1] = shrinkRect.top;
  11767. rect[3] = height;
  11768. chartRect[1] += height;
  11769. chartRect[3] -= height;
  11770. shrinkRect.top += height;
  11771. break;
  11772. case 'bottom':
  11773. chartRect[3] -= height;
  11774. shrinkRect.bottom -= height;
  11775. rect[1] = shrinkRect.bottom;
  11776. rect[3] = height;
  11777. break;
  11778. }
  11779. this.setRect(rect);
  11780. }, alignRect:function(seriesRect) {
  11781. var surfaceRect = this.surface.getRect(), rect = this.getRect();
  11782. rect[0] = seriesRect[0] - surfaceRect[0];
  11783. rect[2] = seriesRect[2];
  11784. this.setRect(rect.slice());
  11785. }, performLayout:function() {
  11786. var me = this, rect = me.getRect(), x = rect[0], y = rect[1], width = rect[2], height = rect[3], sprite = me.getSprite(), tx = sprite.attr.translationX, ty = sprite.attr.translationY, bbox = sprite.getBBox(), align = me.getAlign(), dx, dy;
  11787. switch(align) {
  11788. case 'left':
  11789. dx = x - bbox.x;
  11790. break;
  11791. case 'right':
  11792. dx = x + width - (bbox.x + bbox.width);
  11793. break;
  11794. case 'center':
  11795. dx = x + (width - bbox.width) / 2 - bbox.x;
  11796. break;
  11797. }
  11798. dy = y + (height - bbox.height) / 2 - bbox.y;
  11799. sprite.setAttributes({translationX:tx + dx, translationY:ty + dy});
  11800. }, destroy:function() {
  11801. var me = this;
  11802. if (me.rectSprite) {
  11803. me.rectSprite.destroy();
  11804. }
  11805. me.getSprite().destroy();
  11806. me.callParent();
  11807. }});
  11808. Ext.define('Ext.chart.legend.store.Item', {extend:'Ext.data.Model', fields:['id', 'name', 'mark', 'disabled', 'series', 'index']});
  11809. Ext.define('Ext.chart.legend.store.Store', {extend:'Ext.data.Store', requires:['Ext.chart.legend.store.Item'], model:'Ext.chart.legend.store.Item', isLegendStore:true, config:{autoDestroy:true}});
  11810. Ext.define('Ext.chart.AbstractChart', {extend:'Ext.draw.Container', requires:['Ext.chart.theme.Default', 'Ext.chart.series.Series', 'Ext.chart.interactions.Abstract', 'Ext.chart.axis.Axis', 'Ext.chart.Util', 'Ext.data.StoreManager', 'Ext.chart.legend.Legend', 'Ext.chart.legend.SpriteLegend', 'Ext.chart.Caption', 'Ext.chart.legend.store.Store', 'Ext.data.Store'], isChart:true, defaultBindProperty:'store', config:{store:'ext-empty-store', theme:'default', captions:null, style:null, animation:!Ext.isIE8,
  11811. series:[], axes:[], legend:null, colors:null, insetPadding:{top:10, left:10, right:10, bottom:10}, background:null, interactions:[], mainRect:null, resizeHandler:null, highlightItem:null, surfaceZIndexes:{background:0, main:1, grid:2, series:3, axis:4, chart:5, caption:6, overlay:7, legend:8}}, legendStore:null, animationSuspendCount:0, chartLayoutSuspendCount:0, chartLayoutCount:0, scheduledLayoutId:null, axisThicknessSuspendCount:0, isThicknessChanged:false, constructor:function(config) {
  11812. var me = this;
  11813. me.itemListeners = {};
  11814. me.surfaceMap = {};
  11815. me.chartComponents = {};
  11816. me.isInitializing = true;
  11817. me.suspendChartLayout();
  11818. me.animationSuspendCount++;
  11819. me.callParent(arguments);
  11820. me.isInitializing = false;
  11821. me.getSurface('main');
  11822. me.getSurface('chart').setFlipRtlText(me.getInherited().rtl);
  11823. me.getSurface('overlay').waitFor(me.getSurface('series'));
  11824. me.animationSuspendCount--;
  11825. me.resumeChartLayout();
  11826. }, applyAnimation:function(animation, oldAnimation) {
  11827. return Ext.chart.Util.applyAnimation(animation, oldAnimation);
  11828. }, updateAnimation:function() {
  11829. if (this.isConfiguring) {
  11830. return;
  11831. }
  11832. var seriesList = this.getSeries(), ln = seriesList.length, i, series;
  11833. this.isSettingSeriesAnimation = true;
  11834. for (i = 0; i < ln; i++) {
  11835. series = seriesList[i];
  11836. if (!series.isUserAnimation || this.animationSuspendCount === 0) {
  11837. series.setAnimation(series.getAnimation());
  11838. }
  11839. }
  11840. this.isSettingSeriesAnimation = false;
  11841. }, getAnimation:function() {
  11842. var result;
  11843. if (this.animationSuspendCount) {
  11844. result = {duration:0};
  11845. } else {
  11846. result = this.callParent();
  11847. }
  11848. return result;
  11849. }, suspendAnimation:function() {
  11850. this.animationSuspendCount++;
  11851. if (this.animationSuspendCount === 1) {
  11852. this.updateAnimation();
  11853. }
  11854. }, resumeAnimation:function() {
  11855. this.animationSuspendCount--;
  11856. if (this.animationSuspendCount === 0) {
  11857. this.updateAnimation();
  11858. }
  11859. }, applyInsetPadding:function(padding, oldPadding) {
  11860. var result;
  11861. if (!Ext.isObject(padding)) {
  11862. result = Ext.util.Format.parseBox(padding);
  11863. } else {
  11864. if (!oldPadding) {
  11865. result = padding;
  11866. } else {
  11867. result = Ext.apply(oldPadding, padding);
  11868. }
  11869. }
  11870. return result;
  11871. }, suspendChartLayout:function() {
  11872. var me = this;
  11873. me.chartLayoutSuspendCount++;
  11874. if (me.chartLayoutSuspendCount === 1) {
  11875. if (me.scheduledLayoutId) {
  11876. me.layoutInSuspension = true;
  11877. me.cancelChartLayout();
  11878. } else {
  11879. me.layoutInSuspension = false;
  11880. }
  11881. }
  11882. }, resumeChartLayout:function() {
  11883. var me = this;
  11884. me.chartLayoutSuspendCount--;
  11885. if (me.chartLayoutSuspendCount === 0) {
  11886. if (me.layoutInSuspension) {
  11887. me.scheduleLayout();
  11888. }
  11889. }
  11890. }, cancelChartLayout:function() {
  11891. if (this.scheduledLayoutId) {
  11892. Ext.draw.Animator.cancel(this.scheduledLayoutId);
  11893. this.scheduledLayoutId = null;
  11894. this.checkLayoutEnd();
  11895. }
  11896. }, scheduleLayout:function() {
  11897. var me = this;
  11898. if (me.allowSchedule() && !me.scheduledLayoutId) {
  11899. me.scheduledLayoutId = Ext.draw.Animator.schedule('doScheduleLayout', me);
  11900. }
  11901. }, allowSchedule:function() {
  11902. return true;
  11903. }, doScheduleLayout:function() {
  11904. var me = this;
  11905. me.scheduledLayoutId = null;
  11906. if (me.chartLayoutSuspendCount) {
  11907. me.layoutInSuspension = true;
  11908. } else {
  11909. me.performLayout();
  11910. }
  11911. }, suspendThicknessChanged:function() {
  11912. this.axisThicknessSuspendCount++;
  11913. }, resumeThicknessChanged:function() {
  11914. if (this.axisThicknessSuspendCount > 0) {
  11915. this.axisThicknessSuspendCount--;
  11916. if (this.axisThicknessSuspendCount === 0 && this.isThicknessChanged) {
  11917. this.onThicknessChanged();
  11918. }
  11919. }
  11920. }, onThicknessChanged:function() {
  11921. if (this.axisThicknessSuspendCount === 0) {
  11922. this.isThicknessChanged = false;
  11923. this.performLayout();
  11924. } else {
  11925. this.isThicknessChanged = true;
  11926. }
  11927. }, applySprites:function(sprites) {
  11928. var surface = this.getSurface('chart');
  11929. sprites = Ext.Array.from(sprites);
  11930. surface.removeAll(true);
  11931. surface.add(sprites);
  11932. return sprites;
  11933. }, initItems:function() {
  11934. var items = this.items, i, ln, item;
  11935. if (items && !items.isMixedCollection) {
  11936. this.items = [];
  11937. items = Ext.Array.from(items);
  11938. for (i = 0, ln = items.length; i < ln; i++) {
  11939. item = items[i];
  11940. if (item.type) {
  11941. Ext.raise("To add custom sprites to the chart use the 'sprites' config.");
  11942. } else {
  11943. this.items.push(item);
  11944. }
  11945. }
  11946. }
  11947. this.callParent();
  11948. }, applyBackground:function(newBackground, oldBackground) {
  11949. var surface = this.getSurface('background');
  11950. return this.refreshBackground(surface, newBackground, oldBackground);
  11951. }, refreshBackground:function(surface, newBackground, oldBackground) {
  11952. var width, height, isUpdateOld;
  11953. if (newBackground) {
  11954. if (oldBackground) {
  11955. width = oldBackground.attr.width;
  11956. height = oldBackground.attr.height;
  11957. isUpdateOld = oldBackground.type === (newBackground.type || 'rect');
  11958. }
  11959. if (newBackground.isSprite) {
  11960. oldBackground = newBackground;
  11961. } else {
  11962. if (newBackground.type === 'image' && Ext.isString(newBackground.src)) {
  11963. if (isUpdateOld) {
  11964. oldBackground.setAttributes({src:newBackground.src});
  11965. } else {
  11966. surface.remove(oldBackground, true);
  11967. oldBackground = surface.add(newBackground);
  11968. }
  11969. } else {
  11970. if (isUpdateOld) {
  11971. oldBackground.setAttributes({fillStyle:newBackground});
  11972. } else {
  11973. surface.remove(oldBackground, true);
  11974. oldBackground = surface.add({type:'rect', fillStyle:newBackground, animation:{customDurations:{x:0, y:0, width:0, height:0}}});
  11975. }
  11976. }
  11977. }
  11978. }
  11979. if (width && height) {
  11980. oldBackground.setAttributes({width:width, height:height});
  11981. }
  11982. oldBackground.setAnimation(this.getAnimation());
  11983. return oldBackground;
  11984. }, defaultResizeHandler:function(size) {
  11985. this.scheduleLayout();
  11986. return false;
  11987. }, applyMainRect:function(newRect, rect) {
  11988. if (!rect) {
  11989. return newRect;
  11990. }
  11991. this.getSeries();
  11992. this.getAxes();
  11993. if (newRect[0] === rect[0] && newRect[1] === rect[1] && newRect[2] === rect[2] && newRect[3] === rect[3]) {
  11994. return rect;
  11995. } else {
  11996. return newRect;
  11997. }
  11998. }, register:function(component) {
  11999. var map = this.chartComponents, id = component.getId();
  12000. if (id === undefined) {
  12001. Ext.raise('Chart component id is undefined. ' + 'Please ensure the component has an id.');
  12002. }
  12003. if (id in map) {
  12004. Ext.raise('Registering duplicate chart component id "' + id + '"');
  12005. }
  12006. map[id] = component;
  12007. }, unregister:function(component) {
  12008. var map = this.chartComponents, id = component.getId();
  12009. delete map[id];
  12010. }, get:function(id) {
  12011. return this.chartComponents[id];
  12012. }, getAxis:function(axis) {
  12013. if (axis instanceof Ext.chart.axis.Axis) {
  12014. return axis;
  12015. } else {
  12016. if (Ext.isNumber(axis)) {
  12017. return this.getAxes()[axis];
  12018. } else {
  12019. if (Ext.isString(axis)) {
  12020. return this.get(axis);
  12021. }
  12022. }
  12023. }
  12024. }, getSurface:function(id, type) {
  12025. var me = this, map = me.surfaceMap, surface;
  12026. id = id || 'main';
  12027. type = type || id;
  12028. surface = this.callParent([id, type]);
  12029. if (!map[type]) {
  12030. map[type] = [];
  12031. }
  12032. if (Ext.Array.indexOf(map[type], surface) < 0) {
  12033. surface.type = type;
  12034. map[type].push(surface);
  12035. surface.on('destroy', me.forgetSurface, me);
  12036. }
  12037. return surface;
  12038. }, forgetSurface:function(surface) {
  12039. var map = this.surfaceMap, group, index;
  12040. if (!map || this.destroying) {
  12041. return;
  12042. }
  12043. group = map[surface.type];
  12044. index = group ? Ext.Array.indexOf(group, surface) : -1;
  12045. if (index >= 0) {
  12046. group.splice(index, 1);
  12047. }
  12048. }, applyAxes:function(newAxes, oldAxes) {
  12049. var me = this, positions = {left:'right', right:'left'}, result = [], axis, oldAxis, linkedTo, id, oldMap, series, i, j, ln;
  12050. me.animationSuspendCount++;
  12051. me.getStore();
  12052. if (!oldAxes) {
  12053. oldAxes = [];
  12054. oldAxes.map = {};
  12055. }
  12056. oldMap = oldAxes.map;
  12057. result.map = {};
  12058. newAxes = Ext.Array.from(newAxes, true);
  12059. for (i = 0, ln = newAxes.length; i < ln; i++) {
  12060. axis = newAxes[i];
  12061. if (!axis) {
  12062. continue;
  12063. }
  12064. if (axis instanceof Ext.chart.axis.Axis) {
  12065. oldAxis = oldMap[axis.getId()];
  12066. axis.setChart(me);
  12067. } else {
  12068. axis = Ext.Object.chain(axis);
  12069. linkedTo = axis.linkedTo;
  12070. id = axis.id;
  12071. if (Ext.isNumber(linkedTo)) {
  12072. axis = Ext.merge({}, newAxes[linkedTo], axis);
  12073. } else {
  12074. if (Ext.isString(linkedTo)) {
  12075. Ext.Array.each(newAxes, function(item) {
  12076. if (item.id === axis.linkedTo) {
  12077. axis = Ext.merge({}, item, axis);
  12078. return false;
  12079. }
  12080. });
  12081. }
  12082. }
  12083. axis.id = id;
  12084. axis.chart = me;
  12085. if (me.getInherited().rtl) {
  12086. axis.position = positions[axis.position] || axis.position;
  12087. }
  12088. id = axis.getId && axis.getId() || axis.id;
  12089. axis = Ext.factory(axis, null, oldAxis = oldMap[id], 'axis');
  12090. }
  12091. if (axis) {
  12092. result.push(axis);
  12093. result.map[axis.getId()] = axis;
  12094. }
  12095. }
  12096. me.axesChangeSeries = {};
  12097. for (i in oldMap) {
  12098. if (!result.map[i]) {
  12099. oldAxis = oldMap[i];
  12100. if (oldAxis && !oldAxis.destroyed) {
  12101. for (j = 0, ln = oldAxis.boundSeries.length; j < ln; j++) {
  12102. series = oldAxis.boundSeries[j];
  12103. me.axesChangeSeries[series.getId()] = series;
  12104. }
  12105. oldAxis.destroy();
  12106. }
  12107. }
  12108. }
  12109. me.animationSuspendCount--;
  12110. return result;
  12111. }, updateAxes:function(axes) {
  12112. var me = this, seriesMap = me.axesChangeSeries, series, id, i, ln, axis;
  12113. for (id in seriesMap) {
  12114. series = seriesMap[id];
  12115. series.onAxesChange(me, true);
  12116. }
  12117. for (i = 0, ln = axes.length; i < ln; i++) {
  12118. axis = axes[i];
  12119. axis.onSeriesChange(me);
  12120. }
  12121. if (!me.isConfiguring && !me.destroying) {
  12122. me.scheduleLayout();
  12123. }
  12124. }, circularCopyArray:function(inArray, startIndex, count) {
  12125. var outArray = [], i, len = inArray && inArray.length;
  12126. if (len) {
  12127. for (i = 0; i < count; i++) {
  12128. outArray.push(inArray[(startIndex + i) % len]);
  12129. }
  12130. }
  12131. return outArray;
  12132. }, circularCopyObject:function(inObject, startIndex, count) {
  12133. var me = this, name, value, outObject = {};
  12134. if (count) {
  12135. for (name in inObject) {
  12136. if (inObject.hasOwnProperty(name)) {
  12137. value = inObject[name];
  12138. if (Ext.isArray(value)) {
  12139. outObject[name] = me.circularCopyArray(value, startIndex, count);
  12140. } else {
  12141. outObject[name] = value;
  12142. }
  12143. }
  12144. }
  12145. }
  12146. return outObject;
  12147. }, getColors:function() {
  12148. var me = this, configColors = me.config.colors, theme = me.getTheme();
  12149. if (Ext.isArray(configColors) && configColors.length > 0) {
  12150. configColors = me.applyColors(configColors);
  12151. }
  12152. return configColors || theme && theme.getColors();
  12153. }, applyColors:function(newColors) {
  12154. newColors = Ext.Array.map(newColors, function(color) {
  12155. if (Ext.isString(color)) {
  12156. return color;
  12157. } else {
  12158. return color.toString();
  12159. }
  12160. });
  12161. return newColors;
  12162. }, updateColors:function(newColors) {
  12163. var me = this, theme = me.getTheme(), colors = newColors || theme && theme.getColors(), colorIndex = 0, series = me.getSeries(), seriesCount = series && series.length, i, seriesItem, seriesColors, seriesColorCount;
  12164. if (colors.length) {
  12165. for (i = 0; i < seriesCount; i++) {
  12166. seriesItem = series[i];
  12167. seriesColorCount = seriesItem.themeColorCount();
  12168. seriesColors = me.circularCopyArray(colors, colorIndex, seriesColorCount);
  12169. colorIndex += seriesColorCount;
  12170. seriesItem.updateChartColors(seriesColors);
  12171. }
  12172. }
  12173. if (!me.isConfiguring) {
  12174. me.refreshLegendStore();
  12175. }
  12176. }, applyTheme:function(theme) {
  12177. if (theme && theme.isTheme) {
  12178. return theme;
  12179. }
  12180. return Ext.Factory.chartTheme(theme);
  12181. }, updateGradients:function(gradients) {
  12182. if (!Ext.isEmpty(gradients)) {
  12183. this.updateTheme(this.getTheme());
  12184. }
  12185. }, updateTheme:function(theme, oldTheme) {
  12186. var me = this, axes = me.getAxes(), series = me.getSeries(), colors = me.getColors(), i;
  12187. if (!series) {
  12188. return;
  12189. }
  12190. me.updateChartTheme(theme);
  12191. for (i = 0; i < axes.length; i++) {
  12192. axes[i].updateTheme(theme);
  12193. }
  12194. for (i = 0; i < series.length; i++) {
  12195. series[i].setTheme(theme);
  12196. }
  12197. me.updateSpriteTheme(theme);
  12198. me.updateColors(colors);
  12199. me.redraw();
  12200. me.fireEvent('themechange', me, theme, oldTheme);
  12201. }, themeOnlyIfConfigured:{captions:true}, updateChartTheme:function(theme) {
  12202. var me = this, chartTheme = theme.getChart(), initialConfig = me.getInitialConfig(), defaultConfig = me.defaultConfig, configs = me.self.getConfigurator().configs, genericChartTheme = chartTheme.defaults, specificChartTheme = chartTheme[me.xtype], themeOnlyIfConfigured = me.themeOnlyIfConfigured, key, value, isObjValue, isUnusedConfig, initialValue, cfg;
  12203. chartTheme = Ext.merge({}, genericChartTheme, specificChartTheme);
  12204. for (key in chartTheme) {
  12205. value = chartTheme[key];
  12206. cfg = configs[key];
  12207. if (value !== null && value !== undefined && cfg) {
  12208. initialValue = initialConfig[key];
  12209. isObjValue = Ext.isObject(value);
  12210. isUnusedConfig = initialValue === defaultConfig[key];
  12211. if (isObjValue) {
  12212. if (isUnusedConfig && themeOnlyIfConfigured[key]) {
  12213. continue;
  12214. }
  12215. value = Ext.merge({}, value, initialValue);
  12216. }
  12217. if (isUnusedConfig || isObjValue) {
  12218. me[cfg.names.set](value);
  12219. }
  12220. }
  12221. }
  12222. }, updateSpriteTheme:function(theme) {
  12223. var me = this, chartSurface, sprites, styles, sprite, style, key, attr, isText, i, ln;
  12224. me.getSprites();
  12225. chartSurface = me.getSurface('chart');
  12226. sprites = chartSurface.getItems();
  12227. styles = theme.getSprites();
  12228. for (i = 0, ln = sprites.length; i < ln; i++) {
  12229. sprite = sprites[i];
  12230. style = styles[sprite.type];
  12231. if (style) {
  12232. attr = {};
  12233. isText = sprite.type === 'text';
  12234. for (key in style) {
  12235. if (!(key in sprite.config)) {
  12236. if (!(isText && key.indexOf('font') === 0 && sprite.config.font)) {
  12237. attr[key] = style[key];
  12238. }
  12239. }
  12240. }
  12241. sprite.setAttributes(attr);
  12242. }
  12243. }
  12244. }, addSeries:function(newSeries) {
  12245. var series = this.getSeries();
  12246. series = series.concat(Ext.Array.from(newSeries));
  12247. this.setSeries(series);
  12248. }, removeSeries:function(series) {
  12249. var existingSeries = this.getSeries(), newSeries = [], removeMap = {}, i, len, s;
  12250. series = Ext.Array.from(series);
  12251. for (i = 0, len = series.length; i < len; i++) {
  12252. s = series[i];
  12253. if (typeof s !== 'string') {
  12254. s = s.getId();
  12255. }
  12256. removeMap[s] = true;
  12257. }
  12258. for (i = 0, len = existingSeries.length; i < len; i++) {
  12259. if (!removeMap[existingSeries[i].getId()]) {
  12260. newSeries.push(existingSeries[i]);
  12261. }
  12262. }
  12263. this.setSeries(newSeries);
  12264. }, applySeries:function(newSeries, oldSeries) {
  12265. var me = this, result = [], oldMap, oldSeriesItem, i, ln, series;
  12266. me.animationSuspendCount++;
  12267. me.getAxes();
  12268. if (oldSeries) {
  12269. oldMap = oldSeries.map;
  12270. } else {
  12271. oldSeries = [];
  12272. oldMap = oldSeries.map = {};
  12273. }
  12274. result.map = {};
  12275. newSeries = Ext.Array.from(newSeries, true);
  12276. for (i = 0, ln = newSeries.length; i < ln; i++) {
  12277. series = newSeries[i];
  12278. if (!series) {
  12279. continue;
  12280. }
  12281. oldSeriesItem = oldMap[series.getId && series.getId() || series.id];
  12282. if (series instanceof Ext.chart.series.Series) {
  12283. if (oldSeriesItem && oldSeriesItem !== series) {
  12284. oldSeriesItem.destroy();
  12285. }
  12286. series.setChart(me);
  12287. } else {
  12288. if (Ext.isObject(series)) {
  12289. if (oldSeriesItem) {
  12290. oldSeriesItem.setConfig(series);
  12291. series = oldSeriesItem;
  12292. } else {
  12293. if (Ext.isString(series)) {
  12294. series = {type:series};
  12295. }
  12296. series.chart = me;
  12297. series = Ext.create(series.xclass || 'series.' + series.type, series);
  12298. }
  12299. }
  12300. }
  12301. result.push(series);
  12302. result.map[series.getId()] = series;
  12303. }
  12304. for (i in oldMap) {
  12305. if (!result.map[oldMap[i].id]) {
  12306. oldMap[i].destroy();
  12307. }
  12308. }
  12309. me.animationSuspendCount--;
  12310. return result;
  12311. }, updateSeries:function(newSeries, oldSeries) {
  12312. var me = this;
  12313. if (me.destroying) {
  12314. return;
  12315. }
  12316. me.animationSuspendCount++;
  12317. me.fireEvent('serieschange', me, newSeries, oldSeries);
  12318. if (!Ext.isEmpty(newSeries)) {
  12319. me.updateTheme(me.getTheme());
  12320. }
  12321. me.refreshLegendStore();
  12322. if (!me.isConfiguring && !me.destroying) {
  12323. me.scheduleLayout();
  12324. }
  12325. me.animationSuspendCount--;
  12326. }, defaultLegendType:'sprite', applyLegend:function(legend, oldLegend) {
  12327. var me = this, result = null, alias;
  12328. if (oldLegend && !(oldLegend.destroyed || oldLegend.destroying)) {
  12329. if (me.legendStoreListeners) {
  12330. me.legendStoreListeners.destroy();
  12331. }
  12332. if (me.legendStore) {
  12333. me.legendStore.destroy();
  12334. }
  12335. oldLegend.destroy();
  12336. }
  12337. if (legend) {
  12338. if (Ext.isBoolean(legend)) {
  12339. result = Ext.create('legend.' + me.defaultLegendType, {docked:'bottom', chart:me});
  12340. } else {
  12341. legend.docked = legend.docked || 'bottom';
  12342. legend.chart = me;
  12343. alias = 'legend.' + (legend.type || me.defaultLegendType);
  12344. result = Ext.create(alias, legend);
  12345. }
  12346. }
  12347. return result;
  12348. }, updateLegend:function(legend) {
  12349. var me = this;
  12350. me.destroyLegendStore();
  12351. if (legend) {
  12352. me.getItems();
  12353. legend.setStore(me.refreshLegendStore());
  12354. }
  12355. if (!me.isConfiguring) {
  12356. me.scheduleLayout();
  12357. }
  12358. }, captionApplier:function(caption, oldCaption) {
  12359. var me = this, result;
  12360. if (oldCaption && !(oldCaption.destroyed || oldCaption.destroying)) {
  12361. oldCaption.destroy();
  12362. }
  12363. if (caption) {
  12364. caption.chart = me;
  12365. result = new Ext.chart.Caption(caption);
  12366. }
  12367. return result;
  12368. }, applyCaptions:function(captions, oldCaptions) {
  12369. var map = {}, caption, oldCaption, name, any;
  12370. for (name in captions) {
  12371. caption = captions[name];
  12372. if (caption && !caption.length && !(caption.text && caption.text.length)) {
  12373. caption = null;
  12374. } else {
  12375. if (typeof caption === 'string') {
  12376. caption = {text:caption};
  12377. this.getInitialConfig().captions[name] = caption;
  12378. }
  12379. }
  12380. oldCaption = oldCaptions && oldCaptions[name];
  12381. caption = this.captionApplier(caption, oldCaption);
  12382. if (caption) {
  12383. any = true;
  12384. map[name] = caption;
  12385. }
  12386. }
  12387. return any && map;
  12388. }, updateCaptions:function() {
  12389. var me = this;
  12390. if (!me.isConfiguring) {
  12391. me.scheduleLayout();
  12392. }
  12393. }, getLegendStore:function() {
  12394. var me = this, store = me.legendStore;
  12395. if (!store) {
  12396. store = me.legendStore = new Ext.chart.legend.store.Store({chart:me});
  12397. me.legendStoreListeners = store.on({scope:me, update:'onLegendStoreUpdate', destroyable:true});
  12398. }
  12399. return store;
  12400. }, destroyLegendStore:function() {
  12401. var store = this.legendStore;
  12402. if (store && !(store.destroyed || store.destroying)) {
  12403. store.destroy();
  12404. }
  12405. this.legendStore = null;
  12406. }, refreshLegendStore:function() {
  12407. var me = this, legendStore = me.getLegendStore(), series, seriesList, legendData, i, ln;
  12408. if (legendStore) {
  12409. seriesList = me.getSeries();
  12410. legendData = [];
  12411. for (i = 0, ln = seriesList.length; i < ln; i++) {
  12412. series = seriesList[i];
  12413. if (series.getShowInLegend()) {
  12414. series.provideLegendInfo(legendData);
  12415. }
  12416. }
  12417. legendStore.setData(legendData);
  12418. }
  12419. return legendStore;
  12420. }, onLegendStoreUpdate:function(store, record) {
  12421. var me = this, series;
  12422. if (record) {
  12423. series = this.getSeries().map[record.get('series')];
  12424. if (series) {
  12425. series.setHiddenByIndex(record.get('index'), record.get('disabled'));
  12426. me.redraw();
  12427. }
  12428. }
  12429. }, applyInteractions:function(interactions, oldInteractions) {
  12430. var me = this, result = [], oldMap, interaction, i, ln;
  12431. interactions = Ext.Array.from(interactions, true);
  12432. if (!oldInteractions) {
  12433. oldInteractions = [];
  12434. oldInteractions.map = {};
  12435. }
  12436. oldMap = oldInteractions.map;
  12437. result.map = {};
  12438. for (i = 0, ln = interactions.length; i < ln; i++) {
  12439. interaction = interactions[i];
  12440. if (!interaction) {
  12441. continue;
  12442. }
  12443. interaction = Ext.factory(interaction, null, oldMap[interaction.getId && interaction.getId() || interaction.id], 'interaction');
  12444. if (interaction) {
  12445. interaction.setChart(me);
  12446. result.push(interaction);
  12447. result.map[interaction.getId()] = interaction;
  12448. }
  12449. }
  12450. for (i in oldMap) {
  12451. if (!result.map[i]) {
  12452. oldMap[i].destroy();
  12453. }
  12454. }
  12455. return result;
  12456. }, getInteraction:function(type) {
  12457. var interactions = this.getInteractions(), len = interactions && interactions.length, out = null, interaction, i;
  12458. if (len) {
  12459. for (i = 0; i < len; ++i) {
  12460. interaction = interactions[i];
  12461. if (interaction.type === type) {
  12462. out = interaction;
  12463. break;
  12464. }
  12465. }
  12466. }
  12467. return out;
  12468. }, applyStore:function(store) {
  12469. return store && Ext.StoreManager.lookup(store);
  12470. }, updateStore:function(newStore, oldStore) {
  12471. var me = this;
  12472. if (oldStore && !oldStore.destroyed) {
  12473. oldStore.un({datachanged:'onDataChanged', update:'onDataChanged', scope:me, order:'after'});
  12474. if (oldStore.autoDestroy) {
  12475. oldStore.destroy();
  12476. }
  12477. }
  12478. if (newStore) {
  12479. newStore.on({datachanged:'onDataChanged', update:'onDataChanged', scope:me, order:'after'});
  12480. }
  12481. me.fireEvent('storechange', me, newStore, oldStore);
  12482. me.onDataChanged();
  12483. }, redraw:function() {
  12484. this.fireEvent('redraw', this);
  12485. }, performLayout:function() {
  12486. if (this.destroying || this.destroyed) {
  12487. Ext.raise('Attempting to lay out a dead chart: ' + this.getId());
  12488. return false;
  12489. }
  12490. var me = this, legend = me.getLegend(), chartRect = me.getChartRect(true), background = me.getBackground(), result = true, legendRect;
  12491. me.cancelChartLayout();
  12492. me.fireEvent('beforelayout', me);
  12493. if (background) {
  12494. me.getSurface('background').setRect(chartRect.slice());
  12495. background.setAttributes({width:chartRect[2], height:chartRect[3]});
  12496. }
  12497. if (legend && legend.isSpriteLegend && !legend.isTop) {
  12498. legendRect = legend.computeRect(chartRect);
  12499. }
  12500. me.layoutCaptions(chartRect);
  12501. if (legend && legend.isSpriteLegend && legend.isTop) {
  12502. legendRect = legend.computeRect(chartRect);
  12503. }
  12504. if (legendRect) {
  12505. me.getSurface('legend').setRect(legendRect);
  12506. result = legend.performLayout();
  12507. }
  12508. me.getSurface('chart').setRect(chartRect);
  12509. if (result) {
  12510. me.hasFirstLayout = true;
  12511. }
  12512. return result;
  12513. }, layoutCaptions:function(chartRect) {
  12514. var captions = this.getCaptions(), shrinkRect = {left:0, top:0, right:chartRect[2], bottom:chartRect[3]}, caption, captionName, captionList, i, ln;
  12515. if (captions) {
  12516. captionList = [];
  12517. for (captionName in captions) {
  12518. captionList.push(captions[captionName]);
  12519. }
  12520. captionList.sort(function(a, b) {
  12521. return a.getWeight() - b.getWeight();
  12522. });
  12523. for (i = 0, ln = captionList.length; i < ln; i++) {
  12524. caption = captionList[i];
  12525. if (!i) {
  12526. this.getSurface(caption.surfaceName).setRect(chartRect.slice());
  12527. }
  12528. caption.computeRect(chartRect, shrinkRect);
  12529. }
  12530. this.captionList = captionList;
  12531. }
  12532. }, checkLayoutEnd:function() {
  12533. if (!this.chartLayoutCount && !this.scheduledLayoutId) {
  12534. this.onLayoutEnd();
  12535. }
  12536. }, onLayoutEnd:function() {
  12537. var me = this;
  12538. me.fireEvent('layout', me);
  12539. }, getChartRect:function(isRecompute) {
  12540. var me = this, chartRect, bodySize;
  12541. if (isRecompute) {
  12542. me.chartRect = null;
  12543. }
  12544. if (me.chartRect) {
  12545. chartRect = me.chartRect;
  12546. } else {
  12547. bodySize = me.bodyElement.getSize();
  12548. chartRect = me.chartRect = [0, 0, bodySize.width, bodySize.height];
  12549. }
  12550. return chartRect;
  12551. }, getEventXY:function(e) {
  12552. return this.getSurface('series').getEventXY(e);
  12553. }, getItemForPoint:function(x, y) {
  12554. var me = this, seriesList = me.getSeries(), rect = me.getMainRect(), ln = seriesList.length, minDistance = Infinity, result = null, i, item;
  12555. if (!(me.hasFirstLayout && rect && x >= 0 && x <= rect[2] && y >= 0 && y <= rect[3])) {
  12556. return null;
  12557. }
  12558. for (i = ln - 1; i >= 0; i--) {
  12559. item = seriesList[i].getItemForPoint(x, y);
  12560. if (item) {
  12561. if (!item.distance) {
  12562. result = item;
  12563. break;
  12564. }
  12565. if (item.distance < minDistance) {
  12566. minDistance = item.distance;
  12567. result = item;
  12568. }
  12569. }
  12570. }
  12571. return result;
  12572. }, getItemsForPoint:function(x, y) {
  12573. var me = this, seriesList = me.getSeries(), ln = seriesList.length, i = me.hasFirstLayout ? ln - 1 : -1, items = [], series, item;
  12574. for (; i >= 0; i--) {
  12575. series = seriesList[i];
  12576. item = series.getItemForPoint(x, y);
  12577. if (item && (item.category === 'items' || item.category === 'markers')) {
  12578. items.push(item);
  12579. }
  12580. }
  12581. return items;
  12582. }, onDataChanged:function() {
  12583. var me = this, rect, store, series, axes;
  12584. if (me.isInitializing) {
  12585. return;
  12586. }
  12587. rect = me.getMainRect();
  12588. store = me.getStore();
  12589. series = me.getSeries();
  12590. axes = me.getAxes();
  12591. if (!store || !axes || !series) {
  12592. return;
  12593. }
  12594. if (!rect) {
  12595. me.on({redraw:me.onDataChanged, scope:me, single:true});
  12596. return;
  12597. }
  12598. me.processData();
  12599. me.redraw();
  12600. }, recordCount:0, processData:function() {
  12601. var me = this, recordCount = me.getStore().getCount(), seriesList = me.getSeries(), ln = seriesList.length, isNeedUpdateColors = false, i = 0, series;
  12602. for (; i < ln; i++) {
  12603. series = seriesList[i];
  12604. series.processData();
  12605. if (!isNeedUpdateColors && series.isStoreDependantColorCount) {
  12606. isNeedUpdateColors = true;
  12607. }
  12608. }
  12609. if (isNeedUpdateColors && recordCount > me.recordCount) {
  12610. me.updateColors(me.getColors());
  12611. me.recordCount = recordCount;
  12612. }
  12613. if (!me.isConfiguring) {
  12614. me.refreshLegendStore();
  12615. }
  12616. }, bindStore:function(store) {
  12617. this.setStore(store);
  12618. }, applyHighlightItem:function(newHighlightItem, oldHighlightItem) {
  12619. var i1, i2, s1, s2;
  12620. if (newHighlightItem === oldHighlightItem) {
  12621. return;
  12622. }
  12623. if (Ext.isObject(newHighlightItem) && Ext.isObject(oldHighlightItem)) {
  12624. i1 = newHighlightItem;
  12625. i2 = oldHighlightItem;
  12626. s1 = i1.sprite && (i1.sprite[0] || i1.sprite);
  12627. s2 = i2.sprite && (i2.sprite[0] || i2.sprite);
  12628. if (s1 === s2 && i1.index === i2.index) {
  12629. return;
  12630. }
  12631. }
  12632. return newHighlightItem;
  12633. }, updateHighlightItem:function(newHighlightItem, oldHighlightItem) {
  12634. var newHighlight, oldHighlight;
  12635. if (oldHighlightItem) {
  12636. oldHighlight = oldHighlightItem.series.getHighlight();
  12637. if (oldHighlight) {
  12638. oldHighlightItem.series.setAttributesForItem(oldHighlightItem, {highlighted:false});
  12639. }
  12640. }
  12641. if (newHighlightItem) {
  12642. newHighlight = newHighlightItem.series.getHighlight();
  12643. if (newHighlight) {
  12644. newHighlightItem.series.setAttributesForItem(newHighlightItem, {highlighted:true});
  12645. }
  12646. }
  12647. if (oldHighlight || newHighlight) {
  12648. this.fireEvent('itemhighlight', this, newHighlightItem, oldHighlightItem);
  12649. }
  12650. }, destroyChart:function() {
  12651. var me = this;
  12652. me.setInteractions(null);
  12653. me.setAxes(null);
  12654. me.setSeries(null);
  12655. me.setLegend(null);
  12656. me.setStore(null);
  12657. me.cancelChartLayout();
  12658. }, getRefItems:function(deep) {
  12659. var me = this, series = me.getSeries(), axes = me.getAxes(), interaction = me.getInteractions(), legend = me.getLegend(), ans = [], i, ln;
  12660. for (i = 0, ln = series.length; i < ln; i++) {
  12661. ans.push(series[i]);
  12662. if (series[i].getRefItems) {
  12663. ans.push.apply(ans, series[i].getRefItems(deep));
  12664. }
  12665. }
  12666. for (i = 0, ln = axes.length; i < ln; i++) {
  12667. ans.push(axes[i]);
  12668. if (axes[i].getRefItems) {
  12669. ans.push.apply(ans, axes[i].getRefItems(deep));
  12670. }
  12671. }
  12672. for (i = 0, ln = interaction.length; i < ln; i++) {
  12673. ans.push(interaction[i]);
  12674. if (interaction[i].getRefItems) {
  12675. ans.push.apply(ans, interaction[i].getRefItems(deep));
  12676. }
  12677. }
  12678. if (legend) {
  12679. ans.push(legend);
  12680. }
  12681. return ans;
  12682. }});
  12683. Ext.define('Ext.chart.overrides.AbstractChart', {override:'Ext.chart.AbstractChart', zIndex:0, updateLegend:function(legend, oldLegend) {
  12684. this.callParent([legend, oldLegend]);
  12685. if (legend && legend.isDomLegend) {
  12686. this.add(legend);
  12687. }
  12688. }, onItemRemove:function(item, index, destroy) {
  12689. var map = this.surfaceMap, type = item.type, items = map && map[type];
  12690. this.callParent([item, index, destroy]);
  12691. if (items) {
  12692. Ext.Array.remove(items, item);
  12693. if (items.length === 0) {
  12694. delete map[type];
  12695. }
  12696. }
  12697. }, doDestroy:function() {
  12698. this.destroyChart();
  12699. this.callParent();
  12700. }});
  12701. Ext.define('Ext.chart.grid.HorizontalGrid', {extend:'Ext.draw.sprite.Sprite', alias:'grid.horizontal', inheritableStatics:{def:{processors:{x:'number', y:'number', width:'number', height:'number'}, defaults:{x:0, y:0, width:1, height:1, strokeStyle:'#DDD'}}}, render:function(surface, ctx, rect) {
  12702. var attr = this.attr, y = surface.roundPixel(attr.y), halfLineWidth = ctx.lineWidth * 0.5;
  12703. ctx.beginPath();
  12704. ctx.rect(rect[0] - surface.matrix.getDX(), y + halfLineWidth, +rect[2], attr.height);
  12705. ctx.fill();
  12706. ctx.beginPath();
  12707. ctx.moveTo(rect[0] - surface.matrix.getDX(), y + halfLineWidth);
  12708. ctx.lineTo(rect[0] + rect[2] - surface.matrix.getDX(), y + halfLineWidth);
  12709. ctx.stroke();
  12710. }});
  12711. Ext.define('Ext.chart.grid.VerticalGrid', {extend:'Ext.draw.sprite.Sprite', alias:'grid.vertical', inheritableStatics:{def:{processors:{x:'number', y:'number', width:'number', height:'number'}, defaults:{x:0, y:0, width:1, height:1, strokeStyle:'#DDD'}}}, render:function(surface, ctx, rect) {
  12712. var attr = this.attr, x = surface.roundPixel(attr.x), halfLineWidth = ctx.lineWidth * 0.5;
  12713. ctx.beginPath();
  12714. ctx.rect(x - halfLineWidth, rect[1] - surface.matrix.getDY(), attr.width, rect[3]);
  12715. ctx.fill();
  12716. ctx.beginPath();
  12717. ctx.moveTo(x - halfLineWidth, rect[1] - surface.matrix.getDY());
  12718. ctx.lineTo(x - halfLineWidth, rect[1] + rect[3] - surface.matrix.getDY());
  12719. ctx.stroke();
  12720. }});
  12721. Ext.define('Ext.chart.CartesianChart', {extend:'Ext.chart.AbstractChart', alternateClassName:'Ext.chart.Chart', requires:['Ext.chart.grid.HorizontalGrid', 'Ext.chart.grid.VerticalGrid'], xtype:['cartesian', 'chart'], isCartesian:true, config:{flipXY:false, innerRect:[0, 0, 1, 1], innerPadding:{top:0, left:0, right:0, bottom:0}}, applyInnerPadding:function(padding, oldPadding) {
  12722. if (!Ext.isObject(padding)) {
  12723. return Ext.util.Format.parseBox(padding);
  12724. } else {
  12725. if (!oldPadding) {
  12726. return padding;
  12727. } else {
  12728. return Ext.apply(oldPadding, padding);
  12729. }
  12730. }
  12731. }, getDirectionForAxis:function(position) {
  12732. var flipXY = this.getFlipXY(), direction;
  12733. if (position === 'left' || position === 'right') {
  12734. direction = flipXY ? 'X' : 'Y';
  12735. } else {
  12736. direction = flipXY ? 'Y' : 'X';
  12737. }
  12738. return direction;
  12739. }, performLayout:function() {
  12740. var me = this;
  12741. if (me.callParent() === false) {
  12742. return;
  12743. }
  12744. me.chartLayoutCount++;
  12745. me.suspendAnimation();
  12746. var chartRect = me.getSurface('chart').getRect(), left = chartRect[0], top = chartRect[1], width = chartRect[2], height = chartRect[3], captionList = me.captionList, axes = me.getAxes(), axis, seriesList = me.getSeries(), series, axisSurface, thickness, insetPadding = me.getInsetPadding(), innerPadding = me.getInnerPadding(), surface, gridSurface, shrinkBox = Ext.apply({}, insetPadding), mainRect, innerWidth, innerHeight, elements, floating, floatingValue, matrix, i, ln, isRtl = me.getInherited().rtl,
  12747. flipXY = me.getFlipXY(), caption;
  12748. if (width <= 0 || height <= 0) {
  12749. return;
  12750. }
  12751. me.suspendThicknessChanged();
  12752. for (i = 0; i < axes.length; i++) {
  12753. axis = axes[i];
  12754. axisSurface = axis.getSurface();
  12755. floating = axis.getFloating();
  12756. floatingValue = floating ? floating.value : null;
  12757. thickness = axis.getThickness();
  12758. switch(axis.getPosition()) {
  12759. case 'top':
  12760. axisSurface.setRect([left, top + shrinkBox.top + 1, width, thickness]);
  12761. break;
  12762. case 'bottom':
  12763. axisSurface.setRect([left, top + height - (shrinkBox.bottom + thickness), width, thickness]);
  12764. break;
  12765. case 'left':
  12766. axisSurface.setRect([left + shrinkBox.left, top, thickness, height]);
  12767. break;
  12768. case 'right':
  12769. axisSurface.setRect([left + width - (shrinkBox.right + thickness), top, thickness, height]);
  12770. break;
  12771. }
  12772. if (floatingValue === null) {
  12773. shrinkBox[axis.getPosition()] += thickness;
  12774. }
  12775. }
  12776. width -= shrinkBox.left + shrinkBox.right;
  12777. height -= shrinkBox.top + shrinkBox.bottom;
  12778. mainRect = [left + shrinkBox.left, top + shrinkBox.top, width, height];
  12779. shrinkBox.left += innerPadding.left;
  12780. shrinkBox.top += innerPadding.top;
  12781. shrinkBox.right += innerPadding.right;
  12782. shrinkBox.bottom += innerPadding.bottom;
  12783. innerWidth = width - innerPadding.left - innerPadding.right;
  12784. innerHeight = height - innerPadding.top - innerPadding.bottom;
  12785. me.setInnerRect([shrinkBox.left, shrinkBox.top, innerWidth, innerHeight]);
  12786. if (innerWidth <= 0 || innerHeight <= 0) {
  12787. return;
  12788. }
  12789. me.setMainRect(mainRect);
  12790. me.getSurface().setRect(mainRect);
  12791. for (i = 0, ln = me.surfaceMap.grid && me.surfaceMap.grid.length; i < ln; i++) {
  12792. gridSurface = me.surfaceMap.grid[i];
  12793. gridSurface.setRect(mainRect);
  12794. gridSurface.matrix.set(1, 0, 0, 1, innerPadding.left, innerPadding.top);
  12795. gridSurface.matrix.inverse(gridSurface.inverseMatrix);
  12796. }
  12797. for (i = 0; i < axes.length; i++) {
  12798. axis = axes[i];
  12799. axis.getRange(true);
  12800. axisSurface = axis.getSurface();
  12801. matrix = axisSurface.matrix;
  12802. elements = matrix.elements;
  12803. switch(axis.getPosition()) {
  12804. case 'top':
  12805. case 'bottom':
  12806. elements[4] = shrinkBox.left;
  12807. axis.setLength(innerWidth);
  12808. break;
  12809. case 'left':
  12810. case 'right':
  12811. elements[5] = shrinkBox.top;
  12812. axis.setLength(innerHeight);
  12813. break;
  12814. }
  12815. axis.updateTitleSprite();
  12816. matrix.inverse(axisSurface.inverseMatrix);
  12817. }
  12818. for (i = 0, ln = seriesList.length; i < ln; i++) {
  12819. series = seriesList[i];
  12820. surface = series.getSurface();
  12821. surface.setRect(mainRect);
  12822. if (flipXY) {
  12823. if (isRtl) {
  12824. surface.matrix.set(0, -1, -1, 0, innerPadding.left + innerWidth, innerPadding.top + innerHeight);
  12825. } else {
  12826. surface.matrix.set(0, -1, 1, 0, innerPadding.left, innerPadding.top + innerHeight);
  12827. }
  12828. } else {
  12829. surface.matrix.set(1, 0, 0, -1, innerPadding.left, innerPadding.top + innerHeight);
  12830. }
  12831. surface.matrix.inverse(surface.inverseMatrix);
  12832. series.getOverlaySurface().setRect(mainRect);
  12833. }
  12834. if (captionList) {
  12835. for (i = 0, ln = captionList.length; i < ln; i++) {
  12836. caption = captionList[i];
  12837. if (caption.getAlignTo() === 'series') {
  12838. caption.alignRect(mainRect);
  12839. }
  12840. caption.performLayout();
  12841. }
  12842. }
  12843. me.afterChartLayout();
  12844. me.redraw();
  12845. me.resumeAnimation();
  12846. me.resumeThicknessChanged();
  12847. me.chartLayoutCount--;
  12848. me.checkLayoutEnd();
  12849. }, afterChartLayout:Ext.emptyFn, refloatAxes:function() {
  12850. var me = this, axes = me.getAxes(), axesCount = axes && axes.length || 0, axis, axisSurface, axisRect, floating, value, alongAxis, matrix, chartRect = me.getChartRect(), inset = me.getInsetPadding(), inner = me.getInnerPadding(), width = chartRect[2] - inset.left - inset.right, height = chartRect[3] - inset.top - inset.bottom, isHorizontal, i;
  12851. for (i = 0; i < axesCount; i++) {
  12852. axis = axes[i];
  12853. floating = axis.getFloating();
  12854. value = floating ? floating.value : null;
  12855. if (value === null) {
  12856. axis.floatingAtCoord = null;
  12857. continue;
  12858. }
  12859. axisSurface = axis.getSurface();
  12860. axisRect = axisSurface.getRect();
  12861. if (!axisRect) {
  12862. continue;
  12863. }
  12864. axisRect = axisRect.slice();
  12865. alongAxis = me.getAxis(floating.alongAxis);
  12866. if (alongAxis) {
  12867. isHorizontal = alongAxis.getAlignment() === 'horizontal';
  12868. if (Ext.isString(value)) {
  12869. value = alongAxis.getCoordFor(value);
  12870. }
  12871. alongAxis.floatingAxes[axis.getId()] = value;
  12872. matrix = alongAxis.getSprites()[0].attr.matrix;
  12873. if (isHorizontal) {
  12874. value = value * matrix.getXX() + matrix.getDX();
  12875. axis.floatingAtCoord = value + inner.left + inner.right;
  12876. } else {
  12877. value = value * matrix.getYY() + matrix.getDY();
  12878. axis.floatingAtCoord = value + inner.top + inner.bottom;
  12879. }
  12880. } else {
  12881. isHorizontal = axis.getAlignment() === 'horizontal';
  12882. if (isHorizontal) {
  12883. axis.floatingAtCoord = value + inner.top + inner.bottom;
  12884. } else {
  12885. axis.floatingAtCoord = value + inner.left + inner.right;
  12886. }
  12887. value = axisSurface.roundPixel(0.01 * value * (isHorizontal ? height : width));
  12888. }
  12889. switch(axis.getPosition()) {
  12890. case 'top':
  12891. axisRect[1] = inset.top + inner.top + value - axisRect[3] + 1;
  12892. break;
  12893. case 'bottom':
  12894. axisRect[1] = inset.top + inner.top + (alongAxis ? value : height - value);
  12895. break;
  12896. case 'left':
  12897. axisRect[0] = inset.left + inner.left + value - axisRect[2];
  12898. break;
  12899. case 'right':
  12900. axisRect[0] = inset.left + inner.left + (alongAxis ? value : width - value) - 1;
  12901. break;
  12902. }
  12903. axisSurface.setRect(axisRect);
  12904. }
  12905. }, redraw:function() {
  12906. var me = this, seriesList = me.getSeries(), axes = me.getAxes(), rect = me.getMainRect(), innerWidth, innerHeight, innerPadding = me.getInnerPadding(), sprites, xRange, yRange, isSide, attr, i, j, ln, axis, axisX, axisY, range, visibleRange, flipXY = me.getFlipXY(), zBase = 1000, zIndex, markersZIndex, series, sprite, markers;
  12907. if (!rect) {
  12908. return;
  12909. }
  12910. innerWidth = rect[2] - innerPadding.left - innerPadding.right;
  12911. innerHeight = rect[3] - innerPadding.top - innerPadding.bottom;
  12912. for (i = 0; i < seriesList.length; i++) {
  12913. series = seriesList[i];
  12914. axisX = series.getXAxis();
  12915. if (axisX) {
  12916. visibleRange = axisX.getVisibleRange();
  12917. xRange = axisX.getRange();
  12918. xRange = [xRange[0] + (xRange[1] - xRange[0]) * visibleRange[0], xRange[0] + (xRange[1] - xRange[0]) * visibleRange[1]];
  12919. } else {
  12920. xRange = series.getXRange();
  12921. }
  12922. axisY = series.getYAxis();
  12923. if (axisY) {
  12924. visibleRange = axisY.getVisibleRange();
  12925. yRange = axisY.getRange();
  12926. yRange = [yRange[0] + (yRange[1] - yRange[0]) * visibleRange[0], yRange[0] + (yRange[1] - yRange[0]) * visibleRange[1]];
  12927. } else {
  12928. yRange = series.getYRange();
  12929. }
  12930. attr = {visibleMinX:xRange[0], visibleMaxX:xRange[1], visibleMinY:yRange[0], visibleMaxY:yRange[1], innerWidth:innerWidth, innerHeight:innerHeight, flipXY:flipXY};
  12931. sprites = series.getSprites();
  12932. for (j = 0, ln = sprites.length; j < ln; j++) {
  12933. sprite = sprites[j];
  12934. zIndex = sprite.attr.zIndex;
  12935. if (zIndex < zBase) {
  12936. zIndex += (i + 1) * 100 + zBase;
  12937. sprite.attr.zIndex = zIndex;
  12938. markers = sprite.getMarker('items');
  12939. if (markers) {
  12940. markersZIndex = markers.attr.zIndex;
  12941. if (markersZIndex === Number.MAX_VALUE) {
  12942. markers.attr.zIndex = zIndex;
  12943. } else {
  12944. if (markersZIndex < zBase) {
  12945. markers.attr.zIndex = zIndex + markersZIndex;
  12946. }
  12947. }
  12948. }
  12949. }
  12950. sprite.setAttributes(attr, true);
  12951. }
  12952. }
  12953. for (i = 0; i < axes.length; i++) {
  12954. axis = axes[i];
  12955. isSide = axis.isSide();
  12956. sprites = axis.getSprites();
  12957. range = axis.getRange();
  12958. visibleRange = axis.getVisibleRange();
  12959. attr = {dataMin:range[0], dataMax:range[1], visibleMin:visibleRange[0], visibleMax:visibleRange[1]};
  12960. if (isSide) {
  12961. attr.length = innerHeight;
  12962. attr.startGap = innerPadding.bottom;
  12963. attr.endGap = innerPadding.top;
  12964. } else {
  12965. attr.length = innerWidth;
  12966. attr.startGap = innerPadding.left;
  12967. attr.endGap = innerPadding.right;
  12968. }
  12969. for (j = 0, ln = sprites.length; j < ln; j++) {
  12970. sprites[j].setAttributes(attr, true);
  12971. }
  12972. }
  12973. me.renderFrame();
  12974. me.callParent();
  12975. }, renderFrame:function() {
  12976. this.refloatAxes();
  12977. this.callParent();
  12978. }});
  12979. Ext.define('Ext.chart.grid.CircularGrid', {extend:'Ext.draw.sprite.Circle', alias:'grid.circular', inheritableStatics:{def:{defaults:{r:1, strokeStyle:'#DDD'}}}});
  12980. Ext.define('Ext.chart.grid.RadialGrid', {extend:'Ext.draw.sprite.Path', alias:'grid.radial', inheritableStatics:{def:{processors:{startRadius:'number', endRadius:'number'}, defaults:{startRadius:0, endRadius:1, scalingCenterX:0, scalingCenterY:0, strokeStyle:'#DDD'}, triggers:{startRadius:'path,bbox', endRadius:'path,bbox'}}}, render:function() {
  12981. this.callParent(arguments);
  12982. }, updatePath:function(path, attr) {
  12983. var startRadius = attr.startRadius, endRadius = attr.endRadius;
  12984. path.moveTo(startRadius, 0);
  12985. path.lineTo(endRadius, 0);
  12986. }});
  12987. Ext.define('Ext.chart.PolarChart', {extend:'Ext.chart.AbstractChart', requires:['Ext.chart.grid.CircularGrid', 'Ext.chart.grid.RadialGrid'], xtype:'polar', isPolar:true, config:{center:[0, 0], radius:0, innerPadding:0}, getDirectionForAxis:function(position) {
  12988. return position === 'radial' ? 'Y' : 'X';
  12989. }, updateCenter:function(center) {
  12990. var me = this, axes = me.getAxes(), series = me.getSeries(), i, ln, axis, seriesItem;
  12991. for (i = 0, ln = axes.length; i < ln; i++) {
  12992. axis = axes[i];
  12993. axis.setCenter(center);
  12994. }
  12995. for (i = 0, ln = series.length; i < ln; i++) {
  12996. seriesItem = series[i];
  12997. seriesItem.setCenter(center);
  12998. }
  12999. }, applyInnerPadding:function(padding, oldPadding) {
  13000. return Ext.isNumber(padding) ? padding : oldPadding;
  13001. }, updateInnerPadding:function() {
  13002. if (!this.isConfiguring) {
  13003. this.performLayout();
  13004. }
  13005. }, doSetSurfaceRect:function(surface, rect) {
  13006. var mainRect = this.getMainRect();
  13007. surface.setRect(rect);
  13008. surface.matrix.set(1, 0, 0, 1, mainRect[0] - rect[0], mainRect[1] - rect[1]);
  13009. surface.inverseMatrix.set(1, 0, 0, 1, rect[0] - mainRect[0], rect[1] - mainRect[1]);
  13010. }, applyAxes:function(newAxes, oldAxes) {
  13011. var me = this, firstSeries = Ext.Array.from(me.config.series)[0], i, ln, axis, foundAngular;
  13012. if (firstSeries && firstSeries.type === 'radar' && newAxes && newAxes.length) {
  13013. for (i = 0, ln = newAxes.length; i < ln; i++) {
  13014. axis = newAxes[i];
  13015. if (axis.position === 'angular') {
  13016. foundAngular = true;
  13017. break;
  13018. }
  13019. }
  13020. if (!foundAngular) {
  13021. newAxes.push({type:'category', position:'angular', fields:firstSeries.xField || firstSeries.angleField, style:{estStepSize:1}, grid:true});
  13022. }
  13023. }
  13024. return this.callParent([newAxes, oldAxes]);
  13025. }, performLayout:function() {
  13026. var me = this, applyThickness = true;
  13027. try {
  13028. me.chartLayoutCount++;
  13029. me.suspendAnimation();
  13030. if (this.callParent() === false) {
  13031. applyThickness = false;
  13032. return;
  13033. }
  13034. me.suspendThicknessChanged();
  13035. var chartRect = me.getSurface('chart').getRect(), inset = me.getInsetPadding(), inner = me.getInnerPadding(), shrinkBox = Ext.apply({}, inset), width = Math.max(1, chartRect[2] - chartRect[0] - inset.left - inset.right), height = Math.max(1, chartRect[3] - chartRect[1] - inset.top - inset.bottom), mainRect = [chartRect[0] + inset.left, chartRect[1] + inset.top, width + chartRect[0], height + chartRect[1]], seriesList = me.getSeries(), innerWidth = width - inner * 2, innerHeight = height - inner *
  13036. 2, center = [(chartRect[0] + innerWidth) * 0.5 + inner, (chartRect[1] + innerHeight) * 0.5 + inner], radius = Math.min(innerWidth, innerHeight) * 0.5, axes = me.getAxes(), angularAxes = [], radialAxes = [], seriesRadius = radius - inner, grid = me.surfaceMap.grid, captionList = me.captionList, i, ln, shrinkRadius, floating, floatingValue, gaugeSeries, gaugeRadius, side, series, axis, thickness, halfLineWidth, caption;
  13037. me.setMainRect(mainRect);
  13038. me.doSetSurfaceRect(me.getSurface(), mainRect);
  13039. if (grid) {
  13040. for (i = 0, ln = grid.length; i < ln; i++) {
  13041. me.doSetSurfaceRect(grid[i], chartRect);
  13042. }
  13043. }
  13044. for (i = 0, ln = axes.length; i < ln; i++) {
  13045. axis = axes[i];
  13046. switch(axis.getPosition()) {
  13047. case 'angular':
  13048. angularAxes.push(axis);
  13049. break;
  13050. case 'radial':
  13051. radialAxes.push(axis);
  13052. break;
  13053. }
  13054. }
  13055. for (i = 0, ln = angularAxes.length; i < ln; i++) {
  13056. axis = angularAxes[i];
  13057. floating = axis.getFloating();
  13058. floatingValue = floating ? floating.value : null;
  13059. me.doSetSurfaceRect(axis.getSurface(), chartRect);
  13060. thickness = axis.getThickness();
  13061. for (side in shrinkBox) {
  13062. shrinkBox[side] += thickness;
  13063. }
  13064. width = chartRect[2] - shrinkBox.left - shrinkBox.right;
  13065. height = chartRect[3] - shrinkBox.top - shrinkBox.bottom;
  13066. shrinkRadius = Math.min(width, height) * 0.5;
  13067. if (i === 0) {
  13068. seriesRadius = shrinkRadius - inner;
  13069. }
  13070. axis.setMinimum(0);
  13071. axis.setLength(shrinkRadius);
  13072. axis.getSprites();
  13073. halfLineWidth = axis.sprites[0].attr.lineWidth * 0.5;
  13074. for (side in shrinkBox) {
  13075. shrinkBox[side] += halfLineWidth;
  13076. }
  13077. }
  13078. for (i = 0, ln = radialAxes.length; i < ln; i++) {
  13079. axis = radialAxes[i];
  13080. me.doSetSurfaceRect(axis.getSurface(), chartRect);
  13081. axis.setMinimum(0);
  13082. axis.setLength(seriesRadius);
  13083. axis.getSprites();
  13084. }
  13085. for (i = 0, ln = seriesList.length; i < ln; i++) {
  13086. series = seriesList[i];
  13087. if (series.type === 'gauge' && !gaugeSeries) {
  13088. gaugeSeries = series;
  13089. } else {
  13090. series.setRadius(seriesRadius);
  13091. }
  13092. me.doSetSurfaceRect(series.getSurface(), mainRect);
  13093. }
  13094. me.doSetSurfaceRect(me.getSurface('overlay'), chartRect);
  13095. if (gaugeSeries) {
  13096. gaugeSeries.setRect(mainRect);
  13097. gaugeRadius = gaugeSeries.getRadius() - inner;
  13098. me.setRadius(gaugeRadius);
  13099. me.setCenter(gaugeSeries.getCenter());
  13100. gaugeSeries.setRadius(gaugeRadius);
  13101. if (axes.length && axes[0].getPosition() === 'gauge') {
  13102. axis = axes[0];
  13103. me.doSetSurfaceRect(axis.getSurface(), chartRect);
  13104. axis.setTotalAngle(gaugeSeries.getTotalAngle());
  13105. axis.setLength(gaugeRadius);
  13106. }
  13107. } else {
  13108. me.setRadius(radius);
  13109. me.setCenter(center);
  13110. }
  13111. if (captionList) {
  13112. for (i = 0, ln = captionList.length; i < ln; i++) {
  13113. caption = captionList[i];
  13114. if (caption.getAlignTo() === 'series') {
  13115. caption.alignRect(mainRect);
  13116. }
  13117. caption.performLayout();
  13118. }
  13119. }
  13120. me.redraw();
  13121. } finally {
  13122. me.resumeAnimation();
  13123. if (applyThickness) {
  13124. me.resumeThicknessChanged();
  13125. }
  13126. me.chartLayoutCount--;
  13127. me.checkLayoutEnd();
  13128. }
  13129. }, refloatAxes:function() {
  13130. var me = this, axes = me.getAxes(), mainRect = me.getMainRect(), floating, value, alongAxis, i, n, axis, radius;
  13131. if (!mainRect) {
  13132. return;
  13133. }
  13134. radius = 0.5 * Math.min(mainRect[2], mainRect[3]);
  13135. for (i = 0, n = axes.length; i < n; i++) {
  13136. axis = axes[i];
  13137. floating = axis.getFloating();
  13138. value = floating ? floating.value : null;
  13139. if (value !== null) {
  13140. alongAxis = me.getAxis(floating.alongAxis);
  13141. if (axis.getPosition() === 'angular') {
  13142. if (alongAxis) {
  13143. value = alongAxis.getLength() * value / alongAxis.getRange()[1];
  13144. } else {
  13145. value = 0.01 * value * radius;
  13146. }
  13147. axis.sprites[0].setAttributes({length:value}, true);
  13148. } else {
  13149. if (alongAxis) {
  13150. if (Ext.isString(value)) {
  13151. value = alongAxis.getCoordFor(value);
  13152. }
  13153. value = value / (alongAxis.getRange()[1] + 1) * Math.PI * 2 - Math.PI * 1.5 + axis.getRotation();
  13154. } else {
  13155. value = Ext.draw.Draw.rad(value);
  13156. }
  13157. axis.sprites[0].setAttributes({baseRotation:value}, true);
  13158. }
  13159. }
  13160. }
  13161. }, redraw:function() {
  13162. var me = this, axes = me.getAxes(), axis, seriesList = me.getSeries(), series, i, ln;
  13163. for (i = 0, ln = axes.length; i < ln; i++) {
  13164. axis = axes[i];
  13165. axis.getSprites();
  13166. }
  13167. for (i = 0, ln = seriesList.length; i < ln; i++) {
  13168. series = seriesList[i];
  13169. series.getSprites();
  13170. }
  13171. me.renderFrame();
  13172. me.callParent();
  13173. }, renderFrame:function() {
  13174. this.refloatAxes();
  13175. this.callParent();
  13176. }});
  13177. Ext.define('Ext.chart.SpaceFillingChart', {extend:'Ext.chart.AbstractChart', xtype:'spacefilling', config:{}, performLayout:function() {
  13178. var me = this;
  13179. try {
  13180. me.chartLayoutCount++;
  13181. me.suspendAnimation();
  13182. if (me.callParent() === false) {
  13183. return;
  13184. }
  13185. var chartRect = me.getSurface('chart').getRect(), padding = me.getInsetPadding(), width = chartRect[2] - padding.left - padding.right, height = chartRect[3] - padding.top - padding.bottom, mainRect = [padding.left, padding.top, width, height], seriesList = me.getSeries(), series, i, ln;
  13186. me.getSurface().setRect(mainRect);
  13187. me.setMainRect(mainRect);
  13188. for (i = 0, ln = seriesList.length; i < ln; i++) {
  13189. series = seriesList[i];
  13190. series.getSurface().setRect(mainRect);
  13191. if (series.setRect) {
  13192. series.setRect(mainRect);
  13193. }
  13194. series.getOverlaySurface().setRect(chartRect);
  13195. }
  13196. me.redraw();
  13197. } finally {
  13198. me.resumeAnimation();
  13199. me.chartLayoutCount--;
  13200. me.checkLayoutEnd();
  13201. }
  13202. }, redraw:function() {
  13203. var me = this, seriesList = me.getSeries(), series, i, ln;
  13204. for (i = 0, ln = seriesList.length; i < ln; i++) {
  13205. series = seriesList[i];
  13206. series.getSprites();
  13207. }
  13208. me.renderFrame();
  13209. me.callParent();
  13210. }});
  13211. Ext.define('Ext.chart.axis.sprite.Axis3D', {extend:'Ext.chart.axis.sprite.Axis', alias:'sprite.axis3d', type:'axis3d', inheritableStatics:{def:{processors:{depth:'number'}, defaults:{depth:0}, triggers:{depth:'layout'}}}, config:{animation:{customDurations:{depth:0}}}, layoutUpdater:function() {
  13212. var me = this, chart = me.getAxis().getChart();
  13213. if (chart.isInitializing) {
  13214. return;
  13215. }
  13216. var attr = me.attr, layout = me.getLayout(), depth = layout.isDiscrete ? 0 : attr.depth, isRtl = chart.getInherited().rtl, min = attr.dataMin + (attr.dataMax - attr.dataMin) * attr.visibleMin, max = attr.dataMin + (attr.dataMax - attr.dataMin) * attr.visibleMax, context = {attr:attr, segmenter:me.getSegmenter(), renderer:me.defaultRenderer};
  13217. if (attr.position === 'left' || attr.position === 'right') {
  13218. attr.translationX = 0;
  13219. attr.translationY = max * (attr.length - depth) / (max - min) + depth;
  13220. attr.scalingX = 1;
  13221. attr.scalingY = (-attr.length + depth) / (max - min);
  13222. attr.scalingCenterY = 0;
  13223. attr.scalingCenterX = 0;
  13224. me.applyTransformations(true);
  13225. } else {
  13226. if (attr.position === 'top' || attr.position === 'bottom') {
  13227. if (isRtl) {
  13228. attr.translationX = attr.length + min * attr.length / (max - min) + 1;
  13229. } else {
  13230. attr.translationX = -min * attr.length / (max - min);
  13231. }
  13232. attr.translationY = 0;
  13233. attr.scalingX = (isRtl ? -1 : 1) * (attr.length - depth) / (max - min);
  13234. attr.scalingY = 1;
  13235. attr.scalingCenterY = 0;
  13236. attr.scalingCenterX = 0;
  13237. me.applyTransformations(true);
  13238. }
  13239. }
  13240. if (layout) {
  13241. layout.calculateLayout(context);
  13242. me.setLayoutContext(context);
  13243. }
  13244. }, renderAxisLine:function(surface, ctx, layout, clipRect) {
  13245. var me = this, attr = me.attr, halfLineWidth = attr.lineWidth * 0.5, layout = me.getLayout(), depth = layout.isDiscrete ? 0 : attr.depth, docked = attr.position, position, gaugeAngles;
  13246. if (attr.axisLine && attr.length) {
  13247. switch(docked) {
  13248. case 'left':
  13249. position = surface.roundPixel(clipRect[2]) - halfLineWidth;
  13250. ctx.moveTo(position, -attr.endGap + depth);
  13251. ctx.lineTo(position, attr.length + attr.startGap);
  13252. break;
  13253. case 'right':
  13254. ctx.moveTo(halfLineWidth, -attr.endGap);
  13255. ctx.lineTo(halfLineWidth, attr.length + attr.startGap);
  13256. break;
  13257. case 'bottom':
  13258. ctx.moveTo(-attr.startGap, halfLineWidth);
  13259. ctx.lineTo(attr.length - depth + attr.endGap, halfLineWidth);
  13260. break;
  13261. case 'top':
  13262. position = surface.roundPixel(clipRect[3]) - halfLineWidth;
  13263. ctx.moveTo(-attr.startGap, position);
  13264. ctx.lineTo(attr.length + attr.endGap, position);
  13265. break;
  13266. case 'angular':
  13267. ctx.moveTo(attr.centerX + attr.length, attr.centerY);
  13268. ctx.arc(attr.centerX, attr.centerY, attr.length, 0, Math.PI * 2, true);
  13269. break;
  13270. case 'gauge':
  13271. gaugeAngles = me.getGaugeAngles();
  13272. ctx.moveTo(attr.centerX + Math.cos(gaugeAngles.start) * attr.length, attr.centerY + Math.sin(gaugeAngles.start) * attr.length);
  13273. ctx.arc(attr.centerX, attr.centerY, attr.length, gaugeAngles.start, gaugeAngles.end, true);
  13274. break;
  13275. }
  13276. }
  13277. }});
  13278. Ext.define('Ext.chart.axis.Axis3D', {extend:'Ext.chart.axis.Axis', xtype:'axis3d', requires:['Ext.chart.axis.sprite.Axis3D'], config:{depth:0}, onSeriesChange:function(chart) {
  13279. var me = this, eventName = 'depthchange', listenerName = 'onSeriesDepthChange', i, series;
  13280. function toggle(action) {
  13281. var boundSeries = me.boundSeries;
  13282. for (i = 0; i < boundSeries.length; i++) {
  13283. series = boundSeries[i];
  13284. series[action](eventName, listenerName, me);
  13285. }
  13286. }
  13287. toggle('un');
  13288. me.callParent(arguments);
  13289. toggle('on');
  13290. }, onSeriesDepthChange:function(series, depth) {
  13291. var me = this, maxDepth = depth, boundSeries = me.boundSeries, i, item;
  13292. if (depth > me.getDepth()) {
  13293. maxDepth = depth;
  13294. } else {
  13295. for (i = 0; i < boundSeries.length; i++) {
  13296. item = boundSeries[i];
  13297. if (item !== series && item.getDepth) {
  13298. depth = item.getDepth();
  13299. if (depth > maxDepth) {
  13300. maxDepth = depth;
  13301. }
  13302. }
  13303. }
  13304. }
  13305. me.setDepth(maxDepth);
  13306. }, updateDepth:function(depth) {
  13307. var me = this, sprites = me.getSprites(), attr = {depth:depth};
  13308. if (sprites && sprites.length) {
  13309. sprites[0].setAttributes(attr);
  13310. }
  13311. if (me.gridSpriteEven && me.gridSpriteOdd) {
  13312. me.gridSpriteEven.getTemplate().setAttributes(attr);
  13313. me.gridSpriteOdd.getTemplate().setAttributes(attr);
  13314. }
  13315. }, getGridAlignment:function() {
  13316. switch(this.getPosition()) {
  13317. case 'left':
  13318. case 'right':
  13319. return 'horizontal3d';
  13320. case 'top':
  13321. case 'bottom':
  13322. return 'vertical3d';
  13323. }
  13324. }});
  13325. Ext.define('Ext.chart.axis.Category', {requires:['Ext.chart.axis.layout.CombineDuplicate', 'Ext.chart.axis.segmenter.Names'], extend:'Ext.chart.axis.Axis', alias:'axis.category', type:'category', isCategory:true, config:{layout:'combineDuplicate', segmenter:'names'}});
  13326. Ext.define('Ext.chart.axis.Category3D', {requires:['Ext.chart.axis.layout.CombineDuplicate', 'Ext.chart.axis.segmenter.Names'], extend:'Ext.chart.axis.Axis3D', alias:'axis.category3d', type:'category3d', config:{layout:'combineDuplicate', segmenter:'names'}});
  13327. Ext.define('Ext.chart.axis.Numeric', {extend:'Ext.chart.axis.Axis', type:'numeric', alias:['axis.numeric', 'axis.radial'], requires:['Ext.chart.axis.layout.Continuous', 'Ext.chart.axis.segmenter.Numeric'], config:{layout:'continuous', segmenter:'numeric', aggregator:'double'}});
  13328. Ext.define('Ext.chart.axis.Numeric3D', {extend:'Ext.chart.axis.Axis3D', alias:['axis.numeric3d'], type:'numeric3d', requires:['Ext.chart.axis.layout.Continuous', 'Ext.chart.axis.segmenter.Numeric'], config:{layout:'continuous', segmenter:'numeric', aggregator:'double'}});
  13329. Ext.define('Ext.chart.axis.Time', {extend:'Ext.chart.axis.Numeric', alias:'axis.time', type:'time', requires:['Ext.chart.axis.layout.Continuous', 'Ext.chart.axis.segmenter.Time'], config:{dateFormat:null, fromDate:null, toDate:null, layout:'continuous', segmenter:'time', aggregator:'time'}, updateDateFormat:function(format) {
  13330. var renderer = this.getRenderer();
  13331. if (!renderer || renderer.isDefault) {
  13332. renderer = function(axis, date) {
  13333. return Ext.Date.format(new Date(date), format);
  13334. };
  13335. renderer.isDefault = true;
  13336. this.setRenderer(renderer);
  13337. this.performLayout();
  13338. }
  13339. }, updateRenderer:function(renderer) {
  13340. var dateFormat = this.getDateFormat();
  13341. if (renderer) {
  13342. this.performLayout();
  13343. } else {
  13344. if (dateFormat) {
  13345. this.updateDateFormat(dateFormat);
  13346. }
  13347. }
  13348. }, updateFromDate:function(date) {
  13349. this.setMinimum(+date);
  13350. }, updateToDate:function(date) {
  13351. this.setMaximum(+date);
  13352. }, getCoordFor:function(value) {
  13353. if (Ext.isString(value)) {
  13354. value = new Date(value);
  13355. }
  13356. return +value;
  13357. }});
  13358. Ext.define('Ext.chart.axis.Time3D', {extend:'Ext.chart.axis.Numeric3D', alias:'axis.time3d', type:'time3d', requires:['Ext.chart.axis.layout.Continuous', 'Ext.chart.axis.segmenter.Time'], config:{dateFormat:null, fromDate:null, toDate:null, layout:'continuous', segmenter:'time', aggregator:'time'}, updateDateFormat:function(format) {
  13359. this.setRenderer(function(axis, date) {
  13360. return Ext.Date.format(new Date(date), format);
  13361. });
  13362. }, updateFromDate:function(date) {
  13363. this.setMinimum(+date);
  13364. }, updateToDate:function(date) {
  13365. this.setMaximum(+date);
  13366. }, getCoordFor:function(value) {
  13367. if (Ext.isString(value)) {
  13368. value = new Date(value);
  13369. }
  13370. return +value;
  13371. }});
  13372. Ext.define('Ext.chart.grid.HorizontalGrid3D', {extend:'Ext.chart.grid.HorizontalGrid', alias:'grid.horizontal3d', inheritableStatics:{def:{processors:{depth:'number'}, defaults:{depth:0}}}, render:function(surface, ctx, rect) {
  13373. var attr = this.attr, x = surface.roundPixel(attr.x), y = surface.roundPixel(attr.y), dx = surface.matrix.getDX(), halfLineWidth = ctx.lineWidth * 0.5, height = attr.height, depth = attr.depth, left, top;
  13374. if (y <= rect[1]) {
  13375. return;
  13376. }
  13377. left = rect[0] + depth - dx;
  13378. top = y + halfLineWidth - depth;
  13379. ctx.beginPath();
  13380. ctx.rect(left, top, rect[2], height);
  13381. ctx.fill();
  13382. ctx.beginPath();
  13383. ctx.moveTo(left, top);
  13384. ctx.lineTo(left + rect[2], top);
  13385. ctx.stroke();
  13386. left = rect[0] + x - dx;
  13387. top = y + halfLineWidth;
  13388. ctx.beginPath();
  13389. ctx.moveTo(left, top);
  13390. ctx.lineTo(left + depth, top - depth);
  13391. ctx.lineTo(left + depth, top - depth + height);
  13392. ctx.lineTo(left, top + height);
  13393. ctx.closePath();
  13394. ctx.fill();
  13395. ctx.beginPath();
  13396. ctx.moveTo(left, top);
  13397. ctx.lineTo(left + depth, top - depth);
  13398. ctx.stroke();
  13399. }});
  13400. Ext.define('Ext.chart.grid.VerticalGrid3D', {extend:'Ext.chart.grid.VerticalGrid', alias:'grid.vertical3d', inheritableStatics:{def:{processors:{depth:'number'}, defaults:{depth:0}}}, render:function(surface, ctx, clipRect) {
  13401. var attr = this.attr, x = surface.roundPixel(attr.x), dy = surface.matrix.getDY(), halfLineWidth = ctx.lineWidth * 0.5, width = attr.width, depth = attr.depth, left, top;
  13402. if (x >= clipRect[2]) {
  13403. return;
  13404. }
  13405. left = x - halfLineWidth + depth;
  13406. top = clipRect[1] - depth - dy;
  13407. ctx.beginPath();
  13408. ctx.rect(left, top, width, clipRect[3]);
  13409. ctx.fill();
  13410. ctx.beginPath();
  13411. ctx.moveTo(left, top);
  13412. ctx.lineTo(left, top + clipRect[3]);
  13413. ctx.stroke();
  13414. left = x - halfLineWidth;
  13415. top = clipRect[3];
  13416. ctx.beginPath();
  13417. ctx.moveTo(left, top);
  13418. ctx.lineTo(left + depth, top - depth);
  13419. ctx.lineTo(left + depth + width, top - depth);
  13420. ctx.lineTo(left + width, top);
  13421. ctx.closePath();
  13422. ctx.fill();
  13423. left = x - halfLineWidth;
  13424. top = clipRect[3];
  13425. ctx.beginPath();
  13426. ctx.moveTo(left, top);
  13427. ctx.lineTo(left + depth, top - depth);
  13428. ctx.stroke();
  13429. }});
  13430. Ext.define('Ext.chart.interactions.CrossZoom', {extend:'Ext.chart.interactions.Abstract', type:'crosszoom', alias:'interaction.crosszoom', isCrossZoom:true, config:{axes:true, gestures:{dragstart:'onGestureStart', drag:'onGesture', dragend:'onGestureEnd', dblclick:'onDoubleTap'}, undoButton:{}}, stopAnimationBeforeSync:false, zoomAnimationInProgress:false, constructor:function() {
  13431. this.callParent(arguments);
  13432. this.zoomHistory = [];
  13433. }, applyAxes:function(axesConfig) {
  13434. var result = {};
  13435. if (axesConfig === true) {
  13436. return {top:{}, right:{}, bottom:{}, left:{}};
  13437. } else {
  13438. if (Ext.isArray(axesConfig)) {
  13439. result = {};
  13440. Ext.each(axesConfig, function(axis) {
  13441. result[axis] = {};
  13442. });
  13443. } else {
  13444. if (Ext.isObject(axesConfig)) {
  13445. Ext.iterate(axesConfig, function(key, val) {
  13446. if (val === true) {
  13447. result[key] = {};
  13448. } else {
  13449. if (val !== false) {
  13450. result[key] = val;
  13451. }
  13452. }
  13453. });
  13454. }
  13455. }
  13456. }
  13457. return result;
  13458. }, applyUndoButton:function(button, oldButton) {
  13459. var me = this;
  13460. if (oldButton) {
  13461. oldButton.destroy();
  13462. }
  13463. if (button) {
  13464. return Ext.create('Ext.Button', Ext.apply({cls:[], text:'Undo Zoom', disabled:true, handler:function() {
  13465. me.undoZoom();
  13466. }}, button));
  13467. }
  13468. }, getSurface:function() {
  13469. return this.getChart() && this.getChart().getSurface('overlay');
  13470. }, setSeriesOpacity:function(opacity) {
  13471. var surface = this.getChart() && this.getChart().getSurface('series');
  13472. if (surface) {
  13473. surface.element.setStyle('opacity', opacity);
  13474. }
  13475. }, onGestureStart:function(e) {
  13476. var me = this, chart = me.getChart(), surface = me.getSurface(), rect = chart.getInnerRect(), innerPadding = chart.getInnerPadding(), minX = innerPadding.left, maxX = minX + rect[2], minY = innerPadding.top, maxY = minY + rect[3], xy = chart.getEventXY(e), x = xy[0], y = xy[1];
  13477. e.claimGesture();
  13478. if (me.zoomAnimationInProgress) {
  13479. return;
  13480. }
  13481. if (x > minX && x < maxX && y > minY && y < maxY) {
  13482. me.gestureEvent = 'drag';
  13483. me.lockEvents(me.gestureEvent);
  13484. me.startX = x;
  13485. me.startY = y;
  13486. me.selectionRect = surface.add({type:'rect', globalAlpha:0.5, fillStyle:'rgba(80,80,140,0.5)', strokeStyle:'rgba(80,80,140,1)', lineWidth:2, x:x, y:y, width:0, height:0, zIndex:10000});
  13487. me.setSeriesOpacity(0.8);
  13488. return false;
  13489. }
  13490. }, onGesture:function(e) {
  13491. var me = this;
  13492. if (me.zoomAnimationInProgress) {
  13493. return;
  13494. }
  13495. if (me.getLocks()[me.gestureEvent] === me) {
  13496. var chart = me.getChart(), surface = me.getSurface(), rect = chart.getInnerRect(), innerPadding = chart.getInnerPadding(), minX = innerPadding.left, maxX = minX + rect[2], minY = innerPadding.top, maxY = minY + rect[3], xy = chart.getEventXY(e), x = xy[0], y = xy[1];
  13497. if (x < minX) {
  13498. x = minX;
  13499. } else {
  13500. if (x > maxX) {
  13501. x = maxX;
  13502. }
  13503. }
  13504. if (y < minY) {
  13505. y = minY;
  13506. } else {
  13507. if (y > maxY) {
  13508. y = maxY;
  13509. }
  13510. }
  13511. me.selectionRect.setAttributes({width:x - me.startX, height:y - me.startY});
  13512. if (Math.abs(me.startX - x) < 11 || Math.abs(me.startY - y) < 11) {
  13513. me.selectionRect.setAttributes({globalAlpha:0.5});
  13514. } else {
  13515. me.selectionRect.setAttributes({globalAlpha:1});
  13516. }
  13517. surface.renderFrame();
  13518. return false;
  13519. }
  13520. }, onGestureEnd:function(e) {
  13521. var me = this;
  13522. if (me.zoomAnimationInProgress) {
  13523. return;
  13524. }
  13525. if (me.getLocks()[me.gestureEvent] === me) {
  13526. var chart = me.getChart(), surface = me.getSurface(), rect = chart.getInnerRect(), innerPadding = chart.getInnerPadding(), minX = innerPadding.left, maxX = minX + rect[2], minY = innerPadding.top, maxY = minY + rect[3], rectWidth = rect[2], rectHeight = rect[3], xy = chart.getEventXY(e), x = xy[0], y = xy[1];
  13527. if (x < minX) {
  13528. x = minX;
  13529. } else {
  13530. if (x > maxX) {
  13531. x = maxX;
  13532. }
  13533. }
  13534. if (y < minY) {
  13535. y = minY;
  13536. } else {
  13537. if (y > maxY) {
  13538. y = maxY;
  13539. }
  13540. }
  13541. if (Math.abs(me.startX - x) < 11 || Math.abs(me.startY - y) < 11) {
  13542. surface.remove(me.selectionRect);
  13543. } else {
  13544. me.zoomBy([Math.min(me.startX, x) / rectWidth, 1 - Math.max(me.startY, y) / rectHeight, Math.max(me.startX, x) / rectWidth, 1 - Math.min(me.startY, y) / rectHeight]);
  13545. me.selectionRect.setAttributes({x:Math.min(me.startX, x), y:Math.min(me.startY, y), width:Math.abs(me.startX - x), height:Math.abs(me.startY - y)});
  13546. me.selectionRect.setAnimation(chart.getAnimation() || {duration:0});
  13547. me.selectionRect.setAttributes({globalAlpha:0, x:0, y:0, width:rectWidth, height:rectHeight});
  13548. me.zoomAnimationInProgress = true;
  13549. chart.suspendThicknessChanged();
  13550. me.selectionRect.getAnimation().on('animationend', function() {
  13551. chart.resumeThicknessChanged();
  13552. surface.remove(me.selectionRect);
  13553. me.selectionRect = null;
  13554. me.zoomAnimationInProgress = false;
  13555. });
  13556. }
  13557. surface.renderFrame();
  13558. me.sync();
  13559. me.unlockEvents(me.gestureEvent);
  13560. me.setSeriesOpacity(1);
  13561. if (!me.zoomAnimationInProgress) {
  13562. surface.remove(me.selectionRect);
  13563. me.selectionRect = null;
  13564. }
  13565. }
  13566. }, zoomBy:function(rect) {
  13567. var me = this, axisConfigs = me.getAxes(), chart = me.getChart(), axes = chart.getAxes(), isRtl = chart.getInherited().rtl, zoomMap = {}, config, axis, x1, x2, isSide, oldRange, i;
  13568. if (isRtl) {
  13569. rect = rect.slice();
  13570. x1 = 1 - rect[0];
  13571. x2 = 1 - rect[2];
  13572. rect[0] = Math.min(x1, x2);
  13573. rect[2] = Math.max(x1, x2);
  13574. }
  13575. for (i = 0; i < axes.length; i++) {
  13576. axis = axes[i];
  13577. config = axisConfigs[axis.getPosition()];
  13578. if (config && config.allowZoom !== false) {
  13579. isSide = axis.isSide();
  13580. oldRange = axis.getVisibleRange();
  13581. zoomMap[axis.getId()] = oldRange.slice(0);
  13582. if (!isSide) {
  13583. axis.setVisibleRange([(oldRange[1] - oldRange[0]) * rect[0] + oldRange[0], (oldRange[1] - oldRange[0]) * rect[2] + oldRange[0]]);
  13584. } else {
  13585. axis.setVisibleRange([(oldRange[1] - oldRange[0]) * rect[1] + oldRange[0], (oldRange[1] - oldRange[0]) * rect[3] + oldRange[0]]);
  13586. }
  13587. }
  13588. }
  13589. me.zoomHistory.push(zoomMap);
  13590. me.getUndoButton().setDisabled(false);
  13591. }, undoZoom:function() {
  13592. var zoomMap = this.zoomHistory.pop(), axes = this.getChart().getAxes(), axis, i;
  13593. if (zoomMap) {
  13594. for (i = 0; i < axes.length; i++) {
  13595. axis = axes[i];
  13596. if (zoomMap[axis.getId()]) {
  13597. axis.setVisibleRange(zoomMap[axis.getId()]);
  13598. }
  13599. }
  13600. }
  13601. this.getUndoButton().setDisabled(this.zoomHistory.length === 0);
  13602. this.sync();
  13603. }, onDoubleTap:function(e) {
  13604. this.undoZoom();
  13605. }, destroy:function() {
  13606. this.setUndoButton(null);
  13607. this.callParent();
  13608. }});
  13609. Ext.define('Ext.chart.interactions.Crosshair', {extend:'Ext.chart.interactions.Abstract', requires:['Ext.chart.grid.HorizontalGrid', 'Ext.chart.grid.VerticalGrid', 'Ext.chart.CartesianChart', 'Ext.chart.axis.layout.Discrete'], type:'crosshair', alias:'interaction.crosshair', config:{axes:{top:{label:{}, rect:{}}, right:{label:{}, rect:{}}, bottom:{label:{}, rect:{}}, left:{label:{}, rect:{}}}, lines:{horizontal:{strokeStyle:'black', lineDash:[5, 5]}, vertical:{strokeStyle:'black', lineDash:[5, 5]}},
  13610. gesture:'drag'}, applyAxes:function(axesConfig, oldAxesConfig) {
  13611. return Ext.merge(oldAxesConfig || {}, axesConfig);
  13612. }, applyLines:function(linesConfig, oldLinesConfig) {
  13613. return Ext.merge(oldLinesConfig || {}, linesConfig);
  13614. }, updateChart:function(chart) {
  13615. if (chart && !chart.isCartesian) {
  13616. Ext.raise('Crosshair interaction can only be used on cartesian charts.');
  13617. }
  13618. this.callParent(arguments);
  13619. }, getGestures:function() {
  13620. var me = this, gestures = {}, gesture = me.getGesture();
  13621. gestures[gesture] = 'onGesture';
  13622. gestures[gesture + 'start'] = 'onGestureStart';
  13623. gestures[gesture + 'end'] = 'onGestureEnd';
  13624. gestures[gesture + 'cancel'] = 'onGestureCancel';
  13625. return gestures;
  13626. }, onGestureStart:function(e) {
  13627. var me = this, chart = me.getChart(), axesTheme = chart.getTheme().getAxis(), axisTheme, surface = chart.getSurface('overlay'), rect = chart.getInnerRect(), chartWidth = rect[2], chartHeight = rect[3], xy = chart.getEventXY(e), x = xy[0], y = xy[1], axes = chart.getAxes(), axesConfig = me.getAxes(), linesConfig = me.getLines(), axis, axisSurface, axisRect, axisWidth, axisHeight, axisPosition, axisAlignment, axisLabel, axisLabelConfig, crosshairLabelConfig, tickPadding, axisSprite, attr, lineWidth,
  13628. halfLineWidth, title, titleBBox, horizontalLineCfg, verticalLineCfg, i;
  13629. e.claimGesture();
  13630. if (x > 0 && x < chartWidth && y > 0 && y < chartHeight) {
  13631. me.lockEvents(me.getGesture());
  13632. horizontalLineCfg = Ext.apply({xclass:'Ext.chart.grid.HorizontalGrid', x:0, y:y, width:chartWidth}, linesConfig.horizontal);
  13633. verticalLineCfg = Ext.apply({xclass:'Ext.chart.grid.VerticalGrid', x:x, y:0, height:chartHeight}, linesConfig.vertical);
  13634. me.axesLabels = me.axesLabels || {};
  13635. for (i = 0; i < axes.length; i++) {
  13636. axis = axes[i];
  13637. axisSurface = axis.getSurface();
  13638. axisRect = axisSurface.getRect();
  13639. axisSprite = axis.getSprites()[0];
  13640. axisWidth = axisRect[2];
  13641. axisHeight = axisRect[3];
  13642. axisPosition = axis.getPosition();
  13643. axisAlignment = axis.getAlignment();
  13644. title = axis.getTitle();
  13645. titleBBox = title && title.attr.text !== '' && title.getBBox();
  13646. attr = axisSprite.attr;
  13647. lineWidth = attr.axisLine ? attr.lineWidth : 0;
  13648. halfLineWidth = lineWidth / 2;
  13649. tickPadding = Math.max(attr.majorTickSize, attr.minorTickSize) + lineWidth;
  13650. axisLabel = me.axesLabels[axisPosition] = axisSurface.add({type:'composite'});
  13651. axisLabel.labelRect = axisLabel.addSprite(Ext.apply({type:'rect', fillStyle:'white', x:axisPosition === 'right' ? lineWidth : 0, y:axisPosition === 'bottom' ? lineWidth : 0, width:axisWidth - lineWidth - (axisAlignment === 'vertical' && titleBBox ? titleBBox.width : 0), height:axisHeight - lineWidth - (axisAlignment === 'horizontal' && titleBBox ? titleBBox.height : 0), translationX:axisPosition === 'left' && titleBBox ? titleBBox.width : 0, translationY:axisPosition === 'top' && titleBBox ?
  13652. titleBBox.height : 0}, axesConfig.rect || axesConfig[axisPosition].rect));
  13653. if (axisAlignment === 'vertical' && !verticalLineCfg.strokeStyle) {
  13654. verticalLineCfg.strokeStyle = attr.strokeStyle;
  13655. }
  13656. if (axisAlignment === 'horizontal' && !horizontalLineCfg.strokeStyle) {
  13657. horizontalLineCfg.strokeStyle = attr.strokeStyle;
  13658. }
  13659. axisTheme = Ext.merge({}, axesTheme.defaults, axesTheme[axisPosition]);
  13660. axisLabelConfig = Ext.apply({}, axis.config.label, axisTheme.label);
  13661. crosshairLabelConfig = axesConfig.label || axesConfig[axisPosition].label;
  13662. axisLabel.labelText = axisLabel.addSprite(Ext.apply(axisLabelConfig, crosshairLabelConfig, {type:'text', x:me.calculateLabelTextPoint(false, axisPosition, tickPadding, titleBBox, axisWidth, halfLineWidth), y:me.calculateLabelTextPoint(true, axisPosition, tickPadding, titleBBox, axisHeight, halfLineWidth)}));
  13663. }
  13664. me.horizontalLine = surface.add(horizontalLineCfg);
  13665. me.verticalLine = surface.add(verticalLineCfg);
  13666. return false;
  13667. }
  13668. }, onGesture:function(e) {
  13669. var me = this;
  13670. if (me.getLocks()[me.getGesture()] !== me) {
  13671. return;
  13672. }
  13673. var chart = me.getChart(), surface = chart.getSurface('overlay'), rect = Ext.Array.slice(chart.getInnerRect()), padding = chart.getInnerPadding(), px = padding.left, py = padding.top, chartWidth = rect[2], chartHeight = rect[3], xy = chart.getEventXY(e), x = xy[0], y = xy[1], axes = chart.getAxes(), axis, axisPosition, axisAlignment, axisSurface, axisSprite, axisMatrix, axisLayoutContext, axisSegmenter, axisLabel, labelBBox, textPadding, xx, yy, dx, dy, xValue, yValue, text, i;
  13674. if (x < 0) {
  13675. x = 0;
  13676. } else {
  13677. if (x > chartWidth) {
  13678. x = chartWidth;
  13679. }
  13680. }
  13681. if (y < 0) {
  13682. y = 0;
  13683. } else {
  13684. if (y > chartHeight) {
  13685. y = chartHeight;
  13686. }
  13687. }
  13688. x += px;
  13689. y += py;
  13690. for (i = 0; i < axes.length; i++) {
  13691. axis = axes[i];
  13692. axisPosition = axis.getPosition();
  13693. axisAlignment = axis.getAlignment();
  13694. axisSurface = axis.getSurface();
  13695. axisSprite = axis.getSprites()[0];
  13696. axisMatrix = axisSprite.attr.matrix;
  13697. textPadding = axisSprite.attr.textPadding * 2;
  13698. axisLabel = me.axesLabels[axisPosition];
  13699. axisLayoutContext = axisSprite.getLayoutContext();
  13700. axisSegmenter = axis.getSegmenter();
  13701. if (axisLabel) {
  13702. if (axisAlignment === 'vertical') {
  13703. yy = axisMatrix.getYY();
  13704. dy = axisMatrix.getDY();
  13705. yValue = (y - dy - py) / yy;
  13706. if (axis.getLayout() instanceof Ext.chart.axis.layout.Discrete) {
  13707. y = Math.round(yValue) * yy + dy + py;
  13708. yValue = axisSegmenter.from(Math.round(yValue));
  13709. yValue = axisSprite.attr.data[yValue];
  13710. } else {
  13711. yValue = axisSegmenter.from(yValue);
  13712. }
  13713. text = axisSegmenter.renderer(yValue, axisLayoutContext);
  13714. axisLabel.setAttributes({translationY:y - py});
  13715. axisLabel.labelText.setAttributes({text:text});
  13716. labelBBox = axisLabel.labelText.getBBox();
  13717. axisLabel.labelRect.setAttributes({height:labelBBox.height + textPadding, y:-(labelBBox.height + textPadding) / 2});
  13718. axisSurface.renderFrame();
  13719. } else {
  13720. xx = axisMatrix.getXX();
  13721. dx = axisMatrix.getDX();
  13722. xValue = (x - dx - px) / xx;
  13723. if (axis.getLayout() instanceof Ext.chart.axis.layout.Discrete) {
  13724. x = Math.round(xValue) * xx + dx + px;
  13725. xValue = axisSegmenter.from(Math.round(xValue));
  13726. xValue = axisSprite.attr.data[xValue];
  13727. } else {
  13728. xValue = axisSegmenter.from(xValue);
  13729. }
  13730. text = axisSegmenter.renderer(xValue, axisLayoutContext);
  13731. axisLabel.setAttributes({translationX:x - px});
  13732. axisLabel.labelText.setAttributes({text:text});
  13733. labelBBox = axisLabel.labelText.getBBox();
  13734. axisLabel.labelRect.setAttributes({width:labelBBox.width + textPadding, x:-(labelBBox.width + textPadding) / 2});
  13735. axisSurface.renderFrame();
  13736. }
  13737. }
  13738. }
  13739. me.horizontalLine.setAttributes({y:y, strokeStyle:axisSprite.attr.strokeStyle});
  13740. me.verticalLine.setAttributes({x:x, strokeStyle:axisSprite.attr.strokeStyle});
  13741. surface.renderFrame();
  13742. return false;
  13743. }, onGestureEnd:function(e) {
  13744. var me = this, chart = me.getChart(), surface = chart.getSurface('overlay'), axes = chart.getAxes(), axis, axisPosition, axisSurface, axisLabel, i;
  13745. surface.remove(me.verticalLine);
  13746. surface.remove(me.horizontalLine);
  13747. for (i = 0; i < axes.length; i++) {
  13748. axis = axes[i];
  13749. axisPosition = axis.getPosition();
  13750. axisSurface = axis.getSurface();
  13751. axisLabel = me.axesLabels[axisPosition];
  13752. if (axisLabel) {
  13753. delete me.axesLabels[axisPosition];
  13754. axisSurface.remove(axisLabel);
  13755. }
  13756. axisSurface.renderFrame();
  13757. }
  13758. surface.renderFrame();
  13759. me.unlockEvents(me.getGesture());
  13760. }, onGestureCancel:function(e) {
  13761. this.onGestureEnd(e);
  13762. }, privates:{vertMap:{top:'start', bottom:'end'}, horzMap:{left:'start', right:'end'}, calculateLabelTextPoint:function(vertical, position, tickPadding, titleBBox, axisSize, halfLineWidth) {
  13763. var titlePadding, sizeProp, pointProp;
  13764. if (vertical) {
  13765. pointProp = 'y';
  13766. sizeProp = 'height';
  13767. position = this.vertMap[position];
  13768. } else {
  13769. pointProp = 'x';
  13770. sizeProp = 'width';
  13771. position = this.horzMap[position];
  13772. }
  13773. switch(position) {
  13774. case 'start':
  13775. titlePadding = titleBBox ? titleBBox[pointProp] + titleBBox[sizeProp] : 0;
  13776. return titlePadding + (axisSize - titlePadding - tickPadding) / 2 - halfLineWidth;
  13777. case 'end':
  13778. titlePadding = titleBBox ? axisSize - titleBBox[pointProp] : 0;
  13779. return tickPadding + (axisSize - tickPadding - titlePadding) / 2 + halfLineWidth;
  13780. default:
  13781. return 0;
  13782. }
  13783. }}});
  13784. Ext.define('Ext.chart.interactions.ItemHighlight', {extend:'Ext.chart.interactions.Abstract', type:'itemhighlight', alias:'interaction.itemhighlight', isItemHighlight:true, config:{gestures:{tap:'onTapGesture', mousemove:'onMouseMoveGesture', mousedown:'onMouseDownGesture', mouseup:'onMouseUpGesture', mouseleave:'onMouseUpGesture'}, sticky:false, multiTooltips:false}, constructor:function(config) {
  13785. this.callParent([config]);
  13786. this.stickyHighlightItem = null;
  13787. this.tooltipItems = [];
  13788. }, destroy:function() {
  13789. this.stickyHighlightItem = this.tooltipItems = null;
  13790. this.callParent();
  13791. }, onMouseMoveGesture:function(e) {
  13792. var me = this, tooltipItems = me.tooltipItems, isMousePointer = e.pointerType === 'mouse', tooltips = [], item, oldItem, items, tooltip, oldTooltip, i, len, j, jLen;
  13793. if (me.getSticky()) {
  13794. return true;
  13795. }
  13796. if (isMousePointer && me.stickyHighlightItem) {
  13797. me.stickyHighlightItem = null;
  13798. me.highlight(null);
  13799. }
  13800. if (me.isDragging) {
  13801. if (tooltipItems.length && isMousePointer) {
  13802. me.hideTooltips(tooltipItems);
  13803. tooltipItems.length = 0;
  13804. }
  13805. } else {
  13806. if (!me.stickyHighlightItem) {
  13807. if (me.getMultiTooltips()) {
  13808. items = me.getItemsForEvent(e);
  13809. } else {
  13810. item = me.getItemForEvent(e);
  13811. items = item ? [item] : [];
  13812. }
  13813. for (i = 0, len = items.length; i < len; i++) {
  13814. item = items[i];
  13815. if (i === 0 && item !== me.getChart().getHighlightItem()) {
  13816. me.highlight(item);
  13817. me.sync();
  13818. }
  13819. tooltip = item.series.getTooltip();
  13820. if (tooltip) {
  13821. tooltips.push(tooltip);
  13822. }
  13823. }
  13824. me.highlight(item);
  13825. if (isMousePointer) {
  13826. if (items.length) {
  13827. for (i = 0, len = items.length; i < len; i++) {
  13828. item = items[i];
  13829. tooltip = item.series.getTooltip();
  13830. if (tooltip) {
  13831. for (j = 0, jLen = tooltipItems.length; j < jLen; j++) {
  13832. oldItem = tooltipItems[j];
  13833. if (!Ext.Array.contains(items, oldItem)) {
  13834. oldTooltip = oldItem.series.getTooltip();
  13835. if (!Ext.Array.contains(tooltips, oldTooltip)) {
  13836. oldItem.series.hideTooltip(oldItem, true);
  13837. }
  13838. }
  13839. }
  13840. if (tooltip.getTrackMouse()) {
  13841. item.series.showTooltip(item, e);
  13842. } else {
  13843. me.showUntracked(item);
  13844. }
  13845. }
  13846. }
  13847. me.tooltipItems = items;
  13848. } else {
  13849. me.hideTooltips(tooltipItems);
  13850. tooltipItems.length = 0;
  13851. }
  13852. }
  13853. return false;
  13854. }
  13855. }
  13856. }, highlight:function(item) {
  13857. this.getChart().setHighlightItem(item);
  13858. }, showTooltip:function(e, item) {
  13859. item.series.showTooltip(item, e);
  13860. Ext.Array.include(this.tooltipItems, item);
  13861. }, showUntracked:function(item) {
  13862. var marker = item.sprite.getMarker(item.category), surface, surfaceXY, isInverseY, itemBBox, matrix;
  13863. if (marker) {
  13864. surface = marker.getSurface();
  13865. isInverseY = surface.matrix.elements[3] < 0;
  13866. surfaceXY = surface.element.getXY();
  13867. itemBBox = Ext.clone(marker.getBBoxFor(item.index));
  13868. if (isInverseY) {
  13869. if (surface.getInherited().rtl) {
  13870. matrix = surface.inverseMatrix.clone().flipX().translate(item.sprite.attr.innerWidth, 0, true);
  13871. } else {
  13872. matrix = surface.inverseMatrix;
  13873. }
  13874. itemBBox = matrix.transformBBox(itemBBox);
  13875. }
  13876. itemBBox.x += surfaceXY[0];
  13877. itemBBox.y += surfaceXY[1];
  13878. item.series.showTooltipAt(item, itemBBox.x + itemBBox.width * 0.5, itemBBox.y + itemBBox.height * 0.5);
  13879. }
  13880. }, onMouseDownGesture:function() {
  13881. this.isDragging = true;
  13882. }, onMouseUpGesture:function() {
  13883. this.isDragging = false;
  13884. }, isSameItem:function(a, b) {
  13885. return a && b && a.series === b.series && a.field === b.field && a.index === b.index;
  13886. }, onTapGesture:function(e) {
  13887. var me = this, item;
  13888. if (e.pointerType === 'mouse' && !me.getSticky()) {
  13889. return;
  13890. }
  13891. item = me.getItemForEvent(e);
  13892. if (me.isSameItem(me.stickyHighlightItem, item)) {
  13893. item = null;
  13894. }
  13895. me.stickyHighlightItem = item;
  13896. me.highlight(item);
  13897. }, privates:{hideTooltips:function(items, force) {
  13898. var item, i, len;
  13899. items = Ext.isArray(items) ? items : [items];
  13900. for (i = 0, len = items.length; i < len; i++) {
  13901. item = items[i];
  13902. if (item && item.series && !item.series.destroyed) {
  13903. item.series.hideTooltip(item, force);
  13904. }
  13905. }
  13906. }}});
  13907. Ext.define('Ext.chart.interactions.ItemEdit', {extend:'Ext.chart.interactions.ItemHighlight', requires:['Ext.tip.ToolTip'], type:'itemedit', alias:'interaction.itemedit', isItemEdit:true, config:{style:null, renderer:null, tooltip:true, gestures:{dragstart:'onDragStart', drag:'onDrag', dragend:'onDragEnd'}, cursors:{ewResize:'ew-resize', nsResize:'ns-resize', move:'move'}}, item:null, applyTooltip:function(tooltip) {
  13908. var config;
  13909. if (tooltip) {
  13910. config = Ext.apply({}, tooltip, {renderer:this.defaultTooltipRenderer, constrainPosition:true, shrinkWrapDock:true, autoHide:true, trackMouse:true, mouseOffset:[20, 20]});
  13911. tooltip = new Ext.tip.ToolTip(config);
  13912. }
  13913. return tooltip;
  13914. }, defaultTooltipRenderer:function(tooltip, item, target, e) {
  13915. var parts = [];
  13916. if (target.xField) {
  13917. parts.push(target.xField + ': ' + target.xValue);
  13918. }
  13919. if (target.yField) {
  13920. parts.push(target.yField + ': ' + target.yValue);
  13921. }
  13922. tooltip.setHtml(parts.join('\x3cbr\x3e'));
  13923. }, onDragStart:function(e) {
  13924. var me = this, chart = me.getChart(), item = chart.getHighlightItem();
  13925. e.claimGesture();
  13926. if (item) {
  13927. chart.fireEvent('beginitemedit', chart, me, me.item = item);
  13928. return false;
  13929. }
  13930. }, onDrag:function(e) {
  13931. var me = this, chart = me.getChart(), item = chart.getHighlightItem(), type = item && item.sprite.type;
  13932. if (item) {
  13933. switch(type) {
  13934. case 'barSeries':
  13935. return me.onDragBar(e);
  13936. case 'scatterSeries':
  13937. return me.onDragScatter(e);
  13938. }
  13939. }
  13940. }, highlight:function(item) {
  13941. var me = this, chart = me.getChart(), flipXY = chart.getFlipXY(), cursors = me.getCursors(), type = item && item.sprite.type, style = chart.el.dom.style;
  13942. me.callParent([item]);
  13943. if (item) {
  13944. switch(type) {
  13945. case 'barSeries':
  13946. if (flipXY) {
  13947. style.cursor = cursors.ewResize;
  13948. } else {
  13949. style.cursor = cursors.nsResize;
  13950. }
  13951. break;
  13952. case 'scatterSeries':
  13953. style.cursor = cursors.move;
  13954. break;
  13955. }
  13956. } else {
  13957. chart.el.dom.style.cursor = 'default';
  13958. }
  13959. }, onDragBar:function(e) {
  13960. var me = this, chart = me.getChart(), isRtl = chart.getInherited().rtl, flipXY = chart.isCartesian && chart.getFlipXY(), item = chart.getHighlightItem(), marker = item.sprite.getMarker('items'), instance = marker.getMarkerFor(item.sprite.getId(), item.index), surface = item.sprite.getSurface(), surfaceRect = surface.getRect(), xy = surface.getEventXY(e), matrix = item.sprite.attr.matrix, renderer = me.getRenderer(), style, changes, params, positionY;
  13961. if (flipXY) {
  13962. positionY = isRtl ? surfaceRect[2] - xy[0] : xy[0];
  13963. } else {
  13964. positionY = surfaceRect[3] - xy[1];
  13965. }
  13966. style = {x:instance.x, y:positionY, width:instance.width, height:instance.height + (instance.y - positionY), radius:instance.radius, fillStyle:'none', lineDash:[4, 4], zIndex:100};
  13967. Ext.apply(style, me.getStyle());
  13968. if (Ext.isArray(item.series.getYField())) {
  13969. positionY = positionY - instance.y - instance.height;
  13970. }
  13971. me.target = {index:item.index, yField:item.field, yValue:(positionY - matrix.getDY()) / matrix.getYY()};
  13972. params = [chart, {target:me.target, style:style, item:item}];
  13973. changes = Ext.callback(renderer, null, params, 0, chart);
  13974. if (changes) {
  13975. Ext.apply(style, changes);
  13976. }
  13977. item.sprite.putMarker('items', style, 'itemedit');
  13978. me.showTooltip(e, me.target, item);
  13979. surface.renderFrame();
  13980. }, onDragScatter:function(e) {
  13981. var me = this, chart = me.getChart(), isRtl = chart.getInherited().rtl, flipXY = chart.isCartesian && chart.getFlipXY(), item = chart.getHighlightItem(), marker = item.sprite.getMarker('markers'), instance = marker.getMarkerFor(item.sprite.getId(), item.index), surface = item.sprite.getSurface(), surfaceRect = surface.getRect(), xy = surface.getEventXY(e), matrix = item.sprite.attr.matrix, xAxis = item.series.getXAxis(), isEditableX = xAxis && xAxis.getLayout().isContinuous, renderer = me.getRenderer(),
  13982. style, changes, params, positionX, positionY, hintX, hintY;
  13983. if (flipXY) {
  13984. positionY = isRtl ? surfaceRect[2] - xy[0] : xy[0];
  13985. } else {
  13986. positionY = surfaceRect[3] - xy[1];
  13987. }
  13988. if (isEditableX) {
  13989. if (flipXY) {
  13990. positionX = surfaceRect[3] - xy[1];
  13991. } else {
  13992. positionX = xy[0];
  13993. }
  13994. } else {
  13995. positionX = instance.translationX;
  13996. }
  13997. if (isEditableX) {
  13998. hintX = xy[0];
  13999. hintY = xy[1];
  14000. } else {
  14001. if (flipXY) {
  14002. hintX = xy[0];
  14003. hintY = instance.translationY;
  14004. } else {
  14005. hintX = instance.translationX;
  14006. hintY = xy[1];
  14007. }
  14008. }
  14009. style = {translationX:hintX, translationY:hintY, scalingX:instance.scalingX, scalingY:instance.scalingY, r:instance.r, fillStyle:'none', lineDash:[4, 4], zIndex:100};
  14010. Ext.apply(style, me.getStyle());
  14011. me.target = {index:item.index, yField:item.field, yValue:(positionY - matrix.getDY()) / matrix.getYY()};
  14012. if (isEditableX) {
  14013. Ext.apply(me.target, {xField:item.series.getXField(), xValue:(positionX - matrix.getDX()) / matrix.getXX()});
  14014. }
  14015. params = [chart, {target:me.target, style:style, item:item}];
  14016. changes = Ext.callback(renderer, null, params, 0, chart);
  14017. if (changes) {
  14018. Ext.apply(style, changes);
  14019. }
  14020. item.sprite.putMarker('markers', style, 'itemedit');
  14021. me.showTooltip(e, me.target, item);
  14022. surface.renderFrame();
  14023. }, showTooltip:function(e, target, item) {
  14024. var tooltip = this.getTooltip(), config, chart;
  14025. if (tooltip && Ext.toolkit !== 'modern') {
  14026. config = tooltip.config;
  14027. chart = this.getChart();
  14028. Ext.callback(config.renderer, null, [tooltip, item, target, e], 0, chart);
  14029. tooltip.pointerEvent = e;
  14030. if (tooltip.isVisible()) {
  14031. tooltip.realignToTarget();
  14032. } else {
  14033. tooltip.show();
  14034. }
  14035. }
  14036. }, hideTooltip:function() {
  14037. var tooltip = this.getTooltip();
  14038. if (tooltip && Ext.toolkit !== 'modern') {
  14039. tooltip.hide();
  14040. }
  14041. }, onDragEnd:function(e) {
  14042. var me = this, target = me.target, chart = me.getChart(), store = chart.getStore(), record;
  14043. if (target) {
  14044. record = store.getAt(target.index);
  14045. if (target.yField) {
  14046. record.set(target.yField, target.yValue, {convert:false});
  14047. }
  14048. if (target.xField) {
  14049. record.set(target.xField, target.xValue, {convert:false});
  14050. }
  14051. if (target.yField || target.xField) {
  14052. me.getChart().onDataChanged();
  14053. }
  14054. me.target = null;
  14055. }
  14056. me.hideTooltip();
  14057. if (me.item) {
  14058. chart.fireEvent('enditemedit', chart, me, me.item, target);
  14059. }
  14060. me.highlight(me.item = null);
  14061. }, destroy:function() {
  14062. var tooltip = this.getConfig('tooltip', true);
  14063. Ext.destroy(tooltip);
  14064. this.callParent();
  14065. }});
  14066. Ext.define('Ext.chart.interactions.PanZoom', {extend:'Ext.chart.interactions.Abstract', type:'panzoom', alias:'interaction.panzoom', requires:['Ext.draw.Animator'], config:{axes:{top:{}, right:{}, bottom:{}, left:{}}, minZoom:null, maxZoom:null, showOverflowArrows:true, panGesture:'drag', zoomGesture:'pinch', zoomOnPanGesture:null, zoomOnPan:false, doubleTapReset:false, modeToggleButton:{xtype:'segmentedbutton', width:200, defaults:{ui:'default-toolbar'}, cls:Ext.baseCSSPrefix + 'panzoom-toggle',
  14067. items:[{text:'Pan', value:'pan'}, {text:'Zoom', value:'zoom'}]}, hideLabelInGesture:false}, stopAnimationBeforeSync:true, applyAxes:function(axesConfig, oldAxesConfig) {
  14068. return Ext.merge(oldAxesConfig || {}, axesConfig);
  14069. }, updateZoomOnPan:function(zoomOnPan) {
  14070. var button = this.getModeToggleButton();
  14071. button.setValue(zoomOnPan ? 'zoom' : 'pan');
  14072. }, updateZoomOnPanGesture:function(zoomOnPanGesture) {
  14073. this.setZoomOnPan(zoomOnPanGesture);
  14074. }, getZoomOnPanGesture:function() {
  14075. return this.getZoomOnPan();
  14076. }, applyModeToggleButton:function(button, oldButton) {
  14077. return Ext.factory(button, 'Ext.button.Segmented', oldButton);
  14078. }, updateModeToggleButton:function(button) {
  14079. if (button) {
  14080. button.on('change', 'onModeToggleChange', this);
  14081. }
  14082. }, onModeToggleChange:function(segmentedButton, value) {
  14083. this.setZoomOnPan(value === 'zoom');
  14084. }, getGestures:function() {
  14085. var me = this, gestures = {}, pan = me.getPanGesture(), zoom = me.getZoomGesture();
  14086. gestures[zoom] = 'onZoomGestureMove';
  14087. gestures[zoom + 'start'] = 'onZoomGestureStart';
  14088. gestures[zoom + 'end'] = 'onZoomGestureEnd';
  14089. gestures[pan] = 'onPanGestureMove';
  14090. gestures[pan + 'start'] = 'onPanGestureStart';
  14091. gestures[pan + 'end'] = 'onPanGestureEnd';
  14092. gestures.doubletap = 'onDoubleTap';
  14093. return gestures;
  14094. }, onDoubleTap:function(e) {
  14095. var me = this, doubleTapReset = me.getDoubleTapReset(), chart, axes, axis, i, ln;
  14096. if (doubleTapReset) {
  14097. chart = me.getChart();
  14098. axes = chart.getAxes();
  14099. for (i = 0, ln = axes.length; i < ln; i++) {
  14100. axis = axes[i];
  14101. axis.setVisibleRange([0, 1]);
  14102. }
  14103. chart.redraw();
  14104. }
  14105. }, onPanGestureStart:function(e) {
  14106. var me = this, chart, rect, xy;
  14107. if (!e || !e.touches || e.touches.length < 2) {
  14108. chart = me.getChart();
  14109. rect = chart.getInnerRect();
  14110. xy = chart.element.getXY();
  14111. e.claimGesture();
  14112. chart.suspendAnimation();
  14113. me.startX = e.getX() - xy[0] - rect[0];
  14114. me.startY = e.getY() - xy[1] - rect[1];
  14115. me.oldVisibleRanges = null;
  14116. me.hideLabels();
  14117. chart.suspendThicknessChanged();
  14118. me.lockEvents(me.getPanGesture());
  14119. return false;
  14120. }
  14121. }, onPanGestureMove:function(e) {
  14122. var me = this, isMouse = e.pointerType === 'mouse', isZoomOnPan = isMouse && me.getZoomOnPan(), chart, rect, xy;
  14123. if (me.getLocks()[me.getPanGesture()] === me) {
  14124. chart = me.getChart();
  14125. rect = chart.getInnerRect();
  14126. xy = chart.element.getXY();
  14127. if (isZoomOnPan) {
  14128. me.transformAxesBy(me.getZoomableAxes(e), 0, 0, (e.getX() - xy[0] - rect[0]) / me.startX, me.startY / (e.getY() - xy[1] - rect[1]));
  14129. } else {
  14130. me.transformAxesBy(me.getPannableAxes(e), e.getX() - xy[0] - rect[0] - me.startX, e.getY() - xy[1] - rect[1] - me.startY, 1, 1);
  14131. }
  14132. me.sync();
  14133. return false;
  14134. }
  14135. }, onPanGestureEnd:function(e) {
  14136. var me = this, pan = me.getPanGesture(), chart;
  14137. if (me.getLocks()[pan] === me) {
  14138. chart = me.getChart();
  14139. chart.resumeThicknessChanged();
  14140. me.showLabels();
  14141. me.sync();
  14142. me.unlockEvents(pan);
  14143. chart.resumeAnimation();
  14144. return false;
  14145. }
  14146. }, onZoomGestureStart:function(e) {
  14147. if (e.touches && e.touches.length === 2) {
  14148. var me = this, chart = me.getChart(), xy = chart.element.getXY(), rect = chart.getInnerRect(), x = xy[0] + rect[0], y = xy[1] + rect[1], newPoints = [e.touches[0].point.x - x, e.touches[0].point.y - y, e.touches[1].point.x - x, e.touches[1].point.y - y], xDistance = Math.max(44, Math.abs(newPoints[2] - newPoints[0])), yDistance = Math.max(44, Math.abs(newPoints[3] - newPoints[1]));
  14149. e.claimGesture();
  14150. chart.suspendAnimation();
  14151. chart.suspendThicknessChanged();
  14152. me.lastZoomDistances = [xDistance, yDistance];
  14153. me.lastPoints = newPoints;
  14154. me.oldVisibleRanges = null;
  14155. me.hideLabels();
  14156. me.lockEvents(me.getZoomGesture());
  14157. return false;
  14158. }
  14159. }, onZoomGestureMove:function(e) {
  14160. var me = this;
  14161. if (me.getLocks()[me.getZoomGesture()] === me) {
  14162. var chart = me.getChart(), rect = chart.getInnerRect(), xy = chart.element.getXY(), x = xy[0] + rect[0], y = xy[1] + rect[1], abs = Math.abs, lastPoints = me.lastPoints, newPoints = [e.touches[0].point.x - x, e.touches[0].point.y - y, e.touches[1].point.x - x, e.touches[1].point.y - y], xDistance = Math.max(44, abs(newPoints[2] - newPoints[0])), yDistance = Math.max(44, abs(newPoints[3] - newPoints[1])), lastDistances = this.lastZoomDistances || [xDistance, yDistance], zoomX = xDistance / lastDistances[0],
  14163. zoomY = yDistance / lastDistances[1];
  14164. me.transformAxesBy(me.getZoomableAxes(e), rect[2] * (zoomX - 1) / 2 + newPoints[2] - lastPoints[2] * zoomX, rect[3] * (zoomY - 1) / 2 + newPoints[3] - lastPoints[3] * zoomY, zoomX, zoomY);
  14165. me.sync();
  14166. return false;
  14167. }
  14168. }, onZoomGestureEnd:function(e) {
  14169. var me = this, zoom = me.getZoomGesture(), chart;
  14170. if (me.getLocks()[zoom] === me) {
  14171. chart = me.getChart();
  14172. chart.resumeThicknessChanged();
  14173. me.showLabels();
  14174. me.sync();
  14175. me.unlockEvents(zoom);
  14176. chart.resumeAnimation();
  14177. return false;
  14178. }
  14179. }, hideLabels:function() {
  14180. if (this.getHideLabelInGesture()) {
  14181. this.eachInteractiveAxes(function(axis) {
  14182. axis.hideLabels();
  14183. });
  14184. }
  14185. }, showLabels:function() {
  14186. if (this.getHideLabelInGesture()) {
  14187. this.eachInteractiveAxes(function(axis) {
  14188. axis.showLabels();
  14189. });
  14190. }
  14191. }, isEventOnAxis:function(e, axis) {
  14192. var rect = axis.getSurface().getRect();
  14193. return rect[0] <= e.getX() && e.getX() <= rect[0] + rect[2] && rect[1] <= e.getY() && e.getY() <= rect[1] + rect[3];
  14194. }, getPannableAxes:function(e) {
  14195. var me = this, axisConfigs = me.getAxes(), axes = me.getChart().getAxes(), i, ln = axes.length, result = [], isEventOnAxis = false, config;
  14196. if (e) {
  14197. for (i = 0; i < ln; i++) {
  14198. if (this.isEventOnAxis(e, axes[i])) {
  14199. isEventOnAxis = true;
  14200. break;
  14201. }
  14202. }
  14203. }
  14204. for (i = 0; i < ln; i++) {
  14205. config = axisConfigs[axes[i].getPosition()];
  14206. if (config && config.allowPan !== false && (!isEventOnAxis || this.isEventOnAxis(e, axes[i]))) {
  14207. result.push(axes[i]);
  14208. }
  14209. }
  14210. return result;
  14211. }, getZoomableAxes:function(e) {
  14212. var me = this, axisConfigs = me.getAxes(), axes = me.getChart().getAxes(), result = [], i, ln = axes.length, axis, isEventOnAxis = false, config;
  14213. if (e) {
  14214. for (i = 0; i < ln; i++) {
  14215. if (this.isEventOnAxis(e, axes[i])) {
  14216. isEventOnAxis = true;
  14217. break;
  14218. }
  14219. }
  14220. }
  14221. for (i = 0; i < ln; i++) {
  14222. axis = axes[i];
  14223. config = axisConfigs[axis.getPosition()];
  14224. if (config && config.allowZoom !== false && (!isEventOnAxis || this.isEventOnAxis(e, axis))) {
  14225. result.push(axis);
  14226. }
  14227. }
  14228. return result;
  14229. }, eachInteractiveAxes:function(fn) {
  14230. var me = this, axisConfigs = me.getAxes(), axes = me.getChart().getAxes(), i;
  14231. for (i = 0; i < axes.length; i++) {
  14232. if (axisConfigs[axes[i].getPosition()]) {
  14233. if (false === fn.call(this, axes[i])) {
  14234. return;
  14235. }
  14236. }
  14237. }
  14238. }, transformAxesBy:function(axes, panX, panY, sx, sy) {
  14239. var rect = this.getChart().getInnerRect(), axesCfg = this.getAxes(), oldVisibleRanges = this.oldVisibleRanges, result = false, axisCfg, i;
  14240. if (!oldVisibleRanges) {
  14241. this.oldVisibleRanges = oldVisibleRanges = {};
  14242. this.eachInteractiveAxes(function(axis) {
  14243. oldVisibleRanges[axis.getId()] = axis.getVisibleRange();
  14244. });
  14245. }
  14246. if (!rect) {
  14247. return;
  14248. }
  14249. for (i = 0; i < axes.length; i++) {
  14250. axisCfg = axesCfg[axes[i].getPosition()];
  14251. result = this.transformAxisBy(axes[i], oldVisibleRanges[axes[i].getId()], panX, panY, sx, sy, this.minZoom || axisCfg.minZoom, this.maxZoom || axisCfg.maxZoom) || result;
  14252. }
  14253. return result;
  14254. }, transformAxisBy:function(axis, oldVisibleRange, panX, panY, sx, sy, minZoom, maxZoom) {
  14255. var me = this, visibleLength = oldVisibleRange[1] - oldVisibleRange[0], visibleRange = axis.getVisibleRange(), actualMinZoom = minZoom || me.getMinZoom() || axis.config.minZoom, actualMaxZoom = maxZoom || me.getMaxZoom() || axis.config.maxZoom, rect = me.getChart().getInnerRect(), left, right, isSide, pan, length;
  14256. if (!rect) {
  14257. return;
  14258. }
  14259. isSide = axis.isSide();
  14260. length = isSide ? rect[3] : rect[2];
  14261. pan = isSide ? -panY : panX;
  14262. visibleLength /= isSide ? sy : sx;
  14263. if (visibleLength < 0) {
  14264. visibleLength = -visibleLength;
  14265. }
  14266. if (visibleLength * actualMinZoom > 1) {
  14267. visibleLength = 1;
  14268. }
  14269. if (visibleLength * actualMaxZoom < 1) {
  14270. visibleLength = 1 / actualMaxZoom;
  14271. }
  14272. left = oldVisibleRange[0];
  14273. right = oldVisibleRange[1];
  14274. visibleRange = visibleRange[1] - visibleRange[0];
  14275. if (visibleLength === visibleRange && visibleRange === 1) {
  14276. return;
  14277. }
  14278. axis.setVisibleRange([(oldVisibleRange[0] + oldVisibleRange[1] - visibleLength) * 0.5 - pan / length * visibleLength, (oldVisibleRange[0] + oldVisibleRange[1] + visibleLength) * 0.5 - pan / length * visibleLength]);
  14279. return Math.abs(left - axis.getVisibleRange()[0]) > 1.0E-10 || Math.abs(right - axis.getVisibleRange()[1]) > 1.0E-10;
  14280. }, destroy:function() {
  14281. this.setModeToggleButton(null);
  14282. this.callParent();
  14283. }});
  14284. Ext.define('Ext.chart.interactions.Rotate', {extend:'Ext.chart.interactions.Abstract', type:'rotate', alternateClassName:'Ext.chart.interactions.RotatePie3D', alias:['interaction.rotate', 'interaction.rotatePie3d'], config:{gesture:'rotate', gestures:{dragstart:'onGestureStart', drag:'onGesture', dragend:'onGestureEnd'}, rotation:0}, oldRotations:null, getAngle:function(e) {
  14285. var me = this, chart = me.getChart(), xy = chart.getEventXY(e), center = chart.getCenter();
  14286. return Math.atan2(xy[1] - center[1], xy[0] - center[0]);
  14287. }, onGestureStart:function(e) {
  14288. var me = this;
  14289. e.claimGesture();
  14290. me.lockEvents('drag');
  14291. me.angle = me.getAngle(e);
  14292. me.oldRotations = {};
  14293. me.getChart().suspendAnimation();
  14294. me.fireEvent('rotatestart', me, me.getRotation());
  14295. return false;
  14296. }, onGesture:function(e) {
  14297. var me = this, angle = me.getAngle(e) - me.angle;
  14298. if (me.getLocks().drag === me) {
  14299. me.doRotateTo(angle, true);
  14300. return false;
  14301. }
  14302. }, doRotateTo:function(angle, relative) {
  14303. var me = this, chart = me.getChart(), axes = chart.getAxes(), seriesList = chart.getSeries(), oldRotations = me.oldRotations, rotation, oldRotation, axis, series, id, i, ln;
  14304. for (i = 0, ln = axes.length; i < ln; i++) {
  14305. axis = axes[i];
  14306. id = axis.getId();
  14307. oldRotation = oldRotations[id] || (oldRotations[id] = axis.getRotation());
  14308. rotation = angle + (relative ? oldRotation : 0);
  14309. axis.setRotation(rotation);
  14310. }
  14311. for (i = 0, ln = seriesList.length; i < ln; i++) {
  14312. series = seriesList[i];
  14313. id = series.getId();
  14314. oldRotation = oldRotations[id] || (oldRotations[id] = series.getRotation());
  14315. rotation = Ext.draw.Draw.degrees(angle + (relative ? oldRotation : 0));
  14316. series.setRotation(rotation);
  14317. }
  14318. me.setRotation(rotation);
  14319. me.fireEvent('rotate', me, me.getRotation());
  14320. me.sync();
  14321. }, rotateTo:function(angle, relative, animate) {
  14322. var me = this, chart = me.getChart();
  14323. if (!animate) {
  14324. chart.suspendAnimation();
  14325. }
  14326. me.doRotateTo(angle, relative, animate);
  14327. me.oldRotations = {};
  14328. if (!animate) {
  14329. chart.resumeAnimation();
  14330. }
  14331. }, onGestureEnd:function(e) {
  14332. var me = this;
  14333. if (me.getLocks().drag === me) {
  14334. me.onGesture(e);
  14335. me.unlockEvents('drag');
  14336. me.getChart().resumeAnimation();
  14337. me.fireEvent('rotateend', me, me.getRotation());
  14338. me.fireEvent('rotationEnd', me, me.getRotation());
  14339. return false;
  14340. }
  14341. }});
  14342. Ext.define('Ext.chart.navigator.ContainerBase', {extend:'Ext.Container', updateNavigator:function(navigator, oldNavigator) {
  14343. if (oldNavigator) {
  14344. this.remove(oldNavigator, true);
  14345. }
  14346. this.add(navigator);
  14347. }});
  14348. Ext.define('Ext.chart.navigator.NavigatorBase', {extend:'Ext.chart.CartesianChart', initialize:function() {
  14349. var me = this;
  14350. me.callParent();
  14351. me.setupEvents();
  14352. }});
  14353. Ext.define('Ext.chart.navigator.sprite.RangeMask', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.rangemask', inheritableStatics:{def:{processors:{min:'limited01', max:'limited01', thumbOpacity:'limited01'}, defaults:{min:0, max:1, lineWidth:2, miterLimit:1, strokeStyle:'#787878', thumbOpacity:1}}}, getBBox:function(isWithoutTransform) {
  14354. var me = this, attr = me.attr, bbox = attr.bbox;
  14355. bbox.plain = {x:0, y:0, width:1, height:1};
  14356. if (isWithoutTransform) {
  14357. return bbox.plain;
  14358. }
  14359. return bbox.transform || (bbox.transform = attr.matrix.transformBBox(bbox.plain));
  14360. }, renderThumb:function(surface, ctx, x, y) {
  14361. var me = this, shapeSprite = me.shapeSprite, textureSprite = me.textureSprite, thumbOpacity = me.attr.thumbOpacity, thumbAttributes = {opacity:thumbOpacity, translationX:x, translationY:y};
  14362. if (!shapeSprite) {
  14363. shapeSprite = me.shapeSprite = new Ext.draw.sprite.Rect({x:-9.5, y:-9.5, width:19, height:19, radius:4, lineWidth:1, fillStyle:{type:'linear', degrees:90, stops:[{offset:0, color:'#EEE'}, {offset:1, color:'#FFF'}]}, strokeStyle:'#999'});
  14364. textureSprite = me.textureSprite = new Ext.draw.sprite.Path({path:'M -4, -5, -4, 5 M 0, -5, 0, 5 M 4, -5, 4, 5', strokeStyle:{type:'linear', degrees:90, stops:[{offset:0, color:'#CCC'}, {offset:1, color:'#BBB'}]}, lineWidth:2});
  14365. }
  14366. ctx.save();
  14367. shapeSprite.setAttributes(thumbAttributes);
  14368. shapeSprite.applyTransformations();
  14369. textureSprite.setAttributes(thumbAttributes);
  14370. textureSprite.applyTransformations();
  14371. shapeSprite.useAttributes(ctx);
  14372. shapeSprite.render(surface, ctx);
  14373. textureSprite.useAttributes(ctx);
  14374. textureSprite.render(surface, ctx);
  14375. ctx.restore();
  14376. }, render:function(surface, ctx) {
  14377. var me = this, attr = me.attr, matrix = attr.matrix.elements, sx = matrix[0], sy = matrix[3], tx = matrix[4], ty = matrix[5], min = attr.min, max = attr.max, s_min = min * sx + tx, s_max = max * sx + tx, s_y = Math.round(0.5 * sy + ty);
  14378. ctx.beginPath();
  14379. ctx.moveTo(tx, ty);
  14380. ctx.lineTo(sx + tx, ty);
  14381. ctx.lineTo(sx + tx, sy + ty);
  14382. ctx.lineTo(tx, sy + ty);
  14383. ctx.lineTo(tx, ty);
  14384. ctx.moveTo(s_min, ty);
  14385. ctx.lineTo(s_min, sy + ty);
  14386. ctx.lineTo(s_max, sy + ty);
  14387. ctx.lineTo(s_max, ty);
  14388. ctx.lineTo(s_min, ty);
  14389. ctx.fillStroke(attr, true);
  14390. me.renderThumb(surface, ctx, Math.round(s_min), s_y);
  14391. me.renderThumb(surface, ctx, Math.round(s_max), s_y);
  14392. }});
  14393. Ext.define('Ext.chart.navigator.Navigator', {extend:'Ext.chart.navigator.NavigatorBase', isNavigator:true, requires:['Ext.chart.navigator.sprite.RangeMask'], config:{docked:'bottom', span:'series', insetPadding:0, innerPadding:0, navigatorContainer:null, axis:null, tolerance:20, minimum:0.8, maximum:1, thumbGap:30, autoHideThumbs:true, width:'100%', height:75}, dragType:null, constructor:function(config) {
  14394. var me = this, visibleRange, overlay;
  14395. config = config || {};
  14396. visibleRange = [config.minimum || 0.8, config.maximum || 1];
  14397. me.callParent([config]);
  14398. overlay = me.overlaySurface;
  14399. overlay.element.setStyle({zIndex:100});
  14400. me.rangeMask = overlay.add({type:'rangemask', min:visibleRange[0], max:visibleRange[1], fillStyle:'rgba(0, 0, 0, .25)'});
  14401. me.onDragEnd();
  14402. me.rangeMask.setAnimation({duration:500, customDurations:{min:0, max:0, translationX:0, translationY:0, scalingX:0, scalingY:0, scalingCenterX:0, scalingCenterY:0, fillStyle:0, strokeStyle:0}});
  14403. me.setVisibleRange(visibleRange);
  14404. }, createSurface:function(id) {
  14405. var surface = this.callParent([id]);
  14406. if (id === 'overlay') {
  14407. this.overlaySurface = surface;
  14408. }
  14409. return surface;
  14410. }, applyAxis:function(axis) {
  14411. return this.getNavigatorContainer().getChart().getAxis(axis);
  14412. }, updateAxis:function(axis, oldAxis) {
  14413. var me = this, eventName = 'visiblerangechange', eventHandler = 'onAxisVisibleRangeChange';
  14414. if (oldAxis) {
  14415. oldAxis.un(eventName, eventHandler, me);
  14416. }
  14417. if (axis) {
  14418. axis.on(eventName, eventHandler, me);
  14419. }
  14420. me.axis = axis;
  14421. }, getAxis:function() {
  14422. return this.axis;
  14423. }, onAxisVisibleRangeChange:function(axis, visibleRange) {
  14424. this.setVisibleRange(visibleRange);
  14425. }, updateNavigatorContainer:function(navigatorContainer) {
  14426. var me = this, oldChart = me.chart, chart = me.chart = navigatorContainer && navigatorContainer.getChart(), chartSeriesList = chart && chart.getSeries(), chartLegendStore = me.chartLegendStore, navigatorSeriesList = [], storeEventName = 'update', storeEventHandler = 'onChartLegendStoreUpdate', chartSeries, navigatorSeries, seriesConfig, i;
  14427. if (oldChart) {
  14428. oldChart.un('layout', 'afterBoundChartLayout', me);
  14429. oldChart.un('themechange', 'onChartThemeChange', me);
  14430. oldChart.un('storechange', 'onChartStoreChange', me);
  14431. }
  14432. chart.on('layout', 'afterBoundChartLayout', me);
  14433. for (i = 0; i < chartSeriesList.length; i++) {
  14434. chartSeries = chartSeriesList[i];
  14435. seriesConfig = me.getSeriesConfig(chartSeries);
  14436. navigatorSeries = Ext.create('series.' + seriesConfig.type, seriesConfig);
  14437. navigatorSeries.parentSeries = chartSeries;
  14438. chartSeries.navigatorSeries = navigatorSeries;
  14439. navigatorSeriesList.push(navigatorSeries);
  14440. }
  14441. if (chartLegendStore) {
  14442. chartLegendStore.un(storeEventName, storeEventHandler, me);
  14443. me.chartLegendStore = null;
  14444. }
  14445. if (chart) {
  14446. me.setStore(chart.getStore());
  14447. me.chartLegendStore = chartLegendStore = chart.getLegendStore();
  14448. if (chartLegendStore) {
  14449. chartLegendStore.on(storeEventName, storeEventHandler, me);
  14450. }
  14451. chart.on('themechange', 'onChartThemeChange', me);
  14452. chart.on('storechange', 'onChartStoreChange', me);
  14453. me.onChartThemeChange(chart, chart.getTheme());
  14454. }
  14455. me.setSeries(navigatorSeriesList);
  14456. }, onChartThemeChange:function(chart, theme) {
  14457. this.setTheme(theme);
  14458. }, onChartStoreChange:function(chart, store) {
  14459. this.setStore(store);
  14460. }, addCustomStyle:function(config, style, subStyle) {
  14461. var fillStyle, strokeStyle;
  14462. style = style || {};
  14463. subStyle = subStyle || {};
  14464. config.style = config.style || {};
  14465. config.subStyle = config.subStyle || {};
  14466. fillStyle = style && (style.fillStyle || style.fill);
  14467. strokeStyle = style && (style.strokeStyle || style.stroke);
  14468. if (fillStyle) {
  14469. config.style.fillStyle = fillStyle;
  14470. }
  14471. if (strokeStyle) {
  14472. config.style.strokeStyle = strokeStyle;
  14473. }
  14474. fillStyle = subStyle && (subStyle.fillStyle || subStyle.fill);
  14475. strokeStyle = subStyle && (subStyle.strokeStyle || subStyle.stroke);
  14476. if (fillStyle) {
  14477. config.subStyle.fillStyle = fillStyle;
  14478. }
  14479. if (strokeStyle) {
  14480. config.subStyle.strokeStyle = strokeStyle;
  14481. }
  14482. return config;
  14483. }, getSeriesConfig:function(chartSeries) {
  14484. var me = this, style = chartSeries.getStyle(), config;
  14485. if (chartSeries.isLine) {
  14486. config = me.addCustomStyle({type:'line', fill:true, xField:chartSeries.getXField(), yField:chartSeries.getYField(), smooth:chartSeries.getSmooth()}, style);
  14487. } else {
  14488. if (chartSeries.isCandleStick) {
  14489. config = me.addCustomStyle({type:'line', fill:true, xField:chartSeries.getXField(), yField:chartSeries.getCloseField()}, style.raiseStyle);
  14490. } else {
  14491. if (chartSeries.isArea || chartSeries.isBar) {
  14492. config = me.addCustomStyle({type:'area', xField:chartSeries.getXField(), yField:chartSeries.getYField()}, style, chartSeries.getSubStyle());
  14493. } else {
  14494. Ext.raise("Navigator only works with 'line', 'bar', 'candlestick' and 'area' series.");
  14495. }
  14496. }
  14497. }
  14498. config.style.fillOpacity = 0.2;
  14499. return config;
  14500. }, onChartLegendStoreUpdate:function(store, record) {
  14501. var me = this, chart = me.chart, series;
  14502. if (chart && record) {
  14503. series = chart.getSeries().map[record.get('series')];
  14504. if (series && series.navigatorSeries) {
  14505. series.navigatorSeries.setHiddenByIndex(record.get('index'), record.get('disabled'));
  14506. me.redraw();
  14507. }
  14508. }
  14509. }, setupEvents:function() {
  14510. var me = this, overlayEl = me.overlaySurface.element;
  14511. overlayEl.on({scope:me, drag:'onDrag', dragstart:'onDragStart', dragend:'onDragEnd', dragcancel:'onDragEnd', mousemove:'onMouseMove'});
  14512. }, onMouseMove:function(e) {
  14513. var me = this, overlayEl = me.overlaySurface.element, style = overlayEl.dom.style, dragType = me.getDragType(e.pageX - overlayEl.getXY()[0]);
  14514. switch(dragType) {
  14515. case 'min':
  14516. case 'max':
  14517. style.cursor = 'ew-resize';
  14518. break;
  14519. case 'pan':
  14520. style.cursor = 'move';
  14521. break;
  14522. default:
  14523. style.cursor = 'default';
  14524. }
  14525. }, getDragType:function(x) {
  14526. var me = this, t = me.getTolerance(), width = me.overlaySurface.element.getSize().width, rangeMask = me.rangeMask, min = width * rangeMask.attr.min, max = width * rangeMask.attr.max, dragType;
  14527. if (x > min + t && x < max - t) {
  14528. dragType = 'pan';
  14529. } else {
  14530. if (x <= min + t && x > min - t) {
  14531. dragType = 'min';
  14532. } else {
  14533. if (x >= max - t && x < max + t) {
  14534. dragType = 'max';
  14535. }
  14536. }
  14537. }
  14538. return dragType;
  14539. }, onDragStart:function(e) {
  14540. var me = this, x, dragType;
  14541. if (me.dragType || e && e.touches && e.touches.length > 1) {
  14542. return;
  14543. }
  14544. x = e.touches[0].pageX - me.overlaySurface.element.getXY()[0];
  14545. dragType = me.getDragType(x);
  14546. me.rangeMask.attr.thumbOpacity = 1;
  14547. if (dragType) {
  14548. me.dragType = dragType;
  14549. me.touchId = e.touches[0].identifier;
  14550. me.dragX = x;
  14551. }
  14552. }, onDrag:function(e) {
  14553. if (e.touch.identifier !== this.touchId) {
  14554. return;
  14555. }
  14556. var me = this, overlayEl = me.overlaySurface.element, width = overlayEl.getSize().width, x = e.touches[0].pageX - overlayEl.getXY()[0], thumbGap = me.getThumbGap() / width, rangeMask = me.rangeMask, min = rangeMask.attr.min, max = rangeMask.attr.max, delta = max - min, dragType = me.dragType, drag = me.dragX, dx = (x - drag) / width;
  14557. if (dragType === 'pan') {
  14558. min += dx;
  14559. max += dx;
  14560. if (min < 0) {
  14561. min = 0;
  14562. max = delta;
  14563. }
  14564. if (max > 1) {
  14565. max = 1;
  14566. min = max - delta;
  14567. }
  14568. } else {
  14569. if (dragType === 'min') {
  14570. min += dx;
  14571. if (min < 0) {
  14572. min = 0;
  14573. }
  14574. if (min > max - thumbGap) {
  14575. min = max - thumbGap;
  14576. }
  14577. } else {
  14578. if (dragType === 'max') {
  14579. max += dx;
  14580. if (max > 1) {
  14581. max = 1;
  14582. }
  14583. if (max < min + thumbGap) {
  14584. max = min + thumbGap;
  14585. }
  14586. } else {
  14587. return;
  14588. }
  14589. }
  14590. }
  14591. me.dragX = x;
  14592. me.setVisibleRange([min, max]);
  14593. }, onDragEnd:function() {
  14594. var me = this, autoHideThumbs = me.getAutoHideThumbs();
  14595. me.dragType = null;
  14596. if (autoHideThumbs) {
  14597. me.rangeMask.setAttributes({thumbOpacity:0});
  14598. }
  14599. }, updateMinimum:function(mininum) {
  14600. if (!this.isConfiguring) {
  14601. this.setVisibleRange([mininum, this.getMaximum()]);
  14602. }
  14603. }, updateMaximum:function(maximum) {
  14604. if (!this.isConfiguring) {
  14605. this.setVisibleRange([this.getMinimum(), maximum]);
  14606. }
  14607. }, getMinimum:function() {
  14608. return this.rangeMask.attr.min;
  14609. }, getMaximum:function() {
  14610. return this.rangeMask.attr.max;
  14611. }, setVisibleRange:function(visibleRange) {
  14612. var me = this, chart = me.chart;
  14613. me.axis.setVisibleRange(visibleRange);
  14614. me.rangeMask.setAttributes({min:visibleRange[0], max:visibleRange[1]});
  14615. me.getSurface('overlay').renderFrame();
  14616. chart.suspendAnimation();
  14617. chart.redraw();
  14618. chart.resumeAnimation();
  14619. }, afterBoundChartLayout:function() {
  14620. var me = this, spanSeries = me.getSpan() === 'series', mainRect = me.chart.getMainRect(), size = me.element.getSize();
  14621. if (mainRect && spanSeries) {
  14622. me.setInsetPadding({left:mainRect[0], right:size.width - mainRect[2] - mainRect[0], top:0, bottom:0});
  14623. me.performLayout();
  14624. }
  14625. }, afterChartLayout:function() {
  14626. var me = this, size = me.overlaySurface.element.getSize();
  14627. me.rangeMask.setAttributes({scalingCenterX:0, scalingCenterY:0, scalingX:size.width, scalingY:size.height});
  14628. }, doDestroy:function() {
  14629. var chart = this.chart;
  14630. if (chart && !chart.destroyed) {
  14631. chart.un('layout', 'afterBoundChartLayout', this);
  14632. }
  14633. this.callParent();
  14634. }});
  14635. Ext.define('Ext.chart.navigator.Container', {extend:'Ext.chart.navigator.ContainerBase', requires:['Ext.chart.CartesianChart', 'Ext.chart.navigator.Navigator'], xtype:'chartnavigator', config:{chart:null, navigator:{}}, layout:'fit', applyChart:function(chart, oldChart) {
  14636. if (oldChart) {
  14637. oldChart.destroy();
  14638. }
  14639. if (chart) {
  14640. if (chart.isCartesian) {
  14641. Ext.raise('Only cartesian charts are supported.');
  14642. }
  14643. if (!chart.isChart) {
  14644. chart.$initParent = this;
  14645. chart = new Ext.chart.CartesianChart(chart);
  14646. delete chart.$initParent;
  14647. }
  14648. }
  14649. return chart;
  14650. }, legendStore:null, surfaceRects:null, updateChart:function(chart, oldChart) {
  14651. var me = this;
  14652. if (chart) {
  14653. me.legendStore = chart.getLegendStore();
  14654. if (!me.items && me.initItems) {
  14655. me.initItems();
  14656. }
  14657. me.add(chart);
  14658. }
  14659. }, applyNavigator:function(navigator, oldNavigator) {
  14660. var instance;
  14661. if (oldNavigator) {
  14662. oldNavigator.destroy();
  14663. }
  14664. if (navigator) {
  14665. navigator.navigatorContainer = navigator.parent = this;
  14666. instance = new Ext.chart.navigator.Navigator(navigator);
  14667. }
  14668. return instance;
  14669. }, preview:function() {
  14670. this.getNavigator().preview(this.getImage());
  14671. }, download:function(config) {
  14672. config = config || {};
  14673. config.data = this.getImage().data;
  14674. this.getNavigator().download(config);
  14675. }, setVisibleRange:function(visibleRange) {
  14676. this.getNavigator().setVisibleRange(visibleRange);
  14677. }, getImage:function(format) {
  14678. var me = this, chart = me.getChart(), navigator = me.getNavigator(), docked = navigator.getDocked(), chartImageSize = chart.bodyElement.getSize(), navigatorImageSize = navigator.bodyElement.getSize(), chartSurfaces = chart.getSurfaces(true), navigatorSurfaces = navigator.getSurfaces(true), size = {width:chartImageSize.width, height:chartImageSize.height + navigatorImageSize.height}, image, imageElement, surfaces, surface;
  14679. if (docked === 'top') {
  14680. me.shiftSurfaces(chartSurfaces, 0, navigatorImageSize.height);
  14681. } else {
  14682. me.shiftSurfaces(navigatorSurfaces, 0, chartImageSize.height);
  14683. }
  14684. surfaces = chartSurfaces.concat(navigatorSurfaces);
  14685. surface = surfaces[0];
  14686. if ((Ext.isIE || Ext.isEdge) && surface.isSVG) {
  14687. image = {data:surface.toSVG(size, surfaces), type:'svg-markup'};
  14688. } else {
  14689. image = surface.flatten(size, surfaces);
  14690. if (format === 'image') {
  14691. imageElement = new Image;
  14692. imageElement.src = image.data;
  14693. image.data = imageElement;
  14694. return image;
  14695. }
  14696. if (format === 'stream') {
  14697. image.data = image.data.replace(/^data:image\/[^;]+/, 'data:application/octet-stream');
  14698. return image;
  14699. }
  14700. }
  14701. me.unshiftSurfaces(surfaces);
  14702. return image;
  14703. }, shiftSurfaces:function(surfaces, x, y) {
  14704. var ln = surfaces.length, i = 0, surface;
  14705. this.surfaceRects = {};
  14706. for (; i < ln; i++) {
  14707. surface = surfaces[i];
  14708. this.shiftSurface(surface, x, y);
  14709. }
  14710. }, shiftSurface:function(surface, x, y) {
  14711. var rect = surface.getRect();
  14712. this.surfaceRects[surface.getId()] = rect.slice();
  14713. rect[0] += x;
  14714. rect[1] += y;
  14715. }, unshiftSurfaces:function(surfaces) {
  14716. var rects = this.surfaceRects, ln = surfaces.length, i = 0, surface, rect, oldRect;
  14717. if (rects) {
  14718. for (; i < ln; i++) {
  14719. surface = surfaces[i];
  14720. rect = surface.getRect();
  14721. oldRect = rects[surface.getId()];
  14722. if (oldRect) {
  14723. rect[0] = oldRect[0];
  14724. rect[1] = oldRect[1];
  14725. }
  14726. }
  14727. }
  14728. this.surfaceRects = null;
  14729. }});
  14730. Ext.define('Ext.chart.plugin.ItemEvents', {extend:'Ext.plugin.Abstract', alias:'plugin.chartitemevents', moveEvents:false, mouseMoveEvents:{mousemove:true, mouseover:true, mouseout:true}, itemMouseMoveEvents:{itemmousemove:true, itemmouseover:true, itemmouseout:true}, init:function(chart) {
  14731. var handleEvent = 'handleEvent';
  14732. this.chart = chart;
  14733. chart.addElementListener({click:handleEvent, tap:handleEvent, dblclick:handleEvent, mousedown:handleEvent, mousemove:handleEvent, mouseup:handleEvent, mouseover:handleEvent, mouseout:handleEvent, priority:1001, scope:this});
  14734. }, hasItemMouseMoveListeners:function() {
  14735. var listeners = this.chart.hasListeners, name;
  14736. for (name in this.itemMouseMoveEvents) {
  14737. if (name in listeners) {
  14738. return true;
  14739. }
  14740. }
  14741. return false;
  14742. }, handleEvent:function(e) {
  14743. var me = this, chart = me.chart, isMouseMoveEvent = e.type in me.mouseMoveEvents, lastItem = me.lastItem, chartXY, item;
  14744. if (isMouseMoveEvent && !me.hasItemMouseMoveListeners() && !me.moveEvents) {
  14745. return;
  14746. }
  14747. chartXY = chart.getEventXY(e);
  14748. item = chart.getItemForPoint(chartXY[0], chartXY[1]);
  14749. if (isMouseMoveEvent && !Ext.Object.equals(item, lastItem)) {
  14750. if (lastItem) {
  14751. chart.fireEvent('itemmouseout', chart, lastItem, e);
  14752. lastItem.series.fireEvent('itemmouseout', lastItem.series, lastItem, e);
  14753. }
  14754. if (item) {
  14755. chart.fireEvent('itemmouseover', chart, item, e);
  14756. item.series.fireEvent('itemmouseover', item.series, item, e);
  14757. }
  14758. }
  14759. if (item) {
  14760. chart.fireEvent('item' + e.type, chart, item, e);
  14761. item.series.fireEvent('item' + e.type, item.series, item, e);
  14762. }
  14763. me.lastItem = item;
  14764. }});
  14765. Ext.define('Ext.chart.series.Cartesian', {extend:'Ext.chart.series.Series', config:{xField:null, yField:null, xAxis:null, yAxis:null}, directions:['X', 'Y'], fieldCategoryX:['X'], fieldCategoryY:['Y'], applyXAxis:function(newAxis, oldAxis) {
  14766. return this.getChart().getAxis(newAxis) || oldAxis;
  14767. }, applyYAxis:function(newAxis, oldAxis) {
  14768. return this.getChart().getAxis(newAxis) || oldAxis;
  14769. }, updateXAxis:function(axis) {
  14770. axis.processData(this);
  14771. }, updateYAxis:function(axis) {
  14772. axis.processData(this);
  14773. }, coordinateX:function() {
  14774. return this.coordinate('X', 0, 2);
  14775. }, coordinateY:function() {
  14776. return this.coordinate('Y', 1, 2);
  14777. }, getItemForPoint:function(x, y) {
  14778. var me = this, sprite = me.getSprites()[0], store = me.getStore(), point;
  14779. if (sprite && !me.getHidden()) {
  14780. point = sprite.getNearestDataPoint(x, y);
  14781. }
  14782. return point ? {series:me, sprite:sprite, category:me.getItemInstancing() ? 'items' : 'markers', index:point.index, record:store.getData().items[point.index], field:me.getYField(), distance:point.distance} : null;
  14783. }, createSprite:function() {
  14784. var me = this, sprite = me.callParent(), chart = me.getChart(), xAxis = me.getXAxis();
  14785. sprite.setAttributes({flipXY:chart.getFlipXY(), xAxis:xAxis});
  14786. if (sprite.setAggregator && xAxis && xAxis.getAggregator) {
  14787. if (xAxis.getAggregator) {
  14788. sprite.setAggregator({strategy:xAxis.getAggregator()});
  14789. } else {
  14790. sprite.setAggregator({});
  14791. }
  14792. }
  14793. return sprite;
  14794. }, getSprites:function() {
  14795. var me = this, chart = this.getChart(), sprites = me.sprites;
  14796. if (!chart) {
  14797. return Ext.emptyArray;
  14798. }
  14799. if (!sprites.length) {
  14800. me.createSprite();
  14801. }
  14802. return sprites;
  14803. }, getXRange:function() {
  14804. return [this.dataRange[0], this.dataRange[2]];
  14805. }, getYRange:function() {
  14806. return [this.dataRange[1], this.dataRange[3]];
  14807. }});
  14808. Ext.define('Ext.chart.series.StackedCartesian', {extend:'Ext.chart.series.Cartesian', config:{stacked:true, splitStacks:true, fullStack:false, fullStackTotal:100, hidden:[]}, reversedSpriteZOrder:true, spriteAnimationCount:0, themeColorCount:function() {
  14809. var me = this, yField = me.getYField();
  14810. return Ext.isArray(yField) ? yField.length : 1;
  14811. }, updateStacked:function() {
  14812. this.processData();
  14813. }, updateSplitStacks:function() {
  14814. this.processData();
  14815. }, coordinateY:function() {
  14816. return this.coordinateStacked('Y', 1, 2);
  14817. }, coordinateStacked:function(direction, directionOffset, directionCount) {
  14818. var me = this, store = me.getStore(), items = store.getData().items, itemCount = items.length, axis = me['get' + direction + 'Axis'](), hidden = me.getHidden(), splitStacks = me.getSplitStacks(), fullStack = me.getFullStack(), fullStackTotal = me.getFullStackTotal(), range = [0, 0], directions = me['fieldCategory' + direction], dataStart = [], posDataStart = [], negDataStart = [], dataEnd, stacked = me.getStacked(), sprites = me.getSprites(), coordinatedData = [], i, j, k, fields, fieldCount, posTotals,
  14819. negTotals, fieldCategoriesItem, data, attr;
  14820. if (!sprites.length) {
  14821. return;
  14822. }
  14823. for (i = 0; i < directions.length; i++) {
  14824. fieldCategoriesItem = directions[i];
  14825. fields = me.getFields([fieldCategoriesItem]);
  14826. fieldCount = fields.length;
  14827. for (j = 0; j < itemCount; j++) {
  14828. dataStart[j] = 0;
  14829. posDataStart[j] = 0;
  14830. negDataStart[j] = 0;
  14831. }
  14832. for (j = 0; j < fieldCount; j++) {
  14833. if (!hidden[j]) {
  14834. coordinatedData[j] = me.coordinateData(items, fields[j], axis);
  14835. }
  14836. }
  14837. if (stacked && fullStack) {
  14838. posTotals = [];
  14839. if (splitStacks) {
  14840. negTotals = [];
  14841. }
  14842. for (j = 0; j < itemCount; j++) {
  14843. posTotals[j] = 0;
  14844. if (splitStacks) {
  14845. negTotals[j] = 0;
  14846. }
  14847. for (k = 0; k < fieldCount; k++) {
  14848. data = coordinatedData[k];
  14849. if (!data) {
  14850. continue;
  14851. }
  14852. data = data[j];
  14853. if (data >= 0 || !splitStacks) {
  14854. posTotals[j] += data;
  14855. } else {
  14856. if (data < 0) {
  14857. negTotals[j] += data;
  14858. }
  14859. }
  14860. }
  14861. }
  14862. }
  14863. for (j = 0; j < fieldCount; j++) {
  14864. attr = {};
  14865. if (hidden[j]) {
  14866. attr['dataStart' + fieldCategoriesItem] = dataStart;
  14867. attr['data' + fieldCategoriesItem] = dataStart;
  14868. sprites[j].setAttributes(attr);
  14869. continue;
  14870. }
  14871. data = coordinatedData[j];
  14872. if (stacked) {
  14873. dataEnd = [];
  14874. for (k = 0; k < itemCount; k++) {
  14875. if (!data[k]) {
  14876. data[k] = 0;
  14877. }
  14878. if (data[k] >= 0 || !splitStacks) {
  14879. if (fullStack && posTotals[k]) {
  14880. data[k] *= fullStackTotal / posTotals[k];
  14881. }
  14882. dataStart[k] = posDataStart[k];
  14883. posDataStart[k] += data[k];
  14884. dataEnd[k] = posDataStart[k];
  14885. } else {
  14886. if (fullStack && negTotals[k]) {
  14887. data[k] *= fullStackTotal / negTotals[k];
  14888. }
  14889. dataStart[k] = negDataStart[k];
  14890. negDataStart[k] += data[k];
  14891. dataEnd[k] = negDataStart[k];
  14892. }
  14893. }
  14894. attr['dataStart' + fieldCategoriesItem] = dataStart;
  14895. attr['data' + fieldCategoriesItem] = dataEnd;
  14896. Ext.chart.Util.expandRange(range, dataStart);
  14897. Ext.chart.Util.expandRange(range, dataEnd);
  14898. } else {
  14899. attr['dataStart' + fieldCategoriesItem] = dataStart;
  14900. attr['data' + fieldCategoriesItem] = data;
  14901. Ext.chart.Util.expandRange(range, data);
  14902. }
  14903. sprites[j].setAttributes(attr);
  14904. }
  14905. }
  14906. range = Ext.chart.Util.validateRange(range, me.defaultRange);
  14907. me.dataRange[directionOffset] = range[0];
  14908. me.dataRange[directionOffset + directionCount] = range[1];
  14909. attr = {};
  14910. attr['dataMin' + direction] = range[0];
  14911. attr['dataMax' + direction] = range[1];
  14912. for (i = 0; i < sprites.length; i++) {
  14913. sprites[i].setAttributes(attr);
  14914. }
  14915. }, getFields:function(fieldCategory) {
  14916. var me = this, fields = [], ln = fieldCategory.length, i, fieldsItem;
  14917. for (i = 0; i < ln; i++) {
  14918. fieldsItem = me['get' + fieldCategory[i] + 'Field']();
  14919. if (Ext.isArray(fieldsItem)) {
  14920. fields.push.apply(fields, fieldsItem);
  14921. } else {
  14922. fields.push(fieldsItem);
  14923. }
  14924. }
  14925. return fields;
  14926. }, updateLabelOverflowPadding:function(labelOverflowPadding) {
  14927. var me = this, label;
  14928. if (!me.isConfiguring) {
  14929. label = me.getLabel();
  14930. if (label) {
  14931. label.setAttributes({labelOverflowPadding:labelOverflowPadding});
  14932. }
  14933. }
  14934. }, updateLabelData:function() {
  14935. var me = this, label = me.getLabel();
  14936. if (label) {
  14937. label.setAttributes({labelOverflowPadding:me.getLabelOverflowPadding()});
  14938. }
  14939. me.callParent();
  14940. }, getSprites:function() {
  14941. var me = this, chart = me.getChart(), fields = me.getFields(me.fieldCategoryY), itemInstancing = me.getItemInstancing(), sprites = me.sprites, hidden = me.getHidden(), spritesCreated = false, fieldCount = fields.length, i, sprite;
  14942. if (!chart) {
  14943. return [];
  14944. }
  14945. for (i = 0; i < fieldCount; i++) {
  14946. sprite = sprites[i];
  14947. if (!sprite) {
  14948. sprite = me.createSprite();
  14949. sprite.setAttributes({zIndex:(me.reversedSpriteZOrder ? -1 : 1) * i});
  14950. sprite.setField(fields[i]);
  14951. spritesCreated = true;
  14952. hidden.push(false);
  14953. if (itemInstancing) {
  14954. sprite.getMarker('items').getTemplate().setAttributes(me.getStyleByIndex(i));
  14955. } else {
  14956. sprite.setAttributes(me.getStyleByIndex(i));
  14957. }
  14958. }
  14959. }
  14960. if (spritesCreated) {
  14961. me.updateHidden(hidden);
  14962. }
  14963. return sprites;
  14964. }, getItemForPoint:function(x, y) {
  14965. var me = this, sprites = me.getSprites(), store = me.getStore(), hidden = me.getHidden(), minDistance = Infinity, item = null, spriteIndex = -1, pointIndex = -1, point, yField, sprite, i, ln;
  14966. for (i = 0, ln = sprites.length; i < ln; i++) {
  14967. if (hidden[i]) {
  14968. continue;
  14969. }
  14970. sprite = sprites[i];
  14971. point = sprite.getNearestDataPoint(x, y);
  14972. if (point) {
  14973. if (point.distance < minDistance) {
  14974. minDistance = point.distance;
  14975. pointIndex = point.index;
  14976. spriteIndex = i;
  14977. }
  14978. }
  14979. }
  14980. if (spriteIndex > -1) {
  14981. yField = me.getYField();
  14982. item = {series:me, sprite:sprites[spriteIndex], category:me.getItemInstancing() ? 'items' : 'markers', index:pointIndex, record:store.getData().items[pointIndex], field:typeof yField === 'string' ? yField : yField[spriteIndex], distance:minDistance};
  14983. }
  14984. return item;
  14985. }, provideLegendInfo:function(target) {
  14986. var me = this, sprites = me.getSprites(), title = me.getTitle(), field = me.getYField(), hidden = me.getHidden(), single = sprites.length === 1, style, fill, i, name;
  14987. for (i = 0; i < sprites.length; i++) {
  14988. style = me.getStyleByIndex(i);
  14989. fill = style.fillStyle;
  14990. if (title) {
  14991. if (Ext.isArray(title)) {
  14992. name = title[i];
  14993. } else {
  14994. if (single) {
  14995. name = title;
  14996. }
  14997. }
  14998. }
  14999. if (!title || !name) {
  15000. if (Ext.isArray(field)) {
  15001. name = field[i];
  15002. } else {
  15003. name = me.getId();
  15004. }
  15005. }
  15006. target.push({name:name, mark:(Ext.isObject(fill) ? fill.stops && fill.stops[0].color : fill) || style.strokeStyle || 'black', disabled:hidden[i], series:me.getId(), index:i});
  15007. }
  15008. }, onSpriteAnimationStart:function(sprite) {
  15009. this.spriteAnimationCount++;
  15010. if (this.spriteAnimationCount === 1) {
  15011. this.fireEvent('animationstart');
  15012. }
  15013. }, onSpriteAnimationEnd:function(sprite) {
  15014. this.spriteAnimationCount--;
  15015. if (this.spriteAnimationCount === 0) {
  15016. this.fireEvent('animationend');
  15017. }
  15018. }});
  15019. Ext.define('Ext.chart.series.sprite.Series', {extend:'Ext.draw.sprite.Sprite', mixins:{markerHolder:'Ext.chart.MarkerHolder'}, inheritableStatics:{def:{processors:{dataMinX:'number', dataMaxX:'number', dataMinY:'number', dataMaxY:'number', rangeX:'data', rangeY:'data', dataX:'data', dataY:'data', labels:'default', labelOverflowPadding:'number'}, defaults:{dataMinX:0, dataMaxX:1, dataMinY:0, dataMaxY:1, rangeX:null, rangeY:null, dataX:null, dataY:null, labels:null, labelOverflowPadding:10}, triggers:{dataX:'bbox',
  15020. dataY:'bbox', dataMinX:'bbox', dataMaxX:'bbox', dataMinY:'bbox', dataMaxY:'bbox'}}}, config:{store:null, series:null, field:null}});
  15021. Ext.define('Ext.chart.series.sprite.Cartesian', {extend:'Ext.chart.series.sprite.Series', inheritableStatics:{def:{processors:{selectionTolerance:'number', flipXY:'bool', renderer:'default', visibleMinX:'number', visibleMinY:'number', visibleMaxX:'number', visibleMaxY:'number', innerWidth:'number', innerHeight:'number'}, defaults:{selectionTolerance:20, flipXY:false, renderer:null, transformFillStroke:false, visibleMinX:0, visibleMinY:0, visibleMaxX:1, visibleMaxY:1, innerWidth:1, innerHeight:1},
  15022. triggers:{dataX:'dataX,bbox', dataY:'dataY,bbox', visibleMinX:'panzoom', visibleMinY:'panzoom', visibleMaxX:'panzoom', visibleMaxY:'panzoom', innerWidth:'panzoom', innerHeight:'panzoom'}, updaters:{dataX:function(attr) {
  15023. this.processDataX();
  15024. this.scheduleUpdater(attr, 'dataY', ['dataY']);
  15025. }, dataY:function() {
  15026. this.processDataY();
  15027. }, panzoom:function(attr) {
  15028. var dx = attr.visibleMaxX - attr.visibleMinX, dy = attr.visibleMaxY - attr.visibleMinY, innerWidth = attr.flipXY ? attr.innerHeight : attr.innerWidth, innerHeight = !attr.flipXY ? attr.innerHeight : attr.innerWidth, surface = this.getSurface(), isRtl = surface ? surface.getInherited().rtl : false;
  15029. attr.scalingCenterX = 0;
  15030. attr.scalingCenterY = 0;
  15031. attr.scalingX = innerWidth / dx;
  15032. attr.scalingY = innerHeight / dy;
  15033. attr.translationX = -(attr.visibleMinX * attr.scalingX);
  15034. attr.translationY = -(attr.visibleMinY * attr.scalingY);
  15035. if (isRtl && !attr.flipXY) {
  15036. attr.scalingX *= -1;
  15037. attr.translationX *= -1;
  15038. attr.translationX += innerWidth;
  15039. }
  15040. this.applyTransformations(true);
  15041. }}}}, processDataY:Ext.emptyFn, processDataX:Ext.emptyFn, updatePlainBBox:function(plain) {
  15042. var attr = this.attr;
  15043. plain.x = attr.dataMinX;
  15044. plain.y = attr.dataMinY;
  15045. plain.width = attr.dataMaxX - attr.dataMinX;
  15046. plain.height = attr.dataMaxY - attr.dataMinY;
  15047. }, binarySearch:function(key) {
  15048. var dx = this.attr.dataX, start = 0, end = dx.length, mid, val;
  15049. if (key <= dx[0]) {
  15050. return start;
  15051. }
  15052. if (key >= dx[end - 1]) {
  15053. return end - 1;
  15054. }
  15055. while (start + 1 < end) {
  15056. mid = start + end >> 1;
  15057. val = dx[mid];
  15058. if (val === key) {
  15059. return mid;
  15060. } else {
  15061. if (val < key) {
  15062. start = mid;
  15063. } else {
  15064. end = mid;
  15065. }
  15066. }
  15067. }
  15068. return start;
  15069. }, render:function(surface, ctx, surfaceClipRect) {
  15070. var me = this, attr = me.attr, margin = 1, inverseMatrix = attr.inverseMatrix.clone(), dataClipRect;
  15071. inverseMatrix.appendMatrix(surface.inverseMatrix);
  15072. if (attr.dataX === null || attr.dataX === undefined) {
  15073. return;
  15074. }
  15075. if (attr.dataY === null || attr.dataY === undefined) {
  15076. return;
  15077. }
  15078. if (inverseMatrix.getXX() * inverseMatrix.getYX() || inverseMatrix.getXY() * inverseMatrix.getYY()) {
  15079. Ext.Logger.warn('Cartesian Series sprite does not support rotation/sheering');
  15080. return;
  15081. }
  15082. dataClipRect = inverseMatrix.transformList([[surfaceClipRect[0] - margin, surfaceClipRect[3] + margin], [surfaceClipRect[0] + surfaceClipRect[2] + margin, -margin]]);
  15083. dataClipRect = dataClipRect[0].concat(dataClipRect[1]);
  15084. me.renderClipped(surface, ctx, dataClipRect, surfaceClipRect);
  15085. }, renderClipped:Ext.emptyFn, getIndexNearPoint:function(x, y) {
  15086. var result = this.getNearestDataPoint(x, y);
  15087. return result ? result.index : -1;
  15088. }, getNearestDataPoint:function(x, y) {
  15089. var me = this, attr = me.attr, series = me.getSeries(), surface = me.getSurface(), items = me.boundMarkers.items, matrix = attr.matrix, dataX = attr.dataX, dataY = attr.dataY, selectionTolerance = attr.selectionTolerance, minDistance = Infinity, index = -1, result = null, distance, dx, dy, xy, i, ln, end, inc, bbox;
  15090. if (items) {
  15091. ln = dataX.length;
  15092. if (series.reversedSpriteZOrder) {
  15093. i = ln - 1;
  15094. end = -1;
  15095. inc = -1;
  15096. } else {
  15097. i = 0;
  15098. end = ln;
  15099. inc = 1;
  15100. }
  15101. for (; i !== end; i += inc) {
  15102. bbox = me.getMarkerBBox('items', i);
  15103. xy = surface.inverseMatrix.transformPoint([x, y]);
  15104. if (Ext.draw.Draw.isPointInBBox(xy[0], xy[1], bbox)) {
  15105. index = i;
  15106. minDistance = 0;
  15107. break;
  15108. }
  15109. }
  15110. } else {
  15111. for (i = 0, ln = dataX.length; i < ln; i++) {
  15112. xy = matrix.transformPoint([dataX[i], dataY[i]]);
  15113. xy = surface.matrix.transformPoint(xy);
  15114. dx = x - xy[0];
  15115. dy = y - xy[1];
  15116. distance = Math.sqrt(dx * dx + dy * dy);
  15117. if (selectionTolerance && distance > selectionTolerance) {
  15118. continue;
  15119. }
  15120. if (distance < minDistance) {
  15121. minDistance = distance;
  15122. index = i;
  15123. }
  15124. }
  15125. }
  15126. if (index > -1) {
  15127. result = {index:index, distance:minDistance};
  15128. }
  15129. return result;
  15130. }});
  15131. Ext.define('Ext.chart.series.sprite.StackedCartesian', {extend:'Ext.chart.series.sprite.Cartesian', inheritableStatics:{def:{processors:{groupCount:'number', groupOffset:'number', dataStartY:'data'}, defaults:{selectionTolerance:20, groupCount:1, groupOffset:0, dataStartY:null}, triggers:{dataStartY:'dataY,bbox'}}}});
  15132. Ext.define('Ext.chart.series.sprite.Area', {alias:'sprite.areaSeries', extend:'Ext.chart.series.sprite.StackedCartesian', inheritableStatics:{def:{processors:{step:'bool'}, defaults:{selectionTolerance:0, step:false}}}, renderClipped:function(surface, ctx, dataClipRect) {
  15133. var me = this, store = me.getStore(), series = me.getSeries(), attr = me.attr, dataX = attr.dataX, dataY = attr.dataY, dataStartY = attr.dataStartY, matrix = attr.matrix, x, y, i, lastX, lastY, startX, startY, xx = matrix.elements[0], dx = matrix.elements[4], yy = matrix.elements[3], dy = matrix.elements[5], surfaceMatrix = me.surfaceMatrix, markerCfg = {}, min = Math.min(dataClipRect[0], dataClipRect[2]), max = Math.max(dataClipRect[0], dataClipRect[2]), start = Math.max(0, this.binarySearch(min)),
  15134. end = Math.min(dataX.length - 1, this.binarySearch(max) + 1), renderer = attr.renderer, rendererData = {store:store}, rendererChanges;
  15135. ctx.beginPath();
  15136. startX = dataX[start] * xx + dx;
  15137. startY = dataY[start] * yy + dy;
  15138. ctx.moveTo(startX, startY);
  15139. if (attr.step) {
  15140. lastY = startY;
  15141. for (i = start; i <= end; i++) {
  15142. x = dataX[i] * xx + dx;
  15143. y = dataY[i] * yy + dy;
  15144. ctx.lineTo(x, lastY);
  15145. ctx.lineTo(x, lastY = y);
  15146. }
  15147. } else {
  15148. for (i = start; i <= end; i++) {
  15149. x = dataX[i] * xx + dx;
  15150. y = dataY[i] * yy + dy;
  15151. ctx.lineTo(x, y);
  15152. }
  15153. }
  15154. if (dataStartY) {
  15155. if (attr.step) {
  15156. lastX = dataX[end] * xx + dx;
  15157. for (i = end; i >= start; i--) {
  15158. x = dataX[i] * xx + dx;
  15159. y = dataStartY[i] * yy + dy;
  15160. ctx.lineTo(lastX, y);
  15161. ctx.lineTo(lastX = x, y);
  15162. }
  15163. } else {
  15164. for (i = end; i >= start; i--) {
  15165. x = dataX[i] * xx + dx;
  15166. y = dataStartY[i] * yy + dy;
  15167. ctx.lineTo(x, y);
  15168. }
  15169. }
  15170. } else {
  15171. ctx.lineTo(dataX[end] * xx + dx, y);
  15172. ctx.lineTo(dataX[end] * xx + dx, dy);
  15173. ctx.lineTo(startX, dy);
  15174. ctx.lineTo(startX, dataY[i] * yy + dy);
  15175. }
  15176. if (attr.transformFillStroke) {
  15177. attr.matrix.toContext(ctx);
  15178. }
  15179. ctx.fill();
  15180. if (attr.transformFillStroke) {
  15181. attr.inverseMatrix.toContext(ctx);
  15182. }
  15183. ctx.beginPath();
  15184. ctx.moveTo(startX, startY);
  15185. if (attr.step) {
  15186. for (i = start; i <= end; i++) {
  15187. x = dataX[i] * xx + dx;
  15188. y = dataY[i] * yy + dy;
  15189. ctx.lineTo(x, lastY);
  15190. ctx.lineTo(x, lastY = y);
  15191. markerCfg.translationX = surfaceMatrix.x(x, y);
  15192. markerCfg.translationY = surfaceMatrix.y(x, y);
  15193. if (renderer) {
  15194. rendererChanges = Ext.callback(renderer, null, [me, markerCfg, rendererData, i], 0, series);
  15195. Ext.apply(markerCfg, rendererChanges);
  15196. }
  15197. me.putMarker('markers', markerCfg, i, !renderer);
  15198. }
  15199. } else {
  15200. for (i = start; i <= end; i++) {
  15201. x = dataX[i] * xx + dx;
  15202. y = dataY[i] * yy + dy;
  15203. ctx.lineTo(x, y);
  15204. markerCfg.translationX = surfaceMatrix.x(x, y);
  15205. markerCfg.translationY = surfaceMatrix.y(x, y);
  15206. if (renderer) {
  15207. rendererChanges = Ext.callback(renderer, null, [me, markerCfg, rendererData, i], 0, series);
  15208. Ext.apply(markerCfg, rendererChanges);
  15209. }
  15210. me.putMarker('markers', markerCfg, i, !renderer);
  15211. }
  15212. }
  15213. if (attr.transformFillStroke) {
  15214. attr.matrix.toContext(ctx);
  15215. }
  15216. ctx.stroke();
  15217. }});
  15218. Ext.define('Ext.chart.series.Area', {extend:'Ext.chart.series.StackedCartesian', alias:'series.area', type:'area', seriesType:'areaSeries', isArea:true, requires:['Ext.chart.series.sprite.Area'], config:{splitStacks:false}});
  15219. Ext.define('Ext.chart.series.sprite.Bar', {alias:'sprite.barSeries', extend:'Ext.chart.series.sprite.StackedCartesian', inheritableStatics:{def:{processors:{minBarWidth:'number', maxBarWidth:'number', minGapWidth:'number', radius:'number', inGroupGapWidth:'number'}, defaults:{minBarWidth:2, maxBarWidth:100, minGapWidth:5, inGroupGapWidth:3, radius:0}}}, drawLabel:function(text, dataX, dataStartY, dataY, labelId, sClipRect) {
  15220. var me = this, attr = me.attr, label = me.getMarker('labels'), labelTpl = label.getTemplate(), labelCfg = me.labelCfg || (me.labelCfg = {}), surfaceMatrix = me.surfaceMatrix, labelOverflowPadding = attr.labelOverflowPadding, labelDisplay = labelTpl.attr.display, labelOrientation = labelTpl.attr.orientation, isVerticalText = labelOrientation === 'horizontal' && attr.flipXY || labelOrientation === 'vertical' && !attr.flipXY || !labelOrientation, calloutLine = labelTpl.getCalloutLine(), labelY, halfText,
  15221. labelBBox, calloutLineLength, changes, hasPendingChanges, params, paddingOffset, calloutInfo;
  15222. labelCfg.x = surfaceMatrix.x(dataX, dataY);
  15223. labelCfg.y = surfaceMatrix.y(dataX, dataY);
  15224. if (calloutLine) {
  15225. calloutLineLength = calloutLine.length;
  15226. } else {
  15227. calloutLineLength = 0;
  15228. }
  15229. if (!attr.flipXY) {
  15230. labelCfg.rotationRads = -Math.PI * 0.5;
  15231. } else {
  15232. labelCfg.rotationRads = 0;
  15233. }
  15234. labelCfg.calloutVertical = !attr.flipXY;
  15235. switch(labelOrientation) {
  15236. case 'horizontal':
  15237. labelCfg.rotationRads = 0;
  15238. labelCfg.calloutVertical = false;
  15239. break;
  15240. case 'vertical':
  15241. labelCfg.rotationRads = -Math.PI * 0.5;
  15242. labelCfg.calloutVertical = true;
  15243. break;
  15244. }
  15245. labelCfg.text = text;
  15246. if (labelTpl.attr.renderer) {
  15247. if (!label.get(labelId)) {
  15248. label.putMarkerFor('labels', {}, labelId);
  15249. }
  15250. params = [text, label, labelCfg, {store:me.getStore()}, labelId];
  15251. changes = Ext.callback(labelTpl.attr.renderer, null, params, 0, me.getSeries());
  15252. if (typeof changes === 'string') {
  15253. labelCfg.text = changes;
  15254. } else {
  15255. if (typeof changes === 'object') {
  15256. if ('text' in changes) {
  15257. labelCfg.text = changes.text;
  15258. }
  15259. hasPendingChanges = true;
  15260. }
  15261. }
  15262. }
  15263. labelBBox = me.getMarkerBBox('labels', labelId, true);
  15264. if (!labelBBox) {
  15265. me.putMarker('labels', labelCfg, labelId);
  15266. labelBBox = me.getMarkerBBox('labels', labelId, true);
  15267. }
  15268. if (calloutLineLength > 0) {
  15269. halfText = calloutLineLength;
  15270. } else {
  15271. if (calloutLineLength === 0) {
  15272. halfText = (isVerticalText ? labelBBox.width : labelBBox.height) / 2;
  15273. } else {
  15274. halfText = (isVerticalText ? labelBBox.width : labelBBox.height) / 2 + labelOverflowPadding;
  15275. }
  15276. }
  15277. paddingOffset = labelOverflowPadding * 2;
  15278. if (dataStartY > dataY) {
  15279. halfText = -halfText;
  15280. paddingOffset = -paddingOffset;
  15281. }
  15282. if (isVerticalText) {
  15283. labelY = labelDisplay === 'insideStart' ? dataStartY + halfText : dataY - halfText;
  15284. } else {
  15285. labelY = labelDisplay === 'insideStart' ? dataStartY + paddingOffset : dataY - paddingOffset;
  15286. }
  15287. labelCfg.x = surfaceMatrix.x(dataX, labelY);
  15288. labelCfg.y = surfaceMatrix.y(dataX, labelY);
  15289. calloutInfo = this.getCalloutYPos(labelDisplay, dataStartY, dataY, halfText, sClipRect);
  15290. labelCfg.calloutStartX = surfaceMatrix.x(dataX, calloutInfo.start);
  15291. labelCfg.calloutStartY = surfaceMatrix.y(dataX, calloutInfo.start);
  15292. labelCfg.calloutPlaceX = surfaceMatrix.x(dataX, calloutInfo.place);
  15293. labelCfg.calloutPlaceY = surfaceMatrix.y(dataX, calloutInfo.place);
  15294. labelCfg.calloutColor = calloutLine && calloutLine.color || me.attr.fillStyle;
  15295. if (calloutLine) {
  15296. if (calloutLine.width) {
  15297. labelCfg.calloutWidth = calloutLine.width;
  15298. }
  15299. } else {
  15300. labelCfg.calloutColor = 'none';
  15301. }
  15302. labelCfg.callout = +(Math.abs(dataY - dataStartY) <= Math.abs(halfText * 2) || labelDisplay === 'outside');
  15303. if (hasPendingChanges) {
  15304. Ext.apply(labelCfg, changes);
  15305. }
  15306. me.putMarker('labels', labelCfg, labelId);
  15307. }, callOutObj:{start:0, place:0}, getCalloutYPos:function(display, startY, y, halfText, rect) {
  15308. var me = this, o = me.callOutObj, inside = display === 'insideStart', start = inside ? startY : y, place = inside ? startY - halfText : y + halfText, textSize = halfText * 2, placeText = place + textSize;
  15309. if (!me.fromSelf && !inside && (placeText <= rect[1] || placeText >= rect[3])) {
  15310. me.fromSelf = true;
  15311. o = me.getCalloutYPos('insideStart', startY, y, halfText, rect);
  15312. delete me.fromSelf;
  15313. } else {
  15314. o.start = start;
  15315. o.place = place;
  15316. }
  15317. return o;
  15318. }, drawBar:function(ctx, surface, rect, left, top, right, bottom, index) {
  15319. var me = this, itemCfg = {}, renderer = me.attr.renderer, changes;
  15320. itemCfg.x = left;
  15321. itemCfg.y = top;
  15322. itemCfg.width = right - left;
  15323. itemCfg.height = bottom - top;
  15324. itemCfg.radius = me.attr.radius;
  15325. if (renderer) {
  15326. changes = Ext.callback(renderer, null, [me, itemCfg, {store:me.getStore()}, index], 0, me.getSeries());
  15327. Ext.apply(itemCfg, changes);
  15328. }
  15329. me.putMarker('items', itemCfg, index, !renderer);
  15330. }, renderClipped:function(surface, ctx, dataClipRect, surfaceClipRect) {
  15331. if (this.cleanRedraw) {
  15332. return;
  15333. }
  15334. var me = this, attr = me.attr, dataX = attr.dataX, dataY = attr.dataY, dataText = attr.labels, dataStartY = attr.dataStartY, groupCount = attr.groupCount, groupOffset = attr.groupOffset - (groupCount - 1) * 0.5, inGroupGapWidth = attr.inGroupGapWidth, lineWidth = ctx.lineWidth, matrix = attr.matrix, xx = matrix.elements[0], yy = matrix.elements[3], dx = matrix.elements[4], dy = surface.roundPixel(matrix.elements[5]) - 1, maxBarWidth = Math.abs(xx) - attr.minGapWidth, minBarWidth = (Math.min(maxBarWidth,
  15335. attr.maxBarWidth) - inGroupGapWidth * (groupCount - 1)) / groupCount, barWidth = surface.roundPixel(Math.max(attr.minBarWidth, minBarWidth)), surfaceMatrix = me.surfaceMatrix, left, right, bottom, top, i, center, halfLineWidth = 0.5 * attr.lineWidth, min = Math.min(dataClipRect[0], dataClipRect[2]), max = Math.max(dataClipRect[0], dataClipRect[2]), start = Math.max(0, Math.floor(min)), end = Math.min(dataX.length - 1, Math.ceil(max)), isDrawLabels = dataText && me.getMarker('labels'), yLow, yHi;
  15336. for (i = start; i <= end; i++) {
  15337. yLow = dataStartY ? dataStartY[i] : 0;
  15338. yHi = dataY[i];
  15339. center = dataX[i] * xx + dx + groupOffset * (barWidth + inGroupGapWidth);
  15340. left = surface.roundPixel(center - barWidth / 2) + halfLineWidth;
  15341. top = surface.roundPixel(yHi * yy + dy + lineWidth);
  15342. right = surface.roundPixel(center + barWidth / 2) - halfLineWidth;
  15343. bottom = surface.roundPixel(yLow * yy + dy + lineWidth);
  15344. me.drawBar(ctx, surface, dataClipRect, left, top - halfLineWidth, right, bottom - halfLineWidth, i);
  15345. if (isDrawLabels && dataText[i] != null) {
  15346. me.drawLabel(dataText[i], center, bottom, top, i, surfaceClipRect);
  15347. }
  15348. me.putMarker('markers', {translationX:surfaceMatrix.x(center, top), translationY:surfaceMatrix.y(center, top)}, i, true);
  15349. }
  15350. }});
  15351. Ext.define('Ext.chart.series.Bar', {extend:'Ext.chart.series.StackedCartesian', alias:'series.bar', type:'bar', seriesType:'barSeries', isBar:true, requires:['Ext.chart.series.sprite.Bar', 'Ext.draw.sprite.Rect'], config:{itemInstancing:{type:'rect', animation:{customDurations:{x:0, y:0, width:0, height:0, radius:0}}}}, getItemForPoint:function(x, y) {
  15352. var chart, padding, isRtl;
  15353. if (this.getSprites().length) {
  15354. chart = this.getChart();
  15355. padding = chart.getInnerPadding();
  15356. isRtl = chart.getInherited().rtl;
  15357. arguments[0] = x + (isRtl ? padding.right : -padding.left);
  15358. arguments[1] = y + padding.bottom;
  15359. return this.callParent(arguments);
  15360. }
  15361. }, updateXAxis:function(xAxis) {
  15362. if (!this.is3D && !xAxis.isCategory) {
  15363. Ext.raise("'bar' series should be used with a 'category' axis. " + 'Please refer to the bar series docs.');
  15364. }
  15365. xAxis.setExpandRangeBy(0.5);
  15366. this.callParent(arguments);
  15367. }, updateHidden:function(hidden) {
  15368. this.callParent(arguments);
  15369. this.updateStacked();
  15370. }, updateStacked:function(stacked) {
  15371. var me = this, attributes = {}, sprites = me.getSprites(), spriteCount = sprites.length, visibleSprites = [], visibleSpriteCount, i;
  15372. for (i = 0; i < spriteCount; i++) {
  15373. if (!sprites[i].attr.hidden) {
  15374. visibleSprites.push(sprites[i]);
  15375. }
  15376. }
  15377. visibleSpriteCount = visibleSprites.length;
  15378. if (me.getStacked()) {
  15379. attributes.groupCount = 1;
  15380. attributes.groupOffset = 0;
  15381. for (i = 0; i < visibleSpriteCount; i++) {
  15382. visibleSprites[i].setAttributes(attributes);
  15383. }
  15384. } else {
  15385. attributes.groupCount = visibleSpriteCount;
  15386. for (i = 0; i < visibleSpriteCount; i++) {
  15387. attributes.groupOffset = i;
  15388. visibleSprites[i].setAttributes(attributes);
  15389. }
  15390. }
  15391. me.callParent(arguments);
  15392. }});
  15393. Ext.define('Ext.chart.series.sprite.Bar3D', {extend:'Ext.chart.series.sprite.Bar', alias:'sprite.bar3dSeries', requires:['Ext.draw.gradient.Linear'], inheritableStatics:{def:{processors:{depthWidthRatio:'number', saturationFactor:'number', brightnessFactor:'number', colorSpread:'number'}, defaults:{depthWidthRatio:1 / 3, saturationFactor:1, brightnessFactor:1, colorSpread:1, transformFillStroke:true}, triggers:{groupCount:'panzoom'}, updaters:{panzoom:function(attr) {
  15394. var me = this, dx = attr.visibleMaxX - attr.visibleMinX, dy = attr.visibleMaxY - attr.visibleMinY, innerWidth = attr.flipXY ? attr.innerHeight : attr.innerWidth, innerHeight = !attr.flipXY ? attr.innerHeight : attr.innerWidth, surface = me.getSurface(), isRtl = surface ? surface.getInherited().rtl : false;
  15395. if (isRtl && !attr.flipXY) {
  15396. attr.translationX = innerWidth + attr.visibleMinX * innerWidth / dx;
  15397. } else {
  15398. attr.translationX = -attr.visibleMinX * innerWidth / dx;
  15399. }
  15400. attr.translationY = -attr.visibleMinY * (innerHeight - me.depth) / dy;
  15401. attr.scalingX = (isRtl && !attr.flipXY ? -1 : 1) * innerWidth / dx;
  15402. attr.scalingY = (innerHeight - me.depth) / dy;
  15403. attr.scalingCenterX = 0;
  15404. attr.scalingCenterY = 0;
  15405. me.applyTransformations(true);
  15406. }}}}, config:{showStroke:false}, depth:0, drawBar:function(ctx, surface, clip, left, top, right, bottom, index) {
  15407. var me = this, attr = me.attr, itemCfg = {}, renderer = attr.renderer, changes, depth, series, params;
  15408. itemCfg.x = (left + right) * 0.5;
  15409. itemCfg.y = top;
  15410. itemCfg.width = (right - left) * 0.75;
  15411. itemCfg.height = bottom - top;
  15412. itemCfg.depth = depth = itemCfg.width * attr.depthWidthRatio;
  15413. itemCfg.orientation = attr.flipXY ? 'horizontal' : 'vertical';
  15414. itemCfg.saturationFactor = attr.saturationFactor;
  15415. itemCfg.brightnessFactor = attr.brightnessFactor;
  15416. itemCfg.colorSpread = attr.colorSpread;
  15417. if (depth !== me.depth) {
  15418. me.depth = depth;
  15419. series = me.getSeries();
  15420. series.fireEvent('depthchange', series, depth);
  15421. }
  15422. if (renderer) {
  15423. params = [me, itemCfg, {store:me.getStore()}, index];
  15424. changes = Ext.callback(renderer, null, params, 0, me.getSeries());
  15425. Ext.apply(itemCfg, changes);
  15426. }
  15427. me.putMarker('items', itemCfg, index, !renderer);
  15428. }});
  15429. Ext.define('Ext.chart.sprite.Bar3D', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.bar3d', type:'bar3d', inheritableStatics:{def:{processors:{x:'number', y:'number', width:'number', height:'number', depth:'number', orientation:'enums(vertical,horizontal)', showStroke:'bool', saturationFactor:'number', brightnessFactor:'number', colorSpread:'number'}, triggers:{x:'bbox', y:'bbox', width:'bbox', height:'bbox', depth:'bbox', orientation:'bbox'}, defaults:{x:0, y:0, width:8, height:8, depth:8, orientation:'vertical',
  15430. showStroke:false, saturationFactor:1, brightnessFactor:1, colorSpread:1, lineJoin:'bevel'}}}, constructor:function(config) {
  15431. this.callParent([config]);
  15432. this.topGradient = new Ext.draw.gradient.Linear({});
  15433. this.rightGradient = new Ext.draw.gradient.Linear({});
  15434. this.frontGradient = new Ext.draw.gradient.Linear({});
  15435. }, updatePlainBBox:function(plain) {
  15436. var attr = this.attr, x = attr.x, y = attr.y, width = attr.width, height = attr.height, depth = attr.depth;
  15437. plain.x = x - width * 0.5;
  15438. plain.width = width + depth;
  15439. if (height > 0) {
  15440. plain.y = y;
  15441. plain.height = height + depth;
  15442. } else {
  15443. plain.y = y + depth;
  15444. plain.height = height - depth;
  15445. }
  15446. }, render:function(surface, ctx) {
  15447. var me = this, attr = me.attr, center = attr.x, top = attr.y, bottom = top + attr.height, isNegative = top < bottom, halfWidth = attr.width * 0.5, depth = attr.depth, isHorizontal = attr.orientation === 'horizontal', isTransparent = attr.globalAlpha < 1, fillStyle = attr.fillStyle, color = Ext.util.Color.create(fillStyle.isGradient ? fillStyle.getStops()[0].color : fillStyle), saturationFactor = attr.saturationFactor, brightnessFactor = attr.brightnessFactor, colorSpread = attr.colorSpread, hsv =
  15448. color.getHSV(), bbox = {}, roundX, roundY, temp;
  15449. if (!attr.showStroke) {
  15450. ctx.strokeStyle = Ext.util.Color.RGBA_NONE;
  15451. }
  15452. if (isNegative) {
  15453. temp = top;
  15454. top = bottom;
  15455. bottom = temp;
  15456. }
  15457. me.topGradient.setDegrees(isHorizontal ? 0 : 80);
  15458. me.topGradient.setStops([{offset:0, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * saturationFactor, 0, 1), Ext.Number.constrain((0.5 + colorSpread * 0.1) * brightnessFactor, 0, 1))}, {offset:1, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * saturationFactor, 0, 1), Ext.Number.constrain((0.5 - colorSpread * 0.11) * brightnessFactor, 0, 1))}]);
  15459. me.rightGradient.setDegrees(isHorizontal ? 45 : 90);
  15460. me.rightGradient.setStops([{offset:0, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * saturationFactor, 0, 1), Ext.Number.constrain((0.5 - colorSpread * 0.14) * brightnessFactor, 0, 1))}, {offset:1, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * (1 + colorSpread * 0.4) * saturationFactor, 0, 1), Ext.Number.constrain((0.5 - colorSpread * 0.32) * brightnessFactor, 0, 1))}]);
  15461. if (isHorizontal) {
  15462. me.frontGradient.setDegrees(0);
  15463. } else {
  15464. me.frontGradient.setRadians(Math.atan2(top - bottom, halfWidth * 2));
  15465. }
  15466. me.frontGradient.setStops([{offset:0, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * (1 - colorSpread * 0.1) * saturationFactor, 0, 1), Ext.Number.constrain((0.5 + colorSpread * 0.1) * brightnessFactor, 0, 1))}, {offset:1, color:Ext.util.Color.fromHSV(hsv[0], Ext.Number.constrain(hsv[1] * (1 + colorSpread * 0.1) * saturationFactor, 0, 1), Ext.Number.constrain((0.5 - colorSpread * 0.23) * brightnessFactor, 0, 1))}]);
  15467. if (isTransparent || isNegative) {
  15468. ctx.beginPath();
  15469. ctx.moveTo(center - halfWidth, bottom);
  15470. ctx.lineTo(center - halfWidth + depth, bottom + depth);
  15471. ctx.lineTo(center + halfWidth + depth, bottom + depth);
  15472. ctx.lineTo(center + halfWidth, bottom);
  15473. ctx.closePath();
  15474. bbox.x = center - halfWidth;
  15475. bbox.y = top;
  15476. bbox.width = halfWidth + depth;
  15477. bbox.height = depth;
  15478. ctx.fillStyle = (isHorizontal ? me.rightGradient : me.topGradient).generateGradient(ctx, bbox);
  15479. ctx.fillStroke(attr);
  15480. }
  15481. if (isTransparent) {
  15482. ctx.beginPath();
  15483. ctx.moveTo(center - halfWidth, top);
  15484. ctx.lineTo(center - halfWidth + depth, top + depth);
  15485. ctx.lineTo(center - halfWidth + depth, bottom + depth);
  15486. ctx.lineTo(center - halfWidth, bottom);
  15487. ctx.closePath();
  15488. bbox.x = center + halfWidth;
  15489. bbox.y = bottom;
  15490. bbox.width = depth;
  15491. bbox.height = top + depth - bottom;
  15492. ctx.fillStyle = (isHorizontal ? me.topGradient : me.rightGradient).generateGradient(ctx, bbox);
  15493. ctx.fillStroke(attr);
  15494. }
  15495. roundY = surface.roundPixel(top);
  15496. ctx.beginPath();
  15497. ctx.moveTo(center - halfWidth, roundY);
  15498. ctx.lineTo(center - halfWidth + depth, top + depth);
  15499. ctx.lineTo(center + halfWidth + depth, top + depth);
  15500. ctx.lineTo(center + halfWidth, roundY);
  15501. ctx.closePath();
  15502. bbox.x = center - halfWidth;
  15503. bbox.y = top;
  15504. bbox.width = halfWidth + depth;
  15505. bbox.height = depth;
  15506. ctx.fillStyle = (isHorizontal ? me.rightGradient : me.topGradient).generateGradient(ctx, bbox);
  15507. ctx.fillStroke(attr);
  15508. roundX = surface.roundPixel(center + halfWidth);
  15509. ctx.beginPath();
  15510. ctx.moveTo(roundX, surface.roundPixel(top));
  15511. ctx.lineTo(center + halfWidth + depth, top + depth);
  15512. ctx.lineTo(center + halfWidth + depth, bottom + depth);
  15513. ctx.lineTo(roundX, bottom);
  15514. ctx.closePath();
  15515. bbox.x = center + halfWidth;
  15516. bbox.y = bottom;
  15517. bbox.width = depth;
  15518. bbox.height = top + depth - bottom;
  15519. ctx.fillStyle = (isHorizontal ? me.topGradient : me.rightGradient).generateGradient(ctx, bbox);
  15520. ctx.fillStroke(attr);
  15521. roundX = surface.roundPixel(center + halfWidth);
  15522. roundY = surface.roundPixel(top);
  15523. ctx.beginPath();
  15524. ctx.moveTo(center - halfWidth, bottom);
  15525. ctx.lineTo(center - halfWidth, roundY);
  15526. ctx.lineTo(roundX, roundY);
  15527. ctx.lineTo(roundX, bottom);
  15528. ctx.closePath();
  15529. bbox.x = center - halfWidth;
  15530. bbox.y = bottom;
  15531. bbox.width = halfWidth * 2;
  15532. bbox.height = top - bottom;
  15533. ctx.fillStyle = me.frontGradient.generateGradient(ctx, bbox);
  15534. ctx.fillStroke(attr);
  15535. }});
  15536. Ext.define('Ext.chart.series.Bar3D', {extend:'Ext.chart.series.Bar', requires:['Ext.chart.series.sprite.Bar3D', 'Ext.chart.sprite.Bar3D'], alias:'series.bar3d', type:'bar3d', seriesType:'bar3dSeries', is3D:true, config:{itemInstancing:{type:'bar3d', animation:{customDurations:{x:0, y:0, width:0, height:0, depth:0}}}, highlightCfg:{opacity:0.8}}, reversedSpriteZOrder:false, updateXAxis:function(xAxis, oldXAxis) {
  15537. if (xAxis.type !== 'category3d') {
  15538. Ext.raise("'bar3d' series should be used with a 'category3d' axis." + " Please refer to the 'bar3d' series docs.");
  15539. }
  15540. this.callParent([xAxis, oldXAxis]);
  15541. }, getDepth:function() {
  15542. var sprite = this.getSprites()[0];
  15543. return sprite ? sprite.depth || 0 : 0;
  15544. }});
  15545. Ext.define('Ext.chart.series.sprite.BoxPlot', {alias:'sprite.boxplotSeries', extend:'Ext.chart.series.sprite.Cartesian', inheritableStatics:{def:{processors:{dataLow:'data', dataQ1:'data', dataQ3:'data', dataHigh:'data', minBoxWidth:'number', maxBoxWidth:'number', minGapWidth:'number'}, aliases:{dataMedian:'dataY'}, defaults:{minBoxWidth:2, maxBoxWidth:40, minGapWidth:5}}}, renderClipped:function(surface, ctx, dataClipRect) {
  15546. if (this.cleanRedraw) {
  15547. return;
  15548. }
  15549. var me = this, attr = me.attr, series = me.getSeries(), renderer = attr.renderer, rendererData = {store:me.getStore()}, itemCfg = {}, dataX = attr.dataX, dataLow = attr.dataLow, dataQ1 = attr.dataQ1, dataMedian = attr.dataY, dataQ3 = attr.dataQ3, dataHigh = attr.dataHigh, min = Math.min(dataClipRect[0], dataClipRect[2]), max = Math.max(dataClipRect[0], dataClipRect[2]), start = Math.max(0, Math.floor(min)), end = Math.min(dataX.length - 1, Math.ceil(max)), matrix = attr.matrix, xx = matrix.elements[0],
  15550. yy = matrix.elements[3], dx = matrix.elements[4], dy = matrix.elements[5], maxBoxWidth = Math.abs(xx) - attr.minGapWidth, minBoxWidth = Math.min(maxBoxWidth, attr.maxBoxWidth), boxWidth = Math.round(Math.max(attr.minBoxWidth, minBoxWidth)), x, low, q1, median, q3, high, rendererParams, changes, i;
  15551. if (renderer) {
  15552. rendererParams = [me, itemCfg, rendererData];
  15553. }
  15554. for (i = start; i <= end; i++) {
  15555. x = dataX[i] * xx + dx;
  15556. low = dataLow[i] * yy + dy;
  15557. q1 = dataQ1[i] * yy + dy;
  15558. median = dataMedian[i] * yy + dy;
  15559. q3 = dataQ3[i] * yy + dy;
  15560. high = dataHigh[i] * yy + dy;
  15561. itemCfg.x = x;
  15562. itemCfg.low = low;
  15563. itemCfg.q1 = q1;
  15564. itemCfg.median = median;
  15565. itemCfg.q3 = q3;
  15566. itemCfg.high = high;
  15567. itemCfg.boxWidth = boxWidth;
  15568. if (renderer) {
  15569. rendererParams[3] = i;
  15570. changes = Ext.callback(renderer, null, rendererParams, 0, series);
  15571. Ext.apply(itemCfg, changes);
  15572. }
  15573. me.putMarker('items', itemCfg, i, !renderer);
  15574. }
  15575. }});
  15576. Ext.define('Ext.chart.sprite.BoxPlot', {extend:'Ext.draw.sprite.Sprite', alias:'sprite.boxplot', type:'boxplot', inheritableStatics:{def:{processors:{x:'number', low:'number', q1:'number', median:'number', q3:'number', high:'number', boxWidth:'number', whiskerWidth:'number', crisp:'bool'}, triggers:{x:'bbox', low:'bbox', high:'bbox', boxWidth:'bbox', whiskerWidth:'bbox', crisp:'bbox'}, defaults:{x:0, low:-20, q1:-10, median:0, q3:10, high:20, boxWidth:12, whiskerWidth:0.5, crisp:true, fillStyle:'#ccc',
  15577. strokeStyle:'#000'}}}, updatePlainBBox:function(plain) {
  15578. var me = this, attr = me.attr, halfLineWidth = attr.lineWidth / 2, x = attr.x - attr.boxWidth / 2 - halfLineWidth, y = attr.high - halfLineWidth, width = attr.boxWidth + attr.lineWidth, height = attr.low - attr.high + attr.lineWidth;
  15579. plain.x = x;
  15580. plain.y = y;
  15581. plain.width = width;
  15582. plain.height = height;
  15583. }, render:function(surface, ctx) {
  15584. var me = this, attr = me.attr;
  15585. attr.matrix.toContext(ctx);
  15586. if (attr.crisp) {
  15587. me.crispRender(surface, ctx);
  15588. } else {
  15589. me.softRender(surface, ctx);
  15590. }
  15591. var debug = attr.debug || this.statics().debug || Ext.draw.sprite.Sprite.debug;
  15592. if (debug) {
  15593. this.attr.inverseMatrix.toContext(ctx);
  15594. if (debug.bbox) {
  15595. this.renderBBox(surface, ctx);
  15596. }
  15597. }
  15598. }, softRender:function(surface, ctx) {
  15599. var me = this, attr = me.attr, x = attr.x, low = attr.low, q1 = attr.q1, median = attr.median, q3 = attr.q3, high = attr.high, halfBoxWidth = attr.boxWidth / 2, halfWhiskerWidth = attr.boxWidth * attr.whiskerWidth / 2, dash = ctx.getLineDash();
  15600. ctx.setLineDash([]);
  15601. ctx.beginPath();
  15602. ctx.moveTo(x - halfBoxWidth, q3);
  15603. ctx.lineTo(x + halfBoxWidth, q3);
  15604. ctx.lineTo(x + halfBoxWidth, q1);
  15605. ctx.lineTo(x - halfBoxWidth, q1);
  15606. ctx.closePath();
  15607. ctx.fillStroke(attr, true);
  15608. ctx.setLineDash(dash);
  15609. ctx.beginPath();
  15610. ctx.moveTo(x, q3);
  15611. ctx.lineTo(x, high);
  15612. ctx.moveTo(x, q1);
  15613. ctx.lineTo(x, low);
  15614. ctx.stroke();
  15615. ctx.setLineDash([]);
  15616. ctx.beginPath();
  15617. ctx.moveTo(x - halfWhiskerWidth, low);
  15618. ctx.lineTo(x + halfWhiskerWidth, low);
  15619. ctx.moveTo(x - halfBoxWidth, median);
  15620. ctx.lineTo(x + halfBoxWidth, median);
  15621. ctx.moveTo(x - halfWhiskerWidth, high);
  15622. ctx.lineTo(x + halfWhiskerWidth, high);
  15623. ctx.stroke();
  15624. }, alignLine:function(x, lineWidth) {
  15625. lineWidth = lineWidth || this.attr.lineWidth;
  15626. x = Math.round(x);
  15627. if (lineWidth % 2 === 1) {
  15628. x -= 0.5;
  15629. }
  15630. return x;
  15631. }, crispRender:function(surface, ctx) {
  15632. var me = this, attr = me.attr, x = attr.x, low = me.alignLine(attr.low), q1 = me.alignLine(attr.q1), median = me.alignLine(attr.median), q3 = me.alignLine(attr.q3), high = me.alignLine(attr.high), halfBoxWidth = attr.boxWidth / 2, halfWhiskerWidth = attr.boxWidth * attr.whiskerWidth / 2, stemX = me.alignLine(x), boxLeft = me.alignLine(x - halfBoxWidth), boxRight = me.alignLine(x + halfBoxWidth), whiskerLeft = stemX + Math.round(-halfWhiskerWidth), whiskerRight = stemX + Math.round(halfWhiskerWidth),
  15633. dash = ctx.getLineDash();
  15634. ctx.setLineDash([]);
  15635. ctx.beginPath();
  15636. ctx.moveTo(boxLeft, q3);
  15637. ctx.lineTo(boxRight, q3);
  15638. ctx.lineTo(boxRight, q1);
  15639. ctx.lineTo(boxLeft, q1);
  15640. ctx.closePath();
  15641. ctx.fillStroke(attr, true);
  15642. ctx.setLineDash(dash);
  15643. ctx.beginPath();
  15644. ctx.moveTo(stemX, q3);
  15645. ctx.lineTo(stemX, high);
  15646. ctx.moveTo(stemX, q1);
  15647. ctx.lineTo(stemX, low);
  15648. ctx.stroke();
  15649. ctx.setLineDash([]);
  15650. ctx.beginPath();
  15651. ctx.moveTo(whiskerLeft, low);
  15652. ctx.lineTo(whiskerRight, low);
  15653. ctx.moveTo(boxLeft, median);
  15654. ctx.lineTo(boxRight, median);
  15655. ctx.moveTo(whiskerLeft, high);
  15656. ctx.lineTo(whiskerRight, high);
  15657. ctx.stroke();
  15658. }});
  15659. Ext.define('Ext.chart.series.BoxPlot', {extend:'Ext.chart.series.Cartesian', alias:'series.boxplot', type:'boxplot', seriesType:'boxplotSeries', isBoxPlot:true, requires:['Ext.chart.series.sprite.BoxPlot', 'Ext.chart.sprite.BoxPlot'], config:{itemInstancing:{type:'boxplot', animation:{customDurations:{x:0, low:0, q1:0, median:0, q3:0, high:0}}}, lowField:'low', q1Field:'q1', medianField:'median', q3Field:'q3', highField:'high'}, fieldCategoryY:['Low', 'Q1', 'Median', 'Q3', 'High'], updateXAxis:function(xAxis) {
  15660. xAxis.setExpandRangeBy(0.5);
  15661. this.callParent(arguments);
  15662. }});
  15663. Ext.define('Ext.draw.LimitedCache', {config:{limit:40, feeder:function() {
  15664. return 0;
  15665. }, scope:null}, cache:null, constructor:function(config) {
  15666. this.cache = {};
  15667. this.cache.list = [];
  15668. this.cache.tail = 0;
  15669. this.initConfig(config);
  15670. }, get:function(id) {
  15671. var cache = this.cache, limit = this.getLimit(), feeder = this.getFeeder(), scope = this.getScope() || this;
  15672. if (cache[id]) {
  15673. return cache[id].value;
  15674. }
  15675. if (cache.list[cache.tail]) {
  15676. delete cache[cache.list[cache.tail].cacheId];
  15677. }
  15678. cache[id] = cache.list[cache.tail] = {value:feeder.apply(scope, Array.prototype.slice.call(arguments, 1)), cacheId:id};
  15679. cache.tail++;
  15680. if (cache.tail === limit) {
  15681. cache.tail = 0;
  15682. }
  15683. return cache[id].value;
  15684. }, clear:function() {
  15685. this.cache = {};
  15686. this.cache.list = [];
  15687. this.cache.tail = 0;
  15688. }});
  15689. Ext.define('Ext.draw.SegmentTree', {config:{strategy:'double'}, time:function(result, last, dataX, dataOpen, dataHigh, dataLow, dataClose) {
  15690. var start = 0, lastOffset, lastOffsetEnd, minimum = new Date(dataX[result.startIdx[0]]), maximum = new Date(dataX[result.endIdx[last - 1]]), extDate = Ext.Date, units = [[extDate.MILLI, 1, 'ms1', null], [extDate.MILLI, 2, 'ms2', 'ms1'], [extDate.MILLI, 5, 'ms5', 'ms1'], [extDate.MILLI, 10, 'ms10', 'ms5'], [extDate.MILLI, 50, 'ms50', 'ms10'], [extDate.MILLI, 100, 'ms100', 'ms50'], [extDate.MILLI, 500, 'ms500', 'ms100'], [extDate.SECOND, 1, 's1', 'ms500'], [extDate.SECOND, 10, 's10', 's1'], [extDate.SECOND,
  15691. 30, 's30', 's10'], [extDate.MINUTE, 1, 'mi1', 's10'], [extDate.MINUTE, 5, 'mi5', 'mi1'], [extDate.MINUTE, 10, 'mi10', 'mi5'], [extDate.MINUTE, 30, 'mi30', 'mi10'], [extDate.HOUR, 1, 'h1', 'mi30'], [extDate.HOUR, 6, 'h6', 'h1'], [extDate.HOUR, 12, 'h12', 'h6'], [extDate.DAY, 1, 'd1', 'h12'], [extDate.DAY, 7, 'd7', 'd1'], [extDate.MONTH, 1, 'mo1', 'd1'], [extDate.MONTH, 3, 'mo3', 'mo1'], [extDate.MONTH, 6, 'mo6', 'mo3'], [extDate.YEAR, 1, 'y1', 'mo3'], [extDate.YEAR, 5, 'y5', 'y1'], [extDate.YEAR,
  15692. 10, 'y10', 'y5'], [extDate.YEAR, 100, 'y100', 'y10']], unitIdx, currentUnit, plainStart = start, plainEnd = last, startIdxs = result.startIdx, endIdxs = result.endIdx, minIdxs = result.minIdx, maxIdxs = result.maxIdx, opens = result.open, closes = result.close, minXs = result.minX, minYs = result.minY, maxXs = result.maxX, maxYs = result.maxY, i, current;
  15693. for (unitIdx = 0; last > start + 1 && unitIdx < units.length; unitIdx++) {
  15694. minimum = new Date(dataX[startIdxs[0]]);
  15695. currentUnit = units[unitIdx];
  15696. minimum = extDate.align(minimum, currentUnit[0], currentUnit[1]);
  15697. if (extDate.diff(minimum, maximum, currentUnit[0]) > dataX.length * 2 * currentUnit[1]) {
  15698. continue;
  15699. }
  15700. if (currentUnit[3] && result.map['time_' + currentUnit[3]]) {
  15701. lastOffset = result.map['time_' + currentUnit[3]][0];
  15702. lastOffsetEnd = result.map['time_' + currentUnit[3]][1];
  15703. } else {
  15704. lastOffset = plainStart;
  15705. lastOffsetEnd = plainEnd;
  15706. }
  15707. start = last;
  15708. current = minimum;
  15709. startIdxs[last] = startIdxs[lastOffset];
  15710. endIdxs[last] = endIdxs[lastOffset];
  15711. minIdxs[last] = minIdxs[lastOffset];
  15712. maxIdxs[last] = maxIdxs[lastOffset];
  15713. opens[last] = opens[lastOffset];
  15714. closes[last] = closes[lastOffset];
  15715. minXs[last] = minXs[lastOffset];
  15716. minYs[last] = minYs[lastOffset];
  15717. maxXs[last] = maxXs[lastOffset];
  15718. maxYs[last] = maxYs[lastOffset];
  15719. current = Ext.Date.add(current, currentUnit[0], currentUnit[1]);
  15720. for (i = lastOffset + 1; i < lastOffsetEnd; i++) {
  15721. if (dataX[endIdxs[i]] < +current) {
  15722. endIdxs[last] = endIdxs[i];
  15723. closes[last] = closes[i];
  15724. if (maxYs[i] > maxYs[last]) {
  15725. maxYs[last] = maxYs[i];
  15726. maxXs[last] = maxXs[i];
  15727. maxIdxs[last] = maxIdxs[i];
  15728. }
  15729. if (minYs[i] < minYs[last]) {
  15730. minYs[last] = minYs[i];
  15731. minXs[last] = minXs[i];
  15732. minIdxs[last] = minIdxs[i];
  15733. }
  15734. } else {
  15735. last++;
  15736. startIdxs[last] = startIdxs[i];
  15737. endIdxs[last] = endIdxs[i];
  15738. minIdxs[last] = minIdxs[i];
  15739. maxIdxs[last] = maxIdxs[i];
  15740. opens[last] = opens[i];
  15741. closes[last] = closes[i];
  15742. minXs[last] = minXs[i];
  15743. minYs[last] = minYs[i];
  15744. maxXs[last] = maxXs[i];
  15745. maxYs[last] = maxYs[i];
  15746. current = Ext.Date.add(current, currentUnit[0], currentUnit[1]);
  15747. }
  15748. }
  15749. if (last > start) {
  15750. result.map['time_' + currentUnit[2]] = [start, last];
  15751. }
  15752. }
  15753. }, 'double':function(result, position, dataX, dataOpen, dataHigh, dataLow, dataClose) {
  15754. var offset = 0, lastOffset, step = 1, i, startIdx, endIdx, minIdx, maxIdx, open, close, minX, minY, maxX, maxY;
  15755. while (position > offset + 1) {
  15756. lastOffset = offset;
  15757. offset = position;
  15758. step += step;
  15759. for (i = lastOffset; i < offset; i += 2) {
  15760. if (i === offset - 1) {
  15761. startIdx = result.startIdx[i];
  15762. endIdx = result.endIdx[i];
  15763. minIdx = result.minIdx[i];
  15764. maxIdx = result.maxIdx[i];
  15765. open = result.open[i];
  15766. close = result.close[i];
  15767. minX = result.minX[i];
  15768. minY = result.minY[i];
  15769. maxX = result.maxX[i];
  15770. maxY = result.maxY[i];
  15771. } else {
  15772. startIdx = result.startIdx[i];
  15773. endIdx = result.endIdx[i + 1];
  15774. open = result.open[i];
  15775. close = result.close[i];
  15776. if (result.minY[i] <= result.minY[i + 1]) {
  15777. minIdx = result.minIdx[i];
  15778. minX = result.minX[i];
  15779. minY = result.minY[i];
  15780. } else {
  15781. minIdx = result.minIdx[i + 1];
  15782. minX = result.minX[i + 1];
  15783. minY = result.minY[i + 1];
  15784. }
  15785. if (result.maxY[i] >= result.maxY[i + 1]) {
  15786. maxIdx = result.maxIdx[i];
  15787. maxX = result.maxX[i];
  15788. maxY = result.maxY[i];
  15789. } else {
  15790. maxIdx = result.maxIdx[i + 1];
  15791. maxX = result.maxX[i + 1];
  15792. maxY = result.maxY[i + 1];
  15793. }
  15794. }
  15795. result.startIdx[position] = startIdx;
  15796. result.endIdx[position] = endIdx;
  15797. result.minIdx[position] = minIdx;
  15798. result.maxIdx[position] = maxIdx;
  15799. result.open[position] = open;
  15800. result.close[position] = close;
  15801. result.minX[position] = minX;
  15802. result.minY[position] = minY;
  15803. result.maxX[position] = maxX;
  15804. result.maxY[position] = maxY;
  15805. position++;
  15806. }
  15807. result.map['double_' + step] = [offset, position];
  15808. }
  15809. }, none:Ext.emptyFn, aggregateData:function(dataX, dataOpen, dataHigh, dataLow, dataClose) {
  15810. var length = dataX.length, startIdx = [], endIdx = [], minIdx = [], maxIdx = [], open = [], minX = [], minY = [], maxX = [], maxY = [], close = [], result = {startIdx:startIdx, endIdx:endIdx, minIdx:minIdx, maxIdx:maxIdx, open:open, minX:minX, minY:minY, maxX:maxX, maxY:maxY, close:close}, minValue = Infinity, maxValue = -Infinity, i, v;
  15811. for (i = 0; i < length; i++) {
  15812. v = dataX[i];
  15813. startIdx[i] = i;
  15814. endIdx[i] = i;
  15815. minIdx[i] = i;
  15816. maxIdx[i] = i;
  15817. open[i] = dataOpen[i];
  15818. minX[i] = v;
  15819. minY[i] = dataLow[i];
  15820. maxX[i] = v;
  15821. maxY[i] = dataHigh[i];
  15822. close[i] = dataClose[i];
  15823. if (v < minValue) {
  15824. minValue = v;
  15825. }
  15826. if (v > maxValue) {
  15827. maxValue = v;
  15828. }
  15829. }
  15830. result.map = {original:[0, length]};
  15831. result.range = Math.abs(maxValue - minValue);
  15832. if (length) {
  15833. this[this.getStrategy()](result, length, dataX, dataOpen, dataHigh, dataLow, dataClose);
  15834. }
  15835. return result;
  15836. }, binarySearch:function(items, start, end, key, isMin) {
  15837. var dx = this.dataX, mid, val;
  15838. if (key <= dx[items[0]]) {
  15839. return start;
  15840. }
  15841. if (key >= dx[items[end - 1]]) {
  15842. return end - 1;
  15843. }
  15844. while (start + 1 < end) {
  15845. mid = start + end >> 1;
  15846. val = dx[items[mid]];
  15847. if (val === key) {
  15848. return mid;
  15849. } else {
  15850. if (val < key) {
  15851. start = mid;
  15852. } else {
  15853. end = mid;
  15854. }
  15855. }
  15856. }
  15857. return isMin ? start : end;
  15858. }, constructor:function(config) {
  15859. this.initConfig(config);
  15860. }, setData:function(dataX, dataOpen, dataHigh, dataLow, dataClose) {
  15861. if (!dataHigh) {
  15862. dataClose = dataLow = dataHigh = dataOpen;
  15863. }
  15864. this.dataX = dataX;
  15865. this.dataOpen = dataOpen;
  15866. this.dataHigh = dataHigh;
  15867. this.dataLow = dataLow;
  15868. this.dataClose = dataClose;
  15869. if (dataX.length === dataHigh.length && dataX.length === dataLow.length) {
  15870. this.cache = this.aggregateData(dataX, dataOpen, dataHigh, dataLow, dataClose);
  15871. }
  15872. }, getAggregation:function(min, max, estStep) {
  15873. if (!this.cache) {
  15874. return null;
  15875. }
  15876. var minStep = Infinity, cache = this.cache, range = cache.range, cacheMap = cache.map, result = cacheMap.original, name, positions, ln, step, minIdx, maxIdx;
  15877. for (name in cacheMap) {
  15878. positions = cacheMap[name];
  15879. ln = positions[1] - positions[0] - 1;
  15880. if (ln === 0) {
  15881. continue;
  15882. }
  15883. step = range / ln;
  15884. if (estStep <= step && step < minStep) {
  15885. result = positions;
  15886. minStep = step;
  15887. }
  15888. }
  15889. minIdx = Math.max(this.binarySearch(cache.startIdx, result[0], result[1], min, true), result[0]);
  15890. maxIdx = Math.min(this.binarySearch(cache.endIdx, result[0], result[1], max, false) + 1, result[1]);
  15891. return {data:cache, start:minIdx, end:maxIdx};
  15892. }});
  15893. Ext.define('Ext.chart.series.sprite.Aggregative', {extend:'Ext.chart.series.sprite.Cartesian', requires:['Ext.draw.LimitedCache', 'Ext.draw.SegmentTree'], inheritableStatics:{def:{processors:{dataHigh:'data', dataLow:'data', dataClose:'data'}, aliases:{dataOpen:'dataY'}, defaults:{dataHigh:null, dataLow:null, dataClose:null}}}, config:{aggregator:{}}, applyAggregator:function(aggregator, oldAggr) {
  15894. return Ext.factory(aggregator, Ext.draw.SegmentTree, oldAggr);
  15895. }, constructor:function() {
  15896. this.callParent(arguments);
  15897. }, processDataY:function() {
  15898. var me = this, attr = me.attr, high = attr.dataHigh, low = attr.dataLow, close = attr.dataClose, open = attr.dataY, aggregator;
  15899. me.callParent(arguments);
  15900. if (attr.dataX && open && open.length > 0) {
  15901. aggregator = me.getAggregator();
  15902. if (high) {
  15903. aggregator.setData(attr.dataX, attr.dataY, high, low, close);
  15904. } else {
  15905. aggregator.setData(attr.dataX, attr.dataY);
  15906. }
  15907. }
  15908. }, getGapWidth:function() {
  15909. return 1;
  15910. }, renderClipped:function(surface, ctx, dataClipRect, surfaceClipRect) {
  15911. var me = this, min = Math.min(dataClipRect[0], dataClipRect[2]), max = Math.max(dataClipRect[0], dataClipRect[2]), aggregator = me.getAggregator(), aggregates = aggregator && aggregator.getAggregation(min, max, (max - min) / surfaceClipRect[2] * me.getGapWidth());
  15912. if (aggregates) {
  15913. me.dataStart = aggregates.data.startIdx[aggregates.start];
  15914. me.dataEnd = aggregates.data.endIdx[aggregates.end - 1];
  15915. me.renderAggregates(aggregates.data, aggregates.start, aggregates.end, surface, ctx, dataClipRect, surfaceClipRect);
  15916. }
  15917. }});
  15918. Ext.define('Ext.chart.series.sprite.CandleStick', {alias:'sprite.candlestickSeries', extend:'Ext.chart.series.sprite.Aggregative', inheritableStatics:{def:{processors:{raiseStyle:function(n, o) {
  15919. return Ext.merge({}, o || {}, n);
  15920. }, dropStyle:function(n, o) {
  15921. return Ext.merge({}, o || {}, n);
  15922. }, barWidth:'number', padding:'number', ohlcType:'enums(candlestick,ohlc)'}, defaults:{raiseStyle:{strokeStyle:'green', fillStyle:'green'}, dropStyle:{strokeStyle:'red', fillStyle:'red'}, barWidth:15, padding:3, lineJoin:'miter', miterLimit:5, ohlcType:'candlestick'}, triggers:{raiseStyle:'raiseStyle', dropStyle:'dropStyle'}, updaters:{raiseStyle:function() {
  15923. var me = this, tpl = me.raiseTemplate;
  15924. if (tpl) {
  15925. tpl.setAttributes(me.attr.raiseStyle);
  15926. }
  15927. }, dropStyle:function() {
  15928. var me = this, tpl = me.dropTemplate;
  15929. if (tpl) {
  15930. tpl.setAttributes(me.attr.dropStyle);
  15931. }
  15932. }}}}, candlestick:function(ctx, open, high, low, close, mid, halfWidth) {
  15933. var minOC = Math.min(open, close), maxOC = Math.max(open, close);
  15934. ctx.moveTo(mid, low);
  15935. ctx.lineTo(mid, minOC);
  15936. ctx.moveTo(mid + halfWidth, maxOC);
  15937. ctx.lineTo(mid + halfWidth, minOC);
  15938. ctx.lineTo(mid - halfWidth, minOC);
  15939. ctx.lineTo(mid - halfWidth, maxOC);
  15940. ctx.closePath();
  15941. ctx.moveTo(mid, high);
  15942. ctx.lineTo(mid, maxOC);
  15943. }, ohlc:function(ctx, open, high, low, close, mid, halfWidth) {
  15944. ctx.moveTo(mid, high);
  15945. ctx.lineTo(mid, low);
  15946. ctx.moveTo(mid, open);
  15947. ctx.lineTo(mid - halfWidth, open);
  15948. ctx.moveTo(mid, close);
  15949. ctx.lineTo(mid + halfWidth, close);
  15950. }, constructor:function() {
  15951. var me = this, Rect = Ext.draw.sprite.Rect;
  15952. me.callParent(arguments);
  15953. me.raiseTemplate = new Rect({parent:me});
  15954. me.dropTemplate = new Rect({parent:me});
  15955. }, getGapWidth:function() {
  15956. var attr = this.attr, barWidth = attr.barWidth, padding = attr.padding;
  15957. return barWidth + padding;
  15958. }, renderAggregates:function(aggregates, start, end, surface, ctx, clip) {
  15959. var me = this, attr = me.attr, ohlcType = attr.ohlcType, series = me.getSeries(), matrix = attr.matrix, xx = matrix.getXX(), yy = matrix.getYY(), dx = matrix.getDX(), dy = matrix.getDY(), halfWidth = Math.round(attr.barWidth * 0.5), dataX = attr.dataX, opens = aggregates.open, closes = aggregates.close, maxYs = aggregates.maxY, minYs = aggregates.minY, startIdxs = aggregates.startIdx, pixelAdjust = attr.lineWidth * surface.devicePixelRatio / 2, renderer = attr.renderer, rendererConfig = renderer &&
  15960. {}, rendererParams, rendererChanges, open, high, low, close, mid, i, template;
  15961. me.rendererData = me.rendererData || {store:me.getStore()};
  15962. pixelAdjust -= Math.floor(pixelAdjust);
  15963. ctx.save();
  15964. template = me.raiseTemplate;
  15965. template.useAttributes(ctx, clip);
  15966. if (!renderer) {
  15967. ctx.beginPath();
  15968. }
  15969. for (i = start; i < end; i++) {
  15970. if (opens[i] <= closes[i]) {
  15971. open = Math.round(opens[i] * yy + dy) + pixelAdjust;
  15972. high = Math.round(maxYs[i] * yy + dy) + pixelAdjust;
  15973. low = Math.round(minYs[i] * yy + dy) + pixelAdjust;
  15974. close = Math.round(closes[i] * yy + dy) + pixelAdjust;
  15975. mid = Math.round(dataX[startIdxs[i]] * xx + dx) + pixelAdjust;
  15976. if (renderer) {
  15977. ctx.save();
  15978. ctx.beginPath();
  15979. rendererConfig.open = open;
  15980. rendererConfig.high = high;
  15981. rendererConfig.low = low;
  15982. rendererConfig.close = close;
  15983. rendererConfig.mid = mid;
  15984. rendererConfig.halfWidth = halfWidth;
  15985. rendererParams = [me, rendererConfig, me.rendererData, i];
  15986. rendererChanges = Ext.callback(renderer, null, rendererParams, 0, series);
  15987. Ext.apply(ctx, rendererChanges);
  15988. }
  15989. me[ohlcType](ctx, open, high, low, close, mid, halfWidth);
  15990. if (renderer) {
  15991. ctx.fillStroke(template.attr);
  15992. ctx.restore();
  15993. }
  15994. }
  15995. }
  15996. if (!renderer) {
  15997. ctx.fillStroke(template.attr);
  15998. }
  15999. ctx.restore();
  16000. ctx.save();
  16001. template = me.dropTemplate;
  16002. template.useAttributes(ctx, clip);
  16003. if (!renderer) {
  16004. ctx.beginPath();
  16005. }
  16006. for (i = start; i < end; i++) {
  16007. if (opens[i] > closes[i]) {
  16008. open = Math.round(opens[i] * yy + dy) + pixelAdjust;
  16009. high = Math.round(maxYs[i] * yy + dy) + pixelAdjust;
  16010. low = Math.round(minYs[i] * yy + dy) + pixelAdjust;
  16011. close = Math.round(closes[i] * yy + dy) + pixelAdjust;
  16012. mid = Math.round(dataX[startIdxs[i]] * xx + dx) + pixelAdjust;
  16013. if (renderer) {
  16014. ctx.save();
  16015. ctx.beginPath();
  16016. rendererConfig.open = open;
  16017. rendererConfig.high = high;
  16018. rendererConfig.low = low;
  16019. rendererConfig.close = close;
  16020. rendererConfig.mid = mid;
  16021. rendererConfig.halfWidth = halfWidth;
  16022. rendererParams = [me, rendererConfig, me.rendererData, i];
  16023. rendererChanges = Ext.callback(renderer, null, rendererParams, 0, me.getSeries());
  16024. Ext.apply(ctx, rendererChanges);
  16025. }
  16026. me[ohlcType](ctx, open, high, low, close, mid, halfWidth);
  16027. if (renderer) {
  16028. ctx.fillStroke(template.attr);
  16029. ctx.restore();
  16030. }
  16031. }
  16032. }
  16033. if (!renderer) {
  16034. ctx.fillStroke(template.attr);
  16035. }
  16036. ctx.restore();
  16037. }});
  16038. Ext.define('Ext.chart.series.CandleStick', {extend:'Ext.chart.series.Cartesian', requires:['Ext.chart.series.sprite.CandleStick'], alias:'series.candlestick', type:'candlestick', seriesType:'candlestickSeries', isCandleStick:true, config:{openField:null, highField:null, lowField:null, closeField:null}, fieldCategoryY:['Open', 'High', 'Low', 'Close'], themeColorCount:function() {
  16039. return 2;
  16040. }});
  16041. Ext.define('Ext.chart.series.Polar', {extend:'Ext.chart.series.Series', config:{rotation:0, radius:null, center:[0, 0], offsetX:0, offsetY:0, showInLegend:true, xField:null, yField:null, angleField:null, radiusField:null, xAxis:null, yAxis:null}, directions:['X', 'Y'], fieldCategoryX:['X'], fieldCategoryY:['Y'], deprecatedConfigs:{field:'angleField', lengthField:'radiusField'}, constructor:function(config) {
  16042. var me = this, configurator = me.self.getConfigurator(), configs = configurator.configs, p;
  16043. if (config) {
  16044. for (p in me.deprecatedConfigs) {
  16045. if (p in config && !(config in configs)) {
  16046. Ext.raise("'" + p + "' config has been deprecated. Please use the '" + me.deprecatedConfigs[p] + "' config instead.");
  16047. }
  16048. }
  16049. }
  16050. me.callParent([config]);
  16051. }, getXField:function() {
  16052. return this.getAngleField();
  16053. }, updateXField:function(value) {
  16054. this.setAngleField(value);
  16055. }, getYField:function() {
  16056. return this.getRadiusField();
  16057. }, updateYField:function(value) {
  16058. this.setRadiusField(value);
  16059. }, applyXAxis:function(newAxis, oldAxis) {
  16060. return this.getChart().getAxis(newAxis) || oldAxis;
  16061. }, applyYAxis:function(newAxis, oldAxis) {
  16062. return this.getChart().getAxis(newAxis) || oldAxis;
  16063. }, getXRange:function() {
  16064. return [this.dataRange[0], this.dataRange[2]];
  16065. }, getYRange:function() {
  16066. return [this.dataRange[1], this.dataRange[3]];
  16067. }, themeColorCount:function() {
  16068. var me = this, store = me.getStore(), count = store && store.getCount() || 0;
  16069. return count;
  16070. }, isStoreDependantColorCount:true, getDefaultSpriteConfig:function() {
  16071. return {type:this.seriesType, renderer:this.getRenderer(), centerX:0, centerY:0, rotationCenterX:0, rotationCenterY:0};
  16072. }, applyRotation:function(rotation) {
  16073. return Ext.draw.sprite.AttributeParser.angle(Ext.draw.Draw.rad(rotation));
  16074. }, updateRotation:function(rotation) {
  16075. var sprites = this.getSprites();
  16076. if (sprites && sprites[0]) {
  16077. sprites[0].setAttributes({baseRotation:rotation});
  16078. }
  16079. }});
  16080. Ext.define('Ext.chart.series.Gauge', {alias:'series.gauge', extend:'Ext.chart.series.Polar', type:'gauge', seriesType:'pieslice', requires:['Ext.draw.sprite.Sector'], config:{needle:false, needleLength:90, needleWidth:4, donut:30, showInLegend:false, value:null, colors:null, sectors:null, minimum:0, maximum:100, rotation:0, totalAngle:Math.PI / 2, rect:[0, 0, 1, 1], center:[0.5, 0.75], radius:0.5, wholeDisk:false}, coordinateX:function() {
  16081. return this.coordinate('X', 0, 2);
  16082. }, coordinateY:function() {
  16083. return this.coordinate('Y', 1, 2);
  16084. }, updateNeedle:function(needle) {
  16085. var me = this, sprites = me.getSprites(), angle = me.valueToAngle(me.getValue());
  16086. if (sprites && sprites.length) {
  16087. sprites[0].setAttributes({startAngle:needle ? angle : 0, endAngle:angle, strokeOpacity:needle ? 1 : 0, lineWidth:needle ? me.getNeedleWidth() : 0});
  16088. me.doUpdateStyles();
  16089. }
  16090. }, themeColorCount:function() {
  16091. var me = this, store = me.getStore(), count = store && store.getCount() || 0;
  16092. return count + (me.getNeedle() ? 0 : 1);
  16093. }, updateColors:function(colors, oldColors) {
  16094. var me = this, sectors = me.getSectors(), sectorCount = sectors && sectors.length, sprites = me.getSprites(), newColors = Ext.Array.clone(colors), colorCount = colors && colors.length, i;
  16095. if (!colorCount || !colors[0]) {
  16096. return;
  16097. }
  16098. for (i = 0; i < sectorCount; i++) {
  16099. newColors[i + 1] = sectors[i].color || newColors[i + 1] || colors[i % colorCount];
  16100. }
  16101. if (sprites.length) {
  16102. sprites[0].setAttributes({strokeStyle:newColors[0]});
  16103. }
  16104. this.setSubStyle({fillStyle:newColors, strokeStyle:newColors});
  16105. this.doUpdateStyles();
  16106. }, updateRect:function(rect) {
  16107. var wholeDisk = this.getWholeDisk(), halfTotalAngle = wholeDisk ? Math.PI : this.getTotalAngle() / 2, donut = this.getDonut() / 100, width, height, radius;
  16108. if (halfTotalAngle <= Math.PI / 2) {
  16109. width = 2 * Math.sin(halfTotalAngle);
  16110. height = 1 - donut * Math.cos(halfTotalAngle);
  16111. } else {
  16112. width = 2;
  16113. height = 1 - Math.cos(halfTotalAngle);
  16114. }
  16115. radius = Math.min(rect[2] / width, rect[3] / height);
  16116. this.setRadius(radius);
  16117. this.setCenter([rect[2] / 2, radius + (rect[3] - height * radius) / 2]);
  16118. }, updateCenter:function(center) {
  16119. this.setStyle({centerX:center[0], centerY:center[1], rotationCenterX:center[0], rotationCenterY:center[1]});
  16120. this.doUpdateStyles();
  16121. }, updateRotation:function(rotation) {
  16122. this.setStyle({rotationRads:rotation - (this.getTotalAngle() + Math.PI) / 2});
  16123. this.doUpdateStyles();
  16124. }, doUpdateShape:function(radius, donut) {
  16125. var me = this, sectors = me.getSectors(), sectorCount = sectors && sectors.length || 0, needleLength = me.getNeedleLength() / 100, endRhoArray;
  16126. endRhoArray = [radius * needleLength, radius];
  16127. while (sectorCount--) {
  16128. endRhoArray.push(radius);
  16129. }
  16130. me.setSubStyle({endRho:endRhoArray, startRho:radius / 100 * donut});
  16131. me.doUpdateStyles();
  16132. }, updateRadius:function(radius) {
  16133. var donut = this.getDonut();
  16134. this.doUpdateShape(radius, donut);
  16135. }, updateDonut:function(donut) {
  16136. var radius = this.getRadius();
  16137. this.doUpdateShape(radius, donut);
  16138. }, valueToAngle:function(value) {
  16139. value = this.applyValue(value);
  16140. return this.getTotalAngle() * (value - this.getMinimum()) / (this.getMaximum() - this.getMinimum());
  16141. }, applyValue:function(value) {
  16142. return Math.min(this.getMaximum(), Math.max(value, this.getMinimum()));
  16143. }, updateValue:function(value) {
  16144. var me = this, needle = me.getNeedle(), angle = me.valueToAngle(value), sprites = me.getSprites();
  16145. sprites[0].getRendererData().value = value;
  16146. sprites[0].setAttributes({startAngle:needle ? angle : 0, endAngle:angle});
  16147. me.doUpdateStyles();
  16148. }, processData:function() {
  16149. var me = this, store = me.getStore(), record = store && store.first(), animation, duration, axis, min, max, xField, value;
  16150. if (record) {
  16151. xField = me.getXField();
  16152. if (xField) {
  16153. value = record.get(xField);
  16154. }
  16155. }
  16156. axis = me.getXAxis();
  16157. if (axis) {
  16158. min = axis.getMinimum();
  16159. max = axis.getMaximum();
  16160. animation = axis.getSprites()[0].getAnimation();
  16161. duration = animation.getDuration();
  16162. animation.setDuration(0);
  16163. if (Ext.isNumber(min)) {
  16164. me.setMinimum(min);
  16165. } else {
  16166. axis.setMinimum(me.getMinimum());
  16167. }
  16168. if (Ext.isNumber(max)) {
  16169. me.setMaximum(max);
  16170. } else {
  16171. axis.setMaximum(me.getMaximum());
  16172. }
  16173. animation.setDuration(duration);
  16174. }
  16175. if (!Ext.isNumber(value)) {
  16176. value = me.getMinimum();
  16177. }
  16178. me.setValue(value);
  16179. }, getDefaultSpriteConfig:function() {
  16180. return {type:this.seriesType, renderer:this.getRenderer(), animation:{customDurations:{translationX:0, translationY:0, rotationCenterX:0, rotationCenterY:0, centerX:0, centerY:0, startRho:0, endRho:0, baseRotation:0}}};
  16181. }, normalizeSectors:function(sectors) {
  16182. var me = this, sectorCount = sectors && sectors.length || 0, i, value, start, end;
  16183. if (sectorCount) {
  16184. for (i = 0; i < sectorCount; i++) {
  16185. value = sectors[i];
  16186. if (typeof value === 'number') {
  16187. sectors[i] = {start:i > 0 ? sectors[i - 1].end : me.getMinimum(), end:Math.min(value, me.getMaximum())};
  16188. if (i === sectorCount - 1 && sectors[i].end < me.getMaximum()) {
  16189. sectors[i + 1] = {start:sectors[i].end, end:me.getMaximum()};
  16190. }
  16191. } else {
  16192. if (typeof value.start === 'number') {
  16193. start = Math.max(value.start, me.getMinimum());
  16194. } else {
  16195. start = i > 0 ? sectors[i - 1].end : me.getMinimum();
  16196. }
  16197. if (typeof value.end === 'number') {
  16198. end = Math.min(value.end, me.getMaximum());
  16199. } else {
  16200. end = me.getMaximum();
  16201. }
  16202. sectors[i].start = start;
  16203. sectors[i].end = end;
  16204. }
  16205. }
  16206. } else {
  16207. sectors = [{start:me.getMinimum(), end:me.getMaximum()}];
  16208. }
  16209. return sectors;
  16210. }, getSprites:function() {
  16211. var me = this, store = me.getStore(), value = me.getValue(), label = me.getLabel(), i, ln;
  16212. if (!store && !Ext.isNumber(value)) {
  16213. return Ext.emptyArray;
  16214. }
  16215. var chart = me.getChart(), animation = me.getAnimation() || chart && chart.getAnimation(), sprites = me.sprites, spriteIndex = 0, sprite, sectors, attr, rendererData, lineWidths = [];
  16216. if (sprites && sprites.length) {
  16217. sprites[0].setAnimation(animation);
  16218. return sprites;
  16219. }
  16220. rendererData = {store:store, field:me.getXField(), angleField:me.getXField(), value:value, series:me};
  16221. me.needleSprite = sprite = me.createSprite();
  16222. sprite.setAttributes({zIndex:10}, true);
  16223. sprite.setRendererData(rendererData);
  16224. sprite.setRendererIndex(spriteIndex++);
  16225. lineWidths.push(me.getNeedleWidth());
  16226. if (label) {
  16227. label.getTemplate().setField(true);
  16228. }
  16229. sectors = me.normalizeSectors(me.getSectors());
  16230. for (i = 0, ln = sectors.length; i < ln; i++) {
  16231. attr = {startAngle:me.valueToAngle(sectors[i].start), endAngle:me.valueToAngle(sectors[i].end), label:sectors[i].label, fillStyle:sectors[i].color, strokeOpacity:0, doCallout:false, labelOverflowPadding:-1};
  16232. Ext.apply(attr, sectors[i].style);
  16233. sprite = me.createSprite();
  16234. sprite.setRendererData(rendererData);
  16235. sprite.setRendererIndex(spriteIndex++);
  16236. sprite.setAttributes(attr, true);
  16237. lineWidths.push(attr.lineWidth);
  16238. }
  16239. me.setSubStyle({lineWidth:lineWidths});
  16240. me.doUpdateStyles();
  16241. return sprites;
  16242. }, doUpdateStyles:function() {
  16243. var me = this;
  16244. me.callParent();
  16245. if (me.sprites.length) {
  16246. me.needleSprite.setAttributes({startRho:me.getNeedle() ? 0 : me.getRadius() / 100 * me.getDonut()});
  16247. }
  16248. }});
  16249. Ext.define('Ext.chart.series.sprite.Line', {alias:'sprite.lineSeries', extend:'Ext.chart.series.sprite.Aggregative', inheritableStatics:{def:{processors:{curve:'default', fillArea:'bool', nullStyle:'enums(gap,connect,origin)', preciseStroke:'bool', xAxis:'default', yCap:'default'}, defaults:{curve:{type:'linear'}, nullStyle:'connect', fillArea:false, preciseStroke:true, xAxis:null, yCap:Math.pow(2, 20), yJump:50}, triggers:{dataX:'dataX,bbox,curve', dataY:'dataY,bbox,curve', curve:'curve'}, updaters:{curve:'curveUpdater'}}},
  16250. list:null, curveUpdater:function(attr) {
  16251. var me = this, dataX = attr.dataX, dataY = attr.dataY, curve = attr.curve, smoothable = dataX && dataY && dataX.length > 2 && dataY.length > 2, type = curve.type;
  16252. if (smoothable) {
  16253. if (type === 'natural') {
  16254. me.smoothX = Ext.draw.Draw.naturalSpline(dataX);
  16255. me.smoothY = Ext.draw.Draw.naturalSpline(dataY);
  16256. } else {
  16257. if (type === 'cardinal') {
  16258. me.smoothX = Ext.draw.Draw.cardinalSpline(dataX, curve.tension);
  16259. me.smoothY = Ext.draw.Draw.cardinalSpline(dataY, curve.tension);
  16260. } else {
  16261. smoothable = false;
  16262. }
  16263. }
  16264. }
  16265. if (!smoothable) {
  16266. delete me.smoothX;
  16267. delete me.smoothY;
  16268. }
  16269. }, updatePlainBBox:function(plain) {
  16270. var attr = this.attr, ymin = Math.min(0, attr.dataMinY), ymax = Math.max(0, attr.dataMaxY);
  16271. plain.x = attr.dataMinX;
  16272. plain.y = ymin;
  16273. plain.width = attr.dataMaxX - attr.dataMinX;
  16274. plain.height = ymax - ymin;
  16275. }, drawStrip:function(ctx, strip) {
  16276. var i, ln;
  16277. ctx.moveTo(strip[0], strip[1]);
  16278. for (i = 2, ln = strip.length; i < ln; i += 2) {
  16279. ctx.lineTo(strip[i], strip[i + 1]);
  16280. }
  16281. }, drawStraightStroke:function(surface, ctx, start, end, list, xAxis) {
  16282. var me = this, attr = me.attr, nullStyle = attr.nullStyle, isConnect = nullStyle === 'connect', isOrigin = nullStyle === 'origin', renderer = attr.renderer, curve = attr.curve, step = curve.type === 'step-after', needMoveTo = true, ln = list.length, lineConfig = {type:'line', smooth:false, step:step}, rendererChanges, params, stripStartX, isValidX0, isValidX, isValidX1, isValidPoint0, isValidPoint, isValidPoint1, isGap, lastValidPoint, px, py, x, y, x0, y0, x1, y1, i, strip = [];
  16283. ctx.beginPath();
  16284. for (i = 3; i < ln; i += 3) {
  16285. x0 = list[i - 3];
  16286. y0 = list[i - 2];
  16287. x = list[i];
  16288. y = list[i + 1];
  16289. x1 = list[i + 3];
  16290. y1 = list[i + 4];
  16291. isValidX0 = Ext.isNumber(x0);
  16292. isValidX = Ext.isNumber(x);
  16293. isValidX1 = Ext.isNumber(x1);
  16294. isValidPoint0 = isValidX0 && Ext.isNumber(y0);
  16295. isValidPoint = isValidX && Ext.isNumber(y);
  16296. isValidPoint1 = isValidX1 && Ext.isNumber(y1);
  16297. if (isOrigin) {
  16298. if (!isValidPoint0 && isValidX0) {
  16299. y0 = xAxis;
  16300. isValidPoint0 = true;
  16301. }
  16302. if (!isValidPoint && isValidX) {
  16303. y = xAxis;
  16304. isValidPoint = true;
  16305. }
  16306. if (!isValidPoint1 && isValidX1) {
  16307. y1 = xAxis;
  16308. isValidPoint1 = true;
  16309. }
  16310. }
  16311. if (renderer) {
  16312. lineConfig.x = x;
  16313. lineConfig.y = y;
  16314. lineConfig.x0 = x0;
  16315. lineConfig.y0 = y0;
  16316. params = [me, lineConfig, me.rendererData, start + i / 3];
  16317. rendererChanges = Ext.callback(renderer, null, params, 0, me.getSeries());
  16318. }
  16319. if (isGap && isConnect && isValidPoint0 && lastValidPoint) {
  16320. px = lastValidPoint[0];
  16321. py = lastValidPoint[1];
  16322. if (needMoveTo) {
  16323. ctx.beginPath();
  16324. ctx.moveTo(px, py);
  16325. strip.push(px, py);
  16326. stripStartX = px;
  16327. needMoveTo = false;
  16328. }
  16329. if (step) {
  16330. ctx.lineTo(x0, py);
  16331. strip.push(x0, py);
  16332. }
  16333. ctx.lineTo(x0, y0);
  16334. strip.push(x0, y0);
  16335. lastValidPoint = [x0, y0];
  16336. isGap = false;
  16337. }
  16338. if (isConnect && lastValidPoint && isValidPoint && !isValidPoint0) {
  16339. x0 = lastValidPoint[0];
  16340. y0 = lastValidPoint[1];
  16341. isValidPoint0 = true;
  16342. }
  16343. if (isValidPoint) {
  16344. lastValidPoint = [x, y];
  16345. }
  16346. if (isValidPoint0 && isValidPoint) {
  16347. if (needMoveTo) {
  16348. ctx.beginPath();
  16349. ctx.moveTo(x0, y0);
  16350. strip.push(x0, y0);
  16351. stripStartX = x0;
  16352. needMoveTo = false;
  16353. }
  16354. } else {
  16355. isGap = true;
  16356. continue;
  16357. }
  16358. if (step) {
  16359. ctx.lineTo(x, y0);
  16360. strip.push(x, y0);
  16361. }
  16362. ctx.lineTo(x, y);
  16363. strip.push(x, y);
  16364. if (rendererChanges || !isValidPoint1) {
  16365. ctx.save();
  16366. Ext.apply(ctx, rendererChanges);
  16367. rendererChanges = null;
  16368. if (attr.fillArea) {
  16369. ctx.lineTo(x, xAxis);
  16370. ctx.lineTo(stripStartX, xAxis);
  16371. ctx.closePath();
  16372. ctx.fill();
  16373. }
  16374. ctx.beginPath();
  16375. me.drawStrip(ctx, strip);
  16376. strip = [];
  16377. ctx.stroke();
  16378. ctx.restore();
  16379. ctx.beginPath();
  16380. needMoveTo = true;
  16381. }
  16382. }
  16383. }, calculateScale:function(count, end) {
  16384. var power = 0, n = count;
  16385. while (n < end && count > 0) {
  16386. power++;
  16387. n += count >> power;
  16388. }
  16389. return Math.pow(2, power > 0 ? power - 1 : power);
  16390. }, drawSmoothStroke:function(surface, ctx, start, end, list, xAxis) {
  16391. var me = this, attr = me.attr, step = attr.step, matrix = attr.matrix, renderer = attr.renderer, xx = matrix.getXX(), yy = matrix.getYY(), dx = matrix.getDX(), dy = matrix.getDY(), smoothX = me.smoothX, smoothY = me.smoothY, scale = me.calculateScale(attr.dataX.length, end), cx1, cy1, cx2, cy2, x, y, x0, y0, i, j, changes, params, lineConfig = {type:'line', smooth:true, step:step};
  16392. ctx.beginPath();
  16393. ctx.moveTo(smoothX[start * 3] * xx + dx, smoothY[start * 3] * yy + dy);
  16394. for (i = 0, j = start * 3 + 1; i < list.length - 3; i += 3, j += 3 * scale) {
  16395. cx1 = smoothX[j] * xx + dx;
  16396. cy1 = smoothY[j] * yy + dy;
  16397. cx2 = smoothX[j + 1] * xx + dx;
  16398. cy2 = smoothY[j + 1] * yy + dy;
  16399. x = surface.roundPixel(list[i + 3]);
  16400. y = list[i + 4];
  16401. x0 = surface.roundPixel(list[i]);
  16402. y0 = list[i + 1];
  16403. if (renderer) {
  16404. lineConfig.x0 = x0;
  16405. lineConfig.y0 = y0;
  16406. lineConfig.cx1 = cx1;
  16407. lineConfig.cy1 = cy1;
  16408. lineConfig.cx2 = cx2;
  16409. lineConfig.cy2 = cy2;
  16410. lineConfig.x = x;
  16411. lineConfig.y = y;
  16412. params = [me, lineConfig, me.rendererData, start + i / 3 + 1];
  16413. changes = Ext.callback(renderer, null, params, 0, me.getSeries());
  16414. ctx.save();
  16415. Ext.apply(ctx, changes);
  16416. }
  16417. if (attr.fillArea) {
  16418. ctx.moveTo(x0, y0);
  16419. ctx.bezierCurveTo(cx1, cy1, cx2, cy2, x, y);
  16420. ctx.lineTo(x, xAxis);
  16421. ctx.lineTo(x0, xAxis);
  16422. ctx.lineTo(x0, y0);
  16423. ctx.closePath();
  16424. ctx.fill();
  16425. ctx.beginPath();
  16426. }
  16427. ctx.moveTo(x0, y0);
  16428. ctx.bezierCurveTo(cx1, cy1, cx2, cy2, x, y);
  16429. ctx.stroke();
  16430. ctx.moveTo(x0, y0);
  16431. ctx.closePath();
  16432. if (renderer) {
  16433. ctx.restore();
  16434. }
  16435. ctx.beginPath();
  16436. ctx.moveTo(x, y);
  16437. }
  16438. ctx.beginPath();
  16439. }, drawLabel:function(text, dataX, dataY, labelId, rect) {
  16440. var me = this, attr = me.attr, label = me.getMarker('labels'), labelTpl = label.getTemplate(), labelCfg = me.labelCfg || (me.labelCfg = {}), surfaceMatrix = me.surfaceMatrix, labelX, labelY, labelOverflowPadding = attr.labelOverflowPadding, halfHeight, labelBBox, changes, params, hasPendingChanges;
  16441. labelCfg.x = surfaceMatrix.x(dataX, dataY);
  16442. labelCfg.y = surfaceMatrix.y(dataX, dataY);
  16443. if (attr.flipXY) {
  16444. labelCfg.rotationRads = Math.PI * 0.5;
  16445. } else {
  16446. labelCfg.rotationRads = 0;
  16447. }
  16448. labelCfg.text = text;
  16449. if (labelTpl.attr.renderer) {
  16450. params = [text, label, labelCfg, me.rendererData, labelId];
  16451. changes = Ext.callback(labelTpl.attr.renderer, null, params, 0, me.getSeries());
  16452. if (typeof changes === 'string') {
  16453. labelCfg.text = changes;
  16454. } else {
  16455. if (typeof changes === 'object') {
  16456. if ('text' in changes) {
  16457. labelCfg.text = changes.text;
  16458. }
  16459. hasPendingChanges = true;
  16460. }
  16461. }
  16462. }
  16463. labelBBox = me.getMarkerBBox('labels', labelId, true);
  16464. if (!labelBBox) {
  16465. me.putMarker('labels', labelCfg, labelId);
  16466. labelBBox = me.getMarkerBBox('labels', labelId, true);
  16467. }
  16468. halfHeight = labelBBox.height / 2;
  16469. labelX = dataX;
  16470. switch(labelTpl.attr.display) {
  16471. case 'under':
  16472. labelY = dataY - halfHeight - labelOverflowPadding;
  16473. break;
  16474. case 'rotate':
  16475. labelX += labelOverflowPadding;
  16476. labelY = dataY - labelOverflowPadding;
  16477. labelCfg.rotationRads = -Math.PI / 4;
  16478. break;
  16479. default:
  16480. labelY = dataY + halfHeight + labelOverflowPadding;
  16481. }
  16482. labelCfg.x = surfaceMatrix.x(labelX, labelY);
  16483. labelCfg.y = surfaceMatrix.y(labelX, labelY);
  16484. if (hasPendingChanges) {
  16485. Ext.apply(labelCfg, changes);
  16486. }
  16487. me.putMarker('labels', labelCfg, labelId);
  16488. }, drawMarker:function(x, y, index) {
  16489. var me = this, attr = me.attr, renderer = attr.renderer, surfaceMatrix = me.surfaceMatrix, markerCfg = {}, changes, params;
  16490. if (renderer && me.getMarker('markers')) {
  16491. markerCfg.type = 'marker';
  16492. markerCfg.x = x;
  16493. markerCfg.y = y;
  16494. params = [me, markerCfg, me.rendererData, index];
  16495. changes = Ext.callback(renderer, null, params, 0, me.getSeries());
  16496. if (changes) {
  16497. Ext.apply(markerCfg, changes);
  16498. }
  16499. }
  16500. markerCfg.translationX = surfaceMatrix.x(x, y);
  16501. markerCfg.translationY = surfaceMatrix.y(x, y);
  16502. delete markerCfg.x;
  16503. delete markerCfg.y;
  16504. me.putMarker('markers', markerCfg, index, !renderer);
  16505. }, drawStroke:function(surface, ctx, start, end, list, xAxis) {
  16506. var me = this, isSmooth = me.smoothX && me.smoothY;
  16507. if (isSmooth) {
  16508. me.drawSmoothStroke(surface, ctx, start, end, list, xAxis);
  16509. } else {
  16510. me.drawStraightStroke(surface, ctx, start, end, list, xAxis);
  16511. }
  16512. }, renderAggregates:function(aggregates, start, end, surface, ctx, clip, rect) {
  16513. var me = this, attr = me.attr, dataX = attr.dataX, dataY = attr.dataY, labels = attr.labels, xAxis = attr.xAxis, yCap = attr.yCap, isSmooth = attr.smooth && me.smoothX && me.smoothY, isDrawLabels = labels && me.getMarker('labels'), isDrawMarkers = me.getMarker('markers'), matrix = attr.matrix, pixel = surface.devicePixelRatio, xx = matrix.getXX(), yy = matrix.getYY(), dx = matrix.getDX(), dy = matrix.getDY(), list = me.list || (me.list = []), minXs = aggregates.minX, maxXs = aggregates.maxX, minYs =
  16514. aggregates.minY, maxYs = aggregates.maxY, idx = aggregates.startIdx, isContinuousLine = true, isValidMinX, isValidMaxX, isValidMinY, isValidMaxY, xAxisOrigin, isVerticalX, x, y, i, index, minX, maxX, minY, maxY, lastPointX, lastPointY, firstPointX, firstPointY;
  16515. me.rendererData = {store:me.getStore()};
  16516. list.length = 0;
  16517. for (i = start; i < end; i++) {
  16518. minX = minXs[i];
  16519. maxX = maxXs[i];
  16520. minY = minYs[i];
  16521. maxY = maxYs[i];
  16522. isValidMinX = Ext.isNumber(minX);
  16523. isValidMinY = Ext.isNumber(minY);
  16524. isValidMaxX = Ext.isNumber(maxX);
  16525. isValidMaxY = Ext.isNumber(maxY);
  16526. if (minX < maxX) {
  16527. list.push(isValidMinX ? minX * xx + dx : null, isValidMinY ? minY * yy + dy : null, idx[i]);
  16528. list.push(isValidMaxX ? maxX * xx + dx : null, isValidMaxY ? maxY * yy + dy : null, idx[i]);
  16529. } else {
  16530. if (minX > maxX) {
  16531. list.push(isValidMaxX ? maxX * xx + dx : null, isValidMaxY ? maxY * yy + dy : null, idx[i]);
  16532. list.push(isValidMinX ? minX * xx + dx : null, isValidMinY ? minY * yy + dy : null, idx[i]);
  16533. } else {
  16534. list.push(isValidMaxX ? maxX * xx + dx : null, isValidMaxY ? maxY * yy + dy : null, idx[i]);
  16535. }
  16536. }
  16537. }
  16538. if (list.length) {
  16539. for (i = 0; i < list.length; i += 3) {
  16540. x = list[i];
  16541. y = list[i + 1];
  16542. if (Ext.isNumber(x) && Ext.isNumber(y)) {
  16543. if (y > yCap) {
  16544. y = yCap;
  16545. } else {
  16546. if (y < -yCap) {
  16547. y = -yCap;
  16548. }
  16549. }
  16550. list[i + 1] = y;
  16551. } else {
  16552. isContinuousLine = false;
  16553. continue;
  16554. }
  16555. index = list[i + 2];
  16556. if (isDrawMarkers) {
  16557. me.drawMarker(x, y, index);
  16558. }
  16559. if (isDrawLabels && labels[index]) {
  16560. me.drawLabel(labels[index], x, y, index, rect);
  16561. }
  16562. }
  16563. me.isContinuousLine = isContinuousLine;
  16564. if (isSmooth && !isContinuousLine) {
  16565. Ext.raise('Line smoothing in only supported for gapless data, ' + 'where all data points are finite numbers.');
  16566. }
  16567. if (xAxis) {
  16568. isVerticalX = xAxis.getAlignment() === 'vertical';
  16569. if (Ext.isNumber(xAxis.floatingAtCoord)) {
  16570. xAxisOrigin = (isVerticalX ? rect[2] : rect[3]) - xAxis.floatingAtCoord;
  16571. } else {
  16572. xAxisOrigin = isVerticalX ? rect[0] : rect[1];
  16573. }
  16574. } else {
  16575. xAxisOrigin = attr.flipXY ? rect[0] : rect[1];
  16576. }
  16577. if (attr.preciseStroke) {
  16578. if (attr.fillArea) {
  16579. ctx.fill();
  16580. }
  16581. if (attr.transformFillStroke) {
  16582. attr.inverseMatrix.toContext(ctx);
  16583. }
  16584. me.drawStroke(surface, ctx, start, end, list, xAxisOrigin);
  16585. if (attr.transformFillStroke) {
  16586. attr.matrix.toContext(ctx);
  16587. }
  16588. ctx.stroke();
  16589. } else {
  16590. me.drawStroke(surface, ctx, start, end, list, xAxisOrigin);
  16591. if (isContinuousLine && isSmooth && attr.fillArea && !attr.renderer) {
  16592. lastPointX = dataX[dataX.length - 1] * xx + dx + pixel;
  16593. lastPointY = dataY[dataY.length - 1] * yy + dy;
  16594. firstPointX = dataX[0] * xx + dx - pixel;
  16595. firstPointY = dataY[0] * yy + dy;
  16596. ctx.lineTo(lastPointX, lastPointY);
  16597. ctx.lineTo(lastPointX, xAxisOrigin - attr.lineWidth);
  16598. ctx.lineTo(firstPointX, xAxisOrigin - attr.lineWidth);
  16599. ctx.lineTo(firstPointX, firstPointY);
  16600. }
  16601. if (attr.transformFillStroke) {
  16602. attr.matrix.toContext(ctx);
  16603. }
  16604. if (attr.fillArea) {
  16605. ctx.fillStroke(attr, true);
  16606. } else {
  16607. ctx.stroke(true);
  16608. }
  16609. }
  16610. }
  16611. }});
  16612. Ext.define('Ext.chart.series.Line', {extend:'Ext.chart.series.Cartesian', alias:'series.line', type:'line', seriesType:'lineSeries', isLine:true, requires:['Ext.chart.series.sprite.Line'], config:{selectionTolerance:20, curve:{type:'linear'}, smooth:null, step:null, nullStyle:'gap', fill:undefined, aggregator:{strategy:'double'}}, themeMarkerCount:function() {
  16613. return 1;
  16614. }, getDefaultSpriteConfig:function() {
  16615. var me = this, parentConfig = me.callParent(arguments), style = Ext.apply({}, me.getStyle()), styleWithTheme, fillArea = false;
  16616. if (me.config.fill !== undefined) {
  16617. if (me.config.fill) {
  16618. fillArea = true;
  16619. if (style.fillStyle === undefined) {
  16620. if (style.strokeStyle === undefined) {
  16621. styleWithTheme = me.getStyleWithTheme();
  16622. style.fillStyle = styleWithTheme.fillStyle;
  16623. style.strokeStyle = styleWithTheme.strokeStyle;
  16624. } else {
  16625. style.fillStyle = style.strokeStyle;
  16626. }
  16627. }
  16628. }
  16629. } else {
  16630. if (style.fillStyle) {
  16631. fillArea = true;
  16632. }
  16633. }
  16634. if (!fillArea) {
  16635. delete style.fillStyle;
  16636. }
  16637. style = Ext.apply(parentConfig || {}, style);
  16638. return Ext.apply(style, {fillArea:fillArea, selectionTolerance:me.config.selectionTolerance});
  16639. }, updateFill:function(fill) {
  16640. this.withSprite(function(sprite) {
  16641. return sprite.setAttributes({fillArea:fill});
  16642. });
  16643. }, updateCurve:function(curve) {
  16644. this.withSprite(function(sprite) {
  16645. return sprite.setAttributes({curve:curve});
  16646. });
  16647. }, getCurve:function() {
  16648. return this.withSprite(function(sprite) {
  16649. return sprite.attr.curve;
  16650. });
  16651. }, updateNullStyle:function(nullStyle) {
  16652. this.withSprite(function(sprite) {
  16653. return sprite.setAttributes({nullStyle:nullStyle});
  16654. });
  16655. }, updateSmooth:function(smooth) {
  16656. this.setCurve({type:smooth ? 'natural' : 'linear'});
  16657. }, updateStep:function(step) {
  16658. this.setCurve({type:step ? 'step-after' : 'linear'});
  16659. }});
  16660. Ext.define('Ext.chart.series.sprite.PieSlice', {extend:'Ext.draw.sprite.Sector', mixins:{markerHolder:'Ext.chart.MarkerHolder'}, alias:'sprite.pieslice', inheritableStatics:{def:{processors:{doCallout:'bool', label:'string', rotateLabels:'bool', labelOverflowPadding:'number', renderer:'default'}, defaults:{doCallout:true, rotateLabels:true, label:'', labelOverflowPadding:10, renderer:null}}}, config:{rendererData:null, rendererIndex:0, series:null}, setGradientBBox:function(ctx, rect) {
  16661. var me = this, attr = me.attr, hasGradients = attr.fillStyle && attr.fillStyle.isGradient || attr.strokeStyle && attr.strokeStyle.isGradient;
  16662. if (hasGradients && !attr.constrainGradients) {
  16663. var midAngle = me.getMidAngle(), margin = attr.margin, cx = attr.centerX, cy = attr.centerY, r = attr.endRho, matrix = attr.matrix, scaleX = matrix.getScaleX(), scaleY = matrix.getScaleY(), w = scaleX * r, h = scaleY * r, bbox = {width:w + w, height:h + h};
  16664. if (margin) {
  16665. cx += margin * Math.cos(midAngle);
  16666. cy += margin * Math.sin(midAngle);
  16667. }
  16668. bbox.x = matrix.x(cx, cy) - w;
  16669. bbox.y = matrix.y(cx, cy) - h;
  16670. ctx.setGradientBBox(bbox);
  16671. } else {
  16672. me.callParent([ctx, rect]);
  16673. }
  16674. }, render:function(surface, ctx, rect) {
  16675. var me = this, attr = me.attr, itemCfg = {}, changes;
  16676. if (attr.renderer) {
  16677. itemCfg = {type:'sector', centerX:attr.centerX, centerY:attr.centerY, margin:attr.margin, startAngle:Math.min(attr.startAngle, attr.endAngle), endAngle:Math.max(attr.startAngle, attr.endAngle), startRho:Math.min(attr.startRho, attr.endRho), endRho:Math.max(attr.startRho, attr.endRho)};
  16678. changes = Ext.callback(attr.renderer, null, [me, itemCfg, me.getRendererData(), me.getRendererIndex()], 0, me.getSeries());
  16679. me.setAttributes(changes);
  16680. me.useAttributes(ctx, rect);
  16681. }
  16682. me.callParent([surface, ctx, rect]);
  16683. if (attr.label && me.getMarker('labels')) {
  16684. me.placeLabel();
  16685. }
  16686. }, placeLabel:function() {
  16687. var me = this, attr = me.attr, attributeId = attr.attributeId, startAngle = Math.min(attr.startAngle, attr.endAngle), endAngle = Math.max(attr.startAngle, attr.endAngle), midAngle = (startAngle + endAngle) * 0.5, margin = attr.margin, centerX = attr.centerX, centerY = attr.centerY, sinMidAngle = Math.sin(midAngle), cosMidAngle = Math.cos(midAngle), startRho = Math.min(attr.startRho, attr.endRho) + margin, endRho = Math.max(attr.startRho, attr.endRho) + margin, midRho = (startRho + endRho) * 0.5,
  16688. surfaceMatrix = me.surfaceMatrix, labelCfg = me.labelCfg || (me.labelCfg = {}), label = me.getMarker('labels'), labelTpl = label.getTemplate(), hideLessThan = labelTpl.getHideLessThan(), calloutLine = labelTpl.getCalloutLine(), labelBox, x, y, changes, params, calloutLineLength;
  16689. if (calloutLine) {
  16690. calloutLineLength = calloutLine.length || 40;
  16691. } else {
  16692. calloutLineLength = 0;
  16693. }
  16694. surfaceMatrix.appendMatrix(attr.matrix);
  16695. labelCfg.text = attr.label;
  16696. x = centerX + cosMidAngle * midRho;
  16697. y = centerY + sinMidAngle * midRho;
  16698. labelCfg.x = surfaceMatrix.x(x, y);
  16699. labelCfg.y = surfaceMatrix.y(x, y);
  16700. x = centerX + cosMidAngle * endRho;
  16701. y = centerY + sinMidAngle * endRho;
  16702. labelCfg.calloutStartX = surfaceMatrix.x(x, y);
  16703. labelCfg.calloutStartY = surfaceMatrix.y(x, y);
  16704. x = centerX + cosMidAngle * (endRho + calloutLineLength);
  16705. y = centerY + sinMidAngle * (endRho + calloutLineLength);
  16706. labelCfg.calloutPlaceX = surfaceMatrix.x(x, y);
  16707. labelCfg.calloutPlaceY = surfaceMatrix.y(x, y);
  16708. if (!attr.rotateLabels) {
  16709. labelCfg.rotationRads = 0;
  16710. Ext.log.warn("'series.style.rotateLabels' config is deprecated. " + "Use 'series.label.orientation' config instead.");
  16711. } else {
  16712. switch(labelTpl.attr.orientation) {
  16713. case 'horizontal':
  16714. labelCfg.rotationRads = midAngle + Math.atan2(surfaceMatrix.y(1, 0) - surfaceMatrix.y(0, 0), surfaceMatrix.x(1, 0) - surfaceMatrix.x(0, 0)) + Math.PI / 2;
  16715. break;
  16716. case 'vertical':
  16717. labelCfg.rotationRads = midAngle + Math.atan2(surfaceMatrix.y(1, 0) - surfaceMatrix.y(0, 0), surfaceMatrix.x(1, 0) - surfaceMatrix.x(0, 0));
  16718. break;
  16719. }
  16720. }
  16721. labelCfg.calloutColor = calloutLine && calloutLine.color || me.attr.fillStyle;
  16722. if (calloutLine) {
  16723. if (calloutLine.width) {
  16724. labelCfg.calloutWidth = calloutLine.width;
  16725. }
  16726. } else {
  16727. labelCfg.calloutColor = 'none';
  16728. }
  16729. labelCfg.globalAlpha = attr.globalAlpha * attr.fillOpacity;
  16730. if (labelTpl.display !== 'none') {
  16731. labelCfg.hidden = attr.startAngle == attr.endAngle;
  16732. }
  16733. if (labelTpl.attr.renderer) {
  16734. params = [me.attr.label, label, labelCfg, me.getRendererData(), me.getRendererIndex()];
  16735. changes = Ext.callback(labelTpl.attr.renderer, null, params, 0, me.getSeries());
  16736. if (typeof changes === 'string') {
  16737. labelCfg.text = changes;
  16738. } else {
  16739. Ext.apply(labelCfg, changes);
  16740. }
  16741. }
  16742. me.putMarker('labels', labelCfg, attributeId);
  16743. labelBox = me.getMarkerBBox('labels', attributeId, true);
  16744. if (labelBox) {
  16745. if (attr.doCallout && ((endAngle - startAngle) * endRho > hideLessThan || attr.highlighted)) {
  16746. if (labelTpl.attr.display === 'outside') {
  16747. me.putMarker('labels', {callout:1}, attributeId);
  16748. } else {
  16749. if (labelTpl.attr.display === 'inside') {
  16750. me.putMarker('labels', {callout:0}, attributeId);
  16751. } else {
  16752. me.putMarker('labels', {callout:1 - me.sliceContainsLabel(attr, labelBox)}, attributeId);
  16753. }
  16754. }
  16755. } else {
  16756. me.putMarker('labels', {globalAlpha:me.sliceContainsLabel(attr, labelBox)}, attributeId);
  16757. }
  16758. }
  16759. }, sliceContainsLabel:function(attr, bbox) {
  16760. var padding = attr.labelOverflowPadding, middle = (attr.endRho + attr.startRho) / 2, outer = middle + (bbox.width + padding) / 2, inner = middle - (bbox.width + padding) / 2, sliceAngle, l1, l2, l3;
  16761. if (padding < 0) {
  16762. return 1;
  16763. }
  16764. if (bbox.width + padding * 2 > attr.endRho - attr.startRho) {
  16765. return 0;
  16766. }
  16767. l1 = Math.sqrt(attr.endRho * attr.endRho - outer * outer);
  16768. l2 = Math.sqrt(attr.endRho * attr.endRho - inner * inner);
  16769. sliceAngle = Math.abs(attr.endAngle - attr.startAngle);
  16770. l3 = sliceAngle > Math.PI / 2 ? inner : Math.abs(Math.tan(sliceAngle / 2)) * inner;
  16771. if (bbox.height + padding * 2 > Math.min(l1, l2, l3) * 2) {
  16772. return 0;
  16773. }
  16774. return 1;
  16775. }});
  16776. Ext.define('Ext.chart.series.Pie', {extend:'Ext.chart.series.Polar', requires:['Ext.chart.series.sprite.PieSlice'], type:'pie', alias:'series.pie', seriesType:'pieslice', isPie:true, config:{donut:0, rotation:0, clockwise:true, totalAngle:2 * Math.PI, hidden:[], radiusFactor:100, highlightCfg:{margin:20}, style:{}}, directions:['X'], applyLabel:function(newLabel, oldLabel) {
  16777. if (Ext.isObject(newLabel) && !Ext.isString(newLabel.orientation)) {
  16778. Ext.apply(newLabel = Ext.Object.chain(newLabel), {orientation:'vertical'});
  16779. }
  16780. return newLabel;
  16781. }, updateLabelData:function() {
  16782. var me = this, store = me.getStore(), items = store.getData().items, sprites = me.getSprites(), label = me.getLabel(), labelField = label && label.getTemplate().getField(), hidden = me.getHidden(), i, ln, labels, sprite;
  16783. if (sprites.length && labelField) {
  16784. labels = [];
  16785. for (i = 0, ln = items.length; i < ln; i++) {
  16786. labels.push(items[i].get(labelField));
  16787. }
  16788. for (i = 0, ln = sprites.length; i < ln; i++) {
  16789. sprite = sprites[i];
  16790. sprite.setAttributes({label:labels[i]});
  16791. sprite.putMarker('labels', {hidden:hidden[i]}, sprite.attr.attributeId);
  16792. }
  16793. }
  16794. }, coordinateX:function() {
  16795. var me = this, store = me.getStore(), records = store.getData().items, recordCount = records.length, xField = me.getXField(), yField = me.getYField(), x, sumX = 0, unit, y, maxY = 0, hidden = me.getHidden(), summation = [], i, lastAngle = 0, totalAngle = me.getTotalAngle(), clockwise = me.getClockwise() ? 1 : -1, sprites = me.getSprites(), sprite, labels;
  16796. if (!sprites) {
  16797. return;
  16798. }
  16799. for (i = 0; i < recordCount; i++) {
  16800. x = Math.abs(Number(records[i].get(xField))) || 0;
  16801. y = yField && Math.abs(Number(records[i].get(yField))) || 0;
  16802. if (!hidden[i]) {
  16803. sumX += x;
  16804. if (y > maxY) {
  16805. maxY = y;
  16806. }
  16807. }
  16808. summation[i] = sumX;
  16809. if (i >= hidden.length) {
  16810. hidden[i] = false;
  16811. }
  16812. }
  16813. hidden.length = recordCount;
  16814. me.maxY = maxY;
  16815. if (sumX !== 0) {
  16816. unit = totalAngle / sumX;
  16817. }
  16818. for (i = 0; i < recordCount; i++) {
  16819. sprite = sprites[i];
  16820. if (sprite) {
  16821. sprite.setAttributes({startAngle:lastAngle, endAngle:lastAngle = unit ? clockwise * summation[i] * unit : 0, globalAlpha:1});
  16822. }
  16823. }
  16824. if (recordCount < sprites.length) {
  16825. for (i = recordCount; i < sprites.length; i++) {
  16826. sprite = sprites[i];
  16827. labels = sprite.getMarker('labels');
  16828. if (labels) {
  16829. labels.clear(sprite.getId());
  16830. sprite.releaseMarker('labels');
  16831. }
  16832. sprite.destroy();
  16833. }
  16834. sprites.length = recordCount;
  16835. }
  16836. for (i = recordCount; i < sprites.length; i++) {
  16837. sprites[i].setAttributes({startAngle:totalAngle, endAngle:totalAngle, globalAlpha:0});
  16838. }
  16839. }, updateCenter:function(center) {
  16840. this.setStyle({translationX:center[0] + this.getOffsetX(), translationY:center[1] + this.getOffsetY()});
  16841. this.doUpdateStyles();
  16842. }, updateRadius:function(radius) {
  16843. this.setStyle({startRho:radius * this.getDonut() * 0.01, endRho:radius * this.getRadiusFactor() * 0.01});
  16844. this.doUpdateStyles();
  16845. }, getStyleByIndex:function(i) {
  16846. var me = this, store = me.getStore(), item = store.getAt(i), yField = me.getYField(), radius = me.getRadius(), style = {}, startRho, endRho, y;
  16847. if (item) {
  16848. y = yField && Math.abs(Number(item.get(yField))) || 0;
  16849. startRho = radius * me.getDonut() * 0.01;
  16850. endRho = radius * me.getRadiusFactor() * 0.01;
  16851. style = me.callParent([i]);
  16852. style.startRho = startRho;
  16853. style.endRho = me.maxY ? startRho + (endRho - startRho) * y / me.maxY : endRho;
  16854. }
  16855. return style;
  16856. }, updateDonut:function(donut) {
  16857. var radius = this.getRadius();
  16858. this.setStyle({startRho:radius * donut * 0.01, endRho:radius * this.getRadiusFactor() * 0.01});
  16859. this.doUpdateStyles();
  16860. }, rotationOffset:-Math.PI / 2, updateRotation:function(rotation) {
  16861. this.setStyle({rotationRads:rotation + this.rotationOffset});
  16862. this.doUpdateStyles();
  16863. }, updateTotalAngle:function(totalAngle) {
  16864. this.processData();
  16865. }, getSprites:function() {
  16866. var me = this, chart = me.getChart(), xField = me.getXField(), yField = me.getYField(), store = me.getStore();
  16867. if (!chart || !store) {
  16868. return Ext.emptyArray;
  16869. }
  16870. me.getColors();
  16871. me.getSubStyle();
  16872. var items = store.getData().items, length = items.length, animation = me.getAnimation() || chart && chart.getAnimation(), sprites = me.sprites, sprite, spriteCreated = false, spriteIndex = 0, label = me.getLabel(), labelTpl = label && label.getTemplate(), i, rendererData;
  16873. rendererData = {store:store, field:xField, angleField:xField, radiusField:yField, series:me};
  16874. for (i = 0; i < length; i++) {
  16875. sprite = sprites[i];
  16876. if (!sprite && items[i].get(xField)) {
  16877. sprite = me.createSprite();
  16878. if (me.getHighlight()) {
  16879. sprite.config.highlight = me.getHighlight();
  16880. sprite.addModifier('highlight', true);
  16881. }
  16882. if (labelTpl && labelTpl.getField()) {
  16883. labelTpl.setAttributes({labelOverflowPadding:me.getLabelOverflowPadding()});
  16884. labelTpl.getAnimation().setCustomDurations({'callout':200});
  16885. }
  16886. sprite.setAttributes(me.getStyleByIndex(i));
  16887. sprite.setRendererData(rendererData);
  16888. spriteCreated = true;
  16889. }
  16890. if (sprite) {
  16891. sprite.setRendererIndex(spriteIndex++);
  16892. sprite.setAnimation(animation);
  16893. }
  16894. }
  16895. if (spriteCreated) {
  16896. me.doUpdateStyles();
  16897. }
  16898. return me.sprites;
  16899. }, betweenAngle:function(x, a, b) {
  16900. var pp = Math.PI * 2, offset = this.rotationOffset;
  16901. if (a === b) {
  16902. return false;
  16903. }
  16904. if (!this.getClockwise()) {
  16905. x *= -1;
  16906. a *= -1;
  16907. b *= -1;
  16908. a -= offset;
  16909. b -= offset;
  16910. } else {
  16911. a += offset;
  16912. b += offset;
  16913. }
  16914. x -= a;
  16915. b -= a;
  16916. x %= pp;
  16917. b %= pp;
  16918. x += pp;
  16919. b += pp;
  16920. x %= pp;
  16921. b %= pp;
  16922. return x < b || Ext.Number.isEqual(b, 0, 1.0E-8);
  16923. }, getItemByIndex:function(index, category) {
  16924. category = category || 'sprites';
  16925. return this.callParent([index, category]);
  16926. }, getItemForAngle:function(angle) {
  16927. var me = this, sprites = me.getSprites(), attr, store, items, hidden, i, ln;
  16928. angle %= Math.PI * 2;
  16929. while (angle < 0) {
  16930. angle += Math.PI * 2;
  16931. }
  16932. if (sprites) {
  16933. store = me.getStore();
  16934. items = store.getData().items;
  16935. hidden = me.getHidden();
  16936. for (i = 0, ln = store.getCount(); i < ln; i++) {
  16937. if (!hidden[i]) {
  16938. attr = sprites[i].attr;
  16939. if (attr.startAngle <= angle && attr.endAngle >= angle) {
  16940. return {series:me, sprite:sprites[i], index:i, record:items[i], field:me.getXField()};
  16941. }
  16942. }
  16943. }
  16944. }
  16945. return null;
  16946. }, getItemForPoint:function(x, y) {
  16947. var me = this, sprites = me.getSprites(), center = me.getCenter(), offsetX = me.getOffsetX(), offsetY = me.getOffsetY(), dx = x - center[0] + offsetX, dy = y - center[1] + offsetY, store = me.getStore(), donut = me.getDonut(), records = store.getData().items, direction = Math.atan2(dy, dx) - me.getRotation(), radius = Math.sqrt(dx * dx + dy * dy), startRadius = me.getRadius() * donut * 0.01, hidden = me.getHidden(), result = null, i, ln, attr, sprite;
  16948. for (i = 0, ln = records.length; i < ln; i++) {
  16949. if (hidden[i]) {
  16950. continue;
  16951. }
  16952. sprite = sprites[i];
  16953. if (!sprite) {
  16954. break;
  16955. }
  16956. attr = sprite.attr;
  16957. if (radius >= startRadius + attr.margin && radius <= attr.endRho + attr.margin && me.betweenAngle(direction, attr.startAngle, attr.endAngle)) {
  16958. result = {series:me, sprite:sprites[i], index:i, record:records[i], field:me.getXField()};
  16959. break;
  16960. }
  16961. }
  16962. return result;
  16963. }, provideLegendInfo:function(target) {
  16964. var me = this, store = me.getStore(), items, labelField, xField, hidden, i, style, fill;
  16965. if (store) {
  16966. items = store.getData().items;
  16967. labelField = me.getLabel().getTemplate().getField();
  16968. xField = me.getXField();
  16969. hidden = me.getHidden();
  16970. for (i = 0; i < items.length; i++) {
  16971. style = me.getStyleByIndex(i);
  16972. fill = style.fillStyle;
  16973. if (Ext.isObject(fill)) {
  16974. fill = fill.stops && fill.stops[0].color;
  16975. }
  16976. target.push({name:labelField ? String(items[i].get(labelField)) : xField + ' ' + i, mark:fill || style.strokeStyle || 'black', disabled:hidden[i], series:me.getId(), index:i});
  16977. }
  16978. }
  16979. }});
  16980. Ext.define('Ext.chart.series.sprite.Pie3DPart', {extend:'Ext.draw.sprite.Path', mixins:{markerHolder:'Ext.chart.MarkerHolder'}, alias:'sprite.pie3dPart', inheritableStatics:{def:{processors:{centerX:'number', centerY:'number', startAngle:'number', endAngle:'number', startRho:'number', endRho:'number', margin:'number', thickness:'number', bevelWidth:'number', distortion:'number', baseColor:'color', colorSpread:'number', baseRotation:'number', part:'enums(top,bottom,start,end,innerFront,innerBack,outerFront,outerBack)',
  16981. label:'string'}, aliases:{rho:'endRho'}, triggers:{centerX:'path,bbox', centerY:'path,bbox', startAngle:'path,partZIndex', endAngle:'path,partZIndex', startRho:'path', endRho:'path,bbox', margin:'path,bbox', thickness:'path', distortion:'path', baseRotation:'path,partZIndex', baseColor:'partZIndex,partColor', colorSpread:'partColor', part:'path,partZIndex', globalAlpha:'canvas,alpha', fillOpacity:'canvas,alpha'}, defaults:{centerX:0, centerY:0, startAngle:Math.PI * 2, endAngle:Math.PI * 2, startRho:0,
  16982. endRho:150, margin:0, thickness:35, distortion:0.5, baseRotation:0, baseColor:'white', colorSpread:0.5, miterLimit:1, bevelWidth:5, strokeOpacity:0, part:'top', label:''}, updaters:{alpha:'alphaUpdater', partColor:'partColorUpdater', partZIndex:'partZIndexUpdater'}}}, config:{renderer:null, rendererData:null, rendererIndex:0, series:null}, bevelParams:[], constructor:function(config) {
  16983. this.callParent([config]);
  16984. this.bevelGradient = new Ext.draw.gradient.Linear({stops:[{offset:0, color:'rgba(255,255,255,0)'}, {offset:0.7, color:'rgba(255,255,255,0.6)'}, {offset:1, color:'rgba(255,255,255,0)'}]});
  16985. }, updateRenderer:function() {
  16986. this.setDirty(true);
  16987. }, updateRendererData:function() {
  16988. this.setDirty(true);
  16989. }, updateRendererIndex:function() {
  16990. this.setDirty(true);
  16991. }, alphaUpdater:function(attr) {
  16992. var me = this, opacity = attr.globalAlpha, fillOpacity = attr.fillOpacity, oldOpacity = me.oldOpacity, oldFillOpacity = me.oldFillOpacity;
  16993. if (opacity !== oldOpacity && (opacity === 1 || oldOpacity === 1) || fillOpacity !== oldFillOpacity && (fillOpacity === 1 || oldFillOpacity === 1)) {
  16994. me.scheduleUpdater(attr, 'path', ['globalAlpha']);
  16995. me.oldOpacity = opacity;
  16996. me.oldFillOpacity = fillOpacity;
  16997. }
  16998. }, partColorUpdater:function(attr) {
  16999. var color = Ext.util.Color.fly(attr.baseColor), colorString = color.toString(), colorSpread = attr.colorSpread, fillStyle;
  17000. switch(attr.part) {
  17001. case 'top':
  17002. fillStyle = new Ext.draw.gradient.Radial({start:{x:0, y:0, r:0}, end:{x:0, y:0, r:1}, stops:[{offset:0, color:color.createLighter(0.1 * colorSpread)}, {offset:1, color:color.createDarker(0.1 * colorSpread)}]});
  17003. break;
  17004. case 'bottom':
  17005. fillStyle = new Ext.draw.gradient.Radial({start:{x:0, y:0, r:0}, end:{x:0, y:0, r:1}, stops:[{offset:0, color:color.createDarker(0.2 * colorSpread)}, {offset:1, color:color.toString()}]});
  17006. break;
  17007. case 'outerFront':
  17008. case 'outerBack':
  17009. fillStyle = new Ext.draw.gradient.Linear({stops:[{offset:0, color:color.createDarker(0.15 * colorSpread).toString()}, {offset:0.3, color:colorString}, {offset:0.8, color:color.createLighter(0.2 * colorSpread).toString()}, {offset:1, color:color.createDarker(0.25 * colorSpread).toString()}]});
  17010. break;
  17011. case 'start':
  17012. fillStyle = new Ext.draw.gradient.Linear({stops:[{offset:0, color:color.createDarker(0.1 * colorSpread).toString()}, {offset:1, color:color.createLighter(0.2 * colorSpread).toString()}]});
  17013. break;
  17014. case 'end':
  17015. fillStyle = new Ext.draw.gradient.Linear({stops:[{offset:0, color:color.createDarker(0.1 * colorSpread).toString()}, {offset:1, color:color.createLighter(0.2 * colorSpread).toString()}]});
  17016. break;
  17017. case 'innerFront':
  17018. case 'innerBack':
  17019. fillStyle = new Ext.draw.gradient.Linear({stops:[{offset:0, color:color.createDarker(0.1 * colorSpread).toString()}, {offset:0.2, color:color.createLighter(0.2 * colorSpread).toString()}, {offset:0.7, color:colorString}, {offset:1, color:color.createDarker(0.1 * colorSpread).toString()}]});
  17020. break;
  17021. }
  17022. attr.fillStyle = fillStyle;
  17023. attr.canvasAttributes.fillStyle = fillStyle;
  17024. }, partZIndexUpdater:function(attr) {
  17025. var normalize = Ext.draw.sprite.AttributeParser.angle, rotation = attr.baseRotation, startAngle = attr.startAngle, endAngle = attr.endAngle, depth;
  17026. switch(attr.part) {
  17027. case 'top':
  17028. attr.zIndex = 6;
  17029. break;
  17030. case 'outerFront':
  17031. startAngle = normalize(startAngle + rotation);
  17032. endAngle = normalize(endAngle + rotation);
  17033. if (startAngle >= 0 && endAngle < 0) {
  17034. depth = Math.sin(startAngle);
  17035. } else {
  17036. if (startAngle <= 0 && endAngle > 0) {
  17037. depth = Math.sin(endAngle);
  17038. } else {
  17039. if (startAngle >= 0 && endAngle > 0) {
  17040. if (startAngle > endAngle) {
  17041. depth = 0;
  17042. } else {
  17043. depth = Math.max(Math.sin(startAngle), Math.sin(endAngle));
  17044. }
  17045. } else {
  17046. depth = 1;
  17047. }
  17048. }
  17049. }
  17050. attr.zIndex = 4 + depth;
  17051. break;
  17052. case 'outerBack':
  17053. attr.zIndex = 1;
  17054. break;
  17055. case 'start':
  17056. attr.zIndex = 4 + Math.sin(normalize(startAngle + rotation));
  17057. break;
  17058. case 'end':
  17059. attr.zIndex = 4 + Math.sin(normalize(endAngle + rotation));
  17060. break;
  17061. case 'innerFront':
  17062. attr.zIndex = 2;
  17063. break;
  17064. case 'innerBack':
  17065. attr.zIndex = 4 + Math.sin(normalize((startAngle + endAngle) / 2 + rotation));
  17066. break;
  17067. case 'bottom':
  17068. attr.zIndex = 0;
  17069. break;
  17070. }
  17071. attr.dirtyZIndex = true;
  17072. }, updatePlainBBox:function(plain) {
  17073. var attr = this.attr, part = attr.part, baseRotation = attr.baseRotation, centerX = attr.centerX, centerY = attr.centerY, rho, angle, x, y, sin, cos;
  17074. if (part === 'start') {
  17075. angle = attr.startAngle + baseRotation;
  17076. } else {
  17077. if (part === 'end') {
  17078. angle = attr.endAngle + baseRotation;
  17079. }
  17080. }
  17081. if (Ext.isNumber(angle)) {
  17082. sin = Math.sin(angle);
  17083. cos = Math.cos(angle);
  17084. x = Math.min(centerX + cos * attr.startRho, centerX + cos * attr.endRho);
  17085. y = centerY + sin * attr.startRho * attr.distortion;
  17086. plain.x = x;
  17087. plain.y = y;
  17088. plain.width = cos * (attr.endRho - attr.startRho);
  17089. plain.height = attr.thickness + sin * (attr.endRho - attr.startRho) * 2;
  17090. return;
  17091. }
  17092. if (part === 'innerFront' || part === 'innerBack') {
  17093. rho = attr.startRho;
  17094. } else {
  17095. rho = attr.endRho;
  17096. }
  17097. plain.width = rho * 2;
  17098. plain.height = rho * attr.distortion * 2 + attr.thickness;
  17099. plain.x = attr.centerX - rho;
  17100. plain.y = attr.centerY - rho * attr.distortion;
  17101. }, updateTransformedBBox:function(transform) {
  17102. if (this.attr.part === 'start' || this.attr.part === 'end') {
  17103. return this.callParent(arguments);
  17104. }
  17105. return this.updatePlainBBox(transform);
  17106. }, updatePath:function(path) {
  17107. if (!this.attr.globalAlpha) {
  17108. return;
  17109. }
  17110. if (this.attr.endAngle < this.attr.startAngle) {
  17111. return;
  17112. }
  17113. this[this.attr.part + 'Renderer'](path);
  17114. }, render:function(surface, ctx, rect) {
  17115. var me = this, renderer = me.getRenderer(), attr = me.attr, part = attr.part, itemCfg, changes;
  17116. if (!attr.globalAlpha || Ext.Number.isEqual(attr.startAngle, attr.endAngle, 1.0E-8)) {
  17117. return;
  17118. }
  17119. if (renderer) {
  17120. itemCfg = {type:'pie3dPart', part:attr.part, margin:attr.margin, distortion:attr.distortion, centerX:attr.centerX, centerY:attr.centerY, baseRotation:attr.baseRotation, startAngle:attr.startAngle, endAngle:attr.endAngle, startRho:attr.startRho, endRho:attr.endRho};
  17121. changes = Ext.callback(renderer, null, [me, itemCfg, me.getRendererData(), me.getRendererIndex()], 0, me.getSeries());
  17122. if (changes) {
  17123. if (changes.part) {
  17124. changes.part = part;
  17125. }
  17126. me.setAttributes(changes);
  17127. me.useAttributes(ctx, rect);
  17128. }
  17129. }
  17130. me.callParent([surface, ctx]);
  17131. me.bevelRenderer(surface, ctx);
  17132. if (attr.label && me.getMarker('labels')) {
  17133. me.placeLabel();
  17134. }
  17135. }, placeLabel:function() {
  17136. var me = this, attr = me.attr, attributeId = attr.attributeId, margin = attr.margin, distortion = attr.distortion, centerX = attr.centerX, centerY = attr.centerY, baseRotation = attr.baseRotation, startAngle = attr.startAngle + baseRotation, endAngle = attr.endAngle + baseRotation, midAngle = (startAngle + endAngle) / 2, startRho = attr.startRho + margin, endRho = attr.endRho + margin, midRho = (startRho + endRho) / 2, sin = Math.sin(midAngle), cos = Math.cos(midAngle), surfaceMatrix = me.surfaceMatrix,
  17137. label = me.getMarker('labels'), labelTpl = label.getTemplate(), calloutLine = labelTpl.getCalloutLine(), calloutLineLength = calloutLine && calloutLine.length || 40, labelCfg = {}, rendererParams, rendererChanges, x, y;
  17138. surfaceMatrix.appendMatrix(attr.matrix);
  17139. labelCfg.text = attr.label;
  17140. x = centerX + cos * midRho;
  17141. y = centerY + sin * midRho * distortion;
  17142. labelCfg.x = surfaceMatrix.x(x, y);
  17143. labelCfg.y = surfaceMatrix.y(x, y);
  17144. x = centerX + cos * endRho;
  17145. y = centerY + sin * endRho * distortion;
  17146. labelCfg.calloutStartX = surfaceMatrix.x(x, y);
  17147. labelCfg.calloutStartY = surfaceMatrix.y(x, y);
  17148. x = centerX + cos * (endRho + calloutLineLength);
  17149. y = centerY + sin * (endRho + calloutLineLength) * distortion;
  17150. labelCfg.calloutPlaceX = surfaceMatrix.x(x, y);
  17151. labelCfg.calloutPlaceY = surfaceMatrix.y(x, y);
  17152. labelCfg.calloutWidth = 2;
  17153. if (labelTpl.attr.renderer) {
  17154. rendererParams = [me.attr.label, label, labelCfg, me.getRendererData(), me.getRendererIndex()];
  17155. rendererChanges = Ext.callback(labelTpl.attr.renderer, null, rendererParams, 0, me.getSeries());
  17156. if (typeof rendererChanges === 'string') {
  17157. labelCfg.text = rendererChanges;
  17158. } else {
  17159. Ext.apply(labelCfg, rendererChanges);
  17160. }
  17161. }
  17162. me.putMarker('labels', labelCfg, attributeId);
  17163. me.putMarker('labels', {callout:1}, attributeId);
  17164. }, bevelRenderer:function(surface, ctx) {
  17165. var me = this, attr = me.attr, bevelWidth = attr.bevelWidth, params = me.bevelParams, i;
  17166. for (i = 0; i < params.length; i++) {
  17167. ctx.beginPath();
  17168. ctx.ellipse.apply(ctx, params[i]);
  17169. ctx.save();
  17170. ctx.lineWidth = bevelWidth;
  17171. ctx.strokeOpacity = bevelWidth ? 1 : 0;
  17172. ctx.strokeGradient = me.bevelGradient;
  17173. ctx.stroke(attr);
  17174. ctx.restore();
  17175. }
  17176. }, lidRenderer:function(path, thickness) {
  17177. var attr = this.attr, margin = attr.margin, distortion = attr.distortion, centerX = attr.centerX, centerY = attr.centerY, baseRotation = attr.baseRotation, startAngle = attr.startAngle + baseRotation, endAngle = attr.endAngle + baseRotation, midAngle = (startAngle + endAngle) / 2, startRho = attr.startRho, endRho = attr.endRho, sinEnd = Math.sin(endAngle), cosEnd = Math.cos(endAngle);
  17178. centerX += Math.cos(midAngle) * margin;
  17179. centerY += Math.sin(midAngle) * margin * distortion;
  17180. path.ellipse(centerX, centerY + thickness, startRho, startRho * distortion, 0, startAngle, endAngle, false);
  17181. path.lineTo(centerX + cosEnd * endRho, centerY + thickness + sinEnd * endRho * distortion);
  17182. path.ellipse(centerX, centerY + thickness, endRho, endRho * distortion, 0, endAngle, startAngle, true);
  17183. path.closePath();
  17184. }, topRenderer:function(path) {
  17185. this.lidRenderer(path, 0);
  17186. }, bottomRenderer:function(path) {
  17187. var attr = this.attr, none = Ext.util.Color.RGBA_NONE;
  17188. if (attr.globalAlpha < 1 || attr.fillOpacity < 1 || attr.shadowColor !== none) {
  17189. this.lidRenderer(path, attr.thickness);
  17190. }
  17191. }, sideRenderer:function(path, position) {
  17192. var attr = this.attr, margin = attr.margin, centerX = attr.centerX, centerY = attr.centerY, distortion = attr.distortion, baseRotation = attr.baseRotation, startAngle = attr.startAngle + baseRotation, endAngle = attr.endAngle + baseRotation, isFullPie = !attr.startAngle && Ext.Number.isEqual(Math.PI * 2, attr.endAngle, 1.0E-7), thickness = attr.thickness, startRho = attr.startRho, endRho = attr.endRho, angle = position === 'start' && startAngle || position === 'end' && endAngle, sin = Math.sin(angle),
  17193. cos = Math.cos(angle), isTranslucent = attr.globalAlpha < 1, isVisible = position === 'start' && cos < 0 || position === 'end' && cos > 0 || isTranslucent, midAngle;
  17194. if (isVisible && !isFullPie) {
  17195. midAngle = (startAngle + endAngle) / 2;
  17196. centerX += Math.cos(midAngle) * margin;
  17197. centerY += Math.sin(midAngle) * margin * distortion;
  17198. path.moveTo(centerX + cos * startRho, centerY + sin * startRho * distortion);
  17199. path.lineTo(centerX + cos * endRho, centerY + sin * endRho * distortion);
  17200. path.lineTo(centerX + cos * endRho, centerY + sin * endRho * distortion + thickness);
  17201. path.lineTo(centerX + cos * startRho, centerY + sin * startRho * distortion + thickness);
  17202. path.closePath();
  17203. }
  17204. }, startRenderer:function(path) {
  17205. this.sideRenderer(path, 'start');
  17206. }, endRenderer:function(path) {
  17207. this.sideRenderer(path, 'end');
  17208. }, rimRenderer:function(path, radius, isDonut, isFront) {
  17209. var me = this, attr = me.attr, margin = attr.margin, centerX = attr.centerX, centerY = attr.centerY, distortion = attr.distortion, baseRotation = attr.baseRotation, normalize = Ext.draw.sprite.AttributeParser.angle, startAngle = attr.startAngle + baseRotation, endAngle = attr.endAngle + baseRotation, midAngle = normalize((startAngle + endAngle) / 2), thickness = attr.thickness, isTranslucent = attr.globalAlpha < 1, isAllFront, isAllBack, params;
  17210. me.bevelParams = [];
  17211. startAngle = normalize(startAngle);
  17212. endAngle = normalize(endAngle);
  17213. centerX += Math.cos(midAngle) * margin;
  17214. centerY += Math.sin(midAngle) * margin * distortion;
  17215. isAllFront = startAngle >= 0 && endAngle >= 0;
  17216. isAllBack = startAngle <= 0 && endAngle <= 0;
  17217. function renderLeftFrontChunk() {
  17218. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, Math.PI, startAngle, true);
  17219. path.lineTo(centerX + Math.cos(startAngle) * radius, centerY + Math.sin(startAngle) * radius * distortion);
  17220. params = [centerX, centerY, radius, radius * distortion, 0, startAngle, Math.PI, false];
  17221. if (!isDonut) {
  17222. me.bevelParams.push(params);
  17223. }
  17224. path.ellipse.apply(path, params);
  17225. path.closePath();
  17226. }
  17227. function renderRightFrontChunk() {
  17228. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, 0, endAngle, false);
  17229. path.lineTo(centerX + Math.cos(endAngle) * radius, centerY + Math.sin(endAngle) * radius * distortion);
  17230. params = [centerX, centerY, radius, radius * distortion, 0, endAngle, 0, true];
  17231. if (!isDonut) {
  17232. me.bevelParams.push(params);
  17233. }
  17234. path.ellipse.apply(path, params);
  17235. path.closePath();
  17236. }
  17237. function renderLeftBackChunk() {
  17238. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, Math.PI, endAngle, false);
  17239. path.lineTo(centerX + Math.cos(endAngle) * radius, centerY + Math.sin(endAngle) * radius * distortion);
  17240. params = [centerX, centerY, radius, radius * distortion, 0, endAngle, Math.PI, true];
  17241. if (isDonut) {
  17242. me.bevelParams.push(params);
  17243. }
  17244. path.ellipse.apply(path, params);
  17245. path.closePath();
  17246. }
  17247. function renderRightBackChunk() {
  17248. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, startAngle, 0, false);
  17249. path.lineTo(centerX + radius, centerY);
  17250. params = [centerX, centerY, radius, radius * distortion, 0, 0, startAngle, true];
  17251. if (isDonut) {
  17252. me.bevelParams.push(params);
  17253. }
  17254. path.ellipse.apply(path, params);
  17255. path.closePath();
  17256. }
  17257. if (isFront) {
  17258. if (!isDonut || isTranslucent) {
  17259. if (startAngle >= 0 && endAngle < 0) {
  17260. renderLeftFrontChunk();
  17261. } else {
  17262. if (startAngle <= 0 && endAngle > 0) {
  17263. renderRightFrontChunk();
  17264. } else {
  17265. if (startAngle <= 0 && endAngle < 0) {
  17266. if (startAngle > endAngle) {
  17267. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, 0, Math.PI, false);
  17268. path.lineTo(centerX - radius, centerY);
  17269. params = [centerX, centerY, radius, radius * distortion, 0, Math.PI, 0, true];
  17270. if (!isDonut) {
  17271. me.bevelParams.push(params);
  17272. }
  17273. path.ellipse.apply(path, params);
  17274. path.closePath();
  17275. }
  17276. } else {
  17277. if (startAngle > endAngle) {
  17278. renderLeftFrontChunk();
  17279. renderRightFrontChunk();
  17280. } else {
  17281. params = [centerX, centerY, radius, radius * distortion, 0, startAngle, endAngle, false];
  17282. if (isAllFront && !isDonut || isAllBack && isDonut) {
  17283. me.bevelParams.push(params);
  17284. }
  17285. path.ellipse.apply(path, params);
  17286. path.lineTo(centerX + Math.cos(endAngle) * radius, centerY + Math.sin(endAngle) * radius * distortion + thickness);
  17287. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, endAngle, startAngle, true);
  17288. path.closePath();
  17289. }
  17290. }
  17291. }
  17292. }
  17293. }
  17294. } else {
  17295. if (isDonut || isTranslucent) {
  17296. if (startAngle >= 0 && endAngle < 0) {
  17297. renderLeftBackChunk();
  17298. } else {
  17299. if (startAngle <= 0 && endAngle > 0) {
  17300. renderRightBackChunk();
  17301. } else {
  17302. if (startAngle <= 0 && endAngle < 0) {
  17303. if (startAngle > endAngle) {
  17304. renderLeftBackChunk();
  17305. renderRightBackChunk();
  17306. } else {
  17307. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, startAngle, endAngle, false);
  17308. path.lineTo(centerX + Math.cos(endAngle) * radius, centerY + Math.sin(endAngle) * radius * distortion);
  17309. params = [centerX, centerY, radius, radius * distortion, 0, endAngle, startAngle, true];
  17310. if (isDonut) {
  17311. me.bevelParams.push(params);
  17312. }
  17313. path.ellipse.apply(path, params);
  17314. path.closePath();
  17315. }
  17316. } else {
  17317. if (startAngle > endAngle) {
  17318. path.ellipse(centerX, centerY + thickness, radius, radius * distortion, 0, -Math.PI, 0, false);
  17319. path.lineTo(centerX + radius, centerY);
  17320. params = [centerX, centerY, radius, radius * distortion, 0, 0, -Math.PI, true];
  17321. if (isDonut) {
  17322. me.bevelParams.push(params);
  17323. }
  17324. path.ellipse.apply(path, params);
  17325. path.closePath();
  17326. }
  17327. }
  17328. }
  17329. }
  17330. }
  17331. }
  17332. }, innerFrontRenderer:function(path) {
  17333. this.rimRenderer(path, this.attr.startRho, true, true);
  17334. }, innerBackRenderer:function(path) {
  17335. this.rimRenderer(path, this.attr.startRho, true, false);
  17336. }, outerFrontRenderer:function(path) {
  17337. this.rimRenderer(path, this.attr.endRho, false, true);
  17338. }, outerBackRenderer:function(path) {
  17339. this.rimRenderer(path, this.attr.endRho, false, false);
  17340. }});
  17341. Ext.define('Ext.chart.series.Pie3D', {extend:'Ext.chart.series.Polar', requires:['Ext.chart.series.sprite.Pie3DPart', 'Ext.draw.PathUtil'], type:'pie3d', seriesType:'pie3d', alias:'series.pie3d', is3D:true, config:{rect:[0, 0, 0, 0], thickness:35, distortion:0.5, donut:0, hidden:[], highlightCfg:{margin:20}, shadow:false}, rotationOffset:-Math.PI / 2, setField:function(value) {
  17342. return this.setXField(value);
  17343. }, getField:function() {
  17344. return this.getXField();
  17345. }, updateRotation:function(rotation) {
  17346. var attributes = {baseRotation:rotation + this.rotationOffset};
  17347. this.forEachSprite(function(sprite) {
  17348. sprite.setAttributes(attributes);
  17349. });
  17350. }, updateColors:function(colors) {
  17351. var chart;
  17352. this.setSubStyle({baseColor:colors});
  17353. if (!this.isConfiguring) {
  17354. chart = this.getChart();
  17355. if (chart) {
  17356. chart.refreshLegendStore();
  17357. }
  17358. }
  17359. }, applyShadow:function(shadow) {
  17360. if (shadow === true) {
  17361. shadow = {shadowColor:'rgba(0,0,0,0.8)', shadowBlur:30};
  17362. } else {
  17363. if (!Ext.isObject(shadow)) {
  17364. shadow = {shadowColor:Ext.util.Color.RGBA_NONE};
  17365. }
  17366. }
  17367. return shadow;
  17368. }, updateShadow:function(shadow) {
  17369. var me = this, sprites = me.getSprites(), spritesPerSlice = me.spritesPerSlice, ln = sprites && sprites.length, i, sprite;
  17370. for (i = 1; i < ln; i += spritesPerSlice) {
  17371. sprite = sprites[i];
  17372. if (sprite.attr.part === 'bottom') {
  17373. sprite.setAttributes(shadow);
  17374. }
  17375. }
  17376. }, getStyleByIndex:function(i) {
  17377. var indexStyle = this.callParent([i]), style = this.getStyle(), fillStyle = indexStyle.fillStyle || indexStyle.fill || indexStyle.color, strokeStyle = style.strokeStyle || style.stroke;
  17378. if (fillStyle) {
  17379. indexStyle.baseColor = fillStyle;
  17380. delete indexStyle.fillStyle;
  17381. delete indexStyle.fill;
  17382. delete indexStyle.color;
  17383. }
  17384. if (strokeStyle) {
  17385. indexStyle.strokeStyle = strokeStyle;
  17386. }
  17387. return indexStyle;
  17388. }, doUpdateStyles:function() {
  17389. var me = this, sprites = me.getSprites(), spritesPerSlice = me.spritesPerSlice, ln = sprites && sprites.length, i = 0, j = 0, k, style;
  17390. for (; i < ln; i += spritesPerSlice, j++) {
  17391. style = me.getStyleByIndex(j);
  17392. for (k = 0; k < spritesPerSlice; k++) {
  17393. sprites[i + k].setAttributes(style);
  17394. }
  17395. }
  17396. }, coordinateX:function() {
  17397. var me = this, store = me.getStore(), records = store.getData().items, recordCount = records.length, xField = me.getXField(), animation = me.getAnimation(), rotation = me.getRotation(), hidden = me.getHidden(), sprites = me.getSprites(true), spriteCount = sprites.length, spritesPerSlice = me.spritesPerSlice, center = me.getCenter(), offsetX = me.getOffsetX(), offsetY = me.getOffsetY(), radius = me.getRadius(), thickness = me.getThickness(), distortion = me.getDistortion(), renderer = me.getRenderer(),
  17398. rendererData = me.getRendererData(), highlight = me.getHighlight(), lastAngle = 0, twoPi = Math.PI * 2, delta = 1.0E-10, endAngles = [], sum = 0, value, unit, sprite, style, i, j;
  17399. for (i = 0; i < recordCount; i++) {
  17400. value = Math.abs(+records[i].get(xField)) || 0;
  17401. if (!hidden[i]) {
  17402. sum += value;
  17403. }
  17404. endAngles[i] = sum;
  17405. if (i >= hidden.length) {
  17406. hidden[i] = false;
  17407. }
  17408. }
  17409. if (sum === 0) {
  17410. return;
  17411. }
  17412. unit = 2 * Math.PI / sum;
  17413. for (i = 0; i < recordCount; i++) {
  17414. endAngles[i] *= unit;
  17415. }
  17416. for (i = 0; i < recordCount; i++) {
  17417. style = this.getStyleByIndex(i);
  17418. for (j = 0; j < spritesPerSlice; j++) {
  17419. sprite = sprites[i * spritesPerSlice + j];
  17420. sprite.setAnimation(animation);
  17421. sprite.setAttributes({centerX:center[0] + offsetX, centerY:center[1] + offsetY - thickness / 2, endRho:radius, startRho:radius * me.getDonut() / 100, baseRotation:rotation + me.rotationOffset, startAngle:lastAngle, endAngle:endAngles[i] - delta, thickness:thickness, distortion:distortion, globalAlpha:1});
  17422. sprite.setAttributes(style);
  17423. sprite.setConfig({renderer:renderer, rendererData:rendererData, rendererIndex:i});
  17424. }
  17425. lastAngle = endAngles[i];
  17426. }
  17427. for (i *= spritesPerSlice; i < spriteCount; i++) {
  17428. sprite = sprites[i];
  17429. sprite.setAnimation(animation);
  17430. sprite.setAttributes({startAngle:twoPi, endAngle:twoPi, globalAlpha:0, baseRotation:rotation + me.rotationOffset});
  17431. }
  17432. }, updateHighlight:function(highlight, oldHighlight) {
  17433. this.callParent([highlight, oldHighlight]);
  17434. this.forEachSprite(function(sprite) {
  17435. if (highlight) {
  17436. if (sprite.modifiers.highlight) {
  17437. sprite.modifiers.highlight.setConfig(highlight);
  17438. } else {
  17439. sprite.config.highlight = highlight;
  17440. sprite.addModifier(highlight, true);
  17441. }
  17442. }
  17443. });
  17444. }, updateLabelData:function() {
  17445. var me = this, store = me.getStore(), items = store.getData().items, sprites = me.getSprites(), label = me.getLabel(), labelField = label && label.getTemplate().getField(), hidden = me.getHidden(), spritesPerSlice = me.spritesPerSlice, ln, labels, sprite, name = 'labels', i, j;
  17446. if (sprites.length) {
  17447. if (labelField) {
  17448. labels = [];
  17449. for (j = 0, ln = items.length; j < ln; j++) {
  17450. labels.push(items[j].get(labelField));
  17451. }
  17452. }
  17453. for (i = 0, j = 0, ln = sprites.length; i < ln; i += spritesPerSlice, j++) {
  17454. sprite = sprites[i];
  17455. if (label) {
  17456. if (!sprite.getMarker(name)) {
  17457. sprite.bindMarker(name, label);
  17458. }
  17459. if (labels) {
  17460. sprite.setAttributes({label:labels[j]});
  17461. }
  17462. sprite.putMarker(name, {hidden:hidden[j]}, sprite.attr.attributeId);
  17463. } else {
  17464. sprite.releaseMarker(name);
  17465. }
  17466. }
  17467. }
  17468. }, applyRadius:function() {
  17469. var me = this, chart = me.getChart(), padding = chart.getInnerPadding(), rect = chart.getMainRect() || [0, 0, 1, 1], width = rect[2] - padding * 2, height = rect[3] - padding * 2 - me.getThickness(), horizontalRadius = width / 2, verticalRadius = horizontalRadius * me.getDistortion(), result;
  17470. if (verticalRadius > height / 2) {
  17471. result = height / (me.getDistortion() * 2);
  17472. } else {
  17473. result = horizontalRadius;
  17474. }
  17475. return Math.max(result, 0);
  17476. }, forEachSprite:function(fn) {
  17477. var sprites = this.sprites, ln = sprites.length, i;
  17478. for (i = 0; i < ln; i++) {
  17479. fn(sprites[i], Math.floor(i / this.spritesPerSlice));
  17480. }
  17481. }, updateRadius:function(radius) {
  17482. var donut;
  17483. this.getChart();
  17484. donut = this.getDonut();
  17485. this.forEachSprite(function(sprite) {
  17486. sprite.setAttributes({endRho:radius, startRho:radius * donut / 100});
  17487. });
  17488. }, updateDonut:function(donut) {
  17489. var radius;
  17490. this.getChart();
  17491. radius = this.getRadius();
  17492. this.forEachSprite(function(sprite) {
  17493. sprite.setAttributes({startRho:radius * donut / 100});
  17494. });
  17495. }, updateCenter:function(center) {
  17496. var offsetX, offsetY, thickness;
  17497. this.getChart();
  17498. offsetX = this.getOffsetX();
  17499. offsetY = this.getOffsetY();
  17500. thickness = this.getThickness();
  17501. this.forEachSprite(function(sprite) {
  17502. sprite.setAttributes({centerX:center[0] + offsetX, centerY:center[1] + offsetY - thickness / 2});
  17503. });
  17504. }, updateThickness:function(thickness) {
  17505. var center, offsetY;
  17506. this.getChart();
  17507. this.setRadius();
  17508. center = this.getCenter();
  17509. offsetY = this.getOffsetY();
  17510. this.forEachSprite(function(sprite) {
  17511. sprite.setAttributes({thickness:thickness, centerY:center[1] + offsetY - thickness / 2});
  17512. });
  17513. }, updateDistortion:function(distortion) {
  17514. this.getChart();
  17515. this.setRadius();
  17516. this.forEachSprite(function(sprite) {
  17517. sprite.setAttributes({distortion:distortion});
  17518. });
  17519. }, updateOffsetX:function(offsetX) {
  17520. var center;
  17521. this.getChart();
  17522. center = this.getCenter();
  17523. this.forEachSprite(function(sprite) {
  17524. sprite.setAttributes({centerX:center[0] + offsetX});
  17525. });
  17526. }, updateOffsetY:function(offsetY) {
  17527. var center, thickness;
  17528. this.getChart();
  17529. center = this.getCenter();
  17530. thickness = this.getThickness();
  17531. this.forEachSprite(function(sprite) {
  17532. sprite.setAttributes({centerY:center[1] + offsetY - thickness / 2});
  17533. });
  17534. }, updateAnimation:function(animation) {
  17535. this.getChart();
  17536. this.forEachSprite(function(sprite) {
  17537. sprite.setAnimation(animation);
  17538. });
  17539. }, updateRenderer:function(renderer) {
  17540. var rendererData;
  17541. this.getChart();
  17542. rendererData = this.getRendererData();
  17543. this.forEachSprite(function(sprite, itemIndex) {
  17544. sprite.setConfig({renderer:renderer, rendererData:rendererData, rendererIndex:itemIndex});
  17545. });
  17546. }, getRendererData:function() {
  17547. return {store:this.getStore(), angleField:this.getXField(), radiusField:this.getYField(), series:this};
  17548. }, getSprites:function(createMissing) {
  17549. var me = this, store = me.getStore(), sprites = me.sprites;
  17550. if (!store) {
  17551. return Ext.emptyArray;
  17552. }
  17553. if (sprites && !createMissing) {
  17554. return sprites;
  17555. }
  17556. var surface = me.getSurface(), records = store.getData().items, spritesPerSlice = me.spritesPerSlice, partCount = me.partNames.length, recordCount = records.length, sprite, i, j;
  17557. for (i = 0; i < recordCount; i++) {
  17558. if (!sprites[i * spritesPerSlice]) {
  17559. for (j = 0; j < partCount; j++) {
  17560. sprite = surface.add({type:'pie3dPart', part:me.partNames[j], series:me});
  17561. sprite.getAnimation().setDurationOn('baseRotation', 0);
  17562. sprites.push(sprite);
  17563. }
  17564. }
  17565. }
  17566. return sprites;
  17567. }, betweenAngle:function(x, a, b) {
  17568. var pp = Math.PI * 2, offset = this.rotationOffset;
  17569. a += offset;
  17570. b += offset;
  17571. x -= a;
  17572. b -= a;
  17573. x %= pp;
  17574. b %= pp;
  17575. x += pp;
  17576. b += pp;
  17577. x %= pp;
  17578. b %= pp;
  17579. return x < b || b === 0;
  17580. }, getItemForPoint:function(x, y) {
  17581. var me = this, sprites = me.getSprites(), spritesPerSlice = me.spritesPerSlice, result = null, store, records, hidden, i, ln, sprite, topPartIndex;
  17582. if (!sprites) {
  17583. return result;
  17584. }
  17585. store = me.getStore();
  17586. records = store.getData().items;
  17587. hidden = me.getHidden();
  17588. for (i = 0, ln = records.length; i < ln; i++) {
  17589. if (hidden[i]) {
  17590. continue;
  17591. }
  17592. topPartIndex = i * spritesPerSlice;
  17593. sprite = sprites[topPartIndex];
  17594. if (sprite.hitTest([x, y])) {
  17595. result = {series:me, sprite:sprites.slice(topPartIndex, topPartIndex + spritesPerSlice), index:i, record:records[i], category:'sprites', field:me.getXField()};
  17596. break;
  17597. }
  17598. }
  17599. return result;
  17600. }, provideLegendInfo:function(target) {
  17601. var me = this, store = me.getStore(), items, labelField, field, hidden, style, color, i;
  17602. if (store) {
  17603. items = store.getData().items;
  17604. labelField = me.getLabel().getTemplate().getField();
  17605. field = me.getField();
  17606. hidden = me.getHidden();
  17607. for (i = 0; i < items.length; i++) {
  17608. style = me.getStyleByIndex(i);
  17609. color = style.baseColor;
  17610. target.push({name:labelField ? String(items[i].get(labelField)) : field + ' ' + i, mark:color || 'black', disabled:hidden[i], series:me.getId(), index:i});
  17611. }
  17612. }
  17613. }}, function() {
  17614. var proto = this.prototype, definition = Ext.chart.series.sprite.Pie3DPart.def.getInitialConfig().processors.part;
  17615. proto.partNames = definition.replace(/^enums\(|\)/g, '').split(',');
  17616. proto.spritesPerSlice = proto.partNames.length;
  17617. });
  17618. Ext.define('Ext.chart.series.sprite.Polar', {extend:'Ext.chart.series.sprite.Series', inheritableStatics:{def:{processors:{centerX:'number', centerY:'number', startAngle:'number', endAngle:'number', startRho:'number', endRho:'number', baseRotation:'number'}, defaults:{centerX:0, centerY:0, startAngle:0, endAngle:Math.PI, startRho:0, endRho:150, baseRotation:0}, triggers:{centerX:'bbox', centerY:'bbox', startAngle:'bbox', endAngle:'bbox', startRho:'bbox', endRho:'bbox', baseRotation:'bbox'}}}, updatePlainBBox:function(plain) {
  17619. var attr = this.attr;
  17620. plain.x = attr.centerX - attr.endRho;
  17621. plain.y = attr.centerY + attr.endRho;
  17622. plain.width = attr.endRho * 2;
  17623. plain.height = attr.endRho * 2;
  17624. }});
  17625. Ext.define('Ext.chart.series.sprite.Radar', {alias:'sprite.radar', extend:'Ext.chart.series.sprite.Polar', getDataPointXY:function(index) {
  17626. var me = this, attr = me.attr, centerX = attr.centerX, centerY = attr.centerY, matrix = attr.matrix, minX = attr.dataMinX, maxX = attr.dataMaxX, dataX = attr.dataX, dataY = attr.dataY, endRho = attr.endRho, startRho = attr.startRho, baseRotation = attr.baseRotation, x, y, r, th, ox, oy, maxY;
  17627. if (attr.rangeY) {
  17628. maxY = attr.rangeY[1];
  17629. } else {
  17630. maxY = attr.dataMaxY;
  17631. }
  17632. th = (dataX[index] - minX) / (maxX - minX + 1) * 2 * Math.PI + baseRotation;
  17633. r = dataY[index] / maxY * (endRho - startRho) + startRho;
  17634. ox = centerX + Math.cos(th) * r;
  17635. oy = centerY + Math.sin(th) * r;
  17636. x = matrix.x(ox, oy);
  17637. y = matrix.y(ox, oy);
  17638. return [x, y];
  17639. }, render:function(surface, ctx) {
  17640. var me = this, attr = me.attr, dataX = attr.dataX, length = dataX.length, surfaceMatrix = me.surfaceMatrix, markerCfg = {}, i, x, y, xy;
  17641. ctx.beginPath();
  17642. for (i = 0; i < length; i++) {
  17643. xy = me.getDataPointXY(i);
  17644. x = xy[0];
  17645. y = xy[1];
  17646. if (i === 0) {
  17647. ctx.moveTo(x, y);
  17648. }
  17649. ctx.lineTo(x, y);
  17650. markerCfg.translationX = surfaceMatrix.x(x, y);
  17651. markerCfg.translationY = surfaceMatrix.y(x, y);
  17652. me.putMarker('markers', markerCfg, i, true);
  17653. }
  17654. ctx.closePath();
  17655. ctx.fillStroke(attr);
  17656. }});
  17657. Ext.define('Ext.chart.series.Radar', {extend:'Ext.chart.series.Polar', type:'radar', seriesType:'radar', alias:'series.radar', requires:['Ext.chart.series.sprite.Radar'], themeColorCount:function() {
  17658. return 1;
  17659. }, isStoreDependantColorCount:false, themeMarkerCount:function() {
  17660. return 1;
  17661. }, updateAngularAxis:function(axis) {
  17662. axis.processData(this);
  17663. }, updateRadialAxis:function(axis) {
  17664. axis.processData(this);
  17665. }, coordinateX:function() {
  17666. return this.coordinate('X', 0, 2);
  17667. }, coordinateY:function() {
  17668. return this.coordinate('Y', 1, 2);
  17669. }, updateCenter:function(center) {
  17670. this.setStyle({translationX:center[0] + this.getOffsetX(), translationY:center[1] + this.getOffsetY()});
  17671. this.doUpdateStyles();
  17672. }, updateRadius:function(radius) {
  17673. this.setStyle({endRho:radius});
  17674. this.doUpdateStyles();
  17675. }, updateRotation:function(rotation) {
  17676. var me = this, chart = me.getChart(), axes = chart.getAxes(), i, ln, axis;
  17677. for (i = 0, ln = axes.length; i < ln; i++) {
  17678. axis = axes[i];
  17679. axis.setRotation(rotation);
  17680. }
  17681. me.setStyle({rotationRads:rotation});
  17682. me.doUpdateStyles();
  17683. }, updateTotalAngle:function(totalAngle) {
  17684. this.processData();
  17685. }, getItemForPoint:function(x, y) {
  17686. var me = this, sprite = me.sprites && me.sprites[0], attr = sprite.attr, dataX = attr.dataX, length = dataX.length, store = me.getStore(), marker = me.getMarker(), threshhold, item, xy, i, bbox, markers;
  17687. if (me.getHidden()) {
  17688. return null;
  17689. }
  17690. if (sprite && marker) {
  17691. markers = sprite.getMarker('markers');
  17692. for (i = 0; i < length; i++) {
  17693. bbox = markers.getBBoxFor(i);
  17694. threshhold = (bbox.width + bbox.height) * 0.25;
  17695. xy = sprite.getDataPointXY(i);
  17696. if (Math.abs(xy[0] - x) < threshhold && Math.abs(xy[1] - y) < threshhold) {
  17697. item = {series:me, sprite:sprite, index:i, category:'markers', record:store.getData().items[i], field:me.getYField()};
  17698. return item;
  17699. }
  17700. }
  17701. }
  17702. return me.callParent(arguments);
  17703. }, getDefaultSpriteConfig:function() {
  17704. var config = this.callParent(), animation = {customDurations:{translationX:0, translationY:0, rotationRads:0, dataMinX:0, dataMaxX:0}};
  17705. if (config.animation) {
  17706. Ext.apply(config.animation, animation);
  17707. } else {
  17708. config.animation = animation;
  17709. }
  17710. return config;
  17711. }, getSprites:function() {
  17712. var me = this, chart = me.getChart(), sprites = me.sprites;
  17713. if (!chart) {
  17714. return Ext.emptyArray;
  17715. }
  17716. if (!sprites.length) {
  17717. me.createSprite();
  17718. }
  17719. return sprites;
  17720. }, provideLegendInfo:function(target) {
  17721. var me = this, style = me.getSubStyleWithTheme(), fill = style.fillStyle;
  17722. if (Ext.isArray(fill)) {
  17723. fill = fill[0];
  17724. }
  17725. target.push({name:me.getTitle() || me.getYField() || me.getId(), mark:(Ext.isObject(fill) ? fill.stops && fill.stops[0].color : fill) || style.strokeStyle || 'black', disabled:me.getHidden(), series:me.getId(), index:0});
  17726. }});
  17727. Ext.define('Ext.chart.series.sprite.Scatter', {alias:'sprite.scatterSeries', extend:'Ext.chart.series.sprite.Cartesian', renderClipped:function(surface, ctx, dataClipRect, surfaceClipRect) {
  17728. if (this.cleanRedraw) {
  17729. return;
  17730. }
  17731. var me = this, attr = me.attr, dataX = attr.dataX, dataY = attr.dataY, labels = attr.labels, series = me.getSeries(), isDrawLabels = labels && me.getMarker('labels'), surfaceMatrix = me.surfaceMatrix, matrix = me.attr.matrix, xx = matrix.getXX(), yy = matrix.getYY(), dx = matrix.getDX(), dy = matrix.getDY(), markerCfg = {}, changes, params, xScalingDirection = surface.getInherited().rtl && !attr.flipXY ? -1 : 1, left, right, top, bottom, x, y, i;
  17732. if (attr.flipXY) {
  17733. left = surfaceClipRect[1] - xx * xScalingDirection;
  17734. right = surfaceClipRect[1] + surfaceClipRect[3] + xx * xScalingDirection;
  17735. top = surfaceClipRect[0] - yy;
  17736. bottom = surfaceClipRect[0] + surfaceClipRect[2] + yy;
  17737. } else {
  17738. left = surfaceClipRect[0] - xx * xScalingDirection;
  17739. right = surfaceClipRect[0] + surfaceClipRect[2] + xx * xScalingDirection;
  17740. top = surfaceClipRect[1] - yy;
  17741. bottom = surfaceClipRect[1] + surfaceClipRect[3] + yy;
  17742. }
  17743. for (i = 0; i < dataX.length; i++) {
  17744. x = dataX[i];
  17745. y = dataY[i];
  17746. x = x * xx + dx;
  17747. y = y * yy + dy;
  17748. if (left <= x && x <= right && top <= y && y <= bottom) {
  17749. if (attr.renderer) {
  17750. markerCfg = {type:'markers', translationX:surfaceMatrix.x(x, y), translationY:surfaceMatrix.y(x, y)};
  17751. params = [me, markerCfg, {store:me.getStore()}, i];
  17752. changes = Ext.callback(attr.renderer, null, params, 0, series);
  17753. markerCfg = Ext.apply(markerCfg, changes);
  17754. } else {
  17755. markerCfg.translationX = surfaceMatrix.x(x, y);
  17756. markerCfg.translationY = surfaceMatrix.y(x, y);
  17757. }
  17758. me.putMarker('markers', markerCfg, i, !attr.renderer);
  17759. if (isDrawLabels && labels[i]) {
  17760. me.drawLabel(labels[i], x, y, i, surfaceClipRect);
  17761. }
  17762. }
  17763. }
  17764. }, drawLabel:function(text, dataX, dataY, labelId, rect) {
  17765. var me = this, attr = me.attr, label = me.getMarker('labels'), labelTpl = label.getTemplate(), labelCfg = me.labelCfg || (me.labelCfg = {}), surfaceMatrix = me.surfaceMatrix, labelX, labelY, labelOverflowPadding = attr.labelOverflowPadding, flipXY = attr.flipXY, halfHeight, labelBox, changes, params;
  17766. labelCfg.text = text;
  17767. labelBox = me.getMarkerBBox('labels', labelId, true);
  17768. if (!labelBox) {
  17769. me.putMarker('labels', labelCfg, labelId);
  17770. labelBox = me.getMarkerBBox('labels', labelId, true);
  17771. }
  17772. if (flipXY) {
  17773. labelCfg.rotationRads = Math.PI * 0.5;
  17774. } else {
  17775. labelCfg.rotationRads = 0;
  17776. }
  17777. halfHeight = labelBox.height / 2;
  17778. labelX = dataX;
  17779. switch(labelTpl.attr.display) {
  17780. case 'under':
  17781. labelY = dataY - halfHeight - labelOverflowPadding;
  17782. break;
  17783. case 'rotate':
  17784. labelX += labelOverflowPadding;
  17785. labelY = dataY - labelOverflowPadding;
  17786. labelCfg.rotationRads = -Math.PI / 4;
  17787. break;
  17788. default:
  17789. labelY = dataY + halfHeight + labelOverflowPadding;
  17790. }
  17791. labelCfg.x = surfaceMatrix.x(labelX, labelY);
  17792. labelCfg.y = surfaceMatrix.y(labelX, labelY);
  17793. if (labelTpl.attr.renderer) {
  17794. params = [text, label, labelCfg, {store:me.getStore()}, labelId];
  17795. changes = Ext.callback(labelTpl.attr.renderer, null, params, 0, me.getSeries());
  17796. if (typeof changes === 'string') {
  17797. labelCfg.text = changes;
  17798. } else {
  17799. Ext.apply(labelCfg, changes);
  17800. }
  17801. }
  17802. me.putMarker('labels', labelCfg, labelId);
  17803. }});
  17804. Ext.define('Ext.chart.series.Scatter', {extend:'Ext.chart.series.Cartesian', alias:'series.scatter', type:'scatter', seriesType:'scatterSeries', requires:['Ext.chart.series.sprite.Scatter'], config:{itemInstancing:null, marker:true}, themeMarkerCount:function() {
  17805. return 1;
  17806. }, provideLegendInfo:function(target) {
  17807. var me = this, style = me.getMarkerStyleByIndex(0), fill = style.fillStyle;
  17808. target.push({name:me.getTitle() || me.getYField() || me.getId(), mark:(Ext.isObject(fill) ? fill.stops && fill.stops[0].color : fill) || style.strokeStyle || 'black', disabled:me.getHidden(), series:me.getId(), index:0});
  17809. }});
  17810. Ext.define('Ext.chart.theme.Blue', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.blue', 'chart.theme.Blue'], config:{baseColor:'#4d7fe6'}});
  17811. Ext.define('Ext.chart.theme.BlueGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.blue-gradients', 'chart.theme.Blue:gradients'], config:{baseColor:'#4d7fe6', gradients:{type:'linear', degrees:90}}});
  17812. Ext.define('Ext.chart.theme.Category1', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category1', 'chart.theme.Category1'], config:{colors:['#f0a50a', '#c20024', '#2044ba', '#810065', '#7eae29']}});
  17813. Ext.define('Ext.chart.theme.Category1Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category1-gradients', 'chart.theme.Category1:gradients'], config:{colors:['#f0a50a', '#c20024', '#2044ba', '#810065', '#7eae29'], gradients:{type:'linear', degrees:90}}});
  17814. Ext.define('Ext.chart.theme.Category2', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category2', 'chart.theme.Category2'], config:{colors:['#6d9824', '#87146e', '#2a9196', '#d39006', '#1e40ac']}});
  17815. Ext.define('Ext.chart.theme.Category2Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category2-gradients', 'chart.theme.Category2:gradients'], config:{colors:['#6d9824', '#87146e', '#2a9196', '#d39006', '#1e40ac'], gradients:{type:'linear', degrees:90}}});
  17816. Ext.define('Ext.chart.theme.Category3', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category3', 'chart.theme.Category3'], config:{colors:['#fbbc29', '#ce2e4e', '#7e0062', '#158b90', '#57880e']}});
  17817. Ext.define('Ext.chart.theme.Category3Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category3-gradients', 'chart.theme.Category3:gradients'], config:{colors:['#fbbc29', '#ce2e4e', '#7e0062', '#158b90', '#57880e'], gradients:{type:'linear', degrees:90}}});
  17818. Ext.define('Ext.chart.theme.Category4', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category4', 'chart.theme.Category4'], config:{colors:['#ef5773', '#fcbd2a', '#4f770d', '#1d3eaa', '#9b001f']}});
  17819. Ext.define('Ext.chart.theme.Category4Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category4-gradients', 'chart.theme.Category4:gradients'], config:{colors:['#ef5773', '#fcbd2a', '#4f770d', '#1d3eaa', '#9b001f'], gradients:{type:'linear', degrees:90}}});
  17820. Ext.define('Ext.chart.theme.Category5', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category5', 'chart.theme.Category5'], config:{colors:['#7eae29', '#fdbe2a', '#910019', '#27b4bc', '#d74dbc']}});
  17821. Ext.define('Ext.chart.theme.Category5Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category5-gradients', 'chart.theme.Category5:gradients'], config:{colors:['#7eae29', '#fdbe2a', '#910019', '#27b4bc', '#d74dbc'], gradients:{type:'linear', degrees:90}}});
  17822. Ext.define('Ext.chart.theme.Category6', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category6', 'chart.theme.Category6'], config:{colors:['#44dce1', '#0b2592', '#996e05', '#7fb325', '#b821a1']}});
  17823. Ext.define('Ext.chart.theme.Category6Gradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.category6-gradients', 'chart.theme.Category6:gradients'], config:{colors:['#44dce1', '#0b2592', '#996e05', '#7fb325', '#b821a1'], gradients:{type:'linear', degrees:90}}});
  17824. Ext.define('Ext.chart.theme.DefaultGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.default-gradients', 'chart.theme.Base:gradients'], config:{gradients:{type:'linear', degrees:90}}});
  17825. Ext.define('Ext.chart.theme.Green', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.green', 'chart.theme.Green'], config:{baseColor:'#b1da5a'}});
  17826. Ext.define('Ext.chart.theme.GreenGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.green-gradients', 'chart.theme.Green:gradients'], config:{baseColor:'#b1da5a', gradients:{type:'linear', degrees:90}}});
  17827. Ext.define('Ext.chart.theme.Midnight', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.midnight', 'chart.theme.Midnight'], config:{colors:['#a837ff', '#4ac0f2', '#ff4d35', '#ff8809', '#61c102', '#ff37ea'], chart:{defaults:{captions:{title:{docked:'top', padding:5, style:{textAlign:'center', fontFamily:'default', fontWeight:'bold', fillStyle:'rgb(224, 224, 227)', fontSize:'default*1.6'}}, subtitle:{docked:'top', style:{textAlign:'center', fontFamily:'default', fontWeight:'normal',
  17828. fillStyle:'rgb(224, 224, 227)', fontSize:'default*1.3'}}, credits:{docked:'bottom', padding:5, style:{textAlign:'left', fontFamily:'default', fontWeight:'lighter', fillStyle:'rgb(224, 224, 227)', fontSize:'default'}}}, background:'rgb(52, 52, 53)'}}, axis:{defaults:{style:{strokeStyle:'rgb(224, 224, 227)'}, label:{fillStyle:'rgb(224, 224, 227)'}, title:{fillStyle:'rgb(224, 224, 227)'}, grid:{strokeStyle:'rgb(112, 112, 115)'}}}, series:{defaults:{label:{fillStyle:'rgb(224, 224, 227)'}}}, sprites:{text:{fillStyle:'rgb(224, 224, 227)'}},
  17829. legend:{label:{fillStyle:'white'}, border:{lineWidth:2, fillStyle:'rgba(255, 255, 255, 0.3)', strokeStyle:'rgb(150, 150, 150)'}, background:'rgb(52, 52, 53)'}}});
  17830. Ext.define('Ext.chart.theme.Muted', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.muted', 'chart.theme.Muted'], config:{colors:['#8ca640', '#974144', '#4091ba', '#8e658e', '#3b8d8b', '#b86465', '#d2af69', '#6e8852', '#3dcc7e', '#a6bed1', '#cbaa4b', '#998baa']}});
  17831. Ext.define('Ext.chart.theme.Purple', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.purple', 'chart.theme.Purple'], config:{baseColor:'#da5abd'}});
  17832. Ext.define('Ext.chart.theme.PurpleGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.purple-gradients', 'chart.theme.Purple:gradients'], config:{baseColor:'#da5abd', gradients:{type:'linear', degrees:90}}});
  17833. Ext.define('Ext.chart.theme.Red', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.red', 'chart.theme.Red'], config:{baseColor:'#e84b67'}});
  17834. Ext.define('Ext.chart.theme.RedGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.red-gradients', 'chart.theme.Red:gradients'], config:{baseColor:'#e84b67', gradients:{type:'linear', degrees:90}}});
  17835. Ext.define('Ext.chart.theme.Sky', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.sky', 'chart.theme.Sky'], config:{baseColor:'#4ce0e7'}});
  17836. Ext.define('Ext.chart.theme.SkyGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.sky-gradients', 'chart.theme.Sky:gradients'], config:{baseColor:'#4ce0e7', gradients:{type:'linear', degrees:90}}});
  17837. Ext.define('Ext.chart.theme.Yellow', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.yellow', 'chart.theme.Yellow'], config:{baseColor:'#fec935'}});
  17838. Ext.define('Ext.chart.theme.YellowGradients', {extend:'Ext.chart.theme.Base', singleton:true, alias:['chart.theme.yellow-gradients', 'chart.theme.Yellow:gradients'], config:{baseColor:'#fec935', gradients:{type:'linear', degrees:90}}});
  17839. Ext.define('Ext.chart.theme.series.Series', {config:{}});
  17840. Ext.define('Ext.chart.theme.series.Area', {extend:'Ext.chart.theme.series.Series', config:{}});
  17841. Ext.define('Ext.chart.theme.series.Bar', {extend:'Ext.chart.theme.series.Series', config:{}});
  17842. Ext.define('Ext.chart.theme.series.Bar3D', {extend:'Ext.chart.theme.series.Series', config:{}});
  17843. Ext.define('Ext.chart.theme.series.BoxPlot', {extend:'Ext.chart.theme.series.Series', config:{}});
  17844. Ext.define('Ext.chart.theme.series.CandleStick', {extend:'Ext.chart.theme.series.Series', config:{}});
  17845. Ext.define('Ext.chart.theme.series.Line', {extend:'Ext.chart.theme.series.Series', config:{}});
  17846. Ext.define('Ext.chart.theme.series.Pie', {extend:'Ext.chart.theme.series.Series', config:{}});
  17847. Ext.define('Ext.chart.theme.series.Pie3D', {extend:'Ext.chart.theme.series.Series', config:{}});
  17848. Ext.define('Ext.draw.Point', {requires:['Ext.draw.Draw', 'Ext.draw.Matrix'], isPoint:true, x:0, y:0, length:0, angle:0, angleUnits:'degrees', statics:{fly:function() {
  17849. var point = null;
  17850. return function(x, y) {
  17851. if (!point) {
  17852. point = new Ext.draw.Point;
  17853. }
  17854. point.constructor(x, y);
  17855. return point;
  17856. };
  17857. }()}, constructor:function(x, y) {
  17858. var me = this;
  17859. if (typeof x === 'number') {
  17860. me.x = x;
  17861. if (typeof y === 'number') {
  17862. me.y = y;
  17863. } else {
  17864. me.y = x;
  17865. }
  17866. } else {
  17867. if (Ext.isArray(x)) {
  17868. me.x = x[0];
  17869. me.y = x[1];
  17870. } else {
  17871. if (x) {
  17872. me.x = x.x;
  17873. me.y = x.y;
  17874. }
  17875. }
  17876. }
  17877. me.calculatePolar();
  17878. }, calculateCartesian:function() {
  17879. var me = this, length = me.length, angle = me.angle;
  17880. if (me.angleUnits === 'degrees') {
  17881. angle = Ext.draw.Draw.rad(angle);
  17882. }
  17883. me.x = Math.cos(angle) * length;
  17884. me.y = Math.sin(angle) * length;
  17885. }, calculatePolar:function() {
  17886. var me = this, x = me.x, y = me.y;
  17887. me.length = Math.sqrt(x * x + y * y);
  17888. me.angle = Math.atan2(y, x);
  17889. if (me.angleUnits === 'degrees') {
  17890. me.angle = Ext.draw.Draw.degrees(me.angle);
  17891. }
  17892. }, setX:function(x) {
  17893. this.x = x;
  17894. this.calculatePolar();
  17895. }, setY:function(y) {
  17896. this.y = y;
  17897. this.calculatePolar();
  17898. }, set:function(x, y) {
  17899. this.constructor(x, y);
  17900. }, setAngle:function(angle) {
  17901. this.angle = angle;
  17902. this.calculateCartesian();
  17903. }, setLength:function(length) {
  17904. this.length = length;
  17905. this.calculateCartesian();
  17906. }, setPolar:function(angle, length) {
  17907. this.angle = angle;
  17908. this.length = length;
  17909. this.calculateCartesian();
  17910. }, clone:function() {
  17911. return new Ext.draw.Point(this.x, this.y);
  17912. }, add:function(x, y) {
  17913. var fly = Ext.draw.Point.fly(x, y);
  17914. return new Ext.draw.Point(this.x + fly.x, this.y + fly.y);
  17915. }, sub:function(x, y) {
  17916. var fly = Ext.draw.Point.fly(x, y);
  17917. return new Ext.draw.Point(this.x - fly.x, this.y - fly.y);
  17918. }, mul:function(n) {
  17919. return new Ext.draw.Point(this.x * n, this.y * n);
  17920. }, div:function(n) {
  17921. return new Ext.draw.Point(this.x / n, this.y / n);
  17922. }, dot:function(x, y) {
  17923. var fly = Ext.draw.Point.fly(x, y);
  17924. return this.x * fly.x + this.y * fly.y;
  17925. }, equals:function(x, y) {
  17926. var fly = Ext.draw.Point.fly(x, y);
  17927. return this.x === fly.x && this.y === fly.y;
  17928. }, rotate:function(angle, center) {
  17929. var sin, cos, cx, cy, point;
  17930. if (this.angleUnits === 'degrees') {
  17931. angle = Ext.draw.Draw.rad(angle);
  17932. sin = Math.sin(angle);
  17933. cos = Math.cos(angle);
  17934. }
  17935. if (center) {
  17936. cx = center.x;
  17937. cy = center.y;
  17938. } else {
  17939. cx = 0;
  17940. cy = 0;
  17941. }
  17942. point = Ext.draw.Matrix.fly([cos, sin, -sin, cos, cx - cos * cx + cy * sin, cy - cos * cy + cx * -sin]).transformPoint(this);
  17943. return new Ext.draw.Point(point);
  17944. }, transform:function(matrix) {
  17945. if (matrix && matrix.isMatrix) {
  17946. return new Ext.draw.Point(matrix.transformPoint(this));
  17947. } else {
  17948. if (arguments.length === 6) {
  17949. return new Ext.draw.Point(Ext.draw.Matrix.fly(arguments).transformPoint(this));
  17950. } else {
  17951. Ext.raise('Invalid parameters.');
  17952. }
  17953. }
  17954. }, round:function() {
  17955. return new Ext.draw.Point(Math.round(this.x), Math.round(this.y));
  17956. }, ceil:function() {
  17957. return new Ext.draw.Point(Math.ceil(this.x), Math.ceil(this.y));
  17958. }, floor:function() {
  17959. return new Ext.draw.Point(Math.floor(this.x), Math.floor(this.y));
  17960. }, abs:function(x, y) {
  17961. return new Ext.draw.Point(Math.abs(this.x), Math.abs(this.y));
  17962. }, normalize:function(factor) {
  17963. var x = this.x, y = this.y, k = (factor || 1) / Math.sqrt(x * x + y * y);
  17964. return new Ext.draw.Point(x * k, y * k);
  17965. }, getDistanceToLine:function(p1, p2) {
  17966. var n, pp1;
  17967. if (arguments.length === 4) {
  17968. p1 = new Ext.draw.Point(arguments[0], arguments[1]);
  17969. p2 = new Ext.draw.Point(arguments[2], arguments[3]);
  17970. }
  17971. n = p2.sub(p1).normalize();
  17972. pp1 = p1.sub(this);
  17973. return pp1.sub(n.mul(pp1.dot(n)));
  17974. }, isZero:function() {
  17975. return this.x === 0 && this.y === 0;
  17976. }, isNumber:function() {
  17977. return Ext.isNumber(this.x) && Ext.isNumber(this.y);
  17978. }});
  17979. Ext.define('Ext.draw.plugin.SpriteEvents', {extend:'Ext.plugin.Abstract', alias:'plugin.spriteevents', requires:['Ext.draw.overrides.hittest.All'], mouseMoveEvents:{mousemove:true, mouseover:true, mouseout:true}, spriteMouseMoveEvents:{spritemousemove:true, spritemouseover:true, spritemouseout:true}, init:function(drawContainer) {
  17980. var handleEvent = 'handleEvent';
  17981. this.drawContainer = drawContainer;
  17982. drawContainer.addElementListener({click:handleEvent, dblclick:handleEvent, mousedown:handleEvent, mousemove:handleEvent, mouseup:handleEvent, mouseover:handleEvent, mouseout:handleEvent, priority:1001, scope:this});
  17983. }, hasSpriteMouseMoveListeners:function() {
  17984. var listeners = this.drawContainer.hasListeners, name;
  17985. for (name in this.spriteMouseMoveEvents) {
  17986. if (name in listeners) {
  17987. return true;
  17988. }
  17989. }
  17990. return false;
  17991. }, hitTestEvent:function(e) {
  17992. var items = this.drawContainer.getItems(), surface, sprite, i;
  17993. for (i = items.length - 1; i >= 0; i--) {
  17994. surface = items.get(i);
  17995. sprite = surface.hitTestEvent(e);
  17996. if (sprite) {
  17997. return sprite;
  17998. }
  17999. }
  18000. return null;
  18001. }, handleEvent:function(e) {
  18002. var me = this, drawContainer = me.drawContainer, isMouseMoveEvent = e.type in me.mouseMoveEvents, lastSprite = me.lastSprite, sprite;
  18003. if (isMouseMoveEvent && !me.hasSpriteMouseMoveListeners()) {
  18004. return;
  18005. }
  18006. sprite = me.hitTestEvent(e);
  18007. if (isMouseMoveEvent && !Ext.Object.equals(sprite, lastSprite)) {
  18008. if (lastSprite) {
  18009. drawContainer.fireEvent('spritemouseout', lastSprite, e);
  18010. }
  18011. if (sprite) {
  18012. drawContainer.fireEvent('spritemouseover', sprite, e);
  18013. }
  18014. }
  18015. if (sprite) {
  18016. drawContainer.fireEvent('sprite' + e.type, sprite, e);
  18017. }
  18018. me.lastSprite = sprite;
  18019. }});
  18020. Ext.define('Ext.chart.interactions.ItemInfo', {extend:'Ext.chart.interactions.Abstract', type:'iteminfo', alias:'interaction.iteminfo', config:{gestures:{tap:'onInfoGesture'}, panel:{modal:true, centered:true, width:300, height:200, scrollable:'vertical', hideOnMaskTap:true, fullscreen:false, hidden:false, zIndex:30}}, item:null, applyPanel:function(panel, oldPanel) {
  18021. return Ext.factory(panel, 'Ext.Panel', oldPanel);
  18022. }, updatePanel:function(panel, oldPanel) {
  18023. if (panel) {
  18024. panel.on('hide', 'reset', this);
  18025. }
  18026. if (oldPanel) {
  18027. oldPanel.un('hide', 'reset', this);
  18028. }
  18029. }, onInfoGesture:function(e, element) {
  18030. var me = this, panel = me.getPanel(), item = me.getItemForEvent(e);
  18031. if (item) {
  18032. me.item = item;
  18033. me.fireEvent('show', me, item, panel);
  18034. Ext.Viewport.add(panel);
  18035. panel.show('pop');
  18036. item.series.setAttributesForItem(item, {highlighted:true});
  18037. me.sync();
  18038. }
  18039. return false;
  18040. }, reset:function() {
  18041. var me = this, item = me.item;
  18042. if (item) {
  18043. item.series.setAttributesForItem(item, {highlighted:false});
  18044. me.item = null;
  18045. me.sync();
  18046. }
  18047. }});