layrz-sdk 3.1.14__py3-none-any.whl → 3.1.15__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 +71 -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.15.dist-info}/METADATA +51 -49
- layrz_sdk-3.1.15.dist-info/RECORD +85 -0
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.15.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.15.dist-info}/WHEEL +0 -0
- {layrz_sdk-3.1.14.dist-info → layrz_sdk-3.1.15.dist-info}/top_level.txt +0 -0
|
@@ -1,201 +1,201 @@
|
|
|
1
|
-
"""Column chart"""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from typing import Any
|
|
5
|
-
|
|
6
|
-
from layrz_sdk.helpers import convert_to_rgba
|
|
7
|
-
|
|
8
|
-
from .axis_config import AxisConfig
|
|
9
|
-
from .chart_alignment import ChartAlignment
|
|
10
|
-
from .chart_data_serie import ChartDataSerie
|
|
11
|
-
from .chart_data_serie_type import ChartDataSerieType
|
|
12
|
-
from .chart_render_technology import ChartRenderTechnology
|
|
13
|
-
|
|
14
|
-
if sys.version_info >= (3, 11):
|
|
15
|
-
from typing import Self
|
|
16
|
-
else:
|
|
17
|
-
from typing_extensions import Self
|
|
18
|
-
from pydantic import BaseModel, Field
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
class ColumnChart(BaseModel):
|
|
22
|
-
"""Column chart configuration"""
|
|
23
|
-
|
|
24
|
-
x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
|
|
25
|
-
y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
|
|
26
|
-
title: str = Field(default='Chart', description='Title of the chart')
|
|
27
|
-
align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
|
|
28
|
-
x_axis_config: AxisConfig = Field(
|
|
29
|
-
default_factory=lambda: AxisConfig(),
|
|
30
|
-
description='Configuration of the X Axis',
|
|
31
|
-
)
|
|
32
|
-
y_axis_config: AxisConfig = Field(
|
|
33
|
-
default_factory=lambda: AxisConfig(),
|
|
34
|
-
description='Configuration of the Y Axis',
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
def render(
|
|
38
|
-
self: Self,
|
|
39
|
-
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
40
|
-
) -> 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
|
-
if technology == ChartRenderTechnology.GRAPHIC:
|
|
51
|
-
return {
|
|
52
|
-
'library': 'GRAPHIC',
|
|
53
|
-
'chart': 'COLUMN',
|
|
54
|
-
'configuration': self._render_graphic(),
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
58
|
-
return {
|
|
59
|
-
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
60
|
-
'chart': 'COLUMN',
|
|
61
|
-
'configuration': self._render_syncfusion_flutter_charts(),
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
if technology == ChartRenderTechnology.APEX_CHARTS:
|
|
65
|
-
return {
|
|
66
|
-
'library': 'APEXCHARTS',
|
|
67
|
-
'chart': 'COLUMN',
|
|
68
|
-
'configuration': self._render_apexcharts(),
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return {
|
|
72
|
-
'library': 'FLUTTER',
|
|
73
|
-
'chart': 'TEXT',
|
|
74
|
-
'configuration': [f'Unsupported {technology}'],
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
def _render_syncfusion_flutter_charts(self: Self) -> dict[str, Any]:
|
|
78
|
-
"""
|
|
79
|
-
Converts the configuration of the chart to Syncfusion Flutter Charts.
|
|
80
|
-
"""
|
|
81
|
-
series = []
|
|
82
|
-
|
|
83
|
-
for serie in self.y_axis:
|
|
84
|
-
values = []
|
|
85
|
-
for i, value in enumerate(serie.data):
|
|
86
|
-
x_axis = self.x_axis.data[i]
|
|
87
|
-
values.append({'xAxis': x_axis, 'yAxis': value})
|
|
88
|
-
|
|
89
|
-
series.append(
|
|
90
|
-
{
|
|
91
|
-
'label': serie.label,
|
|
92
|
-
'color': serie.color,
|
|
93
|
-
'values': values,
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
return {
|
|
98
|
-
'series': series,
|
|
99
|
-
'xAxis': {
|
|
100
|
-
'label': self.x_axis_config.label,
|
|
101
|
-
'measureUnit': self.x_axis_config.measure_unit,
|
|
102
|
-
'dataType': self.x_axis_config.data_type.value,
|
|
103
|
-
'minValue': self.x_axis_config.min_value,
|
|
104
|
-
'maxValue': self.x_axis_config.max_value,
|
|
105
|
-
},
|
|
106
|
-
'yAxis': {
|
|
107
|
-
'label': self.y_axis_config.label,
|
|
108
|
-
'measureUnit': self.y_axis_config.measure_unit,
|
|
109
|
-
'dataType': self.y_axis_config.data_type.value,
|
|
110
|
-
'minValue': self.y_axis_config.min_value,
|
|
111
|
-
'maxValue': self.y_axis_config.max_value,
|
|
112
|
-
},
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
def _render_graphic(self: Self) -> list[dict[str, Any]]:
|
|
116
|
-
"""
|
|
117
|
-
Converts the configuration of the chart to Flutter library graphic.
|
|
118
|
-
"""
|
|
119
|
-
|
|
120
|
-
series = []
|
|
121
|
-
|
|
122
|
-
for serie in self.y_axis:
|
|
123
|
-
for i, value in enumerate(serie.data):
|
|
124
|
-
x_axis = self.x_axis.data[i]
|
|
125
|
-
series.append(
|
|
126
|
-
{
|
|
127
|
-
'label': serie.label,
|
|
128
|
-
'color': serie.color,
|
|
129
|
-
'category': x_axis,
|
|
130
|
-
'value': value,
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
return series
|
|
135
|
-
|
|
136
|
-
def _render_apexcharts(self: Self) -> dict[str, Any]:
|
|
137
|
-
"""
|
|
138
|
-
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
139
|
-
"""
|
|
140
|
-
|
|
141
|
-
series = []
|
|
142
|
-
colors = []
|
|
143
|
-
stroke: dict[str, Any] = {'width': [], 'dashArray': []}
|
|
144
|
-
markers = []
|
|
145
|
-
|
|
146
|
-
for serie in self.y_axis:
|
|
147
|
-
modified_serie: dict[str, Any] = {
|
|
148
|
-
'name': serie.label,
|
|
149
|
-
}
|
|
150
|
-
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
151
|
-
modified_serie['data'] = [{'x': item.x, 'y': item.y} for item in serie.data]
|
|
152
|
-
modified_serie['type'] = 'scatter'
|
|
153
|
-
stroke['width'].append(0)
|
|
154
|
-
markers.append(10)
|
|
155
|
-
else:
|
|
156
|
-
modified_serie['data'] = [{'x': self.x_axis.data[i], 'y': item} for i, item in enumerate(serie.data)]
|
|
157
|
-
|
|
158
|
-
if serie.serie_type is not ChartDataSerieType.NONE:
|
|
159
|
-
modified_serie['type'] = serie.serie_type.value
|
|
160
|
-
else:
|
|
161
|
-
modified_serie['type'] = 'column'
|
|
162
|
-
|
|
163
|
-
if serie.dashed and serie.serie_type == ChartDataSerieType.LINE:
|
|
164
|
-
stroke['dashArray'].append(5)
|
|
165
|
-
else:
|
|
166
|
-
stroke['dashArray'].append(0)
|
|
167
|
-
|
|
168
|
-
stroke['width'].append(3)
|
|
169
|
-
markers.append(0)
|
|
170
|
-
|
|
171
|
-
series.append(modified_serie)
|
|
172
|
-
|
|
173
|
-
if serie.serie_type == ChartDataSerieType.AREA:
|
|
174
|
-
color = convert_to_rgba(serie.color)
|
|
175
|
-
colors.append(f'rgba({color[0]}, {color[1]}, {color[2]}, 0.5)')
|
|
176
|
-
else:
|
|
177
|
-
colors.append(serie.color)
|
|
178
|
-
|
|
179
|
-
config = {
|
|
180
|
-
'series': series,
|
|
181
|
-
'colors': colors,
|
|
182
|
-
'xaxis': {
|
|
183
|
-
'type': self.x_axis.data_type.value,
|
|
184
|
-
'title': {
|
|
185
|
-
'text': self.x_axis.label,
|
|
186
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
187
|
-
},
|
|
188
|
-
},
|
|
189
|
-
'dataLabels': {'enabled': False},
|
|
190
|
-
'title': {
|
|
191
|
-
'text': self.title,
|
|
192
|
-
'align': self.align.value,
|
|
193
|
-
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
194
|
-
},
|
|
195
|
-
'markers': {'size': markers},
|
|
196
|
-
'fill': {'type': 'solid'},
|
|
197
|
-
'stroke': stroke,
|
|
198
|
-
'chart': {'animations': {'enabled': False}, 'toolbar': {'show': False}, 'zoom': {'enabled': False}},
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return config
|
|
1
|
+
"""Column chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any
|
|
5
|
+
|
|
6
|
+
from layrz_sdk.helpers import convert_to_rgba
|
|
7
|
+
|
|
8
|
+
from .axis_config import AxisConfig
|
|
9
|
+
from .chart_alignment import ChartAlignment
|
|
10
|
+
from .chart_data_serie import ChartDataSerie
|
|
11
|
+
from .chart_data_serie_type import ChartDataSerieType
|
|
12
|
+
from .chart_render_technology import ChartRenderTechnology
|
|
13
|
+
|
|
14
|
+
if sys.version_info >= (3, 11):
|
|
15
|
+
from typing import Self
|
|
16
|
+
else:
|
|
17
|
+
from typing_extensions import Self
|
|
18
|
+
from pydantic import BaseModel, Field
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class ColumnChart(BaseModel):
|
|
22
|
+
"""Column chart configuration"""
|
|
23
|
+
|
|
24
|
+
x_axis: ChartDataSerie = Field(description='Defines the X Axis of the chart')
|
|
25
|
+
y_axis: list[ChartDataSerie] = Field(description='Defines the Y Axis of the chart', default_factory=list)
|
|
26
|
+
title: str = Field(default='Chart', description='Title of the chart')
|
|
27
|
+
align: ChartAlignment = Field(default=ChartAlignment.CENTER, description='Alignment of the title')
|
|
28
|
+
x_axis_config: AxisConfig = Field(
|
|
29
|
+
default_factory=lambda: AxisConfig(),
|
|
30
|
+
description='Configuration of the X Axis',
|
|
31
|
+
)
|
|
32
|
+
y_axis_config: AxisConfig = Field(
|
|
33
|
+
default_factory=lambda: AxisConfig(),
|
|
34
|
+
description='Configuration of the Y Axis',
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
def render(
|
|
38
|
+
self: Self,
|
|
39
|
+
technology: ChartRenderTechnology = ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS,
|
|
40
|
+
) -> 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
|
+
if technology == ChartRenderTechnology.GRAPHIC:
|
|
51
|
+
return {
|
|
52
|
+
'library': 'GRAPHIC',
|
|
53
|
+
'chart': 'COLUMN',
|
|
54
|
+
'configuration': self._render_graphic(),
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if technology == ChartRenderTechnology.SYNCFUSION_FLUTTER_CHARTS:
|
|
58
|
+
return {
|
|
59
|
+
'library': 'SYNCFUSION_FLUTTER_CHARTS',
|
|
60
|
+
'chart': 'COLUMN',
|
|
61
|
+
'configuration': self._render_syncfusion_flutter_charts(),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if technology == ChartRenderTechnology.APEX_CHARTS:
|
|
65
|
+
return {
|
|
66
|
+
'library': 'APEXCHARTS',
|
|
67
|
+
'chart': 'COLUMN',
|
|
68
|
+
'configuration': self._render_apexcharts(),
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
'library': 'FLUTTER',
|
|
73
|
+
'chart': 'TEXT',
|
|
74
|
+
'configuration': [f'Unsupported {technology}'],
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
def _render_syncfusion_flutter_charts(self: Self) -> dict[str, Any]:
|
|
78
|
+
"""
|
|
79
|
+
Converts the configuration of the chart to Syncfusion Flutter Charts.
|
|
80
|
+
"""
|
|
81
|
+
series = []
|
|
82
|
+
|
|
83
|
+
for serie in self.y_axis:
|
|
84
|
+
values = []
|
|
85
|
+
for i, value in enumerate(serie.data):
|
|
86
|
+
x_axis = self.x_axis.data[i]
|
|
87
|
+
values.append({'xAxis': x_axis, 'yAxis': value})
|
|
88
|
+
|
|
89
|
+
series.append(
|
|
90
|
+
{
|
|
91
|
+
'label': serie.label,
|
|
92
|
+
'color': serie.color,
|
|
93
|
+
'values': values,
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
'series': series,
|
|
99
|
+
'xAxis': {
|
|
100
|
+
'label': self.x_axis_config.label,
|
|
101
|
+
'measureUnit': self.x_axis_config.measure_unit,
|
|
102
|
+
'dataType': self.x_axis_config.data_type.value,
|
|
103
|
+
'minValue': self.x_axis_config.min_value,
|
|
104
|
+
'maxValue': self.x_axis_config.max_value,
|
|
105
|
+
},
|
|
106
|
+
'yAxis': {
|
|
107
|
+
'label': self.y_axis_config.label,
|
|
108
|
+
'measureUnit': self.y_axis_config.measure_unit,
|
|
109
|
+
'dataType': self.y_axis_config.data_type.value,
|
|
110
|
+
'minValue': self.y_axis_config.min_value,
|
|
111
|
+
'maxValue': self.y_axis_config.max_value,
|
|
112
|
+
},
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
def _render_graphic(self: Self) -> list[dict[str, Any]]:
|
|
116
|
+
"""
|
|
117
|
+
Converts the configuration of the chart to Flutter library graphic.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
series = []
|
|
121
|
+
|
|
122
|
+
for serie in self.y_axis:
|
|
123
|
+
for i, value in enumerate(serie.data):
|
|
124
|
+
x_axis = self.x_axis.data[i]
|
|
125
|
+
series.append(
|
|
126
|
+
{
|
|
127
|
+
'label': serie.label,
|
|
128
|
+
'color': serie.color,
|
|
129
|
+
'category': x_axis,
|
|
130
|
+
'value': value,
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
return series
|
|
135
|
+
|
|
136
|
+
def _render_apexcharts(self: Self) -> dict[str, Any]:
|
|
137
|
+
"""
|
|
138
|
+
Converts the configuration of the chart to Javascript library ApexCharts.
|
|
139
|
+
"""
|
|
140
|
+
|
|
141
|
+
series = []
|
|
142
|
+
colors = []
|
|
143
|
+
stroke: dict[str, Any] = {'width': [], 'dashArray': []}
|
|
144
|
+
markers = []
|
|
145
|
+
|
|
146
|
+
for serie in self.y_axis:
|
|
147
|
+
modified_serie: dict[str, Any] = {
|
|
148
|
+
'name': serie.label,
|
|
149
|
+
}
|
|
150
|
+
if serie.serie_type == ChartDataSerieType.SCATTER:
|
|
151
|
+
modified_serie['data'] = [{'x': item.x, 'y': item.y} for item in serie.data]
|
|
152
|
+
modified_serie['type'] = 'scatter'
|
|
153
|
+
stroke['width'].append(0)
|
|
154
|
+
markers.append(10)
|
|
155
|
+
else:
|
|
156
|
+
modified_serie['data'] = [{'x': self.x_axis.data[i], 'y': item} for i, item in enumerate(serie.data)]
|
|
157
|
+
|
|
158
|
+
if serie.serie_type is not ChartDataSerieType.NONE:
|
|
159
|
+
modified_serie['type'] = serie.serie_type.value
|
|
160
|
+
else:
|
|
161
|
+
modified_serie['type'] = 'column'
|
|
162
|
+
|
|
163
|
+
if serie.dashed and serie.serie_type == ChartDataSerieType.LINE:
|
|
164
|
+
stroke['dashArray'].append(5)
|
|
165
|
+
else:
|
|
166
|
+
stroke['dashArray'].append(0)
|
|
167
|
+
|
|
168
|
+
stroke['width'].append(3)
|
|
169
|
+
markers.append(0)
|
|
170
|
+
|
|
171
|
+
series.append(modified_serie)
|
|
172
|
+
|
|
173
|
+
if serie.serie_type == ChartDataSerieType.AREA:
|
|
174
|
+
color = convert_to_rgba(serie.color)
|
|
175
|
+
colors.append(f'rgba({color[0]}, {color[1]}, {color[2]}, 0.5)')
|
|
176
|
+
else:
|
|
177
|
+
colors.append(serie.color)
|
|
178
|
+
|
|
179
|
+
config = {
|
|
180
|
+
'series': series,
|
|
181
|
+
'colors': colors,
|
|
182
|
+
'xaxis': {
|
|
183
|
+
'type': self.x_axis.data_type.value,
|
|
184
|
+
'title': {
|
|
185
|
+
'text': self.x_axis.label,
|
|
186
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
'dataLabels': {'enabled': False},
|
|
190
|
+
'title': {
|
|
191
|
+
'text': self.title,
|
|
192
|
+
'align': self.align.value,
|
|
193
|
+
'style': {'fontFamily': 'Fira Sans Condensed', 'fontSize': '20px', 'fontWeight': 'normal'},
|
|
194
|
+
},
|
|
195
|
+
'markers': {'size': markers},
|
|
196
|
+
'fill': {'type': 'solid'},
|
|
197
|
+
'stroke': stroke,
|
|
198
|
+
'chart': {'animations': {'enabled': False}, 'toolbar': {'show': False}, 'zoom': {'enabled': False}},
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return config
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"""HTML chart"""
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
from typing import Any, Dict
|
|
5
|
-
|
|
6
|
-
from pydantic import BaseModel, Field
|
|
7
|
-
|
|
8
|
-
if sys.version_info >= (3, 11):
|
|
9
|
-
from typing import Self
|
|
10
|
-
else:
|
|
11
|
-
from typing_extensions import Self
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class HTMLChart(BaseModel):
|
|
15
|
-
"""HTML chart configuration"""
|
|
16
|
-
|
|
17
|
-
content: str = Field(description='HTML content of the chart', default='<p>N/A</p>')
|
|
18
|
-
title: str = Field(description='Title of the chart', default='Chart')
|
|
19
|
-
|
|
20
|
-
def render(self: Self) -> dict[str, Any]:
|
|
21
|
-
"""
|
|
22
|
-
Render chart to a graphic Library.
|
|
23
|
-
|
|
24
|
-
:param technology: The technology to use to render the chart.
|
|
25
|
-
:type technology: ChartRenderTechnology
|
|
26
|
-
|
|
27
|
-
:return: The configuration of the chart.
|
|
28
|
-
:rtype: dict[str, Any]
|
|
29
|
-
"""
|
|
30
|
-
return {'library': 'HTML', 'configuration': self._render_html()}
|
|
31
|
-
|
|
32
|
-
def _render_html(self: Self) -> dict[str, Any]:
|
|
33
|
-
"""
|
|
34
|
-
Converts the configuration of the chart to HTML render engine.
|
|
35
|
-
"""
|
|
36
|
-
config = {'content': self.content, 'title': self.title}
|
|
37
|
-
|
|
38
|
-
return config
|
|
1
|
+
"""HTML chart"""
|
|
2
|
+
|
|
3
|
+
import sys
|
|
4
|
+
from typing import Any, Dict
|
|
5
|
+
|
|
6
|
+
from pydantic import BaseModel, Field
|
|
7
|
+
|
|
8
|
+
if sys.version_info >= (3, 11):
|
|
9
|
+
from typing import Self
|
|
10
|
+
else:
|
|
11
|
+
from typing_extensions import Self
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class HTMLChart(BaseModel):
|
|
15
|
+
"""HTML chart configuration"""
|
|
16
|
+
|
|
17
|
+
content: str = Field(description='HTML content of the chart', default='<p>N/A</p>')
|
|
18
|
+
title: str = Field(description='Title of the chart', default='Chart')
|
|
19
|
+
|
|
20
|
+
def render(self: Self) -> dict[str, Any]:
|
|
21
|
+
"""
|
|
22
|
+
Render chart to a graphic Library.
|
|
23
|
+
|
|
24
|
+
:param technology: The technology to use to render the chart.
|
|
25
|
+
:type technology: ChartRenderTechnology
|
|
26
|
+
|
|
27
|
+
:return: The configuration of the chart.
|
|
28
|
+
:rtype: dict[str, Any]
|
|
29
|
+
"""
|
|
30
|
+
return {'library': 'HTML', 'configuration': self._render_html()}
|
|
31
|
+
|
|
32
|
+
def _render_html(self: Self) -> dict[str, Any]:
|
|
33
|
+
"""
|
|
34
|
+
Converts the configuration of the chart to HTML render engine.
|
|
35
|
+
"""
|
|
36
|
+
config = {'content': self.content, 'title': self.title}
|
|
37
|
+
|
|
38
|
+
return config
|