Skip to content

Commit a754923

Browse files
committed
adjust rechart types
1 parent 9251be1 commit a754923

5 files changed

Lines changed: 44 additions & 44 deletions

File tree

pyi_hashes.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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": "eb44b706cdb45f4b8450ef5302a981ae",
117+
"reflex/components/recharts/__init__.pyi": "a060a4abcd018165bc499173e723cf9e",
118+
"reflex/components/recharts/cartesian.pyi": "d64def4f9372f837583bf1dab30eb35e",
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": "71fb8c747e56b4f6bc72bdade16c1385",
122+
"reflex/components/recharts/recharts.pyi": "24a35f769a10a51dbd6d4cbff3b2f071",
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: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
from collections.abc import Sequence
66
from typing import Any, ClassVar
77

8+
from reflex.components.component import Component
89
from reflex.constants import EventTriggers
910
from reflex.constants.colors import Color
1011
from reflex.event import EventHandler, no_args_event_spec
1112
from reflex.vars.base import LiteralVar, Var
1213

1314
from .recharts import (
15+
ACTIVE_DOT_TYPE,
1416
LiteralAnimationEasing,
15-
LiteralAreaType,
17+
LiteralCurveType,
1618
LiteralDirection,
1719
LiteralIfOverflow,
1820
LiteralInterval,
@@ -74,7 +76,7 @@ class Axis(Recharts):
7476
reversed: Var[bool]
7577

7678
# The label of axis, which appears next to the axis.
77-
label: Var[str | int | dict[str, Any]]
79+
label: Var[str | int | Component | dict[str, Any]]
7880

7981
# If 'auto' set, the scale function is decided by the type of chart, and the props type. 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'identity' | 'time' | 'band' | 'point' | 'ordinal' | 'quantile' | 'quantize' | 'utc' | 'sequential' | 'threshold'. Default: "auto"
8082
scale: Var[LiteralScale]
@@ -89,7 +91,7 @@ class Axis(Recharts):
8991
ticks: Var[Sequence[str | int]]
9092

9193
# If set false, no ticks will be drawn.
92-
tick: Var[bool]
94+
tick: Var[bool | dict | Component]
9395

9496
# The count of axis ticks. Not used if 'type' is 'category'. Default: 5
9597
tick_count: Var[int]
@@ -275,6 +277,9 @@ class Cartesian(Recharts):
275277
# 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
276278
legend_type: Var[LiteralLegendType]
277279

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

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

343348
# 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")
349+
type_: Var[LiteralCurveType] = LiteralVar.create("monotone")
345350

346351
# 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]]
352+
dot: Var[ACTIVE_DOT_TYPE]
348353

349354
# 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(
355+
active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
351356
{
352357
"stroke": Color("accent", 2),
353358
"fill": Color("accent", 10),
354359
}
355360
)
356361

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-
360362
# The value which can describle the line, usually calculated internally.
361-
base_line: Var[str | Sequence[dict[str, Any]]]
363+
base_line: Var[int | Sequence[dict[str, Any]]]
362364

363365
# The coordinates of all the points in the area, usually calculated internally.
364366
points: Var[Sequence[dict[str, Any]]]
@@ -392,9 +394,6 @@ class Bar(Cartesian):
392394
# 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
393395
background: Var[bool]
394396

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-
398397
# 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.
399398
stack_id: Var[str]
400399

@@ -431,7 +430,7 @@ class Line(Cartesian):
431430
alias = "RechartsLine"
432431

433432
# 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]
433+
type_: Var[LiteralCurveType]
435434

436435
# The color of the line stroke. Default: rx.color("accent", 9)
437436
stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9))
@@ -440,24 +439,21 @@ class Line(Cartesian):
440439
stroke_width: Var[int]
441440

442441
# 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(
442+
dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
444443
{
445444
"stroke": Color("accent", 10),
446445
"fill": Color("accent", 4),
447446
}
448447
)
449448

450449
# 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(
450+
active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create(
452451
{
453452
"stroke": Color("accent", 2),
454453
"fill": Color("accent", 10),
455454
}
456455
)
457456

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-
461457
# Hides the line when true, useful when toggling visibility state via legend. Default: False
462458
hide: Var[bool]
463459

@@ -661,7 +657,7 @@ class Reference(Recharts):
661657
if_overflow: Var[LiteralIfOverflow]
662658

663659
# If set a string or a number, default label will be drawn, and the option is content.
664-
label: Var[str | int]
660+
label: Var[str | int | Component]
665661

666662
# If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
667663
is_front: Var[bool]
@@ -849,10 +845,10 @@ class CartesianAxis(Grid):
849845
view_box: Var[dict[str, Any]]
850846

851847
# 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]
848+
axis_line: Var[bool | dict]
853849

854850
# If set false, no ticks will be drawn.
855-
tick: Var[bool]
851+
tick: Var[bool | dict | Component]
856852

857853
# If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True
858854
tick_line: Var[bool]
@@ -864,7 +860,7 @@ class CartesianAxis(Grid):
864860
interval: Var[LiteralInterval]
865861

866862
# If set a string or a number, default label will be drawn, and the option is content.
867-
label: Var[str | int]
863+
label: Var[str | int | Component]
868864

869865
# If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
870866
mirror: Var[bool]

reflex/components/recharts/polar.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
from collections.abc import Sequence
66
from typing import Any, ClassVar
77

8+
from reflex.components.component import Component
89
from reflex.constants import EventTriggers
910
from reflex.constants.colors import Color
1011
from reflex.event import EventHandler, no_args_event_spec
1112
from reflex.vars.base import LiteralVar, Var
1213

1314
from .recharts import (
15+
ACTIVE_DOT_TYPE,
1416
LiteralAnimationEasing,
1517
LiteralGridType,
1618
LiteralLegendType,
@@ -65,10 +67,10 @@ class Pie(Recharts):
6567
legend_type: Var[LiteralLegendType]
6668

6769
# 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)
70+
label: Var[bool | dict[str, Any] | Component] = Var.create(False)
6971

7072
# 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]
73+
label_line: Var[bool | dict[str, Any] | Component]
7274

7375
# Valid children components
7476
_valid_children: ClassVar[list[str]] = ["Cell", "LabelList", "Bare"]
@@ -126,7 +128,7 @@ class Radar(Recharts):
126128
points: Var[Sequence[dict[str, Any]]]
127129

128130
# If false set, dots will not be drawn. Default: True
129-
dot: Var[bool]
131+
dot: Var[ACTIVE_DOT_TYPE]
130132

131133
# Stoke color. Default: rx.color("accent", 9)
132134
stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9))
@@ -141,7 +143,7 @@ class Radar(Recharts):
141143
legend_type: Var[LiteralLegendType]
142144

143145
# If false set, labels will not be drawn. Default: True
144-
label: Var[bool]
146+
label: Var[bool | dict[str, Any] | Component]
145147

146148
# If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR
147149
is_animation_active: Var[bool]
@@ -190,10 +192,10 @@ class RadialBar(Recharts):
190192
legend_type: Var[LiteralLegendType]
191193

192194
# If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
193-
label: Var[bool | dict[str, Any]]
195+
label: Var[bool | dict[str, Any] | Component]
194196

195197
# If false set, background sector will not be drawn. Default: False
196-
background: Var[bool | dict[str, Any]]
198+
background: Var[bool | dict[str, Any] | Component]
197199

198200
# If set false, animation of radial bars will be disabled. Default: True
199201
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] | Component

0 commit comments

Comments
 (0)