├── .babelignore ├── .dumirc.ts ├── .editorconfig ├── .eslintignore ├── .eslintrc ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yml └── workflows │ ├── auto-release.yml │ ├── automerge.yml │ ├── build.yml │ ├── codeql-analysis.yml │ ├── npm-publish-github-packages.yml │ └── stale.yml ├── .gitignore ├── .husky ├── .gitignore ├── commit-msg ├── post-merge └── pre-commit ├── .npmignore ├── .npmrc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── __tests__ ├── index.spec.tsx ├── plots │ ├── __snapshots__ │ │ ├── area.spec.tsx.snap │ │ ├── bar.spec.tsx.snap │ │ ├── bidirectional-bar.spec.tsx.snap │ │ ├── box.spec.tsx.snap │ │ ├── bullet.spec.tsx.snap │ │ ├── chord.spec.tsx.snap │ │ ├── circle-packing.spec.tsx.snap │ │ ├── column.spec.tsx.snap │ │ ├── dual-axes.spec.tsx.snap │ │ ├── facet.spec.tsx.snap │ │ ├── funnel.spec.tsx.snap │ │ ├── gauge.spec.tsx.snap │ │ ├── heatmap.spec.tsx.snap │ │ ├── histogram.spec.tsx.snap │ │ ├── line.spec.tsx.snap │ │ ├── liquid.spec.tsx.snap │ │ ├── mix.spec.tsx.snap │ │ ├── multi-view.spec.tsx.snap │ │ ├── pie.spec.tsx.snap │ │ ├── progress.spec.tsx.snap │ │ ├── radar.spec.tsx.snap │ │ ├── radial-bar.spec.tsx.snap │ │ ├── ring-progress.spec.tsx.snap │ │ ├── rose.spec.tsx.snap │ │ ├── sankey.spec.tsx.snap │ │ ├── scatter.spec.tsx.snap │ │ ├── stock.spec.tsx.snap │ │ ├── sunburst.spec.tsx.snap │ │ ├── tiny-area.spec.tsx.snap │ │ ├── tiny-column.spec.tsx.snap │ │ ├── tiny-line.spec.tsx.snap │ │ ├── treemap.spec.tsx.snap │ │ ├── venn.spec.tsx.snap │ │ ├── violin.spec.tsx.snap │ │ ├── waterfall.spec.tsx.snap │ │ └── word-cloud.spec.tsx.snap │ ├── area.spec.tsx │ ├── bar.spec.tsx │ ├── bidirectional-bar.spec.tsx │ ├── box.spec.tsx │ ├── bullet.spec.tsx │ ├── chord.spec.tsx │ ├── circle-packing.spec.tsx │ ├── column.spec.tsx │ ├── dual-axes.spec.tsx │ ├── facet.spec.tsx │ ├── funnel.spec.tsx │ ├── gauge.spec.tsx │ ├── heatmap.spec.tsx │ ├── histogram.spec.tsx │ ├── line.spec.tsx │ ├── liquid.spec.tsx │ ├── mix.spec.tsx │ ├── multi-view.spec.tsx │ ├── pie.spec.tsx │ ├── progress.spec.tsx │ ├── radar.spec.tsx │ ├── radial-bar.spec.tsx │ ├── ring-progress.spec.tsx │ ├── rose.spec.tsx │ ├── sankey.spec.tsx │ ├── scatter.spec.tsx │ ├── stock.spec.tsx │ ├── sunburst.spec.tsx │ ├── tiny-area.spec.tsx │ ├── tiny-column.spec.tsx │ ├── tiny-line.spec.tsx │ ├── treemap.spec.tsx │ ├── venn.spec.tsx │ ├── violin.spec.tsx │ ├── waterfall.spec.tsx │ └── word-cloud.spec.tsx └── setups │ ├── url.js │ └── worker.js ├── assets └── logo.svg ├── azure-pipelines.yml ├── babel.config.js ├── commitlint.config.js ├── docs ├── api │ ├── area.md │ ├── bar.md │ ├── bidirectional-bar.md │ ├── box.md │ ├── bullet.md │ ├── chord.md │ ├── circle-packing.md │ ├── column.md │ ├── dual-axes.md │ ├── facet.md │ ├── funnel.md │ ├── gauge.md │ ├── heatmap.md │ ├── histogram.md │ ├── index.md │ ├── line.md │ ├── liquid.md │ ├── mix.md │ ├── pie.md │ ├── progress.md │ ├── radar.md │ ├── radial-bar.md │ ├── ring-progress.md │ ├── rose.md │ ├── sankey.md │ ├── scatter.md │ ├── stock.md │ ├── sunburst.md │ ├── tiny-area.md │ ├── tiny-column.md │ ├── tiny-line.md │ ├── treemap.md │ ├── venn.md │ ├── violin.md │ ├── waterfall.md │ └── word-cloud.md ├── changelog │ └── index.md ├── demos │ ├── bar.tsx │ ├── column.tsx │ ├── line.tsx │ └── pie.tsx ├── guide │ └── index.md └── index.md ├── jest.config.ts ├── now.json ├── package-lock.json ├── package.json ├── scripts ├── doc-template.ftl └── sync.ts ├── src ├── components │ └── base │ │ └── index.tsx ├── index.ts └── plots │ ├── area │ └── index.tsx │ ├── bar │ └── index.tsx │ ├── bidirectional-bar │ └── index.tsx │ ├── box │ └── index.tsx │ ├── bullet │ └── index.tsx │ ├── chord │ └── index.tsx │ ├── circle-packing │ └── index.tsx │ ├── column │ └── index.tsx │ ├── dual-axes │ └── index.tsx │ ├── facet │ └── index.tsx │ ├── funnel │ └── index.tsx │ ├── gauge │ └── index.tsx │ ├── heatmap │ └── index.tsx │ ├── histogram │ └── index.tsx │ ├── line │ └── index.tsx │ ├── liquid │ └── index.tsx │ ├── mix │ └── index.tsx │ ├── multi-view │ └── index.tsx │ ├── pie │ └── index.tsx │ ├── progress │ └── index.tsx │ ├── radar │ └── index.tsx │ ├── radial-bar │ └── index.tsx │ ├── ring-progress │ └── index.tsx │ ├── rose │ └── index.tsx │ ├── sankey │ └── index.tsx │ ├── scatter │ └── index.tsx │ ├── stock │ └── index.tsx │ ├── sunburst │ └── index.tsx │ ├── tiny-area │ └── index.tsx │ ├── tiny-column │ └── index.tsx │ ├── tiny-line │ └── index.tsx │ ├── treemap │ └── index.tsx │ ├── venn │ └── index.tsx │ ├── violin │ └── index.tsx │ ├── waterfall │ └── index.tsx │ └── word-cloud │ └── index.tsx └── tsconfig.json /.babelignore: -------------------------------------------------------------------------------- 1 | .umi 2 | -------------------------------------------------------------------------------- /.dumirc.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'dumi' 2 | 3 | export default defineConfig({ 4 | themeConfig: { 5 | // name: 'G2Plot React', 6 | logo: 'https://raw.githubusercontent.com/open-data-plan/g2plot-react/master/assets/logo.svg', 7 | nav: [ 8 | { 9 | title: 'Guide', 10 | link: '/guide', 11 | }, 12 | { 13 | title: 'API', 14 | link: '/api', 15 | }, 16 | { 17 | title: 'Changelog', 18 | link: '/changelog', 19 | }, 20 | { 21 | title: 'G2Plot', 22 | link: 'https://g2plot.antv.vision/', 23 | }, 24 | ], 25 | }, 26 | locales: [{ id: 'en-US', name: 'English' }], 27 | resolve: { 28 | docDirs: ['docs'], 29 | entryFile: './src/index.ts', 30 | }, 31 | analytics: { 32 | ga: 'UA-81696369-2', 33 | }, 34 | // dynamicImport: {}, 35 | // ssr: {}, 36 | apiParser: {}, 37 | exportStatic: {}, 38 | mfsu: false, 39 | }) 40 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | end_of_line = lf 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | # output 2 | es/ 3 | lib/ 4 | *.d.ts 5 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@pixas/eslint-config"], 3 | } 4 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '[Bug]' 5 | labels: bug 6 | assignees: kagawagao 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behavior: 14 | 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem or a mini showcase. 25 | 26 | **Desktop (please complete the following information):** 27 | 28 | - OS: [e.g. iOS] 29 | - Browser [e.g. chrome, safari] 30 | - `@antv/g2plot` Version [e.g. v2.3.12] 31 | - `@opd/g2plot-react` Version [e.g. v2.7.0] 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[Feature]" 5 | labels: feature 6 | assignees: kagawagao 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/auto-release.yml: -------------------------------------------------------------------------------- 1 | name: "auto-release" 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v*" 7 | 8 | jobs: 9 | tagged-release: 10 | name: "Tagged Release" 11 | runs-on: "ubuntu-latest" 12 | 13 | steps: 14 | - uses: "marvinpinto/action-automatic-releases@latest" 15 | with: 16 | repo_token: "${{ secrets.GITHUB_TOKEN }}" 17 | prerelease: false 18 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | name: automerge 2 | on: 3 | pull_request: 4 | types: 5 | - labeled 6 | - unlabeled 7 | - synchronize 8 | - opened 9 | - edited 10 | - ready_for_review 11 | - reopened 12 | - unlocked 13 | pull_request_review: 14 | types: 15 | - submitted 16 | check_suite: 17 | types: 18 | - completed 19 | status: {} 20 | jobs: 21 | automerge: 22 | runs-on: ubuntu-latest 23 | steps: 24 | - name: automerge 25 | uses: "pascalgn/automerge-action@v0.16.2" 26 | env: 27 | GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 28 | MERGE_LABELS: "dependencies,!wip" 29 | MERGE_METHOD: "squash" 30 | UPDATE_METHOD: "rebase" 31 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v1 10 | - name: Setup Node.js environment 11 | uses: actions/setup-node@v3.2.0 12 | with: 13 | # Set always-auth in npmrc. 14 | # always-auth: # optional, default is false 15 | # Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0. 16 | node-version: 19.x 17 | # File containing the version Spec of the version to use. Examples: .nvmrc, .node-version. 18 | # node-version-file: # optional 19 | # Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default. 20 | # architecture: # optional 21 | # Set this option if you want the action to check for the latest available version that satisfies the version spec. 22 | # check-latest: true 23 | # Optional registry to set up for auth. Will set the registry in a project level .npmrc and .yarnrc file, and set up auth to read in from env.NODE_AUTH_TOKEN. 24 | # registry-url: # optional 25 | # Optional scope for authenticating against scoped registries. Will fall back to the repository owner when using the GitHub Packages registry (https://npm.pkg.github.com/). 26 | # scope: # optional 27 | # Used to pull node distributions from node-versions. Since there's a default, this is typically not supplied by the user. 28 | # token: # optional, default is ${{ github.token }} 29 | # Used to specify a package manager for caching in the default directory. Supported values: npm, yarn, pnpm. 30 | cache: npm 31 | # Used to specify the path to a dependency file: package-lock.json, yarn.lock, etc. Supports wildcards or a list of file names for caching multiple dependencies. 32 | cache-dependency-path: package-lock.json 33 | - name: npm install, test and build 34 | run: | 35 | npm ci 36 | npm run build 37 | - name: Codecov 38 | uses: codecov/codecov-action@v1.5.0 39 | env: 40 | CI: true 41 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL" 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [master] 9 | schedule: 10 | - cron: '0 1 * * 1' 11 | 12 | jobs: 13 | analyze: 14 | name: Analyze 15 | runs-on: ubuntu-latest 16 | 17 | strategy: 18 | fail-fast: false 19 | matrix: 20 | # Override automatic language detection by changing the below list 21 | # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] 22 | language: ['javascript'] 23 | # Learn more... 24 | # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection 25 | 26 | steps: 27 | - name: Checkout repository 28 | uses: actions/checkout@v2 29 | with: 30 | # We must fetch at least the immediate parents so that if this is 31 | # a pull request then we can checkout the head. 32 | fetch-depth: 2 33 | 34 | # If this run was triggered by a pull request event, then checkout 35 | # the head of the pull request instead of the merge commit. 36 | - run: git checkout HEAD^2 37 | if: ${{ github.event_name == 'pull_request' }} 38 | 39 | # Initializes the CodeQL tools for scanning. 40 | - name: Initialize CodeQL 41 | uses: github/codeql-action/init@v1 42 | with: 43 | languages: ${{ matrix.language }} 44 | 45 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 46 | # If this step fails, then you should remove it and run the build manually (see below) 47 | - name: Autobuild 48 | uses: github/codeql-action/autobuild@v1 49 | 50 | # ℹ️ Command-line programs to run using the OS shell. 51 | # 📚 https://git.io/JvXDl 52 | 53 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 54 | # and modify them (or add more) to build your code if your project 55 | # uses a compiled language 56 | 57 | #- run: | 58 | # make bootstrap 59 | # make release 60 | 61 | - name: Perform CodeQL Analysis 62 | uses: github/codeql-action/analyze@v1 63 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish-github-packages.yml: -------------------------------------------------------------------------------- 1 | # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created 2 | # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages 3 | 4 | name: Node.js Package 5 | 6 | on: 7 | release: 8 | types: [published] 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3 16 | - run: npm ci 17 | - run: npm run build 18 | 19 | publish-gpr: 20 | needs: build 21 | runs-on: ubuntu-latest 22 | permissions: 23 | contents: read 24 | packages: write 25 | steps: 26 | - uses: actions/checkout@v3 27 | - uses: actions/setup-node@v3 28 | with: 29 | registry-url: https://npm.pkg.github.com/ 30 | - run: npm ci 31 | - run: npm publish 32 | env: 33 | NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} 34 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | name: Mark stale issues and pull requests 2 | 3 | on: 4 | schedule: 5 | - cron: "30 1 * * *" 6 | 7 | jobs: 8 | stale: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/stale@v1 14 | with: 15 | repo-token: ${{ secrets.GITHUB_TOKEN }} 16 | stale-issue-message: 'Stale issue message' 17 | stale-pr-message: 'Stale pull request message' 18 | stale-issue-label: 'no-issue-activity' 19 | stale-pr-label: 'no-pr-activity' 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # Typescript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # build Output 61 | lib 62 | es 63 | *.css 64 | 65 | # umi 66 | .umi 67 | .umi-production 68 | dist 69 | es/.umi 70 | lib/.umi 71 | 72 | .dumi 73 | 74 | .now 75 | 76 | .vscode 77 | -------------------------------------------------------------------------------- /.husky/.gitignore: -------------------------------------------------------------------------------- 1 | _ 2 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx commitlint --edit $1 5 | -------------------------------------------------------------------------------- /.husky/post-merge: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx diff-run 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .umi 2 | es/.umi 3 | lib/.umi 4 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | legacy-peer-deps=true 2 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at kingsongao1221@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # CONTRIBUTING 2 | 3 | ## Process 4 | 5 | 1. Fork repository 6 | 1. Create a branch based on `master` 7 | 1. Do what you want 8 | 1. Pull request 9 | 1. Review 10 | 1. Merge or Block 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jingsong Gao 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # @opd/g2plot-react 6 | 7 | > [G2Plot](https://g2plot.antv.vision/) for React 8 | 9 | [![Build Status](https://dev.azure.com/kagawagao/OPD/_apis/build/status/open-data-plan.g2plot-react?branchName=master)](https://dev.azure.com/kagawagao/OPD/_build/latest?definitionId=1&branchName=master) 10 | [![build](https://github.com/open-data-plan/g2plot-react/workflows/build/badge.svg)](https://github.com/open-data-plan/g2plot-react/actions?query=workflow%3Abuild) 11 | [![npm](https://img.shields.io/npm/v/@opd/g2plot-react.svg)](https://www.npmjs.com/package/@opd/g2plot-react) 12 | [![npm](https://img.shields.io/npm/dm/@opd/g2plot-react.svg)](https://www.npmjs.com/package/@opd/g2plot-react) 13 | [![npm](https://img.shields.io/npm/l/@opd/g2plot-react.svg)](https://www.npmjs.com/package/@opd/g2plot-react) 14 | [![codecov](https://codecov.io/gh/open-data-plan/g2plot-react/branch/master/graph/badge.svg)](https://codecov.io/gh/open-data-plan/g2plot-react) 15 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fopen-data-plan%2Fg2plot-react.svg?type=shield)](https://app.fossa.com/projects/git%2Bgithub.com%2Fopen-data-plan%2Fg2plot-react?ref=badge_shield) 16 | 17 | ## Install 18 | 19 | ``` 20 | npm install @opd/g2plot-react 21 | ``` 22 | 23 | ## Usage 24 | 25 | ```tsx 26 | import React, { useRef } from 'react' 27 | import { LineChart, LineChartProps } from '@opd/g2plot-react' 28 | 29 | const config: LineChartProps = { 30 | height: 350, 31 | autoFit: true, 32 | xField: 'year', 33 | yField: 'value', 34 | smooth: true, 35 | meta: { 36 | value: { 37 | max: 15, 38 | }, 39 | }, 40 | data: [ 41 | { year: '1991', value: 3 }, 42 | { year: '1992', value: 4 }, 43 | { year: '1993', value: 3.5 }, 44 | { year: '1994', value: 5 }, 45 | { year: '1995', value: 4.9 }, 46 | { year: '1996', value: 6 }, 47 | { year: '1997', value: 7 }, 48 | { year: '1998', value: 9 }, 49 | { year: '1999', value: 11 }, 50 | ], 51 | } 52 | 53 | export default () => { 54 | const chartRef = useRef() 55 | return 56 | } 57 | ``` 58 | 59 | [![Edit g2plot-react-example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/g2plot-react-example-xx3gp?fontsize=14&hidenavigation=1&theme=dark) 60 | 61 | ## API 62 | 63 | All config defined in `G2Plot` [document](https://g2plot.antv.vision/zh/docs/manual/introduction) can be used as `props` 64 | 65 | ## Develop 66 | 67 | ``` 68 | npm install 69 | npm run build 70 | ``` 71 | 72 | 73 | ## License 74 | [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fopen-data-plan%2Fg2plot-react.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2Fopen-data-plan%2Fg2plot-react?ref=badge_large) -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | 2.x | :white_check_mark: | 8 | | < 2.0 | :x: | 9 | 10 | ## Reporting a Vulnerability 11 | 12 | You can report a vulnerability by [opening an issue](https://github.com/open-data-plan/g2plot-react/issues) on this repository. 13 | -------------------------------------------------------------------------------- /__tests__/index.spec.tsx: -------------------------------------------------------------------------------- 1 | import * as components from '../src'; 2 | 3 | describe('index.tsx', () => { 4 | it('component exported', () => { 5 | expect(components).toBeTruthy(); 6 | expect(components).toHaveProperty('LineChart'); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/area.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`AreaChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/bar.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BarChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/bidirectional-bar.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BidirectionalBarChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/box.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BoxChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/bullet.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`BulletChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/chord.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`ChordChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/circle-packing.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`CirclePackingChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/column.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`ColumnChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/dual-axes.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`DualAxesChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/facet.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`FacetChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/funnel.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`FunnelChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/gauge.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`GaugeChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/heatmap.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`HeatmapChart should render without crashed 1`] = ` 4 |
5 |
8 |
11 | 16 |
17 |
18 |
19 | `; 20 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/histogram.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`HistogramChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/line.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`LineChart lifecycle 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/liquid.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`LiquidChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
21 | 9000.00% 22 |
23 |
24 | 31 | 32 | 33 | `; 34 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/mix.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`MixChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/multi-view.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`MultiViewChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/pie.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`PieChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/progress.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`ProgressChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/radar.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`RadarChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/radial-bar.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`RadialBarChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/ring-progress.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`RingProgressChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
21 | 80.00% 22 |
23 |
24 | 31 | 32 | 33 | `; 34 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/rose.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`RoseChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/sankey.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`SankeyChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/scatter.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`ScatterChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/stock.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`StockChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/sunburst.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`SunburstChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/tiny-area.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`TinyAreaChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/tiny-column.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`TinyColumnChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/tiny-line.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`TinyLineChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/treemap.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`TreemapChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/venn.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`VennChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/violin.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`ViolinChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/waterfall.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`WaterfallChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/__snapshots__/word-cloud.spec.tsx.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`WordCloudChart should render without crashed 1`] = ` 4 |
5 |
9 |
12 | 17 |
18 | 25 | 26 | 27 | `; 28 | -------------------------------------------------------------------------------- /__tests__/plots/area.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import AreaChart from '../../src/plots/area'; 4 | 5 | describe('AreaChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/bar.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import BarChart from '../../src/plots/bar'; 4 | 5 | describe('BarChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/bidirectional-bar.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import BidirectionalBarChart from '../../src/plots/bidirectional-bar'; 4 | 5 | describe('BidirectionalBarChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/box.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import BoxChart from '../../src/plots/box'; 4 | 5 | describe('BoxChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/bullet.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import BulletChart from '../../src/plots/bullet'; 4 | 5 | describe('BulletChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render( 8 | , 19 | ); 20 | 21 | expect(result.container).toMatchSnapshot(); 22 | }); 23 | }); 24 | -------------------------------------------------------------------------------- /__tests__/plots/chord.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import ChordChart from '../../src/plots/chord'; 4 | 5 | const data = [ 6 | { source: '北京', target: '天津', value: 30 }, 7 | { source: '北京', target: '上海', value: 80 }, 8 | { source: '北京', target: '河北', value: 46 }, 9 | { source: '北京', target: '辽宁', value: 49 }, 10 | { source: '北京', target: '黑龙江', value: 69 }, 11 | { source: '北京', target: '吉林', value: 19 }, 12 | { source: '天津', target: '河北', value: 62 }, 13 | { source: '天津', target: '辽宁', value: 82 }, 14 | { source: '天津', target: '上海', value: 16 }, 15 | { source: '上海', target: '黑龙江', value: 16 }, 16 | { source: '河北', target: '黑龙江', value: 76 }, 17 | { source: '河北', target: '内蒙古', value: 24 }, 18 | { source: '内蒙古', target: '北京', value: 32 }, 19 | ]; 20 | 21 | describe('ChordChart', () => { 22 | test('should render without crashed', () => { 23 | const result = render( 24 | , 32 | ); 33 | 34 | expect(result.container).toMatchSnapshot(); 35 | }); 36 | }); 37 | -------------------------------------------------------------------------------- /__tests__/plots/circle-packing.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import axios from 'axios'; 3 | import React from 'react'; 4 | import CirclePackingChart from '../../src/plots/circle-packing'; 5 | 6 | describe('CirclePackingChart', () => { 7 | test('should render without crashed', async () => { 8 | const res = await axios.get('https://gw.alipayobjects.com/os/antfincdn/%24m0nDoQYqH/basic-packing.json'); 9 | const result = render( 10 | b.depth - a.depth, 18 | }, 19 | }} 20 | />, 21 | ); 22 | 23 | expect(result.container).toMatchSnapshot(); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /__tests__/plots/column.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import ColumnChart from '../../src/plots/column'; 4 | 5 | describe('ColumnChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/dual-axes.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import DualAxesChart from '../../src/plots/dual-axes'; 4 | 5 | const data = [ 6 | { year: '1991', value: 3, count: 10 }, 7 | { year: '1992', value: 4, count: 4 }, 8 | { year: '1993', value: 3.5, count: 5 }, 9 | { year: '1994', value: 5, count: 5 }, 10 | { year: '1995', value: 4.9, count: 4.9 }, 11 | { year: '1996', value: 6, count: 35 }, 12 | { year: '1997', value: 7, count: 7 }, 13 | { year: '1998', value: 9, count: 1 }, 14 | { year: '1999', value: 13, count: 20 }, 15 | ]; 16 | 17 | describe('DualAxesChart', () => { 18 | test('should render without crashed', () => { 19 | const result = render( 20 | , 37 | ); 38 | 39 | expect(result.container).toMatchSnapshot(); 40 | }); 41 | }); 42 | -------------------------------------------------------------------------------- /__tests__/plots/facet.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import FacetChart, { FacetChartProps } from '../../src/plots/facet'; 4 | 5 | describe('FacetChart', () => { 6 | test('should render without crashed', () => { 7 | const config: FacetChartProps = { 8 | padding: [0, 10, 10], 9 | appendPadding: [0, 0, 30, 20], 10 | type: 'rect', 11 | fields: ['cut'], 12 | cols: 3, // 超过3个换行 13 | data: [], 14 | axes: {}, 15 | meta: { 16 | carat: { 17 | sync: true, 18 | }, 19 | price: { 20 | sync: true, 21 | }, 22 | clarity: { 23 | sync: true, 24 | }, 25 | }, 26 | eachView: (view, f) => { 27 | return { 28 | type: 'scatter', 29 | options: { 30 | data: f.data, 31 | xField: 'carat', 32 | yField: 'price', 33 | colorField: 'clarity', 34 | shape: 'circle', 35 | pointStyle: { fillOpacity: 0.3, stroke: null }, 36 | }, 37 | }; 38 | }, 39 | }; 40 | const result = render(); 41 | 42 | expect(result.container).toMatchSnapshot(); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /__tests__/plots/funnel.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import FunnelChart from '../../src/plots/funnel'; 4 | 5 | describe('FunnelChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/gauge.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import GaugeChart from '../../src/plots/gauge'; 4 | 5 | describe('GaugeChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/heatmap.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import axios from 'axios'; 3 | import React from 'react'; 4 | import HeatmapChart from '../../src/plots/heatmap'; 5 | 6 | describe('HeatmapChart', () => { 7 | test('should render without crashed', async () => { 8 | const res = await axios.get( 9 | 'https://gw.alipayobjects.com/os/basement_prod/a719cd4e-bd40-4878-a4b4-df8a6b531dfe.json', 10 | ); 11 | const result = render( 12 | , 29 | ); 30 | 31 | expect(result.container).toMatchSnapshot(); 32 | }); 33 | }); 34 | -------------------------------------------------------------------------------- /__tests__/plots/histogram.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import HistogramChart from '../../src/plots/histogram'; 4 | 5 | describe('HistogramChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/line.spec.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable @typescript-eslint/ban-ts-comment */ 2 | import { Plot as BasePlot, LineOptions } from '@antv/g2plot'; 3 | import { act, render } from '@testing-library/react'; 4 | import React, { createRef } from 'react'; 5 | import { createRoot } from 'react-dom/client'; 6 | import LineChart from '../../src/plots/line'; 7 | 8 | let div; 9 | let root; 10 | 11 | beforeEach(() => { 12 | div = document.createElement('div'); 13 | document.body.appendChild(div); 14 | act(() => { 15 | root = createRoot(div); 16 | }); 17 | }); 18 | 19 | afterEach(() => { 20 | act(() => { 21 | root.unmount(); 22 | }); 23 | document.body.removeChild(div); 24 | div = null; 25 | }); 26 | 27 | describe('LineChart', () => { 28 | test('render without crashed', () => { 29 | act(() => { 30 | root.render(); 31 | }); 32 | }); 33 | 34 | test('object ref should be assigned', () => { 35 | const ref = createRef(); 36 | const chartRef = createRef | null>(); 37 | act(() => { 38 | root.render(); 39 | }); 40 | expect(ref.current).toBeDefined(); 41 | expect(chartRef.current).toBeDefined(); 42 | }); 43 | 44 | test('onReady should be called', () => { 45 | const onReady = (plot: BasePlot) => { 46 | expect(plot).toBeDefined(); 47 | }; 48 | act(() => { 49 | root.render(); 50 | }); 51 | }); 52 | 53 | test('function ref should be called', () => { 54 | let chart; 55 | const getChart = (instance) => { 56 | chart = instance; 57 | }; 58 | act(() => { 59 | root.render(); 60 | }); 61 | 62 | expect(chart).toBeDefined(); 63 | }); 64 | 65 | test('test update config and data', () => { 66 | const data = [ 67 | { year: '1991', value: 3 }, 68 | { year: '1992', value: 4 }, 69 | { year: '1993', value: 3.5 }, 70 | { year: '1994', value: 5 }, 71 | { year: '1995', value: 4.9 }, 72 | { year: '1996', value: 6 }, 73 | { year: '1997', value: 7 }, 74 | { year: '1998', value: 9 }, 75 | { year: '1999', value: 13 }, 76 | ]; 77 | const config = { 78 | data, 79 | xField: 'year', 80 | yField: 'value', 81 | smooth: true, 82 | meta: { 83 | value: { 84 | max: 15, 85 | }, 86 | }, 87 | }; 88 | act(() => { 89 | // @ts-ignore 90 | root.render(); 91 | }); 92 | 93 | act(() => { 94 | root.render(); 95 | }); 96 | 97 | act(() => { 98 | // @ts-ignore 99 | root.render(); 100 | }); 101 | 102 | act(() => { 103 | root.render(); 104 | }); 105 | act(() => { 106 | root.render(); 107 | }); 108 | act(() => { 109 | root.render(); 110 | }); 111 | }); 112 | 113 | test('lifecycle', () => { 114 | const result = render(); 115 | 116 | expect(result.container).toMatchSnapshot(); 117 | 118 | result.unmount(); 119 | }); 120 | }); 121 | -------------------------------------------------------------------------------- /__tests__/plots/liquid.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import LiquidChart from '../../src/plots/liquid'; 4 | 5 | describe('LiquidChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/mix.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import MixChart from '../../src/plots/mix'; 4 | 5 | describe('MixChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/multi-view.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import MultiViewChart from '../../src/plots/multi-view'; 4 | 5 | describe('MultiViewChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/pie.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import PieChart, { PieChartProps } from '../../src/plots/pie'; 4 | 5 | const data = [ 6 | { type: '分类一', value: 27 }, 7 | { type: '分类二', value: 25 }, 8 | { type: '分类三', value: 18 }, 9 | { type: '分类四', value: 15 }, 10 | { type: '分类五', value: 10 }, 11 | { type: '其他', value: 5 }, 12 | ]; 13 | 14 | const config: PieChartProps = { 15 | appendPadding: 10, 16 | data, 17 | angleField: 'value', 18 | colorField: 'type', 19 | radius: 0.9, 20 | label: { 21 | type: 'inner', 22 | offset: '-30%', 23 | content: ({ percent }) => `${(percent * 100).toFixed(0)}%`, 24 | style: { 25 | fontSize: 14, 26 | textAlign: 'center', 27 | }, 28 | }, 29 | interactions: [{ type: 'element-active' }], 30 | }; 31 | 32 | describe('PieChart', () => { 33 | test('should render without crashed', () => { 34 | const result = render(); 35 | 36 | expect(result.container).toMatchSnapshot(); 37 | }); 38 | }); 39 | -------------------------------------------------------------------------------- /__tests__/plots/progress.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import ProgressChart from '../../src/plots/progress'; 4 | 5 | describe('ProgressChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/radar.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import RadarChart from '../../src/plots/radar'; 4 | 5 | describe('RadarChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/radial-bar.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import RadialBarChart from '../../src/plots/radial-bar'; 4 | 5 | describe('RadialBarChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/ring-progress.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import RingProgressChart from '../../src/plots/ring-progress'; 4 | 5 | describe('RingProgressChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/rose.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import RoseChart from '../../src/plots/rose'; 4 | 5 | describe('RoseChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/sankey.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import SankeyChart from '../../src/plots/sankey'; 4 | 5 | describe('SankeyChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/scatter.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import ScatterChart from '../../src/plots/scatter'; 4 | 5 | describe('ScatterChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/stock.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import StockChart from '../../src/plots/stock'; 4 | 5 | describe('StockChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/sunburst.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import SunburstChart from '../../src/plots/sunburst'; 4 | 5 | const data = { 6 | name: '咖啡产地', 7 | children: [ 8 | { 9 | name: '非洲', 10 | value: 4, 11 | children: [ 12 | { 13 | continent: '非洲', 14 | country: '埃塞俄比亚', 15 | symbol: '🇪🇹', 16 | area: '耶加雪菲', 17 | name: '埃塞俄比亚', 18 | value: 1, 19 | }, 20 | { 21 | continent: '非洲', 22 | country: '肯尼亚', 23 | symbol: '🇰🇪', 24 | coffee: '阿拉比加卡豆', 25 | name: '肯尼亚', 26 | value: 1, 27 | }, 28 | { 29 | continent: '非洲', 30 | country: '坦桑尼亚', 31 | symbol: '🇹🇿', 32 | coffee: '乞力马扎罗咖啡', 33 | name: '坦桑尼亚', 34 | value: 1, 35 | }, 36 | { 37 | continent: '非洲', 38 | country: '乌干达', 39 | symbol: '🇺🇬', 40 | name: '乌干达', 41 | value: 1, 42 | }, 43 | ], 44 | }, 45 | { 46 | name: '中南美洲', 47 | value: 6, 48 | children: [ 49 | { 50 | continent: '中南美洲', 51 | country: '巴西', 52 | symbol: '🇧🇷', 53 | name: '巴西', 54 | value: 1, 55 | }, 56 | { 57 | continent: '中南美洲', 58 | country: '哥伦比亚', 59 | symbol: '🇨🇴', 60 | name: '哥伦比亚', 61 | value: 1, 62 | }, 63 | { 64 | continent: '中南美洲', 65 | country: '牙买加', 66 | symbol: '🇯🇲', 67 | name: '牙买加', 68 | value: 1, 69 | }, 70 | { 71 | continent: '中南美洲', 72 | country: '巴拿马', 73 | symbol: '🇵🇦', 74 | name: '巴拿马', 75 | value: 1, 76 | }, 77 | { 78 | continent: '中南美洲', 79 | country: '危地马拉', 80 | symbol: '🇬🇹', 81 | name: '危地马拉', 82 | value: 1, 83 | }, 84 | { 85 | continent: '中南美洲', 86 | country: '哥斯达黎加', 87 | symbol: '🇨🇷', 88 | name: '哥斯达黎加', 89 | value: 1, 90 | }, 91 | ], 92 | }, 93 | { 94 | name: '亚洲', 95 | value: 5, 96 | children: [ 97 | { 98 | continent: '亚洲', 99 | country: '印度尼西亚', 100 | symbol: '🇮🇩', 101 | area: '苏门答腊', 102 | coffee: '曼特宁咖啡', 103 | name: '印度尼西亚', 104 | value: 1, 105 | }, 106 | { 107 | continent: '亚洲', 108 | country: '印度', 109 | symbol: '🇮🇳', 110 | name: '印度', 111 | value: 1, 112 | }, 113 | { 114 | continent: '亚洲', 115 | country: '越南', 116 | symbol: '🇻🇳', 117 | name: '越南', 118 | value: 1, 119 | }, 120 | { 121 | continent: '亚洲', 122 | country: '也门', 123 | symbol: '🇾🇪', 124 | name: '也门', 125 | value: 1, 126 | }, 127 | { 128 | continent: '亚洲', 129 | country: '中国', 130 | symbol: '🇨🇳', 131 | name: '中国', 132 | value: 1, 133 | }, 134 | ], 135 | }, 136 | ], 137 | }; 138 | 139 | describe('SunburstChart', () => { 140 | test('should render without crashed', () => { 141 | const result = render(); 142 | 143 | expect(result.container).toMatchSnapshot(); 144 | }); 145 | }); 146 | -------------------------------------------------------------------------------- /__tests__/plots/tiny-area.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import TinyAreaChart from '../../src/plots/tiny-area'; 4 | 5 | describe('TinyAreaChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/tiny-column.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import TinyColumnChart from '../../src/plots/tiny-column'; 4 | 5 | describe('TinyColumnChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/tiny-line.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import TinyLineChart from '../../src/plots/tiny-line'; 4 | 5 | describe('TinyLineChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/treemap.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import TreemapChart from '../../src/plots/treemap'; 4 | 5 | const data = { 6 | name: 'root', 7 | children: [ 8 | { name: '分类 1', value: 560 }, 9 | { name: '分类 2', value: 500 }, 10 | { name: '分类 3', value: 150 }, 11 | { name: '分类 4', value: 140 }, 12 | { name: '分类 5', value: 115 }, 13 | { name: '分类 6', value: 95 }, 14 | { name: '分类 7', value: 90 }, 15 | { name: '分类 8', value: 75 }, 16 | { name: '分类 9', value: 98 }, 17 | { name: '分类 10', value: 60 }, 18 | { name: '分类 11', value: 45 }, 19 | { name: '分类 12', value: 40 }, 20 | { name: '分类 13', value: 40 }, 21 | { name: '分类 14', value: 35 }, 22 | { name: '分类 15', value: 40 }, 23 | { name: '分类 16', value: 40 }, 24 | { name: '分类 17', value: 40 }, 25 | { name: '分类 18', value: 30 }, 26 | { name: '分类 19', value: 28 }, 27 | { name: '分类 20', value: 16 }, 28 | ], 29 | }; 30 | 31 | describe('TreemapChart', () => { 32 | test('should render without crashed', () => { 33 | const result = render( 34 | , 40 | ); 41 | 42 | expect(result.container).toMatchSnapshot(); 43 | }); 44 | }); 45 | -------------------------------------------------------------------------------- /__tests__/plots/venn.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import VennChart from '../../src/plots/venn'; 4 | 5 | describe('VennChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render( 8 | , 24 | ); 25 | 26 | expect(result.container).toMatchSnapshot(); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /__tests__/plots/violin.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import ViolinChart from '../../src/plots/violin'; 4 | 5 | describe('ViolinChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/waterfall.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import WaterfallChart from '../../src/plots/waterfall'; 4 | 5 | describe('WaterfallChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/plots/word-cloud.spec.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import WordCloudChart from '../../src/plots/word-cloud'; 4 | 5 | describe('WordCloudChart', () => { 6 | test('should render without crashed', () => { 7 | const result = render(); 8 | 9 | expect(result.container).toMatchSnapshot(); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /__tests__/setups/url.js: -------------------------------------------------------------------------------- 1 | window.URL.createObjectURL = jest.fn() 2 | -------------------------------------------------------------------------------- /__tests__/setups/worker.js: -------------------------------------------------------------------------------- 1 | class Worker { 2 | constructor(stringUrl) { 3 | this.url = stringUrl 4 | this.onmessage = jest.fn() 5 | } 6 | 7 | postMessage(msg) { 8 | this.onmessage(msg) 9 | } 10 | } 11 | 12 | window.Worker = Worker 13 | -------------------------------------------------------------------------------- /assets/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | g2plot 2 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Node.js 2 | # Build a general Node.js project with npm. 3 | # Add steps that analyze code, save build artifacts, deploy, and more: 4 | # https://docs.microsoft.com/azure/devops/pipelines/languages/javascript 5 | 6 | trigger: 7 | - master 8 | 9 | pr: 10 | branches: 11 | include: 12 | - master 13 | 14 | pool: 15 | vmImage: "ubuntu-latest" 16 | 17 | steps: 18 | - task: NodeTool@0 19 | inputs: 20 | versionSpec: "18.x" 21 | displayName: "Install Node.js" 22 | 23 | - script: | 24 | npm install 25 | npm run build 26 | displayName: "npm install and build" 27 | 28 | - task: PublishCodeCoverageResults@1 29 | inputs: 30 | codeCoverageTool: "Cobertura" 31 | summaryFileLocation: "$(System.DefaultWorkingDirectory)/**/*coverage.xml" 32 | reportDirectory: "$(System.DefaultWorkingDirectory)/coverage" 33 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@pixas/babel-preset-lib'], 3 | } 4 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@commitlint/config-conventional'], 3 | } 4 | -------------------------------------------------------------------------------- /docs/api/area.md: -------------------------------------------------------------------------------- 1 | # AreaChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { AreaChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/bar.md: -------------------------------------------------------------------------------- 1 | # BarChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { BarChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/bidirectional-bar.md: -------------------------------------------------------------------------------- 1 | # BidirectionalBarChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { BidirectionalBarChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/box.md: -------------------------------------------------------------------------------- 1 | # BoxChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { BoxChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/bullet.md: -------------------------------------------------------------------------------- 1 | # BulletChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { BulletChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/chord.md: -------------------------------------------------------------------------------- 1 | # ChordChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { ChordChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/circle-packing.md: -------------------------------------------------------------------------------- 1 | # CirclePackingChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { CirclePackingChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/column.md: -------------------------------------------------------------------------------- 1 | # ColumnChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { ColumnChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/dual-axes.md: -------------------------------------------------------------------------------- 1 | # DualAxesChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { DualAxesChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/facet.md: -------------------------------------------------------------------------------- 1 | # FacetChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { FacetChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/funnel.md: -------------------------------------------------------------------------------- 1 | # FunnelChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { FunnelChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/gauge.md: -------------------------------------------------------------------------------- 1 | # GaugeChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { GaugeChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/heatmap.md: -------------------------------------------------------------------------------- 1 | # HeatmapChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { HeatmapChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/histogram.md: -------------------------------------------------------------------------------- 1 | # HistogramChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { HistogramChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: API 3 | nav: 4 | title: API 5 | --- 6 | 7 | ## Configurations 8 | 9 | All configurations defined in `G2Plot` can be used as `props`, and use `chartRef` can access chart instance 10 | 11 | For example 12 | 13 | ```tsx | pure 14 | import { LineChart } from '@opd/g2plot-react' 15 | 16 | export default () => { 17 | const ref = useRef() 18 | const chartRef = useRef() 19 | return ( 20 | 21 | ) 22 | } 23 | ``` 24 | 25 | view `G2Plot` [docs](https://g2plot.antv.vision/en/docs/manual/introduction) 26 | 27 | 28 | -------------------------------------------------------------------------------- /docs/api/line.md: -------------------------------------------------------------------------------- 1 | # LineChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { LineChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/liquid.md: -------------------------------------------------------------------------------- 1 | # LiquidChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { LiquidChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/mix.md: -------------------------------------------------------------------------------- 1 | # MixChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { MixChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/pie.md: -------------------------------------------------------------------------------- 1 | # PieChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { PieChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/progress.md: -------------------------------------------------------------------------------- 1 | # ProgressChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { ProgressChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/radar.md: -------------------------------------------------------------------------------- 1 | # RadarChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { RadarChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/radial-bar.md: -------------------------------------------------------------------------------- 1 | # RadialBarChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { RadialBarChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/ring-progress.md: -------------------------------------------------------------------------------- 1 | # RingProgressChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { RingProgressChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/rose.md: -------------------------------------------------------------------------------- 1 | # RoseChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { RoseChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/sankey.md: -------------------------------------------------------------------------------- 1 | # SankeyChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { SankeyChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/scatter.md: -------------------------------------------------------------------------------- 1 | # ScatterChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { ScatterChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/stock.md: -------------------------------------------------------------------------------- 1 | # StockChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { StockChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/sunburst.md: -------------------------------------------------------------------------------- 1 | # SunburstChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { SunburstChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/tiny-area.md: -------------------------------------------------------------------------------- 1 | # TinyAreaChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { TinyAreaChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/tiny-column.md: -------------------------------------------------------------------------------- 1 | # TinyColumnChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { TinyColumnChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/tiny-line.md: -------------------------------------------------------------------------------- 1 | # TinyLineChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { TinyLineChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/treemap.md: -------------------------------------------------------------------------------- 1 | # TreemapChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { TreemapChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/venn.md: -------------------------------------------------------------------------------- 1 | # VennChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { VennChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/violin.md: -------------------------------------------------------------------------------- 1 | # ViolinChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { ViolinChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/waterfall.md: -------------------------------------------------------------------------------- 1 | # WaterfallChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { WaterfallChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/api/word-cloud.md: -------------------------------------------------------------------------------- 1 | # WordCloudChart 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { WordCloudChart } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /docs/changelog/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Changelog 3 | --- 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/demos/bar.tsx: -------------------------------------------------------------------------------- 1 | import { BarChart } from '@opd/g2plot-react'; 2 | 3 | const config = { 4 | height: 350, 5 | autoFit: true, 6 | xField: 'value', 7 | yField: 'year', 8 | smooth: true, 9 | meta: { 10 | value: { 11 | max: 15, 12 | }, 13 | }, 14 | data: [ 15 | { year: '1991', value: 3 }, 16 | { year: '1992', value: 4 }, 17 | { year: '1993', value: 3.5 }, 18 | { year: '1994', value: 5 }, 19 | { year: '1995', value: 4.9 }, 20 | { year: '1996', value: 6 }, 21 | { year: '1997', value: 7 }, 22 | { year: '1998', value: 9 }, 23 | { year: '1999', value: 11 }, 24 | ], 25 | }; 26 | 27 | export default () => { 28 | return ; 29 | }; 30 | -------------------------------------------------------------------------------- /docs/demos/column.tsx: -------------------------------------------------------------------------------- 1 | import { ColumnChart } from '@opd/g2plot-react'; 2 | 3 | const config = { 4 | height: 350, 5 | autoFit: true, 6 | xField: 'year', 7 | yField: 'value', 8 | smooth: true, 9 | meta: { 10 | value: { 11 | max: 15, 12 | }, 13 | }, 14 | data: [ 15 | { year: '1991', value: 3 }, 16 | { year: '1992', value: 4 }, 17 | { year: '1993', value: 3.5 }, 18 | { year: '1994', value: 5 }, 19 | { year: '1995', value: 4.9 }, 20 | { year: '1996', value: 6 }, 21 | { year: '1997', value: 7 }, 22 | { year: '1998', value: 9 }, 23 | { year: '1999', value: 11 }, 24 | ], 25 | }; 26 | 27 | export default () => { 28 | return ; 29 | }; 30 | -------------------------------------------------------------------------------- /docs/demos/line.tsx: -------------------------------------------------------------------------------- 1 | import { LineChart } from '@opd/g2plot-react'; 2 | 3 | const config = { 4 | height: 350, 5 | autoFit: true, 6 | xField: 'year', 7 | yField: 'value', 8 | smooth: true, 9 | meta: { 10 | value: { 11 | max: 15, 12 | }, 13 | }, 14 | data: [ 15 | { year: '1991', value: 3 }, 16 | { year: '1992', value: 4 }, 17 | { year: '1993', value: 3.5 }, 18 | { year: '1994', value: 5 }, 19 | { year: '1995', value: 4.9 }, 20 | { year: '1996', value: 6 }, 21 | { year: '1997', value: 7 }, 22 | { year: '1998', value: 9 }, 23 | { year: '1999', value: 11 }, 24 | ], 25 | }; 26 | 27 | export default () => { 28 | return ; 29 | }; 30 | -------------------------------------------------------------------------------- /docs/demos/pie.tsx: -------------------------------------------------------------------------------- 1 | import { PieChart } from '@opd/g2plot-react'; 2 | 3 | const pieConfig = { 4 | height: 350, 5 | autoFit: true, 6 | padding: 'auto', 7 | radius: 1, 8 | data: [ 9 | { 10 | type: 'A', 11 | value: 27, 12 | }, 13 | { 14 | type: 'B', 15 | value: 25, 16 | }, 17 | { 18 | type: 'C', 19 | value: 18, 20 | }, 21 | { 22 | type: 'D', 23 | value: 15, 24 | }, 25 | { 26 | type: 'E', 27 | value: 10, 28 | }, 29 | { 30 | type: 'Others', 31 | value: 5, 32 | }, 33 | ], 34 | angleField: 'value', 35 | colorField: 'type', 36 | label: { 37 | visible: true, 38 | type: 'inner', 39 | }, 40 | legend: { 41 | visible: false, 42 | }, 43 | }; 44 | 45 | export default () => { 46 | return ; 47 | }; 48 | -------------------------------------------------------------------------------- /docs/guide/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: Get Started 3 | --- 4 | 5 | ## What 6 | 7 | `G2Plot React` is a chart component set powered by [`G2Plot`](https://g2plot.antv.vision/) and developed for `React`. 8 | 9 | ## Features 10 | 11 | - Fully support `G2Plot` charts, and will support new chart at first time. 12 | - Developed for `React`, and easily use. 13 | - Native support for `TypeScript`. 14 | - **100%** unit test coverage 15 | 16 | ## Install 17 | 18 | Install package in your work directory 19 | 20 | ```bash 21 | npm install @opd/g2plot-react 22 | ``` 23 | 24 | ## Import 25 | 26 | Import a chart in your `React` Component 27 | 28 | ```ts 29 | import { LineChart } from '@opd/g2plot-react' 30 | ``` 31 | 32 | ## Config 33 | 34 | Config chart based on `G2Plot` [docs](https://g2plot.antv.vision/en/docs/manual/introduction) 35 | 36 | ```ts 37 | const config = { 38 | height: 400, 39 | xField: 'year', 40 | yField: 'value', 41 | smooth: true, 42 | meta: { 43 | value: { 44 | max: 15, 45 | }, 46 | }, 47 | data: [ 48 | { year: '1991', value: 3 }, 49 | { year: '1992', value: 4 }, 50 | { year: '1993', value: 3.5 }, 51 | { year: '1994', value: 5 }, 52 | { year: '1995', value: 4.9 }, 53 | { year: '1996', value: 6 }, 54 | { year: '1997', value: 7 }, 55 | { year: '1998', value: 9 }, 56 | { year: '1999', value: 11 }, 57 | ], 58 | } 59 | ``` 60 | 61 | ## Render 62 | 63 | ```tsx 64 | import { LineChart } from '@opd/g2plot-react' 65 | import { useCallback } from 'react' 66 | 67 | const config = { 68 | height: 400, 69 | xField: 'year', 70 | yField: 'value', 71 | smooth: true, 72 | meta: { 73 | value: { 74 | max: 15, 75 | }, 76 | }, 77 | data: [ 78 | { year: '1991', value: 3 }, 79 | { year: '1992', value: 4 }, 80 | { year: '1993', value: 3.5 }, 81 | { year: '1994', value: 5 }, 82 | { year: '1995', value: 4.9 }, 83 | { year: '1996', value: 6 }, 84 | { year: '1997', value: 7 }, 85 | { year: '1998', value: 9 }, 86 | { year: '1999', value: 11 }, 87 | ], 88 | } 89 | 90 | export default () => { 91 | const getChart = useCallback((chart) => { 92 | console.log(chart) 93 | }, []) 94 | const getContainer = useCallback((container) => { 95 | console.log(container) 96 | }, []) 97 | return 98 | } 99 | ``` 100 | 101 | ## Update Data 102 | 103 | ```tsx 104 | import { LineChart } from '@opd/g2plot-react' 105 | import { useCallback, useState } from 'react' 106 | 107 | const config = { 108 | height: 400, 109 | xField: 'year', 110 | yField: 'value', 111 | smooth: true, 112 | meta: { 113 | value: { 114 | max: 15, 115 | }, 116 | }, 117 | data: [ 118 | { year: '1991', value: 3 }, 119 | { year: '1992', value: 4 }, 120 | { year: '1993', value: 3.5 }, 121 | { year: '1994', value: 5 }, 122 | { year: '1995', value: 4.9 }, 123 | { year: '1996', value: 6 }, 124 | { year: '1997', value: 7 }, 125 | { year: '1998', value: 9 }, 126 | { year: '1999', value: 11 }, 127 | ], 128 | } 129 | 130 | export default () => { 131 | const getChart = useCallback((chart) => { 132 | console.log(chart) 133 | }, []) 134 | const getContainer = useCallback((container) => { 135 | console.log(container) 136 | }, []) 137 | 138 | const [data, setData] = useState([ 139 | { year: '1991', value: 3 }, 140 | { year: '1992', value: 4 }, 141 | { year: '1993', value: 3.5 }, 142 | { year: '1994', value: 5 }, 143 | { year: '1995', value: 4.9 }, 144 | { year: '1996', value: 6 }, 145 | { year: '1997', value: 7 }, 146 | { year: '1998', value: 9 }, 147 | { year: '1999', value: 11 }, 148 | ]) 149 | 150 | const handleBtnClick = useCallback(() => { 151 | setData((items) => { 152 | const last = items.pop() 153 | 154 | return items.concat(last, { 155 | year: (+last.year + 1).toString(), 156 | value: Math.random() * 10, 157 | }) 158 | }) 159 | }, []) 160 | 161 | return ( 162 |
163 | 164 | 170 |
171 | ) 172 | } 173 | ``` 174 | 175 | ## Update Config 176 | 177 | ```tsx 178 | import { LineChart } from '@opd/g2plot-react' 179 | import { useCallback, useState } from 'react' 180 | 181 | const config = { 182 | height: 400, 183 | xField: 'year', 184 | yField: 'value', 185 | smooth: true, 186 | meta: { 187 | value: { 188 | max: 15, 189 | }, 190 | }, 191 | data: [ 192 | { year: '1991', value: 3 }, 193 | { year: '1992', value: 4 }, 194 | { year: '1993', value: 3.5 }, 195 | { year: '1994', value: 5 }, 196 | { year: '1995', value: 4.9 }, 197 | { year: '1996', value: 6 }, 198 | { year: '1997', value: 7 }, 199 | { year: '1998', value: 9 }, 200 | { year: '1999', value: 11 }, 201 | ], 202 | } 203 | 204 | export default () => { 205 | const getChart = useCallback((chart) => { 206 | console.log(chart) 207 | }, []) 208 | const getContainer = useCallback((container) => { 209 | console.log(container) 210 | }, []) 211 | 212 | const [restConfig, setConfig] = useState({}) 213 | 214 | const handleBtnClick = useCallback(() => { 215 | setConfig((config) => ({ 216 | point: config.point ? undefined : {}, 217 | })) 218 | }, []) 219 | 220 | return ( 221 |
222 | 223 | 229 |
230 | ) 231 | } 232 | ``` 233 | 234 | ## Use Lab Chart 235 | 236 | ```tsx | pure 237 | import { Lab } from '@antv/g2plot' 238 | import { BaseChart } from '@opd/g2plot' 239 | 240 | export default () => 241 | ``` 242 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: G2Plot React 3 | hero: 4 | title: G2Plot React 5 | description: G2Plot for React 6 | actions: 7 | - text: API 8 | link: /api 9 | - text: Get Started 10 | link: /guide 11 | features: 12 | - emoji: 🚀 13 | title: G2Plot 14 | description: Powered by G2Plot 15 | link: https://g2plot.antv.vision 16 | - emoji: 📦 17 | title: React 18 | description: Born for React 19 | - emoji: 🛠 20 | title: Type Strong 21 | description: Native support for TypeScript 22 | - emoji: ✅ 23 | title: 100% 24 | description: Full unit test coverage 25 | demo: 26 | cols: 2 27 | --- 28 | 29 | ## Installation 30 | 31 | ```bash 32 | npm install @opd/g2plot-react 33 | ``` 34 | 35 | ## Usage 36 | 37 | ```js 38 | import { LineChart } from '@opd/g2plot-react' 39 | ``` 40 | 41 | ## Examples 42 | 43 | 44 | 45 | 46 | 47 | 48 | ## Links 49 | 50 | - [`G2Plot`](https://g2plot.antv.vision/) 51 | - [`Vue Version`](https://github.com/open-data-plan/g2plot-vue) 52 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * For a detailed explanation regarding each configuration property, visit: 3 | * https://jestjs.io/docs/configuration 4 | */ 5 | 6 | import type { Config } from 'jest'; 7 | 8 | const config: Config = { 9 | // All imported modules in your tests should be mocked automatically 10 | // automock: false, 11 | 12 | // Stop running tests after `n` failures 13 | // bail: 0, 14 | 15 | // The directory where Jest should store its cached dependency information 16 | // cacheDirectory: "/private/var/folders/tn/r8q88kss0jndlc66wz2ksw5w0000gn/T/jest_dx", 17 | 18 | // Automatically clear mock calls, instances, contexts and results before every test 19 | clearMocks: true, 20 | 21 | // Indicates whether the coverage information should be collected while executing the test 22 | collectCoverage: true, 23 | 24 | // An array of glob patterns indicating a set of files for which coverage information should be collected 25 | // collectCoverageFrom: undefined, 26 | 27 | // The directory where Jest should output its coverage files 28 | coverageDirectory: 'coverage', 29 | 30 | // An array of regexp pattern strings used to skip coverage collection 31 | coveragePathIgnorePatterns: ['/node_modules/'], 32 | 33 | // Indicates which provider should be used to instrument code for coverage 34 | // coverageProvider: "babel", 35 | 36 | // A list of reporter names that Jest uses when writing coverage reports 37 | coverageReporters: ['json', 'text', 'lcov', 'clover'], 38 | 39 | // An object that configures minimum threshold enforcement for coverage results 40 | // coverageThreshold: undefined, 41 | 42 | // A path to a custom dependency extractor 43 | // dependencyExtractor: undefined, 44 | 45 | // Make calling deprecated APIs throw helpful error messages 46 | // errorOnDeprecated: false, 47 | 48 | // The default configuration for fake timers 49 | // fakeTimers: { 50 | // "enableGlobally": false 51 | // }, 52 | 53 | // Force coverage collection from ignored files using an array of glob patterns 54 | // forceCoverageMatch: [], 55 | 56 | // A path to a module which exports an async function that is triggered once before all test suites 57 | // globalSetup: undefined, 58 | 59 | // A path to a module which exports an async function that is triggered once after all test suites 60 | // globalTeardown: undefined, 61 | 62 | // A set of global variables that need to be available in all test environments 63 | // globals: {}, 64 | 65 | // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. 66 | // maxWorkers: "50%", 67 | 68 | // An array of directory names to be searched recursively up from the requiring module's location 69 | // moduleDirectories: [ 70 | // "node_modules" 71 | // ], 72 | 73 | // An array of file extensions your modules use 74 | moduleFileExtensions: ['js', 'mjs', 'cjs', 'jsx', 'ts', 'tsx', 'json', 'node'], 75 | 76 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module 77 | // moduleNameMapper: {}, 78 | 79 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader 80 | // modulePathIgnorePatterns: [], 81 | 82 | // Activates notifications for test results 83 | // notify: false, 84 | 85 | // An enum that specifies notification mode. Requires { notify: true } 86 | // notifyMode: "failure-change", 87 | 88 | // A preset that is used as a base for Jest's configuration 89 | // preset: undefined, 90 | 91 | // Run tests from one or more projects 92 | // projects: undefined, 93 | 94 | // Use this configuration option to add custom reporters to Jest 95 | // reporters: undefined, 96 | 97 | // Automatically reset mock state before every test 98 | // resetMocks: false, 99 | 100 | // Reset the module registry before running each individual test 101 | // resetModules: false, 102 | 103 | // A path to a custom resolver 104 | // resolver: undefined, 105 | 106 | // Automatically restore mock state and implementation before every test 107 | // restoreMocks: false, 108 | 109 | // The root directory that Jest should scan for tests and modules within 110 | // rootDir: undefined, 111 | 112 | // A list of paths to directories that Jest should use to search for files in 113 | // roots: [ 114 | // "" 115 | // ], 116 | 117 | // Allows you to use a custom runner instead of Jest's default test runner 118 | // runner: "jest-runner", 119 | 120 | // The paths to modules that run some code to configure or set up the testing environment before each test 121 | 122 | setupFiles: ['jest-canvas-mock', './__tests__/setups/worker.js', './__tests__/setups/url.js'], 123 | 124 | // A list of paths to modules that run some code to configure or set up the testing framework before each test 125 | // setupFilesAfterEnv: [], 126 | 127 | // The number of seconds after which a test is considered as slow and reported as such in the results. 128 | // slowTestThreshold: 5, 129 | 130 | // A list of paths to snapshot serializer modules Jest should use for snapshot testing 131 | // snapshotSerializers: [], 132 | 133 | // The test environment that will be used for testing 134 | testEnvironment: 'jsdom', 135 | 136 | // Options that will be passed to the testEnvironment 137 | // testEnvironmentOptions: {}, 138 | 139 | // Adds a location field to test results 140 | // testLocationInResults: false, 141 | 142 | // The glob patterns Jest uses to detect test files 143 | testMatch: ['/**/*.(spec|test).[tj]s?(x)'], 144 | 145 | // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped 146 | // testPathIgnorePatterns: [ 147 | // "/node_modules/" 148 | // ], 149 | 150 | // The regexp pattern or array of patterns that Jest uses to detect test files 151 | // testRegex: [], 152 | 153 | // This option allows the use of a custom results processor 154 | // testResultsProcessor: undefined, 155 | 156 | // This option allows use of a custom test runner 157 | // testRunner: "jest-circus/runner", 158 | 159 | // A map from regular expressions to paths to transformers 160 | // transform: undefined, 161 | 162 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation 163 | 164 | transformIgnorePatterns: ['/node_modules/!d3-*', '/src/.umi/', '/node_modules/core-js'], 165 | 166 | // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them 167 | // unmockedModulePathPatterns: undefined, 168 | 169 | // Indicates whether each individual test should be reported during the run 170 | // verbose: undefined, 171 | 172 | // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode 173 | // watchPathIgnorePatterns: [], 174 | 175 | // Whether to use watchman for file crawling 176 | // watchman: true, 177 | globals: { 178 | IS_REACT_ACT_ENVIRONMENT: true, 179 | }, 180 | }; 181 | 182 | export default config; 183 | -------------------------------------------------------------------------------- /now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "scope": "opd", 4 | "routes": [ 5 | { "handle": "filesystem" }, 6 | { "src": "/.*", "dest": "/index.html" } 7 | ], 8 | "github": { 9 | "enable": true 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@opd/g2plot-react", 3 | "version": "2.13.5", 4 | "description": "G2Plot for React", 5 | "keywords": [ 6 | "component", 7 | "g2", 8 | "g2plot", 9 | "chart" 10 | ], 11 | "homepage": "https://g2plot.opd.cool/", 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/open-data-plan/g2plot-react.git" 15 | }, 16 | "license": "MIT", 17 | "author": "kagawagao (https://kingsongao.com/)", 18 | "sideEffects": false, 19 | "main": "lib/index.js", 20 | "module": "es/index.js", 21 | "directories": { 22 | "lib": "lib", 23 | "test": "__tests__" 24 | }, 25 | "files": [ 26 | "lib", 27 | "es", 28 | "typings", 29 | "*.d.ts" 30 | ], 31 | "scripts": { 32 | "prebuild": "npm test", 33 | "build": "npm run build:es & npm run build:commonjs", 34 | "postbuild": "npm run build:types", 35 | "build:commonjs": "cross-env BABEL_ENV=commonjs babel src -d lib --extensions .ts,.tsx --delete-dir-on-start", 36 | "build:docs": "dumi build", 37 | "build:es": "babel src -d es --extensions .ts,.tsx --delete-dir-on-start", 38 | "build:types": "tsc --declarationDir ./lib & tsc --declarationDir ./es", 39 | "dev": "dumi dev", 40 | "lint": "eslint . --ext=.ts,.tsx", 41 | "lint:fix": "eslint . --ext=.ts,.tsx --fix", 42 | "postpublish": "git push --follow-tags", 43 | "sync": "ts-node ./scripts/sync.ts", 44 | "test": "jest", 45 | "preversion": "npm run build", 46 | "version": "conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md", 47 | "postversion": "npm publish" 48 | }, 49 | "lint-staged": { 50 | "*.{js,jsx,ts,tsx}": [ 51 | "eslint --fix" 52 | ], 53 | "*.{json,md}": [ 54 | "prettier -c --write" 55 | ] 56 | }, 57 | "prettier": "@pixas/prettier-config", 58 | "dependencies": { 59 | "@babel/runtime": "^7.21.0" 60 | }, 61 | "devDependencies": { 62 | "@antv/g2plot": "^2.4.29", 63 | "@babel/cli": "^7.24.7", 64 | "@commitlint/cli": "^19.1.0", 65 | "@commitlint/config-conventional": "^19.1.0", 66 | "@pixas/babel-preset-lib": "^0.13.0", 67 | "@pixas/eslint-config": "^0.13.0", 68 | "@pixas/prettier-config": "^0.13.0", 69 | "@testing-library/dom": "^10.4.0", 70 | "@testing-library/react": "^16.1.0", 71 | "@types/jest": "^29.5.12", 72 | "@types/lodash": "^4.17.4", 73 | "@types/react": "^19.0.2", 74 | "@types/react-dom": "^19.0.2", 75 | "@types/react-test-renderer": "^19.0.0", 76 | "@types/string-template": "^1.0.2", 77 | "axios": "^1.7.9", 78 | "conventional-changelog-cli": "^5.0.0", 79 | "cross-env": "^7.0.3", 80 | "diff-run": "^1.1.1", 81 | "dumi": "^2.2.16", 82 | "husky": "^9.0.7", 83 | "jest": "^29.7.0", 84 | "jest-canvas-mock": "^2.5.2", 85 | "jest-environment-jsdom": "^29.7.0", 86 | "lint-staged": "^16.0.0", 87 | "lodash": "^4.17.21", 88 | "react": "^19.0.0", 89 | "react-dom": "^19.0.0", 90 | "react-test-renderer": "^19.0.0", 91 | "string-template": "^1.0.0", 92 | "ts-node": "^10.9.1", 93 | "typescript": "^5.5.4" 94 | }, 95 | "peerDependencies": { 96 | "@antv/g2plot": "^2.x", 97 | "lodash": "^4.x", 98 | "react": "*" 99 | }, 100 | "publishConfig": { 101 | "access": "public" 102 | }, 103 | "diffrun": { 104 | "package-lock.json": "npm ci" 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /scripts/doc-template.ftl: -------------------------------------------------------------------------------- 1 | # {cmpName} 2 | 3 | ## Usage 4 | 5 | ```tsx | pure 6 | import { {cmpName} } from '@opd/g2plot-react' 7 | ``` 8 | 9 | ## API 10 | 11 | 12 | 13 | > Visit [G2Plot](https://g2plot.antv.antgroup.com/api/plot-api) form more detail 14 | -------------------------------------------------------------------------------- /scripts/sync.ts: -------------------------------------------------------------------------------- 1 | import { ESLint } from 'eslint'; 2 | import fs from 'fs'; 3 | import { camelCase, kebabCase, upperFirst } from 'lodash'; 4 | import path from 'path'; 5 | import stringTemplate from 'string-template'; 6 | import { promisify } from 'util'; 7 | 8 | console.log('Sync start'); 9 | 10 | const mkdir = promisify(fs.mkdir); 11 | const writeFile = promisify(fs.writeFile); 12 | const readFile = promisify(fs.readFile); 13 | 14 | const eslint = new ESLint({ 15 | extensions: ['.tsx'], 16 | baseConfig: { 17 | extends: ['@pixas/eslint-config'], 18 | }, 19 | fix: true, 20 | }); 21 | const g2PlotDir = path.resolve(process.cwd(), 'node_modules/@antv/g2plot/src/plots'); 22 | const plotDir = path.resolve(process.cwd(), 'src/plots'); 23 | const testDir = path.resolve(process.cwd(), '__tests__/plots'); 24 | const exportPath = path.resolve(process.cwd(), 'src/index.ts'); 25 | 26 | const plotNames = fs 27 | .readdirSync(g2PlotDir) 28 | .filter((dir) => !dir.startsWith('_')) 29 | .map((dir) => upperFirst(camelCase(dir))); 30 | 31 | // const staticProperties = ['length', 'name', 'prototype'] 32 | 33 | // const labCharts = Object.getOwnPropertyNames(Lab).filter((property) => 34 | // /^[A-Z]/.test(property) 35 | // ) 36 | 37 | // console.log(labCharts) 38 | 39 | const allCharts: string[] = []; 40 | 41 | const newCharts: string[] = []; 42 | 43 | plotNames.forEach((chartName) => { 44 | try { 45 | allCharts.push(chartName); 46 | if (!fs.existsSync(path.resolve(plotDir, `${kebabCase(chartName)}/index.tsx`))) { 47 | newCharts.push(chartName); 48 | } 49 | } catch (error) {} 50 | }); 51 | 52 | if (newCharts.length) { 53 | console.log('Follow charts will be added:'); 54 | console.log(newCharts.join(' ')); 55 | } else { 56 | console.log('No new charts found'); 57 | } 58 | 59 | const lintAndFixFileContent = async (fileContent: string, filePath: string) => { 60 | const lintResult = await eslint.lintText(fileContent, { 61 | filePath, 62 | }); 63 | 64 | const { output } = lintResult[0]; 65 | 66 | return output || fileContent; 67 | }; 68 | 69 | const getChartConfig = (chart: string) => { 70 | return { 71 | cmpName: `${chart}Chart`, 72 | cmpPath: kebabCase(chart), 73 | }; 74 | }; 75 | 76 | const createComponents = async () => { 77 | const promises = newCharts.map(async (chart) => { 78 | const cmp = ` 79 | import React, { forwardRef } from 'react' 80 | import { ${chart}, ${chart}Options } from '@antv/g2plot' 81 | import BaseChart, { BaseChartProps } from '../../components/base' 82 | 83 | export type ${chart}ChartProps = Omit, 'chart'> & 84 | ${chart}Options 85 | 86 | const ${chart}Chart = forwardRef( 87 | (props, ref) => { 88 | return 89 | } 90 | ) 91 | 92 | export default ${chart}Chart 93 | `; 94 | 95 | const { cmpPath } = getChartConfig(chart); 96 | const dir = path.resolve(plotDir, cmpPath); 97 | await mkdir(dir); 98 | const filePath = path.resolve(dir, 'index.tsx'); 99 | const fixedContent = await lintAndFixFileContent(cmp, filePath); 100 | 101 | await writeFile(filePath, fixedContent, { 102 | encoding: 'utf8', 103 | }); 104 | }); 105 | 106 | await Promise.all(promises); 107 | }; 108 | 109 | const addExport = async () => { 110 | let exportFileContent = await readFile(exportPath, { 111 | encoding: 'utf8', 112 | }); 113 | 114 | newCharts.forEach((chart) => { 115 | const chartName = chart + 'Chart'; 116 | const { cmpPath } = getChartConfig(chart); 117 | const importPath = `./plots/${cmpPath}`; 118 | 119 | const content = ` 120 | import { ${chartName}Props as _${chartName}Props } from '${importPath}' 121 | \nexport { default as ${chartName} } from '${importPath}' 122 | export type ${chartName}Props = _${chartName}Props 123 | `; 124 | 125 | exportFileContent += content; 126 | }); 127 | 128 | const fixedContent = await lintAndFixFileContent(exportFileContent, exportPath); 129 | 130 | writeFile(exportPath, fixedContent, { 131 | encoding: 'utf8', 132 | }); 133 | }; 134 | 135 | const createTestCases = async () => { 136 | const promises = newCharts.map(async (chart) => { 137 | const { cmpPath } = getChartConfig(chart); 138 | const cmp = ` 139 | import React from 'react' 140 | import { create } from 'react-test-renderer' 141 | import ${chart}Chart from '../../src/plots/${cmpPath}' 142 | 143 | describe('${chart}Chart', () => { 144 | test('should render without crashed', () => { 145 | const result = render(<${chart}Chart data={[]} />) 146 | 147 | expect(result.container).toMatchSnapshot() 148 | }) 149 | }) 150 | `; 151 | 152 | const filePath = path.resolve(testDir, `${cmpPath}.spec.tsx`); 153 | const fixedContent = await lintAndFixFileContent(cmp, filePath); 154 | 155 | await writeFile(filePath, fixedContent, { 156 | encoding: 'utf8', 157 | }); 158 | }); 159 | 160 | await Promise.all(promises); 161 | }; 162 | 163 | const createDocs = async () => { 164 | const docTemplate = await fs.promises.readFile(path.resolve(__dirname, 'doc-template.ftl'), { 165 | encoding: 'utf-8', 166 | }); 167 | await Promise.all( 168 | allCharts.map(async (chart) => { 169 | const { cmpPath, cmpName } = getChartConfig(chart); 170 | 171 | const docFilePath = path.resolve(process.cwd(), `docs/api/${cmpPath}.md`); 172 | const docContent = stringTemplate(docTemplate, { 173 | cmpName, 174 | srcPath: `../../src/plots/${cmpPath}/index.tsx`, 175 | }); 176 | await fs.promises.writeFile(docFilePath, docContent, { 177 | encoding: 'utf-8', 178 | }); 179 | }), 180 | ); 181 | }; 182 | 183 | const start = async () => { 184 | await Promise.all([createComponents(), addExport(), createTestCases(), createDocs()]); 185 | console.log('Sync done'); 186 | }; 187 | 188 | start(); 189 | -------------------------------------------------------------------------------- /src/components/base/index.tsx: -------------------------------------------------------------------------------- 1 | import { Plot as BasePlot } from '@antv/g2plot'; 2 | import cloneDeep from 'lodash/cloneDeep'; 3 | import isEmpty from 'lodash/isEmpty'; 4 | import isEqual from 'lodash/isEqual'; 5 | import { 6 | forwardRef, 7 | HTMLAttributes, 8 | ReactElement, 9 | Ref, 10 | RefAttributes, 11 | RefCallback, 12 | RefObject, 13 | useEffect, 14 | useImperativeHandle, 15 | useRef, 16 | } from 'react'; 17 | 18 | interface Options { 19 | [x: string]: any; 20 | } 21 | 22 | type PickedAttrs = 'className' | 'style'; 23 | 24 | type ChartConfig = Omit; 25 | 26 | export interface Plot { 27 | new (container: HTMLElement, config: C): BasePlot; 28 | } 29 | 30 | const syncRef = ( 31 | source: RefObject | null>, 32 | target?: RefCallback | null> | RefObject | null>, 33 | ) => { 34 | /* istanbul ignore else */ 35 | if (typeof target === 'function') { 36 | target(source.current); 37 | } else if (target) { 38 | target.current = source.current; 39 | } 40 | }; 41 | 42 | export interface BaseChartProps extends Pick, PickedAttrs> { 43 | /** 44 | * Plot Class 45 | * @note Internal use, should not use directly 46 | */ 47 | chart: Plot; 48 | /** 49 | * Plot Ref 50 | */ 51 | chartRef?: RefCallback | null> | RefObject | null>; 52 | data?: Record | Record[]; 53 | onReady?: (plot: BasePlot) => void; 54 | } 55 | 56 | const BaseChart = (props: BaseChartProps, ref?: Ref) => { 57 | const { chart: Chart, style, className, chartRef: chart, onReady, ...restProps } = props; 58 | const chartRef = useRef | null>(null); 59 | const configRef = useRef(null); 60 | const containerRef = useRef(null); 61 | const isFirstRenderRef = useRef(true); 62 | const dataRef = useRef[]>([]); 63 | 64 | useImperativeHandle(ref, () => containerRef.current as HTMLDivElement); 65 | 66 | useEffect(() => { 67 | const { current: container } = containerRef; 68 | /* istanbul ignore else */ 69 | if (container) { 70 | const { data, ...config } = restProps as Options; 71 | configRef.current = cloneDeep(config); 72 | const normalizedData = data || []; 73 | dataRef.current = normalizedData; 74 | const mergedConfig = { 75 | ...config, 76 | data: normalizedData, 77 | } as any; 78 | chartRef.current = new Chart(container, mergedConfig); 79 | chartRef.current.render(); 80 | } 81 | syncRef(chartRef, chart); 82 | if (chartRef.current) { 83 | onReady?.(chartRef.current); 84 | } 85 | return () => { 86 | /* istanbul ignore else */ 87 | if (chartRef.current) { 88 | chartRef.current.destroy(); 89 | chartRef.current = null; 90 | syncRef(chartRef, chart); 91 | } 92 | }; 93 | // eslint-disable-next-line 94 | }, []); 95 | 96 | useEffect(() => { 97 | const { current: chart } = chartRef; 98 | /* istanbul ignore else */ 99 | if (chart) { 100 | // avoid update in first time 101 | if (!isFirstRenderRef.current) { 102 | const { data, ...config } = restProps as Options; 103 | const normalizedData = data || []; 104 | if (!isEqual(config, configRef.current) || isEmpty(dataRef.current)) { 105 | configRef.current = cloneDeep(config); 106 | const mergedConfig = { 107 | ...config, 108 | data: normalizedData, 109 | }; 110 | 111 | chart.update(mergedConfig as any); 112 | chart.render(); 113 | } else { 114 | chart.changeData(normalizedData); 115 | } 116 | dataRef.current = normalizedData; 117 | } else { 118 | isFirstRenderRef.current = false; 119 | } 120 | } 121 | }, [restProps]); 122 | 123 | return
; 124 | }; 125 | 126 | export default forwardRef(BaseChart) as ( 127 | p: BaseChartProps & RefAttributes, 128 | ) => ReactElement; 129 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import { BaseChartProps as _BaseChartProps } from './components/base'; 2 | // base plots 3 | import { AreaChartProps as _AreaChartProps } from './plots/area'; 4 | import { BarChartProps as _BarChartProps } from './plots/bar'; 5 | import { BulletChartProps as _BulletChartProps } from './plots/bullet'; 6 | import { ColumnChartProps as _ColumnChartProps } from './plots/column'; 7 | import { FunnelChartProps as _FunnelChartProps } from './plots/funnel'; 8 | import { GaugeChartProps as _GaugeChartProps } from './plots/gauge'; 9 | import { HeatmapChartProps as _HeatmapChartProps } from './plots/heatmap'; 10 | import { HistogramChartProps as _HistogramChartProps } from './plots/histogram'; 11 | import { LineChartProps as _LineChartProps } from './plots/line'; 12 | import { LiquidChartProps as _LiquidChartProps } from './plots/liquid'; 13 | import { PieChartProps as _PieChartProps } from './plots/pie'; 14 | import { RadarChartProps as _RadarChartProps } from './plots/radar'; 15 | import { RoseChartProps as _RoseChartProps } from './plots/rose'; 16 | import { ScatterChartProps as _ScatterChartProps } from './plots/scatter'; 17 | import { WaterfallChartProps as _WaterfallChartProps } from './plots/waterfall'; 18 | import { WordCloudChartProps as _WordCloudChartProps } from './plots/word-cloud'; 19 | 20 | // mini plots 21 | import { ProgressChartProps as _ProgressChartProps } from './plots/progress'; 22 | import { RingProgressChartProps as _RingProgressChartProps } from './plots/ring-progress'; 23 | import { TinyAreaChartProps as _TinyAreaChartProps } from './plots/tiny-area'; 24 | import { TinyColumnChartProps as _TinyColumnChartProps } from './plots/tiny-column'; 25 | import { TinyLineChartProps as _TinyLineChartProps } from './plots/tiny-line'; 26 | 27 | import { DualAxesChartProps as _DualAxesChartProps } from './plots/dual-axes'; 28 | 29 | import { BoxChartProps as _BoxChartProps } from './plots/box'; 30 | 31 | import { StockChartProps as _StockChartProps } from './plots/stock'; 32 | 33 | import { SunburstChartProps as _SunburstChartProps } from './plots/sunburst'; 34 | 35 | import { RadialBarChartProps as _RadialBarChartProps } from './plots/radial-bar'; 36 | 37 | import { BidirectionalBarChartProps as _BidirectionalBarChartProps } from './plots/bidirectional-bar'; 38 | 39 | import { SankeyChartProps as _SankeyChartProps } from './plots/sankey'; 40 | 41 | import { TreemapChartProps as _TreemapChartProps } from './plots/treemap'; 42 | 43 | import { ChordChartProps as _ChordChartProps } from './plots/chord'; 44 | 45 | import { MultiViewChartProps as _MultiViewChartProps } from './plots/multi-view'; 46 | 47 | import { MixChartProps as _MixChartProps } from './plots/mix'; 48 | 49 | import { ViolinChartProps as _ViolinChartProps } from './plots/violin'; 50 | 51 | import { FacetChartProps as _FacetChartProps } from './plots/facet'; 52 | 53 | import { CirclePackingChartProps as _CirclePackingChartProps } from './plots/circle-packing'; 54 | 55 | import { Options } from '@antv/g2plot'; 56 | import { VennChartProps as _VennChartProps } from './plots/venn'; 57 | 58 | export { default as BaseChart } from './components/base'; 59 | export { default as AreaChart } from './plots/area'; 60 | export { default as BarChart } from './plots/bar'; 61 | export { default as BidirectionalBarChart } from './plots/bidirectional-bar'; 62 | export { default as BoxChart } from './plots/box'; 63 | export { default as BulletChart } from './plots/bullet'; 64 | export { default as ChordChart } from './plots/chord'; 65 | export { default as CirclePackingChart } from './plots/circle-packing'; 66 | export { default as ColumnChart } from './plots/column'; 67 | export { default as DualAxesChart } from './plots/dual-axes'; 68 | export { default as FacetChart } from './plots/facet'; 69 | export { default as FunnelChart } from './plots/funnel'; 70 | export { default as GaugeChart } from './plots/gauge'; 71 | export { default as HeatmapChart } from './plots/heatmap'; 72 | export { default as HistogramChart } from './plots/histogram'; 73 | export { default as LineChart } from './plots/line'; 74 | export { default as LiquidChart } from './plots/liquid'; 75 | export { default as MixChart } from './plots/mix'; 76 | export { default as MultiViewChart } from './plots/multi-view'; 77 | export { default as PieChart } from './plots/pie'; 78 | // mini plots 79 | export { default as ProgressChart } from './plots/progress'; 80 | export { default as RadarChart } from './plots/radar'; 81 | export { default as RadialBarChart } from './plots/radial-bar'; 82 | export { default as RingProgressChart } from './plots/ring-progress'; 83 | export { default as RoseChart } from './plots/rose'; 84 | export { default as SankeyChart } from './plots/sankey'; 85 | export { default as ScatterChart } from './plots/scatter'; 86 | export { default as StockChart } from './plots/stock'; 87 | export { default as SunburstChart } from './plots/sunburst'; 88 | export { default as TinyAreaChart } from './plots/tiny-area'; 89 | export { default as TinyColumnChart } from './plots/tiny-column'; 90 | export { default as TinyLineChart } from './plots/tiny-line'; 91 | export { default as TreemapChart } from './plots/treemap'; 92 | export { default as VennChart } from './plots/venn'; 93 | export { default as ViolinChart } from './plots/violin'; 94 | export { default as WaterfallChart } from './plots/waterfall'; 95 | export { default as WordCloudChart } from './plots/word-cloud'; 96 | 97 | export type BaseChartProps = _BaseChartProps; 98 | 99 | export type AreaChartProps = _AreaChartProps; 100 | 101 | export type BarChartProps = _BarChartProps; 102 | 103 | export type BulletChartProps = _BulletChartProps; 104 | 105 | export type ColumnChartProps = _ColumnChartProps; 106 | 107 | export type FunnelChartProps = _FunnelChartProps; 108 | 109 | export type GaugeChartProps = _GaugeChartProps; 110 | 111 | export type HeatmapChartProps = _HeatmapChartProps; 112 | 113 | export type HistogramChartProps = _HistogramChartProps; 114 | 115 | export type LineChartProps = _LineChartProps; 116 | 117 | export type LiquidChartProps = _LiquidChartProps; 118 | 119 | export type PieChartProps = _PieChartProps; 120 | 121 | export type RadarChartProps = _RadarChartProps; 122 | 123 | export type RoseChartProps = _RoseChartProps; 124 | 125 | export type ScatterChartProps = _ScatterChartProps; 126 | 127 | export type WordCloudChartProps = _WordCloudChartProps; 128 | 129 | export type ProgressChartProps = _ProgressChartProps; 130 | 131 | export type RingProgressChartProps = _RingProgressChartProps; 132 | 133 | export type TinyAreaChartProps = _TinyAreaChartProps; 134 | 135 | export type TinyColumnChartProps = _TinyColumnChartProps; 136 | 137 | export type TinyLineChartProps = _TinyLineChartProps; 138 | 139 | export type WaterfallChartProps = _WaterfallChartProps; 140 | 141 | export type DualAxesChartProps = _DualAxesChartProps; 142 | 143 | export type BoxChartProps = _BoxChartProps; 144 | 145 | export type StockChartProps = _StockChartProps; 146 | 147 | export type SunburstChartProps = _SunburstChartProps; 148 | 149 | export type RadialBarChartProps = _RadialBarChartProps; 150 | 151 | export type BidirectionalBarChartProps = _BidirectionalBarChartProps; 152 | 153 | export type SankeyChartProps = _SankeyChartProps; 154 | 155 | export type TreemapChartProps = _TreemapChartProps; 156 | 157 | export type ChordChartProps = _ChordChartProps; 158 | 159 | export type MultiViewChartProps = _MultiViewChartProps; 160 | 161 | export type MixChartProps = _MixChartProps; 162 | 163 | export type ViolinChartProps = _ViolinChartProps; 164 | 165 | export type FacetChartProps = _FacetChartProps; 166 | 167 | export type CirclePackingChartProps = _CirclePackingChartProps; 168 | 169 | export type VennChartProps = _VennChartProps; 170 | -------------------------------------------------------------------------------- /src/plots/area/index.tsx: -------------------------------------------------------------------------------- 1 | import { Area, AreaOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type AreaChartProps = Omit, 'chart' | 'data'> & AreaOptions; 6 | 7 | const AreaChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default AreaChart; 12 | -------------------------------------------------------------------------------- /src/plots/bar/index.tsx: -------------------------------------------------------------------------------- 1 | import { Bar, BarOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type BarChartProps = Omit, 'chart' | 'data'> & BarOptions; 6 | 7 | const BarChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default BarChart; 12 | -------------------------------------------------------------------------------- /src/plots/bidirectional-bar/index.tsx: -------------------------------------------------------------------------------- 1 | import { BidirectionalBar, BidirectionalBarOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type BidirectionalBarChartProps = Omit, 'chart' | 'data'> & 6 | BidirectionalBarOptions; 7 | 8 | const BidirectionalBarChart = forwardRef((props, ref) => { 9 | return ; 10 | }); 11 | 12 | export default BidirectionalBarChart; 13 | -------------------------------------------------------------------------------- /src/plots/box/index.tsx: -------------------------------------------------------------------------------- 1 | import { Box, BoxOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type BoxChartProps = Omit, 'chart' | 'data'> & BoxOptions; 6 | 7 | const BoxChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default BoxChart; 12 | -------------------------------------------------------------------------------- /src/plots/bullet/index.tsx: -------------------------------------------------------------------------------- 1 | import { Bullet, BulletOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type BulletChartProps = Omit, 'chart' | 'data'> & BulletOptions; 6 | 7 | const BulletChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default BulletChart; 12 | -------------------------------------------------------------------------------- /src/plots/chord/index.tsx: -------------------------------------------------------------------------------- 1 | import { Chord, ChordOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type ChordChartProps = Omit, 'chart' | 'data'> & ChordOptions; 6 | 7 | const ChordChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default ChordChart; 12 | -------------------------------------------------------------------------------- /src/plots/circle-packing/index.tsx: -------------------------------------------------------------------------------- 1 | import { CirclePacking, CirclePackingOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type CirclePackingChartProps = Omit, 'chart' | 'data'> & 6 | CirclePackingOptions; 7 | 8 | const CirclePackingChart = forwardRef((props, ref) => { 9 | return ; 10 | }); 11 | 12 | export default CirclePackingChart; 13 | -------------------------------------------------------------------------------- /src/plots/column/index.tsx: -------------------------------------------------------------------------------- 1 | import { Column, ColumnOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type ColumnChartProps = Omit, 'chart' | 'data'> & ColumnOptions; 6 | 7 | const ColumnChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default ColumnChart; 12 | -------------------------------------------------------------------------------- /src/plots/dual-axes/index.tsx: -------------------------------------------------------------------------------- 1 | import { DualAxes, DualAxesOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type DualAxesChartProps = Omit, 'chart' | 'data'> & DualAxesOptions; 6 | 7 | const DualAxesChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default DualAxesChart; 12 | -------------------------------------------------------------------------------- /src/plots/facet/index.tsx: -------------------------------------------------------------------------------- 1 | import { Facet, FacetOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type FacetChartProps = Omit, 'chart' | 'data'> & FacetOptions; 6 | 7 | const FacetChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default FacetChart; 12 | -------------------------------------------------------------------------------- /src/plots/funnel/index.tsx: -------------------------------------------------------------------------------- 1 | import { Funnel, FunnelOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type FunnelChartProps = Omit, 'chart' | 'data'> & FunnelOptions; 6 | 7 | const FunnelChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default FunnelChart; 12 | -------------------------------------------------------------------------------- /src/plots/gauge/index.tsx: -------------------------------------------------------------------------------- 1 | import { Gauge, GaugeOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type GaugeChartProps = Omit, 'chart' | 'data'> & GaugeOptions; 6 | 7 | const GaugeChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default GaugeChart; 12 | -------------------------------------------------------------------------------- /src/plots/heatmap/index.tsx: -------------------------------------------------------------------------------- 1 | import { Heatmap, HeatmapOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type HeatmapChartProps = Omit, 'chart' | 'data'> & HeatmapOptions; 6 | 7 | const HeatmapChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default HeatmapChart; 12 | -------------------------------------------------------------------------------- /src/plots/histogram/index.tsx: -------------------------------------------------------------------------------- 1 | import { Histogram, HistogramOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type HistogramChartProps = Omit, 'chart' | 'data'> & HistogramOptions; 6 | 7 | const HistogramChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default HistogramChart; 12 | -------------------------------------------------------------------------------- /src/plots/line/index.tsx: -------------------------------------------------------------------------------- 1 | import { Line, LineOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type LineChartProps = Omit, 'chart' | 'data'> & LineOptions; 6 | 7 | const LineChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default LineChart; 12 | -------------------------------------------------------------------------------- /src/plots/liquid/index.tsx: -------------------------------------------------------------------------------- 1 | import { Liquid, LiquidOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type LiquidChartProps = Omit, 'chart' | 'data'> & LiquidOptions; 6 | 7 | const LiquidChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default LiquidChart; 12 | -------------------------------------------------------------------------------- /src/plots/mix/index.tsx: -------------------------------------------------------------------------------- 1 | import { Mix, MixOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type MixChartProps = Omit, 'chart' | 'data'> & MixOptions; 6 | 7 | const MixChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default MixChart; 12 | -------------------------------------------------------------------------------- /src/plots/multi-view/index.tsx: -------------------------------------------------------------------------------- 1 | import { Mix, MixOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type MultiViewChartProps = Omit, 'chart' | 'data'> & MixOptions; 6 | 7 | /** 8 | * @deprecated use `MixChart` instead 9 | */ 10 | const MultiViewChart = forwardRef((props, ref) => { 11 | return ; 12 | }); 13 | 14 | export default MultiViewChart; 15 | -------------------------------------------------------------------------------- /src/plots/pie/index.tsx: -------------------------------------------------------------------------------- 1 | import { Pie, PieOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type PieChartProps = Omit, 'chart' | 'data'> & PieOptions; 6 | 7 | const PieChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default PieChart; 12 | -------------------------------------------------------------------------------- /src/plots/progress/index.tsx: -------------------------------------------------------------------------------- 1 | import { Progress, ProgressOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type ProgressChartProps = Omit, 'chart' | 'data'> & ProgressOptions; 6 | 7 | const ProgressChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default ProgressChart; 12 | -------------------------------------------------------------------------------- /src/plots/radar/index.tsx: -------------------------------------------------------------------------------- 1 | import { Radar, RadarOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type RadarChartProps = Omit, 'chart' | 'data'> & RadarOptions; 6 | 7 | const RadarChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default RadarChart; 12 | -------------------------------------------------------------------------------- /src/plots/radial-bar/index.tsx: -------------------------------------------------------------------------------- 1 | import { RadialBar, RadialBarOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type RadialBarChartProps = Omit, 'chart' | 'data'> & RadialBarOptions; 6 | 7 | const RadialBarChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default RadialBarChart; 12 | -------------------------------------------------------------------------------- /src/plots/ring-progress/index.tsx: -------------------------------------------------------------------------------- 1 | import { RingProgress, RingProgressOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type RingProgressChartProps = Omit, 'chart' | 'data'> & RingProgressOptions; 6 | 7 | const RingProgressChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default RingProgressChart; 12 | -------------------------------------------------------------------------------- /src/plots/rose/index.tsx: -------------------------------------------------------------------------------- 1 | import { Rose, RoseOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type RoseChartProps = Omit, 'chart' | 'data'> & RoseOptions; 6 | 7 | const RoseChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default RoseChart; 12 | -------------------------------------------------------------------------------- /src/plots/sankey/index.tsx: -------------------------------------------------------------------------------- 1 | import { Sankey, SankeyOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type SankeyChartProps = Omit, 'chart' | 'data'> & SankeyOptions; 6 | 7 | const SankeyChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default SankeyChart; 12 | -------------------------------------------------------------------------------- /src/plots/scatter/index.tsx: -------------------------------------------------------------------------------- 1 | import { Scatter, ScatterOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type ScatterChartProps = Omit, 'chart' | 'data'> & ScatterOptions; 6 | 7 | const ScatterChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default ScatterChart; 12 | -------------------------------------------------------------------------------- /src/plots/stock/index.tsx: -------------------------------------------------------------------------------- 1 | import { Stock, StockOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type StockChartProps = Omit, 'chart' | 'data'> & StockOptions; 6 | 7 | const StockChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default StockChart; 12 | -------------------------------------------------------------------------------- /src/plots/sunburst/index.tsx: -------------------------------------------------------------------------------- 1 | import { Sunburst, SunburstOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type SunburstChartProps = Omit, 'chart' | 'data'> & SunburstOptions; 6 | 7 | const SunburstChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default SunburstChart; 12 | -------------------------------------------------------------------------------- /src/plots/tiny-area/index.tsx: -------------------------------------------------------------------------------- 1 | import { TinyArea, TinyAreaOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type TinyAreaChartProps = Omit, 'chart' | 'data'> & TinyAreaOptions; 6 | 7 | const TinyAreaChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default TinyAreaChart; 12 | -------------------------------------------------------------------------------- /src/plots/tiny-column/index.tsx: -------------------------------------------------------------------------------- 1 | import { TinyColumn, TinyColumnOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type TinyColumnChartProps = Omit, 'chart' | 'data'> & TinyColumnOptions; 6 | 7 | const TinyColumnChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default TinyColumnChart; 12 | -------------------------------------------------------------------------------- /src/plots/tiny-line/index.tsx: -------------------------------------------------------------------------------- 1 | import { TinyLine, TinyLineOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type TinyLineChartProps = Omit, 'chart' | 'data'> & TinyLineOptions; 6 | 7 | const TinyLineChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default TinyLineChart; 12 | -------------------------------------------------------------------------------- /src/plots/treemap/index.tsx: -------------------------------------------------------------------------------- 1 | import { Treemap, TreemapOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type TreemapChartProps = Omit, 'chart' | 'data'> & TreemapOptions; 6 | 7 | const TreemapChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default TreemapChart; 12 | -------------------------------------------------------------------------------- /src/plots/venn/index.tsx: -------------------------------------------------------------------------------- 1 | import { Venn, VennOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type VennChartProps = Omit, 'chart'> & VennOptions; 6 | 7 | const VennChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default VennChart; 12 | -------------------------------------------------------------------------------- /src/plots/violin/index.tsx: -------------------------------------------------------------------------------- 1 | import { Violin, ViolinOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type ViolinChartProps = Omit, 'chart' | 'data'> & ViolinOptions; 6 | 7 | const ViolinChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default ViolinChart; 12 | -------------------------------------------------------------------------------- /src/plots/waterfall/index.tsx: -------------------------------------------------------------------------------- 1 | import { Waterfall, WaterfallOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type WaterfallChartProps = Omit, 'chart' | 'data'> & WaterfallOptions; 6 | 7 | const WaterfallChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default WaterfallChart; 12 | -------------------------------------------------------------------------------- /src/plots/word-cloud/index.tsx: -------------------------------------------------------------------------------- 1 | import { WordCloud, WordCloudOptions } from '@antv/g2plot'; 2 | import { forwardRef } from 'react'; 3 | import BaseChart, { BaseChartProps } from '../../components/base'; 4 | 5 | export type WordCloudChartProps = Omit, 'chart' | 'data'> & WordCloudOptions; 6 | 7 | const WordCloudChart = forwardRef((props, ref) => { 8 | return ; 9 | }); 10 | 11 | export default WordCloudChart; 12 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* Basic Options */ 4 | // "incremental": true, /* Enable incremental compilation */ 5 | "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */, 6 | "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, 7 | // "lib": [], /* Specify library files to be included in the compilation. */ 8 | // "allowJs": true, /* Allow javascript files to be compiled. */ 9 | // "checkJs": true, /* Report errors in .js files. */ 10 | "jsx": "react-jsx" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */, 11 | "declaration": true /* Generates corresponding '.d.ts' file. */, 12 | "emitDeclarationOnly": true, 13 | // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ 14 | // "sourceMap": true, /* Generates corresponding '.map' file. */ 15 | // "outFile": "./", /* Concatenate and emit output to single file. */ 16 | // "outDir": "./lib" /* Redirect output structure to the directory. */, 17 | "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, 18 | // "composite": true, /* Enable project compilation */ 19 | // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ 20 | // "removeComments": true, /* Do not emit comments to output. */ 21 | // "noEmit": true /* Do not emit outputs. */, 22 | // "importHelpers": true, /* Import emit helpers from 'tslib'. */ 23 | // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ 24 | // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ 25 | 26 | /* Strict Type-Checking Options */ 27 | "strict": true /* Enable all strict type-checking options. */, 28 | // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ 29 | // "strictNullChecks": true, /* Enable strict null checks. */ 30 | // "strictFunctionTypes": true, /* Enable strict checking of function types. */ 31 | // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ 32 | // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ 33 | // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ 34 | // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ 35 | 36 | /* Additional Checks */ 37 | "noUnusedLocals": true /* Report errors on unused locals. */, 38 | // "noUnusedParameters": true, /* Report errors on unused parameters. */ 39 | // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ 40 | // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ 41 | 42 | /* Module Resolution Options */ 43 | "moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */, 44 | // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ 45 | // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ 46 | // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ 47 | // "typeRoots": [], /* List of folders to include type definitions from. */ 48 | // "types": [], /* Type declaration files to be included in compilation. */ 49 | // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ 50 | "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, 51 | // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ 52 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 53 | 54 | /* Source Map Options */ 55 | // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ 56 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 57 | // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ 58 | // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ 59 | 60 | /* Experimental Options */ 61 | // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ 62 | // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ 63 | "skipLibCheck": true 64 | }, 65 | "include": ["src"], 66 | "exclude": ["lib", "es"] 67 | } 68 | --------------------------------------------------------------------------------