Skip to content

Commit 5e97bd2

Browse files
Merged css files into one
Added markdown annotations to samples
1 parent 4e53e27 commit 5e97bd2

File tree

87 files changed

+1919
-2048
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+1919
-2048
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Adding new items to chart at runtime
2+
3+
Component is designed to update only visual elements effected by the scope of changed properties. For example on screen annotations positions depend on positions of nodes they are bound to, so when we make changes to on-screen annotations there is no need to redraw diagram nodes. The same applies to other visual elements, chart compares current properties to the new one and in case of changes it triggers rendering of effected visual elements.
4+
5+
Chart does not track individual items, if we add or remove one of them then the whole collection of items is considered to be changed, so control will layout diagram again. But at the same time if we change properties of items not effecting their layout positions, then component will refresh only items content without layout changes. The component is designed to be used in React, so end user may change any API properties on every rendering cycle, the control will check properties and make visual updates in the scope of changed properties only. The point of this statement is that if we assign new items array to items property, but we make no changes to actual items, chart will not perform any layout calculations and rendering, so resulting React virtual DOM of the component will stay the same.
6+
7+
The following example demonstrates adding new items to organizational chart at run time, application keeps state of items collection via adding and deleting nodes. For more complex implementation of chart editing functionality see chart editor demo.
8+
9+
[React](../src/Samples/AddingNewItemsToChartAtRuntime.js)

docs/AdviserAndAssistantItemTypes.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Custom Placement of Children
2+
## Adviser & Assistant Item Types
3+
4+
Organizational Chart items are defined in form of regular hierarchy, so every item may have only one parent. This is conceptually easy to understand for end user who edits organizational chart and software devloper to maintain required structures in database and in application.
5+
6+
In the reality pure hierarchical relations are rare, so organizational chart provides means to represent none hierarchical realations in form of item types and on-screen annotations.
7+
8+
Chart supports following `itemType`s:
9+
10+
* `primitives.orgdiagram.ItemType.Regular`
11+
* `primitives.orgdiagram.ItemType.Adviser`
12+
* `primitives.orgdiagram.ItemType.Assistant`
13+
* `primitives.orgdiagram.ItemType.SubAdviser`
14+
* `primitives.orgdiagram.ItemType.SubAssistant`
15+
* `primitives.orgdiagram.ItemType.GeneralPartner`
16+
* `primitives.orgdiagram.ItemType.LimitedPartner`
17+
* `primitives.orgdiagram.ItemType.AdviserPartner`
18+
19+
All of them control child placement relative to its logial parent in the hierarchy. The following example demonstrates `Adviser` and `Assistant` types. `Adviser` item placed on the side of its logical parent and connected to it horizontally. `Assistant` item is placed at level in between its parent and remaining `Regular` children and horizontally connected to connection line connecting parent and its `Regular` children.
20+
21+
Use `adviserPlacementType` property of `ItemConfig` to place `Adviser` or `Assistant` on the left or right side of the hierarchy
22+
* `primitives.common.AdviserPlacementType.Left`
23+
* `primitives.common.AdviserPlacementType.Right`
24+
25+
[React](../src/Samples/AdviserAndAssistantItemTypes.js)
26+
27+
## Sub Adviser & Sub Assistant item types
28+
29+
Sub Adviser & Sub Assistant item types are variations of regular Adviser & Assistant types. The only difference is they are shift down one level relative to their parents, so they are connected by their top side to the hierarchy.
30+
31+
Use `adviserPlacementType` property to place them on the left or right side of parent's hierarchy as well.
32+
33+
[React](../src/Samples/SubAdviserAndSubAssistantItemTypes.js)

