I have a rather simple page to try to integrate VantaJS into my dash app but am having some issues that I think are due to delayed rendering timing.
My app is the following (with ./assets/custom.js containing the required code to trigger the visual):
import datetime
import dash_defer_js_import as dji
import dash
import dash_bootstrap_components as dbc
import numpy as np
import plotly.express as px
from dash import dash_table
from dash import dcc
from dash import html as html
app = dash.Dash(__name__,
external_stylesheets=[dbc.themes.BOOTSTRAP, 'https://fonts.googleapis.com/css?family=Poppins',
dbc.themes.MINTY],
external_scripts=['https://cdnjs.cloudflare.com/ajax/libs/three.js/r121/three.min.js',
'https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.cells.min.js'])
# app = dash.Dash(__name__, external_stylesheets=['https://fonts.googleapis.com/css?family=Poppins'])
app.layout = html.Div(style={'font-family': 'Poppins'}, children=[
html.Canvas(id='foo', style={'width': '500px', 'height': '500px'}),
]
)
if __name__ == '__main__':
app.run_server(debug=True, host='0.0.0.0')
But within the inspect of the browser console I get: [VANTA] Cannot find element #foo
Similarly, if move custom to the parent level of the app (in the same location as my app.py) and add:
dji.Import('./custom.js')
I do not receive the error but I also do no not see the visual.
Any help would be greatly appreciated.
I have been able to create a simple html page locally and that page is able to display the vanta animation without issue.