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
Currently, it's a little tricky to figure out the size of a table and keep it in sync if it ties to something that needs to be displayed. For example, this code checks if a partitioned table has the partitions to ensure that it will render the plot correctly.
import deephaven.plot.express as dx
import deephaven.ui as ui
from deephaven import empty_table, time_table
from random import choice
def rand_type() -> str:
return choice(["Sine", "Cosine"])
tt = time_table("PT0.25s").update([
"Type = rand_type()",
"X = 0.05 * i",
"Y = (Type == `Sine`) ? sin(X) : cos(X)"
])
pt = tt.partition_by("Type")
@ui.component
def plot_pt(partitioned_table, initial_val):
text, set_text = ui.use_state(initial_val)
data = ui.use_table_data(partitioned_table.table)
ct = ui.use_memo(
lambda: partitioned_table.get_constituent(text.capitalize()) if text != "" else None,
[partitioned_table, text, data]
)
return [
ui.text_field(value=text, on_change=set_text),
dx.line(
ct, x="X", y="Y", title=f"Partition Key: {text}"
)
if ct != None else ui.text("Please enter a valid partition.")
]
p = plot_pt(pt, "Sine")
This is not great with a large table since it would be pulling out a lot of data. Of course if this was adding and removing rows you might have to do something like this anyways, but regardless, there could be cases where you want to see the size of the table and we don't have a good way of keeping that in sync without using use_table_listener or a hook built on top of that (use_table_data in this case)
The text was updated successfully, but these errors were encountered:
Currently, it's a little tricky to figure out the size of a table and keep it in sync if it ties to something that needs to be displayed. For example, this code checks if a partitioned table has the partitions to ensure that it will render the plot correctly.
This is not great with a large table since it would be pulling out a lot of data. Of course if this was adding and removing rows you might have to do something like this anyways, but regardless, there could be cases where you want to see the size of the table and we don't have a good way of keeping that in sync without using
use_table_listener
or a hook built on top of that (use_table_data
in this case)The text was updated successfully, but these errors were encountered: