S
SolaraMaartenBreddels

```

from typing import List, cast

import plotly

import solara

df = plotly.data.gapminder()
columns = solara.reactive(cast(List[str], []))


@solara.component
def Page():
with solara.Column():
solara.SelectMultiple("Filter on", all_values=list(df.columns), values=columns)
for column in columns.value:
dtype = df[column].dtype
if dtype == "object":
solara.CrossFilterSelect(df, column)
elif dtype == "int64":
solara.CrossFilterSlider(df, column)
else:
solara.Error(f"dtype {dtype} not supported yet for column {column}")
solara.CrossFilterDataFrame(df)
from typing import List, cast

import plotly

import solara

df = plotly.data.gapminder()
columns = solara.reactive(cast(List[str], []))


@solara.component
def Page():
with solara.Column():
solara.SelectMultiple("Filter on", all_values=list(df.columns), values=columns)
for column in columns.value:
dtype = df[column].dtype
if dtype == "object":
solara.CrossFilterSelect(df, column)
elif dtype == "int64":
solara.CrossFilterSlider(df, column)
else:
solara.Error(f"dtype {dtype} not supported yet for column {column}")
solara.CrossFilterDataFrame(df)
Does this help ?
M
MaartenBreddels297d ago
slighly improved:
from typing import List, cast

import plotly

import solara

df = plotly.data.gapminder()
columns = solara.reactive(cast(List[str], []))


@solara.component
def Page():
with solara.Column(gap="0px", classes=["ma-4"]):
solara.SelectMultiple("Filter on", all_values=cast(List[str], list(df.columns)), values=columns)
for column in columns.value:
with solara.Columns([0, 20], style={"align-items": "center"}, classes=["pa-0"], gutters=False):
with solara.Row(classes=["px-2"]):
solara.Text("↳", classes=["pw-0"])
solara.v.Icon(children=["mdi-filter"], class_="pe-0")
dtype = df[column].dtype
if dtype == "object":
solara.CrossFilterSelect(df, column).key("filter-" + column)
elif dtype == "int64":
solara.CrossFilterSlider(df, column).key("filter-" + column)
else:
solara.Error(f"dtype {dtype} not supported yet for column {column}")
solara.CrossFilterDataFrame(df).key("dataframe")
from typing import List, cast

import plotly

import solara

df = plotly.data.gapminder()
columns = solara.reactive(cast(List[str], []))


@solara.component
def Page():
with solara.Column(gap="0px", classes=["ma-4"]):
solara.SelectMultiple("Filter on", all_values=cast(List[str], list(df.columns)), values=columns)
for column in columns.value:
with solara.Columns([0, 20], style={"align-items": "center"}, classes=["pa-0"], gutters=False):
with solara.Row(classes=["px-2"]):
solara.Text("↳", classes=["pw-0"])
solara.v.Icon(children=["mdi-filter"], class_="pe-0")
dtype = df[column].dtype
if dtype == "object":
solara.CrossFilterSelect(df, column).key("filter-" + column)
elif dtype == "int64":
solara.CrossFilterSlider(df, column).key("filter-" + column)
else:
solara.Error(f"dtype {dtype} not supported yet for column {column}")
solara.CrossFilterDataFrame(df).key("dataframe")
using .key() the dataframe does not flicker, and if a cross filter gets removed in between, it does not reset the state of the other