docs/Buttons.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Buttons panel
2+
3+
Component provides options to preserve some space around nodes to render custom controls or buttons. Buttons rendered in diagram layout provides better UI discoverability compared to context popup panel.
4+
5+
Buttons panel visibility can be enabled at component scope with `hasButtons` property:
6+
* `primitives.common.Enabled.Auto` - Buttons visible only for cursor item.
7+
* `primitives.common.Enabled.True` - Every normal item has buttons visible.
8+
* `primitives.common.Enabled.False` - No buttons.
9+
10+
Buttons panel visibility can be enabled individually per `ItemConfig` with similar 'hasButtons' property:
11+
* `primitives.common.Enabled.Auto` - Buttons panel visibility depends on component scope `hasButtons` value.
12+
* `primitives.common.Enabled.True` - Has buttons visible.
13+
* `primitives.common.Enabled.False` - No buttons panel.
14+
15+
The size of the buttons panel set in component `Config` `buttonsPanelSize` property. It is regular numeric value in `px`.
16+
17+
Buttons panel content can be customized per component or per item template with `onButtonsRender` callback function. See item template definition in the following example:
18+
19+
Please, pay attention that every button `onClick` event handler suppresses even propogation, it is needed to avoid chart cursor item change and following layout
20+
21+
```JavaScript
22+
onClick={(event) => {
23+
event.stopPropagation();
24+
alert(`User clicked on Coffe button for node ${itemConfig.title}`)
25+
}}>
26+
```
27+
28+
[React](../src/Samples/ButtonsPanel.js)

docs/ChildrenLayout.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Regular Children Layout
2+
3+
Children Placement Layout can be defined individually per item or globally for all chart items. Following component and individual items properties are used to define layout of the children:
4+
5+
* `childrenPlacementType` - this property is available for chart and for individual items, it defines shape of children with enumeration `primitives.common.ChildrenPlacementType` it provides following options `Vertical`, `Horizontal` & `Matrix`
6+
* `leavesPlacementType` - this option is available only at component scope and it is used to control children layout having no sub children, so it is only for children of the last level in hierarchy.
7+
* `maximumColumnsInMatrix` - by default children in matrix are shaped into square, in order to form them into rectangular shape you have to limit maximum number of columns in matrix, so rectangular shape would grow vertically.
8+
9+
In general children layouts are all matrix, the only difference is that horizontal layout has only one row and vertical layout has only one column.
10+
11+
The `maximumColumnsInMatrix` value should limit children matrix growth outside of the view port width, in order to avoid the necessety of simultanious horizontal and vertical scrolling of nodes. Keeping square shape of nodes is good for small matrixes which easely fit into view port, but large groups of children are better shaped into wide columns.
12+
13+
[React](../src/Samples/ChildrenPlacementType.js)

docs/ConnectorAnnotation.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Connector Annotations
2+
3+
Connector annotation is on screen direct connection line between two nodes of diagram. Use them the same way as highlight markers for temporary or per transaction drawings over diagram nodes. See following example for how it works:
4+
5+
## Styles
6+
Connector annotations are drawn on top of exisiting diagram, so sometimes space between nodes is not enough to fit annotation label and arrow, so for this case connector annotation supports offbeat style of drawing, so instead of straight line connecting two nodes, the connector is drawn as free hand spline on side of them.
7+
* `primitives.common.ConnectorPlacementType.Offbeat` - Free hand drawing of connector annotation
8+
* `primitives.common.ConnectorPlacementType.Straight` - Straight line between nodes
9+
10+
## Shapes
11+
In general shape of connector annotation may indicate various business relations, so component supports following simple use case:
12+
* `primitives.common.ConnectorShapeType.OneWay` - The arrow line between `fromItem` and `toItem` nodes
13+
* `primitives.common.ConnectorShapeType.TwoWay` - Two opposite direction arrow lines between `fromItem` and `toItem` nodes
14+
* `primitives.common.ConnectorShapeType.BothWay` - One line having arrows on both ends
15+
16+
The more complex use cases can be built with multiple connector annotations originating from the same `fromItem` and `toItem` nodes. Component supports simple conflict resolution, for example in the above mentioned case if multiple straight line connectors overlap each other, the diagram will try to offset them and draw side by side in parallel.
17+
18+
## Labels
19+
Connector annotations labels are defined as a plane text or JSX elements. Please, pay attention that component does not resolve connector annotations labels overlapping, so large number of labels can clutter view and diagram in general.
20+
21+
[React](../src/Samples/ConnectorAnnotation.js)

