├── .babelrc ├── .github └── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── .gitignore ├── .npmignore ├── LICENSE ├── README.md ├── _config.yml ├── example ├── all-modes │ └── index.html ├── ar-graph │ └── index.html ├── auto-colored │ └── index.html ├── basic │ └── index.html ├── bloom-effect │ └── index.html ├── camera-auto-orbit │ └── index.html ├── click-to-focus │ └── index.html ├── collision-detection │ └── index.html ├── curved-links │ └── index.html ├── custom-node-shape │ ├── index-canvas.html │ └── index-three.html ├── datasets │ ├── blocks.json │ ├── d3-dependencies.csv │ ├── forcegraph-dependencies.json │ ├── miserables.json │ └── random-data.js ├── directional-links-arrows │ └── index.html ├── directional-links-particles │ └── index.html ├── dynamic │ └── index.html ├── emit-particles │ └── index.html ├── expandable-nodes │ └── index.html ├── fit-to-canvas │ └── index.html ├── fix-dragged-nodes │ └── index.html ├── forcegraph-dependencies │ └── index.html ├── highlight │ └── index.html ├── html-nodes │ └── index.html ├── img-nodes │ ├── imgs │ │ ├── cat.jpg │ │ ├── dog.jpg │ │ ├── eagle.jpg │ │ ├── elephant.jpg │ │ ├── grasshopper.jpg │ │ ├── octopus.jpg │ │ ├── owl.jpg │ │ ├── panda.jpg │ │ ├── squirrel.jpg │ │ ├── tiger.jpg │ │ └── whale.jpg │ └── index.html ├── large-graph │ └── index.html ├── multi-selection │ └── index.html ├── preview.png ├── text-links │ └── index-3d.html ├── text-nodes │ ├── index-2d.html │ └── index-3d.html └── tree │ └── index.html ├── package.json ├── rollup.config.dev.js ├── rollup.config.js └── src ├── forcegraph-proptypes.js ├── index.d.ts ├── index.js └── packages ├── react-force-graph-2d ├── index.d.ts ├── index.js ├── package.json ├── rollup.config.dev.js └── rollup.config.js ├── react-force-graph-3d ├── index.d.ts ├── index.js ├── package.json ├── rollup.config.dev.js └── rollup.config.js ├── react-force-graph-ar ├── index.d.ts ├── index.js ├── package.json ├── rollup.config.dev.js └── rollup.config.js └── react-force-graph-vr ├── index.d.ts ├── index.js ├── package.json ├── rollup.config.dev.js └── rollup.config.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["@babel/preset-env", { "modules": false }], 4 | "@babel/preset-react" 5 | ] 6 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | dist/ 3 | yarn.lock 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | **/node_modules/ 2 | yarn.lock -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Vasco Asturiano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | react-force-graph 2 | ================= 3 | 4 | **2D**: 5 | [![NPM package][npm-2d-img]][npm-2d-url] 6 | [![Build Size][build-size-2d-img]][build-size-2d-url] 7 | [![NPM Downloads][npm-downloads-2d-img]][npm-downloads-2d-url] 8 | 9 | **3D**: 10 | [![NPM package][npm-3d-img]][npm-3d-url] 11 | [![Build Size][build-size-3d-img]][build-size-3d-url] 12 | [![NPM Downloads][npm-downloads-3d-img]][npm-downloads-3d-url] 13 | 14 | **VR**: 15 | [![NPM package][npm-vr-img]][npm-vr-url] 16 | [![Build Size][build-size-vr-img]][build-size-vr-url] 17 | [![NPM Downloads][npm-downloads-vr-img]][npm-downloads-vr-url] 18 | 19 | **AR**: 20 | [![NPM package][npm-ar-img]][npm-ar-url] 21 | [![Build Size][build-size-ar-img]][build-size-ar-url] 22 | [![NPM Downloads][npm-downloads-ar-img]][npm-downloads-ar-url] 23 | 24 | React bindings for the **force-graph** [suite](https://vasturiano.github.io/react-force-graph/example/forcegraph-dependencies) of components: [force-graph](https://github.com/vasturiano/force-graph) (2D HTML Canvas), [3d-force-graph](https://github.com/vasturiano/3d-force-graph) (ThreeJS/WebGL), [3d-force-graph-vr](https://github.com/vasturiano/3d-force-graph-vr) (A-Frame) and [3d-force-graph-ar](https://github.com/vasturiano/3d-force-graph-ar) (AR.js). 25 | 26 |

27 | 28 |

29 | 30 | This module exports 4 stand-alone React component packages with identical interfaces: `react-force-graph-2d`, `react-force-graph-3d`, `react-force-graph-vr` and `react-force-graph-ar`. 31 | Each can be used to represent a graph data structure in a 2 or 3-dimensional space using a force-directed iterative layout. 32 | 33 | Uses canvas/WebGL for rendering and [d3-force-3d](https://github.com/vasturiano/d3-force-3d) for the underlying physics engine. 34 | Supports zooming/panning, node dragging and node/link hover/click interactions. 35 | 36 | See also the [react-three-fiber component](https://github.com/vasturiano/r3f-forcegraph). 37 | 38 | ## Examples 39 | 40 | * [Basic](https://vasturiano.github.io/react-force-graph/example/basic/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/basic/index.html)) 41 | * [Directional arrows](https://vasturiano.github.io/react-force-graph/example/directional-links-arrows/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/directional-links-arrows/index.html)) 42 | * [Directional moving particles](https://vasturiano.github.io/react-force-graph/example/directional-links-particles/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/directional-links-particles/index.html)) 43 | * [Auto-colored nodes/links](https://vasturiano.github.io/react-force-graph/example/auto-colored/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/auto-colored/index.html)) 44 | * [AR graph](https://vasturiano.github.io/react-force-graph/example/ar-graph/index.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/ar-graph/index.html)) 45 | * [2D Text nodes](https://vasturiano.github.io/react-force-graph/example/text-nodes/index-2d.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/text-nodes/index-2d.html)) 46 | * [3D Text nodes](https://vasturiano.github.io/react-force-graph/example/text-nodes/index-3d.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/text-nodes/index-3d.html)) 47 | * [Image nodes](https://vasturiano.github.io/react-force-graph/example/img-nodes/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/img-nodes/index.html)) 48 | * [HTML in nodes](https://vasturiano.github.io/react-force-graph/example/html-nodes/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/html-nodes/index.html)) 49 | * [Custom 2D node shapes](https://vasturiano.github.io/react-force-graph/example/custom-node-shape/index-canvas.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/custom-node-shape/index-canvas.html)) 50 | * [Custom 3D/VR node geometries](https://vasturiano.github.io/react-force-graph/example/custom-node-shape/index-three.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/custom-node-shape/index-three.html)) 51 | * [Curved lines and self links](https://vasturiano.github.io/react-force-graph/example/curved-links/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/curved-links/index.html)) 52 | * [Text in links](https://vasturiano.github.io/react-force-graph/example/text-links/index-3d.html) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/text-links/index-3d.html)) 53 | * [Highlight nodes/links](https://vasturiano.github.io/react-force-graph/example/highlight/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/highlight/index.html)) 54 | * [Multiple Node Selection](https://vasturiano.github.io/react-force-graph/example/multi-selection/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/multi-selection/index.html)) 55 | * [Larger graph](https://vasturiano.github.io/react-force-graph/example/large-graph/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/large-graph/index.html)) 56 | * [Dynamic data changes](https://vasturiano.github.io/react-force-graph/example/dynamic/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/dynamic/index.html)) 57 | * [Click to focus on node](https://vasturiano.github.io/react-force-graph/example/click-to-focus/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/click-to-focus/index.html)) 58 | * [Click to expand/collapse nodes](https://vasturiano.github.io/react-force-graph/example/expandable-nodes/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/expandable-nodes/index.html)) 59 | * [Fix nodes after dragging](https://vasturiano.github.io/react-force-graph/example/fix-dragged-nodes/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/fix-dragged-nodes/index.html)) 60 | * [Fit graph to canvas](https://vasturiano.github.io/react-force-graph/example/fit-to-canvas/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/fit-to-canvas/index.html)) 61 | * [Camera automatic orbitting](https://vasturiano.github.io/react-force-graph/example/camera-auto-orbit/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/camera-auto-orbit/index.html)) 62 | * [Node collision detection](https://vasturiano.github.io/react-force-graph/example/collision-detection/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/collision-detection/index.html)) 63 | * [Emit link particles on demand](https://vasturiano.github.io/react-force-graph/example/emit-particles/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/emit-particles/index.html)) 64 | * [Force-directed tree (DAG mode)](https://vasturiano.github.io/react-force-graph/example/tree/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/tree/index.html)) 65 | * [Bloom Post-Processing Effect](https://vasturiano.github.io/react-force-graph/example/bloom-effect/) ([source](https://github.com/vasturiano/react-force-graph/blob/master/example/bloom-effect/index.html)) 66 | 67 | ## ❤️ Support This Project 68 | 69 | If you find this module useful and would like to support its development, you can [buy me a ☕](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=L398E7PKP47E8¤cy_code=USD&source=url). Your contributions help keep open-source sustainable! 70 | [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=L398E7PKP47E8¤cy_code=USD&source=url) 71 | 72 | ## Quick start 73 | 74 | ```js 75 | import ForceGraph2D from 'react-force-graph-2d'; 76 | import ForceGraph3D from 'react-force-graph-3d'; 77 | import ForceGraphVR from 'react-force-graph-vr'; 78 | import ForceGraphAR from 'react-force-graph-ar'; 79 | ``` 80 | 81 | or using a *script* tag 82 | 83 | ```html 84 | 85 | 86 | 87 | 88 | ``` 89 | 90 | then 91 | 92 | ```jsx 93 | 96 | ``` 97 | 98 | ## API reference 99 | 100 | Note that not all props listed below apply to all 4 components. The last 4 columns in these tables indicate the specific component availability of each prop/method. 101 | 102 | ### Data input 103 | 104 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 105 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 106 | | graphData | object | `{ nodes: [], links: [] }` | Graph data structure (see below for syntax details). Can also be used to apply incremental updates. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 107 | | nodeId | string | `id` | Node object accessor attribute for unique node id (used in link objects source/target). | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 108 | | linkSource | string | `source` | Link object accessor attribute referring to id of source node. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 109 | | linkTarget | string | `target` | Link object accessor attribute referring to id of target node. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 110 | 111 | ### Container layout 112 | 113 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 114 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 115 | | width | number | *<window width>* | Canvas width, in px. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 116 | | height | number | *<window height>* | Canvas height, in px. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 117 | | backgroundColor | string | (2D - light / 3D - dark)| Chart background color. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | 118 | | showNavInfo | bool | `true` | Whether to show the navigation controls footer info. | | :heavy_check_mark: | :heavy_check_mark: | | 119 | | yOffset | number | 1.5 | In AR mode, defines the offset distance above the marker where to place the center coordinates `<0,0,0>` of the force directed graph. Measured in terms of marker width units. | | | | :heavy_check_mark: | 120 | | glScale | number | 200 | In AR mode, defines the translation scale between real world distances and WebGL units, determining the overall size of the graph. Defined in terms of how many GL units fit in a full marker width. | | | | :heavy_check_mark: | 121 | | markerAttrs | object | `{ preset: 'hiro' }` | Set of attributes that define the marker where the AR force directed graph is mounted, according to the [a-marker specification](https://ar-js-org.github.io/AR.js-Docs/marker-based/). This prop only has an effect on component mount. | | | | :heavy_check_mark: | 122 | 123 | ### Node styling 124 | 125 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 126 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 127 | | nodeRelSize | number | 4 | Ratio of node circle area (square px) [2D] or sphere volume (cubic px) [3D] per value unit. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 128 | | nodeVal | number, string or func | `val` | Node object accessor function, attribute or a numeric constant for the node numeric value (affects node size). | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 129 | | nodeLabel | string or func | `name` | Node object accessor function or attribute for name (shown in label). Supports plain text or HTML content (except in VR). | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | 130 | | nodeDesc | string or func | `desc` | For VR only. Node object accessor function or attribute for description (shown under label). | | | :heavy_check_mark: | | 131 | | nodeVisibility| bool, string or func | `true` | Node object accessor function, attribute or a boolean constant for whether to display the node. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 132 | | nodeColor | string or func | `color` | Node object accessor function or attribute for node color. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 133 | | nodeAutoColorBy | string or func | | Node object accessor function or attribute to automatically group colors by. Only affects nodes without a color attribute. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 134 | | nodeOpacity | number | 0.75 | Nodes sphere opacity, between [0,1]. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 135 | | nodeResolution | number | 8 | Geometric resolution of each node's sphere, expressed in how many slice segments to divide the circumference. Higher values yield smoother spheres. Only applicable to 3D modes. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 136 | | nodeCanvasObject | func | *default 2D node object is a circle, sized according to `val` and styled according to `color`.* | Callback function for painting a custom 2D canvas object to represent graph nodes. Should use the provided canvas context attribute to perform drawing operations for each node. The callback function will be called for each node at every frame, and has the signature: `nodeCanvasObject(, , )`. | :heavy_check_mark: | | | | 137 | | nodeCanvasObjectMode | string or func | `() => 'replace'` | Node object accessor function or attribute for the custom drawing mode. Use in combination with `nodeCanvasObject` to specify how to customize nodes painting. Possible values are:
  • `replace`: the node is rendered using just `nodeCanvasObject`.
  • `before`: the node is rendered by invoking `nodeCanvasObject` and then proceeding with the default node painting.
  • `after`: `nodeCanvasObject` is applied after the default node painting takes place.
Any other value will be ignored and the default drawing will be applied. | :heavy_check_mark: | | | | 138 | | nodeThreeObject | Object3d, string or func | *default 3D node object is a sphere, sized according to `val` and styled according to `color`.* | Node object accessor function or attribute for generating a custom 3d object to render as graph nodes. Should return an instance of [ThreeJS Object3d](https://threejs.org/docs/index.html#api/core/Object3D). If a falsy value is returned, the default 3d object type will be used instead for that node. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 139 | | nodeThreeObjectExtend | bool, string or func | `false` | Node object accessor function, attribute or a boolean value for whether to replace the default node when using a custom `nodeThreeObject` (`false`) or to extend it (`true`). | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 140 | 141 | ### Link styling 142 | 143 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 144 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 145 | | linkLabel | string or func | `name` | Link object accessor function or attribute for name (shown in label). Supports plain text or HTML content (except in VR). | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | | 146 | | linkDesc | string or func | `desc` | For VR only. Link object accessor function or attribute for description (shown under label). | | | :heavy_check_mark: | | 147 | | linkVisibility| bool, string or func | `true` | Link object accessor function, attribute or a boolean constant for whether to display the link line. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 148 | | linkColor| string or func | `color` | Link object accessor function or attribute for line color. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 149 | | linkAutoColorBy | string or func | | Link object accessor function or attribute to automatically group colors by. Only affects links without a color attribute. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 150 | | linkOpacity | number | 0.2 | Line opacity of links, between [0,1]. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 151 | | linkLineDash | number[], string or func] | | Link object accessor function, attribute or number array (e.g. `[5, 15]`) to determine if a line dash should be applied to this rendered link. Refer to the [HTML canvas setLineDash API](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/setLineDash) for example values. Either a falsy value or an empty array will disable dashing. | :heavy_check_mark: | | | | 152 | | linkWidth | number, string or func | 1 | Link object accessor function, attribute or a numeric constant for the link line width. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 153 | | linkResolution | number | 6 | Geometric resolution of each link 3D line, expressed in how many radial segments to divide the cylinder. Higher values yield smoother cylinders. Applicable only to links with positive width. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 154 | | linkCurvature | number, string or func | 0 | Link object accessor function, attribute or a numeric constant for the curvature radius of the link line. A value of `0` renders a straight line. `1` indicates a radius equal to half of the line length, causing the curve to approximate a semi-circle. For self-referencing links (`source` equal to `target`) the curve is represented as a loop around the node, with length proportional to the curvature value. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 155 | | linkCurveRotation | number, string or func | 0 | Link object accessor function, attribute or a numeric constant for the rotation along the line axis to apply to the curve. Has no effect on straight lines. At `0` rotation, the curve is oriented in the direction of the intersection with the `XY` plane. The rotation angle (in radians) will rotate the curved line clockwise around the "start-to-end" axis from this reference orientation. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 156 | | linkMaterial | Material, string or func | *default link material is [MeshLambertMaterial](https://threejs.org/docs/#api/materials/MeshLambertMaterial) styled according to `color` and `opacity`.* | Link object accessor function or attribute for specifying a custom material to style the graph links with. Should return an instance of [ThreeJS Material](https://threejs.org/docs/#api/materials/Material). If a falsy value is returned, the default material will be used instead for that link. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 157 | | linkCanvasObject | func | *default 2D link object is a line, styled according to `width` and `color`.* | Callback function for painting a custom canvas object to represent graph links. Should use the provided canvas context attribute to perform drawing operations for each link. The callback function will be called for each link at every frame, and has the signature: `.linkCanvasObject(, , )`. | :heavy_check_mark: | | | | 158 | | linkCanvasObjectMode | string or func | `() => 'replace'` | Link object accessor function or attribute for the custom drawing mode. Use in combination with `linkCanvasObject` to specify how to customize links painting. Possible values are:
  • `replace`: the link is rendered using just `linkCanvasObject`.
  • `before`: the link is rendered by invoking `linkCanvasObject` and then proceeding with the default link painting.
  • `after`: `linkCanvasObject` is applied after the default link painting takes place.
Any other value will be ignored and the default drawing will be applied. | :heavy_check_mark: | | | | 159 | | linkThreeObject | Object3d, string or func | *default 3D link object is a line or cylinder, sized according to `width` and styled according to `material`.* | Link object accessor function or attribute for generating a custom 3d object to render as graph links. Should return an instance of [ThreeJS Object3d](https://threejs.org/docs/index.html#api/core/Object3D). If a falsy value is returned, the default 3d object type will be used instead for that link. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 160 | | linkThreeObjectExtend | bool, string or func | `false` | Link object accessor function, attribute or a boolean value for whether to replace the default link when using a custom `linkThreeObject` (`false`) or to extend it (`true`). | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 161 | | linkPositionUpdate | func(linkObject, { start, end }, link) | | Custom function to call for updating the position of links at every render iteration. It receives the respective link `ThreeJS Object3d`, the `start` and `end` coordinates of the link (`{x,y,z}` each), and the link's `data`. If the function returns a truthy value, the regular position update function will not run for that link. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 162 | | linkDirectionalArrowLength | number, string or func | 0 | Link object accessor function, attribute or a numeric constant for the length of the arrow head indicating the link directionality. The arrow is displayed directly over the link line, and points in the direction of `source` > `target`. A value of `0` hides the arrow. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 163 | | linkDirectionalArrowColor | string or func | `color` | Link object accessor function or attribute for the color of the arrow head. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 164 | | linkDirectionalArrowRelPos | number, string or func | 0.5 | Link object accessor function, attribute or a numeric constant for the longitudinal position of the arrow head along the link line, expressed as a ratio between `0` and `1`, where `0` indicates immediately next to the `source` node, `1` next to the `target` node, and `0.5` right in the middle. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 165 | | linkDirectionalArrowResolution | number | 8 | Geometric resolution of the arrow head, expressed in how many slice segments to divide the cone base circumference. Higher values yield smoother arrows. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 166 | | linkDirectionalParticles | number, string or func | 0 | Link object accessor function, attribute or a numeric constant for the number of particles (small spheres) to display over the link line. The particles are distributed equi-spaced along the line, travel in the direction `source` > `target`, and can be used to indicate link directionality. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 167 | | linkDirectionalParticleSpeed | number, string or func | 0.01 | Link object accessor function, attribute or a numeric constant for the directional particles speed, expressed as the ratio of the link length to travel per frame. Values above `0.5` are discouraged. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 168 | | linkDirectionalParticleWidth | number, string or func | 0.5 | Link object accessor function, attribute or a numeric constant for the directional particles width. Values are rounded to the nearest decimal for indexing purposes. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 169 | | linkDirectionalParticleColor | string or func | `color` | Link object accessor function or attribute for the directional particles color. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 170 | | linkDirectionalParticleResolution | number | 4 | Geometric resolution of each 3D directional particle, expressed in how many slice segments to divide the circumference. Higher values yield smoother particles. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 171 | 172 | | Method | Arguments | Description | 2D | 3D | VR | AR | 173 | | --- | :--: | --- | :--: | :--: | :--: | :--: | 174 | | emitParticle | (link) | An alternative mechanism for generating particles, this method emits a non-cyclical single particle within a specific link. The emitted particle shares the styling (speed, width, color) of the regular particle props. A valid `link` object that is included in `graphData` should be passed as a single parameter. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 175 | 176 | ### Render control 177 | 178 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 179 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 180 | | rendererConfig | object | `{ antialias: true, alpha: true }` | Configuration parameters to pass to the [ThreeJS WebGLRenderer](https://threejs.org/docs/#api/en/renderers/WebGLRenderer) constructor. This prop only has an effect on component mount. | | :heavy_check_mark: | | | 181 | | extraRenderers | array | `[]` | If you wish to include custom objects that require a dedicated renderer besides `WebGL`, such as [CSS3DRenderer](https://threejs.org/docs/#examples/en/renderers/CSS3DRenderer), include in this array those extra renderer instances. | | :heavy_check_mark: | | | 182 | | autoPauseRedraw | bool | `true` | Enable performance optimization to automatically pause redrawing the 2D canvas at every frame whenever the simulation engine is halted. If you have custom dynamic objects that rely on a constant redraw of the canvas, it's recommended to switch this option off. | :heavy_check_mark: | | | | 183 | | minZoom | number | 0.01 | Lowest zoom out level permitted on the 2D canvas. | :heavy_check_mark: | | | | 184 | | maxZoom | number | 1000 | Highest zoom in level permitted on the 2D canvas. | :heavy_check_mark: | | | | 185 | | onRenderFramePre | func | *-* | Callback function to invoke at every frame, immediately before any node/link is rendered to the canvas. This can be used to draw additional external items on the canvas. The canvas context and the current global scale are included as parameters: `.onRenderFramePre(, )`. | :heavy_check_mark: | | | | 186 | | onRenderFramePost | func | *-* | Callback function to invoke at every frame, immediately after the last node/link is rendered to the canvas. This can be used to draw additional external items on the canvas. The canvas context and the current global scale are included as parameters: `.onRenderFramePost(, )`. | :heavy_check_mark: | | | | 187 | 188 | | Method | Arguments | Description | 2D | 3D | VR | AR | 189 | | --- | :--: | --- | :--: | :--: | :--: | :--: | 190 | | pauseAnimation | *-* | Pauses the rendering cycle of the component, effectively freezing the current view and cancelling all user interaction. This method can be used to save performance in circumstances when a static image is sufficient. | :heavy_check_mark: | :heavy_check_mark: | | | 191 | | resumeAnimation | *-* | Resumes the rendering cycle of the component, and re-enables the user interaction. This method can be used together with `pauseAnimation` for performance optimization purposes. | :heavy_check_mark: | :heavy_check_mark: | | | 192 | | centerAt | ([x], [y], [ms]) | Set the coordinates of the center of the viewport. This method can be used to perform panning on the 2D canvas programmatically. Each of the `x, y` coordinates is optional, allowing for motion in just one dimension. An optional 3rd argument defines the duration of the transition (in ms) to animate the canvas motion. | :heavy_check_mark: | | | 193 | | zoom | ([number], [ms]) | Set the 2D canvas zoom amount. The zoom is defined in terms of the scale transform of each px. A value of `1` indicates unity, larger values zoom in and smaller values zoom out. An optional 2nd argument defines the duration of the transition (in ms) to animate the canvas motion. By default the zoom is set to a value inversely proportional to the amount of nodes in the system. | :heavy_check_mark: | | | 194 | | zoomToFit | ([ms], [px], [nodeFilterFn]) | Automatically zooms/pans the canvas so that all of the nodes fit inside it. If no nodes are found no action is taken. It accepts two optional arguments: the first defines the duration of the transition (in ms) to animate the canvas motion (default: 0ms). The second argument is the amount of padding (in px) between the edge of the canvas and the outermost node (default: 10px). The third argument specifies a custom node filter: `node => `, which should return a truthy value if the node is to be included. This can be useful for focusing on a portion of the graph. | :heavy_check_mark: | :heavy_check_mark: | | | 195 | | cameraPosition | ([{x,y,z}],[lookAt], [ms]) | Re-position the camera, in terms of `x`, `y`, `z` coordinates. Each of the coordinates is optional, allowing for motion in just some dimensions. The optional second argument can be used to define the direction that the camera should aim at, in terms of an `{x,y,z}` point in the 3D space. The 3rd optional argument defines the duration of the transition (in ms) to animate the camera motion. A value of 0 (default) moves the camera immediately to the final position. By default the camera will face the center of the graph at a `z` distance proportional to the amount of nodes in the system. | | :heavy_check_mark: | | | 196 | | lights | ([array]) | Getter/setter for the list of lights to use in the scene. Each item should be an instance of [Light](https://threejs.org/docs/#api/en/lights/Light). | | :heavy_check_mark: | | | 197 | | scene | *-* | Access the internal ThreeJS [Scene](https://threejs.org/docs/#api/scenes/Scene). | | :heavy_check_mark: | | | 198 | | camera | *-* | Access the internal ThreeJS [Camera](https://threejs.org/docs/#api/cameras/PerspectiveCamera). | | :heavy_check_mark: | | | 199 | | renderer | *-* | Access the internal ThreeJS [WebGL renderer](https://threejs.org/docs/#api/renderers/WebGLRenderer). | | :heavy_check_mark: | | | 200 | | postProcessingComposer | *-* | Access the [post-processing composer](https://threejs.org/docs/#examples/en/postprocessing/EffectComposer). Use this to add post-processing [rendering effects](https://github.com/mrdoob/three.js/tree/dev/examples/jsm/postprocessing) to the scene. By default the composer has a single pass ([RenderPass](https://github.com/mrdoob/three.js/blob/dev/examples/jsm/postprocessing/RenderPass.js)) that directly renders the scene without any effects. | | :heavy_check_mark: | | | 201 | | controls | *-* | Access the internal ThreeJS controls object. | | :heavy_check_mark: | | | 202 | | refresh | *-* | Redraws all the nodes/links. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 203 | 204 | ### Force engine configuration 205 | 206 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 207 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 208 | | numDimensions | 1, 2 or 3 | 3 | Not applicable to 2D mode. Number of dimensions to run the force simulation on. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 209 | | forceEngine | string | `d3` | Which force-simulation engine to use ([*d3*](https://github.com/vasturiano/d3-force-3d) or [*ngraph*](https://github.com/anvaka/ngraph.forcelayout)). | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 210 | | dagMode | string | *-* | Apply layout constraints based on the graph directionality. Only works correctly for [DAG](https://en.wikipedia.org/wiki/Directed_acyclic_graph) graph structures (without cycles). Choice between `td` (top-down), `bu` (bottom-up), `lr` (left-to-right), `rl` (right-to-left), `zout` (near-to-far), `zin` (far-to-near), `radialout` (outwards-radially) or `radialin` (inwards-radially). | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 211 | | dagLevelDistance | number | *auto-derived from the number of nodes* | If `dagMode` is engaged, this specifies the distance between the different graph depths. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 212 | | dagNodeFilter | func | `node => true` | Node accessor function to specify nodes to ignore during the DAG layout processing. This accessor method receives a node object and should return a `boolean` value indicating whether the node is to be included. Excluded nodes will be left unconstrained and free to move in any direction. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 213 | | onDagError | func | *-* | Callback to invoke if a cycle is encountered while processing the data structure for a DAG layout. The loop segment of the graph is included for information, as an array of node ids. By default an exception will be thrown whenever a loop is encountered. You can override this method to handle this case externally and allow the graph to continue the DAG processing. Strict graph directionality is not guaranteed if a loop is encountered and the result is a best effort to establish a hierarchy. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 214 | | d3AlphaMin | number | 0 | Sets the [simulation alpha min](https://github.com/vasturiano/d3-force-3d#simulation_alphaMin) parameter. Only applicable if using the d3 simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 215 | | d3AlphaDecay | number | 0.0228 | Sets the [simulation intensity decay](https://github.com/vasturiano/d3-force-3d#simulation_alphaDecay) parameter. Only applicable if using the d3 simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 216 | | d3VelocityDecay | number | 0.4 | Nodes' [velocity decay](https://github.com/vasturiano/d3-force-3d#simulation_velocityDecay) that simulates the medium resistance. Only applicable if using the d3 simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 217 | | ngraphPhysics | object | *-* | Specify custom physics configuration for ngraph, according to its [configuration object](https://github.com/anvaka/ngraph.forcelayout#configuring-physics) syntax. Only applicable if using the ngraph simulation engine. | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 218 | | warmupTicks | number | 0 | Number of layout engine cycles to dry-run at ignition before starting to render. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 219 | | cooldownTicks | number | Infinity | How many build-in frames to render before stopping and freezing the layout engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 220 | | cooldownTime | number | 15000 | How long (ms) to render for before stopping and freezing the layout engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 221 | | onEngineTick | func | *-* | Callback function invoked at every tick of the simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 222 | | onEngineStop | func | *-* | Callback function invoked when the simulation engine stops and the layout is frozen. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 223 | 224 | | Method | Arguments | Description | 2D | 3D | VR | AR | 225 | | --- | :--: | --- | :--: | :--: | :--: | :--: | 226 | | d3Force | (string, [func]) | Access to the internal forces that control the d3 simulation engine. Follows the same interface as `d3-force-3d`'s [simulation.force](https://github.com/vasturiano/d3-force-3d#simulation_force). Three forces are included by default: `'link'` (based on [forceLink](https://github.com/vasturiano/d3-force-3d#forceLink)), `'charge'` (based on [forceManyBody](https://github.com/vasturiano/d3-force-3d#forceManyBody)) and `'center'` (based on [forceCenter](https://github.com/vasturiano/d3-force-3d#forceCenter)). Each of these forces can be reconfigured, or new forces can be added to the system. Only applicable if using the d3 simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 227 | | d3ReheatSimulation | () | Reheats the force simulation engine, by setting the `alpha` value to `1`. Only applicable if using the d3 simulation engine. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 228 | 229 | ### Interaction 230 | 231 | | Prop | Type | Default | Description | 2D | 3D | VR | AR | 232 | | --- | :--: | :--: | --- | :--: | :--: | :--: | :--: | 233 | | onNodeClick | func | *-* | Callback function for node (left-button) clicks. The node object and the event object are included as arguments `onNodeClick(node, event)`. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 234 | | onNodeRightClick | func | *-* | Callback function for node right-clicks. The node object and the event object are included as arguments `onNodeRightClick(node, event)`. | :heavy_check_mark: | :heavy_check_mark: | | | 235 | | onNodeHover | func | *-* | Callback function for node mouse over events. The node object (or `null` if there's no node under the pointer line of sight) is included as the first argument, and the previous node object (or null) as second argument: `onNodeHover(node, prevNode)`. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 236 | | onNodeDrag | func | *-* | Callback function for node drag interactions. This function is invoked repeatedly while dragging a node, every time its position is updated. The node object is included as the first argument, and the change in coordinates since the last iteration of this function are included as the second argument in format {x,y,z}: `onNodeDrag(node, translate)`. | :heavy_check_mark: | :heavy_check_mark: | | | 237 | | onNodeDragEnd | func | *-* | Callback function for the end of node drag interactions. This function is invoked when the node is released. The node object is included as the first argument, and the change in coordinates from the node's initial postion are included as the second argument in format {x,y,z}: `onNodeDragEnd(node, translate)`. | :heavy_check_mark: | :heavy_check_mark: | | | 238 | | onLinkClick | func | *-* | Callback function for link (left-button) clicks. The link object and the event object are included as arguments `onLinkClick(link, event)`. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 239 | | onLinkRightClick | func | *-* | Callback function for link right-clicks. The link object and the event object are included as arguments `onLinkRightClick(link, event)`. | :heavy_check_mark: | :heavy_check_mark: | | | 240 | | onLinkHover | func | *-* | Callback function for link mouse over events. The link object (or `null` if there's no link under the pointer line of sight) is included as the first argument, and the previous link object (or null) as second argument: `onLinkHover(link, prevLink)`. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 241 | | onBackgroundClick | func | *-* | Callback function for click events on the empty space between the nodes and links. The event object is included as single argument `onBackgroundClick(event)`. | :heavy_check_mark: | :heavy_check_mark: | | | 242 | | onBackgroundRightClick | func | *-* | Callback function for right-click events on the empty space between the nodes and links. The event object is included as single argument `onBackgroundRightClick(event)`. | :heavy_check_mark: | :heavy_check_mark: | | | 243 | | linkHoverPrecision | number | 4 | Whether to display the link label when gazing the link closely (low value) or from far away (high value). | :heavy_check_mark: | :heavy_check_mark: | | | 244 | | onZoom | func | *-* | Callback function for zoom/pan events. The current zoom transform is included as single argument `onZoom({ k, x, y })`. Note that `onZoom` is triggered by user interaction as well as programmatic zooming/panning with `zoom()` and `centerAt()`. | :heavy_check_mark: | | | | 245 | | onZoomEnd | func | *-* | Callback function for on 'end' of zoom/pan events. The current zoom transform is included as single argument `onZoomEnd({ k, x, y })`. Note that `onZoomEnd` is triggered by user interaction as well as programmatic zooming/panning with `zoom()` and `centerAt()`. | :heavy_check_mark: | | | | 246 | | controlType | string | `trackball` | Which type of control to use to control the camera on 3D mode. Choice between [trackball](https://threejs.org/examples/misc_controls_trackball.html), [orbit](https://threejs.org/examples/#misc_controls_orbit) or [fly](https://threejs.org/examples/misc_controls_fly.html). | | :heavy_check_mark: | | | 247 | | enableZoomInteraction | bool | `true` | Whether to enable zooming user interactions on a 2D canvas. | :heavy_check_mark: | | | | 248 | | enablePanInteraction | bool | `true` | Whether to enable panning user interactions on a 2D canvas. | :heavy_check_mark: | | | | 249 | | enableNavigationControls | bool | `true` | Whether to enable the trackball navigation controls used to move the camera using mouse interactions (rotate/zoom/pan). | | :heavy_check_mark: | | | 250 | | enablePointerInteraction | bool | `true` | Whether to enable the mouse tracking events. This activates an internal tracker of the canvas mouse position and enables the functionality of object hover/click and tooltip labels, at the cost of performance. If you're looking for maximum gain in your graph performance it's recommended to switch off this property. | :heavy_check_mark: | :heavy_check_mark: | | | 251 | | enableNodeDrag | bool | `true` | Whether to enable the user interaction to drag nodes by click-dragging. If enabled, every time a node is dragged the simulation is re-heated so the other nodes react to the changes. Only applicable if enablePointerInteraction is `true`. | :heavy_check_mark: | :heavy_check_mark: | | | 252 | | nodePointerAreaPaint | func | *default interaction area is a circle centered on the node and sized according to `val`.* | Callback function for painting a canvas area used to detect node pointer interactions. The provided paint color uniquely identifies the node and should be used to perform drawing operations on the provided canvas context. This painted area will not be visible, but instead be used to detect pointer interactions with the node. The callback function has the signature: `nodePointerAreaPaint(, , , )`. | :heavy_check_mark: | | | | 253 | | linkPointerAreaPaint | func | *default interaction area is a straight line between the source and target nodes.* | Callback function for painting a canvas area used to detect link pointer interactions. The provided paint color uniquely identifies the link and should be used to perform drawing operations on the provided canvas context. This painted area will not be visible, but instead be used to detect pointer interactions with the link. The callback function has the signature: `linkPointerAreaPaint(, , , )`. | :heavy_check_mark: | | | | 254 | 255 | ### Utility 256 | 257 | | Method | Arguments | Description | 2D | 3D | VR | AR | 258 | | --- | :--: | --- | :--: | :--: | :--: | :--: | 259 | | getGraphBbox | ([nodeFilterFn]) | Returns the current bounding box of the nodes in the graph, formatted as `{ x: [, ], y: [, ], z: [, ] }`. If no nodes are found, returns `null`. Accepts an optional argument to define a custom node filter: `node => `, which should return a truthy value if the node is to be included. This can be useful to calculate the bounding box of a portion of the graph. | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | 260 | | screen2GraphCoords | (x, y[, distance]) | Utility method to translate viewport coordinates to the graph domain. Given a pair of `x`,`y` screen coordinates, and optionally distance from camera for 3D mode, returns the current equivalent `{x, y (, z)}` in the domain of graph node coordinates. | :heavy_check_mark: | :heavy_check_mark: | | | 261 | | graph2ScreenCoords | (x, y[, z]) | Utility method to translate node coordinates to the viewport domain. Given a set of `x`,`y`(,`z`) graph coordinates, returns the current equivalent `{x, y}` in viewport coordinates. | :heavy_check_mark: | :heavy_check_mark: | | | 262 | 263 | ### Input JSON syntax 264 | 265 | ```json 266 | { 267 | "nodes": [ 268 | { 269 | "id": "id1", 270 | "name": "name1", 271 | "val": 1 272 | }, 273 | { 274 | "id": "id2", 275 | "name": "name2", 276 | "val": 10 277 | }, 278 | ... 279 | ], 280 | "links": [ 281 | { 282 | "source": "id1", 283 | "target": "id2" 284 | }, 285 | ... 286 | ] 287 | } 288 | ``` 289 | 290 | 291 | [npm-2d-img]: https://img.shields.io/npm/v/react-force-graph-2d 292 | [npm-3d-img]: https://img.shields.io/npm/v/react-force-graph-3d 293 | [npm-vr-img]: https://img.shields.io/npm/v/react-force-graph-vr 294 | [npm-ar-img]: https://img.shields.io/npm/v/react-force-graph-ar 295 | [npm-2d-url]: https://npmjs.org/package/react-force-graph-2d 296 | [npm-3d-url]: https://npmjs.org/package/react-force-graph-3d 297 | [npm-vr-url]: https://npmjs.org/package/react-force-graph-vr 298 | [npm-ar-url]: https://npmjs.org/package/react-force-graph-ar 299 | [build-size-2d-img]: https://img.shields.io/bundlephobia/minzip/react-force-graph-2d 300 | [build-size-3d-img]: https://img.shields.io/bundlephobia/minzip/react-force-graph-3d 301 | [build-size-vr-img]: https://img.shields.io/bundlephobia/minzip/react-force-graph-vr 302 | [build-size-ar-img]: https://img.shields.io/bundlephobia/minzip/react-force-graph-ar 303 | [build-size-2d-url]: https://bundlephobia.com/result?p=react-force-graph-2d 304 | [build-size-3d-url]: https://bundlephobia.com/result?p=react-force-graph-3d 305 | [build-size-vr-url]: https://bundlephobia.com/result?p=react-force-graph-vr 306 | [build-size-ar-url]: https://bundlephobia.com/result?p=react-force-graph-ar 307 | [npm-downloads-2d-img]: https://img.shields.io/npm/dt/react-force-graph-2d 308 | [npm-downloads-3d-img]: https://img.shields.io/npm/dt/react-force-graph-3d 309 | [npm-downloads-vr-img]: https://img.shields.io/npm/dt/react-force-graph-vr 310 | [npm-downloads-ar-img]: https://img.shields.io/npm/dt/react-force-graph-ar 311 | [npm-downloads-2d-url]: https://www.npmtrends.com/react-force-graph-2d 312 | [npm-downloads-3d-url]: https://www.npmtrends.com/react-force-graph-2d 313 | [npm-downloads-vr-url]: https://www.npmtrends.com/react-force-graph-vr 314 | [npm-downloads-ar-url]: https://www.npmtrends.com/react-force-graph-ar 315 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /example/all-modes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 36 | -------------------------------------------------------------------------------- /example/ar-graph/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 41 | -------------------------------------------------------------------------------- /example/auto-colored/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 35 | -------------------------------------------------------------------------------- /example/basic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 27 | -------------------------------------------------------------------------------- /example/bloom-effect/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 48 | -------------------------------------------------------------------------------- /example/camera-auto-orbit/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 55 | -------------------------------------------------------------------------------- /example/click-to-focus/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 51 | -------------------------------------------------------------------------------- /example/collision-detection/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 72 | -------------------------------------------------------------------------------- /example/curved-links/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 73 | -------------------------------------------------------------------------------- /example/custom-node-shape/index-canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 45 | -------------------------------------------------------------------------------- /example/custom-node-shape/index-three.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 49 | -------------------------------------------------------------------------------- /example/datasets/d3-dependencies.csv: -------------------------------------------------------------------------------- 1 | size,path 2 | ,d3 3 | ,d3/d3-array 4 | ,d3/d3-array/threshold 5 | ,d3/d3-axis 6 | ,d3/d3-brush 7 | ,d3/d3-chord 8 | ,d3/d3-collection 9 | ,d3/d3-color 10 | ,d3/d3-dispatch 11 | ,d3/d3-drag 12 | ,d3/d3-dsv 13 | ,d3/d3-ease 14 | ,d3/d3-force 15 | ,d3/d3-format 16 | ,d3/d3-geo 17 | ,d3/d3-geo/clip 18 | ,d3/d3-geo/path 19 | ,d3/d3-geo/projection 20 | ,d3/d3-hierarchy 21 | ,d3/d3-hierarchy/hierarchy 22 | ,d3/d3-hierarchy/pack 23 | ,d3/d3-hierarchy/treemap 24 | ,d3/d3-interpolate 25 | ,d3/d3-interpolate/transform 26 | ,d3/d3-path 27 | ,d3/d3-polygon 28 | ,d3/d3-quadtree 29 | ,d3/d3-queue 30 | ,d3/d3-random 31 | ,d3/d3-request 32 | ,d3/d3-scale 33 | ,d3/d3-selection 34 | ,d3/d3-selection/selection 35 | ,d3/d3-shape 36 | ,d3/d3-shape/curve 37 | ,d3/d3-shape/offset 38 | ,d3/d3-shape/order 39 | ,d3/d3-shape/symbol 40 | ,d3/d3-time-format 41 | ,d3/d3-time 42 | ,d3/d3-timer 43 | ,d3/d3-transition 44 | ,d3/d3-transition/selection 45 | ,d3/d3-transition/transition 46 | ,d3/d3-voronoi 47 | ,d3/d3-zoom 48 | 90,d3/d3-array/array.js 49 | 86,d3/d3-array/ascending.js 50 | 238,d3/d3-array/bisect.js 51 | 786,d3/d3-array/bisector.js 52 | 72,d3/d3-array/constant.js 53 | 86,d3/d3-array/descending.js 54 | 135,d3/d3-array/deviation.js 55 | 553,d3/d3-array/extent.js 56 | 1876,d3/d3-array/histogram.js 57 | 43,d3/d3-array/identity.js 58 | 451,d3/d3-array/max.js 59 | 362,d3/d3-array/mean.js 60 | 452,d3/d3-array/median.js 61 | 339,d3/d3-array/merge.js 62 | 451,d3/d3-array/min.js 63 | 63,d3/d3-array/number.js 64 | 182,d3/d3-array/pairs.js 65 | 161,d3/d3-array/permute.js 66 | 416,d3/d3-array/quantile.js 67 | 344,d3/d3-array/range.js 68 | 357,d3/d3-array/scan.js 69 | 285,d3/d3-array/shuffle.js 70 | 295,d3/d3-array/sum.js 71 | 361,d3/d3-array/threshold/freedmanDiaconis.js 72 | 180,d3/d3-array/threshold/scott.js 73 | 96,d3/d3-array/threshold/sturges.js 74 | 672,d3/d3-array/ticks.js 75 | 356,d3/d3-array/transpose.js 76 | 540,d3/d3-array/variance.js 77 | 99,d3/d3-array/zip.js 78 | 42,d3/d3-axis/array.js 79 | 5239,d3/d3-axis/axis.js 80 | 43,d3/d3-axis/identity.js 81 | 15778,d3/d3-brush/brush.js 82 | 72,d3/d3-brush/constant.js 83 | 127,d3/d3-brush/event.js 84 | 202,d3/d3-brush/noevent.js 85 | 42,d3/d3-chord/array.js 86 | 3178,d3/d3-chord/chord.js 87 | 72,d3/d3-chord/constant.js 88 | 159,d3/d3-chord/math.js 89 | 2340,d3/d3-chord/ribbon.js 90 | 137,d3/d3-collection/entries.js 91 | 104,d3/d3-collection/keys.js 92 | 1988,d3/d3-collection/map.js 93 | 2021,d3/d3-collection/nest.js 94 | 800,d3/d3-collection/set.js 95 | 115,d3/d3-collection/values.js 96 | 9276,d3/d3-color/color.js 97 | 1855,d3/d3-color/cubehelix.js 98 | 340,d3/d3-color/define.js 99 | 3167,d3/d3-color/lab.js 100 | 72,d3/d3-color/math.js 101 | 2729,d3/d3-dispatch/dispatch.js 102 | 72,d3/d3-drag/constant.js 103 | 4297,d3/d3-drag/drag.js 104 | 430,d3/d3-drag/event.js 105 | 857,d3/d3-drag/nodrag.js 106 | 202,d3/d3-drag/noevent.js 107 | 199,d3/d3-dsv/csv.js 108 | 3582,d3/d3-dsv/dsv.js 109 | 200,d3/d3-dsv/tsv.js 110 | 653,d3/d3-ease/back.js 111 | 521,d3/d3-ease/bounce.js 112 | 261,d3/d3-ease/circle.js 113 | 210,d3/d3-ease/cubic.js 114 | 1309,d3/d3-ease/elastic.js 115 | 251,d3/d3-ease/exp.js 116 | 43,d3/d3-ease/linear.js 117 | 596,d3/d3-ease/poly.js 118 | 192,d3/d3-ease/quad.js 119 | 236,d3/d3-ease/sin.js 120 | 654,d3/d3-force/center.js 121 | 2447,d3/d3-force/collide.js 122 | 72,d3/d3-force/constant.js 123 | 69,d3/d3-force/jiggle.js 124 | 3213,d3/d3-force/link.js 125 | 3181,d3/d3-force/manyBody.js 126 | 3444,d3/d3-force/simulation.js 127 | 1030,d3/d3-force/x.js 128 | 1030,d3/d3-force/y.js 129 | 361,d3/d3-format/defaultLocale.js 130 | 134,d3/d3-format/exponent.js 131 | 656,d3/d3-format/formatDecimal.js 132 | 368,d3/d3-format/formatDefault.js 133 | 475,d3/d3-format/formatGroup.js 134 | 611,d3/d3-format/formatPrefixAuto.js 135 | 458,d3/d3-format/formatRounded.js 136 | 1589,d3/d3-format/formatSpecifier.js 137 | 846,d3/d3-format/formatTypes.js 138 | 5247,d3/d3-format/locale.js 139 | 119,d3/d3-format/precisionFixed.js 140 | 190,d3/d3-format/precisionPrefix.js 141 | 186,d3/d3-format/precisionRound.js 142 | 906,d3/d3-geo/adder.js 143 | 1958,d3/d3-geo/area.js 144 | 5361,d3/d3-geo/bounds.js 145 | 929,d3/d3-geo/cartesian.js 146 | 3816,d3/d3-geo/centroid.js 147 | 2373,d3/d3-geo/circle.js 148 | 2897,d3/d3-geo/clip/antimeridian.js 149 | 470,d3/d3-geo/clip/buffer.js 150 | 5956,d3/d3-geo/clip/circle.js 151 | 5527,d3/d3-geo/clip/extent.js 152 | 3813,d3/d3-geo/clip/index.js 153 | 1099,d3/d3-geo/clip/line.js 154 | 2802,d3/d3-geo/clip/polygon.js 155 | 250,d3/d3-geo/compose.js 156 | 72,d3/d3-geo/constant.js 157 | 229,d3/d3-geo/distance.js 158 | 3034,d3/d3-geo/graticule.js 159 | 43,d3/d3-geo/identity.js 160 | 911,d3/d3-geo/interpolate.js 161 | 1309,d3/d3-geo/length.js 162 | 880,d3/d3-geo/math.js 163 | 34,d3/d3-geo/noop.js 164 | 945,d3/d3-geo/path/area.js 165 | 485,d3/d3-geo/path/bounds.js 166 | 2033,d3/d3-geo/path/centroid.js 167 | 914,d3/d3-geo/path/context.js 168 | 1690,d3/d3-geo/path/index.js 169 | 1149,d3/d3-geo/path/string.js 170 | 139,d3/d3-geo/pointEqual.js 171 | 2491,d3/d3-geo/polygonContains.js 172 | 235,d3/d3-geo/projection/albers.js 173 | 3986,d3/d3-geo/projection/albersUsa.js 174 | 502,d3/d3-geo/projection/azimuthal.js 175 | 447,d3/d3-geo/projection/azimuthalEqualArea.js 176 | 443,d3/d3-geo/projection/azimuthalEquidistant.js 177 | 402,d3/d3-geo/projection/conic.js 178 | 1017,d3/d3-geo/projection/conicConformal.js 179 | 871,d3/d3-geo/projection/conicEqualArea.js 180 | 771,d3/d3-geo/projection/conicEquidistant.js 181 | 314,d3/d3-geo/projection/cylindricalEqualArea.js 182 | 253,d3/d3-geo/projection/equirectangular.js 183 | 910,d3/d3-geo/projection/fit.js 184 | 387,d3/d3-geo/projection/gnomonic.js 185 | 1922,d3/d3-geo/projection/identity.js 186 | 3752,d3/d3-geo/projection/index.js 187 | 1119,d3/d3-geo/projection/mercator.js 188 | 376,d3/d3-geo/projection/orthographic.js 189 | 3275,d3/d3-geo/projection/resample.js 190 | 436,d3/d3-geo/projection/stereographic.js 191 | 762,d3/d3-geo/projection/transverseMercator.js 192 | 2509,d3/d3-geo/rotation.js 193 | 2305,d3/d3-geo/stream.js 194 | 701,d3/d3-geo/transform.js 195 | 166,d3/d3-hierarchy/accessors.js 196 | 2093,d3/d3-hierarchy/cluster.js 197 | 120,d3/d3-hierarchy/constant.js 198 | 138,d3/d3-hierarchy/hierarchy/ancestors.js 199 | 121,d3/d3-hierarchy/hierarchy/descendants.js 200 | 381,d3/d3-hierarchy/hierarchy/each.js 201 | 353,d3/d3-hierarchy/hierarchy/eachAfter.js 202 | 282,d3/d3-hierarchy/hierarchy/eachBefore.js 203 | 1819,d3/d3-hierarchy/hierarchy/index.js 204 | 164,d3/d3-hierarchy/hierarchy/leaves.js 205 | 246,d3/d3-hierarchy/hierarchy/links.js 206 | 606,d3/d3-hierarchy/hierarchy/path.js 207 | 151,d3/d3-hierarchy/hierarchy/sort.js 208 | 264,d3/d3-hierarchy/hierarchy/sum.js 209 | 2452,d3/d3-hierarchy/pack/enclose.js 210 | 1917,d3/d3-hierarchy/pack/index.js 211 | 389,d3/d3-hierarchy/pack/shuffle.js 212 | 3497,d3/d3-hierarchy/pack/siblings.js 213 | 1266,d3/d3-hierarchy/partition.js 214 | 1934,d3/d3-hierarchy/stratify.js 215 | 7060,d3/d3-hierarchy/tree.js 216 | 1184,d3/d3-hierarchy/treemap/binary.js 217 | 309,d3/d3-hierarchy/treemap/dice.js 218 | 2810,d3/d3-hierarchy/treemap/index.js 219 | 1029,d3/d3-hierarchy/treemap/resquarify.js 220 | 166,d3/d3-hierarchy/treemap/round.js 221 | 309,d3/d3-hierarchy/treemap/slice.js 222 | 170,d3/d3-hierarchy/treemap/sliceDice.js 223 | 1868,d3/d3-hierarchy/treemap/squarify.js 224 | 372,d3/d3-interpolate/array.js 225 | 600,d3/d3-interpolate/basis.js 226 | 360,d3/d3-interpolate/basisClosed.js 227 | 697,d3/d3-interpolate/color.js 228 | 72,d3/d3-interpolate/constant.js 229 | 760,d3/d3-interpolate/cubehelix.js 230 | 134,d3/d3-interpolate/date.js 231 | 547,d3/d3-interpolate/hcl.js 232 | 547,d3/d3-interpolate/hsl.js 233 | 447,d3/d3-interpolate/lab.js 234 | 100,d3/d3-interpolate/number.js 235 | 390,d3/d3-interpolate/object.js 236 | 163,d3/d3-interpolate/quantize.js 237 | 1277,d3/d3-interpolate/rgb.js 238 | 112,d3/d3-interpolate/round.js 239 | 1758,d3/d3-interpolate/string.js 240 | 672,d3/d3-interpolate/transform/decompose.js 241 | 2064,d3/d3-interpolate/transform/index.js 242 | 980,d3/d3-interpolate/transform/parse.js 243 | 598,d3/d3-interpolate/value.js 244 | 1387,d3/d3-interpolate/zoom.js 245 | 4089,d3/d3-path/path.js 246 | 243,d3/d3-polygon/area.js 247 | 346,d3/d3-polygon/centroid.js 248 | 411,d3/d3-polygon/contains.js 249 | 402,d3/d3-polygon/cross.js 250 | 1710,d3/d3-polygon/hull.js 251 | 375,d3/d3-polygon/length.js 252 | 2441,d3/d3-quadtree/add.js 253 | 1667,d3/d3-quadtree/cover.js 254 | 170,d3/d3-quadtree/data.js 255 | 206,d3/d3-quadtree/extent.js 256 | 1696,d3/d3-quadtree/find.js 257 | 134,d3/d3-quadtree/quad.js 258 | 2077,d3/d3-quadtree/quadtree.js 259 | 1898,d3/d3-quadtree/remove.js 260 | 51,d3/d3-quadtree/root.js 261 | 155,d3/d3-quadtree/size.js 262 | 695,d3/d3-quadtree/visit.js 263 | 773,d3/d3-quadtree/visitAfter.js 264 | 138,d3/d3-quadtree/x.js 265 | 138,d3/d3-quadtree/y.js 266 | 29,d3/d3-queue/array.js 267 | 2870,d3/d3-queue/queue.js 268 | 168,d3/d3-random/bates.js 269 | 113,d3/d3-random/exponential.js 270 | 137,d3/d3-random/irwinHall.js 271 | 178,d3/d3-random/logNormal.js 272 | 503,d3/d3-random/normal.js 273 | 236,d3/d3-random/uniform.js 274 | 101,d3/d3-request/csv.js 275 | 517,d3/d3-request/dsv.js 276 | 157,d3/d3-request/html.js 277 | 127,d3/d3-request/json.js 278 | 4593,d3/d3-request/request.js 279 | 109,d3/d3-request/text.js 280 | 118,d3/d3-request/tsv.js 281 | 370,d3/d3-request/type.js 282 | 174,d3/d3-request/xml.js 283 | 90,d3/d3-scale/array.js 284 | 2637,d3/d3-scale/band.js 285 | 119,d3/d3-scale/category10.js 286 | 179,d3/d3-scale/category20.js 287 | 179,d3/d3-scale/category20b.js 288 | 179,d3/d3-scale/category20c.js 289 | 101,d3/d3-scale/colors.js 290 | 72,d3/d3-scale/constant.js 291 | 3328,d3/d3-scale/continuous.js 292 | 188,d3/d3-scale/cubehelix.js 293 | 463,d3/d3-scale/identity.js 294 | 1206,d3/d3-scale/linear.js 295 | 3273,d3/d3-scale/log.js 296 | 340,d3/d3-scale/nice.js 297 | 44,d3/d3-scale/number.js 298 | 1116,d3/d3-scale/ordinal.js 299 | 1000,d3/d3-scale/pow.js 300 | 1280,d3/d3-scale/quantile.js 301 | 1066,d3/d3-scale/quantize.js 302 | 536,d3/d3-scale/rainbow.js 303 | 717,d3/d3-scale/sequential.js 304 | 802,d3/d3-scale/threshold.js 305 | 1203,d3/d3-scale/tickFormat.js 306 | 4565,d3/d3-scale/time.js 307 | 379,d3/d3-scale/utcTime.js 308 | 6471,d3/d3-scale/viridis.js 309 | 72,d3/d3-selection/constant.js 310 | 662,d3/d3-selection/creator.js 311 | 536,d3/d3-selection/local.js 312 | 533,d3/d3-selection/matcher.js 313 | 224,d3/d3-selection/mouse.js 314 | 303,d3/d3-selection/namespace.js 315 | 254,d3/d3-selection/namespaces.js 316 | 448,d3/d3-selection/point.js 317 | 259,d3/d3-selection/select.js 318 | 282,d3/d3-selection/selectAll.js 319 | 235,d3/d3-selection/selection/append.js 320 | 1460,d3/d3-selection/selection/attr.js 321 | 134,d3/d3-selection/selection/call.js 322 | 1740,d3/d3-selection/selection/classed.js 323 | 3597,d3/d3-selection/selection/data.js 324 | 132,d3/d3-selection/selection/datum.js 325 | 869,d3/d3-selection/selection/dispatch.js 326 | 289,d3/d3-selection/selection/each.js 327 | 53,d3/d3-selection/selection/empty.js 328 | 792,d3/d3-selection/selection/enter.js 329 | 176,d3/d3-selection/selection/exit.js 330 | 546,d3/d3-selection/selection/filter.js 331 | 520,d3/d3-selection/selection/html.js 332 | 2216,d3/d3-selection/selection/index.js 333 | 468,d3/d3-selection/selection/insert.js 334 | 171,d3/d3-selection/selection/lower.js 335 | 575,d3/d3-selection/selection/merge.js 336 | 258,d3/d3-selection/selection/node.js 337 | 140,d3/d3-selection/selection/nodes.js 338 | 3119,d3/d3-selection/selection/on.js 339 | 367,d3/d3-selection/selection/order.js 340 | 617,d3/d3-selection/selection/property.js 341 | 138,d3/d3-selection/selection/raise.js 342 | 153,d3/d3-selection/selection/remove.js 343 | 653,d3/d3-selection/selection/select.js 344 | 550,d3/d3-selection/selection/selectAll.js 345 | 98,d3/d3-selection/selection/size.js 346 | 681,d3/d3-selection/selection/sort.js 347 | 71,d3/d3-selection/selection/sparse.js 348 | 889,d3/d3-selection/selection/style.js 349 | 528,d3/d3-selection/selection/text.js 350 | 152,d3/d3-selection/selector.js 351 | 171,d3/d3-selection/selectorAll.js 352 | 175,d3/d3-selection/sourceEvent.js 353 | 407,d3/d3-selection/touch.js 354 | 323,d3/d3-selection/touches.js 355 | 218,d3/d3-selection/window.js 356 | 8831,d3/d3-shape/arc.js 357 | 2917,d3/d3-shape/area.js 358 | 42,d3/d3-shape/array.js 359 | 81,d3/d3-shape/constant.js 360 | 1436,d3/d3-shape/curve/basis.js 361 | 1530,d3/d3-shape/curve/basisClosed.js 362 | 1069,d3/d3-shape/curve/basisOpen.js 363 | 1081,d3/d3-shape/curve/bundle.js 364 | 1633,d3/d3-shape/curve/cardinal.js 365 | 1605,d3/d3-shape/curve/cardinalClosed.js 366 | 1288,d3/d3-shape/curve/cardinalOpen.js 367 | 2637,d3/d3-shape/curve/catmullRom.js 368 | 2083,d3/d3-shape/curve/catmullRomClosed.js 369 | 1760,d3/d3-shape/curve/catmullRomOpen.js 370 | 738,d3/d3-shape/curve/linear.js 371 | 514,d3/d3-shape/curve/linearClosed.js 372 | 3203,d3/d3-shape/curve/monotone.js 373 | 1761,d3/d3-shape/curve/natural.js 374 | 655,d3/d3-shape/curve/radial.js 375 | 1367,d3/d3-shape/curve/step.js 376 | 86,d3/d3-shape/descending.js 377 | 43,d3/d3-shape/identity.js 378 | 1516,d3/d3-shape/line.js 379 | 106,d3/d3-shape/math.js 380 | 29,d3/d3-shape/noop.js 381 | 319,d3/d3-shape/offset/expand.js 382 | 310,d3/d3-shape/offset/none.js 383 | 314,d3/d3-shape/offset/silhouette.js 384 | 740,d3/d3-shape/offset/wiggle.js 385 | 305,d3/d3-shape/order/ascending.js 386 | 112,d3/d3-shape/order/descending.js 387 | 545,d3/d3-shape/order/insideOut.js 388 | 120,d3/d3-shape/order/none.js 389 | 97,d3/d3-shape/order/reverse.js 390 | 2336,d3/d3-shape/pie.js 391 | 81,d3/d3-shape/point.js 392 | 934,d3/d3-shape/radialArea.js 393 | 396,d3/d3-shape/radialLine.js 394 | 1432,d3/d3-shape/stack.js 395 | 186,d3/d3-shape/symbol/circle.js 396 | 476,d3/d3-shape/symbol/cross.js 397 | 307,d3/d3-shape/symbol/diamond.js 398 | 137,d3/d3-shape/symbol/square.js 399 | 609,d3/d3-shape/symbol/star.js 400 | 255,d3/d3-shape/symbol/triangle.js 401 | 733,d3/d3-shape/symbol/wye.js 402 | 1160,d3/d3-shape/symbol.js 403 | 867,d3/d3-time-format/defaultLocale.js 404 | 284,d3/d3-time-format/isoFormat.js 405 | 319,d3/d3-time-format/isoParse.js 406 | 13876,d3/d3-time-format/locale.js 407 | 462,d3/d3-time/day.js 408 | 164,d3/d3-time/duration.js 409 | 569,d3/d3-time/hour.js 410 | 1845,d3/d3-time/interval.js 411 | 668,d3/d3-time/millisecond.js 412 | 437,d3/d3-time/minute.js 413 | 414,d3/d3-time/month.js 414 | 440,d3/d3-time/second.js 415 | 397,d3/d3-time/utcDay.js 416 | 399,d3/d3-time/utcHour.js 417 | 412,d3/d3-time/utcMinute.js 418 | 453,d3/d3-time/utcMonth.js 419 | 979,d3/d3-time/utcWeek.js 420 | 808,d3/d3-time/utcYear.js 421 | 963,d3/d3-time/week.js 422 | 754,d3/d3-time/year.js 423 | 400,d3/d3-timer/interval.js 424 | 250,d3/d3-timer/timeout.js 425 | 2771,d3/d3-timer/timer.js 426 | 484,d3/d3-transition/active.js 427 | 665,d3/d3-transition/interrupt.js 428 | 245,d3/d3-transition/selection/index.js 429 | 138,d3/d3-transition/selection/interrupt.js 430 | 1090,d3/d3-transition/selection/transition.js 431 | 2473,d3/d3-transition/transition/attr.js 432 | 904,d3/d3-transition/transition/attrTween.js 433 | 510,d3/d3-transition/transition/delay.js 434 | 528,d3/d3-transition/transition/duration.js 435 | 348,d3/d3-transition/transition/ease.js 436 | 574,d3/d3-transition/transition/filter.js 437 | 1892,d3/d3-transition/transition/index.js 438 | 340,d3/d3-transition/transition/interpolate.js 439 | 653,d3/d3-transition/transition/merge.js 440 | 853,d3/d3-transition/transition/on.js 441 | 284,d3/d3-transition/transition/remove.js 442 | 4792,d3/d3-transition/transition/schedule.js 443 | 826,d3/d3-transition/transition/select.js 444 | 883,d3/d3-transition/transition/selectAll.js 445 | 174,d3/d3-transition/transition/selection.js 446 | 2119,d3/d3-transition/transition/style.js 447 | 607,d3/d3-transition/transition/styleTween.js 448 | 473,d3/d3-transition/transition/text.js 449 | 691,d3/d3-transition/transition/transition.js 450 | 2026,d3/d3-transition/transition/tween.js 451 | 4381,d3/d3-voronoi/Beach.js 452 | 4087,d3/d3-voronoi/Cell.js 453 | 1632,d3/d3-voronoi/Circle.js 454 | 72,d3/d3-voronoi/constant.js 455 | 3415,d3/d3-voronoi/Diagram.js 456 | 3634,d3/d3-voronoi/Edge.js 457 | 81,d3/d3-voronoi/point.js 458 | 5302,d3/d3-voronoi/RedBlackTree.js 459 | 1420,d3/d3-voronoi/voronoi.js 460 | 72,d3/d3-zoom/constant.js 461 | 137,d3/d3-zoom/event.js 462 | 202,d3/d3-zoom/noevent.js 463 | 1336,d3/d3-zoom/transform.js 464 | 12133,d3/d3-zoom/zoom.js -------------------------------------------------------------------------------- /example/datasets/forcegraph-dependencies.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": [ 3 | { "package": "react-force-graph", "user": "vasturiano" }, 4 | { "package": "force-graph", "user": "vasturiano" }, 5 | { "package": "3d-force-graph", "user": "vasturiano" }, 6 | { "package": "three-render-objects", "user": "vasturiano" }, 7 | { "package": "3d-force-graph-vr", "user": "vasturiano" }, 8 | { "package": "3d-force-graph-ar", "user": "vasturiano" }, 9 | { "package": "aframe-forcegraph-component", "user": "vasturiano" }, 10 | { "package": "three-forcegraph", "user": "vasturiano" }, 11 | { "package": "d3-force-3d", "user": "vasturiano" }, 12 | { "package": "d3-force", "user": "d3" }, 13 | { "package": "ngraph", "user": "anvaka" }, 14 | { "package": "three.js", "user": "mrdoob" }, 15 | { "package": "aframe", "user": "aframevr" }, 16 | { "package": "AR.js", "user": "jeromeetienne" } 17 | ], 18 | "links": [ 19 | { "target": "force-graph", "source": "react-force-graph" }, 20 | { "target": "3d-force-graph", "source": "react-force-graph" }, 21 | { "target": "3d-force-graph-vr", "source": "react-force-graph" }, 22 | { "target": "3d-force-graph-ar", "source": "react-force-graph" }, 23 | { "target": "aframe-forcegraph-component", "source": "3d-force-graph-vr" }, 24 | { "target": "aframe-forcegraph-component", "source": "3d-force-graph-ar" }, 25 | { "target": "three-forcegraph", "source": "3d-force-graph" }, 26 | { "target": "three-render-objects", "source": "3d-force-graph" }, 27 | { "target": "three-forcegraph", "source": "aframe-forcegraph-component" }, 28 | { "target": "d3-force-3d", "source": "three-forcegraph" }, 29 | { "target": "ngraph", "source": "three-forcegraph" }, 30 | { "target": "d3-force", "source": "force-graph" }, 31 | { "target": "aframe", "source": "3d-force-graph-vr" }, 32 | { "target": "three.js", "source": "aframe" }, 33 | { "target": "three.js", "source": "3d-force-graph" }, 34 | { "target": "AR.js", "source": "3d-force-graph-ar" }, 35 | { "target": "aframe", "source": "AR.js" }] 36 | } -------------------------------------------------------------------------------- /example/datasets/miserables.json: -------------------------------------------------------------------------------- 1 | { 2 | "nodes": [ 3 | {"id": "Myriel", "group": 1}, 4 | {"id": "Napoleon", "group": 1}, 5 | {"id": "Mlle.Baptistine", "group": 1}, 6 | {"id": "Mme.Magloire", "group": 1}, 7 | {"id": "CountessdeLo", "group": 1}, 8 | {"id": "Geborand", "group": 1}, 9 | {"id": "Champtercier", "group": 1}, 10 | {"id": "Cravatte", "group": 1}, 11 | {"id": "Count", "group": 1}, 12 | {"id": "OldMan", "group": 1}, 13 | {"id": "Labarre", "group": 2}, 14 | {"id": "Valjean", "group": 2}, 15 | {"id": "Marguerite", "group": 3}, 16 | {"id": "Mme.deR", "group": 2}, 17 | {"id": "Isabeau", "group": 2}, 18 | {"id": "Gervais", "group": 2}, 19 | {"id": "Tholomyes", "group": 3}, 20 | {"id": "Listolier", "group": 3}, 21 | {"id": "Fameuil", "group": 3}, 22 | {"id": "Blacheville", "group": 3}, 23 | {"id": "Favourite", "group": 3}, 24 | {"id": "Dahlia", "group": 3}, 25 | {"id": "Zephine", "group": 3}, 26 | {"id": "Fantine", "group": 3}, 27 | {"id": "Mme.Thenardier", "group": 4}, 28 | {"id": "Thenardier", "group": 4}, 29 | {"id": "Cosette", "group": 5}, 30 | {"id": "Javert", "group": 4}, 31 | {"id": "Fauchelevent", "group": 0}, 32 | {"id": "Bamatabois", "group": 2}, 33 | {"id": "Perpetue", "group": 3}, 34 | {"id": "Simplice", "group": 2}, 35 | {"id": "Scaufflaire", "group": 2}, 36 | {"id": "Woman1", "group": 2}, 37 | {"id": "Judge", "group": 2}, 38 | {"id": "Champmathieu", "group": 2}, 39 | {"id": "Brevet", "group": 2}, 40 | {"id": "Chenildieu", "group": 2}, 41 | {"id": "Cochepaille", "group": 2}, 42 | {"id": "Pontmercy", "group": 4}, 43 | {"id": "Boulatruelle", "group": 6}, 44 | {"id": "Eponine", "group": 4}, 45 | {"id": "Anzelma", "group": 4}, 46 | {"id": "Woman2", "group": 5}, 47 | {"id": "MotherInnocent", "group": 0}, 48 | {"id": "Gribier", "group": 0}, 49 | {"id": "Jondrette", "group": 7}, 50 | {"id": "Mme.Burgon", "group": 7}, 51 | {"id": "Gavroche", "group": 8}, 52 | {"id": "Gillenormand", "group": 5}, 53 | {"id": "Magnon", "group": 5}, 54 | {"id": "Mlle.Gillenormand", "group": 5}, 55 | {"id": "Mme.Pontmercy", "group": 5}, 56 | {"id": "Mlle.Vaubois", "group": 5}, 57 | {"id": "Lt.Gillenormand", "group": 5}, 58 | {"id": "Marius", "group": 8}, 59 | {"id": "BaronessT", "group": 5}, 60 | {"id": "Mabeuf", "group": 8}, 61 | {"id": "Enjolras", "group": 8}, 62 | {"id": "Combeferre", "group": 8}, 63 | {"id": "Prouvaire", "group": 8}, 64 | {"id": "Feuilly", "group": 8}, 65 | {"id": "Courfeyrac", "group": 8}, 66 | {"id": "Bahorel", "group": 8}, 67 | {"id": "Bossuet", "group": 8}, 68 | {"id": "Joly", "group": 8}, 69 | {"id": "Grantaire", "group": 8}, 70 | {"id": "MotherPlutarch", "group": 9}, 71 | {"id": "Gueulemer", "group": 4}, 72 | {"id": "Babet", "group": 4}, 73 | {"id": "Claquesous", "group": 4}, 74 | {"id": "Montparnasse", "group": 4}, 75 | {"id": "Toussaint", "group": 5}, 76 | {"id": "Child1", "group": 10}, 77 | {"id": "Child2", "group": 10}, 78 | {"id": "Brujon", "group": 4}, 79 | {"id": "Mme.Hucheloup", "group": 8} 80 | ], 81 | "links": [ 82 | {"source": "Napoleon", "target": "Myriel", "value": 1}, 83 | {"source": "Mlle.Baptistine", "target": "Myriel", "value": 8}, 84 | {"source": "Mme.Magloire", "target": "Myriel", "value": 10}, 85 | {"source": "Mme.Magloire", "target": "Mlle.Baptistine", "value": 6}, 86 | {"source": "CountessdeLo", "target": "Myriel", "value": 1}, 87 | {"source": "Geborand", "target": "Myriel", "value": 1}, 88 | {"source": "Champtercier", "target": "Myriel", "value": 1}, 89 | {"source": "Cravatte", "target": "Myriel", "value": 1}, 90 | {"source": "Count", "target": "Myriel", "value": 2}, 91 | {"source": "OldMan", "target": "Myriel", "value": 1}, 92 | {"source": "Valjean", "target": "Labarre", "value": 1}, 93 | {"source": "Valjean", "target": "Mme.Magloire", "value": 3}, 94 | {"source": "Valjean", "target": "Mlle.Baptistine", "value": 3}, 95 | {"source": "Valjean", "target": "Myriel", "value": 5}, 96 | {"source": "Marguerite", "target": "Valjean", "value": 1}, 97 | {"source": "Mme.deR", "target": "Valjean", "value": 1}, 98 | {"source": "Isabeau", "target": "Valjean", "value": 1}, 99 | {"source": "Gervais", "target": "Valjean", "value": 1}, 100 | {"source": "Listolier", "target": "Tholomyes", "value": 4}, 101 | {"source": "Fameuil", "target": "Tholomyes", "value": 4}, 102 | {"source": "Fameuil", "target": "Listolier", "value": 4}, 103 | {"source": "Blacheville", "target": "Tholomyes", "value": 4}, 104 | {"source": "Blacheville", "target": "Listolier", "value": 4}, 105 | {"source": "Blacheville", "target": "Fameuil", "value": 4}, 106 | {"source": "Favourite", "target": "Tholomyes", "value": 3}, 107 | {"source": "Favourite", "target": "Listolier", "value": 3}, 108 | {"source": "Favourite", "target": "Fameuil", "value": 3}, 109 | {"source": "Favourite", "target": "Blacheville", "value": 4}, 110 | {"source": "Dahlia", "target": "Tholomyes", "value": 3}, 111 | {"source": "Dahlia", "target": "Listolier", "value": 3}, 112 | {"source": "Dahlia", "target": "Fameuil", "value": 3}, 113 | {"source": "Dahlia", "target": "Blacheville", "value": 3}, 114 | {"source": "Dahlia", "target": "Favourite", "value": 5}, 115 | {"source": "Zephine", "target": "Tholomyes", "value": 3}, 116 | {"source": "Zephine", "target": "Listolier", "value": 3}, 117 | {"source": "Zephine", "target": "Fameuil", "value": 3}, 118 | {"source": "Zephine", "target": "Blacheville", "value": 3}, 119 | {"source": "Zephine", "target": "Favourite", "value": 4}, 120 | {"source": "Zephine", "target": "Dahlia", "value": 4}, 121 | {"source": "Fantine", "target": "Tholomyes", "value": 3}, 122 | {"source": "Fantine", "target": "Listolier", "value": 3}, 123 | {"source": "Fantine", "target": "Fameuil", "value": 3}, 124 | {"source": "Fantine", "target": "Blacheville", "value": 3}, 125 | {"source": "Fantine", "target": "Favourite", "value": 4}, 126 | {"source": "Fantine", "target": "Dahlia", "value": 4}, 127 | {"source": "Fantine", "target": "Zephine", "value": 4}, 128 | {"source": "Fantine", "target": "Marguerite", "value": 2}, 129 | {"source": "Fantine", "target": "Valjean", "value": 9}, 130 | {"source": "Mme.Thenardier", "target": "Fantine", "value": 2}, 131 | {"source": "Mme.Thenardier", "target": "Valjean", "value": 7}, 132 | {"source": "Thenardier", "target": "Mme.Thenardier", "value": 13}, 133 | {"source": "Thenardier", "target": "Fantine", "value": 1}, 134 | {"source": "Thenardier", "target": "Valjean", "value": 12}, 135 | {"source": "Cosette", "target": "Mme.Thenardier", "value": 4}, 136 | {"source": "Cosette", "target": "Valjean", "value": 31}, 137 | {"source": "Cosette", "target": "Tholomyes", "value": 1}, 138 | {"source": "Cosette", "target": "Thenardier", "value": 1}, 139 | {"source": "Javert", "target": "Valjean", "value": 17}, 140 | {"source": "Javert", "target": "Fantine", "value": 5}, 141 | {"source": "Javert", "target": "Thenardier", "value": 5}, 142 | {"source": "Javert", "target": "Mme.Thenardier", "value": 1}, 143 | {"source": "Javert", "target": "Cosette", "value": 1}, 144 | {"source": "Fauchelevent", "target": "Valjean", "value": 8}, 145 | {"source": "Fauchelevent", "target": "Javert", "value": 1}, 146 | {"source": "Bamatabois", "target": "Fantine", "value": 1}, 147 | {"source": "Bamatabois", "target": "Javert", "value": 1}, 148 | {"source": "Bamatabois", "target": "Valjean", "value": 2}, 149 | {"source": "Perpetue", "target": "Fantine", "value": 1}, 150 | {"source": "Simplice", "target": "Perpetue", "value": 2}, 151 | {"source": "Simplice", "target": "Valjean", "value": 3}, 152 | {"source": "Simplice", "target": "Fantine", "value": 2}, 153 | {"source": "Simplice", "target": "Javert", "value": 1}, 154 | {"source": "Scaufflaire", "target": "Valjean", "value": 1}, 155 | {"source": "Woman1", "target": "Valjean", "value": 2}, 156 | {"source": "Woman1", "target": "Javert", "value": 1}, 157 | {"source": "Judge", "target": "Valjean", "value": 3}, 158 | {"source": "Judge", "target": "Bamatabois", "value": 2}, 159 | {"source": "Champmathieu", "target": "Valjean", "value": 3}, 160 | {"source": "Champmathieu", "target": "Judge", "value": 3}, 161 | {"source": "Champmathieu", "target": "Bamatabois", "value": 2}, 162 | {"source": "Brevet", "target": "Judge", "value": 2}, 163 | {"source": "Brevet", "target": "Champmathieu", "value": 2}, 164 | {"source": "Brevet", "target": "Valjean", "value": 2}, 165 | {"source": "Brevet", "target": "Bamatabois", "value": 1}, 166 | {"source": "Chenildieu", "target": "Judge", "value": 2}, 167 | {"source": "Chenildieu", "target": "Champmathieu", "value": 2}, 168 | {"source": "Chenildieu", "target": "Brevet", "value": 2}, 169 | {"source": "Chenildieu", "target": "Valjean", "value": 2}, 170 | {"source": "Chenildieu", "target": "Bamatabois", "value": 1}, 171 | {"source": "Cochepaille", "target": "Judge", "value": 2}, 172 | {"source": "Cochepaille", "target": "Champmathieu", "value": 2}, 173 | {"source": "Cochepaille", "target": "Brevet", "value": 2}, 174 | {"source": "Cochepaille", "target": "Chenildieu", "value": 2}, 175 | {"source": "Cochepaille", "target": "Valjean", "value": 2}, 176 | {"source": "Cochepaille", "target": "Bamatabois", "value": 1}, 177 | {"source": "Pontmercy", "target": "Thenardier", "value": 1}, 178 | {"source": "Boulatruelle", "target": "Thenardier", "value": 1}, 179 | {"source": "Eponine", "target": "Mme.Thenardier", "value": 2}, 180 | {"source": "Eponine", "target": "Thenardier", "value": 3}, 181 | {"source": "Anzelma", "target": "Eponine", "value": 2}, 182 | {"source": "Anzelma", "target": "Thenardier", "value": 2}, 183 | {"source": "Anzelma", "target": "Mme.Thenardier", "value": 1}, 184 | {"source": "Woman2", "target": "Valjean", "value": 3}, 185 | {"source": "Woman2", "target": "Cosette", "value": 1}, 186 | {"source": "Woman2", "target": "Javert", "value": 1}, 187 | {"source": "MotherInnocent", "target": "Fauchelevent", "value": 3}, 188 | {"source": "MotherInnocent", "target": "Valjean", "value": 1}, 189 | {"source": "Gribier", "target": "Fauchelevent", "value": 2}, 190 | {"source": "Mme.Burgon", "target": "Jondrette", "value": 1}, 191 | {"source": "Gavroche", "target": "Mme.Burgon", "value": 2}, 192 | {"source": "Gavroche", "target": "Thenardier", "value": 1}, 193 | {"source": "Gavroche", "target": "Javert", "value": 1}, 194 | {"source": "Gavroche", "target": "Valjean", "value": 1}, 195 | {"source": "Gillenormand", "target": "Cosette", "value": 3}, 196 | {"source": "Gillenormand", "target": "Valjean", "value": 2}, 197 | {"source": "Magnon", "target": "Gillenormand", "value": 1}, 198 | {"source": "Magnon", "target": "Mme.Thenardier", "value": 1}, 199 | {"source": "Mlle.Gillenormand", "target": "Gillenormand", "value": 9}, 200 | {"source": "Mlle.Gillenormand", "target": "Cosette", "value": 2}, 201 | {"source": "Mlle.Gillenormand", "target": "Valjean", "value": 2}, 202 | {"source": "Mme.Pontmercy", "target": "Mlle.Gillenormand", "value": 1}, 203 | {"source": "Mme.Pontmercy", "target": "Pontmercy", "value": 1}, 204 | {"source": "Mlle.Vaubois", "target": "Mlle.Gillenormand", "value": 1}, 205 | {"source": "Lt.Gillenormand", "target": "Mlle.Gillenormand", "value": 2}, 206 | {"source": "Lt.Gillenormand", "target": "Gillenormand", "value": 1}, 207 | {"source": "Lt.Gillenormand", "target": "Cosette", "value": 1}, 208 | {"source": "Marius", "target": "Mlle.Gillenormand", "value": 6}, 209 | {"source": "Marius", "target": "Gillenormand", "value": 12}, 210 | {"source": "Marius", "target": "Pontmercy", "value": 1}, 211 | {"source": "Marius", "target": "Lt.Gillenormand", "value": 1}, 212 | {"source": "Marius", "target": "Cosette", "value": 21}, 213 | {"source": "Marius", "target": "Valjean", "value": 19}, 214 | {"source": "Marius", "target": "Tholomyes", "value": 1}, 215 | {"source": "Marius", "target": "Thenardier", "value": 2}, 216 | {"source": "Marius", "target": "Eponine", "value": 5}, 217 | {"source": "Marius", "target": "Gavroche", "value": 4}, 218 | {"source": "BaronessT", "target": "Gillenormand", "value": 1}, 219 | {"source": "BaronessT", "target": "Marius", "value": 1}, 220 | {"source": "Mabeuf", "target": "Marius", "value": 1}, 221 | {"source": "Mabeuf", "target": "Eponine", "value": 1}, 222 | {"source": "Mabeuf", "target": "Gavroche", "value": 1}, 223 | {"source": "Enjolras", "target": "Marius", "value": 7}, 224 | {"source": "Enjolras", "target": "Gavroche", "value": 7}, 225 | {"source": "Enjolras", "target": "Javert", "value": 6}, 226 | {"source": "Enjolras", "target": "Mabeuf", "value": 1}, 227 | {"source": "Enjolras", "target": "Valjean", "value": 4}, 228 | {"source": "Combeferre", "target": "Enjolras", "value": 15}, 229 | {"source": "Combeferre", "target": "Marius", "value": 5}, 230 | {"source": "Combeferre", "target": "Gavroche", "value": 6}, 231 | {"source": "Combeferre", "target": "Mabeuf", "value": 2}, 232 | {"source": "Prouvaire", "target": "Gavroche", "value": 1}, 233 | {"source": "Prouvaire", "target": "Enjolras", "value": 4}, 234 | {"source": "Prouvaire", "target": "Combeferre", "value": 2}, 235 | {"source": "Feuilly", "target": "Gavroche", "value": 2}, 236 | {"source": "Feuilly", "target": "Enjolras", "value": 6}, 237 | {"source": "Feuilly", "target": "Prouvaire", "value": 2}, 238 | {"source": "Feuilly", "target": "Combeferre", "value": 5}, 239 | {"source": "Feuilly", "target": "Mabeuf", "value": 1}, 240 | {"source": "Feuilly", "target": "Marius", "value": 1}, 241 | {"source": "Courfeyrac", "target": "Marius", "value": 9}, 242 | {"source": "Courfeyrac", "target": "Enjolras", "value": 17}, 243 | {"source": "Courfeyrac", "target": "Combeferre", "value": 13}, 244 | {"source": "Courfeyrac", "target": "Gavroche", "value": 7}, 245 | {"source": "Courfeyrac", "target": "Mabeuf", "value": 2}, 246 | {"source": "Courfeyrac", "target": "Eponine", "value": 1}, 247 | {"source": "Courfeyrac", "target": "Feuilly", "value": 6}, 248 | {"source": "Courfeyrac", "target": "Prouvaire", "value": 3}, 249 | {"source": "Bahorel", "target": "Combeferre", "value": 5}, 250 | {"source": "Bahorel", "target": "Gavroche", "value": 5}, 251 | {"source": "Bahorel", "target": "Courfeyrac", "value": 6}, 252 | {"source": "Bahorel", "target": "Mabeuf", "value": 2}, 253 | {"source": "Bahorel", "target": "Enjolras", "value": 4}, 254 | {"source": "Bahorel", "target": "Feuilly", "value": 3}, 255 | {"source": "Bahorel", "target": "Prouvaire", "value": 2}, 256 | {"source": "Bahorel", "target": "Marius", "value": 1}, 257 | {"source": "Bossuet", "target": "Marius", "value": 5}, 258 | {"source": "Bossuet", "target": "Courfeyrac", "value": 12}, 259 | {"source": "Bossuet", "target": "Gavroche", "value": 5}, 260 | {"source": "Bossuet", "target": "Bahorel", "value": 4}, 261 | {"source": "Bossuet", "target": "Enjolras", "value": 10}, 262 | {"source": "Bossuet", "target": "Feuilly", "value": 6}, 263 | {"source": "Bossuet", "target": "Prouvaire", "value": 2}, 264 | {"source": "Bossuet", "target": "Combeferre", "value": 9}, 265 | {"source": "Bossuet", "target": "Mabeuf", "value": 1}, 266 | {"source": "Bossuet", "target": "Valjean", "value": 1}, 267 | {"source": "Joly", "target": "Bahorel", "value": 5}, 268 | {"source": "Joly", "target": "Bossuet", "value": 7}, 269 | {"source": "Joly", "target": "Gavroche", "value": 3}, 270 | {"source": "Joly", "target": "Courfeyrac", "value": 5}, 271 | {"source": "Joly", "target": "Enjolras", "value": 5}, 272 | {"source": "Joly", "target": "Feuilly", "value": 5}, 273 | {"source": "Joly", "target": "Prouvaire", "value": 2}, 274 | {"source": "Joly", "target": "Combeferre", "value": 5}, 275 | {"source": "Joly", "target": "Mabeuf", "value": 1}, 276 | {"source": "Joly", "target": "Marius", "value": 2}, 277 | {"source": "Grantaire", "target": "Bossuet", "value": 3}, 278 | {"source": "Grantaire", "target": "Enjolras", "value": 3}, 279 | {"source": "Grantaire", "target": "Combeferre", "value": 1}, 280 | {"source": "Grantaire", "target": "Courfeyrac", "value": 2}, 281 | {"source": "Grantaire", "target": "Joly", "value": 2}, 282 | {"source": "Grantaire", "target": "Gavroche", "value": 1}, 283 | {"source": "Grantaire", "target": "Bahorel", "value": 1}, 284 | {"source": "Grantaire", "target": "Feuilly", "value": 1}, 285 | {"source": "Grantaire", "target": "Prouvaire", "value": 1}, 286 | {"source": "MotherPlutarch", "target": "Mabeuf", "value": 3}, 287 | {"source": "Gueulemer", "target": "Thenardier", "value": 5}, 288 | {"source": "Gueulemer", "target": "Valjean", "value": 1}, 289 | {"source": "Gueulemer", "target": "Mme.Thenardier", "value": 1}, 290 | {"source": "Gueulemer", "target": "Javert", "value": 1}, 291 | {"source": "Gueulemer", "target": "Gavroche", "value": 1}, 292 | {"source": "Gueulemer", "target": "Eponine", "value": 1}, 293 | {"source": "Babet", "target": "Thenardier", "value": 6}, 294 | {"source": "Babet", "target": "Gueulemer", "value": 6}, 295 | {"source": "Babet", "target": "Valjean", "value": 1}, 296 | {"source": "Babet", "target": "Mme.Thenardier", "value": 1}, 297 | {"source": "Babet", "target": "Javert", "value": 2}, 298 | {"source": "Babet", "target": "Gavroche", "value": 1}, 299 | {"source": "Babet", "target": "Eponine", "value": 1}, 300 | {"source": "Claquesous", "target": "Thenardier", "value": 4}, 301 | {"source": "Claquesous", "target": "Babet", "value": 4}, 302 | {"source": "Claquesous", "target": "Gueulemer", "value": 4}, 303 | {"source": "Claquesous", "target": "Valjean", "value": 1}, 304 | {"source": "Claquesous", "target": "Mme.Thenardier", "value": 1}, 305 | {"source": "Claquesous", "target": "Javert", "value": 1}, 306 | {"source": "Claquesous", "target": "Eponine", "value": 1}, 307 | {"source": "Claquesous", "target": "Enjolras", "value": 1}, 308 | {"source": "Montparnasse", "target": "Javert", "value": 1}, 309 | {"source": "Montparnasse", "target": "Babet", "value": 2}, 310 | {"source": "Montparnasse", "target": "Gueulemer", "value": 2}, 311 | {"source": "Montparnasse", "target": "Claquesous", "value": 2}, 312 | {"source": "Montparnasse", "target": "Valjean", "value": 1}, 313 | {"source": "Montparnasse", "target": "Gavroche", "value": 1}, 314 | {"source": "Montparnasse", "target": "Eponine", "value": 1}, 315 | {"source": "Montparnasse", "target": "Thenardier", "value": 1}, 316 | {"source": "Toussaint", "target": "Cosette", "value": 2}, 317 | {"source": "Toussaint", "target": "Javert", "value": 1}, 318 | {"source": "Toussaint", "target": "Valjean", "value": 1}, 319 | {"source": "Child1", "target": "Gavroche", "value": 2}, 320 | {"source": "Child2", "target": "Gavroche", "value": 2}, 321 | {"source": "Child2", "target": "Child1", "value": 3}, 322 | {"source": "Brujon", "target": "Babet", "value": 3}, 323 | {"source": "Brujon", "target": "Gueulemer", "value": 3}, 324 | {"source": "Brujon", "target": "Thenardier", "value": 3}, 325 | {"source": "Brujon", "target": "Gavroche", "value": 1}, 326 | {"source": "Brujon", "target": "Eponine", "value": 1}, 327 | {"source": "Brujon", "target": "Claquesous", "value": 1}, 328 | {"source": "Brujon", "target": "Montparnasse", "value": 1}, 329 | {"source": "Mme.Hucheloup", "target": "Bossuet", "value": 1}, 330 | {"source": "Mme.Hucheloup", "target": "Joly", "value": 1}, 331 | {"source": "Mme.Hucheloup", "target": "Grantaire", "value": 1}, 332 | {"source": "Mme.Hucheloup", "target": "Bahorel", "value": 1}, 333 | {"source": "Mme.Hucheloup", "target": "Courfeyrac", "value": 1}, 334 | {"source": "Mme.Hucheloup", "target": "Gavroche", "value": 1}, 335 | {"source": "Mme.Hucheloup", "target": "Enjolras", "value": 1} 336 | ] 337 | } 338 | -------------------------------------------------------------------------------- /example/datasets/random-data.js: -------------------------------------------------------------------------------- 1 | export function genRandomTree(N = 300, reverse = false) { 2 | return { 3 | nodes: [...Array(N).keys()].map(i => ({ id: i })), 4 | links: [...Array(N).keys()] 5 | .filter(id => id) 6 | .map(id => ({ 7 | [reverse ? 'target' : 'source']: id, 8 | [reverse ? 'source' : 'target']: Math.round(Math.random() * (id-1)) 9 | })) 10 | }; 11 | } -------------------------------------------------------------------------------- /example/directional-links-arrows/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 32 | -------------------------------------------------------------------------------- /example/directional-links-particles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 34 | -------------------------------------------------------------------------------- /example/dynamic/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 60 | -------------------------------------------------------------------------------- /example/emit-particles/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 41 | -------------------------------------------------------------------------------- /example/expandable-nodes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 73 | -------------------------------------------------------------------------------- /example/fit-to-canvas/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 38 | -------------------------------------------------------------------------------- /example/fix-dragged-nodes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 37 | -------------------------------------------------------------------------------- /example/forcegraph-dependencies/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 46 | -------------------------------------------------------------------------------- /example/highlight/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 106 | -------------------------------------------------------------------------------- /example/html-nodes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 53 | -------------------------------------------------------------------------------- /example/img-nodes/imgs/cat.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/cat.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/dog.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/eagle.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/eagle.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/elephant.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/elephant.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/grasshopper.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/grasshopper.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/octopus.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/octopus.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/owl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/owl.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/panda.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/panda.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/squirrel.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/squirrel.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/tiger.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/tiger.jpg -------------------------------------------------------------------------------- /example/img-nodes/imgs/whale.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/img-nodes/imgs/whale.jpg -------------------------------------------------------------------------------- /example/img-nodes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 51 | -------------------------------------------------------------------------------- /example/large-graph/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 33 | -------------------------------------------------------------------------------- /example/multi-selection/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 62 | -------------------------------------------------------------------------------- /example/preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vasturiano/react-force-graph/a27da7c4828a9398997e23350a839d71ec298cd1/example/preview.png -------------------------------------------------------------------------------- /example/text-links/index-3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 49 | -------------------------------------------------------------------------------- /example/text-nodes/index-2d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 53 | -------------------------------------------------------------------------------- /example/text-nodes/index-3d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 38 | -------------------------------------------------------------------------------- /example/tree/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 98 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-force-graph", 3 | "version": "1.47.6", 4 | "description": "React component for 2D, 3D, VR and AR force directed graphs", 5 | "license": "MIT", 6 | "type": "module", 7 | "unpkg": "dist/react-force-graph.min.js", 8 | "jsdelivr": "dist/react-force-graph.min.js", 9 | "main": "dist/react-force-graph.mjs", 10 | "module": "dist/react-force-graph.mjs", 11 | "types": "dist/react-force-graph.d.ts", 12 | "exports": { 13 | "types": "./dist/react-force-graph.d.ts", 14 | "umd": "./dist/react-force-graph.min.js", 15 | "default": "./dist/react-force-graph.mjs" 16 | }, 17 | "sideEffects": false, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vasturiano/react-force-graph.git" 21 | }, 22 | "homepage": "https://github.com/vasturiano/react-force-graph", 23 | "keywords": [ 24 | "react", 25 | "force", 26 | "graph", 27 | "3d", 28 | "2d", 29 | "vr", 30 | "ar", 31 | "three", 32 | "webgl", 33 | "canvas" 34 | ], 35 | "author": { 36 | "name": "Vasco Asturiano", 37 | "url": "https://github.com/vasturiano" 38 | }, 39 | "bugs": { 40 | "url": "https://github.com/vasturiano/react-force-graph/issues" 41 | }, 42 | "scripts": { 43 | "build": "rimraf dist && rollup -c", 44 | "dev": "rollup -w -c rollup.config.dev.js", 45 | "prepare": "npm run build" 46 | }, 47 | "files": [ 48 | "dist/**/*" 49 | ], 50 | "dependencies": { 51 | "3d-force-graph": "^1.76", 52 | "3d-force-graph-ar": "^1.9", 53 | "3d-force-graph-vr": "^3.0", 54 | "force-graph": "^1.49", 55 | "prop-types": "15", 56 | "react-kapsule": "^2.5" 57 | }, 58 | "peerDependencies": { 59 | "react": "*" 60 | }, 61 | "devDependencies": { 62 | "@babel/core": "^7.26.8", 63 | "@babel/preset-env": "^7.26.8", 64 | "@babel/preset-react": "^7.26.3", 65 | "@rollup/plugin-babel": "^6.0.4", 66 | "@rollup/plugin-commonjs": "^28.0.2", 67 | "@rollup/plugin-node-resolve": "^16.0.0", 68 | "@rollup/plugin-replace": "^6.0.2", 69 | "@rollup/plugin-terser": "^0.4.4", 70 | "@types/react": "^19.0.8", 71 | "@types/three": "^0.173.0", 72 | "rimraf": "^6.0.1", 73 | "rollup": "^4.34.6", 74 | "rollup-plugin-dts": "^6.1.1", 75 | "typescript": "^5.7.3" 76 | }, 77 | "engines": { 78 | "node": ">=12" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /rollup.config.dev.js: -------------------------------------------------------------------------------- 1 | import buildConfig from './rollup.config.js'; 2 | 3 | // use first output of first config block for dev 4 | const config = Array.isArray(buildConfig) ? buildConfig[0] : buildConfig; 5 | Array.isArray(config.output) && (config.output = config.output[0]); 6 | 7 | export default config; -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonJs from '@rollup/plugin-commonjs'; 3 | import replace from '@rollup/plugin-replace'; 4 | import babel from '@rollup/plugin-babel'; 5 | import terser from "@rollup/plugin-terser"; 6 | import dts from 'rollup-plugin-dts'; 7 | 8 | import pkg from './package.json' with { type: 'json' }; 9 | const { name, homepage, version, dependencies, peerDependencies } = pkg; 10 | 11 | const umdConf = { 12 | format: 'umd', 13 | name: 'ForceGraph', 14 | globals: { react: 'React' }, 15 | banner: `// Version ${version} ${name} - ${homepage}` 16 | }; 17 | 18 | export default [ 19 | { 20 | external: ['react'], 21 | input: 'src/index.js', 22 | output: [ 23 | { 24 | ...umdConf, 25 | file: `dist/${name}.js`, 26 | sourcemap: true 27 | }, 28 | { // minify 29 | ...umdConf, 30 | file: `dist/${name}.min.js`, 31 | plugins: [terser({ 32 | output: { comments: '/Version/' } 33 | })] 34 | } 35 | ], 36 | plugins: [ 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), // To fool React in the browser 38 | babel({ exclude: '**/node_modules/**' }), 39 | resolve(), 40 | commonJs() 41 | ] 42 | }, 43 | { // ES module 44 | input: 'src/index.js', 45 | output: [ 46 | { 47 | format: 'es', 48 | file: `dist/${name}.mjs` 49 | } 50 | ], 51 | external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)], 52 | plugins: [ 53 | babel() 54 | ] 55 | }, 56 | { // expose TS declarations 57 | input: 'src/index.d.ts', 58 | output: [{ 59 | file: `dist/${name}.d.ts`, 60 | format: 'es' 61 | }], 62 | plugins: [dts()] 63 | } 64 | ]; -------------------------------------------------------------------------------- /src/forcegraph-proptypes.js: -------------------------------------------------------------------------------- 1 | import PropTypes from 'prop-types'; 2 | 3 | const commonPropTypes = { 4 | width: PropTypes.number, 5 | height: PropTypes.number, 6 | graphData: PropTypes.shape({ 7 | nodes: PropTypes.arrayOf(PropTypes.object).isRequired, 8 | links: PropTypes.arrayOf(PropTypes.object).isRequired 9 | }), 10 | backgroundColor: PropTypes.string, 11 | nodeRelSize: PropTypes.number, 12 | nodeId: PropTypes.string, 13 | nodeLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 14 | nodeVal: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 15 | nodeVisibility: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.func]), 16 | nodeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 17 | nodeAutoColorBy: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 18 | onNodeHover: PropTypes.func, 19 | onNodeClick: PropTypes.func, 20 | linkSource: PropTypes.string, 21 | linkTarget: PropTypes.string, 22 | linkLabel: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 23 | linkVisibility: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.func]), 24 | linkColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 25 | linkAutoColorBy: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 26 | linkWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 27 | linkCurvature: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 28 | linkDirectionalArrowLength: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 29 | linkDirectionalArrowColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 30 | linkDirectionalArrowRelPos: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 31 | linkDirectionalParticles: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 32 | linkDirectionalParticleSpeed: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 33 | linkDirectionalParticleWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 34 | linkDirectionalParticleColor: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 35 | onLinkHover: PropTypes.func, 36 | onLinkClick: PropTypes.func, 37 | dagMode: PropTypes.oneOf(['td', 'bu', 'lr', 'rl', 'zin', 'zout', 'radialin', 'radialout']), 38 | dagLevelDistance: PropTypes.number, 39 | dagNodeFilter: PropTypes.func, 40 | onDagError: PropTypes.func, 41 | d3AlphaMin: PropTypes.number, 42 | d3AlphaDecay: PropTypes.number, 43 | d3VelocityDecay: PropTypes.number, 44 | warmupTicks: PropTypes.number, 45 | cooldownTicks: PropTypes.number, 46 | cooldownTime: PropTypes.number, 47 | onEngineTick: PropTypes.func, 48 | onEngineStop: PropTypes.func, 49 | getGraphBbox: PropTypes.func 50 | }; 51 | 52 | const pointerBasedPropTypes = { 53 | zoomToFit: PropTypes.func, 54 | onNodeRightClick: PropTypes.func, 55 | onNodeDrag: PropTypes.func, 56 | onNodeDragEnd: PropTypes.func, 57 | onLinkRightClick: PropTypes.func, 58 | linkHoverPrecision: PropTypes.number, 59 | onBackgroundClick: PropTypes.func, 60 | onBackgroundRightClick: PropTypes.func, 61 | enablePointerInteraction: PropTypes.bool, 62 | enableNodeDrag: PropTypes.bool 63 | }; 64 | 65 | const threeBasedPropTypes = { 66 | showNavInfo: PropTypes.bool, 67 | nodeOpacity: PropTypes.number, 68 | nodeResolution: PropTypes.number, 69 | nodeThreeObject: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]), 70 | nodeThreeObjectExtend: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.func]), 71 | linkOpacity: PropTypes.number, 72 | linkResolution: PropTypes.number, 73 | linkCurveRotation: PropTypes.oneOfType([PropTypes.number, PropTypes.string, PropTypes.func]), 74 | linkMaterial: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]), 75 | linkThreeObject: PropTypes.oneOfType([PropTypes.object, PropTypes.string, PropTypes.func]), 76 | linkThreeObjectExtend: PropTypes.oneOfType([PropTypes.bool, PropTypes.string, PropTypes.func]), 77 | linkPositionUpdate: PropTypes.func, 78 | linkDirectionalArrowResolution: PropTypes.number, 79 | linkDirectionalParticleResolution: PropTypes.number, 80 | forceEngine: PropTypes.oneOf(['d3', 'ngraph']), 81 | ngraphPhysics: PropTypes.object, 82 | numDimensions: PropTypes.oneOf([1, 2, 3]) 83 | }; 84 | 85 | export const ForceGraph2DPropTypes = Object.assign({}, 86 | commonPropTypes, 87 | pointerBasedPropTypes, 88 | { 89 | linkLineDash: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.string, PropTypes.func]), 90 | nodeCanvasObjectMode: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 91 | nodeCanvasObject: PropTypes.func, 92 | nodePointerAreaPaint: PropTypes.func, 93 | linkCanvasObjectMode: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 94 | linkCanvasObject: PropTypes.func, 95 | linkPointerAreaPaint: PropTypes.func, 96 | autoPauseRedraw: PropTypes.bool, 97 | minZoom: PropTypes.number, 98 | maxZoom: PropTypes.number, 99 | enableZoomInteraction: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), 100 | enablePanInteraction: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]), 101 | onZoom: PropTypes.func, 102 | onZoomEnd: PropTypes.func, 103 | onRenderFramePre: PropTypes.func, 104 | onRenderFramePost: PropTypes.func 105 | } 106 | ); 107 | 108 | export const ForceGraph3DPropTypes = Object.assign({}, 109 | commonPropTypes, 110 | pointerBasedPropTypes, 111 | threeBasedPropTypes, 112 | { 113 | enableNavigationControls: PropTypes.bool, 114 | controlType: PropTypes.oneOf(['trackball', 'orbit', 'fly']), 115 | rendererConfig: PropTypes.object, 116 | extraRenderers: PropTypes.arrayOf(PropTypes.shape({ render: PropTypes.func.isRequired })) 117 | } 118 | ); 119 | 120 | export const ForceGraphVRPropTypes = Object.assign({}, 121 | commonPropTypes, 122 | threeBasedPropTypes, 123 | { 124 | nodeDesc: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), 125 | linkDesc: PropTypes.oneOfType([PropTypes.string, PropTypes.func]) 126 | } 127 | ); 128 | 129 | export const ForceGraphARPropTypes = Object.assign({}, 130 | commonPropTypes, 131 | threeBasedPropTypes, 132 | { 133 | markerAttrs: PropTypes.object, 134 | yOffset: PropTypes.number, 135 | glScale: PropTypes.number 136 | } 137 | ); 138 | -------------------------------------------------------------------------------- /src/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as ForceGraphVR } from './packages/react-force-graph-vr'; 2 | export { default as ForceGraphAR } from './packages/react-force-graph-ar'; 3 | export { default as ForceGraph3D } from './packages/react-force-graph-3d'; 4 | export { default as ForceGraph2D } from './packages/react-force-graph-2d'; -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | // Load VR first to avoid three.js collisions 2 | export { default as ForceGraphVR } from './packages/react-force-graph-vr/index.js'; 3 | export { default as ForceGraphAR } from './packages/react-force-graph-ar/index.js'; 4 | export { default as ForceGraph3D } from './packages/react-force-graph-3d/index.js'; 5 | export { default as ForceGraph2D } from './packages/react-force-graph-2d/index.js'; -------------------------------------------------------------------------------- /src/packages/react-force-graph-2d/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import ForceGraphKapsule from 'force-graph'; 3 | 4 | export interface GraphData { 5 | nodes: NodeObject[]; 6 | links: LinkObject[]; 7 | } 8 | 9 | export type NodeObject = NodeType & { 10 | id?: string | number; 11 | x?: number; 12 | y?: number; 13 | vx?: number; 14 | vy?: number; 15 | fx?: number; 16 | fy?: number; 17 | [others: string]: any; 18 | }; 19 | 20 | export type LinkObject = LinkType & { 21 | source?: string | number | NodeObject; 22 | target?: string | number | NodeObject; 23 | [others: string]: any; 24 | }; 25 | 26 | type Accessor = Out | string | ((obj: In) => Out); 27 | type NodeAccessor = Accessor, T>; 28 | type LinkAccessor = Accessor, T>; 29 | 30 | type TooltipContent = string | React.ReactHTMLElement; 31 | 32 | type CanvasCustomRenderMode = 'replace' | 'before' | 'after'; 33 | type CanvasCustomRenderFn = (obj: T, canvasContext: CanvasRenderingContext2D, globalScale: number) => void; 34 | type CanvasPointerAreaPaintFn = (obj: T, paintColor: string, canvasContext: CanvasRenderingContext2D, globalScale: number) => void; 35 | 36 | type DagMode = 'td' | 'bu' | 'lr' | 'rl' | 'radialout' | 'radialin'; 37 | 38 | interface ForceFn { 39 | (alpha: number): void; 40 | initialize?: (nodes: NodeObject[], ...args: any[]) => void; 41 | [key: string]: any; 42 | } 43 | 44 | export interface ForceGraphProps< 45 | NodeType = {}, 46 | LinkType = {} 47 | > { 48 | // Data input 49 | graphData?: GraphData, LinkObject>; 50 | nodeId?: string; 51 | linkSource?: string; 52 | linkTarget?: string; 53 | 54 | // Container layout 55 | width?: number; 56 | height?: number; 57 | backgroundColor?: string; 58 | 59 | // Node styling 60 | nodeRelSize?: number; 61 | nodeVal?: NodeAccessor; 62 | nodeLabel?: NodeAccessor; 63 | nodeVisibility?: NodeAccessor; 64 | nodeColor?: NodeAccessor; 65 | nodeAutoColorBy?: NodeAccessor; 66 | nodeCanvasObjectMode?: string | ((obj: NodeObject) => CanvasCustomRenderMode | any); 67 | nodeCanvasObject?: CanvasCustomRenderFn>; 68 | nodePointerAreaPaint?: CanvasPointerAreaPaintFn>; 69 | 70 | // Link styling 71 | linkLabel?: LinkAccessor; 72 | linkVisibility?: LinkAccessor; 73 | linkColor?: LinkAccessor; 74 | linkAutoColorBy?: LinkAccessor; 75 | linkLineDash?: LinkAccessor; 76 | linkWidth?: LinkAccessor; 77 | linkCurvature?: LinkAccessor; 78 | linkCanvasObject?: CanvasCustomRenderFn>; 79 | linkCanvasObjectMode?: string | ((obj: LinkObject) => CanvasCustomRenderMode | any); 80 | linkDirectionalArrowLength?: LinkAccessor; 81 | linkDirectionalArrowColor?: LinkAccessor; 82 | linkDirectionalArrowRelPos?: LinkAccessor; 83 | linkDirectionalParticles?: LinkAccessor; 84 | linkDirectionalParticleSpeed?: LinkAccessor; 85 | linkDirectionalParticleWidth?: LinkAccessor; 86 | linkDirectionalParticleColor?: LinkAccessor; 87 | linkPointerAreaPaint?: CanvasPointerAreaPaintFn>; 88 | 89 | // Render control 90 | autoPauseRedraw?: boolean; 91 | minZoom?: number; 92 | maxZoom?: number; 93 | onRenderFramePre?: (canvasContext: CanvasRenderingContext2D, globalScale: number) => void; 94 | onRenderFramePost?: (canvasContext: CanvasRenderingContext2D, globalScale: number) => void; 95 | 96 | // Force engine (d3-force) configuration 97 | dagMode?: DagMode; 98 | dagLevelDistance?: number | null; 99 | dagNodeFilter?: (node: NodeObject) => boolean; 100 | onDagError?: ((loopNodeIds: (string | number)[]) => void) | undefined; 101 | d3AlphaMin?: number; 102 | d3AlphaDecay?: number; 103 | d3VelocityDecay?: number; 104 | ngraphPhysics?: object; 105 | warmupTicks?: number; 106 | cooldownTicks?: number; 107 | cooldownTime?: number; 108 | onEngineTick?: () => void; 109 | onEngineStop?: () => void; 110 | 111 | // Interaction 112 | onNodeClick?: (node: NodeObject, event: MouseEvent) => void; 113 | onNodeRightClick?: (node: NodeObject, event: MouseEvent) => void; 114 | onNodeHover?: (node: NodeObject | null, previousNode: NodeObject | null) => void; 115 | onNodeDrag?: (node: NodeObject, translate: { x: number, y: number }) => void; 116 | onNodeDragEnd?: (node: NodeObject, translate: { x: number, y: number }) => void; 117 | onLinkClick?: (link: LinkObject, event: MouseEvent) => void; 118 | onLinkRightClick?: (link: LinkObject, event: MouseEvent) => void; 119 | onLinkHover?: (link: LinkObject | null, previousLink: LinkObject | null) => void; 120 | linkHoverPrecision?: number; 121 | onBackgroundClick?: (event: MouseEvent) => void; 122 | onBackgroundRightClick?: (event: MouseEvent) => void; 123 | onZoom?: (transform: {k: number, x: number, y: number}) => void; 124 | onZoomEnd?: (transform: {k: number, x: number, y: number}) => void; 125 | enableNodeDrag?: boolean; 126 | enableZoomInteraction?: boolean | ((event: MouseEvent) => boolean); 127 | enablePanInteraction?: boolean | ((event: MouseEvent) => boolean); 128 | enablePointerInteraction?: boolean; 129 | } 130 | 131 | export interface ForceGraphMethods< 132 | NodeType = {}, 133 | LinkType = {} 134 | > { 135 | // Link styling 136 | emitParticle(link: LinkObject): ForceGraphKapsule; 137 | 138 | // Force engine (d3-force) configuration 139 | d3Force(forceName: 'link' | 'charge' | 'center' | string): ForceFn> | undefined; 140 | d3Force(forceName: 'link' | 'charge' | 'center' | string, forceFn: ForceFn> | null): ForceGraphKapsule; 141 | d3ReheatSimulation(): ForceGraphKapsule; 142 | 143 | // Render control 144 | pauseAnimation(): ForceGraphKapsule; 145 | resumeAnimation(): ForceGraphKapsule; 146 | centerAt(): {x: number, y: number}; 147 | centerAt(x?: number, y?: number, durationMs?: number): ForceGraphKapsule; 148 | zoom(): number; 149 | zoom(scale: number, durationMs?: number): ForceGraphKapsule; 150 | zoomToFit(durationMs?: number, padding?: number, nodeFilter?: (node: NodeObject) => boolean): ForceGraphKapsule; 151 | 152 | // Utility 153 | getGraphBbox(nodeFilter?: (node: NodeObject) => boolean): { x: [number, number], y: [number, number] }; 154 | screen2GraphCoords(x: number, y: number): { x: number, y: number }; 155 | graph2ScreenCoords(x: number, y: number): { x: number, y: number }; 156 | } 157 | 158 | type FCwithRef = (props: ForceGraphProps, LinkObject> & { ref?: React.MutableRefObject, LinkObject> | undefined>; }) => React.ReactElement; 159 | 160 | declare const ForceGraph: FCwithRef; 161 | 162 | export default ForceGraph; 163 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-2d/index.js: -------------------------------------------------------------------------------- 1 | import fromKapsule from 'react-kapsule'; 2 | import ForceGraph2DKapsule from 'force-graph'; 3 | import { ForceGraph2DPropTypes } from '../../forcegraph-proptypes'; 4 | 5 | const ForceGraph2D = fromKapsule( 6 | ForceGraph2DKapsule, 7 | { 8 | methodNames: [ // bind methods 9 | 'emitParticle', 10 | 'd3Force', 11 | 'd3ReheatSimulation', 12 | 'stopAnimation', 13 | 'pauseAnimation', 14 | 'resumeAnimation', 15 | 'centerAt', 16 | 'zoom', 17 | 'zoomToFit', 18 | 'getGraphBbox', 19 | 'screen2GraphCoords', 20 | 'graph2ScreenCoords' 21 | ] 22 | } 23 | ); 24 | 25 | ForceGraph2D.displayName = 'ForceGraph2D'; 26 | ForceGraph2D.propTypes = ForceGraph2DPropTypes; 27 | 28 | export default ForceGraph2D; 29 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-2d/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-force-graph-2d", 3 | "version": "1.27.1", 4 | "description": "React component for 2D force directed graphs", 5 | "license": "MIT", 6 | "type": "module", 7 | "unpkg": "dist/react-force-graph-2d.min.js", 8 | "jsdelivr": "dist/react-force-graph-2d.min.js", 9 | "main": "dist/react-force-graph-2d.mjs", 10 | "module": "dist/react-force-graph-2d.mjs", 11 | "types": "dist/react-force-graph-2d.d.ts", 12 | "exports": { 13 | "types": "./dist/react-force-graph-2d.d.ts", 14 | "umd": "./dist/react-force-graph-2d.min.js", 15 | "default": "./dist/react-force-graph-2d.mjs" 16 | }, 17 | "sideEffects": false, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vasturiano/react-force-graph.git" 21 | }, 22 | "homepage": "https://github.com/vasturiano/react-force-graph", 23 | "keywords": [ 24 | "react", 25 | "force", 26 | "graph", 27 | "2d", 28 | "canvas" 29 | ], 30 | "author": { 31 | "name": "Vasco Asturiano", 32 | "url": "https://github.com/vasturiano" 33 | }, 34 | "bugs": { 35 | "url": "https://github.com/vasturiano/react-force-graph/issues" 36 | }, 37 | "scripts": { 38 | "build": "rimraf dist && rollup -c", 39 | "dev": "rollup -w -c rollup.config.dev.js", 40 | "prepare": "npm run build" 41 | }, 42 | "files": [ 43 | "dist/**/*" 44 | ], 45 | "dependencies": { 46 | "force-graph": "^1.49", 47 | "prop-types": "15", 48 | "react-kapsule": "^2.5" 49 | }, 50 | "peerDependencies": { 51 | "react": "*" 52 | }, 53 | "devDependencies": { 54 | "rimraf": "^6.0.1", 55 | "rollup": "^4.34.6" 56 | }, 57 | "engines": { 58 | "node": ">=12" 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-2d/rollup.config.dev.js: -------------------------------------------------------------------------------- 1 | import buildConfig from './rollup.config.js'; 2 | 3 | // use first output of first config block for dev 4 | const config = Array.isArray(buildConfig) ? buildConfig[0] : buildConfig; 5 | Array.isArray(config.output) && (config.output = config.output[0]); 6 | 7 | export default config; -------------------------------------------------------------------------------- /src/packages/react-force-graph-2d/rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonJs from '@rollup/plugin-commonjs'; 3 | import replace from '@rollup/plugin-replace'; 4 | import babel from '@rollup/plugin-babel'; 5 | import terser from "@rollup/plugin-terser"; 6 | import dts from 'rollup-plugin-dts'; 7 | 8 | import pkg from './package.json' with { type: 'json' }; 9 | const { name, homepage, version, dependencies, peerDependencies } = pkg; 10 | 11 | const umdConf = { 12 | format: 'umd', 13 | name: 'ForceGraph2D', 14 | globals: { react: 'React' }, 15 | banner: `// Version ${version} ${name} - ${homepage}` 16 | }; 17 | 18 | export default [ 19 | { 20 | external: ['react'], 21 | input: 'index.js', 22 | output: [ 23 | { 24 | ...umdConf, 25 | file: `dist/${name}.js`, 26 | sourcemap: true 27 | }, 28 | { // minify 29 | ...umdConf, 30 | file: `dist/${name}.min.js`, 31 | plugins: [terser({ 32 | output: { comments: '/Version/' } 33 | })] 34 | } 35 | ], 36 | plugins: [ 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), // To fool React in the browser 38 | resolve(), 39 | commonJs(), 40 | babel({ exclude: 'node_modules/**' }) 41 | ] 42 | }, 43 | { // ES module 44 | input: 'index.js', 45 | output: [ 46 | { 47 | format: 'es', 48 | file: `dist/${name}.mjs` 49 | } 50 | ], 51 | external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)], 52 | plugins: [ 53 | babel() 54 | ] 55 | }, 56 | { // expose TS declarations 57 | input: 'index.d.ts', 58 | output: [{ 59 | file: `dist/${name}.d.ts`, 60 | format: 'es' 61 | }], 62 | plugins: [dts()] 63 | } 64 | ]; -------------------------------------------------------------------------------- /src/packages/react-force-graph-3d/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Light, Scene, Camera, WebGLRenderer, Object3D, Material } from 'three'; 3 | import { EffectComposer } from 'three/examples/jsm/postprocessing/EffectComposer.js'; 4 | import { ConfigOptions, ForceGraph3DInstance as ForceGraphKapsuleInstance } from '3d-force-graph'; 5 | 6 | export interface GraphData { 7 | nodes: NodeObject[]; 8 | links: LinkObject[]; 9 | } 10 | 11 | export type NodeObject = NodeType & { 12 | id?: string | number; 13 | x?: number; 14 | y?: number; 15 | z?: number; 16 | vx?: number; 17 | vy?: number; 18 | vz?: number; 19 | fx?: number; 20 | fy?: number; 21 | fz?: number; 22 | [others: string]: any; 23 | }; 24 | 25 | export type LinkObject = LinkType & { 26 | source?: string | number | NodeObject; 27 | target?: string | number | NodeObject; 28 | [others: string]: any; 29 | }; 30 | 31 | type Accessor = Out | string | ((obj: In) => Out); 32 | type NodeAccessor = Accessor, T>; 33 | type LinkAccessor = Accessor, T>; 34 | 35 | type TooltipContent = string | React.ReactHTMLElement; 36 | 37 | type DagMode = 'td' | 'bu' | 'lr' | 'rl' | 'zout' | 'zin' | 'radialout' | 'radialin'; 38 | 39 | type ForceEngine = 'd3' | 'ngraph'; 40 | 41 | interface ForceFn { 42 | (alpha: number): void; 43 | initialize?: (nodes: NodeObject[], ...args: any[]) => void; 44 | [key: string]: any; 45 | } 46 | 47 | type Coords = { x: number; y: number; z: number; } 48 | 49 | type LinkPositionUpdateFn = (obj: Object3D, coords: { start: Coords, end: Coords }, link: LinkObject) => void | null | boolean; 50 | 51 | export interface ForceGraphProps< 52 | NodeType = {}, 53 | LinkType = {} 54 | > extends ConfigOptions { 55 | // Data input 56 | graphData?: GraphData, LinkObject>; 57 | nodeId?: string; 58 | linkSource?: string; 59 | linkTarget?: string; 60 | 61 | // Container layout 62 | width?: number; 63 | height?: number; 64 | backgroundColor?: string; 65 | showNavInfo?: boolean; 66 | 67 | // Node styling 68 | nodeRelSize?: number; 69 | nodeVal?: NodeAccessor; 70 | nodeLabel?: NodeAccessor; 71 | nodeVisibility?: NodeAccessor; 72 | nodeColor?: NodeAccessor; 73 | nodeAutoColorBy?: NodeAccessor; 74 | nodeOpacity?: number; 75 | nodeResolution?: number; 76 | nodeThreeObject?: NodeAccessor; 77 | nodeThreeObjectExtend?: NodeAccessor; 78 | 79 | // Link styling 80 | linkLabel?: LinkAccessor; 81 | linkVisibility?: LinkAccessor; 82 | linkColor?: LinkAccessor; 83 | linkAutoColorBy?: LinkAccessor; 84 | linkWidth?: LinkAccessor; 85 | linkOpacity?: number; 86 | linkResolution?: number; 87 | linkCurvature?: LinkAccessor; 88 | linkCurveRotation?: LinkAccessor; 89 | linkMaterial?: LinkAccessor; 90 | linkThreeObject?: LinkAccessor; 91 | linkThreeObjectExtend?: LinkAccessor; 92 | linkPositionUpdate?: LinkPositionUpdateFn | null; 93 | linkDirectionalArrowLength?: LinkAccessor; 94 | linkDirectionalArrowColor?: LinkAccessor; 95 | linkDirectionalArrowRelPos?: LinkAccessor; 96 | linkDirectionalArrowResolution?: number; 97 | linkDirectionalParticles?: LinkAccessor; 98 | linkDirectionalParticleSpeed?: LinkAccessor; 99 | linkDirectionalParticleWidth?: LinkAccessor; 100 | linkDirectionalParticleColor?: LinkAccessor; 101 | linkDirectionalParticleResolution?: number; 102 | 103 | // Force engine (d3-force) configuration 104 | forceEngine?: ForceEngine; 105 | numDimensions?: 1 | 2 | 3; 106 | dagMode?: DagMode; 107 | dagLevelDistance?: number | null; 108 | dagNodeFilter?: (node: NodeObject) => boolean; 109 | onDagError?: ((loopNodeIds: (string | number)[]) => void) | undefined; 110 | d3AlphaMin?: number; 111 | d3AlphaDecay?: number; 112 | d3VelocityDecay?: number; 113 | ngraphPhysics?: object; 114 | warmupTicks?: number; 115 | cooldownTicks?: number; 116 | cooldownTime?: number; 117 | onEngineTick?: () => void; 118 | onEngineStop?: () => void; 119 | 120 | // Interaction 121 | onNodeClick?: (node: NodeObject, event: MouseEvent) => void; 122 | onNodeRightClick?: (node: NodeObject, event: MouseEvent) => void; 123 | onNodeHover?: (node: NodeObject | null, previousNode: NodeObject | null) => void; 124 | onNodeDrag?: (node: NodeObject, translate: { x: number, y: number }) => void; 125 | onNodeDragEnd?: (node: NodeObject, translate: { x: number, y: number }) => void; 126 | onLinkClick?: (link: LinkObject, event: MouseEvent) => void; 127 | onLinkRightClick?: (link: LinkObject, event: MouseEvent) => void; 128 | onLinkHover?: (link: LinkObject | null, previousLink: LinkObject | null) => void; 129 | linkHoverPrecision?: number; 130 | onBackgroundClick?: (event: MouseEvent) => void; 131 | onBackgroundRightClick?: (event: MouseEvent) => void; 132 | enableNodeDrag?: boolean; 133 | enableNavigationControls?: boolean; 134 | enablePointerInteraction?: boolean; 135 | } 136 | 137 | export interface ForceGraphMethods< 138 | NodeType = {}, 139 | LinkType = {} 140 | > { 141 | // Link styling 142 | emitParticle(link: LinkObject): ForceGraphKapsuleInstance; 143 | 144 | // Force engine (d3-force) configuration 145 | d3Force(forceName: 'link' | 'charge' | 'center' | string): ForceFn> | undefined; 146 | d3Force(forceName: 'link' | 'charge' | 'center' | string, forceFn: ForceFn> | null): ForceGraphKapsuleInstance; 147 | d3ReheatSimulation(): ForceGraphKapsuleInstance; 148 | 149 | // Render control 150 | pauseAnimation(): ForceGraphKapsuleInstance; 151 | resumeAnimation(): ForceGraphKapsuleInstance; 152 | cameraPosition(position: Partial, lookAt?: Coords, transitionMs?: number): ForceGraphKapsuleInstance; 153 | zoomToFit(durationMs?: number, padding?: number, nodeFilter?: (node: NodeObject) => boolean): ForceGraphKapsuleInstance; 154 | postProcessingComposer(): EffectComposer; 155 | lights(): Light[]; 156 | lights(lights: Light[]): ForceGraphKapsuleInstance; 157 | scene(): Scene; 158 | camera(): Camera; 159 | renderer(): WebGLRenderer; 160 | controls(): object; 161 | refresh(): ForceGraphKapsuleInstance; 162 | 163 | // Utility 164 | getGraphBbox(nodeFilter?: (node: NodeObject) => boolean): { x: [number, number], y: [number, number], z: [number, number] }; 165 | screen2GraphCoords(x: number, y: number, distance: number): Coords; 166 | graph2ScreenCoords(x: number, y: number, z: number): Coords; 167 | } 168 | 169 | type FCwithRef = (props: ForceGraphProps, LinkObject> & { ref?: React.MutableRefObject, LinkObject> | undefined>; }) => React.ReactElement; 170 | 171 | declare const ForceGraph: FCwithRef; 172 | 173 | export default ForceGraph; 174 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-3d/index.js: -------------------------------------------------------------------------------- 1 | import fromKapsule from 'react-kapsule'; 2 | import ForceGraph3DKapsule from '3d-force-graph'; 3 | import { ForceGraph3DPropTypes } from '../../forcegraph-proptypes'; 4 | 5 | const ForceGraph3D = fromKapsule( 6 | ForceGraph3DKapsule, 7 | { 8 | methodNames: [ // bind methods 9 | 'emitParticle', 10 | 'd3Force', 11 | 'd3ReheatSimulation', 12 | 'stopAnimation', 13 | 'pauseAnimation', 14 | 'resumeAnimation', 15 | 'cameraPosition', 16 | 'zoomToFit', 17 | 'getGraphBbox', 18 | 'screen2GraphCoords', 19 | 'graph2ScreenCoords', 20 | 'postProcessingComposer', 21 | 'lights', 22 | 'scene', 23 | 'camera', 24 | 'renderer', 25 | 'controls', 26 | 'refresh' 27 | ], 28 | initPropNames: ['controlType', 'rendererConfig', 'extraRenderers'] 29 | } 30 | ); 31 | 32 | ForceGraph3D.displayName = 'ForceGraph3D'; 33 | ForceGraph3D.propTypes = ForceGraph3DPropTypes; 34 | 35 | export default ForceGraph3D; 36 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-3d/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-force-graph-3d", 3 | "version": "1.26.1", 4 | "description": "React component for 3D force directed graphs", 5 | "license": "MIT", 6 | "type": "module", 7 | "unpkg": "dist/react-force-graph-3d.min.js", 8 | "jsdelivr": "dist/react-force-graph-3d.min.js", 9 | "main": "dist/react-force-graph-3d.mjs", 10 | "module": "dist/react-force-graph-3d.mjs", 11 | "types": "dist/react-force-graph-3d.d.ts", 12 | "exports": { 13 | "types": "./dist/react-force-graph-3d.d.ts", 14 | "umd": "./dist/react-force-graph-3d.min.js", 15 | "default": "./dist/react-force-graph-3d.mjs" 16 | }, 17 | "sideEffects": false, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vasturiano/react-force-graph.git" 21 | }, 22 | "homepage": "https://github.com/vasturiano/react-force-graph", 23 | "keywords": [ 24 | "react", 25 | "force", 26 | "graph", 27 | "3d", 28 | "three", 29 | "webgl" 30 | ], 31 | "author": { 32 | "name": "Vasco Asturiano", 33 | "url": "https://github.com/vasturiano" 34 | }, 35 | "bugs": { 36 | "url": "https://github.com/vasturiano/react-force-graph/issues" 37 | }, 38 | "scripts": { 39 | "build": "rimraf dist && rollup -c", 40 | "dev": "rollup -w -c rollup.config.dev.js", 41 | "prepare": "npm run build" 42 | }, 43 | "files": [ 44 | "dist/**/*" 45 | ], 46 | "dependencies": { 47 | "3d-force-graph": "^1.76", 48 | "prop-types": "15", 49 | "react-kapsule": "^2.5" 50 | }, 51 | "peerDependencies": { 52 | "react": "*" 53 | }, 54 | "devDependencies": { 55 | "rimraf": "^6.0.1", 56 | "rollup": "^4.34.6" 57 | }, 58 | "engines": { 59 | "node": ">=12" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-3d/rollup.config.dev.js: -------------------------------------------------------------------------------- 1 | import buildConfig from './rollup.config.js'; 2 | 3 | // use first output of first config block for dev 4 | const config = Array.isArray(buildConfig) ? buildConfig[0] : buildConfig; 5 | Array.isArray(config.output) && (config.output = config.output[0]); 6 | 7 | export default config; -------------------------------------------------------------------------------- /src/packages/react-force-graph-3d/rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonJs from '@rollup/plugin-commonjs'; 3 | import replace from '@rollup/plugin-replace'; 4 | import babel from '@rollup/plugin-babel'; 5 | import terser from "@rollup/plugin-terser"; 6 | import dts from 'rollup-plugin-dts'; 7 | 8 | import pkg from './package.json' with { type: 'json' }; 9 | const { name, homepage, version, dependencies, peerDependencies } = pkg; 10 | 11 | const umdConf = { 12 | format: 'umd', 13 | name: 'ForceGraph3D', 14 | globals: { react: 'React' }, 15 | banner: `// Version ${version} ${name} - ${homepage}` 16 | }; 17 | 18 | export default [ 19 | { 20 | external: ['react'], 21 | input: 'index.js', 22 | output: [ 23 | { 24 | ...umdConf, 25 | file: `dist/${name}.js`, 26 | sourcemap: true 27 | }, 28 | { // minify 29 | ...umdConf, 30 | file: `dist/${name}.min.js`, 31 | plugins: [terser({ 32 | output: { comments: '/Version/' } 33 | })] 34 | } 35 | ], 36 | plugins: [ 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), // To fool React in the browser 38 | resolve(), 39 | commonJs(), 40 | babel({ exclude: 'node_modules/**' }) 41 | ] 42 | }, 43 | { // ES module 44 | input: 'index.js', 45 | output: [ 46 | { 47 | format: 'es', 48 | file: `dist/${name}.mjs` 49 | } 50 | ], 51 | external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)], 52 | plugins: [ 53 | babel() 54 | ] 55 | }, 56 | { // expose TS declarations 57 | input: 'index.d.ts', 58 | output: [{ 59 | file: `dist/${name}.d.ts`, 60 | format: 'es' 61 | }], 62 | plugins: [dts()] 63 | } 64 | ]; -------------------------------------------------------------------------------- /src/packages/react-force-graph-ar/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Object3D, Material } from 'three'; 3 | import { ConfigOptions, ForceGraphARInstance as ForceGraphKapsuleInstance } from '3d-force-graph-ar'; 4 | 5 | export interface GraphData { 6 | nodes: NodeObject[]; 7 | links: LinkObject[]; 8 | } 9 | 10 | export type NodeObject = NodeType & { 11 | id?: string | number; 12 | x?: number; 13 | y?: number; 14 | z?: number; 15 | vx?: number; 16 | vy?: number; 17 | vz?: number; 18 | fx?: number; 19 | fy?: number; 20 | fz?: number; 21 | [others: string]: any; 22 | }; 23 | 24 | export type LinkObject = LinkType & { 25 | source?: string | number | NodeObject; 26 | target?: string | number | NodeObject; 27 | [others: string]: any; 28 | }; 29 | 30 | type Accessor = Out | string | ((obj: In) => Out); 31 | type NodeAccessor = Accessor, T>; 32 | type LinkAccessor = Accessor, T>; 33 | 34 | type DagMode = 'td' | 'bu' | 'lr' | 'rl' | 'zout' | 'zin' | 'radialout' | 'radialin'; 35 | 36 | type ForceEngine = 'd3' | 'ngraph'; 37 | 38 | interface ForceFn { 39 | (alpha: number): void; 40 | initialize?: (nodes: NodeObject[], ...args: any[]) => void; 41 | [key: string]: any; 42 | } 43 | 44 | type Coords = { x: number; y: number; z: number; } 45 | 46 | type LinkPositionUpdateFn = (obj: Object3D, coords: { start: Coords, end: Coords }, link: LinkObject) => void | null | boolean; 47 | 48 | export interface ForceGraphProps< 49 | NodeType = {}, 50 | LinkType = {} 51 | > extends ConfigOptions { 52 | // Data input 53 | graphData?: GraphData, LinkObject>; 54 | nodeId?: string; 55 | linkSource?: string; 56 | linkTarget?: string; 57 | 58 | // Container layout 59 | width?: number; 60 | height?: number; 61 | backgroundColor?: string; 62 | showNavInfo?: boolean; 63 | 64 | // Node styling 65 | nodeRelSize?: number; 66 | nodeVal?: NodeAccessor; 67 | nodeVisibility?: NodeAccessor; 68 | nodeColor?: NodeAccessor; 69 | nodeAutoColorBy?: NodeAccessor; 70 | nodeOpacity?: number; 71 | nodeResolution?: number; 72 | nodeThreeObject?: NodeAccessor; 73 | nodeThreeObjectExtend?: NodeAccessor; 74 | 75 | // Link styling 76 | linkVisibility?: LinkAccessor; 77 | linkColor?: LinkAccessor; 78 | linkAutoColorBy?: LinkAccessor; 79 | linkWidth?: LinkAccessor; 80 | linkOpacity?: number; 81 | linkResolution?: number; 82 | linkCurvature?: LinkAccessor; 83 | linkCurveRotation?: LinkAccessor; 84 | linkMaterial?: LinkAccessor; 85 | linkThreeObject?: LinkAccessor; 86 | linkThreeObjectExtend?: LinkAccessor; 87 | linkPositionUpdate?: LinkPositionUpdateFn | null; 88 | linkDirectionalArrowLength?: LinkAccessor; 89 | linkDirectionalArrowColor?: LinkAccessor; 90 | linkDirectionalArrowRelPos?: LinkAccessor; 91 | linkDirectionalArrowResolution?: number; 92 | linkDirectionalParticles?: LinkAccessor; 93 | linkDirectionalParticleSpeed?: LinkAccessor; 94 | linkDirectionalParticleWidth?: LinkAccessor; 95 | linkDirectionalParticleColor?: LinkAccessor; 96 | linkDirectionalParticleResolution?: number; 97 | 98 | // Force engine (d3-force) configuration 99 | forceEngine?: ForceEngine; 100 | numDimensions?: 1 | 2 | 3; 101 | dagMode?: DagMode; 102 | dagLevelDistance?: number | null; 103 | dagNodeFilter?: (node: NodeObject) => boolean; 104 | onDagError?: ((loopNodeIds: (string | number)[]) => void) | undefined; 105 | d3AlphaMin?: number; 106 | d3AlphaDecay?: number; 107 | d3VelocityDecay?: number; 108 | ngraphPhysics?: object; 109 | warmupTicks?: number; 110 | cooldownTicks?: number; 111 | cooldownTime?: number; 112 | onEngineTick?: () => void; 113 | onEngineStop?: () => void; 114 | 115 | // Interaction 116 | onNodeHover?: (node: NodeObject | null, previousNode: NodeObject | null) => void; 117 | onNodeClick?: (link: LinkObject) => void; 118 | onLinkHover?: (link: LinkObject | null, previousLink: LinkObject | null) => void; 119 | onLinkClick?: (link: LinkObject) => void; 120 | } 121 | 122 | export interface ForceGraphMethods< 123 | NodeType = {}, 124 | LinkType = {} 125 | > { 126 | // Link styling 127 | emitParticle(link: LinkObject): ForceGraphKapsuleInstance; 128 | 129 | // Force engine (d3-force) configuration 130 | d3Force(forceName: 'link' | 'charge' | 'center' | string): ForceFn> | undefined; 131 | d3Force(forceName: 'link' | 'charge' | 'center' | string, forceFn: ForceFn> | null): ForceGraphKapsuleInstance; 132 | d3ReheatSimulation(): ForceGraphKapsuleInstance; 133 | 134 | // Render control 135 | refresh(): ForceGraphKapsuleInstance; 136 | 137 | // Utility 138 | getGraphBbox(nodeFilter?: (node: NodeObject) => boolean): { x: [number, number], y: [number, number], z: [number, number] }; 139 | } 140 | 141 | type FCwithRef = (props: ForceGraphProps, LinkObject> & { ref?: React.MutableRefObject, LinkObject> | undefined>; }) => React.ReactElement; 142 | 143 | declare const ForceGraph: FCwithRef; 144 | 145 | export default ForceGraph; 146 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-ar/index.js: -------------------------------------------------------------------------------- 1 | import fromKapsule from 'react-kapsule'; 2 | import ForceGraphARKapsule from '3d-force-graph-ar'; 3 | import { ForceGraphARPropTypes } from '../../forcegraph-proptypes'; 4 | 5 | const ForceGraphAR = fromKapsule( 6 | ForceGraphARKapsule, 7 | { 8 | methodNames: [ // bind methods 9 | 'getGraphBbox', 10 | 'emitParticle', 11 | 'd3Force', 12 | 'd3ReheatSimulation', 13 | 'refresh' 14 | ], 15 | initPropNames: ['markerAttrs'] 16 | } 17 | ); 18 | 19 | ForceGraphAR.displayName = 'ForceGraphAR'; 20 | ForceGraphAR.propTypes = ForceGraphARPropTypes; 21 | 22 | export default ForceGraphAR; 23 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-ar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-force-graph-ar", 3 | "version": "1.8.3", 4 | "description": "React component for AR force directed graphs", 5 | "license": "MIT", 6 | "type": "module", 7 | "unpkg": "dist/react-force-graph-ar.min.js", 8 | "jsdelivr": "dist/react-force-graph-ar.min.js", 9 | "main": "dist/react-force-graph-ar.mjs", 10 | "module": "dist/react-force-graph-ar.mjs", 11 | "types": "dist/react-force-graph-ar.d.ts", 12 | "exports": { 13 | "types": "./dist/react-force-graph-ar.d.ts", 14 | "umd": "./dist/react-force-graph-ar.min.js", 15 | "default": "./dist/react-force-graph-ar.mjs" 16 | }, 17 | "sideEffects": false, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vasturiano/react-force-graph.git" 21 | }, 22 | "homepage": "https://github.com/vasturiano/react-force-graph", 23 | "keywords": [ 24 | "react", 25 | "force", 26 | "graph", 27 | "ar", 28 | "a-frame", 29 | "ar.js", 30 | "webgl" 31 | ], 32 | "author": { 33 | "name": "Vasco Asturiano", 34 | "url": "https://github.com/vasturiano" 35 | }, 36 | "bugs": { 37 | "url": "https://github.com/vasturiano/react-force-graph/issues" 38 | }, 39 | "scripts": { 40 | "build": "rimraf dist && rollup -c", 41 | "dev": "rollup -w -c rollup.config.dev.js", 42 | "prepare": "npm run build" 43 | }, 44 | "files": [ 45 | "dist/**/*" 46 | ], 47 | "dependencies": { 48 | "3d-force-graph-ar": "^1.9", 49 | "prop-types": "15", 50 | "react-kapsule": "^2.5" 51 | }, 52 | "peerDependencies": { 53 | "react": "*" 54 | }, 55 | "devDependencies": { 56 | "rimraf": "^6.0.1", 57 | "rollup": "^4.34.6" 58 | }, 59 | "engines": { 60 | "node": ">=12" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-ar/rollup.config.dev.js: -------------------------------------------------------------------------------- 1 | import buildConfig from './rollup.config.js'; 2 | 3 | // use first output of first config block for dev 4 | const config = Array.isArray(buildConfig) ? buildConfig[0] : buildConfig; 5 | Array.isArray(config.output) && (config.output = config.output[0]); 6 | 7 | export default config; -------------------------------------------------------------------------------- /src/packages/react-force-graph-ar/rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonJs from '@rollup/plugin-commonjs'; 3 | import replace from '@rollup/plugin-replace'; 4 | import babel from '@rollup/plugin-babel'; 5 | import terser from "@rollup/plugin-terser"; 6 | import dts from 'rollup-plugin-dts'; 7 | 8 | import pkg from './package.json' with { type: 'json' }; 9 | const { name, homepage, version, dependencies, peerDependencies } = pkg; 10 | 11 | const umdConf = { 12 | format: 'umd', 13 | name: 'ForceGraphAR', 14 | globals: { react: 'React' }, 15 | banner: `// Version ${version} ${name} - ${homepage}` 16 | }; 17 | 18 | export default [ 19 | { 20 | external: ['react'], 21 | input: 'index.js', 22 | output: [ 23 | { 24 | ...umdConf, 25 | file: `dist/${name}.js`, 26 | sourcemap: true 27 | }, 28 | { // minify 29 | ...umdConf, 30 | file: `dist/${name}.min.js`, 31 | plugins: [terser({ 32 | output: { comments: '/Version/' } 33 | })] 34 | } 35 | ], 36 | plugins: [ 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), // To fool React in the browser 38 | resolve(), 39 | commonJs(), 40 | babel({ exclude: 'node_modules/**' }) 41 | ] 42 | }, 43 | { // ES module 44 | input: 'index.js', 45 | output: [ 46 | { 47 | format: 'es', 48 | file: `dist/${name}.mjs` 49 | } 50 | ], 51 | external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)], 52 | plugins: [ 53 | babel() 54 | ] 55 | }, 56 | { // expose TS declarations 57 | input: 'index.d.ts', 58 | output: [{ 59 | file: `dist/${name}.d.ts`, 60 | format: 'es' 61 | }], 62 | plugins: [dts()] 63 | } 64 | ]; -------------------------------------------------------------------------------- /src/packages/react-force-graph-vr/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from 'react'; 2 | import { Object3D, Material } from 'three'; 3 | import { ConfigOptions, ForceGraphVRInstance as ForceGraphKapsuleInstance } from '3d-force-graph-vr'; 4 | 5 | export interface GraphData { 6 | nodes: NodeObject[]; 7 | links: LinkObject[]; 8 | } 9 | 10 | export type NodeObject = NodeType & { 11 | id?: string | number; 12 | x?: number; 13 | y?: number; 14 | z?: number; 15 | vx?: number; 16 | vy?: number; 17 | vz?: number; 18 | fx?: number; 19 | fy?: number; 20 | fz?: number; 21 | [others: string]: any; 22 | }; 23 | 24 | export type LinkObject = LinkType & { 25 | source?: string | number | NodeObject; 26 | target?: string | number | NodeObject; 27 | [others: string]: any; 28 | }; 29 | 30 | type Accessor = Out | string | ((obj: In) => Out); 31 | type NodeAccessor = Accessor, T>; 32 | type LinkAccessor = Accessor, T>; 33 | 34 | type DagMode = 'td' | 'bu' | 'lr' | 'rl' | 'zout' | 'zin' | 'radialout' | 'radialin'; 35 | 36 | type ForceEngine = 'd3' | 'ngraph'; 37 | 38 | interface ForceFn { 39 | (alpha: number): void; 40 | initialize?: (nodes: NodeObject[], ...args: any[]) => void; 41 | [key: string]: any; 42 | } 43 | 44 | type Coords = { x: number; y: number; z: number; } 45 | 46 | type LinkPositionUpdateFn = (obj: Object3D, coords: { start: Coords, end: Coords }, link: LinkObject) => void | null | boolean; 47 | 48 | export interface ForceGraphProps< 49 | NodeType = {}, 50 | LinkType = {} 51 | > extends ConfigOptions { 52 | // Data input 53 | graphData?: GraphData, LinkObject>; 54 | nodeId?: string; 55 | linkSource?: string; 56 | linkTarget?: string; 57 | 58 | // Container layout 59 | width?: number; 60 | height?: number; 61 | yOffset?: number; 62 | glScale?: number; 63 | 64 | // Node styling 65 | nodeLabel?: NodeAccessor; 66 | nodeDesc?: NodeAccessor; 67 | nodeRelSize?: number; 68 | nodeVal?: NodeAccessor; 69 | nodeVisibility?: NodeAccessor; 70 | nodeColor?: NodeAccessor; 71 | nodeAutoColorBy?: NodeAccessor; 72 | nodeOpacity?: number; 73 | nodeResolution?: number; 74 | nodeThreeObject?: NodeAccessor; 75 | nodeThreeObjectExtend?: NodeAccessor; 76 | 77 | // Link styling 78 | linkLabel?: LinkAccessor; 79 | linkDesc?: LinkAccessor; 80 | linkVisibility?: LinkAccessor; 81 | linkColor?: LinkAccessor; 82 | linkAutoColorBy?: LinkAccessor; 83 | linkWidth?: LinkAccessor; 84 | linkOpacity?: number; 85 | linkResolution?: number; 86 | linkCurvature?: LinkAccessor; 87 | linkCurveRotation?: LinkAccessor; 88 | linkMaterial?: LinkAccessor; 89 | linkThreeObject?: LinkAccessor; 90 | linkThreeObjectExtend?: LinkAccessor; 91 | linkPositionUpdate?: LinkPositionUpdateFn | null; 92 | linkDirectionalArrowLength?: LinkAccessor; 93 | linkDirectionalArrowColor?: LinkAccessor; 94 | linkDirectionalArrowRelPos?: LinkAccessor; 95 | linkDirectionalArrowResolution?: number; 96 | linkDirectionalParticles?: LinkAccessor; 97 | linkDirectionalParticleSpeed?: LinkAccessor; 98 | linkDirectionalParticleWidth?: LinkAccessor; 99 | linkDirectionalParticleColor?: LinkAccessor; 100 | linkDirectionalParticleResolution?: number; 101 | 102 | // Force engine (d3-force) configuration 103 | forceEngine?: ForceEngine; 104 | numDimensions?: 1 | 2 | 3; 105 | dagMode?: DagMode; 106 | dagLevelDistance?: number | null; 107 | dagNodeFilter?: (node: NodeObject) => boolean; 108 | onDagError?: ((loopNodeIds: (string | number)[]) => void) | undefined; 109 | d3AlphaMin?: number; 110 | d3AlphaDecay?: number; 111 | d3VelocityDecay?: number; 112 | ngraphPhysics?: object; 113 | warmupTicks?: number; 114 | cooldownTicks?: number; 115 | cooldownTime?: number; 116 | onEngineTick?: () => void; 117 | onEngineStop?: () => void; 118 | 119 | // Interaction 120 | onNodeHover?: (node: NodeObject | null, previousNode: NodeObject | null) => void; 121 | onNodeClick?: (link: LinkObject) => void; 122 | onLinkHover?: (link: LinkObject | null, previousLink: LinkObject | null) => void; 123 | onLinkClick?: (link: LinkObject) => void; 124 | } 125 | 126 | export interface ForceGraphMethods< 127 | NodeType = {}, 128 | LinkType = {} 129 | > { 130 | // Link styling 131 | emitParticle(link: LinkObject): ForceGraphKapsuleInstance; 132 | 133 | // Force engine (d3-force) configuration 134 | d3Force(forceName: 'link' | 'charge' | 'center' | string): ForceFn> | undefined; 135 | d3Force(forceName: 'link' | 'charge' | 'center' | string, forceFn: ForceFn> | null): ForceGraphKapsuleInstance; 136 | d3ReheatSimulation(): ForceGraphKapsuleInstance; 137 | 138 | // Render control 139 | refresh(): ForceGraphKapsuleInstance; 140 | 141 | // Utility 142 | getGraphBbox(nodeFilter?: (node: NodeObject) => boolean): { x: [number, number], y: [number, number], z: [number, number] }; 143 | } 144 | 145 | type FCwithRef = (props: ForceGraphProps, LinkObject> & { ref?: React.MutableRefObject, LinkObject> | undefined>; }) => React.ReactElement; 146 | 147 | declare const ForceGraph: FCwithRef; 148 | 149 | export default ForceGraph; 150 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-vr/index.js: -------------------------------------------------------------------------------- 1 | import fromKapsule from 'react-kapsule'; 2 | import ForceGraphVRKapsule from '3d-force-graph-vr'; 3 | import { ForceGraphVRPropTypes } from '../../forcegraph-proptypes'; 4 | 5 | const ForceGraphVR = fromKapsule( 6 | ForceGraphVRKapsule, 7 | { 8 | methodNames: [ // bind methods 9 | 'getGraphBbox', 10 | 'emitParticle', 11 | 'd3Force', 12 | 'd3ReheatSimulation', 13 | 'refresh' 14 | ] 15 | } 16 | ); 17 | 18 | ForceGraphVR.displayName = 'ForceGraphVR'; 19 | ForceGraphVR.propTypes = ForceGraphVRPropTypes; 20 | 21 | export default ForceGraphVR; 22 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-vr/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-force-graph-vr", 3 | "version": "2.0.2", 4 | "description": "React component for VR force directed graphs", 5 | "license": "MIT", 6 | "type": "module", 7 | "unpkg": "dist/react-force-graph-vr.min.js", 8 | "jsdelivr": "dist/react-force-graph-vr.min.js", 9 | "main": "dist/react-force-graph-vr.mjs", 10 | "module": "dist/react-force-graph-vr.mjs", 11 | "types": "dist/react-force-graph-vr.d.ts", 12 | "exports": { 13 | "types": "./dist/react-force-graph-vr.d.ts", 14 | "umd": "./dist/react-force-graph-vr.min.js", 15 | "default": "./dist/react-force-graph-vr.mjs" 16 | }, 17 | "sideEffects": false, 18 | "repository": { 19 | "type": "git", 20 | "url": "git+https://github.com/vasturiano/react-force-graph.git" 21 | }, 22 | "homepage": "https://github.com/vasturiano/react-force-graph", 23 | "keywords": [ 24 | "react", 25 | "force", 26 | "graph", 27 | "vr", 28 | "a-frame", 29 | "webgl" 30 | ], 31 | "author": { 32 | "name": "Vasco Asturiano", 33 | "url": "https://github.com/vasturiano" 34 | }, 35 | "bugs": { 36 | "url": "https://github.com/vasturiano/react-force-graph/issues" 37 | }, 38 | "scripts": { 39 | "build": "rimraf dist && rollup -c", 40 | "dev": "rollup -w -c rollup.config.dev.js", 41 | "prepare": "npm run build" 42 | }, 43 | "files": [ 44 | "dist/**/*" 45 | ], 46 | "dependencies": { 47 | "3d-force-graph-vr": "^3.0", 48 | "prop-types": "15", 49 | "react-kapsule": "^2.5" 50 | }, 51 | "peerDependencies": { 52 | "aframe": "^1.5", 53 | "react": "*" 54 | }, 55 | "devDependencies": { 56 | "rimraf": "^6.0.1", 57 | "rollup": "^4.34.6" 58 | }, 59 | "engines": { 60 | "node": ">=12" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/packages/react-force-graph-vr/rollup.config.dev.js: -------------------------------------------------------------------------------- 1 | import buildConfig from './rollup.config.js'; 2 | 3 | // use first output of first config block for dev 4 | const config = Array.isArray(buildConfig) ? buildConfig[0] : buildConfig; 5 | Array.isArray(config.output) && (config.output = config.output[0]); 6 | 7 | export default config; -------------------------------------------------------------------------------- /src/packages/react-force-graph-vr/rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonJs from '@rollup/plugin-commonjs'; 3 | import replace from '@rollup/plugin-replace'; 4 | import babel from '@rollup/plugin-babel'; 5 | import terser from "@rollup/plugin-terser"; 6 | import dts from 'rollup-plugin-dts'; 7 | 8 | import pkg from './package.json' with { type: 'json' }; 9 | const { name, homepage, version, dependencies, peerDependencies } = pkg; 10 | 11 | const umdConf = { 12 | format: 'umd', 13 | name: 'ForceGraphVR', 14 | globals: { react: 'React' }, 15 | banner: `// Version ${version} ${name} - ${homepage}` 16 | }; 17 | 18 | export default [ 19 | { 20 | external: ['react'], 21 | input: 'index.js', 22 | output: [ 23 | { 24 | ...umdConf, 25 | file: `dist/${name}.js`, 26 | sourcemap: true 27 | }, 28 | { // minify 29 | ...umdConf, 30 | file: `dist/${name}.min.js`, 31 | plugins: [terser({ 32 | output: { comments: '/Version/' } 33 | })] 34 | } 35 | ], 36 | plugins: [ 37 | replace({ 'process.env.NODE_ENV': JSON.stringify('development') }), // To fool React in the browser 38 | resolve(), 39 | commonJs(), 40 | babel({ exclude: 'node_modules/**' }) 41 | ] 42 | }, 43 | { // ES module 44 | input: 'index.js', 45 | output: [ 46 | { 47 | format: 'es', 48 | file: `dist/${name}.mjs` 49 | } 50 | ], 51 | external: [...Object.keys(dependencies), ...Object.keys(peerDependencies)], 52 | plugins: [ 53 | babel() 54 | ] 55 | }, 56 | { // expose TS declarations 57 | input: 'index.d.ts', 58 | output: [{ 59 | file: `dist/${name}.d.ts`, 60 | format: 'es' 61 | }], 62 | plugins: [dts()] 63 | } 64 | ]; --------------------------------------------------------------------------------