zhongrj
2025-11-24 276323dce9613867abb3f58a4cc2abbfb2fd0dea
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{% extends "app/plugins/templates/base.html" %}
{% load i18n %}
{% block content %}
 
    <div class="row text-center">
        <div class="col-md-12 col-sm-12">
            <h4>{% trans 'Projects' %}</h4>
            <form action="/plugins/projects-charts/" method="get" class="mt-6">
                <div class="row">
                    <div class="col-sm-4">
                        <label for="year">{% trans 'Year' %}</label>
                    </div>
                    {% for field in form %}
                        <div class="col-sm-4">
 
                        {{ field }}
                    {% endfor %}
                    </div>
 
 
                    <div class="col-sm-4">
                        {{ form.non_field_errors }}
                        <input type="submit" value="{% trans 'Next' %}" class="btn btn-primary"/>
                    </div>
                </div>
            </form>
 
            <div class="col-md-12 col-sm-12">
                <div style="width: 80%; margin-left: 10%;">
                    <canvas id="projectsChart" width="200" height="50" style="margin-bottom: 12px;"></canvas>
                </div>
            </div>
 
            <div style="width: 80%; margin-left: 10%;">
                <canvas id="tasksChart" width="200" height="50" style="margin-bottom: 12px;"></canvas>
            </div>
 
        </div>
    </div>
    <script>
 
        (function () {
            const ctx = document.getElementById('projectsChart').getContext('2d');
 
            new Chart(ctx, {
                type: 'bar',
                options: {
                    tooltip: {
                        enabled: false,
                    },
                    scales: {
                        y: {
                            beginAtZero: true,
                            ticks: {
                                stepSize: 1
                            },
                        }
                    }
                },
 
                data: {
                    labels: [
                        {% for month in months %}
                            "{{ month }}",
                        {% endfor %}
                    ],
                    datasets: [
                        {
                            label: "{% trans 'Projects by month' %}",
                            data: [{{ projects_by_month|join:", "  }}],
                            backgroundColor: [
                                {% for _ in projects_by_month %}
                                    'rgba(54, 162, 235, 0.4)',
                                {% endfor %}
                            ],
                        },
                    ]
                },
 
            });
        })();
 
        (function () {
            const ctx = document.getElementById('tasksChart').getContext('2d');
 
            new Chart(ctx, {
                type: 'bar',
                options: {
                    tooltip: {
                        enabled: false,
                    },
 
                    scales: {
                        y: {
                            beginAtZero: true,
                            ticks: {
                                stepSize: 1
                            },
                        }
                    }
                },
 
                data: {
                    labels: [
                        {% for month in months %}
                            "{{ month }}",
                        {% endfor %}
                    ],
                    datasets: [
                        {
                            label: "{% trans 'Tasks by month' %}",
                            data: [{{ tasks_by_month|join:", "  }}],
                            backgroundColor: [
                                {% for _ in tasks_by_month %}
                                    'rgba(54, 162, 235, 0.4)',
                                {% endfor %}
                            ],
                        },
                    ]
                },
 
            });
        })();
 
    </script>
{% endblock %}