Chartjs-Fail to show date array in chart.js labels/x-axis in Django

0👍

Finally I solve the problem with following codes:

{% for emp_day_output in emp_day_outputs %}
                new Date("{{ emp_day_output.output_date|date:"Y-m-d" }}").toLocaleDateString(),
            {% endfor %}

With the new Date().toLocaleDateString() function, it makes the html with javascript convert the date string for displaying the chart axis provided by the chart.js.

Leave a comment