How to draw Pie-chart in typescript
Closed this issue · 0 comments
Hi
I have been working on amcharts3 for my project, where i have to implement the pie-chart in typescript. Do you provide a source for this?
Implemented logic in typescript
`import {AmChart, AmChartsService} from '@amcharts/amcharts3-angular';
@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
private chart: AmChart;
constructor(private AmCharts: AmChartsService,
private zone: NgZone) {}
drawChart(): void {
this.chart = this.AmCharts.makeChart('chartdiv', {
type: 'pie',
theme: 'none',
dataProvider: [ {
country: 'Lithuania',
litres: 501.9
}, {
country: 'Czech Republic',
litres: 301.9
}, {
country: 'Ireland',
litres: 201.1
}, {
country: 'Germany',
litres: 165.8
}, {
country: 'Australia',
litres: 139.9
}, {
country: 'Austria',
litres: 128.3
}, {
country: 'UK',
litres: 99
}, {
country: 'Belgium',
litres: 60
}, {
country: 'The Netherlands',
litres: 50
} ],
valueField: 'litres',
titleField: 'country',
balloon: {
fixedPosition: true
},
export: {
enabled: true
}
} );
}
// tslint:disable-next-line:typedef
resetConfig() {
if (this.chart) {
this.AmCharts.destroyChart(this.chart);
}
}
}`
For above logic, i'm getting nothing in ui.
In cosole i'm getting this : ERROR NullInjectorError: R3InjectorError(AppModule)[AmChartsService -> AmChartsService -> AmChartsService]: NullInjectorError: No provider for AmChartsService!
will anyone hep me out regarding this,
Thanks in advance.