cartesian.py 32 KB

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