Просмотр исходного кода

Hanson/tooltip-improvement/props (#3525)

* added props for tooltip

* formatted

* added pyi

* new pyi

---------

Co-authored-by: Hongyu Yao <hongyuyao@Hongyus-MacBook-Pro-3.local>
HongyuHansonYao 11 месяцев назад
Родитель
Сommit
4318bb597f
2 измененных файлов с 51 добавлено и 0 удалено
  1. 27 0
      reflex/components/recharts/general.py
  2. 24 0
      reflex/components/recharts/general.pyi

+ 27 - 0
reflex/components/recharts/general.py

@@ -9,6 +9,7 @@ from reflex.event import EventHandler
 from reflex.vars import Var
 from reflex.vars import Var
 
 
 from .recharts import (
 from .recharts import (
+    LiteralAnimationEasing,
     LiteralIconType,
     LiteralIconType,
     LiteralLayout,
     LiteralLayout,
     LiteralLegendAlign,
     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.
     # 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]]
     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.
     # If set true, the tooltip is displayed. If set false, the tooltip is hidden, usually calculated internally.
     active: Var[bool]
     active: Var[bool]
 
 
@@ -151,6 +169,15 @@ class GraphingTooltip(Recharts):
     # The coordinate of tooltip which is usually calculated internally.
     # The coordinate of tooltip which is usually calculated internally.
     coordinate: Var[Dict[str, Any]]
     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):
 class Label(Recharts):
     """A Label component in Recharts."""
     """A Label component in Recharts."""

+ 24 - 0
reflex/components/recharts/general.pyi

@@ -12,6 +12,7 @@ from reflex.components.component import MemoizationLeaf
 from reflex.event import EventHandler
 from reflex.event import EventHandler
 from reflex.vars import Var
 from reflex.vars import Var
 from .recharts import (
 from .recharts import (
+    LiteralAnimationEasing,
     LiteralIconType,
     LiteralIconType,
     LiteralLayout,
     LiteralLayout,
     LiteralLegendAlign,
     LiteralLegendAlign,
@@ -259,9 +260,24 @@ class GraphingTooltip(Recharts):
         filter_null: Optional[Union[Var[bool], bool]] = None,
         filter_null: Optional[Union[Var[bool], bool]] = None,
         cursor: 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,
         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,
         active: Optional[Union[Var[bool], bool]] = None,
         position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
         position: Optional[Union[Var[Dict[str, Any]], Dict[str, Any]]] = None,
         coordinate: 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,
         style: Optional[Style] = None,
         key: Optional[Any] = None,
         key: Optional[Any] = None,
         id: 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.
             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.
             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.
             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.
             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.
             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.
             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.
             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.