File: Script.py

package info (click to toggle)
python-opem 1.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,076 kB
  • sloc: python: 7,777; sh: 27; makefile: 10
file content (115 lines) | stat: -rw-r--r-- 2,793 bytes parent folder | download
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
# -*- coding: utf-8 -*-
import os
external_chart_js_path = '/usr/share/javascript/chart.js/chart.min.js'
with open(external_chart_js_path, 'r') as f:
   JS_SCRIPT = f.read()

LINE_CHART = '''
<div style="width:{4};margin:15px;">
    <canvas id="{3}" width="100" height="100"></canvas>
        </div>
<script>
var ctx = document.getElementById("{3}").getContext('2d');
var myChart = new Chart(ctx, {{
    type: 'line',
    data: {{
        labels: {0},
        datasets: [{5}]
    }},
    options: {{
        scales: {{
            yAxes: [{{
                ticks: {{
                    beginAtZero:false,
                }},
                scaleLabel: {{
                            display: true,
                            labelString: '{1}'
                        }}
            }}],
            xAxes: [{{
                ticks: {{
                    beginAtZero:false,
                }},
                scaleLabel: {{
                            display: true,
                            labelString: '{2}'
                        }}
            }}]
        }}
    }}
}});
</script>
'''

MULTI_AXES_LINE_CHART = '''
<div style="width:{5};margin:15px;">
    <canvas id="{4}" width="100" height="100"></canvas>
        </div>
<script>
var ctx = document.getElementById("{4}").getContext('2d');
var myChart = new Chart(ctx, {{
    type: 'line',
    data: {{
        labels: {0},
        datasets: [{6}]
    }},
    options: {{
        scales: {{
            yAxes: [{{
                id: 'A',
                position: 'left',
                ticks: {{
                    beginAtZero:false,
                }},
                scaleLabel: {{
                            display: true,
                            labelString: '{1}'
                        }}
            }},
            {{
                id: 'B',
                position: 'right',
                ticks: {{
                    beginAtZero:false,
                }},
                scaleLabel: {{
                            display: true,
                            labelString: '{2}'
                        }}
            }}],
            xAxes: [{{
                ticks: {{
                    beginAtZero:false,
                }},
                scaleLabel: {{
                            display: true,
                            labelString: '{3}'
                        }}
            }}]
        }}
    }}
}});
</script>
'''

CHART_DATA = '''
{{
            label: '{0}',
            fill:false,
            data: {1},
            borderColor:'{2}',
            borderWidth: 1
        }}
'''

MULTI_AXES_CHART_DATA = '''
{{
            label: '{0}',
            fill:false,
            data: {1},
            borderColor:'{2}',
            borderWidth: 1,
            yAxisID: {3}
        }}
'''