0
npm install ng2-charts --save

I am using ng2-charts in my Angular 5 project.Pie chart is being used.

public chartClicked(e:any):void {
console.log(e);

}

This event is provided in its documentation. This event is common for all the sections of pie chart.My requirement is to bind different click events to these 3 different sections as shown in the figure. How can i select different section and perform different operations?

Abhiz
  • 970
  • 1
  • 16
  • 36
  • Hey can you post your code what have you done so far.. – Anil Samal May 16 '18 at 06:12
  • I don't think you can bind different click events, because the chart is a canvas, so a single element. With the click event you receive which section of the chart is currently active (the one your mouse is hovering), with that you could define what to do next and call different methods depending on that value. – Fussel May 16 '18 at 06:33
  • Possible duplicate of [Chart.js & Angular 2 - ng2-charts Custom on Click Event](https://stackoverflow.com/questions/38378984/chart-js-angular-2-ng2-charts-custom-on-click-event) – P. Moloney May 16 '18 at 07:48
  • @AnilSamal. public regChartClicked(e: any): void { this.httpGet.getData('http://172.16.0.119:8080/registrant?status=true') .subscribe((response) => { this.successRawEvents = response; if (this.successRawEvents.status === 200) { console.log(this.successRawEvents.responseData); this.modalSuccessFlag = true; this.paginateService.paginationInit(this.successRawEvents.responseData.length); this.successLast = this.paginateService.lastPage; this.successCurrent = this.paginateService.currentPage; } }); – Abhiz May 16 '18 at 08:58

0 Answers0