{"id":13588913,"url":"https://github.com/emiliorizzo/vue-d3-network","last_synced_at":"2025-05-16T12:07:56.324Z","repository":{"id":22881992,"uuid":"97432383","full_name":"emiliorizzo/vue-d3-network","owner":"emiliorizzo","description":"Vue component to graph networks using d3-force","archived":false,"fork":false,"pushed_at":"2022-12-09T04:50:19.000Z","size":4874,"stargazers_count":509,"open_issues_count":42,"forks_count":142,"subscribers_count":17,"default_branch":"master","last_synced_at":"2024-04-15T08:04:54.683Z","etag":null,"topics":["chart","component","d3","d3-force","d3v4","graph","network","vue"],"latest_commit_sha":null,"homepage":"https://emiliorizzo.github.io/vue-d3-network/","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emiliorizzo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-17T03:39:54.000Z","updated_at":"2024-04-11T07:39:45.000Z","dependencies_parsed_at":"2023-01-13T22:22:47.983Z","dependency_job_id":null,"html_url":"https://github.com/emiliorizzo/vue-d3-network","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emiliorizzo%2Fvue-d3-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emiliorizzo%2Fvue-d3-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emiliorizzo%2Fvue-d3-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emiliorizzo%2Fvue-d3-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emiliorizzo","download_url":"https://codeload.github.com/emiliorizzo/vue-d3-network/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248018050,"owners_count":21034047,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","component","d3","d3-force","d3v4","graph","network","vue"],"created_at":"2024-08-01T15:07:01.233Z","updated_at":"2025-04-09T10:03:24.696Z","avatar_url":"https://github.com/emiliorizzo.png","language":"Vue","funding_links":[],"categories":["Vue","Library","UI组件","Components \u0026 Libraries","UI Components","UI Components [🔝](#readme)"],"sub_categories":["图表","UI Components","Charts"],"readme":"\n\n[![GitHub issues](https://img.shields.io/github/issues/emiliorizzo/vue-d3-network.svg)](https://github.com/emiliorizzo/vue-d3-network/issues) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/emiliorizzo/vue-d3-network/master/LICENSE) [![npm](https://img.shields.io/npm/v/vue-d3-network.svg)](https://www.npmjs.com/package/vue-d3-network)\n\n# vue-d3-network\n\n\u003e Vue component to graph networks using d3-force\n\n![vue d3 network](vue-d3-network.png)\n\n## Demo\n\n[Demo](https://emiliorizzo.github.io/vue-d3-network/)\n\n## Features\n\n- **SVG** render\n- **Canvas** render\n- Links and nodes selection\n- **svg \u003c-\u003e canvas** shared styles via css\n- **Screenshots**, *export as svg or png (svg renderer), export as png (canvas renderer)* \n- **Touch support**\n\n## Installation\n\n``` bash\nnpm install vue-d3-network --save\n\n```\n\n## Usage\n\n- [fiddle](https://jsfiddle.net/emii/ru24unsz/)\n- [codePen](https://codepen.io/emilio/pen/mwYpbj)\n\n```xml\n\u003cd3-network :net-nodes=\"nodes\" :net-links=\"links\" :options=\"options\" /\u003e\n\n```\n\n``` javascript  \nimport D3Network from 'vue-d3-network'\n  components: {\n    D3Network\n  }\n```\n\n``` html\n\n\u003cstyle src=\"vue-d3-network/dist/vue-d3-network.css\"\u003e\u003c/style\u003e\n\n```\n\n  Or: *import source component from:* 'vue-d3-network/src/vue-d3-network.vue'\n  *And install devDependencies.* (d3-force, stylus and pug)\n  See: [package.json](https://github.com/emiliorizzo/vue-d3-network/blob/master/package.json))\n\n## Props\n\n**net-nodes**: Array of [node objects](#node-object)\n\n**net-links**: Array of [link objects](#link-object)\n\n**selection** : Object, *links and nodes selected*\n\n- **links**: Object with node.ids as keys, node objects as values\n- **nodes**: Object  with link.ids as keys, links objects as values\n\n**nodeSym**: String, *node sprite svg doc*\n\n**nodeCb**: Function(node) -\u003e node, *node formatter*\n\n**linkCb**: Function(link) -\u003e link, *node link formatter*\n\n**simCb**: Function(sim) -\u003e sim, *d3 simulation formatter*\n\n**customForces**: Object: { [d3Function]:args }\n\n**options**:\n\n- **canvas**: Boolean, *render as canvas*, false = svg\n- **size**: Object, *graph size*. **Default:** container size\n  - **w**: Number\n  - **h**: Number\n\n- **offset**: Object, *graph center offset* \n  - **x**: Number\n  - **y**: Number\n\n- **force**: Number\n- **forces** Object:\n  - **Center**: *Boolean*, use d3.forceCenter\n  - **X**: *strength*, use d3.forceX\n  - **Y**: *strength*, use d3.forceY\n  - **ManyBody**: *Boolean*, use d3.forceManyBody, *takes the negative value of 'force'  option*\n  - **Link**: *Boolean*, use  d3.forceLink\n\n- **nodeSize**: Number, *node radius | size in px* \n- **linkWidth**: Number, *link thickness in px*\n- **nodeLabels**: Boolean, *show nodes names*\n- **linkLabels**: Boolean, *show links names*\n- **fontSize**: Number, *for node labels, px*\n- **strLinks**: Boolean, *draw links as rect lines* \n- **resizeListener**:Boolean, defaults: true ,add listener to window.resize event\n- **noNodes**: Boolean, *no render nodes*\n- **canvasStyles**: Object\n\n## Events\n\n- **node-click**:  *fired when click on node*, emits **(event,node-object)**\n- **link-click**:  *fired when click on link*, emits **(event, link-object)**\n- **screen-shot**: *fired when screenshot creation is done*, emits **(error)**\n\n## Methods\n\n- **screenShot** (name, bgColor, toSVG, svgAllCss), all arguments are optional\n  - **name:** file name\n  - **bgColor:** CSS color, png background color\n  - **toSVG:** *Boolean*, (svg renderer) true: export as svg, false : export as png\n  - **svgAllCss:** *Boolean* (svg renderer) true: include all styles in svg false: include only matched styles.\n  *This option is useful, for example to include hover actions on exported svg file*\n\n## Node object\n\n- **id**: node id. *If not provided uses array index*\n- **name**: node name. *If not provided uses: 'node [node_id]'*\n- **_color**: node color, e.g. *red*, *#aa00bb*,\n- **_cssClass**: node css class name\n- **_labelClass**: node label css class name\n- **svgSym**: node icon, svg document (only works in svg renderer)\n- **_size** : node size *(svg renderer only)*\n- **_width**: node width *(svg renderer only)*\n- **_height**: node height *(svg renderer only)*\n- **_svgAttrs**: Object, svg node attributes\n\n## Link Object\n\n- **id**: link id. *If not provided uses array index*\n- **name**: node name. *If not provided uses: 'link [link_id]'*\n- **tid**: id of target node\n- **sid**: id of source node\n- **_color**: link color, e.g. *red*, *#aa00bb*,\n- **_svgAttrs**: Object, svg line attributes\n\n## Css style and canvas style\n\nSVG css classes:\n\n- **.node**: nodes symbol\n- **.link**: link line\n- **.node-label**: nodes names\n- **.node .selected**: node selected\n- **.link .selected** link selected\n- **.node .pinned**: node pinned\n\nTo use this css styles in canvas we create 'ghosts' svg elements to pick up values from computed css properties.\nIf you want, you can stylize the canvas elements directly, setting: options.canvasStyles, but these styles will not be applied to the svg graph.\n\nsee: [src/canvasStyles.js](https://github.com/emiliorizzo/vue-d3-network/blob/master/src/lib/canvasStyles.js)\n\n## TODO\n\n- [x]  Touch support\n- [ ]   Optimization\n- [ ]   Zoom\n- [x]  Canvas Render\n- [x]  Nodes sprites\n\n## More Examples\n\n- [svg marks on links](https://codepen.io/emilio/pen/QOaQjP)\n- [Links labels](https://codepen.io/emilio/pen/ZampZb)\n- [No-link forces](https://jsfiddle.net/emii/4odfweq9)\n- [Change node icon on the fly](https://codepen.io/emilio/pen/YOeaWN)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femiliorizzo%2Fvue-d3-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femiliorizzo%2Fvue-d3-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femiliorizzo%2Fvue-d3-network/lists"}