Skip to content

wittech/ant-design-charts

 
 

Repository files navigation

@ant-design/charts

A React chart library, based on G2Plot

Features

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

Installation

npm

$ npm install @ant-design/charts

Usage

ClassComponent

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

class Page extends Component {
  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 <Line {...config} />;
  }
}
export default Page;

FunctionComponent

import React 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',
  };
  return <Line {...config} />;
};
export default Page;

result:

Gallery

gallery

Document

API

Direct G2Plot

Extra props:

Property Description Type defaultValue
chartRef chart ref (React.MutableRefObject<Line>)=> void -
className container class string -
style container style React.CSSProperties -

How to Contribute

We welcome all contributions.

License

Charts is available under the License MIT.

develop

depend

start

# 安装依赖
$ npm install

# 开发 library
$ npm run dev

Contributors(5)

Ordered by date of first contribution.

  • 福晋
  • 辟起 🍑
  • 愚道
  • 期贤 🙏
  • 绯一

About

A React Chart Library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 59.0%
  • TypeScript 38.4%
  • HTML 2.6%