This commit is contained in:
Khaleel Al-Adhami 2024-10-10 14:36:39 -07:00
commit 086f273991
15 changed files with 375 additions and 185 deletions

View File

@ -257,15 +257,39 @@ class Cartesian(Recharts):
# The key of a group of data which should be unique in an area chart. # The key of a group of data which should be unique in an area chart.
data_key: Var[Union[str, int]] data_key: Var[Union[str, int]]
# The id of x-axis which is corresponding to the data. # The id of x-axis which is corresponding to the data. Default: 0
x_axis_id: Var[Union[str, int]] x_axis_id: Var[Union[str, int]]
# The id of y-axis which is corresponding to the data. # The id of y-axis which is corresponding to the data. Default: 0
y_axis_id: Var[Union[str, int]] y_axis_id: Var[Union[str, int]]
# 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 # 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
legend_type: Var[LiteralLegendType] legend_type: Var[LiteralLegendType]
# If set false, animation of bar will be disabled. Default: True
is_animation_active: Var[bool]
# Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int]
# Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int]
# The type of easing function. Default: "ease"
animation_easing: Var[LiteralAnimationEasing]
# The unit of data. This option will be used in tooltip.
unit: Var[Union[str, int]]
# The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
name: Var[Union[str, int]]
# The customized event handler of animation start
on_animation_start: EventHandler[lambda: []]
# The customized event handler of animation end
on_animation_end: EventHandler[lambda: []]
# The customized event handler of click on the component in this group # The customized event handler of click on the component in this group
on_click: EventHandler[empty_event] on_click: EventHandler[empty_event]
@ -528,30 +552,33 @@ class Funnel(Recharts):
# The source data, in which each element is an object. # The source data, in which each element is an object.
data: Var[List[Dict[str, Any]]] data: Var[List[Dict[str, Any]]]
# The key of a group of data which should be unique in an area chart. # The key or getter of a group of data which should be unique in a FunnelChart.
data_key: Var[Union[str, int]] data_key: Var[Union[str, int]]
# The key or getter of a group of data which should be unique in a LineChart. # The key of each sector's name. Default: "name"
name_key: Var[str] name_key: Var[str]
# The type of icon in legend. If set to 'none', no legend item will be rendered. # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line"
legend_type: Var[LiteralLegendType] legend_type: Var[LiteralLegendType]
# If set false, animation of line will be disabled. # If set false, animation of line will be disabled. Default: True
is_animation_active: Var[bool] is_animation_active: Var[bool]
# Specifies when the animation should begin, the unit of this option is ms. # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int] animation_begin: Var[int]
# Specifies the duration of animation, the unit of this option is ms. # Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_duration: Var[int] animation_duration: Var[int]
# The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease"
animation_easing: Var[LiteralAnimationEasing] animation_easing: Var[LiteralAnimationEasing]
# stroke color # Stroke color. Default: rx.color("gray", 3)
stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3)) stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3))
# The coordinates of all the trapezoids in the funnel, usually calculated internally.
trapezoids: Var[List[Dict[str, Any]]]
# Valid children components # Valid children components
_valid_children: List[str] = ["LabelList", "Cell"] _valid_children: List[str] = ["LabelList", "Cell"]
@ -593,20 +620,20 @@ class ErrorBar(Recharts):
alias = "RechartsErrorBar" alias = "RechartsErrorBar"
# The direction of error bar. 'x' | 'y' | 'both' # Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
direction: Var[LiteralDirection] direction: Var[LiteralDirection]
# The key of a group of data which should be unique in an area chart. # The key of a group of data which should be unique in an area chart.
data_key: Var[Union[str, int]] data_key: Var[Union[str, int]]
# The width of the error bar ends. # The width of the error bar ends. Default: 5
width: Var[int] width: Var[int]
# The stroke color of error bar. # The stroke color of error bar. Default: rx.color("gray", 8)
stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 8)) stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 8))
# The stroke width of error bar. # The stroke width of error bar. Default: 1.5
stroke_width: Var[int] stroke_width: Var[Union[int, float]]
class Reference(Recharts): class Reference(Recharts):
@ -751,16 +778,16 @@ class ReferenceArea(Recharts):
class Grid(Recharts): class Grid(Recharts):
"""A base class for grid components in Recharts.""" """A base class for grid components in Recharts."""
# The x-coordinate of grid. # The x-coordinate of grid. Default: 0
x: Var[int] x: Var[int]
# The y-coordinate of grid. # The y-coordinate of grid. Default: 0
y: Var[int] y: Var[int]
# The width of grid. # The width of grid. Default: 0
width: Var[int] width: Var[int]
# The height of grid. # The height of grid. Default: 0
height: Var[int] height: Var[int]

