Sorry about that. Here is the code and screenshot showing the plotly express hover issue. It is solved by converting to a string (but my question is why can’t plotly express handle the 18 digit int64 without rounding at the 16th position – a 64 bit integer has 19 digits).
Here is a screenshot of the code:
Here is a screenshot of the hover function (showing that converting to a string is a work around):
Because plotly handles large int64 digits by rounding after the 16th position, it makes me think that Dash has the same issue handling these large 18 digit integers. Here is part of the code in question (omitting the code where the data arrays are derived):
from dash import Dash, dcc, Output, Input
import dash_bootstrap_components as dbc
import pandas as pd
import numpy as np
import os
import plotly.express as px
import plotly.graph_objects as go
components
app = Dash(name, external_stylesheets=[dbc.themes.LUX])
mytitle = dcc.Markdown(children=‘’)
mygraph = dcc.Graph(figure={})
dropdown = dcc.Dropdown(options=clean_complete.cellid.values,
value=str(clean_complete.cellid.values[0]), # initial value displayed when page first loads
clearable=False)
layout
app.layout = dbc.Container([
dbc.Row([
dbc.Col([mytitle], width=6)
], justify=‘center’),
dbc.Row([
dbc.Col([mygraph], width=12)
]),
dbc.Row([
dbc.Col([dropdown], width=6)
], justify=‘center’),
], fluid=True)
callback
@app.callback(
Output(mygraph, ‘figure’),
Output(mytitle, ‘children’),
Input(dropdown, ‘value’)
)
def update_graph(cellid): # function arguments come from the component property of the Input
fig = go.Figure(data=[
go.Scatter3d(
x=postsyn_xyz_dict.get('postsyn_xyz_dict_' + str(cellid))[:,0],
y=postsyn_xyz_dict.get('postsyn_xyz_dict_' + str(cellid))[:,1],
z=postsyn_xyz_dict.get('postsyn_xyz_dict_' + str(cellid))[:,2],
mode="markers",
marker=dict(size=2),
showlegend=False)
])
fig.add_trace(
go.Scatter3d(
x=presyn_xyz_dict.get('presyn_xyz_dict_' + str(cellid))[:,0],
y=presyn_xyz_dict.get('presyn_xyz_dict_' + str(cellid))[:,1],
z=presyn_xyz_dict.get('presyn_xyz_dict_' + str(cellid))[:,2],
mode="markers",
marker=dict(size=3),
showlegend=False)
)
return fig, '# '+cellid # returned objects are assigned to the component property of the Output
run app
if name==‘main’:
app.run_server(debug=False, port=8044)
Here is the screenshot again for the resulting dropdown: