-
Use
gitto download theamcharts3-reactplugin:git clone https://github.com/amcharts/amcharts3-react.git -
Include
reactandreact-dom:<script src="https://unpkg.com/[email protected]/dist/react.min.js"></script> <script src="https://unpkg.com/[email protected]/dist/react-dom.min.js"></script> -
Also include
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> -
Lastly include the
amcharts3-reactplugin:<script src="amcharts3-react/amcharts3-react.js"></script>
-
Create a
package.jsonwhich includesreact,react-dom,amcharts/amcharts3, andamcharts/amcharts3-react:{ "devDependencies": { "react": "^15.4.2", "react-dom": "^15.4.2", "amcharts3": "amcharts/amcharts3", "amcharts3-react": "amcharts/amcharts3-react" } } -
Run
npm install -
You can now import the
amcharts3-reactplugin:var AmCharts = require("amcharts3-react");And then you can use it:
React.createElement(AmCharts.React, { ... });Or alternatively if you are using JSX:
<AmCharts.React ... /> -
You will probably need to specify the
pathproperty, so that AmCharts can find the appropriate images:React.createElement(AmCharts.React, { "path": "node_modules/amcharts3/amcharts" }) -
If you want to use plugins (like dataloader, export, responsive, animate, etc.) you will need to do the following steps:
-
Include the plugin in your
package.json:{ "devDependencies": { "amcharts3-export": "amcharts/export" } } -
When you want to use the plugin, put a
requireat the top of the file:// This must be at the top of the file: require("amcharts3-export"); // The rest of the code goes here: var React = require("react"); var AmCharts = require("amcharts3-react"); React.createElement(AmCharts.React, { "export": { "enabled": true } });
You can see an example program in the
examples/webpack-exportfolder. -
Use the AmCharts.React component in your React programs:
React.createElement(AmCharts.React, {
"type": "serial",
"theme": "light",
"graphs": [...],
"dataProvider": [...]
})
Or alternatively if you are using JSX:
<AmCharts.React
type="serial"
theme="light"
graphs={[...]}
dataProvider={[...]} />
The configuration is exactly the same as the AmCharts.makeChart method.
Changes to the configuration 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 see some example React programs in the examples folder. It updates the chart's dataProvider every 3 seconds.
- Fixing another bug with updating the chart data
- Fixing a bug where the chart does not zoom out when changing the
dataProvider
- Fixing a bug where the chart won't show up properly on the first update
- Fixing a bug which caused stock charts to not update correctly
- Deprecating using
AmChartswith Webpack, instead useAmCharts.React - Adding in the various global
AmChartsproperties for Webpack
- Fixing a bug that caused the
listenersto trigger multiple times
- Fixing an issue with
peerDependencies
- Adding in support for npm / webpack
- Initial release