docs/CursorTemplate.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Cursor template
2+
The diagram in general is collection component, so it supports concept of current cursor item, which enables navigation related functionality. The current cursor item is supposed to have visual feedback on diagram, by default it is solid `2px` wide border line around it. The general idea about cursor template is to provide convenient API to customize that border line around cursor item.
3+
4+
## Properties:
5+
Component customizes visual representaion of items with `templates`, every template has customization properties for item content, cursor and highlight visualizations. By default if properties are not set then component uses built in default functionality. The following properties customize cursor template:
6+
* `cursorPadding` - Reserves space around item, for example: `{left: 3, top: 3, right: 50, bottom: 3}` will provide extra `50px` on right side of item for sursor content.
7+
* `cursorBorderWidth` - some sort of legacy property, it is used to align cursor position around item properly.
8+
* `onCursorRender` - callback method to render cursor content for given item of diagram
9+
10+
See Item template for more details.
11+
12+
```JavaScript
13+
onCursorRender: ({ context: itemConfig }) => {
14+
return <div style={{ borderColor: itemConfig.badgeColor }} />;
15+
}
16+
```
17+
18+
## Cursor item & preserving space for context control panel
19+
The conventional approach is to place controls for current cursor item in diagram in the panel on the side of the diagram and change its content as user navigates from item to item, this approach takes a cut of screen space out of the diagram layout. The similar approach is to draw context menu panel on top of the diagram on the side of the cursor item, but this obstructs view of other diagram nodes. The compromise UI design is to expand space around cursor node and place context controls into that space, so cursor template provides `cursorPadding` property to preserve that required space around cursor node.
20+
21+
```JavaScript
22+
<OrgDiagram config={{
23+
cursorPadding: {left: 3, top: 3, right: 50, bottom: 3}
24+
}} />
25+
```
26+
27+
## Avoiding conflicts between custom controls & annotations
28+
User controls in cursor item template plays a role of in-layout annotation, non-blocking neighboring items in diagram. In case when every full size item is supposed to have UI controls then item template should be customized instead. Use `z-index` style attribute to layer controls properly, otherwise they can be blocked by annotations. Ideally only cursor item should have controls inside, so annotations will not be drawn over edit boxes or drop down combo boxes. If you draw connector annotations only for current cursor item, then you avoid conflicts with annotations.
29+
30+
Every time we change cursor node control recalculates layout, so this slows down rendering of large diagram. Our design view on this problem is to limit number of simultaneously shown nodes in diagram. Control provides default mechanism to reduce nodes into dots, but general approach is to replace groups of diagram nodes with single node and expand them as user moves cursor close to them. This kind of design approach is implemented in Dynamic Data Loading demo.
31+
32+
## Custom cursor template border
33+
The following example demonstrates how to create custom cursor border having item specific color and tag element.
34+
35+
[React](../src/Samples/CursorTemplate.js)
36+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Custom layout with Invisible items
2+
Organizational chart navigation is defined by parent-children relations between items. When user selects cursor item, component shows all its neighbours i.e. children, parents and siblings in full size, so user can proceed navigation from item to item in diagram. The invisible items are not shown in layout so they cannot be shown in full size, so chart shows all neighbours of invisible items in full size instead. This feature combined with custom item types and children layouts provides great flexibility to visualize various logical parent child relations.
3+
4+
Following example demonstrates how to use invisible items to display multiple groups of children attached to one parent item. It has two rows of assistants and two levels of children. In order to implement this layout we create two invisible items of regular item type. Children of invisible items logically belong to their parent in our case it is root item of organizational chart, so when cursor is set to root then all items in chart become selected and displayed in full size, so user may navigate to any of them directly.
5+
6+
See custom item types, children layout and inactive items samples as well.
7+
8+
[React](../src/Samples/CustomLayoutWithInvisibleItems.js)
9+
10+
## Skipped Levels
11+
12+
Invisible items can be used to skip levels in organizational chart. This is actually workaround, invisible items occupy space, so they can be used to shift children items down one level relative to their parents. See `primitives.orgdiagram.ItemConfig.isVisible` property.
13+
14+
[React](../src/Samples/SkippedLevels.js)
15+

