Socket
Socket
Sign inDemoInstall

d3-brush

Package Overview
Dependencies
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-brush - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

34

dist/d3-brush.js

@@ -1,7 +0,7 @@

// https://d3js.org/d3-brush/ v2.1.0 Copyright 2020 Mike Bostock
// https://d3js.org/d3-brush/ v3.0.0 Copyright 2010-2021 Mike Bostock
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-dispatch'), require('d3-drag'), require('d3-interpolate'), require('d3-selection'), require('d3-transition')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-dispatch', 'd3-drag', 'd3-interpolate', 'd3-selection', 'd3-transition'], factory) :
(global = global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3, global.d3, global.d3, global.d3));
}(this, function (exports, d3Dispatch, d3Drag, d3Interpolate, d3Selection, d3Transition) { 'use strict';
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.d3 = global.d3 || {}, global.d3, global.d3, global.d3, global.d3, global.d3));
}(this, (function (exports, d3Dispatch, d3Drag, d3Interpolate, d3Selection, d3Transition) { 'use strict';

@@ -240,3 +240,3 @@ var constant = x => () => x;

brush.move = function(group, selection) {
brush.move = function(group, selection, event) {
if (group.tween) {

@@ -274,3 +274,3 @@ group

redraw.call(that);
emit.start().brush().end();
emit.start(event).brush(event).end(event);
});

@@ -280,4 +280,4 @@ }

brush.clear = function(group) {
brush.move(group, null);
brush.clear = function(group, event) {
brush.move(group, null, event);
};

@@ -393,2 +393,5 @@

d3Transition.interrupt(that);
var emit = emitter(that, arguments, true).beforestart();
if (type === "overlay") {

@@ -404,3 +407,3 @@ if (selection) moving = true;

]];
if (points.length > 1) move();
if (points.length > 1) move(event);
} else {

@@ -424,5 +427,2 @@ w0 = selection[0][0];

d3Transition.interrupt(that);
var emit = emitter(that, arguments, true).beforestart();
if (event.touches) {

@@ -553,3 +553,3 @@ emit.moved = moved;

mode = MODE_CENTER;
move();
move(event);
}

@@ -564,3 +564,3 @@ break;

overlay.attr("cursor", cursors.selection);
move();
move(event);
}

@@ -579,3 +579,3 @@ break;

lockX = lockY = shifting = false;
move();
move(event);
}

@@ -589,3 +589,3 @@ break;

mode = MODE_HANDLE;
move();
move(event);
}

@@ -606,3 +606,3 @@ break;

overlay.attr("cursor", cursors[type]);
move();
move(event);
}

@@ -667,2 +667,2 @@ break;

}));
})));

@@ -1,2 +0,2 @@

