Example shows an Angular Chart with zooming / panning enabled. This helps you to select a region of focus to better analyze data.
/* 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 { title = 'angular17ssrapp'; generateRandomData = () => { var y = 1000, dps = []; for(var i = 0; i < 1000; i++) { y += Math.ceil(Math.random() * 10 - 5); dps.push({ y: y}); } return dps; } chartOptions = { zoomEnabled: true, exportEnabled: true, theme: "light2", title: { text: "Try Zooming & Panning" }, data: [{ type: "line", dataPoints: this.generateRandomData() }] } }
/* app.component.html */ <div> <canvasjs-chart [options]="chartOptions" [styles]="{width: '100%', height:'360px'}"></canvasjs-chart> </div>
You can zoom or pan along x-axis or y-axis or both. This can be controlled by using zoomType property. You can also customize the look & feel of the toolbar that contains buttons & options for zoom, pan, reset & export options. The color of the dataseries can be changed by setting color property.
Note For step by step instructions, follow our Angular Integration Tutorial