layrz-sdk 3.0.8__py3-none-any.whl → 3.0.10__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/entities/broadcasts/request.py +10 -9
- layrz_sdk/entities/broadcasts/response.py +10 -9
- layrz_sdk/entities/broadcasts/result.py +13 -11
- layrz_sdk/entities/broadcasts/service.py +8 -9
- layrz_sdk/entities/broadcasts/status.py +10 -9
- layrz_sdk/entities/cases/case.py +33 -30
- layrz_sdk/entities/cases/comment.py +10 -10
- layrz_sdk/entities/cases/trigger.py +9 -10
- layrz_sdk/entities/charts/alignment.py +9 -8
- layrz_sdk/entities/charts/bar.py +31 -45
- layrz_sdk/entities/charts/color.py +12 -10
- layrz_sdk/entities/charts/column.py +30 -49
- layrz_sdk/entities/charts/configuration.py +11 -12
- layrz_sdk/entities/charts/data_type.py +9 -8
- layrz_sdk/entities/charts/exceptions.py +11 -12
- layrz_sdk/entities/charts/html.py +6 -5
- layrz_sdk/entities/charts/line.py +52 -46
- layrz_sdk/entities/charts/map.py +23 -19
- layrz_sdk/entities/charts/number.py +6 -5
- layrz_sdk/entities/charts/pie.py +27 -34
- layrz_sdk/entities/charts/radar.py +14 -34
- layrz_sdk/entities/charts/radial_bar.py +27 -34
- layrz_sdk/entities/charts/render_technology.py +9 -8
- layrz_sdk/entities/charts/scatter.py +52 -53
- layrz_sdk/entities/charts/serie.py +4 -3
- layrz_sdk/entities/charts/serie_type.py +9 -8
- layrz_sdk/entities/charts/table.py +6 -6
- layrz_sdk/entities/charts/timeline.py +21 -32
- layrz_sdk/entities/checkpoints/checkpoint.py +15 -12
- layrz_sdk/entities/checkpoints/geofence.py +9 -10
- layrz_sdk/entities/checkpoints/waypoint.py +14 -12
- layrz_sdk/entities/events/event.py +15 -13
- layrz_sdk/entities/formatting/text_align.py +10 -9
- layrz_sdk/entities/general/asset.py +16 -13
- layrz_sdk/entities/general/asset_operation_mode.py +9 -8
- layrz_sdk/entities/general/custom_field.py +9 -10
- layrz_sdk/entities/general/device.py +13 -12
- layrz_sdk/entities/general/sensor.py +9 -10
- layrz_sdk/entities/general/user.py +9 -10
- layrz_sdk/entities/repcom/transaction.py +4 -4
- layrz_sdk/entities/reports/col.py +17 -15
- layrz_sdk/entities/reports/format.py +3 -4
- layrz_sdk/entities/reports/header.py +4 -5
- layrz_sdk/entities/reports/page.py +12 -11
- layrz_sdk/entities/reports/report.py +18 -14
- layrz_sdk/entities/reports/row.py +10 -10
- layrz_sdk/entities/telemetry/message.py +5 -4
- layrz_sdk/entities/telemetry/position.py +13 -12
- layrz_sdk/lcl/core.py +53 -53
- {layrz_sdk-3.0.8.dist-info → layrz_sdk-3.0.10.dist-info}/METADATA +1 -1
- layrz_sdk-3.0.10.dist-info/RECORD +69 -0
- layrz_sdk-3.0.8.dist-info/RECORD +0 -69
- {layrz_sdk-3.0.8.dist-info → layrz_sdk-3.0.10.dist-info}/LICENSE +0 -0
- {layrz_sdk-3.0.8.dist-info → layrz_sdk-3.0.10.dist-info}/WHEEL +0 -0
- {layrz_sdk-3.0.8.dist-info → layrz_sdk-3.0.10.dist-info}/top_level.txt +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
1
|
+
"""Column chart"""
|
|
2
|
+
|
|
3
|
+
from typing import Any, List
|
|
3
4
|
|
|
4
5
|
from layrz_sdk.helpers import convert_to_rgba
|
|
5
6
|
|
|
@@ -18,7 +19,7 @@ class ColumnChart:
|
|
|
18
19
|
"""
|
|
19
20
|
|
|
20
21
|
def __init__(
|
|
21
|
-
self
|
|
22
|
+
self,
|
|
22
23
|
x_axis: ChartDataSerie,
|
|
23
24
|
y_axis: List[ChartDataSerie],
|
|
24
25
|
title: str = 'Chart',
|
|
@@ -71,7 +72,7 @@ class ColumnChart:
|
|
|
71
72
|
self.y_axis_config = y_axis_config
|
|
72
73
|
|
|
73
74
|
def render(
|
|
74
|
-
self
|
|
75
|
+
self,
|
|
75
76
|
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
76
77
|
) -> Any:
|
|
77
78
|
"""
|
|
@@ -108,7 +109,7 @@ class ColumnChart:
|
|
|
108
109
|
'configuration': [f'Unsupported {technology}'],
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
def _render_syncfusion_flutter_charts(self
|
|
112
|
+
def _render_syncfusion_flutter_charts(self) -> Any:
|
|
112
113
|
"""
|
|
113
114
|
Converts the configuration of the chart to Syncfusion Flutter Charts.
|
|
114
115
|
"""
|
|
@@ -120,11 +121,13 @@ class ColumnChart:
|
|
|
120
121
|
x_axis = self.x_axis.data[i]
|
|
121
122
|
values.append({'xAxis': x_axis, 'yAxis': value})
|
|
122
123
|
|
|
123
|
-
series.append(
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
series.append(
|
|
125
|
+
{
|
|
126
|
+
'label': serie.label,
|
|
127
|
+
'color': serie.color,
|
|
128
|
+
'values': values,
|
|
129
|
+
}
|
|
130
|
+
)
|
|
128
131
|
|
|
129
132
|
return {
|
|
130
133
|
'series': series,
|
|
@@ -144,7 +147,7 @@ class ColumnChart:
|
|
|
144
147
|
},
|
|
145
148
|
}
|
|
146
149
|
|
|
147
|
-
def _render_graphic(self
|
|
150
|
+
def _render_graphic(self) -> Any:
|
|
148
151
|
"""
|
|
149
152
|
Converts the configuration of the chart to Flutter library graphic.
|
|
150
153
|
"""
|
|
@@ -154,16 +157,18 @@ class ColumnChart:
|
|
|
154
157
|
for serie in self.y_axis:
|
|
155
158
|
for i, value in enumerate(serie.data):
|
|
156
159
|
x_axis = self.x_axis.data[i]
|
|
157
|
-
series.append(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
160
|
+
series.append(
|
|
161
|
+
{
|
|
162
|
+
'label': serie.label,
|
|
163
|
+
'color': serie.color,
|
|
164
|
+
'category': x_axis,
|
|
165
|
+
'value': value,
|
|
166
|
+
}
|
|
167
|
+
)
|
|
163
168
|
|
|
164
169
|
return series
|
|
165
170
|
|
|
166
|
-
def _render_apexcharts(self
|
|
171
|
+
def _render_apexcharts(self) -> Any:
|
|
167
172
|
"""
|
|
168
173
|
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
169
174
|
"""
|
|
@@ -213,43 +218,19 @@ class ColumnChart:
|
|
|
213
218
|
'type': self.x_axis.data_type.value,
|
|
214
219
|
'title': {
|
|
215
220
|
'text': self.x_axis.label,
|
|
216
|
-
'style': {
|
|
217
|
-
|
|
218
|
-
'fontSize': '20px',
|
|
219
|
-
'fontWeight': 'normal'
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
'dataLabels': {
|
|
224
|
-
'enabled': False
|
|
221
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
222
|
+
},
|
|
225
223
|
},
|
|
224
|
+
'dataLabels': {'enabled': False},
|
|
226
225
|
'title': {
|
|
227
226
|
'text': self.title,
|
|
228
227
|
'align': self.align.value,
|
|
229
|
-
'style': {
|
|
230
|
-
'fontFamily': 'Fira Sans Condensed',
|
|
231
|
-
'fontSize': '20px',
|
|
232
|
-
'fontWeight': 'normal'
|
|
233
|
-
}
|
|
234
|
-
},
|
|
235
|
-
'markers': {
|
|
236
|
-
'size': markers
|
|
237
|
-
},
|
|
238
|
-
'fill': {
|
|
239
|
-
'type': 'solid'
|
|
228
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
240
229
|
},
|
|
230
|
+
'markers': {'size': markers},
|
|
231
|
+
'fill': {'type': 'solid'},
|
|
241
232
|
'stroke': stroke,
|
|
242
|
-
'chart': {
|
|
243
|
-
'animations': {
|
|
244
|
-
'enabled': False
|
|
245
|
-
},
|
|
246
|
-
'toolbar': {
|
|
247
|
-
'show': False
|
|
248
|
-
},
|
|
249
|
-
'zoom': {
|
|
250
|
-
'enabled': False
|
|
251
|
-
}
|
|
252
|
-
}
|
|
233
|
+
'chart': {'animations': {'enabled': False}, 'toolbar': {'show': False}, 'zoom': {'enabled': False}},
|
|
253
234
|
}
|
|
254
235
|
|
|
255
236
|
return config
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
from typing import Self
|
|
1
|
+
"""Charts entities"""
|
|
3
2
|
|
|
4
3
|
from .data_type import ChartDataType
|
|
5
4
|
|
|
@@ -9,30 +8,30 @@ class ChartConfiguration:
|
|
|
9
8
|
Chart configuration
|
|
10
9
|
"""
|
|
11
10
|
|
|
12
|
-
def __init__(self
|
|
13
|
-
"""
|
|
11
|
+
def __init__(self, name: str, description: str) -> None:
|
|
12
|
+
"""Constructor"""
|
|
14
13
|
self.name = name
|
|
15
14
|
self.description = description
|
|
16
15
|
|
|
17
16
|
@property
|
|
18
|
-
def _readable(self
|
|
19
|
-
"""
|
|
17
|
+
def _readable(self) -> str | None | bool:
|
|
18
|
+
"""Readable"""
|
|
20
19
|
return f'ChartConfiguration(name="{self.name}")'
|
|
21
20
|
|
|
22
|
-
def __str__(self
|
|
23
|
-
"""
|
|
21
|
+
def __str__(self) -> str | None | bool:
|
|
22
|
+
"""Readable property"""
|
|
24
23
|
return self._readable
|
|
25
24
|
|
|
26
|
-
def __repr__(self
|
|
27
|
-
"""
|
|
25
|
+
def __repr__(self) -> str | None | bool:
|
|
26
|
+
"""Readable property"""
|
|
28
27
|
return self._readable
|
|
29
28
|
|
|
30
29
|
|
|
31
30
|
class AxisConfig:
|
|
32
|
-
"""
|
|
31
|
+
"""Axis configuration"""
|
|
33
32
|
|
|
34
33
|
def __init__(
|
|
35
|
-
self
|
|
34
|
+
self,
|
|
36
35
|
label: str = '',
|
|
37
36
|
measure_unit: str = '',
|
|
38
37
|
min_value: float = None,
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Chart Data type"""
|
|
2
|
+
|
|
2
3
|
from enum import Enum
|
|
3
|
-
from typing import Self
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
class ChartDataType(Enum):
|
|
7
7
|
"""
|
|
8
8
|
Chart Data Type
|
|
9
9
|
"""
|
|
10
|
+
|
|
10
11
|
STRING = 'STRING'
|
|
11
12
|
DATETIME = 'DATETIME'
|
|
12
13
|
NUMBER = 'NUMBER'
|
|
13
14
|
|
|
14
15
|
@property
|
|
15
|
-
def _readable(self
|
|
16
|
-
"""
|
|
16
|
+
def _readable(self) -> str | None | bool:
|
|
17
|
+
"""Readable"""
|
|
17
18
|
return f'ChartDataType.{self.value}'
|
|
18
19
|
|
|
19
|
-
def __str__(self
|
|
20
|
-
"""
|
|
20
|
+
def __str__(self) -> str | None | bool:
|
|
21
|
+
"""Readable property"""
|
|
21
22
|
return self._readable
|
|
22
23
|
|
|
23
|
-
def __repr__(self
|
|
24
|
-
"""
|
|
24
|
+
def __repr__(self) -> str | None | bool:
|
|
25
|
+
"""Readable property"""
|
|
25
26
|
return self._readable
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
from typing import Self
|
|
1
|
+
"""Chart exceptions"""
|
|
3
2
|
|
|
4
3
|
|
|
5
4
|
class ChartException(BaseException):
|
|
@@ -7,24 +6,24 @@ class ChartException(BaseException):
|
|
|
7
6
|
Chart Exception
|
|
8
7
|
"""
|
|
9
8
|
|
|
10
|
-
def __init__(self
|
|
11
|
-
"""
|
|
9
|
+
def __init__(self, message: str) -> None:
|
|
10
|
+
"""Constructor"""
|
|
12
11
|
self._message = message
|
|
13
12
|
|
|
14
13
|
@property
|
|
15
|
-
def message(self
|
|
16
|
-
"""
|
|
14
|
+
def message(self) -> str | None | bool:
|
|
15
|
+
"""Message"""
|
|
17
16
|
return self._message
|
|
18
17
|
|
|
19
18
|
@property
|
|
20
|
-
def _readable(self
|
|
21
|
-
"""
|
|
19
|
+
def _readable(self) -> str | None | bool:
|
|
20
|
+
"""Readable"""
|
|
22
21
|
return f'ChartException: {self._message}'
|
|
23
22
|
|
|
24
|
-
def __str__(self
|
|
25
|
-
"""
|
|
23
|
+
def __str__(self) -> str | None | bool:
|
|
24
|
+
"""Readable property"""
|
|
26
25
|
return self._readable
|
|
27
26
|
|
|
28
|
-
def __repr__(self
|
|
29
|
-
"""
|
|
27
|
+
def __repr__(self) -> str | None | bool:
|
|
28
|
+
"""Readable property"""
|
|
30
29
|
return self._readable
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
1
|
+
"""HTML chart"""
|
|
2
|
+
|
|
3
|
+
from typing import Any, List
|
|
3
4
|
|
|
4
5
|
from .exceptions import ChartException
|
|
5
6
|
|
|
@@ -9,7 +10,7 @@ class HTMLChart:
|
|
|
9
10
|
HTML chart configuration
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
|
-
def __init__(self
|
|
13
|
+
def __init__(self, content: str = '<p>N/A</p>', title: str = 'Chart') -> None:
|
|
13
14
|
"""
|
|
14
15
|
Constructor
|
|
15
16
|
|
|
@@ -27,14 +28,14 @@ class HTMLChart:
|
|
|
27
28
|
raise ChartException('title must be an instance of str')
|
|
28
29
|
self.title = title
|
|
29
30
|
|
|
30
|
-
def render(self
|
|
31
|
+
def render(self) -> Any:
|
|
31
32
|
"""
|
|
32
33
|
Render chart to a Javascript Library.
|
|
33
34
|
Currently only available for HTML.
|
|
34
35
|
"""
|
|
35
36
|
return {'library': 'HTML', 'configuration': self._render_html()}
|
|
36
37
|
|
|
37
|
-
def _render_html(self
|
|
38
|
+
def _render_html(self) -> Any:
|
|
38
39
|
"""
|
|
39
40
|
Converts the configuration of the chart to HTML render engine.
|
|
40
41
|
"""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Line chart"""
|
|
2
|
+
|
|
2
3
|
import logging
|
|
3
|
-
from typing import Any, List
|
|
4
|
+
from typing import Any, List
|
|
4
5
|
|
|
5
6
|
from .alignment import ChartAlignment
|
|
6
7
|
from .configuration import AxisConfig
|
|
@@ -20,7 +21,7 @@ class LineChart:
|
|
|
20
21
|
"""
|
|
21
22
|
|
|
22
23
|
def __init__(
|
|
23
|
-
self
|
|
24
|
+
self,
|
|
24
25
|
x_axis: ChartDataSerie,
|
|
25
26
|
y_axis: List[ChartDataSerie],
|
|
26
27
|
title: str = 'Chart',
|
|
@@ -72,7 +73,7 @@ class LineChart:
|
|
|
72
73
|
raise ChartException('y_axis_config must be an instance of AxisConfig')
|
|
73
74
|
self.y_axis_config = y_axis_config
|
|
74
75
|
|
|
75
|
-
def render(self
|
|
76
|
+
def render(self, technology: ChartRenderTechnology) -> Any:
|
|
76
77
|
"""
|
|
77
78
|
Render chart to a graphic Library.
|
|
78
79
|
We have two graphic libraries: GRAPHIC and CANVASJS.
|
|
@@ -108,7 +109,7 @@ class LineChart:
|
|
|
108
109
|
'configuration': [f'Unsupported {technology}'],
|
|
109
110
|
}
|
|
110
111
|
|
|
111
|
-
def _render_syncfusion_flutter_charts(self
|
|
112
|
+
def _render_syncfusion_flutter_charts(self) -> Any:
|
|
112
113
|
"""
|
|
113
114
|
Converts the configuration of the chart to a Flutter library syncfusion_flutter_charts.
|
|
114
115
|
"""
|
|
@@ -134,20 +135,24 @@ class LineChart:
|
|
|
134
135
|
y_value = 0
|
|
135
136
|
|
|
136
137
|
if not isinstance(y_value, (int, float)):
|
|
137
|
-
log.debug(
|
|
138
|
+
log.debug("Value isn't a number: %s", y_value)
|
|
138
139
|
continue
|
|
139
140
|
|
|
140
|
-
points.append(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
141
|
+
points.append(
|
|
142
|
+
{
|
|
143
|
+
'xAxis': x_value,
|
|
144
|
+
'yAxis': y_value,
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
series.append(
|
|
149
|
+
{
|
|
150
|
+
'color': serie.color,
|
|
151
|
+
'values': points,
|
|
152
|
+
'label': serie.label,
|
|
153
|
+
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
154
|
+
}
|
|
155
|
+
)
|
|
151
156
|
|
|
152
157
|
return {
|
|
153
158
|
'series': series,
|
|
@@ -167,7 +172,7 @@ class LineChart:
|
|
|
167
172
|
},
|
|
168
173
|
}
|
|
169
174
|
|
|
170
|
-
def _render_graphic(self
|
|
175
|
+
def _render_graphic(self) -> Any:
|
|
171
176
|
"""
|
|
172
177
|
Converts the configuration of the chart to a Flutter library Graphic.
|
|
173
178
|
"""
|
|
@@ -180,25 +185,29 @@ class LineChart:
|
|
|
180
185
|
points = []
|
|
181
186
|
|
|
182
187
|
for i, value in enumerate(self.x_axis.data):
|
|
183
|
-
points.append(
|
|
184
|
-
|
|
185
|
-
'
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
188
|
+
points.append(
|
|
189
|
+
{
|
|
190
|
+
'x_axis': {
|
|
191
|
+
'value': value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
192
|
+
'is_datetime': self.x_axis.data_type == ChartDataType.DATETIME,
|
|
193
|
+
},
|
|
194
|
+
'y_axis': serie.data[i],
|
|
195
|
+
}
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
series.append(
|
|
199
|
+
{
|
|
200
|
+
'group': serie.label,
|
|
201
|
+
'color': serie.color,
|
|
202
|
+
'dashed': serie.serie_type == ChartDataSerieType.LINE and serie.dashed,
|
|
203
|
+
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
204
|
+
'values': points,
|
|
205
|
+
}
|
|
206
|
+
)
|
|
198
207
|
|
|
199
208
|
return series
|
|
200
209
|
|
|
201
|
-
def _render_canvasjs(self
|
|
210
|
+
def _render_canvasjs(self) -> Any:
|
|
202
211
|
"""
|
|
203
212
|
Converts the configuration of the chart to Javascript library CanvasJS.
|
|
204
213
|
"""
|
|
@@ -236,10 +245,12 @@ class LineChart:
|
|
|
236
245
|
points.append({'x': point.x, 'y': point.y})
|
|
237
246
|
else:
|
|
238
247
|
for i, value in enumerate(self.x_axis.data):
|
|
239
|
-
points.append(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
248
|
+
points.append(
|
|
249
|
+
{
|
|
250
|
+
'x': (value.timestamp() * 1000) if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
251
|
+
'y': serie.data[i],
|
|
252
|
+
}
|
|
253
|
+
)
|
|
243
254
|
|
|
244
255
|
dataset['dataPoints'] = points
|
|
245
256
|
datasets.append(dataset)
|
|
@@ -251,7 +262,7 @@ class LineChart:
|
|
|
251
262
|
'text': self.title,
|
|
252
263
|
'fontFamily': 'Fira Sans Condensed',
|
|
253
264
|
'fontSize': 20,
|
|
254
|
-
'horizontalAlign': self.align.value
|
|
265
|
+
'horizontalAlign': self.align.value,
|
|
255
266
|
},
|
|
256
267
|
'data': datasets,
|
|
257
268
|
'axisX': {
|
|
@@ -259,13 +270,8 @@ class LineChart:
|
|
|
259
270
|
'titleFontFamily': 'Fira Sans Condensed',
|
|
260
271
|
'titleFontSize': 20,
|
|
261
272
|
},
|
|
262
|
-
'toolTip': {
|
|
263
|
-
|
|
264
|
-
'shared': True
|
|
265
|
-
},
|
|
266
|
-
'legend': {
|
|
267
|
-
'cursor': 'pointer'
|
|
268
|
-
}
|
|
273
|
+
'toolTip': {'animationEnabled': False, 'shared': True},
|
|
274
|
+
'legend': {'cursor': 'pointer'},
|
|
269
275
|
}
|
|
270
276
|
|
|
271
277
|
|
layrz_sdk/entities/charts/map.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""
|
|
1
|
+
"""Map chart"""
|
|
2
|
+
|
|
2
3
|
from enum import Enum
|
|
3
|
-
from typing import Any, List,
|
|
4
|
+
from typing import Any, List, Tuple
|
|
4
5
|
|
|
5
6
|
from .exceptions import ChartException
|
|
6
7
|
from .render_technology import ChartRenderTechnology
|
|
@@ -10,28 +11,29 @@ class MapCenterType(Enum):
|
|
|
10
11
|
"""
|
|
11
12
|
Map Chart center type
|
|
12
13
|
"""
|
|
14
|
+
|
|
13
15
|
FIXED = 'FIXED'
|
|
14
16
|
CONTAIN = 'CONTAIN'
|
|
15
17
|
|
|
16
18
|
@property
|
|
17
|
-
def _readable(self
|
|
18
|
-
"""
|
|
19
|
+
def _readable(self) -> str | None | bool:
|
|
20
|
+
"""Readable"""
|
|
19
21
|
return f'BroadcastStatus.{self.value}'
|
|
20
22
|
|
|
21
|
-
def __str__(self
|
|
22
|
-
"""
|
|
23
|
+
def __str__(self) -> str | None | bool:
|
|
24
|
+
"""Readable property"""
|
|
23
25
|
return self._readable
|
|
24
26
|
|
|
25
|
-
def __repr__(self
|
|
26
|
-
"""
|
|
27
|
+
def __repr__(self) -> str | None | bool:
|
|
28
|
+
"""Readable property"""
|
|
27
29
|
return self._readable
|
|
28
30
|
|
|
29
31
|
|
|
30
32
|
class MapPoint:
|
|
31
|
-
"""
|
|
33
|
+
"""Map point configuration"""
|
|
32
34
|
|
|
33
35
|
def __init__(
|
|
34
|
-
self
|
|
36
|
+
self,
|
|
35
37
|
latitude: float,
|
|
36
38
|
longitude: float,
|
|
37
39
|
label: str,
|
|
@@ -69,7 +71,7 @@ class MapChart:
|
|
|
69
71
|
"""
|
|
70
72
|
|
|
71
73
|
def __init__(
|
|
72
|
-
self
|
|
74
|
+
self,
|
|
73
75
|
points: List[MapPoint],
|
|
74
76
|
title: str = 'Chart',
|
|
75
77
|
center: MapCenterType = MapCenterType.CONTAIN,
|
|
@@ -100,7 +102,7 @@ class MapChart:
|
|
|
100
102
|
raise ChartException('center_latlng must be an instance of list or tuple')
|
|
101
103
|
self.center_latlng = center_latlng
|
|
102
104
|
|
|
103
|
-
def render(self
|
|
105
|
+
def render(self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER_MAP) -> Any:
|
|
104
106
|
"""
|
|
105
107
|
Render chart to a graphic Library.
|
|
106
108
|
We have two graphic libraries: FLUTTER_MAP and LEAFLET.
|
|
@@ -121,18 +123,20 @@ class MapChart:
|
|
|
121
123
|
'configuration': [f'Unsupported {technology}'],
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
def _render_flutter_map(self
|
|
126
|
+
def _render_flutter_map(self) -> Any:
|
|
125
127
|
"""
|
|
126
128
|
Converts the configuration to the chart to Flutter Map engine.
|
|
127
129
|
"""
|
|
128
130
|
points = []
|
|
129
131
|
|
|
130
132
|
for point in self.points:
|
|
131
|
-
points.append(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
points.append(
|
|
134
|
+
{
|
|
135
|
+
'label': point.label,
|
|
136
|
+
'color': point.color,
|
|
137
|
+
'latlng': (point.latitude, point.longitude),
|
|
138
|
+
}
|
|
139
|
+
)
|
|
136
140
|
|
|
137
141
|
center = 'CONTAIN'
|
|
138
142
|
|
|
@@ -149,7 +153,7 @@ class MapChart:
|
|
|
149
153
|
|
|
150
154
|
return config
|
|
151
155
|
|
|
152
|
-
def _render_leaflet(self
|
|
156
|
+
def _render_leaflet(self) -> Any:
|
|
153
157
|
"""
|
|
154
158
|
Converts the configuration of the chart to Leaflet map engine.
|
|
155
159
|
"""
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
"""
|
|
2
|
-
|
|
1
|
+
"""Number chart"""
|
|
2
|
+
|
|
3
|
+
from typing import Any
|
|
3
4
|
|
|
4
5
|
from .render_technology import ChartRenderTechnology
|
|
5
6
|
|
|
@@ -9,7 +10,7 @@ class NumberChart:
|
|
|
9
10
|
Number chart configuration
|
|
10
11
|
"""
|
|
11
12
|
|
|
12
|
-
def __init__(self
|
|
13
|
+
def __init__(self, value: float, color: str, label: str) -> None:
|
|
13
14
|
"""
|
|
14
15
|
Constructor
|
|
15
16
|
|
|
@@ -23,7 +24,7 @@ class NumberChart:
|
|
|
23
24
|
self.color = color
|
|
24
25
|
self.label = label
|
|
25
26
|
|
|
26
|
-
def render(self
|
|
27
|
+
def render(self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) -> Any:
|
|
27
28
|
"""
|
|
28
29
|
Render chart to a graphic Library.
|
|
29
30
|
"""
|
|
@@ -40,7 +41,7 @@ class NumberChart:
|
|
|
40
41
|
'configuration': [f'Unsupported {technology}'],
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
def _render_flutter(self
|
|
44
|
+
def _render_flutter(self) -> Any:
|
|
44
45
|
"""
|
|
45
46
|
Converts the configuration of the chart to a Flutter native components.
|
|
46
47
|
"""
|