layrz-sdk 3.0.14__py3-none-any.whl → 3.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of layrz-sdk might be problematic. Click here for more details.
- layrz_sdk/__init__.py +1 -1
- layrz_sdk/constants.py +5 -0
- layrz_sdk/entities/__init__.py +129 -73
- layrz_sdk/entities/asset.py +71 -0
- layrz_sdk/entities/{general/asset_operation_mode.py → asset_operation_mode.py} +31 -30
- layrz_sdk/entities/broadcast_request.py +12 -0
- layrz_sdk/entities/broadcast_response.py +12 -0
- layrz_sdk/entities/broadcast_result.py +20 -0
- layrz_sdk/entities/{broadcasts/status.py → broadcast_status.py} +28 -27
- layrz_sdk/entities/case.py +47 -0
- layrz_sdk/entities/case_ignored_status.py +26 -0
- layrz_sdk/entities/case_status.py +23 -0
- layrz_sdk/entities/charts/axis_config.py +15 -0
- layrz_sdk/entities/charts/{bar.py → bar_chart.py} +171 -208
- layrz_sdk/entities/charts/chart_alignment.py +27 -0
- layrz_sdk/entities/charts/chart_color.py +44 -0
- layrz_sdk/entities/charts/chart_configuration.py +10 -0
- layrz_sdk/entities/charts/chart_data_serie.py +19 -0
- layrz_sdk/entities/charts/chart_data_serie_type.py +28 -0
- layrz_sdk/entities/charts/chart_data_type.py +27 -0
- layrz_sdk/entities/charts/{render_technology.py → chart_render_technology.py} +30 -29
- layrz_sdk/entities/charts/{column.py → column_chart.py} +197 -236
- layrz_sdk/entities/charts/html_chart.py +34 -0
- layrz_sdk/entities/charts/{line.py → line_chart.py} +244 -282
- layrz_sdk/entities/charts/map_center_type.py +22 -0
- layrz_sdk/entities/charts/map_chart.py +104 -0
- layrz_sdk/entities/charts/map_point.py +22 -0
- layrz_sdk/entities/charts/number_chart.py +50 -0
- layrz_sdk/entities/charts/{pie.py → pie_chart.py} +127 -148
- layrz_sdk/entities/charts/radar_chart.py +77 -0
- layrz_sdk/entities/charts/{radial_bar.py → radial_bar_chart.py} +127 -148
- layrz_sdk/entities/charts/{scatter.py → scatter_chart.py} +206 -290
- layrz_sdk/entities/charts/scatter_serie.py +15 -0
- layrz_sdk/entities/charts/scatter_serie_item.py +8 -0
- layrz_sdk/entities/charts/table_chart.py +50 -0
- layrz_sdk/entities/charts/table_header.py +8 -0
- layrz_sdk/entities/charts/table_row.py +9 -0
- layrz_sdk/entities/charts/timeline_chart.py +75 -0
- layrz_sdk/entities/charts/timeline_serie.py +12 -0
- layrz_sdk/entities/charts/timeline_serie_item.py +12 -0
- layrz_sdk/entities/checkpoint.py +18 -0
- layrz_sdk/entities/comment.py +16 -0
- layrz_sdk/entities/custom_field.py +10 -0
- layrz_sdk/entities/custom_report_page.py +16 -0
- layrz_sdk/entities/device.py +13 -0
- layrz_sdk/entities/event.py +23 -0
- layrz_sdk/entities/geofence.py +11 -0
- layrz_sdk/entities/last_message.py +12 -0
- layrz_sdk/entities/message.py +23 -0
- layrz_sdk/entities/outbound_service.py +10 -0
- layrz_sdk/entities/position.py +101 -0
- layrz_sdk/entities/presence_type.py +16 -0
- layrz_sdk/entities/{reports/report.py → report.py} +257 -286
- layrz_sdk/entities/report_col.py +40 -0
- layrz_sdk/entities/report_configuration.py +8 -0
- layrz_sdk/entities/report_data_type.py +28 -0
- layrz_sdk/entities/{reports/format.py → report_format.py} +27 -26
- layrz_sdk/entities/report_header.py +43 -0
- layrz_sdk/entities/report_page.py +17 -0
- layrz_sdk/entities/report_row.py +28 -0
- layrz_sdk/entities/sensor.py +11 -0
- layrz_sdk/entities/{formatting/text_align.py → text_alignment.py} +26 -25
- layrz_sdk/entities/trigger.py +11 -0
- layrz_sdk/entities/user.py +10 -0
- layrz_sdk/entities/waypoint.py +18 -0
- layrz_sdk/helpers/__init__.py +8 -2
- layrz_sdk/helpers/color.py +41 -45
- layrz_sdk/lcl/__init__.py +7 -2
- layrz_sdk/lcl/core.py +832 -820
- layrz_sdk/py.typed +0 -0
- {layrz_sdk-3.0.14.dist-info → layrz_sdk-3.1.1.dist-info}/LICENSE +6 -6
- {layrz_sdk-3.0.14.dist-info → layrz_sdk-3.1.1.dist-info}/METADATA +48 -45
- layrz_sdk-3.1.1.dist-info/RECORD +75 -0
- {layrz_sdk-3.0.14.dist-info → layrz_sdk-3.1.1.dist-info}/WHEEL +1 -1
- layrz_sdk/entities/broadcasts/__init__.py +0 -6
- layrz_sdk/entities/broadcasts/request.py +0 -30
- layrz_sdk/entities/broadcasts/response.py +0 -30
- layrz_sdk/entities/broadcasts/result.py +0 -53
- layrz_sdk/entities/broadcasts/service.py +0 -28
- layrz_sdk/entities/cases/__init__.py +0 -4
- layrz_sdk/entities/cases/case.py +0 -120
- layrz_sdk/entities/cases/comment.py +0 -37
- layrz_sdk/entities/cases/trigger.py +0 -31
- layrz_sdk/entities/charts/__init__.py +0 -21
- layrz_sdk/entities/charts/alignment.py +0 -26
- layrz_sdk/entities/charts/color.py +0 -38
- layrz_sdk/entities/charts/configuration.py +0 -54
- layrz_sdk/entities/charts/data_type.py +0 -26
- layrz_sdk/entities/charts/exceptions.py +0 -29
- layrz_sdk/entities/charts/html.py +0 -44
- layrz_sdk/entities/charts/map.py +0 -179
- layrz_sdk/entities/charts/number.py +0 -52
- layrz_sdk/entities/charts/radar.py +0 -102
- layrz_sdk/entities/charts/serie.py +0 -56
- layrz_sdk/entities/charts/serie_type.py +0 -27
- layrz_sdk/entities/charts/table.py +0 -74
- layrz_sdk/entities/charts/timeline.py +0 -148
- layrz_sdk/entities/checkpoints/__init__.py +0 -4
- layrz_sdk/entities/checkpoints/checkpoint.py +0 -50
- layrz_sdk/entities/checkpoints/waypoint.py +0 -52
- layrz_sdk/entities/events/__init__.py +0 -2
- layrz_sdk/entities/events/event.py +0 -58
- layrz_sdk/entities/formatting/__init__.py +0 -2
- layrz_sdk/entities/general/__init__.py +0 -9
- layrz_sdk/entities/general/asset.py +0 -72
- layrz_sdk/entities/general/custom_field.py +0 -29
- layrz_sdk/entities/general/device.py +0 -45
- layrz_sdk/entities/general/geofence.py +0 -53
- layrz_sdk/entities/general/sensor.py +0 -31
- layrz_sdk/entities/general/user.py +0 -29
- layrz_sdk/entities/repcom/__init__.py +0 -2
- layrz_sdk/entities/repcom/transaction.py +0 -54
- layrz_sdk/entities/reports/__init__.py +0 -7
- layrz_sdk/entities/reports/col.py +0 -86
- layrz_sdk/entities/reports/header.py +0 -57
- layrz_sdk/entities/reports/page.py +0 -64
- layrz_sdk/entities/reports/row.py +0 -43
- layrz_sdk/entities/telemetry/__init__.py +0 -5
- layrz_sdk/entities/telemetry/last_message.py +0 -41
- layrz_sdk/entities/telemetry/message.py +0 -37
- layrz_sdk/entities/telemetry/position.py +0 -51
- layrz_sdk-3.0.14.dist-info/RECORD +0 -70
- {layrz_sdk-3.0.14.dist-info → layrz_sdk-3.1.1.dist-info}/top_level.txt +0 -0
|
@@ -1,290 +1,206 @@
|
|
|
1
|
-
"""Scatter chart"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
from
|
|
7
|
-
|
|
8
|
-
from .
|
|
9
|
-
from .
|
|
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
|
-
def
|
|
36
|
-
self,
|
|
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
|
-
series
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
'
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
'
|
|
198
|
-
'
|
|
199
|
-
'
|
|
200
|
-
'
|
|
201
|
-
'
|
|
202
|
-
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
'dataType': self.y_axis_config.data_type.value,
|
|
208
|
-
'minValue': self.y_axis_config.min_value,
|
|
209
|
-
'maxValue': self.y_axis_config.max_value,
|
|
210
|
-
},
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
def _render_graphic(self) -> Any:
|
|
214
|
-
"""
|
|
215
|
-
Converts the configuration of the chart to Flutter library Graphic.
|
|
216
|
-
"""
|
|
217
|
-
series = []
|
|
218
|
-
for serie in self.series:
|
|
219
|
-
data = []
|
|
220
|
-
|
|
221
|
-
type_serie = 'SCATTER'
|
|
222
|
-
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
223
|
-
type_serie = 'SCATTER'
|
|
224
|
-
elif serie.serie_type == ChartDataSerieType.LINE:
|
|
225
|
-
type_serie = 'LINE'
|
|
226
|
-
elif serie.serie_type == ChartDataSerieType.AREA:
|
|
227
|
-
type_serie = 'AREA'
|
|
228
|
-
else:
|
|
229
|
-
continue
|
|
230
|
-
|
|
231
|
-
for item in serie.data:
|
|
232
|
-
data.append(
|
|
233
|
-
{
|
|
234
|
-
'x_axis': item.x,
|
|
235
|
-
'y_axis': item.y,
|
|
236
|
-
}
|
|
237
|
-
)
|
|
238
|
-
|
|
239
|
-
series.append(
|
|
240
|
-
{
|
|
241
|
-
'group': serie.label,
|
|
242
|
-
'color': serie.color,
|
|
243
|
-
'values': data,
|
|
244
|
-
'type': type_serie,
|
|
245
|
-
}
|
|
246
|
-
)
|
|
247
|
-
|
|
248
|
-
return series
|
|
249
|
-
|
|
250
|
-
def _render_apexcharts(self) -> Any:
|
|
251
|
-
"""
|
|
252
|
-
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
253
|
-
"""
|
|
254
|
-
|
|
255
|
-
series = []
|
|
256
|
-
colors = []
|
|
257
|
-
|
|
258
|
-
for serie in self.series:
|
|
259
|
-
data = []
|
|
260
|
-
|
|
261
|
-
for item in serie.data:
|
|
262
|
-
data.append([item.x, item.y])
|
|
263
|
-
|
|
264
|
-
series.append(
|
|
265
|
-
{
|
|
266
|
-
'name': serie.label,
|
|
267
|
-
'data': data,
|
|
268
|
-
'type': serie.serie_type.value,
|
|
269
|
-
}
|
|
270
|
-
)
|
|
271
|
-
colors.append(serie.color)
|
|
272
|
-
|
|
273
|
-
config = {
|
|
274
|
-
'series': series,
|
|
275
|
-
'colors': colors,
|
|
276
|
-
'title': {
|
|
277
|
-
'text': self.title,
|
|
278
|
-
'align': self.align.value,
|
|
279
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
280
|
-
},
|
|
281
|
-
'chart': {
|
|
282
|
-
'type': 'scatter',
|
|
283
|
-
'animations': {'enabled': False},
|
|
284
|
-
'toolbar': {'show': False},
|
|
285
|
-
'zoom': {'enabled': False},
|
|
286
|
-
},
|
|
287
|
-
'dataLabels': {'enabled': True},
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return config
|
|
1
|
+
"""Scatter chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .axis_config import AxisConfig
|
|
9
|
+
from .chart_alignment import ChartAlignment
|
|
10
|
+
from .chart_data_serie_type import ChartDataSerieType
|
|
11
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
12
|
+
from .scatter_serie import ScatterSerie
|
|
13
|
+
|
|
14
|
+
if sys.version_info >= (3, 11):
|
|
15
|
+
from typing import Self
|
|
16
|
+
else:
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class ScatterChart(BaseModel):
|
|
21
|
+
"""Scatter chart configuration"""
|
|
22
|
+
|
|
23
|
+
series: List[ScatterSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
|
|
24
|
+
title: str = Field(description='Title of the chart', default='Chart')
|
|
25
|
+
align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
|
|
26
|
+
x_axis_config: AxisConfig = Field(
|
|
27
|
+
default_factory=lambda: AxisConfig(),
|
|
28
|
+
description='Configuration of the X Axis',
|
|
29
|
+
)
|
|
30
|
+
y_axis_config: AxisConfig = Field(
|
|
31
|
+
default_factory=lambda: AxisConfig(),
|
|
32
|
+
description='Configuration of the Y Axis',
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
def render(
|
|
36
|
+
self: Self,
|
|
37
|
+
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
38
|
+
) -> Dict[str, Any]:
|
|
39
|
+
"""
|
|
40
|
+
Render chart to a graphic Library.
|
|
41
|
+
:param technology: The technology to use to render the chart.
|
|
42
|
+
:return: The configuration of the chart.
|
|
43
|
+
"""
|
|
44
|
+
if technology == ChartRenderTechnology.GRAPHIC:
|
|
45
|
+
return {
|
|
46
|
+
'library': 'GRAPHIC',
|
|
47
|
+
'chart': 'SCATTER',
|
|
48
|
+
'configuration': self._render_graphic(),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
52
|
+
return {
|
|
53
|
+
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
54
|
+
'chart': 'SCATTER',
|
|
55
|
+
'configuration': self._render_syncfusion_flutter_charts(),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if technology == ChartRenderTechnology.APEX_CHARTS:
|
|
59
|
+
return {
|
|
60
|
+
'library': 'APEXCHARTS',
|
|
61
|
+
'chart': 'SCATTER',
|
|
62
|
+
'configuration': self._render_apexcharts(),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
'library': 'FLUTTER',
|
|
67
|
+
'chart': 'TEXT',
|
|
68
|
+
'configuration': [f'Unsupported {technology}'],
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
def _render_syncfusion_flutter_charts(self: Self) -> Dict[str, Any]:
|
|
72
|
+
"""
|
|
73
|
+
Converts the configuration of the chart to Flutter library Graphic.
|
|
74
|
+
"""
|
|
75
|
+
series = []
|
|
76
|
+
for serie in self.series:
|
|
77
|
+
data = []
|
|
78
|
+
|
|
79
|
+
type_serie = 'SCATTER'
|
|
80
|
+
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
81
|
+
type_serie = 'SCATTER'
|
|
82
|
+
elif serie.serie_type == ChartDataSerieType.LINE:
|
|
83
|
+
type_serie = 'LINE'
|
|
84
|
+
elif serie.serie_type == ChartDataSerieType.AREA:
|
|
85
|
+
type_serie = 'AREA'
|
|
86
|
+
else:
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
for item in serie.data:
|
|
90
|
+
if not isinstance(item.x, (int, float)):
|
|
91
|
+
continue
|
|
92
|
+
if not isinstance(item.y, (int, float)):
|
|
93
|
+
continue
|
|
94
|
+
|
|
95
|
+
data.append(
|
|
96
|
+
{
|
|
97
|
+
'xAxis': item.x,
|
|
98
|
+
'yAxis': item.y,
|
|
99
|
+
}
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
series.append(
|
|
103
|
+
{
|
|
104
|
+
'label': serie.label,
|
|
105
|
+
'color': serie.color,
|
|
106
|
+
'values': data,
|
|
107
|
+
'type': type_serie,
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
'series': series,
|
|
113
|
+
'xAxis': {
|
|
114
|
+
'label': self.x_axis_config.label,
|
|
115
|
+
'measureUnit': self.x_axis_config.measure_unit,
|
|
116
|
+
'dataType': self.x_axis_config.data_type.value,
|
|
117
|
+
'minValue': self.x_axis_config.min_value,
|
|
118
|
+
'maxValue': self.x_axis_config.max_value,
|
|
119
|
+
},
|
|
120
|
+
'yAxis': {
|
|
121
|
+
'label': self.y_axis_config.label,
|
|
122
|
+
'measureUnit': self.y_axis_config.measure_unit,
|
|
123
|
+
'dataType': self.y_axis_config.data_type.value,
|
|
124
|
+
'minValue': self.y_axis_config.min_value,
|
|
125
|
+
'maxValue': self.y_axis_config.max_value,
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
def _render_graphic(self: Self) -> List[Dict[str, Any]]:
|
|
130
|
+
"""
|
|
131
|
+
Converts the configuration of the chart to Flutter library Graphic.
|
|
132
|
+
"""
|
|
133
|
+
series = []
|
|
134
|
+
for serie in self.series:
|
|
135
|
+
data = []
|
|
136
|
+
|
|
137
|
+
type_serie = 'SCATTER'
|
|
138
|
+
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
139
|
+
type_serie = 'SCATTER'
|
|
140
|
+
elif serie.serie_type == ChartDataSerieType.LINE:
|
|
141
|
+
type_serie = 'LINE'
|
|
142
|
+
elif serie.serie_type == ChartDataSerieType.AREA:
|
|
143
|
+
type_serie = 'AREA'
|
|
144
|
+
else:
|
|
145
|
+
continue
|
|
146
|
+
|
|
147
|
+
for item in serie.data:
|
|
148
|
+
data.append(
|
|
149
|
+
{
|
|
150
|
+
'x_axis': item.x,
|
|
151
|
+
'y_axis': item.y,
|
|
152
|
+
}
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
series.append(
|
|
156
|
+
{
|
|
157
|
+
'group': serie.label,
|
|
158
|
+
'color': serie.color,
|
|
159
|
+
'values': data,
|
|
160
|
+
'type': type_serie,
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
return series
|
|
165
|
+
|
|
166
|
+
def _render_apexcharts(self: Self) -> Dict[str, Any]:
|
|
167
|
+
"""
|
|
168
|
+
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
series = []
|
|
172
|
+
colors = []
|
|
173
|
+
|
|
174
|
+
for serie in self.series:
|
|
175
|
+
data = []
|
|
176
|
+
|
|
177
|
+
for item in serie.data:
|
|
178
|
+
data.append([item.x, item.y])
|
|
179
|
+
|
|
180
|
+
series.append(
|
|
181
|
+
{
|
|
182
|
+
'name': serie.label,
|
|
183
|
+
'data': data,
|
|
184
|
+
'type': serie.serie_type.value,
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
colors.append(serie.color)
|
|
188
|
+
|
|
189
|
+
config = {
|
|
190
|
+
'series': series,
|
|
191
|
+
'colors': colors,
|
|
192
|
+
'title': {
|
|
193
|
+
'text': self.title,
|
|
194
|
+
'align': self.align.value,
|
|
195
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
196
|
+
},
|
|
197
|
+
'chart': {
|
|
198
|
+
'type': 'scatter',
|
|
199
|
+
'animations': {'enabled': False},
|
|
200
|
+
'toolbar': {'show': False},
|
|
201
|
+
'zoom': {'enabled': False},
|
|
202
|
+
},
|
|
203
|
+
'dataLabels': {'enabled': True},
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
return config
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from typing import List
|
|
2
|
+
|
|
3
|
+
from pydantic import BaseModel, Field
|
|
4
|
+
|
|
5
|
+
from .chart_data_serie_type import ChartDataSerieType
|
|
6
|
+
from .scatter_serie_item import ScatterSerieItem
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ScatterSerie(BaseModel):
|
|
10
|
+
"""Chart Data Serie for Timeline charts"""
|
|
11
|
+
|
|
12
|
+
data: List[ScatterSerieItem] = Field(description='List of data points', default_factory=list)
|
|
13
|
+
color: str = Field(description='Color of the serie', default='')
|
|
14
|
+
label: str = Field(description='Label of the serie', default='')
|
|
15
|
+
serie_type: ChartDataSerieType = Field(description='Type of the serie', default=ChartDataSerieType.SCATTER)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Number chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
9
|
+
from .table_header import TableHeader
|
|
10
|
+
from .table_row import TableRow
|
|
11
|
+
|
|
12
|
+
if sys.version_info >= (3, 11):
|
|
13
|
+
from typing import Self
|
|
14
|
+
else:
|
|
15
|
+
from typing_extensions import Self
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TableChart(BaseModel):
|
|
19
|
+
"""Table chart configuration"""
|
|
20
|
+
|
|
21
|
+
columns: List[TableHeader] = Field(description='List of columns', default_factory=list)
|
|
22
|
+
rows: List[TableRow] = Field(description='List of rows', default_factory=list)
|
|
23
|
+
|
|
24
|
+
def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) -> Dict[str, Any]:
|
|
25
|
+
"""
|
|
26
|
+
Render chart to a graphic Library.
|
|
27
|
+
:param technology: The technology to use to render the chart.
|
|
28
|
+
:return: The configuration of the chart.
|
|
29
|
+
"""
|
|
30
|
+
if technology == ChartRenderTechnology.FLUTTER:
|
|
31
|
+
return {
|
|
32
|
+
'library': 'FLUTTER',
|
|
33
|
+
'chart': 'TABLE',
|
|
34
|
+
'configuration': self._render_flutter(),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
'library': 'FLUTTER',
|
|
39
|
+
'chart': 'TEXT',
|
|
40
|
+
'configuration': [f'Unsupported {technology}'],
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
def _render_flutter(self: Self) -> Dict[str, Any]:
|
|
44
|
+
"""
|
|
45
|
+
Converts the configuration of the chart to a Flutter native components.
|
|
46
|
+
"""
|
|
47
|
+
return {
|
|
48
|
+
'columns': [{'key': column.key, 'label': column.label} for column in self.columns],
|
|
49
|
+
'rows': [{'data': row.data} for row in self.rows],
|
|
50
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Timeline chart entities"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Dict, List
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .chart_alignment import ChartAlignment
|
|
9
|
+
from .timeline_serie import TimelineSerie
|
|
10
|
+
|
|
11
|
+
if sys.version_info >= (3, 11):
|
|
12
|
+
from typing import Self
|
|
13
|
+
else:
|
|
14
|
+
from typing_extensions import Self
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class TimelineChart(BaseModel):
|
|
18
|
+
"""Timeline chart configuration"""
|
|
19
|
+
|
|
20
|
+
series: List[TimelineSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
|
|
21
|
+
title: str = Field(description='Title of the chart', default='Chart')
|
|
22
|
+
align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
|
|
23
|
+
|
|
24
|
+
def render(self: Self) -> Dict[str, Any]:
|
|
25
|
+
"""
|
|
26
|
+
Render chart to a graphic Library.
|
|
27
|
+
:param technology: The technology to use to render the chart.
|
|
28
|
+
:return: The configuration of the chart.
|
|
29
|
+
"""
|
|
30
|
+
return {'library': 'APEXCHARTS', 'configuration': self._render_apexcharts()}
|
|
31
|
+
|
|
32
|
+
def _render_apexcharts(self: Self) -> Dict[str, Any]:
|
|
33
|
+
"""
|
|
34
|
+
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
35
|
+
"""
|
|
36
|
+
|
|
37
|
+
series = []
|
|
38
|
+
|
|
39
|
+
for serie in self.series:
|
|
40
|
+
data = []
|
|
41
|
+
|
|
42
|
+
for item in serie.data:
|
|
43
|
+
data.append(
|
|
44
|
+
{
|
|
45
|
+
'x': item.name,
|
|
46
|
+
'y': [item.start_at.timestamp() * 1000, item.end_at.timestamp() * 1000],
|
|
47
|
+
'fillColor': item.color,
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
series.append({'name': serie.label, 'data': data})
|
|
52
|
+
|
|
53
|
+
config = {
|
|
54
|
+
'series': series,
|
|
55
|
+
'title': {
|
|
56
|
+
'text': self.title,
|
|
57
|
+
'align': self.align.value,
|
|
58
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
59
|
+
},
|
|
60
|
+
'chart': {
|
|
61
|
+
'type': 'rangeBar',
|
|
62
|
+
'animations': {'enabled': False},
|
|
63
|
+
'toolbar': {'show': False},
|
|
64
|
+
'zoom': {'enabled': False},
|
|
65
|
+
},
|
|
66
|
+
'xaxis': {'type': 'datetime'},
|
|
67
|
+
'plotOptions': {
|
|
68
|
+
'bar': {
|
|
69
|
+
'horizontal': True,
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
'dataLabels': {'enabled': True},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return config
|