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

show the utils file in the samples page to clarify what the functions do #9160

Merged
merged 1 commit into from May 26, 2021

Conversation

LeeLenaleee
Copy link
Collaborator

Since the question came by multiple times on where to find the Utils file I think it will clarify things a lot better this way instead of that people need to dig in the repo to find the file

@etimberg etimberg added this to the Version 3.3.1 milestone May 26, 2021
@etimberg etimberg merged commit 140cbb4 into chartjs:master May 26, 2021
@LeeLenaleee LeeLenaleee deleted the docs/utils branch May 26, 2021 14:59
@BernhardBaumrock
Copy link

Thx for that push in the right direction! I'm totally oldschool regarding JS so I don't know how to include that file properly. Can you please help me? I tried to do this:

<script type='text/javascript' src='https://raw.githubusercontent.com/chartjs/Chart.js/master/docs/scripts/utils.js'></script>

But I still get Utils is not defined - is there a CDN version of utils so that one can simply copy and paste the code from the samples pages??

Thx for your help!

@LeeLenaleee
Copy link
Collaborator Author

As pointed out it's not meant to be included in production software, there is also no CDN version available for this, the only place you could point a src to is https://www.chartjs.org/samples/2.9.4/utils.js but this is not a CDN so you can get bad loading times, you are best off to copy paste the methods in your own code if you really want to use them

@BernhardBaumrock
Copy link

Hi @LeeLenaleee thx for your help. I'm not talking about using the examples on production. I'm talking about simply and quickly using the examples from the samples page for testing, for playing around, for showing a demo to clients...

I'm really lost how the samples can be used :( The docs state the following:

All our examples are available online but you can also download the Chart.js.zip archive attached to every release to experiment with our samples locally from the /samples folder.

But I downloaded the ZIP and the only samples folder I can find only has .md files in it. No HTML/JS files to quickly play with.

Maybe I'm missing something obvious, but I really can't get the samples to work on my local machine or on jsfiddle...

I can get a working example from this page by just copy+pasting the code: https://www.chartjs.org/docs/latest/
https://jsfiddle.net/baumrock/2xtz03wq/5/

But how would I do that for the doughnut chart for example? I'm still getting Utils is not defined even if I include your utils.js file: https://jsfiddle.net/baumrock/vznLtj93/2/

What I'd hope is that the samples page had samples that I can easily copy and paste and quickly modify the charts to try things out and to learn. Maybe that is already possible - then it would be great if the samples page had a section about how to use them for quick and easy test setups.

Thx again!

@LeeLenaleee
Copy link
Collaborator Author

LeeLenaleee commented May 29, 2021

Here you go: https://jsfiddle.net/Leelenaleee/zkd50mr1/6/,
Since its using outdated version of the utils package you are better off implementing the methods yourself by copy pasting them from the file

@etimberg
Copy link
Member

In terms of using the samples locally, the note in the docs is incorrect for v3. If you clone the repo, you can run the samples locally by doing:

npm ci
npm run docs:dev

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

Successfully merging this pull request may close these issues.

None yet

4 participants