docs/DiagramSizing.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Diagram Sizing
2+
## Responsive Design
3+
Like any other Data Visualization component it combines scalable and non-scalable graphics elements. For example we would like to show 10'000 labels but it is just physically impossible to fit them, because their total square size is multiple times bigger than available screen space. At the same time we cannot scale all of them down to points, since they become simply unreadable. Try to disable "fit to page" for large hierarchy demo, the resulting diagram is going to be so big that its visualization makes no sense, this rendering mode is useful only for PDF generation for reporting purposes only. If we speak about BI applications designed for data analysis then we need to show nodes only in the scope of current user focus of interest, so diagramming applications should be dynamic and adopt to user data and requirements. Another argument in favour of diagramming applications having auto layout is the fact that in large organizations where we have over 500 people the rate of changes is so high that any organizational structure becomes obsolete as soon as we make its hard copy. So we use various strategies to show as mush data as possible to the user within available screen space, so control needs to be notified about its placeholder size changes in order to trigger rendering cycle.
4+
5+
## Diagram placeholder sizing is applications responsibility
6+
Component occupies all available space inside parent `div`, so if application changes size of `div` containing diagram component it triggers component state change and following rendering cycle. Component uses [`resize-observer-polyfill`](https://www.npmjs.com/package/resize-observer-polyfill) to handle diagram size change.
7+
8+
## Component Sizing with CSS @Media
9+
The main point of CSS @Media based control sizing is to keep diagram component size less than screen size. We want to have diagram to be as large as possible, but we need to avoid situation when user has to scroll diagram and page srollbars altogether in order to see diagram content. The first image shows unusable scroll bars.
10+
11+
![Unusable scrollbars](./images/PageSizeDiagram1.png "Unusable scrollbars")
12+
13+
Having scroll bars enabled for components is fine if they fit into the page view port. So we can place diagram component and stack it verticaly with other components on the page. The following image shows 2 components having scrollable content, both of them are usable, since user can scroll them into the current view port and work with their content scrollbars individually.
14+
15+
![Usable control scrollbars](./images/PageSizeDiagram2.png "Usable control scrollbars")
16+
17+
The "classic" and the most popular approach for desktop applications is to fit page and diagram 100%. In that case you have to design your web site appropriatly.
18+
19+
![Classic desktop layout](./images/PageSizeDiagram2.png "Classic desktop layout")
20+
21+
The following sample control hight is sized by CSS @Media rules to be within current page view port size. Try to resize your browser window in order to see how it works. The diagraming component has minimum vertical size set to hardcoded 250px.
22+
23+
See [CSS @Media](https://developer.mozilla.org/en-US/docs/Web/CSS/@media) for more reference
24+
25+
[Sample of diagram size controlled by CSS @Media](../src/Samples/PageSizeDiagram.js)
26+
27+
## Auto Size Diagram in Article
28+
Another diagram integration scenario is diagram placement inside article, so component needs to auto expand its size in order to accommodate all nodes of diagram without minimization or trancation. Set `pageFitMode` to `primitives.common.PageFitMode.AutoSize` and component will size itself to show all nodes of diagram.
29+
30+
Use following options to constrain component auto size:
31+
32+
* `autoSizeMinimum` - it limits minimal size of diagram, so if it is empty then you are going to see empty `div` of this size.
33+
* `autoSizeMaximum` - does not allow to grow component beyond this size. Set maximum size to some value if you need to avoid humongous diagram on your page.
34+
35+
for example in order to set widget minimal size:
36+
37+
```JavaScript
38+
<OrgDiagram centerOnCursor={true} config={{
39+
autoSizeMinimum: new primitives.common.Size(800, 600),
40+
autoSizeMaximum: new primitives.common.Size(1024, 768)
41+
// other properties
42+
}} />
43+
```
44+
45+
[React](../src/Samples/AutoSize.js)

docs/FamilyChartItemsOrdering.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Family diagram items ordering
2+
Family diagram supports multiple parents and children per node, so there is no deterministic way to define groups of items and their order inside of the group, so family diagram provides non-determenistic API to order items. That means if items expected to be in one layout group then user can use following properties to guide layout engine about user preferred relative order of items:
3+
4+
1. `relativeItem` - item position and placement type defined relative to this property referenced item
5+
2. `placementType` - item placement on the left or right side of relative item. Property has following values:
6+
* `primitives.common.AdviserPlacementType.Left`
7+
* `primitives.common.AdviserPlacementType.Right`
8+
3. `position` - if several items reference the same `relativeItem` and placement then this `position` property defines order of them.
9+
10+
This relative optional ordering approach gives none ordered nodes to be placed optimally, so if item has no relative item defined then layout engine will try to find the best place for it based on its relations.
11+
12+
Please, pay attention that loops in references are completely ignored, so don't create mutual references between items.
13+
14+
## Family Items Ordering Sample
15+
16+
[React](../src/Samples/FamilyChartItemsOrdering.js)
17+
18+
## Multiple Families Ordering Sample
19+
20+
[React](../src/Samples/MultipleFamiliesOrdering.js)

0 commit comments

Comments
 (0)