8.1.1 • Published 5 years ago

@mondal/org-chart v8.1.1

Weekly downloads
53
License
MIT
Repository
github
Last release
5 years ago

Hierarchical Organization Chart for Angular

The mui-org-chart component displays heirarchal Organizational Chart.

Org Chart

Table of Contents

Usage

Each employee is represented by an object with the following properties. Note that all the properties are optional.

PropertyTypeDescription
namestringThe name of the employee
cssClassstringThe CSS class to apply to the employee block
imageUrlstringURL to the employee's image
designationstringEmployee's designation
subordinatesEmployee[]An array of subordinate employees

Installation

$ npm install @mondal/org-chart

Include default styles in your application

For Angular CLI based applications, import the theming in your styles.scss.

@import "~@mondal/org-chart/_theming.scss";

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { OrgChartModule } from '@mondal/org-chart';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,

    OrgChartModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

app.component.html:

<mui-org-chart [topEmployee]="topEmployee" direction="horizontal"></mui-org-chart>

app.component.ts:

export class AppComponent {
  topEmployee: any = {
    name: 'Janis Martin',
    designation: 'CEO',
    subordinates: [
      {
        name: 'Matthew Wikes',
        designation: 'VP',
        subordinates: [
          {
            name: 'Tina Landry',
            designation: 'Budget Analyst',
            subordinates: []
          }

        ]
      },
      {
        name: 'Patricia Lyons',
        designation: 'VP',
        subordinates: [
          {
            name: 'Dylan Wilson',
            designation: 'Web Manager',
            subordinates: []
          },
          {
            name: 'Deb Curtis',
            designation: 'Art Director',
            subordinates: []
          }
        ]
      },
      {
        name: 'Larry Phung',
        designation: 'VP',
        subordinates: []
      }
    ]
  };
}

Inputs

NameTypeDescription
topEmployeeEmployee objectThe Employe object mentioned above
directionvertical or horizontalRenders chart vertically or horizontally

Outputs

NameParametersDescription
itemClickEmployeeThe Employee object which was clicked

Default Look

Horizontal

Horizontal Chart

Vertical

Vertical Chart

Custom Styling

You can override default styles with your custom SCSS. Make sure you include your custom SCSS after including the default SCSS so that your styles override the default styles.

.mui-oc-name {
  font-family: 'Patua One', cursive;
}

.mui-oc-designation {
  font-family: 'Oswald', sans-serif;
}

.mui-oc-border {
  border-color: #9E9E9E;
}

.mui-oc-box {
  color: white;
  width: 10em;
}

// Custom cssClass from Employee object
.mui-oc-ceo {
  background-color: #4caf50;
}
.mui-oc-vp {
  background-color: #03A9F4;
}
.mui-oc-dir {
  background-color: #607D8B;
}
.mui-oc-man {
  background-color: #9C27B0;
}