Skip to content

Commit b818961

Browse files
authored
adjust rechart types (#5336)
* adjust rechart types * remove Component as type for now
1 parent 12fc9f6 commit b818961

5 files changed

Lines changed: 38 additions & 40 deletions

File tree

pyi_hashes.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"reflex/components/datadisplay/code.pyi": "651fc3d417b998eb1c3d072328f505d0",
2626
"reflex/components/datadisplay/dataeditor.pyi": "601c59f3ced6ab94fcf5527b90472a4f",
2727
"reflex/components/datadisplay/shiki_code_block.pyi": "ac16fd6c23eef7ce0185437ecf2d529d",
28-
"reflex/components/el/__init__.pyi": "09042a2db5e0637e99b5173430600522",
28+
"reflex/components/el/__init__.pyi": "f07f5957ca4dc3d95ffdc2ddb75fe2f8",
2929
"reflex/components/el/element.pyi": "323cfb5d67d8ccb58ac36c7cc7641dc3",
3030
"reflex/components/el/elements/__init__.pyi": "baeddd04d4d3a82799420b2a6df368f6",
3131
"reflex/components/el/elements/base.pyi": "697cd6716e3b1127b35299435c3d4e69",
@@ -114,12 +114,12 @@
114114
"reflex/components/react_player/audio.pyi": "bd7e024d39ac641f8279ee0f6afd7985",
115115
"reflex/components/react_player/react_player.pyi": "40db798bcb7fa40207d24f49722135ae",
116116
"reflex/components/react_player/video.pyi": "22d84a7f57be13ece90cb30536d76c7d",
117-
"reflex/components/recharts/__init__.pyi": "a52c9055e37c6ee25ded15688d45e8a5",
118-
"reflex/components/recharts/cartesian.pyi": "5f893a3a6b1428a463cbbc4db5aa8097",
117+
"reflex/components/recharts/__init__.pyi": "a060a4abcd018165bc499173e723cf9e",
118+
"reflex/components/recharts/cartesian.pyi": "601e1acb0ad6bd93ce371d763220aabe",
119119
"reflex/components/recharts/charts.pyi": "2f0a39f9c02de83d9e2d97763b4411af",
120120
"reflex/components/recharts/general.pyi": "06d0e97776cc82b946fed465ab36fba4",
121-
"reflex/components/recharts/polar.pyi": "7c445e98c1d0c95868411173de8fe85e",
122-
"reflex/components/recharts/recharts.pyi": "f2739c20a27990a571d16133a40a0878",
121+
"reflex/components/recharts/polar.pyi": "77ca6e0d992f5d5c0479de73db4f71ba",
122+
"reflex/components/recharts/recharts.pyi": "bbaec232c2da035b31b5d0e3888f4801",
123123
"reflex/components/sonner/toast.pyi": "6dc6d5d05d9a8d7d364c0326fb2e6503",
124124
"reflex/components/suneditor/editor.pyi": "0a6dcab61cc2d750488601e3808080d9",
125125
"reflex/experimental/layout.pyi": "fb4c52b954431d9a927fbdd612b562eb"

reflex/components/recharts/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@
9090
],
9191
"recharts": [
9292
"LiteralAnimationEasing",
93-
"LiteralAreaType",
9493
"LiteralAxisType",
9594
"LiteralBarChartStackOffset",
9695
"LiteralComposedChartBaseValue",
96+
"LiteralCurveType",
9797
"LiteralDirection",
9898
"LiteralGridType",
9999
"LiteralIconType",

reflex/components/recharts/cartesian.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
from reflex.vars.base import LiteralVar, Var
1212

1313
from .recharts import (
14+
ACTIVE_DOT_TYPE,
1415
LiteralAnimationEasing,
15-
LiteralAreaType,
16+
LiteralCurveType,
1617
LiteralDirection,
1718
LiteralIfOverflow,
1819
LiteralInterval,
@@ -89,7 +90,7 @@ class Axis(Recharts):
8990
ticks: Var[Sequence[str | int]]
9091

9192
# If set false, no ticks will be drawn.
92-
tick: Var[bool]
93+
tick: Var[bool | dict]
9394

9495
# The count of axis ticks. Not used if 'type' is 'category'. Default: 5
9596
tick_count: Var[int]
@@ -275,6 +276,9 @@ class Cartesian(Recharts):
275276
# The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'star' | 'triangle' | 'wye' | 'none' optional
276277
legend_type: Var[LiteralLegendType]
277278

279+
# If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
280+
label: Var[bool | dict[str, Any]]
281+
278282
# If set false, animation of bar will be disabled. Default: True
279283
is_animation_active: Var[bool]
280284

@@ -341,24 +345,21 @@ class Area(Cartesian):
341345
fill: Var[str | Color] = LiteralVar.create(Color("accent", 5))
342346

343347
# The interpolation type of area. And customized interpolation function can be set to type. 'basis' | 'basisClosed' | 'basisOpen' | 'bumpX' | 'bumpY' | 'bump' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter'. Default: "monotone"
344-
type_: Var[LiteralAreaType] = LiteralVar.create("monotone")
348+
type_: Var[LiteralCurveType] = LiteralVar.create("monotone")
345349

346350
# If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
347-
dot: Var[bool | dict[str, Any]]
351+
dot: Var[ACTIVE_DOT_TYPE]
348352

349353
# The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {stroke: rx.color("accent", 2), fill: rx.color("accent", 10)}
350-
active_dot: Var[bool | dict[str, Any]] = LiteralVar.create(
354+
active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
351355
{
352356
"stroke": Color("accent", 2),
353357
"fill": Color("accent", 10),
354358
}
355359
)
356360

357-
# If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False
358-
label: Var[bool]
359-
360361
# The value which can describle the line, usually calculated internally.
361-
base_line: Var[str | Sequence[dict[str, Any]]]
362+
base_line: Var[int | Sequence[dict[str, Any]]]
362363

363364
# The coordinates of all the points in the area, usually calculated internally.
364365
points: Var[Sequence[dict[str, Any]]]
@@ -392,9 +393,6 @@ class Bar(Cartesian):
392393
# If false set, background of bars will not be drawn. If true set, background of bars will be drawn which have the props calculated internally. Default: False
393394
background: Var[bool]
394395

395-
# If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
396-
label: Var[bool]
397-
398396
# The stack id of bar, when two bars have the same value axis and same stack_id, then the two bars are stacked in order.
399397
stack_id: Var[str]
400398

@@ -431,7 +429,7 @@ class Line(Cartesian):
431429
alias = "RechartsLine"
432430

433431
# The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
434-
type_: Var[LiteralAreaType]
432+
type_: Var[LiteralCurveType]
435433

436434
# The color of the line stroke. Default: rx.color("accent", 9)
437435
stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9))
@@ -440,24 +438,21 @@ class Line(Cartesian):
440438
stroke_width: Var[str | int | float]
441439

