ichart.1.2.js 195 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815
  1. /**
  2. * ichartjs Library v1.2 http://www.ichartjs.com/
  3. *
  4. * @author wanghe
  5. * @Copyright 2013 wanghetommy@gmail.com Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
  8. */
  9. ;
  10. (function(window) {
  11. var ua = navigator.userAgent.toLowerCase(), mc = function(e) {
  12. return e.test(ua)
  13. }, ts = Object.prototype.toString, isOpera = mc(/opera/), isChrome = mc(/\bchrome\b/), isWebKit = mc(/webkit/), isSafari = !isChrome && mc(/safari/), isIE = !isOpera && mc(/msie/), supportCanvas = !!document.createElement('canvas').getContext, isGecko = !isWebKit
  14. && mc(/gecko/), isMobile = mc(/ipod|ipad|iphone|android/gi), arithmetic = {
  15. Linear : function(t, b, c, d) {
  16. return c * t / d + b;
  17. },
  18. Cubic : {
  19. easeIn : function(t, b, c, d) {
  20. return c * (t /= d) * t * t + b;
  21. },
  22. easeOut : function(t, b, c, d) {
  23. return c * ((t = t / d - 1) * t * t + 1) + b;
  24. },
  25. easeInOut : function(t, b, c, d) {
  26. if ((t /= d / 2) < 1)
  27. return c / 2 * t * t * t + b;
  28. return c / 2 * ((t -= 2) * t * t + 2) + b;
  29. }
  30. }
  31. };
  32. var iChart_ = (function(window) {
  33. /**
  34. * spirit from jquery
  35. */
  36. var isReady = false, readyBound = false, readyList = [], DOMContentLoaded = (function() {
  37. if (document.addEventListener) {
  38. return function() {
  39. document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
  40. ready();
  41. };
  42. } else if (document.attachEvent) {
  43. return function() {
  44. if (document.readyState === "complete") {
  45. document.detachEvent("onreadystatechange", DOMContentLoaded);
  46. ready();
  47. }
  48. };
  49. }
  50. })(), doScrollCheck = function() {
  51. if (isReady) {
  52. return;
  53. }
  54. try {
  55. document.documentElement.doScroll("left");
  56. } catch (e) {
  57. setTimeout(doScrollCheck, 1);
  58. return;
  59. }
  60. ready();
  61. }, ready = function() {
  62. if (!isReady) {
  63. isReady = true;
  64. for ( var i = 0; i < readyList.length; i++) {
  65. readyList[i].call(document);
  66. }
  67. readyList = [];
  68. }
  69. }, bindReady = function() {
  70. if (readyBound)
  71. return;
  72. readyBound = true;
  73. if (document.readyState === "complete") {
  74. return setTimeout(ready, 1);
  75. }
  76. if (document.addEventListener) {
  77. document.addEventListener("DOMContentLoaded", DOMContentLoaded, false);
  78. window.addEventListener("load", ready, false);
  79. } else if (document.attachEvent) {
  80. document.attachEvent("onreadystatechange", DOMContentLoaded);
  81. window.attachEvent("onload", ready);
  82. var toplevel = false;
  83. try {
  84. toplevel = window.frameElement == null;
  85. } catch (e) {
  86. }
  87. if (document.documentElement.doScroll && toplevel) {
  88. doScrollCheck();
  89. }
  90. }
  91. }, bind = function(fn) {
  92. bindReady();
  93. if (isReady)
  94. fn.call(document, _);
  95. else
  96. readyList.push(function() {
  97. return fn.call(this);
  98. });
  99. }, _ = function(selector) {
  100. if (!selector || selector.nodeType) {
  101. return selector;
  102. }
  103. if (typeof selector === "string") {
  104. if (selector.indexOf("#") != -1) {
  105. selector = selector.substring(1);
  106. }
  107. return document.getElementById(selector);
  108. }
  109. if (typeof selector === "function") {
  110. bind(selector);
  111. }
  112. };
  113. _.apply = function(d, e) {
  114. if (d && e && typeof e == "object") {
  115. for ( var a in e) {
  116. if (typeof e[a] != 'undefined')
  117. d[a] = e[a]
  118. }
  119. }
  120. if (!e && d) {
  121. var clone = {};
  122. for ( var a in d) {
  123. clone[a] = d[a]
  124. }
  125. return clone;
  126. }
  127. return d
  128. };
  129. _.apply(_, {
  130. version : "1.0",
  131. email : 'taylor@ichartjs.com',
  132. isEmpty : function(C, e) {
  133. return C === null || C === undefined || ((_.isArray(C) && !C.length)) || (!e ? C === "" : false)
  134. },
  135. isArray : function(e) {
  136. return ts.apply(e) === "[object Array]"
  137. },
  138. isDate : function(e) {
  139. return ts.apply(e) === "[object Date]"
  140. },
  141. isObject : function(e) {
  142. return !!e && ts.apply(e) === "[object Object]"
  143. },
  144. isFunction : function(e) {
  145. return ts.apply(e) === "[object Function]"
  146. },
  147. isNumber : function(e) {
  148. return typeof e === "number" && isFinite(e)
  149. },
  150. isString : function(e) {
  151. return typeof e === "string"
  152. },
  153. isBoolean : function(e) {
  154. return typeof e === "boolean"
  155. },
  156. isFalse : function(e) {
  157. return typeof e === "boolean" && !e;
  158. },
  159. isElement : function(e) {
  160. return e ? !!e.tagName : false
  161. },
  162. isDefined : function(e) {
  163. return typeof e !== "undefined"
  164. }
  165. });
  166. /**
  167. * only get the attr that target not exist
  168. */
  169. _.applyIf = function(d, e) {
  170. if (d && _.isObject(e)) {
  171. for ( var a in e) {
  172. if (_.isDefined(e[a]) && !_.isDefined(d[a]))
  173. d[a] = e[a]
  174. }
  175. }
  176. if (!e && d) {
  177. return _.apply(d);
  178. }
  179. return d
  180. };
  181. /**
  182. * there will apply a deep clone
  183. */
  184. _.merge = function(d, e, f) {
  185. if (d && _.isObject(e)) {
  186. for ( var a in e) {
  187. if (_.isDefined(e[a])) {
  188. if (_.isObject(e[a])) {
  189. if (_.isObject(d[a])) {
  190. _.merge(d[a], e[a]);
  191. } else {
  192. d[a] = _.clone(e[a], true);
  193. }
  194. } else {
  195. d[a] = e[a];
  196. }
  197. }
  198. }
  199. if (_.isObject(f)) {
  200. return _.merge(d, f);
  201. }
  202. }
  203. return d;
  204. };
  205. /**
  206. * clone attribute that given
  207. */
  208. _.clone = function(a, e, deep) {
  209. var d = {};
  210. if (_.isArray(a)&& _.isObject(e)) {
  211. for ( var i = 0; i < a.length; i++) {
  212. if (deep && _.isObject(e[a[i]]))
  213. d[a[i]] = _.clone(e[a[i]],deep);
  214. else
  215. d[a[i]] = e[a[i]];
  216. }
  217. } else if (_.isObject(a)) {
  218. for ( var b in a) {
  219. // avoid recursion reference
  220. if (e && _.isObject(a[b])&& !(a[b].ICHARTJS_OBJECT))
  221. d[b] = _.clone(a[b], e);
  222. else
  223. d[b] = a[b];
  224. }
  225. }
  226. return d;
  227. };
  228. _.override = function(e, D) {
  229. if (e&&D) {
  230. var C = e.prototype;
  231. _.apply(C, D);
  232. if (_.isIE && D.hasOwnProperty("toString")) {
  233. C.toString = D.toString
  234. }
  235. }
  236. };
  237. /**
  238. * spirit from ext2.0
  239. */
  240. _.extend = function() {
  241. var C = function(E) {
  242. for ( var D in E) {
  243. this[D] = E[D];
  244. }
  245. };
  246. var e = Object.prototype.constructor;
  247. return function(G, O) {
  248. var J = function() {
  249. G.apply(this, arguments);
  250. }
  251. var E = function() {
  252. }, H, D = G.prototype;
  253. E.prototype = D;
  254. H = J.prototype = new E();
  255. H.constructor = J;
  256. J.superclass = D;
  257. if (D.constructor == e) {
  258. D.constructor = G;
  259. }
  260. J.override = function(F) {
  261. _.override(J, F);
  262. };
  263. H.superclass = H.supr = (function() {
  264. return D;
  265. });
  266. H.override = C;
  267. _.override(J, O);
  268. J.extend = function(F) {
  269. return _.extend(J, F)
  270. };
  271. J.plugin_ = {};
  272. J.plugin = function(M,F) {
  273. if (_.isString(M) && _.isFunction(F))
  274. J.plugin_[M] = F;
  275. };
  276. return J;
  277. }
  278. }();
  279. var sin = Math.sin, cos = Math.cos, atan = Math.atan, tan = Math.tan, acos = Math.acos, sqrt = Math.sqrt, abs = Math.abs, pi = Math.PI, pi2 = 2 * pi, ceil = Math.ceil, round = Math.round, floor = Math.floor, max = Math.max, min = Math.min, pF = parseFloat,
  280. Registry={},Repository={},
  281. factor = function(v, w) {
  282. if (v == 0)
  283. return v;
  284. var M = abs(v),f = 0.1;
  285. if(M>1){
  286. while(M>1){
  287. M = M/10;
  288. f = f*10;
  289. }
  290. return floor(v/f+w)*f;
  291. }else{
  292. f = 1;
  293. while(M<1){
  294. M = M*10;
  295. f = f *10;
  296. }
  297. return round(v*f+w)/f;
  298. }
  299. }, colors = {
  300. white : 'rgb(255,255,255)',
  301. green : 'rgb(0,128,0)',
  302. gray : 'rgb(80,80,80)',
  303. red : 'rgb(255,0,0)',
  304. blue : 'rgb(0,0,255)',
  305. yellow : 'rgb(255,255,0)',
  306. black : 'rgb(0,0,0)'
  307. }, hex2Rgb = function(hex) {
  308. hex = hex.replace(/#/g, "").replace(/^(\w)(\w)(\w)$/, "$1$1$2$2$3$3");
  309. return (hex.length==7?'rgba(':'rgb(') + parseInt(hex.substring(0, 2), 16) + ',' + parseInt(hex.substring(2, 4), 16) + ',' + parseInt(hex.substring(4, 6), 16) + (hex.length==7?',0.'+hex.substring(6,7)+')':')');
  310. }, i2hex = function(N) {
  311. return ('0' + parseInt(N).toString(16)).slice(-2);
  312. }, rgb2Hex = function(rgb) {
  313. var m = rgb.match(/rgb\((\d+),(\d+),(\d+)\)/);
  314. return m ? ('#' + i2hex(m[1]) + i2hex(m[2]) + i2hex(m[3])).toUpperCase() : null;
  315. }, c2a = function(rgb) {
  316. var result = /rgb\((\w*),(\w*),(\w*)\)/.exec(rgb);
  317. if (result) {
  318. return new Array(result[1], result[2], result[3]);
  319. }
  320. result = /rgba\((\w*),(\w*),(\w*),(.*)\)/.exec(rgb);
  321. if (result) {
  322. return new Array(result[1], result[2], result[3], result[4]);
  323. }
  324. throw new Error("invalid colors value '" + rgb + "'");
  325. }, toHsv = function(r, g, b) {
  326. if (_.isArray(r)) {
  327. g = r[1];
  328. b = r[2];
  329. r = r[0];
  330. }
  331. r = r / 255;
  332. g = g / 255;
  333. b = b / 255;
  334. var m = max(max(r, g), b), mi = min(min(r, g), b), dv = m - mi;
  335. if (dv == 0) {
  336. return new Array(0, 0, m);
  337. }
  338. var h;
  339. if (r == m) {
  340. h = (g - b) / dv;
  341. } else if (g == m) {
  342. h = (b - r) / dv + 2;
  343. } else if (b == m) {
  344. h = (r - g) / dv + 4;
  345. }
  346. h *= 60;
  347. if (h < 0)
  348. h += 360;
  349. return new Array(h, dv / m, m);
  350. }, toRgb = function(color) {
  351. if (!color)
  352. return color;
  353. color = color.replace(/\s/g, '').toLowerCase();
  354. // Look for rgb(255,255,255)
  355. if (/^rgb\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3}\)$/.exec(color)) {
  356. return color;
  357. }
  358. // Look for rgba(255,255,255,0.3)
  359. if (/^rgba\([0-9]{1,3},[0-9]{1,3},[0-9]{1,3},(0(\.[0-9])?|1(\.0)?)\)$/.exec(color)) {
  360. return color;
  361. }
  362. // Look for #a0b1c2 or #fff
  363. if (/^#(([a-fA-F0-9]{6,7})|([a-fA-F0-9]{3}))$/.exec(color))
  364. return hex2Rgb(color);
  365. // Look a string for green
  366. if (colors[color])
  367. return colors[color];
  368. throw new Error("invalid colors value '" + color + "'");
  369. }, hsv2Rgb = function(h, s, v, a) {
  370. if (_.isArray(h)) {
  371. a = s;
  372. s = h[1];
  373. v = h[2];
  374. h = h[0];
  375. }
  376. var r, g, b,
  377. hi = floor(h / 60) % 6,
  378. f = h / 60 - hi,
  379. p = v * (1 - s),
  380. q = v * (1 - s * f),
  381. t = v * (1 - s * (1 - f));
  382. switch (hi) {
  383. case 0 :
  384. r = v;
  385. g = t;
  386. b = p;
  387. break;
  388. case 1 :
  389. r = q;
  390. g = v;
  391. b = p;
  392. break;
  393. case 2 :
  394. r = p;
  395. g = v;
  396. b = t;
  397. break;
  398. case 3 :
  399. r = p;
  400. g = q;
  401. b = v;
  402. break;
  403. case 4 :
  404. r = t;
  405. g = p;
  406. b = v;
  407. break;
  408. case 5 :
  409. r = v;
  410. g = p;
  411. b = q;
  412. break;
  413. }
  414. return 'rgb' + (a ? 'a' : '') + '(' + round(r * 255) + ',' + round(g * 255) + ',' + round(b * 255) + (a ? ',' + a + ')' : ')');
  415. },
  416. /**
  417. * the increment of s(v) of hsv model
  418. */
  419. s_inc = 0.05, v_inc = 0.14,
  420. inc = function(v, iv) {
  421. iv = iv || v_inc;
  422. if (v > 0.5) {
  423. return iv - (1 - v) / 10;
  424. } else if (v > 0.1) {
  425. return iv - 0.16 + v / 5;
  426. } else {
  427. return v > iv ? iv : v / 2;
  428. }
  429. },
  430. /**
  431. * @method anole,make color darker or lighter
  432. * @param {Boolean} d true:dark,false:light
  433. * @param {Object} rgb:color
  434. * @param {Number} iv (0-1)
  435. * @param {Number} is (0-1)
  436. */
  437. anole = function(d, rgb, iv, is) {
  438. if (!rgb)
  439. return rgb;
  440. rgb = c2a(toRgb(rgb));
  441. var hsv = toHsv(rgb);
  442. is = is!=0?(is || s_inc):is;
  443. hsv[1] -= is;
  444. if (d) {
  445. hsv[2] -= inc(hsv[2], iv);
  446. hsv[1] = _.upTo(hsv[1], 1);
  447. hsv[2] = _.lowTo(hsv[2], 0);
  448. } else {
  449. hsv[2] += inc((1 - hsv[2]), iv);
  450. hsv[1] = _.lowTo(hsv[1], 0);
  451. hsv[2] = _.upTo(hsv[2], 1);
  452. }
  453. return hsv2Rgb(hsv, rgb[3]);
  454. },
  455. topi = function(v){
  456. if(v==0)return 0;
  457. if(v%pi2==0)return pi2;
  458. return v%pi2;
  459. };
  460. _.apply(_, {
  461. getFont : function(w, s, f, u) {
  462. return w + " " + s + (u||"px")+" " + f;
  463. },
  464. /**
  465. * obtain the Dom Document*/
  466. getDoc : function() {
  467. var doc = window.contentWindow ? window.contentWindow.document : window.contentDocument ? window.contentDocument : window.document;
  468. return doc;
  469. },
  470. /**
  471. * define the interface,the subclass must implement it
  472. */
  473. DefineAbstract : function(M, H) {
  474. if (!H[M])
  475. throw new Error("Cannot instantiate the type '" + H.type + "'.you must implements it with method '" + M + "'.");
  476. },
  477. getAA : function(tf) {
  478. if (tf == 'linear')
  479. return arithmetic.Linear;
  480. if (tf == 'easeInOut' || tf == 'easeIn' || tf == 'easeOut')
  481. return arithmetic.Cubic[tf];
  482. return arithmetic.Linear;
  483. },
  484. /**
  485. * simple noConflict implements
  486. */
  487. noConflict : function() {
  488. return iChart_;
  489. },
  490. plugin : function(t, m, f) {
  491. if (_.isFunction(t))
  492. t.plugin(m, f);
  493. },
  494. parsePadding : function(s, d) {
  495. s = s || 0;
  496. if (_.isNumber(s))
  497. return new Array(s, s, s, s);
  498. if (_.isArray(s))
  499. return s;
  500. d = d || 0;
  501. s = s.replace(/^\s+|\s+$/g, "").replace(/\s{2,}/g, /\s/).replace(/\s/g, ',').split(",");
  502. if (s.length == 1) {
  503. s[0] = s[1] = s[2] = s[3] = pF(s[0]) || d;
  504. } else if (s.length == 2) {
  505. s[0] = s[2] = pF(s[0]) || d;
  506. s[1] = s[3] = pF(s[1]) || d;
  507. } else if (s.length == 3) {
  508. s[0] = pF(s[0]) || d;
  509. s[1] = s[3] = pF(s[1]) || d;
  510. s[2] = pF(s[2]) || d;
  511. } else {
  512. s[0] = pF(s[0]) || d;
  513. s[1] = pF(s[1]) || d;
  514. s[2] = pF(s[2]) || d;
  515. s[3] = pF(s[3]) || d;
  516. }
  517. return s;
  518. },
  519. /**
  520. * the distance of two point
  521. */
  522. distanceP2P : function(x1, y1, x2, y2) {
  523. return sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  524. },
  525. atan2Radian : function(ox, oy, x, y) {
  526. if (ox == x) {
  527. if (y > oy)
  528. return pi / 2;
  529. return pi * 3 / 2;
  530. }
  531. if (oy == y) {
  532. if (x > ox)
  533. return 0;
  534. return pi;
  535. }
  536. var q = _.quadrant(ox, oy, x, y),
  537. r = atan(abs((oy - y) / (ox - x)));
  538. return q?(q == 3?pi2:pi)+(q == 2?r:-r):r;
  539. },
  540. angle2Radian : function(a) {
  541. return a * pi / 180;
  542. },
  543. radian2Angle : function(r) {
  544. return r * 180 / pi;
  545. },
  546. /**
  547. * indicate angle in which quadrant,and it different from concept of Math.this will return 0 if it in first quadrant(other eg.0,1,2,3)
  548. */
  549. quadrant : function(ox, oy, x, y) {
  550. if (ox < x) {
  551. if (oy < y) {
  552. return 0;
  553. } else {
  554. return 3;
  555. }
  556. } else {
  557. if (oy < y) {
  558. return 1;
  559. } else {
  560. return 2;
  561. }
  562. }
  563. },
  564. toPI2 : function(a) {
  565. while(a<0)
  566. a+=pi2;
  567. return a;
  568. },
  569. visible:function(s, e, f){
  570. if(s>=e)return [];
  571. var q1 = _.quadrantd(s),q2 = _.quadrantd(e);
  572. if((q1==2||q1==3)&&(q2==2||q2==3)&&((e-s)<pi))return[];
  573. s = _.toPI2(s);
  574. e = _.toPI2(e);
  575. if(e<=s){e+=pi2;}
  576. if(s > pi){s = pi2;}
  577. else if(e>pi2){
  578. return [{s:s,e:pi,f:f},{s:pi2,e:e,f:f}]
  579. }else if(e>pi){
  580. e = pi;
  581. }
  582. return {s:s,e:e,f:f};
  583. },
  584. quadrantd : function(a) {
  585. if(a==0)return 0;
  586. if(a % pi2==0)return 3;
  587. while(a<0)
  588. a+=pi2;
  589. return ceil(2 * (a % pi2) / pi)-1;
  590. },
  591. upTo : function(u, v) {
  592. return v > u ? u : v;
  593. },
  594. lowTo : function(l, v) {
  595. return v < l ? l : v;
  596. },
  597. between : function(l, u, v) {
  598. return l>u?_.between(u, l, v):(v > u ? u : v < l ? l : v);
  599. },
  600. inRange : function(l, u, v) {
  601. return u > v && l < v;
  602. },
  603. angleInRange : function(l, u, v) {
  604. v = (v -l);
  605. v = v<0?v+pi2:v;
  606. v = v %pi2;
  607. return (u -l) > v;
  608. },
  609. angleZInRange : function(l, u, v) {
  610. return u < l?(v > l || v < u):(u > v && l < v);
  611. },
  612. inRangeClosed : function(l, u, v) {
  613. return u >= v && l <= v;
  614. },
  615. inEllipse : function(x, y, a, b) {
  616. return (x * x / a / a + y * y / b / b) <= 1;
  617. },
  618. p2Point : function(x, y, a, C) {
  619. return {
  620. x : x + cos(a) * C,
  621. y : y + sin(a) * C
  622. }
  623. },
  624. toRgb:toRgb,
  625. toRgba:function(c,o){
  626. var rgb = c2a(toRgb(c));
  627. return 'rgba(' + rgb[0]+',' + rgb[1]+',' + rgb[2]+',' + o +')';
  628. },
  629. /**
  630. * vector point
  631. */
  632. vectorP2P : function(x, y, radian) {
  633. if (!radian) {
  634. y = _.angle2Radian(y);
  635. x = _.angle2Radian(x);
  636. }
  637. y = sin(y);
  638. return {
  639. x : y * sin(x),
  640. y : y * cos(x)
  641. }
  642. },
  643. uid : function(k) {
  644. return (k || 'ichartjs') + '_' + ceil(Math.random()*10000)+new Date().getTime().toString().substring(4);
  645. },
  646. register:function(c){
  647. if (_.isString(c)) {
  648. Repository[c.toLowerCase()] = c;
  649. }else{
  650. var id = c.get('id');
  651. if(!id||id==''){
  652. id = _.uid(c.type);
  653. while(Registry[id]){
  654. id = _.uid(c.type);
  655. }
  656. c.push('id',id);
  657. }
  658. if(Registry[id]){
  659. throw new Error("exist reduplicate id :"+id);
  660. }
  661. c.id = id;
  662. Registry[id] = c;
  663. }
  664. },
  665. create:function(C){
  666. if(!C.type||!Repository[C.type]){
  667. throw new Error("TypeNotFoundException["+C.type+"]");
  668. }
  669. return new _[Repository[C.type]](C);
  670. },
  671. get:function(id){
  672. return Registry[id];
  673. },
  674. isPercent:function(v){
  675. return _.isString(v)&&v.match(/(.*)%/);
  676. },
  677. parsePercent:function(v,f){
  678. if(_.isString(v)){
  679. v = v.match(/(.*)%/);
  680. if(v){
  681. v = f?floor(pF(v[1])*f/100):v[1]/100;
  682. }
  683. }
  684. return (!v ||v <= 0 || v > f)?f:v;
  685. },
  686. parseFloat : function(v, d) {
  687. if (!_.isNumber(v)) {
  688. v = pF(v);
  689. if (!_.isNumber(v))
  690. throw new Error("[" + d +"]=" +v + "is not a valid number.");
  691. }
  692. return v;
  693. },
  694. ceil : function(max) {
  695. return factor(max,1);
  696. },
  697. floor : function(max, f) {
  698. return factor(max,-1);
  699. },
  700. _2D : '2d',
  701. _3D : '3d',
  702. light : function(rgb, iv, is) {
  703. return anole(false, rgb, iv, is);
  704. },
  705. dark : function(rgb, iv, is) {
  706. return anole(true, rgb, iv, is);
  707. },
  708. fixPixel : function(v) {
  709. return _.isNumber(v) ? v : pF(v.replace('px', "")) || 0;
  710. },
  711. toPixel : function(v) {
  712. return _.isNumber(v) ? v + 'px' : _.fixPixel(v) + 'px';
  713. },
  714. emptyFn : function() {
  715. return true;
  716. },
  717. supportCanvas : supportCanvas,
  718. isOpera : isOpera,
  719. isWebKit : isWebKit,
  720. isChrome : isChrome,
  721. isSafari : isSafari,
  722. isIE : isIE,
  723. isGecko : isGecko,
  724. isMobile : isMobile,
  725. touch: "ontouchend" in document,
  726. FRAME : isMobile ? 30 : 60
  727. });
  728. _.Assert = {
  729. isTrue : function(v, cause) {
  730. if (v !== true)
  731. throw new Error(cause);
  732. }
  733. };
  734. /**
  735. * shim layer with setTimeout fallback
  736. */
  737. _.requestAnimFrame = (function() {
  738. var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
  739. window.setTimeout(callback, 1000 / 60);
  740. };
  741. return function(f){raf(f)}
  742. })();
  743. /**
  744. * defined Event
  745. */
  746. _.Event = {
  747. addEvent : function(ele, type, fn, useCapture) {
  748. if (ele.addEventListener)
  749. ele.addEventListener(type, fn, useCapture);
  750. else if (ele.attachEvent)
  751. ele.attachEvent('on' + type, fn);
  752. else
  753. ele['on' + type] = fn;
  754. },
  755. fix : function(e) {
  756. /**
  757. * Fix event for mise
  758. */
  759. if (typeof (e) == 'undefined') {
  760. e = window.event;
  761. }
  762. var E = {
  763. target:e.target,
  764. pageX : e.pageX,
  765. pageY : e.pageY,
  766. offsetX : e.offsetX,
  767. offsetY : e.offsetY,
  768. stopPropagation:false,
  769. //time: new Date().getTime(),
  770. event:e
  771. };
  772. /**
  773. * This is mainly for FF which doesn't provide offsetX
  774. */
  775. if (typeof (e.offsetX) == 'undefined') {
  776. /**
  777. * Fix target property, if necessary
  778. */
  779. if (!e.target) {
  780. E.target = e.srcElement || document;
  781. }
  782. if(e.targetTouches){
  783. E.pageX = e.targetTouches[0].pageX;
  784. E.pageY = e.targetTouches[0].pageY;
  785. }
  786. /**
  787. * Calculate pageX/Y if missing and clientX/Y available
  788. */
  789. if (E.pageX == null && e.clientX != null) {
  790. var doc = document.documentElement, body = document.body;
  791. E.pageX = e.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
  792. E.pageY = e.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
  793. }
  794. /**
  795. * Browser not with offsetX and offsetY
  796. */
  797. var x = 0, y = 0, obj = e.target;
  798. while (obj != document.body && obj) {
  799. x += obj.offsetLeft-(obj.scrollLeft||0);
  800. y += obj.offsetTop;
  801. obj = obj.offsetParent;
  802. }
  803. E.offsetX = E.pageX - x;
  804. E.offsetY = E.pageY - y;
  805. }
  806. E.x = E.offsetX;
  807. E.y = E.offsetY;
  808. /**
  809. * Any browser that doesn't implement stopPropagation() (MSIE)
  810. */
  811. if (!e.stopPropagation) {
  812. e.stopPropagation = function() {
  813. window.event.cancelBubble = true;
  814. }
  815. }
  816. return E;
  817. }
  818. };
  819. return _;
  820. })(window);
  821. /**
  822. * Add useful method,need to optimized
  823. */
  824. Array.prototype.each = function(f, s) {
  825. var j = this.length, r;
  826. for ( var i = 0; i < j; i++) {
  827. r = s ? f.call(s, this[i], i) : f(this[i], i);
  828. if (typeof r === "boolean" && !r) {
  829. break
  830. }
  831. };
  832. return this;
  833. };
  834. Array.prototype.eachAll = function(f, s) {
  835. this.each(function(d, i) {
  836. if (iChart_.isArray(d)) {
  837. return d.eachAll(f, s);
  838. } else {
  839. return s ? f.call(s, d, i) : f(d, i);
  840. }
  841. }, s);
  842. };
  843. Array.prototype.sor = function(f) {
  844. var _=this,L = _.length-1,T;
  845. for(var i = 0; i < L; i++){
  846. for (var j = L; j > i;j--) {
  847. if (f ? !f(_[j], _[j - 1]) : (_[j] < _[j - 1])) {
  848. T = _[j];
  849. _[j] = _[j - 1];
  850. _[j - 1] = T;
  851. }
  852. }
  853. }
  854. };
  855. window.iChart = iChart_;
  856. if (!window.$) {
  857. window.$ = window.iChart;
  858. }
  859. })(window);
  860. ;(function($){
  861. /**
  862. * @overview This is base class of all element.All must extend this so that has ability for configuration and event
  863. * this class include some base attribute
  864. * @component#$.Element
  865. * @extend#Object
  866. */
  867. $.Element = function(config) {
  868. var _ = this._();
  869. /**
  870. * indicate the element's type
  871. */
  872. _.type = 'element';
  873. _.ICHARTJS_OBJECT = true;
  874. /**
  875. * define abstract method
  876. */
  877. $.DefineAbstract('configure', _);
  878. $.DefineAbstract('afterConfiguration', _);
  879. /**
  880. * All of the configuration will in this property
  881. */
  882. _.options = {};
  883. _.set({
  884. /**
  885. * @cfg {Object} Specifies the border for this element.
  886. * Available property are:
  887. * @Option enable {boolean} If enable the border
  888. * @Option color {String} the border's color.(default to '#BCBCBC')
  889. * @Option style {String} the border's style.(default to 'solid')
  890. * @Option width {Number/String} the border's width.If given array,the option radius will be 0.(default to 1)
  891. * @Option radius {Number/String} the border's radius.(default to 0)
  892. */
  893. border : {
  894. enable : false,
  895. color : '#BCBCBC',
  896. style : 'solid',
  897. width : 1,
  898. radius : 0
  899. },
  900. /**
  901. * @cfg {Boolean} Specifies whether the element should be show a shadow.In general there will be get a high render speed when apply false.(default to false)
  902. */
  903. shadow : false,
  904. /**
  905. * @cfg {String} Specifies the color of your shadow is.(default to '#666666')
  906. */
  907. shadow_color : '#666666',
  908. /**
  909. * @cfg {Number} Specifies How blur you want your shadow to be.(default to 4)
  910. */
  911. shadow_blur : 4,
  912. /**
  913. * @cfg {Number} Specifies Horizontal distance (x-axis) between the shadow and the shape in pixel.(default to 0)
  914. */
  915. shadow_offsetx : 0,
  916. /**
  917. * @cfg {Number} Specifies Vertical distance (y-axis) between the shadow and the shape in pixel.(default to 0)
  918. */
  919. shadow_offsety : 0
  920. });
  921. /**
  922. * variable for short
  923. */
  924. _.W = 'width';
  925. _.H = 'height';
  926. _.O = 'top';
  927. _.B = 'bottom';
  928. _.L = 'left';
  929. _.R = 'right';
  930. _.C = 'center';
  931. _.X = 'originx';
  932. _.Y = 'originy';
  933. /**
  934. * the running variable cache
  935. */
  936. _.variable = {};
  937. /**
  938. * the root of all events
  939. */
  940. _.events = {
  941. 'mouseup':[],
  942. 'touchstart':[],
  943. 'touchmove':[],
  944. 'touchend':[],
  945. 'mousedown':[],
  946. 'dblclick':[]
  947. };
  948. _.registerEvent(
  949. /**
  950. * @event Fires after the element initializing is finished this is for test
  951. * @paramter $.Painter#this
  952. */
  953. 'initialize');
  954. _.initialization = false;
  955. /**
  956. * inititalize configure
  957. */
  958. _.configure.apply(_, Array.prototype.slice.call(arguments, 1));
  959. /**
  960. * clone the original config
  961. */
  962. _.default_ = $.clone(_.options,true);
  963. /**
  964. * megre customize config
  965. */
  966. _.set(config);
  967. _.afterConfiguration(_);
  968. }
  969. $.Element.prototype = {
  970. _:function(){return this},
  971. afterConfiguration : function(_) {
  972. /**
  973. * register customize event
  974. */
  975. if ($.isObject(_.get('listeners'))) {
  976. for ( var e in _.get('listeners')) {
  977. _.on(e, _.get('listeners')[e]);
  978. }
  979. }
  980. _.initialize();
  981. /**
  982. * fire the initialize event,this probable use to unit test
  983. */
  984. _.fireEvent(_, 'initialize', [_]);
  985. },
  986. registerEvent : function() {
  987. for ( var i = 0; i < arguments.length; i++) {
  988. this.events[arguments[i]] = [];
  989. }
  990. },
  991. fireString : function(socpe, name, args, s) {
  992. var t = this.fireEvent(socpe, name, args);
  993. return $.isString(t) ? t : (t!==true&&$.isDefined(t)?t.toString():s);
  994. },
  995. fireEvent : function(socpe, name, args) {
  996. var L = this.events[name].length;
  997. if (L == 1)
  998. return this.events[name][0].apply(socpe, args);
  999. var r = true;
  1000. for ( var i = 0; i < L; i++) {
  1001. if(!this.events[name][i].apply(socpe, args))
  1002. r = false;
  1003. }
  1004. return r;
  1005. },
  1006. on : function(n, fn) {
  1007. if($.isString(n)&&$.isArray(this.events[n])){
  1008. this.events[n].push(fn);
  1009. }else if($.isArray(n)){
  1010. n.each(function(c){this.on(c, fn)},this);
  1011. }
  1012. return this;
  1013. },
  1014. getPlugin:function(n){
  1015. return this.constructor.plugin_[n];
  1016. },
  1017. set : function(c) {
  1018. if ($.isObject(c))
  1019. $.merge(this.options, c);
  1020. },
  1021. pushIf : function(n, v) {
  1022. if (!$.isDefined(this.get(n))||this.get(n)==null) {
  1023. return this.push(n, v);
  1024. }
  1025. return this.get(n);
  1026. },
  1027. /**
  1028. * average write speed about 0.013ms
  1029. */
  1030. push : function(n, v) {
  1031. var A = n.split("."),L=A.length - 1,V = this.options;
  1032. for (var i = 0; i < L; i++) {
  1033. if (!V[A[i]])
  1034. V[A[i]] = {};
  1035. V = V[A[i]];
  1036. }
  1037. V[A[L]] = v;
  1038. return v;
  1039. },
  1040. /**
  1041. * average read speed about 0.005ms
  1042. */
  1043. get : function(n) {
  1044. var A = n.split("."), V = this.options[A[0]];
  1045. for (var i = 1; i < A.length; i++) {
  1046. if (!V)
  1047. return null;
  1048. V = V[A[i]];
  1049. }
  1050. return V;
  1051. }
  1052. }
  1053. /**
  1054. * @end
  1055. */
  1056. /**
  1057. * @overview The interface this class defined d,so the sub class has must capability to draw and aware of event. this class is a abstract class,so you should not try to initialize it.
  1058. * @component#$.Painter
  1059. * @extend#$.Element
  1060. */
  1061. $.Painter = $.extend($.Element, {
  1062. configure : function() {
  1063. /**
  1064. * indicate the element's type
  1065. */
  1066. this.type = 'painter';
  1067. this.dimension = $._2D;
  1068. /**
  1069. * define abstract method
  1070. */
  1071. $.DefineAbstract('commonDraw', this);
  1072. $.DefineAbstract('initialize', this);
  1073. this.set({
  1074. /**
  1075. * @cfg {String} Specifies the default strokeStyle of the canvas's context in this element.(defaults to 'gray')
  1076. */
  1077. strokeStyle : 'gray',
  1078. /**
  1079. * @cfg {Number} Specifies the padding for this element in pixel,the same rule as css padding.(defaults to 10)
  1080. */
  1081. padding : 10,
  1082. /**
  1083. * @cfg {String} Specifies the font's color for this element.(defaults to 'black')
  1084. */
  1085. color : 'black',
  1086. /**
  1087. * @cfg {Number} Specifies Horizontal offset(x-axis) in pixel.(default to 0)
  1088. */
  1089. offsetx : 0,
  1090. /**
  1091. * @cfg {Number}Specifies Vertical distance (y-axis) in pixel.(default to 0)
  1092. */
  1093. offsety : 0,
  1094. /**
  1095. * @cfg {String} Specifies the backgroundColor for this element.(defaults to 'FDFDFD')
  1096. */
  1097. background_color : '#FEFEFE',
  1098. /**
  1099. * @cfg {float} Specifies the factor make color dark or light for this element,relative to background-color,the bigger the value you set,the larger the color changed.scope{0.01 - 0.5}.(defaults to '0.15')
  1100. */
  1101. color_factor : 0.15,
  1102. /**
  1103. * @inner {String} ('2d','3d')
  1104. */
  1105. style : '',
  1106. /**
  1107. * @cfg {Object} Here,specify as true by default
  1108. */
  1109. border : {
  1110. enable : true
  1111. },
  1112. /**
  1113. * @cfg {Boolean} True to apply the gradient.(default to false)
  1114. */
  1115. gradient : false,
  1116. /**
  1117. * @cfg {String} Specifies the gradient mode of background.(defaults to 'LinearGradientUpDown')
  1118. * @Option 'LinearGradientUpDown'
  1119. * @Option 'LinearGradientDownUp'
  1120. * @Option 'LinearGradientLeftRight'
  1121. * @Option 'LinearGradientRightLeft'
  1122. * @Option 'RadialGradientOutIn'
  1123. * @Option 'RadialGradientInOut'
  1124. */
  1125. gradient_mode:'LinearGradientUpDown',
  1126. /**
  1127. * @cfg {Number}Specifies the z-index.(default to 0)
  1128. */
  1129. z_index : 0,
  1130. /**
  1131. * @cfg {Object} A config object containing one or more event handlers.(default to null)
  1132. */
  1133. listeners : null,
  1134. /**
  1135. * @cfg {Number} If you want to totally override the positioning of the chart,you should setting it.(default to null)
  1136. */
  1137. originx : null,
  1138. /**
  1139. * @cfg {Number} If you want to totally override the positioning of the chart,you should setting it.(default to null)
  1140. */
  1141. originy : null
  1142. });
  1143. this.variable.event = {
  1144. mouseover : false
  1145. };
  1146. this.variable.animation = {}
  1147. /**
  1148. * register the common event
  1149. */
  1150. this.registerEvent(
  1151. /**
  1152. * @event Fires when this element is clicked
  1153. * @paramter $.Painter#this
  1154. * @paramter EventObject#e The click event object
  1155. * @paramter Object#param The additional parameter
  1156. */
  1157. 'click',
  1158. /**
  1159. * @event Fires when the mouse move on the element
  1160. * @paramter $.Painter#this
  1161. * @paramter EventObject#e The mousemove event object
  1162. */
  1163. 'mousemove',
  1164. /**
  1165. * @event Fires when the mouse hovers over the element
  1166. * @paramter $.Painter#this
  1167. * @paramter EventObject#e The mouseover event object
  1168. */
  1169. 'mouseover',
  1170. /**
  1171. * @event Fires when the mouse exits the element
  1172. * @paramter $.Painter#this
  1173. * @paramter EventObject#e The mouseout event object
  1174. */
  1175. 'mouseout',
  1176. /**
  1177. * @event Fires before the element drawing.Return false from an event handler to stop the draw.
  1178. * @paramter $.Painter#this
  1179. */
  1180. 'beforedraw',
  1181. /**
  1182. * @event Fires after the element drawing when calling the draw method.
  1183. * @paramter $.Painter#this
  1184. */
  1185. 'draw');
  1186. },
  1187. is3D : function() {
  1188. return this.dimension == $._3D;
  1189. },
  1190. applyGradient:function(x,y,w,h){
  1191. var _ = this._();
  1192. if(_.get('gradient')&&_.get('f_color')){
  1193. _.push('f_color', _.T.gradient(x||_.x||0,y||_.y||0,w||_.get(_.W),h||_.get(_.H),[_.get('dark_color'), _.get('light_color')],_.get('gradient_mode')));
  1194. _.push('light_color', _.T.gradient(x||_.x||0,y||_.y||0,w||_.get(_.W),h||_.get(_.H),[_.get('background_color'), _.get('light_color')],_.get('gradient_mode')));
  1195. _.push('f_color_',_.get('f_color'));
  1196. }
  1197. },
  1198. /**
  1199. * @method The commnd fire to draw the chart use configuration,
  1200. * this is a abstract method.Currently known,both <link>$.Chart</link> and <link>$.Component</link> implement this method.
  1201. * @return void
  1202. */
  1203. draw : function(e,comb) {
  1204. if(comb){
  1205. /**
  1206. * fire the root Refresh
  1207. */
  1208. this.root.draw(e);
  1209. }else{
  1210. /**
  1211. * fire the beforedraw event
  1212. */
  1213. if (!this.fireEvent(this, 'beforedraw', [this,e])) {
  1214. return this;
  1215. }
  1216. /**
  1217. * execute the commonDraw() that the subClass implement
  1218. */
  1219. this.commonDraw(this,e);
  1220. /**
  1221. * fire the draw event
  1222. */
  1223. this.fireEvent(this, 'draw', [this,e]);
  1224. }
  1225. },
  1226. inject : function(c) {
  1227. if (c) {
  1228. this.root = c;
  1229. this.target = this.T = c.T;
  1230. }
  1231. },
  1232. doConfig : function() {
  1233. var _ = this._(), p = $.parsePadding(_.get('padding')), b = _.get('border.enable'), b = b ? $.parsePadding(_.get('border.width')) : [0, 0, 0, 0], bg = $.toRgb(_.get('background_color')), f = _.get('color_factor'),g=_.get('gradient')?0:null;
  1234. _.set({
  1235. border_top:b[0],
  1236. border_right:b[1],
  1237. border_bottom:b[2],
  1238. border_left:b[3],
  1239. hborder:b[1] + b[3],
  1240. vborder:b[0] + b[2],
  1241. padding_top:p[0] + b[0],
  1242. padding_right:p[1] + b[1],
  1243. padding_bottom:p[2] + b[2],
  1244. padding_left:p[3] + b[3],
  1245. hpadding:p[1] + p[3] + b[1] + b[3],
  1246. vpadding:p[0] + p[2] + b[0] + b[2]
  1247. });
  1248. if (_.get('shadow')===true) {
  1249. _.push('shadow', {
  1250. color : _.get('shadow_color'),
  1251. blur : _.get('shadow_blur'),
  1252. offsetx : _.get('shadow_offsetx'),
  1253. offsety : _.get('shadow_offsety')
  1254. });
  1255. }
  1256. _.push('f_color', bg);
  1257. _.push('f_color_', bg);
  1258. _.push("light_color", $.light(bg, f,g));
  1259. _.push("dark_color", $.dark(bg, f*0.8,g));
  1260. _.push("light_color2", $.light(bg, f * 2,g));
  1261. if(_.is3D()&&!_.get('xAngle_')){
  1262. var P = $.vectorP2P(_.get('xAngle'),_.get('yAngle'));
  1263. _.push('xAngle_',P.x);
  1264. _.push('yAngle_',P.y);
  1265. }
  1266. }
  1267. });
  1268. /**
  1269. * @end
  1270. */
  1271. /**
  1272. *
  1273. * @overview the base class use for Html componment
  1274. * @component#$.Html
  1275. * @extend#$.Element
  1276. */
  1277. $.Html = $.extend($.Element,{
  1278. configure : function(T) {
  1279. /**
  1280. * indicate the element's type
  1281. */
  1282. this.type = 'html';
  1283. this.T = T;
  1284. /**
  1285. * define abstract method
  1286. */
  1287. $.DefineAbstract('beforeshow',this);
  1288. this.set({
  1289. animation:true,
  1290. /**
  1291. * @cfg If true the component will has defalut action when event fired.(default to true)
  1292. */
  1293. default_action:true,
  1294. /**
  1295. * @inner Specifies the width of this element in pixels.
  1296. */
  1297. width:0,
  1298. /**
  1299. * @inner Specifies the height of this element in pixels.
  1300. */
  1301. height:0,
  1302. /**
  1303. * @cfg {String} Custom style specification to be applied to this element.(default to '')
  1304. * like this:'padding:10px;font-size:12px'
  1305. */
  1306. style:'',
  1307. /**
  1308. * @inner The z-index of this element.(default to 999)
  1309. */
  1310. index:999,
  1311. /**
  1312. * @inner The top of this element.(default to 0)
  1313. */
  1314. offset_top:0,
  1315. /**
  1316. * @inner The left of this element.(default to 0)
  1317. */
  1318. offset_left:0
  1319. });
  1320. this.transitions = "";
  1321. },
  1322. initialize:function(){
  1323. var _ = this._();
  1324. _.wrap = _.get('wrap');
  1325. _.dom = document.createElement("div");
  1326. if(_.get('shadow')){
  1327. _.css('boxShadow',_.get('shadow_offsetx')+'px '+_.get('shadow_offsety')+'px '+_.get('shadow_blur')+'px '+_.get('shadow_color'));
  1328. }
  1329. if(_.get('border.enable')){
  1330. _.css('border',_.get('border.width')+"px "+_.get('border.style')+" "+_.get('border.color'));
  1331. _.css('borderRadius',_.get('border.radius')+"px");
  1332. }
  1333. _.css('position','absolute');
  1334. _.css('zIndex',_.get('index'));
  1335. _.applyStyle();
  1336. _.wrap.appendChild(_.dom);
  1337. _.style = _.dom.style;
  1338. if(_.get('default_action')){
  1339. _.doAction(_);
  1340. }
  1341. },
  1342. width:function(){
  1343. return this.dom.offsetWidth;
  1344. },
  1345. height:function(){
  1346. return this.dom.offsetHeight;
  1347. },
  1348. onTransitionEnd:function(fn,useCapture){
  1349. var type = 'transitionend';
  1350. if($.isWebKit){
  1351. type = 'webkitTransitionEnd';
  1352. }else if($.isOpera){
  1353. type = 'oTransitionEnd';
  1354. }
  1355. $.Event.addEvent(this.dom,type,fn,useCapture);
  1356. },
  1357. destroy:function(){
  1358. this.wrap.removeChild(this.dom);
  1359. this.dom = null;
  1360. },
  1361. transition:function(v){
  1362. this.transitions = this.transitions==''?v:this.transitions+','+v;
  1363. if($.isWebKit){
  1364. this.css('WebkitTransition',this.transitions);
  1365. }else if($.isGecko){
  1366. this.css('MozTransition',this.transitions);
  1367. }else if($.isOpera){
  1368. this.css('OTransition',this.transitions);
  1369. }else{
  1370. this.css('transition',this.transitions);
  1371. }
  1372. },
  1373. beforeshow:function(e,m,_){
  1374. _.follow(e,m,_);
  1375. },
  1376. show:function(e,m){
  1377. this.beforeshow(e,m,this);
  1378. this.css('visibility','visible');
  1379. if(this.get('animation')){
  1380. this.css('opacity',1);
  1381. }
  1382. },
  1383. hidden:function(e){
  1384. this.css('visibility','hidden');
  1385. },
  1386. getDom:function(){
  1387. return this.dom;
  1388. },
  1389. css:function(k,v){
  1390. if($.isString(k))if($.isDefined(v))this.dom.style[k]=v;else return this.dom.style[k];
  1391. },
  1392. applyStyle:function(){
  1393. var styles = this.get('style').split(";"),style;
  1394. for(var i = 0;i< styles.length;i++){
  1395. style = styles[i].split(":");
  1396. if(style.length>1)this.css(style[0],style[1]);
  1397. }
  1398. }
  1399. });
  1400. /**
  1401. * @end
  1402. */
  1403. /**
  1404. * @overview this a abstract component of all concrete chart
  1405. * @component#$.Component
  1406. * @extend#$.Painter
  1407. */
  1408. $.Component = $.extend($.Painter, {
  1409. configure : function(c) {
  1410. /**
  1411. * invoked the super class's configuration
  1412. */
  1413. $.Component.superclass.configure.apply(this, arguments);
  1414. /**
  1415. * indicate the element's type
  1416. */
  1417. this.type = 'component';
  1418. this.set({
  1419. /**
  1420. * @cfg {Number} Specifies the font size of this element in pixels.(default to 12)
  1421. */
  1422. fontsize : 12,
  1423. /**
  1424. * @cfg {String} Specifies the font of this element.(default to 'Verdana')
  1425. */
  1426. font : 'Verdana',
  1427. /**
  1428. * @cfg {String} Specifies the font weight of this element.(default to 'normal')
  1429. */
  1430. fontweight : 'normal',
  1431. /**
  1432. * @cfg {String} Specifies the unit of font-size.(default to 'px')
  1433. */
  1434. fontunit:'px',
  1435. /**
  1436. * @inner {Boolean} Specifies the config of Tip.For details see <link>$.Tip</link> Note:this has a extra property named 'enable',indicate whether tip available(default to false)
  1437. */
  1438. tip : {
  1439. enable : false,
  1440. border : {
  1441. width : 2
  1442. }
  1443. }
  1444. });
  1445. /**
  1446. * If this element can split or contain others.(default to false)
  1447. */
  1448. this.atomic = false;
  1449. /**
  1450. * If method draw be proxy.(default to false)
  1451. */
  1452. this.proxy = false;
  1453. this.ICHARTJS_CHART = false;
  1454. this.inject(c);
  1455. },
  1456. initialize : function() {
  1457. $.DefineAbstract('isEventValid', this);
  1458. $.DefineAbstract('doDraw', this);
  1459. this.doConfig();
  1460. this.initialization = true;
  1461. },
  1462. /**
  1463. * @method return the component's dimension,return hold following property
  1464. * @property x:the left-top coordinate-x
  1465. * @property y:the left-top coordinate-y
  1466. * @property width:the width of component,note:available there applies box model
  1467. * @property height:the height of component,note:available there applies box model
  1468. * @return object
  1469. */
  1470. getDimension : function() {
  1471. return {
  1472. x : this.x,
  1473. y : this.y,
  1474. width : this.get("width"),
  1475. height : this.get("height")
  1476. }
  1477. },
  1478. destroy:function(){
  1479. if(this.tip){
  1480. this.tip.destroy();
  1481. }
  1482. },
  1483. doConfig : function() {
  1484. $.Component.superclass.doConfig.call(this);
  1485. var _ = this._(),w = _.get(_.W),W = _.get('maxwidth'),x = _.get(_.X);
  1486. if(w&&W){
  1487. w = _.push(_.W,$.parsePercent(w,W));
  1488. if(w>W){
  1489. w = _.push('width',W);
  1490. }
  1491. if(W>w){
  1492. var C = _.get('align')||_.C;
  1493. if(C == _.C){
  1494. x +=(W-w)/2;
  1495. }else if(C == _.R){
  1496. x += (W-w);
  1497. }
  1498. }
  1499. }
  1500. _.x = _.push(_.X, x + _.get('offsetx'));
  1501. _.y = _.push(_.Y, _.get(_.Y) + _.get('offsety'));
  1502. _.push('fontStyle', $.getFont(_.get('fontweight'), _.get('fontsize'), _.get('font'),_.get('fontunit')));
  1503. /**
  1504. * if have evaluate it
  1505. */
  1506. _.data = _.get('data');
  1507. if (_.get('tip.enable')) {
  1508. /**
  1509. * make tip's border in accord with sector
  1510. */
  1511. _.pushIf('tip.border.color', _.get('f_color'));
  1512. if (!$.isFunction(_.get('tip.invokeOffset')))
  1513. /**
  1514. * indicate the tip must calculate position
  1515. */
  1516. _.push('tip.invokeOffset', _.tipInvoke());
  1517. }
  1518. },
  1519. isMouseOver : function(e) {
  1520. return this.isEventValid(e,this);
  1521. },
  1522. redraw : function(e) {
  1523. this.root.draw(e,this.root.Combination);
  1524. },
  1525. last:$.emptyFn,
  1526. commonDraw : function(_) {
  1527. /**
  1528. * execute the doDraw() that the subClass implement
  1529. */
  1530. if (!_.proxy)
  1531. _.doDraw.call(_,_);
  1532. }
  1533. });
  1534. /**
  1535. * @end
  1536. */
  1537. /**
  1538. * @overview the tip component.
  1539. * @component#$.Tip
  1540. * @extend#$.Element
  1541. */
  1542. $.Tip = $.extend($.Html,{
  1543. configure:function(){
  1544. /**
  1545. * invoked the super class's configuration
  1546. */
  1547. $.Tip.superclass.configure.apply(this,arguments);
  1548. /**
  1549. * indicate the legend's type
  1550. */
  1551. this.type = 'tip';
  1552. this.set({
  1553. name:'',
  1554. index:0,
  1555. value:'',
  1556. /**
  1557. * @cfg {String} Specifies the text want to disply.(default to '')
  1558. */
  1559. text:'',
  1560. /**
  1561. * @cfg {String} Specifies the tip's type.(default to 'follow') Available value are:
  1562. * @Option follow
  1563. * @Option fixed
  1564. */
  1565. showType:'follow',
  1566. /**
  1567. * @cfg {Function} Specifies Function to calculate the position.(default to null)
  1568. */
  1569. invokeOffset:null,
  1570. /**
  1571. * @cfg {Number} Specifies the duration when fadeIn/fadeOut in millisecond.(default to 300)
  1572. */
  1573. fade_duration:300,
  1574. /**
  1575. * @cfg {Number} Specifies the duration when move in millisecond.(default to 100)
  1576. */
  1577. move_duration:100,
  1578. /**
  1579. * ease
  1580. * linear
  1581. * ease-in
  1582. * ease-out
  1583. * ease-in-out
  1584. */
  1585. timing_function:'ease-out',
  1586. /**
  1587. * @cfg {Boolean} if calculate the position every time (default to false)
  1588. */
  1589. invokeOffsetDynamic:false,
  1590. /**
  1591. * @cfg {String} Specifies the css of this Dom.
  1592. */
  1593. style:'textAlign:left;padding:4px 5px;cursor:pointer;backgroundColor:rgba(239,239,239,.85);fontSize:12px;color:black;',
  1594. /**
  1595. * @cfg {Object} Override the default as enable = true,radius = 5
  1596. */
  1597. border:{
  1598. enable:true,
  1599. radius : 5
  1600. },
  1601. delay:200
  1602. });
  1603. this.registerEvent(
  1604. /**
  1605. * @event Fires when parse this tip's text.Return value will override existing.
  1606. * @paramter <link>$.Tip</link>#tip
  1607. * @paramter string#name the current tip's name
  1608. * @paramter string#value the current tip's value
  1609. * @paramter string#text the current tip's text
  1610. * @paramter int#index index of data,if there was a line
  1611. */
  1612. 'parseText');
  1613. },
  1614. position:function(t,l,_){
  1615. _.style.top = (t<0?0:t)+"px";
  1616. _.style.left = (l<0?0:l)+"px";
  1617. },
  1618. follow:function(e,m,_){
  1619. //_.style.width = "";
  1620. if(_.get('invokeOffsetDynamic')){
  1621. if(m.hit){
  1622. if($.isString(m.text)||$.isNumber(m.text)){
  1623. _.text(m.name,m.value,m.text,m.i,_);
  1624. }
  1625. var o = _.get('invokeOffset')(_.width(),_.height(),m);
  1626. _.position(o.top,o.left,_);
  1627. }
  1628. }else{
  1629. if(_.get('showType')!='follow'&&$.isFunction(_.get('invokeOffset'))){
  1630. var o = _.get('invokeOffset')(_.width(),_.height(),m);
  1631. _.position(o.top,o.left,_);
  1632. }else{
  1633. _.position((e.y-_.height()*1.1-2),e.x+2,_);
  1634. }
  1635. }
  1636. },
  1637. text:function(n,v,t,i,_){
  1638. _.dom.innerHTML = _.fireString(_, 'parseText', [_,n,v,t,i],t);
  1639. },
  1640. hidden:function(e){
  1641. if(this.get('animation')){
  1642. this.css('opacity',0);
  1643. }else{
  1644. this.css('visibility','hidden');
  1645. }
  1646. },
  1647. doAction:function(_){
  1648. _.T.on('mouseover',function(c,e,m){
  1649. _.show(e,m);
  1650. }).on('mouseout',function(c,e,m){
  1651. _.hidden(e);
  1652. });
  1653. if(_.get('showType')=='follow'){
  1654. _.T.on('mousemove',function(c,e,m){
  1655. if(_.T.variable.event.mouseover){
  1656. setTimeout(function(){
  1657. if(_.T.variable.event.mouseover)
  1658. _.follow(e,m,_);
  1659. },_.get('delay'));
  1660. }
  1661. });
  1662. }
  1663. },
  1664. initialize:function(){
  1665. $.Tip.superclass.initialize.call(this);
  1666. var _ = this._();
  1667. _.text(_.get('name'),_.get('value'),_.get('text'),_.get('index'),_);
  1668. _.hidden();
  1669. if(_.get('animation')){
  1670. var m = _.get('move_duration')/1000+'s '+_.get('timing_function')+' 0s';
  1671. _.transition('opacity '+_.get('fade_duration')/1000+'s '+_.get('timing_function')+' 0s');
  1672. _.transition('top '+m);
  1673. _.transition('left '+m);
  1674. _.onTransitionEnd(function(e){
  1675. if(_.css('opacity')==0){
  1676. _.css('visibility','hidden');
  1677. }
  1678. },false);
  1679. }
  1680. }
  1681. });
  1682. /**
  1683. * @end
  1684. */
  1685. /**
  1686. * @overview this element simulate the crosshair on the coordinate.actually this composed of some div of html.
  1687. * @component#$.CrossHair
  1688. * @extend#$.Html
  1689. */
  1690. $.CrossHair = $.extend($.Html,{
  1691. configure:function(){
  1692. /**
  1693. * invoked the super class's configuration
  1694. */
  1695. $.CrossHair.superclass.configure.apply(this,arguments);
  1696. /**
  1697. * indicate the component's type
  1698. */
  1699. this.type = 'crosshair';
  1700. this.set({
  1701. /**
  1702. * @inner {Number} Specifies the position top,normally this will given by chart.(default to 0)
  1703. */
  1704. top:0,
  1705. /**
  1706. * @inner {Number} Specifies the position left,normally this will given by chart.(default to 0)
  1707. */
  1708. left:0,
  1709. /**
  1710. * @inner {Boolean} private use
  1711. */
  1712. hcross:true,
  1713. /**
  1714. * @inner {Boolean} private use
  1715. */
  1716. vcross:true,
  1717. /**
  1718. * @inner {Function} private use
  1719. */
  1720. invokeOffset:null,
  1721. /**
  1722. * @cfg {Number} Specifies the linewidth of the crosshair.(default to 1)
  1723. */
  1724. line_width:1,
  1725. /**
  1726. * @cfg {Number} Specifies the linewidth of the crosshair.(default to 1)
  1727. */
  1728. line_color:'#1A1A1A',
  1729. delay:200
  1730. });
  1731. },
  1732. /**
  1733. * this function will implement at every target object,and this just default effect
  1734. */
  1735. follow:function(e,m,_){
  1736. if(_.get('invokeOffset')){
  1737. var o = _.get('invokeOffset')(e,m);
  1738. if(o&&o.hit){
  1739. _.o_valid = true;
  1740. _.position(o.top-_.top,o.left-_.left,_);
  1741. }else if(!o||!_.o_valid){
  1742. _.position(_.owidth,_.oheight,_);
  1743. }
  1744. }else{
  1745. /**
  1746. * set the 1px offset will make the line at the top left all the time
  1747. */
  1748. _.position(e.y-_.top-1,e.x-_.left-1,_);
  1749. }
  1750. },
  1751. position:function(t,l,_){
  1752. _.horizontal.style.top = (t-_.size)+"px";
  1753. _.vertical.style.left = (l-_.size)+"px";
  1754. },
  1755. doCreate:function(_,w,h){
  1756. var d = document.createElement("div");
  1757. d.style.width= $.toPixel(w);
  1758. d.style.height= $.toPixel(h);
  1759. d.style.backgroundColor = _.get('line_color');
  1760. d.style.position="absolute";
  1761. _.dom.appendChild(d);
  1762. return d;
  1763. },
  1764. doAction:function(_){
  1765. _.T.on('mouseover',function(c,e,m){
  1766. _.show(e,m);
  1767. }).on('mouseout',function(c,e,m){
  1768. _.hidden(e,m);
  1769. }).on('mousemove',function(c,e,m){
  1770. _.follow(e,m,_);
  1771. });
  1772. },
  1773. initialize:function(){
  1774. $.CrossHair.superclass.initialize.call(this);
  1775. var _ = this._(),L = $.toPixel(_.get('line_width'));
  1776. _.size = _.get('line_width')/2;
  1777. _.top = $.fixPixel(_.get(_.O));
  1778. _.left = $.fixPixel(_.get(_.L));
  1779. _.owidth = -_.T.root.width;
  1780. _.oheight = -_.T.root.height;
  1781. _.o_valid = false;
  1782. /**
  1783. * set size zero make integration with vertical and horizontal
  1784. */
  1785. _.css('width','0px');
  1786. _.css('height','0px');
  1787. _.css('top',_.top+'px');
  1788. _.css('left',_.left+'px');
  1789. _.css('visibility','hidden');
  1790. _.horizontal = _.doCreate(_,_.get('hcross')?$.toPixel(_.get(_.W)):"0px",L);
  1791. _.vertical = _.doCreate(_,L,_.get('vcross')?$.toPixel(_.get(_.H)):"0px");
  1792. }
  1793. });
  1794. /**
  1795. * @end
  1796. */
  1797. /**
  1798. * @overview the legend componment
  1799. * @component#$.Legend
  1800. * @extend#$.Component
  1801. */
  1802. $.Legend = $.extend($.Component, {
  1803. configure : function() {
  1804. /**
  1805. * invoked the super class's configuration
  1806. */
  1807. $.Legend.superclass.configure.apply(this, arguments);
  1808. /**
  1809. * indicate the legend's type
  1810. */
  1811. this.type = 'legend';
  1812. this.set({
  1813. /**
  1814. * @cfg {Array} Required,The datasource of Legend.Normally,this will given by chart.(default to undefined)
  1815. */
  1816. data : undefined,
  1817. /**
  1818. * @inner {Number} Specifies the width.Note if set to 'auto' will be fit the actual width.(default to 'auto')
  1819. */
  1820. width : 'auto',
  1821. /**
  1822. * @cfg {Number/String} Specifies the number of column.(default to 1) Note:If set to 'max',the list will be lie on the property row
  1823. */
  1824. column : 1,
  1825. /**
  1826. * @cfg {Number/String} Specifies the number of column.(default to 'max') Note:If set to 'max',the list will be lie on the property column
  1827. */
  1828. row : 'max',
  1829. /**
  1830. * @cfg {Number} Specifies the limited width.Normally,this will given by chart.(default to 0)
  1831. */
  1832. maxwidth : 0,
  1833. /**
  1834. * @cfg {Number} Specifies the lineheight when text display multiline.(default to 16)
  1835. */
  1836. line_height : 16,
  1837. /**
  1838. * @cfg {String} Specifies the shape of legend' sign (default to 'square') Available value are:
  1839. * @Option 'round'
  1840. * @Option 'square'
  1841. * @Option 'bar'
  1842. * @Option 'round-bar'
  1843. * @Option 'square-bar'
  1844. */
  1845. sign : 'square',
  1846. /**
  1847. * @cfg {Number} the size of legend' sign (default to 10)
  1848. */
  1849. sign_size : 10,
  1850. /**
  1851. * @cfg {Number} the distance of legend' sign and text (default to 5)
  1852. */
  1853. sign_space : 5,
  1854. /**
  1855. * @cfg {Number} Specifies the space between the sign and text.(default to 5)
  1856. */
  1857. legend_space : 5,
  1858. z_index : 1009,
  1859. /**
  1860. * @cfg {Boolean} If true the text's color will accord with sign's.(default to false)
  1861. */
  1862. text_with_sign_color : false,
  1863. /**
  1864. * @cfg {String} Specifies the horizontal position of the legend in chart.(defaults to 'right').Available value are:
  1865. * @Option 'left'
  1866. * @Option 'center' Only applies when valign = 'top|bottom'
  1867. * @Option 'right'
  1868. */
  1869. align : 'right',
  1870. /**
  1871. * @cfg {String} this property specifies the vertical position of the legend in an module (defaults to 'middle'). Available value are:
  1872. * @Option 'top'
  1873. * @Option 'middle' Only applies when align = 'left|right'
  1874. * @Option 'bottom'
  1875. */
  1876. valign : 'middle'
  1877. });
  1878. /**
  1879. * this element support boxMode
  1880. */
  1881. this.atomic = true;
  1882. this.registerEvent(
  1883. /**
  1884. * @event Fires when parse this element'data.Return text value will override existing.
  1885. * @paramter $.Chart#this
  1886. * @paramter string#text the text will display
  1887. * @paramter int#i the index of data
  1888. * @return string
  1889. */
  1890. 'parse');
  1891. },
  1892. isEventValid : function(e,_) {
  1893. var r = {
  1894. valid : false
  1895. };
  1896. if (e.x > this.x && e.x < (_.x + _.width) && e.y > _.y && e.y < (_.y + _.height)) {
  1897. _.data.each(function(d, i) {
  1898. if (e.x > d.x && e.x < (d.x + d.width_ + _.get('signwidth')) && e.y > d.y && e.y < (d.y + _.get('line_height'))) {
  1899. r = {
  1900. valid : true,
  1901. index : i,
  1902. target : d
  1903. }
  1904. return false;
  1905. }
  1906. }, _);
  1907. }
  1908. return r;
  1909. },
  1910. drawCell : function(x, y, text, color,n,_) {
  1911. var s = _.get('sign_size'),f = _.getPlugin('sign');
  1912. if(!f||!f.call(_,_.T,n,{x:x + s / 2,y:y},s,color)){
  1913. if(n.indexOf("bar")!=-1){
  1914. _.T.box(x, y - s / 12, s, s / 6, 0, color);
  1915. }
  1916. if(n=='round'){
  1917. _.T.round(x + s / 2, y, s / 2, color);
  1918. }else if(n=='round-bar'){
  1919. _.T.round(x + s / 2, y, s / 4, color);
  1920. }else if (n == 'square-bar') {
  1921. _.T.box(x + s / 4, y - s / 4, s / 2, s / 2, 0, color);
  1922. }else if (n == 'square'){
  1923. _.T.box(x, y-s/2, s, s, 0, color);
  1924. }
  1925. }
  1926. _.T.fillText(text, x + _.get('signwidth'), y, 0, _.get('text_with_sign_color')?color:_.get('color'),'lr',_.get('line_height'));
  1927. },
  1928. doDraw : function(_) {
  1929. _.T.box(_.x, _.y, _.width, _.height, _.get('border'), _.get('f_color'), false, _.get('shadow'));
  1930. _.T.textStyle(_.L, 'middle', $.getFont(_.get('fontweight'), _.get('fontsize'), _.get('font')));
  1931. _.data.each(function(d) {
  1932. _.drawCell(d.x, d.y, d.text, d.color,d.sign,_);
  1933. });
  1934. },
  1935. doLayout:function(_,g){
  1936. var ss = _.get('sign_size'),
  1937. w = 0,
  1938. h=0,
  1939. temp = 0,
  1940. c = _.get('column'),
  1941. r = _.get('row'),
  1942. L = _.data.length;
  1943. _.T.textFont(_.get('fontStyle'));
  1944. if (_.get('line_height') < ss) {
  1945. _.push('line_height', ss + ss / 5);
  1946. }
  1947. _.push('signwidth', (ss + _.get('sign_space')));
  1948. /**
  1949. * calculate the width each item will used
  1950. */
  1951. _.data.each(function(d) {
  1952. d.width_ = _.T.measureText(d.text);
  1953. }, _);
  1954. /**
  1955. * calculate the each column's width it will used
  1956. */
  1957. for ( var i = 0; i < c; i++) {
  1958. temp = 0;
  1959. for ( var j = i; j < L; j+=c) {
  1960. temp = Math.max(temp, _.data[j].width_);
  1961. }
  1962. _.columnwidth[i] = temp;
  1963. w += temp;
  1964. }
  1965. /**
  1966. * calculate the each row's height it will used
  1967. */
  1968. for ( var i = 0; i < r; i++) {
  1969. temp =0;
  1970. for ( var j = i*c; j < L; j++) {
  1971. temp = Math.max(temp, _.data[j].text.split("\n").length);
  1972. }
  1973. _.columnheight[i] = temp;
  1974. h+=temp;
  1975. }
  1976. w = _.push(_.W, w + _.get('hpadding') + _.get('signwidth') * c + (c - 1) * _.get('legend_space'));
  1977. if (w > _.get('maxwidth')){
  1978. var fs=Math.floor(_.get('fontsize')*(_.get('maxwidth')/w));
  1979. if(!(fs<10&&c==1)){
  1980. if(fs>9){
  1981. _.push('fontStyle',$.getFont(_.get('fontweight'), _.push('fontsize', fs), _.get('font')));
  1982. }else if(c>1){
  1983. _.push('row', Math.ceil(L / _.push('column',c-1)));
  1984. }
  1985. _.doLayout(_,g);
  1986. return;
  1987. }
  1988. }
  1989. var d,x,y,y2;
  1990. _.width = w;
  1991. _.height = h = _.push(_.H, h * _.get('line_height') + _.get('vpadding'));
  1992. if (_.get('valign') == _.O) {
  1993. _.y = g.get('t_originy');
  1994. } else if (_.get('valign') == _.B) {
  1995. _.y = g.get('b_originy') - h;
  1996. } else {
  1997. _.y = g.get('centery') - h / 2;
  1998. }
  1999. if (_.get('align') == _.L) {
  2000. _.x = g.get('l_originx');
  2001. } else if (_.get('align') == _.C) {
  2002. _.x = g.get('centerx') - w / 2;
  2003. } else {
  2004. _.x = g.get('r_originx') - w;
  2005. }
  2006. _.x = _.push(_.X, (_.x<0?g.get('l_originx'):_.x) + _.get('offsetx'));
  2007. _.y = _.push(_.Y, (_.y<0?g.get('t_originy'):_.y) + _.get('offsety'));
  2008. y = _.y + _.get('padding_top');
  2009. ss = _.get('legend_space')+_.get('signwidth');
  2010. /**
  2011. * calculate the each cell's coordinate point
  2012. */
  2013. for ( var i = 0; i < r; i++) {
  2014. x = _.x + _.get('padding_left');
  2015. y2=(_.columnheight[i]/2)*_.get('line_height');
  2016. y+=y2;
  2017. for ( var j = 0; j < c&&i*c+j<L; j++) {
  2018. d = _.data[i*c+j];
  2019. d.y = y;
  2020. d.x = x;
  2021. x += _.columnwidth[j] + ss;
  2022. }
  2023. y+=y2;
  2024. }
  2025. },
  2026. doConfig : function() {
  2027. $.Legend.superclass.doConfig.call(this);
  2028. var _ = this._(),g = _.root,c = $.isNumber(_.get('column')),r = $.isNumber(_.get('row')), L = _.data.length;
  2029. /**
  2030. * if the position is incompatible,rectify it.
  2031. */
  2032. if (_.get('align') == _.C && _.get('valign') == 'middle') {
  2033. _.push('valign', _.O);
  2034. }
  2035. /**
  2036. * if this position incompatible with root,rectify it.
  2037. */
  2038. if (g.get('align') == _.L) {
  2039. if (_.get('valign') == 'middle') {
  2040. _.push('align', _.R);
  2041. }
  2042. }
  2043. /**
  2044. * calculate the width each item will used
  2045. */
  2046. _.data.each(function(d, i) {
  2047. $.merge(d, _.fireEvent(_, 'parse', [_, d.name, i]));
  2048. d.text = d.text || d.name ||'';
  2049. d.sign = d.sign || _.get('sign')
  2050. }, _);
  2051. if (!c && !r)
  2052. c = _.push('column',1);
  2053. if (c && !r)
  2054. r = _.push('row', Math.ceil(L / _.get('column')));
  2055. if (!c && r)
  2056. c = _.push('column', Math.ceil(L / _.get('row')));
  2057. c = _.get('column');
  2058. r = _.get('row');
  2059. if (L > r * c) {
  2060. r += Math.ceil((L - r * c) / c);
  2061. r = _.push('row', r);
  2062. }
  2063. _.columnwidth = [];
  2064. _.columnheight = [];
  2065. _.doLayout(_,g);
  2066. }
  2067. });/** @end */
  2068. /**
  2069. * @overview the label componment
  2070. * @component#$.Label
  2071. * @extend#$.Component
  2072. */
  2073. $.Label = $.extend($.Component, {
  2074. configure : function() {
  2075. /**
  2076. * invoked the super class's configuration
  2077. */
  2078. $.Label.superclass.configure.apply(this, arguments);
  2079. /**
  2080. * indicate the legend's type
  2081. */
  2082. this.type = 'label';
  2083. this.set({
  2084. /**
  2085. * @cfg {String} Specifies the text of this label,Normally,this will given by chart.(default to '').
  2086. */
  2087. text : '',
  2088. /**
  2089. * @cfg {Number} Specifies the lineheight when text display multiline.(default to 12).
  2090. */
  2091. line_height : 12,
  2092. /**
  2093. * @cfg {Number} Specifies the thickness of line in pixel.(default to 1).
  2094. */
  2095. line_thickness : 1,
  2096. /**
  2097. * @cfg {String} Specifies the shape of legend' sign (default to 'square').Available value are:
  2098. * @Option 'round'
  2099. * @Option 'square'
  2100. */
  2101. sign : 'square',
  2102. /**
  2103. * @cfg {Number} Specifies the size of legend' sign in pixel.(default to 12)
  2104. */
  2105. sign_size : 12,
  2106. /**
  2107. * @cfg {Number} Override the default as 2 in pixel.
  2108. */
  2109. padding : '2 5',
  2110. /**
  2111. * @cfg {Number} Override the default as 2 in pixel.
  2112. */
  2113. offsety : 2,
  2114. /**
  2115. * @cfg {Number} Specifies the space between the sign and text.(default to 5)
  2116. */
  2117. sign_space : 5,
  2118. /**
  2119. * @cfg {Number} Override the default as '#efefef'.
  2120. */
  2121. background_color : '#efefef',
  2122. /**
  2123. * @cfg {Boolean} If true the text's color will accord with sign's.(default to false)
  2124. */
  2125. text_with_sign_color : false
  2126. });
  2127. /**
  2128. * this element support boxMode
  2129. */
  2130. this.atomic = true;
  2131. this.registerEvent();
  2132. },
  2133. isEventValid : function(e,_) {
  2134. return {
  2135. valid : $.inRange(_.labelx, _.labelx + _.get(_.W), e.x) && $.inRange(_.labely, _.labely + _.get(_.H), e.y)
  2136. };
  2137. },
  2138. text : function(text) {
  2139. if (text)
  2140. this.push('text', text);
  2141. this.push(this.W, this.T.measureText(this.get('text')) + this.get('hpadding') + this.get('sign_size') + this.get('sign_space'));
  2142. },
  2143. localizer : function(_) {
  2144. var Q = _.get('quadrantd'),p = _.get('line_points'),m=_.get('smooth'),Q=(Q >= 1 && Q <= 2),x=_.get('labelx'),y=_.get('labely');
  2145. _.labelx = x+(Q ? - _.get(_.W)-m : m);
  2146. _.labely = y-_.get(_.H)/2;
  2147. p[2] = {x:x,y:y};
  2148. p[3] = {x:p[2].x+(Q ? -m : m),y:p[2].y};
  2149. },
  2150. doLayout : function(x, y,n,_) {
  2151. _.push('labelx', _.get('labelx') + x/n);
  2152. _.push('labely', _.get('labely') + y/n);
  2153. _.get('line_points').each(function(p,i) {
  2154. p.x += x;
  2155. p.y += y;
  2156. return i==1;
  2157. }, _);
  2158. _.localizer(_);
  2159. },
  2160. doDraw : function(_){
  2161. var p = _.get('line_points'), ss = _.get('sign_size'), x = _.labelx + _.get('padding_left'), y = _.labely + _.get('padding_top');
  2162. _.T.label(p, _.get('line_thickness'), _.get('border.color'));
  2163. _.T.box(_.labelx, _.labely, _.get(_.W), _.get(_.H), _.get('border'), _.get('f_color'), false, _.get('shadow'));
  2164. _.T.textStyle(_.L, _.O, _.get('fontStyle'));
  2165. var textcolor = _.get('color');
  2166. if (_.get('text_with_sign_color')) {
  2167. textcolor = _.get('scolor');
  2168. }
  2169. if (_.get('sign') == 'square') {
  2170. _.T.box(x, y, ss, ss, 0, _.get('scolor'));
  2171. } else if(_.get('sign')){
  2172. _.T.round(x + ss / 2, y + ss / 2, ss / 2, _.get('scolor'));
  2173. }
  2174. _.T.fillText(_.get('text'), x + ss + _.get('sign_space'), y, _.get('textwidth'), textcolor);
  2175. },
  2176. doConfig : function() {
  2177. $.Label.superclass.doConfig.call(this);
  2178. var _ = this._();
  2179. _.T.textFont(_.get('fontStyle'));
  2180. if (_.get('fontsize') > _.get('line_height')) {
  2181. _.push('line_height', _.get('fontsize'));
  2182. }
  2183. if(!_.get('sign')){
  2184. _.push('sign_size',0);
  2185. _.push('sign_space',0);
  2186. }
  2187. _.push(_.H, _.get('line_height') + _.get('vpadding'));
  2188. _.text();
  2189. _.localizer(_);
  2190. }
  2191. });
  2192. /**
  2193. * @end
  2194. */
  2195. /**
  2196. * @overview the text componment
  2197. * @component#$.Text
  2198. * @extend#$.Component
  2199. */
  2200. $.Text = $.extend($.Component,{
  2201. configure:function(){
  2202. /**
  2203. * invoked the super class's configuration
  2204. */
  2205. $.Text.superclass.configure.apply(this,arguments);
  2206. /**
  2207. * indicate the component's type
  2208. */
  2209. this.type = 'text';
  2210. this.set({
  2211. /**
  2212. * @cfg {String} Specifies the text want to disply.(default to '')
  2213. */
  2214. text:'',
  2215. /**
  2216. * @cfg {String} there has two layers of meaning,when width is 0,Specifies the textAlign of html5.else this is the alignment of box.(default to 'center')
  2217. * when width is 0,Available value are:
  2218. * @Option start
  2219. * @Option end
  2220. * @Option left
  2221. * @Option right
  2222. * @Option center
  2223. * when width is not 0,Available value are:
  2224. * @Option left
  2225. * @Option right
  2226. * @Option center
  2227. */
  2228. textAlign:'center',
  2229. /**
  2230. * @cfg {String} Specifies the alignment in box.(default to 'center')
  2231. * @Option left
  2232. * @Option right
  2233. * @Option center
  2234. */
  2235. align:'center',
  2236. /**
  2237. * @cfg {String} Here,specify as false to make background transparent.(default to null)
  2238. */
  2239. background_color : 0,
  2240. /**
  2241. * @cfg {String} Specifies the textBaseline of html5.(default to 'top')
  2242. * Available value are:
  2243. * @Option top
  2244. * @Option hanging
  2245. * @Option middle
  2246. * @Option alphabetic
  2247. * @Option ideographic
  2248. * @Option bottom
  2249. */
  2250. textBaseline:'top',
  2251. /**
  2252. * @cfg {Object} Here,specify as false by default
  2253. * @see <link>$.Element#border</link>
  2254. */
  2255. border : {
  2256. enable : false
  2257. },
  2258. /**
  2259. * @cfg {Number} Specifies the maxwidth of text in pixels,if given 0 will not be limited.(default to 0)
  2260. */
  2261. width:0,
  2262. /**
  2263. * @cfg {Number} Specifies the maxheight of text in pixels,if given 0 will not be limited(default to 0)
  2264. */
  2265. height:0,
  2266. /**
  2267. * @cfg {Number} Here,specify as 0 by default
  2268. */
  2269. padding:0,
  2270. /**
  2271. * @cfg {String} Specifies the writing-mode of text.(default to 'lr') .
  2272. * Available value are:
  2273. * @Option 'lr'
  2274. */
  2275. writingmode : 'lr',
  2276. /**
  2277. * @cfg {Number} Specifies the lineheight when text display multiline.(default to 16).
  2278. */
  2279. line_height : 16,
  2280. /**
  2281. * @cfg {Number} Specifies the angle that text writed.0 to horizontal,clockwise.(default to 0).
  2282. */
  2283. rotate:0
  2284. });
  2285. this.registerEvent();
  2286. },
  2287. doDraw:function(_){
  2288. if(_.get('box_feature'))
  2289. _.T.box(_.x,_.y,_.get(_.W),_.get(_.H),_.get('border'),_.get('f_color'));
  2290. _.T.text(_.get('text'),_.get('textx'),_.get('texty'),_.get(_.W)-_.get('hpadding'),_.get('color'),_.get('textAlign'),_.get('textBaseline'),_.get('fontStyle'),_.get('writingmode'),_.get('line_height'),_.get('shadow'),_.get('rotate'));
  2291. },
  2292. isEventValid:function(){
  2293. return {valid:false};
  2294. },
  2295. doLayout:function(x,y,n,_){
  2296. _.x = _.push(_.X,_.x+x);
  2297. _.y = _.push(_.Y,_.y+y);
  2298. _.push('textx',_.get('textx')+x);
  2299. _.push('texty',_.get('texty')+y);
  2300. },
  2301. doConfig:function(){
  2302. $.Text.superclass.doConfig.call(this);
  2303. var _ = this._(),x = _.x,y=_.y+_.get('padding_top'),w=_.get(_.W),h=_.get(_.H),a=_.get('textAlign');
  2304. x+=(a==_.C?w/2:(a==_.R?w-_.get('padding_right'):_.get('padding_left')));
  2305. if(h){
  2306. y+=h/2;
  2307. _.push('textBaseline','middle');
  2308. }
  2309. _.push('textx',x);
  2310. _.push('texty',y);
  2311. _.push('box_feature',w&&h);
  2312. _.applyGradient();
  2313. }
  2314. });
  2315. /**
  2316. * @end
  2317. */
  2318. ;
  2319. (function($) {
  2320. var PI = Math.PI, inc = PI / 90,inc2 = inc/2, ceil = Math.ceil, floor = Math.floor, PI2 = 2 * PI, max = Math.max, min = Math.min, sin = Math.sin, cos = Math.cos, fd = function(w, c) {
  2321. return w == 1 ? (floor(c) + 0.5) : Math.round(c);
  2322. }, getCurvePoint = function(seg, point, i, smo) {
  2323. var x = point.x, y = point.y, lp = seg[i - 1], np = seg[i + 1], lcx, lcy, rcx, rcy;
  2324. if (i < seg.length - 1) {
  2325. var lastY = lp.y, nextY = np.y, c;
  2326. lcx = (smo * x + lp.x) / (smo + 1);
  2327. lcy = (smo * y + lastY) / (smo + 1);
  2328. rcx = (smo * x + np.x) / (smo + 1);
  2329. rcy = (smo * y + nextY) / (smo + 1);
  2330. c = ((rcy - lcy) * (rcx - x)) / (rcx - lcx) + y - rcy;
  2331. lcy += c;
  2332. rcy += c;
  2333. if (lcy > lastY && lcy > y) {
  2334. lcy = max(lastY, y);
  2335. rcy = 2 * y - lcy;
  2336. } else if (lcy < lastY && lcy < y) {
  2337. lcy = min(lastY, y);
  2338. rcy = 2 * y - lcy;
  2339. }
  2340. if (rcy > nextY && rcy > y) {
  2341. rcy = max(nextY, y);
  2342. lcy = 2 * y - rcy;
  2343. } else if (rcy < nextY && rcy < y) {
  2344. rcy = min(nextY, y);
  2345. lcy = 2 * y - rcy;
  2346. }
  2347. point.rcx = rcx;
  2348. point.rcy = rcy;
  2349. }
  2350. return [lp.rcx || lp.x, lp.rcy || lp.y, lcx || x, lcy || y, x, y];
  2351. },
  2352. pF = function(n){
  2353. return $.isNumber(n)?n:$.parseFloat(n,n);
  2354. },
  2355. parse = function(c,_){
  2356. var M,V=0,MI,ML=0,init=false,g = _.get('labels');
  2357. _.data = c;
  2358. if(_.dataType=='simple'){
  2359. _.total = 0;
  2360. c.each(function(d,i){
  2361. d.background_color = d.color;
  2362. V = d.value||0;
  2363. if($.isArray(V)){
  2364. var T = 0;
  2365. ML = V.length>ML?V.length:ML;
  2366. for(var j=0;j<V.length;j++){
  2367. V[j] = pF(V[j]);
  2368. T+=V[j];
  2369. if(!init){
  2370. M = MI = V[j];
  2371. init=true;
  2372. }
  2373. M = max(V[j],M);
  2374. MI = min(V[j],MI);
  2375. }
  2376. d.total = T;
  2377. }else{
  2378. V = pF(V);
  2379. d.value = V;
  2380. _.total+=V;
  2381. if(!init){
  2382. M = MI = V;
  2383. init=true;
  2384. }
  2385. M = max(V,M);
  2386. MI = min(V,MI);
  2387. }
  2388. },_);
  2389. if($.isArray(g)){
  2390. ML = g.length>ML?g.length:ML;
  2391. }
  2392. _.push('maxItemSize',ML);
  2393. }else if(_.dataType=='stacked'||_.dataType=='complex'){
  2394. var L=g.length,item,T,r,stack=_.dataType=='stacked';
  2395. if(L==0){
  2396. L=c[0].value.length;for(var i=0;i<L;i++)g.push("");
  2397. }
  2398. _.columns = [];
  2399. for(var i=0;i<L;i++){
  2400. item = [],T = 0;
  2401. c.each(function(d,j){
  2402. V = d.value[i];
  2403. if(!V)return;
  2404. d.value[i] = V = pF(V,V);
  2405. T+=V;
  2406. if(stack){
  2407. r = c[j].color;
  2408. }else{
  2409. r = d.color;
  2410. if(!init){
  2411. M = MI = V;
  2412. init=true;
  2413. }
  2414. M = max(V,M);
  2415. MI = min(V,MI);
  2416. }
  2417. item.push($.applyIf({
  2418. name:d.name,
  2419. value:d.value[i],
  2420. background_color:r,
  2421. color:r
  2422. },$.isArray(d.extra)?(d.extra[i]||{}):d));
  2423. });
  2424. if(stack){
  2425. if(!init){
  2426. M = MI = V;
  2427. init=true;
  2428. }
  2429. M = max(T,M);
  2430. MI = min(T,MI);
  2431. }
  2432. _.columns.push({
  2433. total:T,
  2434. name:g[i],
  2435. item:item
  2436. });
  2437. }
  2438. }
  2439. _.push('minValue',MI);
  2440. _.push('maxValue',M);
  2441. _.doConfig();
  2442. _.initialization = true;
  2443. };
  2444. /**
  2445. * @private support an improved API for drawing in canvas
  2446. */
  2447. function Cans(c) {
  2448. if (typeof c === "string")
  2449. c = $(c);
  2450. if (!c || !c['tagName'] || c['tagName'].toLowerCase() != 'canvas')
  2451. throw new Error("there not a canvas element");
  2452. this.canvas = c;
  2453. this.c = this.canvas.getContext("2d");
  2454. }
  2455. Cans.prototype = {
  2456. getContext:function(){
  2457. return this.c;
  2458. },
  2459. css : function(a, s) {
  2460. if ($.isDefined(s))
  2461. this.canvas.style[a] = s;
  2462. else
  2463. return this.canvas.style[a];
  2464. },
  2465. /**
  2466. * draw ellipse API
  2467. */
  2468. ellipse : function(x, y, a, b, s, e, c, bo, bow, boc, sw, ccw, a2r, last) {
  2469. var angle = s,a2r = !!a2r;
  2470. this.save().gCo(last).strokeStyle(bo,bow, boc).shadowOn(sw).fillStyle(c).moveTo(x, y).beginPath();
  2471. if (a2r)
  2472. this.moveTo(x, y);
  2473. while (angle <= e) {
  2474. this.lineTo(x + a * cos(angle), y + (b * sin(angle)));
  2475. angle += inc;
  2476. }
  2477. return this.lineTo(x + a * cos(e), y + (b * sin(e))).closePath().stroke(bo).fill(c).restore();
  2478. },
  2479. /**
  2480. * arc
  2481. */
  2482. arc : function(x, y, r, dw, s, e, c, b, bw, bc, sw, ccw, a2r, last) {
  2483. if(b)
  2484. r-=floor(bw/2);
  2485. if(r<=0)return this;
  2486. this.save().gCo(last).strokeStyle(b,bw,bc).fillStyle(c).beginPath();
  2487. if(dw){
  2488. this.moveTo(x+cos(s)*(r-dw),y+sin(s)*(r-dw)).lineTo(x+cos(s)*r,y+sin(s)*r);
  2489. this.c.arc(x, y, r, s, e,ccw);
  2490. this.lineTo(x+cos(e)*(r-dw),y+sin(e)*(r-dw));
  2491. this.c.arc(x, y, r-dw, e, s,!ccw);
  2492. }else{
  2493. this.c.arc(x, y, r, s, e, ccw);
  2494. if (a2r)
  2495. this.lineTo(x, y);
  2496. }
  2497. this.closePath();
  2498. if(!b){
  2499. this.shadowOn(sw).fill(c);
  2500. }else{
  2501. this.shadowOn(sw).stroke(b).shadowOff().fill(c);
  2502. }
  2503. return this.restore();
  2504. },
  2505. /**
  2506. * draw sector
  2507. */
  2508. sector : function(x, y, r, dw,s, e, c, b, bw, bc, sw, ccw,a2a,font) {
  2509. if (sw)
  2510. this.arc(x, y, r, dw, s, e,c,b,bw,bc,sw,ccw, !a2a, !font);
  2511. return this.arc(x, y, r, dw, s, e, c, b, bw, bc, false, ccw, !a2a);
  2512. },
  2513. sector3D : function() {
  2514. var x0, y0,sPaint = function(x, y, a, b, s, e, ccw, h, c) {
  2515. var Lo = function(A, h) {
  2516. this.lineTo(x + a * cos(A), y + (h || 0) + (b * sin(A)));
  2517. },
  2518. angle = s;
  2519. this.fillStyle($.dark(c)).moveTo(x + a * cos(s), y + (b * sin(s))).beginPath();
  2520. while (angle <= e) {
  2521. Lo.call(this, angle);
  2522. angle = angle + inc;
  2523. }
  2524. Lo.call(this, e);
  2525. this.lineTo(x + a * cos(e), (y + h) + (b * sin(e)));
  2526. angle = e;
  2527. while (angle >= s) {
  2528. Lo.call(this, angle, h);
  2529. angle = angle - inc;
  2530. }
  2531. Lo.call(this, s, h);
  2532. this.lineTo(x + a * cos(s), y + (b * sin(s))).closePath().fill(true);
  2533. }, layerDraw = function(x, y, a, b, ccw, h, A, c) {
  2534. var x0 = x + a * cos(A);
  2535. var y0 = y + h + (b * sin(A));
  2536. this.moveTo(x, y).beginPath().fillStyle(c).lineTo(x, y + h).lineTo(x0, y0).lineTo(x0, y0 - h).lineTo(x, y).closePath().fill(true);
  2537. }, layerPaint = function(x, y, a, b, s, e, ccw, h, c) {
  2538. var q1 = $.quadrantd(s),q2 = $.quadrantd(e);
  2539. c = $.dark(c);
  2540. if (q1==1||q1==2)
  2541. layerDraw.call(this, x, y, a, b, ccw, h, s, c);
  2542. if (q2==0||q2==3)
  2543. layerDraw.call(this, x, y, a, b, ccw, h, e, c);
  2544. };
  2545. var s3 = function(x, y, a, b, s, e, h, c, bo, bow, boc, sw, ccw, isw) {
  2546. /**
  2547. * paint bottom layer
  2548. */
  2549. this.ellipse(x, y + h, a, b, s, e, c, bo, bow, boc, sw, ccw, true);
  2550. /**
  2551. * paint inside layer
  2552. */
  2553. layerPaint.call(this, x, y, a, b, s, e, ccw, h, c);
  2554. /**
  2555. * paint top layer
  2556. */
  2557. this.ellipse(x, y, a, b, s, e, c, bo, bow, boc, false, ccw, true);
  2558. /**
  2559. * paint outside layer
  2560. */
  2561. sPaint.call(this, x, y, a, b, s, e, ccw, h, c);
  2562. return this;
  2563. }
  2564. s3.layerPaint = layerPaint;
  2565. s3.sPaint = sPaint;
  2566. s3.layerDraw = layerDraw;
  2567. return s3;
  2568. }(),
  2569. textStyle : function(a, l, f) {
  2570. return this.textAlign(a).textBaseline(l).textFont(f);
  2571. },
  2572. strokeStyle : function(b,w, c, j) {
  2573. if(b){
  2574. if (w)
  2575. this.c.lineWidth = w;
  2576. if (c)
  2577. this.c.strokeStyle = c;
  2578. if (j)
  2579. this.c.lineJoin = j;
  2580. }
  2581. return this;
  2582. },
  2583. globalAlpha : function(v) {
  2584. if (v)
  2585. this.c.globalAlpha = v;
  2586. return this;
  2587. },
  2588. fillStyle : function(c) {
  2589. if (c)
  2590. this.c.fillStyle = c;
  2591. return this;
  2592. },
  2593. arc2 : function(x, y, r, s, e, c) {
  2594. if(r)
  2595. this.c.arc(x, y, r, s, e, c);
  2596. return this;
  2597. },
  2598. textAlign : function(a) {
  2599. if (a)
  2600. this.c.textAlign = a;
  2601. return this;
  2602. },
  2603. textBaseline : function(l) {
  2604. if (l)
  2605. this.c.textBaseline = l;
  2606. return this;
  2607. },
  2608. textFont : function(font) {
  2609. if (font)
  2610. this.c.font = font;
  2611. return this;
  2612. },
  2613. shadowOn : function(s) {
  2614. if (s) {
  2615. this.c.shadowColor = s.color;
  2616. this.c.shadowBlur = s.blur;
  2617. this.c.shadowOffsetX = s.offsetx;
  2618. this.c.shadowOffsetY = s.offsety;
  2619. }
  2620. return this;
  2621. },
  2622. shadowOff : function() {
  2623. this.c.shadowColor = 'white';
  2624. this.c.shadowBlur = this.c.shadowOffsetX = this.c.shadowOffsetY = 0;
  2625. return this;
  2626. },
  2627. gradient : function(x, y, w, h, c,m,r) {
  2628. m = m.toLowerCase();
  2629. var x0=x,y0=y,f=!m.indexOf("linear");
  2630. m = m.substring(14);
  2631. if(f){
  2632. switch (m) {
  2633. case 'updown':
  2634. y0 += h;
  2635. break;
  2636. case 'downup':
  2637. y += h;
  2638. break;
  2639. case 'leftright':
  2640. x0 += w;
  2641. break;
  2642. case 'rightleft':
  2643. x += w;
  2644. break;
  2645. default:
  2646. return c[0];
  2647. }
  2648. return this.avgLinearGradient(x, y, x0, y0, c);
  2649. }else{
  2650. x+=w/2;
  2651. y+=h/2;
  2652. return this.avgRadialGradient(x,y,(r||0),x,y,(w>h?h:w),m=='outin'?c.reverse():c);
  2653. }
  2654. },
  2655. avgLinearGradient : function(xs, ys, xe, ye, c) {
  2656. var g = this.createLinearGradient(xs, ys, xe, ye);
  2657. for ( var i = 0; i < c.length; i++)
  2658. g.addColorStop(i / (c.length - 1), c[i]);
  2659. return g;
  2660. },
  2661. createLinearGradient : function(xs, ys, xe, ye) {
  2662. return this.c.createLinearGradient(xs, ys, xe, ye);
  2663. },
  2664. avgRadialGradient : function(xs, ys, rs, xe, ye, re, c) {
  2665. var g = this.createRadialGradient(xs, ys, rs, xe, ye, re);
  2666. for ( var i = 0; i < c.length; i++)
  2667. g.addColorStop(i/ (c.length - 1), c[i]);
  2668. return g;
  2669. },
  2670. createRadialGradient : function(xs, ys, rs, xe, ye, re) {
  2671. return this.c.createRadialGradient(xs, ys, rs, xe, ye, re);
  2672. },
  2673. text : function(t, x, y, max, color, align, line, font, mode, h,sw,ro) {
  2674. return this.save().textStyle(align, line, font).fillText(t, x, y, max, color, mode, h,sw,ro).restore();
  2675. },
  2676. fillText : function(t, x, y, max, color, mode, h,sw,ro) {
  2677. t = t.toString();
  2678. if(!t||!t.length)return this;
  2679. max = max || false;
  2680. mode = mode || 'lr';
  2681. h = h || 16;
  2682. x = fd(0, x);
  2683. y = fd(0, y);
  2684. var T = t.split(mode == 'tb' ? "" : "\n");
  2685. if(T.length>1){
  2686. if(this.c.textBaseline=='middle'){
  2687. y = y - (T.length-1)*h/2;
  2688. }else if(this.c.textBaseline=='bottom'){
  2689. y = y - (T.length-1)*h;
  2690. }
  2691. }
  2692. this.save().fillStyle(color).translate(x,y).rotate(inc2*ro).shadowOn(sw);
  2693. T.each(function(t,i) {
  2694. try {
  2695. if (max&&max>0)
  2696. this.c.fillText(t, 0,i*h, max);
  2697. else
  2698. this.c.fillText(t, 0, i*h);
  2699. } catch (e) {
  2700. console.log(e.message + '[' + t + ',' + x + ',' + y + ']');
  2701. }
  2702. }, this);
  2703. return this.restore();
  2704. },
  2705. measureText : function(t){
  2706. t = t.split("\n");
  2707. var m=0;
  2708. t.each(function(o){
  2709. m = max(this.measureText(o).width,m);
  2710. },this.c);
  2711. return m;
  2712. },
  2713. moveTo : function(x, y) {
  2714. x = x || 0;
  2715. y = y || 0;
  2716. this.c.moveTo(x, y);
  2717. return this;
  2718. },
  2719. lineTo : function(x, y) {
  2720. x = x || 0;
  2721. y = y || 0;
  2722. this.c.lineTo(x, y);
  2723. return this;
  2724. },
  2725. save : function() {
  2726. this.c.save();
  2727. return this;
  2728. },
  2729. restore : function() {
  2730. this.c.restore();
  2731. return this;
  2732. },
  2733. beginPath : function() {
  2734. this.c.beginPath();
  2735. return this;
  2736. },
  2737. closePath : function() {
  2738. this.c.closePath();
  2739. return this;
  2740. },
  2741. stroke : function(s) {
  2742. if(s)
  2743. this.c.stroke();
  2744. return this;
  2745. },
  2746. fill : function(f) {
  2747. if(f)
  2748. this.c.fill();
  2749. return this;
  2750. },
  2751. /**
  2752. * can use cube3D instead of this?
  2753. */
  2754. cube : function(x, y, xv, yv, width, height, zdeep, bg, b, bw, bc, sw) {
  2755. x = fd(bw, x);
  2756. y = fd(bw, y);
  2757. zdeep = (zdeep && zdeep > 0) ? zdeep : width;
  2758. var x1 = x + zdeep * xv, y1 = y - zdeep * yv;
  2759. x1 = fd(bw, x1);
  2760. y1 = fd(bw, y1);
  2761. /**
  2762. * styles -> top-front-right
  2763. */
  2764. if (sw) {
  2765. this.polygon(bg, b, bw, bc, sw, false, [{x:x, y:y},{x: x1, y:y1},{x: x1 + width, y:y1},{x: x + width, y:y}]);
  2766. this.polygon(bg, b, bw, bc, sw, false, [{x:x, y:y},{x: x, y:y + height},{x: x + width,y: y + height},{x: x + width, y:y}]);
  2767. this.polygon(bg, b, bw, bc, sw, false, [{x:x + width, y:y},{x: x1 + width, y:y1},{x: x1 + width, y:y1 + height},{x: x + width, y:y + height}]);
  2768. }
  2769. /**
  2770. * clear the shadow on the body
  2771. */
  2772. this.polygon($.dark(bg), b, bw, bc, false, false, [{x:x, y:y}, {x:x1, y:y1}, {x:x1 + width, y:y1}, {x:x + width, y:y}]);
  2773. this.polygon(bg, b, bw, bc, false, false, [{x:x, y:y}, {x:x, y:y + height}, {x:x + width, y:y + height}, {x:x + width,y: y}]);
  2774. this.polygon($.dark(bg), b, bw, bc, false, false, [{x:x + width, y:y}, {x:x1 + width, y:y1}, {x:x1 + width, y:y1 + height}, {x:x + width, y:y + height}]);
  2775. return this;
  2776. },
  2777. cube3D : function(x, y, rotatex, rotatey, angle, w, h, zh, b, bw, bc, styles) {
  2778. /**
  2779. * styles -> lowerBottom-bottom-left-right-top-front
  2780. */
  2781. x = fd(bw, x);
  2782. y = fd(bw, y);
  2783. zh = (!zh || zh == 0) ? w : zh;
  2784. if (angle) {
  2785. var P = $.vectorP2P(rotatex, rotatey);
  2786. rotatex = x + zh * P.x, rotatey = y - zh * P.y;
  2787. } else {
  2788. rotatex = x + zh * rotatex, rotatey = y - zh * rotatey;
  2789. }
  2790. while (styles.length < 6)
  2791. styles.push(false);
  2792. rotatex = fd(bw, rotatex);
  2793. rotatey = fd(bw, rotatey);
  2794. var side = [];
  2795. if (rotatey < 0) {
  2796. if ($.isObject(styles[4]))
  2797. side.push($.applyIf({
  2798. points : [{x:x,y:y - h},{x:rotatex,y:rotatey - h},{x:rotatex + w, y:rotatey - h},{x: x + w, y:y - h}]
  2799. }, styles[4]));
  2800. } else {
  2801. if ($.isObject(styles[0]))
  2802. side.push($.applyIf({
  2803. points : [{x:x, y:y},{x: rotatex, y:rotatey},{x: rotatex + w, y:rotatey},{x: x + w,y:y}]
  2804. }, styles[0]));
  2805. }
  2806. if ($.isObject(styles[1]))
  2807. side.push($.applyIf({
  2808. points : [{x:rotatex, y:rotatey},{x: rotatex, y:rotatey - h}, {x:rotatex + w, y:rotatey - h},{x: rotatex + w,y:rotatey}]
  2809. }, styles[1]));
  2810. if ($.isObject(styles[2]))
  2811. side.push($.applyIf({
  2812. points : [{x:x, y:y}, {x:x, y:y - h},{x: rotatex, y:rotatey - h},{x: rotatex, y:rotatey}]
  2813. }, styles[2]));
  2814. if ($.isObject(styles[3]))
  2815. side.push($.applyIf({
  2816. points : [{x:x + w, y:y}, {x:x + w, y:y - h}, {x:rotatex + w, y:rotatey - h}, {x:rotatex + w, y:rotatey}]
  2817. }, styles[3]));
  2818. if (rotatey < 0) {
  2819. if ($.isObject(styles[0]))
  2820. side.push($.applyIf({
  2821. points : [{x:x,y: y}, {x:rotatex, y:rotatey}, {x:rotatex + w, y:rotatey}, {x:x + w, y:y}]
  2822. }, styles[0]));
  2823. } else {
  2824. if ($.isObject(styles[4]))
  2825. side.push($.applyIf({
  2826. points : [{x:x, y:y - h}, {x:rotatex, y:rotatey - h}, {x:rotatex + w, y:rotatey - h}, {x:x + w, y:y - h}]
  2827. }, styles[4]));
  2828. }
  2829. if ($.isObject(styles[5]))
  2830. side.push($.applyIf({
  2831. points : [{x:x, y:y}, {x:x, y:y - h}, {x:x + w, y:y - h}, {x:x + w, y:y}]
  2832. }, styles[5]));
  2833. side.each(function(s) {
  2834. this.polygon(s.color, b, bw, bc, s.shadow, s.alpha, s.points);
  2835. }, this);
  2836. return this;
  2837. },
  2838. polygon : function(bg, b, bw, bc, sw, alpham, p, smooth, smo,l) {
  2839. this.save().strokeStyle(b,bw, bc).beginPath().fillStyle(bg).globalAlpha(alpham).shadowOn(sw).moveTo(p[0].x,p[0].y);
  2840. if (smooth) {
  2841. this.moveTo(fd(bw,l[0].x),fd(bw,l[0].y)).lineTo(fd(bw, p[0].x), fd(bw, p[0].y));
  2842. for ( var i = 1; i < p.length; i++)
  2843. this.bezierCurveTo(getCurvePoint(p, p[i], i, smo));
  2844. this.lineTo(fd(bw,l[1].x),fd(bw,l[1].y));
  2845. } else {
  2846. for ( var i = 1; i < p.length; i++)
  2847. this.lineTo(fd(bw, p[i].x), fd(bw, p[i].y));
  2848. }
  2849. return this.closePath().stroke(b).fill(bg).restore();
  2850. },
  2851. lines : function(p, w, c, last) {
  2852. if(!w)return this;
  2853. this.save().gCo(last).beginPath().strokeStyle(true,w, c).moveTo(fd(w, p[0]), fd(w, p[1]));
  2854. for ( var i = 2; i < p.length - 1; i += 2) {
  2855. this.lineTo(fd(w, p[i]), fd(w, p[i + 1]));
  2856. }
  2857. return this.stroke(true).restore();
  2858. },
  2859. bezierCurveTo : function(r) {
  2860. this.c.bezierCurveTo(r[0], r[1], r[2], r[3], r[4], r[5]);
  2861. return this;
  2862. },
  2863. label : function(p, w, c) {
  2864. return this.save()
  2865. .beginPath()
  2866. .strokeStyle(true,w, c)
  2867. .moveTo(fd(w, p[0].x), fd(w, p[0].y))
  2868. .bezierCurveTo([p[1].x,p[1].y,p[2].x,p[2].y,p[3].x,p[3].y])
  2869. .stroke(true)
  2870. .restore();
  2871. },
  2872. lineArray : function(p, w, c, smooth, smo) {
  2873. if(!w)return this;
  2874. this.save().beginPath().strokeStyle(true,w, c).moveTo(fd(w, p[0].x), fd(w, p[0].y));
  2875. for ( var i = 1; i < p.length; i++){
  2876. if (smooth) {
  2877. this.bezierCurveTo(getCurvePoint(p, p[i], i, smo || 1.5));
  2878. } else {
  2879. this.lineTo(fd(w, p[i].x), fd(w, p[i].y));
  2880. }
  2881. }
  2882. return this.stroke(true).restore();
  2883. },
  2884. dotted : function(x1, y1, x2, y2, w, c,L,f,last) {
  2885. if (!w)
  2886. return this;
  2887. x1 = fd(w, x1);
  2888. y1 = fd(w, y1);
  2889. x2 = fd(w, x2);
  2890. y2 = fd(w, y2);
  2891. var d = $.distanceP2P(x1, y1, x2, y2),t;
  2892. if(L<=0||d<=L||(x1!=x2&&y1!=y2)){
  2893. return this.line(x1, y1, x2, y2, w, c, last);
  2894. }
  2895. if(x1>x2||y1>y2){
  2896. t = x1;
  2897. x1 = x2;
  2898. x2 = t;
  2899. t = y1;
  2900. y1 = y2;
  2901. y2 = t;
  2902. }
  2903. this.save().gCo(last).strokeStyle(true,w, c).beginPath().moveTo(x1,y1);
  2904. var S = L*(f || 1),g = floor(d/(L+S)),k = (d-g*(L+S))>L,h=(y1==y2);
  2905. g = k?g+1:g;
  2906. for(var i=1;i<=g;i++){
  2907. this.lineTo(h?x1+L*i+S*(i-1):x1,h?y1:y1+L*i+S*(i-1)).moveTo(h?x1+(L+S)*i:x1, h?y1:y1+(L+S)*i);
  2908. }
  2909. if(!k){
  2910. this.lineTo(x2,y2);
  2911. }
  2912. return this.stroke(true).restore();
  2913. },
  2914. line : function(x1, y1, x2, y2, w, c, last) {
  2915. if (!w)
  2916. return this;
  2917. this.save().gCo(last);
  2918. return this.beginPath().strokeStyle(true,w, c).moveTo(fd(w, x1), fd(w, y1)).lineTo(fd(w, x2), fd(w, y2)).stroke(true).restore();
  2919. },
  2920. round : function(x, y, r, c, bw, bc) {
  2921. return this.arc(x, y, r,0, 0, PI2, c, !!bc, bw, bc);
  2922. },
  2923. round0 : function(q, r, c, bw, bc) {
  2924. return this.arc(q.x, q.y, r,0, 0, PI2, c, !!bc, bw, bc);
  2925. },
  2926. fillRect : function(x, y, w, h) {
  2927. this.c.fillRect(x, y, w, h);
  2928. return this;
  2929. },
  2930. translate : function(x, y) {
  2931. this.c.translate(x, y);
  2932. return this;
  2933. },
  2934. rotate : function(r) {
  2935. this.c.rotate(r);
  2936. return this;
  2937. },
  2938. clearRect : function(x, y, w, h) {
  2939. x = x || 0;
  2940. y = y || 0;
  2941. w = w || this.canvas.width;
  2942. h = h || this.canvas.height;
  2943. this.c.clearRect(x, y, w, h);
  2944. return this;
  2945. },
  2946. gCo : function(l) {
  2947. if(l)
  2948. return this.gCO(l);
  2949. return this;
  2950. },
  2951. gCO : function(l) {
  2952. this.c.globalCompositeOperation = l ? "destination-over" : "source-over";
  2953. return this;
  2954. },
  2955. box : function(x, y, w, h, b, bg, shadow, m,last) {
  2956. b = b || {
  2957. enable : 0
  2958. }
  2959. if (b.enable) {
  2960. var j = b.width, c = b.color, r = b.radius, f = $.isNumber(j);
  2961. j = $.parsePadding(j);
  2962. if(j[0]==j[1]&&j[1]==j[2]&&j[2]==j[3]){
  2963. f = true;
  2964. }
  2965. m = m?1:-1;
  2966. w += m*(j[1] + j[3]) / 2;
  2967. h += m*(j[0] + j[2]) / 2;
  2968. x -= m*(j[3] / 2);
  2969. y -= m*(j[0] / 2);
  2970. j = f ? j[0] : j;
  2971. r = (!f ||!r|| r == 0 || r == '0') ? 0 : $.parsePadding(r);
  2972. }
  2973. this.save().gCo(last).fillStyle(bg).strokeStyle(f,j, c);
  2974. /**
  2975. * draw a round corners border
  2976. */
  2977. if (r) {
  2978. this.beginPath().moveTo(fd(j,x+r[0]), fd(j, y))
  2979. .lineTo(fd(j,x+w - r[1]), fd(j, y))
  2980. .arc2(fd(j,x+w - r[1]), fd(j, y+r[1]), r[1], PI*3/2, PI2)
  2981. .lineTo(fd(j, x+w), fd(j,y+h - r[2]))
  2982. .arc2(fd(j,x+w - r[2]), fd(j, y+h-r[2]), r[2], 0, PI/2)
  2983. .lineTo(fd(j,x+r[3]), fd(j, y+h))
  2984. .arc2(fd(j,x+r[3]), fd(j, y+h-r[3]), r[3], PI/2, PI)
  2985. .lineTo(fd(j,x), fd(j,y+r[0]))
  2986. .arc2(fd(j,x+r[0]), fd(j, y+r[0]), r[0], PI, PI*3/2)
  2987. .closePath().shadowOn(shadow).stroke(j).shadowOff().fill(bg);
  2988. } else {
  2989. if (!b.enable || f) {
  2990. if (j&&b.enable){
  2991. this.shadowOn(shadow).c.strokeRect(x, y, w, h);
  2992. this.shadowOff();
  2993. }
  2994. if (bg)
  2995. this.fillRect(x, y, w, h);
  2996. } else {
  2997. if(j){
  2998. c = $.isArray(c) ? c : [c, c, c, c];
  2999. this.shadowOn(shadow).line(x+w, y+j[0] / 2, x+w, y+h - j[0] / 2, j[1], c[1], 0).line(x, y+j[0] / 2, x, y+h - j[0] / 2, j[3], c[3], 0).line(floor(x-j[3] / 2),y, x+w + j[1] / 2, y, j[0], c[0], 0).line(floor(x-j[3] / 2), y+h, x+w + j[1] / 2, y+h, j[2], c[2], 0).shadowOff();
  3000. }
  3001. if (bg) {
  3002. this.beginPath().moveTo(floor(x+j[3] / 2), floor(y+j[0] / 2)).lineTo(ceil(x+w - j[1] / 2), y+j[0] / 2).lineTo(ceil(x+w - j[1] / 2), ceil(y+h - j[2] / 2)).lineTo(floor(x+j[3] / 2), ceil(y+h - j[2] / 2)).lineTo(floor(x+j[3] / 2), floor(y+j[0] / 2)).closePath().fill(bg);
  3003. }
  3004. }
  3005. }
  3006. return this.restore();
  3007. },
  3008. toDataURL : function(g) {
  3009. return this.canvas.toDataURL(g || "image/png");
  3010. },
  3011. addEvent : function(type, fn, useCapture) {
  3012. $.Event.addEvent(this.canvas, type, fn, useCapture);
  3013. }
  3014. }
  3015. /**
  3016. * the public method,inner use
  3017. */
  3018. $.taylor = {
  3019. light:function(_,e){
  3020. e.highlight = false;
  3021. _.on('mouseover',function(){
  3022. e.highlight = true;
  3023. _.redraw('mouseover');
  3024. }).on('mouseout',function(){
  3025. e.highlight = false;
  3026. _.redraw('mouseout');
  3027. }).on('beforedraw',function(){
  3028. _.push('f_color',e.highlight?_.get('light_color'):_.get('f_color_'));
  3029. return true;
  3030. });
  3031. }
  3032. }
  3033. /**
  3034. * @overview this component is a super class of all chart
  3035. * @component#$.Chart
  3036. * @extend#$.Painter
  3037. */
  3038. $.Chart = $.extend($.Painter, {
  3039. /**
  3040. * @cfg {TypeName}
  3041. */
  3042. configure : function() {
  3043. /**
  3044. * invoked the super class's configuration
  3045. */
  3046. $.Chart.superclass.configure.apply(this, arguments);
  3047. /**
  3048. * indicate the element's type
  3049. */
  3050. this.type = 'chart';
  3051. /**
  3052. * indicate the data structure
  3053. */
  3054. this.dataType = 'simple';
  3055. this.set({
  3056. /**
  3057. * @cfg {String} The unique id of this element (defaults to an auto-assigned id).
  3058. */
  3059. id : '',
  3060. /**
  3061. * @cfg {String} id of dom you want rendered(defaults '').
  3062. */
  3063. render : '',
  3064. /**
  3065. * @cfg {Array} Required,The datasource of Chart.must be not empty.
  3066. */
  3067. data : [],
  3068. /**
  3069. * @cfg {Number} Specifies the width of this canvas
  3070. */
  3071. width : undefined,
  3072. /**
  3073. * @cfg {Number} Specifies the height of this canvas
  3074. */
  3075. height : undefined,
  3076. /**
  3077. * @cfg {String} Specifies the default lineJoin of the canvas's context in this element.(defaults to 'round')
  3078. */
  3079. lineJoin : 'round',
  3080. /**
  3081. * @cfg {String} this property specifies the horizontal alignment of chart in an module (defaults to 'center') Available value are:
  3082. * @Option 'left'
  3083. * @Option 'center'
  3084. * @Option 'right'
  3085. */
  3086. align : 'center',
  3087. /**
  3088. * @cfg {Boolean} If true mouse change to a pointer when a mouseover fired.only available when use PC.(defaults to true)
  3089. */
  3090. default_mouseover_css : true,
  3091. /**
  3092. * @cfg {Boolean} If true ignore the event touchmove.only available when support touchEvent.(defaults to false)
  3093. */
  3094. turn_off_touchmove : false,
  3095. /**
  3096. * @cfg {Boolean} Specifies as true to display with percent.(default to false)
  3097. */
  3098. showpercent : false,
  3099. /**
  3100. * @cfg {Number} Specifies the number of decimal when use percent.(default to 1)
  3101. */
  3102. decimalsnum : 1,
  3103. /**
  3104. * @cfg {Object/String} Specifies the config of Title details see <link>$.Text</link>,If given a string,it will only apply the text.note:If the text is empty,then will not display
  3105. */
  3106. title : {
  3107. text : '',
  3108. fontweight : 'bold',
  3109. /**
  3110. * Specifies the font-size in pixels of title.(default to 20)
  3111. */
  3112. fontsize : 20,
  3113. /**
  3114. * Specifies the height of title will be take.(default to 30)
  3115. */
  3116. height : 30
  3117. },
  3118. /**
  3119. * @cfg {Object/String}Specifies the config of subtitle details see <link>$.Text</link>,If given a string,it will only apply the text.note:If the title or subtitle'text is empty,then will not display
  3120. */
  3121. subtitle : {
  3122. text : '',
  3123. fontweight : 'bold',
  3124. /**
  3125. * Specifies the font-size in pixels of title.(default to 16)
  3126. */
  3127. fontsize : 16,
  3128. /**
  3129. * Specifies the height of title will be take.(default to 20)
  3130. */
  3131. height : 20
  3132. },
  3133. /**
  3134. * @cfg {Object/String}Specifies the config of footnote details see <link>$.Text</link>,If given a string,it will only apply the text.note:If the text is empty,then will not display
  3135. */
  3136. footnote : {
  3137. text : '',
  3138. /**
  3139. * Specifies the font-color of footnote.(default to '#5d7f97')
  3140. */
  3141. color : '#5d7f97',
  3142. textAlign : 'right',
  3143. /**
  3144. * Specifies the height of title will be take.(default to 20)
  3145. */
  3146. height : 20
  3147. },
  3148. /**
  3149. * @cfg {Boolean} If true element will have a animation when show, false to skip the animation.(default to false)
  3150. */
  3151. animation : false,
  3152. /**
  3153. * @Function {Function} the custom funtion for animation.(default to null)
  3154. */
  3155. doAnimation : null,
  3156. /**
  3157. * @cfg {String} (default to 'ease-in-out') Available value are:
  3158. * @Option 'easeIn'
  3159. * @Option 'easeOut'
  3160. * @Option 'easeInOut'
  3161. * @Option 'linear'
  3162. */
  3163. animation_timing_function : 'easeInOut',
  3164. /**
  3165. * @cfg {Number} Specifies the duration when animation complete in millisecond.(default to 1000)
  3166. */
  3167. animation_duration : 1000,
  3168. /**
  3169. * @cfg {Number} Specifies the chart's z_index.override the default as 999 to make it at top layer.(default to 999)
  3170. */
  3171. z_index:999,
  3172. /**
  3173. * @cfg {Object}Specifies the config of Legend.For details see <link>$.Legend</link> Note:this has a extra property named 'enable',indicate whether legend available(default to false)
  3174. */
  3175. legend : {
  3176. enable : false
  3177. },
  3178. /**
  3179. * @cfg {Object} Specifies the config of Tip.For details see <link>$.Tip</link> Note:this has a extra property named 'enable',indicate whether tip available(default to false)
  3180. */
  3181. tip : {
  3182. enable : false
  3183. }
  3184. });
  3185. /**
  3186. * register the common event
  3187. */
  3188. this.registerEvent(
  3189. /**
  3190. * @event Fires before this element Animation.Only valid when <link>animation</link> is true
  3191. * @paramter $.Chart#this
  3192. */
  3193. 'beforeAnimation',
  3194. /**
  3195. * @event Fires when this element Animation finished.Only valid when <link>animation</link> is true
  3196. * @paramter $.Chart#this
  3197. */
  3198. 'afterAnimation',
  3199. /**
  3200. * @event Fires when chart resize.
  3201. * @paramter int#width chart's width
  3202. * @paramter int#height chart's height
  3203. * @return Object object the new config for chart
  3204. */
  3205. 'resize',
  3206. 'animating');
  3207. this.T = null;
  3208. this.Rendered = false;
  3209. this.Combination = false;
  3210. this.Animationed = false;
  3211. this.show = false;
  3212. this.data = [];
  3213. this.plugins = [];
  3214. this.components = [];
  3215. this.oneways = [];
  3216. this.total = 0;
  3217. this.ICHARTJS_CHART = true;
  3218. },
  3219. toDataURL : function(g) {
  3220. return this.T.toDataURL(g);
  3221. },
  3222. segmentRect : function() {
  3223. if(!this.Combination)
  3224. this.T.clearRect();
  3225. },
  3226. resetCanvas : function() {
  3227. if(!this.Combination)
  3228. this.T.box(this.get('l_originx'), this.get('t_originy'), this.get('client_width'), this.get('client_height'),0,this.get('f_color'),0,0,true);
  3229. },
  3230. animation : function(_) {
  3231. /**
  3232. * clear the part of canvas
  3233. */
  3234. _.segmentRect();
  3235. /**
  3236. * draw coordinate
  3237. */
  3238. if(_.coo&&!_.ILLUSIVE_COO)
  3239. _.coo.draw();
  3240. /**
  3241. * doAnimation of implement
  3242. */
  3243. _.doAnimation(_.variable.animation.time, _.duration,_);
  3244. /**
  3245. * draw plugins
  3246. */
  3247. _.plugins.each(function(p){
  3248. if(p.A_draw){
  3249. p.variable.animation.animating =true;
  3250. p.variable.animation.time =_.variable.animation.time;
  3251. p.draw();
  3252. p.variable.animation.animating =false;
  3253. }
  3254. });
  3255. if(_.Combination){
  3256. return;
  3257. }
  3258. _.oneways.each(function(o) {o.draw()});
  3259. if (_.variable.animation.time < _.duration) {
  3260. _.variable.animation.time++;
  3261. $.requestAnimFrame(function() {
  3262. _.animation(_);
  3263. });
  3264. } else {
  3265. $.requestAnimFrame(function() {
  3266. _.Animationed = true;
  3267. /**
  3268. * make plugins's status is the same as chart
  3269. */
  3270. _.plugins.each(function(p){
  3271. p.Animationed = true;
  3272. });
  3273. _.processAnimation = false;
  3274. _.draw();
  3275. _.plugins.each(function(p){
  3276. p.processAnimation = false;
  3277. });
  3278. _.fireEvent(_, 'afterAnimation', [_]);
  3279. });
  3280. }
  3281. },
  3282. runAnimation : function(_) {
  3283. _.fireEvent(_, 'beforeAnimation', [_]);
  3284. if(!_.A_draw)
  3285. _.variable.animation = {
  3286. type : 0,
  3287. time : 0,
  3288. queue : []
  3289. }
  3290. _.processAnimation = true;
  3291. _.animation(_);
  3292. },
  3293. doSort:function(){
  3294. var f = function(p, q){return ($.isArray(p)?(p.zIndex||0):p.get('z_index'))>($.isArray(q)?(q.zIndex||0):q.get('z_index'))};
  3295. this.components.sor(f);
  3296. this.oneways.sor(f);
  3297. },
  3298. commonDraw : function(_,e) {
  3299. _.show = false;
  3300. if (!_.redraw) {
  3301. $.Assert.isTrue(_.Rendered, _.type + ' has not rendered');
  3302. $.Assert.isTrue(_.data&&_.data.length>0,_.type + '\'s data is empty');
  3303. $.Assert.isTrue(_.initialization, _.type + ' Failed to initialize');
  3304. _.doSort();
  3305. }
  3306. _.redraw = true;
  3307. if (!_.Animationed && _.get('animation')) {
  3308. _.runAnimation(_);
  3309. return;
  3310. }
  3311. _.segmentRect();
  3312. //order?
  3313. _.components.eachAll(function(c) {
  3314. c.draw(e);
  3315. });
  3316. _.components.eachAll(function(c) {
  3317. if(c.last)c.last(c);
  3318. });
  3319. //order?
  3320. _.oneways.each(function(o) {o.draw()});
  3321. _.show = true;
  3322. },
  3323. /**
  3324. * @method register the customize component or combinate with other charts
  3325. * @paramter <link>$.Custom</link><link>$.Chart</link>#object
  3326. * @return void
  3327. */
  3328. plugin : function(c) {
  3329. var _ = this._();
  3330. c.inject(_);
  3331. if(c.ICHARTJS_CHART){
  3332. c.Combination = true;
  3333. c.setUp();
  3334. }
  3335. if(!_.get('animation')){
  3336. c.push('animation',false);
  3337. }
  3338. c.duration =_.duration;
  3339. _.register(c);
  3340. _.plugins.push(c);
  3341. },
  3342. destroy:function(_){
  3343. _.components.eachAll(function(C){
  3344. C.destroy();
  3345. });
  3346. _.oneways.each(function(O){
  3347. O.destroy();
  3348. });
  3349. },
  3350. /**
  3351. * @method return the title,return undefined if unavailable
  3352. * @return <link>$.Text</link>#the title object
  3353. */
  3354. getTitle:function(){
  3355. return this.title;
  3356. },
  3357. /**
  3358. * @method return the subtitle,return undefined if unavailable
  3359. * @return <link>$.Text</link>#the subtitle object
  3360. */
  3361. getSubTitle:function(){
  3362. return this.subtitle;
  3363. },
  3364. /**
  3365. * @method return the footnote,return undefined if unavailable
  3366. * @return <link>$.Text</link>#the footnote object
  3367. */
  3368. getFootNote:function(){
  3369. return this.footnote;
  3370. },
  3371. /**
  3372. * @method return the main Drawing Area's dimension,return following property:
  3373. * x:the left-top coordinate-x
  3374. * y:the left-top coordinate-y
  3375. * width:the width of drawing area
  3376. * height:the height of drawing area
  3377. * @return Object#contains dimension info
  3378. */
  3379. getDrawingArea:function(){
  3380. return {
  3381. x:this.get("l_originx"),
  3382. x:this.get("t_originy"),
  3383. width:this.get("client_width"),
  3384. height:this.get("client_height")
  3385. }
  3386. },
  3387. create : function(_,shell) {
  3388. /**
  3389. * fit the window
  3390. */
  3391. if(_.get('fit')){
  3392. var w = window.innerWidth,
  3393. h = window.innerHeight,
  3394. style = $.getDoc().body.style;
  3395. style.padding = "0px";
  3396. style.margin = "0px";
  3397. style.overflow = "hidden";
  3398. _.push(_.W, w);
  3399. _.push(_.H, h);
  3400. }
  3401. _.canvasid = $.uid(_.type);
  3402. _.shellid = "shell-"+_.canvasid;
  3403. var H = [];
  3404. H.push("<div id='");
  3405. H.push(_.shellid);
  3406. H.push("' style='padding:0px;margin:0px;overflow:hidden;position:relative;'>");
  3407. H.push("<canvas id= '");
  3408. H.push(_.canvasid);
  3409. H.push("' style='-webkit-text-size-adjust: none;'>");
  3410. H.push("<p>Your browser does not support the canvas element</p></canvas>");
  3411. H.push("</div>");
  3412. /**
  3413. * also use appendChild()
  3414. */
  3415. shell.innerHTML = H.join("");
  3416. _.shell = $(_.shellid);
  3417. /**
  3418. * the base canvas wrap for draw
  3419. */
  3420. _.T = _.target = new Cans(_.canvasid);
  3421. /**
  3422. * do size
  3423. */
  3424. _.size(_);
  3425. _.Rendered = true;
  3426. },
  3427. /**
  3428. * @method set up the chart by latest configruation
  3429. * @return void
  3430. */
  3431. setUp:function(){
  3432. var _ = this._();
  3433. _.redraw = false;
  3434. _.T.clearRect();
  3435. _.initialization = false;
  3436. _.initialize();
  3437. },
  3438. /**
  3439. * @method load the new data
  3440. * @paramter array#data
  3441. * @return void
  3442. */
  3443. load:function(d){
  3444. var _ = this._();
  3445. _.push('data', d||[]);
  3446. _.setUp();
  3447. (_.Combination?_.root:_).draw();
  3448. },
  3449. /**
  3450. * @method resize the chart
  3451. * @paramter int#width
  3452. * @paramter int#height
  3453. * @return void
  3454. */
  3455. resize:function(w,h){
  3456. w = $.parseFloat(w);
  3457. h = $.parseFloat(h);
  3458. var _ = this._();
  3459. if(!_.Combination){
  3460. _.width = _.push(_.W, w);
  3461. _.height = _.push(_.H, h);
  3462. _.size(_);
  3463. }
  3464. _.set(_.fireEvent(_,'resize',[w,h]));
  3465. _.setUp();
  3466. _.plugins.eachAll(function(P) {
  3467. if(P.Combination){
  3468. P.resize(w,h);
  3469. }
  3470. });
  3471. if(!_.Combination){
  3472. _.draw();
  3473. }
  3474. },
  3475. size:function(_){
  3476. _.T.canvas.width = _.width = _.pushIf(_.W, 400);
  3477. _.T.canvas.height = _.height = _.pushIf(_.H, 300);
  3478. _.shell.style.width = _.width+'px';
  3479. _.shell.style.height = _.height+'px';
  3480. },
  3481. initialize : function() {
  3482. var _ = this._(),d = _.get('data'),r = _.get('render');
  3483. _.push(_.X, null);
  3484. _.push(_.Y, null);
  3485. if(_.Combination){
  3486. $.apply(_.options, $.clone([_.W,_.H,'padding','border','client_height','client_width',
  3487. 'minDistance','maxDistance','centerx', 'centery',
  3488. 'l_originx','r_originx','t_originy','b_originy'], _.root.options,true));
  3489. _.width = _.get(_.W);
  3490. _.height = _.get(_.H);
  3491. _.shell = _.root.shell;
  3492. _.Rendered = true;
  3493. }else if (!_.Rendered) {
  3494. if(r)
  3495. _.create(_,$(r));
  3496. }
  3497. if(_.Rendered && !_.initialization){
  3498. if(d&&d.length>0){
  3499. parse.call(_,d,_);
  3500. }else if($.isString(_.get('url'))){
  3501. _.ajax.call(_,_.get('url'),function(D){
  3502. _.push('data',D);
  3503. _.initialize();
  3504. _.draw();
  3505. });
  3506. }
  3507. }
  3508. },
  3509. /**
  3510. * @method turn off the event listener
  3511. * @return void
  3512. */
  3513. eventOff:function(){this.stopEvent = true},
  3514. /**
  3515. * @method turn on the event listener
  3516. * @return void
  3517. */
  3518. eventOn:function(){this.stopEvent = false},
  3519. /**
  3520. * this method only invoked once
  3521. */
  3522. oneWay:function(_){
  3523. _.T.strokeStyle(true,0, _.get('strokeStyle'), _.get('lineJoin'));
  3524. _.processAnimation = _.get('animation');
  3525. if($.isFunction(_.get('doAnimation'))){
  3526. _.doAnimation = _.get('doAnimation');
  3527. }
  3528. _.animationArithmetic = $.getAA(_.get('animation_timing_function'));
  3529. var E = _.variable.event,comb=_.Combination,tot=!_.get('turn_off_touchmove')&&!comb, mCSS = !$.touch&&_.get('default_mouseover_css')&&!comb, O, AO,events = $.touch?['touchstart','touchmove']:['click','mousemove'];
  3530. _.stopEvent = false;
  3531. _.A_draw = comb&&_.processAnimation;
  3532. /**
  3533. * register chart in Registry
  3534. */
  3535. $.register(_);
  3536. /**
  3537. * If Combination,ignore binding event because of root have been do this.
  3538. */
  3539. if(!comb){
  3540. events.each(function(it) {
  3541. _.T.addEvent(it, function(e) {
  3542. if (_.processAnimation||_.stopEvent)
  3543. return;
  3544. if(e.targetTouches&&e.targetTouches.length!=1){
  3545. return;
  3546. }
  3547. _.fireEvent(_, it, [_, $.Event.fix(e)]);
  3548. }, false);
  3549. });
  3550. }
  3551. _.on(events[0], function(_, e) {
  3552. _.components.eachAll(function(C) {
  3553. if(C.ICHARTJS_CHART){
  3554. /**
  3555. * meaning this component is a Combination Chart
  3556. */
  3557. if(C.fireEvent(C,events[0], [C, e])){
  3558. E.click = true;
  3559. return false;
  3560. }
  3561. }else{
  3562. /**
  3563. * generic component
  3564. */
  3565. var M = C.isMouseOver(e);
  3566. if (M.valid){
  3567. E.click = true;
  3568. C.fireEvent(C,'click', [C, e, M]);
  3569. return !e.stopPropagation;
  3570. }
  3571. }
  3572. });
  3573. if(E.click){
  3574. if(tot)
  3575. e.event.preventDefault();
  3576. E.click = false;
  3577. return true;
  3578. }
  3579. });
  3580. if(!$.touch||tot){
  3581. _.on(events[1], function(_, e) {
  3582. O = AO = false;
  3583. _.components.eachAll(function(C) {
  3584. if(C.ICHARTJS_CHART){
  3585. /**
  3586. * meaning this component is a Combination Chart
  3587. */
  3588. if(C.fireEvent(C,events[1], [C, e])){
  3589. O = true;
  3590. return false;
  3591. }
  3592. }else{
  3593. var cE = C.variable.event, M = C.isMouseOver(e);
  3594. if (M.valid) {
  3595. O = O || C.atomic;
  3596. if (!cE.mouseover) {
  3597. cE.mouseover = true;
  3598. C.fireEvent(C, 'mouseover', [C,e, M]);
  3599. }
  3600. C.fireEvent(C, 'mousemove', [C,e, M]);
  3601. if(M.stop){
  3602. return false;
  3603. }
  3604. } else {
  3605. if (cE.mouseover) {
  3606. cE.mouseover = false;
  3607. C.fireEvent(C, 'mouseout', [C,e, M]);
  3608. }
  3609. }
  3610. return !e.stopPropagation;
  3611. }
  3612. });
  3613. if(E.mouseover){
  3614. e.event.preventDefault();
  3615. if (!O) {
  3616. E.mouseover = false;
  3617. _.fireEvent(_, 'mouseout', [_,e]);
  3618. }
  3619. return E.mouseover;
  3620. }else{
  3621. if(O){
  3622. E.mouseover = O;
  3623. _.fireEvent(_, 'mouseover', [_,e]);
  3624. }
  3625. }
  3626. });
  3627. /**
  3628. * defalut mouse style
  3629. */
  3630. if (mCSS) {
  3631. _.on('mouseover',function(){
  3632. _.T.css("cursor", "pointer");
  3633. }).on('mouseout',function(){
  3634. _.T.css("cursor", "default");
  3635. });
  3636. }
  3637. }
  3638. /**
  3639. * clone config to sub_option
  3640. */
  3641. $.applyIf(_.get('sub_option'), $.clone(['shadow','tip'], _.options,true));
  3642. if(!_.Combination){
  3643. /**
  3644. * push the background in it
  3645. */
  3646. _.bg = new $.Custom({
  3647. z_index:-1,
  3648. drawFn:function(){
  3649. _.T.box(0, 0, _.width, _.height, _.get('border'), _.get('f_color'),0,0,true);
  3650. }
  3651. });
  3652. _.duration = ceil(_.get('animation_duration') * $.FRAME / 1000);
  3653. }
  3654. _.oneWay = $.emptyFn;
  3655. },
  3656. /**
  3657. * calculate chart's alignment
  3658. */
  3659. originXY:function(_,x,y){
  3660. var A = _.get('align');
  3661. if (A == _.L) {
  3662. _.pushIf(_.X, x[0]);
  3663. } else if (A == _.R) {
  3664. _.pushIf(_.X, x[1]);
  3665. } else {
  3666. _.pushIf(_.X, x[2]);
  3667. }
  3668. _.x = _.push(_.X, _.get(_.X) + _.get('offsetx'));
  3669. _.y = _.push(_.Y, y[0]+ _.get('offsety'));
  3670. return {
  3671. x:_.x,
  3672. y:_.y
  3673. }
  3674. },
  3675. getPercent:function(v,T){
  3676. return this.get('showpercent') ? (v / (T||this.total||1) * 100).toFixed(this.get('decimalsnum')) + '%' : v;
  3677. },
  3678. doActing:function(_,d,o,i,t){
  3679. var f=!!_.get('communal_acting'),v=_.getPercent(d.value,d.total);
  3680. /**
  3681. * store or restore the option
  3682. */
  3683. _.push(f?'sub_option':'communal_acting',$.clone(_.get(f?'communal_acting':'sub_option'),true));
  3684. /**
  3685. * merge the option
  3686. */
  3687. $.merge(_.get('sub_option'),d);
  3688. /**
  3689. * merge specific option
  3690. */
  3691. $.merge(_.get('sub_option'),o);
  3692. _.push('sub_option.value',v);
  3693. _.push('sub_option.value_',d.value);
  3694. if (_.get('sub_option.tip.enable')){
  3695. _.push('sub_option.tip.text',t || (d.name + ' ' +v));
  3696. _.push('sub_option.tip.name',d.name);
  3697. _.push('sub_option.tip.index',i);
  3698. _.push('sub_option.tip.value',d.value);
  3699. _.push('sub_option.tip.total',d.total||_.total);
  3700. }
  3701. },
  3702. register:function(c){
  3703. c.id = $.uid(c.type);
  3704. this.components.push(c);
  3705. return c;
  3706. },
  3707. remove:function(_,c){
  3708. if(c)
  3709. _.components.each(function(C,i){
  3710. if(c.id==C.id){
  3711. _.components.splice(i,1);
  3712. return false;
  3713. }
  3714. });
  3715. },
  3716. doConfig : function() {
  3717. $.Chart.superclass.doConfig.call(this);
  3718. var _ = this._();
  3719. _.destroy(_);
  3720. _.oneways.length =0;
  3721. _.oneWay(_);
  3722. /**
  3723. * for store the option of each item in chart
  3724. */
  3725. _.push('communal_acting',0);
  3726. if(!_.Combination){
  3727. _.oneways.push(_.bg);
  3728. _.push('r_originx', _.width - _.get('padding_right'));
  3729. _.push('b_originy', _.height - _.get('padding_bottom'));
  3730. _.applyGradient();
  3731. if ($.isString(_.get('title'))) {
  3732. _.push('title', $.applyIf({
  3733. text : _.get('title')
  3734. }, _.default_.title));
  3735. }
  3736. if ($.isString(_.get('subtitle'))) {
  3737. _.push('subtitle', $.applyIf({
  3738. text : _.get('subtitle')
  3739. }, _.default_.subtitle));
  3740. }
  3741. if ($.isString(_.get('footnote'))) {
  3742. _.push('footnote', $.applyIf({
  3743. text : _.get('footnote')
  3744. }, _.default_.footnote));
  3745. }
  3746. var H = 0, l = _.push('l_originx', _.get('padding_left')), t = _.push('t_originy', _.get('padding_top')), w = _.push('client_width', (_.width - _.get('hpadding'))), h;
  3747. if (_.get('title.text') != ''){
  3748. var st = _.get('subtitle.text') != '';
  3749. H = st ? _.get('title.height') + _.get('subtitle.height') : _.get('title.height');
  3750. t = _.push('t_originy', t + H);
  3751. _.push('title.originx', l);
  3752. _.push('title.originy', _.get('padding_top'));
  3753. _.push('title.maxwidth', w);
  3754. _.pushIf('title.width', w);
  3755. _.title = new $.Text(_.get('title'), _);
  3756. _.oneways.push(_.title);
  3757. if (st) {
  3758. _.push('subtitle.originx', l);
  3759. _.push('subtitle.originy', _.get('padding_top') + _.get('title.height'));
  3760. _.pushIf('subtitle.width', w);
  3761. _.push('subtitle.maxwidth', w);
  3762. _.subtitle = new $.Text(_.get('subtitle'), _);
  3763. _.oneways.push(_.subtitle);
  3764. }
  3765. }
  3766. if (_.get('footnote.text') != '') {
  3767. var g = _.get('footnote.height');
  3768. H += g;
  3769. _.push('b_originy', _.get('b_originy') - g);
  3770. _.push('footnote.originx', l);
  3771. _.push('footnote.originy', _.get('b_originy'));
  3772. _.push('footnote.maxwidth', w);
  3773. _.pushIf('footnote.width', w);
  3774. _.footnote = new $.Text(_.get('footnote'), _);
  3775. _.oneways.push(_.footnote);
  3776. }
  3777. h = _.push('client_height', (_.get(_.H) - _.get('vpadding') - _.pushIf('other_height',H)));
  3778. _.push('minDistance', min(w, h));
  3779. _.push('maxDistance', max(w, h));
  3780. _.push('centerx', l + w / 2);
  3781. _.push('centery', t + h / 2);
  3782. }
  3783. /**
  3784. * TODO legend dosize?
  3785. */
  3786. if (_.get('legend.enable')){
  3787. _.legend = new $.Legend($.apply({
  3788. maxwidth : _.get('client_width'),
  3789. data : _.data
  3790. }, _.get('legend')), _);
  3791. _.oneways.push(_.legend);
  3792. }
  3793. _.push('sub_option.tip.wrap',_.push('tip.wrap', _.shell));
  3794. }
  3795. });
  3796. })($);
  3797. /**
  3798. * @end
  3799. */
  3800. /**
  3801. * @overview the customize componment
  3802. * @component#$.Custom
  3803. * @extend#$.Component
  3804. */
  3805. $.Custom = $.extend($.Component,{
  3806. configure:function(){
  3807. /**
  3808. * invoked the super class's configuration
  3809. */
  3810. $.Custom.superclass.configure.apply(this,arguments);
  3811. /**
  3812. * indicate the component's type
  3813. */
  3814. this.type = 'custom';
  3815. this.set({
  3816. /**
  3817. * @cfg {Function} Specifies the customize function.(default to emptyFn)
  3818. */
  3819. drawFn:$.emptyFn,
  3820. configFn:$.emptyFn,
  3821. /**
  3822. * @cfg {Function} Specifies the customize event valid function.(default to undefined)
  3823. */
  3824. eventValid:undefined,
  3825. /**
  3826. * @cfg {Boolean} If true when chart animating it also invoke darw.(default to true)
  3827. */
  3828. animating_draw:true
  3829. });
  3830. },
  3831. doDraw:function(_){
  3832. _.get('drawFn').call(_,_);
  3833. },
  3834. isEventValid:function(e,_){
  3835. if($.isFunction(this.get('eventValid')))
  3836. return this.get('eventValid').call(this,e,_);
  3837. return {valid:false};
  3838. },
  3839. doConfig:function(){
  3840. $.Custom.superclass.doConfig.call(this);
  3841. var _ = this._();
  3842. _.A_draw = _.get('animating_draw');
  3843. _.variable.animation = {
  3844. animating:false,
  3845. time : 0
  3846. };
  3847. _.duration = 0;
  3848. _.get('configFn').call(_,_);
  3849. }
  3850. });
  3851. /**
  3852. * @end
  3853. */
  3854. /**
  3855. * @overview this is inner use for axis
  3856. * @component#$.Scale
  3857. * @extend#$.Component
  3858. */
  3859. $.Scale = $.extend($.Component, {
  3860. configure : function() {
  3861. /**
  3862. * invoked the super class's configuration
  3863. */
  3864. $.Scale.superclass.configure.apply(this, arguments);
  3865. /**
  3866. * indicate the component's type
  3867. */
  3868. this.type = 'scale';
  3869. this.set({
  3870. /**
  3871. * @cfg {String} Specifies alignment of this scale.(default to 'left')
  3872. */
  3873. position : 'left',
  3874. /**
  3875. * @cfg {String} the axis's type(default to 'h') Available value are:
  3876. * @Option 'h' :horizontal
  3877. * @Option 'v' :vertical
  3878. */
  3879. which : 'h',
  3880. /**
  3881. * @cfg {Number} Specifies value of Baseline Coordinate.(default to 0)
  3882. */
  3883. basic_value:0,
  3884. /**
  3885. * @cfg {Boolean} indicate whether the grid is accord with scale.(default to true)
  3886. */
  3887. scale2grid : true,
  3888. /**
  3889. * @inner {Number}
  3890. */
  3891. distance : undefined,
  3892. /**
  3893. * @cfg {Number} Specifies the start coordinate scale value.(default to 0)
  3894. */
  3895. start_scale : 0,
  3896. /**
  3897. * @cfg {Number} Specifies the end coordinate scale value.Note either this or property of max_scale must be has the given value.(default to undefined)
  3898. */
  3899. end_scale : undefined,
  3900. /**
  3901. * @cfg {Number} Specifies the chart's minimal value
  3902. */
  3903. min_scale : undefined,
  3904. /**
  3905. * @cfg {Number} Specifies the chart's maximal value
  3906. */
  3907. max_scale : undefined,
  3908. /**
  3909. * @cfg {Number} Specifies the space of two scale.Note either this or property of scale_share must be has the given value.(default to undefined)
  3910. */
  3911. scale_space : undefined,
  3912. /**
  3913. * @cfg {Number} Specifies the number of scale on axis.(default to 5)
  3914. */
  3915. scale_share : 5,
  3916. /**
  3917. * @cfg {Boolean} True to display the scale line.(default to true)
  3918. */
  3919. scale_enable : true,
  3920. /**
  3921. * @cfg {Number} Specifies the size of brush(context.linewidth).(default to 1)
  3922. */
  3923. scale_size : 1,
  3924. /**
  3925. * @cfg {Number} Specifies the width(length) of scale.(default to 4)
  3926. */
  3927. scale_width : 4,
  3928. /**
  3929. * @cfg {String} Specifies the color of scale.(default to 4)
  3930. */
  3931. scale_color : '#333333',
  3932. /**
  3933. * @cfg {String} Specifies the align against axis.(default to 'center') When the property of which set to 'h',Available value are:
  3934. * @Option 'left'
  3935. * @Option 'center'
  3936. * @Option 'right'
  3937. * When the property of which set to 'v', Available value are:
  3938. * @Option 'top'
  3939. * @Option 'center'
  3940. * @Option 'bottom'
  3941. */
  3942. scaleAlign : 'center',
  3943. /**
  3944. * @cfg {Array} the customize labels
  3945. */
  3946. labels : [],
  3947. /**
  3948. * @cfg {<link>$.Text</link>} Specifies label's option.
  3949. */
  3950. label : {},
  3951. /**
  3952. * @cfg {Number} Specifies the distance to scale.(default to 6)
  3953. */
  3954. text_space : 6,
  3955. /**
  3956. * @cfg {String} Specifies the align against axis.(default to 'left' or 'bottom' in v mode) When the property of which set to 'h',Available value are:
  3957. * @Option 'left'
  3958. * @Option 'right' When the property of which set to 'v', Available value are:
  3959. * @Option 'top'
  3960. * @Option 'bottom'
  3961. */
  3962. textAlign : 'left',
  3963. /**
  3964. * @cfg {Number} Specifies the number of decimal.this will change along with scale.(default to 0)
  3965. */
  3966. decimalsnum : 0,
  3967. /**
  3968. * @inner {String} the style of overlapping(default to 'none') Available value are:
  3969. * @Option 'square'
  3970. * @Option 'round'
  3971. * @Option 'none'
  3972. */
  3973. join_style : 'none',
  3974. /**
  3975. * @inner {Number}
  3976. */
  3977. join_size : 2
  3978. });
  3979. this.registerEvent(
  3980. /**
  3981. * @event Fires the event when parse text,you can return a object like this:{text:'',originx:100,originy:100} to override the given.
  3982. * @paramter string#text item's text
  3983. * @paramter int#originx coordinate-x of item's text
  3984. * @paramter int#originy coordinate-y of item's text
  3985. * @paramter int#index item's index
  3986. * @paramter boolean#last If last item
  3987. */
  3988. 'parseText');
  3989. },
  3990. isEventValid : function() {
  3991. return {
  3992. valid : false
  3993. };
  3994. },
  3995. getScale:function(_){
  3996. var u = [_.get('basic_value'),_.get('start_scale'),_.get('end_scale'),_.get('end_scale') - _.get('start_scale'),0];
  3997. u[4] = $.inRange(u[1],u[2]+1,u[0])||$.inRange(u[2]-1,u[1],u[0]);
  3998. return {
  3999. range:u[4],
  4000. basic:u[4]?(u[0]-u[1]) / u[3]:0,
  4001. start : u[4]?u[0]:u[1],
  4002. end : u[2],
  4003. distance : u[3]
  4004. }
  4005. },
  4006. /**
  4007. * from left to right,top to bottom
  4008. */
  4009. doDraw : function(_) {
  4010. if (_.get('scale_enable'))
  4011. _.items.each(function(item) {
  4012. _.T.line(item.x0, item.y0, item.x1, item.y1, _.get('scale_size'), _.get('scale_color'), false);
  4013. });
  4014. _.labels.each(function(l) {
  4015. l.draw();
  4016. });
  4017. },
  4018. doLayout:function(x,y,_){
  4019. if (_.get('scale_enable'))
  4020. _.items.each(function(item) {
  4021. item.x0+=x;
  4022. item.y0+=y;
  4023. item.x1+=x;
  4024. item.y1+=y;
  4025. });
  4026. _.labels.each(function(l) {
  4027. l.doLayout(x,y,0,l);
  4028. });
  4029. },
  4030. doConfig : function() {
  4031. $.Scale.superclass.doConfig.call(this);
  4032. var _ = this._(),abs = Math.abs,customL = _.get('labels').length, min_s = _.get('min_scale'), max_s = _.get('max_scale'), s_space = _.get('scale_space'), e_scale = _.get('end_scale'), start_scale = _.get('start_scale');
  4033. _.items = [];
  4034. _.labels = [];
  4035. _.number = 0;
  4036. if (customL > 0) {
  4037. _.number = customL - 1;
  4038. } else {
  4039. /**
  4040. * startScale must less than minScale
  4041. */
  4042. if (start_scale > min_s) {
  4043. start_scale = _.push('start_scale', $.floor(min_s));
  4044. }
  4045. /**
  4046. * end_scale must greater than maxScale
  4047. */
  4048. if (!$.isNumber(e_scale) || e_scale < max_s) {
  4049. e_scale = $.ceil(max_s);
  4050. e_scale = _.push('end_scale', (!e_scale&&!start_scale)?1:e_scale);
  4051. }
  4052. if (s_space && abs(s_space) < abs(e_scale - start_scale)) {
  4053. _.push('scale_share', (e_scale - start_scale) / s_space);
  4054. }
  4055. _.number = _.push('scale_share', abs(_.get('scale_share')));
  4056. /**
  4057. * value of each scale
  4058. */
  4059. if (!s_space || s_space >( e_scale - start_scale)) {
  4060. var W = ((e_scale - start_scale)+"").indexOf('.')+1,M=1;
  4061. while(W>0){W--;M*=10;}
  4062. s_space = _.push('scale', (e_scale - start_scale)*M / _.get('scale_share')/M);
  4063. }
  4064. if (parseInt(s_space)!=s_space && _.get('decimalsnum') == 0) {
  4065. _.push('decimalsnum',(s_space+"").substring((s_space+"").indexOf('.')+1).length);
  4066. }
  4067. }
  4068. /**
  4069. * the real distance of each scale
  4070. */
  4071. _.push('distanceOne', _.get('valid_distance') / _.number);
  4072. var text, x, y, x1 = 0, y1 = 0, x0 = 0, y0 = 0, tx = 0, ty = 0, w = _.get('scale_width'), w2 = w / 2, sa = _.get('scaleAlign'), ta = _.get('position'), ts = _.get('text_space'), tbl = '',aw = _.get('coo').get('axis.width');
  4073. _.push('which', _.get('which').toLowerCase());
  4074. _.isH = _.get('which') == 'h';
  4075. if (_.isH) {
  4076. if (sa == _.O) {
  4077. y0 = -w;
  4078. } else if (sa == _.C) {
  4079. y0 = -w2;
  4080. y1 = w2;
  4081. } else {
  4082. y1 = w;
  4083. }
  4084. if (ta == _.O) {
  4085. ty = -ts-aw[0];
  4086. tbl = _.B;
  4087. } else {
  4088. ty = ts+aw[2];
  4089. tbl = _.O;
  4090. }
  4091. ta = _.C;
  4092. } else {
  4093. if (sa == _.L) {
  4094. x0 = -w;
  4095. } else if (sa == _.C) {
  4096. x0 = -w2;
  4097. x1 = w2;
  4098. } else {
  4099. x1 = w;
  4100. }
  4101. tbl = 'middle';
  4102. if (ta == _.R) {
  4103. ta = _.L;
  4104. tx = ts+aw[1];
  4105. } else {
  4106. ta = _.R;
  4107. tx = -ts-aw[3];
  4108. }
  4109. }
  4110. /**
  4111. * valid width only applies when there is h,then valid_height only applies when there is v
  4112. */
  4113. for ( var i = 0; i <= _.number; i++) {
  4114. text = customL ? _.get('labels')[i] : (s_space * i + start_scale).toFixed(_.get('decimalsnum'));
  4115. x = _.isH ? _.get('valid_x') + i * _.get('distanceOne') : _.x;
  4116. y = _.isH ? _.y : _.get('valid_y') + _.get('valid_distance') - i * _.get('distanceOne');
  4117. _.items.push({
  4118. x : x,
  4119. y : y,
  4120. x0 : x + x0,
  4121. y0 : y + y0,
  4122. x1 : x + x1,
  4123. y1 : y + y1
  4124. });
  4125. /**
  4126. * put the label into a Text?
  4127. */
  4128. if(_.get('label'))
  4129. _.labels.push(new $.Text($.applyIf($.apply(_.get('label'), $.merge({
  4130. text : text,
  4131. x : x,
  4132. y : y,
  4133. originx : x + tx,
  4134. originy : y + ty
  4135. }, _.fireEvent(_, 'parseText', [text, x + tx, y + ty, i, _.number == i]))), {
  4136. textAlign : ta,
  4137. textBaseline : tbl
  4138. }), _));
  4139. /**
  4140. * maxwidth = Math.max(maxwidth, _.T.measureText(text));
  4141. */
  4142. }
  4143. }
  4144. });
  4145. /**
  4146. * @end
  4147. */
  4148. $.Coordinate = {
  4149. coordinate_ : function(g) {
  4150. var _ = this._(),coo = _.get('coordinate');
  4151. if(coo.ICHARTJS_OBJECT){
  4152. _.x = _.push(_.X, coo.x);
  4153. _.y = _.push(_.Y, coo.y);
  4154. /**
  4155. * Imply it was illusive
  4156. */
  4157. _.ILLUSIVE_COO = true;
  4158. return coo;
  4159. }
  4160. /**
  4161. * Apply the coordinate feature
  4162. */
  4163. var f = '85%',
  4164. parse=$.parsePercent,
  4165. scale = _.get('coordinate.scale'),
  4166. li=_.get('scaleAlign'),
  4167. w = _.push('coordinate._width',parse(_.get('coordinate.width')||f,Math.floor(_.get('client_width'))));
  4168. h = _.push('coordinate._height',parse(_.get('coordinate.height')||f,Math.floor(_.get('client_height')))-(_.is3D()?((_.get('coordinate.pedestal_height')||22) + (_.get('coordinate.board_deep')||20)):0));
  4169. _.push('coordinate.valid_height_value',parse(_.get('coordinate.valid_height'),h));
  4170. _.push('coordinate.valid_width_value',parse(_.get('coordinate.valid_width'),w));
  4171. _.originXY(_,[_.get('l_originx'),_.get('r_originx') - w,_.get('centerx') - w / 2],[_.get('centery') - h / 2]);
  4172. _.push('coordinate.originx', _.x);
  4173. _.push('coordinate.originy', _.y);
  4174. /**
  4175. * invoke call back
  4176. */
  4177. if(g)g();
  4178. if($.isObject(scale)){
  4179. scale = [scale];
  4180. }
  4181. if($.isArray(scale)){
  4182. var ST = _.dataType != 'stacked';
  4183. scale.each(function(s){
  4184. /**
  4185. * applies the percent shower
  4186. */
  4187. if(_.get('percent')&&s.position==li){
  4188. s = $.apply(s,{
  4189. start_scale : 0,
  4190. end_scale : 100,
  4191. scale_space : 10,
  4192. listeners:{
  4193. parseText:function(t,x,y){
  4194. return {text:t+'%'}
  4195. }
  4196. }
  4197. });
  4198. }
  4199. if(!s.start_scale||(ST&&s.start_scale>_.get('minValue')))
  4200. s.min_scale = _.get('minValue');
  4201. if(!s.end_scale||(ST&&s.end_scale<_.get('maxValue')))
  4202. s.max_scale = _.get('maxValue');
  4203. });
  4204. }else{
  4205. _.push('coordinate.scale',{
  4206. position : li,
  4207. scaleAlign : li,
  4208. max_scale : _.get('maxValue'),
  4209. min_scale : _.get('minValue')
  4210. });
  4211. }
  4212. if (_.is3D()) {
  4213. _.push('coordinate.xAngle_', _.get('xAngle_'));
  4214. _.push('coordinate.yAngle_', _.get('yAngle_'));
  4215. /**
  4216. * the Coordinate' Z is same as long as the column's
  4217. */
  4218. _.push('coordinate.zHeight', _.get('zHeight') * _.get('bottom_scale'));
  4219. }
  4220. _.remove(_,_.coo);
  4221. return _.register(new $[_.is3D()?'Coordinate3D':'Coordinate2D'](_.get('coordinate'), _));;
  4222. }
  4223. }
  4224. /**
  4225. * @overview the coordinate2d componment
  4226. * @component#$.Coordinate2D
  4227. * @extend#$.Component
  4228. */
  4229. $.Coordinate2D = $.extend($.Component, {
  4230. configure : function() {
  4231. /**
  4232. * invoked the super class's configurationuration
  4233. */
  4234. $.Coordinate2D.superclass.configure.apply(this, arguments);
  4235. /**
  4236. * indicate the component's type
  4237. */
  4238. this.type = 'coordinate2d';
  4239. this.set({
  4240. /**
  4241. * @inner {Number}
  4242. */
  4243. sign_size : 12,
  4244. /**
  4245. * @inner {Number}
  4246. */
  4247. sign_space : 5,
  4248. /**
  4249. * @cfg {Array} the option for scale.For details see <link>$.Scale</link>
  4250. */
  4251. scale : [],
  4252. /**
  4253. * @cfg {String/Number} Here,specify as '85%' relative to client width.(default to '85%')
  4254. */
  4255. width:'85%',
  4256. /**
  4257. * @cfg {String/Number} Here,specify as '85%' relative to client height.(default to '85%')
  4258. */
  4259. height:'85%',
  4260. /**
  4261. * @cfg {String/Number} Specifies the valid width,less than the width of coordinate.you can applies a percent value relative to width.(default to '100%')
  4262. */
  4263. valid_width : '100%',
  4264. /**
  4265. * @cfg {String/Number} Specifies the valid height,less than the height of coordinate.you can applies a percent value relative to width.(default to '100%')
  4266. */
  4267. valid_height : '100%',
  4268. /**
  4269. * @cfg {Number} Specifies the linewidth of the grid.(default to 1)
  4270. */
  4271. grid_line_width : 1,
  4272. /**
  4273. * @cfg {String} Specifies the color of the grid.(default to '#dbe1e1')
  4274. */
  4275. grid_color : '#dbe1e1',
  4276. /**
  4277. * @cfg {Object} Specifies the stlye of horizontal grid.(default to empty object).Available property are:
  4278. * @Option solid {Boolean} True to draw a solid line.else draw a dotted line.(default to true)
  4279. * @Option size {Number} Specifies size of line segment when solid is false.(default to 10)
  4280. * @Option fator {Number} Specifies the times to size(default to 1)
  4281. * @Option width {Number} Specifies the width of grid line.(default to 1)
  4282. * @Option color {String} Specifies the color of grid line.(default to '#dbe1e1')
  4283. */
  4284. gridHStyle : {},
  4285. /**
  4286. * @cfg {Object} Specifies the stlye of horizontal grid.(default to empty object).Available property are:
  4287. * @Option solid {Boolean} True to draw a solid line.else draw a dotted line.(default to true)
  4288. * @Option size {Number} Specifies size of line segment when solid is false.(default to 10)
  4289. * @Option fator {Number} Specifies the times to size(default to 1)
  4290. * @Option width {Number} Specifies the width of grid line.(default to 1)
  4291. * @Option color {String} Specifies the color of grid line.(default to '#dbe1e1')
  4292. */
  4293. gridVStyle : {},
  4294. /**
  4295. * @cfg {Boolean} True to display grid line.(default to true)
  4296. */
  4297. gridlinesVisible : true,
  4298. /**
  4299. * @cfg {Boolean} indicate whether the grid is accord with scale,on the premise of grids is not specify. this just give a convenient way bulid grid for default.and actual value depend on scale's scale2grid
  4300. */
  4301. scale2grid : true,
  4302. /**
  4303. * @cfg {Object} this is grid config for custom.there has two valid property horizontal and vertical.the property's sub property is: way:the manner calculate grid-line (default to 'share_alike') Available property are:
  4304. * @Option share_alike
  4305. * @Option given_value value: when property way apply to 'share_alike' this property mean to the number of grid's line.
  4306. * when apply to 'given_value' this property mean to the distance each grid line(unit:pixel) .
  4307. * code will like:
  4308. * {
  4309. * horizontal: {way:'share_alike',value:10},
  4310. * vertical: { way:'given_value', value:40 }
  4311. * }
  4312. */
  4313. grids : undefined,
  4314. /**
  4315. * @cfg {Boolean} If True the grid line will be ignored when gird and axis overlap.(default to true)
  4316. */
  4317. ignoreOverlap : true,
  4318. /**
  4319. * @cfg {Boolean} If True the grid line will be ignored when gird and coordinate's edge overlap.(default to false)
  4320. */
  4321. ignoreEdge : false,
  4322. /**
  4323. * @inner {String} Specifies the label on x-axis
  4324. */
  4325. xlabel : '',
  4326. /**
  4327. * @inner {String} Specifies the label on y-axis
  4328. */
  4329. ylabel : '',
  4330. /**
  4331. * @cfg {String} Here,specify as false to make background transparent.(default to null)
  4332. */
  4333. background_color : 0,
  4334. /**
  4335. * @cfg {Boolean} True to stripe the axis.(default to true)
  4336. */
  4337. striped : true,
  4338. /**
  4339. * @cfg {String} Specifies the direction apply striped color.(default to 'v')Available value are:
  4340. * @Option 'h' horizontal
  4341. * @Option 'v' vertical
  4342. */
  4343. striped_direction : 'v',
  4344. /**
  4345. * @cfg {float(0.01 - 0.5)} Specifies the factor make color dark striped,relative to background-color,the bigger the value you set,the larger the color changed.(defaults to '0.01')
  4346. */
  4347. striped_factor : 0.01,
  4348. /**
  4349. * @cfg {Object} Specifies config crosshair.(default enable to false).For details see <link>$.CrossHair</link> Note:this has a extra property named 'enable',indicate whether crosshair available(default to false)
  4350. */
  4351. crosshair : {
  4352. enable : false
  4353. },
  4354. /**
  4355. * @cfg {Number}Override the default as -1 to make sure it at the bottom.(default to -1)
  4356. */
  4357. z_index : -1,
  4358. /**
  4359. * @cfg {Object} Specifies style for axis of this coordinate. Available property are:
  4360. * @Option enable {Boolean} True to display the axis.(default to true)
  4361. * @Option color {String} Specifies the color of each axis.(default to '#666666')
  4362. * @Option width {Number/Array} Specifies the width of each axis, If given the a array,there must be have have 4 element, like this:[1,0,0,1](top-right-bottom-left).(default to 1)
  4363. */
  4364. axis : {
  4365. enable : true,
  4366. color : '#666666',
  4367. width : 1
  4368. }
  4369. });
  4370. this.scale = [];
  4371. this.gridlines = [];
  4372. },
  4373. getScale : function(p,L) {
  4374. var _ = this._(),r;
  4375. for(var i=0;i<_.scale.length;i++){
  4376. if(_.scale[i].get('position')==p){
  4377. return _.scale[i].getScale(_.scale[i]);
  4378. }
  4379. }
  4380. if(!L){
  4381. if(p==_.L){
  4382. p = _.R;
  4383. }else if(p==_.R){
  4384. p = _.L;
  4385. }else if(p==_.O){
  4386. p = _.B;
  4387. }else{
  4388. p = _.O;
  4389. }
  4390. return _.getScale(p,true);
  4391. }
  4392. throw new Error("there no valid scale");
  4393. },
  4394. isEventValid : function(e,_) {
  4395. return {
  4396. valid : e.x > _.x && e.x < (_.x + _.width) && e.y < _.y + _.height && e.y > _.y
  4397. };
  4398. },
  4399. doDraw : function(_) {
  4400. _.T.box(_.x, _.y, _.width, _.height, 0, _.get('f_color'));
  4401. if (_.get('striped')) {
  4402. var x, y, f = false, axis = _.get('axis.width'), c = $.dark(_.get('background_color'), _.get('striped_factor'),0);
  4403. }
  4404. var v = (_.get('striped_direction') == 'v');
  4405. _.gridlines.each(function(g,i) {
  4406. if (_.get('striped')) {
  4407. if (f) {
  4408. if (v)
  4409. _.T.box(g.x1, g.y1 + g.width, g.x2 - g.x1, y - g.y1 - g.width, 0, c);
  4410. else
  4411. _.T.box(x + g.width, g.y2, g.x1 - x, g.y1 - g.y2, 0, c);
  4412. }
  4413. x = g.x1;
  4414. y = g.y1;
  4415. f = !f;
  4416. }
  4417. }).each(function(g) {
  4418. if(!g.overlap){
  4419. if(g.solid){
  4420. _.T.line(g.x1, g.y1, g.x2, g.y2, g.width, g.color);
  4421. }else{
  4422. _.T.dotted(g.x1, g.y1, g.x2, g.y2, g.width, g.color,g.size,g.fator);
  4423. }
  4424. }
  4425. });
  4426. _.T.box(_.x, _.y, _.width, _.height, _.get('axis'), false, _.get('shadow'),true);
  4427. _.scale.each(function(s) {
  4428. s.draw()
  4429. });
  4430. },
  4431. destroy:function(){
  4432. if(this.crosshair){
  4433. this.crosshair.destroy();
  4434. }
  4435. },
  4436. doCrosshair:function(_){
  4437. if (_.get('crosshair.enable')&&!_.crosshair) {
  4438. _.push('crosshair.wrap', _.root.shell);
  4439. _.push('crosshair.height', _.height);
  4440. _.push('crosshair.width', _.width);
  4441. _.push('crosshair.top', _.y);
  4442. _.push('crosshair.left', _.x);
  4443. _.crosshair = new $.CrossHair(_.get('crosshair'), _);
  4444. }
  4445. },
  4446. doConfig : function() {
  4447. $.Coordinate2D.superclass.doConfig.call(this);
  4448. var _ = this._();
  4449. /**
  4450. * this element not atomic because it is a container,so this is a particular case.
  4451. */
  4452. _.atomic = false;
  4453. _.width = _.get('_width');
  4454. _.height = _.get('_height');
  4455. _.valid_width = _.get('valid_width_value');
  4456. _.valid_height = _.get('valid_height_value');
  4457. /**
  4458. * apply the gradient color to f_color
  4459. */
  4460. if (_.get('gradient') && $.isString(_.get('f_color'))) {
  4461. _.push('f_color', _.T.avgLinearGradient(_.x, _.y, _.x, _.y + _.height, [_.get('dark_color'), _.get('light_color')]));
  4462. }
  4463. if (_.get('axis.enable')) {
  4464. var aw = _.get('axis.width');
  4465. if (!$.isArray(aw))
  4466. _.push('axis.width', [aw, aw, aw, aw]);
  4467. }else{
  4468. _.push('axis.width', [0, 0, 0, 0]);
  4469. }
  4470. _.doCrosshair(_);
  4471. var jp, cg = !!(_.get('gridlinesVisible') && _.get('grids')), hg = cg && !!_.get('grids.horizontal'), vg = cg && !!_.get('grids.vertical'), h = _.height, w = _.width, vw = _.valid_width, vh = _.valid_height, k2g = _.get('gridlinesVisible')
  4472. && _.get('scale2grid') && !(hg && vg), sw = _.push('x_start', _.x+(w - vw) / 2), sh = _.push('y_start', _.y+(h - vh) / 2), axis = _.get('axis.width');
  4473. _.push('x_end', _.x + (w + vw) / 2);
  4474. _.push('y_end', _.y + (h + vh) / 2);
  4475. if (!$.isArray(_.get('scale'))) {
  4476. if ($.isObject(_.get('scale')))
  4477. _.push('scale', [_.get('scale')]);
  4478. else
  4479. _.push('scale', []);
  4480. }
  4481. _.get('scale').each(function(kd, i) {
  4482. jp = kd['position'];
  4483. jp = jp || _.L;
  4484. jp = jp.toLowerCase();
  4485. kd[_.X] = _.x;
  4486. kd['coo'] = _;
  4487. kd[_.Y] = _.y;
  4488. kd['valid_x'] = sw;
  4489. kd['valid_y'] = sh;
  4490. kd['position'] = jp;
  4491. /**
  4492. * calculate coordinate,direction,distance
  4493. */
  4494. if (jp == _.O) {
  4495. kd['which'] = 'h';
  4496. kd['distance'] = w;
  4497. kd['valid_distance'] = vw;
  4498. } else if (jp == _.R) {
  4499. kd['which'] = 'v';
  4500. kd['distance'] = h;
  4501. kd['valid_distance'] = vh;
  4502. kd[_.X] += w;
  4503. kd['valid_x'] += vw;
  4504. } else if (jp == _.B) {
  4505. kd['which'] = 'h';
  4506. kd['distance'] = w;
  4507. kd['valid_distance'] = vw;
  4508. kd[_.Y] += h;
  4509. kd['valid_y'] += vh;
  4510. } else {
  4511. kd['which'] = 'v';
  4512. kd['distance'] = h;
  4513. kd['valid_distance'] = vh;
  4514. }
  4515. _.scale.push(new $.Scale(kd, _.root));
  4516. }, _);
  4517. var iol = _.push('ignoreOverlap', _.get('ignoreOverlap') && _.get('axis.enable') || _.get('ignoreEdge'));
  4518. if (iol) {
  4519. if (_.get('ignoreEdge')) {
  4520. var ignoreOverlap = function(w, x, y) {
  4521. return w == 'v' ? (y == _.y) || (y == _.y + h) : (x == _.x) || (x == _.x + w);
  4522. }
  4523. } else {
  4524. var ignoreOverlap = function(wh, x, y) {
  4525. return wh == 'v' ? (y == _.y && axis[0] > 0) || (y == (_.y + h) && axis[2] > 0) : (x == _.x && axis[3] > 0) || (x == (_.x + w) && axis[1] > 0);
  4526. }
  4527. }
  4528. }
  4529. var g = {
  4530. solid : true,
  4531. size : 10,
  4532. fator : 1,
  4533. width : _.get('grid_line_width'),
  4534. color : _.get('grid_color')
  4535. },
  4536. ghs = $.applyIf(_.get('gridHStyle'),g),
  4537. gvs = $.applyIf(_.get('gridVStyle'),g);
  4538. if (k2g) {
  4539. var scale, x, y, p;
  4540. _.scale.each(function(scale) {
  4541. p = scale.get('position');
  4542. /**
  4543. * disable,given specfiy grid will ignore scale2grid
  4544. */
  4545. if ($.isFalse(scale.get('scale2grid')) || hg && scale.get('which') == 'v' || vg && scale.get('which') == 'h') {
  4546. return;
  4547. }
  4548. x = y = 0;
  4549. if (p == _.O) {
  4550. y = h;
  4551. } else if (p == _.R) {
  4552. x = -w;
  4553. } else if (p == _.B) {
  4554. y = -h;
  4555. } else {
  4556. x = w;
  4557. }
  4558. scale.items.each(function(e) {
  4559. if (iol)
  4560. _.gridlines.push($.applyIf({
  4561. overlap:ignoreOverlap.call(_, scale.get('which'), e.x, e.y),
  4562. x1 : e.x,
  4563. y1 : e.y,
  4564. x2 : e.x + x,
  4565. y2 : e.y + y
  4566. },scale.isH?gvs:ghs));
  4567. });
  4568. });
  4569. }
  4570. if (vg) {
  4571. var gv = _.get('grids.vertical');
  4572. $.Assert.isTrue(gv['value']>0, 'vertical value');
  4573. var d = w / gv['value'], n = gv['value'];
  4574. if (gv['way'] == 'given_value') {
  4575. n = d;
  4576. d = gv['value'];
  4577. d = d > w ? w : d;
  4578. }
  4579. for ( var i = 0; i <= n; i++) {
  4580. if (iol)
  4581. _.gridlines.push($.applyIf({
  4582. overlap:ignoreOverlap.call(_, 'h', _.x + i * d, _.y),
  4583. x1 : _.x + i * d,
  4584. y1 : _.y,
  4585. x2 : _.x + i * d,
  4586. y2 : _.y + h,
  4587. H : false,
  4588. width : gvs.width,
  4589. color : gvs.color
  4590. },gvs));
  4591. }
  4592. }
  4593. if (hg) {
  4594. var gh = _.get('grids.horizontal');
  4595. $.Assert.isTrue(gh['value']>0,'horizontal value');
  4596. var d = h / gh['value'], n = gh['value'];
  4597. if (gh['way'] == 'given_value') {
  4598. n = d;
  4599. d = gh['value'];
  4600. d = d > h ? h : d;
  4601. }
  4602. for ( var i = 0; i <= n; i++) {
  4603. if (iol)
  4604. _.gridlines.push($.applyIf({
  4605. overlap:ignoreOverlap.call(_, 'v', _.x, _.y + i * d),
  4606. x1 : _.x,
  4607. y1 : _.y + i * d,
  4608. x2 : _.x + w,
  4609. y2 : _.y + i * d,
  4610. H : true,
  4611. width : ghs.width,
  4612. color : ghs.color
  4613. },ghs));
  4614. }
  4615. }
  4616. }
  4617. });
  4618. /**
  4619. * @end
  4620. */
  4621. /**
  4622. * @overview the coordinate3d componment
  4623. * @component#$.Coordinate3D
  4624. * @extend#$.Coordinate2D
  4625. */
  4626. $.Coordinate3D = $.extend($.Coordinate2D, {
  4627. configure : function() {
  4628. /**
  4629. * invoked the super class's configurationuration
  4630. */
  4631. $.Coordinate3D.superclass.configure.apply(this, arguments);
  4632. /**
  4633. * indicate the component's type
  4634. */
  4635. this.type = 'coordinate3d';
  4636. this.dimension = $._3D;
  4637. this.set({
  4638. /**
  4639. * @cfg {Number} Three-dimensional rotation X in degree(angle).socpe{0-90},Normally, this will accord with the chart.(default to 60)
  4640. */
  4641. xAngle : 60,
  4642. /**
  4643. * @cfg {Number} Three-dimensional rotation Y in degree(angle).socpe{0-90},Normally, this will accord with the chart.(default to 20)
  4644. */
  4645. yAngle : 20,
  4646. xAngle_ : undefined,
  4647. yAngle_ : undefined,
  4648. /**
  4649. * @cfg {Number} Required,Specifies the z-axis deep of this coordinate,Normally, this will given by chart.(default to 0)
  4650. */
  4651. zHeight : 0,
  4652. /**
  4653. * @cfg {Number} Specifies pedestal height of this coordinate.(default to 22)
  4654. */
  4655. pedestal_height : 22,
  4656. /**
  4657. * @cfg {Number} Specifies board deep of this coordinate.(default to 20)
  4658. */
  4659. board_deep : 20,
  4660. /**
  4661. * @cfg {Boolean} If true display the left board.(default to true)
  4662. */
  4663. left_board:true,
  4664. /**
  4665. * @cfg {Boolean} Override the default as true
  4666. */
  4667. gradient : true,
  4668. /**
  4669. * @cfg {float} Override the default as 0.18.
  4670. */
  4671. color_factor : 0.18,
  4672. /**
  4673. * @cfg {Boolean} Override the default as true.
  4674. */
  4675. ignoreEdge : true,
  4676. /**
  4677. * @cfg {Boolean} Override the default as false.
  4678. */
  4679. striped : false,
  4680. /**
  4681. * @cfg {String} Override the default as '#a4ad96'.
  4682. */
  4683. grid_color : '#a4ad96',
  4684. /**
  4685. * @cfg {String} Override the default as '#d6dbd2'.
  4686. */
  4687. background_color : '#d6dbd2',
  4688. /**
  4689. * @cfg {Number} Override the default as 4.
  4690. */
  4691. shadow_offsetx : 4,
  4692. /**
  4693. * @cfg {Number} Override the default as 2.
  4694. */
  4695. shadow_offsety : 2,
  4696. /**
  4697. * @cfg {Array} Specifies the style of board(wall) of this coordinate.
  4698. * the length of array will be 6,if less than 6,it will instead of <link>background_color</link>.and each object option has two property. Available property are:
  4699. * @Option color the color of wall
  4700. * @Option alpha the opacity of wall
  4701. */
  4702. wall_style : [],
  4703. /**
  4704. * @cfg {Boolean} Override the default as axis.enable = false.
  4705. */
  4706. axis : {
  4707. enable : false
  4708. }
  4709. });
  4710. },
  4711. doDraw : function(_) {
  4712. var w = _.width, h = _.height, xa = _.get('xAngle_'), ya = _.get('yAngle_'), zh = _.get('zHeight'), offx = _.get('z_offx'), offy = _.get('z_offy');
  4713. /**
  4714. * bottom
  4715. */
  4716. if(_.get('pedestal_height'))
  4717. _.T.cube3D(_.x, _.y + h + _.get('pedestal_height'), xa, ya, false, w, _.get('pedestal_height'), zh * 3 / 2, _.get('axis.enable'), _.get('axis.width'), _.get('axis.color'), _.get('bottom_style'));
  4718. /**
  4719. * board_style
  4720. */
  4721. if(_.get('board_deep'))
  4722. _.T.cube3D(_.x +offx, _.y+h - offy, xa, ya, false, w, h, _.get('board_deep'), _.get('axis.enable'), _.get('axis.width'), _.get('axis.color'), _.get('board_style'));
  4723. _.T.cube3D(_.x, _.y + h, xa, ya, false, w, h, zh, _.get('axis.enable'), _.get('axis.width'), _.get('axis.color'), _.get('wall_style'));
  4724. _.gridlines.each(function(g) {
  4725. if(g.solid){
  4726. if(_.get('left_board'))
  4727. _.T.line(g.x1, g.y1, g.x1 + offx, g.y1 - offy,g.width, g.color);
  4728. _.T.line(g.x1 + offx, g.y1 - offy, g.x2 + offx, g.y2 - offy, g.width, g.color);
  4729. }else{
  4730. if(_.get('left_board'))
  4731. _.T.dotted(g.x1, g.y1, g.x1 + offx, g.y1 - offy,g.width, g.color,g.size,g.fator);
  4732. _.T.dotted(g.x1 + offx, g.y1 - offy, g.x2 + offx, g.y2 - offy, g.width, g.color,g.size,g.fator);
  4733. }
  4734. });
  4735. _.scale.each(function(s) {
  4736. s.draw();
  4737. });
  4738. },
  4739. doConfig : function() {
  4740. $.Coordinate3D.superclass.doConfig.call(this);
  4741. var _ = this._(),
  4742. ws = _.get('wall_style'),
  4743. bg = _.get('background_color')||'#d6dbd2',
  4744. h = _.height,
  4745. w = _.width,
  4746. f = _.get('color_factor'),
  4747. offx = _.push('z_offx',_.get('xAngle_') * _.get('zHeight')),
  4748. offy = _.push('z_offy',_.get('yAngle_') * _.get('zHeight'));
  4749. /**
  4750. * bottom-lower bottom-left
  4751. */
  4752. while(ws.length < 6){
  4753. ws.push({color : bg});
  4754. }
  4755. if(!_.get('left_board')){
  4756. ws[2] = false;
  4757. _.scale.each(function(s){
  4758. s.doLayout(offx,-offy,s);
  4759. });
  4760. }
  4761. /**
  4762. * right-front
  4763. */
  4764. _.push('bottom_style', [{
  4765. color : _.get('shadow_color'),
  4766. shadow : _.get('shadow')
  4767. }, false, false, {
  4768. color : ws[3].color
  4769. },false, {
  4770. color : ws[3].color
  4771. }]);
  4772. /**
  4773. * right-top
  4774. */
  4775. _.push('board_style', [false, false, false,{
  4776. color : ws[4].color
  4777. },{
  4778. color : ws[5].color
  4779. }, false]);
  4780. /**
  4781. * lowerBottom-bottom-left-right-top-front
  4782. */
  4783. if (_.get('gradient')) {
  4784. if ($.isString(ws[0].color)) {
  4785. ws[0].color = _.T.avgLinearGradient(_.x, _.y + h, _.x + w, _.y + h, [$.dark(ws[0].color,f/2+0.06),$.dark(ws[0].color,f/2+0.06)]);
  4786. }
  4787. if ($.isString(ws[1].color)) {
  4788. ws[1].color = _.T.avgLinearGradient(_.x + offx, _.y - offy, _.x + offx, _.y + h - offy, [$.dark(ws[1].color,f),$.light(ws[1].color,f)]);
  4789. }
  4790. if ($.isString(ws[2].color)) {
  4791. ws[2].color = _.T.avgLinearGradient(_.x, _.y, _.x, _.y + h, [$.light(ws[2].color,f/3),$.dark(ws[2].color,f)]);
  4792. }
  4793. _.get('bottom_style')[5].color = _.T.avgLinearGradient(_.x, _.y + h, _.x, _.y + h + _.get('pedestal_height'), [$.light(ws[3].color,f/2+0.06),$.dark(ws[3].color,f/2,0)]);
  4794. }
  4795. _.push('wall_style', [ws[0],ws[1],ws[2]]);
  4796. }
  4797. });
  4798. /*
  4799. * @end
  4800. */
  4801. /**
  4802. * @overview the base class of rectangle
  4803. * @component#$.Rectangle
  4804. * @extend#$.Component
  4805. */
  4806. $.Rectangle = $.extend($.Component,{
  4807. configure:function(){
  4808. /**
  4809. * invoked the super class's configuration
  4810. */
  4811. $.Rectangle.superclass.configure.apply(this,arguments);
  4812. /**
  4813. * indicate the component's type
  4814. */
  4815. this.type = 'rectangle';
  4816. this.set({
  4817. /**
  4818. * @cfg {Number} Specifies the width of this element in pixels,Normally,this will given by chart.(default to 0)
  4819. */
  4820. width:0,
  4821. /**
  4822. * @cfg {Number} Specifies the height of this element in pixels,Normally,this will given by chart.(default to 0)
  4823. */
  4824. height:0,
  4825. /**
  4826. * @cfg {Number} the distance of column's edge and value in pixels.(default to 4)
  4827. */
  4828. value_space:4,
  4829. /**
  4830. * @cfg {String} Specifies the text of this element,Normally,this will given by chart.(default to '')
  4831. */
  4832. value:'',
  4833. /**
  4834. * @cfg {<link>$.Text</link>} Specifies the config of label,set false to make label disabled.
  4835. */
  4836. label : {},
  4837. /**
  4838. * @cfg {String} Specifies the name of this element,Normally,this will given by chart.(default to '')
  4839. */
  4840. name:'',
  4841. /**
  4842. * @cfg {String} Specifies the tip alignment of chart(defaults to 'top').Available value are:
  4843. * @Option 'left'
  4844. * @Option 'right'
  4845. * @Option 'top'
  4846. * @Option 'bottom'
  4847. */
  4848. tipAlign:'top',
  4849. /**
  4850. * @cfg {String} Specifies the value's text alignment of chart(defaults to 'top') Available value are:
  4851. * @Option 'left'
  4852. * @Option 'right'
  4853. * @Option 'middle'
  4854. * @Option 'top'
  4855. * @Option 'bottom'
  4856. */
  4857. valueAlign:'top',
  4858. /**
  4859. * @cfg {Number} Override the default as 3
  4860. */
  4861. shadow_blur:3,
  4862. /**
  4863. * @cfg {Number} Override the default as -1
  4864. */
  4865. shadow_offsety:-1
  4866. });
  4867. /**
  4868. * this element support boxMode
  4869. */
  4870. this.atomic = true;
  4871. this.registerEvent(
  4872. /**
  4873. * @event Fires when parse this label's data.Return value will override existing.
  4874. * @paramter <link>$.Rectangle</link>#rect
  4875. * @paramter string#text the current label's text
  4876. */
  4877. 'parseText');
  4878. this.label = null;
  4879. },
  4880. last:function(_){
  4881. if(_.label)
  4882. _.label.draw();
  4883. },
  4884. doDraw:function(_){
  4885. _.drawRectangle();
  4886. },
  4887. doConfig:function(){
  4888. $.Rectangle.superclass.doConfig.call(this);
  4889. var _ = this._(),v = _.variable.event,vA=_.get('valueAlign');
  4890. /**
  4891. * mouseover light
  4892. */
  4893. $.taylor.light(_,v);
  4894. _.width = _.get(_.W);
  4895. _.height = _.get(_.H);
  4896. var x = _.push('centerx',_.x + _.width/2),
  4897. y = _.push('centery',_.y + _.height/2),
  4898. a = _.C,
  4899. b = 'middle',
  4900. s=_.get('value_space');
  4901. if(vA==_.L){
  4902. a = _.R;
  4903. x = _.x - s;
  4904. }else if(vA==_.R){
  4905. a = _.L;
  4906. x =_.x + _.width + s;
  4907. }else if(vA==_.B){
  4908. y = _.y + _.height + s;
  4909. b = _.O;
  4910. }else if(vA==_.O){
  4911. y = _.y - s;
  4912. b = _.B;
  4913. }
  4914. if(_.get('label')){
  4915. _.push('label.originx', x);
  4916. _.push('label.originy', y);
  4917. _.push('label.text',_.push('value',_.fireString(_, 'parseText', [_, _.get('value')], _.get('value'))));
  4918. $.applyIf(_.get('label'),{
  4919. textAlign : a,
  4920. textBaseline : b,
  4921. color:_.get('color')
  4922. });
  4923. _.label = new $.Text(_.get('label'), _);
  4924. }
  4925. if(_.get('tip.enable')){
  4926. if(_.get('tip.showType')!='follow'){
  4927. _.push('tip.invokeOffsetDynamic',false);
  4928. }
  4929. _.tip = new $.Tip(_.get('tip'),_);
  4930. }
  4931. }
  4932. });
  4933. /**
  4934. *@end
  4935. */
  4936. /**
  4937. * @overview the rectangle2d componment
  4938. * @component#$.Rectangle2D
  4939. * @extend#$.Rectangle
  4940. */
  4941. $.Rectangle2D = $.extend($.Rectangle,{
  4942. configure:function(){
  4943. /**
  4944. * invoked the super class's configuration
  4945. */
  4946. $.Rectangle2D.superclass.configure.apply(this,arguments);
  4947. /**
  4948. * indicate the component's type
  4949. */
  4950. this.type = 'rectangle2d';
  4951. this.set({
  4952. /**
  4953. * @cfg {Number} Override the default as -2
  4954. */
  4955. shadow_offsety:-2
  4956. });
  4957. },
  4958. drawRectangle:function(){
  4959. var _ = this._();
  4960. _.T.box(
  4961. _.get(_.X),
  4962. _.get(_.Y),
  4963. _.get(_.W),
  4964. _.get(_.H),
  4965. _.get('border'),
  4966. _.get('f_color'),
  4967. _.get('shadow'));
  4968. },
  4969. isEventValid:function(e,_){
  4970. return {valid:e.x>_.x&&e.x<(_.x+_.width)&&e.y<(_.y+_.height)&&e.y>(_.y)};
  4971. },
  4972. tipInvoke:function(){
  4973. var _ = this._();
  4974. /**
  4975. * base on event?
  4976. */
  4977. return function(w,h){
  4978. return {
  4979. left:_.tipX(w,h),
  4980. top:_.tipY(w,h)
  4981. }
  4982. }
  4983. },
  4984. doConfig:function(){
  4985. $.Rectangle2D.superclass.doConfig.call(this);
  4986. var _ = this._(),tipAlign = _.get('tipAlign');
  4987. if(tipAlign==_.L||tipAlign==_.R){
  4988. _.tipY = function(w,h){return _.get('centery') - h/2;};
  4989. }else{
  4990. _.tipX = function(w,h){return _.get('centerx') -w/2;};
  4991. }
  4992. if(tipAlign==_.L){
  4993. _.tipX = function(w,h){return _.x - _.get('value_space') -w;};
  4994. }else if(tipAlign==_.R){
  4995. _.tipX = function(w,h){return _.x + _.width + _.get('value_space');};
  4996. }else if(tipAlign==_.B){
  4997. _.tipY = function(w,h){return _.y +_.height+3;};
  4998. }else{
  4999. _.tipY = function(w,h){return _.y - h -3;};
  5000. }
  5001. _.applyGradient();
  5002. }
  5003. });
  5004. /**
  5005. *@end
  5006. */
  5007. /**
  5008. * @overview the rectangle3d componment
  5009. * @component#$.Rectangle3D
  5010. * @extend#$.Rectangle
  5011. */
  5012. $.Rectangle3D = $.extend($.Rectangle,{
  5013. configure:function(){
  5014. /**
  5015. * invoked the super class's configuration
  5016. */
  5017. $.Rectangle3D.superclass.configure.apply(this,arguments);
  5018. /**
  5019. * indicate the component's type
  5020. */
  5021. this.type = 'rectangle3d';
  5022. this.dimension = $._3D;
  5023. this.set({
  5024. /**
  5025. * @cfg {Number} Specifies Three-dimensional z-axis deep in pixels.Normally,this will given by chart.(default to undefined)
  5026. */
  5027. zHeight:undefined,
  5028. /**
  5029. * @cfg {Number} Three-dimensional rotation X in degree(angle).socpe{0-90}.Normally,this will given by chart.(default to 60)
  5030. */
  5031. xAngle:60,
  5032. /**
  5033. * @cfg {Number} Three-dimensional rotation Y in degree(angle).socpe{0-90}.Normally,this will given by chart.(default to 20)
  5034. */
  5035. yAngle:20,
  5036. xAngle_:undefined,
  5037. yAngle_:undefined,
  5038. /**
  5039. * @cfg {Number} Override the default as 2
  5040. */
  5041. shadow_offsetx:2
  5042. });
  5043. },
  5044. drawRectangle:function(){
  5045. var _ = this._();
  5046. _.T.cube(
  5047. _.get(_.X),
  5048. _.get(_.Y),
  5049. _.get('xAngle_'),
  5050. _.get('yAngle_'),
  5051. _.get(_.W),
  5052. _.get(_.H),
  5053. _.get('zHeight'),
  5054. _.get('f_color'),
  5055. _.get('border.enable'),
  5056. _.get('border.width'),
  5057. _.get('light_color'),
  5058. _.get('shadow')
  5059. );
  5060. },
  5061. isEventValid:function(e,_){
  5062. return {valid:e.x>_.x&&e.x<(_.x+_.get(_.W))&&e.y<_.y+_.get(_.H)&&e.y>_.y};
  5063. },
  5064. tipInvoke:function(){
  5065. var _ = this._();
  5066. return function(w,h){
  5067. return {
  5068. left:_.topCenterX - w/2,
  5069. top:_.topCenterY - h
  5070. }
  5071. }
  5072. },
  5073. doConfig:function(){
  5074. $.Rectangle3D.superclass.doConfig.call(this);
  5075. var _ = this._();
  5076. _.pushIf("zHeight",_.get(_.W));
  5077. _.topCenterX=_.x+(_.get(_.W)+_.get(_.W)*_.get('xAngle_'))/2;
  5078. _.topCenterY=_.y-_.get(_.W)*_.get('yAngle_')/2-_.get('value_space');
  5079. if(_.get('valueAlign')==_.O&&_.label){
  5080. _.label.push('textx',_.topCenterX);
  5081. _.label.push('texty',_.topCenterY);
  5082. }
  5083. }
  5084. });
  5085. /**
  5086. *@end
  5087. */
  5088. /**
  5089. * @overview this component use for config sector,this is a abstract class.
  5090. * @component#$.Sector
  5091. * @extend#$.Component
  5092. */
  5093. $.Sector = $.extend($.Component, {
  5094. configure : function() {
  5095. /**
  5096. * invoked the super class's configuration
  5097. */
  5098. $.Sector.superclass.configure.apply(this, arguments);
  5099. /**
  5100. * indicate the component's type
  5101. */
  5102. this.type = 'sector';
  5103. this.set({
  5104. /**
  5105. * @cfg {String} Specifies the value of this element,Normally,this will given by chart.(default to '')
  5106. */
  5107. value : '',
  5108. /**
  5109. * @cfg {String} Specifies the name of this element,Normally,this will given by chart.(default to '')
  5110. */
  5111. name : '',
  5112. /**
  5113. * @cfg {Boolean} True will not darw.(default to false)
  5114. */
  5115. ignored : false,
  5116. /**
  5117. * @inner {Boolean} True to make sector counterclockwise.(default to false)
  5118. */
  5119. counterclockwise : false,
  5120. /**
  5121. * @cfg {Number} Specifies the start angle of this sector.Normally,this will given by chart.(default to 0)
  5122. */
  5123. startAngle : 0,
  5124. /**
  5125. * @cfg {Number} middleAngle = (endAngle - startAngle)/2.Normally,this will given by chart.(default to 0)
  5126. */
  5127. middleAngle : 0,
  5128. /**
  5129. * @cfg {Number} Specifies the end angle of this sector.Normally,this will given by chart.(default to 0)
  5130. */
  5131. endAngle : 0,
  5132. /**
  5133. * @cfg {Number} Specifies total angle of this sector,totalAngle = (endAngle - startAngle).Normally,this will given by chart.(default to 0)
  5134. */
  5135. totalAngle : 0,
  5136. /**
  5137. * @inner {String} the event's name trigger pie bound(default to 'click').
  5138. */
  5139. bound_event : 'click',
  5140. /**
  5141. * @cfg {Boolean} True to bound this sector.(default to false)
  5142. */
  5143. expand : false,
  5144. /**
  5145. * @cfg {Number} Specifies the width when show a donut.only applies when it not 0.(default to 0)
  5146. */
  5147. donutwidth : 0,
  5148. /**
  5149. * @inner {Boolean} If true means just one piece could bound at same time.(default to false)
  5150. */
  5151. mutex : false,
  5152. /**
  5153. * @inner {Number} Specifies the offset when bounded.Normally,this will given by chart.(default to undefined)
  5154. */
  5155. increment : undefined,
  5156. label_length : undefined,
  5157. /**
  5158. * @cfg {String} Specifies the gradient mode of background.(defaults to 'RadialGradientOutIn')
  5159. * @Option 'RadialGradientOutIn'
  5160. * @Option 'RadialGradientInOut'
  5161. */
  5162. gradient_mode : 'RadialGradientOutIn',
  5163. /**
  5164. * @cfg {Number} Specifies the threshold value in angle that applies mini_label.(default to 15)
  5165. */
  5166. mini_label_threshold_angle : 15,
  5167. /**
  5168. * @cfg {<link>$.Text</link>} Specifies the config of label.when mini_label is a object,there will as a <link>$.Text</link>.(default to false) note:set false to make minilabel disabled.
  5169. */
  5170. mini_label : false,
  5171. /**
  5172. * @cfg {<link>$.Label</link>} Specifies the config of label.when mini_label is unavailable,there will as a <link>$.Label</link>. note:set false to make label disabled.
  5173. */
  5174. label : {},
  5175. rounded:false
  5176. });
  5177. /**
  5178. * this element support boxMode
  5179. */
  5180. this.atomic = true;
  5181. this.registerEvent('changed',
  5182. /**
  5183. * @event Fires when parse this label's data.Return value will override existing. Only valid when label is available
  5184. * @paramter <link>$.Sector</link>#sector the sector object
  5185. * @paramter string#text the current label's text
  5186. */
  5187. 'parseText');
  5188. this.label = null;
  5189. this.tip = null;
  5190. },
  5191. bound : function() {
  5192. if (!this.expanded)
  5193. this.toggle();
  5194. },
  5195. rebound : function() {
  5196. if (this.expanded)
  5197. this.toggle();
  5198. },
  5199. toggle : function() {
  5200. this.fireEvent(this, this.get('bound_event'), [this]);
  5201. },
  5202. /**
  5203. * @method get the sector's dimension,return hold following property
  5204. * @property x:the x-coordinate of the center of the sector
  5205. * @property y:the y-coordinate of the center of the sector
  5206. * @property startAngle:The starting angle, in radians (0 is at the 3 o'clock position of the arc's circle)
  5207. * @property endAngle:the ending angle, in radians
  5208. * @property middleAngle:the middle angle, in radians
  5209. * @return object
  5210. */
  5211. getDimension : function() {
  5212. var _ = this._();
  5213. return {
  5214. x : _.x,
  5215. x : _.y,
  5216. startAngle : _.get("startAngle"),
  5217. middleAngle : _.get("middleAngle"),
  5218. endAngle : _.get("endAngle")
  5219. }
  5220. },
  5221. doDraw : function(_) {
  5222. if (!_.get('ignored')) {
  5223. if (_.label&&!_.get('mini_label')){
  5224. _.label.draw();
  5225. }
  5226. _.drawSector();
  5227. if (_.label&&_.get('mini_label')){
  5228. _.label.draw();
  5229. }
  5230. }
  5231. },
  5232. doText : function(_, x, y) {
  5233. _.push('label.originx', x);
  5234. _.push('label.originy', y);
  5235. _.push('label.textBaseline', 'middle');
  5236. _.label = new $.Text(_.get('label'), _);
  5237. },
  5238. doLabel : function(_, x, y, Q, p, x0, y0,L) {
  5239. _.push('label.originx', x);
  5240. _.push('label.originy', y);
  5241. _.push('label.quadrantd', Q);
  5242. _.push('label.line_points', p);
  5243. _.push('label.labelx', x0);
  5244. _.push('label.labely', y0);
  5245. _.push('label.smooth', L);
  5246. _.push('label.angle', _.get('middleAngle')%(Math.PI*2));
  5247. _.label = new $.Label(_.get('label'), _);
  5248. },
  5249. isLabel : function() {
  5250. return this.get('label') && !this.get('mini_label');
  5251. },
  5252. doConfig : function() {
  5253. $.Sector.superclass.doConfig.call(this);
  5254. var _ = this._(), v = _.variable.event, f = _.get('label'),event=_.get('bound_event'),g;
  5255. if(_.get('rounded')){
  5256. _.push('startAngle',0);
  5257. _.push('endAngle',Math.PI*2);
  5258. return;
  5259. }
  5260. /**
  5261. * mouseover light
  5262. */
  5263. $.taylor.light(_,v);
  5264. _.push('totalAngle', _.get('endAngle') - _.get('startAngle'));
  5265. if (f) {
  5266. if (_.get('mini_label')) {
  5267. if ((_.get('mini_label_threshold_angle') * Math.PI / 180) > _.get('totalAngle')) {
  5268. _.push('mini_label', false);
  5269. } else {
  5270. $.apply(_.get('label'),_.get('mini_label'));
  5271. }
  5272. }
  5273. _.push('label.text', _.fireString(_, 'parseText', [_,_.get('label.text')], _.get('label.text')));
  5274. _.pushIf('label.border.color', _.get('border.color'));
  5275. /**
  5276. * make the label's color in accord with sector
  5277. */
  5278. _.push('label.scolor', _.get('background_color'));
  5279. }
  5280. _.variable.event.status = _.expanded = _.get('expand');
  5281. if (_.get('tip.enable')) {
  5282. if (_.get('tip.showType') != 'follow') {
  5283. _.push('tip.invokeOffsetDynamic', false);
  5284. }
  5285. _.tip = new $.Tip(_.get('tip'), _);
  5286. }
  5287. v.poped = false;
  5288. /**
  5289. *need test profile/time
  5290. */
  5291. _.on(event, function() {
  5292. v.poped = true;
  5293. _.expanded = !_.expanded;
  5294. _.redraw(event);
  5295. v.poped = false;
  5296. });
  5297. _.on('beforedraw', function(a,b) {
  5298. if(b==event){
  5299. g = false;
  5300. _.x = _.get(_.X);
  5301. _.y = _.get(_.Y);
  5302. if (_.expanded) {
  5303. if (_.get('mutex') && !v.poped) {
  5304. _.expanded = false;
  5305. g = true;
  5306. } else {
  5307. _.x += _.get('inc_x');
  5308. _.y -= _.get('inc_y');
  5309. }
  5310. }
  5311. if (v.status != _.expanded) {
  5312. _.fireEvent(_, 'changed', [_, _.expanded]);
  5313. g = true;
  5314. v.status = _.expanded;
  5315. }
  5316. if (f&&g)
  5317. _.label.doLayout(_.get('inc_x') * (_.expanded ? 1 : -1), -_.get('inc_y') * (_.expanded ? 1 : -1),2,_.label);
  5318. }
  5319. return true;
  5320. });
  5321. }
  5322. });
  5323. /**
  5324. * @end
  5325. */
  5326. /**
  5327. * @overview the sector2d componment
  5328. * @component#$.Sector2D
  5329. * @extend#$.Sector
  5330. */
  5331. $.Sector2D = $.extend($.Sector,{
  5332. configure:function(){
  5333. /**
  5334. * invoked the super class's configuration
  5335. */
  5336. $.Sector2D.superclass.configure.apply(this,arguments);
  5337. /**
  5338. * indicate the component's type
  5339. */
  5340. this.type = 'sector2d';
  5341. this.set({
  5342. /**
  5343. * @cfg {Float (0~)} Specifies the sector's radius.Normally,this will given by chart.(default to 0)
  5344. */
  5345. radius:0
  5346. });
  5347. },
  5348. drawSector:function(){
  5349. this.T.sector(
  5350. this.x,
  5351. this.y,
  5352. this.r,
  5353. this.get('donutwidth'),
  5354. this.get('startAngle'),
  5355. this.get('endAngle'),
  5356. this.get('f_color'),
  5357. this.get('border.enable'),
  5358. this.get('border.width'),
  5359. this.get('border.color'),
  5360. this.get('shadow'),
  5361. this.get('counterclockwise'));
  5362. },
  5363. isEventValid:function(e,_){
  5364. if(!_.get('ignored')){
  5365. if(_.isLabel()&&_.label.isEventValid(e,_.label).valid){
  5366. return {valid:true};
  5367. }
  5368. var r = $.distanceP2P(_.x,_.y,e.x,e.y),b=_.get('donutwidth');
  5369. if(_.r<r||(b&&(_.r-b)>r)){
  5370. return {valid:false};
  5371. }
  5372. if($.angleInRange(_.get('startAngle'),_.get('endAngle'),$.atan2Radian(_.x,_.y,e.x,e.y))){
  5373. return {valid:true};
  5374. }
  5375. }
  5376. return {valid:false};
  5377. },
  5378. tipInvoke:function(){
  5379. var _ = this,A = _.get('middleAngle'),Q = $.quadrantd(A);
  5380. return function(w,h){
  5381. var P = $.p2Point(_.x,_.y,A,_.r*0.8)
  5382. return {
  5383. left:(Q>=1&&Q<=2)?(P.x - w):P.x,
  5384. top:Q>=2?(P.y - h):P.y
  5385. }
  5386. }
  5387. },
  5388. doConfig:function(){
  5389. $.Sector2D.superclass.doConfig.call(this);
  5390. var _ = this._();
  5391. _.r = _.get('radius');
  5392. if(_.get('donutwidth')>_.r){
  5393. _.push('donutwidth',0);
  5394. }
  5395. _.applyGradient(_.x-_.r,_.y-_.r,2*_.r*0.9,2*_.r*0.9);
  5396. var A = _.get('middleAngle'),L = _.pushIf('increment',$.lowTo(5,_.r/10)),p2;
  5397. _.push('inc_x',L * Math.cos(2 * Math.PI -A));
  5398. _.push('inc_y',L * Math.sin(2 * Math.PI - A));
  5399. L *=2;
  5400. if(_.get('label')){
  5401. if(_.get('mini_label')){
  5402. P2 = $.p2Point(_.x,_.y,A,_.get('donutwidth')?_.r - _.get('donutwidth')/2:_.r*5/8);
  5403. _.doText(_,P2.x,P2.y);
  5404. }else{
  5405. var Q = $.quadrantd(A),
  5406. P = $.p2Point(_.x,_.y,A,_.r + L),
  5407. C1 = $.p2Point(_.x,_.y,A,_.r + L*0.6);
  5408. P2 = $.p2Point(_.x,_.y,A,_.r);
  5409. _.doLabel(_,P2.x,P2.y,Q,[{x:P2.x,y:P2.y},{x:C1.x,y:C1.y},{x:P.x,y:P.y}],P.x,P.y,L*0.4);
  5410. }
  5411. }
  5412. }
  5413. });
  5414. /**
  5415. * @end
  5416. */
  5417. /**
  5418. * @overview the sector3d componment
  5419. * @component#$.Sector3D
  5420. * @extend#$.Sector
  5421. */
  5422. $.Sector3D = $.extend($.Sector,{
  5423. configure:function(){
  5424. /**
  5425. * invoked the super class's configuration
  5426. */
  5427. $.Sector3D.superclass.configure.apply(this,arguments);
  5428. /**
  5429. * indicate the component's type
  5430. */
  5431. this.type = 'sector3d';
  5432. this.dimension = $._3D;
  5433. this.set({
  5434. /**
  5435. * @cfg {Number} Specifies major semiaxis of ellipse.Normally,this will given by chart.(default to 0)
  5436. */
  5437. semi_major_axis:0,
  5438. /**
  5439. * @cfg {Number} Specifies minor semiaxis of ellipse.Normally,this will given by chart.(default to 0)
  5440. */
  5441. semi_minor_axis:0,
  5442. /**
  5443. * @cfg {Float (0~)} Specifies the sector's height(thickness).Normally,this will given by chart.(default to 0)
  5444. */
  5445. cylinder_height:0
  5446. });
  5447. this.proxy = true;
  5448. },
  5449. isEventValid:function(e,_){
  5450. if(!_.get('ignored')){
  5451. if(_.isLabel()&&_.label.isEventValid(e,_.label).valid){
  5452. return {valid:true};
  5453. }
  5454. if(!$.inEllipse(e.x - _.x,e.y-_.y,_.a,_.b)){
  5455. return {valid:false};
  5456. }
  5457. if($.angleZInRange(_.sA,_.eA,$.atan2Radian(_.x,_.y,e.x,e.y))){
  5458. return {valid:true};
  5459. }
  5460. }
  5461. return {valid:false};
  5462. },
  5463. p2p:function(x,y,a,z){
  5464. return {
  5465. x:x+this.a*Math.cos(a)*z,
  5466. y:y+this.b*Math.sin(a)*z
  5467. };
  5468. },
  5469. tipInvoke:function(){
  5470. var _ = this,A = _.get('middleAngle'),Q = $.quadrantd(A);
  5471. return function(w,h){
  5472. var P = _.p2p(_.x,_.y,A,0.6);
  5473. return {
  5474. left:(Q>=2&&Q<=3)?(P.x - w):P.x,
  5475. top:Q>=3?(P.y - h):P.y
  5476. }
  5477. }
  5478. },
  5479. doConfig:function(){
  5480. $.Sector3D.superclass.doConfig.call(this);
  5481. var _ = this._(),ccw = _.get('counterclockwise'),mA = _.get('middleAngle');
  5482. _.a = _.get('semi_major_axis');
  5483. _.b = _.get('semi_minor_axis');
  5484. _.h = _.get('cylinder_height');
  5485. $.Assert.isTrue(_.a*_.b>=0,'major&minor');
  5486. var pi2 = 2 * Math.PI,toAngle = function(A){
  5487. while(A<0)A+=pi2;
  5488. return Math.abs($.atan2Radian(0,0,_.a*Math.cos(A),ccw?(-_.b*Math.sin(A)):(_.b*Math.sin(A))));
  5489. },
  5490. L = _.pushIf('increment',$.lowTo(5,_.a/10));
  5491. _.sA = toAngle.call(_,_.get('startAngle'));
  5492. _.eA = toAngle.call(_,_.get('endAngle'));
  5493. _.mA = toAngle.call(_,mA);
  5494. _.push('inc_x',L * Math.cos(pi2 -_.mA));
  5495. _.push('inc_y',L * Math.sin(pi2 - _.mA));
  5496. L *=2;
  5497. if(_.get('label')){
  5498. if(_.get('mini_label')){
  5499. var P3 = _.p2p(_.x,_.y,mA,0.5);
  5500. _.doText(_,P3.x,P3.y);
  5501. }else{
  5502. var Q = $.quadrantd(mA),
  5503. P = _.p2p(_.x,_.y,mA,L/_.a+1),
  5504. C1 = _.p2p(_.x,_.y,mA,L*0.6/_.a+1),
  5505. P2 = _.p2p(_.x,_.y,mA,1);
  5506. _.doLabel(_,P2.x,P2.y,Q,[{x:P2.x,y:P2.y},{x:C1.x,y:C1.y},{x:P.x,y:P.y}],P.x,P.y,L*0.4);
  5507. }
  5508. }
  5509. }
  5510. });
  5511. /**
  5512. *@end
  5513. */
  5514. /**
  5515. * @overview the base class of pie chart
  5516. * @component#$.Pie
  5517. * @extend#$.Chart
  5518. */
  5519. $.Pie = $.extend($.Chart, {
  5520. /**
  5521. * initialize the context for the pie
  5522. */
  5523. configure : function() {
  5524. /**
  5525. * invoked the super class's configuration
  5526. */
  5527. $.Pie.superclass.configure.call(this);
  5528. this.type = 'pie';
  5529. this.set({
  5530. /**
  5531. * @cfg {Float/String} Specifies the pie's radius.If given a percentage,it will relative to minDistance.(default to '100%')
  5532. */
  5533. radius : '100%',
  5534. /**
  5535. * @cfg {Number} initial angle for first sector.(default to 0)
  5536. */
  5537. offset_angle : 0,
  5538. /**
  5539. * @cfg {Number(0~90)} separate angle of all sector.(default to 0)
  5540. */
  5541. separate_angle:0,
  5542. /**
  5543. * @cfg {String} the event's name trigger pie pop(default to 'click')
  5544. */
  5545. bound_event : 'click',
  5546. /**
  5547. * @inner {Boolean} True to make sector counterclockwise.(default to false)
  5548. */
  5549. counterclockwise : false,
  5550. /**
  5551. * @cfg {Boolean} when label's position in conflict.auto layout.(default to true).
  5552. */
  5553. intellectLayout : true,
  5554. /**
  5555. * @cfg {Number} Specifies the distance in pixels when two label is incompatible with each other.(default 4),
  5556. */
  5557. layout_distance : 4,
  5558. /**
  5559. * @inner {Boolean} if it has animate when a piece popd (default to false)
  5560. */
  5561. pop_animate : false,
  5562. /**
  5563. * @cfg {Boolean} Specifies as true it means just one piece could pop (default to false)
  5564. */
  5565. mutex : false,
  5566. /**
  5567. * @cfg {Number} Specifies the length when sector bounded.(default to 1/8 radius,and minimum is 5),
  5568. */
  5569. increment : undefined,
  5570. /**
  5571. * @cfg {<link>$.Sector</link>} option of sector.Note,Pie2d depend on Sector2d and pie3d depend on Sector3d.For details see <link>$.Sector</link>
  5572. */
  5573. sub_option : {
  5574. label : {}
  5575. }
  5576. });
  5577. this.registerEvent(
  5578. /**
  5579. * @event Fires when this element' sector bounded
  5580. * @paramter <link>$.Sector2d</link>#sector
  5581. * @paramter string#name
  5582. * @paramter int#index
  5583. */
  5584. 'bound',
  5585. /**
  5586. * @event Fires when this element' sector rebounded
  5587. * @paramter <link>$.Sector2d</link>#sector
  5588. * @paramter string#name
  5589. * @paramter int#index
  5590. */
  5591. 'rebound');
  5592. this.sectors = [];
  5593. this.components.push(this.sectors);
  5594. this.ILLUSIVE_COO = true;
  5595. },
  5596. /**
  5597. * @method Toggle sector bound or rebound by a specific index.
  5598. * @paramter int#i the index of sector
  5599. * @return void
  5600. */
  5601. toggle : function(i) {
  5602. this.sectors[i || 0].toggle();
  5603. },
  5604. /**
  5605. * @method bound sector by a specific index.
  5606. * @paramter int#i the index of sector
  5607. * @return void
  5608. */
  5609. bound : function(i) {
  5610. this.sectors[i || 0].bound();
  5611. },
  5612. /**
  5613. * @method rebound sector by a specific index.
  5614. * @paramter int#i the index of sector
  5615. * @return void
  5616. */
  5617. rebound : function(i) {
  5618. this.sectors[i || 0].rebound();
  5619. },
  5620. /**
  5621. * @method Returns an array containing all sectors of this pie
  5622. * @return Array#the collection of sectors
  5623. */
  5624. getSectors : function() {
  5625. return this.sectors;
  5626. },
  5627. doAnimation : function(t, d,_) {
  5628. var si = 0, cs = _.oA;
  5629. _.sectors.each(function(s, i) {
  5630. si = _.animationArithmetic(t, 0, s.get('totalAngle'), d);
  5631. s.push('startAngle', cs);
  5632. s.push('endAngle', cs+=si);
  5633. if (!_.is3D())
  5634. s.drawSector();
  5635. });
  5636. if (_.is3D()) {
  5637. _.proxy.drawSector();
  5638. }
  5639. },
  5640. parse : function(_) {
  5641. _.data.each(function(d,i){
  5642. _.doParse(_,d,i);
  5643. },_);
  5644. /**
  5645. * layout the label
  5646. */
  5647. _.localizer(_);
  5648. },
  5649. doParse : function(_,d, i) {
  5650. var t = d.name + ' ' +_.getPercent(d.value);
  5651. _.doActing(_,d,null,i,t);
  5652. _.push('sub_option.id', i);
  5653. if(_.get('sub_option.label'))
  5654. _.push('sub_option.label.text', t);
  5655. _.push('sub_option.listeners.changed', function(se, st, i) {
  5656. _.fireEvent(_, st ? 'bound' : 'rebound', [_, se.get('name')]);
  5657. });
  5658. _.sectors.push(_.doSector(_,d));
  5659. },
  5660. doSector:function(_){
  5661. return new $[_.sub](_.get('sub_option'), _);
  5662. },
  5663. dolayout : function(_,x,y,l,d,Q) {
  5664. if(_.is3D()?$.inEllipse(_.get(_.X) - x,_.topY-y,_.a,_.b):$.distanceP2P(_.get(_.X),_.topY,x,y)<_.r){
  5665. y=_.topY-y;
  5666. l.push('labelx',_.get(_.X)+(Math.sqrt(_.r*_.r-y*y)*2+d)*(Q==0||Q==3?1:-1));
  5667. l.localizer(l);
  5668. }
  5669. },
  5670. localizer:function(_){
  5671. if (_.get('intellectLayout')) {
  5672. var unlayout = [],layouted = [],d = _.get('layout_distance'),Q,x,y;
  5673. _.sectors.each(function(f, i) {
  5674. if(f.isLabel())
  5675. unlayout.push(f.label);
  5676. });
  5677. unlayout.sor(function(p, q) {
  5678. return Math.abs(Math.sin(p.get('angle'))) - Math.abs(Math.sin(q.get('angle')))>0;
  5679. });
  5680. unlayout.each(function(la) {
  5681. layouted.each(function(l) {
  5682. x = l.labelx, y = l.labely;
  5683. if ((la.labely <= y && (y - la.labely-1) < la.get(_.H)) || (la.labely > y && (la.labely - y-1) < l.get(_.H))) {
  5684. if ((la.labelx <= x && (x - la.labelx) < la.get(_.W)) || (la.labelx > x && (la.labelx - x) < l.get(_.W))) {
  5685. Q = la.get('quadrantd');
  5686. la.push('labely', (la.get('labely')+ y - la.labely) + (la.get(_.H) + d)*(Q>1?-1:1));
  5687. la.localizer(la);
  5688. _.dolayout(_,la.get('labelx'),la.get('labely')+la.get(_.H)/2*(Q<2?-1:1),la,d,Q);
  5689. }
  5690. }
  5691. }, _);
  5692. layouted.push(la);
  5693. });
  5694. }
  5695. },
  5696. doConfig : function() {
  5697. $.Pie.superclass.doConfig.call(this);
  5698. var _ = this._(),V,r = _.get('radius'), f = _.get('sub_option.label') ? 0.35 : 0.44,pi2=Math.PI*2;
  5699. _.sub = _.is3D()?'Sector3D':'Sector2D';
  5700. _.sectors.zIndex = _.get('z_index');
  5701. _.sectors.length = 0;
  5702. _.oA = $.angle2Radian(_.get('offset_angle'))%pi2;
  5703. //If 3D,let it bigger
  5704. if (_.is3D())
  5705. f += 0.06;
  5706. var L = _.data.length,sepa = $.angle2Radian($.between(0,90,_.get('separate_angle'))),PI = pi2-sepa,sepa=sepa/L,eA = _.oA+sepa, sA = eA;
  5707. if(_.total==0){
  5708. V = 1/L;
  5709. }
  5710. _.data.each(function(d, i) {
  5711. eA += (V||(d.value / _.total)) * PI;
  5712. if (i == (L - 1)) {
  5713. eA = pi2 + _.oA;
  5714. }
  5715. d.startAngle = sA;
  5716. d.endAngle = eA;
  5717. d.totalAngle = eA - sA;
  5718. d.middleAngle = (sA + eA) / 2;
  5719. sA = eA+sepa;
  5720. }, _);
  5721. _.r = r = $.parsePercent(r,Math.floor(_.get('minDistance') * f));
  5722. _.topY = _.originXY(_,[r + _.get('l_originx'),_.get('r_originx') - r,_.get('centerx')],[_.get('centery')]).y;
  5723. $.apply(_.get('sub_option'),$.clone([_.X, _.Y, 'bound_event','mutex','increment'], _.options));
  5724. }
  5725. });
  5726. /** @end */
  5727. /**
  5728. * @overview the pie2d componment
  5729. * @component#@chart#$.Pie2D
  5730. * @extend#$.Pie
  5731. */
  5732. $.Pie2D = $.extend($.Pie, {
  5733. /**
  5734. * initialize the context for the pie2d
  5735. */
  5736. configure : function() {
  5737. /**
  5738. * invoked the super class's configuration
  5739. */
  5740. $.Pie2D.superclass.configure.call(this);
  5741. this.type = 'pie2d';
  5742. },
  5743. doConfig : function() {
  5744. $.Pie2D.superclass.doConfig.call(this);
  5745. var _ = this._();
  5746. /**
  5747. * quick config to all rectangle
  5748. */
  5749. _.push('sub_option.radius',_.r)
  5750. _.parse(_);
  5751. }
  5752. });
  5753. $.register('Pie2D');
  5754. /**
  5755. * @end
  5756. */
  5757. /**
  5758. * @overview the pie3d componment
  5759. * @component#@chart#$.Pie3D
  5760. * @extend#$.Pie
  5761. */
  5762. $.Pie3D = $.extend($.Pie, {
  5763. configure : function() {
  5764. /**
  5765. * invoked the super class's configuration
  5766. */
  5767. $.Pie3D.superclass.configure.apply(this, arguments);
  5768. this.type = 'pie3d';
  5769. this.dimension = $._3D;
  5770. this.set({
  5771. /**
  5772. * @cfg {Number} Three-dimensional rotation Z in degree(angle).socpe{0-90}.(default to 45)
  5773. */
  5774. zRotate : 45,
  5775. /**
  5776. * @cfg {Number} Specifies the pie's thickness in pixels.(default to 30)
  5777. */
  5778. yHeight : 30
  5779. });
  5780. this.positive = true;
  5781. },
  5782. doSector : function(_,d) {
  5783. _.push('sub_option.cylinder_height', (d.cylinder_height ? d.cylinder_height * _.get('zRotate_') : _.get('cylinder_height')));
  5784. return new $[_.sub](_.get('sub_option'), _);
  5785. },
  5786. one:function(_){
  5787. var layer,spaint,L = [],c = _.get('counterclockwise'), abs = function(n,M) {
  5788. /**
  5789. * If M,close to pi/2,else pi*3/2
  5790. */
  5791. return 1 + Math.sin(M?(n+Math.PI):n);
  5792. }, t = 'startAngle', d = 'endAngle',Q,s,e
  5793. /**
  5794. * If the inside layer visibile
  5795. */
  5796. lay =function(C,g,z,f){
  5797. Q = $.quadrantd(g);
  5798. if (C &&(Q ==0 || Q ==3) || (!C && (Q ==2 || Q ==1))) {
  5799. layer.push({
  5800. g : g,
  5801. z : g==z,
  5802. x : f.x,
  5803. y : f.y,
  5804. a : f.a,
  5805. b : f.b,
  5806. color : $.dark(f.get('background_color')),
  5807. h : f.h,
  5808. F : f
  5809. });
  5810. }
  5811. };
  5812. _.proxy = new $.Custom({
  5813. z_index : _.get('z_index') + 1,
  5814. drawFn : function() {
  5815. this.drawSector();
  5816. L = [];
  5817. _.sectors.each(function(s) {
  5818. if (s.get('label')) {
  5819. if (s.expanded)
  5820. L.push(s.label);
  5821. else
  5822. s.label.draw();
  5823. }
  5824. });
  5825. L.each(function(l) {
  5826. l.draw()
  5827. });
  5828. }
  5829. });
  5830. _.proxy.drawSector = function() {
  5831. /**
  5832. * paint bottom layer
  5833. */
  5834. _.sectors.each(function(s, i) {
  5835. _.T.ellipse(s.x, s.y + s.h, s.a, s.b, s.get(t), s.get(d), 0, s.get('border.enable'), s.get('border.width'), s.get('border.color'), s.get('shadow'), c, true);
  5836. }, _);
  5837. layer = [];
  5838. spaint = [];
  5839. /**
  5840. * sort layer
  5841. */
  5842. _.sectors.each(function(f) {
  5843. lay(c,f.get(t),f.get(d),f);
  5844. lay(!c,f.get(d),f.get(t),f);
  5845. spaint = spaint.concat($.visible(f.get(t),f.get(d),f));
  5846. }, _);
  5847. /**
  5848. * realtime sort
  5849. */
  5850. layer.sor(function(p, q) {
  5851. var r = abs(p.g) - abs(q.g);
  5852. return r==0?p.z:r > 0;
  5853. });
  5854. /**
  5855. * paint inside layer
  5856. */
  5857. layer.each(function(f, i) {
  5858. _.T.sector3D.layerDraw.call(_.T, f.x, f.y, f.a + 0.5, f.b + 0.5, c, f.h, f.g, f.color);
  5859. }, _);
  5860. if(!_.processAnimation){
  5861. /**
  5862. * realtime sort
  5863. */
  5864. spaint.sor(function(p, q) {
  5865. return abs((p.s+p.e)/2,1) - abs((q.s+q.e)/2,1)<0;
  5866. });
  5867. }
  5868. /**
  5869. * paint outside layer
  5870. */
  5871. spaint.each(function(s, i) {
  5872. _.T.sector3D.sPaint.call(_.T, s.f.x, s.f.y, s.f.a, s.f.b, s.s, s.e, c, s.f.h, s.f.get('f_color'));
  5873. }, _);
  5874. /**
  5875. * paint top layer
  5876. */
  5877. _.sectors.each(function(s, i) {
  5878. _.T.ellipse(s.x, s.y, s.a, s.b, s.get(t), s.get(d), s.get('f_color'), s.get('border.enable'), s.get('border.width'), s.get('border.color'), false, false, true);
  5879. }, _);
  5880. }
  5881. _.one = $.emptyFn;
  5882. },
  5883. doConfig : function() {
  5884. $.Pie3D.superclass.doConfig.call(this);
  5885. var _ = this._(), z = $.angle2Radian(_.get('zRotate'));
  5886. _.push('cylinder_height', _.get('yHeight') * _.push('zRotate_',Math.abs(Math.cos(z))));
  5887. _.a = _.push('sub_option.semi_major_axis', _.r);
  5888. _.b = _.push('sub_option.semi_minor_axis', _.r * Math.abs(Math.sin(z)));
  5889. _.topY = _.push('sub_option.originy', _.get(_.Y) - _.get('yHeight') / 2);
  5890. _.parse(_);
  5891. _.one(_);
  5892. _.components.push(_.proxy);
  5893. }
  5894. });
  5895. $.register('Pie3D');
  5896. /**
  5897. * @end
  5898. */
  5899. /**
  5900. * @overview this component use for show a donut chart
  5901. * @component#@chart#$.Donut2D
  5902. * @extend#$.Pie
  5903. */
  5904. $.Donut2D = $.extend($.Pie, {
  5905. /**
  5906. * initialize the context for the pie2d
  5907. */
  5908. configure : function() {
  5909. /**
  5910. * invoked the super class's configuration
  5911. */
  5912. $.Donut2D.superclass.configure.call(this);
  5913. this.type = 'donut2d';
  5914. this.set({
  5915. /**
  5916. * @cfg {Number} Specifies the width when show a donut.If the value lt 1,It will be as a percentage,value will be radius*donutwidth.only applies when it not 0.(default to 0.3)
  5917. */
  5918. donutwidth : 0.3,
  5919. /**
  5920. * @cfg {Object/String} Specifies the config of Center Text details see <link>$.Text</link>,If given a string,it will only apply the text.note:If the text is empty,then will not display
  5921. */
  5922. center : {
  5923. text:'',
  5924. line_height:24,
  5925. fontweight : 'bold',
  5926. /**
  5927. * Specifies the font-size in pixels of center text.(default to 24)
  5928. */
  5929. fontsize : 24
  5930. }
  5931. });
  5932. },
  5933. doConfig : function() {
  5934. $.Donut2D.superclass.doConfig.call(this);
  5935. var _ = this._(),d='donutwidth',r = _.r;
  5936. /**
  5937. * quick config to all rectangle
  5938. */
  5939. _.push('sub_option.radius',r)
  5940. if(_.get(d)>0){
  5941. if(_.get(d)<1){
  5942. _.push(d,Math.floor(r*_.get(d)));
  5943. }else if(_.get(d)>=r){
  5944. _.push(d,0);
  5945. }
  5946. _.push('sub_option.donutwidth',_.get(d));
  5947. }
  5948. if ($.isString(_.get('center'))) {
  5949. _.push('center', $.applyIf({
  5950. text : _.get('center')
  5951. }, _.default_.center));
  5952. }
  5953. if (_.get('center.text') != '') {
  5954. _.push('center.originx',_.get(_.X));
  5955. _.push('center.originy',_.get(_.Y));
  5956. _.push('center.textBaseline','middle');
  5957. _.center = new $.Text(_.get('center'), _);
  5958. _.components.push(_.center);
  5959. }
  5960. _.parse(_);
  5961. }
  5962. });
  5963. $.register('Donut2D');
  5964. /**
  5965. * @end
  5966. */
  5967. /**
  5968. * @overview this class is abstract,use for config column
  5969. * @component#$.Column
  5970. * @extend#$.Chart
  5971. */
  5972. $.Column = $.extend($.Chart, {
  5973. /**
  5974. * initialize the context for the Column
  5975. */
  5976. configure : function(config) {
  5977. /**
  5978. * invoked the super class's configuration
  5979. */
  5980. $.Column.superclass.configure.call(this);
  5981. this.type = 'column';
  5982. this.set({
  5983. /**
  5984. * @cfg {<link>$.Coordinate2D</link>} the option for coordinate.
  5985. */
  5986. coordinate : {},
  5987. /**
  5988. * @cfg {Number} By default,if a width is not specified the chart will attempt to distribution in horizontally.(default to undefined)
  5989. */
  5990. column_width : undefined,
  5991. /**
  5992. * @cfg {Number} the space of each column.this option is readOnly.(default to undefined)
  5993. */
  5994. column_space : undefined,
  5995. /**
  5996. * @cfg {Number} the distance of column's bottom and text(default to 6)
  5997. */
  5998. text_space : 6,
  5999. /**
  6000. * @cfg {String} the align of scale(default to 'left') Available value are:
  6001. * @Option 'left'
  6002. * @Option 'right'
  6003. */
  6004. scaleAlign : 'left',
  6005. /**
  6006. * @cfg {<link>$.Rectangle</link>} Specifies option of rectangle.
  6007. */
  6008. sub_option : {},
  6009. /**
  6010. * @cfg {<link>$.Text</link>} Specifies option of label at bottom.
  6011. */
  6012. label:{}
  6013. });
  6014. this.registerEvent();
  6015. this.rectangles = [];
  6016. this.labels = [];
  6017. this.components.push(this.labels);
  6018. this.components.push(this.rectangles);
  6019. },
  6020. doAnimation : function(t, d,_) {
  6021. var h;
  6022. _.labels.each(function(l){
  6023. l.draw();
  6024. });
  6025. _.rectangles.each(function(r){
  6026. h = Math.ceil(_.animationArithmetic(t, 0, r.height, d));
  6027. r.push(_.Y, r.y + (r.height - h));
  6028. r.push(_.H, h);
  6029. r.drawRectangle();
  6030. });
  6031. },
  6032. /**
  6033. * @method Returns the coordinate of this element.
  6034. * @return $.Coordinate2D
  6035. */
  6036. getCoordinate:function(){
  6037. return this.coo;
  6038. },
  6039. doLabel:function(_,id,text,x, y){
  6040. _.labels.push(new $.Text($.apply(_.get('label'),{
  6041. id : id,
  6042. text : text,
  6043. originx : x,
  6044. originy : y
  6045. }), _));
  6046. },
  6047. doParse : function(_,d, i, o) {
  6048. _.doActing(_,d,o,i);
  6049. },
  6050. engine:function(_){
  6051. var cw = _.get('column_width'),
  6052. s = _.get('column_space'),
  6053. S = _.coo.getScale(_.get('scaleAlign')),
  6054. H = _.coo.valid_height,
  6055. w2 = cw / 2,
  6056. q = cw * (_.get('group_fator') || 0),
  6057. gw = _.dataType != 'complex'?(cw + s):(_.data.length * cw + s + (_.is3D() ? (_.data.length - 1) * q : 0)),
  6058. y0 = _.coo.get('y_end'),
  6059. y = y0 - S.basic*H - (_.is3D()?(_.get('zHeight') * (_.get('bottom_scale') - 1) / 2 * _.get('yAngle_')):0),
  6060. x = s+_.coo.get('x_start');
  6061. y0 = y0 + _.get('text_space') + _.coo.get('axis.width')[2];
  6062. /**
  6063. * applies paramters to subClass
  6064. */
  6065. _.doEngine(_,cw,s,S,H,w2,q,gw,x,y,y0);
  6066. },
  6067. doConfig : function() {
  6068. $.Column.superclass.doConfig.call(this);
  6069. var _ = this._(),c = 'column_width',z = 'z_index';
  6070. _.sub = _.is3D()?'Rectangle3D':'Rectangle2D';
  6071. _.rectangles.length = 0;
  6072. _.labels.length = 0;
  6073. _.rectangles.zIndex = _.get(z);
  6074. _.labels.zIndex = _.get(z) + 1;
  6075. /**
  6076. * use option create a coordinate
  6077. */
  6078. _.coo = $.Coordinate.coordinate_.call(_,function(){
  6079. var L = _.data.length, W = _.get('coordinate.valid_width_value'),w_,hw,KL;
  6080. if (_.dataType == 'complex') {
  6081. KL = _.get('labels').length;
  6082. L = KL * L + (_.is3D()?(L-1)*KL*_.get('group_fator'):0);
  6083. w_= Math.floor(W / (KL + 1 + L));
  6084. hw = _.pushIf(c,w_);
  6085. KL +=1;
  6086. }else{
  6087. if(_.dataType == 'stacked'){
  6088. L = _.get('labels').length;
  6089. }
  6090. w_= Math.floor(W*2 / (L * 3 + 1));
  6091. hw = _.pushIf(c, w_);
  6092. KL = L+1;
  6093. }
  6094. if(hw * L > W){
  6095. hw = _.push(c, w_);
  6096. }
  6097. /**
  6098. * the space of two column
  6099. */
  6100. _.push('column_space', (W - hw * L) / KL);
  6101. if (_.is3D()) {
  6102. _.push('zHeight', _.get(c) * _.get('zScale'));
  6103. _.push('sub_option.zHeight', _.get('zHeight'));
  6104. _.push('sub_option.xAngle_', _.get('xAngle_'));
  6105. _.push('sub_option.yAngle_', _.get('yAngle_'));
  6106. }
  6107. });
  6108. _.push('sub_option.width', _.get(c));
  6109. }
  6110. });
  6111. /**
  6112. * @end
  6113. */
  6114. /**
  6115. * @overview the column2d componment
  6116. * @component#@chart#$.Column2D
  6117. * @extend#$.Column
  6118. */
  6119. $.Column2D = $.extend($.Column, {
  6120. /**
  6121. * initialize the context for the Column2D
  6122. */
  6123. configure : function() {
  6124. /**
  6125. * invoked the super class's configuration
  6126. */
  6127. $.Column2D.superclass.configure.call(this);
  6128. this.type = 'column2d';
  6129. },
  6130. doEngine:function(_,cw,s,S,H,w2,q,gw,x,y,y0){
  6131. var h;
  6132. _.data.each(function(d, i) {
  6133. h = (d.value - S.start) * H / S.distance;
  6134. _.doParse(_,d, i, {
  6135. id : i,
  6136. originx :x + i * gw,
  6137. originy : y - (h>0? h :0),
  6138. height : Math.abs(h)
  6139. });
  6140. _.rectangles.push(new $[_.sub](_.get('sub_option'), _));
  6141. _.doLabel(_,i, d.name, x + gw * i + w2, y0);
  6142. }, _);
  6143. },
  6144. doConfig : function() {
  6145. $.Column2D.superclass.doConfig.call(this);
  6146. /**
  6147. * start up engine
  6148. */
  6149. this.engine(this);
  6150. }
  6151. });
  6152. $.register('Column2D');
  6153. /**
  6154. *@end
  6155. */
  6156. /**
  6157. * @overview the column3d componment
  6158. * @component#@chart#$.Column3D
  6159. * @extend#$.Column2D
  6160. */
  6161. $.Column3D = $.extend($.Column2D, {
  6162. /**
  6163. * initialize the context for the Column3D
  6164. */
  6165. configure : function() {
  6166. /**
  6167. * invoked the super class's configuration
  6168. */
  6169. $.Column3D.superclass.configure.call(this);
  6170. this.type = 'column3d';
  6171. this.dimension = $._3D;
  6172. this.set({
  6173. /**
  6174. * @cfg {<link>$.Coordinate3D</link>} the option for coordinate.
  6175. */
  6176. coordinate : {},
  6177. /**
  6178. * @cfg {Number(0~90)} Three-dimensional rotation X in degree(angle).(default to 60)
  6179. */
  6180. xAngle : 60,
  6181. /**
  6182. * @cfg {Number(0~90)} Three-dimensional rotation Y in degree(angle).(default to 20)
  6183. */
  6184. yAngle : 20,
  6185. /**
  6186. * @cfg {Number} Three-dimensional z-axis deep factor.frame of reference is width.(default to 1)
  6187. */
  6188. zScale : 1,
  6189. /**
  6190. * @cfg {Number(1~)} Three-dimensional z-axis deep factor of pedestal.frame of reference is width.(default to 1.4)
  6191. */
  6192. bottom_scale : 1.4
  6193. });
  6194. },
  6195. doConfig : function() {
  6196. $.Column3D.superclass.doConfig.call(this);
  6197. }
  6198. });
  6199. $.register('Column3D');
  6200. /**
  6201. *@end
  6202. */
  6203. /**
  6204. * @overview this component will draw a cluster column2d chart.
  6205. * @component#@chart#$.ColumnMulti2D
  6206. * @extend#$.Column
  6207. */
  6208. $.ColumnMulti2D = $.extend($.Column, {
  6209. /**
  6210. * initialize the context for the ColumnMulti2D
  6211. */
  6212. configure : function() {
  6213. /**
  6214. * invoked the super class's configuration
  6215. */
  6216. $.ColumnMulti2D.superclass.configure.call(this);
  6217. this.type = 'columnmulti2d';
  6218. this.dataType = 'complex';
  6219. this.set({
  6220. /**
  6221. * @cfg {Array} the array of labels close to the axis
  6222. */
  6223. labels : []
  6224. });
  6225. },
  6226. doEngine:function(_,cw,s,S,H,w2,q,gw,x,y,y0){
  6227. var h;
  6228. _.columns.each(function(c, i) {
  6229. c.item.each(function(d, j) {
  6230. h = (d.value - S.start) * H / S.distance;
  6231. _.doParse(_, d, j, {
  6232. id : i + '_' + j,
  6233. originx : x + j * (cw + q) + i * gw,
  6234. originy : y - (h > 0 ? h : 0),
  6235. height : Math.abs(h)
  6236. });
  6237. _.rectangles.push(new $[_.sub](_.get('sub_option'), _));
  6238. }, _);
  6239. _.doLabel(_, i, c.name, x - s * 0.5 + (i + 0.5) * gw, y0);
  6240. }, _);
  6241. },
  6242. doConfig : function() {
  6243. $.ColumnMulti2D.superclass.doConfig.call(this);
  6244. /**
  6245. * start up engine
  6246. */
  6247. this.engine(this);
  6248. }
  6249. });
  6250. $.register('ColumnMulti2D');
  6251. /**
  6252. * @end
  6253. */
  6254. /**
  6255. * @overview this component will draw a cluster column3d chart.
  6256. * @component#@chart#$.ColumnMulti3D
  6257. * @extend#$.ColumnMulti2D
  6258. */
  6259. $.ColumnMulti3D = $.extend($.ColumnMulti2D, {
  6260. /**
  6261. * initialize the context for the ColumnMulti3D
  6262. */
  6263. configure : function() {
  6264. /**
  6265. * invoked the super class's configuration
  6266. */
  6267. $.ColumnMulti3D.superclass.configure.call(this);
  6268. this.type = 'columnmulti3d';
  6269. this.dataType = 'complex';
  6270. this.dimension = $._3D;
  6271. this.set({
  6272. /**
  6273. * @cfg {Number(0~90)} Three-dimensional rotation X in degree(angle).(default to 60)
  6274. */
  6275. xAngle : 60,
  6276. /**
  6277. * @cfg {Number(0~90)} Three-dimensional rotation Y in degree(angle).(default to 20)
  6278. */
  6279. yAngle : 20,
  6280. /**
  6281. * @cfg {Number} Three-dimensional z-axis deep factor.frame of reference is width.(default to 1)
  6282. */
  6283. zScale : 1,
  6284. group_fator : 0.3,
  6285. /**
  6286. * @cfg {Number(1~)} Three-dimensional z-axis deep factor of pedestal.frame of reference is width.(default to 1.4)
  6287. */
  6288. bottom_scale : 1.4
  6289. });
  6290. },
  6291. doConfig : function() {
  6292. $.ColumnMulti3D.superclass.doConfig.call(this);
  6293. }
  6294. });
  6295. $.register('ColumnMulti3D');
  6296. /**
  6297. * @end
  6298. */
  6299. /**
  6300. * @overview the stacked column2d componment
  6301. * @component#@chart#$.ColumnStacked2D
  6302. * @extend#$.Column
  6303. */
  6304. $.ColumnStacked2D = $.extend($.Column, {
  6305. /**
  6306. * initialize the context for the ColumnStacked2D
  6307. */
  6308. configure : function() {
  6309. /**
  6310. * invoked the super class's configuration
  6311. */
  6312. $.ColumnStacked2D.superclass.configure.call(this);
  6313. this.type = 'columnstacked2d';
  6314. /**
  6315. * indicate the data structure
  6316. */
  6317. this.dataType = 'stacked';
  6318. this.set({
  6319. /**
  6320. * @cfg {Boolean} Specifies as true to display with percent.(default to false)
  6321. */
  6322. percent : false,
  6323. /**
  6324. * @cfg {Array} the array of labels close to the axis
  6325. */
  6326. labels : [],
  6327. sub_option:{
  6328. label:{color:'#ffffff'},
  6329. valueAlign:'middle'
  6330. }
  6331. });
  6332. },
  6333. doEngine:function(_,cw,s,S,H,w2,q,gw,x,y,y0){
  6334. var h0,h,v,p = _.get('percent');
  6335. _.columns.each(function(c, i) {
  6336. h0 = 0;
  6337. v = p?100/c.total:1;
  6338. c.item.each(function(d, j) {
  6339. h = (d.value*v - S.start) * H / S.distance;
  6340. d.total = c.total;
  6341. _.doParse(_, d, j, {
  6342. id : i + '_' + j,
  6343. originx : x + i * gw,
  6344. originy : y - (h > 0 ? h : 0)-h0,
  6345. height : Math.abs(h)
  6346. });
  6347. h0 += h;
  6348. _.rectangles.push(new $[_.sub](_.get('sub_option'), _));
  6349. }, _);
  6350. _.doLabel(_, i, c.name, x - s * 0.5 + (i + 0.5) * gw, y0);
  6351. }, _);
  6352. },
  6353. doConfig : function() {
  6354. $.ColumnStacked2D.superclass.doConfig.call(this);
  6355. /**
  6356. * start up engine
  6357. */
  6358. this.engine(this);
  6359. }
  6360. });
  6361. $.register('ColumnStacked2D');
  6362. /**
  6363. *@end
  6364. */
  6365. /**
  6366. * @overview the stacked column2d componment
  6367. * @component#@chart#$.ColumnStacked3D
  6368. * @extend#$.ColumnStacked2D
  6369. */
  6370. $.ColumnStacked3D = $.extend($.ColumnStacked2D, {
  6371. /**
  6372. * initialize the context for the ColumnStacked2D
  6373. */
  6374. configure : function() {
  6375. /**
  6376. * invoked the super class's configuration
  6377. */
  6378. $.ColumnStacked3D.superclass.configure.call(this);
  6379. this.type = 'columnstacked3d';
  6380. /**
  6381. * indicate the data structure
  6382. */
  6383. this.dataType = 'stacked';
  6384. this.dimension = $._3D;
  6385. this.set({
  6386. /**
  6387. * @cfg {Boolean} Specifies as true to display with percent.(default to false)
  6388. */
  6389. percent : false,
  6390. sub_option:{
  6391. label:{color:'#ffffff'},
  6392. valueAlign:'middle'
  6393. },
  6394. /**
  6395. * @cfg {<link>$.Coordinate3D</link>} the option for coordinate.
  6396. */
  6397. coordinate : {},
  6398. /**
  6399. * @cfg {Number(0~90)} Three-dimensional rotation X in degree(angle).(default to 60)
  6400. */
  6401. xAngle : 60,
  6402. /**
  6403. * @cfg {Number(0~90)} Three-dimensional rotation Y in degree(angle).(default to 20)
  6404. */
  6405. yAngle : 20,
  6406. /**
  6407. * @cfg {Number} Three-dimensional z-axis deep factor.frame of reference is width.(default to 1)
  6408. */
  6409. zScale : 1,
  6410. /**
  6411. * @cfg {Number(1~)} Three-dimensional z-axis deep factor of pedestal.frame of reference is width.(default to 1.4)
  6412. */
  6413. bottom_scale : 1.4
  6414. });
  6415. },
  6416. doConfig : function() {
  6417. $.ColumnStacked3D.superclass.doConfig.call(this);
  6418. }
  6419. });
  6420. $.register('ColumnStacked3D');
  6421. /**
  6422. *@end
  6423. */
  6424. /**
  6425. * @overview this class is abstract,use for config bar
  6426. * @component#$.Bar
  6427. * @extend#$.Chart
  6428. */
  6429. $.Bar = $.extend($.Chart, {
  6430. /**
  6431. * initialize the context for the bar
  6432. */
  6433. configure : function() {
  6434. /**
  6435. * invoked the super class's configuration
  6436. */
  6437. $.Bar.superclass.configure.call(this);
  6438. this.type = 'bar';
  6439. this.set({
  6440. /**
  6441. * @cfg {<link>$.Coordinate2D</link>} the option for coordinate.
  6442. */
  6443. coordinate : {
  6444. striped_direction : 'h'
  6445. },
  6446. /**
  6447. * @cfg {Number} Specifies the width of each bar(default to calculate according to coordinate's height)
  6448. */
  6449. bar_height : undefined,
  6450. /**
  6451. * @cfg {Number} the space of each column.this option is readOnly.(default to undefined)
  6452. */
  6453. bar_space : undefined,
  6454. /**
  6455. * @cfg {Number} Specifies the distance of bar's bottom and text(default to 6)
  6456. */
  6457. text_space : 6,
  6458. /**
  6459. * @cfg {String} Specifies the align of scale(default to 'bottom') Available value are:
  6460. * @Option 'bottom'
  6461. */
  6462. scaleAlign : 'bottom',
  6463. /**
  6464. * @cfg {<link>$.Rectangle</link>} Specifies option of rectangle.
  6465. */
  6466. sub_option : {},
  6467. /**
  6468. * @cfg {<link>$.Text</link>} Specifies option of label at left.
  6469. */
  6470. label : {}
  6471. });
  6472. },
  6473. /**
  6474. * @method Returns the coordinate of this element.
  6475. * @return $.Coordinate2D
  6476. */
  6477. getCoordinate : function() {
  6478. return this.coo;
  6479. },
  6480. doLabel : function(_,id, text, x, y) {
  6481. _.labels.push(new $.Text($.apply(_.get('label'), {
  6482. id : id,
  6483. text : text,
  6484. textAlign : 'right',
  6485. textBaseline : 'middle',
  6486. originx : x,
  6487. originy : y
  6488. }), _));
  6489. },
  6490. doParse : function(_, d, i, o) {
  6491. _.doActing(_, d, o,i);
  6492. },
  6493. engine:function(_){
  6494. var bh = _.get('bar_height'),
  6495. s = _.get('bar_space'),
  6496. S = _.coo.getScale(_.get('scaleAlign')),
  6497. W = _.coo.valid_width,
  6498. h2 = bh / 2,
  6499. gw = _.dataType != 'complex'?bh + s:_.data.length * bh + s,
  6500. x = _.coo.get('x_start')+ S.basic * W,
  6501. x0 = _.coo.get(_.X) - _.get('text_space')-_.coo.get('axis.width')[3],
  6502. y0 = _.coo.get('y_start')+ s;
  6503. _.doEngine(_,bh,s,S,W,h2,gw,x,x0,y0);
  6504. },
  6505. doAnimation : function(t, d,_) {
  6506. _.labels.each(function(l) {
  6507. l.draw();
  6508. });
  6509. _.rectangles.each(function(r) {
  6510. r.push(_.W, Math.ceil(_.animationArithmetic(t, 0, r.width, d)));
  6511. r.drawRectangle();
  6512. });
  6513. },
  6514. doConfig : function() {
  6515. $.Bar.superclass.doConfig.call(this);
  6516. var _ = this._(), b = 'bar_height', z = 'z_index';
  6517. _.rectangles = [];
  6518. _.labels = [];
  6519. _.rectangles.zIndex = _.get(z);
  6520. _.labels.zIndex = _.get(z) + 1;
  6521. _.components.push(_.labels);
  6522. _.components.push(_.rectangles);
  6523. /**
  6524. * use option create a coordinate
  6525. */
  6526. _.coo = $.Coordinate.coordinate_.call(_,function(){
  6527. var L = _.data.length, H = _.get('coordinate.valid_height_value'),h_,bh,KL;
  6528. if (_.dataType == 'complex') {
  6529. KL = _.get('labels').length;
  6530. L = KL * L + (_.is3D()?(L-1)*KL*_.get('group_fator'):0);
  6531. h_= Math.floor(H / (KL + 1 + L));
  6532. bh = _.pushIf(b,h_);
  6533. KL +=1;
  6534. }else{
  6535. if(_.dataType == 'stacked'){
  6536. L = _.get('labels').length;
  6537. }
  6538. h_= Math.floor(H*2 / (L * 3 + 1));
  6539. bh = _.pushIf(b, h_);
  6540. KL = L+1;
  6541. }
  6542. if (bh * L > H) {
  6543. bh = _.push(b, h_);
  6544. }
  6545. /**
  6546. * the space of two bar
  6547. */
  6548. _.push('bar_space', (H - bh * L) / KL);
  6549. });
  6550. /**
  6551. * quick config to all rectangle
  6552. */
  6553. _.push('sub_option.height', _.get(b));
  6554. _.push('sub_option.valueAlign', _.R);
  6555. _.push('sub_option.tipAlign', _.R);
  6556. }
  6557. });
  6558. /**
  6559. * @end
  6560. */
  6561. /**
  6562. * @overview this component will draw a bar2d chart.
  6563. * @component#@chart#$.Bar2D
  6564. * @extend#$.Bar
  6565. */
  6566. $.Bar2D = $.extend($.Bar, {
  6567. /**
  6568. * initialize the context for the pie
  6569. */
  6570. configure : function() {
  6571. /**
  6572. * invoked the super class's configuration
  6573. */
  6574. $.Bar2D.superclass.configure.call(this);
  6575. this.type = 'bar2d';
  6576. },
  6577. doEngine:function(_,bh,s,S,W,h2,gw,x,x0,y0){
  6578. var w;
  6579. _.data.each(function(d, i) {
  6580. w = (d.value - S.start) * W / S.distance;
  6581. _.doParse(_, d, i, {
  6582. id : i,
  6583. originy : y0 + i * gw,
  6584. width : Math.abs(w),
  6585. originx : x + (w > 0 ? 0 : -Math.abs(w))
  6586. });
  6587. _.rectangles.push(new $.Rectangle2D(_.get('sub_option'), _));
  6588. _.doLabel(_,i, d.name, x0, y0 + i * gw + h2);
  6589. }, _);
  6590. },
  6591. doConfig : function() {
  6592. $.Bar2D.superclass.doConfig.call(this);
  6593. /**
  6594. * start up engine
  6595. */
  6596. this.engine(this);
  6597. }
  6598. });
  6599. $.register('Bar2D');
  6600. /**
  6601. * @end
  6602. */
  6603. /**
  6604. * @overview this component will draw a cluster bar2d chart.
  6605. * @component#@chart#$.BarMulti2D
  6606. * @extend#$.Bar
  6607. */
  6608. $.BarMulti2D = $.extend($.Bar, {
  6609. /**
  6610. * initialize the context for the BarMulti2D
  6611. */
  6612. configure : function() {
  6613. /**
  6614. * invoked the super class's configuration
  6615. */
  6616. $.BarMulti2D.superclass.configure.call(this);
  6617. this.type = 'barmulti2d';
  6618. this.dataType = 'complex';
  6619. this.set({
  6620. /**
  6621. * @cfg {Array} the array of labels close to the axis
  6622. */
  6623. labels : []
  6624. });
  6625. },
  6626. doEngine:function(_,bh,s,S,W,h2,gw,x,x0,y0){
  6627. var w;
  6628. _.columns.each(function(c, i) {
  6629. c.item.each(function(d, j) {
  6630. w = (d.value - S.start) * W / S.distance;
  6631. _.doParse(_, d, j, {
  6632. id : i + '_' + j,
  6633. originy : y0 + j * bh + i * gw,
  6634. width : Math.abs(w),
  6635. originx: x+(w>0?0:-Math.abs(w))
  6636. });
  6637. _.rectangles.push(new $.Rectangle2D(_.get('sub_option'), _));
  6638. }, _);
  6639. _.doLabel(_,i, c.name, x0, y0 - s * 0.5 + (i + 0.5) * gw);
  6640. }, _);
  6641. },
  6642. doConfig : function() {
  6643. $.BarMulti2D.superclass.doConfig.call(this);
  6644. /**
  6645. * start up engine
  6646. */
  6647. this.engine(this);
  6648. }
  6649. });
  6650. $.register('BarMulti2D');
  6651. /**
  6652. * @end
  6653. */
  6654. /**
  6655. * @overview the stacked bar2d componment
  6656. * @component#@chart#$.BarStacked2D
  6657. * @extend#$.Bar
  6658. */
  6659. $.BarStacked2D = $.extend($.Bar, {
  6660. /**
  6661. * initialize the context for the BarStacked2D
  6662. */
  6663. configure : function() {
  6664. /**
  6665. * invoked the super class's configuration
  6666. */
  6667. $.BarStacked2D.superclass.configure.call(this);
  6668. this.type = 'barstacked2d';
  6669. /**
  6670. * indicate the data structure
  6671. */
  6672. this.dataType = 'stacked';
  6673. this.set({
  6674. /**
  6675. * @cfg {Boolean} Specifies as true to display with percent.(default to false)
  6676. */
  6677. percent : false,
  6678. /**
  6679. * @cfg {Array} the array of labels close to the axis
  6680. */
  6681. labels : [],
  6682. sub_option:{
  6683. label:{color:'#ffffff'},
  6684. valueAlign:'middle'
  6685. }
  6686. });
  6687. },
  6688. doEngine:function(_,bh,s,S,W,h2,gw,x,x0,y0){
  6689. var w0,w,v,p = _.get('percent');
  6690. _.columns.each(function(c, i) {
  6691. w0 = 0;
  6692. v = p?100/c.total:1;
  6693. c.item.each(function(d, j) {
  6694. w = (d.value*v - S.start) * W / S.distance;
  6695. d.total = c.total;
  6696. _.doParse(_, d, j, {
  6697. id : i + '_' + j,
  6698. originy : y0 + i * gw,
  6699. originx : x + (w > 0 ? 0 : -Math.abs(w))+w0,
  6700. width : Math.abs(w)
  6701. });
  6702. w0 += w;
  6703. _.rectangles.push(new $.Rectangle2D(_.get('sub_option'), _));
  6704. }, _);
  6705. _.doLabel(_, i, c.name,x0, y0 - s * 0.5 + (i + 0.5) * gw);
  6706. }, _);
  6707. },
  6708. doConfig : function() {
  6709. $.BarStacked2D.superclass.doConfig.call(this);
  6710. this.push('sub_option.valueAlign', this.C);
  6711. /**
  6712. * start up engine
  6713. */
  6714. this.engine(this);
  6715. }
  6716. });
  6717. $.register('BarStacked2D');
  6718. /**
  6719. *@end
  6720. */
  6721. /**
  6722. * @overview the line segment componment
  6723. * @component#$.LineSegment
  6724. * @extend#$.Component
  6725. */
  6726. $.LineSegment = $.extend($.Component, {
  6727. configure : function() {
  6728. /**
  6729. * invoked the super class's configuration
  6730. */
  6731. $.LineSegment.superclass.configure.apply(this, arguments);
  6732. /**
  6733. * indicate the component's type
  6734. */
  6735. this.type = 'linesegment';
  6736. this.set({
  6737. /**
  6738. * @cfg {Number} Specifies the default linewidth of the canvas's context in this element.(defaults to 1)
  6739. */
  6740. brushsize : 1,
  6741. /**
  6742. * @cfg {Boolean} If true there show a point when Line-line intersection(default to true)
  6743. */
  6744. intersection : true,
  6745. /**
  6746. * @cfg {<link>$.Text</link>} Specifies the config of label,set false to make label disabled.
  6747. */
  6748. label : {},
  6749. /**
  6750. * @cfg {String} Specifies the shape of two line segment' point(default to 'round').Only applies when intersection is true Available value are:
  6751. * @Option 'round'
  6752. */
  6753. sign : 'round',
  6754. /**
  6755. * @cfg {String} Specifies the bgcolor when applies a Area.If not given,use lighter bgcolor of line.(default to null)
  6756. */
  6757. area_color:null,
  6758. /**
  6759. * @cfg {Boolean} If true the centre of point will be hollow.(default to true)
  6760. */
  6761. hollow : true,
  6762. /**
  6763. * @cfg {Boolean} If true the color of the centre of point will be hollow_color.else will be background_color.(default to true)
  6764. */
  6765. hollow_inside:true,
  6766. /**
  6767. * @cfg {String} Specifies the bgcolor when hollow applies true.(default to '#FEFEFE')
  6768. */
  6769. hollow_color : '#FEFEFE',
  6770. /**
  6771. * @cfg {Boolean} If true Line will smooth.(default to false)
  6772. */
  6773. smooth : false,
  6774. /**
  6775. * @cfg {Number} Specifies smoothness of line will be.(default to 1.5)
  6776. * 1 means control points midway between points, 2 means 1/3 from the point,formula is 1/(smoothing + 1) from the point
  6777. */
  6778. smoothing : 1.5,
  6779. /**
  6780. * @cfg {Number} Specifies the size of point.(default size 6).Only applies when intersection is true
  6781. */
  6782. point_size : 6,
  6783. /**
  6784. * @inner {Array} the set of points to compose line segment
  6785. */
  6786. points : [],
  6787. /**
  6788. * @inner {Boolean} If true the event accord width coordinate.(default to false)
  6789. */
  6790. keep_with_coordinate : false,
  6791. /**
  6792. * @cfg {Number} Override the default as 1
  6793. */
  6794. shadow_blur : 1,
  6795. /**
  6796. * @cfg {Number} Override the default as 1
  6797. */
  6798. shadow_offsety : 1,
  6799. /**
  6800. * @inner {Number} Specifies the space between two point
  6801. */
  6802. point_space : 0,
  6803. /**
  6804. * @inner {Object} reference of coordinate
  6805. */
  6806. coordinate : null,
  6807. /**
  6808. * @cfg {Number} Specifies the valid range of x-direction.(default to 0)
  6809. */
  6810. event_range_x : 0,
  6811. /**
  6812. * @cfg {Boolean} If true tip show when the mouse must enter the valid distance of axis y.(default to false)
  6813. */
  6814. limit_y : false,
  6815. /**
  6816. * @cfg {Number} Specifies the space between the tip and point.(default to 2)
  6817. */
  6818. tip_offset : 2,
  6819. /**
  6820. * @cfg {Number} Specifies the valid range of y-direction.(default to 0)
  6821. */
  6822. event_range_y : 0
  6823. });
  6824. this.registerEvent(
  6825. /**
  6826. * @event Fires when parse this label's data.Return value will override existing.
  6827. * @paramter <link>$.LineSegment</link>#seg
  6828. * @paramter string#text the current label's text
  6829. */
  6830. 'parseText');
  6831. this.tip = null;
  6832. },
  6833. drawSegment : function() {
  6834. var _ = this._();
  6835. _.polygons.each(function(P){
  6836. _.T.polygon.apply(_.T,P);
  6837. });
  6838. _.T.shadowOn(_.get('shadow'));
  6839. _.lines.each(function(L){
  6840. _.T.lineArray.apply(_.T,L);
  6841. });
  6842. _.intersections.each(function(I){
  6843. if(_.sign_plugin){
  6844. _.sign_plugin_fn.apply(_,I);
  6845. }else{
  6846. _.T.round0.apply(_.T,I);
  6847. }
  6848. });
  6849. if (_.get('shadow')) {
  6850. _.T.shadowOff();
  6851. }
  6852. },
  6853. doDraw : function(_) {
  6854. _.drawSegment();
  6855. if (_.get('label')) {
  6856. _.labels.each(function(l){
  6857. l.draw();
  6858. });
  6859. }
  6860. },
  6861. isEventValid : function() {},
  6862. tipInvoke : function() {
  6863. var x = this.x, y = this.y, o = this.get('tip_offset'), s = this.get('point_size') + o, _ = this;
  6864. return function(w, h, m) {
  6865. var l = m.left, t = m.top;
  6866. l = ((_.tipPosition < 3 && (l - w - x - o > 0)) || (_.tipPosition > 2 && (l - w - x - o < 0))) ? l - (w + o) : l + o;
  6867. t = _.tipPosition % 2 == 0 ? t + s : t - h - s;
  6868. return {
  6869. left : l,
  6870. top : t
  6871. }
  6872. }
  6873. },
  6874. PP:function(_,p,x1,y1,x2,y2){
  6875. if(_.get('area')){
  6876. _.polygons.push([_.get('area_color')||_.get('light_color2'),0,_.get('brushsize'),0,0,_.get('area_opacity'),_.get('smooth')?p:[{x:x1,y:y1}].concat(p.concat([{x:x2,y:y2}])),_.get('smooth'),_.get('smoothing') || 1.5,[{x:x1,y:y1},{x:x2,y:y2}]]);
  6877. }
  6878. },
  6879. parse:function(_){
  6880. _.polygons = [];
  6881. _.lines = [];
  6882. _.intersections = [];
  6883. _.labels = [];
  6884. var p = _.get('points'),I = _.get('intersection'),L = !!_.get('label'), T = [],Q = false,s = _.get('smooth'), sm = _.get('smoothing') || 1.5, b = _.get('f_color'), h = _.get('brushsize'),ps=_.get('point_size');
  6885. if (I) {
  6886. var f = _.getPlugin('sign'),g=b,j = _.get('hollow_color');
  6887. _.sign_plugin = $.isFunction(f);
  6888. _.sign_plugin_fn = f;
  6889. if(_.get('hollow_inside')){
  6890. g = j;
  6891. j = b;
  6892. }
  6893. }
  6894. p.each(function(q){
  6895. q.x_ = q.x;
  6896. q.y_ = q.y;
  6897. if(!q.ignored&&L){
  6898. _.push('label.originx', q.x);
  6899. _.push('label.originy', q.y-ps/2-1);
  6900. _.push('label.text',_.fireString(_, 'parseText', [_, q.value],q.value));
  6901. $.applyIf(_.get('label'),{
  6902. textBaseline : 'bottom',
  6903. color:_.get('f_color')
  6904. });
  6905. _.labels.push(new $.Text(_.get('label'), _))
  6906. }
  6907. if(q.ignored&&Q){
  6908. _.lines.push([T, h, b, s, sm]);
  6909. _.PP(_,T,T[0].x,_.y,T[T.length-1].x,_.y);
  6910. T = [];
  6911. Q = false;
  6912. }else if(!q.ignored){
  6913. T.push(q);
  6914. Q = true;
  6915. }
  6916. if(I&&!q.ignored){
  6917. _.intersections.push(_.sign_plugin?[_.T,_.get('sign'),q,ps,q.color||g,q.hollow_color||j]:_.get('hollow')?[q, ps/2-h+1,q.color||g,h+1,q.hollow_color||j]:[q,ps/2,q.color||g]);
  6918. }
  6919. });
  6920. if(T.length){
  6921. _.lines.push([T, h, b, s, sm]);
  6922. _.PP(_,T,T[0].x,_.y,T[T.length-1].x,_.y);
  6923. }
  6924. },
  6925. doConfig : function() {
  6926. $.LineSegment.superclass.doConfig.call(this);
  6927. $.Assert.isTrue(this.get('point_space')>0,'point_space');
  6928. var _ = this._(), ps = _.get('point_size') * 3 / 2, sp = _.get('point_space'), ry = _.get('event_range_y'), rx = _
  6929. .get('event_range_x'), heap = _.get('tipInvokeHeap'), p = _.get('points'), N = _.get('name');
  6930. _.parse(_);
  6931. if (rx <= 0||rx > sp / 2) {
  6932. rx = _.push('event_range_x', sp / 2);
  6933. }
  6934. if (ry == 0) {
  6935. ry = _.push('event_range_y', ps/2);
  6936. }
  6937. if (_.get('tip.enable')) {
  6938. /**
  6939. * _ use for tip coincidence
  6940. */
  6941. _.on('mouseover', function(c,e, m) {
  6942. heap.push(_);
  6943. _.tipPosition = heap.length;
  6944. }).on('mouseout', function(c,e, m) {
  6945. heap.pop();
  6946. });
  6947. _.push('tip.invokeOffsetDynamic', true);
  6948. _.tip = new $.Tip(_.get('tip'), _);
  6949. }
  6950. var c = _.get('coordinate'), ly = _.get('limit_y'), k = _.get('keep_with_coordinate'), valid = function(p0, x, y) {
  6951. if (!p0.ignored&&Math.abs(x - (p0.x)) < rx && (!ly || (ly && Math.abs(y - (p0.y)) < ry))) {
  6952. return true;
  6953. }
  6954. return false;
  6955. }, to = function(i) {
  6956. return {
  6957. valid : true,
  6958. name : N,
  6959. value : p[i].value,
  6960. text : p[i].text,
  6961. top : p[i].y,
  6962. left : p[i].x,
  6963. i:i,
  6964. hit : true
  6965. };
  6966. };
  6967. /**
  6968. * override the default method
  6969. */
  6970. _.isEventValid = function(e) {
  6971. if (c && !c.isEventValid(e,c).valid) {
  6972. return {
  6973. valid : false
  6974. };
  6975. }
  6976. var ii = Math.floor((e.x - _.x) / sp);
  6977. if (ii < 0 || ii >= (p.length - 1)) {
  6978. ii = $.between(0, p.length - 1, ii);
  6979. if (valid(p[ii], e.x, e.y))
  6980. return to(ii);
  6981. else
  6982. return {
  6983. valid : k
  6984. };
  6985. }
  6986. /**
  6987. * calculate the pointer's position will between which two point?this function can improve location speed
  6988. */
  6989. for ( var i = ii; i <= ii + 1; i++) {
  6990. if (valid(p[i], e.x, e.y))
  6991. return to(i);
  6992. }
  6993. return {
  6994. valid : k
  6995. };
  6996. }
  6997. }
  6998. });
  6999. /**
  7000. *@end
  7001. */
  7002. /**
  7003. * @overview this class is abstract,use for config line
  7004. * @component#$.Line
  7005. * @extend#$.Chart
  7006. */
  7007. $.Line = $.extend($.Chart, {
  7008. /**
  7009. * initialize the context for the line
  7010. */
  7011. configure : function() {
  7012. /**
  7013. * invoked the super class's configuration
  7014. */
  7015. $.Line.superclass.configure.call(this);
  7016. this.type = 'line';
  7017. this.set({
  7018. /**
  7019. * @cfg {Number} Specifies the default linewidth of the canvas's context in this element.(defaults to 1)
  7020. */
  7021. brushsize : 1,
  7022. /**
  7023. * @cfg {Object} the option for coordinate
  7024. */
  7025. coordinate : {
  7026. axis : {
  7027. width : [0, 0, 2, 2]
  7028. }
  7029. },
  7030. /**
  7031. * @cfg {Object} Specifies config crosshair.(default enable to false).For details see <link>$.CrossHair</link> Note:this has a extra property named 'enable',indicate whether crosshair available(default to false)
  7032. */
  7033. crosshair : {
  7034. enable : false
  7035. },
  7036. /**
  7037. * @cfg {Function} when there has more than one linesegment,you can use tipMocker make them as a tip.(default to null)
  7038. * @paramter Array tips the array of linesegment's tip
  7039. * @paramter int the index of data
  7040. * @return String
  7041. */
  7042. tipMocker:null,
  7043. /**
  7044. * @cfg {Number(0.0~1.0)} If null,the position there will follow the points.If given a number,there has a fixed postion,0 is top,and 1 to bottom.(default to null)
  7045. */
  7046. tipMockerOffset:null,
  7047. /**
  7048. * @cfg {String} the align of scale.(default to 'left') Available value are:
  7049. * @Option 'left'
  7050. * @Option 'right'
  7051. */
  7052. scaleAlign : 'left',
  7053. /**
  7054. * @cfg {String} the align of label.(default to 'bottom') Available value are:
  7055. * @Option 'top,'bottom'
  7056. */
  7057. labelAlign : 'bottom',
  7058. /**
  7059. * @cfg {Array} the array of labels close to the axis
  7060. */
  7061. labels : [],
  7062. /**
  7063. * @inner {Number} the distance of column's bottom and text.(default to 6)
  7064. */
  7065. label_space : 6,
  7066. /**
  7067. * @inner {Boolean} if the point are proportional space.(default to true)
  7068. */
  7069. proportional_spacing : true,
  7070. /**
  7071. * @cfg {<link>$.LineSegment</link>} the option for linesegment.
  7072. */
  7073. sub_option : {},
  7074. /**
  7075. * {Object} the option for legend.
  7076. */
  7077. legend : {
  7078. sign : 'bar'
  7079. },
  7080. /**
  7081. * @cfg {<link>$.Text</link>} Specifies option of label at bottom.
  7082. */
  7083. label:{}
  7084. });
  7085. this.registerEvent(
  7086. /**
  7087. * @event Fires when parse this element'data.Return value will override existing.
  7088. * @paramter object#data the data of one linesegment
  7089. * @paramter object#v the point's value
  7090. * @paramter int#x coordinate-x of point
  7091. * @paramter int#y coordinate-y of point
  7092. * @paramter int#index the index of point
  7093. * @return Object object Detail:
  7094. * @property text the text of point
  7095. * @property x coordinate-x of point
  7096. * @property y coordinate-y of point
  7097. */
  7098. 'parsePoint');
  7099. this.lines = [];
  7100. this.components.push(this.lines);
  7101. },
  7102. /**
  7103. * @method Returns the coordinate of this element.
  7104. * @return $.Coordinate2D
  7105. */
  7106. getCoordinate : function() {
  7107. return this.coo;
  7108. },
  7109. doConfig : function() {
  7110. $.Line.superclass.doConfig.call(this);
  7111. var _ = this._(), s = _.data.length == 1;
  7112. _.lines.length = 0;
  7113. _.lines.zIndex = _.get('z_index');
  7114. var k = _.pushIf('sub_option.keep_with_coordinate',s);
  7115. if (_.get('crosshair.enable')) {
  7116. _.pushIf('crosshair.hcross', s);
  7117. _.push('crosshair.invokeOffset', function(e, m) {
  7118. /**
  7119. * TODO how fire muti line?now fire by first line
  7120. */
  7121. var r = _.lines[0].isEventValid(e);
  7122. return r.valid ? r : k;
  7123. });
  7124. }
  7125. if(!_.Combination){
  7126. _.push('coordinate.crosshair', _.get('crosshair'));
  7127. _.pushIf('coordinate.scale',[{
  7128. position : _.get('scaleAlign'),
  7129. max_scale : _.get('maxValue')
  7130. }, {
  7131. position : _.get('labelAlign'),
  7132. start_scale : 1,
  7133. scale : 1,
  7134. end_scale : _.get('maxItemSize'),
  7135. labels : _.get('labels'),
  7136. label:_.get('label')
  7137. }]);
  7138. }
  7139. /**
  7140. * use option create a coordinate
  7141. */
  7142. _.coo = $.Coordinate.coordinate_.call(_);
  7143. if(_.Combination){
  7144. _.coo.push('crosshair', _.get('crosshair'));
  7145. _.coo.doCrosshair(_.coo);
  7146. }
  7147. var vw = _.coo.valid_width,nw=vw,size=_.get('maxItemSize') - 1,M=vw / (size),ps=_.get('point_space');
  7148. if (_.get('proportional_spacing')){
  7149. if(ps&&ps<M){
  7150. nw = size*ps;
  7151. }else{
  7152. _.push('point_space',M);
  7153. }
  7154. }
  7155. _.push('sub_option.width', nw);
  7156. _.push('sub_option.height', _.coo.valid_height);
  7157. _.push('sub_option.originx', _.coo.get('x_start')+(vw-nw)/2);
  7158. _.push('sub_option.originy', _.coo.get('y_end'));
  7159. if (_.get('tip.enable')){
  7160. if(!_.mocker&&$.isFunction(_.get('tipMocker'))){
  7161. _.push('sub_option.tip.enable', false);
  7162. _.push('tip.invokeOffsetDynamic', true);
  7163. var U,x=_.coo.get(_.X),y=_.coo.get(_.Y),H=_.coo.height,f = _.get('tipMockerOffset'),r0,r,r1;
  7164. f = $.isNumber(f)?(f<0?0:(f>1?1:f)):null;
  7165. _.push('tip.invokeOffset',function(w,h,m){
  7166. if(f!=null){
  7167. m.top = y+(H-h)*f;
  7168. }else{
  7169. m.top = m.maxTop-(m.maxTop-m.minTop)/3-h;
  7170. if(h>H||y>m.top){
  7171. m.top = y;
  7172. }
  7173. }
  7174. return {
  7175. left:(m.left - w - x > 5)?m.left-w-5:m.left+5,
  7176. top:m.top
  7177. }
  7178. });
  7179. /**
  7180. * proxy the event parseText
  7181. */
  7182. var p = _.get('tip.listeners.parseText');
  7183. if(p)
  7184. delete _.get('tip.listeners').parseText;
  7185. _.mocker = new $.Custom({
  7186. eventValid:function(e){
  7187. r = _.lines[0].isEventValid(e);
  7188. r.hit = r0 != r.i;
  7189. if(r.valid){
  7190. r0 = r.i;
  7191. U = [];
  7192. _.lines.each(function(l,i){
  7193. r1 = l.isEventValid(e);
  7194. if(i==0){
  7195. r.minTop = r.maxTop = r1.top;
  7196. }else{
  7197. r.minTop = Math.min(r.minTop,r1.top);
  7198. r.maxTop = Math.max(r.maxTop,r1.top);
  7199. }
  7200. U.push(p?p(null,r1.name,r1.value,r1.text,r1.i):(r1.name+' '+r1.value));
  7201. });
  7202. r.text = _.get('tipMocker').call(_,U,r.i)||'tipMocker not return';
  7203. }
  7204. return r.valid ? r : false;
  7205. }
  7206. });
  7207. new $.Tip(_.get('tip'),_.mocker);
  7208. _.register(_.mocker);
  7209. }
  7210. }
  7211. _.pushIf('sub_option.area_opacity',_.get('area_opacity'));
  7212. }
  7213. });
  7214. /**
  7215. * @end
  7216. */
  7217. /**
  7218. * @overview this component will draw a line2d chart.
  7219. * @component#@chart#$.LineBasic2D
  7220. * @extend#$.Line
  7221. */
  7222. $.LineBasic2D = $.extend($.Line, {
  7223. /**
  7224. * initialize the context for the LineBasic2D
  7225. */
  7226. configure : function() {
  7227. /**
  7228. * invoked the super class's configuration
  7229. */
  7230. $.LineBasic2D.superclass.configure.call(this);
  7231. this.type = 'basicline2d';
  7232. this.tipInvokeHeap = [];
  7233. },
  7234. doAnimation : function(t, d,_) {
  7235. _.lines.each(function(l){
  7236. l.get('points').each(function(p){
  7237. p.y = l.y - Math.ceil(_.animationArithmetic(t, 0, l.y - p.y_, d));
  7238. });
  7239. l.drawSegment();
  7240. });
  7241. },
  7242. doConfig : function() {
  7243. $.LineBasic2D.superclass.doConfig.call(this);
  7244. var _ = this._();
  7245. /**
  7246. * get the max/min scale of this coordinate for calculated the height
  7247. */
  7248. var S, H = _.coo.valid_height, sp = _.get('point_space'), points, x, y,
  7249. ox = _.get('sub_option.originx'), oy, p;
  7250. _.push('sub_option.tip.showType', 'follow');
  7251. _.push('sub_option.coordinate', _.coo);
  7252. _.push('sub_option.tipInvokeHeap', _.tipInvokeHeap);
  7253. _.push('sub_option.point_space', sp);
  7254. _.data.each(function(d, i) {
  7255. S = _.coo.getScale(d.scaleAlign||_.get('scaleAlign'));
  7256. oy = _.get('sub_option.originy')- S.basic*H;
  7257. points = [];
  7258. d.value.each(function(v, j) {
  7259. x = sp * j;
  7260. y = (v - S.start) * H / S.distance;
  7261. p = {
  7262. x : ox + x,
  7263. y : oy - y,
  7264. value : v,
  7265. text : d.name+' '+v
  7266. };
  7267. $.merge(p, _.fireEvent(_, 'parsePoint', [d, v, x, y, j,S]));
  7268. points.push(p);
  7269. }, _);
  7270. /**
  7271. * merge the option
  7272. */
  7273. $.merge(_.get('sub_option'),d);
  7274. _.push('sub_option.points', points);
  7275. _.push('sub_option.brushsize', d.linewidth || d.line_width);
  7276. _.lines.push(new $.LineSegment(_.get('sub_option'), _));
  7277. }, this);
  7278. }
  7279. });
  7280. $.register('LineBasic2D');
  7281. /**
  7282. * @end
  7283. */
  7284. /**
  7285. * @overview the area2d componment
  7286. * @component#@chart#$.Area2D
  7287. * @extend#$.LineBasic2D
  7288. */
  7289. $.Area2D = $.extend($.LineBasic2D, {
  7290. /**
  7291. * initialize the context for the area2d
  7292. */
  7293. configure : function() {
  7294. /**
  7295. * invoked the super class's configuration
  7296. */
  7297. $.Area2D.superclass.configure.call(this);
  7298. this.type = 'area2d';
  7299. this.set({
  7300. /**
  7301. * @cfg {Float} Specifies the opacity of this area.(default to 0.3)
  7302. */
  7303. area_opacity : 0.3
  7304. });
  7305. },
  7306. doConfig : function() {
  7307. /**
  7308. * must apply the area's config before
  7309. */
  7310. this.push('sub_option.area', true);
  7311. $.Area2D.superclass.doConfig.call(this);
  7312. }
  7313. });
  7314. $.register('Area2D');
  7315. /**
  7316. * @end
  7317. */
  7318. })(iChart);