cartesian.py 29 KB

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