442440
# The dot is shown when mouse enter a line chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 10), "fill": rx.color("accent", 4)}
443-
dot: Var[bool | dict[str, Any]] = LiteralVar.create(
441+
dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
444442
{
445443
"stroke": Color("accent", 10),
446444
"fill": Color("accent", 4),
447445
}
448446
)
449447

450448
# The dot is shown when user enter an area chart and this chart has tooltip. If false set, no active dot will not be drawn. If true set, active dot will be drawn which have the props calculated internally. Default: {"stroke": rx.color("accent", 2), "fill": rx.color("accent", 10)}
451-
active_dot: Var[bool | dict[str, Any]] = LiteralVar.create(
449+
active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
452450
{
453451
"stroke": Color("accent", 2),
454452
"fill": Color("accent", 10),
455453
}
456454
)
457455

458-
# If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
459-
label: Var[bool]
460-
461456
# Hides the line when true, useful when toggling visibility state via legend. Default: False
462457
hide: Var[bool]
463458

@@ -849,10 +844,10 @@ class CartesianAxis(Grid):
849844
view_box: Var[dict[str, Any]]
850845

851846
# If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True
852-
axis_line: Var[bool]
847+
axis_line: Var[bool | dict]
853848

854849
# If set false, no ticks will be drawn.
855-
tick: Var[bool]
850+
tick: Var[bool | dict]
856851

