Angular UI Components Documentation
This tutorial builds an Angular CLI application with a horizontal column chart of country populations. It shows how chart settings map to component inputs and how to refresh the chart when the data changes.
npm install -g @angular/cli
ng new jqwidgets-chart-app
cd jqwidgets-chart-app
npm install jqwidgets-ng
Use Node 22 or later, and answer No to server-side rendering when ng new asks.
The chart draws with SVG, but its tooltips and title use the jQWidgets stylesheets. Add them to the styles array in angular.json:
"styles": [
"node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css",
"node_modules/jqwidgets-ng/jqwidgets/styles/jqx.light.css",
"src/styles.css"
]
The chart's settings are ordinary inputs: source holds the rows, xAxis names the category field, and seriesGroups describes how to draw the values.
src/app/app.ts:
import { Component, viewChild } from '@angular/core';
import { jqxChartComponent, jqxChartModule } from 'jqwidgets-ng/jqxchart';
interface CountryPopulation {
Country: string;
Population: number;
Percent: number;
}
@Component({ selector: 'app-root', imports: [jqxChartModule], templateUrl: './app.html' })
export class App {
readonly myChart = viewChild.required<jqxChartComponent>('myChart');
readonly sampleData: CountryPopulation[] = [
{ Country: 'India', Population: 1438069596, Percent: 17.8 },
{ Country: 'China', Population: 1409670000, Percent: 17.5 },
{ Country: 'USA', Population: 340110988, Percent: 4.2 },
{ Country: 'Indonesia', Population: 281190067, Percent: 3.5 },
{ Country: 'Pakistan', Population: 247504495, Percent: 3.1 }
];
readonly padding = { left: 20, top: 5, right: 20, bottom: 5 };
readonly titlePadding = { left: 90, top: 0, right: 0, bottom: 10 };
readonly xAxis = { dataField: 'Country', gridLines: { visible: true } };
readonly valueAxis = {
flip: true,
labels: {
visible: true,
formatFunction: (value: string): string =>
String(Math.round(parseInt(value, 10) / 1000000))
}
};
readonly seriesGroups = [
{
type: 'column',
orientation: 'horizontal',
columnsGapPercent: 50,
toolTipFormatSettings: { thousandsSeparator: ',' },
series: [{ dataField: 'Population', displayText: 'Population (millions)' }]
}
];
showPercent(): void {
const chart = this.myChart();
chart.seriesGroups()[0].series[0] = {
dataField: 'Percent',
displayText: 'Share of world population (%)'
};
chart.valueAxis({ flip: true, labels: { visible: true } });
chart.update();
}
}
src/app/app.html:
<jqxChart #myChart
[width]="850"
[height]="500"
[title]="'Most populous countries'"
[description]="'Population in millions, 2024'"
[showLegend]="true"
[enableAnimations]="true"
[padding]="padding"
[titlePadding]="titlePadding"
[source]="sampleData"
[xAxis]="xAxis"
[valueAxis]="valueAxis"
[seriesGroups]="seriesGroups"
[colorScheme]="'scheme01'">
</jqxChart>
<button type="button" (click)="showPercent()">Show share of world population</button>
Chart settings are read when the chart renders. When you change a setting object in place, call the chart's update method so it redraws, as showPercent does.
ng serve
Open http://localhost:4200/. Hover a bar to see the tooltip with thousands separators, then press the button to switch the series.
Next: Angular Chart getting started, or the same setup with a data grid. More chart types: jQWidgets Angular demos.