`ngx-doughnut-chart` is a light weight with no dependencies angular component to draw donut charts using svgs.
npm install ngx-doughnut-chartngx-doughnut-chart is a light weight with no dependencies angular component to draw donut charts using svgs.
bash
$ npm i ngx-doughnut-chart --save
`
or
`bash
$ yarn add ngx-doughnut-chart --save
`
Usage
Import NgxDonutChartModule module into your main module
and add it to imports:
`typescript
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { NgxDonutChartModule } from 'ngx-doughnut-chart';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgxDonutChartModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
...
Pass data like this:
`typescript
donutChartData = [
{
label: 'Liverpool FC',
value: 5,
color: 'red',
},
{
label: 'Real Madrid ',
value: 13,
color: 'black',
},
{
label: 'FC Bayern München',
value: 5,
color: 'blue',
},
];
`
and then use the component in your html like:
`html
[data]="donutChartData"
[title]="'Sessions'"
[radius]="88"
[thickness]="10"
[margin]="30">
``