recharts.py 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. """A component that wraps a recharts lib."""
  2. from typing import Dict, Literal
  3. from reflex.components.component import Component, MemoizationLeaf, NoSSRComponent
  4. from reflex.utils import console
  5. class Recharts(Component):
  6. """A component that wraps a recharts lib."""
  7. library = "recharts@2.12.7"
  8. def render(self) -> Dict:
  9. """Render the tag.
  10. Returns:
  11. The rendered tag.
  12. """
  13. tag = super().render()
  14. if any(p.startswith("css") for p in tag["props"]):
  15. console.warn(
  16. f"CSS props do not work for {self.__class__.__name__}. Consult docs to style it with its own prop."
  17. )
  18. tag["props"] = [p for p in tag["props"] if not p.startswith("css")]
  19. return tag
  20. class RechartsCharts(NoSSRComponent, MemoizationLeaf):
  21. """A component that wraps a recharts lib."""
  22. library = "recharts@2.12.7"
  23. LiteralAnimationEasing = Literal["ease", "ease-in", "ease-out", "ease-in-out", "linear"]
  24. LiteralIfOverflow = Literal["discard", "hidden", "visible", "extendDomain"]
  25. LiteralShape = Literal[
  26. "square", "circle", "cross", "diamond", "star", "triangle", "wye"
  27. ]
  28. LiteralLineType = Literal["joint", "fitting"]
  29. LiteralOrientation = Literal["top", "bottom", "left", "right", "middle"]
  30. LiteralOrientationLeftRightMiddle = Literal["left", "right", "middle"]
  31. LiteralOrientationTopBottom = Literal["top", "bottom"]
  32. LiteralOrientationLeftRight = Literal["left", "right"]
  33. LiteralOrientationTopBottomLeftRight = Literal["top", "bottom", "left", "right"]
  34. LiteralScale = Literal[
  35. "auto",
  36. "linear",
  37. "pow",
  38. "sqrt",
  39. "log",
  40. "identity",
  41. "time",
  42. "band",
  43. "point",
  44. "ordinal",
  45. "quantile",
  46. "quantize",
  47. "utc",
  48. "sequential",
  49. "threshold",
  50. ]
  51. LiteralLayout = Literal["horizontal", "vertical"]
  52. LiteralPolarRadiusType = Literal["number", "category"]
  53. LiteralGridType = Literal["polygon", "circle"]
  54. LiteralPosition = Literal[
  55. "top",
  56. "left",
  57. "right",
  58. "bottom",
  59. "inside",
  60. "outside",
  61. "insideLeft",
  62. "insideRight",
  63. "insideTop",
  64. "insideBottom",
  65. "insideTopLeft",
  66. "insideBottomLeft",
  67. "insideTopRight",
  68. "insideBottomRight",
  69. "insideStart",
  70. "insideEnd",
  71. "end",
  72. "center",
  73. ]
  74. LiteralIconType = Literal[
  75. "line",
  76. "plainline",
  77. "square",
  78. "rect",
  79. "circle",
  80. "cross",
  81. "diamond",
  82. "star",
  83. "triangle",
  84. "wye",
  85. ]
  86. LiteralLegendType = Literal[
  87. "line",
  88. "plainline",
  89. "square",
  90. "rect",
  91. "circle",
  92. "cross",
  93. "diamond",
  94. "star",
  95. "triangle",
  96. "wye",
  97. "none",
  98. ]
  99. LiteralLegendAlign = Literal["left", "center", "right"]
  100. LiteralVerticalAlign = Literal["top", "middle", "bottom"]
  101. LiteralStackOffset = Literal["expand", "none", "wiggle", "silhouette"]
  102. LiteralBarChartStackOffset = Literal["expand", "none", "wiggle", "silhouette", "sign"]
  103. LiteralComposedChartBaseValue = Literal["dataMin", "dataMax", "auto"]
  104. LiteralAxisType = Literal["number", "category"]
  105. LiteralAreaType = Literal[
  106. "basis",
  107. "basisClosed",
  108. "basisOpen",
  109. "bumpX",
  110. "bumpY",
  111. "bump",
  112. "linear",
  113. "linearClosed",
  114. "natural",
  115. "monotoneX",
  116. "monotoneY",
  117. "monotone",
  118. "step",
  119. "stepBefore",
  120. "stepAfter",
  121. ]
  122. LiteralDirection = Literal["x", "y", "both"]
  123. LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
  124. LiteralSyncMethod = Literal["index", "value"]