项目作者: Synapsium

项目描述 :
Angular wrapper library for beautiful charts based on Chartjs
高级语言: TypeScript
项目地址: git://github.com/Synapsium/ngx-chartjs.git
创建时间: 2018-11-11T14:49:34Z
项目社区:https://github.com/Synapsium/ngx-chartjs

开源协议:MIT License

下载





ngx-chartjs




Quickly way to integrate Chart.js components with Angular

chart.js

One of the most popular and powerful open source library to create a data visualization. To use this library you should get familiar with the Chart.js documentation.

Setup

Installation

Install chart.js and ngx-chartjs library from npm

  1. npm install chart.js @synapsium/ngx-chartjs --save

Install @types/chart.js library from npm

  1. npm install @types/chart.js --save-dev

Module usage

Add ChartjsModule to module

  1. import { ChartjsModule, ChartjsConfig, CHARTJS_CONFIG } from '@synapsium/ngx-chartjs';
  2. const DEFAULT_CHARTJS_CONFIG: ChartjsConfig = {
  3. options {
  4. responsive: true,
  5. maintainAspectRatio: false
  6. }
  7. };
  8. @NgModule({
  9. ...
  10. imports: [
  11. ...
  12. ChartjsModule
  13. ],
  14. providers: [
  15. {
  16. provide: CHARTJS_CONFIG,
  17. useValue: DEFAULT_CHARTJS_CONFIG
  18. }
  19. ]
  20. })

Check out the API Doc for the available options.

How to use

In your target component integrate chartjs element :

  1. <chartjs [className]="chart"
  2. [type]="type"
  3. [data]="data"
  4. [options]="options">
  5. </chartjs>

Inputs

Input Type Default Description
className string Custom css class name applied on parent container of chart canvas
type string 'doughnut' Type of chart : 'doughnut', 'line', 'bar', 'radar', 'pie', 'polarArea', 'bubble', 'scatter'
data ChartData '{}' Data of chart
options ChartOptions { responsive: true, maintainAspectRatio: false} Options of chart

Options properties of global config will be replaced by local Options.