recharts.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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.13.0"
  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.13.0"
  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. LiteralTextAnchor = Literal["start", "middle", "end"]
  52. LiteralLayout = Literal["horizontal", "vertical"]
  53. LiteralPolarRadiusType = Literal["number", "category"]
  54. LiteralGridType = Literal["polygon", "circle"]
  55. LiteralPosition = Literal[
  56. "top",
  57. "left",
  58. "right",
  59. "bottom",
  60. "inside",
  61. "outside",
  62. "insideLeft",
  63. "insideRight",
  64. "insideTop",
  65. "insideBottom",
  66. "insideTopLeft",
  67. "insideBottomLeft",
  68. "insideTopRight",
  69. "insideBottomRight",
  70. "insideStart",
  71. "insideEnd",
  72. "end",
  73. "center",
  74. ]
  75. LiteralIconType = Literal[
  76. "line",
  77. "plainline",
  78. "square",
  79. "rect",
  80. "circle",
  81. "cross",
  82. "diamond",
  83. "star",
  84. "triangle",
  85. "wye",
  86. ]
  87. LiteralLegendType = Literal[
  88. "line",
  89. "plainline",
  90. "square",
  91. "rect",
  92. "circle",
  93. "cross",
  94. "diamond",
  95. "star",
  96. "triangle",
  97. "wye",
  98. "none",
  99. ]
  100. LiteralLegendAlign = Literal["left", "center", "right"]
  101. LiteralVerticalAlign = Literal["top", "middle", "bottom"]
  102. LiteralStackOffset = Literal["expand", "none", "wiggle", "silhouette"]
  103. LiteralBarChartStackOffset = Literal["expand", "none", "wiggle", "silhouette", "sign"]
  104. LiteralComposedChartBaseValue = Literal["dataMin", "dataMax", "auto"]
  105. LiteralAxisType = Literal["number", "category"]
  106. LiteralAreaType = Literal[
  107. "basis",
  108. "basisClosed",
  109. "basisOpen",
  110. "bumpX",
  111. "bumpY",
  112. "bump",
  113. "linear",
  114. "linearClosed",
  115. "natural",
  116. "monotoneX",
  117. "monotoneY",
  118. "monotone",
  119. "step",
  120. "stepBefore",
  121. "stepAfter",
  122. ]
  123. LiteralDirection = Literal["x", "y"]
  124. LiteralInterval = Literal["preserveStart", "preserveEnd", "preserveStartEnd"]
  125. LiteralIntervalAxis = Literal[
  126. "preserveStart", "preserveEnd", "preserveStartEnd", "equidistantPreserveStart"
  127. ]
  128. LiteralSyncMethod = Literal["index", "value"]