857852
# If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True
858853
tick_line: Var[bool]

reflex/components/recharts/polar.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from reflex.vars.base import LiteralVar, Var
1212

1313
from .recharts import (
14+
ACTIVE_DOT_TYPE,
1415
LiteralAnimationEasing,
1516
LiteralGridType,
1617
LiteralLegendType,
@@ -65,10 +66,10 @@ class Pie(Recharts):
6566
legend_type: Var[LiteralLegendType]
6667

6768
# If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
68-
label: Var[bool] = Var.create(False)
69+
label: Var[bool | dict[str, Any]] = Var.create(False)
6970

7071
# If false set, label lines will not be drawn. If true set, label lines will be drawn which have the props calculated internally. Default: False
71-
label_line: Var[bool]
72+
label_line: Var[bool | dict[str, Any]]
7273

7374
# Valid children components
7475
_valid_children: ClassVar[list[str]] = ["Cell", "LabelList", "Bare"]
@@ -126,7 +127,7 @@ class Radar(Recharts):
126127
points: Var[Sequence[dict[str, Any]]]
127128

128129
# If false set, dots will not be drawn. Default: True
129-
dot: Var[bool]
130+
dot: Var[ACTIVE_DOT_TYPE]
130131

131132
# Stoke color. Default: rx.color("accent", 9)
132133
stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9))
@@ -141,7 +142,7 @@ class Radar(Recharts):
141142
legend_type: Var[LiteralLegendType]
142143

143144
# If false set, labels will not be drawn. Default: True
144-
label: Var[bool]
145+
label: Var[bool | dict[str, Any]]
145146

146147
# If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR
147148
is_animation_active: Var[bool]

reflex/components/recharts/recharts.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""A component that wraps a recharts lib."""
22

3-
from typing import Literal
3+
from typing import Any, Literal
44

55
from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
66

@@ -73,25 +73,25 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf):
7373
"center",
7474
]
7575
LiteralIconType = Literal[
76-
"line",
77-
"plainline",
78-
"square",
79-
"rect",
8076
"circle",
8177
"cross",
8278
"diamond",
79+
"line",
80+
"plainline",
81+
"rect",
82+
"square",
8383
"star",
8484
"triangle",
8585
"wye",
8686
]
8787
LiteralLegendType = Literal[
88-
"line",
89-
"plainline",
90-
"square",
91-
"rect",
9288
"circle",
9389
"cross",
9490
"diamond",
91+
"line",
92+
"plainline",
93+
"rect",
94+
"square",
9595
"star",
9696
"triangle",
9797
"wye",
@@ -103,7 +103,7 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf):
103103
LiteralBarChartStackOffset = Literal["expand", "none", "wiggle", "silhouette", "sign"]
104104
LiteralComposedChartBaseValue = Literal["dataMin", "dataMax", "auto"]
105105
LiteralAxisType = Literal["number", "category"]
106-
LiteralAreaType = Literal[
106+
LiteralCurveType = Literal[
107107
"basis",
108108
"basisClosed",
109109
"basisOpen",
@@ -126,3 +126,5 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf):
126126
"preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart"
127127
]
128128
LiteralSyncMethod = Literal["index", "value"]
129+
130+
ACTIVE_DOT_TYPE = bool | dict[str, Any]

0 commit comments

Comments
 (0)