import pandas as pd
import plotly.express as px
import solara
# Generate data
df = pd.DataFrame.from_records(
[
{'code': "GBR", "value": 1},
{'code': "NLD", "value": 10},
{'code': "USA", "value": 3},
{'code': "FRA", "value": 2},
{'code': "ES", "value": 7},
]
)
# Make a figure
fig = px.choropleth(data_frame=df, locations='code', color='value')
# Simple solara app that captures clicks on the map and prints the click event:
@solara.component
def Page():
number = solara.use_reactive(0)
text = solara.use_reactive("text")
def function(x):
x = str(x)
text.set(x)
def increment():
number.set(number.value + 1)
x = str(number.value)
text.set(x)
with solara.Column():
solara.FigurePlotly(fig=fig, on_click=function)
solara.Button(on_click=increment)
solara.Card(title=text.value)
print(text.value)
solara.Markdown(text.value)