layrz-sdk 3.1.11__py3-none-any.whl → 3.1.13__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 -5
- layrz_sdk/entities/__init__.py +129 -129
- layrz_sdk/entities/asset.py +60 -60
- layrz_sdk/entities/asset_operation_mode.py +31 -31
- layrz_sdk/entities/broadcast_request.py +12 -12
- layrz_sdk/entities/broadcast_response.py +12 -12
- layrz_sdk/entities/broadcast_result.py +20 -20
- layrz_sdk/entities/broadcast_status.py +28 -28
- layrz_sdk/entities/case.py +48 -47
- layrz_sdk/entities/case_ignored_status.py +26 -26
- layrz_sdk/entities/case_status.py +23 -23
- layrz_sdk/entities/charts/axis_config.py +15 -15
- layrz_sdk/entities/charts/bar_chart.py +175 -175
- layrz_sdk/entities/charts/chart_alignment.py +27 -27
- layrz_sdk/entities/charts/chart_color.py +44 -44
- layrz_sdk/entities/charts/chart_configuration.py +10 -10
- layrz_sdk/entities/charts/chart_data_serie.py +19 -19
- layrz_sdk/entities/charts/chart_data_serie_type.py +28 -28
- layrz_sdk/entities/charts/chart_data_type.py +27 -27
- layrz_sdk/entities/charts/chart_render_technology.py +30 -30
- layrz_sdk/entities/charts/column_chart.py +201 -201
- layrz_sdk/entities/charts/html_chart.py +38 -38
- layrz_sdk/entities/charts/line_chart.py +248 -248
- layrz_sdk/entities/charts/map_center_type.py +22 -22
- layrz_sdk/entities/charts/map_chart.py +108 -108
- layrz_sdk/entities/charts/map_point.py +22 -22
- layrz_sdk/entities/charts/number_chart.py +54 -54
- layrz_sdk/entities/charts/pie_chart.py +131 -131
- layrz_sdk/entities/charts/radar_chart.py +81 -81
- layrz_sdk/entities/charts/radial_bar_chart.py +131 -131
- layrz_sdk/entities/charts/scatter_chart.py +210 -210
- layrz_sdk/entities/charts/scatter_serie.py +13 -15
- layrz_sdk/entities/charts/scatter_serie_item.py +8 -8
- layrz_sdk/entities/charts/table_chart.py +54 -54
- layrz_sdk/entities/charts/table_header.py +8 -8
- layrz_sdk/entities/charts/table_row.py +9 -9
- layrz_sdk/entities/charts/timeline_chart.py +79 -79
- layrz_sdk/entities/charts/timeline_serie.py +10 -12
- layrz_sdk/entities/charts/timeline_serie_item.py +12 -12
- layrz_sdk/entities/checkpoint.py +17 -18
- layrz_sdk/entities/comment.py +16 -16
- layrz_sdk/entities/custom_field.py +10 -10
- layrz_sdk/entities/custom_report_page.py +40 -16
- layrz_sdk/entities/device.py +13 -13
- layrz_sdk/entities/event.py +23 -23
- layrz_sdk/entities/geofence.py +11 -11
- layrz_sdk/entities/last_message.py +12 -12
- layrz_sdk/entities/message.py +23 -23
- layrz_sdk/entities/outbound_service.py +10 -10
- layrz_sdk/entities/position.py +116 -116
- layrz_sdk/entities/presence_type.py +16 -16
- layrz_sdk/entities/report.py +289 -283
- layrz_sdk/entities/report_col.py +40 -40
- layrz_sdk/entities/report_configuration.py +8 -8
- layrz_sdk/entities/report_data_type.py +28 -28
- layrz_sdk/entities/report_format.py +27 -27
- layrz_sdk/entities/report_header.py +43 -43
- layrz_sdk/entities/report_page.py +15 -17
- layrz_sdk/entities/report_row.py +28 -28
- layrz_sdk/entities/sensor.py +11 -11
- layrz_sdk/entities/text_alignment.py +26 -26
- layrz_sdk/entities/trigger.py +11 -11
- layrz_sdk/entities/user.py +10 -10
- layrz_sdk/entities/waypoint.py +18 -18
- layrz_sdk/helpers/__init__.py +5 -8
- layrz_sdk/helpers/color.py +44 -44
- layrz_sdk/lcl/__init__.py +5 -7
- layrz_sdk/lcl/core.py +848 -848
- {layrz_sdk-3.1.11.dist-info → layrz_sdk-3.1.13.dist-info}/METADATA +49 -49
- layrz_sdk-3.1.13.dist-info/RECORD +75 -0
- {layrz_sdk-3.1.11.dist-info → layrz_sdk-3.1.13.dist-info}/WHEEL +1 -1
- {layrz_sdk-3.1.11.dist-info → layrz_sdk-3.1.13.dist-info}/licenses/LICENSE +6 -6
- layrz_sdk-3.1.11.dist-info/RECORD +0 -75
- {layrz_sdk-3.1.11.dist-info → layrz_sdk-3.1.13.dist-info}/top_level.txt +0 -0
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
"""Map chart"""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from typing import Any,
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
from .chart_render_technology import ChartRenderTechnology
|
|
9
|
-
from .map_center_type import MapCenterType
|
|
10
|
-
from .map_point import MapPoint
|
|
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 MapChart(BaseModel):
|
|
19
|
-
"""Map chart configuration"""
|
|
20
|
-
|
|
21
|
-
points:
|
|
22
|
-
title: str = Field(description='Title of the chart', default='Chart')
|
|
23
|
-
center: MapCenterType = Field(description='Center of the chart', default=MapCenterType.CONTAIN)
|
|
24
|
-
center_latlng: Optional[
|
|
25
|
-
|
|
26
|
-
def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER_MAP) ->
|
|
27
|
-
"""
|
|
28
|
-
Render chart to a graphic Library.
|
|
29
|
-
|
|
30
|
-
:param technology: The technology to use to render the chart.
|
|
31
|
-
:type technology: ChartRenderTechnology
|
|
32
|
-
|
|
33
|
-
:return: The configuration of the chart.
|
|
34
|
-
:rtype:
|
|
35
|
-
"""
|
|
36
|
-
if technology == ChartRenderTechnology.FLUTTER_MAP:
|
|
37
|
-
return {
|
|
38
|
-
'library': 'FLUTTER_MAP',
|
|
39
|
-
'chart': 'MAP',
|
|
40
|
-
'configuration': self._render_flutter_map(),
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
'library': 'FLUTTER',
|
|
45
|
-
'chart': 'TEXT',
|
|
46
|
-
'configuration': [f'Unsupported {technology}'],
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
def _render_flutter_map(self: Self) ->
|
|
50
|
-
"""
|
|
51
|
-
Converts the configuration to the chart to Flutter Map engine.
|
|
52
|
-
"""
|
|
53
|
-
points = []
|
|
54
|
-
|
|
55
|
-
for point in self.points:
|
|
56
|
-
points.append(
|
|
57
|
-
{
|
|
58
|
-
'label': point.label,
|
|
59
|
-
'color': point.color,
|
|
60
|
-
'latlng': (point.latitude, point.longitude),
|
|
61
|
-
}
|
|
62
|
-
)
|
|
63
|
-
|
|
64
|
-
center = 'CONTAIN'
|
|
65
|
-
|
|
66
|
-
if self.center == MapCenterType.FIXED:
|
|
67
|
-
center = 'FIXED'
|
|
68
|
-
|
|
69
|
-
config:
|
|
70
|
-
'points': points,
|
|
71
|
-
'center': center,
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if self.center == MapCenterType.FIXED:
|
|
75
|
-
if self.center_latlng is not None:
|
|
76
|
-
config['centerLatLng'] = self.center_latlng
|
|
77
|
-
else:
|
|
78
|
-
config['center'] = 'CONTAIN'
|
|
79
|
-
|
|
80
|
-
return config
|
|
81
|
-
|
|
82
|
-
def _render_leaflet(self: Self) ->
|
|
83
|
-
"""
|
|
84
|
-
Converts the configuration of the chart to Leaflet map engine.
|
|
85
|
-
"""
|
|
86
|
-
points = []
|
|
87
|
-
|
|
88
|
-
for point in self.points:
|
|
89
|
-
points.append({'label': point.label, 'color': point.color, 'latlng': (point.latitude, point.longitude)})
|
|
90
|
-
|
|
91
|
-
center = 'CONTAIN'
|
|
92
|
-
|
|
93
|
-
if self.center == MapCenterType.FIXED:
|
|
94
|
-
center = 'FIXED'
|
|
95
|
-
|
|
96
|
-
config:
|
|
97
|
-
'points': points,
|
|
98
|
-
'title': self.title,
|
|
99
|
-
'center': center,
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if self.center == MapCenterType.FIXED:
|
|
103
|
-
if self.center_latlng is not None:
|
|
104
|
-
config['centerLatLng'] = self.center_latlng
|
|
105
|
-
else:
|
|
106
|
-
config['center'] = 'CONTAIN'
|
|
107
|
-
|
|
108
|
-
return config
|
|
1
|
+
"""Map chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Optional, Tuple
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
9
|
+
from .map_center_type import MapCenterType
|
|
10
|
+
from .map_point import MapPoint
|
|
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 MapChart(BaseModel):
|
|
19
|
+
"""Map chart configuration"""
|
|
20
|
+
|
|
21
|
+
points: list[MapPoint] = Field(description='Points of the chart', default_factory=list)
|
|
22
|
+
title: str = Field(description='Title of the chart', default='Chart')
|
|
23
|
+
center: MapCenterType = Field(description='Center of the chart', default=MapCenterType.CONTAIN)
|
|
24
|
+
center_latlng: Optional[list[float]] = Field(description='Center of the chart in latlng format', default=None)
|
|
25
|
+
|
|
26
|
+
def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER_MAP) -> dict[str, Any]:
|
|
27
|
+
"""
|
|
28
|
+
Render chart to a graphic Library.
|
|
29
|
+
|
|
30
|
+
:param technology: The technology to use to render the chart.
|
|
31
|
+
:type technology: ChartRenderTechnology
|
|
32
|
+
|
|
33
|
+
:return: The configuration of the chart.
|
|
34
|
+
:rtype: dict[str, Any]
|
|
35
|
+
"""
|
|
36
|
+
if technology == ChartRenderTechnology.FLUTTER_MAP:
|
|
37
|
+
return {
|
|
38
|
+
'library': 'FLUTTER_MAP',
|
|
39
|
+
'chart': 'MAP',
|
|
40
|
+
'configuration': self._render_flutter_map(),
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
'library': 'FLUTTER',
|
|
45
|
+
'chart': 'TEXT',
|
|
46
|
+
'configuration': [f'Unsupported {technology}'],
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
def _render_flutter_map(self: Self) -> dict[str, Any]:
|
|
50
|
+
"""
|
|
51
|
+
Converts the configuration to the chart to Flutter Map engine.
|
|
52
|
+
"""
|
|
53
|
+
points = []
|
|
54
|
+
|
|
55
|
+
for point in self.points:
|
|
56
|
+
points.append(
|
|
57
|
+
{
|
|
58
|
+
'label': point.label,
|
|
59
|
+
'color': point.color,
|
|
60
|
+
'latlng': (point.latitude, point.longitude),
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
center = 'CONTAIN'
|
|
65
|
+
|
|
66
|
+
if self.center == MapCenterType.FIXED:
|
|
67
|
+
center = 'FIXED'
|
|
68
|
+
|
|
69
|
+
config: dict[str, Any] = {
|
|
70
|
+
'points': points,
|
|
71
|
+
'center': center,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if self.center == MapCenterType.FIXED:
|
|
75
|
+
if self.center_latlng is not None:
|
|
76
|
+
config['centerLatLng'] = self.center_latlng
|
|
77
|
+
else:
|
|
78
|
+
config['center'] = 'CONTAIN'
|
|
79
|
+
|
|
80
|
+
return config
|
|
81
|
+
|
|
82
|
+
def _render_leaflet(self: Self) -> dict[str, Any]:
|
|
83
|
+
"""
|
|
84
|
+
Converts the configuration of the chart to Leaflet map engine.
|
|
85
|
+
"""
|
|
86
|
+
points = []
|
|
87
|
+
|
|
88
|
+
for point in self.points:
|
|
89
|
+
points.append({'label': point.label, 'color': point.color, 'latlng': (point.latitude, point.longitude)})
|
|
90
|
+
|
|
91
|
+
center = 'CONTAIN'
|
|
92
|
+
|
|
93
|
+
if self.center == MapCenterType.FIXED:
|
|
94
|
+
center = 'FIXED'
|
|
95
|
+
|
|
96
|
+
config: dict[str, Any] = {
|
|
97
|
+
'points': points,
|
|
98
|
+
'title': self.title,
|
|
99
|
+
'center': center,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if self.center == MapCenterType.FIXED:
|
|
103
|
+
if self.center_latlng is not None:
|
|
104
|
+
config['centerLatLng'] = self.center_latlng
|
|
105
|
+
else:
|
|
106
|
+
config['center'] = 'CONTAIN'
|
|
107
|
+
|
|
108
|
+
return config
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
from pydantic import BaseModel, Field, field_validator
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class MapPoint(BaseModel):
|
|
5
|
-
"""Map point configuration"""
|
|
6
|
-
|
|
7
|
-
latitude: float = Field(description='Latitude of the point')
|
|
8
|
-
longitude: float = Field(description='Longitude of the point')
|
|
9
|
-
label: str = Field(description='Label of the point')
|
|
10
|
-
color: str = Field(description='Color of the point')
|
|
11
|
-
|
|
12
|
-
@field_validator('latitude', mode='before')
|
|
13
|
-
def _validate_latitude(cls, value: float) -> float:
|
|
14
|
-
if value < -90 or value > 90:
|
|
15
|
-
raise ValueError('Latitude must be between -90 and 90 degrees')
|
|
16
|
-
return value
|
|
17
|
-
|
|
18
|
-
@field_validator('longitude', mode='before')
|
|
19
|
-
def _validate_longitude(cls, value: float) -> float:
|
|
20
|
-
if value < -180 or value > 180:
|
|
21
|
-
raise ValueError('Longitude must be between -180 and 180 degrees')
|
|
22
|
-
return value
|
|
1
|
+
from pydantic import BaseModel, Field, field_validator
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class MapPoint(BaseModel):
|
|
5
|
+
"""Map point configuration"""
|
|
6
|
+
|
|
7
|
+
latitude: float = Field(description='Latitude of the point')
|
|
8
|
+
longitude: float = Field(description='Longitude of the point')
|
|
9
|
+
label: str = Field(description='Label of the point')
|
|
10
|
+
color: str = Field(description='Color of the point')
|
|
11
|
+
|
|
12
|
+
@field_validator('latitude', mode='before')
|
|
13
|
+
def _validate_latitude(cls, value: float) -> float:
|
|
14
|
+
if value < -90 or value > 90:
|
|
15
|
+
raise ValueError('Latitude must be between -90 and 90 degrees')
|
|
16
|
+
return value
|
|
17
|
+
|
|
18
|
+
@field_validator('longitude', mode='before')
|
|
19
|
+
def _validate_longitude(cls, value: float) -> float:
|
|
20
|
+
if value < -180 or value > 180:
|
|
21
|
+
raise ValueError('Longitude must be between -180 and 180 degrees')
|
|
22
|
+
return value
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
"""Number chart"""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from typing import Any, Dict
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
from .chart_render_technology import ChartRenderTechnology
|
|
9
|
-
|
|
10
|
-
if sys.version_info >= (3, 11):
|
|
11
|
-
from typing import Self
|
|
12
|
-
else:
|
|
13
|
-
from typing_extensions import Self
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
class NumberChart(BaseModel):
|
|
17
|
-
"""Number chart configuration"""
|
|
18
|
-
|
|
19
|
-
value: float = Field(description='Value of the number')
|
|
20
|
-
color: str = Field(description='Color of the number')
|
|
21
|
-
label: str = Field(description='Label of the number')
|
|
22
|
-
|
|
23
|
-
def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) ->
|
|
24
|
-
"""
|
|
25
|
-
Render chart to a graphic Library.
|
|
26
|
-
|
|
27
|
-
:param technology: The technology to use to render the chart.
|
|
28
|
-
:type technology: ChartRenderTechnology
|
|
29
|
-
|
|
30
|
-
:return: The configuration of the chart.
|
|
31
|
-
:rtype:
|
|
32
|
-
"""
|
|
33
|
-
if technology == ChartRenderTechnology.FLUTTER:
|
|
34
|
-
return {
|
|
35
|
-
'library': 'FLUTTER',
|
|
36
|
-
'chart': 'NUMBER',
|
|
37
|
-
'configuration': self._render_flutter(),
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
'library': 'FLUTTER',
|
|
42
|
-
'chart': 'TEXT',
|
|
43
|
-
'configuration': [f'Unsupported {technology}'],
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
def _render_flutter(self: Self) ->
|
|
47
|
-
"""
|
|
48
|
-
Converts the configuration of the chart to a Flutter native components.
|
|
49
|
-
"""
|
|
50
|
-
return {
|
|
51
|
-
'value': self.value,
|
|
52
|
-
'color': self.color,
|
|
53
|
-
'label': self.label,
|
|
54
|
-
}
|
|
1
|
+
"""Number chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Dict
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
9
|
+
|
|
10
|
+
if sys.version_info >= (3, 11):
|
|
11
|
+
from typing import Self
|
|
12
|
+
else:
|
|
13
|
+
from typing_extensions import Self
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class NumberChart(BaseModel):
|
|
17
|
+
"""Number chart configuration"""
|
|
18
|
+
|
|
19
|
+
value: float = Field(description='Value of the number')
|
|
20
|
+
color: str = Field(description='Color of the number')
|
|
21
|
+
label: str = Field(description='Label of the number')
|
|
22
|
+
|
|
23
|
+
def render(self: Self, technology: ChartRenderTechnology = ChartRenderTechnology.FLUTTER) -> dict[str, Any]:
|
|
24
|
+
"""
|
|
25
|
+
Render chart to a graphic Library.
|
|
26
|
+
|
|
27
|
+
:param technology: The technology to use to render the chart.
|
|
28
|
+
:type technology: ChartRenderTechnology
|
|
29
|
+
|
|
30
|
+
:return: The configuration of the chart.
|
|
31
|
+
:rtype: dict[str, Any]
|
|
32
|
+
"""
|
|
33
|
+
if technology == ChartRenderTechnology.FLUTTER:
|
|
34
|
+
return {
|
|
35
|
+
'library': 'FLUTTER',
|
|
36
|
+
'chart': 'NUMBER',
|
|
37
|
+
'configuration': self._render_flutter(),
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
'library': 'FLUTTER',
|
|
42
|
+
'chart': 'TEXT',
|
|
43
|
+
'configuration': [f'Unsupported {technology}'],
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
def _render_flutter(self: Self) -> dict[str, Any]:
|
|
47
|
+
"""
|
|
48
|
+
Converts the configuration of the chart to a Flutter native components.
|
|
49
|
+
"""
|
|
50
|
+
return {
|
|
51
|
+
'value': self.value,
|
|
52
|
+
'color': self.color,
|
|
53
|
+
'label': self.label,
|
|
54
|
+
}
|
|
@@ -1,131 +1,131 @@
|
|
|
1
|
-
"""Pie chart"""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
from .chart_alignment import ChartAlignment
|
|
9
|
-
from .chart_data_serie import ChartDataSerie
|
|
10
|
-
from .chart_render_technology import ChartRenderTechnology
|
|
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 PieChart(BaseModel):
|
|
19
|
-
"""Pie chart configuration"""
|
|
20
|
-
|
|
21
|
-
series:
|
|
22
|
-
title: str = Field(description='Title of the chart', default='Chart')
|
|
23
|
-
align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
|
|
24
|
-
|
|
25
|
-
def render(
|
|
26
|
-
self: Self,
|
|
27
|
-
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
28
|
-
) ->
|
|
29
|
-
"""
|
|
30
|
-
Render chart to a graphic Library.
|
|
31
|
-
|
|
32
|
-
:param technology: The technology to use to render the chart.
|
|
33
|
-
:type technology: ChartRenderTechnology
|
|
34
|
-
|
|
35
|
-
:return: The configuration of the chart.
|
|
36
|
-
:rtype:
|
|
37
|
-
"""
|
|
38
|
-
if technology == ChartRenderTechnology.GRAPHIC:
|
|
39
|
-
return {
|
|
40
|
-
'library': 'GRAPHIC',
|
|
41
|
-
'chart': 'PIE',
|
|
42
|
-
'configuration': self._render_graphic(),
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
46
|
-
return {
|
|
47
|
-
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
48
|
-
'chart': 'PIE',
|
|
49
|
-
'configuration': self._render_syncfusion_flutter_charts(),
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if technology == ChartRenderTechnology.APEX_CHARTS:
|
|
53
|
-
return {
|
|
54
|
-
'library': 'APEXCHARTS',
|
|
55
|
-
'chart': 'PIE',
|
|
56
|
-
'configuration': self._render_apexcharts(),
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
'library': 'FLUTTER',
|
|
61
|
-
'chart': 'TEXT',
|
|
62
|
-
'configuration': [f'Unsupported {technology}'],
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
def _render_syncfusion_flutter_charts(self: Self) ->
|
|
66
|
-
"""
|
|
67
|
-
Converts the configuration of the chart to Syncfusion Flutter Charts.
|
|
68
|
-
"""
|
|
69
|
-
series = []
|
|
70
|
-
|
|
71
|
-
for serie in self.series:
|
|
72
|
-
series.append(
|
|
73
|
-
{
|
|
74
|
-
'label': serie.label,
|
|
75
|
-
'color': serie.color,
|
|
76
|
-
'value': serie.data[0],
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
|
|
80
|
-
return {'series': series}
|
|
81
|
-
|
|
82
|
-
def _render_graphic(self: Self) ->
|
|
83
|
-
"""
|
|
84
|
-
Converts the configuration of the chart to a Flutter library Graphic.
|
|
85
|
-
"""
|
|
86
|
-
series = []
|
|
87
|
-
|
|
88
|
-
for serie in self.series:
|
|
89
|
-
series.append(
|
|
90
|
-
{
|
|
91
|
-
'group': serie.label,
|
|
92
|
-
'color': serie.color,
|
|
93
|
-
'value': serie.data[0],
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
return series
|
|
98
|
-
|
|
99
|
-
def _render_apexcharts(self: Self) ->
|
|
100
|
-
"""
|
|
101
|
-
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
series = []
|
|
105
|
-
colors = []
|
|
106
|
-
labels = []
|
|
107
|
-
|
|
108
|
-
for serie in self.series:
|
|
109
|
-
series.append(serie.data[0])
|
|
110
|
-
colors.append(serie.color)
|
|
111
|
-
labels.append(serie.label)
|
|
112
|
-
|
|
113
|
-
config = {
|
|
114
|
-
'series': series,
|
|
115
|
-
'colors': colors,
|
|
116
|
-
'labels': labels,
|
|
117
|
-
'title': {
|
|
118
|
-
'text': self.title,
|
|
119
|
-
'align': self.align.value,
|
|
120
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
121
|
-
},
|
|
122
|
-
'chart': {
|
|
123
|
-
'type': 'pie',
|
|
124
|
-
'animations': {'enabled': False},
|
|
125
|
-
'toolbar': {'show': False},
|
|
126
|
-
'zoom': {'enabled': False},
|
|
127
|
-
},
|
|
128
|
-
'dataLabels': {'enabled': True},
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return config
|
|
1
|
+
"""Pie chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
from .chart_alignment import ChartAlignment
|
|
9
|
+
from .chart_data_serie import ChartDataSerie
|
|
10
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
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 PieChart(BaseModel):
|
|
19
|
+
"""Pie chart configuration"""
|
|
20
|
+
|
|
21
|
+
series: list[ChartDataSerie] = Field(description='List of series to be displayed in the chart', default_factory=list)
|
|
22
|
+
title: str = Field(description='Title of the chart', default='Chart')
|
|
23
|
+
align: ChartAlignment = Field(description='Alignment of the chart', default=ChartAlignment.CENTER)
|
|
24
|
+
|
|
25
|
+
def render(
|
|
26
|
+
self: Self,
|
|
27
|
+
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
28
|
+
) -> dict[str, Any]:
|
|
29
|
+
"""
|
|
30
|
+
Render chart to a graphic Library.
|
|
31
|
+
|
|
32
|
+
:param technology: The technology to use to render the chart.
|
|
33
|
+
:type technology: ChartRenderTechnology
|
|
34
|
+
|
|
35
|
+
:return: The configuration of the chart.
|
|
36
|
+
:rtype: dict[str, Any]
|
|
37
|
+
"""
|
|
38
|
+
if technology == ChartRenderTechnology.GRAPHIC:
|
|
39
|
+
return {
|
|
40
|
+
'library': 'GRAPHIC',
|
|
41
|
+
'chart': 'PIE',
|
|
42
|
+
'configuration': self._render_graphic(),
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
46
|
+
return {
|
|
47
|
+
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
48
|
+
'chart': 'PIE',
|
|
49
|
+
'configuration': self._render_syncfusion_flutter_charts(),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if technology == ChartRenderTechnology.APEX_CHARTS:
|
|
53
|
+
return {
|
|
54
|
+
'library': 'APEXCHARTS',
|
|
55
|
+
'chart': 'PIE',
|
|
56
|
+
'configuration': self._render_apexcharts(),
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
'library': 'FLUTTER',
|
|
61
|
+
'chart': 'TEXT',
|
|
62
|
+
'configuration': [f'Unsupported {technology}'],
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
def _render_syncfusion_flutter_charts(self: Self) -> dict[str, Any]:
|
|
66
|
+
"""
|
|
67
|
+
Converts the configuration of the chart to Syncfusion Flutter Charts.
|
|
68
|
+
"""
|
|
69
|
+
series = []
|
|
70
|
+
|
|
71
|
+
for serie in self.series:
|
|
72
|
+
series.append(
|
|
73
|
+
{
|
|
74
|
+
'label': serie.label,
|
|
75
|
+
'color': serie.color,
|
|
76
|
+
'value': serie.data[0],
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return {'series': series}
|
|
81
|
+
|
|
82
|
+
def _render_graphic(self: Self) -> list[dict[str, Any]]:
|
|
83
|
+
"""
|
|
84
|
+
Converts the configuration of the chart to a Flutter library Graphic.
|
|
85
|
+
"""
|
|
86
|
+
series = []
|
|
87
|
+
|
|
88
|
+
for serie in self.series:
|
|
89
|
+
series.append(
|
|
90
|
+
{
|
|
91
|
+
'group': serie.label,
|
|
92
|
+
'color': serie.color,
|
|
93
|
+
'value': serie.data[0],
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return series
|
|
98
|
+
|
|
99
|
+
def _render_apexcharts(self: Self) -> dict[str, Any]:
|
|
100
|
+
"""
|
|
101
|
+
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
102
|
+
"""
|
|
103
|
+
|
|
104
|
+
series = []
|
|
105
|
+
colors = []
|
|
106
|
+
labels = []
|
|
107
|
+
|
|
108
|
+
for serie in self.series:
|
|
109
|
+
series.append(serie.data[0])
|
|
110
|
+
colors.append(serie.color)
|
|
111
|
+
labels.append(serie.label)
|
|
112
|
+
|
|
113
|
+
config = {
|
|
114
|
+
'series': series,
|
|
115
|
+
'colors': colors,
|
|
116
|
+
'labels': labels,
|
|
117
|
+
'title': {
|
|
118
|
+
'text': self.title,
|
|
119
|
+
'align': self.align.value,
|
|
120
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
121
|
+
},
|
|
122
|
+
'chart': {
|
|
123
|
+
'type': 'pie',
|
|
124
|
+
'animations': {'enabled': False},
|
|
125
|
+
'toolbar': {'show': False},
|
|
126
|
+
'zoom': {'enabled': False},
|
|
127
|
+
},
|
|
128
|
+
'dataLabels': {'enabled': True},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return config
|