diff --git a/.gitignore b/.gitignore new file mode 100755 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 670dba6..a29a7ac --- a/README.md +++ b/README.md @@ -1,3 +1 @@ # scatter-pod - -Scatter Pod \ No newline at end of file diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js new file mode 100755 index 0000000..f189e91 --- /dev/null +++ b/build/webpack.base.conf.js @@ -0,0 +1,35 @@ +const path = require('path'); + + +function resolve(dir) { + return path.join(__dirname, '..', dir) +} + +module.exports = { + context: resolve('src'), + entry: './index.ts', + plugins: [], + module: { + rules: [ + { + test: /\.ts$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /\.css$/, + use: ['style-loader', 'css-loader'], + exclude: /node_modules/ + } + ], + }, + resolve: { + extensions: ['.ts', '.js'], + }, + output: { + filename: 'index.js', + path: resolve('dist'), + libraryTarget: 'umd', + umdNamedDefine: true + } +}; diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js new file mode 100755 index 0000000..9a05316 --- /dev/null +++ b/build/webpack.dev.conf.js @@ -0,0 +1,8 @@ +const baseWebpackConfig = require('./webpack.base.conf'); + +var conf = baseWebpackConfig; +conf.devtool = 'inline-source-map'; +conf.watch = true; +conf.mode = 'development'; + +module.exports = conf; diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js new file mode 100755 index 0000000..94cb91d --- /dev/null +++ b/build/webpack.prod.conf.js @@ -0,0 +1,6 @@ +const baseWebpackConfig = require('./webpack.base.conf'); + +var conf = baseWebpackConfig; +conf.mode = 'production'; + +module.exports = baseWebpackConfig; diff --git a/demo.html b/demo.html new file mode 100644 index 0000000..78cbb2a --- /dev/null +++ b/demo.html @@ -0,0 +1,86 @@ + + +
+ + + + + + + + + + + diff --git a/dist/delaunay.d.ts b/dist/delaunay.d.ts new file mode 100644 index 0000000..4f8ec4a --- /dev/null +++ b/dist/delaunay.d.ts @@ -0,0 +1,15 @@ +import { ScatterData } from './types'; +import * as d3 from 'd3'; +export declare class DelaunayDiagram { + protected series: ScatterData[]; + private _delaunayData; + private _delaunayDiagram; + constructor(series: ScatterData[], xScale: d3.ScaleLinear>1)+h+t+M+k.slice(S);break;default:t=k+h+t+M}return a(t)}return y=void 0===y?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=Cc(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(kc(n)/3))),i=Math.pow(10,-r),o=Dc[8+r/3];return function(t){return e(i*t)+o}}}};function Uc(t){return Oc=Fc(t),jc=Oc.format,Rc=Oc.formatPrefix,Oc}Uc({decimal:".",thousands:",",grouping:[3],currency:["$",""],minus:"-"});var Bc=function(t){return Math.max(0,-kc(Math.abs(t)))},qc=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(kc(n)/3)))-kc(Math.abs(t)))},Vc=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,kc(n)-kc(t))+1},Yc=function(){return new Hc};function Hc(){this.reset()}Hc.prototype={constructor:Hc,reset:function(){this.s=this.t=0},add:function(t){Wc($c,t,this.t),Wc(this,$c.s,this.s),this.s?this.t+=$c.t:this.s=$c.t},valueOf:function(){return this.s}};var $c=new Hc;function Wc(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Gc=Math.PI,Xc=Gc/2,Zc=Gc/4,Kc=2*Gc,Qc=180/Gc,Jc=Gc/180,tf=Math.abs,nf=Math.atan,ef=Math.atan2,rf=Math.cos,of=Math.ceil,uf=Math.exp,af=(Math.floor,Math.log),cf=Math.pow,ff=Math.sin,sf=Math.sign||function(t){return t>0?1:t<0?-1:0},lf=Math.sqrt,hf=Math.tan;function df(t){return t>1?0:t<-1?Gc:Math.acos(t)}function pf(t){return t>1?Xc:t<-1?-Xc:Math.asin(t)}function vf(t){return(t=ff(t/2))*t}function yf(){}function gf(t,n){t&&bf.hasOwnProperty(t.type)&&bf[t.type](t,n)}var _f={Feature:function(t,n){gf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=rf(n=(n*=Jc)/2+Zc),u=ff(n),a=kf*u,c=Sf*o+a*rf(i),f=a*r*ff(i);Cf.add(ef(f,c)),Af=t,Sf=o,kf=u}var Pf=function(t){return Tf.reset(),Ef(t,Nf),2*Tf};function If(t){return[ef(t[1],t[0]),pf(t[2])]}function Lf(t){var n=t[0],e=t[1],r=rf(e);return[r*rf(n),r*ff(n),ff(e)]}function Df(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function Ff(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Uf(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Bf(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function qf(t){var n=lf(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var Vf,Yf,Hf,$f,Wf,Gf,Xf,Zf,Kf,Qf,Jf=Yc(),ts={point:ns,lineStart:rs,lineEnd:is,polygonStart:function(){ts.point=os,ts.lineStart=us,ts.lineEnd=as,Jf.reset(),Nf.polygonStart()},polygonEnd:function(){Nf.polygonEnd(),ts.point=ns,ts.lineStart=rs,ts.lineEnd=is,Cf<0?(Vf=-(Hf=180),Yf=-($f=90)):Jf>1e-6?$f=90:Jf<-1e-6&&(Yf=-90),Qf[0]=Vf,Qf[1]=Hf},sphere:function(){Vf=-(Hf=180),Yf=-($f=90)}};function ns(t,n){Kf.push(Qf=[Vf=t,Hf=t]),n >>1;f[v]1e-12)if(p>sx-1e-12)a.moveTo(l*rx(h),l*ux(h)),a.arc(0,0,l,h,d,!v),s>1e-12&&(a.moveTo(s*rx(d),s*ux(d)),a.arc(0,0,s,d,h,v));else{var y,g,_=h,b=d,m=h,x=d,w=p,M=p,A=u.apply(this,arguments)/2,S=A>1e-12&&(r?+r.apply(this,arguments):ax(s*s+l*l)),k=ox(nx(l-s)/2,+e.apply(this,arguments)),E=k,C=k;if(S>1e-12){var T=hx(S/s*ux(A)),N=hx(S/l*ux(A));(w-=2*T)>1e-12?(m+=T*=v?1:-1,x-=T):(w=0,m=x=(h+d)/2),(M-=2*N)>1e-12?(_+=N*=v?1:-1,b-=N):(M=0,_=b=(h+d)/2)}var O=l*rx(_),j=l*ux(_),R=s*rx(x),z=s*ux(x);if(k>1e-12){var P,I=l*rx(b),L=l*ux(b),D=s*rx(m),F=s*ux(m);if(p0){if(o>l)return;o>s&&(s=o)}if(o=r-c,h||!(o<0)){if(o/=h,h<0){if(o>l)return;o>s&&(s=o)}else if(h>0){if(o0)){if(o/=d,d<0){if(o0){if(o>l)return;o>s&&(s=o)}if(o=i-f,d||!(o<0)){if(o/=d,d<0){if(o>l)return;o>s&&(s=o)}else if(d>0){if(o0||l<1)||(s>0&&(t[0]=[c+s*h,f+s*d]),l<1&&(t[1]=[c+l*h,f+l*d]),!0)}}}}}function NM(t,n,e,r,i){var o=t[1];if(o)return!0;var u,a,c=t[0],f=t.left,s=t.right,l=f[0],h=f[1],d=s[0],p=s[1],v=(l+d)/2,y=(h+p)/2;if(p===h){if(vr?(r+i)/2:Math.min(0,r)||Math.max(0,i),u>o?(o+u)/2:Math.min(0,o)||Math.max(0,u))}var vA,yA=function(){var t,n,e=fA,r=sA,i=pA,o=hA,u=dA,a=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],f=250,s=Gp,l=$t("start","zoom","end"),h=0;function d(t){t.property("__zoom",lA).on("wheel.zoom",m).on("mousedown.zoom",x).on("dblclick.zoom",w).filter(u).on("touchstart.zoom",M).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(t,n){return(n=Math.max(a[0],Math.min(a[1],n)))===t.k?t:new iA(n,t.x,t.y)}function v(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new iA(t.k,r,i)}function y(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function g(t,n,e){t.on("start.zoom",(function(){_(this,arguments).start()})).on("interrupt.zoom end.zoom",(function(){_(this,arguments).end()})).tween("zoom",(function(){var t=this,i=arguments,o=_(t,i),u=r.apply(t,i),a=null==e?y(u):"function"==typeof e?e.apply(t,i):e,c=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),f=t.__zoom,l="function"==typeof n?n.apply(t,i):n,h=s(f.invert(a).concat(c/f.k),l.invert(a).concat(c/l.k));return function(t){if(1===t)t=l;else{var n=h(t),e=c/n[2];t=new iA(e,a[0]-n[0]*e,a[1]-n[1]*e)}o.zoom(null,t)}}))}function _(t,n,e){return!e&&t.__zooming||new b(t,n)}function b(t,n){this.that=t,this.args=n,this.active=0,this.extent=r.apply(t,n),this.taps=0}function m(){if(e.apply(this,arguments)){var t=_(this,arguments),n=this.__zoom,r=Math.max(a[0],Math.min(a[1],n.k*Math.pow(2,o.apply(this,arguments)))),u=pr(this);if(t.wheel)t.mouse[0][0]===u[0]&&t.mouse[0][1]===u[1]||(t.mouse[1]=n.invert(t.mouse[0]=u)),clearTimeout(t.wheel);else{if(n.k===r)return;t.mouse=[u,n.invert(u)],qr(this),t.start()}cA(),t.wheel=setTimeout(f,150),t.zoom("mouse",i(v(p(n,r),t.mouse[0],t.mouse[1]),t.extent,c))}function f(){t.wheel=null,t.end()}}function x(){if(!n&&e.apply(this,arguments)){var t=_(this,arguments,!0),r=oe(Hn.view).on("mousemove.zoom",f,!0).on("mouseup.zoom",s,!0),o=pr(this),u=Hn.clientX,a=Hn.clientY;ce(Hn.view),aA(),t.mouse=[o,this.__zoom.invert(o)],qr(this),t.start()}function f(){if(cA(),!t.moved){var n=Hn.clientX-u,e=Hn.clientY-a;t.moved=n*n+e*e>h}t.zoom("mouse",i(v(t.that.__zoom,t.mouse[0]=pr(t.that),t.mouse[1]),t.extent,c))}function s(){r.on("mousemove.zoom mouseup.zoom",null),fe(Hn.view,t.moved),cA(),t.end()}}function w(){if(e.apply(this,arguments)){var t=this.__zoom,n=pr(this),o=t.invert(n),u=t.k*(Hn.shiftKey?.5:2),a=i(v(p(t,u),n,o),r.apply(this,arguments),c);cA(),f>0?oe(this).transition().duration(f).call(g,a,n):oe(this).call(d.transform,a)}}function M(){if(e.apply(this,arguments)){var n,r,i,o,u=Hn.touches,a=u.length,c=_(this,arguments,Hn.changedTouches.length===a);for(aA(),r=0;r;
+export declare type ScatterOptions = Options & Partial