Example shows Angular Bar Chart with Category Axis. Category axis is automatically selected when you set labels in datapoints without setting x values.
/* app.component.ts */ import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { RouterOutlet } from '@angular/router'; import { CanvasJSAngularChartsModule } from '@canvasjs/angular-charts'; @Component({ selector: 'app-root', standalone: true, imports: [CommonModule, RouterOutlet, CanvasJSAngularChartsModule], templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { chart: any; chartOptions = { title:{ text: "Total Impressions by Platforms" }, animationEnabled: true, axisY: { includeZero: true, suffix: "K" }, data: [{ type: "bar", indexLabel: "{y}", yValueFormatString: "#,###K", dataPoints: [ { label: "Snapchat", y: 15 }, { label: "Instagram", y: 20 }, { label: "YouTube", y: 24 }, { label: "Twitter", y: 29 }, { label: "Facebook", y: 73 } ] }] } }
<div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
In the above graph, axisX can be reversed by setting reversed property to true. Format of values shown in axis label can be set using valueFormatString property and can completely customize the axis labels using labelFormatter.
Note For step by step instructions, follow our Angular Integration Tutorial