S
Solara

general

another question i just want to combine

Rrh-afk10/16/2023
another question , i just want to combine cross filter with map (leafmap) however I couldn't make it work: filter, _set_filter = solara.use_cross_filter(id(df))
solara.CrossFilterSelect(df, "class") solara.CrossFilterSelect(df, "name") solara.CrossFilterSlider(df, "Time", mode=">=")
dff = df.loc[filter] if filter is not None else df with solara.Columns([2, 2]): class Map(leafmap.Map): def init(self, kwargs): super().init(kwargs)
self.add_points_from_xy( dff, x="lon", y="lat", spin=True, add_legend=True, )
solara.CrossFilterDataFrame(dff) solara.FigurePlotly(px.histogram(dff, "Time")) how to solve and make interactively between filter, dataframe and map thanks
MMaartenBreddels10/17/2023
what do you mean by "does not work" what behaviour do you expect that is not happening?
Rrh-afk10/17/2023
Hi @MaartenBreddels thanks for your reply, when I select based on filter specify all dataframe and plot was updated as the filter applied to them however nothing plot in the map
Rrh-afk10/17/2023
No description
Rrh-afk10/17/2023
my example dataframe like this (just a dummy data): df=pd.DataFrame(data={'class': [1, 2,3,25], 'name':['A1','A2','A3','A4'],'Time': [10, 20,30,40],'lat':[40.741895,40.73098527339601,40.66905379201422,-0.22470045920182688],'lon':[-73.989308,-74.12560713330078,-74.1163374189453,114.96660935839847]},dtype=np.int8) zoom = solara.reactive(zoom_default) center = solara.reactive(center_default) marker_location = solara.reactive(center_default) #map_name = solara.reactive(list(maps)[0]) @solara.component def Page():
solara.Title("Test") with solara.Column(): filter, _set_filter = solara.use_cross_filter(id(df))

with solara.Sidebar(): solara.Markdown("## Test") solara.Markdown(f"Market set to: {marker_location.value}", style={"color": "#6e6e6e"}) def location_changed(location): # do things with the location marker_location.set(location) def goto_marker(): center.value = marker_location.value zoom.value = 13 def reset_view(): center.value = center_default zoom.value = zoom_default solara.SliderInt(label="Zoom level", value=zoom, min=1, max=16) with solara.Row(): solara.Button(label="Zoom to marker", on_click=goto_marker) solara.Button(label="Reset view", on_click=reset_view) with solara.Card("Test Filter"): with solara.Columns([2, 2]): filter, _set_filter = solara.use_cross_filter(id(df))
solara.CrossFilterSelect(df, "class") solara.CrossFilterSelect(df, "name") solara.CrossFilterSlider(df, "Time", mode=">=")
dff = df.loc[filter] if filter is not None else df with solara.Columns([2, 2]): class Map(leafmap.Map): def init(self, kwargs): super().init(kwargs)
self.add_points_from_xy( dff, x="lon", y="lat", spin=True, add_legend=True, )
solara.CrossFilterDataFrame(dff) solara.FigurePlotly(px.histogram(dff, "Time")) with solara.Card("map"): with solara.Columns([1, 2],style={"min-width": "500px", "height": "500px"}): solara.Markdown("map") Map.element( # type: ignore zoom=zoom.value, on_zoom=zoom.set, center=center.value, on_center=center.set, scroll_wheel_zoom=True, #crs=my_projection, toolbar_control=False, #layers=[
)
@solara.component def Layout(children): route, routes = solara.use_route() return solara.AppLayout(children=children)

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts
2 No if you put in a top level dict not2) No, if you put in a top level dict (not reactive) in a module, every user sees the same dictionarIf I ve setup an app with multiple pagesIf I've setup an app with multiple pages using Solara's routing, is there an easy way to redirect a Thank you for your answer but nextThank you for your answer, but next question, why display(button) from widget on solara component doBlender with Solarawould be very happy to be a guinnea pigwould be very happy to be a guinnea pig 😄Which version of lab running pip installWhich version of lab? running !pip install will install it in the kernel environment, if the lab serThanks how could I programatically setThanks ! how could I programatically set theme from Python side ?it seems to be functional not sure Iit seems to be functional. not sure I understand the downside of my current approach. but fixing any3 what s the best way to implement `push3. what's the best way to implement `push notification` ? is it something like this ? and is it run 2 when I create a module level reactive2. when I create a module level reactive var like `x = solara.reactive(None)`, is it application widcouple of questions around sessioncouple of questions around session management: 1. I found Solara manages session via cookie which isI m not sure what you mean but changingI'm not exactly sure what you mean, but changing the value from the backend would look something likhey solara team looking into statehey solara team looking into state documentation. It seems solara.reactive is session based as in ifhope to know when we will get this fixedhope to know when we will get this fixed. I am developing some demo with Solara and don't want to se