A React Chart Library
Go to file
Joel Alan 95bc350d6a
fix: graph disconnect (#2567)
* fix: graph disconnect

* fix: changelog
2024-06-19 11:22:20 +08:00
.changeset feat: lerna to pnpm (#1558) 2022-09-08 21:27:49 +08:00
.github fix: cdn component error (#2241) 2023-11-28 13:40:07 +08:00
config fix: cdn component error (#2241) 2023-11-28 13:40:07 +08:00
docs chore: add CNAME 2023-10-08 20:41:05 +08:00
packages fix: graph disconnect (#2567) 2024-06-19 11:22:20 +08:00
public update CNAME 2020-05-09 14:02:32 +08:00
scripts fix: shell 2023-04-12 15:03:35 +08:00
template docs: 下线行政地图&文档更新 (#1556) 2022-09-07 21:20:05 +08:00
.babelrc fix: 兼容 ie9 (#522) 2021-03-08 10:48:47 +08:00
.editorconfig init 2019-12-15 16:49:00 +08:00
.eslintignore chore: new website lib (#1897) 2023-04-10 11:14:54 +08:00
.eslintrc.js chore: 升级到webpack5 (#928) 2021-10-15 10:46:09 +08:00
.gitignore fix: site menu 2023-04-10 16:06:03 +08:00
.npmrc feat: add ConversionDagreGraph (#1757) 2023-01-31 10:31:48 +08:00
.prettierignore chore: new website lib (#1897) 2023-04-10 11:14:54 +08:00
.prettierrc.js docs: plots (#916) 2021-10-11 21:26:39 +08:00
.stylelintrc 迁移到dumi、father 2020-04-01 20:34:15 +08:00
CHANGELOG.md fix: 修复安全漏洞 (#1434) 2022-07-19 15:31:13 +08:00
CNAME Create CNAME 2024-02-22 17:05:52 +08:00
CONTRIBUTING.zh-CN.md chore: 新增贡献文档 (#1754) 2023-01-09 11:23:36 +08:00
jest.config.js ci:完善测试环境 (#1108) 2022-01-17 20:04:26 +08:00
LICENSE chore: update readme (#597) 2021-04-28 17:00:27 +08:00
package.json fix: cdn component error (#2241) 2023-11-28 13:40:07 +08:00
pnpm-workspace.yaml fix: preview (#1663) 2022-11-14 19:39:23 +08:00
README.md chore: 补充 readme 文档 (#1433) 2022-07-19 13:58:58 +08:00
tsconfig.json fix: 修复数据更新时legend留存 (#1600) 2022-10-09 15:51:14 +08:00

@ant-design/charts

A React chart library, based on G2Plot, G6, X6, L7Plot.

build npm npm GitHub stars npm License

WebsiteQuick StartGalleryFAQBlog

Case

Statistical charts

Flowchart

Maps

Relation Graphs

Features

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

📦 Installation

$ npm install @ant-design/charts

🔨 Usage

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,
    width: 800,
    height: 400,
    autoFit: false,
    xField: 'year',
    yField: 'value',
    point: {
      size: 5,
      shape: 'diamond',
    },
    label: {
      style: {
        fill: '#aaa',
      },
    },
  };

  let chart;

  // Export Image
  const downloadImage = () => {
    chart?.downloadImage();
  };

  // Get chart base64 string
  const toDataURL = () => {
    console.log(chart?.toDataURL());
  };

  return (
    <div>
      <button type="button" onClick={downloadImage} style={{ marginRight: 24 }}>
        Export Image
      </button>
      <button type="button" onClick={toDataURL}>
        Get base64
      </button>
      <Line {...config} onReady={(chartInstance) => (chart = chartInstance)} />
    </div>
  );
};
export default Page;

Preview

📜 Document & API

See chart API for details. Common props:

Property Description Type defaultValue
onReady chart loaded callback (chart)=> void -
onEvent chart events (chart, event)=> void -
loading loading status boolean -
loadingTemplate loading template React.ReactElement -
errorTemplate custom error template (e: Error) => React.ReactNode -
className container class string -
style container style React.CSSProperties -

🤝 How to Contribute

Your contributions are always welcome! Please Do have a look at the issues first.

📧 Contact us

DingTalk group number: 44788198 .

License

MIT