cartesian.py 34 KB

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