Răsfoiți Sursa

update graphing (#3606)

* update graphing

* fix pyi

* update graphing

rebase#

* fix pyi

* precommit fail

* fix pyi generator file

* update pyi again

* pyi

* fix pyi generator to have single line builtin check

* change dict to Dict

---------

Co-authored-by: Tom Gotsman <tomgotsman@toms-mbp.lan>
Co-authored-by: Tom Gotsman <tomgotsman@Toms-MacBook-Pro.local>
Co-authored-by: Lendemor <thomas.brandeho@gmail.com>
Tom Gotsman 10 luni în urmă
părinte
comite
b20f3ac29a

+ 3 - 0
reflex/components/recharts/cartesian.py

@@ -67,6 +67,9 @@ class Axis(Recharts):
     # Reverse the ticks or not.
     reversed: Var[bool]
 
+    # The label of axis, which appears next to the axis.
+    label: Var[Union[str, int, Dict[str, Any]]]
+
     # 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' | Function
     scale: Var[LiteralScale]
 

+ 12 - 0
reflex/components/recharts/cartesian.pyi

@@ -36,6 +36,9 @@ class Axis(Recharts):
         axis_line: Optional[Union[Var[bool], bool]] = None,
         mirror: Optional[Union[Var[bool], bool]] = None,
         reversed: Optional[Union[Var[bool], bool]] = None,
+        label: Optional[
+            Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+        ] = None,
         scale: Optional[
             Union[
                 Var[
@@ -157,6 +160,7 @@ class Axis(Recharts):
             axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
             mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
             reversed: Reverse the ticks or not.
+            label: The label of axis, which appears next to the axis.
             scale: 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' | Function
             unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
             name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
@@ -205,6 +209,9 @@ class XAxis(Axis):
         axis_line: Optional[Union[Var[bool], bool]] = None,
         mirror: Optional[Union[Var[bool], bool]] = None,
         reversed: Optional[Union[Var[bool], bool]] = None,
+        label: Optional[
+            Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+        ] = None,
         scale: Optional[
             Union[
                 Var[
@@ -328,6 +335,7 @@ class XAxis(Axis):
             axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
             mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
             reversed: Reverse the ticks or not.
+            label: The label of axis, which appears next to the axis.
             scale: 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' | Function
             unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
             name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
@@ -375,6 +383,9 @@ class YAxis(Axis):
         axis_line: Optional[Union[Var[bool], bool]] = None,
         mirror: Optional[Union[Var[bool], bool]] = None,
         reversed: Optional[Union[Var[bool], bool]] = None,
+        label: Optional[
+            Union[Var[Union[Dict[str, Any], int, str]], str, int, Dict[str, Any]]
+        ] = None,
         scale: Optional[
             Union[
                 Var[
@@ -497,6 +508,7 @@ class YAxis(Axis):
             axis_line: If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line.
             mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside.
             reversed: Reverse the ticks or not.
+            label: The label of axis, which appears next to the axis.
             scale: 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' | Function
             unit: The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
             name: The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.

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

@@ -5,6 +5,7 @@ from __future__ import annotations
 from typing import Any, Dict, List, Union
 
 from reflex.components.component import MemoizationLeaf
+from reflex.constants.colors import Color
 from reflex.event import EventHandler
 from reflex.vars import Var
 
@@ -215,6 +216,12 @@ class LabelList(Recharts):
     # The offset to the specified "position"
     offset: Var[int]
 
+    # The color of the line stroke.
+    stroke: Var[Union[str, Color]]
+
+    # The width of the line stroke.
+    fill: Var[Union[str, Color]]
+
 
 responsive_container = ResponsiveContainer.create
 legend = Legend.create

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

@@ -6,6 +6,7 @@
 from typing import Any, Callable, Dict, Literal, Optional, Union, overload
 
 from reflex.components.component import MemoizationLeaf
+from reflex.constants.colors import Color
 from reflex.event import EventHandler, EventSpec
 from reflex.style import Style
 from reflex.vars import BaseVar, Var
@@ -540,6 +541,8 @@ class LabelList(Recharts):
             ]
         ] = None,
         offset: Optional[Union[Var[int], int]] = None,
+        stroke: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
+        fill: Optional[Union[Var[Union[Color, str]], str, Color]] = None,
         style: Optional[Style] = None,
         key: Optional[Any] = None,
         id: Optional[Any] = None,
@@ -600,6 +603,8 @@ class LabelList(Recharts):
             data_key: The key of a group of label values in data.
             position: The position of each label relative to it view box。"Top" | "left" | "right" | "bottom" | "inside" | "outside" | "insideLeft" | "insideRight" | "insideTop" | "insideBottom" | "insideTopLeft" | "insideBottomLeft" | "insideTopRight" | "insideBottomRight" | "insideStart" | "insideEnd" | "end" | "center"
             offset: The offset to the specified "position"
+            stroke: The color of the line stroke.
+            fill: The width of the line stroke.
             style: The style of the component.
             key: A unique key for the component.
             id: The id for the component.

+ 4 - 1
reflex/utils/pyi_generator.py

@@ -159,7 +159,10 @@ def _get_type_hint(value, type_hint_globals, is_optional=True) -> str:
             ]
         )
 
-        if value.__name__ not in type_hint_globals:
+        if (
+            value.__module__ not in ["builtins", "__builtins__"]
+            and value.__name__ not in type_hint_globals
+        ):
             raise TypeError(
                 f"{value.__module__ + '.' + value.__name__} is not a default import, "
                 "add it to DEFAULT_IMPORTS in pyi_generator.py"