Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dappsnation/ng-antv

Angular wrapper around the antv libraries
https://github.com/dappsnation/ng-antv

Last synced: 2 months ago
JSON representation

Angular wrapper around the antv libraries

Awesome Lists containing this project

README

        

Angular antv

A repository for Angular helpers around the [@antv vision](https://antv.vision/) libraries.

## [G6](https://g6.antv.vision/)
[![GitHub](https://img.shields.io/github/license/dappsnation/ng-antv)](LICENSE)
[![npm](https://img.shields.io/npm/v/ng-antv-g6)](https://www.npmjs.com/package/ng-antv-g6)
[![npm](https://img.shields.io/npm/dm/ng-antv-g6)](https://www.npmjs.com/package/ng-antv-g6)

[Documentation](https://ng-antv.netlify.app/doc)

```
npm install @antv/g6 ng-antv-g6
```

### Graph
[Online Editor](https://ng-antv.netlify.app/graph)

Create a module with your default config:

`g6.module.ts`
```typescript
import { G6GraphModule, G6_GRAPH_OPTIONS } from 'ng-antv-g6';

@NgModule({
exports: [ G6GraphModule ],
providers: [
{
provide: G6_GRAPH_OPTIONS,
useValue: {
modes: { default: ['drag-canvas', 'zoom-canvas'] },
layout: {
type: 'dagre',
ranksep: 10,
},
defaultNode: {
type: 'rect',
anchorPoints: [[ 0.5, 0 ], [ 0.5, 1 ]],
},
}
},
]
})
export class G6Module {}
```

Import it into you `AppModule`:

`app.module.ts`:
```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppComponent } from './app.component';
import { G6Module } from './g6.module';

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
G6Module // <-- Here
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

```

Now you can use it in your template :
```html



```

The canvas will have the same size as the `g6-graph` tag so don't forget to set its height :
```scss
g6-graph {
height: 500px;
width: 500px;
}
```

### G6TreeGraph
`G6TreeGraph` can have default config.

`g6.module.ts`
```typescript
import { G6TreeGraphModule, G6_TREE_GRAPH_OPTIONS } from 'ng-antv-g6';

@NgModule({
exports: [ G6TreeGraphModule ],
providers: [
{
provide: G6_TREE_GRAPH_OPTIONS,
useValue: {
modes: { default: ['zoom-canvas', 'drag-node'] },
layout: {
type: 'dendrogram',
direction: 'LR',
},
}
},
]
})
export class G6Module {}
```

Now you can use it in your template :
```html




```

⚠️ Due to an [angular issue](https://github.com/angular/angular/issues/14842), the tree graph won't work with dynamic node.
The example below **won't** work : ⚠️
```html









```

### Menu
The Menu uses `@angular/cdk` for the overlay :
```
npm install @angular/cdk
```
And you need to import the style in
`styles.scss`
```scss
@import '~@angular/cdk/overlay-prebuilt.css';
```

> If you're using @angular/material, you don't need to import it.

```html


Delete

```