{ "_args": [ [ { "raw": "d3-brush@1.0.4", "scope": null, "escapedName": "d3-brush", "name": "d3-brush", "rawSpec": "1.0.4", "spec": "1.0.4", "type": "version" }, "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3" ] ], "_from": "d3-brush@1.0.4", "_id": "d3-brush@1.0.4", "_inCache": true, "_location": "/d3-brush", "_nodeVersion": "7.3.0", "_npmOperationalInternal": { "host": "packages-18-east.internal.npmjs.com", "tmp": "tmp/d3-brush-1.0.4.tgz_1489169705167_0.8677684487774968" }, "_npmUser": { "name": "mbostock", "email": "mike@ocks.org" }, "_npmVersion": "3.10.10", "_phantomChildren": {}, "_requested": { "raw": "d3-brush@1.0.4", "scope": null, "escapedName": "d3-brush", "name": "d3-brush", "rawSpec": "1.0.4", "spec": "1.0.4", "type": "version" }, "_requiredBy": [ "/d3" ], "_resolved": "https://registry.npmjs.org/d3-brush/-/d3-brush-1.0.4.tgz", "_shasum": "00c2f238019f24f6c0a194a26d41a1530ffe7bc4", "_shrinkwrap": null, "_spec": "d3-brush@1.0.4", "_where": "C:\\Users\\Giuliano\\worldwind\\nasaworldwind\\node\\node_modules\\d3", "author": { "name": "Mike Bostock", "url": "http://bost.ocks.org/mike" }, "bugs": { "url": "https://github.com/d3/d3-brush/issues" }, "dependencies": { "d3-dispatch": "1", "d3-drag": "1", "d3-interpolate": "1", "d3-selection": "1", "d3-transition": "1" }, "description": "Select a one- or two-dimensional region using the mouse or touch.", "devDependencies": { "eslint": "3", "package-preamble": "0.0", "rollup": "0.41", "tape": "4", "uglify-js": "^2.8.11" }, "directories": {}, "dist": { "shasum": "00c2f238019f24f6c0a194a26d41a1530ffe7bc4", "tarball": "https://registry.npmjs.org/d3-brush/-/d3-brush-1.0.4.tgz" }, "gitHead": "0544e1352d59c24230bb95bd6ba151823c0dde8e", "homepage": "https://d3js.org/d3-brush/", "jsnext:main": "index", "keywords": [ "d3", "d3-module", "brush", "interaction" ], "license": "BSD-3-Clause", "main": "build/d3-brush.js", "maintainers": [ { "name": "mbostock", "email": "mike@ocks.org" } ], "module": "index", "name": "d3-brush", "optionalDependencies": {}, "readme": "# d3-brush\n\nBrushing is the interactive specification a one- or two-dimensional selected region using a pointing gesture, such as by clicking and dragging the mouse. Brushing is often used to select discrete elements, such as dots in a scatterplot or files on a desktop. It can also be used to zoom-in to a region of interest, or to select continuous regions for [cross-filtering data](http://square.github.io/crossfilter/) or live histograms:\n\n[\"Mona](http://bl.ocks.org/mbostock/0d20834e3d5a46138752f86b9b79727e)\n\nThe d3-brush module implements brushing for mouse and touch events using [SVG](https://www.w3.org/TR/SVG/). Click and drag on the brush selection to translate the selection. Click and drag on one of the selection handles to move the corresponding edge (or edges) of the selection. Click and drag on the invisible overlay to define a new brush selection, or click anywhere within the brushable region while holding down the META (⌘) key. Holding down the ALT (⌥) key while moving the brush causes it to reposition around its center, while holding down SPACE locks the current brush size, allowing only translation.\n\nBrushes also support programmatic control. For example, you can listen to [*end* events](#brush-events), and then initiate a transition with [*brush*.move](#brush_move) to snap the brush selection to semantic boundaries:\n\n[\"Brush](http://bl.ocks.org/mbostock/6232537)\n\n## Installing\n\nIf you use NPM, `npm install d3-brush`. Otherwise, download the [latest release](https://github.com/d3/d3-brush/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-brush.v1.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:\n\n```html\n\n\n\n\n\n\n\n\n\n\n```\n\n[Try d3-brush in your browser.](https://tonicdev.com/npm/d3-brush)\n\n## API Reference\n\n# d3.brush() [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L131 \"Source\")\n\nCreates a new two-dimensional brush.\n\n# d3.brushX() [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L123 \"Source\")\n\nCreates a new one-dimensional brush along the *x*-dimension.\n\n# d3.brushY() [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L127 \"Source\")\n\nCreates a new one-dimensional brush along the *y*-dimension.\n\n# brush(group) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L142 \"Source\")\n\nApplies the brush to the specified *group*, which must be a [selection](https://github.com/d3/d3-selection) of SVG [G elements](https://www.w3.org/TR/SVG/struct.html#Groups). This function is typically not invoked directly, and is instead invoked via [*selection*.call](https://github.com/d3/d3-selection#selection_call). For example, to render a brush:\n\n```js\nsvg.append(\"g\")\n .attr(\"class\", \"brush\")\n .call(d3.brush().on(\"brush\", brushed));\n```\n\nInternally, the brush uses [*selection*.on](https://github.com/d3/d3-selection#selection_on) to bind the necessary event listeners for dragging. The listeners use the name `.brush`, so you can subsequently unbind the brush event listeners as follows:\n\n```js\ngroup.on(\".brush\", null);\n```\n\nThe brush also creates the SVG elements necessary to display the brush selection and to receive input events for interaction. You can add, remove or modify these elements as desired to change the brush appearance; you can also apply stylesheets to modify the brush appearance. The structure of a two-dimensional brush is as follows:\n\n```html\n\n \n \n \n \n \n \n \n \n \n \n\n```\n\nThe overlay rect covers the brushable area defined by [*brush*.extent](#brush_extent). The selection rect covers the area defined by the current [brush selection](#brushSelection). The handle rects cover the edges and corners of the brush selection, allowing the corresponding value in the brush selection to be modified interactively. To modify the brush selection programmatically, use [*brush*.move](#brush_move).\n\n# brush.move(group, selection) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L189 \"Source\")\n\nSets 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.\n\n# brush.extent([extent]) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L521 \"Source\")\n\nIf *extent* is specified, sets the brushable extent to the specified array of points [[*x0*, *y0*], [*x1*, *y1*]], where [*x0*, *y0*] is the top-left corner and [*x1*, *y1*] is the bottom-right corner, and returns this brush. The *extent* 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. If *extent* is not specified, returns the current extent accessor, which defaults to:\n\n```js\nfunction extent() {\n var svg = this.ownerSVGElement || this;\n return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]];\n}\n```\n\nThis default implementation requires that the owner SVG element have defined [width](https://www.w3.org/TR/SVG/struct.html#SVGElementWidthAttribute) and [height](https://www.w3.org/TR/SVG/struct.html#SVGElementHeightAttribute) attributes rather than (for example) relying on CSS properties or the viewBox attribute; SVG provides no programmatic method for retrieving the [initial viewport size](https://www.w3.org/TR/SVG/coords.html#ViewportSpace). Alternatively, consider using [*element*.getBoundingClientRect](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect). (In Firefox, [*element*.clientWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth) and [*element*.clientHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight) is zero for SVG elements!)\n\nThe brush extent determines the size of the invisible overlay and also constrains the brush selection; the brush selection cannot go outside the brush extent.\n\n# brush.filter([filter]) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L525 \"Source\")\n\nIf *filter* is specified, sets the filter to the specified function and returns the brush. If *filter* is not specified, returns the current filter, which defaults to:\n\n```js\nfunction filter() {\n return !event.button;\n}\n```\n\nIf the filter returns falsey, the initiating event is ignored and no brush gesture is started. Thus, the filter determines which input events are ignored. The default filter ignores mousedown events on secondary buttons, since those buttons are typically intended for other purposes, such as the context menu.\n\n# brush.handleSize([size]) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L529 \"Source\")\n\nIf *size* is specified, sets the size of the brush handles to the specified number and returns the brush. If *size* is not specified, returns the current handle size, which defaults to six. This method must be called before [applying the brush](#_brush) to a selection; changing the handle size does not affect brushes that were previously rendered.\n\n# brush.on(typenames, [listener]) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L533 \"Source\")\n\nIf *listener* is specified, sets the event *listener* for the specified *typenames* and returns the brush. If an event listener was already registered for the same type and name, the existing listener is removed before the new listener is added. If *listener* is null, removes the current event listeners for the specified *typenames*, if any. If *listener* is not specified, returns the first currently-assigned listener matching the specified *typenames*, if any. When a specified event is dispatched, each *listener* will be invoked with the same context and arguments as [*selection*.on](https://github.com/d3/d3-selection#selection_on) listeners: the current datum `d` and index `i`, with the `this` context as the current DOM element.\n\nThe *typenames* is a string containing one or more *typename* separated by whitespace. Each *typename* is a *type*, optionally followed by a period (`.`) and a *name*, such as `brush.foo` and `brush.bar`; the name allows multiple listeners to be registered for the same *type*. The *type* must be one of the following:\n\n* `start` - at the start of a brush gesture, such as on mousedown.\n* `brush` - when the brush moves, such as on mousemove.\n* `end` - at the end of a brush gesture, such as on mouseup.\n\nSee [*dispatch*.on](https://github.com/d3/d3-dispatch#dispatch_on) and [Brush Events](#brush-events) for more.\n\n# d3.brushSelection(node) [<>](https://github.com/d3/d3-brush/blob/master/src/brush.js#L118 \"Source\")\n\nReturns the current brush selection for the specified *node*. Internally, an element’s brush state is stored as *element*.\\_\\_brush; however, you should use this method rather than accessing it directly. If the given *node* has no selection, returns null. Otherwise, the *selection* is defined as an array of numbers. For a [two-dimensional brush](#brush), it is [[*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 is [*x0*, *x1*]; for a [*y*-brush](#brushY), it is [*y0*, *y1*].\n\n### Brush Events\n\nWhen a [brush event listener](#brush_on) is invoked, [d3.event](https://github.com/d3/d3-selection#event) is set to the current brush event. The *event* object exposes several fields:\n\n* `target` - the associated [brush behavior](#brush).\n* `type` - the string “start”, “brush” or “end”; see [*brush*.on](#brush_on).\n* `selection` - the current [brush selection](#brushSelection).\n* `sourceEvent` - the underlying input event, such as mousemove or touchmove.\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/d3/d3-brush.git" }, "scripts": { "postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3-brush/build/d3-brush.js d3-brush.v1.js && cp ../d3-brush/build/d3-brush.min.js d3-brush.v1.min.js && git add d3-brush.v1.js d3-brush.v1.min.js && git commit -m \"d3-brush ${npm_package_version}\" && git push && cd - && zip -j build/d3-brush.zip -- LICENSE README.md build/d3-brush.js build/d3-brush.min.js", "prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-brush.js -c -m -o build/d3-brush.min.js", "pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -g d3-dispatch:d3,d3-drag:d3,d3-interpolate:d3,d3-selection:d3,d3-transition:d3 -f umd -n d3 -o build/d3-brush.js -- index.js", "test": "tape 'test/**/*-test.js' && eslint index.js src" }, "version": "1.0.4" }