View File

@ -95,18 +95,18 @@ class Axis(Recharts):
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -239,18 +239,18 @@ class XAxis(Axis):
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -386,18 +386,18 @@ class YAxis(Axis):
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[[]]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -646,25 +646,38 @@ class Cartesian(Recharts):
], ],
] ]
] = None, ] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
class_name: Optional[Any] = None, class_name: Optional[Any] = None,
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[[]]] = None,
on_animation_start: Optional[EventType[[]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -675,9 +688,15 @@ class Cartesian(Recharts):
*children: The children of the component. *children: The children of the component.
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart. data_key: The key of a group of data which should be unique in an area chart.
x_axis_id: The id of x-axis which is corresponding to the data. x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
y_axis_id: The id of y-axis which is corresponding to the data. y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
legend_type: 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 legend_type: 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
is_animation_active: If set false, animation of bar will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_easing: The type of easing function. Default: "ease"
unit: The unit of data. This option will be used in tooltip.
name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -794,25 +813,38 @@ class Area(Cartesian):
], ],
] ]
] = None, ] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
unit: Optional[Union[Var[Union[int, str]], int, str]] = None,
name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
class_name: Optional[Any] = None, class_name: Optional[Any] = None,
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[[]]] = None,
on_animation_start: Optional[EventType[[]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -834,9 +866,15 @@ class Area(Cartesian):
connect_nulls: Whether to connect a graph area across null points. Default: False connect_nulls: Whether to connect a graph area across null points. Default: False
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart. data_key: The key of a group of data which should be unique in an area chart.
x_axis_id: The id of x-axis which is corresponding to the data. x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
y_axis_id: The id of y-axis which is corresponding to the data. y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
legend_type: 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 legend_type: 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
is_animation_active: If set false, animation of bar will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_easing: The type of easing function. Default: "ease"
unit: The unit of data. This option will be used in tooltip.
name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -909,25 +947,36 @@ class Bar(Cartesian):
], ],
] ]
] = None, ] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
class_name: Optional[Any] = None, class_name: Optional[Any] = None,
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[[]]] = None,
on_animation_start: Optional[EventType[[]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -944,15 +993,19 @@ class Bar(Cartesian):
stack_id: 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. stack_id: 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.
unit: The unit of data. This option will be used in tooltip. unit: The unit of data. This option will be used in tooltip.
min_point_size: The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts. min_point_size: The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts.
name: The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively. name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
bar_size: Size of the bar (if one bar_size is set then a bar_size must be set for all bars) bar_size: Size of the bar (if one bar_size is set then a bar_size must be set for all bars)
max_bar_size: Max size of the bar max_bar_size: Max size of the bar
radius: If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0 radius: If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart. data_key: The key of a group of data which should be unique in an area chart.
x_axis_id: The id of x-axis which is corresponding to the data. x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
y_axis_id: The id of y-axis which is corresponding to the data. y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
legend_type: 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 legend_type: 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
is_animation_active: If set false, animation of bar will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_easing: The type of easing function. Default: "ease"
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1067,25 +1120,37 @@ class Line(Cartesian):
], ],
] ]
] = None, ] = None,
is_animation_active: Optional[Union[Var[bool], bool]] = None,
animation_begin: Optional[Union[Var[int], int]] = None,
animation_duration: Optional[Union[Var[int], int]] = None,
animation_easing: Optional[
Union[
Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"],
Var[Literal["ease", "ease-in", "ease-in-out", "ease-out", "linear"]],
]
] = None,
name: Optional[Union[Var[Union[int, str]], int, str]] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
class_name: Optional[Any] = None, class_name: Optional[Any] = None,
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[[]]] = None,
on_animation_start: Optional[EventType[[]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -1107,9 +1172,14 @@ class Line(Cartesian):
stroke_dasharray: The pattern of dashes and gaps used to paint the line. stroke_dasharray: The pattern of dashes and gaps used to paint the line.
layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical' layout: The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
data_key: The key of a group of data which should be unique in an area chart. data_key: The key of a group of data which should be unique in an area chart.
x_axis_id: The id of x-axis which is corresponding to the data. x_axis_id: The id of x-axis which is corresponding to the data. Default: 0
y_axis_id: The id of y-axis which is corresponding to the data. y_axis_id: The id of y-axis which is corresponding to the data. Default: 0
legend_type: 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 legend_type: 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
is_animation_active: If set false, animation of bar will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_easing: The type of easing function. Default: "ease"
name: The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1204,18 +1274,18 @@ class Scatter(Recharts):
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -1301,27 +1371,30 @@ class Funnel(Recharts):
] ]
] = None, ] = None,
stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
trapezoids: Optional[
Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]
] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
class_name: Optional[Any] = None, class_name: Optional[Any] = None,
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_animation_end: Optional[EventType[[]]] = None, on_animation_end: Optional[EventType[()]] = None,
on_animation_start: Optional[EventType[[]]] = None, on_animation_start: Optional[EventType[()]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -1331,14 +1404,15 @@ class Funnel(Recharts):
Args: Args:
*children: The children of the component. *children: The children of the component.
data: The source data, in which each element is an object. data: The source data, in which each element is an object.
data_key: The key of a group of data which should be unique in an area chart. data_key: The key or getter of a group of data which should be unique in a FunnelChart.
name_key: The key or getter of a group of data which should be unique in a LineChart. name_key: The key of each sector's name. Default: "name"
legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line"
is_animation_active: If set false, animation of line will be disabled. is_animation_active: If set false, animation of line will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. animation_duration: Specifies the duration of animation, the unit of this option is ms. Default: 1500
animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear' animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease"
stroke: stroke color stroke: Stroke color. Default: rx.color("gray", 3)
trapezoids: The coordinates of all the trapezoids in the funnel, usually calculated internally.
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1358,13 +1432,11 @@ class ErrorBar(Recharts):
def create( # type: ignore def create( # type: ignore
cls, cls,
*children, *children,
direction: Optional[ direction: Optional[Union[Literal["x", "y"], Var[Literal["x", "y"]]]] = None,
Union[Literal["both", "x", "y"], Var[Literal["both", "x", "y"]]]
] = None,
data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
width: Optional[Union[Var[int], int]] = None, width: Optional[Union[Var[int], int]] = None,
stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None,
stroke_width: Optional[Union[Var[int], int]] = None, stroke_width: Optional[Union[Var[Union[float, int]], float, int]] = None,
style: Optional[Style] = None, style: Optional[Style] = None,
key: Optional[Any] = None, key: Optional[Any] = None,
id: Optional[Any] = None, id: Optional[Any] = None,
@ -1392,11 +1464,11 @@ class ErrorBar(Recharts):
Args: Args:
*children: The children of the component. *children: The children of the component.
direction: The direction of error bar. 'x' | 'y' | 'both' direction: Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
data_key: The key of a group of data which should be unique in an area chart. data_key: The key of a group of data which should be unique in an area chart.
width: The width of the error bar ends. width: The width of the error bar ends. Default: 5
stroke: The stroke color of error bar. stroke: The stroke color of error bar. Default: rx.color("gray", 8)
stroke_width: The stroke width of error bar. stroke_width: The stroke width of error bar. Default: 1.5
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1570,18 +1642,18 @@ class ReferenceDot(Reference):
autofocus: Optional[bool] = None, autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None, custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[EventType[[]]] = None, on_blur: Optional[EventType[[]]] = None,
on_click: Optional[EventType[[]]] = None, on_click: Optional[EventType[()]] = None,
on_context_menu: Optional[EventType[[]]] = None, on_context_menu: Optional[EventType[[]]] = None,
on_double_click: Optional[EventType[[]]] = None, on_double_click: Optional[EventType[[]]] = None,
on_focus: Optional[EventType[[]]] = None, on_focus: Optional[EventType[[]]] = None,
on_mount: Optional[EventType[[]]] = None, on_mount: Optional[EventType[[]]] = None,
on_mouse_down: Optional[EventType[[]]] = None, on_mouse_down: Optional[EventType[()]] = None,
on_mouse_enter: Optional[EventType[[]]] = None, on_mouse_enter: Optional[EventType[()]] = None,
on_mouse_leave: Optional[EventType[[]]] = None, on_mouse_leave: Optional[EventType[()]] = None,
on_mouse_move: Optional[EventType[[]]] = None, on_mouse_move: Optional[EventType[()]] = None,
on_mouse_out: Optional[EventType[[]]] = None, on_mouse_out: Optional[EventType[()]] = None,
on_mouse_over: Optional[EventType[[]]] = None, on_mouse_over: Optional[EventType[()]] = None,
on_mouse_up: Optional[EventType[[]]] = None, on_mouse_up: Optional[EventType[()]] = None,
on_scroll: Optional[EventType[[]]] = None, on_scroll: Optional[EventType[[]]] = None,
on_unmount: Optional[EventType[[]]] = None, on_unmount: Optional[EventType[[]]] = None,
**props, **props,
@ -1723,10 +1795,10 @@ class Grid(Recharts):
Args: Args:
*children: The children of the component. *children: The children of the component.
x: The x-coordinate of grid. x: The x-coordinate of grid. Default: 0
y: The y-coordinate of grid. y: The y-coordinate of grid. Default: 0
width: The width of grid. width: The width of grid. Default: 0
height: The height of grid. height: The height of grid. Default: 0
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1797,10 +1869,10 @@ class CartesianGrid(Grid):
fill_opacity: The opacity of the background used to fill the space between grid lines. fill_opacity: The opacity of the background used to fill the space between grid lines.
stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid. stroke_dasharray: The pattern of dashes and gaps used to paint the lines of the grid.
stroke: the stroke color of grid. Default: rx.color("gray", 7) stroke: the stroke color of grid. Default: rx.color("gray", 7)
x: The x-coordinate of grid. x: The x-coordinate of grid. Default: 0
y: The y-coordinate of grid. y: The y-coordinate of grid. Default: 0
width: The width of grid. width: The width of grid. Default: 0
height: The height of grid. height: The height of grid. Default: 0
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.
@ -1881,10 +1953,10 @@ class CartesianAxis(Grid):
label: If set a string or a number, default label will be drawn, and the option is content. label: If set a string or a number, default label will be drawn, and the option is content.
mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
tick_margin: The margin between tick line and tick. tick_margin: The margin between tick line and tick.
x: The x-coordinate of grid. x: The x-coordinate of grid. Default: 0
y: The y-coordinate of grid. y: The y-coordinate of grid. Default: 0
width: The width of grid. width: The width of grid. Default: 0
height: The height of grid. height: The height of grid. Default: 0
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.

View File

@ -158,31 +158,34 @@ class RadialBar(Recharts):
alias = "RechartsRadialBar" alias = "RechartsRadialBar"
# The source data which each element is an object.
data: Var[List[Dict[str, Any]]]
# The key of a group of data which should be unique to show the meaning of angle axis. # The key of a group of data which should be unique to show the meaning of angle axis.
data_key: Var[Union[str, int]] data_key: Var[Union[str, int]]
# Min angle of each bar. A positive value between 0 and 360. # Min angle of each bar. A positive value between 0 and 360. Default: 0
min_angle: Var[int] min_angle: Var[int]
# Type of legend # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
legend_type: Var[str] legend_type: Var[LiteralLegendType]
# If false set, labels will not be drawn. # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
label: Var[Union[bool, Dict[str, Any]]] label: Var[Union[bool, Dict[str, Any]]]
# If false set, background sector will not be drawn. # If false set, background sector will not be drawn. Default: False
background: Var[Union[bool, Dict[str, Any]]] background: Var[Union[bool, Dict[str, Any]]]
# If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR # If set false, animation of radial bars will be disabled. Default: True
is_animation_active: Var[bool] is_animation_active: Var[bool]
# Specifies when the animation should begin, the unit of this option is ms. By default 0 # Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_begin: Var[int] animation_begin: Var[int]
# Specifies the duration of animation, the unit of this option is ms. By default 1500 # Specifies the duration of animation, the unit of this option is ms. Default 1500
animation_duration: Var[int] animation_duration: Var[int]
# The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease' # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
animation_easing: Var[LiteralAnimationEasing] animation_easing: Var[LiteralAnimationEasing]
# Valid children components # Valid children components

View File

@ -216,9 +216,41 @@ class RadialBar(Recharts):
def create( # type: ignore def create( # type: ignore
cls, cls,
*children, *children,
data: Optional[Union[List[Dict[str, Any]], Var[List[Dict[str, Any]]]]] = None,
data_key: Optional[Union[Var[Union[int, str]], int, str]] = None, data_key: Optional[Union[Var[Union[int, str]], int, str]] = None,
min_angle: Optional[Union[Var[int], int]] = None, min_angle: Optional[Union[Var[int], int]] = None,
legend_type: Optional[Union[Var[str], str]] = None, legend_type: Optional[
Union[
Literal[
"circle",
"cross",
"diamond",
"line",
"none",
"plainline",
"rect",
"square",
"star",
"triangle",
"wye",
],
Var[
Literal[
"circle",
"cross",
"diamond",
"line",
"none",
"plainline",
"rect",
"square",
"star",
"triangle",
"wye",
]
],
]
] = None,
label: Optional[ label: Optional[
Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool] Union[Dict[str, Any], Var[Union[Dict[str, Any], bool]], bool]
] = None, ] = None,
@ -254,15 +286,16 @@ class RadialBar(Recharts):
Args: Args:
*children: The children of the component. *children: The children of the component.
data: The source data which each element is an object.
data_key: The key of a group of data which should be unique to show the meaning of angle axis. data_key: The key of a group of data which should be unique to show the meaning of angle axis.
min_angle: Min angle of each bar. A positive value between 0 and 360. min_angle: Min angle of each bar. A positive value between 0 and 360. Default: 0
legend_type: Type of legend legend_type: The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "rect"
label: If false set, labels will not be drawn. label: If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
background: If false set, background sector will not be drawn. background: If false set, background sector will not be drawn. Default: False
is_animation_active: If set false, animation of radial bars will be disabled. By default true in CSR, and false in SSR is_animation_active: If set false, animation of radial bars will be disabled. Default: True
animation_begin: Specifies when the animation should begin, the unit of this option is ms. By default 0 animation_begin: Specifies when the animation should begin, the unit of this option is ms. Default: 0
animation_duration: Specifies the duration of animation, the unit of this option is ms. By default 1500 animation_duration: Specifies the duration of animation, the unit of this option is ms. Default 1500
animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. By default 'ease' animation_easing: The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default: "ease"
style: The style of the component. style: The style of the component.
key: A unique key for the component. key: A unique key for the component.
id: The id for the component. id: The id for the component.

View File

@ -131,6 +131,6 @@ LiteralAreaType = Literal[
"stepBefore", "stepBefore",
"stepAfter", "stepAfter",
] ]
LiteralDirection = Literal["x", "y", "both"] LiteralDirection = Literal["x", "y"]
LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
LiteralSyncMethod = Literal["index", "value"] LiteralSyncMethod = Literal["index", "value"]

View File

@ -202,6 +202,6 @@ LiteralAreaType = Literal[
"stepBefore", "stepBefore",
"stepAfter", "stepAfter",
] ]
LiteralDirection = Literal["x", "y", "both"] LiteralDirection = Literal["x", "y"]
LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
LiteralSyncMethod = Literal["index", "value"] LiteralSyncMethod = Literal["index", "value"]

