Example demonstrates responsive feature of our angular charts that let you render charts seamlessly across devices & browsers. Charts automatically scales to fit it's container even when you change orientation of device.
- /* app.component.ts */
- import { Component } from '@angular/core';
- @Component({
- selector: 'app-root',
- templateUrl: './app.component.html',
- styleUrls: ['./app.component.css']
- })
- export class AppComponent {
- chartOptions = {
- title: {
- text: "Monthly Sales Data"
- },
- theme: "light2",
- animationEnabled: true,
- exportEnabled: true,
- axisY: {
- includeZero: true,
- valueFormatString: "$#,##0k"
- },
- data: [{
- type: "column", //change type to bar, line, area, pie, etc
- yValueFormatString: "$#,##0k",
- color: "#01b8aa",
- dataPoints: [
- { label: "Jan", y: 172 },
- { label: "Feb", y: 189 },
- { label: "Mar", y: 201 },
- { label: "Apr", y: 240 },
- { label: "May", y: 166 },
- { label: "Jun", y: 196 },
- { label: "Jul", y: 218 },
- { label: "Aug", y: 167 },
- { label: "Sep", y: 175 },
- { label: "Oct", y: 152 },
- { label: "Nov", y: 156 },
- { label: "Dec", y: 164 }
- ]
- }]
- }
- }
- /* app.module.ts */
- import { NgModule } from '@angular/core';
- import { BrowserModule } from '@angular/platform-browser';
- import { AppComponent } from './app.component';
- import { CanvasJSAngularChartsModule } from '@canvasjs/angular-charts';
- @NgModule({
- declarations: [
- AppComponent
- ],
- imports: [
- BrowserModule,
- CanvasJSAngularChartsModule
- ],
- providers: [],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
You can set the width & height of the chart using width & height properties. You can also set the width of dataPoints in column / bar, ohlc and candlestick charts by setting dataPointWidth property.
Note For step by step instructions, follow our Angular Integration Tutorial