Chart
NewBring data into focus with responsive charts powered by Chart.js.
Basic
Select a bar to inspect revenue, click a legend to toggle its series, or update the data.
Select a bar to inspect its value.
View data table
| Quarter | Revenue |
|---|---|
| Q1 | 42 |
| Q2 | 58 |
| Q3 | 73 |
| Q4 | 91 |
Pie
Compare the contribution of each traffic source.
View data table
| Category | Visits |
|---|---|
| Direct | 35 |
| Search | 30 |
| Social | 20 |
| 15 |
Doughnut
The same proportions with a hollow center.
View data table
| Category | Visits |
|---|---|
| Direct | 35 |
| Search | 30 |
| Social | 20 |
| 15 |
Vertical Bar
Compare online and retail sales across six months.
View data table
| Category | Online | Retail |
|---|---|---|
| January | 45 | 32 |
| February | 62 | 40 |
| March | 54 | 48 |
| April | 78 | 52 |
| May | 86 | 61 |
| June | 98 | 68 |
Horizontal Bar
Place categories on the vertical axis with indexAxis: y.
View data table
| Category | Online | Retail |
|---|---|---|
| January | 45 | 32 |
| February | 62 | 40 |
| March | 54 | 48 |
| April | 78 | 52 |
| May | 86 | 61 |
| June | 98 | 68 |
Stacked Bar
Combine both sales channels into a monthly total.
View data table
| Category | Online | Retail |
|---|---|---|
| January | 45 | 32 |
| February | 62 | 40 |
| March | 54 | 48 |
| April | 78 | 52 |
| May | 86 | 61 |
| June | 98 | 68 |
Line
Track the evolution of both sales channels.
View data table
| Category | Online | Retail |
|---|---|---|
| January | 45 | 32 |
| February | 62 | 40 |
| March | 54 | 48 |
| April | 78 | 52 |
| May | 86 | 61 |
| June | 98 | 68 |
MultiAxis
Show revenue and conversion rate using independent axes.
View data table
| Category | Revenue | Conversion (%) |
|---|---|---|
| January | 45 | 2.4 |
| February | 62 | 3.1 |
| March | 54 | 2.8 |
| April | 78 | 3.9 |
| May | 86 | 4.2 |
| June | 98 | 4.8 |
Line Styles
Use filled areas, curves and dashed lines to distinguish series.
View data table
| Category | Actual | Target |
|---|---|---|
| January | 45 | 50 |
| February | 62 | 60 |
| March | 54 | 70 |
| April | 78 | 80 |
| May | 86 | 90 |
| June | 98 | 100 |
Polar Area
Equal angles with radii proportional to the traffic share.
View data table
| Category | Visits |
|---|---|
| Direct | 35 |
| Search | 30 |
| Social | 20 |
| 15 |
Radar
Compare two teams across five skills.
View data table
| Category | Team A | Team B |
|---|---|---|
| Design | 85 | 70 |
| Delivery | 72 | 88 |
| Quality | 90 | 75 |
| Support | 78 | 82 |
| Research | 65 | 92 |
Combo
Combine a line target and monthly bars in one chart.
View data table
| Category | Target | Revenue |
|---|---|---|
| January | 50 | 45 |
| February | 60 | 62 |
| March | 70 | 54 |
| April | 80 | 78 |
| May | 90 | 86 |
| June | 100 | 98 |
Usage
Install Chart.js 4.5 or newer in your application, then import AvChart into your standalone component.
npm install chart.jsimport { AvChart, AvChartData, AvChartOptions } from 'avero-ui';
data: AvChartData = {
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
datasets: [{ label: 'Revenue', data: [42, 58, 73, 91] }]
};
options: AvChartOptions = { scales: { y: { beginAtZero: true } } };
<av-chart type="bar" [data]="data" [options]="options"
height="320px" ariaLabel="Quarterly revenue"
(onDataSelect)="select($event)" />API and accessibility
Inputs: type, data, options, plugins, responsive (true), width (100%), height (320px), ariaLabel, ariaLabelledBy and ariaDescribedBy. The type, datasets, options and plugins use Chart.js types and support mixed datasets.
Replace data or options to update a chart automatically. Call refresh() after in-place edits, reinit() to recreate the chart, resize() after layout changes, or update(mode) after changing the instance returned by getChart(). clear() clears the canvas; getCanvas() returns the canvas and getBase64Image() returns its current image after initialization.
Outputs: onReady provides the Chart.js instance; onDataSelect provides originalEvent, element, datasetIndex and index; onError reports loading or rendering failures. Existing options.onClick callbacks are preserved. Options default to maintainAspectRatio: false; responsive is controlled by the component input.
Charts initialize only in the browser after rendering. Data and plain options are copied before Chart.js receives them; custom plugins retain their identity. Instances and observers are released when the component is destroyed.
Canvas content does not provide keyboard access to individual data points. Supply a descriptive label and a data table or text alternative, as in these examples. Projected content appears below the canvas and is also available during SSR. Use options.animation: false when animation is unsuitable.