forked from BALKANGraph/OrgChartJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorgchart.d.ts
More file actions
1766 lines (1486 loc) · 37.1 KB
/
Copy pathorgchart.d.ts
File metadata and controls
1766 lines (1486 loc) · 37.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
declare namespace OrgChart {
enum orientation {
top,
left,
right,
bottom,
top_left,
bottom_left,
right_top,
left_top
}
enum action {
/**
* mouseScrool value
*/
zoom,
/**
* mouseScrool value
*/
xScroll,
/**
* mouseScrool value
*/
yScroll,
/**
* nodeMouseClick value
*/
edit,
/**
* nodeMouseClick and nodeMouseDbClick value
*/
details,
/**
* nodeMouseClick and nodeMouseDbClick value
*/
expandCollapse,
/**
* nodeMouseClick, nodeMouseDbClick and mouseScrool value
*/
none,
update,
centerNode
}
enum scroll {
visible,
}
enum match {
height,
width,
boundary
}
enum anim {
inPow,
outPow,
inOutPow,
inSin,
outSin,
inOutSin,
inExp,
outExp,
inOutExp,
inCirc,
outCirc,
inOutCirc,
rebound,
inBack,
outBack,
inOutBack
}
// enum templates {
// base,
// ana,
// group_orange,
// group_yellow,
// group_grey,
// group_grey_one_column,
// ula,
// olivia,
// belinda,
// rony,
// mery,
// polina,
// mila,
// diva,
// luba,
// derek,
// isla,
// deborah
// }
const templates: any;
const icon: any;
const none: any;
const CENTER: any;
const ORIENTATION: any;
const COLLAPSE: any;
const EXPAND: any;
const COLLAPSE_PARENT_NEIGHBORS: any;
const COLLAPSE_SUB_CHILDRENS: any;
const normal: any;
const mixed: any;
const tree: any;
const treeLeftOffset: any;
const treeRightOffset: any;
const slinkTemplates: any;
}
interface Menu {
add?: Object,
edit?: Object,
details?: Object,
remove?: Object,
svg?: Object,
pdf?: Object,
png?: Object,
csv?: Object,
addInGroup?: Object,
addAsChild?: Object,
[name: string]: Object,
}
interface TagsProps {
state?: OrgChart, /** OrgChart.COLLAPSE or OrgChart.EXPAND */
group?: Boolean,
groupName?: String,
groupState?: OrgChart, /** OrgChart.COLLAPSE or OrgChart.EXPAND */
template?: string,
nodeMenu?: Object,
}
interface Tags {
[name: string]: TagsProps,
}
interface OrgChartOptions {
/**
* Lazy loading is technique that defers loading of non-critical nodes at page load time. Instead, these non-critical nodes are loaded at the moment of need.
* Default value: true
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
lazyLoading: true;
});
```
*/
lazyLoading?: boolean,
/**
* Enables advanced search.
Default value: true
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
enableSearch: true,
});
```
*/
enableSearch?: boolean,
/**
* Specifies the orientation of the OrgChart JS. could accept one of the following values:
- OrgChart.orientation.top
- OrgChart.orientation.bottom
- OrgChart.orientation.right
- OrgChart.orientation.left
- OrgChart.orientation.top_left
- OrgChart.orientation.bottom_left
- OrgChart.orientation.right_top
- OrgChart.orientation.left_top
Default value: OrgChart.orientation.top
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
orientation: OrgChart.orientation.bottom
});
```
*/
orientation?: OrgChart.orientation,
/**
* mouseScrool can accept the following values:
- OrgChart.action.zoom - will zoom in/out on mouse scroll
- OrgChart.action.xScroll - left/right move of the chart on mouse scroll
- OrgChart.action.yScroll - up/down move of the chart on mouse scroll
- OrgChart.action.none - do nothing on mouse scroll
Default value: OrgChart.action.zoom
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
mouseScrool: OrgChart.action.zoom
});
```
*/
mouseScrool?: OrgChart.action,
/**
* Node binding in OrgChart JS maps node data to node template parameters.
Code example:
```
var chart = new OrgChart(document.getElementById("orgchart"), {
nodeBinding: {
field_0: "name"
},
nodes: [
{ id: 1, name: "Amber McKenzie" },
{ id: 2, pid: 1, name: "Ava Field" },
{ id: 3, pid: 1, name: "Peter Stevens" }
]
});
```
In the example above the field name will be bount to field_0 from the template.
Also you can define your own field in the templae, for more information go to Fields page on our website.
*/
nodeBinding?: Object,
/**
* With the drag and drop features of OrgChart, you can move nodes easily.
* Default value: true
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
enableDragDrop: true,
});
```
*/
enableDragDrop?: boolean,
enableTouch?: boolean,
/**
* Enables edit, add, remove and other node operations. Also you can define your own node operation for more information see Node Menu Item
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
nodeMenu:{
details: {text:"Details"},
edit: {text:"Edit"},
add: {text:"Add"},
remove: {text:"Remove"}
},
});
```
*/
nodeMenu?: Menu,
/**
* Context menu. Also you can define your own node operation for more information see Menu
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
nodeContextMenu:{
details: {text:"Details"},
edit: {text:"Edit"},
add: {text:"Add"},
remove: {text:"Remove"}
},
...
});
```
*/
nodeContextMenu?: Menu,
/**
* Use dragDropMenu with drag & drop and grouping feature.
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
dragDropMenu: {
addInGroup: { text: "Add in group" },
addAsChild: { text: "Add as child" }
},
});
```
*/
dragDropMenu?: Menu,
/**
* Enables export to excel, export to svg and other OrgChart operations. Also you can define your own OrgChart operation for more information see OrgChart.ImportFormCSV
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
menu: {
svg: { text: "Export SVG" },
csv: { text: "Export CSV" }
},
});
```
*/
menu?: Menu,
/**
* A toolbar is a set of icons or buttons.
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
toolbar: {
layout: true,
zoom: true,
fit: true,
expandAll: false
},
...
});
```
*/
toolbar?: Object,
/**
* Stop the org chart locking to the top of the screen once you move it.
Default value: true
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
sticky: false
...
});
```
*/
sticky?: boolean,
/**
* nodeMouseClick can accept the following values:
- OrgChart.action.edit - will open the edit view for the clicked node on the right hand side
- OrgChart.action.details - will open the details view for the clicked node on the right hand side, the details view is very similar to the edit view the only difference is that is read only.
- OrgChart.action.expandCollapse - will expand or collapse the children nodes
- OrgChart.action.none - do nothing on node click event
Default value: OrgChart.action.details
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
nodeMouseClick: OrgChart.action.edit
});
```
*/
nodeMouseClick?: OrgChart.action,
/**
* nodeMouseDbClick can accept the following values:
- OrgChart.action.edit - will open the edit view for the clicked node on the right hand side
- OrgChart.action.details - will open the details view for the clicked node on the right hand side, the details view is very similar to the edit view the only difference is that is read only.
- OrgChart.action.expandCollapse - will expand or collapse the children nodes
- OrgChart.action.none - do nothing on node double click event
Default value: OrgChart.none
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
nodeMouseDbClick: OrgChart.action.edit
...
});
```
*/
nodeMouseDdClick?: OrgChart.action,
/**
* showXScroll can accept the following values:
- OrgChart.none
- OrgChart.scroll.visible - Will display horisontal scroll bar
Default value: OrgChart.none
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
showXScroll: OrgChart.scroll.visible
});
```
*/
showXScroll?: OrgChart.scroll,
/**
*
* showYScroll can accept the following values:
- OrgChart.none
- OrgChart.scroll.visible - Will display vertical scroll bar
Default value: OrgChart.none
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
showYScroll: OrgChart.scroll.visible
});
```
*/
showYScroll?: OrgChart.scroll,
/**
Set template if you want to change the appearance of the chart. OrgChart JS comes with number of build-in templates:
- ana
- ula
- olivia
- belinda
- rony
- mery
- polina
- mila
- diva
- luba
- derek
- base
- deborah
Also you can define your own template. For more information see Creating Custom Template
Default value: ana
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
template: "derek"
});
```
*/
template?: string,
/**
* With tags option you can:
- Set specific template for tagged nodes
- Set the default state (expand/collapse) for tagged nodes
- Define a group for tagged nodes
- Set node as assistant for tagged nodes
- Set node menu items for tagged nodes
Set specific template for tagged nodes. See Multiple Templates in one chart for more details.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
tags: {
Management: {
template: "rony"
}
},
nodes: [
{ id: 1, tags: ["Management"] },
]
});
```
Set the default state (expand/collapse) for tagged nodes. See Expand/Collapse for more details.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
tags: {
hide: {
state: OrgChart.COLLAPSE
}
},
nodes: [
{ id: "1" },
{ id: "2", tags: ["hide"] },
{ id: "3" }
]
});
```
Define a group for tagged nodes. See Grouping for more details.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
tags: {
HRs: {
group: true,
groupName: "HR Team",
groupState: OrgChart.EXPAND,
template: "group_grey"
}
},
nodes: [
{ id: 1, tags: ["HRs"] }
]
});
```
Set node as assistant for tagged nodes. See Assistant for more details.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
tags: {
assistant: {
template: "mery"
}
},
nodes: [
{ id: 1, tags: ["assistant"] }
]
});
```
Set node menu items for tagged nodes. See Node Menu Item for more details.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
tags:
customMenuItems: {
nodeMenu: {
add: { text: "Add New" }
}
}
},
});
```
*/
tags?: Tags,
/**
* Link binding in OrgChart JS maps node data to link template parameters.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
linkBinding: {
link_field_0: "createdAt"
},
nodes: [
{ id: "1", name: "Amber McKenzie" },
{ id: "2", pid: "1", createdAt: "Since 08/08/2018" },
{ id: "3", pid: "1", createdAt: "Since 05/04/2018" }
]
});
```
*/
linkBinding?: Object,
/**
* Search by the fields defined in searchFields.
Default value: Empty array
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
searchFields: ["name", "title", etc...],
...
});
```
*/
searchFields?: Array<string>,
/**
* Array of node data JSON objects. nodes option is the data source of the chart.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
nodes: [
{ id: "1" },
{ id: "2", pid: "1" },
{ id: "3", pid: "1", tags: ["Sales"] }
]
});
```
Node JSON objects could have unlimited number of properties, id, pid and tags are reserved node properties.
- id - unique identifier, it clould be integer or string
- pid - is the parent id
- tags - array of strings
*/
nodes?: Array<Object>,
/**
* Add C link.
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById('tree'), {
clinks: [
{from: 4, to: 0, label: 'text'},
{from: 4, to: 5, template: 'blue', label: '4 reports to 5' },
{from: 2, to: 6, template: 'yellow', label: 'lorem ipsum' },
]
...
});
```
*/
clinks?: Array<Object>,
/**
* Add S link.
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById('tree'), {
slinks: [
{from: 4, to: 0, label: 'text'},
{from: 4, to: 5, template: 'blue', label: 'reports to' },
{from: 2, to: 6, template: 'yellow', label: 'lorem ipsum' },
]
...
});
```
*/
slinks?: Array<Object>,
/**
* The gap between each level.
Default value: 60
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
levelSeparation: 50
});
```
*/
levelSeparation?: number,
/**
* The gap between nodes in a subtree.
Default value: 20
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
siblingSeparation: 50
});
```
*/
siblingSeparation?: number,
/**
* The gap between subtrees.
Default value: 40
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
subtreeSeparation: 50
});
```
*/
subtreeSeparation?: number,
/**
* The gap between nodes in vertical layout.
Default value: 20
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
mixedHierarchyNodesSeparation: 5
});
```
*/
mixedHierarchyNodesSeparation?: number,
/**
* The padding option sets the padding area on all four sides of the OrgChart.
Default value: 30
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
padding: 20
});
```
*/
padding?: number,
/**
* The layout of the OrgChart
- OrgChart.normal
- OrgChart.mixed
- OrgChart.tree
- OrgChart.treeLeftOffset
- OrgChart.treeRightOffset
Default value: OrgChart.normal
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
layout: OrgChart.mixed
});
```
*/
layout?: OrgChart,
/**
* The scale factor determines what fraction of the entire scale is visible at one time.
- OrgChart.match.height
- OrgChart.match.width
- OrgChart.match.boundary
- [float]
Default value: 1
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
scaleInitial: 0.5
});
```
For more information go to Layout page on our website.
*/
scaleInitial?: OrgChart.match | number,
/**
* Determines the minimum scale factor.
Default value: 0.1
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
scaleMin: 0.2
});
```
*/
scaleMin?: number,
/**
* Determines the naximum scale factor.
Default value: 5
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
scaleMax: 10
});
```
*/
scaleMax?: number,
/**
* The orderBy option is used to sort the nodes in ascending order by specified field. The default order is by nodes order in the nodes array.
Default value: null
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
...
orderBy: "orderId",
nodes: [
...
{ id: 10, pid: 1, orderId: 2 },
{ id: 11, pid: 1, orderId: 1 }
...
]
});
```
In the example above node with id 11 will be before node with id 10. orderBy can be set to any property from the node JSON object, string or integer.
*/
orderBy?: string,
editUI?: Object,
searchUI?: Object,
xScrollUI?: Object,
yScrollUI?: Object,
nodeMenuUI?: Object,
nodeContextMenuUI?: Object,
toolbarUI?: Object,
notifierUI?: Object,
dragDropMenuUI?: Object,
menuUI?: Object,
/**
* The URL to the export server.
Default value: https://balkangraph.com/export
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
exportUrl: "https://balkangraph.com/export",
...
});
```
*/
exportUrl?: string,
/**
* Collapse specified level of the chart and its children if allChildren is true.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
collapse: {
level: 2,
allChildren: true
},
...
});
```
*/
collapse?: Object,
/**
* Expand specified node ids and its children if allChildren is true.
The expand option works only if collapse is set.
In the example above the second level of the chart will be collapsed but node with id 155 and its children will be expanded.
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
collapse: {
level: 2,
allChildren: true
},
expand:{
nodes: [155],
allChildren: true
}
...
});
```
*/
expand?: Object,
/**
* The align option specifies the alignment of the nodes inside OrgChart JS.
Default value: OrgChart.CENTER
- OrgChart.CENTER - centered
- OrgChart.ORIENTATION - according to the orientation option
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
align: OrgChart.ORIENTATION,
...
});
```
*/
align?: OrgChart,
UI?: OrgChart,
/**
*Can be used to control the transition of the nodes on expand/collapse operation.
Default value: func: OrgChart.anim.outPow, duration: 200
duration: defines how long time an animation should take to complete
func: Easing functions specify the speed at which an animation progresses at different points within the animation. Can accept one of the following values:
- OrgChart.anim.inPow
- OrgChart.anim.outPow
- OrgChart.anim.inOutPow
- OrgChart.anim.inSin
- OrgChart.anim.outSin
- OrgChart.anim.inOutSin
- OrgChart.anim.inExp
- OrgChart.anim.outExp
- OrgChart.anim.inOutExp
- OrgChart.anim.inCirc
- OrgChart.anim.outCirc
- OrgChart.anim.inOutCirc
- OrgChart.anim.rebound
- OrgChart.anim.inBack
- OrgChart.anim.outBack
- OrgChart.anim.inOutBack
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
anim: {
func: OrgChart.anim.outBack,
duration: 500
},
...
});
```
*/
anim?: Object,
/**
* Can be used to control the zooming sensitivity.
Default value: speed: 120, smooth: 12
Code example:
```
var chart = new OrgChart(document.getElementById("tree"), {
zoom: {
speed: 130,
smooth: 10
},
...
});
```
*/
zoom?: Object,
roots?: Array<number>,
onUpdate?: string,
onRemove?: string,
onAdd?: string,
onRedraw?: string,
onImageUploaded?: string,
onUpdateTags?: string,
onClick?: ((sender: OrgChart, event: NodeEvent<MouseEvent>) => boolean),
onDbClick?: string,
onExpCollClick?: string,
onExportStart?: string,
onExportEnd?: string,
onSearchClick?: string,
onReady?: string
}
interface NodeEvent<T> {
node: Object
event: T
}
declare class OrgChart {
constructor(element: HTMLElement, options: OrgChartOptions);
/**
* Updates the node JSON object.
Signature:
```
chart.updateNode(nodeJSONdata);
```
Parameters:
- nodeJSONdata - node json data
Code example:
```
chart.updateNode({ id: 4, pid: 2, name: "Updated Name", title: "Updated Title" });
```
Will update the node with id 4 and will redraw the chart.
* @param nodeJSONdata
*/
updateNode(nodeJSONdata: Object): void;
/**
* Updates the node JSON object.
Signature:
```
chart.update(nodeJSONdata);
```
Parameters:
- nodeJSONdata - node json data
Code example:
```
chart.update({ id: 4, pid: 2, name: "Updated Name", title: "Updated Title" });