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

Annotations broken when using array syntax #572

Closed
elitastic opened this issue Dec 17, 2021 · 2 comments · Fixed by #575
Closed

Annotations broken when using array syntax #572

elitastic opened this issue Dec 17, 2021 · 2 comments · Fixed by #575
Labels

Comments

@elitastic
Copy link
Contributor

When writing annotations in array syntax, I get the following error (since version 1.2.0):

Cannot read properties of undefined (reading 'borderCapStyle')

Reproduction:

from

annotation: {
  annotations: {
    annotation1,
    annotation2,
    annotation3
  }
}

to

annotation: {
  annotations: [
    annotation1,
    annotation2,
    annotation3
  ]
}
@kurkle
Copy link
Member

kurkle commented Dec 17, 2021

Fixed by: chartjs/Chart.js#9969 (not released yet)

I think this only affects the new types.

Edit: some explanation

  • the element type can not be resolved in the array format for the defaults, because of the chart.js bug.

_fallback: (prop, opts) => `elements.${annotationTypes[resolveType(opts.type)].id}`,

  • so the line annotation defaults are used instead. Those defaults do not have font or callout. So those are undefined.
    => undefined is added to the proxy _scopes array, and the error happens when an option is read that would fallback to the element defaults (and is not found in the line defaults).

@kurkle kurkle added the bug label Dec 17, 2021
@kurkle kurkle linked a pull request Dec 17, 2021 that will close this issue
@kurkle kurkle closed this as completed Dec 17, 2021
@elitastic
Copy link
Contributor Author

Thanks for your help!

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

Successfully merging a pull request may close this issue.

2 participants