PageRenderTime 60ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/slippy-chart.shrink.js

https://bitbucket.org/kelvin/slippy-chart
JavaScript | 2155 lines | 2154 code | 1 blank | 0 comment | 166 complexity | db91e90cd13dfddce35d96110aa6c145 MD5 | raw file
  1. (function($){
  2. var _1=this,_2=_1.document,_3,_4=_1.SlippyChart,_5=_1.$c,$c=_1.$c=SlippyChart=_1.SlippyChart={};
  3. var _6=function(el,_7,fn){
  4. if(_1.attachEvent){
  5. _6=function(el,_8,fn){
  6. el.attachEvent("on"+_8,fn);
  7. };
  8. }else{
  9. _6=function(el,_9,fn){
  10. if(_9=="mousewheel"){
  11. _9="DOMMouseScroll";
  12. }
  13. el.addEventListener(_9,fn,false);
  14. };
  15. }
  16. _6(el,_7,fn);
  17. };
  18. var _a=function(el,_b,fn){
  19. if(_1.detachEvent){
  20. _a=function(el,_c,fn){
  21. el.detachEvent("on"+_c,fn);
  22. };
  23. }else{
  24. _a=function(el,_d,fn){
  25. el.removeEventListener(_d,fn,false);
  26. };
  27. }
  28. _a(el,_b,fn);
  29. };
  30. var _e=function(e){
  31. e=e?e:_1.event;
  32. if(e.stopPropagation){
  33. e.stopPropagation();
  34. }
  35. if(e.preventDefault){
  36. e.preventDefault();
  37. }
  38. e["cancelBubble"]=true;
  39. e["cancel"]=true;
  40. e["returnValue"]=false;
  41. return false;
  42. };
  43. var _f=function(_10,_11){
  44. var len=_11.length||0;
  45. var res=[];
  46. res.length=len;
  47. for(var i=len-1;i>=0;i--){
  48. res[i]=_10(_11[i]);
  49. }
  50. return res;
  51. };
  52. var _12=function(_13,_14,_15){
  53. var len=_14.length||0;
  54. if(len===0){
  55. return _15;
  56. }
  57. var i=0;
  58. if(typeof _15==="undefined"){
  59. _15=_14[i++];
  60. }
  61. for(;i<len;i++){
  62. _15=_13(_15,_14[i]);
  63. }
  64. return _15;
  65. };
  66. var _16=function(_17,_18){
  67. var len=_18.length||0;
  68. var res=[];
  69. for(var i=len-1;i>=0;i--){
  70. if(_17(_18[i])){
  71. res.push(_18[i]);
  72. }
  73. }
  74. return res.reverse();
  75. };
  76. var _19=function(){
  77. var _1a=arguments.length||0;
  78. if(_1a===0){
  79. return [];
  80. }
  81. var len=arguments[0].length||0;
  82. var res=[];
  83. res.length=len;
  84. for(var i=len-1;i>=0;i--){
  85. res[i]=_f(function(x){
  86. return x[i];
  87. },arguments);
  88. }
  89. return res;
  90. };
  91. var _1b=function(_1c,_1d){
  92. var low=0;
  93. var _1e=_1c.length-1;
  94. while(low<=_1e){
  95. var mid=Math.floor((low+_1e)/2);
  96. var _1f=_1c[mid];
  97. if(_1f<_1d){
  98. low=mid+1;
  99. }else{
  100. if(_1f>_1d){
  101. _1e=mid-1;
  102. }else{
  103. return mid;
  104. }
  105. }
  106. }
  107. return -(low+1);
  108. };
  109. var _20=function(_21,_22){
  110. var low=0;
  111. var _23=_21.length-1;
  112. while(low<=_23){
  113. var mid=Math.floor((low+_23)/2);
  114. var _24=_21[mid];
  115. if(_24<_22){
  116. low=mid+1;
  117. }else{
  118. if(_24>_22){
  119. _23=mid-1;
  120. }else{
  121. return _21.slice(mid);
  122. }
  123. }
  124. }
  125. return _21.slice(low);
  126. };
  127. var _25=function(_26,_27){
  128. var low=0;
  129. var _28=_26.length-1;
  130. while(low<=_28){
  131. var mid=Math.floor((low+_28)/2);
  132. var _29=_26[mid];
  133. if(_29<_27){
  134. low=mid+1;
  135. }else{
  136. if(_29>_27){
  137. _28=mid-1;
  138. }else{
  139. return _26.slice(0,mid+1);
  140. }
  141. }
  142. }
  143. return _26.slice(0,_28+1);
  144. };
  145. var _2a=function(_2b,_2c,_2d){
  146. var low,_2e,mid,_2f,_30,_31;
  147. low=0;
  148. _2e=_2b.length-1;
  149. while(low<=_2e){
  150. mid=Math.floor((low+_2e)/2);
  151. _2f=_2b[mid];
  152. if(_2f<_2c){
  153. low=mid+1;
  154. }else{
  155. if(_2f>_2c){
  156. _2e=mid-1;
  157. }else{
  158. low=mid;
  159. break;
  160. }
  161. }
  162. }
  163. _30=low;
  164. _2e=_2b.length-1;
  165. while(low<=_2e){
  166. mid=Math.floor((low+_2e)/2);
  167. _2f=_2b[mid];
  168. if(_2f<_2d){
  169. low=mid+1;
  170. }else{
  171. if(_2f>_2d){
  172. _2e=mid-1;
  173. }else{
  174. _2e=mid;
  175. break;
  176. }
  177. }
  178. }
  179. _31=_2e+1;
  180. return _2b.slice(_30,_31);
  181. };
  182. var _32=function(){
  183. this.first=null;
  184. this.last=null;
  185. this.length=0;
  186. };
  187. var _33=function(_34){
  188. this.prev=null;
  189. this.next=null;
  190. this.data=_34;
  191. };
  192. _32.prototype.prepend=function(_35){
  193. if(this.first===null){
  194. this.first=_35;
  195. this.last=_35;
  196. }else{
  197. _35.prev=null;
  198. _35.next=this.first;
  199. this.first.prev=_35;
  200. this.first=_35;
  201. }
  202. this.length++;
  203. };
  204. _32.prototype.append=function(_36){
  205. if(this.first===null){
  206. this.first=_36;
  207. this.last=_36;
  208. }else{
  209. _36.prev=this.last;
  210. _36.next=null;
  211. this.last.next=_36;
  212. this.last=_36;
  213. }
  214. this.length++;
  215. };
  216. _32.prototype.remove=function(_37){
  217. if(this.first==this.last){
  218. this.first=null;
  219. this.last=null;
  220. }else{
  221. if(_37.prev){
  222. _37.prev.next=_37.next;
  223. }
  224. if(_37.next){
  225. _37.next.prev=_37.prev;
  226. }
  227. if(_37==this.first){
  228. this.first=_37.next;
  229. }
  230. if(_37==this.last){
  231. this.last=_37.prev;
  232. }
  233. }
  234. this.length--;
  235. _37.prev=null;
  236. _37.next=null;
  237. };
  238. var _38=function(){
  239. this.map={};
  240. this.list=new _32();
  241. };
  242. _38.prototype.add=function(key,val){
  243. if(typeof this.map[key]!=="undefined"){
  244. return;
  245. }
  246. var _39=new _33(val);
  247. this.map[key]=_39;
  248. this.list.append(_39);
  249. };
  250. _38.prototype.remove=function(key){
  251. if(typeof this.map[key]==="undefined"){
  252. return;
  253. }
  254. this.list.remove(this.map[key]);
  255. delete (this.map[key]);
  256. };
  257. var _3a=function(){
  258. this.channels={};
  259. };
  260. _3a.prototype={uid_counter:0};
  261. _3a.prototype.publish=function(_3b){
  262. setTimeout((function(_3c){
  263. var _3d=arguments;
  264. var _3e=this.channels;
  265. return function(){
  266. var _3f=Array.prototype.slice.call(_3d,1);
  267. var _40=_3e[_3c]&&_3e[_3c].list.first;
  268. while(_40){
  269. var _41=_40.data;
  270. setTimeout((function(_42,_43){
  271. return function(){
  272. _42.apply(this,_43);
  273. };
  274. }).call(this,_41,_3f),0);
  275. _40=_40.next;
  276. }
  277. };
  278. }).apply(this,arguments),0);
  279. };
  280. _3a.prototype.subscribe=function(_44,_45,_46){
  281. if(typeof this.channels[_44]==="undefined"){
  282. this.channels[_44]=new _38();
  283. }
  284. var _47=Array.prototype.slice.call(arguments,3);
  285. if(typeof _45._psb_uid=="undefined"){
  286. _45._psb_uid=++this.uid_counter;
  287. }
  288. var key=_45._psb_uid+":"+_46+":"+_47;
  289. this.channels[_44].add(key,function(){
  290. var _48=Array.prototype.slice.call(arguments,0);
  291. _45[_46].apply((_45||_1),_47.concat(_48));
  292. });
  293. };
  294. _3a.prototype.unsubscribe=function(_49,_4a,_4b){
  295. if(typeof this.channels[_49]==="undefined"){
  296. return;
  297. }
  298. var _4c=Array.prototype.slice.call(arguments,3);
  299. var key=_4a._psb_uid+":"+_4b+":"+_4c;
  300. this.channels[_49].remove(key);
  301. };
  302. function _4d(_4e){
  303. _4e._calc=function(_4f){
  304. return _4e.lineWidth%2?Math.floor(_4f)+0.5:Math.floor(_4f);
  305. };
  306. _4e._moveTo=function(x_,y_){
  307. _4e.moveTo(_4e._calc(x_),_4e._calc(y_));
  308. };
  309. _4e._lineTo=function(x_,y_){
  310. _4e.lineTo(_4e._calc(x_),_4e._calc(y_));
  311. };
  312. };
  313. var _50=[[60,1,15],[60*5,3,12],[60*30,2,12],[60*60*3,2,16],[60*60*12,4,16]];
  314. var _51=[[60,1,20],[60*5,4,18],[60*30,3,18],[60*60*3,3,20],[60*60*12,5,31]];
  315. var _52=[[60,1,30],[60*5,6,30],[60*30,5,30],[60*60*3,5,32],[60*60*12,8,31]];
  316. var _53=[[60,1,40],[60*5,8,42],[60*30,7,42],[60*60*3,7,40],[60*60*12,10,31]];
  317. var _54=[[60,1,60],[60*5,12,60],[60*30,10,60],[60*60*3,10,60],[60*60*12,15,31]];
  318. var _55=[[60,1,120],[60*5,24,120],[60*30,20,120],[60*60*3,20,120],[60*60*12,30,31]];
  319. var _56=function(_57){
  320. var _58=_57,_59=0,_5a=0,_5b=0,_5c=0,_5d=0,_5e=0,_5f=[],_60=[];
  321. this.model=function(){
  322. return _58;
  323. };
  324. this.min_time=function(){
  325. return _59;
  326. };
  327. this.max_time=function(){
  328. return _5a;
  329. };
  330. this.cache=function(){
  331. return _5f;
  332. };
  333. function _61(_62,_63){
  334. _59=_62;
  335. _5a=_63;
  336. _5b=_56.prototype.bucket_size;
  337. _5c=_56.prototype.min_buckets;
  338. _5d=_56.prototype.max_buckets;
  339. _5e=_56.prototype.bucket_ttl;
  340. _60.length=_5b;
  341. for(var i=0;i<_58.zoom_schema().length;i++){
  342. _5f[i]={};
  343. }
  344. for(var i=0;i<4;i++){
  345. var _64=[];
  346. _64.length=_5b;
  347. var _65=70-i*10;
  348. for(var j=0;j<_5b;j++){
  349. if(i==2){
  350. _64[j]=50;
  351. }else{
  352. _64[j]=_65+Math.random()*30;
  353. }
  354. }
  355. _5f[0][i]=_64;
  356. }
  357. var _66=_58.zoom_schema();
  358. if(_66.length>=2){
  359. __sum=function(x,y){
  360. return (x||0)+(y||0);
  361. };
  362. _sum=function(_67){
  363. return _12(__sum,_67,0);
  364. };
  365. _5f[1][0]=[];
  366. _5f[1][0].length=_5b;
  367. var k=0;
  368. for(i=0;i<4;i++){
  369. for(j=0;j<_5b;j+=5){
  370. _5f[1][0][k++]=_sum(_5f[0][i].slice(j,j+5))/5;
  371. }
  372. }
  373. var len=k;
  374. }
  375. if(_66.length>=3){
  376. _5f[2][0]=[];
  377. _5f[2][0].length=_5b;
  378. k=0;
  379. for(i=0;i<len;i+=6){
  380. _5f[2][0][k++]=_sum(_5f[1][0].slice(i,i+6))/6;
  381. }
  382. len=k;
  383. }
  384. if(_66.length>=4){
  385. _5f[3][0]=[];
  386. _5f[3][0].length=_5b;
  387. k=0;
  388. for(i=0;i<len;i+=6){
  389. _5f[3][0][k++]=_sum(_5f[2][0].slice(i,i+6))/6;
  390. }
  391. len=k;
  392. }
  393. if(_66.length>=5){
  394. _5f[4][0]=[];
  395. _5f[4][0].length=_5b;
  396. k=0;
  397. for(i=0;i<len;i+=4){
  398. _5f[4][0][k++]=_sum(_5f[3][0].slice(i,i+4))/4;
  399. }
  400. }
  401. var _68=_58.broker();
  402. _68.subscribe("/cache/flush",this,"_flush");
  403. };
  404. this.init=_61;
  405. function _69(_6a,_6b,_6c){
  406. var _6d=_5f[_6a];
  407. var _6e=Math.floor(_6b/_5b);
  408. var _6f=Math.floor(_6c/_5b);
  409. _6b-=_6e*_5b;
  410. _6c-=_6f*_5b;
  411. _6c+=1;
  412. if(_6e===_6f){
  413. var _70=_6d[_6e];
  414. if(!_70){
  415. _70=_60;
  416. }
  417. return _70.slice(_6b,_6c);
  418. }
  419. var _71=_6d[_6e];
  420. if(!_71){
  421. _71=_60;
  422. }
  423. var _72=_6d[_6f];
  424. if(!_72){
  425. _72=_60;
  426. }
  427. var _73=_71.slice(_6b,_5b);
  428. var _74=_72.slice(0,_6c);
  429. return _73.concat(_74);
  430. };
  431. this.fetch=_69;
  432. function _75(){
  433. };
  434. this._flush=_75;
  435. };
  436. _56.prototype={bucket_size:60*24,min_buckets:10,max_buckets:100,bucket_ttl:60*1000};
  437. var _76=function(_77,_78){
  438. var _79=_77,_7a=_78,_7b=_79.broker(),_7c=0,_7d=0,_7e=0,_7f=[],_80=_76.prototype.upkeep_interval;
  439. this.parent=function(){
  440. return _79;
  441. };
  442. this.zoom_schema=function(){
  443. return _7a;
  444. };
  445. this.zoom_level=function(){
  446. return _7a[_79.zoom_scale()];
  447. };
  448. this.zoom_delta=function(){
  449. return _7a[_79.zoom_scale()][0];
  450. };
  451. this.broker=function(){
  452. return _7b;
  453. };
  454. this.min_time=function(){
  455. return _7c;
  456. };
  457. this.max_time=function(){
  458. return _7d;
  459. };
  460. this._time_range=function(){
  461. return _7e;
  462. };
  463. this.data=function(){
  464. return _7f;
  465. };
  466. function _81(_82,_83,_84,_85){
  467. _7c=_82;
  468. _7d=_83;
  469. _7e=_7d-_7c;
  470. var _86=_84/_85;
  471. for(var i=0;i<_7a.length;i++){
  472. var _87=_7a[i];
  473. if(_7e<(_87[0]*_84)){
  474. _7a.length=i+1;
  475. _max_points=Math.floor(_7e/_87[0]);
  476. _7a[i][2]=Math.ceil(_max_points/_86);
  477. break;
  478. }
  479. }
  480. var _88=new _56(this);
  481. _88.init(_7c,_7d);
  482. _7f[0]=_88;
  483. setTimeout(_89,_80);
  484. };
  485. this.init=_81;
  486. function _8a(_8b,_8c,_8d){
  487. var _8e=_8c+_8d;
  488. var _8f=[];
  489. for(var i=_7f.length-1;i>=0;i--){
  490. _8f.push(_7f[i].fetch(_8b,_8c,_8e));
  491. }
  492. _8f.reverse();
  493. return _8f;
  494. };
  495. this.fetch=_8a;
  496. function _89(){
  497. _7b.publish("/cache/flush");
  498. setTimeout(_89,_80);
  499. };
  500. };
  501. _76.prototype={upkeep_interval:60*1000};
  502. var _90=1.25;
  503. if($.browser.msie){
  504. _90=1.6;
  505. }
  506. var _91=16;
  507. var _92=0;
  508. var _93="rgb(194,218,241)";
  509. if($.browser.msie){
  510. _92=-1;
  511. }
  512. var _94=5;
  513. var _95=function(_96,_97){
  514. var _98=_96,_99=_98.model(),_9a=0,_9b=0,_9c=_97,_9d=Math.floor(_9c/2),_9e=0,_9f=0,_a0=null,_a1=null,_a2=null,c=null,_a3=null,_a4=[],_a5=0,_a6=0;
  515. this.parent=function(){
  516. return _98;
  517. };
  518. this.time_offset=function(){
  519. return _9a;
  520. };
  521. this._data_offset=function(){
  522. return _9b;
  523. };
  524. this.container=function(){
  525. return _a0;
  526. };
  527. this.canvas=function(){
  528. return _a2;
  529. };
  530. this.offset=function(){
  531. return parseInt(_a1.left,10);
  532. };
  533. this.c=function(){
  534. return c;
  535. };
  536. this.tape=function(){
  537. return _a3;
  538. };
  539. this._data=function(){
  540. return _a4;
  541. };
  542. this._min_y=function(){
  543. return _a5;
  544. };
  545. this._max_y=function(){
  546. return _a6;
  547. };
  548. function _a7(){
  549. _9e=_98.draw_height();
  550. _9f=_98.chart_height();
  551. _a0=$(["<div","style=\"","position:\tabsolute;","left:\t\t0px;","top:\t\t0px;","z-index:\t0;","width:\t\t"+_9c+"px;","height:\t"+_9e+"px;","\"></div>"].join(" ")).appendTo(_98.container());
  552. _a1=_a0[0].style;
  553. _a2=_2.createElement("canvas");
  554. _a2.width=_9c;
  555. _a2.height=_9f;
  556. var _a8=$(_a2);
  557. _a8.css("position","absolute");
  558. _a8.css("left","0px");
  559. _a8.css("top","0px");
  560. _a8.css("z-index","0");
  561. _a8.css("width",_9c+"px");
  562. _a8.css("height",_9f+"px");
  563. _a8.appendTo(_a0);
  564. if($.browser.msie){
  565. _a2=_1.G_vmlCanvasManager.initElement(_a2);
  566. }
  567. c=_a2.getContext("2d");
  568. _4d(c);
  569. if($.browser.msie&&c.setTransform){
  570. c.setTransform(1,0,0,-1,0,_9f);
  571. }
  572. _a3=$(["<div","style=\"","position:\t\tabsolute;","left:\t\t\t0px;","top:\t\t\t"+_9f+"px;","z-index:\t\t0;","width:\t\t\t"+_9c+"px;","height:\t\t"+(_9e-_9f)+"px;","text-align:\tleft;","\"></div>"].join(" ")).appendTo(_a0);
  573. var _a9=_98.broker();
  574. _a9.subscribe("/pane/translate",this,"translate");
  575. _a9.subscribe("/pane/redraw",this,"_draw");
  576. };
  577. this.init=_a7;
  578. function _aa(_ab){
  579. _a1.left=(parseInt(_a1.left,10)+_ab)+"px";
  580. };
  581. this.translate=_aa;
  582. function _ac(_ad){
  583. if($.browser.msie&&c.setTransform){
  584. _ac=function(_ae){
  585. c.lineWidth=1;
  586. c.beginPath();
  587. c.strokeStyle="rgb(200,200,200)";
  588. c._moveTo(_ae,0);
  589. c._lineTo(_ae,_9f);
  590. c.stroke();
  591. c.beginPath();
  592. c.strokeStyle="rgb(100,100,100)";
  593. c._moveTo(_ae,0);
  594. c._lineTo(_ae,_94);
  595. c.stroke();
  596. };
  597. }else{
  598. _ac=function(_af){
  599. c.lineWidth=1;
  600. c.beginPath();
  601. c.strokeStyle="rgb(200,200,200)";
  602. c._moveTo(_af,0);
  603. c._lineTo(_af,_9f);
  604. c.stroke();
  605. c.beginPath();
  606. c.strokeStyle="rgb(100,100,100)";
  607. c._moveTo(_af,_9f);
  608. var _b0=_9f-_94;
  609. c._lineTo(_af,_b0);
  610. c.stroke();
  611. };
  612. }
  613. return _ac(_ad);
  614. };
  615. this.__grid_x=_ac;
  616. function _b1(_b2){
  617. if($.browser.msie&&c.setTransform){
  618. _b1=function(_b3){
  619. c.lineWidth=1;
  620. c.strokeStyle="rgb(200,200,200)";
  621. for(var i=_b3.length-1;i>=0;i--){
  622. c.beginPath();
  623. var y=_b3[i];
  624. c._moveTo(0,y);
  625. c._lineTo(_9c,y);
  626. c.stroke();
  627. }
  628. };
  629. }else{
  630. _b1=function(_b4){
  631. c.lineWidth=1;
  632. c.strokeStyle="rgb(200,200,200)";
  633. for(var i=_b4.length-1;i>=0;i--){
  634. c.beginPath();
  635. var _b5=_9f-_b4[i];
  636. c._moveTo(0,_b5);
  637. c._lineTo(_9c,_b5);
  638. c.stroke();
  639. }
  640. };
  641. }
  642. return _b1(_b2);
  643. };
  644. this.__grid_y=_b1;
  645. function _b6(_b7,_b8,_b9){
  646. if($.browser.msie&&c.setTransform){
  647. _b6=function(_ba,_bb,_bc){
  648. c.lineWidth=_90;
  649. c.strokeStyle="rgb(25,106,227)";
  650. c.lineJoin="miter";
  651. c.beginPath();
  652. c._moveTo(-1*_ba,(_bc[-1]||0)*_bb);
  653. c._lineTo(0,(_bc[0]||0)*_bb);
  654. var i=1;
  655. var _bd=_bc.length-2;
  656. var n=_bd%8;
  657. while(n--){
  658. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  659. i++;
  660. }
  661. n=parseInt(_bd/8,10);
  662. while(n--){
  663. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  664. i++;
  665. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  666. i++;
  667. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  668. i++;
  669. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  670. i++;
  671. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  672. i++;
  673. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  674. i++;
  675. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  676. i++;
  677. c._lineTo(i*_ba,(_bc[i]||0)*_bb);
  678. i++;
  679. }
  680. c._lineTo(_9c,(_bc[_bc.length-1]||0)*_bb);
  681. c._lineTo(_9c+1,(_bc[_bc.length-1]||0)*_bb);
  682. c.stroke();
  683. c._lineTo(_9c+1,0);
  684. c._lineTo(-1*_ba,0);
  685. c.fillStyle="rgba(183,220,255, 0.4)";
  686. c.fill();
  687. };
  688. }else{
  689. _b6=function(_be,_bf,_c0){
  690. c.lineWidth=_90;
  691. c.strokeStyle="rgb(25,106,227)";
  692. c.lineJoin="miter";
  693. c.beginPath();
  694. c._moveTo(-1*_be,_9f-(_c0[-1]||0)*_bf);
  695. c._lineTo(0,_9f-(_c0[0]||0)*_bf);
  696. var i=1;
  697. var _c1=_c0.length-2;
  698. var n=_c1%8;
  699. while(n--){
  700. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  701. i++;
  702. }
  703. n=parseInt(_c1/8,10);
  704. while(n--){
  705. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  706. i++;
  707. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  708. i++;
  709. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  710. i++;
  711. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  712. i++;
  713. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  714. i++;
  715. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  716. i++;
  717. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  718. i++;
  719. c._lineTo(i*_be,_9f-(_c0[i]||0)*_bf);
  720. i++;
  721. }
  722. c._lineTo(_9c,_9f-(_c0[_c0.length-1]||0)*_bf);
  723. c._lineTo(_9c+1,_9f-(_c0[_c0.length-1]||0)*_bf);
  724. c.stroke();
  725. c.fillStyle="rgba(183,220,255, 0.4)";
  726. c._lineTo(_9c+1,_9f);
  727. c._lineTo(-1*_be,_9f);
  728. c.fill();
  729. };
  730. }
  731. return _b6(_b7,_b8,_b9);
  732. };
  733. this.__plot=_b6;
  734. function _c2(_c3,_c4){
  735. _a3.append(["<div","class=\"tape-tick\"","style=\"","position:\tabsolute;","left:\t\t"+_c3+"px;","top:\t\t0px;","z-index:\t0;","width:\t\t"+_9c+"px;","\">"+_c4+"</div>"].join(" "));
  736. };
  737. this.__tape_marker=_c2;
  738. function _c5(){
  739. _a4=_99.fetch(_98.zoom_scale(),_9b-1,_98._pane_period()+1);
  740. if(_a4.length===0){
  741. _a5=0;
  742. _a6=0;
  743. return;
  744. }
  745. var i,j,_c6;
  746. for(i=_a4.length-1;i>=0;i--){
  747. _c6=_a4[i];
  748. _c6[-1]=_c6.shift();
  749. }
  750. _a5=_a6=_a4[0][0]||0;
  751. for(i=_a4.length-1;i>=0;i--){
  752. _c6=_a4[i];
  753. for(j=_c6.length-1;j>=0;j--){
  754. var _c7=_c6[j]||0;
  755. _a5=Math.min(_a5,_c7);
  756. _a6=Math.max(_a6,_c7);
  757. }
  758. }
  759. };
  760. function _c8(){
  761. c.clearRect(0,0,_9c,_9e);
  762. _a3.empty();
  763. var _c9=_98._x_scale();
  764. var _ca=_98._y_scale();
  765. var _cb=_98._x_tick()(_9a);
  766. var _cc=(_cb[0]/_99.zoom_delta())*_c9;
  767. if(_cc<_9c){
  768. _ac(_cc);
  769. _c2(_cc,_cb[1]);
  770. }
  771. _b1(_98._y_intervals());
  772. for(var i=_a4.length-1;i>=0;i--){
  773. _b6(_c9,_ca,_a4[i]);
  774. }
  775. };
  776. this._draw=_c8;
  777. function _cd(_ce,_cf){
  778. _9b=_ce;
  779. _a1.left=_cf+"px";
  780. _9a=_99.min_time()+_9b*_99.zoom_delta();
  781. _c5();
  782. };
  783. this._reset=_cd;
  784. function _d0(_d1,_d2){
  785. _cd(_d1,_d2);
  786. _c8();
  787. };
  788. this.reset=_d0;
  789. function _d3(_d4,_d5){
  790. if(_a4.length===0){
  791. return [0,0];
  792. }
  793. var min,max;
  794. min=max=_a4[0][_d4]||0;
  795. for(var i=_a4.length-1;i>=0;i--){
  796. var _d6=_a4[i].slice(_d4,_d5);
  797. for(var j=_d6.length-1;j>=0;j--){
  798. var _d7=_d6[j]||0;
  799. min=Math.min(min,_d7);
  800. max=Math.max(max,_d7);
  801. }
  802. }
  803. return [min,max];
  804. };
  805. this.range_min_max_y=_d3;
  806. };
  807. NAV_HEIGHT=75;
  808. NAV_BUTTON_HEIGHT=13;
  809. NAV_BUTTON_WIDTH=16;
  810. NAV_SCROLL_RATE=1000*0.1;
  811. NAV_SCROLL_SPEED=50;
  812. NAV_SCROLL_MIN_WIDTH=20;
  813. NAV_SCROLL_MID_THRESHOLD=60;
  814. NAV_OVERVIEW_TOP_OFFSET=5;
  815. NAV_OVERVIEW_SCALE_FACTOR=1.1;
  816. NAV_RANGE_OFFSET=-9;
  817. NAV_RANGE_WIDTH=13;
  818. NAV_RANGE_CENTER_THRESHOLD=13;
  819. NAV_RANGE_CENTER_OFFSET=-8;
  820. var _d8=function(_d9){
  821. var _da=_d9,_db=_da.model(),_dc=_da.broker(),_dd=0,_de=0,_df=null,_e0=null,_e1=null,_e2=null,_e3=null,_e4=0,_e5=null,oc=null,_e6=null,_e7=null,pc=null,_e8=[],_e9=0,_ea=0,_eb=null,_ec=null,_ed=0,_ee=null,_ef=null,_f0=null,_f1=1,_f2=null,_f3=null,_f4=null,_f5=null,_f6=false,_f7=false;
  822. this.parent=function(){
  823. return _da;
  824. };
  825. this.model=function(){
  826. return _db;
  827. };
  828. this.width=function(){
  829. return _dd;
  830. };
  831. this.height=function(){
  832. return _de;
  833. };
  834. this.container=function(){
  835. return _df;
  836. };
  837. this.zoom_level=function(){
  838. return _e3;
  839. };
  840. this.overview_left=function(){
  841. return _e4;
  842. };
  843. this.overview=function(){
  844. return _e5;
  845. };
  846. this.oc=function(){
  847. return oc;
  848. };
  849. this.preview=function(){
  850. return _e6;
  851. };
  852. this._preview=function(){
  853. return _e7;
  854. };
  855. this.pc=function(){
  856. return pc;
  857. };
  858. this._data=function(){
  859. return _e8;
  860. };
  861. this._x_scale=function(){
  862. return _e9;
  863. };
  864. this._y_scale=function(){
  865. return _ea;
  866. };
  867. this.viewer=function(){
  868. return _eb;
  869. };
  870. this._viewer=function(){
  871. return _ec;
  872. };
  873. this.viewer_width=function(){
  874. return _ed;
  875. };
  876. this.slider=function(){
  877. return _ee;
  878. };
  879. this._slider=function(){
  880. return _ef;
  881. };
  882. this.slider_middle=function(){
  883. return _f0;
  884. };
  885. this.drag_modifier=function(){
  886. return _f1;
  887. };
  888. this.range_min=function(){
  889. return _f2;
  890. };
  891. this._range_min=function(){
  892. return _f3;
  893. };
  894. this.range_max=function(){
  895. return _f4;
  896. };
  897. this._range_max=function(){
  898. return _f5;
  899. };
  900. function _f8(_f9,_fa,_fb,_fc){
  901. _f9.clearRect(0,0,_e5.width,_e5.height);
  902. _f9.lineWidth=1;
  903. _f9.strokeStyle=_fa;
  904. _f9.lineJoin="round";
  905. _f9.beginPath();
  906. _f9._moveTo(_e5.width,_e5.height-(_e8[_e8.length-2]||0)*_ea);
  907. for(var i=_e8.length-3;i>0;i--){
  908. _f9._lineTo(i*_e9,_e5.height-(_e8[i]||0)*_ea);
  909. }
  910. _f9._lineTo(0,_e5.height-(_e8[0]||0)*_ea);
  911. _f9.stroke();
  912. _f9.fillStyle=_fb;
  913. _f9._lineTo(0,_e5.height);
  914. _f9._lineTo(_e5.width,_e5.height);
  915. _f9.fill();
  916. _f9.lineWidth=1;
  917. _f9.strokeStyle=_fc;
  918. _f9.lineJoin="round";
  919. _f9.beginPath();
  920. _f9.moveTo(0,_e5.height);
  921. _f9.lineTo(0,0);
  922. _f9.lineTo(_e5.width,0);
  923. _f9.lineTo(_e5.width,_e5.height);
  924. _f9.stroke();
  925. };
  926. function _fd(_fe,_ff,_100,top_,_101){
  927. _dd=_ff;
  928. _de=_100;
  929. _df=$(["<div","style=\"","position:\t\tabsolute;","left:\t\t\t"+_101+"px;","top:\t\t\t"+top_+"px;","width:\t\t\t"+_dd+"px;","height:\t\t"+_de+"px;","\"></div>"].join(" ")).appendTo(_fe);
  930. _e0=$(["<div","class=\"nav-left-unsel\"","style=\"","position:\tabsolute;","overflow:\thidden;","left:\t\t"+(-_146)+"px;","top:\t\t"+(NAV_HEIGHT-NAV_BUTTON_HEIGHT)+"px;","width:\t \t"+NAV_BUTTON_WIDTH+"px;","height:\t"+NAV_BUTTON_HEIGHT+"px;","\"></div>"].join(" ")).appendTo(_df);
  931. _e1=$(["<div","class=\"nav-unsel nav-right-unsel\"","style=\"","position:\tabsolute;","overflow:\thidden;","left:\t\t"+(-_146+NAV_BUTTON_WIDTH)+"px;","top:\t\t"+(NAV_HEIGHT-NAV_BUTTON_HEIGHT)+"px;","width:\t\t"+NAV_BUTTON_WIDTH+"px;","height:\t"+NAV_BUTTON_HEIGHT+"px;","\"></div>"].join(" ")).appendTo(_df);
  932. _e2=$(["<div","style=\"","position:\t\tabsolute;","left:\t\t\t"+(_146+2*NAV_BUTTON_WIDTH)+"px;","top:\t\t\t"+(NAV_HEIGHT-NAV_BUTTON_HEIGHT)+"px;","width:\t\t\t"+(_dd-_146-2*NAV_BUTTON_WIDTH)+"px;","height:\t\t"+(NAV_BUTTON_HEIGHT)+"px;","font-size:\t\t0px;","border-top:\t1px solid #aaa;","border-right:\t1px solid #aaa;","border-bottom:\t1px solid #aaa;","\"></div>"].join(" ")).appendTo(_df);
  933. _e5=_2.createElement("canvas");
  934. _e5.width=_dd-2*NAV_BUTTON_WIDTH;
  935. _e5.height=NAV_HEIGHT-NAV_BUTTON_HEIGHT-NAV_OVERVIEW_TOP_OFFSET;
  936. _e4=_146+2*NAV_BUTTON_WIDTH;
  937. var _102=$(_e5);
  938. _102.css("position","absolute");
  939. _102.css("left",_e4+"px");
  940. _102.css("top",NAV_OVERVIEW_TOP_OFFSET+"px");
  941. _102.css("z-index","0");
  942. _102.css("width",_e5.width+"px");
  943. _102.css("height",_e5.height+"px");
  944. _102.appendTo(_df);
  945. if($.browser.msie){
  946. _e5=_1.G_vmlCanvasManager.initElement(_e5);
  947. }
  948. oc=_e5.getContext("2d");
  949. _4d(oc);
  950. var _103=_db.zoom_schema().length-1;
  951. _e3=_db.zoom_schema()[_103];
  952. _e8=_db.fetch(_103,0,Math.ceil(_db._time_range()/_e3[0]));
  953. _e8=_e8[0]||[];
  954. _e9=_e5.width/(_e8.length-1);
  955. var _104,_105,_106;
  956. _104=_105=_e8[_e8.length-1]||0;
  957. for(var i=_e8.length-2;i>=0;i--){
  958. _106=_e8[i]||0;
  959. _104=_106<_104?_106:_104;
  960. _105=_106>_105?_106:_105;
  961. }
  962. _105=(_105-_104)*NAV_OVERVIEW_SCALE_FACTOR+_104;
  963. _ea=(_e5.height-1)/(_105-_104);
  964. _f8(oc,"rgb(225,225,225)","rgba(200,200,200,0.2)","rgb(200,200,200)");
  965. _ee=$(["<div","class=\"nav-slider\"","style=\"","display:\t\tnone;","position:\t\tabsolute;","overflow:\t\thidden;","left:\t\t\t"+_e4+"px;","top:\t\t\t"+(NAV_HEIGHT-NAV_BUTTON_HEIGHT)+"px;","width:\t \t\t10px;","height:\t\t"+NAV_BUTTON_HEIGHT+"px;","text-align:\tcenter;","\"></div>"].join(" ")).appendTo(_df);
  966. _ef=_ee[0];
  967. _ee.append(["<img","src=\"/assets/slider.left.gif\"","style=\"","position:\tabsolute;","top:\t\t0px;","left:\t\t0px;","\"/>"].join(" "));
  968. _ee.append(["<img","src=\"/assets/slider.right.gif\"","style=\"","position:\tabsolute;","top:\t\t0px;","right:\t\t0px;","\"/>"].join(" "));
  969. _f0=$(["<img","src=\"/assets/slider.middle.gif\"","style=\"","display:\tnone;","\"/>"].join(" ")).appendTo(_ee);
  970. _eb=$(["<div","class=\"nav-viewer\"","style=\"","position:\t\t\tabsolute;","left:\t\t\t\t"+_e4+"px;","top:\t\t\t\t0px;","width:\t\t\t\t1px;","height:\t\t\t"+(NAV_HEIGHT-NAV_BUTTON_HEIGHT)+"px;","\"></div>"].join(" ")).appendTo(_df);
  971. _ec=_eb[0];
  972. var _107=$(["<div","style=\"","position:\tabsolute;","overflow:\thidden;","left:\t\t0px;","top:\t\t0px;","width:\t\t100%;","height:\t100%;","\"><div>"].join(" ")).appendTo(_eb);
  973. _e6=_2.createElement("canvas");
  974. _e6.width=_e5.width;
  975. _e6.height=_e5.height;
  976. _e7=$(_e6);
  977. _e7.css("position","absolute");
  978. _e7.css("left",(-_146)+"px");
  979. _e7.css("top",NAV_OVERVIEW_TOP_OFFSET+"px");
  980. _e7.css("width",_e6.width+"px");
  981. _e7.css("height",_e6.height+"px");
  982. _e7.css("z-index","0");
  983. _e7.css("border-bottom","1px solid #aaa");
  984. _e7.appendTo(_107);
  985. if($.browser.msie){
  986. _e6=_1.G_vmlCanvasManager.initElement(_e6);
  987. }
  988. pc=_e6.getContext("2d");
  989. _4d(pc);
  990. _f8(pc,"rgb(25,106,227)","rgba(25,106,227,0.1)","rgb(200,200,200)");
  991. _eb.css("display","none");
  992. _f2=$(["<img","src=\"/assets/range.gif\"","style=\"","position:\tabsolute;","top:\t\t"+Math.floor(_e6.height/2)+"px;","left:\t\t"+NAV_RANGE_OFFSET+"px;","cursor:\tcol-resize;","\"/>"].join(" ")).appendTo(_eb);
  993. _f3=_f2[0];
  994. _f4=$(["<img","src=\"/assets/range.gif\"","style=\"","position:\tabsolute;","top:\t\t"+Math.floor(_e6.height/2)+"px;","right:\t\t"+NAV_RANGE_OFFSET+"px;","cursor:\tcol-resize;","\"/>"].join(" ")).appendTo(_eb);
  995. _f5=_f4[0];
  996. _f6=true;
  997. _6(_e0[0],"mousedown",_108);
  998. _6(_e1[0],"mousedown",_109);
  999. _6(_ef,"mousedown",_10a);
  1000. _ef.onmousedown=function(e){
  1001. return _e(e);
  1002. };
  1003. _6(_ec,"mousedown",_10a);
  1004. _ec.onmousedown=function(e){
  1005. return _e(e);
  1006. };
  1007. _df.hover(_120,_121);
  1008. _6(_f3,"mousedown",_122);
  1009. _f3.onmousedown=function(e){
  1010. return _e(e);
  1011. };
  1012. _6(_f5,"mousedown",_124);
  1013. _f5.onmousedown=function(e){
  1014. return _e(e);
  1015. };
  1016. _dc.subscribe("/nav/center",this,"center");
  1017. _dc.subscribe("/nav/translate",this,"translate");
  1018. _dc.subscribe("/nav/range/update",this,"update_range");
  1019. _dc.subscribe("/nav/center",this,"post_init");
  1020. };
  1021. this.init=_fd;
  1022. function _10b(){
  1023. _dc.unsubscribe("/nav/center",this,"post_init");
  1024. _eb.css("display","inline");
  1025. _ee.css("display","inline");
  1026. };
  1027. this.post_init=_10b;
  1028. function _10c(){
  1029. var _10d=_e5.width-2;
  1030. _10c=function(){
  1031. var _10e=_da._chart_period()*_db.zoom_delta()/_e3[0];
  1032. _ed=Math.max(1,Math.min(_10d,Math.floor(_10e*_e9)));
  1033. _ec.style.width=_ed+"px";
  1034. _ef.style.width=Math.max(NAV_SCROLL_MIN_WIDTH,_ed)+"px";
  1035. if(_ed>NAV_SCROLL_MID_THRESHOLD){
  1036. _f0.css("display","inline");
  1037. }else{
  1038. _f0.css("display","none");
  1039. }
  1040. _10f();
  1041. _f1=(_e3[0]/_db.zoom_delta())*_da._x_scale()/_e9;
  1042. var _110=_eb.width();
  1043. if(_110>NAV_RANGE_CENTER_THRESHOLD){
  1044. _f3.style.left=NAV_RANGE_OFFSET+"px";
  1045. if(_f6){
  1046. _f4.css("display","inline");
  1047. }
  1048. }else{
  1049. _f3.style.left=Math.floor(_110/2+NAV_RANGE_CENTER_OFFSET)+"px";
  1050. _f4.css("display","none");
  1051. }
  1052. };
  1053. return _10c();
  1054. };
  1055. this.center=_10c;
  1056. function _10f(){
  1057. var _111=_da.width()/2;
  1058. var _112=_e5.width-2;
  1059. var _113=_112+_e4;
  1060. _10f=function(){
  1061. var _114=_da.min_pixel();
  1062. var _115=_da.max_pixel();
  1063. var _116=_da.center_pixel();
  1064. var _117=_114-_111;
  1065. var _118=_115+_111;
  1066. var _119;
  1067. if(_116<_115){
  1068. _119=_e4;
  1069. if(_116>_114){
  1070. var _11a=_118-_117;
  1071. _119+=(_116-_117)/_11a*_112;
  1072. _119-=(_ed/2);
  1073. _119=Math.round(_119);
  1074. }
  1075. }else{
  1076. _119=_113-_ed;
  1077. }
  1078. _119=Math.min((_113-_ed),_119);
  1079. _119=Math.max(_e4,_119);
  1080. _e6.style.left=(_e4-_119)+"px";
  1081. _ec.style.left=_119+"px";
  1082. if(_ed<NAV_SCROLL_MIN_WIDTH){
  1083. _119-=NAV_SCROLL_MIN_WIDTH-_ed;
  1084. }
  1085. _ef.style.left=Math.max(_e4,_119)+"px";
  1086. };
  1087. return _10f();
  1088. };
  1089. this.translate=_10f;
  1090. function _108(e){
  1091. _e1[0].className="nav-right-unsel nav-sel";
  1092. _e0[0].className="nav-left-sel";
  1093. _6(_2,"mouseup",_11b);
  1094. _dc.publish("/chart/draw/start");
  1095. _dc.publish("/chart/scroll/start",1);
  1096. };
  1097. function _11b(e){
  1098. _e1[0].className="nav-right-unsel nav-unsel";
  1099. _e0[0].className="nav-left-unsel";
  1100. _a(_2,"mouseup",_11b);
  1101. _dc.publish("/chart/draw/stop");
  1102. _dc.publish("/chart/scroll/stop");
  1103. };
  1104. function _109(e){
  1105. _e1[0].className="nav-right-sel nav-sel";
  1106. _6(_2,"mouseup",_11c);
  1107. _dc.publish("/chart/draw/start");
  1108. _dc.publish("/chart/scroll/start",-1);
  1109. };
  1110. function _11c(e){
  1111. _e1[0].className="nav-right-unsel nav-unsel";
  1112. _a(_2,"mouseup",_11c);
  1113. _dc.publish("/chart/draw/stop");
  1114. _dc.publish("/chart/scroll/stop");
  1115. };
  1116. function _10a(e){
  1117. e=e?e:_1.event;
  1118. _6(_2,"mousemove",_11d);
  1119. _eb._drag_x=e.clientX;
  1120. _6(_2,"mouseup",_11e);
  1121. _dc.publish("/chart/draw/start");
  1122. };
  1123. function _11d(e){
  1124. e=e?e:_1.event;
  1125. var _11f=e.clientX-_eb._drag_x;
  1126. if(Math.abs(_11f)<=1){
  1127. return _e(e);
  1128. }
  1129. _eb._drag_x=e.clientX;
  1130. _11f=-1*Math.floor(_f1*_11f);
  1131. _dc.publish("/chart/translate",_11f);
  1132. return _e(e);
  1133. };
  1134. function _11e(e){
  1135. _a(_2,"mousemove",_11d);
  1136. _a(_2,"mouseup",_11e);
  1137. _dc.publish("/chart/draw/stop");
  1138. };
  1139. function _120(e){
  1140. _f6=true;
  1141. _f2.css("display","inline");
  1142. if(_eb.width()>NAV_RANGE_CENTER_THRESHOLD){
  1143. _f4.css("display","inline");
  1144. }
  1145. };
  1146. function _121(e){
  1147. _f6=false;
  1148. _f2.css("display","none");
  1149. _f4.css("display","none");
  1150. };
  1151. function _122(e){
  1152. _f7=true;
  1153. _123(e);
  1154. };
  1155. function _124(e){
  1156. _f7=false;
  1157. _123(e);
  1158. };
  1159. function _123(e){
  1160. e=e?e:_1.event;
  1161. _6(_2,"mousemove",_125);
  1162. _eb._range_x=e.clientX;
  1163. _6(_2,"mouseup",_126);
  1164. _dc.publish("/chart/draw/start");
  1165. };
  1166. function _127(_128,_129){
  1167. var _12a=_e5.width-2;
  1168. var _12b=_db.zoom_schema();
  1169. var _12c=_da.width()/_da._pane_width();
  1170. var _12d=Math.floor(_da.width()/2);
  1171. _127=function(_12e,_12f){
  1172. var _130=Math.min(_12e,_12f);
  1173. var _131=Math.max(_12e,_12f);
  1174. var _132=_130===_12f?true:false;
  1175. var _133=Math.max(0,_130-_e4);
  1176. var _134=Math.min(_12a,_131-_e4);
  1177. var _135=(_134-_133)/_12a;
  1178. var _136=Math.floor(_db._time_range()*_135);
  1179. var _137,_138;
  1180. for(var i=0;i<_12b.length;i++){
  1181. _138=i;
  1182. _137=_12b[_138];
  1183. if((_137[0]*_137[2]*_12c)>=_136){
  1184. break;
  1185. }
  1186. }
  1187. var _139,_13a;
  1188. for(i=_137[1];i<=_137[2];i++){
  1189. _139=i;
  1190. _13a=_137[0]*i*_12c;
  1191. if(_13a>=_136){
  1192. break;
  1193. }
  1194. }
  1195. var _13b=_13a/2;
  1196. var _13c;
  1197. if(_132){
  1198. _13c=_db.min_time();
  1199. _13c+=_db._time_range()*(_133/_12a);
  1200. _13c+=_13b;
  1201. }else{
  1202. _13c=_db.min_time();
  1203. _13c+=_db._time_range()*(_134/_12a);
  1204. _13c-=_13b;
  1205. }
  1206. _13c=Math.floor(_13c);
  1207. _da._update_zoom(_138,_139);
  1208. _da.center(_13c,_12d);
  1209. };
  1210. return _127(_128,_129);
  1211. };
  1212. this.update_range=_127;
  1213. function _125(e){
  1214. e=e?e:_1.event;
  1215. if(Math.abs(e.clientX-_eb._range_x)<=1){
  1216. return _e(e);
  1217. }
  1218. _eb._range_x=e.clientX;
  1219. var _13d=parseInt(_ec.style.left,10);
  1220. var _13e;
  1221. if(_f7){
  1222. _13e=_eb.offset().left-e.clientX;
  1223. var _13f=_13d-_13e;
  1224. var _140=_13d+_eb.width();
  1225. if(_13f>_140){
  1226. _f7=false;
  1227. return _e(e);
  1228. }
  1229. _dc.publish("/nav/range/update",_13f,_140);
  1230. }else{
  1231. var _141=_eb.width();
  1232. _13e=(_eb.offset().left+_141)-e.clientX;
  1233. var _142=_13d+_141-_13e;
  1234. if(_142<_13d){
  1235. _f7=true;
  1236. return _e(e);
  1237. }
  1238. _dc.publish("/nav/range/update",_142,_13d);
  1239. }
  1240. return _e(e);
  1241. };
  1242. function _126(e){
  1243. _a(_2,"mousemove",_125);
  1244. _a(_2,"mouseup",_126);
  1245. _dc.publish("/chart/draw/stop");
  1246. };
  1247. };
  1248. var _143=720;
  1249. var _144=6;
  1250. var _145=3;
  1251. var _146=1;
  1252. var _147=1;
  1253. var _148=25;
  1254. var _149="rgb(175,175,175)";
  1255. var _14a=0.5;
  1256. var _14b=1000/25;
  1257. var _14c=1000*0.5;
  1258. if($.browser.msie){
  1259. _14b=4*1000;
  1260. _14c=1000;
  1261. }
  1262. var _14d=1.1;
  1263. var _14e=100;
  1264. var _14f=4;
  1265. var _150=-12;
  1266. var _151="W";
  1267. var _152=0.5;
  1268. var _153=2;
  1269. if($.browser.msie){
  1270. _152=0.75;
  1271. }
  1272. var _154=[60,60*5,60*10,60*15,60*30,60*60,60*60*3,60*60*6,60*60*12,60*60*24,60*60*24*7,60*60*24*14,60*60*24*31];
  1273. var _155=new Date();
  1274. var _156=function(_157){
  1275. if(_157.getSeconds()!==0){
  1276. return _158(_157,"h:mm:ss a");
  1277. }
  1278. if(_157.getMinutes()!==0){
  1279. return _158(_157,"h:mm a");
  1280. }
  1281. if(_157.getHours()!==0){
  1282. return _158(_157,"h a");
  1283. }
  1284. if(_157.getDay()!==1){
  1285. return _158(_157,"MMM d");
  1286. }
  1287. if(_157.getMonth()!==0){
  1288. return _158(_157,"MMM");
  1289. }
  1290. return _158(_157,"yyyy");
  1291. };
  1292. var _159=function(_15a){
  1293. _155.setTime(_15a*1000);
  1294. if(_155.getSeconds()!==0){
  1295. _155.setSeconds(60);
  1296. }
  1297. return [(_155.getTime()/1000)-_15a,_156(_155)];
  1298. };
  1299. var _15b=function(_15c){
  1300. _155.setTime(_15c*1000);
  1301. var _15d=_155.getMinutes();
  1302. var _15e=_15d%10;
  1303. if(_155.getSeconds()!==0||_15e!==0){
  1304. _155.setSeconds(0);
  1305. _155.setMinutes(_15d+(10-_15e));
  1306. }
  1307. return [(_155.getTime()/1000)-_15c,_156(_155)];
  1308. };
  1309. var _15f=function(_160){
  1310. _155.setTime(_160*1000);
  1311. var _161=_155.getMinutes();
  1312. var _162=_161%5;
  1313. if(_155.getSeconds()!==0||_162!==0){
  1314. _155.setSeconds(0);
  1315. _155.setMinutes(_161+(5-_162));
  1316. }
  1317. return [(_155.getTime()/1000)-_160,_156(_155)];
  1318. };
  1319. var _163=function(_164){
  1320. _155.setTime(_164*1000);
  1321. var _165=_155.getMinutes();
  1322. var _166=_165%15;
  1323. if(_155.getSeconds()!==0||_166!==0){
  1324. _155.setSeconds(0);
  1325. _155.setMinutes(_165+(15-_166));
  1326. }
  1327. return [(_155.getTime()/1000)-_164,_156(_155)];
  1328. };
  1329. var _167=function(_168){
  1330. _155.setTime(_168*1000);
  1331. var _169=_155.getMinutes();
  1332. var _16a=_169%30;
  1333. if(_155.getSeconds()!==0||_16a!==0){
  1334. _155.setSeconds(0);
  1335. _155.setMinutes(_169+(30-_16a));
  1336. }
  1337. return [(_155.getTime()/1000)-_168,_156(_155)];
  1338. };
  1339. var _16b=function(_16c){
  1340. _155.setTime(_16c*1000);
  1341. if(_155.getSeconds()!==0||_155.getMinutes()!==0){
  1342. _155.setSeconds(0);
  1343. _155.setMinutes(0);
  1344. _155.setHours(_155.getHours()+1);
  1345. }
  1346. return [(_155.getTime()/1000)-_16c,_156(_155)];
  1347. };
  1348. var _16d=function(_16e){
  1349. _155.setTime(_16e*1000);
  1350. var _16f=_155.getHours();
  1351. var _170=_16f%3;
  1352. if(_155.getSeconds()!==0||_155.getMinutes()!==0||_170!==0){
  1353. _155.setSeconds(0);
  1354. _155.setMinutes(0);
  1355. _155.setHours(_16f+(3-_170));
  1356. }
  1357. return [(_155.getTime()/1000)-_16e,_156(_155)];
  1358. };
  1359. var _171=function(_172){
  1360. _155.setTime(_172*1000);
  1361. var _173=_155.getHours();
  1362. var _174=_173%6;
  1363. if(_155.getSeconds()!==0||_155.getMinutes()!==0||_174!==0){
  1364. _155.setSeconds(0);
  1365. _155.setMinutes(0);
  1366. _155.setHours(_173+(6-_174));
  1367. }
  1368. return [(_155.getTime()/1000)-_172,_156(_155)];
  1369. };
  1370. var _175=function(_176){
  1371. _155.setTime(_176*1000);
  1372. var _177=_155.getHours();
  1373. var _178=_177%12;
  1374. if(_155.getSeconds()!==0||_155.getMinutes()!==0||_178!==0){
  1375. _155.setSeconds(0);
  1376. _155.setMinutes(0);
  1377. _155.setHours(_177+(12-_178));
  1378. }
  1379. return [(_155.getTime()/1000)-_176,_156(_155)];
  1380. };
  1381. var _179=function(_17a){
  1382. _155.setTime(_17a*1000);
  1383. if(_155.getSeconds()!==0||_155.getMinutes()!==0||_155.getHours()!==0){
  1384. _155.setSeconds(0);
  1385. _155.setMinutes(0);
  1386. _155.setHours(24);
  1387. }
  1388. return [(_155.getTime()/1000)-_17a,_156(_155)];
  1389. };
  1390. var _17b=60*60*24*7;
  1391. var _17c=function(_17d){
  1392. _155.setTime(_17d*1000);
  1393. _155.setSeconds(0);
  1394. _155.setMinutes(0);
  1395. _155.setHours(0);
  1396. _155.setMonth(0,1);
  1397. var _17e=_155.getTime()/1000;
  1398. var _17f=_17d-_17e;
  1399. return [_17b-(_17f%_17b),_156(_155)];
  1400. };
  1401. var _180=2*_17b;
  1402. var _181=function(_182){
  1403. _155.setTime(_182*1000);
  1404. _155.setSeconds(0);
  1405. _155.setMinutes(0);
  1406. _155.setHours(0);
  1407. _155.setMonth(0,1);
  1408. var _183=_155.getTime()/1000;
  1409. var _184=_182-_183;
  1410. return [_180-(_184%_180),_156(_155)];
  1411. };
  1412. var _185=function(_186){
  1413. _155.setTime(_186*1000);
  1414. if(_155.getSeconds()!==0||_155.getMinutes()!==0||_155.getHours()!==0||_155.getDay()!==1||_155.getMonth()!==0){
  1415. _155.setSeconds(0);
  1416. _155.setMinutes(0);
  1417. _155.setHours(0);
  1418. _155.setMonth(_155.getMonth()+1,1);
  1419. }
  1420. return [(_155.getTime()/1000)-_186,_156(_155)];
  1421. };
  1422. var _187=function(_188){
  1423. _155.setTime(_188*1000);
  1424. return [0,_156(_155)];
  1425. };
  1426. var _189={};
  1427. _189[60]=_159;
  1428. _189[60*5]=_15f;
  1429. _189[60*10]=_15b;
  1430. _189[60*15]=_163;
  1431. _189[60*30]=_167;
  1432. _189[60*60]=_16b;
  1433. _189[60*60*3]=_16d;
  1434. _189[60*60*6]=_171;
  1435. _189[60*60*12]=_175;
  1436. _189[60*60*24]=_179;
  1437. _189[60*60*24*7]=_17c;
  1438. _189[60*60*24*14]=_181;
  1439. _189[60*60*24*31]=_185;
  1440. var _18a=function(_18b,_18c){
  1441. var lo=0;
  1442. var hi=_18b.length;
  1443. while(lo<hi){
  1444. var mid=Math.floor((lo+hi)/2);
  1445. if(_18b[mid]<_18c){
  1446. lo=mid+1;
  1447. }else{
  1448. hi=mid;
  1449. }
  1450. }
  1451. return lo;
  1452. };
  1453. var _18d=[[60*5,"5m"],[60*30,"30m"],[60*60,"1h"],[60*60*6,"6h"],[60*60*12,"12h"],[60*60*24,"1d"],[60*60*24*7,"1w"],[60*60*24*7*2,"2w"],[60*60*24*31,"1M"],[60*60*24*31*3,"3M"]];
  1454. var _18e=function(_18f){
  1455. var _190=$(_18f),_191=null,_192=null,_193=null,_194=0,_195=0,_196=0,_197=0,_198=null,_199=null,_19a=null,_19b=null,_19c=null,_19d=null,_19e=null,_19f=false,_1a0=0,_1a1=1,_1a2=0,_1a3=0,_1a4=0,_1a5=0,_1a6=_187,_1a7=0,_1a8=[],_1a9=[],bg=null,_1aa=0,_1ab=0,_1ac=0,_1ad=new _3a(),_1ae=false,_1af=0,_1b0=_3,_1b1=0,_1b2=0,_1b3=0,_1b4=0,nav=null,_1b5=0,_1b6=false,_1b7=0;
  1456. this.target=function(){
  1457. return _190;
  1458. };
  1459. this.model=function(){
  1460. return _191;
  1461. };
  1462. this.container=function(){
  1463. return _192;
  1464. };
  1465. this.y_labels=function(){
  1466. return _193;
  1467. };
  1468. this.width=function(){
  1469. return _194;
  1470. };
  1471. this.max_left=function(){
  1472. return _195;
  1473. };
  1474. this.max_right=function(){
  1475. return _196;
  1476. };
  1477. this.height=function(){
  1478. return _197;
  1479. };
  1480. this.top_pane=function(){
  1481. return _198;
  1482. };
  1483. this.zoom_scale=function(){
  1484. return _1a0;
  1485. };
  1486. this._pane_period=function(){
  1487. return _1a1;
  1488. };
  1489. this._pane_width=function(){
  1490. return _1a2;
  1491. };
  1492. this.max_y=function(){
  1493. return _1a3;
  1494. };
  1495. this.min_y=function(){
  1496. return _1a4;
  1497. };
  1498. this._x_scale=function(){
  1499. return _1a5;
  1500. };
  1501. this._x_tick=function(){
  1502. return _1a6;
  1503. };
  1504. this._y_scale=function(){
  1505. return _1a7;
  1506. };
  1507. this._y_intervals=function(){
  1508. return _1a8;
  1509. };
  1510. this.panes=function(){
  1511. return _1a9;
  1512. };
  1513. this.bg=function(){
  1514. return bg;
  1515. };
  1516. this.draw_width=function(){
  1517. return _1aa;
  1518. };
  1519. this.draw_height=function(){
  1520. return _1ab;
  1521. };
  1522. this.chart_height=function(){
  1523. return _1ac;
  1524. };
  1525. this.broker=function(){
  1526. return _1ad;
  1527. };
  1528. this.updating=function(){
  1529. return _1ae;
  1530. };
  1531. this.update_delta=function(){
  1532. return _1af;
  1533. };
  1534. this.update_id=function(){
  1535. return _1b0;
  1536. };
  1537. this.update_time=function(){
  1538. return _1b1;
  1539. };
  1540. this.center_pixel=function(){
  1541. return _1b2;
  1542. };
  1543. this.min_pixel=function(){
  1544. return _1b3;
  1545. };
  1546. this.max_pixel=function(){
  1547. return _1b4;
  1548. };
  1549. this.nav=function(){
  1550. return nav;
  1551. };
  1552. this.scroll_id=function(){
  1553. return _1b7;
  1554. };
  1555. function _1b8(){
  1556. var _1b9=_194/_1a2;
  1557. var map={};
  1558. for(var i=_1a2;i>0;i--){
  1559. map[i]=_1b9*i;
  1560. }
  1561. _1b8=function(){
  1562. return map[_1a1];
  1563. };
  1564. return _1b8();
  1565. };
  1566. this._chart_period=_1b8;
  1567. function _1ba(){
  1568. _1a5=_1a2/_1a1;
  1569. var _1bb=_18a(_154,_191.zoom_delta()*_1a1);
  1570. var _1bc=_189[_154[_1bb]];
  1571. if(_1bc){
  1572. _1a6=_1bc;
  1573. }else{
  1574. _1a6=_187;
  1575. }
  1576. };
  1577. this._calc_x_scale=_1ba;
  1578. function _1bd(){
  1579. var min,max,_1be,_1bf,_1c0;
  1580. var _1c1=_1a9.length-1;
  1581. while(_1c1>=0){
  1582. _1bf=_1a9[_1c1--];
  1583. _1c0=_1bf.offset();
  1584. if(_1c0<=_194){
  1585. _1be=_1bf.range_min_max_y(0,Math.ceil(((_194-_1c0)/_1a2)*_1a1));
  1586. min=_1be[0];
  1587. max=_1be[1];
  1588. break;
  1589. }
  1590. }
  1591. for(var i=_1c1;i>=0;i--){
  1592. _1bf=_1a9[i];
  1593. _1c0=_1bf.offset();
  1594. if(_1c0<_194){
  1595. if(_1c0>0){
  1596. min=Math.min(min,_1bf._min_y());
  1597. max=Math.max(max,_1bf._max_y());
  1598. }else{
  1599. if(_1c0>-_1a2){
  1600. _1be=_1bf.range_min_max_y(Math.floor((-_1c0/_1a2)*_1a1),_1a1);
  1601. min=Math.min(min,_1be[0]);
  1602. max=Math.max(max,_1be[1]);
  1603. }
  1604. }
  1605. }
  1606. }
  1607. return [min,max];
  1608. };
  1609. this._min_max_y=_1bd;
  1610. var _1c2=Math.log(10);
  1611. function _1c3(){
  1612. _193.empty();
  1613. var _1c4=Math.pow(10,Math.floor(Math.log(_1a3)/_1c2));
  1614. var _1c5,_1c6;
  1615. if(_1a3<(2*_1c4)){
  1616. _1c5=0.5*_1c4;
  1617. _1c6=4;
  1618. }else{
  1619. if(_1a3<(3*_1c4)){
  1620. _1c5=_1c4;
  1621. _1c6=3;
  1622. }else{
  1623. if(_1a3<(4*_1c4)){
  1624. _1c5=_1c4;
  1625. _1c6=4;
  1626. }else{
  1627. if(_1a3<(5*_1c4)){
  1628. _1c5=_1c4;
  1629. _1c6=5;
  1630. }else{
  1631. if(_1a3<(6*_1c4)){
  1632. _1c5=2*_1c4;
  1633. _1c6=3;
  1634. }else{
  1635. if(_1a3<(8*_1c4)){
  1636. _1c5=2*_1c4;
  1637. _1c6=4;
  1638. }else{
  1639. _1c5=2*_1c4;
  1640. _1c6=5;
  1641. }
  1642. }
  1643. }
  1644. }
  1645. }
  1646. }
  1647. var _1c7=_1c6*_1c5*_14d;
  1648. _1a7=_1ac/_1c7;
  1649. _1a8=[];
  1650. for(var i=_1c6;i>0;i--){
  1651. var _1c8=i*_1c5;
  1652. var _1c9=_1c8*_1a7;
  1653. _1a8.push(_1c9);
  1654. _193.append(["<div","class=\"y-tick\"","style=\"","position:\tabsolute;","left:\t\t0px;","top:\t\t"+(_1ac-_1c9+_150)+"px;","z-index:\t0;","width:\t\t"+_14e+"px;","\">"+_1c8+" "+_151+"</div>"].join(" "));
  1655. }
  1656. };
  1657. this._calc_y_scale=_1c3;
  1658. function _1ca(){
  1659. _1c3();
  1660. _1ad.publish("/pane/redraw");
  1661. };
  1662. this._rescale_y_axis=_1ca;
  1663. function init(){
  1664. _194=_190.width();
  1665. _197=_190.height()-NAV_HEIGHT;
  1666. var _1cb=_52;
  1667. if(_194>_143){
  1668. _1a2=Math.floor(_194/_144);
  1669. if($.browser.msie){
  1670. _1cb=_51;
  1671. }
  1672. }else{
  1673. _1a2=Math.floor(_194/_145);
  1674. _1cb=_50;
  1675. }
  1676. _191=new _76(this,_1cb);
  1677. _191.init(1243411200,1243411200+4*_56.prototype.bucket_size*60-60,_194,_1a2);
  1678. var _1cc=1243411200+3*_56.prototype.bucket_size*60;
  1679. _1a0=0;
  1680. _1a1=20;
  1681. _1a9=[];
  1682. _190.html("");
  1683. _190.css("position","relative");
  1684. bg=$(["<div","style=\"","overflow:\thidden;","position:\tabsolute;","left:\t\t0px;","top:\t\t0px;","z-index:\t-1;","width:\t\t"+_194+"px;","height:\t"+_197+"px;","border:\t1px solid rgb(0,0,0);","\"></div>"].join(" ")).appendTo(_190);
  1685. _198=$(["<div","class=\"top-pane\"","style=\"","position:\t\tabsolute;","left:\t\t\t"+_146+"px;","top:\t\t\t0px;","width:\t\t\t"+_194+"px;","height:\t\t"+_148+"px;","border-bottom:\t1px solid "+_149+";","\"></div>"].join(" ")).appendTo(_190);
  1686. var _1cd=$(["<div","class=\"top-zoom\"","></div>"].join(" ")).appendTo(_198);
  1687. _1cd.append("<strong>Zoom:</strong>");
  1688. var _1ce=_191.zoom_schema().length-1;
  1689. var _1cf=_191.zoom_schema()[_1ce];
  1690. var _1d0=_1cf[0]*_1cf[2];
  1691. var _1d1=_18d.length-1;
  1692. for(;_1d1>=0;_1d1--){
  1693. if(_18d[_1d1][0]<_1d0){
  1694. break;
  1695. }
  1696. }
  1697. _1d1+=1;
  1698. var _1d2=_194/_1a2;
  1699. var _1d3=[];
  1700. var _1d4=0;
  1701. for(i=0;i<=_1ce;i++){
  1702. var _1d5=_191.zoom_schema()[i];
  1703. for(var j=_1d5[1];j<=_1d5[2];j++){
  1704. if((_1d5[0]*j*_1d2)>=_18d[_1d4][0]){
  1705. _1d3[_1d4]=[i,j];
  1706. _1d4+=1;
  1707. if(_1d4>_1d1){
  1708. break;
  1709. }
  1710. }
  1711. }
  1712. }
  1713. for(i=0;i<=_1d1;i++){
  1714. var _1d6=_18d[i];
  1715. var _1d7=$(["<a","class=\"zoom-link\"","href=\"#"+_1d6[1]+"\"",">"+_1d6[1]+"</a>"].join(" ")).appendTo(_1cd)[0];
  1716. (function(obj,_1d8,_1d9){
  1717. _6(obj,"click",function(){
  1718. _213(_1d8,_1d9);
  1719. });
  1720. })(_1d7,_1d3[i][0],_1d3[i][1]);
  1721. }
  1722. var _1da=$(["<a","class=\"zoom-link\"","href=\"#max\"",">max</a>"].join(" ")).appendTo(_1cd)[0];
  1723. _6(_1da,"click",function(){
  1724. _213(_1ce,_1cf[2]);
  1725. });
  1726. _199=$(["<div","class=\"top-right\"","></div>"].join(" ")).appendTo(_198);
  1727. _19a=$("<span></span>").appendTo(_199);
  1728. _19b=$(["<div","class=\"top-right\"","style=\"","display:\tnone;","\"></div>"].join(" ")).appendTo(_198);
  1729. _19c=$("<span class=\"top-point-time\"></span>").appendTo(_19b);
  1730. _19d=$("<span class=\"top-point-value\"></span>").appendTo(_19b);
  1731. bg.append(["<div","style=\"","position:\t\t\tabsolute;","left:\t\t\t\t0px;","top:\t\t\t\t"+(_197-_91+_92)+"px;","width:\t\t\t\t"+_194+"px;","height:\t\t\t"+_91+"px;","background-color: \t"+_93+";","border:\t\t\t0px;","\"></div>"].join(" "));
  1732. _1aa=_194;
  1733. _1ab=_197-_148-_147;
  1734. _1ac=_1ab-_91;
  1735. _192=$(["<div","style=\"","position:\tabsolute;","overflow:\thidden;","left:\t\t"+_146+"px;","top:\t\t"+(_148+2*_147)+"px;","width:\t\t"+_1aa+"px;","height:\t"+_1ab+"px;","cursor:\tmove;","\"></div>"].join(" ")).appendTo(_190);
  1736. var _1db=Math.ceil(_194/_1a2)+2;
  1737. var _1dc=(-_1db*_1a2/2)-(-_194/2);
  1738. _195=_1dc-(_1a2/2);
  1739. _196=_1dc+((_1db-0.5)*_1a2);
  1740. for(i=0;i<_1db;i++){
  1741. var pane=new _95(this,_1a2);
  1742. pane.init();
  1743. _1a9.push(pane);
  1744. }
  1745. _193=$(["<div","style=\"","overflow:\thidden;","position:\tabsolute;","right:\t\t"+_14f+"px;","top:\t\t0px;","width:\t\t"+_14e+"px;","height:\t"+_1ac+"px;","\"></div>"].join(" ")).appendTo(_192);
  1746. nav=new _d8(this);
  1747. nav.init(_190,_194,NAV_HEIGHT,(_197+_147),_146);
  1748. _19e=$(["<div","style=\"","display:\t\t\tnone;","position:\t\t\tabsolute;","top:\t\t\t\t"+(_148+_147)+"px;","width:\t\t\t\t1px;","height:\t\t\t"+(_1ac+_147)+"px;","background-color:\t#666;","\"></div>"].join(" ")).appendTo(_190);
  1749. _1ad.subscribe("/chart/center",this,"center");
  1750. _1ad.subscribe("/chart/translate",this,"translate");
  1751. _1ad.subscribe("/chart/recycle",this,"recycle");
  1752. _1ad.subscribe("/chart/replace",this,"replace");
  1753. _1ad.subscribe("/chart/draw/start",this,"draw_start");
  1754. _1ad.subscribe("/chart/draw/stop",this,"draw_stop");
  1755. _1ad.subscribe("/chart/draw/rescale",this,"_rescale_y_axis");
  1756. _1ad.subscribe("/chart/scroll/start",this,"scroll_start");
  1757. _1ad.subscribe("/chart/scroll/stop",this,"scroll_stop");
  1758. _1ad.subscribe("/info/range/update",this,"_update_top_range");
  1759. _1ad.subscribe("/info/point/update",this,"_update_top_point");
  1760. _6(_192[0],"mousedown",_1e1);
  1761. _192[0].onmousedown=function(e){
  1762. return _e(e);
  1763. };
  1764. _6(_192[0],"dblclick",_1dd);
  1765. _6(_192[0],"mousewheel",_1de);
  1766. _192.hover(_1df,_1e0);
  1767. _1ad.publish("/chart/center",_1cc,_194/2);
  1768. };
  1769. this.init=init;
  1770. function _1e1(e){
  1771. e=e?e:_1.event;
  1772. _6(_2,"mousemove",_1e2);
  1773. _192._drag_x=e.clientX;
  1774. _6(_2,"mouseup",_1e3);
  1775. _1ad.publish("/chart/draw/start");
  1776. _a(_192[0],"mousemove",_1e4);
  1777. };
  1778. function _1e2(e){
  1779. e=e?e:_1.event;
  1780. var _1e5=e.clientX-_192._drag_x;
  1781. if(Math.abs(_1e5)<=1){
  1782. return _e(e);
  1783. }
  1784. _192._drag_x=e.clientX;
  1785. _1ad.publish("/chart/translate",_1e5);
  1786. return _e(e);
  1787. };
  1788. function _1e3(e){
  1789. _a(_2,"mousemove",_1e2);
  1790. _a(_2,"mouseup",_1e3);
  1791. _1ad.publish("/chart/draw/stop");
  1792. if(_19f){
  1793. _6(_192[0],"mousemove",_1e4);
  1794. _192._cursor_x=e.clientX;
  1795. }
  1796. };
  1797. function _1e6(e,_1e7){
  1798. var _1e8=_192.offset();
  1799. var _1e9=e.clientX-_1e8.left;
  1800. var _1ea=e.clientY-_1e8.top;
  1801. var _1eb=_1a9[0];
  1802. var _1ec=_1eb.time_offset()+(_1e9-_1eb.offset())/_1a5*_191.zoom_delta();
  1803. if(_1e7>0){
  1804. _1a1=Math.max(_191.zoom_level()[1],_1a1-_1e7);
  1805. _1a1-=_1e7;
  1806. if(_1a1<_191.zoom_level()[1]){
  1807. if(_1a0>0){
  1808. _1a0-=1;
  1809. _1a1=_191.zoom_level()[2];
  1810. }else{
  1811. _1a1=_191.zoom_level()[1];
  1812. }
  1813. }
  1814. }else{
  1815. _1a1-=_1e7;
  1816. if(_1a1>_191.zoom_level()[2]){
  1817. if(_1a0<(_191.zoom_schema().length-1)){
  1818. _1a0+=1;
  1819. _1a1=_191.zoom_level()[1];
  1820. }else{
  1821. _1a1=_191.zoom_level()[2];
  1822. }
  1823. }
  1824. }
  1825. _1ad.publish("/chart/center",_1ec,_1e9);
  1826. };
  1827. function _1dd(e){
  1828. e=e?e:_1.event;
  1829. _1e6(e,Math.max(1,Math.floor(_1a1*0.25)));
  1830. };
  1831. function _1de(e){
  1832. e=e?e:_1.event;
  1833. var _1ed=e.detail?-e.detail:e.wheelDelta/40;
  1834. if(Math.abs(_1ed)>0){
  1835. _1ed=Math.min(Math.round(_1ed*_152),_153);
  1836. _1e6(e,_1ed);
  1837. }
  1838. return _e(e);
  1839. };
  1840. function _1df(e){
  1841. _19f=true;
  1842. e=e?e:_1.event;
  1843. _6(_192[0],"mousemove",_1e4);
  1844. _192._cursor_x=e.clientX;
  1845. };
  1846. function _1e0(e){
  1847. _19f=false;
  1848. _a(_192[0],"mousemove",_1e4);
  1849. };
  1850. function _1e4(e){
  1851. e=e?e:_1.event;
  1852. if(Math.abs(e.clientX-_192._cursor_x)<=1){
  1853. return e;
  1854. }
  1855. _192._cursor_x=e.clientX;
  1856. _1ee(e.clientX-(_192.offset().left+_194/2));
  1857. return e;
  1858. };
  1859. function _1ef(_1f0,_1f1){
  1860. _1ba();
  1861. var _1f2=_191.zoom_delta();
  1862. var _1f3=_194/2;
  1863. _1f1=Math.floor(_1f1);
  1864. var _1f4=Math.floor((_1f0-_191.min_time())/_1f2);
  1865. var _1f5=Math.floor(_191._time_range()/_1f2);
  1866. if(_1f5<=_1b8()){
  1867. _1f4=Math.floor(_1f5/2);
  1868. _1f1=Math.floor(_1f3);
  1869. _1b3=_1b4=_1b2=Math.round((_1f4*_1a5)+_1f3-_1f1);
  1870. }else{
  1871. var _1f6=(((_191.max_time()-_1f0)/_1f2)-1)*_1a5;
  1872. if((_194-_1f1)>_1f6){
  1873. _1f1=Math.floor(_194-_1f6);
  1874. }else{
  1875. if(_1f1>(_1f4*_1a5)){
  1876. _1f1=Math.floor(_1f4*_1a5);
  1877. }
  1878. }
  1879. _1b3=Math.ceil(_1f3);
  1880. var _1f7=(_191._time_range()/_1f2)-1;
  1881. _1b4=Math.floor((_1f7*_1a5)-_1f3);
  1882. _1b2=Math.round((_1f4*_1a5)+_1f3-_1f1);
  1883. }
  1884. var len=_1a9.length;
  1885. var _1f8=_194+(_1f1%_1a2);
  1886. var _1f9=_1f4+(len-Math.floor(_1f1/_1a2)-2)*_1a1;
  1887. var i=len;
  1888. while(i--){
  1889. var pane=_1a9[i];
  1890. pane._reset(_1f9,_1f8);
  1891. _1f9-=_1a1;
  1892. _1f8-=_1a2;
  1893. }
  1894. var _1fa=_1bd();
  1895. _1a4=_1fa[0];
  1896. _1a3=_1fa[1];
  1897. _1ad.publish("/chart/draw/rescale");
  1898. _1ad.publish("/nav/center");
  1899. _1ad.publish("/info/range/update");
  1900. };
  1901. this.center=_1ef;
  1902. function _1fb(_1fc){
  1903. var _1fd,_1fe;
  1904. if(_1fc>0){
  1905. while(_1a9[_1a9.length-1].offset()>_196){
  1906. _1fe=_1a9.pop();
  1907. _1fd=_1a9[0];
  1908. _1fe.reset(_1fd._data_offset()-_1a1,_1fd.offset()-_1a2);
  1909. _1a9.unshift(_1fe);
  1910. }
  1911. }else{
  1912. if(_1fc<0){
  1913. while(_1a9[0].offset()<_195){
  1914. _1fd=_1a9.shift();
  1915. _1fe=_1a9[_1a9.length-1];
  1916. _1fd.reset(_1fe._data_offset()+_1a1,_1fe.offset()+_1a2);
  1917. _1a9.push(_1fd);
  1918. }
  1919. }
  1920. }
  1921. };
  1922. this.recycle=_1fb;
  1923. function _1ff(_200){
  1924. _1b2-=_200;
  1925. if(_1b2<_1b4){
  1926. if(_1b2<_1b3){
  1927. _200-=_1b3-_1b2;
  1928. _1b2=_1b3;
  1929. if(!_200){
  1930. return;
  1931. }
  1932. }
  1933. }else{
  1934. _200+=_1b2-_1b4;
  1935. _1b2=_1b4;
  1936. if(!_200){
  1937. return;
  1938. }
  1939. }
  1940. if(Math.abs(_200)<_194){
  1941. _1ad.publish("/pane/translate",_200);
  1942. _1ad.publish("/chart/recycle",_200);
  1943. }else{
  1944. _1ad.publish("/chart/replace",_1b2);
  1945. }
  1946. _1ad.publish("/nav/translate",_200);
  1947. _1ad.publish("/info/range/update");
  1948. };
  1949. this.translate=_1ff;
  1950. function _201(_202){
  1951. var _203=Math.floor(_202/_1a2);
  1952. var _204=_202%_1a2;
  1953. var _205=Math.floor(_1a9.length/2);
  1954. var _206=(_203+_205)*_1a1;
  1955. var _207=Math.floor(_194/2)+_205*_1a2-_204;
  1956. var i=_1a9.length;
  1957. while(i--){
  1958. var pane=_1a9[i];
  1959. pane.reset(_206,_207);
  1960. _206-=_1a1;
  1961. _207-=_1a2;
  1962. }
  1963. var _208=_1bd();
  1964. _1a4=_208[0];
  1965. _1a3=_208[1];
  1966. _1ad.publish("/chart/draw/rescale");
  1967. _1ad.publish("/nav/center");
  1968. };
  1969. this.replace=_201;
  1970. function _209(){
  1971. var _20a=_1bd();
  1972. if(_20a[0]!=_1a4||_20a[1]!=_1a3){
  1973. _1a4=_20a[0];
  1974. _1a3=_20a[1];
  1975. _1ad.publish("/chart/draw/rescale");
  1976. }
  1977. if(!_1ae){
  1978. return;
  1979. }
  1980. var now=(new Date()).getTime();
  1981. _1af=Math.max(_14a*(now-_1b1),_14b);
  1982. _1b1=now;
  1983. _1b0=setTimeout(_209,_1af);
  1984. };
  1985. function _20b(){
  1986. clearTimeout(_1b0);
  1987. _1ae=true;
  1988. _1b1=(new Date()).getTime();
  1989. _1b0=setTimeout(_209,_1af);
  1990. };
  1991. this.draw_start=_20b;
  1992. function _20c(){
  1993. clearTimeout(_1b0);
  1994. _1ae=false;
  1995. _1b0=setTimeout(_209,_14c);
  1996. };
  1997. this.draw_stop=_20c;
  1998. function _20d(){
  1999. if(!_1b6){
  2000. return;
  2001. }
  2002. _1ad.publish("/chart/translate",_1b5);
  2003. _1b7=setTimeout(_20d,NAV_SCROLL_RATE);
  2004. };
  2005. function _20e(sign){
  2006. clearTimeout(_1b7);
  2007. _1b5=sign*NAV_SCROLL_SPEED;
  2008. _1b6=true;
  2009. _20d();
  2010. };
  2011. this.scroll_start=_20e;
  2012. function _20f(){
  2013. _1b6=false;
  2014. };
  2015. this.scroll_stop=_20f;
  2016. function _210(_211,_212){
  2017. _1a0=_211;
  2018. _1a1=_212;
  2019. };
  2020. this._update_zoom=_210;
  2021. function _213(_214,_215){
  2022. var _216=_1b2/_1a2;
  2023. var _217=_191.min_time();
  2024. _217+=_216*_1a1*_191.zoom_delta();
  2025. _217=Math.floor(_217);
  2026. _210(_214,_215);
  2027. _1ef(_217,Math.floor(_194/2));
  2028. };
  2029. this.set_zoom=_213;
  2030. function _218(){
  2031. var _219=_194/2;
  2032. var _21a=60*60*24;
  2033. _218=function(){
  2034. _19e.css("display","none");
  2035. _19b.css("display","none");
  2036. var _21b=_1b2-_219;
  2037. var _21c=_1b2+_219;
  2038. var _21d=_191.min_time()+(_21b/_1a5*_191.zoom_delta());
  2039. var _21e=_191.min_time()+(_21c/_1a5*_191.zoom_delta());
  2040. var _21f=new Date(_21d*1000);
  2041. var _220=new Date(_21e*1000);
  2042. if((_21e-_21d)<_21a&&_21f.getDay()===_220.getDay()){
  2043. _19a.text(_158(_21f,"MMM d, yyyy"));
  2044. }else{
  2045. _19a.text(_158(_21f,"NNN d, yyyy")+" - "+_158(_220,"NNN d, yyyy"));
  2046. }
  2047. _199.css("display","inline");
  2048. };
  2049. return _218();
  2050. };
  2051. this._update_top_range=_218;
  2052. function _1ee(_221){
  2053. var _222=_194/2;
  2054. _1ee=function(_223){
  2055. _199.css("display","none");
  2056. var _224=Math.round((_1b2+_223)/_1a2*_1a1);
  2057. var _225=_224*_1a5;
  2058. var _226=new Date((_191.min_time()+(_224*_191.zoom_delta()))*1000);
  2059. var _227=_191.fetch(_1a0,_224,0)[0][0]||0;
  2060. _19c.text(_158(_226,"MMM d, yyyy"));
  2061. _19d.text(Math.round(_227*1000)/1000);
  2062. var _228=_1b2-_222;
  2063. _19e.css("left",Math.floor(_225-_228)+1);
  2064. _19b.css("display","inline");
  2065. _19e.css("display","inline");
  2066. };
  2067. return _1ee(_221);
  2068. };
  2069. this._update_top_point=_1ee;
  2070. };
  2071. _18e.prototype={version:"0.1"};
  2072. $c.chart=function(_229){
  2073. var _22a=new _18e(_229);
  2074. _22a.init();
  2075. return _22a;
  2076. };
  2077. var _22b=["January","February","March","April","May","June","July","August","September","October","November","December","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];
  2078. var _22c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sun","Mon","Tue","Wed","Thu","Fri","Sat"];
  2079. function LZ(x){
  2080. return (x<0||x>9?"":"0")+x;
  2081. };
  2082. function _158(date,_22d){
  2083. _22d=_22d+"";
  2084. var _22e="";
  2085. var _22f=0;
  2086. var c="";
  2087. var _230="";
  2088. var y=date.getYear()+"";
  2089. var M=date.getMonth()+1;
  2090. var d=date.getDate();
  2091. var E=date.getDay();
  2092. var H=date.getHours();
  2093. var m=date.getMinutes();
  2094. var s=date.getSeconds();
  2095. var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,KK,K,kk,k;
  2096. var _231={};
  2097. if(y.length<4){
  2098. y=""+(y-0+1900);
  2099. }
  2100. _231.y=""+y;
  2101. _231.yyyy=y;
  2102. _231.yy=y.substring(2,4);
  2103. _231.M=M;
  2104. _231.MM=LZ(M);
  2105. _231.MMM=_22b[M-1];
  2106. _231.NNN=_22b[M+11];
  2107. _231.d=d;
  2108. _231.dd=LZ(d);
  2109. _231.E=_22c[E+7];
  2110. _231.EE=_22c[E];
  2111. _231.H=H;
  2112. _231.HH=LZ(H);
  2113. if(H==0){
  2114. _231.h=12;
  2115. }else{
  2116. if(H>12){
  2117. _231.h=H-12;
  2118. }else{
  2119. _231.h=H;
  2120. }
  2121. }
  2122. _231.hh=LZ(_231.h);
  2123. if(H>11){
  2124. _231.K=H-12;
  2125. }else{
  2126. _231.K=H;
  2127. }
  2128. _231.k=H+1;
  2129. _231.KK=LZ(_231.K);
  2130. _231.kk=LZ(_231.k);
  2131. if(H>11){
  2132. _231.a="PM";
  2133. }else{
  2134. _231.a="AM";
  2135. }
  2136. _231.m=m;
  2137. _231.mm=LZ(m);
  2138. _231.s=s;
  2139. _231.ss=LZ(s);
  2140. while(_22f<_22d.length){
  2141. c=_22d.charAt(_22f);
  2142. _230="";
  2143. while((_22d.charAt(_22f)==c)&&(_22f<_22d.length)){
  2144. _230+=_22d.charAt(_22f++);
  2145. }
  2146. if(_231[_230]){
  2147. _22e=_22e+_231[_230];
  2148. }else{
  2149. _22e=_22e+_230;
  2150. }
  2151. }
  2152. return _22e;
  2153. };
  2154. })(jQuery);