View File

@ -9,6 +9,8 @@ import urllib.parse
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Set, Union from typing import Any, Dict, List, Optional, Set, Union
from reflex.utils.exceptions import ConfigError
try: try:
import pydantic.v1 as pydantic import pydantic.v1 as pydantic
except ModuleNotFoundError: except ModuleNotFoundError:
@ -220,6 +222,9 @@ class Config(Base):
# Number of gunicorn workers from user # Number of gunicorn workers from user
gunicorn_workers: Optional[int] = None gunicorn_workers: Optional[int] = None
# Indicate which type of state manager to use
state_manager_mode: constants.StateManagerMode = constants.StateManagerMode.DISK
# Maximum expiration lock time for redis state manager # Maximum expiration lock time for redis state manager
redis_lock_expiration: int = constants.Expiration.LOCK redis_lock_expiration: int = constants.Expiration.LOCK
@ -235,6 +240,9 @@ class Config(Base):
Args: Args:
*args: The args to pass to the Pydantic init method. *args: The args to pass to the Pydantic init method.
**kwargs: The kwargs to pass to the Pydantic init method. **kwargs: The kwargs to pass to the Pydantic init method.
Raises:
ConfigError: If some values in the config are invalid.
""" """
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
@ -248,6 +256,14 @@ class Config(Base):
self._non_default_attributes.update(kwargs) self._non_default_attributes.update(kwargs)
self._replace_defaults(**kwargs) self._replace_defaults(**kwargs)
if (
self.state_manager_mode == constants.StateManagerMode.REDIS
and not self.redis_url
):
raise ConfigError(
"REDIS_URL is required when using the redis state manager."
)
@property @property
def module(self) -> str: def module(self) -> str:
"""Get the module name of the app. """Get the module name of the app.

