Hanson/radial bar chart (#3532)

* refactored event triggers

* update eventhandler method

* updated pyi files

* .

* Update pyi

* new pyis

* lower passing bar for test coverage to 60

---------

Co-authored-by: Hongyu Yao <hongyuyao@hongyus-mbp-3.lan>
Co-authored-by: Nikhil Rao <nikhil@reflex.dev>
Co-authored-by: Hongyu Yao <hongyuyao@Hongyus-MacBook-Pro-3.local>
This commit is contained in:
HongyuHansonYao 2024-06-20 21:41:10 -07:00 committed by GitHub
parent c2c6286537
commit f41e852b0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 89 additions and 29 deletions

View File

@ -11,7 +11,7 @@ omit =
[report]
show_missing = true
# TODO bump back to 79
fail_under = 66
fail_under = 60
precision = 2
# Regexes for lines to exclude from consideration

View File

@ -385,18 +385,6 @@ class RadialBarChart(ChartBase):
"RadialBar",
]
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
"""Get the event triggers that pass the component's value to the handler.
Returns:
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
EventTriggers.ON_CLICK: lambda: [],
EventTriggers.ON_MOUSE_ENTER: lambda: [],
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
}
class ScatterChart(ChartBase):
"""A Scatter chart component in Recharts."""

View File

@ -798,7 +798,6 @@ class RadarChart(ChartBase):
...
class RadialBarChart(ChartBase):
def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
@overload
@classmethod
def create( # type: ignore
@ -823,15 +822,51 @@ class RadialBarChart(ChartBase):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_leave: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_move: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_out: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
) -> "RadialBarChart":
"""Create a chart component.

View File

@ -5,6 +5,7 @@ from __future__ import annotations
from typing import Any, Dict, List, Union
from reflex.constants import EventTriggers
from reflex.event import EventHandler
from reflex.vars import Var
from .recharts import (
@ -216,23 +217,32 @@ class PolarAngleAxis(Recharts):
# Allow the axis has duplicated categorys or not when the type of axis is "category".
allow_duplicated_category: Var[bool]
# Valid children components
# Valid children components.
_valid_children: List[str] = ["Label"]
def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
"""Get the event triggers that pass the component's value to the handler.
# The customized event handler of click on the ticks of this axis.
on_click: EventHandler[lambda: []]
Returns:
A dict mapping the event trigger to the var that is passed to the handler.
"""
return {
EventTriggers.ON_CLICK: lambda: [],
EventTriggers.ON_MOUSE_MOVE: lambda: [],
EventTriggers.ON_MOUSE_OVER: lambda: [],
EventTriggers.ON_MOUSE_OUT: lambda: [],
EventTriggers.ON_MOUSE_ENTER: lambda: [],
EventTriggers.ON_MOUSE_LEAVE: lambda: [],
}
# The customized event handler of mousedown on the the ticks of this axis.
on_mouse_down: EventHandler[lambda: []]
# The customized event handler of mouseup on the ticks of this axis.
on_mouse_up: EventHandler[lambda: []]
# The customized event handler of mousemove on the ticks of this axis.
on_mouse_move: EventHandler[lambda: []]
# The customized event handler of mouseover on the ticks of this axis.
on_mouse_over: EventHandler[lambda: []]
# The customized event handler of mouseout on the ticks of this axis.
on_mouse_out: EventHandler[lambda: []]
# The customized event handler of moustenter on the ticks of this axis.
on_mouse_enter: EventHandler[lambda: []]
# The customized event handler of mouseleave on the ticks of this axis.
on_mouse_leave: EventHandler[lambda: []]
class PolarGrid(Recharts):

View File

@ -9,6 +9,7 @@ from reflex.event import EventChain, EventHandler, EventSpec
from reflex.style import Style
from typing import Any, Dict, List, Union
from reflex.constants import EventTriggers
from reflex.event import EventHandler
from reflex.vars import Var
from .recharts import (
LiteralAnimationEasing,
@ -298,7 +299,6 @@ class RadialBar(Recharts):
...
class PolarAngleAxis(Recharts):
def get_event_triggers(self) -> dict[str, Union[Var, Any]]: ...
@overload
@classmethod
def create( # type: ignore
@ -325,9 +325,27 @@ class PolarAngleAxis(Recharts):
class_name: Optional[Any] = None,
autofocus: Optional[bool] = None,
custom_attrs: Optional[Dict[str, Union[Var, str]]] = None,
on_blur: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_context_menu: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_double_click: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_focus: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_down: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_enter: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
@ -343,6 +361,15 @@ class PolarAngleAxis(Recharts):
on_mouse_over: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_mouse_up: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_scroll: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
on_unmount: Optional[
Union[EventHandler, EventSpec, list, function, BaseVar]
] = None,
**props
) -> "PolarAngleAxis":
"""Create the component.