翻譯|使用教程|編輯:龔雪|2021-12-13 10:20:25.337|閱讀 276 次
概述:本文主要介紹如何使用Kendo UI for Angular組件的圖表功能,歡迎下載最新版產品體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
本文提供了開始使用Kendo UI for Angular圖表所需的信息,包括有關的安裝方法、所需依賴項、運行項目的代碼以及其他一些資源說明。Charts Package 是 Kendo UI for Angular 的一部分,這是一個專業級的 UI 庫,具有 100 多個組件,用于構建現代且功能豐富的應用程序。
完成本指南后,您將能夠獲得如下示例所示的最終結果。
import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: ` <kendo-chart style="height:250px"> <kendo-chart-series> <kendo-chart-series-item [data]="[1, 4, 5, 2, 1, 8]"> </kendo-chart-series-item> </kendo-chart-series> </kendo-chart> ` }) export class AppComponent {}
在開始安裝任何Kendo UI for Angular控件之前,請確保您有一個正在運行的Angular項目。無論您要使用什么Kendo UI for Angular包,完成組件安裝的先決條件是相同的。
您可以選擇使用以下兩種方法當中的一種來安裝Kendo UI for Angular包和您要應用的樣式:
使用 Angular CLI 快速設置
快速設置提供了一種通過 ng-add 命令使用 Angular CLI 添加包的自動方法,它適用于節省時間和精力,因為 ng-add 在單個步驟中執行一組其他單獨需要的命令。
要為Angular Charts包添加Kendo UI,請運行以下命令:
ng add @progress/kendo-angular-charts
因此,ng-add 命令將執行以下操作:
手動設置
手動設置提供了對安裝在 Angular 應用程序中的文件和引用的更高可見性和更好的控制,您可以通過為每個步驟運行單獨的命令并在應用程序根或功能模塊中導入所需的組件模塊來安裝所需的對等依賴項和 Kendo UI 主題。
1. 通過運行以下命令安裝 Charts 包及其依賴項:
npm install --save @progress/kendo-angular-charts @progress/kendo-angular-common @progress/kendo-angular-intl @progress/kendo-angular-l10n @progress/kendo-angular-popup @progress/kendo-drawing hammerjs @progress/kendo-licensing
2. 如果您的應用程序中需要所有 Charts 組件,請使用 ChartsModule 一次導入所有 Charts。否則,通過添加單獨的模塊來導入特定的組件。
Charts 包為其組件導出以下各個模塊:
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ChartsModule } from '@progress/kendo-angular-charts'; import { AppComponent } from './app.component'; import 'hammerjs'; @NgModule({ bootstrap: [AppComponent], declarations: [AppComponent], imports: [BrowserModule, BrowserAnimationsModule, ChartsModule] }) export class AppModule { }
import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; // Imports the Chart module import { ChartModule } from '@progress/kendo-angular-charts'; // Imports the Sparkline module import { SparklineModule } from '@progress/kendo-angular-charts'; @NgModule({ bootstrap: [AppComponent], imports: [ BrowserModule, BrowserAnimationsModule, ChartModule, SparklineModule ] }) export class AppModule { }
3. 下一步是通過安裝可用的 Kendo UI 主題(Kendo UI Default、Kendo UI Material 或 Kendo UI Bootstrap)來設置組件的樣式。
3.1 要開始使用主題,請通過 NPM 安裝其包。
默認主題
npm install --save @progress/kendo-theme-default
Bootstrap主題
npm install --save @progress/kendo-theme-bootstrap
Material主題
npm install --save @progress/kendo-theme-material
3.2 安裝主題包后,在您的項目中引用它,您可以通過以下方式在項目中包含 Kendo UI 主題:
1. 成功安裝Charts包并導入需要的模塊后,在app.component.html中添加您需要的組件對應的標簽。 比如需要Chart組件,添加如下代碼:
<kendo-chart> <kendo-chart-series> <kendo-chart-series-item [data]="[1, 4, 5, 2, 1, 8]"> </kendo-chart-series-item> </kendo-chart-series> </kendo-chart>
2. 通過在根文件夾中運行以下命令來構建和提供應用程序。
ng serve
3. 將瀏覽器指向 //localhost:4200來查看頁面上Kendo UI for Angular Chart 組件。
截至 2020 年 12 月,使用Kendo UI for Angular庫中的任何 UI 組件都需要商業授權許可證密鑰或有效的試用許可證密鑰。 如果您的應用程序不包含Kendo UI授權許可證文件,請激活您的許可證密鑰。
下表列出了每個 Charts 依賴項根據包提供的特定功能:
Kendo UI for Angular是Kendo UI系列商業產品的最新產品。Kendo UI for Angular是專用于Angular開發的專業級Angular組件。telerik致力于提供純粹的高性能Angular UI組件,無需任何jQuery依賴關系。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都網