Giter VIP home page Giter VIP logo

org-chart's Introduction

Angular Org Chart

An Angular 2+ library for displaying Organization charts. It's a very lightweigt library with the features currently not available in any other library. It's written in pure typescript and is developed focussing on Angular projects

Getting Started

For using the chart, you'll need to do the folloing steps:

Installation

npm install angular-org-chart --save

Add the dependency in module

Add 'OrgChartModule' in imports

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { OrgChartModule } from 'angular-org-chart';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
	OrgChartModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Formatting the data in component

The data requires few parameters for displaying the correct chart:

{
      name: "Element Value",
      type: 'Element Type',
      children:[]
}

Example component

import { Component } from '@angular/core';
import { OrgData } from 'angular-org-chart/src/app/modules/org-chart/orgData';


@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  orgData: OrgData= {
    name: "Iron Man",
    type: 'CEO',
    children: [
		{
			name: "Captain America",
			type: 'VP',
			children: [
				{
					name: "Hawkeye",
					type: 'manager',
					children: []
				},
				{
					name: "Antman",
					type: 'Manager',
					children: []
				}
			]
		},
		{
			name: "Black Widow",
			type: 'VP',
			children: [
				{
					name: "Hulk",
					type: 'manager',
					children: [
						{
							name: "Spiderman",
							type: 'Intern',
							children: []
						}
					]
				},
				{
					name: "Thor",
					type: 'Manager',
					children: [
						{
							name: "Loki",
							type: 'Team Lead',
							children: []
						}
					]
				}
			]
		}
	]
  };
}

Using the org chart in HTML template

<angular-org-chart id="orgChartId" [data]="orgData"></angular-org-chart>

Pleaase note that 'id' is required if you want to change the css. As the style which you'll need to give for the boxes and the lines, you'll be required to add it on the basis of 'id' else the css won't be applied.

Personalized CSS

Use the 'id' and place these css: For Lines:

#orgChartId .org-chart-entity-border {
	border-left: 1px solid green;
	border-top: 1px solid green;
}

For Distance between the levels:

#orgChartId .org-chart-entity-connector {
	height: 2em;
}

For box styles:

#orgChartId .org-chart-entity-box {
	align-items: center;
    border: 1px solid blue;
    background-color: blue;
    border-radius: 3px;
	box-shadow: 0 .5rem 1rem #777!important;
}

Example

enter image description here

Features

  • Expand/Collapse on clilck
  • Custom Styles
  • Maintained and lightweight code

Upcoming features

  • Feature to turn off default expand/collapse on click.
  • Icon support.
  • More freedom of custom styles.
  • Expand / Collapse all feature.

Authors

  • Shrey Kumar Jain - Initial work - Blog

org-chart's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.