cartesian.py 31 KB

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