reflex 0.2.9a2__py3-none-any.whl → 0.3.0a2__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 reflex might be problematic. Click here for more details.
- reflex/__init__.py +0 -1
- reflex/components/__init__.py +42 -15
- reflex/components/base/script.py +1 -1
- reflex/components/datadisplay/code.py +1 -1
- reflex/components/datadisplay/datatable.py +2 -2
- reflex/components/forms/debounce.py +1 -1
- reflex/components/forms/upload.py +1 -1
- reflex/components/graphing/__init__.py +1 -16
- reflex/components/graphing/plotly.py +2 -2
- reflex/components/graphing/recharts/__init__.py +41 -0
- reflex/components/graphing/recharts/cartesian.py +530 -0
- reflex/components/graphing/recharts/charts.py +456 -0
- reflex/components/graphing/recharts/general.py +166 -0
- reflex/components/graphing/recharts/polar.py +306 -0
- reflex/components/graphing/recharts/recharts.py +21 -0
- reflex/components/libs/react_player.py +1 -1
- reflex/components/media/icon.py +1 -1
- reflex/components/media/image.py +14 -5
- reflex/components/overlay/menu.py +26 -2
- reflex/components/typography/markdown.py +9 -5
- reflex/constants/installer.py +17 -16
- reflex/constants/style.py +1 -1
- reflex/event.py +12 -0
- reflex/utils/console.py +1 -1
- reflex/utils/exec.py +1 -1
- reflex/vars.py +6 -0
- {reflex-0.2.9a2.dist-info → reflex-0.3.0a2.dist-info}/METADATA +1 -1
- {reflex-0.2.9a2.dist-info → reflex-0.3.0a2.dist-info}/RECORD +31 -28
- reflex/.templates/web/bun.lockb +0 -0
- reflex/components/graphing/victory.py +0 -608
- reflex/components/graphing/victory.pyi +0 -308
- {reflex-0.2.9a2.dist-info → reflex-0.3.0a2.dist-info}/LICENSE +0 -0
- {reflex-0.2.9a2.dist-info → reflex-0.3.0a2.dist-info}/WHEEL +0 -0
- {reflex-0.2.9a2.dist-info → reflex-0.3.0a2.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
"""A module that defines the chart components in Recharts."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import Any, Dict, List, Union
|
|
5
|
+
|
|
6
|
+
from reflex.components.component import Component
|
|
7
|
+
from reflex.components.graphing.recharts.general import ResponsiveContainer
|
|
8
|
+
from reflex.constants import EventTriggers
|
|
9
|
+
from reflex.vars import Var
|
|
10
|
+
|
|
11
|
+
from .recharts import RechartsCharts
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ChartBase(RechartsCharts):
|
|
15
|
+
"""A component that wraps a Recharts charts."""
|
|
16
|
+
|
|
17
|
+
# The source data, in which each element is an object.
|
|
18
|
+
data: Var[List[Dict[str, Any]]]
|
|
19
|
+
|
|
20
|
+
# If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
|
|
21
|
+
sync_id: Var[str]
|
|
22
|
+
|
|
23
|
+
# When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
|
|
24
|
+
sync_method: Var[str]
|
|
25
|
+
|
|
26
|
+
# The width of chart container. String or Integer
|
|
27
|
+
width: Var[Union[str, int]] = "100%" # type: ignore
|
|
28
|
+
|
|
29
|
+
# The height of chart container.
|
|
30
|
+
height: Var[Union[str, int]] = "100%" # type: ignore
|
|
31
|
+
|
|
32
|
+
# The layout of area in the chart. 'horizontal' | 'vertical'
|
|
33
|
+
layout: Var[str]
|
|
34
|
+
|
|
35
|
+
# The sizes of whitespace around the chart.
|
|
36
|
+
margin: Var[Dict[str, Any]]
|
|
37
|
+
|
|
38
|
+
# The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
|
|
39
|
+
stack_offset: Var[str]
|
|
40
|
+
|
|
41
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
42
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
46
|
+
"""
|
|
47
|
+
return {
|
|
48
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
49
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
50
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
51
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@classmethod
|
|
55
|
+
def create(cls, *children, **props) -> Component:
|
|
56
|
+
"""Create a chart component.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
*children: The children of the chart component.
|
|
60
|
+
**props: The properties of the chart component.
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
The chart component wrapped in a responsive container.
|
|
64
|
+
"""
|
|
65
|
+
return ResponsiveContainer.create(
|
|
66
|
+
super().create(*children, **props),
|
|
67
|
+
width=props.pop("width", "100%"),
|
|
68
|
+
height=props.pop("height", "100%"),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class AreaChart(ChartBase):
|
|
73
|
+
"""An Area chart component in Recharts."""
|
|
74
|
+
|
|
75
|
+
tag = "AreaChart"
|
|
76
|
+
|
|
77
|
+
# The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
|
|
78
|
+
base_value: Var[Union[int, str]]
|
|
79
|
+
|
|
80
|
+
# The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape.
|
|
81
|
+
stack_offset: Var[str]
|
|
82
|
+
|
|
83
|
+
# Valid children components
|
|
84
|
+
valid_children: List[str] = [
|
|
85
|
+
"XAxis",
|
|
86
|
+
"YAxis",
|
|
87
|
+
"ReferenceArea",
|
|
88
|
+
"ReferenceDot",
|
|
89
|
+
"ReferenceLine",
|
|
90
|
+
"Brush",
|
|
91
|
+
"CartesianGrid",
|
|
92
|
+
"Legend",
|
|
93
|
+
"GraphingTooltip",
|
|
94
|
+
"Area",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class BarChart(ChartBase):
|
|
99
|
+
"""A Bar chart component in Recharts."""
|
|
100
|
+
|
|
101
|
+
tag = "BarChart"
|
|
102
|
+
|
|
103
|
+
# The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
|
|
104
|
+
bar_category_gap: Var[Union[str, int]] # type: ignore
|
|
105
|
+
|
|
106
|
+
# The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
|
|
107
|
+
bar_gap: Var[Union[str, int]] # type: ignore
|
|
108
|
+
|
|
109
|
+
# The width of all the bars in the chart. Number
|
|
110
|
+
bar_size: Var[int]
|
|
111
|
+
|
|
112
|
+
# The maximum width of all the bars in a horizontal BarChart, or maximum height in a vertical BarChart.
|
|
113
|
+
max_bar_size: Var[int]
|
|
114
|
+
|
|
115
|
+
# The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape.
|
|
116
|
+
stack_offset: Var[str]
|
|
117
|
+
|
|
118
|
+
# If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
|
|
119
|
+
reverse_stack_order: Var[bool]
|
|
120
|
+
|
|
121
|
+
# Valid children components
|
|
122
|
+
valid_children: List[str] = [
|
|
123
|
+
"XAxis",
|
|
124
|
+
"YAxis",
|
|
125
|
+
"ReferenceArea",
|
|
126
|
+
"ReferenceDot",
|
|
127
|
+
"ReferenceLine",
|
|
128
|
+
"Brush",
|
|
129
|
+
"CartesianGrid",
|
|
130
|
+
"Legend",
|
|
131
|
+
"GraphingTooltip",
|
|
132
|
+
"Bar",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class LineChart(ChartBase):
|
|
137
|
+
"""A Line chart component in Recharts."""
|
|
138
|
+
|
|
139
|
+
tag = "LineChart"
|
|
140
|
+
|
|
141
|
+
# Valid children components
|
|
142
|
+
valid_children: List[str] = [
|
|
143
|
+
"XAxis",
|
|
144
|
+
"YAxis",
|
|
145
|
+
"ReferenceArea",
|
|
146
|
+
"ReferenceDot",
|
|
147
|
+
"ReferenceLine",
|
|
148
|
+
"Brush",
|
|
149
|
+
"CartesianGrid",
|
|
150
|
+
"Legend",
|
|
151
|
+
"GraphingTooltip",
|
|
152
|
+
"Line",
|
|
153
|
+
]
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class ComposedChart(ChartBase):
|
|
157
|
+
"""A Composed chart component in Recharts."""
|
|
158
|
+
|
|
159
|
+
tag = "ComposedChart"
|
|
160
|
+
|
|
161
|
+
# The base value of area. Number | 'dataMin' | 'dataMax' | 'auto'
|
|
162
|
+
base_value: Var[Union[int, str]]
|
|
163
|
+
|
|
164
|
+
# The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
|
|
165
|
+
bar_category_gap: Var[Union[str, int]] # type: ignore
|
|
166
|
+
|
|
167
|
+
# The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
|
|
168
|
+
bar_gap: Var[int]
|
|
169
|
+
|
|
170
|
+
# The width of all the bars in the chart. Number
|
|
171
|
+
bar_size: Var[int]
|
|
172
|
+
|
|
173
|
+
# If false set, stacked items will be rendered left to right. If true set, stacked items will be rendered right to left. (Render direction affects SVG layering, not x position.)
|
|
174
|
+
reverse_stack_order: Var[bool]
|
|
175
|
+
|
|
176
|
+
# Valid children components
|
|
177
|
+
valid_children: List[str] = [
|
|
178
|
+
"XAxis",
|
|
179
|
+
"YAxis",
|
|
180
|
+
"ReferenceArea",
|
|
181
|
+
"ReferenceDot",
|
|
182
|
+
"ReferenceLine",
|
|
183
|
+
"Brush",
|
|
184
|
+
"CartesianGrid",
|
|
185
|
+
"Legend",
|
|
186
|
+
"GraphingTooltip",
|
|
187
|
+
"Area",
|
|
188
|
+
"Line",
|
|
189
|
+
"Bar",
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class PieChart(ChartBase):
|
|
194
|
+
"""A Pie chart component in Recharts."""
|
|
195
|
+
|
|
196
|
+
tag = "PieChart"
|
|
197
|
+
|
|
198
|
+
# Valid children components
|
|
199
|
+
valid_children: List[str] = [
|
|
200
|
+
"PolarAngleAxis",
|
|
201
|
+
"PolarRadiusAxis",
|
|
202
|
+
"PolarGrid",
|
|
203
|
+
"Legend",
|
|
204
|
+
"GraphingTooltip",
|
|
205
|
+
"Pie",
|
|
206
|
+
]
|
|
207
|
+
|
|
208
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
209
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
210
|
+
|
|
211
|
+
Returns:
|
|
212
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
213
|
+
"""
|
|
214
|
+
return {
|
|
215
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
216
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
217
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
class RadarChart(ChartBase):
|
|
222
|
+
"""A Radar chart component in Recharts."""
|
|
223
|
+
|
|
224
|
+
tag = "RadarChart"
|
|
225
|
+
|
|
226
|
+
# The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
|
|
227
|
+
cx: Var[Union[int, str]]
|
|
228
|
+
|
|
229
|
+
# The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
|
|
230
|
+
cy: Var[Union[int, str]]
|
|
231
|
+
|
|
232
|
+
# The angle of first radial direction line.
|
|
233
|
+
start_angle: Var[int]
|
|
234
|
+
|
|
235
|
+
# The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
|
|
236
|
+
end_angle: Var[int]
|
|
237
|
+
|
|
238
|
+
# The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
|
|
239
|
+
inner_radius: Var[Union[int, str]]
|
|
240
|
+
|
|
241
|
+
# The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
|
|
242
|
+
outer_radius: Var[Union[int, str]]
|
|
243
|
+
|
|
244
|
+
# Valid children components
|
|
245
|
+
valid_children: List[str] = [
|
|
246
|
+
"PolarAngleAxis",
|
|
247
|
+
"PolarRadiusAxis",
|
|
248
|
+
"PolarGrid",
|
|
249
|
+
"Legend",
|
|
250
|
+
"GraphingTooltip",
|
|
251
|
+
"Radar",
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
255
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
259
|
+
"""
|
|
260
|
+
return {
|
|
261
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
262
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
263
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
264
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
class RadialBarChart(ChartBase):
|
|
269
|
+
"""A RadialBar chart component in Recharts."""
|
|
270
|
+
|
|
271
|
+
tag = "RadialBarChart"
|
|
272
|
+
|
|
273
|
+
# The The x-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of width. Number | Percentage
|
|
274
|
+
cx: Var[Union[int, str]]
|
|
275
|
+
|
|
276
|
+
# The The y-coordinate of center. If set a percentage, the final value is obtained by multiplying the percentage of height. Number | Percentage
|
|
277
|
+
cy: Var[Union[int, str]]
|
|
278
|
+
|
|
279
|
+
# The angle of first radial direction line.
|
|
280
|
+
start_angle: Var[int]
|
|
281
|
+
|
|
282
|
+
# The angle of last point in the circle which should be startAngle - 360 or startAngle + 360. We'll calculate the direction of chart by 'startAngle' and 'endAngle'.
|
|
283
|
+
end_angle: Var[int]
|
|
284
|
+
|
|
285
|
+
# The inner radius of first circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
|
|
286
|
+
inner_radius: Var[Union[int, str]]
|
|
287
|
+
|
|
288
|
+
# The outer radius of last circle grid. If set a percentage, the final value is obtained by multiplying the percentage of maxRadius which is calculated by the width, height, cx, cy. Number | Percentage
|
|
289
|
+
outer_radius: Var[Union[int, str]]
|
|
290
|
+
|
|
291
|
+
# The gap between two bar categories, which can be a percent value or a fixed value. Percentage | Number
|
|
292
|
+
bar_category_gap: Var[Union[int, str]]
|
|
293
|
+
|
|
294
|
+
# The gap between two bars in the same category, which can be a percent value or a fixed value. Percentage | Number
|
|
295
|
+
bar_gap: Var[str]
|
|
296
|
+
|
|
297
|
+
# The size of each bar. If the barSize is not specified, the size of bar will be calculated by the barCategoryGap, barGap and the quantity of bar groups.
|
|
298
|
+
bar_size: Var[int]
|
|
299
|
+
|
|
300
|
+
# Valid children components
|
|
301
|
+
valid_children: List[str] = [
|
|
302
|
+
"PolarAngleAxis",
|
|
303
|
+
"PolarRadiusAxis",
|
|
304
|
+
"PolarGrid",
|
|
305
|
+
"Legend",
|
|
306
|
+
"GraphingTooltip",
|
|
307
|
+
"RadialBar",
|
|
308
|
+
]
|
|
309
|
+
|
|
310
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
311
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
315
|
+
"""
|
|
316
|
+
return {
|
|
317
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
318
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
319
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
320
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
class ScatterChart(ChartBase):
|
|
325
|
+
"""A Scatter chart component in Recharts."""
|
|
326
|
+
|
|
327
|
+
tag = "ScatterChart"
|
|
328
|
+
|
|
329
|
+
# Valid children components
|
|
330
|
+
valid_children: List[str] = [
|
|
331
|
+
"XAxis",
|
|
332
|
+
"YAxis",
|
|
333
|
+
"ZAxis",
|
|
334
|
+
"ReferenceArea",
|
|
335
|
+
"ReferenceDot",
|
|
336
|
+
"ReferenceLine",
|
|
337
|
+
"Brush",
|
|
338
|
+
"CartesianGrid",
|
|
339
|
+
"Legend",
|
|
340
|
+
"GraphingTooltip",
|
|
341
|
+
"Scatter",
|
|
342
|
+
]
|
|
343
|
+
|
|
344
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
345
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
346
|
+
|
|
347
|
+
Returns:
|
|
348
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
349
|
+
"""
|
|
350
|
+
return {
|
|
351
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
352
|
+
EventTriggers.ON_MOUSE_OVER: lambda: [],
|
|
353
|
+
EventTriggers.ON_MOUSE_OUT: lambda: [],
|
|
354
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
355
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
356
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
class FunnelChart(RechartsCharts):
|
|
361
|
+
"""A Funnel chart component in Recharts."""
|
|
362
|
+
|
|
363
|
+
tag = "FunnelChart"
|
|
364
|
+
|
|
365
|
+
# The source data, in which each element is an object.
|
|
366
|
+
data: Var[List[Dict[str, Any]]]
|
|
367
|
+
|
|
368
|
+
# If any two categorical charts(rx.line_chart, rx.area_chart, rx.bar_chart, rx.composed_chart) have the same sync_id, these two charts can sync the position GraphingTooltip, and the start_index, end_index of Brush.
|
|
369
|
+
sync_id: Var[str]
|
|
370
|
+
|
|
371
|
+
# When sync_id is provided, allows customisation of how the charts will synchronize GraphingTooltips and brushes. Using 'index' (default setting), other charts will reuse current datum's index within the data array. In cases where data does not have the same length, this might yield unexpected results. In that case use 'value' which will try to match other charts values, or a fully custom function which will receive tick, data as argument and should return an index. 'index' | 'value' | function
|
|
372
|
+
sync_method: Var[str]
|
|
373
|
+
|
|
374
|
+
# The width of chart container. String or Integer
|
|
375
|
+
width: Var[Union[str, int]] = "100%" # type: ignore
|
|
376
|
+
|
|
377
|
+
# The height of chart container.
|
|
378
|
+
height: Var[Union[str, int]] = "100%" # type: ignore
|
|
379
|
+
|
|
380
|
+
# The layout of area in the chart. 'horizontal' | 'vertical'
|
|
381
|
+
layout: Var[str]
|
|
382
|
+
|
|
383
|
+
# The sizes of whitespace around the chart.
|
|
384
|
+
margin: Var[Dict[str, Any]]
|
|
385
|
+
|
|
386
|
+
# The type of offset function used to generate the lower and upper values in the series array. The four types are built-in offsets in d3-shape. 'expand' | 'none' | 'wiggle' | 'silhouette'
|
|
387
|
+
stack_offset: Var[str]
|
|
388
|
+
|
|
389
|
+
# The layout of bars in the chart. centeric
|
|
390
|
+
layout: Var[str]
|
|
391
|
+
|
|
392
|
+
# Valid children components
|
|
393
|
+
valid_children: List[str] = ["Legend", "GraphingTooltip", "Funnel"]
|
|
394
|
+
|
|
395
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
396
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
397
|
+
|
|
398
|
+
Returns:
|
|
399
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
400
|
+
"""
|
|
401
|
+
return {
|
|
402
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
403
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
404
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
405
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class Treemap(RechartsCharts):
|
|
410
|
+
"""A Treemap chart component in Recharts."""
|
|
411
|
+
|
|
412
|
+
tag = "Treemap"
|
|
413
|
+
|
|
414
|
+
# The width of chart container. String or Integer
|
|
415
|
+
width: Var[Union[str, int]] = "100%" # type: ignore
|
|
416
|
+
|
|
417
|
+
# The height of chart container.
|
|
418
|
+
height: Var[Union[str, int]] = "100%" # type: ignore
|
|
419
|
+
|
|
420
|
+
# data of treemap. Array
|
|
421
|
+
data: Var[List[Dict[str, Any]]]
|
|
422
|
+
|
|
423
|
+
# The key of a group of data which should be unique in a treemap. String | Number | Function
|
|
424
|
+
data_key: Var[Union[str, int]]
|
|
425
|
+
|
|
426
|
+
# The treemap will try to keep every single rectangle's aspect ratio near the aspectRatio given. Number
|
|
427
|
+
aspect_ratio: Var[int]
|
|
428
|
+
|
|
429
|
+
# If set false, animation of area will be disabled.
|
|
430
|
+
is_animation_active: Var[bool]
|
|
431
|
+
|
|
432
|
+
# Specifies when the animation should begin, the unit of this option is ms.
|
|
433
|
+
animation_begin: Var[int]
|
|
434
|
+
|
|
435
|
+
# Specifies the duration of animation, the unit of this option is ms.
|
|
436
|
+
animation_duration: Var[int]
|
|
437
|
+
|
|
438
|
+
# The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'
|
|
439
|
+
animation_easing: Var[str]
|
|
440
|
+
|
|
441
|
+
@classmethod
|
|
442
|
+
def create(cls, *children, **props) -> Component:
|
|
443
|
+
"""Create a chart component.
|
|
444
|
+
|
|
445
|
+
Args:
|
|
446
|
+
*children: The children of the chart component.
|
|
447
|
+
**props: The properties of the chart component.
|
|
448
|
+
|
|
449
|
+
Returns:
|
|
450
|
+
The Treemap component wrapped in a responsive container.
|
|
451
|
+
"""
|
|
452
|
+
return ResponsiveContainer.create(
|
|
453
|
+
super().create(*children, **props),
|
|
454
|
+
width=props.pop("width", "100%"),
|
|
455
|
+
height=props.pop("height", "100%"),
|
|
456
|
+
)
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""General components for Recharts."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from typing import Any, Dict, List, Union
|
|
5
|
+
|
|
6
|
+
from reflex.constants import EventTriggers
|
|
7
|
+
from reflex.vars import Var
|
|
8
|
+
|
|
9
|
+
from .recharts import Recharts
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ResponsiveContainer(Recharts):
|
|
13
|
+
"""A base class for responsive containers in Recharts."""
|
|
14
|
+
|
|
15
|
+
tag = "ResponsiveContainer"
|
|
16
|
+
|
|
17
|
+
# The aspect ratio of the container. The final aspect ratio of the SVG element will be (width / height) * aspect. Number
|
|
18
|
+
aspect: Var[int]
|
|
19
|
+
|
|
20
|
+
# The width of chart container. Can be a number or string
|
|
21
|
+
width: Var[Union[int, str]]
|
|
22
|
+
|
|
23
|
+
# The height of chart container. Number
|
|
24
|
+
height: Var[Union[int, str]]
|
|
25
|
+
|
|
26
|
+
# The minimum width of chart container.
|
|
27
|
+
min_width: Var[int]
|
|
28
|
+
|
|
29
|
+
# The minimum height of chart container. Number
|
|
30
|
+
min_height: Var[int]
|
|
31
|
+
|
|
32
|
+
# If specified a positive number, debounced function will be used to handle the resize event.
|
|
33
|
+
debounce: Var[int]
|
|
34
|
+
|
|
35
|
+
# Valid children components
|
|
36
|
+
valid_children: List[str] = [
|
|
37
|
+
"AreaChart",
|
|
38
|
+
"BarChart",
|
|
39
|
+
"LineChart",
|
|
40
|
+
"PieChart",
|
|
41
|
+
"RadarChart",
|
|
42
|
+
"RadialBarChart",
|
|
43
|
+
"ScatterChart",
|
|
44
|
+
"Treemap",
|
|
45
|
+
"ComposedChart",
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class Legend(Recharts):
|
|
50
|
+
"""A Legend component in Recharts."""
|
|
51
|
+
|
|
52
|
+
tag = "Legend"
|
|
53
|
+
|
|
54
|
+
# The width of legend container. Number
|
|
55
|
+
width: Var[int]
|
|
56
|
+
|
|
57
|
+
# The height of legend container. Number
|
|
58
|
+
height: Var[int]
|
|
59
|
+
|
|
60
|
+
# The layout of legend items. 'horizontal' | 'vertical'
|
|
61
|
+
layout: Var[str]
|
|
62
|
+
|
|
63
|
+
# The alignment of legend items in 'horizontal' direction, which can be 'left', 'center', 'right'.
|
|
64
|
+
align: Var[str]
|
|
65
|
+
|
|
66
|
+
# The alignment of legend items in 'vertical' direction, which can be 'top', 'middle', 'bottom'.
|
|
67
|
+
vertical_align: Var[str]
|
|
68
|
+
|
|
69
|
+
# The size of icon in each legend item.
|
|
70
|
+
icon_size: Var[int]
|
|
71
|
+
|
|
72
|
+
# The type of icon in each legend item. 'line' | 'plainline' | 'square' | 'rect' | 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye'
|
|
73
|
+
icon_type: Var[str]
|
|
74
|
+
|
|
75
|
+
# The width of chart container, usually calculated internally.
|
|
76
|
+
chart_width: Var[int]
|
|
77
|
+
|
|
78
|
+
# The height of chart container, usually calculated internally.
|
|
79
|
+
chart_height: Var[int]
|
|
80
|
+
|
|
81
|
+
# The margin of chart container, usually calculated internally.
|
|
82
|
+
margin: Var[Dict[str, Any]]
|
|
83
|
+
|
|
84
|
+
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
|
|
85
|
+
"""Get the event triggers that pass the component's value to the handler.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
A dict mapping the event trigger to the var that is passed to the handler.
|
|
89
|
+
"""
|
|
90
|
+
return {
|
|
91
|
+
EventTriggers.ON_CLICK: lambda: [],
|
|
92
|
+
EventTriggers.ON_MOUSE_MOVE: lambda: [],
|
|
93
|
+
EventTriggers.ON_MOUSE_OVER: lambda: [],
|
|
94
|
+
EventTriggers.ON_MOUSE_OUT: lambda: [],
|
|
95
|
+
EventTriggers.ON_MOUSE_ENTER: lambda: [],
|
|
96
|
+
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class GraphingTooltip(Recharts):
|
|
101
|
+
"""A Tooltip component in Recharts."""
|
|
102
|
+
|
|
103
|
+
tag = "Tooltip"
|
|
104
|
+
|
|
105
|
+
# The separator between name and value.
|
|
106
|
+
separator: Var[str]
|
|
107
|
+
|
|
108
|
+
# The offset size of tooltip. Number
|
|
109
|
+
offset: Var[int]
|
|
110
|
+
|
|
111
|
+
# When an item of the payload has value null or undefined, this item won't be displayed.
|
|
112
|
+
filter_null: Var[bool]
|
|
113
|
+
|
|
114
|
+
# If set false, no cursor will be drawn when tooltip is active.
|
|
115
|
+
cursor: Var[bool]
|
|
116
|
+
|
|
117
|
+
# The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally.
|
|
118
|
+
view_box: Var[Dict[str, Any]]
|
|
119
|
+
|
|
120
|
+
# If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally.
|
|
121
|
+
active: Var[bool]
|
|
122
|
+
|
|
123
|
+
# If this field is set, the tooltip position will be fixed and will not move anymore.
|
|
124
|
+
position: Var[Dict[str, Any]]
|
|
125
|
+
|
|
126
|
+
# The coordinate of tooltip which is usually calculated internally.
|
|
127
|
+
coordinate: Var[Dict[str, Any]]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
class Label(Recharts):
|
|
131
|
+
"""A Label component in Recharts."""
|
|
132
|
+
|
|
133
|
+
tag = "Label"
|
|
134
|
+
|
|
135
|
+
# The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally.
|
|
136
|
+
view_box: Var[Dict[str, Any]]
|
|
137
|
+
|
|
138
|
+
# The value of label, which can be specified by this props or the children of <Label />
|
|
139
|
+
value: Var[str]
|
|
140
|
+
|
|
141
|
+
# The offset of label which can be specified by this props or the children of <Label />
|
|
142
|
+
offset: Var[int]
|
|
143
|
+
|
|
144
|
+
# The position of label which can be specified by this props or the children of <Label />
|
|
145
|
+
position: Var[str]
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class LabelList(Recharts):
|
|
149
|
+
"""A LabelList component in Recharts."""
|
|
150
|
+
|
|
151
|
+
tag = "LabelList"
|
|
152
|
+
|
|
153
|
+
# The key of a group of label values in data.
|
|
154
|
+
data_key: Var[Union[str, int]]
|
|
155
|
+
|
|
156
|
+
# The position of each label relative to it view box。op" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
|
|
157
|
+
position: Var[str]
|
|
158
|
+
|
|
159
|
+
# The offset to the specified "position"
|
|
160
|
+
offset: Var[int]
|
|
161
|
+
|
|
162
|
+
# Color of the fill
|
|
163
|
+
fill: Var[str]
|
|
164
|
+
|
|
165
|
+
# Color of the stroke
|
|
166
|
+
stroke: Var[str]
|