# ngx-antv-f2

> Functional Antvis/F2 wrapper for Angular.

Latest version **1.0.2** (published 2019-04-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-antv-f2
pnpm add ngx-antv-f2
yarn add ngx-antv-f2
bun add ngx-antv-f2
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2019-04-15 |
| First published | 2019-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 550.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Maintainers | sanshine |
| Keywords | Angular, Antv, F2 |

## Links

- npm: https://www.npmjs.com/package/ngx-antv-f2
- Repository: https://github.com/CK110/ngx-antv-f2
- Homepage: https://github.com/CK110/ngx-antv-f2#readme
- Issues: https://github.com/CK110/ngx-antv-f2/issues
- npm.io page: https://npm.io/package/ngx-antv-f2

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0
- [@antv/f2](https://npm.io/package/@antv/f2.md) ^3.3.4

## Recent versions

- 1.0.2 (latest) — 2019-04-15
- 1.0.1 — 2019-01-30
- 1.0.0 — 2019-01-29
- 0.0.10 — 2019-01-29
- 0.0.9 — 2019-01-25
- 0.0.8 — 2019-01-25
- 0.0.7 — 2019-01-25
- 0.0.6 — 2019-01-24
- 0.0.5 — 2019-01-24
- 0.0.4 — 2019-01-23
- 0.0.3 — 2019-01-21
- 0.0.2 — 2019-01-17
- 0.0.1 — 2019-01-17

## README

## ngx-antv-f2

> Functional [Antvis/F2](https://github.com/antvis/f2) wrapper for Angular 

[![NPM version](https://img.shields.io/npm/v/ngx-antv-f2.svg)](https://www.npmjs.com/package/ngx-antv-f2)


## Demo

[Demo](https://bnmixlqv.github.stackblitz.io)

## Installation

```
npm i ngx-antv-f2 --save
```

```javascript
import {F2Module} from 'ngx-antv-f2'

@NgModule({
  imports: [
    F2Module
  ]
})
```

## Use

### Use template

#### f2-pie-basic.component.html

```html
<f2-chart>
  <f2-source [data]="data" [colDefs]="colDefs"></f2-source>
  <f2-legend [config]="legendConfig"></f2-legend>
  <f2-tooltip [disabled]="true"></f2-tooltip>
  <f2-coord-polar [config]="{transposed: true,radius: 0.85}"></f2-coord-polar>
  <f2-axis [disabled]="true"></f2-axis>
  <f2-geometry [type]="'interval'"
               [position]="'a*percent'"
               [color]="['name',['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0']]"
               [adjust]="'stack'"
               [style]="{lineWidth: 1,stroke: '#fff',lineJoin: 'round',lineCap: 'round'}"
               [animate]="{appear: {duration: 1200,easing: 'bounceOut'}}"
  ></f2-geometry>
</f2-chart>
```

#### f2-pie-basic.component.ts

```js
import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-f2-pie-basic',
  templateUrl: './f2-pie-basic.component.html',
  styleUrls: ['./f2-pie-basic.component.css']
})
export class F2PieBasicComponent implements OnInit {

  map = {
    '芳华': '40%',
    '妖猫传': '20%',
    '机器之血': '18%',
    '心理罪': '15%',
    '寻梦环游记': '5%',
    '其他': '2%'
  };

  data = [{
    name: '芳华',
    percent: 0.4,
    a: '1'
  }, {
    name: '妖猫传',
    percent: 0.2,
    a: '1'
  }, {
    name: '机器之血',
    percent: 0.18,
    a: '1'
  }, {
    name: '心理罪',
    percent: 0.15,
    a: '1'
  }, {
    name: '寻梦环游记',
    percent: 0.05,
    a: '1'
  }, {
    name: '其他',
    percent: 0.02,
    a: '1'
  }];

  colDefs = {
    percent: {
      formatter: function formatter(val) {
        return val * 100 + '%';
      }
    }
  };

  legendConfig = {
    position: 'right',
    itemFormatter: (val) => {
      return val + '  ' + this.map[val];
    }
  };


  constructor() {
  }

  ngOnInit() {
  }
}
```

### custom Render

#### custom-render-pie-basic.component.html

```html
<f2-chart [preventRender]="true" (customRender)="customRender($event)"></f2-chart>
```

#### custom-render-pie-basic.component.ts

```js
import {Component, OnInit} from '@angular/core';

@Component({
  selector: 'app-custom-render-pie-basic',
  templateUrl: './custom-render-pie-basic.component.html',
  styleUrls: ['./custom-render-pie-basic.component.css']
})
export class CustomRenderPieBasicComponent implements OnInit {

  map = {
    '芳华': '40%',
    '妖猫传': '20%',
    '机器之血': '18%',
    '心理罪': '15%',
    '寻梦环游记': '5%',
    '其他': '2%'
  };

  data = [{
    name: '芳华',
    percent: 0.4,
    a: '1'
  }, {
    name: '妖猫传',
    percent: 0.2,
    a: '1'
  }, {
    name: '机器之血',
    percent: 0.18,
    a: '1'
  }, {
    name: '心理罪',
    percent: 0.15,
    a: '1'
  }, {
    name: '寻梦环游记',
    percent: 0.05,
    a: '1'
  }, {
    name: '其他',
    percent: 0.02,
    a: '1'
  }];

  constructor() {
  }

  ngOnInit() {
  }

  customRender(chart: any) {
    chart.source(this.data, {
      percent: {
        formatter: function formatter(val) {
          return val * 100 + '%';
        }
      }
    });
    chart.legend({
      position: 'right',
      itemFormatter: (val) => {
        return val + '  ' + this.map[val];
      }
    });
    chart.tooltip(false);
    chart.coord('polar', {
      transposed: true,
      radius: 0.85
    });
    chart.axis(false);
    chart.interval()
      .position('a*percent')
      .color('name', ['#1890FF', '#13C2C2', '#2FC25B', '#FACC14', '#F04864', '#8543E0'])
      .adjust('stack')
      .style({
        lineWidth: 1,
        stroke: '#fff',
        lineJoin: 'round',
        lineCap: 'round'
      })
      .animate({
        appear: {
          duration: 1200,
          easing: 'bounceOut'
        }
      });

    chart.render();
  }
}
```




## License

The MIT License (see the [LICENSE](https://github.com/CK110/ngx-antv-f2/blob/master/LICENSE) file for the full text)

---
_Source: https://npm.io/package/ngx-antv-f2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
