ng-apexcharts is a wrapper for apexcharts for angular. It introduces one simple component that enables you to use apexcharts in an angular project.
For a demo checkout: Stackblitz example
- Install using npm:
npm install apexcharts ng-apexcharts --save
- Open angular.json and under scripts add:
- Add ng-apexcharts-module to imports
In any component you can use the chart using:
You need to provide at least the series and chart attribute to make sure the chart can get created.
You can also use any other attribute from the following options.
All options of the chart can inserted using the attributes. This is a list of all available attributes:
chart: ApexChart;annotations: ApexAnnotations;colors: string;dataLabels: ApexDataLabels;series: ApexAxisChartSeries | ApexNonAxisChartSeries;stroke: ApexStroke;labels: string;legend: ApexLegend;fill: ApexFill;tooltip: ApexTooltip;plotOptions: ApexPlotOptions;responsive: ApexResponsive;xaxis: ApexXAxis;yaxis: ApexYAxis | ApexYAxis;grid: ApexGrid;states: ApexStates;title: ApexTitleSubtitle;subtitle: ApexTitleSubtitle;theme: ApexTheme;
Auto update series
With the attribute
autoUpdateSeries you can control if the chart component should
updateSeries function automatically if the series attribute is changed.
Set this attribute to false if you are using and changig the type property in your
series for a mixed chart. This only has the effect that the whole chart rerenders
even if only the series changes.
For a basic usage of the charts you dont need to use the methods of the chart.
But if you want to toggle a series for example you need to call them. All methods are proxied through the component so that you dont need to access the DOM by yourself.
Just reference the component as a ViewChild in your Component by using:
and chaning the template to this:
Now you're able to call methods from your Component.