This project is a classic organization chart, with employees arranged in a hierarchy, with an inspector for the selected employee, allowing you to see and edit further details.
The organization chart demonstrates:
- Using React components to render vertices in your data set
- The Hierarchy layout, which positions vertices in a hierarchy, oriented either vertically or horizontally
- The
useZoomhook, to render different content based on the current zoom level - Inspectors - automatically wire up forms for editing the vertices in your dataset.
- The Miniview component, which provides an interactive miniaturized view of the contents of the canvas
The application is built using several core components from @visuallyjs/browser-ui-react:
SurfaceProvider: Provides the context and state management for the chart.SurfaceComponent: The main canvas area where the organizational structure is rendered.MiniviewComponent: Provides a navigation map for exploring large organizational structures.ControlsComponent: Standard zoom and pan controls.useZoomHook, for hiding/showing content based on zoom level.
PersonComponent: A custom JSX component for rendering individual employees, including their name, role, and avatar.OrgchartInspector: A property editor and search component for finding and selecting individuals within the organization.
renderOptions: Configures the underlying VisuallyJS surface, including node and edge styles.viewOptions: Maps the "person" node type to the customPersonComponentfor JSX rendering.
The chart features interactive selection: when a person is selected in the inspector, the application programmatically centers the view on that person and zooms in using the centerOnAndZoom method of the surface.
The useZoom hook is used to show extra details about each user when the zoom level is greater than 1.
- VisuallyJS Core: The core styles are included in
src/index.cssvia@import "@visuallyjs/browser-ui/css/visuallyjs.css";. - App Styles: Custom styles for the employee cards and the organizational layout are imported from
orgchart.css.