@amcharts/amcharts3-react

中文文档
3.1.1发布于 2023/01/01SEE LICENSE IN LICENSECommonJS近 30 天下载 1.3万

How to install ==============

原始使用文档
文档目录22 节
  1. Changelog
  2. 3.1.1
  3. 3.1.0
  4. 3.0.3
  5. 3.0.0
  6. 2.0.7
  7. 2.0.6
  8. 2.0.5
  9. 2.0.4
  10. 2.0.3
  11. 2.0.2
  12. 2.0.0
  13. 1.1.8
  14. 1.1.7
  15. 1.1.6
  16. 1.1.5
  17. 1.1.4
  18. 1.1.3
  19. 1.1.2
  20. 1.1.1
  21. 1.1.0
  22. 1.0.0

How to install

  1. Create a package.json which includes react, react-dom, and @amcharts/amcharts3-react:

    {
      "devDependencies": {
        "react": "^16.0.0",
        "react-dom": "^16.0.0",
        "@amcharts/amcharts3-react": "^3.0.0"
      }
    }
    
  2. Run npm install

  3. Use <script> tags in your HTML file to load AmCharts:

    <script src="https://www.amcharts.com/lib/3/amcharts.js"></script>
    <script src="https://www.amcharts.com/lib/3/serial.js"></script>
    <script src="https://www.amcharts.com/lib/3/themes/light.js"></script>
    
  4. If you are using a bundler (like Webpack), import the @amcharts/amcharts3-react plugin:

    import AmCharts from "@amcharts/amcharts3-react";
    

    If you are using <script> tags, include the React and amcharts3-react.js files in your HTML:

    <script src="node_modules/react/umd/react.production.min.js"></script>
    <script src="node_modules/react-dom/umd/react-dom.production.min.js"></script>
    <script src="node_modules/create-react-class/create-react-class.min.js"></script>
    <script src="node_modules/@amcharts/amcharts3-react/amcharts3-react.js"></script>
    

How to use

React.createElement(AmCharts.React, {
  className: "my-class",
  style: {
    width: "100%",
    height: "500px"
  },
  options: {
    "type": "serial",
    "theme": "light",
    "graphs": [...],
    "dataProvider": [...]
  }
})

Or alternatively if you are using JSX:

<AmCharts.React
  className="my-class"
  style={{
    width: "100%",
    height: "500px"
  }}
  options={{
    "type": "serial",
    "theme": "light",
    "graphs": [...],
    "dataProvider": [...]
  }} />

You can also define the options object separately:

var config = {
  "type": "serial",
  "theme": "light",
  "graphs": [...],
  "dataProvider": [...]
};

<AmCharts.React options={config} />

The options property supports exactly the same configuration as the AmCharts.makeChart method, so all of the AmCharts demos work the same.

Changes to options are automatically detected when rendering (you do not need to call validateNow or validateData).

In addition, this plugin automatically generates an id, so you do not need to specify it.

You can find some examples in the examples folder.


If you want to use plugins (like dataloader, export, responsive, animate, etc.) you will need to include the appropriate <script> tags.

Here is an example for the export plugin:

<link rel="stylesheet" href="https://www.amcharts.com/lib/3/plugins/export/export.css" type="text/css" media="all" />

<script src="https://www.amcharts.com/lib/3/plugins/export/export.min.js"></script>

You can see an example program in the examples/webpack-export folder. It updates the chart's dataProvider every 3 seconds.

Changelog

3.1.1

  • Adding in support for React 17 and React 18.

3.1.0

  • Adding in className property for specifying the CSS class for the element.

3.0.3

  • Fixing version ranges for react and react-dom

3.0.0

  • Rather than passing in the configuration directly, instead you must pass in the configuration using the new options property.

  • Adding in delay property for controlling the chart delay.

2.0.7

  • Reverting the code which waits for the chart to initialize.

2.0.6

  • It now waits for the chart to initialize before it updates (this fixes some errors).

2.0.5

  • Republishing 2.0.4

2.0.4

2.0.3

2.0.2

2.0.0

  • Major breaking change: this plugin no longer automatically imports AmCharts, so you must use <script> tags to load AmCharts

  • Major breaking change: you must now use AmCharts.React rather than AmCharts

1.1.8

  • Fixing another bug with updating the chart data

1.1.7

  • Fixing a bug where the chart does not zoom out when changing the dataProvider

1.1.6

  • Fixing a bug where the chart won't show up properly on the first update

1.1.5

  • Fixing a bug which caused stock charts to not update correctly

1.1.4

  • Deprecating using AmCharts with Webpack, instead use AmCharts.React
  • Adding in the various global AmCharts properties for Webpack

1.1.3

  • Fixing a bug that caused the listeners to trigger multiple times

1.1.2

1.1.1

1.1.0

  • Adding in support for npm / Webpack

1.0.0

  • Initial release

版本与发布记录

@amcharts/amcharts3-react 共发布 16 个版本,首次发布于 2017/03/31;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.1.1latest2023/01/013 年前
3.1.02018/04/168 年前
3.0.42018/01/168 年前
3.0.32017/10/269 年前
3.0.22017/10/139 年前
3.0.12017/09/029 年前

关于 @amcharts/amcharts3-react 的常见问题

@amcharts/amcharts3-react 是什么?

How to install ==============

如何安装 @amcharts/amcharts3-react?

在项目目录运行 npm install @amcharts/amcharts3-react,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0)、react-dom(^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@amcharts/amcharts3-react 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/amcharts__amcharts3-react 是否存在。

@amcharts/amcharts3-react 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amcharts/amcharts3-react 可以商用吗?

@amcharts/amcharts3-react 使用 SEE LICENSE IN LICENSE 许可。许可条款写在包内的独立文件中,请阅读该文件确认可否商用。以上为概括,不构成法律意见,请以许可原文为准。

@amcharts/amcharts3-react 的下载量有多少?

根据 npm 官方下载统计,@amcharts/amcharts3-react 在 2026/10/06 – 2026/11/04 这 30 天内被下载 13,145 次,日均约 438 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amcharts/amcharts3-react 还在维护吗?

最新版本 3.1.1 发布于 2023/01/01(3 年前);至今共发布 16 个版本,其中过去 12 个月发布了 0 个;首次发布于 2017/03/31。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。