dashboard-400409-web-dashboard-integrate-dashboard-component-dashboard-component-for-angular-add-web-dashboard-to-an-angular-cli-application.md
This article assumes that you implement a client-server architecture. An ASP.NET Core or an ASP.NET MVC application serves as the backend (server side). The client (frontend) application includes all the necessary styles, scripts and HTML-templates. Note that client scripts, libraries on the server side, and devexpress npm packages should have matching version numbers.
This topic describes how to import the DxDashboardControlModule module into an Angular application and display Web Dashboard.
Tip
If you are not familiar with the basic concepts and patterns of Angular, please review the fundamentals before you continue: angular.io
In the command prompt, create an Angular application:
ng new dashboard-angular-app
Navigate to the created folder after the project is created:
cd dashboard-angular-app
Install the following npm packages:
npm install [email protected] [email protected] @devexpress/[email protected] [email protected] [email protected] --save
The devexpress-dashboard npm package references devextreme and @devexpress/analytics-core as peer dependencies. The peer dependencies packages should be installed manually.
You can find all the libraries in the node_modules folder after installation is completed.
In the app.ts file, import the DxDashboardControlModule module.
// ...
import { DxDashboardControlModule } from 'devexpress-dashboard-angular';
@Component({
// ...
imports: [
// ...
DxDashboardControlModule
],
// ...
})
export class AppComponent { }
Open the app.html file and add the <dx-dashboard-control> element to render the dashboard component:
<dx-dashboard-control
style="display: block;width:100%;height:800px;"
endpoint="https://demos.devexpress.com/services/dashboard/api"
>
</dx-dashboard-control>
The DashboardControlOptions.endpoint property specifies the URL used to send data requests to a server. The value should consist of a base URL where the Web Dashboard’s server side is hosted and a route prefix - a value that is set in the MVC / .NET Core MapDashboardRoute properties.
Add the following global styles to the styles.css file:
@import url("../node_modules/ace-builds/css/ace.css");
@import url("../node_modules/ace-builds/css/theme/dreamweaver.css");
@import url("../node_modules/ace-builds/css/theme/ambiance.css");
@import url("../node_modules/devextreme/dist/css/dx.light.css");
@import url("../node_modules/@devexpress/analytics-core/dist/css/dx-analytics.common.css");
@import url("../node_modules/@devexpress/analytics-core/dist/css/dx-analytics.light.css");
@import url("../node_modules/@devexpress/analytics-core/dist/css/dx-querybuilder.css");
@import url("../node_modules/devexpress-dashboard/dist/css/dx-dashboard.light.css");
Run the application.
npm start
Open http://localhost:4200/ in your browser to see the result. The Web Dashboard displays the dashboard stored on the preconfigured server (https://demos.devexpress.com/services/dashboard/api). To configure your own server, follow the instructions below:
See Also