Chart.js
Chart.js copied to clipboard
HTML template for using config / setup / actions from Samples section
Documentation Is:
- [X] Missing or needed?
- [ ] Confusing
- [ ] Not sure?
Please Explain in Detail...
Hi all,
maybe I just overlooked that part in you documentation.
But it took me some time to figure out, how to use the code displayed in Samples section from tabs config / setup / actions - e.g. from here https://www.chartjs.org/docs/latest/samples/bar/border-radius.html - in some working HTML example.
I simply missed some HTML template, where I would replace 3 sections with the code from the Sample to see the outcome.
Regards, Lukas
Your Proposal for Changes
I would add somewhere in this page a sample HTML template (e.g. using CDN for including the js library) and the instruction that it is enough to replace 3 sections based on the Sample for config / setup / actions tabs.
To be honest I did not investigate where to copy the code from actions tab. I did not need that in my HTML example.
Important are these two lines, but some complete example is needed:
...
<script>
const ctx = document.getElementById('myChart');
// definitions for config / setup / actions
const myChart = new Chart(ctx, config);
</script>
...
Example
No response
For a sample that can be copied and pasted and used directly you can check the usage page.
Links to this page in the documentation: https://www.chartjs.org/docs/latest/getting-started/usage.html
There used to be simple samples in the 2.9 version https://github.com/chartjs/Chart.js/blob/2.9/samples/charts/bar/stacked-group.html
But they are no longer present in the latest version of the repo...