Chartjs-Django chart.js multi axis line chart

1👍

Done It was a comma positioning mistake, I checked the console and the problem was that when my if condition was not being checked instead of skipping, it was adding an empty value, meaning that I was getting for example 1, , , , 2 , , , 3 instead of 1,2,3 and the chart was rendering the empty cells, anyway here is the how I was able to fix it for data :

data: {
labels: [{% for year in years %} '{{year}}', {% endfor %}],
datasets: [
    {% for site in sites %}

    {
  label: '{{site.site}}',
  yAxisID: 'y',
  borderColor: '{{site.color}}',
  backgroundColor: 'transparent',

  data: [ {% for item in qs %}
        {% if item.site == site.site %}


        {{item.turn_over}} ,{% endif %}  {% endfor %}
    ]
}, {% endfor %}

 ]

}

enter image description here

Leave a comment