I’m trying to implement a simple version of dash to Rust, but being new to front-end programming , I’m stucking the following situation.
In Python:
from dash import Dash, dcc, html, Input, Output, callback
import plotly.express as px
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = Dash(__name__, external_stylesheets=external_stylesheets)
fig = px.scatter(x=["a", "b", "c"], y=[1, 2, 3])
fig.update_traces(marker_size=20)
app.layout = html.Div([
dcc.Graph(
id='basic-interactions',
figure=fig
),
html.Div(id="hover-data")
])
@callback(
Output('hover-data', 'children'),
Input('basic-interactions', 'hoverData'))
def display_hover_data(hoverData):
# return json.dumps(hoverData, indent=2)
return str(hoverData)
if __name__ == '__main__':
app.run(debug=True, port="8082")
The generated callback function display_hover_data
accepts an object of hoverData
, which must be generated by some information lieing in the .html
file. If I wanna to implement similar callback function in other language, I must extract the same inforamtion and then make an object hoverData
firstly. But how can I extract the information from the .html
file, where the information lies? I tried to read the source code from package Dash.py
, but I still can’t figure it out. Can anyone help me?