-
Notifications
You must be signed in to change notification settings - Fork 0
/
Chart.py
97 lines (84 loc) · 2.96 KB
/
Chart.py
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
from svg.charts.plot import Plot
class Chart:
# 加速曲線のSVGデータを作成する
@classmethod
def createSpeedAccel(self, profiles):
g = Plot(
dict(
width=700,
height=640,
graph_title="加速曲線",
show_graph_title=True,
no_css=True,
key=True,
scale_x_integers=True,
min_x_value=0,
min_y_value=0,
show_data_labels=True,
show_x_guidelines=True,
show_x_title=True,
x_title="速度",
show_y_title=True,
y_title="加速度",
y_title_text_direction='bt',
scale_y_divisions=0.05
)
)
g.scale_x_divisions=10
for profile in profiles:
g.add_data({
'data': profile[1],
'title': f'{profile[0]}'
})
return g.burn()
# 出力曲線のSVGデータを作成する
@classmethod
def createSpeedOutput(self, profiles):
g = Plot(
dict(
width=700,
height=640,
graph_title="出力曲線",
show_graph_title=True,
no_css=True,
key=True,
scale_x_integers=True,
scale_y_integers=True,
min_x_value=0,
min_y_value=0,
show_data_labels=True,
show_x_guidelines=True,
show_x_title=True,
x_title="速度",
show_y_title=True,
y_title="出力値",
y_title_text_direction='bt',
)
)
g.scale_x_divisions=10
for profile in profiles:
g.add_data({
'data': profile[1],
'title': f'{profile[0]}'
})
return g.burn()
@classmethod
def genAccelProfileFromCurveGroups(self, curve_groups):
profiles = []
for curve_group_id, curves in curve_groups.items():
profile = []
for curve in curves:
profile.append(curve['speed'])
profile.append(curve['accel'])
profiles.append([curve_group_id, profile])
return profiles
@classmethod
def genOutputProfileFromCurveGroups(self, curve_groups):
profiles = []
for curve_group_id, curves in curve_groups.items():
profile = []
for curve in curves:
profile.append(curve['speed'])
profile.append(curve['output'])
profiles.append([curve_group_id, profile])
return profiles