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,54 +0,0 @@
|
|
|
1
|
-
"""Charts entities"""
|
|
2
|
-
|
|
3
|
-
from .data_type import ChartDataType
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ChartConfiguration:
|
|
7
|
-
"""
|
|
8
|
-
Chart configuration
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
def __init__(self, name: str, description: str) -> None:
|
|
12
|
-
"""Constructor"""
|
|
13
|
-
self.name = name
|
|
14
|
-
self.description = description
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def _readable(self) -> str | None | bool:
|
|
18
|
-
"""Readable"""
|
|
19
|
-
return f'ChartConfiguration(name="{self.name}")'
|
|
20
|
-
|
|
21
|
-
def __str__(self) -> str | None | bool:
|
|
22
|
-
"""Readable property"""
|
|
23
|
-
return self._readable
|
|
24
|
-
|
|
25
|
-
def __repr__(self) -> str | None | bool:
|
|
26
|
-
"""Readable property"""
|
|
27
|
-
return self._readable
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
class AxisConfig:
|
|
31
|
-
"""Axis configuration"""
|
|
32
|
-
|
|
33
|
-
def __init__(
|
|
34
|
-
self,
|
|
35
|
-
label: str = '',
|
|
36
|
-
measure_unit: str = '',
|
|
37
|
-
min_value: float = None,
|
|
38
|
-
max_value: float = None,
|
|
39
|
-
data_type: ChartDataType = ChartDataType.DATETIME,
|
|
40
|
-
) -> None:
|
|
41
|
-
"""
|
|
42
|
-
Constructor
|
|
43
|
-
---
|
|
44
|
-
Arguments
|
|
45
|
-
- label : Label of the axis
|
|
46
|
-
- color : Color of the axis
|
|
47
|
-
- min_value : Minimum value of the axis
|
|
48
|
-
- max_value : Maximum value of the axis
|
|
49
|
-
"""
|
|
50
|
-
self.label = label
|
|
51
|
-
self.measure_unit = measure_unit
|
|
52
|
-
self.min_value = min_value
|
|
53
|
-
self.max_value = max_value
|
|
54
|
-
self.data_type = data_type
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"""Chart Data type"""
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ChartDataType(Enum):
|
|
7
|
-
"""
|
|
8
|
-
Chart Data Type
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
STRING = 'STRING'
|
|
12
|
-
DATETIME = 'DATETIME'
|
|
13
|
-
NUMBER = 'NUMBER'
|
|
14
|
-
|
|
15
|
-
@property
|
|
16
|
-
def _readable(self) -> str | None | bool:
|
|
17
|
-
"""Readable"""
|
|
18
|
-
return f'ChartDataType.{self.value}'
|
|
19
|
-
|
|
20
|
-
def __str__(self) -> str | None | bool:
|
|
21
|
-
"""Readable property"""
|
|
22
|
-
return self._readable
|
|
23
|
-
|
|
24
|
-
def __repr__(self) -> str | None | bool:
|
|
25
|
-
"""Readable property"""
|
|
26
|
-
return self._readable
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"""Chart exceptions"""
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ChartException(BaseException):
|
|
5
|
-
"""
|
|
6
|
-
Chart Exception
|
|
7
|
-
"""
|
|
8
|
-
|
|
9
|
-
def __init__(self, message: str) -> None:
|
|
10
|
-
"""Constructor"""
|
|
11
|
-
self._message = message
|
|
12
|
-
|
|
13
|
-
@property
|
|
14
|
-
def message(self) -> str | None | bool:
|
|
15
|
-
"""Message"""
|
|
16
|
-
return self._message
|
|
17
|
-
|
|
18
|
-
@property
|
|
19
|
-
def _readable(self) -> str | None | bool:
|
|
20
|
-
"""Readable"""
|
|
21
|
-
return f'ChartException: {self._message}'
|
|
22
|
-
|
|
23
|
-
def __str__(self) -> str | None | bool:
|
|
24
|
-
"""Readable property"""
|
|
25
|
-
return self._readable
|
|
26
|
-
|
|
27
|
-
def __repr__(self) -> str | None | bool:
|
|
28
|
-
"""Readable property"""
|
|
29
|
-
return self._readable
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"""HTML chart"""
|
|
2
|
-
|
|
3
|
-
from typing import Any, List
|
|
4
|
-
|
|
5
|
-
from .exceptions import ChartException
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class HTMLChart:
|
|
9
|
-
"""
|
|
10
|
-
HTML chart configuration
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, content: str = '<p>N/A</p>', title: str = 'Chart') -> None:
|
|
14
|
-
"""
|
|
15
|
-
Constructor
|
|
16
|
-
|
|
17
|
-
Args
|
|
18
|
-
----
|
|
19
|
-
content (str): HTML content of the chart.
|
|
20
|
-
title (str): Title of the chart.
|
|
21
|
-
align (ChartAlignment): Alignment of the chart.
|
|
22
|
-
"""
|
|
23
|
-
if not isinstance(content, str):
|
|
24
|
-
raise ChartException('content must be an instance of str')
|
|
25
|
-
self.content = content
|
|
26
|
-
|
|
27
|
-
if not isinstance(title, str):
|
|
28
|
-
raise ChartException('title must be an instance of str')
|
|
29
|
-
self.title = title
|
|
30
|
-
|
|
31
|
-
def render(self) -> Any:
|
|
32
|
-
"""
|
|
33
|
-
Render chart to a Javascript Library.
|
|
34
|
-
Currently only available for HTML.
|
|
35
|
-
"""
|
|
36
|
-
return {'library': 'HTML', 'configuration': self._render_html()}
|
|
37
|
-
|
|
38
|
-
def _render_html(self) -> Any:
|
|
39
|
-
"""
|
|
40
|
-
Converts the configuration of the chart to HTML render engine.
|
|
41
|
-
"""
|
|
42
|
-
config = {'content': self.content, 'title': self.title}
|
|
43
|
-
|
|
44
|
-
return config
|
layrz_sdk/entities/charts/map.py
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
"""Map chart"""
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
from typing import Any, List, Tuple
|
|
5
|
-
|
|
6
|
-
from .exceptions import ChartException
|
|
7
|
-
from .render_technology import ChartRenderTechnology
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class MapCenterType(Enum):
|
|
11
|
-
"""
|
|
12
|
-
Map Chart center type
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
FIXED = 'FIXED'
|
|
16
|
-
CONTAIN = 'CONTAIN'
|
|
17
|
-
|
|
18
|
-
@property
|
|
19
|
-
def _readable(self) -> str | None | bool:
|
|
20
|
-
"""Readable"""
|
|
21
|
-
return f'BroadcastStatus.{self.value}'
|
|
22
|
-
|
|
23
|
-
def __str__(self) -> str | None | bool:
|
|
24
|
-
"""Readable property"""
|
|
25
|
-
return self._readable
|
|
26
|
-
|
|
27
|
-
def __repr__(self) -> str | None | bool:
|
|
28
|
-
"""Readable property"""
|
|
29
|
-
return self._readable
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
class MapPoint:
|
|
33
|
-
"""Map point configuration"""
|
|
34
|
-
|
|
35
|
-
def __init__(
|
|
36
|
-
self,
|
|
37
|
-
latitude: float,
|
|
38
|
-
longitude: float,
|
|
39
|
-
label: str,
|
|
40
|
-
color: str,
|
|
41
|
-
) -> None:
|
|
42
|
-
"""
|
|
43
|
-
Constructor
|
|
44
|
-
---
|
|
45
|
-
Arguments
|
|
46
|
-
latitude : Latitude of the point
|
|
47
|
-
longitude : Longitude of the point
|
|
48
|
-
label : Label of the point
|
|
49
|
-
color : Color of the point
|
|
50
|
-
"""
|
|
51
|
-
if not isinstance(latitude, float):
|
|
52
|
-
raise ChartException('latitude must be an instance of float')
|
|
53
|
-
self.latitude = latitude
|
|
54
|
-
|
|
55
|
-
if not isinstance(longitude, float):
|
|
56
|
-
raise ChartException('longitude must be an instance of float')
|
|
57
|
-
self.longitude = longitude
|
|
58
|
-
|
|
59
|
-
if not isinstance(label, str):
|
|
60
|
-
raise ChartException('label must be an instance of str')
|
|
61
|
-
self.label = label
|
|
62
|
-
|
|
63
|
-
if not isinstance(color, str):
|
|
64
|
-
raise ChartException('color must be an instance of str')
|
|
65
|
-
self.color = color
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class MapChart:
|
|
69
|
-
"""
|
|
70
|
-
Map chart configuration
|
|
71
|
-
"""
|
|
72
|
-
|
|
73
|
-
def __init__(
|
|
74
|
-
self,
|
|
75
|
-
points: List[MapPoint],
|
|
76
|
-
title: str = 'Chart',
|
|
77
|
-
center: MapCenterType = MapCenterType.CONTAIN,
|
|
78
|
-
center_latlng: List[float] | Tuple[float] = None,
|
|
79
|
-
) -> None:
|
|
80
|
-
"""
|
|
81
|
-
Constructor
|
|
82
|
-
Args
|
|
83
|
-
----
|
|
84
|
-
points : Points of the chart
|
|
85
|
-
title : Title of the chart
|
|
86
|
-
align : Alignment of the title
|
|
87
|
-
"""
|
|
88
|
-
for i, point in enumerate(points):
|
|
89
|
-
if not isinstance(point, MapPoint):
|
|
90
|
-
raise ChartException(f'Point {i} must be an instance of MapPoint')
|
|
91
|
-
self.points = points
|
|
92
|
-
|
|
93
|
-
if not isinstance(title, str):
|
|
94
|
-
raise ChartException('title must be an instance of str')
|
|
95
|
-
self.title = title
|
|
96
|
-
|
|
97
|
-
if not isinstance(center, MapCenterType):
|
|
98
|
-
raise ChartException('center must be an instance of MapCenterType')
|
|
99
|
-
self.center = center
|
|
100
|
-
|
|
101
|
-
if self.center == MapCenterType.FIXED and not isinstance(center_latlng, (List, Tuple)):
|
|
102
|
-
raise ChartException('center_latlng must be an instance of list or tuple')
|
|
103
|
-
self.center_latlng = center_latlng
|
|
104
|
-
|
|
105
|
-
def render(self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER_MAP) -> Any:
|
|
106
|
-
"""
|
|
107
|
-
Render chart to a graphic Library.
|
|
108
|
-
We have two graphic libraries: FLUTTER_MAP and LEAFLET.
|
|
109
|
-
|
|
110
|
-
FLUTTER_MAP is a Flutter chart library. To return this option, use the parameter use_new_definition=True.
|
|
111
|
-
LEAFLET is a Javascript chart library. This is the default option.
|
|
112
|
-
"""
|
|
113
|
-
if technology == ChartRenderTechnology.FLUTTER_MAP:
|
|
114
|
-
return {
|
|
115
|
-
'library': 'FLUTTER_MAP',
|
|
116
|
-
'chart': 'MAP',
|
|
117
|
-
'configuration': self._render_flutter_map(),
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
return {
|
|
121
|
-
'library': 'FLUTTER',
|
|
122
|
-
'chart': 'TEXT',
|
|
123
|
-
'configuration': [f'Unsupported {technology}'],
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
def _render_flutter_map(self) -> Any:
|
|
127
|
-
"""
|
|
128
|
-
Converts the configuration to the chart to Flutter Map engine.
|
|
129
|
-
"""
|
|
130
|
-
points = []
|
|
131
|
-
|
|
132
|
-
for point in self.points:
|
|
133
|
-
points.append(
|
|
134
|
-
{
|
|
135
|
-
'label': point.label,
|
|
136
|
-
'color': point.color,
|
|
137
|
-
'latlng': (point.latitude, point.longitude),
|
|
138
|
-
}
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
center = 'CONTAIN'
|
|
142
|
-
|
|
143
|
-
if self.center == MapCenterType.FIXED:
|
|
144
|
-
center = 'FIXED'
|
|
145
|
-
|
|
146
|
-
config = {
|
|
147
|
-
'points': points,
|
|
148
|
-
'center': center,
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if self.center == MapCenterType.FIXED:
|
|
152
|
-
config['centerLatLng'] = self.center_latlng
|
|
153
|
-
|
|
154
|
-
return config
|
|
155
|
-
|
|
156
|
-
def _render_leaflet(self) -> Any:
|
|
157
|
-
"""
|
|
158
|
-
Converts the configuration of the chart to Leaflet map engine.
|
|
159
|
-
"""
|
|
160
|
-
points = []
|
|
161
|
-
|
|
162
|
-
for point in self.points:
|
|
163
|
-
points.append({'label': point.label, 'color': point.color, 'latlng': (point.latitude, point.longitude)})
|
|
164
|
-
|
|
165
|
-
center = 'CONTAIN'
|
|
166
|
-
|
|
167
|
-
if self.center == MapCenterType.FIXED:
|
|
168
|
-
center = 'FIXED'
|
|
169
|
-
|
|
170
|
-
config = {
|
|
171
|
-
'points': points,
|
|
172
|
-
'title': self.title,
|
|
173
|
-
'center': center,
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if self.center == MapCenterType.FIXED:
|
|
177
|
-
config['centerLatLng'] = self.center_latlng
|
|
178
|
-
|
|
179
|
-
return config
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"""Number chart"""
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from .render_technology import ChartRenderTechnology
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class NumberChart:
|
|
9
|
-
"""
|
|
10
|
-
Number chart configuration
|
|
11
|
-
"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, value: float, color: str, label: str) -> None:
|
|
14
|
-
"""
|
|
15
|
-
Constructor
|
|
16
|
-
|
|
17
|
-
Arguments
|
|
18
|
-
---
|
|
19
|
-
value : Value of the number
|
|
20
|
-
color : Color of the number
|
|
21
|
-
label : Label of the number
|
|
22
|
-
"""
|
|
23
|
-
self.value = value
|
|
24
|
-
self.color = color
|
|
25
|
-
self.label = label
|
|
26
|
-
|
|
27
|
-
def render(self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) -> Any:
|
|
28
|
-
"""
|
|
29
|
-
Render chart to a graphic Library.
|
|
30
|
-
"""
|
|
31
|
-
if technology == ChartRenderTechnology.FLUTTER:
|
|
32
|
-
return {
|
|
33
|
-
'library': 'FLUTTER',
|
|
34
|
-
'chart': 'NUMBER',
|
|
35
|
-
'configuration': self._render_flutter(),
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
'library': 'FLUTTER',
|
|
40
|
-
'chart': 'TEXT',
|
|
41
|
-
'configuration': [f'Unsupported {technology}'],
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
def _render_flutter(self) -> Any:
|
|
45
|
-
"""
|
|
46
|
-
Converts the configuration of the chart to a Flutter native components.
|
|
47
|
-
"""
|
|
48
|
-
return {
|
|
49
|
-
'value': self.value,
|
|
50
|
-
'color': self.color,
|
|
51
|
-
'label': self.label,
|
|
52
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
"""Radar chart"""
|
|
2
|
-
|
|
3
|
-
from typing import Any, List
|
|
4
|
-
|
|
5
|
-
from .alignment import ChartAlignment
|
|
6
|
-
from .exceptions import ChartException
|
|
7
|
-
from .serie import ChartDataSerie
|
|
8
|
-
from .serie_type import ChartDataSerieType
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class RadarChart:
|
|
12
|
-
"""
|
|
13
|
-
Radar chart configuration
|
|
14
|
-
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
def __init__(
|
|
18
|
-
self,
|
|
19
|
-
x_axis: ChartDataSerie,
|
|
20
|
-
y_axis: List[ChartDataSerie],
|
|
21
|
-
title: str = 'Chart',
|
|
22
|
-
align: ChartAlignment = ChartAlignment.CENTER,
|
|
23
|
-
) -> None:
|
|
24
|
-
"""
|
|
25
|
-
Constructor
|
|
26
|
-
----
|
|
27
|
-
Arguments
|
|
28
|
-
- x_axis : Defines the X Axis of the chart, uses the ChartDataSerie class.
|
|
29
|
-
Please read the documentation to more information.
|
|
30
|
-
- y_axis : Defines the Y Axis of the chart, uses the ChartDataSerie class.
|
|
31
|
-
Please read the documentation to more information.
|
|
32
|
-
- title : Title of the chart
|
|
33
|
-
- align : Alignment of the title
|
|
34
|
-
"""
|
|
35
|
-
for i, serie in enumerate(y_axis):
|
|
36
|
-
if not isinstance(serie, ChartDataSerie):
|
|
37
|
-
raise ChartException(f'Y Axis serie {i} must be an instance of ChartDataSerie')
|
|
38
|
-
self.y_axis = y_axis
|
|
39
|
-
|
|
40
|
-
if not isinstance(x_axis, ChartDataSerie):
|
|
41
|
-
raise ChartException('X Axis must be an instance of ChartDataSerie')
|
|
42
|
-
self.x_axis = x_axis
|
|
43
|
-
|
|
44
|
-
if not isinstance(title, str):
|
|
45
|
-
raise ChartException('title must be an instance of str')
|
|
46
|
-
self.title = title
|
|
47
|
-
|
|
48
|
-
if not isinstance(align, ChartAlignment):
|
|
49
|
-
raise ChartException('align must be an instance of ChartAlignment')
|
|
50
|
-
self.align = align
|
|
51
|
-
|
|
52
|
-
def render(self) -> Any:
|
|
53
|
-
"""
|
|
54
|
-
Render chart to a Javascript Library.
|
|
55
|
-
Currently only available for ApexCharts.
|
|
56
|
-
"""
|
|
57
|
-
return {'library': 'APEXCHARTS', 'configuration': self._render_apexcharts()}
|
|
58
|
-
|
|
59
|
-
def _render_apexcharts(self) -> Any:
|
|
60
|
-
"""
|
|
61
|
-
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
62
|
-
"""
|
|
63
|
-
|
|
64
|
-
series = []
|
|
65
|
-
colors = []
|
|
66
|
-
|
|
67
|
-
for serie in self.y_axis:
|
|
68
|
-
modified_serie = {'name': serie.label, 'data': serie.data}
|
|
69
|
-
|
|
70
|
-
if serie.serie_type is not ChartDataSerieType.NONE:
|
|
71
|
-
modified_serie['type'] = serie.serie_type.value
|
|
72
|
-
|
|
73
|
-
series.append(modified_serie)
|
|
74
|
-
colors.append(serie.color)
|
|
75
|
-
|
|
76
|
-
config = {
|
|
77
|
-
'series': series,
|
|
78
|
-
'colors': colors,
|
|
79
|
-
'xaxis': {
|
|
80
|
-
'categories': self.x_axis.data,
|
|
81
|
-
'type': self.x_axis.data_type.value,
|
|
82
|
-
'title': {
|
|
83
|
-
'text': self.x_axis.label,
|
|
84
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
'title': {
|
|
88
|
-
'text': self.title,
|
|
89
|
-
'align': self.align.value,
|
|
90
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
91
|
-
},
|
|
92
|
-
'chart': {
|
|
93
|
-
'type': 'radar',
|
|
94
|
-
'animations': {'enabled': False},
|
|
95
|
-
'toolbar': {'show': False},
|
|
96
|
-
'zoom': {'enabled': False},
|
|
97
|
-
},
|
|
98
|
-
'dataLabels': {'enabled': True},
|
|
99
|
-
'plotOptions': {'bar': {'horizontal': True, 'borderRadius': 4}},
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return config
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"""Chart Data Serie"""
|
|
2
|
-
|
|
3
|
-
from typing import Any
|
|
4
|
-
|
|
5
|
-
from .data_type import ChartDataType
|
|
6
|
-
from .exceptions import ChartException
|
|
7
|
-
from .serie_type import ChartDataSerieType
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class ChartDataSerie:
|
|
11
|
-
"""
|
|
12
|
-
Chart Serie
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
def __init__(
|
|
16
|
-
self,
|
|
17
|
-
data: Any,
|
|
18
|
-
color: str = '#000000',
|
|
19
|
-
label: str = '',
|
|
20
|
-
serie_type: ChartDataSerieType = ChartDataSerieType.LINE,
|
|
21
|
-
data_type: ChartDataType = ChartDataType.NUMBER,
|
|
22
|
-
dashed: bool = False,
|
|
23
|
-
) -> None:
|
|
24
|
-
"""
|
|
25
|
-
Constructor
|
|
26
|
-
|
|
27
|
-
Args
|
|
28
|
-
----
|
|
29
|
-
data : List of data points.
|
|
30
|
-
color : Color of the serie.
|
|
31
|
-
label : Label of the serie.
|
|
32
|
-
serie_type : Type of the serie. Only used for mixed range charts.
|
|
33
|
-
data_type : Type of the data.
|
|
34
|
-
dashed : If the serie should be dashed.
|
|
35
|
-
"""
|
|
36
|
-
self.data = data
|
|
37
|
-
|
|
38
|
-
if not isinstance(color, str):
|
|
39
|
-
raise ChartException('color must be an instance of str')
|
|
40
|
-
self.color = color
|
|
41
|
-
|
|
42
|
-
if not isinstance(label, str):
|
|
43
|
-
raise ChartException('label must be an instance of str')
|
|
44
|
-
self.label = label
|
|
45
|
-
|
|
46
|
-
if not isinstance(data_type, ChartDataType):
|
|
47
|
-
raise ChartException('data_type must be an instance of ChartDataType')
|
|
48
|
-
self.data_type = data_type
|
|
49
|
-
|
|
50
|
-
if not isinstance(serie_type, ChartDataSerieType):
|
|
51
|
-
raise ChartException('serie_type must be an instance of ChartDataSerieType')
|
|
52
|
-
self.serie_type = serie_type or ChartDataSerieType.NONE
|
|
53
|
-
|
|
54
|
-
if not isinstance(dashed, bool):
|
|
55
|
-
raise ChartException('dashed must be an instance of bool')
|
|
56
|
-
self.dashed = dashed
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"""Chart Serie type"""
|
|
2
|
-
|
|
3
|
-
from enum import Enum
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class ChartDataSerieType(Enum):
|
|
7
|
-
"""
|
|
8
|
-
Chart data serie type
|
|
9
|
-
"""
|
|
10
|
-
|
|
11
|
-
NONE = None
|
|
12
|
-
LINE = 'line'
|
|
13
|
-
AREA = 'area'
|
|
14
|
-
SCATTER = 'scatter'
|
|
15
|
-
|
|
16
|
-
@property
|
|
17
|
-
def _readable(self) -> str | None | bool:
|
|
18
|
-
"""Readable"""
|
|
19
|
-
return f'BroadcastStatus.{self.value}'
|
|
20
|
-
|
|
21
|
-
def __str__(self) -> str | None | bool:
|
|
22
|
-
"""Readable property"""
|
|
23
|
-
return self._readable
|
|
24
|
-
|
|
25
|
-
def __repr__(self) -> str | None | bool:
|
|
26
|
-
"""Readable property"""
|
|
27
|
-
return self._readable
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"""Number chart"""
|
|
2
|
-
|
|
3
|
-
from typing import Any, List
|
|
4
|
-
|
|
5
|
-
from .render_technology import ChartRenderTechnology
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class TableHeader:
|
|
9
|
-
"""Table header chart configuration"""
|
|
10
|
-
|
|
11
|
-
def __init__(self, label: str, key: str) -> None:
|
|
12
|
-
"""Constructor
|
|
13
|
-
---
|
|
14
|
-
Arguments
|
|
15
|
-
- label : Label of the header
|
|
16
|
-
- key : Key of the header
|
|
17
|
-
"""
|
|
18
|
-
self.label = label
|
|
19
|
-
self.key = key
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
class TableRow:
|
|
23
|
-
"""Table row chart configuration"""
|
|
24
|
-
|
|
25
|
-
def __init__(self, data: Any) -> None:
|
|
26
|
-
"""Constructor
|
|
27
|
-
---
|
|
28
|
-
Arguments
|
|
29
|
-
- data : Data of the row
|
|
30
|
-
"""
|
|
31
|
-
self.data = data
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class TableChart:
|
|
35
|
-
"""
|
|
36
|
-
Table chart configuration
|
|
37
|
-
"""
|
|
38
|
-
|
|
39
|
-
def __init__(self, columns: List[TableHeader], rows: List[TableRow]) -> None:
|
|
40
|
-
"""
|
|
41
|
-
Constructor
|
|
42
|
-
---
|
|
43
|
-
Arguments
|
|
44
|
-
- columns : List of columns
|
|
45
|
-
- rows : List of rows
|
|
46
|
-
"""
|
|
47
|
-
self.columns = columns
|
|
48
|
-
self.rows = rows
|
|
49
|
-
|
|
50
|
-
def render(self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) -> Any:
|
|
51
|
-
"""
|
|
52
|
-
Render chart to a graphic Library.
|
|
53
|
-
"""
|
|
54
|
-
if technology == ChartRenderTechnology.FLUTTER:
|
|
55
|
-
return {
|
|
56
|
-
'library': 'FLUTTER',
|
|
57
|
-
'chart': 'TABLE',
|
|
58
|
-
'configuration': self._render_flutter(),
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
'library': 'FLUTTER',
|
|
63
|
-
'chart': 'TEXT',
|
|
64
|
-
'configuration': [f'Unsupported {technology}'],
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
def _render_flutter(self) -> Any:
|
|
68
|
-
"""
|
|
69
|
-
Converts the configuration of the chart to a Flutter native components.
|
|
70
|
-
"""
|
|
71
|
-
return {
|
|
72
|
-
'columns': [{'key': column.key, 'label': column.label} for column in self.columns],
|
|
73
|
-
'rows': [{'data': row.data} for row in self.rows],
|
|
74
|
-
}
|