You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Angular 12 ,"ng2-charts": "^3.0.9", and "chart.js": "^3.7.1", Legend onClick not working properly, somtimes works by click the legend and moving the cursor somewhere or mouse over from the menu.
the same workins in chart.js 2.9.4 and ng2-charts 2.4.2
Example code is provided below and my requirement is when I click the Legend it will display the "Show Text".
I am using Angular 12 ,"ng2-charts": "^3.0.9", and "chart.js": "^3.7.1", Legend onClick not working properly, somtimes works by click the legend and moving the cursor somewhere or mouse over from the menu.
the same workins in chart.js 2.9.4 and ng2-charts 2.4.2
Example code is provided below and my requirement is when I click the Legend it will display the "Show Text".
Html code
Total New Parameters
Angular code
To simulate the issue go to https://stackblitz.com/edit/ng2-charts-line-template-v3?file=src%2Fapp%2Fapp.component.ts
And replace the below code,
import { Component } from '@angular/core';
import { ChartConfiguration, ChartOptions, ChartType } from "chart.js";
@component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
title = 'ng2-charts-demo';
public lineChartData: ChartConfiguration<'line'>['data'] = {
labels: [
'January',
'February',
'March',
'April',
'May',
'June',
'July'
],
datasets: [
{
data: [ 65, 59, 80, 81, 56, 55, 40 ],
label: 'Series A',
fill: true,
tension: 0.5,
borderColor: 'black',
backgroundColor: 'rgba(255,0,0,0.3)'
}
]
};
public lineChartOptions: ChartOptions<'bar'> = {
responsive: false,
plugins: {
legend: {
display: true,
onClick: (e, legendItem, legend) => {
if (legendItem.text === 'Series A') {
this.isTransDocumentation = true;
} else {
this.isTransDocumentation = false;
}
console.log('I am in');
}
}
}
};
public lineChartLegend = true;
public lineChartPlugins = [];
isTransDocumentation: boolean;
constructor() {
}
ngOnInit() {
}
}
`
to check ngif and display the below text
`
When I onClick the Legend it should show the "Some Text" on the html page
The text was updated successfully, but these errors were encountered: