family-hierarchy
Version:
A small library for **Angular 9+** that implements [vis-network](https://github.com/visjs/vis-network) to generate a hierarchy chart of a family.
126 lines (100 loc) • 2.13 kB
Markdown
A small library for **Angular 9+** that implements [vis-network](https://github.com/visjs/vis-network) to generate a hierarchy chart of a family.

[](https://thenomo3000.github.io/FamilyHierarchy/)
We use ngx-vis, to generate the graph, and so we have to install some dependencies:
```bash
npm install moment @egjs/hammerjs vis-data vis-util keycharm
```
Just add the FamilyHierarchy for use the component
```typescript
import { FamilyHierarchy } from 'FamilyHierarchy';
import { AppComponent } from './app.component';
@NgModule({
imports: [
(...)
FamilyHierarchy,
(...)
],
declarations: [AppComponent],
})
```
```html
<FamilyHierarchy
[]="config"
[]="links"
[]="nodes"
[]="unions"
(selected)="nodeSelected($event)">
</FamilyHierarchy>
```
```typescript
export const DEFAULT_CONFIG: FhConfig = {
links: {
childrens: {
styles : {
color: '#848484',
highlight: '#848484',
hover: '#848484'
}
},
parents: {
styles: {
color: '#99004d',
highlight: '#800040',
hover: '#800040',
}
}
},
nodes : {
images: DEFAULT_NODE_IMAGE,
size: 20
},
union: {
images: DEFAULT_UNION_IMAGE,
size: 20
}
}
```
```typescript
export interface FhNode {
id: any;
label: string;
level: number;
image?: string;
data?: any;
color ?: {};
}
```
```typescript
export interface FhLink {
unionId: any;
nodeId: any;
}
```
```typescript
export interface FhUnion {
id: any;
components: any [];
image?: string;
data?: any;
}
```
If there is an error with moment, it can be fixed by adding the following to the **compile options** in **tsconfig.app**
```json
(...)
"compilerOptions": {
(...)
"allowSyntheticDefaultImports": true,
}
(...)
```