I want to perform a function when I click on a point in the graph.
Currently I am using Python, Streamlit and Vega-Lite for the graph. I want to create something that gives me more information about a clicked point by executing a python function.
So I want to perform the search()
function but instead of giving arguments myself I want to give the a, b and c values of the clicked point.
df = pd.DataFrame(np.random.randn(200, 3),columns=['a', 'b', 'c'])
df = df.append({'a':1, 'b':1, 'c':1}, ignore_index=True)
st.vega_lite_chart(df, {
'mark': {'type': 'circle', 'tooltip': True},
'encoding': {
'x': {'field': 'a', 'type': 'quantitative'},
'y': {'field': 'b', 'type': 'quantitative'},
'size': {'field': 'c', 'type': 'quantitative'},
'color': {'field': 'c', 'type': 'quantitative'},
},
})
def search(arg1, arg2, arg3):
return df.loc[(df['a']==1) & (df['b']==1) & (df['c']==1)]
searched = search(1,1,1)
searched
I know it's possible to click on a graph with vega-lite like the following example https://vega.github.io/vega-lite/examples/point_href.html. But instead of going to Google I want to preform a python function.
Is there some type of graph that can be used for this type of problems?
Interactions with graphs are not supported yet.
For further details see this link.