You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All charts inheriting from reflex.components.recharts.charts.ChartBase are limited because the height or width property cannot be assigned to a State attribute. Trying to do so would result in the following error:
<more stuff, omitted>
File "D:\Code\reflex-demo\reflex_demo\reflex_demo.py", line 22, in bar_vertical
return rx.recharts.bar_chart(
^^^^^^^^^^^^^^^^^^^^^^
File "D:\Code\reflex-demo\.venv\Lib\site-packages\reflex\components\recharts\charts.py", line 89, in create
"height": height or "100%",
^^^^^^^^^^^^^^^^
File "D:\Code\reflex-demo\.venv\Lib\site-packages\reflex\vars\base.py", line 1181, in __bool__
raise VarTypeError(
reflex.utils.exceptions.VarTypeError: Cannot convert Var 'reflex___state____state__reflex_demo___reflex_demo____graph_data_state.height' to bool for use with `if`, `and`, `or`, and `not`. Instead use `rx.cond` and bitwise operators `&` (and), `|` (or), `~` (invert).
Thus, I'm forced to hard-code the height / width (as integers or percentage strings).
Hard-coding numbers make no sense because data often comes from a database, and I don't know beforehand how many rows the database will return. Sure, my application logic needs to keep the numbers in check (I don't want to plot a bar chart with 1000000 entries), but I would like to be able to compute a sensible height in my State's on_load_data() method. Would this addition be possible?
The text was updated successfully, but these errors were encountered:
Describe the Enhancement you want
All charts inheriting from
reflex.components.recharts.charts.ChartBase
are limited because theheight
orwidth
property cannot be assigned to aState
attribute. Trying to do so would result in the following error:This is for the following example:
Thus, I'm forced to hard-code the height / width (as integers or percentage strings).
Hard-coding numbers make no sense because data often comes from a database, and I don't know beforehand how many rows the database will return. Sure, my application logic needs to keep the numbers in check (I don't want to plot a bar chart with 1000000 entries), but I would like to be able to compute a sensible height in my State's
on_load_data()
method. Would this addition be possible?The text was updated successfully, but these errors were encountered: