orgchart 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +32 -0
- package/README.md +172 -93
- package/README.zh-cn.md +163 -74
- package/README.zh-tw.md +163 -74
- package/bower.json +6 -9
- package/demo/10000-nodes.html +139 -0
- package/demo/ajax-datasource.html +46 -45
- package/demo/bottom2top.html +12 -9
- package/demo/center-on-selected-node.html +21 -17
- package/demo/color-coded.html +12 -9
- package/demo/css/style.css +28 -0
- package/demo/custom-icons.html +12 -9
- package/demo/custom-template.html +12 -9
- package/demo/data-prop-compact.html +11 -8
- package/demo/data-prop-hybrid.html +79 -50
- package/demo/default-collapsed.html +12 -9
- package/demo/drag-drop-hybrid-chart.html +17 -14
- package/demo/drag-drop.html +21 -16
- package/demo/edit-chart.html +148 -94
- package/demo/edit-hybrid-chart.html +178 -135
- package/demo/expand-to-given-depth.html +30 -22
- package/demo/export-chart-pdf.html +12 -9
- package/demo/export-chart-with-pictures.html +19 -12
- package/demo/export-chart.html +12 -9
- package/demo/family-tree.html +14 -11
- package/demo/familytree-custom-properties.html +108 -0
- package/demo/filter-node.html +104 -57
- package/demo/get-hierarchy.html +17 -12
- package/demo/get-related-nodes.html +27 -17
- package/demo/index.html +5 -2
- package/demo/integrate-map.html +32 -27
- package/demo/left2right.html +12 -9
- package/demo/level-offset.html +16 -15
- package/demo/link-node.html +12 -9
- package/demo/local-datasource.html +11 -8
- package/demo/minimap.html +224 -0
- package/demo/nodes-of-different-widths.html +11 -8
- package/demo/ondemand-loading-data.html +88 -91
- package/demo/option-createNode.html +28 -17
- package/demo/pan-zoom.html +20 -11
- package/demo/reload-data.html +17 -14
- package/demo/report-path.html +59 -29
- package/demo/responsive-design.html +14 -11
- package/demo/right2left.html +12 -9
- package/demo/toggle-sibs-resp.html +12 -9
- package/demo/ul-datasource.html +11 -8
- package/demo/vertical-level.html +12 -9
- package/dist/css/{jquery.orgchart.css → orgchart.css} +143 -80
- package/dist/css/orgchart.min.css +1 -0
- package/dist/js/orgchart.js +4101 -0
- package/dist/js/orgchart.min.js +2 -0
- package/dist/js/orgchart.min.js.map +1 -0
- package/gulpfile.js +37 -26
- package/package.json +32 -32
- package/src/css/{jquery.orgchart.css → orgchart.css} +143 -80
- package/src/js/orgchart.js +4101 -0
- package/test/cypress/e2e/demo-interactions.cy.js +91 -0
- package/test/cypress/e2e/demo-rendering.cy.js +100 -0
- package/test/cypress/e2e/drag-drop-hybrid-chart.cy.js +22 -0
- package/test/cypress/e2e/edit-chart.cy.js +20 -0
- package/test/cypress/e2e/level-offset.cy.js +21 -0
- package/test/cypress/e2e/minimap.cy.js +66 -0
- package/test/cypress/e2e/pan-zoom.cy.js +165 -0
- package/test/cypress/e2e/report-path.cy.js +20 -0
- package/test/cypress/e2e/vertical-vevel.cy.js +5 -3
- package/test/e2e/local-datasource/test.js +1 -1
- package/test/integration/init-tests.js +168 -62
- package/test/integration/tests.js +1034 -56
- package/test/unit/lifecycle-builders-export.tests.js +1426 -0
- package/test/unit/minimap.tests.js +210 -0
- package/test/unit/tests.js +2372 -252
- package/dist/css/jquery.orgchart.min.css +0 -1
- package/dist/js/jquery.orgchart.js +0 -1741
- package/dist/js/jquery.orgchart.min.js +0 -5
- package/dist/js/jquery.orgchart.min.js.map +0 -1
- package/src/js/jquery.orgchart.js +0 -1741
package/README.md
CHANGED
|
@@ -13,6 +13,8 @@ First of all, thanks a lot for [wesnolte](https://github.com/wesnolte)'s great w
|
|
|
13
13
|
Unfortunately, it's long time not to see the update of jOrgChart. on the other hand, I got some interesting ideas to add, so I choose to create a new repo.
|
|
14
14
|
- Since version 3.0, we use nested ul to construct tree-like chart instead of nested table.
|
|
15
15
|
- Since version 4.0, users build up the ajax datasoure by themselves.
|
|
16
|
+
- Since version 5.0, users are allowed to build up the family tree.
|
|
17
|
+
- Since version 6.0, The orgchart component has been reverted to native implementation and no longer relies on jQuery.
|
|
16
18
|
|
|
17
19
|
## Features
|
|
18
20
|
- Supports both local data and remote data (JSON).
|
|
@@ -32,7 +34,7 @@ Users could find the related CDN support for OrgChart's CSS and JavaScript.
|
|
|
32
34
|
[](https://cdnjs.com/libraries/orgchart) https://cdnjs.com/libraries/orgchart
|
|
33
35
|
|
|
34
36
|
## Installation
|
|
35
|
-
Of course, you can directly use the standalone build by including dist/js/
|
|
37
|
+
Of course, you can directly use the standalone build by including dist/js/orgchart.js and dist/css/orgchart.css in your webapps.
|
|
36
38
|
### Install with Bower
|
|
37
39
|
```
|
|
38
40
|
# From version 1.0.2 on, users can install orgchart and add it to bower.json dependencies
|
|
@@ -44,7 +46,9 @@ $ bower install orgchart
|
|
|
44
46
|
# From version 1.0.4 on, users can install orgchart with npm
|
|
45
47
|
$ npm install orgchart
|
|
46
48
|
```
|
|
47
|
-
require('orgchart')
|
|
49
|
+
In CommonJS environments, `require('orgchart')` exports the `OrgChart` constructor directly.
|
|
50
|
+
|
|
51
|
+
FYI, [How to use jQuery Orchart in React](https://stackblitz.com/edit/vitejs-vite-hqv4nbdt)
|
|
48
52
|
|
|
49
53
|
## [Demos on github pages](https://dabeng.github.io/OrgChart/)
|
|
50
54
|
## [Demos based on nested ul](https://codepen.io/collection/xKmPeK)
|
|
@@ -169,36 +173,36 @@ You need the solution based on new datasource structure with **levelOffset data
|
|
|
169
173
|
|
|
170
174
|

|
|
171
175
|
|
|
172
|
-
We use the following two-dimensional array datasource to build up the Family Tree.
|
|
176
|
+
We use the following two-dimensional array datasource to build up the Family Tree. Here, prop "gender" is optional.
|
|
173
177
|
```
|
|
174
178
|
var datascource = [
|
|
175
179
|
[
|
|
176
|
-
{ 'id': '8', 'name': 'Lao Ye', 'title': 'Grandfather'
|
|
180
|
+
{ 'id': '8', 'name': 'Lao Ye', 'title': 'Grandfather' },
|
|
177
181
|
{
|
|
178
|
-
'id': '1', 'name': 'Lao Lao', 'title': 'Grandmother',
|
|
182
|
+
'id': '1', 'name': 'Lao Lao', 'title': 'Grandmother', 'outsider': true,
|
|
179
183
|
'children': [
|
|
180
184
|
[
|
|
181
|
-
{ 'id': '2', 'name': 'Bo miao', 'title': 'Aunt'
|
|
185
|
+
{ 'id': '2', 'name': 'Bo miao', 'title': 'Aunt' }
|
|
182
186
|
],
|
|
183
187
|
[
|
|
184
|
-
{ 'id': '3', 'name': 'Su Miao', 'title': 'Mother',
|
|
188
|
+
{ 'id': '3', 'name': 'Su Miao', 'title': 'Mother',
|
|
185
189
|
'children': [
|
|
186
190
|
[
|
|
187
191
|
|
|
188
|
-
{ 'id': '12', 'name': 'Pang Pang', 'title': 'Wife', '
|
|
192
|
+
{ 'id': '12', 'name': 'Pang Pang', 'title': 'Wife', 'outsider': true,
|
|
189
193
|
'children': [
|
|
190
|
-
[{ 'id': '7', 'name': 'Dan Dan', 'title': 'Daughter'
|
|
191
|
-
[{ 'id': '6', 'name': 'Er Dan', 'title': 'Daughter'
|
|
194
|
+
[{ 'id': '7', 'name': 'Dan Dan', 'title': 'Daughter' }],
|
|
195
|
+
[{ 'id': '6', 'name': 'Er Dan', 'title': 'Daughter' }],
|
|
192
196
|
]
|
|
193
197
|
},
|
|
194
|
-
{ 'id': '5', 'name': 'Hei Hei', 'title': 'Me'
|
|
198
|
+
{ 'id': '5', 'name': 'Hei Hei', 'title': 'Me' },
|
|
195
199
|
]
|
|
196
200
|
]
|
|
197
201
|
},
|
|
198
|
-
{ 'id': '9', 'name': 'Tie Hua', 'title': 'Father', '
|
|
202
|
+
{ 'id': '9', 'name': 'Tie Hua', 'title': 'Father', 'outsider': true }
|
|
199
203
|
],
|
|
200
204
|
[
|
|
201
|
-
{ 'id': '10', 'name': 'Hong miao', 'title': 'Aunt'
|
|
205
|
+
{ 'id': '10', 'name': 'Hong miao', 'title': 'Aunt' }
|
|
202
206
|
]
|
|
203
207
|
]
|
|
204
208
|
}
|
|
@@ -206,6 +210,16 @@ var datascource = [
|
|
|
206
210
|
];
|
|
207
211
|
```
|
|
208
212
|
|
|
213
|
+
- [I want to add property tags to family tree](https://dabeng.github.io/OrgChart/familytree-custom-properties.html)
|
|
214
|
+
|
|
215
|
+

|
|
216
|
+
|
|
217
|
+
- [I want to navigate the orgchart with a minimap](https://dabeng.github.io/OrgChart/minimap.html)
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
Enable the `minimap` option to display an overview navigator. Drag its viewport to move the chart, or use the mouse wheel over the minimap to zoom.
|
|
222
|
+
|
|
209
223
|
### how to start up demos locally
|
|
210
224
|
|
|
211
225
|
- you have to install node.js v6+ because our unit tests are based on jsdom v11
|
|
@@ -219,7 +233,10 @@ var datascource = [
|
|
|
219
233
|
|
|
220
234
|
### Instantiation Statement
|
|
221
235
|
```js
|
|
222
|
-
var oc =
|
|
236
|
+
var oc = new OrgChart({
|
|
237
|
+
chartContainer: '#chartContainerId',
|
|
238
|
+
data: datasource
|
|
239
|
+
});
|
|
223
240
|
```
|
|
224
241
|
|
|
225
242
|
### Structure of Datasource
|
|
@@ -230,7 +247,7 @@ var oc = $('#chartContainerId').orgchart(options);
|
|
|
230
247
|
'collapsed': true, // By default, the children nodes of current node is hidden.
|
|
231
248
|
'className': 'top-level', // It's a optional property
|
|
232
249
|
// which will be used as className attribute of node.
|
|
233
|
-
'nodeTitle': 'name', // This property is used to retrieve
|
|
250
|
+
'nodeTitle': 'name', // This property is used to retrieve “title†value in datasource
|
|
234
251
|
'nodeContent': 'title',// This property is used to retrieve "content" value in datasource
|
|
235
252
|
'relationship': relationshipValue, // Note: when you activate ondemand loading nodes feature,
|
|
236
253
|
// you should use json datsource (local or remote) and set this property.
|
|
@@ -290,10 +307,10 @@ var oc = $('#chartContainerId').orgchart(options);
|
|
|
290
307
|
<tbody>
|
|
291
308
|
<tr>
|
|
292
309
|
<td>data</td>
|
|
293
|
-
<td>json or
|
|
310
|
+
<td>json or HTMLUListElement</td>
|
|
294
311
|
<td>yes</td>
|
|
295
312
|
<td></td>
|
|
296
|
-
<td>datasource
|
|
313
|
+
<td>datasource used to build out structure of orgchart. It can be a json object or an HTML ul element.</td>
|
|
297
314
|
</tr>
|
|
298
315
|
<tr>
|
|
299
316
|
<td>pan</td>
|
|
@@ -391,7 +408,7 @@ var oc = $('#chartContainerId').orgchart(options);
|
|
|
391
408
|
<td>function</td>
|
|
392
409
|
<td>no</td>
|
|
393
410
|
<td></td>
|
|
394
|
-
<td>It's a callback function used to customize every orgchart node. It receives two parameters: "
|
|
411
|
+
<td>It's a callback function used to customize every orgchart node. It receives two parameters: "node" stands for the single node element; "data" stands for datasource of single node.</td>
|
|
395
412
|
</tr>
|
|
396
413
|
<tr>
|
|
397
414
|
<td>exportButton</td>
|
|
@@ -447,7 +464,7 @@ var oc = $('#chartContainerId').orgchart(options);
|
|
|
447
464
|
<td>function</td>
|
|
448
465
|
<td>no</td>
|
|
449
466
|
<td></td>
|
|
450
|
-
<td>It can often be useful to know when your table has fully been initialised, data loaded and rendered. It receives one
|
|
467
|
+
<td>It can often be useful to know when your table has fully been initialised, data loaded and rendered. It receives one parameter: "chart" stands for the initialized chart element.</td>
|
|
451
468
|
</tr>
|
|
452
469
|
<tr>
|
|
453
470
|
<td>icons</td>
|
|
@@ -482,14 +499,48 @@ var oc = $('#chartContainerId').orgchart(options);
|
|
|
482
499
|
</table>
|
|
483
500
|
|
|
484
501
|
### Methods
|
|
485
|
-
|
|
502
|
+
Create an instance with `new OrgChart(options)`. Its `chartContainer` and `chart` properties expose the native container and rendered chart elements.
|
|
486
503
|
|
|
487
|
-
|
|
488
|
-
|
|
504
|
+
```js
|
|
505
|
+
const oc = new OrgChart({ chartContainer: '#chartContainerId', data: datasource });
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
The public API is: `init`, `setOptions`, `attachMinimap`, `detachMinimap`, `updateMinimap`, `addAncestors`, `addDescendants`, `addParent`, `addSiblings`, `addChildren`, `removeNodes`, `getHierarchy`, `getNodeState`, `getParent`, `getChildren`, `getSiblings`, `getRelatedNodes`, `hideParent`, `showParent`, `hideChildren`, `showChildren`, `hideSiblings`, `showSiblings`, `setChartScale`, `export`, `exportPNG`, and `exportPDF`. Arguments that refer to nodes or charts are native `HTMLElement` instances.
|
|
509
|
+
|
|
510
|
+
#### API reference
|
|
511
|
+
| Call | Parameters | Return value and behavior |
|
|
512
|
+
| --- | --- | --- |
|
|
513
|
+
| `oc.init(options)` | Partial options object; use `data` to replace the data source. | Rebuilds the chart and returns `oc`. |
|
|
514
|
+
| `oc.setOptions(options)`<br>`oc.setOptions(name, value)` | Object containing `data`, `pan`, `zoom`, or `minimap`; or one of the supported names with a boolean value. | Rebuilds for `data`; toggles pan, zoom, or minimap otherwise; returns `oc`. |
|
|
515
|
+
| `oc.attachMinimap()`<br>`oc.detachMinimap()`<br>`oc.updateMinimap(forceRefresh)` | `forceRefresh` is optional; `true` redraws preview nodes. | Creates, removes, or refreshes the minimap. Prefer `setOptions('minimap', value)` for normal enablement. |
|
|
516
|
+
| `oc.addAncestors(data, parentId)` | Ancestor data and the id of the ancestor node that receives the existing root. | Inserts ancestor hierarchy; no return value. |
|
|
517
|
+
| `oc.addDescendants(data, parent)` | Array of descendant data and a rendered parent `.node`. | Appends descendant hierarchy; no return value. |
|
|
518
|
+
| `oc.addParent(currentRoot, data)` | Rendered root `.node` and its new parent data. | Wraps the current root with a parent; no return value. |
|
|
519
|
+
| `oc.addSiblings(node, data)`<br>`oc.addChildren(node, data)` | Rendered `.node` and an array of sibling or child data. | Adds rendered nodes; no return value. |
|
|
520
|
+
| `oc.removeNodes(node)` | Rendered `.node` to remove. | Removes the node and its descendants; no return value. |
|
|
521
|
+
| `oc.getHierarchy(includeNodeData)` | Optional boolean, default `false`. | Returns the hierarchy object; returns an error string when the chart or required node ids are unavailable. |
|
|
522
|
+
| `oc.getNodeState(node, relation)` | Rendered `.node`; `relation` is `parent`, `children`, or `siblings`. | Returns `{ exist, visible }`. |
|
|
523
|
+
| `oc.getParent(node)` | Rendered `.node`. | Returns its parent `.node`, or `null`. |
|
|
524
|
+
| `oc.getChildren(node)`<br>`oc.getSiblings(node)` | Rendered `.node`. | Returns an array of direct child or sibling `.node` elements. |
|
|
525
|
+
| `oc.getRelatedNodes(node, relation)` | Rendered `.node`; `relation` is `parent`, `children`, or `siblings`. | Equivalent generalized query; parent returns a node or `null`, other relations return arrays. |
|
|
526
|
+
| `oc.hideParent(node)` / `oc.showParent(node)`<br>`oc.hideChildren(node)` / `oc.showChildren(node)` | Rendered `.node`. | Hides or reveals the related branch with the chart transition; no return value. |
|
|
527
|
+
| `oc.hideSiblings(node, direction)`<br>`oc.showSiblings(node, direction)` | Rendered `.node`; optional `direction` is `left` or `right`. | Hides or reveals siblings on one side, or all siblings when omitted; no return value. |
|
|
528
|
+
| `oc.setChartScale(chart, multiplier, zoomAnchor)` | Usually pass `oc.chart`; positive relative scale multiplier; optional viewport point `{ x, y }`. | Scales within configured zoom limits and keeps `zoomAnchor` fixed when supplied. |
|
|
529
|
+
| `oc.export(filename, extension)` | Optional filename and `png` or `pdf` extension. | Starts export using configured defaults; returns `false` if the chart cannot be exported. |
|
|
530
|
+
| `oc.exportPNG(canvas, filename)`<br>`oc.exportPDF(canvas, filename, exportScale)` | Prepared canvas; filename; PDF scale defaults to `1`. | Downloads the supplied canvas directly as PNG or PDF; normally call `export()` instead. |
|
|
489
531
|
|
|
490
532
|
#### init(newOptions)
|
|
491
533
|
It's the useful way when users want to re-initialize or refresh orgchart based on new options or reload new data.
|
|
492
534
|
|
|
535
|
+
#### setOptions(options) / setOptions(name, value)
|
|
536
|
+
Updates `pan`, `zoom`, or `minimap` without rebuilding the chart. Pass an options object, or a supported option name and boolean value. Passing an object containing `data` rebuilds the chart.
|
|
537
|
+
|
|
538
|
+
#### attachMinimap() / detachMinimap()
|
|
539
|
+
Creates or removes the minimap overlay for the current chart. Usually use `setOptions('minimap', true|false)` so the option state and overlay stay synchronized.
|
|
540
|
+
|
|
541
|
+
#### updateMinimap(forceRefresh)
|
|
542
|
+
Recalculates the minimap viewport after changing the chart transform or layout. Pass `true` to redraw the minimap node preview.
|
|
543
|
+
|
|
493
544
|
#### addAncestors(data, parentId)
|
|
494
545
|
Adds the ancestors for current orgchart.
|
|
495
546
|
<table>
|
|
@@ -520,7 +571,7 @@ Adds the ancestors for current orgchart.
|
|
|
520
571
|
</tbody>
|
|
521
572
|
</table>
|
|
522
573
|
|
|
523
|
-
#### addDescendants(data,
|
|
574
|
+
#### addDescendants(data, parent)
|
|
524
575
|
Adds the descendants for specified parent node.
|
|
525
576
|
<table>
|
|
526
577
|
<thead>
|
|
@@ -541,16 +592,16 @@ Adds the descendants for specified parent node.
|
|
|
541
592
|
<td>datasource for building descendants</td>
|
|
542
593
|
</tr>
|
|
543
594
|
<tr>
|
|
544
|
-
<td
|
|
545
|
-
<td>
|
|
595
|
+
<td>parent</td>
|
|
596
|
+
<td>HTMLElement</td>
|
|
546
597
|
<td>yes</td>
|
|
547
598
|
<td></td>
|
|
548
|
-
<td>append descendants to the
|
|
599
|
+
<td>append descendants to the parent node</td>
|
|
549
600
|
</tr>
|
|
550
601
|
</tbody>
|
|
551
602
|
</table>
|
|
552
603
|
|
|
553
|
-
#### addParent(data)
|
|
604
|
+
#### addParent(currentRoot, data)
|
|
554
605
|
Adds parent node(actullay it's always root node) for current orgchart.
|
|
555
606
|
<table>
|
|
556
607
|
<thead>
|
|
@@ -563,6 +614,13 @@ Adds parent node(actullay it's always root node) for current orgchart.
|
|
|
563
614
|
</tr>
|
|
564
615
|
</thead>
|
|
565
616
|
<tbody>
|
|
617
|
+
<tr>
|
|
618
|
+
<td>currentRoot</td>
|
|
619
|
+
<td>HTMLElement</td>
|
|
620
|
+
<td>yes</td>
|
|
621
|
+
<td></td>
|
|
622
|
+
<td>current root node that the new parent node will wrap</td>
|
|
623
|
+
</tr>
|
|
566
624
|
<tr>
|
|
567
625
|
<td>data</td>
|
|
568
626
|
<td>json object</td>
|
|
@@ -573,7 +631,7 @@ Adds parent node(actullay it's always root node) for current orgchart.
|
|
|
573
631
|
</tbody>
|
|
574
632
|
</table>
|
|
575
633
|
|
|
576
|
-
#### addSiblings(
|
|
634
|
+
#### addSiblings(node, data)
|
|
577
635
|
Adds sibling nodes for designated node.
|
|
578
636
|
<table>
|
|
579
637
|
<thead>
|
|
@@ -587,8 +645,8 @@ Adds sibling nodes for designated node.
|
|
|
587
645
|
</thead>
|
|
588
646
|
<tbody>
|
|
589
647
|
<tr>
|
|
590
|
-
<td
|
|
591
|
-
<td>
|
|
648
|
+
<td>node</td>
|
|
649
|
+
<td>HTMLElement</td>
|
|
592
650
|
<td>yes</td>
|
|
593
651
|
<td></td>
|
|
594
652
|
<td>we'll add sibling nodes based on this node</td>
|
|
@@ -603,7 +661,7 @@ Adds sibling nodes for designated node.
|
|
|
603
661
|
</tbody>
|
|
604
662
|
</table>
|
|
605
663
|
|
|
606
|
-
#### addChildren(
|
|
664
|
+
#### addChildren(node, data)
|
|
607
665
|
Adds child nodes for designed node.
|
|
608
666
|
<table>
|
|
609
667
|
<thead>
|
|
@@ -617,8 +675,8 @@ Adds child nodes for designed node.
|
|
|
617
675
|
</thead>
|
|
618
676
|
<tbody>
|
|
619
677
|
<tr>
|
|
620
|
-
<td
|
|
621
|
-
<td>
|
|
678
|
+
<td>node</td>
|
|
679
|
+
<td>HTMLElement</td>
|
|
622
680
|
<td>yes</td>
|
|
623
681
|
<td></td>
|
|
624
682
|
<td>we'll add child nodes based on this node</td>
|
|
@@ -633,7 +691,7 @@ Adds child nodes for designed node.
|
|
|
633
691
|
</tbody>
|
|
634
692
|
</table>
|
|
635
693
|
|
|
636
|
-
#### removeNodes(
|
|
694
|
+
#### removeNodes(node)
|
|
637
695
|
Removes the designated node and its descedant nodes.
|
|
638
696
|
<table>
|
|
639
697
|
<thead>
|
|
@@ -647,8 +705,8 @@ Removes the designated node and its descedant nodes.
|
|
|
647
705
|
</thead>
|
|
648
706
|
<tbody>
|
|
649
707
|
<tr>
|
|
650
|
-
<td
|
|
651
|
-
<td>
|
|
708
|
+
<td>node</td>
|
|
709
|
+
<td>HTMLElement</td>
|
|
652
710
|
<td>yes</td>
|
|
653
711
|
<td></td>
|
|
654
712
|
<td>node to be removed</td>
|
|
@@ -675,7 +733,7 @@ This method is designed to get the hierarchy relationships of orgchart for furth
|
|
|
675
733
|
</tr>
|
|
676
734
|
</table>
|
|
677
735
|
|
|
678
|
-
#### hideParent(
|
|
736
|
+
#### hideParent(node)
|
|
679
737
|
This method allows you to hide programatically the parent node of any specific node(.node element), if it has.
|
|
680
738
|
<table>
|
|
681
739
|
<tr>
|
|
@@ -686,15 +744,15 @@ This method allows you to hide programatically the parent node of any specific n
|
|
|
686
744
|
<th>Description</th>
|
|
687
745
|
</tr>
|
|
688
746
|
<tr>
|
|
689
|
-
<td
|
|
690
|
-
<td>
|
|
747
|
+
<td>node</td>
|
|
748
|
+
<td>HTMLElement</td>
|
|
691
749
|
<td>Yes</td>
|
|
692
750
|
<td></td>
|
|
693
|
-
<td>It
|
|
751
|
+
<td>It is the node element whose parent node should be hidden. Its sibling nodes will be hidden at the same time.</td>
|
|
694
752
|
</tr>
|
|
695
753
|
</table>
|
|
696
754
|
|
|
697
|
-
#### showParent(
|
|
755
|
+
#### showParent(node)
|
|
698
756
|
This method allows you to show programatically the parent node of any specific node(.node element), if it has.
|
|
699
757
|
<table>
|
|
700
758
|
<tr>
|
|
@@ -705,15 +763,15 @@ This method allows you to show programatically the parent node of any specific n
|
|
|
705
763
|
<th>Description</th>
|
|
706
764
|
</tr>
|
|
707
765
|
<tr>
|
|
708
|
-
<td
|
|
709
|
-
<td>
|
|
766
|
+
<td>node</td>
|
|
767
|
+
<td>HTMLElement</td>
|
|
710
768
|
<td>Yes</td>
|
|
711
769
|
<td></td>
|
|
712
|
-
<td>It
|
|
770
|
+
<td>It is the node element whose parent node should be shown</td>
|
|
713
771
|
</tr>
|
|
714
772
|
</table>
|
|
715
773
|
|
|
716
|
-
#### hideChildren(
|
|
774
|
+
#### hideChildren(node)
|
|
717
775
|
This method allows you to hide programatically the children of any specific node(.node element), if it has.
|
|
718
776
|
<table>
|
|
719
777
|
<tr>
|
|
@@ -724,15 +782,15 @@ This method allows you to hide programatically the children of any specific node
|
|
|
724
782
|
<th>Description</th>
|
|
725
783
|
</tr>
|
|
726
784
|
<tr>
|
|
727
|
-
<td
|
|
728
|
-
<td>
|
|
785
|
+
<td>node</td>
|
|
786
|
+
<td>HTMLElement</td>
|
|
729
787
|
<td>Yes</td>
|
|
730
788
|
<td></td>
|
|
731
|
-
<td>It
|
|
789
|
+
<td>It is the node element whose child nodes should be hidden</td>
|
|
732
790
|
</tr>
|
|
733
791
|
</table>
|
|
734
792
|
|
|
735
|
-
#### showChildren(
|
|
793
|
+
#### showChildren(node)
|
|
736
794
|
This method allows you to show programatically the children of any specific node(.node element), if it has.
|
|
737
795
|
<table>
|
|
738
796
|
<tr>
|
|
@@ -743,15 +801,15 @@ This method allows you to show programatically the children of any specific node
|
|
|
743
801
|
<th>Description</th>
|
|
744
802
|
</tr>
|
|
745
803
|
<tr>
|
|
746
|
-
<td
|
|
747
|
-
<td>
|
|
804
|
+
<td>node</td>
|
|
805
|
+
<td>HTMLElement</td>
|
|
748
806
|
<td>Yes</td>
|
|
749
807
|
<td></td>
|
|
750
|
-
<td>It
|
|
808
|
+
<td>It is the node element whose child nodes should be shown</td>
|
|
751
809
|
</tr>
|
|
752
810
|
</table>
|
|
753
811
|
|
|
754
|
-
#### hideSiblings(
|
|
812
|
+
#### hideSiblings(node, direction)
|
|
755
813
|
This method allows you to hide programatically the siblings of any specific node(.node element), if it has.
|
|
756
814
|
<table>
|
|
757
815
|
<tr>
|
|
@@ -762,11 +820,11 @@ This method allows you to hide programatically the siblings of any specific node
|
|
|
762
820
|
<th>Description</th>
|
|
763
821
|
</tr>
|
|
764
822
|
<tr>
|
|
765
|
-
<td
|
|
766
|
-
<td>
|
|
823
|
+
<td>node</td>
|
|
824
|
+
<td>HTMLElement</td>
|
|
767
825
|
<td>Yes</td>
|
|
768
826
|
<td></td>
|
|
769
|
-
<td>It
|
|
827
|
+
<td>It is the node element whose sibling nodes should be hidden</td>
|
|
770
828
|
</tr>
|
|
771
829
|
<tr>
|
|
772
830
|
<td>direction</td>
|
|
@@ -777,7 +835,7 @@ This method allows you to hide programatically the siblings of any specific node
|
|
|
777
835
|
</tr>
|
|
778
836
|
</table>
|
|
779
837
|
|
|
780
|
-
#### showSiblings(
|
|
838
|
+
#### showSiblings(node, direction)
|
|
781
839
|
This method allows you to show programatically the siblings of any specific node(.node element), if it has.
|
|
782
840
|
<table>
|
|
783
841
|
<tr>
|
|
@@ -788,11 +846,11 @@ This method allows you to show programatically the siblings of any specific node
|
|
|
788
846
|
<th>Description</th>
|
|
789
847
|
</tr>
|
|
790
848
|
<tr>
|
|
791
|
-
<td
|
|
792
|
-
<td>
|
|
849
|
+
<td>node</td>
|
|
850
|
+
<td>HTMLElement</td>
|
|
793
851
|
<td>Yes</td>
|
|
794
852
|
<td></td>
|
|
795
|
-
<td>It
|
|
853
|
+
<td>It is the node element whose sibling nodes should be shown</td>
|
|
796
854
|
</tr>
|
|
797
855
|
<tr>
|
|
798
856
|
<td>direction</td>
|
|
@@ -803,7 +861,7 @@ This method allows you to show programatically the siblings of any specific node
|
|
|
803
861
|
</tr>
|
|
804
862
|
</table>
|
|
805
863
|
|
|
806
|
-
#### getNodeState(
|
|
864
|
+
#### getNodeState(node, relation)
|
|
807
865
|
This method returns you the display state of related node of the specified node.
|
|
808
866
|
<table>
|
|
809
867
|
<tr>
|
|
@@ -814,11 +872,11 @@ This method returns you the display state of related node of the specified node.
|
|
|
814
872
|
<th>Description</th>
|
|
815
873
|
</tr>
|
|
816
874
|
<tr>
|
|
817
|
-
<td
|
|
818
|
-
<td>
|
|
875
|
+
<td>node</td>
|
|
876
|
+
<td>HTMLElement</td>
|
|
819
877
|
<td>Yes</td>
|
|
820
878
|
<td></td>
|
|
821
|
-
<td>It
|
|
879
|
+
<td>It is the node element whose related nodes' display state you want to inspect.</td>
|
|
822
880
|
</tr>
|
|
823
881
|
<tr>
|
|
824
882
|
<td>relation</td>
|
|
@@ -837,7 +895,7 @@ The returning object will have the following structure:
|
|
|
837
895
|
}
|
|
838
896
|
```
|
|
839
897
|
|
|
840
|
-
#### getRelatedNodes(
|
|
898
|
+
#### getRelatedNodes(node, relation)
|
|
841
899
|
This method returns you the nodes related to the specified node.
|
|
842
900
|
<table>
|
|
843
901
|
<tr>
|
|
@@ -848,11 +906,11 @@ This method returns you the nodes related to the specified node.
|
|
|
848
906
|
<th>Description</th>
|
|
849
907
|
</tr>
|
|
850
908
|
<tr>
|
|
851
|
-
<td
|
|
852
|
-
<td>
|
|
909
|
+
<td>node</td>
|
|
910
|
+
<td>HTMLElement</td>
|
|
853
911
|
<td>Yes</td>
|
|
854
912
|
<td></td>
|
|
855
|
-
<td>It
|
|
913
|
+
<td>It is the node element whose related nodes you want to inspect</td>
|
|
856
914
|
</tr>
|
|
857
915
|
<tr>
|
|
858
916
|
<td>relation</td>
|
|
@@ -863,7 +921,7 @@ This method returns you the nodes related to the specified node.
|
|
|
863
921
|
</tr>
|
|
864
922
|
</table>
|
|
865
923
|
|
|
866
|
-
#### getParent(
|
|
924
|
+
#### getParent(node)
|
|
867
925
|
This method returns you the parent node of the specified node.
|
|
868
926
|
<table>
|
|
869
927
|
<tr>
|
|
@@ -874,15 +932,15 @@ This method returns you the parent node of the specified node.
|
|
|
874
932
|
<th>Description</th>
|
|
875
933
|
</tr>
|
|
876
934
|
<tr>
|
|
877
|
-
<td
|
|
878
|
-
<td>
|
|
935
|
+
<td>node</td>
|
|
936
|
+
<td>HTMLElement</td>
|
|
879
937
|
<td>Yes</td>
|
|
880
938
|
<td></td>
|
|
881
|
-
<td>It
|
|
939
|
+
<td>It is the node element whose parent node you want to inspect</td>
|
|
882
940
|
</tr>
|
|
883
941
|
</table>
|
|
884
942
|
|
|
885
|
-
#### getSiblings(
|
|
943
|
+
#### getSiblings(node)
|
|
886
944
|
This method returns you the sibling nodes of the specified node.
|
|
887
945
|
<table>
|
|
888
946
|
<tr>
|
|
@@ -893,15 +951,15 @@ This method returns you the sibling nodes of the specified node.
|
|
|
893
951
|
<th>Description</th>
|
|
894
952
|
</tr>
|
|
895
953
|
<tr>
|
|
896
|
-
<td
|
|
897
|
-
<td>
|
|
954
|
+
<td>node</td>
|
|
955
|
+
<td>HTMLElement</td>
|
|
898
956
|
<td>Yes</td>
|
|
899
957
|
<td></td>
|
|
900
|
-
<td>It
|
|
958
|
+
<td>It is the node element whose sibling nodes you want to inspect</td>
|
|
901
959
|
</tr>
|
|
902
960
|
</table>
|
|
903
961
|
|
|
904
|
-
#### getChildren(
|
|
962
|
+
#### getChildren(node)
|
|
905
963
|
This method returns you the child nodes of the specified node.
|
|
906
964
|
<table>
|
|
907
965
|
<tr>
|
|
@@ -912,16 +970,18 @@ This method returns you the child nodes of the specified node.
|
|
|
912
970
|
<th>Description</th>
|
|
913
971
|
</tr>
|
|
914
972
|
<tr>
|
|
915
|
-
<td
|
|
916
|
-
<td>
|
|
973
|
+
<td>node</td>
|
|
974
|
+
<td>HTMLElement</td>
|
|
917
975
|
<td>Yes</td>
|
|
918
976
|
<td></td>
|
|
919
|
-
<td>It
|
|
977
|
+
<td>It is the node element whose child nodes you want to inspect</td>
|
|
920
978
|
</tr>
|
|
921
979
|
</table>
|
|
922
980
|
|
|
923
|
-
#### setChartScale(
|
|
981
|
+
#### setChartScale(chart, newScale, zoomAnchor)
|
|
924
982
|
This method helps you set the specified chart with new scale.
|
|
983
|
+
|
|
984
|
+
`zoomAnchor` is optional and has the form `{ x, y }` in viewport coordinates. When provided, that point remains fixed while the chart is scaled.
|
|
925
985
|
<table>
|
|
926
986
|
<tr>
|
|
927
987
|
<th>Name</th>
|
|
@@ -931,11 +991,11 @@ This method helps you set the specified chart with new scale.
|
|
|
931
991
|
<th>Description</th>
|
|
932
992
|
</tr>
|
|
933
993
|
<tr>
|
|
934
|
-
<td
|
|
935
|
-
<td>
|
|
994
|
+
<td>chart</td>
|
|
995
|
+
<td>HTMLElement</td>
|
|
936
996
|
<td>Yes</td>
|
|
937
997
|
<td></td>
|
|
938
|
-
<td>It
|
|
998
|
+
<td>It is the chart element in your chart-container</td>
|
|
939
999
|
</tr>
|
|
940
1000
|
<tr>
|
|
941
1001
|
<td>newScale</td>
|
|
@@ -972,7 +1032,21 @@ This method allow you to export current orgchart as png or pdf file.
|
|
|
972
1032
|
</tr>
|
|
973
1033
|
</table>
|
|
974
1034
|
|
|
1035
|
+
#### exportPNG(canvas, exportFilename)
|
|
1036
|
+
Exports a prepared canvas as a PNG download. This helper is useful when application code supplies its own canvas; most users should call `export()` instead.
|
|
1037
|
+
|
|
1038
|
+
#### exportPDF(canvas, exportFilename, exportScale)
|
|
1039
|
+
Exports a prepared canvas as a PDF download. `exportScale` is the canvas render scale and is used to preserve the PDF's logical dimensions; most users should call `export()` instead.
|
|
1040
|
+
|
|
975
1041
|
### Events
|
|
1042
|
+
OrgChart dispatches bubbling native `CustomEvent` objects. Subscribe with `addEventListener`; event payloads are available on `event.detail`.
|
|
1043
|
+
|
|
1044
|
+
```js
|
|
1045
|
+
oc.chart.addEventListener('nodedrop.orgchart', function (event) {
|
|
1046
|
+
const { draggedNode, dragZone, dropZone } = event.detail;
|
|
1047
|
+
});
|
|
1048
|
+
```
|
|
1049
|
+
|
|
976
1050
|
<table>
|
|
977
1051
|
<thead>
|
|
978
1052
|
<tr>
|
|
@@ -984,23 +1058,28 @@ This method allow you to export current orgchart as png or pdf file.
|
|
|
984
1058
|
<tbody>
|
|
985
1059
|
<tr>
|
|
986
1060
|
<td>nodedrop.orgchart</td>
|
|
987
|
-
<td>draggedNode, dragZone, dropZone</td>
|
|
988
|
-
<td>
|
|
1061
|
+
<td><code>event.detail</code>: draggedNode, dragZone, dropZone</td>
|
|
1062
|
+
<td>Fires on the chart before a node is moved. Call <code>event.preventDefault()</code> to cancel the drop.</td>
|
|
1063
|
+
</tr>
|
|
1064
|
+
<tr>
|
|
1065
|
+
<td>otherdropped.orgchart</td>
|
|
1066
|
+
<td><code>event.detail</code>: draggedItem, dropZone</td>
|
|
1067
|
+
<td>Fires on the chart when a non-OrgChart draggable item is dropped onto a node.</td>
|
|
989
1068
|
</tr>
|
|
990
1069
|
<tr>
|
|
991
1070
|
<td>init.orgchart</td>
|
|
992
|
-
<td>chart</td>
|
|
993
|
-
<td>
|
|
1071
|
+
<td>None; <code>event.target</code> is the chart element</td>
|
|
1072
|
+
<td>Fires after the chart has been rendered.</td>
|
|
994
1073
|
</tr>
|
|
995
1074
|
<tr>
|
|
996
1075
|
<td>show-[relation].orgchart</td>
|
|
997
1076
|
<td></td>
|
|
998
|
-
<td>
|
|
1077
|
+
<td>Fires on the node when related nodes become visible. <code>relation</code> is parent, children, or siblings.</td>
|
|
999
1078
|
</tr>
|
|
1000
1079
|
<tr>
|
|
1001
1080
|
<td>hide-[relation].orgchart</td>
|
|
1002
1081
|
<td></td>
|
|
1003
|
-
<td>
|
|
1082
|
+
<td>Fires on the node when related nodes are hidden. <code>relation</code> is parent, children, or siblings.</td>
|
|
1004
1083
|
</tr>
|
|
1005
1084
|
</tbody>
|
|
1006
1085
|
</table>
|
|
@@ -1011,9 +1090,9 @@ This use case is inspired by the [issue](https://github.com/dabeng/OrgChart/issu
|
|
|
1011
1090
|
|
|
1012
1091
|
Users can enable/disable exapand/collapse feature with className "noncollapsable" as shown below.
|
|
1013
1092
|
```js
|
|
1014
|
-
|
|
1093
|
+
oc.chart.classList.add('noncollapsable'); // deactivate
|
|
1015
1094
|
|
|
1016
|
-
|
|
1095
|
+
oc.chart.classList.remove('noncollapsable'); // activate
|
|
1017
1096
|
```
|
|
1018
1097
|
|
|
1019
1098
|
#### Why is the root node gone?
|
|
@@ -1022,7 +1101,7 @@ For details, please refer to the [issue](https://github.com/dabeng/OrgChart/issu
|
|
|
1022
1101
|
|
|
1023
1102
|
Users can embed any clear up logics into the click handler of the reset buttton as shown below.
|
|
1024
1103
|
```js
|
|
1025
|
-
|
|
1104
|
+
oc.chart.style.transform = ''; // remove transform settings
|
|
1026
1105
|
```
|
|
1027
1106
|
|
|
1028
1107
|
## Browser Compatibility
|