Skip to content
New issue

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

Documentation lists undefined labels and is missing the complete type of context for formatter #343

Open
tdauth opened this issue Sep 23, 2022 · 0 comments

Comments

@tdauth
Copy link

tdauth commented Sep 23, 2022

Hi,
I am using this plugin to show the labels of the datasets inside the bars. Hence, I customize the formatter.
The example values from the documentation (https://v2_1_0--chartjs-plugin-datalabels.netlify.app/guide/formatting.html#custom-labels):

context.dataset.data[context.dataIndex].label;  // labels in each data object
context.dataset.labels[context.dataIndex];      // labels store in the dataset
globalLabels[context.dataIndex];                // labels store outside the chart

seem to be rather useless here. They were undefined except for the first one.
By setting a breakpoint I discovered that my dataset had in fact one label:

context.dataset.label

Maybe add more example values or document the context type.
I guess the values depend on which values your dataset has (for example not all datasets have a 'stack' member).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant