layrz-sdk 3.1.14__py3-none-any.whl → 3.1.16__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 +19 -5
- layrz_sdk/entities/__init__.py +138 -129
- layrz_sdk/entities/asset.py +76 -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 +52 -52
- 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 -13
- 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 -10
- layrz_sdk/entities/charts/timeline_serie_item.py +12 -12
- layrz_sdk/entities/checkpoint.py +17 -17
- layrz_sdk/entities/comment.py +16 -16
- layrz_sdk/entities/custom_field.py +10 -10
- layrz_sdk/entities/custom_report_page.py +40 -40
- layrz_sdk/entities/device.py +18 -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/modbus/__init__.py +9 -0
- layrz_sdk/entities/modbus/config.py +19 -0
- layrz_sdk/entities/modbus/parameter.py +110 -0
- layrz_sdk/entities/modbus/schema.py +10 -0
- layrz_sdk/entities/modbus/status.py +16 -0
- layrz_sdk/entities/modbus/wait.py +134 -0
- 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 -289
- 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 -15
- layrz_sdk/entities/report_row.py +28 -28
- layrz_sdk/entities/sensor.py +11 -11
- layrz_sdk/entities/static_position.py +17 -0
- layrz_sdk/entities/telemetry/__init__.py +6 -0
- layrz_sdk/entities/telemetry/assetmessage.py +159 -0
- layrz_sdk/entities/telemetry/devicemessage.py +122 -0
- 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 -5
- layrz_sdk/helpers/color.py +44 -44
- layrz_sdk/lcl/__init__.py +5 -5
- layrz_sdk/lcl/core.py +848 -848
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.16.dist-info}/METADATA +54 -49
- layrz_sdk-3.1.16.dist-info/RECORD +85 -0
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.16.dist-info}/licenses/LICENSE +6 -6
- layrz_sdk-3.1.14.dist-info/RECORD +0 -75
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.16.dist-info}/WHEEL +0 -0
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.16.dist-info}/top_level.txt +0 -0
|
@@ -1,248 +1,248 @@
|
|
|
1
|
-
"""Line chart"""
|
|
2
|
-
|
|
3
|
-
import logging
|
|
4
|
-
import sys
|
|
5
|
-
from typing import Any
|
|
6
|
-
|
|
7
|
-
from pydantic import BaseModel, Field
|
|
8
|
-
|
|
9
|
-
from .axis_config import AxisConfig
|
|
10
|
-
from .chart_alignment import ChartAlignment
|
|
11
|
-
from .chart_data_serie import ChartDataSerie
|
|
12
|
-
from .chart_data_serie_type import ChartDataSerieType
|
|
13
|
-
from .chart_data_type import ChartDataType
|
|
14
|
-
from .chart_render_technology import ChartRenderTechnology
|
|
15
|
-
|
|
16
|
-
if sys.version_info >= (3, 11):
|
|
17
|
-
from typing import Self
|
|
18
|
-
else:
|
|
19
|
-
from typing_extensions import Self
|
|
20
|
-
|
|
21
|
-
log = logging.getLogger(__name__)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class LineChart(BaseModel):
|
|
25
|
-
"""Line chart configuration"""
|
|
26
|
-
|
|
27
|
-
x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
|
|
28
|
-
y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
|
|
29
|
-
title: str = Field(default='Chart', description='Title of the chart')
|
|
30
|
-
align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
|
|
31
|
-
x_axis_config: AxisConfig = Field(
|
|
32
|
-
default_factory=lambda: AxisConfig(),
|
|
33
|
-
description='Configuration of the X Axis',
|
|
34
|
-
)
|
|
35
|
-
y_axis_config: AxisConfig = Field(
|
|
36
|
-
default_factory=lambda: AxisConfig(),
|
|
37
|
-
description='Configuration of the Y Axis',
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
def render(self: Self, technology: ChartRenderTechnology) -> dict[str, Any]:
|
|
41
|
-
"""
|
|
42
|
-
Render chart to a graphic Library.
|
|
43
|
-
|
|
44
|
-
:param technology: The technology to use to render the chart.
|
|
45
|
-
:type technology: ChartRenderTechnology
|
|
46
|
-
|
|
47
|
-
:return: The configuration of the chart.
|
|
48
|
-
:rtype: dict[str, Any]
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
if technology == ChartRenderTechnology.GRAPHIC:
|
|
52
|
-
return {
|
|
53
|
-
'library': 'GRAPHIC',
|
|
54
|
-
'chart': 'LINE',
|
|
55
|
-
'configuration': self._render_graphic(),
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
59
|
-
return {
|
|
60
|
-
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
61
|
-
'chart': 'LINE',
|
|
62
|
-
'configuration': self._render_syncfusion_flutter_charts(),
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if technology == ChartRenderTechnology.CANVAS_JS:
|
|
66
|
-
return {
|
|
67
|
-
'library': 'CANVASJS',
|
|
68
|
-
'chart': 'LINE',
|
|
69
|
-
'configuration': self._render_canvasjs(),
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
'library': 'FLUTTER',
|
|
74
|
-
'chart': 'TEXT',
|
|
75
|
-
'configuration': [f'Unsupported {technology}'],
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
def _render_syncfusion_flutter_charts(self: Self) -> dict[str, Any]:
|
|
79
|
-
"""
|
|
80
|
-
Converts the configuration of the chart to a Flutter library syncfusion_flutter_charts.
|
|
81
|
-
"""
|
|
82
|
-
series = []
|
|
83
|
-
|
|
84
|
-
for serie in self.y_axis:
|
|
85
|
-
if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
|
|
86
|
-
log.warning('Serie type not supported: %s', serie.serie_type)
|
|
87
|
-
continue
|
|
88
|
-
|
|
89
|
-
points = []
|
|
90
|
-
|
|
91
|
-
for i, value in enumerate(self.x_axis.data):
|
|
92
|
-
x_value = value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value
|
|
93
|
-
if not isinstance(x_value, (int, float)):
|
|
94
|
-
continue
|
|
95
|
-
|
|
96
|
-
y_value = serie.data[i]
|
|
97
|
-
if isinstance(y_value, bool):
|
|
98
|
-
if y_value:
|
|
99
|
-
y_value = 1
|
|
100
|
-
else:
|
|
101
|
-
y_value = 0
|
|
102
|
-
|
|
103
|
-
if not isinstance(y_value, (int, float)):
|
|
104
|
-
log.debug("Value isn't a number: %s", y_value)
|
|
105
|
-
continue
|
|
106
|
-
|
|
107
|
-
points.append(
|
|
108
|
-
{
|
|
109
|
-
'xAxis': x_value,
|
|
110
|
-
'yAxis': y_value,
|
|
111
|
-
}
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
series.append(
|
|
115
|
-
{
|
|
116
|
-
'color': serie.color,
|
|
117
|
-
'values': points,
|
|
118
|
-
'label': serie.label,
|
|
119
|
-
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
120
|
-
}
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
return {
|
|
124
|
-
'series': series,
|
|
125
|
-
'xAxis': {
|
|
126
|
-
'label': self.x_axis_config.label,
|
|
127
|
-
'measureUnit': self.x_axis_config.measure_unit,
|
|
128
|
-
'dataType': self.x_axis_config.data_type.value,
|
|
129
|
-
'minValue': self.x_axis_config.min_value,
|
|
130
|
-
'maxValue': self.x_axis_config.max_value,
|
|
131
|
-
},
|
|
132
|
-
'yAxis': {
|
|
133
|
-
'label': self.y_axis_config.label,
|
|
134
|
-
'measureUnit': self.y_axis_config.measure_unit,
|
|
135
|
-
'dataType': self.y_axis_config.data_type.value,
|
|
136
|
-
'minValue': self.y_axis_config.min_value,
|
|
137
|
-
'maxValue': self.y_axis_config.max_value,
|
|
138
|
-
},
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
def _render_graphic(self: Self) -> list[dict[str, Any]]:
|
|
142
|
-
"""
|
|
143
|
-
Converts the configuration of the chart to a Flutter library Graphic.
|
|
144
|
-
"""
|
|
145
|
-
series = []
|
|
146
|
-
|
|
147
|
-
for serie in self.y_axis:
|
|
148
|
-
if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
|
|
149
|
-
continue
|
|
150
|
-
|
|
151
|
-
points = []
|
|
152
|
-
|
|
153
|
-
for i, value in enumerate(self.x_axis.data):
|
|
154
|
-
points.append(
|
|
155
|
-
{
|
|
156
|
-
'x_axis': {
|
|
157
|
-
'value': value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
158
|
-
'is_datetime': self.x_axis.data_type == ChartDataType.DATETIME,
|
|
159
|
-
},
|
|
160
|
-
'y_axis': serie.data[i],
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
series.append(
|
|
165
|
-
{
|
|
166
|
-
'group': serie.label,
|
|
167
|
-
'color': serie.color,
|
|
168
|
-
'dashed': serie.serie_type == ChartDataSerieType.LINE and serie.dashed,
|
|
169
|
-
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
170
|
-
'values': points,
|
|
171
|
-
}
|
|
172
|
-
)
|
|
173
|
-
|
|
174
|
-
return series
|
|
175
|
-
|
|
176
|
-
def _render_canvasjs(self: Self) -> dict[str, Any]:
|
|
177
|
-
"""
|
|
178
|
-
Converts the configuration of the chart to Javascript library CanvasJS.
|
|
179
|
-
"""
|
|
180
|
-
datasets = []
|
|
181
|
-
|
|
182
|
-
for serie in self.y_axis:
|
|
183
|
-
dataset = {
|
|
184
|
-
'type': 'line',
|
|
185
|
-
'name': serie.label,
|
|
186
|
-
'connectNullData': True,
|
|
187
|
-
'nullDataLineDashType': 'solid',
|
|
188
|
-
'showInLegend': True,
|
|
189
|
-
'color': serie.color,
|
|
190
|
-
'markerSize': 3,
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if serie.serie_type != ChartDataSerieType.NONE:
|
|
194
|
-
dataset['type'] = serie.serie_type.value
|
|
195
|
-
|
|
196
|
-
if serie.serie_type == ChartDataSerieType.AREA:
|
|
197
|
-
dataset['fillOpacity'] = 0.3
|
|
198
|
-
|
|
199
|
-
if self.x_axis.data_type == ChartDataType.DATETIME:
|
|
200
|
-
dataset['xValueType'] = 'dateTime'
|
|
201
|
-
dataset['xValueFormatString'] = 'YYYY-MM-DD HH:mm:ss TT'
|
|
202
|
-
|
|
203
|
-
if serie.serie_type == ChartDataSerieType.LINE and serie.dashed:
|
|
204
|
-
dataset['lineDashType'] = 'dash'
|
|
205
|
-
dataset['markerSize'] = 0
|
|
206
|
-
|
|
207
|
-
points = []
|
|
208
|
-
|
|
209
|
-
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
210
|
-
for point in serie.data:
|
|
211
|
-
points.append({'x': point.x, 'y': point.y})
|
|
212
|
-
else:
|
|
213
|
-
for i, value in enumerate(self.x_axis.data):
|
|
214
|
-
points.append(
|
|
215
|
-
{
|
|
216
|
-
'x': (value.timestamp() * 1000) if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
217
|
-
'y': serie.data[i],
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
dataset['dataPoints'] = points
|
|
222
|
-
datasets.append(dataset)
|
|
223
|
-
|
|
224
|
-
return {
|
|
225
|
-
'animationEnabled': False,
|
|
226
|
-
'zoomEnabled': True,
|
|
227
|
-
'title': {
|
|
228
|
-
'text': self.title,
|
|
229
|
-
'fontFamily': 'Fira Sans Condensed',
|
|
230
|
-
'fontSize': 20,
|
|
231
|
-
'horizontalAlign': self.align.value,
|
|
232
|
-
},
|
|
233
|
-
'data': datasets,
|
|
234
|
-
'axisX': {
|
|
235
|
-
'title': self.x_axis.label,
|
|
236
|
-
'titleFontFamily': 'Fira Sans Condensed',
|
|
237
|
-
'titleFontSize': 20,
|
|
238
|
-
},
|
|
239
|
-
'toolTip': {'animationEnabled': False, 'shared': True},
|
|
240
|
-
'legend': {'cursor': 'pointer'},
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
class AreaChart(LineChart):
|
|
245
|
-
"""
|
|
246
|
-
Line chart
|
|
247
|
-
Deprecation warning: This class will be removed in the next version. Use LineChart instead.
|
|
248
|
-
"""
|
|
1
|
+
"""Line chart"""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import sys
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from pydantic import BaseModel, Field
|
|
8
|
+
|
|
9
|
+
from .axis_config import AxisConfig
|
|
10
|
+
from .chart_alignment import ChartAlignment
|
|
11
|
+
from .chart_data_serie import ChartDataSerie
|
|
12
|
+
from .chart_data_serie_type import ChartDataSerieType
|
|
13
|
+
from .chart_data_type import ChartDataType
|
|
14
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
15
|
+
|
|
16
|
+
if sys.version_info >= (3, 11):
|
|
17
|
+
from typing import Self
|
|
18
|
+
else:
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
log = logging.getLogger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class LineChart(BaseModel):
|
|
25
|
+
"""Line chart configuration"""
|
|
26
|
+
|
|
27
|
+
x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
|
|
28
|
+
y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
|
|
29
|
+
title: str = Field(default='Chart', description='Title of the chart')
|
|
30
|
+
align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
|
|
31
|
+
x_axis_config: AxisConfig = Field(
|
|
32
|
+
default_factory=lambda: AxisConfig(),
|
|
33
|
+
description='Configuration of the X Axis',
|
|
34
|
+
)
|
|
35
|
+
y_axis_config: AxisConfig = Field(
|
|
36
|
+
default_factory=lambda: AxisConfig(),
|
|
37
|
+
description='Configuration of the Y Axis',
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
def render(self: Self, technology: ChartRenderTechnology) -> dict[str, Any]:
|
|
41
|
+
"""
|
|
42
|
+
Render chart to a graphic Library.
|
|
43
|
+
|
|
44
|
+
:param technology: The technology to use to render the chart.
|
|
45
|
+
:type technology: ChartRenderTechnology
|
|
46
|
+
|
|
47
|
+
:return: The configuration of the chart.
|
|
48
|
+
:rtype: dict[str, Any]
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
if technology == ChartRenderTechnology.GRAPHIC:
|
|
52
|
+
return {
|
|
53
|
+
'library': 'GRAPHIC',
|
|
54
|
+
'chart': 'LINE',
|
|
55
|
+
'configuration': self._render_graphic(),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
59
|
+
return {
|
|
60
|
+
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
61
|
+
'chart': 'LINE',
|
|
62
|
+
'configuration': self._render_syncfusion_flutter_charts(),
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if technology == ChartRenderTechnology.CANVAS_JS:
|
|
66
|
+
return {
|
|
67
|
+
'library': 'CANVASJS',
|
|
68
|
+
'chart': 'LINE',
|
|
69
|
+
'configuration': self._render_canvasjs(),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
'library': 'FLUTTER',
|
|
74
|
+
'chart': 'TEXT',
|
|
75
|
+
'configuration': [f'Unsupported {technology}'],
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
def _render_syncfusion_flutter_charts(self: Self) -> dict[str, Any]:
|
|
79
|
+
"""
|
|
80
|
+
Converts the configuration of the chart to a Flutter library syncfusion_flutter_charts.
|
|
81
|
+
"""
|
|
82
|
+
series = []
|
|
83
|
+
|
|
84
|
+
for serie in self.y_axis:
|
|
85
|
+
if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
|
|
86
|
+
log.warning('Serie type not supported: %s', serie.serie_type)
|
|
87
|
+
continue
|
|
88
|
+
|
|
89
|
+
points = []
|
|
90
|
+
|
|
91
|
+
for i, value in enumerate(self.x_axis.data):
|
|
92
|
+
x_value = value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value
|
|
93
|
+
if not isinstance(x_value, (int, float)):
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
y_value = serie.data[i]
|
|
97
|
+
if isinstance(y_value, bool):
|
|
98
|
+
if y_value:
|
|
99
|
+
y_value = 1
|
|
100
|
+
else:
|
|
101
|
+
y_value = 0
|
|
102
|
+
|
|
103
|
+
if not isinstance(y_value, (int, float)):
|
|
104
|
+
log.debug("Value isn't a number: %s", y_value)
|
|
105
|
+
continue
|
|
106
|
+
|
|
107
|
+
points.append(
|
|
108
|
+
{
|
|
109
|
+
'xAxis': x_value,
|
|
110
|
+
'yAxis': y_value,
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
series.append(
|
|
115
|
+
{
|
|
116
|
+
'color': serie.color,
|
|
117
|
+
'values': points,
|
|
118
|
+
'label': serie.label,
|
|
119
|
+
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
120
|
+
}
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
'series': series,
|
|
125
|
+
'xAxis': {
|
|
126
|
+
'label': self.x_axis_config.label,
|
|
127
|
+
'measureUnit': self.x_axis_config.measure_unit,
|
|
128
|
+
'dataType': self.x_axis_config.data_type.value,
|
|
129
|
+
'minValue': self.x_axis_config.min_value,
|
|
130
|
+
'maxValue': self.x_axis_config.max_value,
|
|
131
|
+
},
|
|
132
|
+
'yAxis': {
|
|
133
|
+
'label': self.y_axis_config.label,
|
|
134
|
+
'measureUnit': self.y_axis_config.measure_unit,
|
|
135
|
+
'dataType': self.y_axis_config.data_type.value,
|
|
136
|
+
'minValue': self.y_axis_config.min_value,
|
|
137
|
+
'maxValue': self.y_axis_config.max_value,
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
def _render_graphic(self: Self) -> list[dict[str, Any]]:
|
|
142
|
+
"""
|
|
143
|
+
Converts the configuration of the chart to a Flutter library Graphic.
|
|
144
|
+
"""
|
|
145
|
+
series = []
|
|
146
|
+
|
|
147
|
+
for serie in self.y_axis:
|
|
148
|
+
if serie.serie_type not in [ChartDataSerieType.LINE, ChartDataSerieType.AREA]:
|
|
149
|
+
continue
|
|
150
|
+
|
|
151
|
+
points = []
|
|
152
|
+
|
|
153
|
+
for i, value in enumerate(self.x_axis.data):
|
|
154
|
+
points.append(
|
|
155
|
+
{
|
|
156
|
+
'x_axis': {
|
|
157
|
+
'value': value.timestamp() if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
158
|
+
'is_datetime': self.x_axis.data_type == ChartDataType.DATETIME,
|
|
159
|
+
},
|
|
160
|
+
'y_axis': serie.data[i],
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
series.append(
|
|
165
|
+
{
|
|
166
|
+
'group': serie.label,
|
|
167
|
+
'color': serie.color,
|
|
168
|
+
'dashed': serie.serie_type == ChartDataSerieType.LINE and serie.dashed,
|
|
169
|
+
'type': 'AREA' if serie.serie_type == ChartDataSerieType.AREA else 'LINE',
|
|
170
|
+
'values': points,
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
return series
|
|
175
|
+
|
|
176
|
+
def _render_canvasjs(self: Self) -> dict[str, Any]:
|
|
177
|
+
"""
|
|
178
|
+
Converts the configuration of the chart to Javascript library CanvasJS.
|
|
179
|
+
"""
|
|
180
|
+
datasets = []
|
|
181
|
+
|
|
182
|
+
for serie in self.y_axis:
|
|
183
|
+
dataset = {
|
|
184
|
+
'type': 'line',
|
|
185
|
+
'name': serie.label,
|
|
186
|
+
'connectNullData': True,
|
|
187
|
+
'nullDataLineDashType': 'solid',
|
|
188
|
+
'showInLegend': True,
|
|
189
|
+
'color': serie.color,
|
|
190
|
+
'markerSize': 3,
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if serie.serie_type != ChartDataSerieType.NONE:
|
|
194
|
+
dataset['type'] = serie.serie_type.value
|
|
195
|
+
|
|
196
|
+
if serie.serie_type == ChartDataSerieType.AREA:
|
|
197
|
+
dataset['fillOpacity'] = 0.3
|
|
198
|
+
|
|
199
|
+
if self.x_axis.data_type == ChartDataType.DATETIME:
|
|
200
|
+
dataset['xValueType'] = 'dateTime'
|
|
201
|
+
dataset['xValueFormatString'] = 'YYYY-MM-DD HH:mm:ss TT'
|
|
202
|
+
|
|
203
|
+
if serie.serie_type == ChartDataSerieType.LINE and serie.dashed:
|
|
204
|
+
dataset['lineDashType'] = 'dash'
|
|
205
|
+
dataset['markerSize'] = 0
|
|
206
|
+
|
|
207
|
+
points = []
|
|
208
|
+
|
|
209
|
+
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
210
|
+
for point in serie.data:
|
|
211
|
+
points.append({'x': point.x, 'y': point.y})
|
|
212
|
+
else:
|
|
213
|
+
for i, value in enumerate(self.x_axis.data):
|
|
214
|
+
points.append(
|
|
215
|
+
{
|
|
216
|
+
'x': (value.timestamp() * 1000) if self.x_axis.data_type == ChartDataType.DATETIME else value,
|
|
217
|
+
'y': serie.data[i],
|
|
218
|
+
}
|
|
219
|
+
)
|
|
220
|
+
|
|
221
|
+
dataset['dataPoints'] = points
|
|
222
|
+
datasets.append(dataset)
|
|
223
|
+
|
|
224
|
+
return {
|
|
225
|
+
'animationEnabled': False,
|
|
226
|
+
'zoomEnabled': True,
|
|
227
|
+
'title': {
|
|
228
|
+
'text': self.title,
|
|
229
|
+
'fontFamily': 'Fira Sans Condensed',
|
|
230
|
+
'fontSize': 20,
|
|
231
|
+
'horizontalAlign': self.align.value,
|
|
232
|
+
},
|
|
233
|
+
'data': datasets,
|
|
234
|
+
'axisX': {
|
|
235
|
+
'title': self.x_axis.label,
|
|
236
|
+
'titleFontFamily': 'Fira Sans Condensed',
|
|
237
|
+
'titleFontSize': 20,
|
|
238
|
+
},
|
|
239
|
+
'toolTip': {'animationEnabled': False, 'shared': True},
|
|
240
|
+
'legend': {'cursor': 'pointer'},
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
class AreaChart(LineChart):
|
|
245
|
+
"""
|
|
246
|
+
Line chart
|
|
247
|
+
Deprecation warning: This class will be removed in the next version. Use LineChart instead.
|
|
248
|
+
"""
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import sys
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
if sys.version_info >= (3, 11):
|
|
5
|
-
from typing import Self
|
|
6
|
-
else:
|
|
7
|
-
from typing_extensions import Self
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class MapCenterType(Enum):
|
|
11
|
-
"""Map Chart center type"""
|
|
12
|
-
|
|
13
|
-
FIXED = 'FIXED'
|
|
14
|
-
CONTAIN = 'CONTAIN'
|
|
15
|
-
|
|
16
|
-
def __str__(self: Self) -> str:
|
|
17
|
-
"""Readable property"""
|
|
18
|
-
return self.name
|
|
19
|
-
|
|
20
|
-
def __repr__(self: Self) -> str:
|
|
21
|
-
"""Readable property"""
|
|
22
|
-
return f'MapCenterType.{self.name}'
|
|
1
|
+
import sys
|
|
2
|
+
from enum import Enum
|
|
3
|
+
|
|
4
|
+
if sys.version_info >= (3, 11):
|
|
5
|
+
from typing import Self
|
|
6
|
+
else:
|
|
7
|
+
from typing_extensions import Self
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class MapCenterType(Enum):
|
|
11
|
+
"""Map Chart center type"""
|
|
12
|
+
|
|
13
|
+
FIXED = 'FIXED'
|
|
14
|
+
CONTAIN = 'CONTAIN'
|
|
15
|
+
|
|
16
|
+
def __str__(self: Self) -> str:
|
|
17
|
+
"""Readable property"""
|
|
18
|
+
return self.name
|
|
19
|
+
|
|
20
|
+
def __repr__(self: Self) -> str:
|
|
21
|
+
"""Readable property"""
|
|
22
|
+
return f'MapCenterType.{self.name}'
|