From d3124dbd93620c9b3fc310feba1e0a7ec5aa5369 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 3 Mar 2018 12:52:23 +0100 Subject: [PATCH] Refactoring Coordinate System Completed --- .vs/AAWebPlatform/v15/.suo | Bin 83456 -> 82432 bytes ChartGrid.js | 8 ++++---- ProductCard.js | 2 +- TimeLineCoordinateSystem.js | 25 +++++++++++++++---------- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.vs/AAWebPlatform/v15/.suo b/.vs/AAWebPlatform/v15/.suo index 8d66792515104cc49fa953c186583750644e33ac..7f9750aa98c87d91338bd05b07033f58cfc121fa 100644 GIT binary patch delta 1091 zcmbVKdq`7Z6u;+gcT>0Nrp|nnk6h&2RYZb`+3Z16d>~R_g5)0(NIipT>$&VzIA@0{Ov4Hr4X8SbhU zi_f|GDjCL~VHgp`kHy7B>KLF1e2_5*Aj1$gh)d5XAD<*8tQ5c#D@6OSPq_(aMOsx9 zZQMoSM-fS}4Y!IzAsP>e^{RN9Z=i6cNT7(T$?(FbVsF17nz&I=GKU2?<8bm-d;++( zj=OeBCUKJKiA8!^rf_u2ot-#Xq`@+;Av9iyB4yrU33QPPe?6c@swJ}l@;Gy*1>_3a z9kFaerlHAs3Tl|AQP(RYz?Vd24?%5~P65I$f(U|NBFIWxs!Ens$!xA%#8u4ip! zFbU4F17FMvh2t!LnB`Bh{1Mh%WmGHX>69R(fJ#hSpNV#ifkHIy&GIT`ikN)n7;}gz zV{}X&Q_AFHP2EBAsxDeq`{EJY#E_<=7~3vG`=>CJwiKd%(j8sr!?4O!i0RWDp1Ku_ zV%~(JfhMAFyuy+yQ#^;A!+X#=6^VfjiQs{~6D4Tv--2h&-9G)o8V>XCc~4{Eb&>^| zAoG0?V|9P3lWrV~>~iwBeJ9||jFf(94F+0ts#NE+;0h?z#5f}X^JOEqxD{$;h z$nSV~ZX+5d*U~06@D9C~G)~1{la^@TTA{v#12v{hD(ch35QlB^IzbyZcY40?V<+En zOr=k&h^;jg(9paeFO5h^_(&>Tn}8S+Gny#JzKNoLKfsmpOFP)ih_|BPg&pqe6xB0fv zd{1~_jNpjJ)P$%Ql`(8=Zf;6ZiATIB`VJt+2rgVGG%G=H6m-p#kn-W@Jfc(;@KQmrpK{T2e)_h>1OBQt9^3 zlLi(mA&sQo&1&#^M;Tq}@b~kz>j?>96;-5N6yZ67Sc7USkFA5jI89@qmqpAtY)wK@ zw4rOUn=V^hIS}26`7^t4y89ujCj~5+^P+3E*Su6lMF(bjz|jvpetlPrdZ&P{XNwx; zuXERqgfo7O&MuY%+@)!>037#Qg#SF>OMfq!xuz6hP=~g`tldZ1oLiGJ1CvUbaGr$q*O)QcyWMk!d;SL>NA0duWS zcUH$65NHl2aNcxsh03t5H<>2)jRR_?bXYx=jtf&~u;OjKBqpxeVyJUA8gQUni%Sc> zXqfl!G|EAZ>IFIGua9pXf>3BSRbIokbptibA5l=p%qnav&c;y)VNB`7-%9tx4m!}D zW%T*83v|v}@O^h8I={V9W^M`S{+^_&A9fhB%i$DY%S;Sf=gR)wZH0{k4l_T6uxk_Z PcfBE%0AJE=8NmMp+KY2r diff --git a/ChartGrid.js b/ChartGrid.js index 9601f03de..e1aeee53d 100644 --- a/ChartGrid.js +++ b/ChartGrid.js @@ -476,8 +476,8 @@ y: j }; - point1 = timeLineCoordinateSystem.inverseTransform(point1, container.frame.height); - point2 = timeLineCoordinateSystem.inverseTransform(point2, container.frame.height); + point1 = timeLineCoordinateSystem.transformThisPoint(point1); + point2 = timeLineCoordinateSystem.transformThisPoint(point2); point1 = transformThisPoint(point1, container); point2 = transformThisPoint(point2, container); @@ -540,8 +540,8 @@ y: timeLineCoordinateSystem.max.y }; - point3 = timeLineCoordinateSystem.inverseTransform(point3, container.frame.height); - point4 = timeLineCoordinateSystem.inverseTransform(point4, container.frame.height); + point3 = timeLineCoordinateSystem.transformThisPoint(point3); + point4 = timeLineCoordinateSystem.transformThisPoint(point4); point3 = transformThisPoint(point3, container); point4 = transformThisPoint(point4, container); diff --git a/ProductCard.js b/ProductCard.js index 957bc0f5a..6b73e15d5 100644 --- a/ProductCard.js +++ b/ProductCard.js @@ -1,6 +1,6 @@ function newProductCard() { - const CONSOLE_LOG = true; + const CONSOLE_LOG = false; var thisObject = { container: undefined, diff --git a/TimeLineCoordinateSystem.js b/TimeLineCoordinateSystem.js index 631faad4e..fe4cc88b3 100644 --- a/TimeLineCoordinateSystem.js +++ b/TimeLineCoordinateSystem.js @@ -13,8 +13,8 @@ function newTimeLineCoordinateSystem() { min: undefined, max: undefined, scale: undefined, - inverseTransform: inverseTransform, - inverseTransform2: inverseTransform2, + transformThisPoint: transformThisPoint, + transformThisPoint2: transformThisPoint2, unInverseTransform: unInverseTransform, inverseTransformUncappedY: inverseTransformUncappedY, initializeX: initializeX, @@ -41,9 +41,11 @@ function newTimeLineCoordinateSystem() { thisObject.max = max; thisObject.scale = scale; + let maxHeight; + return thisObject; - function initialize(minValue, maxValue, maxWidth, maxHeight) { + function initialize(minValue, maxValue, maxWidth, pMaxHeight) { /* Defines the min and max value of rate that we are going to transport to the available screen at the center position. */ @@ -56,7 +58,9 @@ function newTimeLineCoordinateSystem() { /* Defines the initial Zoom level at center position. */ thisObject.scale.x = maxWidth / (thisObject.max.x - thisObject.min.x); - thisObject.scale.y = maxHeight / (thisObject.max.y - thisObject.min.y); + thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y); + + maxHeight = pMaxHeight; } @@ -69,32 +73,33 @@ function newTimeLineCoordinateSystem() { } - function initializeY(minValue, maxValue, maxHeight) { + function initializeY(minValue, maxValue, pMaxHeight) { thisObject.min.y = minValue.y; // * 0.999; // 0.1% less thisObject.max.y = maxValue.y; // * 1.001; // 0.1% more - thisObject.scale.y = maxHeight / (thisObject.max.y - thisObject.min.y); + thisObject.scale.y = pMaxHeight / (thisObject.max.y - thisObject.min.y); + maxHeight = pMaxHeight; } - function inverseTransform(point, inverseY) { + function transformThisPoint(point) { point = { x: (point.x - this.min.x) * this.scale.x, - y: inverseY - (point.y - this.min.y) * this.scale.y + y: maxHeight - (point.y - this.min.y) * this.scale.y }; return point; } - function inverseTransform2(point, inverseY) { + function transformThisPoint2(point) { point = { x: (point.x - this.min.x) * this.scale.x, - y: (inverseY - point.y - this.min.y) * this.scale.y + y: (maxHeight- point.y - this.min.y) * this.scale.y }; return point;