From 3da1a8d0826f137ac2134aaf5783822bd52264bb Mon Sep 17 00:00:00 2001 From: Carlos <36110765+carlosabadia@users.noreply.github.com> Date: Fri, 11 Oct 2024 00:10:42 +0200 Subject: [PATCH] default props comment for Axis (#4109) * default props comment for Axis * update --- reflex/components/recharts/cartesian.py | 40 +++-- reflex/components/recharts/cartesian.pyi | 180 +++++++++++++++++------ reflex/components/recharts/recharts.py | 4 + reflex/components/recharts/recharts.pyi | 4 + 4 files changed, 167 insertions(+), 61 deletions(-) diff --git a/reflex/components/recharts/cartesian.py b/reflex/components/recharts/cartesian.py index 45ed0aea4..153d3fb2a 100644 --- a/reflex/components/recharts/cartesian.py +++ b/reflex/components/recharts/cartesian.py @@ -15,6 +15,7 @@ from .recharts import ( LiteralDirection, LiteralIfOverflow, LiteralInterval, + LiteralIntervalAxis, LiteralLayout, LiteralLegendType, LiteralLineType, @@ -24,6 +25,7 @@ from .recharts import ( LiteralPolarRadiusType, LiteralScale, LiteralShape, + LiteralTextAnchor, Recharts, ) @@ -34,7 +36,7 @@ class Axis(Recharts): # The key of data displayed in the axis. data_key: Var[Union[str, int]] - # If set true, the axis do not display in the chart. + # If set true, the axis do not display in the chart. Default: False hide: Var[bool] # The width of axis which is usually calculated internally. @@ -46,28 +48,34 @@ class Axis(Recharts): # The type of axis 'number' | 'category' type_: Var[LiteralPolarRadiusType] - # Allow the ticks of XAxis to be decimals or not. + # If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + interval: Var[Union[LiteralIntervalAxis, int]] + + # Allow the ticks of Axis to be decimals or not. Default: True allow_decimals: Var[bool] - # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. + # When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False allow_data_overflow: Var[bool] - # Allow the axis has duplicated categorys or not when the type of axis is "category". + # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True allow_duplicated_category: Var[bool] - # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. + # The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + domain: Var[List] + + # If set false, no axis line will be drawn. Default: True axis_line: Var[bool] - # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. + # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False mirror: Var[bool] - # Reverse the ticks or not. + # Reverse the ticks or not. Default: False 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 + # 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] # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart. @@ -82,23 +90,23 @@ class Axis(Recharts): # If set false, no ticks will be drawn. tick: Var[bool] - # The count of axis ticks. + # The count of axis ticks. Not used if 'type' is 'category'. Default: 5 tick_count: Var[int] - # If set false, no axis tick lines will be drawn. - tick_line: Var[bool] = LiteralVar.create(False) + # If set false, no axis tick lines will be drawn. Default: True + tick_line: Var[bool] - # The length of tick line. + # The length of tick line. Default: 6 tick_size: Var[int] - # The minimum gap between two adjacent labels + # The minimum gap between two adjacent labels. Default: 5 min_tick_gap: Var[int] - # The stroke color of axis + # The stroke color of axis. Default: rx.color("gray", 9) stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9)) - # The text anchor of axis - text_anchor: Var[str] # 'start', 'middle', 'end' + # The text anchor of axis. Default: "middle" + text_anchor: Var[LiteralTextAnchor] # The customized event handler of click on the ticks of this axis on_click: EventHandler[empty_event] diff --git a/reflex/components/recharts/cartesian.pyi b/reflex/components/recharts/cartesian.pyi index 113790418..3205ee689 100644 --- a/reflex/components/recharts/cartesian.pyi +++ b/reflex/components/recharts/cartesian.pyi @@ -27,9 +27,32 @@ class Axis(Recharts): type_: Optional[ Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] + ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, @@ -87,7 +110,12 @@ class Axis(Recharts): tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, - text_anchor: Optional[Union[Var[str], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -136,28 +164,30 @@ class Axis(Recharts): Args: *children: The children of the component. data_key: The key of data displayed in the axis. - hide: If set true, the axis do not display in the chart. + hide: If set true, the axis do not display in the chart. Default: False width: The width of axis which is usually calculated internally. height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - 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. + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False 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 + 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'. Default: "auto" 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. ticks: Set the values of axis ticks manually. tick: If set false, no ticks will be drawn. - tick_count: The count of axis ticks. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -191,9 +221,32 @@ class XAxis(Axis): type_: Optional[ Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] + ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, @@ -251,7 +304,12 @@ class XAxis(Axis): tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, - text_anchor: Optional[Union[Var[str], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -305,28 +363,30 @@ class XAxis(Axis): angle: The angle of axis ticks. Default: 0 padding: Specify the padding of x-axis. Default: {"left": 0, "right": 0} data_key: The key of data displayed in the axis. - hide: If set true, the axis do not display in the chart. + hide: If set true, the axis do not display in the chart. Default: False width: The width of axis which is usually calculated internally. height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - 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. + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False 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 + 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'. Default: "auto" 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. ticks: Set the values of axis ticks manually. tick: If set false, no ticks will be drawn. - tick_count: The count of axis ticks. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" style: The style of the component. key: A unique key for the component. id: The id for the component. @@ -358,9 +418,32 @@ class YAxis(Axis): type_: Optional[ Union[Literal["category", "number"], Var[Literal["category", "number"]]] ] = None, + interval: Optional[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + Var[ + Union[ + Literal[ + "equidistantPreserveStart", + "preserveEnd", + "preserveStart", + "preserveStartEnd", + ], + int, + ] + ], + int, + ] + ] = None, allow_decimals: Optional[Union[Var[bool], bool]] = None, allow_data_overflow: Optional[Union[Var[bool], bool]] = None, allow_duplicated_category: Optional[Union[Var[bool], bool]] = None, + domain: Optional[Union[List, Var[List]]] = None, axis_line: Optional[Union[Var[bool], bool]] = None, mirror: Optional[Union[Var[bool], bool]] = None, reversed: Optional[Union[Var[bool], bool]] = None, @@ -418,7 +501,12 @@ class YAxis(Axis): tick_size: Optional[Union[Var[int], int]] = None, min_tick_gap: Optional[Union[Var[int], int]] = None, stroke: Optional[Union[Color, Var[Union[Color, str]], str]] = None, - text_anchor: Optional[Union[Var[str], str]] = None, + text_anchor: Optional[ + Union[ + Literal["end", "middle", "start"], + Var[Literal["end", "middle", "start"]], + ] + ] = None, style: Optional[Style] = None, key: Optional[Any] = None, id: Optional[Any] = None, @@ -470,28 +558,30 @@ class YAxis(Axis): y_axis_id: The id of y-axis which is corresponding to the data. Default: 0 padding: Specify the padding of y-axis. Default: {"top": 0, "bottom": 0} data_key: The key of data displayed in the axis. - hide: If set true, the axis do not display in the chart. + hide: If set true, the axis do not display in the chart. Default: False width: The width of axis which is usually calculated internally. height: The height of axis, which can be setted by user. type_: The type of axis 'number' | 'category' - allow_decimals: Allow the ticks of XAxis to be decimals or not. - allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. - allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". - 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. + interval: If set 0, all the ticks will be shown. If set preserveStart", "preserveEnd" or "preserveStartEnd", the ticks which is to be shown or hidden will be calculated automatically. Default: "preserveEnd" + allow_decimals: Allow the ticks of Axis to be decimals or not. Default: True + allow_data_overflow: When domain of the axis is specified and the type of the axis is 'number', if allowDataOverflow is set to be false, the domain will be adjusted when the minimum value of data is smaller than domain[0] or the maximum value of data is greater than domain[1] so that the axis displays all data values. If set to true, graphic elements (line, area, bars) will be clipped to conform to the specified domain. Default: False + allow_duplicated_category: Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True + domain: The range of the axis. Work best in conjuction with allow_data_overflow. Default: [0, "auto"] + axis_line: If set false, no axis line will be drawn. Default: True + mirror: If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False + reversed: Reverse the ticks or not. Default: False 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 + 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'. Default: "auto" 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. ticks: Set the values of axis ticks manually. tick: If set false, no ticks will be drawn. - tick_count: The count of axis ticks. - tick_line: If set false, no axis tick lines will be drawn. - tick_size: The length of tick line. - min_tick_gap: The minimum gap between two adjacent labels - stroke: The stroke color of axis - text_anchor: The text anchor of axis + tick_count: The count of axis ticks. Not used if 'type' is 'category'. Default: 5 + tick_line: If set false, no axis tick lines will be drawn. Default: True + tick_size: The length of tick line. Default: 6 + min_tick_gap: The minimum gap between two adjacent labels. Default: 5 + stroke: The stroke color of axis. Default: rx.color("gray", 9) + text_anchor: The text anchor of axis. Default: "middle" style: The style of the component. key: A unique key for the component. id: The id for the component. diff --git a/reflex/components/recharts/recharts.py b/reflex/components/recharts/recharts.py index a9b54af83..9068cb396 100644 --- a/reflex/components/recharts/recharts.py +++ b/reflex/components/recharts/recharts.py @@ -60,6 +60,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -133,4 +134,7 @@ LiteralAreaType = Literal[ ] LiteralDirection = Literal["x", "y"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] +LiteralIntervalAxis = Literal[ + "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart" +] LiteralSyncMethod = Literal["index", "value"] diff --git a/reflex/components/recharts/recharts.pyi b/reflex/components/recharts/recharts.pyi index 14065a213..71d308ce3 100644 --- a/reflex/components/recharts/recharts.pyi +++ b/reflex/components/recharts/recharts.pyi @@ -171,6 +171,7 @@ LiteralScale = Literal[ "sequential", "threshold", ] +LiteralTextAnchor = Literal["start", "middle", "end"] LiteralLayout = Literal["horizontal", "vertical"] LiteralPolarRadiusType = Literal["number", "category"] LiteralGridType = Literal["polygon", "circle"] @@ -244,4 +245,7 @@ LiteralAreaType = Literal[ ] LiteralDirection = Literal["x", "y"] LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"] +LiteralIntervalAxis = Literal[ + "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart" +] LiteralSyncMethod = Literal["index", "value"]