chartjs / chartjs/chartjs-plugin-datalabels

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

Open
#343 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
920
Forks
507
PR merge metrics
No merged PRs in 30d

Description

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).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.