diff --git a/src/views/organizationchart/OrganizationChartDemo.vue b/src/views/organizationchart/OrganizationChartDemo.vue
index a152b2b5e..7e9986f19 100644
--- a/src/views/organizationchart/OrganizationChartDemo.vue
+++ b/src/views/organizationchart/OrganizationChartDemo.vue
@@ -8,8 +8,7 @@
-
Advanced
-
Hierarchical data with zero configuration.
+
Advanced
@@ -25,7 +24,6 @@
Basic
-
Hierarchical data with zero configuration.
{{slotProps.node.data.label}}
@@ -227,6 +225,4 @@ export default {
color: #8a0a39 !important;
}
}
-
-
\ No newline at end of file
diff --git a/src/views/organizationchart/OrganizationChartDoc.vue b/src/views/organizationchart/OrganizationChartDoc.vue
index 14100199b..163c40727 100644
--- a/src/views/organizationchart/OrganizationChartDoc.vue
+++ b/src/views/organizationchart/OrganizationChartDoc.vue
@@ -4,56 +4,344 @@
Import
-import Panel from 'primevue/panel';
+import OrganizationChart from 'primevue/organizationchart';
Getting Started
- Panel is a container component that accepts content as its children.
+ OrganizationChart requires an OrganizationChartNode instance as its root value and at least one template to display node content where node instance is passed via slotProps.
-<Panel header="Godfather I">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
-</Panel>
-
-
- Custom Header
- Header of the panel is either defined with the header property or the header template.
-
-<Panel>
- <template #header>
- Header Content
+
+ <OrganizationChart :value="data">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
</template>
- Content
-</Panel>
+</OrganizationChart>
+
- Toggleable
- Content of the panel can be expanded and collapsed using toggleable option.
-
-<Panel header="Godfather I" :toggleable="true">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
-</Panel>
+
+export default {
+ data() {
+ return {
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
- To control the initial state of the toggleable panel, use the collapsed property.
+ OrganizationChartNode
+ API of the OrganizationChartNode has the properties below.
+
+
+
+
+ Name |
+ Type |
+ Default |
+ Description |
+
+
+
+
+ key |
+ any |
+ null |
+ Unique identifier of the node. (required) |
+
+
+ type |
+ string |
+ null |
+ Type of the node to match a template. |
+
+
+ styleClass |
+ string |
+ null |
+ Style class of the node content. |
+
+
+ data |
+ any |
+ null |
+ Data represented by the node. |
+
+
+ selectable |
+ boolean |
+ true |
+ Whether node is selectable when selection is enabled. |
+
+
+ children |
+ array |
+ null |
+ Children nodes array. |
+
+
+
+
+
+ Collapsible Nodes
+ All nodes are expanded by default however they can be expanded and collapsed when collapsible is enabled. The optional collapsedKeys property defines the keys
+ that are collapsed, this property is two-way binding enabled so that user changes or programmatic changes are reflected to the UI.
+
+ Example below displays the root of chart in previous example as collapsed. Notice that the collapsedKeys is a map whose key is the
+ key of the node and value is true.
+
-<Panel header="Header Text" :toggleable="true" :collapsed="true">
- Content
-</Panel>
+
+ <OrganizationChart :value="data" :collapsible="true" :collapsedKeys="collapsedKeys">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
- Use the sync operator to enable two-way binding.
+
+export default {
+ data() {
+ return {
+ collapsedKeys: {
+ '0': true
+ },
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+ Selection
+ Selection is enabled by defining the selectionMode to either "single" or "multiple" and specifying the selectionKeys with the sync operator. Note that
+ selection on a particular node can be disabled if the selectable is false on the node instance.
+
+
+ <OrganizationChart :value="data" selecionMode="single" :selectionKeys.sync="selectionKeys">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ selectionKeys: null,
+ data: {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+}
+
+
+ Templating
+ The type property of an OrganizationChartNode is used to map a template to a node. If it is undefined, the default template is used.
-<button type="button" @click="isCollapsed = !isCollapsed">Toggle Programmatically</button>
-<Panel header="Header Text" :toggleable="true" :collapsed.sync="isCollapsed">
- Content
-</Panel>
+
+<OrganizationChart :value="data">
+ <template #person="slotProps">
+ <div class="node-header ui-corner-top">{{slotProps.node.data.label}}</div>
+ <div class="node-content">
+ <img :src="'demo/images/organization/' + slotProps.node.data.avatar" width="32">
+ <div>{{slotProps.node.data.name}}</div>
+ </div>
+ </template>
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+</OrganizationChart>
+
+
+
+
+export default {
+ data() {
+ return {
+ data: {
+ key: '0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CEO', name: 'Walter White', avatar: 'walter.jpg'},
+ children: [
+ {
+ key: '0_0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CFO', name:'Saul Goodman', avatar: 'saul.jpg'},
+ children:[{
+ key: '0_0_0',
+ data: {label: 'Tax'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'Legal'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ }],
+ },
+ {
+ key: '0_1',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'COO', name:'Mike E.', avatar: 'mike.jpg'},
+ children:[{
+ key: '0_1_0',
+ data: {label: 'Operations'},
+ selectable: false,
+ styleClass: 'department-coo'
+ }]
+ },
+ {
+ key: '0_2',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CTO', name:'Jesse Pinkman', avatar: 'jesse.jpg'},
+ children:[{
+ key: '0_2_0',
+ data: {label: 'Development'},
+ selectable: false,
+ styleClass: 'department-cto',
+ children:[{
+ key: '0_2_0_0',
+ data: {label: 'Analysis'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_1',
+ data: {label: 'Front End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_2',
+ data: {label: 'Back End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ },
+ {
+ key: '0_2_1',
+ data: {label: 'QA'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_2',
+ data: {label: 'R&D'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ }
+ ]
+ }
+ }
+ }
+}
Properties
@@ -70,22 +358,34 @@ import Panel from 'primevue/panel';
- header |
+ value |
+ OrganizationChartNode |
+ null |
+ Value of the component. |
+
+
+ selectionKeys |
+ object |
+ null |
+ A map instance of key-value pairs to represented the selected nodes. |
+
+
+ selectionMode |
string |
null |
- Header text of the panel. |
+ Type of the selection, valid values are "single" and "multiple". |
- toggleable |
+ collapsible |
boolean |
- null |
- Defines if content of panel can be expanded and collapsed. |
+ false |
+ Whether the nodes can be expanded or toggled. |
- collapsed |
- boolean |
+ collapsedKeys |
+ object |
null |
- Defines the initial state of panel content. |
+ A map instance of key-value pairs to represented the collapsed nodes. |
@@ -103,11 +403,24 @@ import Panel from 'primevue/panel';
- toggle |
- event.originalEvent: browser event
- event.value: collapsed state as a boolean
- |
- Callback to invoke when a tab toggle. |
+ noode-select |
+ node: Node instance |
+ Callback to invoke when a node is selected. |
+
+
+ noode-unselect |
+ node: Node instance |
+ Callback to invoke when a node is unselected. |
+
+
+ noode-expand |
+ node: Node instance |
+ Callback to invoke when a node is expanded. |
+
+
+ noode-collapse |
+ node: Node instance |
+ Callback to invoke when a node is collapsed. |
@@ -125,24 +438,32 @@ import Panel from 'primevue/panel';
- p-panel |
+ p-organizationchart |
Container element. |
- p-panel-titlebar |
- Header section. |
+ p-organizationchart-table |
+ Table container of a node. |
- p-panel-title |
- Title text of panel. |
+ p-organizationchart-lines |
+ Connector lines container. |
- p-panel-titlebar-toggler |
- Toggle icon. |
+ p-organizationchart-nodes |
+ Contained of node children. |
- p-panel-content |
- Content of panel. |
+ p-organizationchart-line-right |
+ Right side line of a node connector. |
+
+
+ p-organizationchart-line-left |
+ Left side line of a node connector. |
+
+
+ p-organizationchart-line-top |
+ Top side line of a node connector. |
@@ -153,40 +474,232 @@ import Panel from 'primevue/panel';
-
+
View on GitHub
-<template>
- <div>
- <div class="content-section introduction">
- <div class="feature-intro">
- <h1>Panel</h1>
- <p>Panel is a grouping component with the optional content toggle feature.</p>
- </div>
- </div>
+<div>
+ <div class="content-section introduction">
+ <div class="feature-intro">
+ <h1>OrganizationChart</h1>
+ <p>OrganizationChart visualizes hierarchical organization data.</p>
+ </div>
+ </div>
- <div class="content-section implementation">
- <h3 class="first">Regular</h3>
- <Panel header="Godfather I">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
- </Panel>
+ <div class="content-section implementation">
+ <h3>Advanced</h3>
+ <OrganizationChart :value="data1" :collapsible="true" class="company" selectionMode="single" :selectionKeys.sync="selection"
+ @node-select="onNodeSelect" @node-unselect="onNodeUnselect" @node-collapse="onNodeCollapse" @node-expand="onNodeExpand">
+ <template #person="slotProps">
+ <div class="node-header ui-corner-top">{{slotProps.node.data.label}}</div>
+ <div class="node-content">
+ <img :src="'demo/images/organization/' + slotProps.node.data.avatar" width="32">
+ <div>{{slotProps.node.data.name}}</div>
+ </div>
+ </template>
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+ </OrganizationChart>
- <h3>Toggleable</h3>
- <Panel header="Godfather I" :toggleable="true">
- The story begins as Don Vito Corleone, the head of a New York Mafia family, oversees his daughter's wedding.
- His beloved son Michael has just come home from the war, but does not intend to become part of his father's business.
- Through Michael's life the nature of the family business becomes clear. The business of the family is just like the head of the family,
- kind and benevolent to those who give respect, but given to ruthless violence whenever anything stands against the good of the family.
- </Panel>
- </div>
- </div>
-</template>
+ <h3>Basic</h3>
+ <OrganizationChart :value="data2">
+ <template #default="slotProps">
+ <span>{{slotProps.node.data.label}}</span>
+ </template>
+ </OrganizationChart>
+ </div>
+</div>
+
+
+
+export default {
+ data() {
+ return {
+ data1: {
+ key: '0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CEO', name: 'Walter White', avatar: 'walter.jpg'},
+ children: [
+ {
+ key: '0_0',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CFO', name:'Saul Goodman', avatar: 'saul.jpg'},
+ children:[{
+ key: '0_0_0',
+ data: {label: 'Tax'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'Legal'},
+ selectable: false,
+ styleClass: 'department-cfo'
+ }],
+ },
+ {
+ key: '0_1',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'COO', name:'Mike E.', avatar: 'mike.jpg'},
+ children:[{
+ key: '0_1_0',
+ data: {label: 'Operations'},
+ selectable: false,
+ styleClass: 'department-coo'
+ }]
+ },
+ {
+ key: '0_2',
+ type: 'person',
+ styleClass: 'p-person',
+ data: {label: 'CTO', name:'Jesse Pinkman', avatar: 'jesse.jpg'},
+ children:[{
+ key: '0_2_0',
+ data: {label: 'Development'},
+ selectable: false,
+ styleClass: 'department-cto',
+ children:[{
+ key: '0_2_0_0',
+ data: {label: 'Analysis'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_1',
+ data: {label: 'Front End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_0_2',
+ data: {label: 'Back End'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ },
+ {
+ key: '0_2_1',
+ data: {label: 'QA'},
+ selectable: false,
+ styleClass: 'department-cto'
+ },
+ {
+ key: '0_2_2',
+ data: {label: 'R&D'},
+ selectable: false,
+ styleClass: 'department-cto'
+ }]
+ }
+ ]
+ },
+ data2 : {
+ key: '0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0',
+ data: {label: 'F.C. Barcelona'},
+ children: [
+ {
+ key: '0_0_0',
+ data: {label: 'Chelsea F.C.'}
+ },
+ {
+ key: '0_0_1',
+ data: {label: 'F.C. Barcelona'}
+ }
+ ]
+ },
+ {
+ key: '0_1',
+ data: {label: 'Real Madrid'},
+ children: [
+ {
+ key: '0_1_0',
+ data: {label: 'Bayern Munich'}
+ },
+ {
+ key: '0_1_1',
+ data: {label: 'Real Madrid'}
+ }
+ ]
+ }
+ ]
+ },
+ selection: {}
+ }
+ },
+ methods: {
+ onNodeSelect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Selected', detail: node.data.label, life: 3000});
+ },
+ onNodeUnselect(node) {
+ this.$toast.add({severity:'success', summary: 'Node Unselected', detail: node.data.label, life: 3000});
+ },
+ onNodeExpand(node) {
+ this.$toast.add({severity:'success', summary: 'Node Expanded', detail: node.data.label, life: 3000});
+ },
+ onNodeCollapse(node) {
+ this.$toast.add({severity:'success', summary: 'Node Collapsed', detail: node.data.label, life: 3000});
+ }
+ }
+}
+
+
+
+/deep/ .p-organizationchart {
+ .p-person {
+ padding: 0;
+ border: 0 none;
+ }
+
+ .node-header, .node-content {
+ padding: .5em .7em;
+ }
+
+ .node-header {
+ background-color: #495ebb;
+ color: #ffffff;
+ }
+
+ .node-content {
+ text-align: center;
+ border: 1px solid #495ebb;
+ }
+
+ .node-content img {
+ border-radius: 50%;
+ }
+
+ .department-cfo {
+ background-color: #7247bc;
+ color: #ffffff;
+ }
+
+ .department-coo {
+ background-color: #a534b6;
+ color: #ffffff;
+ }
+
+ .department-cto {
+ background-color: #e9286f;
+ color: #ffffff;
+ }
+
+ .p-person .p-node-toggler {
+ color: #495ebb !important;
+ }
+
+ .department-cto .p-node-toggler {
+ color: #8a0a39 !important;
+ }
+}