View File

@ -63,6 +63,7 @@ from .route import (
RouteRegex, RouteRegex,
RouteVar, RouteVar,
) )
from .state import StateManagerMode
from .style import Tailwind from .style import Tailwind
__ALL__ = [ __ALL__ = [
@ -115,6 +116,7 @@ __ALL__ = [
SETTER_PREFIX, SETTER_PREFIX,
SKIP_COMPILE_ENV_VAR, SKIP_COMPILE_ENV_VAR,
SocketEvent, SocketEvent,
StateManagerMode,
Tailwind, Tailwind,
Templates, Templates,
CompileVars, CompileVars,

11
reflex/constants/state.py Normal file
View File

@ -0,0 +1,11 @@
"""State-related constants."""
from enum import Enum
class StateManagerMode(str, Enum):
"""State manager constants."""
DISK = "disk"
MEMORY = "memory"
REDIS = "redis"

View File

@ -76,6 +76,7 @@ from reflex.utils.exceptions import (
DynamicRouteArgShadowsStateVar, DynamicRouteArgShadowsStateVar,
EventHandlerShadowsBuiltInStateMethod, EventHandlerShadowsBuiltInStateMethod,
ImmutableStateError, ImmutableStateError,
InvalidStateManagerMode,
LockExpiredError, LockExpiredError,
SetUndefinedStateVarError, SetUndefinedStateVarError,
StateSchemaMismatchError, StateSchemaMismatchError,
@ -1879,13 +1880,8 @@ class BaseState(Base, ABC, extra=pydantic.Extra.allow):
self.dirty_vars.update(self._always_dirty_computed_vars) self.dirty_vars.update(self._always_dirty_computed_vars)
self._mark_dirty() self._mark_dirty()
def dictify(value: Any):
if dataclasses.is_dataclass(value) and not isinstance(value, type):
return dataclasses.asdict(value)
return value
base_vars = { base_vars = {
prop_name: dictify(self.get_value(getattr(self, prop_name))) prop_name: self.get_value(getattr(self, prop_name))
for prop_name in self.base_vars for prop_name in self.base_vars
} }
if initial and include_computed: if initial and include_computed:
@ -2519,20 +2515,30 @@ class StateManager(Base, ABC):
Args: Args:
state: The state class to use. state: The state class to use.
Raises:
InvalidStateManagerMode: If the state manager mode is invalid.
Returns: Returns:
The state manager (either disk or redis). The state manager (either disk, memory or redis).
""" """
redis = prerequisites.get_redis() config = get_config()
if redis is not None: if config.state_manager_mode == constants.StateManagerMode.DISK:
# make sure expiration values are obtained only from the config object on creation return StateManagerMemory(state=state)
config = get_config() if config.state_manager_mode == constants.StateManagerMode.MEMORY:
return StateManagerRedis( return StateManagerDisk(state=state)
state=state, if config.state_manager_mode == constants.StateManagerMode.REDIS:
redis=redis, redis = prerequisites.get_redis()
token_expiration=config.redis_token_expiration, if redis is not None:
lock_expiration=config.redis_lock_expiration, # make sure expiration values are obtained only from the config object on creation
) return StateManagerRedis(
return StateManagerDisk(state=state) state=state,
redis=redis,
token_expiration=config.redis_token_expiration,
lock_expiration=config.redis_lock_expiration,
)
raise InvalidStateManagerMode(
f"Expected one of: DISK, MEMORY, REDIS, got {config.state_manager_mode}"
)
@abstractmethod @abstractmethod
async def get_state(self, token: str) -> BaseState: async def get_state(self, token: str) -> BaseState:

View File

@ -394,9 +394,14 @@ class AppHarness:
def consume_frontend_output(): def consume_frontend_output():
while True: while True:
line = ( try:
self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess] line = (
) self.frontend_process.stdout.readline() # pyright: ignore [reportOptionalMemberAccess]
)
# catch I/O operation on closed file.
except ValueError as e:
print(e)
break
if not line: if not line:
break break
print(line) print(line)

View File

@ -5,6 +5,14 @@ class ReflexError(Exception):
"""Base exception for all Reflex exceptions.""" """Base exception for all Reflex exceptions."""
class ConfigError(ReflexError):
"""Custom exception for config related errors."""
class InvalidStateManagerMode(ReflexError, ValueError):
"""Raised when an invalid state manager mode is provided."""
class ReflexRuntimeError(ReflexError, RuntimeError): class ReflexRuntimeError(ReflexError, RuntimeError):
"""Custom RuntimeError for Reflex.""" """Custom RuntimeError for Reflex."""

View File

@ -545,7 +545,7 @@ class LiteralStringVar(LiteralVar, StringVar):
def create( def create(
cls, cls,
value: str, value: str,
_var_type: GenericType | None = str, _var_type: GenericType | None = None,
_var_data: VarData | None = None, _var_data: VarData | None = None,
) -> StringVar: ) -> StringVar:
"""Create a var from a string value. """Create a var from a string value.
@ -558,6 +558,9 @@ class LiteralStringVar(LiteralVar, StringVar):
Returns: Returns:
The var. The var.
""" """
# Determine var type in case the value is inherited from str.
_var_type = _var_type or type(value) or str
if REFLEX_VAR_OPENING_TAG in value: if REFLEX_VAR_OPENING_TAG in value:
strings_and_vals: list[Var | str] = [] strings_and_vals: list[Var | str] = []
offset = 0 offset = 0

View File

@ -1290,19 +1290,19 @@ def test_computed_var_depends_on_parent_non_cached():
assert ps.dirty_vars == set() assert ps.dirty_vars == set()
assert cs.dirty_vars == set() assert cs.dirty_vars == set()
dict1 = ps.dict() dict1 = json.loads(json_dumps(ps.dict()))
assert dict1[ps.get_full_name()] == { assert dict1[ps.get_full_name()] == {
"no_cache_v": 1, "no_cache_v": 1,
"router": formatted_router, "router": formatted_router,
} }
assert dict1[cs.get_full_name()] == {"dep_v": 2} assert dict1[cs.get_full_name()] == {"dep_v": 2}
dict2 = ps.dict() dict2 = json.loads(json_dumps(ps.dict()))
assert dict2[ps.get_full_name()] == { assert dict2[ps.get_full_name()] == {
"no_cache_v": 3, "no_cache_v": 3,
"router": formatted_router, "router": formatted_router,
} }
assert dict2[cs.get_full_name()] == {"dep_v": 4} assert dict2[cs.get_full_name()] == {"dep_v": 4}
dict3 = ps.dict() dict3 = json.loads(json_dumps(ps.dict()))
assert dict3[ps.get_full_name()] == { assert dict3[ps.get_full_name()] == {
"no_cache_v": 5, "no_cache_v": 5,
"router": formatted_router, "router": formatted_router,
@ -3201,6 +3201,7 @@ import reflex as rx
config = rx.Config( config = rx.Config(
app_name="project1", app_name="project1",
redis_url="redis://localhost:6379", redis_url="redis://localhost:6379",
state_manager_mode="redis",
{config_items} {config_items}
) )
""" """

View File

@ -1809,3 +1809,6 @@ def test_to_string_operation():
assert cast(Var, TestState.email)._var_type == Email assert cast(Var, TestState.email)._var_type == Email
assert cast(Var, TestState.optional_email)._var_type == Optional[Email] assert cast(Var, TestState.optional_email)._var_type == Optional[Email]
single_var = Var.create(Email())
assert single_var._var_type == Email