Skip to content

Commit a639a98

Browse files
committed
Add documentation for link.breakPoints #378 @lironhl. Fix "functional:local: script. Add breakPoints example to small.data.js
1 parent bdff657 commit a639a98

3 files changed

Lines changed: 55 additions & 38 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"docs:lint": "documentation lint src/**/*.js",
1616
"docs:watch": "documentation --config documentation.yml build src/**/*.js -f html -o gen-docs --watch",
1717
"docs": "npm run docs:lint && documentation --config documentation.yml build src/**/*.js -f html -o gen-docs && documentation build src/**/*.js -f md > gen-docs/DOCUMENTATION.md",
18-
"functional:local": "cross-env CYPRESS_SANDBOX_URL=\"http://localhost:3002\" && cypress open",
18+
"functional:local": "cross-env CYPRESS_SANDBOX_URL=\"http://localhost:3002\" cypress open",
1919
"functional:remote": "cross-env CYPRESS_SANDBOX_URL=\"https://danielcaldas.github.io/react-d3-graph/sandbox/index.html\" cypress open",
2020
"functional": "cross-env CYPRESS_SANDBOX_URL=\"http://127.0.0.1:8888\" cypress run",
2121
"generate:tooltips": "jsdoc -X ./src/components/graph/graph.config.js > ./tools/graph-config-jsdoc.json && cd tools && node tooltips-docs-generator.js > ../sandbox/graph-config-tooltips.js",

sandbox/data/small/small.data.js

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,43 @@
11
module.exports = {
2-
links: [
3-
{
4-
source: 1,
5-
target: 2,
6-
label: "link 1 and 2",
7-
},
8-
{
9-
source: 1,
10-
target: 3,
11-
},
12-
{
13-
source: 1,
14-
target: 4,
15-
},
16-
{
17-
source: 3,
18-
target: 4,
19-
},
20-
],
21-
nodes: [
22-
{
23-
id: 1,
24-
name: "Node 1",
25-
},
26-
{
27-
id: 2,
28-
name: "Node 2",
29-
},
30-
{
31-
id: 3,
32-
name: "Node 3",
33-
},
34-
{
35-
id: 4,
36-
name: "Node 4",
37-
},
38-
],
2+
links: [
3+
{
4+
source: 1,
5+
target: 2,
6+
label: "link 1 and 2",
7+
},
8+
{
9+
source: 1,
10+
target: 3,
11+
},
12+
{
13+
source: 1,
14+
target: 4,
15+
},
16+
{
17+
source: 3,
18+
target: 4,
19+
breakPoints: [
20+
{ x: 100, y: 20 },
21+
{ x: 20, y: 100 },
22+
],
23+
},
24+
],
25+
nodes: [
26+
{
27+
id: 1,
28+
name: "Node 1",
29+
},
30+
{
31+
id: 2,
32+
name: "Node 2",
33+
},
34+
{
35+
id: 3,
36+
name: "Node 3",
37+
},
38+
{
39+
id: 4,
40+
name: "Node 4",
41+
},
42+
],
3943
};

src/components/graph/graph.config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,19 @@
180180
* </br>
181181
* @param {Object} link link object is explained in the next section. ⬇️
182182
* <h2 id="config-link"><a href="#config-link">#</a> Link level configurations</h2>
183+
* @param {Array.<Object>} [link.breakPoints=[]] - <a id="link-breakpoints" href="#link-breakPoints">🔗</a> 🔍 an array of coordinates, each coordinate indicates a breakpoint
184+
* where the link will break its natural flow and link to the next breakpoint in the list. [Here's the original feature request](https://github.com/danielcaldas/react-d3-graph/issues/373) it should give you an idea of the capabilities of this feature.
185+
* **Note that** this property can only be defined a link level and **not** through the config object.
186+
* ```javascript
187+
* const data = {
188+
* nodes: [ ... ],
189+
* links: [
190+
* source: 'a',
191+
* target: 'b',
192+
* breakPoints: [{ x: 100, y: 20 }, { x: 20, y: 100 }]
193+
* ]
194+
* };
195+
* ```
183196
* @param {string} [link.color="#d3d3d3"] - <a id="link-color" href="#link-color">🔗</a> 🔍 the color for links
184197
* (from version 1.3.0 this property can be configured at link level). <b>Note:</b> there's a current limitation where arrow markers in directed graphs won't have the same color as the link. Again this issue
185198
* only occurs for individually colored links, if links are colored globally through `link.color`

0 commit comments

Comments
 (0)