From a7549232c9c585c54e99b617eef0ceb171048175 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Fri, 23 May 2025 14:55:02 -0700 Subject: [PATCH 1/2] adjust rechart types --- pyi_hashes.json | 8 ++--- reflex/components/recharts/__init__.py | 2 +- reflex/components/recharts/cartesian.py | 42 +++++++++++-------------- reflex/components/recharts/polar.py | 14 +++++---- reflex/components/recharts/recharts.py | 22 +++++++------ 5 files changed, 44 insertions(+), 44 deletions(-) diff --git a/pyi_hashes.json b/pyi_hashes.json index 69c4ff61e7b..683f3cc3a17 100644 --- a/pyi_hashes.json +++ b/pyi_hashes.json @@ -114,12 +114,12 @@ "reflex/components/react_player/audio.pyi": "bd7e024d39ac641f8279ee0f6afd7985", "reflex/components/react_player/react_player.pyi": "40db798bcb7fa40207d24f49722135ae", "reflex/components/react_player/video.pyi": "22d84a7f57be13ece90cb30536d76c7d", - "reflex/components/recharts/__init__.pyi": "a52c9055e37c6ee25ded15688d45e8a5", - "reflex/components/recharts/cartesian.pyi": "eb44b706cdb45f4b8450ef5302a981ae", + "reflex/components/recharts/__init__.pyi": "a060a4abcd018165bc499173e723cf9e", + "reflex/components/recharts/cartesian.pyi": "d64def4f9372f837583bf1dab30eb35e", "reflex/components/recharts/charts.pyi": "2f0a39f9c02de83d9e2d97763b4411af", "reflex/components/recharts/general.pyi": "06d0e97776cc82b946fed465ab36fba4", - "reflex/components/recharts/polar.pyi": "7c445e98c1d0c95868411173de8fe85e", - "reflex/components/recharts/recharts.pyi": "f2739c20a27990a571d16133a40a0878", + "reflex/components/recharts/polar.pyi": "71fb8c747e56b4f6bc72bdade16c1385", + "reflex/components/recharts/recharts.pyi": "24a35f769a10a51dbd6d4cbff3b2f071", "reflex/components/sonner/toast.pyi": "6dc6d5d05d9a8d7d364c0326fb2e6503", "reflex/components/suneditor/editor.pyi": "0a6dcab61cc2d750488601e3808080d9", "reflex/experimental/layout.pyi": "fb4c52b954431d9a927fbdd612b562eb" diff --git a/reflex/components/recharts/__init__.py b/reflex/components/recharts/__init__.py index 7aa0041d901..6b4b358095b 100644 --- a/reflex/components/recharts/__init__.py +++ b/reflex/components/recharts/__init__.py @@ -90,10 +90,10 @@ ], "recharts": [ "LiteralAnimationEasing", - "LiteralAreaType", "LiteralAxisType", "LiteralBarChartStackOffset", "LiteralComposedChartBaseValue", + "LiteralCurveType", "LiteralDirection", "LiteralGridType", "LiteralIconType", diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index b2d56b38afb..047cc884dc8 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -5,14 +5,16 @@ from collections.abc import Sequence from typing import Any, ClassVar +from reflex.components.component import Component from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler, no_args_event_spec from reflex.vars.base import LiteralVar, Var from .recharts import ( + ACTIVE_DOT_TYPE, LiteralAnimationEasing, - LiteralAreaType, + LiteralCurveType, LiteralDirection, LiteralIfOverflow, LiteralInterval, @@ -74,7 +76,7 @@ class Axis(Recharts): reversed: Var[bool] # The label of axis, which appears next to the axis. - label: Var[str | int | dict[str, Any]] + label: Var[str | int | Component | 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'. Default: "auto" scale: Var[LiteralScale] @@ -89,7 +91,7 @@ class Axis(Recharts): ticks: Var[Sequence[str | int]] # If set false, no ticks will be drawn. - tick: Var[bool] + tick: Var[bool | dict | Component] # The count of axis ticks. Not used if 'type' is 'category'. Default: 5 tick_count: Var[int] @@ -275,6 +277,9 @@ class Cartesian(Recharts): # 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] + # 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[bool | dict[str, Any] | Component] + # If set false, animation of bar will be disabled. Default: True is_animation_active: Var[bool] @@ -341,24 +346,21 @@ class Area(Cartesian): fill: Var[str | Color] = LiteralVar.create(Color("accent", 5)) # 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" - type_: Var[LiteralAreaType] = LiteralVar.create("monotone") + type_: Var[LiteralCurveType] = LiteralVar.create("monotone") # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False - dot: Var[bool | dict[str, Any]] + dot: Var[ACTIVE_DOT_TYPE] # 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)} - active_dot: Var[bool | dict[str, Any]] = LiteralVar.create( + active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create( { "stroke": Color("accent", 2), "fill": Color("accent", 10), } ) - # If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False - label: Var[bool] - # The value which can describle the line, usually calculated internally. - base_line: Var[str | Sequence[dict[str, Any]]] + base_line: Var[int | Sequence[dict[str, Any]]] # The coordinates of all the points in the area, usually calculated internally. points: Var[Sequence[dict[str, Any]]] @@ -392,9 +394,6 @@ class Bar(Cartesian): # 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 background: Var[bool] - # 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[bool] - # 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: Var[str] @@ -431,7 +430,7 @@ class Line(Cartesian): alias = "RechartsLine" # The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area. - type_: Var[LiteralAreaType] + type_: Var[LiteralCurveType] # The color of the line stroke. Default: rx.color("accent", 9) stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9)) @@ -440,7 +439,7 @@ class Line(Cartesian): stroke_width: Var[int] # 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)} - dot: Var[bool | dict[str, Any]] = LiteralVar.create( + dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create( { "stroke": Color("accent", 10), "fill": Color("accent", 4), @@ -448,16 +447,13 @@ class Line(Cartesian): ) # 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)} - active_dot: Var[bool | dict[str, Any]] = LiteralVar.create( + active_dot: Var[ACTIVE_DOT_TYPE] = LiteralVar.create( { "stroke": Color("accent", 2), "fill": Color("accent", 10), } ) - # 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[bool] - # Hides the line when true, useful when toggling visibility state via legend. Default: False hide: Var[bool] @@ -661,7 +657,7 @@ class Reference(Recharts): if_overflow: Var[LiteralIfOverflow] # If set a string or a number, default label will be drawn, and the option is content. - label: Var[str | int] + label: Var[str | int | Component] # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False is_front: Var[bool] @@ -849,10 +845,10 @@ class CartesianAxis(Grid): view_box: Var[dict[str, Any]] # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True - axis_line: Var[bool] + axis_line: Var[bool | dict] # If set false, no ticks will be drawn. - tick: Var[bool] + tick: Var[bool | dict | Component] # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True tick_line: Var[bool] @@ -864,7 +860,7 @@ class CartesianAxis(Grid): interval: Var[LiteralInterval] # If set a string or a number, default label will be drawn, and the option is content. - label: Var[str | int] + label: Var[str | int | Component] # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: Var[bool] diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index c27772dfc0a..cfa4751bf44 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -5,12 +5,14 @@ from collections.abc import Sequence from typing import Any, ClassVar +from reflex.components.component import Component from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler, no_args_event_spec from reflex.vars.base import LiteralVar, Var from .recharts import ( + ACTIVE_DOT_TYPE, LiteralAnimationEasing, LiteralGridType, LiteralLegendType, @@ -65,10 +67,10 @@ class Pie(Recharts): legend_type: Var[LiteralLegendType] # 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[bool] = Var.create(False) + label: Var[bool | dict[str, Any] | Component] = Var.create(False) # 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 - label_line: Var[bool] + label_line: Var[bool | dict[str, Any] | Component] # Valid children components _valid_children: ClassVar[list[str]] = ["Cell", "LabelList", "Bare"] @@ -126,7 +128,7 @@ class Radar(Recharts): points: Var[Sequence[dict[str, Any]]] # If false set, dots will not be drawn. Default: True - dot: Var[bool] + dot: Var[ACTIVE_DOT_TYPE] # Stoke color. Default: rx.color("accent", 9) stroke: Var[str | Color] = LiteralVar.create(Color("accent", 9)) @@ -141,7 +143,7 @@ class Radar(Recharts): legend_type: Var[LiteralLegendType] # If false set, labels will not be drawn. Default: True - label: Var[bool] + label: Var[bool | dict[str, Any] | Component] # If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR is_animation_active: Var[bool] @@ -190,10 +192,10 @@ class RadialBar(Recharts): legend_type: Var[LiteralLegendType] # 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[bool | dict[str, Any]] + label: Var[bool | dict[str, Any] | Component] # If false set, background sector will not be drawn. Default: False - background: Var[bool | dict[str, Any]] + background: Var[bool | dict[str, Any] | Component] # If set false, animation of radial bars will be disabled. Default: True is_animation_active: Var[bool] diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index 40891253245..d767e170ce4 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -1,6 +1,6 @@ """A component that wraps a recharts lib.""" -from typing import Literal +from typing import Any, Literal from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent @@ -73,25 +73,25 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): "center", ] LiteralIconType = Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "plainline", + "rect", + "square", "star", "triangle", "wye", ] LiteralLegendType = Literal[ - "line", - "plainline", - "square", - "rect", "circle", "cross", "diamond", + "line", + "plainline", + "rect", + "square", "star", "triangle", "wye", @@ -103,7 +103,7 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): LiteralBarChartStackOffset = Literal["expand", "none", "wiggle", "silhouette", "sign"] LiteralComposedChartBaseValue = Literal["dataMin", "dataMax", "auto"] LiteralAxisType = Literal["number", "category"] -LiteralAreaType = Literal[ +LiteralCurveType = Literal[ "basis", "basisClosed", "basisOpen", @@ -126,3 +126,5 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart" ] LiteralSyncMethod = Literal["index", "value"] + +ACTIVE_DOT_TYPE = bool | dict[str, Any] | Component From 945575b47f5c1e0069dc9db71b30ba3dabf587f2 Mon Sep 17 00:00:00 2001 From: Lendemor Date: Fri, 23 May 2025 18:53:46 -0700 Subject: [PATCH 2/2] remove Component as type for now --- pyi_hashes.json | 6 +++--- reflex/components/recharts/cartesian.py | 13 ++++++------- reflex/components/recharts/polar.py | 11 +++++------ reflex/components/recharts/recharts.py | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/pyi_hashes.json b/pyi_hashes.json index 683f3cc3a17..0ceb987bef5 100644 --- a/pyi_hashes.json +++ b/pyi_hashes.json @@ -115,11 +115,11 @@ "reflex/components/react_player/react_player.pyi": "40db798bcb7fa40207d24f49722135ae", "reflex/components/react_player/video.pyi": "22d84a7f57be13ece90cb30536d76c7d", "reflex/components/recharts/__init__.pyi": "a060a4abcd018165bc499173e723cf9e", - "reflex/components/recharts/cartesian.pyi": "d64def4f9372f837583bf1dab30eb35e", + "reflex/components/recharts/cartesian.pyi": "651bfad3d5037cbef8309acc74b5f28e", "reflex/components/recharts/charts.pyi": "2f0a39f9c02de83d9e2d97763b4411af", "reflex/components/recharts/general.pyi": "06d0e97776cc82b946fed465ab36fba4", - "reflex/components/recharts/polar.pyi": "71fb8c747e56b4f6bc72bdade16c1385", - "reflex/components/recharts/recharts.pyi": "24a35f769a10a51dbd6d4cbff3b2f071", + "reflex/components/recharts/polar.pyi": "77ca6e0d992f5d5c0479de73db4f71ba", + "reflex/components/recharts/recharts.pyi": "bbaec232c2da035b31b5d0e3888f4801", "reflex/components/sonner/toast.pyi": "6dc6d5d05d9a8d7d364c0326fb2e6503", "reflex/components/suneditor/editor.pyi": "0a6dcab61cc2d750488601e3808080d9", "reflex/experimental/layout.pyi": "fb4c52b954431d9a927fbdd612b562eb" diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index 047cc884dc8..8ca51f98f54 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -5,7 +5,6 @@ from collections.abc import Sequence from typing import Any, ClassVar -from reflex.components.component import Component from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler, no_args_event_spec @@ -76,7 +75,7 @@ class Axis(Recharts): reversed: Var[bool] # The label of axis, which appears next to the axis. - label: Var[str | int | Component | dict[str, Any]] + label: Var[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'. Default: "auto" scale: Var[LiteralScale] @@ -91,7 +90,7 @@ class Axis(Recharts): ticks: Var[Sequence[str | int]] # If set false, no ticks will be drawn. - tick: Var[bool | dict | Component] + tick: Var[bool | dict] # The count of axis ticks. Not used if 'type' is 'category'. Default: 5 tick_count: Var[int] @@ -278,7 +277,7 @@ class Cartesian(Recharts): legend_type: Var[LiteralLegendType] # 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[bool | dict[str, Any] | Component] + label: Var[bool | dict[str, Any]] # If set false, animation of bar will be disabled. Default: True is_animation_active: Var[bool] @@ -657,7 +656,7 @@ class Reference(Recharts): if_overflow: Var[LiteralIfOverflow] # If set a string or a number, default label will be drawn, and the option is content. - label: Var[str | int | Component] + label: Var[str | int] # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False is_front: Var[bool] @@ -848,7 +847,7 @@ class CartesianAxis(Grid): axis_line: Var[bool | dict] # If set false, no ticks will be drawn. - tick: Var[bool | dict | Component] + tick: Var[bool | dict] # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True tick_line: Var[bool] @@ -860,7 +859,7 @@ class CartesianAxis(Grid): interval: Var[LiteralInterval] # If set a string or a number, default label will be drawn, and the option is content. - label: Var[str | int | Component] + label: Var[str | int] # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: Var[bool] diff --git a/reflex/components/recharts/polar.py b/reflex/components/recharts/polar.py index cfa4751bf44..5e881cf6de5 100644 --- a/reflex/components/recharts/polar.py +++ b/reflex/components/recharts/polar.py @@ -5,7 +5,6 @@ from collections.abc import Sequence from typing import Any, ClassVar -from reflex.components.component import Component from reflex.constants import EventTriggers from reflex.constants.colors import Color from reflex.event import EventHandler, no_args_event_spec @@ -67,10 +66,10 @@ class Pie(Recharts): legend_type: Var[LiteralLegendType] # 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[bool | dict[str, Any] | Component] = Var.create(False) + label: Var[bool | dict[str, Any]] = Var.create(False) # 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 - label_line: Var[bool | dict[str, Any] | Component] + label_line: Var[bool | dict[str, Any]] # Valid children components _valid_children: ClassVar[list[str]] = ["Cell", "LabelList", "Bare"] @@ -143,7 +142,7 @@ class Radar(Recharts): legend_type: Var[LiteralLegendType] # If false set, labels will not be drawn. Default: True - label: Var[bool | dict[str, Any] | Component] + label: Var[bool | dict[str, Any]] # If set false, animation of polygon will be disabled. Default: True in CSR, and False in SSR is_animation_active: Var[bool] @@ -192,10 +191,10 @@ class RadialBar(Recharts): legend_type: Var[LiteralLegendType] # 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[bool | dict[str, Any] | Component] + label: Var[bool | dict[str, Any]] # If false set, background sector will not be drawn. Default: False - background: Var[bool | dict[str, Any] | Component] + background: Var[bool | dict[str, Any]] # If set false, animation of radial bars will be disabled. Default: True is_animation_active: Var[bool] diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index d767e170ce4..fb2e9695295 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -127,4 +127,4 @@ class RechartsCharts(NoSSRComponent, MemoizationLeaf): ] LiteralSyncMethod = Literal["index", "value"] -ACTIVE_DOT_TYPE = bool | dict[str, Any] | Component +ACTIVE_DOT_TYPE = bool | dict[str, Any]