Open julianna-langston opened 1 year ago
@julianna-langston I think the issue is related to cdn.skypack
, where we had already some issues (see #786).
If you use
import {Chart, registerables} from "https://cdn.jsdelivr.net/npm/chart.js@4.2.1/+esm";
instead of
import {Chart, registerables} from "https://cdn.skypack.dev/chart.js@4.2.1";
it works.
@julianna-langston let me explain better why the error is occurring. The annotation plugin is leveraging on fallback CHART.JS approach for the configuration options.
All annotation types are CHART.JS elements with their defaults. To enable it, it's mandatory to define the plugin globally because the plugin is catching the registration hook in order to register the annotation elements and then to activate the fallback.
When these kinds of errors are occurring means that the registration for whatever reason hasn't happened.
Even if we could of course check the consistency of the label object (in this case), we could have other issues (you have already seen for font) therefore the root cause is not the missing check but the missing registration of the elements.
Thank you so much, and you got me unblocked with your previous comment.
Is it possible to include links in the docs to a CodePen/JSFiddle/CodeSandbox example? I always the initial setup to be the hardest with chartjs plugins (since all the working example obfuscate how imports/registrations work), so a link to a fully functioning code example would be helpful, at least to me.
I think it's possible, I need to check if there is already ready something as community or chartjs org. Of course I have got my codepens but I think it' better to have something at community level in order to add links to the doc. @kurkle @LeeLenaleee as far as you know, is there any community org in CodePen/JSFiddle/CodeSandbox to use to add some samples? Makes sense for you?
I know there is a codepen account of chart.js that has some but verry outdated samples. Thats it. For the reproducible sample templates of the main repo for exaple I just used my personal account
I could come up with some codepen prefills, so that it doesn't have to be hosted by any account? If you think that's a workable approach, I can file a new issue and submit a PR.
Backstory I was trying to set up a codepen to try using chartjs-plugin-annotaiton. (If I just set it up wrong, I'm sorry). I created If you go look at the codepen, you'll notice that:
So, I dug into the code. The error was thrown on this line:
So, if
options.label
is consideredundefined
, where is options coming from?which is called by
...which is called from over here:
and now we've switched from
options
toresolver
. Maybe there's a mistake, and maybe the function is expecting an option and receiving a resolver? Maybe I'm providing the config in the wrong way? So I go look at the other pages in the docs, and I start recognizing options I saw in the code. So, I update my annotation to have these properties:and then I was able to move forward to another error message
which took me back to the updateElements function abov. So, another function that thought
resolver
would have something that it didn't. Suspicious...What's the bug?
Maybe they're related?