We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the type of the parameter mode here:
mode
Chart.js/src/types/index.d.ts
Line 519 in 44b97b8
should allow a function aswell.
In this method which is called by chart.update, the parameter mode is checked if it is a function.
chart.update
Chart.js/src/core/core.controller.js
Line 676 in 44b97b8
The current type definition of the parameter mode is UpdateMode:
UpdateMode
Lines 570 to 580 in 44b97b8
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGwG6ZxkwAecALxwAJhDIBXEAFMAdjCoBzaTACiAG2kz5AIQCeASREAKAEQg9aTDFMBKOOjpwAEgBUAsgBlk6WVzoaWnIwLKxcUHAWVljCstIA7iiUMMa8fAA0iGxwOXAwemDSAFyk6sBxJOnZuSLoMOglCNW5ueroAEbS6nQlANqmAErSIqaZpjrqEtKjcKYAml3qEPEzpgDiUNJyqwAKElBgmqsA8lC+yqYAulWsLS219XQqPXC9Tbd3n22d6iUkAMRwCB4OAANQgMGkDBun0+DwarwAjAAmTKIgCcmQAzJkAKyZVFwLHXZp3bCXUnYG7YWyhNhRZJUCRgB7SYypfiNUR1RwqAyyETSPglWRSToRGlCAB8cAA9AAqOCyCFweLQADW5UU8tltKAA
No response
change the type of mode to a union type: UpdateMode | ((ctx: { datasetIndex: number }) => UpdateMode)
UpdateMode | ((ctx: { datasetIndex: number }) => UpdateMode)
I stumpled across this issue when trying to change the visibility of multiple datasets with one legend label.
my solution required passing a function to chart.update in the overwritten plugins.legend.onClick method:
onClick(e, legendItem, legend) { const isNowVisible = !legend.chart.isDatasetVisible(legendItem.datasetIndex); const mode = isNowVisible ? 'show' : 'hide'; if (isNowVisible) { legend.chart.show(legendItem.datasetIndex); legend.chart.show(anotherIndex); } else { legend.chart.hide(legendItem.datasetIndex); legend.chart.hide(anotherIndex); } (legend.chart as any).update((ctx: { datasetIndex: number }) => [legendItem.datasetIndex, anotherIndex].includes(ctx.datasetIndex) ? mode : undefined); }
v4.4.0
The text was updated successfully, but these errors were encountered:
Resolved in #11488
Sorry, something went wrong.
No branches or pull requests
Expected behavior
the type of the parameter
mode
here:Chart.js/src/types/index.d.ts
Line 519 in 44b97b8
should allow a function aswell.
In this method which is called by
chart.update
, the parametermode
is checked if it is a function.Chart.js/src/core/core.controller.js
Line 676 in 44b97b8
Current behavior
The current type definition of the parameter
mode
isUpdateMode
:Chart.js/src/types/index.d.ts
Lines 570 to 580 in 44b97b8
Reproducible sample
https://www.typescriptlang.org/play?#code/JYWwDg9gTgLgBAbzgYQBYENZwL5wGZQQhwDkAxhrAHQBWAziQNwCwAUGwG6ZxkwAecALxwAJhDIBXEAFMAdjCoBzaTACiAG2kz5AIQCeASREAKAEQg9aTDFMBKOOjpwAEgBUAsgBlk6WVzoaWnIwLKxcUHAWVljCstIA7iiUMMa8fAA0iGxwOXAwemDSAFyk6sBxJOnZuSLoMOglCNW5ueroAEbS6nQlANqmAErSIqaZpjrqEtKjcKYAml3qEPEzpgDiUNJyqwAKElBgmqsA8lC+yqYAulWsLS219XQqPXC9Tbd3n22d6iUkAMRwCB4OAANQgMGkDBun0+DwarwAjAAmTKIgCcmQAzJkAKyZVFwLHXZp3bCXUnYG7YWyhNhRZJUCRgB7SYypfiNUR1RwqAyyETSPglWRSToRGlCAB8cAA9AAqOCyCFweLQADW5UU8tltKAA
Optional extra steps/info to reproduce
No response
Possible solution
change the type of
mode
to a union type:UpdateMode | ((ctx: { datasetIndex: number }) => UpdateMode)
Context
I stumpled across this issue when trying to change the visibility of multiple datasets with one legend label.
my solution required passing a function to
chart.update
in the overwritten plugins.legend.onClick method:chart.js version
v4.4.0
Browser name and version
No response
Link to your project
No response
The text was updated successfully, but these errors were encountered: