Official Angular plugin for amCharts V3
Installation
npm install amcharts/amcharts3-angular2 --save
How to use
- In your HTML file, load the amCharts library using
<script>
tags:
- In your app module, import the
AmChartsModule
module and add it to theimports
:
; @ {}
- Inject the
AmChartsService
into your app component, create a<div>
element with anid
, then use themakeChart
method to create the chart:
; @ private chart: any; {} { thischart = thisAmCharts; } { thisAmCharts; }
The first argument to makeChart
must be the same as the <div>
's id
. The id
can be whatever you want, but if you display multiple charts each chart must have a different id
When you are finished with the chart, you must call the destroyChart
method. It's good to put this inside the ngOnDestroy
method.
- If you want to change the chart after the chart has been created, you must make the changes using the
updateChart
method:
// This must be called when making any changes to the chartthisAmCharts;
You can see some examples in the examples
directory.
Changelog
1.2.0
- Adding in support for Angular 4
- Deprecating the
<amCharts>
element in favor of the newAmChartsService
1.1.0
- Various fixes
- Adding examples
1.0.0
- Initial release