For comprehensive amCharts 5 documentation, visit amcharts.com/docs/v5.
amCharts 5 core concepts
The root element
Every amCharts 5 chart starts with a root element. The root manages the chart lifecycle and is required to create every other amCharts object. Create it by passing the ID of a container<div>:
The .new() pattern
amCharts 5 uses a static .new() method instead of the new keyword to create instances. The first argument is always the root element:
Setting data
UsesetAll() to bind data to a series. Pass an array of objects where keys match the field names you configured on the series:
Themes
Themes control the visual appearance of chart elements. Apply themes to the root usingsetThemes(). You can combine multiple themes, and order matters — later themes override earlier ones:
Using Anvil2 themes in React
Basic setup pattern
amCharts 5 manages its own DOM, which does not fit naturally into React’s rendering model. Create the root in auseLayoutEffect and dispose of it on cleanup to prevent memory leaks.
In React Strict Mode, effects can run twice in development, so it’s important to dispose the chart root in the cleanup function to avoid duplicate chart instances and visual glitches:
Switching themes
To use a different Anvil2 theme, swap the import:Combining with amCharts built-in themes
Combine the Anvil2 themes with amCharts built-in themes for additional functionality. TheAnimated theme adds smooth transitions:
Chart modules
amCharts 5 organizes chart types into separate modules to keep bundle sizes small. Import only the modules you need:| Module | Import | Chart types |
|---|---|---|
| Core | @amcharts/amcharts5 | Root, Legend, Tooltip, Label, ColorSet |
| Percent | @amcharts/amcharts5/percent | PieChart, PieSeries (donut/pie charts) |
| XY | @amcharts/amcharts5/xy | XYChart, ColumnSeries, CategoryAxis, ValueAxis (bar charts) |
| Themes | @amcharts/amcharts5/themes/Animated | Built-in animation theme |
Next steps
- Bar Charts — Vertical, horizontal, grouped, and stacked bar chart examples
- Donut Charts — Pie and donut chart examples with legends
- Data Visualization Guidelines — Design guidelines for color palettes, variable ordering, and chart anatomy
- amCharts 5 Documentation — Full amCharts 5 reference