Chart + Jinja2 调用方法

2021-01-27  本文已影响0人  龃龉前行
<script>
    var ctx = $('#atndCount');
    var atndCount = new Chart(ctx, {
        type: 'bar',
        data: {
            labels: [ {% set pipe = joiner(",") %}
                        {% for k,v in count_dict.items() %}
                            {{ pipe() }} "{{k}}"
                        {% endfor %}
                        ],
            datasets: [
                {
                    label: "异常次数 (次)",
                    backgroundColor: ["#FF6384", "#36A2EB", "#4BC0C0", "#FFCD56", "#F39346", "#FF86D0", "#91BAFF", "#FF7979"],
                    data: [{% set pipe = joiner(",") %}
                        {% for k,v in count_dict.items() %}
                            {{ pipe() }} {{v}}
                        {% endfor %}]
                }
            ]
        },
        options: {
            maintainAspectRatio: false,
            responsive: true,
            legend: {display: false},
            title: {
                display: true,
                text: '考勤异常情况'
            }
        }

    });
</script>
上一篇 下一篇

猜你喜欢

热点阅读