2.2.0 • Published 3 years ago

ngx-g2plot v2.2.0

Weekly downloads
16
License
MIT
Repository
github
Last release
3 years ago

About

Angular's g2plot package is easy to use

Install

npm install --save  ngx-g2plot
#or
yarn add  ngx-g2plot

Preview

https://stack-stark.github.io/ngx-g2plot-preview-compiled/

Usage

line.component.html

<div starkG2plotLine  #divG2plotLine="g2plotLine" [options]="options"></div>

line.component.ts

import { Component, ViewChild } from '@angular/core';
import { G2plotLineDirective } from 'ngx-g2plot';

@Component({
  selector: 'app-line',
  templateUrl: './line.component.html',
  styleUrls: ['./line.component.less']
})
export class LineComponent {

  constructor() { }
  // Gets to the instruction object
  @ViewChild('divG2plotLine') divG2plotLine!: G2plotLineDirective;

  data: Array<object> = [
    { year: '1991', value: 3 },
    { year: '1992', value: 4 },
    { year: '1993', value: 3.5 },
    { year: '1994', value: 5 },
    { year: '1995', value: 4.9 },
    { year: '1996', value: 6 },
    { year: '1997', value: 7 },
    { year: '1998', value: 9 },
    { year: '1999', value: 13 },
  ];

  options = {
    title: {
      visible: true,
      text: '折线图',
    },
    description: {
      visible: true,
      text: '用平滑的曲线代替折线。',
    },
    data: this.data,
    xField: 'year',
    yField: 'value',
  };

  update(): void {
   const options = {
      title: {
        visible: true,
        text: 'The line chart',
      },
      description: {
        visible: true,
        text: 'Replace broken lines with smooth curves.',
      },
      xField: 'year',
      yField: 'value',
    };
    this.divG2plotLine.update(options);
  }

  changeData(): void {
    const data = [
      { year: '1991', value: 13 },
      { year: '1992', value: 14 },
      { year: '1993', value: 13.5 },
      { year: '1994', value: 15 },
      { year: '1995', value: 14.9 },
      { year: '1996', value: 16 },
      { year: '1997', value: 17 },
      { year: '1998', value: 19 },
      { year: '1999', value: 23 },
    ];
    this.divG2plotLine.changeData(data);
  }

  destroy(): void {
    this.divG2plotLine.destroy();
  }

  changeSize(): void {
    //Use the current instance method
    this.divG2plotLine.instance.changeSize(300, 300);
  }
}

line.module.ts

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { G2plotLineModule } from 'ngx-g2plot';

@NgModule({
  declarations: [G2plotDemoComponent],
  imports: [
    CommonModule,
    G2plotLineModule
  ]
})
export class G2plotDemoModule { }

Tip

I'm using exportAs the deduced update(), changeData(), destroy() the three methods, so that you can at any time to change chart.

If you need to get the current diagram instance and all its properties and methods, use this.xxx.instance. See changeSize() above for details.

See the official documentation for all methods of charting: https://g2plot.antv.vision/zh/docs/manual/plot-api

All Directive

指令名/Directive图表名exportAsModule
starkG2plotAreaArea - 面积图g2plotAreaG2plotAreaModule
starkG2plotBarBar - 基础条形图g2plotBarG2plotBarModule
starkG2plotBidirectionalBarBidirectionalBar - 对称条形图g2plotBidirectionalBarG2plotBidirectionalBarModule
starkG2plotBoxBox - 箱图g2plotBoxG2plotBoxModule
starkG2plotBulletBullet - 子弹图g2plotBulletG2plotBulletModule
starkG2plotChordChord - 弦图g2plotChordG2plotChordModule
starkG2plotColumnColumn - 柱状图g2plotColumnG2plotColumnModule
starkG2plotDualAxesDualAxes - 柱线混合图g2plotDualAxesG2plotDualAxesModule
starkG2plotFunnelFunnel - 漏斗图g2plotFunnelG2plotFunnelModule
starkG2plotGaugeGauge - 仪表盘g2plotGaugeG2plotGaugeModule
starkG2plotHeatmapHeatmap - 热力图g2plotHeatmapG2plotHeatmapModule
starkG2plotHistogramHistogram - 直方图g2plotHistogramG2plotHistogramModule
starkG2plotLineLine - 折线图g2plotLineG2plotLineModule
starkG2plotLiquidLiquid - 水波图g2plotLiquidG2plotLiquidModule
starkG2plotPiePie - 饼图g2plotPieG2plotPieModule
starkG2plotRadialBarRadialBar - 玉珏图g2plotRadialBarG2plotRadialBarModule
starkG2plotRadarRadar - 雷达图g2plotRadarG2plotRadarModule
starkG2plotRoseRose - 玫瑰图g2plotRoseG2plotRoseModule
starkG2plotSankeySankey - 桑基图g2plotSankeyG2plotSankeyModule
starkG2plotScatterScatter - 散点图g2plotScatterG2plotScatterModule
starkG2plotStockStock - 股票图g2plotStockG2plotStockModule
starkG2plotSunburstSunburst - 旭日图图g2plotSunburstG2plotSunburstModule
starkG2plotTinyColumnTinyColumn - 迷你图g2plotTinyColumnG2plotTinyColumnModule
starkG2plotTreemapTreemap - 树图g2plotTreemapG2plotTreemapModule
starkG2plotWaterfallWaterfall - 瀑布图g2plotWaterfallG2plotWaterfallModule
starkG2plotWordCloudWordCloud - 词云g2plotWordCloudG2plotWordCloudModule

About the name

Directive = starkG2plot + Graph Name,

exportAs = g2plot + Graph Name,

Module = G2plot + Graph Name + Module

G2plot official document address

https://g2plot.antv.vision/zh/docs/manual/introduction

Use has encountered a problem or defect?

https://github.com/stack-stark/ngx-g2plot/issues

License

MIT

2.2.0

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago