0👍
I put ‘ing1, ‘ing2’ and ‘ing3’ into a list called ‘title’ inside my views , then put that list into the context , then did the following inside the chart.js script :
{% for item in title %} '{{ item }}', {% endfor %}
now it adds the correct data to the labels array.
- Chartjs-Rotating a chart.js pie chart with two datapoints to align both sectors on horizontal axis
- Chartjs-Define backgroundColor from data in chartJS
Source:stackexchange.com