Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ant-design/charts-yfd

Package Overview
Dependencies
Maintainers
22
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ant-design/charts-yfd

React translate g2plot

  • 1.0.0-beta.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
22
Weekly downloads
 
Created
Source

@ant-design/charts

A React chart library, based on G2Plot

npm npm GitHub stars Test CI

Features

  • Easy to use
  • TypeScript
  • Pretty & Lightweight
  • Responsive
  • Storytelling

Installation

npm

$ npm install @ant-design/charts

Usage

ClassComponent

import React, { Component, createRef } from 'react';
import { Line } from '@ant-design/charts';

class Page extends Component {
  ref = createRef();

  // DownloadImage
  downloadImage = () => {
    this.ref.current?.downloadImage();
  };

  // Get data base64
  toDataURL = () => {
    console.log(this.ref.current?.toDataURL());
  };

  render() {
    const data = [
      { 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 },
    ];

    const config = {
      data,
      title: {
        visible: true,
        text: '带数据点的折线图',
      },
      xField: 'year',
      yField: 'value',
    };

    return (
      <div>
        <button type="button" onClick={this.downloadImage} style={{ marginRight: 24 }}>
          下载图片
        </button>
        <button type="button" onClick={this.toDataURL}>
          获取图片信息
        </button>
        <Line {...config} chartRef={this.ref} />
      </div>
    );
  }
}
export default Page;

FunctionComponent

import React, { useRef } from 'react';
import { Line } from '@ant-design/charts';

const Page: React.FC = () => {
  const data = [
    { 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 },
  ];

  const config = {
    data,
    title: {
      visible: true,
      text: '带数据点的折线图',
    },
    xField: 'year',
    yField: 'value',
  };

  const ref = useRef();

  // 导出图片
  const downloadImage = () => {
    ref.current?.downloadImage();
  };

  // 获取图表 base64 数据
  const toDataURL = () => {
    console.log(ref.current?.toDataURL());
  };

  return (
    <div>
      <button type="button" onClick={downloadImage} style={{ marginRight: 24 }}>
        导出图片
      </button>
      <button type="button" onClick={toDataURL}>
        获取图表信息
      </button>
      <Line {...config} chartRef={ref} />
    </div>
  );
};
export default Page;

result:

gallery

Document

API

Direct G2Plot

Extra props:

PropertyDescriptionTypedefaultValue
chartRefchart ref(React.MutableRefObject<Line>)=> void-
classNamecontainer classstring-
stylecontainer styleReact.CSSProperties-
memoDatacontroll rerenderstring | number | any []-

More usage

FAQ

How to Contribute

We welcome all contributions.

License

Charts is available under the License MIT.

develop

depend

start

# 安装依赖
$ npm install

# 开发 library
$ npm run dev

FAQs

Package last updated on 20 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc