cartesian.py 27 KB

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