From 4318bb597f80e462032216db4150eaf696a95b8a Mon Sep 17 00:00:00 2001 From: HongyuHansonYao <159659100+HongyuHansonYao@users.noreply.github.com> Date: Thu, 20 Jun 2024 15:09:33 -0700 Subject: [PATCH] Hanson/tooltip-improvement/props (#3525) * added props for tooltip * formatted * added pyi * new pyi --------- Co-authored-by: Hongyu Yao --- reflex/components/recharts/general.py | 27 ++++++++++++++++++++++++++ reflex/components/recharts/general.pyi | 24 +++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/reflex/components/recharts/general.py b/reflex/components/recharts/general.py index 08d6cc0d4..8e2685914 100644 --- a/reflex/components/recharts/general.py +++ b/reflex/components/recharts/general.py @@ -9,6 +9,7 @@ from reflex.event import EventHandler from reflex.vars import Var from .recharts import ( + LiteralAnimationEasing, LiteralIconType, LiteralLayout, LiteralLegendAlign, @@ -142,6 +143,23 @@ class GraphingTooltip(Recharts): # The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally. view_box: Var[Dict[str, Any]] + # The style of default tooltip content item which is a li element. DEFAULT: {} + item_style: Var[Dict[str, Any]] + + # The style of tooltip wrapper which is a dom element. DEFAULT: {} + wrapper_style: Var[Dict[str, Any]] + + # The style of tooltip content which is a dom element. DEFAULT: {} + content_style: Var[Dict[str, Any]] + + # The style of default tooltip label which is a p element. DEFAULT: {} + label_style: Var[Dict[str, Any]] + + # This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false } + allow_escape_view_box: Var[Dict[str, bool]] = Var.create_safe( + {"x": False, "y": False} + ) + # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. active: Var[bool] @@ -151,6 +169,15 @@ class GraphingTooltip(Recharts): # The coordinate of tooltip which is usually calculated internally. coordinate: Var[Dict[str, Any]] + # If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR + is_animation_active: Var[bool] + + # 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] + class Label(Recharts): """A Label component in Recharts.""" diff --git a/reflex/components/recharts/general.pyi b/reflex/components/recharts/general.pyi index bc7aea17d..4211b20da 100644 --- a/reflex/components/recharts/general.pyi +++ b/reflex/components/recharts/general.pyi @@ -12,6 +12,7 @@ from reflex.components.component import MemoizationLeaf from reflex.event import EventHandler from reflex.vars import Var from .recharts import ( + LiteralAnimationEasing, LiteralIconType, LiteralLayout, LiteralLegendAlign, @@ -259,9 +260,24 @@ class GraphingTooltip(Recharts): filter_null: Optional[Union[Var[bool], bool]] = None, cursor: Optional[Union[Var[bool], bool]] = None, view_box: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + item_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + wrapper_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + content_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + label_style: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + allow_escape_view_box: Optional[ + Union[Var[Dict[str, bool]], Dict[str, bool]] + ] = None, active: Optional[Union[Var[bool], bool]] = None, position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, coordinate: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None, + is_animation_active: Optional[Union[Var[bool], bool]] = None, + animation_duration: Optional[Union[Var[int], int]] = None, + animation_easing: Optional[ + Union[ + Var[Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]], + Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"], + ] + ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -324,9 +340,17 @@ class GraphingTooltip(Recharts): filter_null: When an item of the payload has value null or undefined, this item won't be displayed. cursor: If set false, no cursor will be drawn when tooltip is active. view_box: The box of viewing area, which has the shape of {x: someVal, y: someVal, width: someVal, height: someVal}, usually calculated internally. + item_style: The style of default tooltip content item which is a li element. DEFAULT: {} + wrapper_style: The style of tooltip wrapper which is a dom element. DEFAULT: {} + content_style: The style of tooltip content which is a dom element. DEFAULT: {} + label_style: The style of default tooltip label which is a p element. DEFAULT: {} + allow_escape_view_box: This option allows the tooltip to extend beyond the viewBox of the chart itself. DEFAULT: { x: false, y: false } active: If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally. position: If this field is set, the tooltip position will be fixed and will not move anymore. coordinate: The coordinate of tooltip which is usually calculated internally. + is_animation_active: If set false, animation of tooltip will be disabled. DEFAULT: true in CSR, and false in SSR + 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. key: A unique key for the component. id: The id for the component.