// https://d3js.org/d3-brush/ v2.1.0 Copyright 2020 Mike Bostock
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-dispatch"),require("d3-drag"),require("d3-interpolate"),require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["exports","d3-dispatch","d3-drag","d3-interpolate","d3-selection","d3-transition"],t):t((e=e||self).d3=e.d3||{},e.d3,e.d3,e.d3,e.d3,e.d3)}(this,function(e,t,n,r,i,s){"use strict";var u=e=>()=>e;function o(e,{sourceEvent:t,target:n,selection:r,mode:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function a(e){e.preventDefault(),e.stopImmediatePropagation()}var l={name:"drag"},c={name:"space"},h={name:"handle"},f={name:"center"};const{abs:d,max:p,min:b}=Math;function y(e){return[+e[0],+e[1]]}function v(e){return[y(e[0]),y(e[1])]}var m={name:"x",handles:["w","e"].map(E),input:function(e,t){return null==e?null:[[+e[0],t[0][1]],[+e[1],t[1][1]]]},output:function(e){return e&&[e[0][0],e[1][0]]}},w={name:"y",handles:["n","s"].map(E),input:function(e,t){return null==e?null:[[t[0][0],+e[0]],[t[1][0],+e[1]]]},output:function(e){return e&&[e[0][1],e[1][1]]}},g={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(E),input:function(e){return null==e?null:v(e)},output:function(e){return e}},_={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},x={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},k={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},z={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},A={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function E(e){return{type:e}}function q(e){return!e.ctrlKey&&!e.button}function K(){var e=this.ownerSVGElement||this;return e.hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}function P(){return navigator.maxTouchPoints||"ontouchstart"in this}function T(e){for(;!e.__brush;)if(!(e=e.parentNode))return;return e.__brush}function V(e){var y,g=K,V=q,j=P,M=!0,S=t.dispatch("start","brush","end"),B=6;function C(t){var n=t.property("__brush",Y).selectAll(".overlay").data([E("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",_.overlay).merge(n).each(function(){var e=T(this).extent;i.select(this).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1])}),t.selectAll(".selection").data([E("selection")]).enter().append("rect").attr("class","selection").attr("cursor",_.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=t.selectAll(".handle").data(e.handles,function(e){return e.type});r.exit().remove(),r.enter().append("rect").attr("class",function(e){return"handle handle--"+e.type}).attr("cursor",function(e){return _[e.type]}),t.each(D).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",G).filter(j).on("touchstart.brush",G).on("touchmove.brush",N).on("touchend.brush touchcancel.brush",X).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function D(){var e=i.select(this),t=T(this).selection;t?(e.selectAll(".selection").style("display",null).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1]),e.selectAll(".handle").style("display",null).attr("x",function(e){return"e"===e.type[e.type.length-1]?t[1][0]-B/2:t[0][0]-B/2}).attr("y",function(e){return"s"===e.type[0]?t[1][1]-B/2:t[0][1]-B/2}).attr("width",function(e){return"n"===e.type||"s"===e.type?t[1][0]-t[0][0]+B:B}).attr("height",function(e){return"e"===e.type||"w"===e.type?t[1][1]-t[0][1]+B:B})):e.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function I(e,t,n){var r=e.__brush.emitter;return!r||n&&r.clean?new O(e,t,n):r}function O(e,t,n){this.that=e,this.args=t,this.state=e.__brush,this.active=0,this.clean=n}function G(t){if((!y||t.touches)&&V.apply(this,arguments)){var r,u,o,v,g,E,q,K,P,j,S,B=this,C=t.target.__data__.type,O="selection"===(M&&t.metaKey?C="overlay":C)?l:M&&t.altKey?f:h,G=e===w?null:z[C],N=e===m?null:A[C],X=T(B),Y=X.extent,F=X.selection,H=Y[0][0],J=Y[0][1],L=Y[1][0],Q=Y[1][1],R=0,U=0,W=G&&N&&M&&t.shiftKey,Z=Array.from(t.touches||[t],e=>{const t=e.identifier;return(e=i.pointer(e,B)).point0=e.slice(),e.identifier=t,e});if("overlay"===C){F&&(P=!0);const t=[Z[0],Z[1]||Z[0]];X.selection=F=[[r=e===w?H:b(t[0][0],t[1][0]),o=e===m?J:b(t[0][1],t[1][1])],[g=e===w?L:p(t[0][0],t[1][0]),q=e===m?Q:p(t[0][1],t[1][1])]],Z.length>1&&ie()}else r=F[0][0],o=F[0][1],g=F[1][0],q=F[1][1];u=r,v=o,E=g,K=q;var $=i.select(B).attr("pointer-events","none"),ee=$.selectAll(".overlay").attr("cursor",_[C]);s.interrupt(B);var te=I(B,arguments,!0).beforestart();if(t.touches)te.moved=re,te.ended=se;else{var ne=i.select(t.view).on("mousemove.brush",re,!0).on("mouseup.brush",se,!0);M&&ne.on("keydown.brush",function(e){switch(e.keyCode){case 16:W=G&&N;break;case 18:O===h&&(G&&(g=E-R*G,r=u+R*G),N&&(q=K-U*N,o=v+U*N),O=f,ie());break;case 32:O!==h&&O!==f||(G<0?g=E-R:G>0&&(r=u-R),N<0?q=K-U:N>0&&(o=v-U),O=c,ee.attr("cursor",_.selection),ie());break;default:return}a(e)},!0).on("keyup.brush",function(e){switch(e.keyCode){case 16:W&&(j=S=W=!1,ie());break;case 18:O===f&&(G<0?g=E:G>0&&(r=u),N<0?q=K:N>0&&(o=v),O=h,ie());break;case 32:O===c&&(e.altKey?(G&&(g=E-R*G,r=u+R*G),N&&(q=K-U*N,o=v+U*N),O=f):(G<0?g=E:G>0&&(r=u),N<0?q=K:N>0&&(o=v),O=h),ee.attr("cursor",_[C]),ie());break;default:return}a(e)},!0),n.dragDisable(t.view)}D.call(B),te.start(t,O.name)}function re(e){for(const t of e.changedTouches||[e])for(const e of Z)e.identifier===t.identifier&&(e.cur=i.pointer(t,B));if(W&&!j&&!S&&1===Z.length){const e=Z[0];d(e.cur[0]-e[0])>d(e.cur[1]-e[1])?S=!0:j=!0}for(const e of Z)e.cur&&(e[0]=e.cur[0],e[1]=e.cur[1]);P=!0,a(e),ie(e)}function ie(e){const t=Z[0],n=t.point0;var i;switch(R=t[0]-n[0],U=t[1]-n[1],O){case c:case l:G&&(R=p(H-r,b(L-g,R)),u=r+R,E=g+R),N&&(U=p(J-o,b(Q-q,U)),v=o+U,K=q+U);break;case h:Z[1]?(G&&(u=p(H,b(L,Z[0][0])),E=p(H,b(L,Z[1][0])),G=1),N&&(v=p(J,b(Q,Z[0][1])),K=p(J,b(Q,Z[1][1])),N=1)):(G<0?(R=p(H-r,b(L-r,R)),u=r+R,E=g):G>0&&(R=p(H-g,b(L-g,R)),u=r,E=g+R),N<0?(U=p(J-o,b(Q-o,U)),v=o+U,K=q):N>0&&(U=p(J-q,b(Q-q,U)),v=o,K=q+U));break;case f:G&&(u=p(H,b(L,r-R*G)),E=p(H,b(L,g+R*G))),N&&(v=p(J,b(Q,o-U*N)),K=p(J,b(Q,q+U*N)))}E<u&&(G*=-1,i=r,r=g,g=i,i=u,u=E,E=i,C in x&&ee.attr("cursor",_[C=x[C]])),K<v&&(N*=-1,i=o,o=q,q=i,i=v,v=K,K=i,C in k&&ee.attr("cursor",_[C=k[C]])),X.selection&&(F=X.selection),j&&(u=F[0][0],E=F[1][0]),S&&(v=F[0][1],K=F[1][1]),F[0][0]===u&&F[0][1]===v&&F[1][0]===E&&F[1][1]===K||(X.selection=[[u,v],[E,K]],D.call(B),te.brush(e,O.name))}function se(e){if(function(e){e.stopImmediatePropagation()}(e),e.touches){if(e.touches.length)return;y&&clearTimeout(y),y=setTimeout(function(){y=null},500)}else n.dragEnable(e.view,P),ne.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);$.attr("pointer-events","all"),ee.attr("cursor",_.overlay),X.selection&&(F=X.selection),function(e){return e[0][0]===e[1][0]||e[0][1]===e[1][1]}(F)&&(X.selection=null,D.call(B)),te.end(e,O.name)}}function N(e){I(this,arguments).moved(e)}function X(e){I(this,arguments).ended(e)}function Y(){var t=this.__brush||{selection:null};return t.extent=v(g.apply(this,arguments)),t.dim=e,t}return C.move=function(t,n){t.tween?t.on("start.brush",function(e){I(this,arguments).beforestart().start(e)}).on("interrupt.brush end.brush",function(e){I(this,arguments).end(e)}).tween("brush",function(){var t=this,i=t.__brush,s=I(t,arguments),u=i.selection,o=e.input("function"==typeof n?n.apply(this,arguments):n,i.extent),a=r.interpolate(u,o);function l(e){i.selection=1===e&&null===o?null:a(e),D.call(t),s.brush()}return null!==u&&null!==o?l:l(1)}):t.each(function(){var t=this,r=arguments,i=t.__brush,u=e.input("function"==typeof n?n.apply(t,r):n,i.extent),o=I(t,r).beforestart();s.interrupt(t),i.selection=null===u?null:u,D.call(t),o.start().brush().end()})},C.clear=function(e){C.move(e,null)},O.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(e,t){return this.starting?(this.starting=!1,this.emit("start",e,t)):this.emit("brush",e),this},brush:function(e,t){return this.emit("brush",e,t),this},end:function(e,t){return 0==--this.active&&(delete this.state.emitter,this.emit("end",e,t)),this},emit:function(t,n,r){var s=i.select(this.that).datum();S.call(t,this.that,new o(t,{sourceEvent:n,target:C,selection:e.output(this.state.selection),mode:r,dispatch:S}),s)}},C.extent=function(e){return arguments.length?(g="function"==typeof e?e:u(v(e)),C):g},C.filter=function(e){return arguments.length?(V="function"==typeof e?e:u(!!e),C):V},C.touchable=function(e){return arguments.length?(j="function"==typeof e?e:u(!!e),C):j},C.handleSize=function(e){return arguments.length?(B=+e,C):B},C.keyModifiers=function(e){return arguments.length?(M=!!e,C):M},C.on=function(){var e=S.on.apply(S,arguments);return e===S?C:e},C}e.brush=function(){return V(g)},e.brushSelection=function(e){var t=e.__brush;return t?t.dim.output(t.selection):null},e.brushX=function(){return V(m)},e.brushY=function(){return V(w)},Object.defineProperty(e,"__esModule",{value:!0})});
// https://d3js.org/d3-brush/ v3.0.0 Copyright 2010-2021 Mike Bostock
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-dispatch"),require("d3-drag"),require("d3-interpolate"),require("d3-selection"),require("d3-transition")):"function"==typeof define&&define.amd?define(["exports","d3-dispatch","d3-drag","d3-interpolate","d3-selection","d3-transition"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).d3=e.d3||{},e.d3,e.d3,e.d3,e.d3,e.d3)}(this,(function(e,t,n,r,i,s){"use strict";var u=e=>()=>e;function o(e,{sourceEvent:t,target:n,selection:r,mode:i,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:s}})}function a(e){e.stopImmediatePropagation()}function l(e){e.preventDefault(),e.stopImmediatePropagation()}var c={name:"drag"},h={name:"space"},f={name:"handle"},d={name:"center"};const{abs:p,max:b,min:y}=Math;function v(e){return[+e[0],+e[1]]}function m(e){return[v(e[0]),v(e[1])]}var w={name:"x",handles:["w","e"].map(T),input:function(e,t){return null==e?null:[[+e[0],t[0][1]],[+e[1],t[1][1]]]},output:function(e){return e&&[e[0][0],e[1][0]]}},g={name:"y",handles:["n","s"].map(T),input:function(e,t){return null==e?null:[[t[0][0],+e[0]],[t[1][0],+e[1]]]},output:function(e){return e&&[e[0][1],e[1][1]]}},_={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(T),input:function(e){return null==e?null:m(e)},output:function(e){return e}},x={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},k={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},z={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},A={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},E={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function T(e){return{type:e}}function q(e){return!e.ctrlKey&&!e.button}function K(){var e=this.ownerSVGElement||this;return e.hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]}function P(){return navigator.maxTouchPoints||"ontouchstart"in this}function V(e){for(;!e.__brush;)if(!(e=e.parentNode))return;return e.__brush}function j(e){return e[0][0]===e[1][0]||e[0][1]===e[1][1]}function M(e){var v,_=K,M=q,S=P,B=!0,C=t.dispatch("start","brush","end"),D=6;function I(t){var n=t.property("__brush",H).selectAll(".overlay").data([T("overlay")]);n.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",x.overlay).merge(n).each((function(){var e=V(this).extent;i.select(this).attr("x",e[0][0]).attr("y",e[0][1]).attr("width",e[1][0]-e[0][0]).attr("height",e[1][1]-e[0][1])})),t.selectAll(".selection").data([T("selection")]).enter().append("rect").attr("class","selection").attr("cursor",x.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=t.selectAll(".handle").data(e.handles,(function(e){return e.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(e){return"handle handle--"+e.type})).attr("cursor",(function(e){return x[e.type]})),t.each(O).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",X).filter(S).on("touchstart.brush",X).on("touchmove.brush",Y).on("touchend.brush touchcancel.brush",F).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function O(){var e=i.select(this),t=V(this).selection;t?(e.selectAll(".selection").style("display",null).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1]),e.selectAll(".handle").style("display",null).attr("x",(function(e){return"e"===e.type[e.type.length-1]?t[1][0]-D/2:t[0][0]-D/2})).attr("y",(function(e){return"s"===e.type[0]?t[1][1]-D/2:t[0][1]-D/2})).attr("width",(function(e){return"n"===e.type||"s"===e.type?t[1][0]-t[0][0]+D:D})).attr("height",(function(e){return"e"===e.type||"w"===e.type?t[1][1]-t[0][1]+D:D}))):e.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function G(e,t,n){var r=e.__brush.emitter;return!r||n&&r.clean?new N(e,t,n):r}function N(e,t,n){this.that=e,this.args=t,this.state=e.__brush,this.active=0,this.clean=n}function X(t){if((!v||t.touches)&&M.apply(this,arguments)){var r,u,o,m,_,T,q,K,P,S,C,D=this,I=t.target.__data__.type,N="selection"===(B&&t.metaKey?I="overlay":I)?c:B&&t.altKey?d:f,X=e===g?null:A[I],Y=e===w?null:E[I],F=V(D),H=F.extent,J=F.selection,L=H[0][0],Q=H[0][1],R=H[1][0],U=H[1][1],W=0,Z=0,$=X&&Y&&B&&t.shiftKey,ee=Array.from(t.touches||[t],(e=>{const t=e.identifier;return(e=i.pointer(e,D)).point0=e.slice(),e.identifier=t,e}));s.interrupt(D);var te=G(D,arguments,!0).beforestart();if("overlay"===I){J&&(P=!0);const n=[ee[0],ee[1]||ee[0]];F.selection=J=[[r=e===g?L:y(n[0][0],n[1][0]),o=e===w?Q:y(n[0][1],n[1][1])],[_=e===g?R:b(n[0][0],n[1][0]),q=e===w?U:b(n[0][1],n[1][1])]],ee.length>1&&ue(t)}else r=J[0][0],o=J[0][1],_=J[1][0],q=J[1][1];u=r,m=o,T=_,K=q;var ne=i.select(D).attr("pointer-events","none"),re=ne.selectAll(".overlay").attr("cursor",x[I]);if(t.touches)te.moved=se,te.ended=oe;else{var ie=i.select(t.view).on("mousemove.brush",se,!0).on("mouseup.brush",oe,!0);B&&ie.on("keydown.brush",ae,!0).on("keyup.brush",le,!0),n.dragDisable(t.view)}O.call(D),te.start(t,N.name)}function se(e){for(const t of e.changedTouches||[e])for(const e of ee)e.identifier===t.identifier&&(e.cur=i.pointer(t,D));if($&&!S&&!C&&1===ee.length){const e=ee[0];p(e.cur[0]-e[0])>p(e.cur[1]-e[1])?C=!0:S=!0}for(const e of ee)e.cur&&(e[0]=e.cur[0],e[1]=e.cur[1]);P=!0,l(e),ue(e)}function ue(e){const t=ee[0],n=t.point0;var i;switch(W=t[0]-n[0],Z=t[1]-n[1],N){case h:case c:X&&(W=b(L-r,y(R-_,W)),u=r+W,T=_+W),Y&&(Z=b(Q-o,y(U-q,Z)),m=o+Z,K=q+Z);break;case f:ee[1]?(X&&(u=b(L,y(R,ee[0][0])),T=b(L,y(R,ee[1][0])),X=1),Y&&(m=b(Q,y(U,ee[0][1])),K=b(Q,y(U,ee[1][1])),Y=1)):(X<0?(W=b(L-r,y(R-r,W)),u=r+W,T=_):X>0&&(W=b(L-_,y(R-_,W)),u=r,T=_+W),Y<0?(Z=b(Q-o,y(U-o,Z)),m=o+Z,K=q):Y>0&&(Z=b(Q-q,y(U-q,Z)),m=o,K=q+Z));break;case d:X&&(u=b(L,y(R,r-W*X)),T=b(L,y(R,_+W*X))),Y&&(m=b(Q,y(U,o-Z*Y)),K=b(Q,y(U,q+Z*Y)))}T<u&&(X*=-1,i=r,r=_,_=i,i=u,u=T,T=i,I in k&&re.attr("cursor",x[I=k[I]])),K<m&&(Y*=-1,i=o,o=q,q=i,i=m,m=K,K=i,I in z&&re.attr("cursor",x[I=z[I]])),F.selection&&(J=F.selection),S&&(u=J[0][0],T=J[1][0]),C&&(m=J[0][1],K=J[1][1]),J[0][0]===u&&J[0][1]===m&&J[1][0]===T&&J[1][1]===K||(F.selection=[[u,m],[T,K]],O.call(D),te.brush(e,N.name))}function oe(e){if(a(e),e.touches){if(e.touches.length)return;v&&clearTimeout(v),v=setTimeout((function(){v=null}),500)}else n.dragEnable(e.view,P),ie.on("keydown.brush keyup.brush mousemove.brush mouseup.brush",null);ne.attr("pointer-events","all"),re.attr("cursor",x.overlay),F.selection&&(J=F.selection),j(J)&&(F.selection=null,O.call(D)),te.end(e,N.name)}function ae(e){switch(e.keyCode){case 16:$=X&&Y;break;case 18:N===f&&(X&&(_=T-W*X,r=u+W*X),Y&&(q=K-Z*Y,o=m+Z*Y),N=d,ue(e));break;case 32:N!==f&&N!==d||(X<0?_=T-W:X>0&&(r=u-W),Y<0?q=K-Z:Y>0&&(o=m-Z),N=h,re.attr("cursor",x.selection),ue(e));break;default:return}l(e)}function le(e){switch(e.keyCode){case 16:$&&(S=C=$=!1,ue(e));break;case 18:N===d&&(X<0?_=T:X>0&&(r=u),Y<0?q=K:Y>0&&(o=m),N=f,ue(e));break;case 32:N===h&&(e.altKey?(X&&(_=T-W*X,r=u+W*X),Y&&(q=K-Z*Y,o=m+Z*Y),N=d):(X<0?_=T:X>0&&(r=u),Y<0?q=K:Y>0&&(o=m),N=f),re.attr("cursor",x[I]),ue(e));break;default:return}l(e)}}function Y(e){G(this,arguments).moved(e)}function F(e){G(this,arguments).ended(e)}function H(){var t=this.__brush||{selection:null};return t.extent=m(_.apply(this,arguments)),t.dim=e,t}return I.move=function(t,n,i){t.tween?t.on("start.brush",(function(e){G(this,arguments).beforestart().start(e)})).on("interrupt.brush end.brush",(function(e){G(this,arguments).end(e)})).tween("brush",(function(){var t=this,i=t.__brush,s=G(t,arguments),u=i.selection,o=e.input("function"==typeof n?n.apply(this,arguments):n,i.extent),a=r.interpolate(u,o);function l(e){i.selection=1===e&&null===o?null:a(e),O.call(t),s.brush()}return null!==u&&null!==o?l:l(1)})):t.each((function(){var t=this,r=arguments,u=t.__brush,o=e.input("function"==typeof n?n.apply(t,r):n,u.extent),a=G(t,r).beforestart();s.interrupt(t),u.selection=null===o?null:o,O.call(t),a.start(i).brush(i).end(i)}))},I.clear=function(e,t){I.move(e,null,t)},N.prototype={beforestart:function(){return 1==++this.active&&(this.state.emitter=this,this.starting=!0),this},start:function(e,t){return this.starting?(this.starting=!1,this.emit("start",e,t)):this.emit("brush",e),this},brush:function(e,t){return this.emit("brush",e,t),this},end:function(e,t){return 0==--this.active&&(delete this.state.emitter,this.emit("end",e,t)),this},emit:function(t,n,r){var s=i.select(this.that).datum();C.call(t,this.that,new o(t,{sourceEvent:n,target:I,selection:e.output(this.state.selection),mode:r,dispatch:C}),s)}},I.extent=function(e){return arguments.length?(_="function"==typeof e?e:u(m(e)),I):_},I.filter=function(e){return arguments.length?(M="function"==typeof e?e:u(!!e),I):M},I.touchable=function(e){return arguments.length?(S="function"==typeof e?e:u(!!e),I):S},I.handleSize=function(e){return arguments.length?(D=+e,I):D},I.keyModifiers=function(e){return arguments.length?(B=!!e,I):B},I.on=function(){var e=C.on.apply(C,arguments);return e===C?I:e},I}e.brush=function(){return M(_)},e.brushSelection=function(e){var t=e.__brush;return t?t.dim.output(t.selection):null},e.brushX=function(){return M(w)},e.brushY=function(){return M(g)},Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "d3-brush",
"version": "2.1.0",
"version": "3.0.0",
"description": "Select a one- or two-dimensional region using the mouse or touch.",
"homepage": "https://d3js.org/d3-brush/",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-brush.git"
},
"keywords": [

@@ -11,16 +16,8 @@ "d3",

],
"homepage": "https://d3js.org/d3-brush/",
"license": "BSD-3-Clause",
"license": "ISC",
"author": {
"name": "Mike Bostock",
"url": "http://bost.ocks.org/mike"
"url": "https://bost.ocks.org/mike"
},
"main": "dist/d3-brush.js",
"unpkg": "dist/d3-brush.min.js",
"jsdelivr": "dist/d3-brush.min.js",
"module": "src/index.js",
"repository": {
"type": "git",
"url": "https://github.com/d3/d3-brush.git"
},
"type": "module",
"files": [

@@ -30,21 +27,31 @@ "dist/**/*.js",

],
"scripts": {
"pretest": "rollup -c",
"test": "tape 'test/**/*-test.js' && eslint src",
"prepublishOnly": "rm -rf dist && yarn test",
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd - && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
"module": "src/index.js",
"main": "src/index.js",
"jsdelivr": "dist/d3-brush.min.js",
"unpkg": "dist/d3-brush.min.js",
"exports": {
"umd": "./dist/d3-brush.min.js",
"default": "./src/index.js"
},
"dependencies": {
"d3-dispatch": "1 - 2",
"d3-drag": "2",
"d3-interpolate": "1 - 2",
"d3-selection": "2",
"d3-transition": "2"
"d3-dispatch": "1 - 3",
"d3-drag": "2 - 3",
"d3-interpolate": "1 - 3",
"d3-selection": "3",
"d3-transition": "3"
},
"devDependencies": {
"eslint": "6",
"rollup": "1",
"rollup-plugin-terser": "5",
"tape": "4"
"eslint": "7",
"mocha": "9",
"rollup": "2",
"rollup-plugin-terser": "7"
},
"scripts": {
"test": "mocha 'test/**/*-test.js' && eslint src test",
"prepublishOnly": "rm -rf dist && yarn test && rollup -c && git push",
"postpublish": "git push --tags && cd ../d3.github.com && git pull && cp ../${npm_package_name}/dist/${npm_package_name}.js ${npm_package_name}.v${npm_package_version%%.*}.js && cp ../${npm_package_name}/dist/${npm_package_name}.min.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git add ${npm_package_name}.v${npm_package_version%%.*}.js ${npm_package_name}.v${npm_package_version%%.*}.min.js && git commit -m \"${npm_package_name} ${npm_package_version}\" && git push && cd -"
},
"engines": {
"node": ">=12"
}
}

@@ -19,17 +19,29 @@ # d3-brush

If you use NPM, `npm install d3-brush`. Otherwise, download the [latest release](https://github.com/d3/d3-brush/releases/latest). You can load as a [standalone library](https://d3js.org/d3-brush.v1.min.js) or as part of [D3](https://github.com/d3/d3). ES modules, AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
If you use npm, `npm install d3-brush`. You can also download the [latest release on GitHub](https://github.com/d3/d3-brush/releases/latest). For vanilla HTML in modern browsers, import d3-brush from Skypack:
```html
<script src="https://d3js.org/d3-color.v2.min.js"></script>
<script src="https://d3js.org/d3-dispatch.v2.min.js"></script>
<script src="https://d3js.org/d3-ease.v2.min.js"></script>
<script src="https://d3js.org/d3-interpolate.v2.min.js"></script>
<script src="https://d3js.org/d3-timer.v2.min.js"></script>
<script src="https://d3js.org/d3-selection.v2.min.js"></script>
<script src="https://d3js.org/d3-transition.v2.min.js"></script>
<script src="https://d3js.org/d3-drag.v2.min.js"></script>
<script src="https://d3js.org/d3-brush.v2.min.js"></script>
<script type="module">
import {brushX} from "https://cdn.skypack.dev/d3-brush@3";
const brush = brushX();
</script>
```
For legacy environments, you can load d3-brush’s UMD bundle from an npm-based CDN such as jsDelivr; a `d3` global is exported:
```html
<script src="https://cdn.jsdelivr.net/npm/d3-color@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-dispatch@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-ease@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-interpolate@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-selection@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-timer@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-drag@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-transition@3"></script>
<script src="https://cdn.jsdelivr.net/npm/d3-brush@3"></script>
<script>
var brush = d3.brush();
const brush = d3.brushX();

@@ -39,2 +51,3 @@ </script>

[Try d3-brush in your browser.](https://observablehq.com/collection/@d3/d3-brush)

@@ -91,7 +104,7 @@

<a href="#brush_move" name="brush_move">#</a> <i>brush</i>.<b>move</b>(<i>group</i>, <i>selection</i>) · [Source](https://github.com/d3/d3-brush/blob/master/src/brush.js), [Examples](https://observablehq.com/d/93b91f86f9ebc9b9)
<a href="#brush_move" name="brush_move">#</a> <i>brush</i>.<b>move</b>(<i>group</i>, <i>selection</i>[, <i>event</i>]) · [Source](https://github.com/d3/d3-brush/blob/master/src/brush.js), [Examples](https://observablehq.com/d/93b91f86f9ebc9b9)
Sets the active *selection* of the brush on the specified *group*, which must be a [selection](https://github.com/d3/d3-selection) or a [transition](https://github.com/d3/d3-transition) of SVG [G elements](https://www.w3.org/TR/SVG/struct.html#Groups). The *selection* must be defined as an array of numbers, or null to clear the brush selection. For a [two-dimensional brush](#brush), it must be defined as [[*x0*, *y0*], [*x1*, *y1*]], where *x0* is the minimum *x*-value, *y0* is the minimum *y*-value, *x1* is the maximum *x*-value, and *y1* is the maximum *y*-value. For an [*x*-brush](#brushX), it must be defined as [*x0*, *x1*]; for a [*y*-brush](#brushY), it must be defined as [*y0*, *y1*]. The selection may also be specified as a function which returns such an array; if a function, it is invoked for each selected element, being passed the current datum `d` and index `i`, with the `this` context as the current DOM element. The returned array defines the brush selection for that element.
<a href="#brush_clear" name="brush_clear">#</a> <i>brush</i>.<b>clear</b>(<i>group</i>) · [Source](https://github.com/d3/d3-brush/blob/master/src/brush.js), [Examples](https://observablehq.com/@d3/double-click-brush-clear)
<a href="#brush_clear" name="brush_clear">#</a> <i>brush</i>.<b>clear</b>(<i>group</i>[, <i>event</i>]) · [Source](https://github.com/d3/d3-brush/blob/master/src/brush.js), [Examples](https://observablehq.com/@d3/double-click-brush-clear)

@@ -98,0 +111,0 @@ An alias for [*brush*.move](#brush_move) with the null selection.

@@ -214,3 +214,3 @@ import {dispatch} from "d3-dispatch";

brush.move = function(group, selection) {
brush.move = function(group, selection, event) {
if (group.tween) {

@@ -248,3 +248,3 @@ group

redraw.call(that);
emit.start().brush().end();
emit.start(event).brush(event).end(event);
});

@@ -254,4 +254,4 @@ }

brush.clear = function(group) {
brush.move(group, null);
brush.clear = function(group, event) {
brush.move(group, null, event);
};

@@ -367,2 +367,5 @@

interrupt(that);
var emit = emitter(that, arguments, true).beforestart();
if (type === "overlay") {

@@ -378,3 +381,3 @@ if (selection) moving = true;

]];
if (points.length > 1) move();
if (points.length > 1) move(event);
} else {

@@ -398,5 +401,2 @@ w0 = selection[0][0];

interrupt(that);
var emit = emitter(that, arguments, true).beforestart();
if (event.touches) {

@@ -527,3 +527,3 @@ emit.moved = moved;

mode = MODE_CENTER;
move();
move(event);
}

@@ -538,3 +538,3 @@ break;

overlay.attr("cursor", cursors.selection);
move();
move(event);
}

@@ -553,3 +553,3 @@ break;

lockX = lockY = shifting = false;
move();
move(event);
}

@@ -563,3 +563,3 @@ break;

mode = MODE_HANDLE;
move();
move(event);
}

@@ -580,3 +580,3 @@ break;

overlay.attr("cursor", cursors[type]);
move();
move(event);
}

@@ -583,0 +583,0 @@ break;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc