Skip to content

JavaScript Organogram

JavaScript Components

The jSuites Organogram is a lightweight and flexible JavaScript plugin that allows developers to create interactive organogram charts from JSON data. It provides essential features such as navigation controls, zoom functionality, event handling, and support for programmatically triggered actions.

  • Navigation controls
  • Zoom functionality
  • Event handling
  • Programmatic actions
  • Build organogram charts directly from JSON objects

Below are the key methods available for customizing and controlling the jSuites Organogram.

MethodDescription
refresh()Resets the organogram chart to its initial state.
addItem(item: object)Appends a new item to the organogram chart.
@param {object} item - Item object to be added.
removeItem(item: object)Removes an item from the organogram chart.
@param {object} item - Item object to be removed.
show(id: int)Shows or hides children of an organogram item.
@param {number} id - Item ID.
search(query: string)Searches for a specific item in the organogram chart.
@param {string} query - Search term.
setDimensions(width: number, height: number)Defines the dimensions of the organogram container.
@param {number} width
@param {number} height

The JavaScript Component provides the following events, allowing developers to respond to user interactions and changes in the organogram.

EventDescription
onloadFired when the component is loaded.
onload(DOMElement element, Object obj) => void
onchangeFired when an item is added to the chart.
onchange(DOMElement element, Object obj) => void
onclickFired when an element is clicked.
onclick(DOMElement element, Object obj, DOMEvent e) => void

The following settings allow you to customize the behaviour and appearance of the jSuites Organogram.

PropertyDescription
url: stringLoads data from an external file.
data: mixedData to be rendered in the organogram.
zoom: intControls zoom speed on the mouse wheel. Defaults to 0.1.
vertical: booleanEnables or disables vertical view. Defaults to false.
width: numberSets the organogram container width.
height: numberSets the organogram container height.
search: booleanEnables or turns off the search input. Defaults to true.
searchPlaceHolder: stringDefines a placeholder for the search input field.

This example demonstrates how to create a basic organogram using the jSuites Organogram plugin. The data for the organogram is sourced from an external JSON file, and the chart is configured with a vertical layout.

<html>
<script src="https://jsuites.net/v6/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v6/jsuites.css" type="text/css" />
<script src="https://cdn.jsdelivr.net/npm/@jsuites/organogram/organogram.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@jsuites/organogram/organogram.min.css" type="text/css" />

<div id='organogram'></div>

<script>
organogram(document.getElementById('organogram'), {
    width: 460,
    height: 420,
    url: '/plugins/organogram.json',
    vertical: true,
});
</script>
</html>