Chartjs-Displaying the output on chart.js using Django and HTML

0👍

Traditionally data like that is served from a separate endpoint, so when your front-end needs chart data (in that model), it would make a fetch to get it from a separate URL on your site, eg. yoursite.com/chartdata/5.

However, if you have the data already on load, you can simply put it into a Javascript variable, by outputting it inside a <script> tag, eg.

 <script>
 const chartData = *outputHereAsJSON*;
 useYour(chartData);
 </script>

Leave a comment