cartesian.py 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886
  1. """Cartesian charts in Recharts."""
  2. from __future__ import annotations
  3. from typing import Any, Dict, List, Union
  4. from reflex.constants import EventTriggers
  5. from reflex.constants.colors import Color
  6. from reflex.event import EventHandler, no_args_event_spec
  7. from reflex.vars.base import LiteralVar, Var
  8. from .recharts import (
  9. LiteralAnimationEasing,
  10. LiteralAreaType,
  11. LiteralDirection,
  12. LiteralIfOverflow,
  13. LiteralInterval,
  14. LiteralIntervalAxis,
  15. LiteralLayout,
  16. LiteralLegendType,
  17. LiteralLineType,
  18. LiteralOrientationLeftRight,
  19. LiteralOrientationTopBottom,
  20. LiteralOrientationTopBottomLeftRight,
  21. LiteralPolarRadiusType,
  22. LiteralScale,
  23. LiteralShape,
  24. LiteralTextAnchor,
  25. Recharts,
  26. )
  27. class Axis(Recharts):
  28. """A base class for axes in Recharts."""
  29. # The key of data displayed in the axis.
  30. data_key: Var[Union[str, int]]
  31. # If set true, the axis do not display in the chart. Default: False
  32. hide: Var[bool]
  33. # The width of axis which is usually calculated internally.
  34. width: Var[Union[str, int]]
  35. # The height of axis, which can be set by user.
  36. height: Var[Union[str, int]]
  37. # The type of axis 'number' | 'category'
  38. type_: Var[LiteralPolarRadiusType]
  39. # 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"
  40. interval: Var[Union[LiteralIntervalAxis, int]]
  41. # Allow the ticks of Axis to be decimals or not. Default: True
  42. allow_decimals: Var[bool]
  43. # 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
  44. allow_data_overflow: Var[bool]
  45. # Allow the axis has duplicated categorys or not when the type of axis is "category". Default: True
  46. allow_duplicated_category: Var[bool]
  47. # The range of the axis. Work best in conjunction with allow_data_overflow. Default: [0, "auto"]
  48. domain: Var[List]
  49. # If set false, no axis line will be drawn. Default: True
  50. axis_line: Var[bool]
  51. # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
  52. mirror: Var[bool]
  53. # Reverse the ticks or not. Default: False
  54. reversed: Var[bool]
  55. # The label of axis, which appears next to the axis.
  56. label: Var[Union[str, int, Dict[str, Any]]]
  57. # 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"
  58. scale: Var[LiteralScale]
  59. # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
  60. unit: Var[Union[str, int]]
  61. # The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
  62. name: Var[Union[str, int]]
  63. # Set the values of axis ticks manually.
  64. ticks: Var[List[Union[str, int]]]
  65. # If set false, no ticks will be drawn.
  66. tick: Var[bool]
  67. # The count of axis ticks. Not used if 'type' is 'category'. Default: 5
  68. tick_count: Var[int]
  69. # If set false, no axis tick lines will be drawn. Default: True
  70. tick_line: Var[bool]
  71. # The length of tick line. Default: 6
  72. tick_size: Var[int]
  73. # The minimum gap between two adjacent labels. Default: 5
  74. min_tick_gap: Var[int]
  75. # The stroke color of axis. Default: rx.color("gray", 9)
  76. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9))
  77. # The text anchor of axis. Default: "middle"
  78. text_anchor: Var[LiteralTextAnchor]
  79. # The customized event handler of click on the ticks of this axis
  80. on_click: EventHandler[no_args_event_spec]
  81. # The customized event handler of mousedown on the ticks of this axis
  82. on_mouse_down: EventHandler[no_args_event_spec]
  83. # The customized event handler of mouseup on the ticks of this axis
  84. on_mouse_up: EventHandler[no_args_event_spec]
  85. # The customized event handler of mousemove on the ticks of this axis
  86. on_mouse_move: EventHandler[no_args_event_spec]
  87. # The customized event handler of mouseout on the ticks of this axis
  88. on_mouse_out: EventHandler[no_args_event_spec]
  89. # The customized event handler of mouseenter on the ticks of this axis
  90. on_mouse_enter: EventHandler[no_args_event_spec]
  91. # The customized event handler of mouseleave on the ticks of this axis
  92. on_mouse_leave: EventHandler[no_args_event_spec]
  93. class XAxis(Axis):
  94. """An XAxis component in Recharts."""
  95. tag = "XAxis"
  96. alias = "RechartsXAxis"
  97. # The orientation of axis 'top' | 'bottom'. Default: "bottom"
  98. orientation: Var[LiteralOrientationTopBottom]
  99. # The id of x-axis which is corresponding to the data. Default: 0
  100. x_axis_id: Var[Union[str, int]]
  101. # Ensures that all datapoints within a chart contribute to its domain calculation, even when they are hidden. Default: False
  102. include_hidden: Var[bool]
  103. # The angle of axis ticks. Default: 0
  104. angle: Var[int]
  105. # Specify the padding of x-axis. Default: {"left": 0, "right": 0}
  106. padding: Var[Dict[str, int]]
  107. class YAxis(Axis):
  108. """A YAxis component in Recharts."""
  109. tag = "YAxis"
  110. alias = "RechartsYAxis"
  111. # The orientation of axis 'left' | 'right'. Default: "left"
  112. orientation: Var[LiteralOrientationLeftRight]
  113. # The id of y-axis which is corresponding to the data. Default: 0
  114. y_axis_id: Var[Union[str, int]]
  115. # Specify the padding of y-axis. Default: {"top": 0, "bottom": 0}
  116. padding: Var[Dict[str, int]]
  117. class ZAxis(Recharts):
  118. """A ZAxis component in Recharts."""
  119. tag = "ZAxis"
  120. alias = "RechartsZAxis"
  121. # The key of data displayed in the axis.
  122. data_key: Var[Union[str, int]]
  123. # The unique id of z-axis. Default: 0
  124. z_axis_id: Var[Union[str, int]]
  125. # The range of axis. Default: [10, 10]
  126. range: Var[List[int]]
  127. # The unit of data displayed in the axis. This option will be used to represent an index unit in a scatter chart.
  128. unit: Var[Union[str, int]]
  129. # The name of data displayed in the axis. This option will be used to represent an index in a scatter chart.
  130. name: Var[Union[str, int]]
  131. # If 'auto' set, the scale function is decided by the type of chart, and the props type. Default: "auto"
  132. scale: Var[LiteralScale]
  133. class Brush(Recharts):
  134. """A Brush component in Recharts."""
  135. tag = "Brush"
  136. alias = "RechartsBrush"
  137. # Stroke color. Default: rx.color("gray", 9)
  138. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 9))
  139. # The fill color of brush. Default: rx.color("gray", 2)
  140. fill: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 2))
  141. # The key of data displayed in the axis.
  142. data_key: Var[Union[str, int]]
  143. # The x-coordinate of brush. Default: 0
  144. x: Var[int]
  145. # The y-coordinate of brush. Default: 0
  146. y: Var[int]
  147. # The width of brush. Default: 0
  148. width: Var[int]
  149. # The height of brush. Default: 40
  150. height: Var[int]
  151. # The original data of a LineChart, a BarChart or an AreaChart.
  152. data: Var[List[Any]]
  153. # The width of each traveller. Default: 5
  154. traveller_width: Var[int]
  155. # The data with gap of refreshing chart. If the option is not set, the chart will be refreshed every time. Default: 1
  156. gap: Var[int]
  157. # The default start index of brush. If the option is not set, the start index will be 0. Default: 0
  158. start_index: Var[int]
  159. # The default end index of brush. If the option is not set, the end index will be calculated by the length of data.
  160. end_index: Var[int]
  161. # The fill color of brush
  162. fill: Var[Union[str, Color]]
  163. # The stroke color of brush
  164. stroke: Var[Union[str, Color]]
  165. def get_event_triggers(self) -> dict[str, Union[Var, Any]]:
  166. """Get the event triggers that pass the component's value to the handler.
  167. Returns:
  168. A dict mapping the event trigger to the var that is passed to the handler.
  169. """
  170. return {
  171. EventTriggers.ON_CHANGE: no_args_event_spec,
  172. }
  173. class Cartesian(Recharts):
  174. """A base class for cartesian charts in Recharts."""
  175. # The layout of bar in the chart, usually inherited from parent. 'horizontal' | 'vertical'
  176. layout: Var[LiteralLayout]
  177. # The key of a group of data which should be unique in an area chart.
  178. data_key: Var[Union[str, int]]
  179. # The id of x-axis which is corresponding to the data. Default: 0
  180. x_axis_id: Var[Union[str, int]]
  181. # The id of y-axis which is corresponding to the data. Default: 0
  182. y_axis_id: Var[Union[str, int]]
  183. # 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
  184. legend_type: Var[LiteralLegendType]
  185. # If set false, animation of bar will be disabled. Default: True
  186. is_animation_active: Var[bool]
  187. # Specifies when the animation should begin, the unit of this option is ms. Default: 0
  188. animation_begin: Var[int]
  189. # Specifies the duration of animation, the unit of this option is ms. Default: 1500
  190. animation_duration: Var[int]
  191. # The type of easing function. Default: "ease"
  192. animation_easing: Var[LiteralAnimationEasing]
  193. # The unit of data. This option will be used in tooltip.
  194. unit: Var[Union[str, int]]
  195. # The name of data. This option will be used in tooltip and legend to represent the component. If no value was set to this option, the value of dataKey will be used alternatively.
  196. name: Var[Union[str, int]]
  197. # The customized event handler of animation start
  198. on_animation_start: EventHandler[no_args_event_spec]
  199. # The customized event handler of animation end
  200. on_animation_end: EventHandler[no_args_event_spec]
  201. # The customized event handler of click on the component in this group
  202. on_click: EventHandler[no_args_event_spec]
  203. # The customized event handler of mousedown on the component in this group
  204. on_mouse_down: EventHandler[no_args_event_spec]
  205. # The customized event handler of mouseup on the component in this group
  206. on_mouse_up: EventHandler[no_args_event_spec]
  207. # The customized event handler of mousemove on the component in this group
  208. on_mouse_move: EventHandler[no_args_event_spec]
  209. # The customized event handler of mouseover on the component in this group
  210. on_mouse_over: EventHandler[no_args_event_spec]
  211. # The customized event handler of mouseout on the component in this group
  212. on_mouse_out: EventHandler[no_args_event_spec]
  213. # The customized event handler of mouseenter on the component in this group
  214. on_mouse_enter: EventHandler[no_args_event_spec]
  215. # The customized event handler of mouseleave on the component in this group
  216. on_mouse_leave: EventHandler[no_args_event_spec]
  217. class Area(Cartesian):
  218. """An Area component in Recharts."""
  219. tag = "Area"
  220. alias = "RechartsArea"
  221. # The color of the line stroke. Default: rx.color("accent", 9)
  222. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
  223. # The width of the line stroke. Default: 1
  224. stroke_width: Var[int]
  225. # The color of the area fill. Default: rx.color("accent", 5)
  226. fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 5))
  227. # 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"
  228. type_: Var[LiteralAreaType] = LiteralVar.create("monotone")
  229. # If false set, dots will not be drawn. If true set, dots will be drawn which have the props calculated internally. Default: False
  230. dot: Var[Union[bool, Dict[str, Any]]]
  231. # 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)}
  232. active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
  233. {
  234. "stroke": Color("accent", 2),
  235. "fill": Color("accent", 10),
  236. }
  237. )
  238. # If set false, labels will not be drawn. If set true, labels will be drawn which have the props calculated internally. Default: False
  239. label: Var[bool]
  240. # The value which can describle the line, usually calculated internally.
  241. base_line: Var[Union[str, List[Dict[str, Any]]]]
  242. # The coordinates of all the points in the area, usually calculated internally.
  243. points: Var[List[Dict[str, Any]]]
  244. # The stack id of area, when two areas have the same value axis and same stack_id, then the two areas are stacked in order.
  245. stack_id: Var[Union[str, int]]
  246. # Whether to connect a graph area across null points. Default: False
  247. connect_nulls: Var[bool]
  248. # Valid children components
  249. _valid_children: List[str] = ["LabelList"]
  250. class Bar(Cartesian):
  251. """A Bar component in Recharts."""
  252. tag = "Bar"
  253. alias = "RechartsBar"
  254. # The color of the line stroke.
  255. stroke: Var[Union[str, Color]]
  256. # The width of the line stroke.
  257. stroke_width: Var[int]
  258. # The width of the line stroke. Default: Color("accent", 9)
  259. fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
  260. # 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
  261. background: Var[bool]
  262. # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
  263. label: Var[bool]
  264. # 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.
  265. stack_id: Var[str]
  266. # The unit of data. This option will be used in tooltip.
  267. unit: Var[Union[str, int]]
  268. # The minimal height of a bar in a horizontal BarChart, or the minimal width of a bar in a vertical BarChart. By default, 0 values are not shown. To visualize a 0 (or close to zero) point, set the minimal point size to a pixel value like 3. In stacked bar charts, minPointSize might not be respected for tightly packed values. So we strongly recommend not using this prop in stacked BarCharts.
  269. min_point_size: Var[int]
  270. # The name of data. This option will be used in tooltip and legend to represent a bar. If no value was set to this option, the value of dataKey will be used alternatively.
  271. name: Var[Union[str, int]]
  272. # Size of the bar (if one bar_size is set then a bar_size must be set for all bars)
  273. bar_size: Var[int]
  274. # Max size of the bar
  275. max_bar_size: Var[int]
  276. # If set a value, the option is the radius of all the rounded corners. If set a array, the option are in turn the radiuses of top-left corner, top-right corner, bottom-right corner, bottom-left corner. Default: 0
  277. radius: Var[Union[int, List[int]]]
  278. # The active bar is shown when a user enters a bar chart and this chart has tooltip. If set to false, no active bar will be drawn. If set to true, active bar will be drawn with the props calculated internally. If passed an object, active bar will be drawn, and the internally calculated props will be merged with the key value pairs of the passed object.
  279. # active_bar: Var[Union[bool, Dict[str, Any]]] #noqa: ERA001
  280. # Valid children components
  281. _valid_children: List[str] = ["Cell", "LabelList", "ErrorBar"]
  282. class Line(Cartesian):
  283. """A Line component in Recharts."""
  284. tag = "Line"
  285. alias = "RechartsLine"
  286. # The interpolation type of line. And customized interpolation function can be set to type. It's the same as type in Area.
  287. type_: Var[LiteralAreaType]
  288. # The color of the line stroke. Default: rx.color("accent", 9)
  289. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
  290. # The width of the line stroke. Default: 1
  291. stroke_width: Var[int]
  292. # 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)}
  293. dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
  294. {
  295. "stroke": Color("accent", 10),
  296. "fill": Color("accent", 4),
  297. }
  298. )
  299. # 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)}
  300. active_dot: Var[Union[bool, Dict[str, Any]]] = LiteralVar.create(
  301. {
  302. "stroke": Color("accent", 2),
  303. "fill": Color("accent", 10),
  304. }
  305. )
  306. # If false set, labels will not be drawn. If true set, labels will be drawn which have the props calculated internally. Default: False
  307. label: Var[bool]
  308. # Hides the line when true, useful when toggling visibility state via legend. Default: False
  309. hide: Var[bool]
  310. # Whether to connect a graph line across null points.
  311. connect_nulls: Var[bool]
  312. # The unit of data. This option will be used in tooltip.
  313. unit: Var[Union[str, int]]
  314. # The coordinates of all the points in the line, usually calculated internally.
  315. points: Var[List[Dict[str, Any]]]
  316. # The pattern of dashes and gaps used to paint the line.
  317. stroke_dasharray: Var[str]
  318. # Valid children components
  319. _valid_children: List[str] = ["LabelList", "ErrorBar"]
  320. class Scatter(Recharts):
  321. """A Scatter component in Recharts."""
  322. tag = "Scatter"
  323. alias = "RechartsScatter"
  324. # The source data, in which each element is an object.
  325. data: Var[List[Dict[str, Any]]]
  326. # The type of icon in legend. If set to 'none', no legend item will be rendered. 'line' | 'plainline' | 'square' | 'rect'| 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye' | 'none'. Default: "circle"
  327. legend_type: Var[LiteralLegendType]
  328. # The id of x-axis which is corresponding to the data. Default: 0
  329. x_axis_id: Var[Union[str, int]]
  330. # The id of y-axis which is corresponding to the data. Default: 0
  331. y_axis_id: Var[Union[str, int]]
  332. # The id of z-axis which is corresponding to the data. Default: 0
  333. z_axis_id: Var[Union[str, int]]
  334. # If false set, line will not be drawn. If true set, line will be drawn which have the props calculated internally. Default: False
  335. line: Var[bool]
  336. # If a string set, specified symbol will be used to show scatter item. 'circle' | 'cross' | 'diamond' | 'square' | 'star' | 'triangle' | 'wye'. Default: "circle"
  337. shape: Var[LiteralShape]
  338. # If 'joint' set, line will generated by just jointing all the points. If 'fitting' set, line will be generated by fitting algorithm. 'joint' | 'fitting'. Default: "joint"
  339. line_type: Var[LiteralLineType]
  340. # The fill color of the scatter. Default: rx.color("accent", 9)
  341. fill: Var[Union[str, Color]] = LiteralVar.create(Color("accent", 9))
  342. # Valid children components.
  343. _valid_children: List[str] = ["LabelList", "ErrorBar"]
  344. # If set false, animation of bar will be disabled. Default: True in CSR, False in SSR
  345. is_animation_active: Var[bool]
  346. # Specifies when the animation should begin, the unit of this option is ms. Default: 0
  347. animation_begin: Var[int]
  348. # Specifies the duration of animation, the unit of this option is ms. Default: 1500
  349. animation_duration: Var[int]
  350. # The type of easing function. Default: "ease"
  351. animation_easing: Var[LiteralAnimationEasing]
  352. # The customized event handler of click on the component in this group
  353. on_click: EventHandler[no_args_event_spec]
  354. # The customized event handler of mousedown on the component in this group
  355. on_mouse_down: EventHandler[no_args_event_spec]
  356. # The customized event handler of mouseup on the component in this group
  357. on_mouse_up: EventHandler[no_args_event_spec]
  358. # The customized event handler of mousemove on the component in this group
  359. on_mouse_move: EventHandler[no_args_event_spec]
  360. # The customized event handler of mouseover on the component in this group
  361. on_mouse_over: EventHandler[no_args_event_spec]
  362. # The customized event handler of mouseout on the component in this group
  363. on_mouse_out: EventHandler[no_args_event_spec]
  364. # The customized event handler of mouseenter on the component in this group
  365. on_mouse_enter: EventHandler[no_args_event_spec]
  366. # The customized event handler of mouseleave on the component in this group
  367. on_mouse_leave: EventHandler[no_args_event_spec]
  368. class Funnel(Recharts):
  369. """A Funnel component in Recharts."""
  370. tag = "Funnel"
  371. alias = "RechartsFunnel"
  372. # The source data, in which each element is an object.
  373. data: Var[List[Dict[str, Any]]]
  374. # The key or getter of a group of data which should be unique in a FunnelChart.
  375. data_key: Var[Union[str, int]]
  376. # The key of each sector's name. Default: "name"
  377. name_key: Var[str]
  378. # The type of icon in legend. If set to 'none', no legend item will be rendered. Default: "line"
  379. legend_type: Var[LiteralLegendType]
  380. # If set false, animation of line will be disabled. Default: True
  381. is_animation_active: Var[bool]
  382. # Specifies when the animation should begin, the unit of this option is ms. Default: 0
  383. animation_begin: Var[int]
  384. # Specifies the duration of animation, the unit of this option is ms. Default: 1500
  385. animation_duration: Var[int]
  386. # The type of easing function. 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'linear'. Default "ease"
  387. animation_easing: Var[LiteralAnimationEasing]
  388. # Stroke color. Default: rx.color("gray", 3)
  389. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 3))
  390. # The coordinates of all the trapezoids in the funnel, usually calculated internally.
  391. trapezoids: Var[List[Dict[str, Any]]]
  392. # Valid children components
  393. _valid_children: List[str] = ["LabelList", "Cell"]
  394. # The customized event handler of animation start
  395. on_animation_start: EventHandler[no_args_event_spec]
  396. # The customized event handler of animation end
  397. on_animation_end: EventHandler[no_args_event_spec]
  398. # The customized event handler of click on the component in this group
  399. on_click: EventHandler[no_args_event_spec]
  400. # The customized event handler of mousedown on the component in this group
  401. on_mouse_down: EventHandler[no_args_event_spec]
  402. # The customized event handler of mouseup on the component in this group
  403. on_mouse_up: EventHandler[no_args_event_spec]
  404. # The customized event handler of mousemove on the component in this group
  405. on_mouse_move: EventHandler[no_args_event_spec]
  406. # The customized event handler of mouseover on the component in this group
  407. on_mouse_over: EventHandler[no_args_event_spec]
  408. # The customized event handler of mouseout on the component in this group
  409. on_mouse_out: EventHandler[no_args_event_spec]
  410. # The customized event handler of mouseenter on the component in this group
  411. on_mouse_enter: EventHandler[no_args_event_spec]
  412. # The customized event handler of mouseleave on the component in this group
  413. on_mouse_leave: EventHandler[no_args_event_spec]
  414. class ErrorBar(Recharts):
  415. """An ErrorBar component in Recharts."""
  416. tag = "ErrorBar"
  417. alias = "RechartsErrorBar"
  418. # Only used for ScatterChart with error bars in two directions. Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
  419. direction: Var[LiteralDirection]
  420. # The key of a group of data which should be unique in an area chart.
  421. data_key: Var[Union[str, int]]
  422. # The width of the error bar ends. Default: 5
  423. width: Var[int]
  424. # The stroke color of error bar. Default: rx.color("gray", 8)
  425. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 8))
  426. # The stroke width of error bar. Default: 1.5
  427. stroke_width: Var[Union[int, float]]
  428. class Reference(Recharts):
  429. """A base class for reference components in Reference."""
  430. # The id of x-axis which is corresponding to the data. Default: 0
  431. x_axis_id: Var[Union[str, int]]
  432. # The id of y-axis which is corresponding to the data. Default: 0
  433. y_axis_id: Var[Union[str, int]]
  434. # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
  435. if_overflow: Var[LiteralIfOverflow]
  436. # If set a string or a number, default label will be drawn, and the option is content.
  437. label: Var[Union[str, int]]
  438. # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
  439. is_front: Var[bool]
  440. class ReferenceLine(Reference):
  441. """A ReferenceLine component in Recharts."""
  442. tag = "ReferenceLine"
  443. alias = "RechartsReferenceLine"
  444. # If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn.
  445. x: Var[Union[str, int]]
  446. # If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn.
  447. y: Var[Union[str, int]]
  448. # The color of the reference line.
  449. stroke: Var[Union[str, Color]]
  450. # The width of the stroke. Default: 1
  451. stroke_width: Var[Union[str, int]]
  452. # Valid children components
  453. _valid_children: List[str] = ["Label"]
  454. # Array of endpoints in { x, y } format. These endpoints would be used to draw the ReferenceLine.
  455. segment: List[Any] = []
  456. class ReferenceDot(Reference):
  457. """A ReferenceDot component in Recharts."""
  458. tag = "ReferenceDot"
  459. alias = "RechartsReferenceDot"
  460. # If set a string or a number, a vertical line perpendicular to the x-axis specified by xAxisId will be drawn. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys, otherwise no line will be drawn.
  461. x: Var[Union[str, int]]
  462. # If set a string or a number, a horizontal line perpendicular to the y-axis specified by yAxisId will be drawn. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys, otherwise no line will be drawn.
  463. y: Var[Union[str, int]]
  464. # The radius of dot.
  465. r: Var[int]
  466. # The color of the area fill.
  467. fill: Var[Union[str, Color]]
  468. # The color of the line stroke.
  469. stroke: Var[Union[str, Color]]
  470. # Valid children components
  471. _valid_children: List[str] = ["Label"]
  472. # The customized event handler of click on the component in this chart
  473. on_click: EventHandler[no_args_event_spec]
  474. # The customized event handler of mousedown on the component in this chart
  475. on_mouse_down: EventHandler[no_args_event_spec]
  476. # The customized event handler of mouseup on the component in this chart
  477. on_mouse_up: EventHandler[no_args_event_spec]
  478. # The customized event handler of mouseover on the component in this chart
  479. on_mouse_over: EventHandler[no_args_event_spec]
  480. # The customized event handler of mouseout on the component in this chart
  481. on_mouse_out: EventHandler[no_args_event_spec]
  482. # The customized event handler of mouseenter on the component in this chart
  483. on_mouse_enter: EventHandler[no_args_event_spec]
  484. # The customized event handler of mousemove on the component in this chart
  485. on_mouse_move: EventHandler[no_args_event_spec]
  486. # The customized event handler of mouseleave on the component in this chart
  487. on_mouse_leave: EventHandler[no_args_event_spec]
  488. class ReferenceArea(Recharts):
  489. """A ReferenceArea component in Recharts."""
  490. tag = "ReferenceArea"
  491. alias = "RechartsReferenceArea"
  492. # Stroke color
  493. stroke: Var[Union[str, Color]]
  494. # Fill color
  495. fill: Var[Union[str, Color]]
  496. # The opacity of area.
  497. fill_opacity: Var[float]
  498. # The id of x-axis which is corresponding to the data.
  499. x_axis_id: Var[Union[str, int]]
  500. # The id of y-axis which is corresponding to the data.
  501. y_axis_id: Var[Union[str, int]]
  502. # A boundary value of the area. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys. If one of x1 or x2 is invalidate, the area will cover along x-axis.
  503. x1: Var[Union[str, int]]
  504. # A boundary value of the area. If the specified x-axis is a number axis, the type of x must be Number. If the specified x-axis is a category axis, the value of x must be one of the categorys. If one of x1 or x2 is invalidate, the area will cover along x-axis.
  505. x2: Var[Union[str, int]]
  506. # A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis.
  507. y1: Var[Union[str, int]]
  508. # A boundary value of the area. If the specified y-axis is a number axis, the type of y must be Number. If the specified y-axis is a category axis, the value of y must be one of the categorys. If one of y1 or y2 is invalidate, the area will cover along y-axis.
  509. y2: Var[Union[str, int]]
  510. # Defines how to draw the reference line if it falls partly outside the canvas. If set to 'discard', the reference line will not be drawn at all. If set to 'hidden', the reference line will be clipped to the canvas. If set to 'visible', the reference line will be drawn completely. If set to 'extendDomain', the domain of the overflown axis will be extended such that the reference line fits into the canvas. Default: "discard"
  511. if_overflow: Var[LiteralIfOverflow]
  512. # If set true, the line will be rendered in front of bars in BarChart, etc. Default: False
  513. is_front: Var[bool]
  514. # Valid children components
  515. _valid_children: List[str] = ["Label"]
  516. class Grid(Recharts):
  517. """A base class for grid components in Recharts."""
  518. # The x-coordinate of grid. Default: 0
  519. x: Var[int]
  520. # The y-coordinate of grid. Default: 0
  521. y: Var[int]
  522. # The width of grid. Default: 0
  523. width: Var[int]
  524. # The height of grid. Default: 0
  525. height: Var[int]
  526. class CartesianGrid(Grid):
  527. """A CartesianGrid component in Recharts."""
  528. tag = "CartesianGrid"
  529. alias = "RechartsCartesianGrid"
  530. # The horizontal line configuration. Default: True
  531. horizontal: Var[bool]
  532. # The vertical line configuration. Default: True
  533. vertical: Var[bool]
  534. # The x-coordinates in pixel values of all vertical lines. Default: []
  535. vertical_points: Var[List[Union[str, int]]]
  536. # The x-coordinates in pixel values of all vertical lines. Default: []
  537. horizontal_points: Var[List[Union[str, int]]]
  538. # The background of grid.
  539. fill: Var[Union[str, Color]]
  540. # The opacity of the background used to fill the space between grid lines.
  541. fill_opacity: Var[float]
  542. # The pattern of dashes and gaps used to paint the lines of the grid.
  543. stroke_dasharray: Var[str]
  544. # the stroke color of grid. Default: rx.color("gray", 7)
  545. stroke: Var[Union[str, Color]] = LiteralVar.create(Color("gray", 7))
  546. class CartesianAxis(Grid):
  547. """A CartesianAxis component in Recharts."""
  548. tag = "CartesianAxis"
  549. alias = "RechartsCartesianAxis"
  550. # The orientation of axis 'top' | 'bottom' | 'left' | 'right'. Default: "bottom"
  551. orientation: Var[LiteralOrientationTopBottomLeftRight]
  552. # The box of viewing area. Default: {"x": 0, "y": 0, "width": 0, "height": 0}
  553. view_box: Var[Dict[str, Any]]
  554. # If set false, no axis line will be drawn. If set a object, the option is the configuration of axis line. Default: True
  555. axis_line: Var[bool]
  556. # If set false, no ticks will be drawn.
  557. tick: Var[bool]
  558. # If set false, no axis tick lines will be drawn. If set a object, the option is the configuration of tick lines. Default: True
  559. tick_line: Var[bool]
  560. # The length of tick line. Default: 6
  561. tick_size: Var[int]
  562. # 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"
  563. interval: Var[LiteralInterval]
  564. # If set a string or a number, default label will be drawn, and the option is content.
  565. label: Var[Union[str, int]]
  566. # If set true, flips ticks around the axis line, displaying the labels inside the chart instead of outside. Default: False
  567. mirror: Var[bool]
  568. # The margin between tick line and tick.
  569. tick_margin: Var[int]
  570. area = Area.create
  571. bar = Bar.create
  572. line = Line.create
  573. scatter = Scatter.create
  574. x_axis = XAxis.create
  575. y_axis = YAxis.create
  576. z_axis = ZAxis.create
  577. brush = Brush.create
  578. cartesian_axis = CartesianAxis.create
  579. cartesian_grid = CartesianGrid.create
  580. reference_line = ReferenceLine.create
  581. reference_dot = ReferenceDot.create
  582. reference_area = ReferenceArea.create
  583. error_bar = ErrorBar.create
  584. funnel = Funnel.create