Chart Component
ABP Chart component exposed by @abp/ng.components/chart.js
is based on charts.js
v3+. You don't need to install the chart.js
package. Since the @abp/ng.components
is dependent on the chart.js
, the package is already installed in your project.
Chart component loads
chart.js
script lazy. So it does not increase the bundle size.
How to Use
First of all, need to import the ChartModule
to your feature module as follows:
Then, abp-chart
component can be used. See an example:
Important Note: Changing the chart data without creating a new data instance does not trigger change detection. In order to chart to redraw itself, a new data object needs to be created.
See the result:
Examples
Doughnut
Result:
Bar
Result:
Radar
Result:
See the chart.js
samples for more examples.
API
abp-chart
Properties
Name | Description | Type | Default |
---|---|---|---|
[type] |
Type of the chart. | string |
null |
[data] |
Chart data to display | any |
null |
[options] |
Chart options to customize | any |
null |
[plugins] |
Chart plugins to customize behavior | any |
null |
[width] |
Width of the chart | string |
null |
[height] |
Height of the chart | string |
null |
[responsive] |
Whether the chart is responsive | boolean |
true |
(dataSelect) |
A callback that executes when an element on the chart is clicked | EventEmitter<any> |
- |
(initialized) |
A callback that executes when the chart is initialized | EventEmitter<boolean> |
- |
Methods
Name | Description | Parameters |
---|---|---|
refresh |
Redraws the chart | - |
reinit |
Destroys the chart then creates it again | - |
getBase64Image |
Returns a base 64 encoded string of the chart in it's current state | - |
generateLegend |
Returns an HTML string of a legend for the chart | - |
getCanvas |
Returns the canvas HTML element | - |