Preconditions
- Basic knowledge of Angular CLI
- Bootstrap
- Node.js
- V.S. Code
We Covers the belowing things
- Create Angular application
- Create header,side menu and layout component with admin module.
- Angular Routing
- Kendo UI setup
Now let's use following command to create angular project,
Now install bootstrap by using the following command,
Now install KendoUI packages using following command,
Now install KendoUI theme using following command, I used default theme,
Default theme
Bootstrap theme
Material theme
Now Create the dashboard and layout component using the following command,
Now add the code in the following pages-:
Add this in app.module.ts
Add this in app.component.html
Add this in app-routing.module.ts
Add this in layout.component.ts
Add this in layout.component.html
Add this inlayout.component.css
Add this in dashboard.component.ts
import {
Component,
OnInit
} from '@angular/core';
@Component({
selector: 'app-dashboard',
templateUrl: './dashboard.component.html',
styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
ngOnInit(): void {}
constructor() {}
public events: string[] = [];
public series: any[] = [{
name: "India",
data: [
3.907, 7.943, 7.848, 9.284, 9.263, 9.801, 3.89, 8.238, 9.552, 6.855,
],
}, {
name: "Russian Federation",
data: [4.743, 7.295, 7.175, 6.376, 8.153, 8.535, 5.247, -7.832, 4.3, 4.3],
}, {
name: "Germany",
data: [
0.01, -0.375, 1.161, 0.684, 3.7, 3.269, 1.083, -5.127, 3.69, 2.995,
],
}, {
name: "World",
data: [
1.988, 2.733, 3.994, 3.464, 4.001, 3.939, 1.333, -2.245, 4.339, 2.727,
],
}, ];
public categories: number[] = [
2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
];
public onRender(): void {
this.log("render");
}
public onAxisLabelClick(e: any): void {
this.log("axisLabelClick", e);
}
public onLegendItemClick(e: any): void {
this.log("legendItemClick", e);
}
public onLegendItemHover(e: any): void {
this.log("legendItemHover", e);
}
public onPlotAreaClick(e: any): void {
this.log("plotAreaClick", e);
}
public onPlotAreaHover(e: any): void {
this.log("plotAreaHover", e);
}
public onSeriesClick(e: any): void {
this.log("seriesClick", e);
}
public onSeriesHover(e: any): void {
this.log("seriesHover", e);
}
private log(event: string, arg: any = null): void {
this.events.push(`${event}`);
console.log(arg);
}
public data: any[] = [{
kind: 'Hydroelectric',
share: 0.175
}, {
kind: 'Nuclear',
share: 0.238
}, {
kind: 'Coal',
share: 0.118
}, {
kind: 'Solar',
share: 0.052
}, {
kind: 'Wind',
share: 0.225
}, {
kind: 'Other',
share: 0.192
}];
public labelContent(e: any): string {
return e.category;
}
}
Add this in dashboard.component.html
<kendo-chart>
<kendo-chart-title text="Units sold"></kendo-chart-title>
<kendo-chart-category-axis>
<kendo-chart-category-axis-item
[categories]="['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'august' , 'september' , 'October', 'november', 'December']"
[title]="{ text: 'Months' }">
</kendo-chart-category-axis-item>
</kendo-chart-category-axis>
<kendo-chart-series-defaults [highlight]="{ inactiveOpacity: 0.3 }">
</kendo-chart-series-defaults>
<kendo-chart-series>
<kendo-chart-series-item type="area" [data]="[123, 276, 310, 212, 240, 156, 98, 210, 200, 220, 180, 170]">
</kendo-chart-series-item>
<kendo-chart-series-item type="area" [data]="[165, 210, 287, 144, 190, 167, 212, 190, 210, 250, 260, 220]">
</kendo-chart-series-item>
<kendo-chart-series-item type="area" [data]="[56, 140, 195, 46, 123, 78, 95, 240, 250, 210, 280, 290, 320]">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
<hr>
<kendo-chart>
<kendo-chart-series>
<kendo-chart-series-item
type="donut" [data]="data"
categoryField="kind" field="share">
<kendo-chart-series-item-labels
[content]="labelContent"
color="#fff" background="none">
</kendo-chart-series-item-labels>
</kendo-chart-series-item>
</kendo-chart-series>
<kendo-chart-legend [visible]="false"></kendo-chart-legend>
</kendo-chart>
Add this in package.json dependencies
"private": true,
"dependencies": {
"@angular/animations": "~12.1.0-",
"@angular/common": "~12.1.0-",
"@angular/compiler": "~12.1.0-",
"@angular/core": "~12.1.0-",
"@angular/forms": "~12.1.0-",
"@angular/localize": "~12.1.0-",
"@angular/platform-browser": "~12.1.0-",
"@angular/platform-browser-dynamic": "~12.1.0-",
"@angular/router": "~12.1.0-",
"@progress/kendo-angular-buttons": "^7.0.0",
"@progress/kendo-angular-charts": "^6.0.0",
"@progress/kendo-angular-common": "^2.0.0",
"@progress/kendo-angular-dateinputs": "^6.0.0",
"@progress/kendo-angular-dialog": "^6.0.1",
"@progress/kendo-angular-dropdowns": "^6.0.0",
"@progress/kendo-angular-excel-export": "^4.0.0",
"@progress/kendo-angular-grid": "^6.0.1",
"@progress/kendo-angular-icons": "^1.0.0",
"@progress/kendo-angular-indicators": "^1.1.2",
"@progress/kendo-angular-inputs": "^8.0.0",
"@progress/kendo-angular-intl": "^3.0.0",
"@progress/kendo-angular-l10n": "^3.0.0",
"@progress/kendo-angular-label": "^3.0.0",
"@progress/kendo-angular-layout": "^6.5.0",
"@progress/kendo-angular-navigation": "^1.1.4",
"@progress/kendo-angular-notification": "^3.0.4",
"@progress/kendo-angular-pdf-export": "^3.0.0",
"@progress/kendo-angular-popup": "^4.0.3",
"@progress/kendo-angular-progressbar": "^2.0.3",
"@progress/kendo-angular-treeview": "^6.0.0",
"@progress/kendo-angular-upload": "^8.0.0",
"@progress/kendo-data-query": "^1.0.0",
"@progress/kendo-drawing": "^1.0.0",
"@progress/kendo-licensing": "^1.0.2",
"@progress/kendo-svg-icons": "^0.1.2",
"@progress/kendo-theme-default": "^5.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.2.0",
"zone.js": "~0.11.4"
},
Now add the attached images
![]()
Now run the following command.
Now, please run the application using the 'npm start' command and check the result.
![How to use kendo UI in angular application]()