Comments (8)
Hi @thanosam,
My bad, I made a typo! I indeed use the django-plotly-dash
repo and adjusted my above comment accordingly.
My first guess would be that sockets are in some way (pre)configurable with django; and you need to configure them properly to integrate successively?
Maybe this blogpost can help? https://medium.com/geekculture/a-beginners-guide-to-websockets-in-django-e45e68c68a71
from plotly-resampler.
I tried to integrate it in Django but I receive the following error:
_File ".../python3.9/site-packages/plotly_resampler/figure_resampler/figure_resampler.py", line 211, in register_update_graph_callback
app.callback(
File ".../lib/python3.9/site-packages/django_plotly_dash/dash_wrapper.py", line 345, in wrap_func
func.expanded = DjangoDash.get_expanded_arguments(func, inputs, state)
AttributeError: 'method' object has no attribute 'expanded'_
Part of the code below:
...
date_rng = pd.date_range(start='1/1/2018', end='3/1/2018', freq='S')
df = pd.DataFrame(date_rng, columns=['date'])
df['data'] = np.random.randint(0, 100, size=(len(date_rng)))
fig = FigureResampler(go.Figure())
fig.add_trace(go.Scattergl(name='Timestamps', showlegend=True), hf_x=date_rng, hf_y=df['data'])
app = DjangoDash({myappname}) ##
app.layout = html.Div([
dcc.Graph(id="graph-id", figure=fig),
trace_updater.TraceUpdater(id="trace-updater", gdID="graph-id"),
])
fig.register_update_graph_callback(app, "graph-id", "trace-updater") ##
...
So here because we are in Django our app = DjangoDash(.......
and not app=Dash(....
.
What causes the error is the register_update_graph_callback, which seems to be incompatible with the django-plotly-dash library.
Any ideas ?
from plotly-resampler.
Hi @thanosam!
Yesterday I played around a little with the examples from the django-plotly-dash
repo and got to the point where everything seemed to run/work except the sockets of TraceUpdater. (so the graph was not loaded /updated)
For me it seemed that I could not rely on the register_updat_graph_callback
method and needed to implement it this way:
# I support liveOut should be "app" in your use-case
@liveOut.callback(
dash.dependencies.Output("trace-updater", "updateData"),
dash.dependencies.Input("graph-id", "relayoutData"),
prevent_initial_call=True,
)
def update(relayout):
return fig.construct_update_data(relayout)
Maybe this can help you further.
Please let us know if you have any update about this issue! This might also help others!
from plotly-resampler.
Hi @jvdd !
Thank you for your fast answer. My pleasure to share with the community my findings.
I will try it and I will let you know.
Fyi I am using the django-plotly-dash library, not the django-dash but I guess your proposal applies the same :)
I had the same issue. Everything seems to work fine except the sockets so when I zoom the graph doesn't update
from plotly-resampler.
Following this tutorial I manage to handle dash @app.callbacks in Django: https://www.youtube.com/watch?v=psvU4zwO3Ao&t=2615s&ab_channel=PipInstallPython
In the simpleexample.py file I replaced the content as follows:
app = DjangoDash('SimpleExample')
x = np.arange(5_000_000)
noisy_sin = (3 + np.sin(x / 200) + np.random.randn(len(x)) / 10) * x / 1_000
fig = FigureResampler(go.Figure())
fig.add_trace(go.Scattergl(name='noisy sine', showlegend=True), hf_x=x, hf_y=noisy_sin)
app.layout = html.Div([
dcc.Graph(id="graph-id", figure=fig),
trace_updater.TraceUpdater(id="trace-updater", gdID="graph-id"),
])
@app.callback(Output("trace-updater", "updateData"),[Input("graph-id", "relayoutData")],prevent_initial_call=True,)
def update(relayout):
return fig.construct_update_data(relayout)
Now, I see the 'Loading...' in the plot for a sec and then nothing. :/
The problem seems to be in this line:
trace_updater.TraceUpdater(id="trace-updater", gdID="graph-id"),
I work with serve_locally=False, trace-updater==0.0.8, plotly-resampler==0.7.2.1, plotly==5.8.2, dash==2.5.1, dash-core-components==2.0.0, dash-html-components==2.0.0, dash-renderer==1.9.1, dash-table==5.0.0, Django==3.2, django-plotly-dash==1.6.3
The error in the console:
Error: trace_updater was not found.
Pn https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
ou https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
iu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
os https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
React 11
react-dom.production.min.js:125:24
React 24
Uncaught Error: trace_updater was not found.
Pn https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
ou https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
uu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
iu https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
os https://unpkg.com/[email protected]/build/dash_renderer.min.js:2
React 11
Any ideas please?
from plotly-resampler.
Hi @jonasvdd,
I am facing the same problem as @thanosam.
Any updates on this issue? :)
from plotly-resampler.
Going through the described issue, I got to the same result as @thanosam using his example.
After collecting the static files with Django, the code worked just fine.
This added the missing trace_updater.min.js (among others) to your static files location.
If you run Django behind NGINX inside Docker, make sure that all static files are accessible from or copied into the NGINX-Image.
Hope it helps!
from plotly-resampler.
Thanks! This got it working for me.
How did you get django to collect trace_updater.min.js? I had to manually copy it into a static directory in my app with the correct plotly file path (dash/component/trace_updater
) for it to work. Not a great workaround. Thought about referencing the site-packages directory in my STATICFILES_PATHS settings, but that seemed like a workaround too.
from plotly-resampler.
Related Issues (20)
- Support for data that is not time series HOT 1
- whl install issue in kaggle HOT 1
- [BUG] Hover data does not match the displayed resampled point in scatter plot HOT 1
- [BUG] TraceUpdater fails to update graphs in Tabs after switching tab HOT 8
- Python 3.12 support HOT 4
- Zooming in does not resample when Y-value are identical HOT 9
- [FEAT] improve documentation of the aggregators HOT 1
- Feature Request: Support polars and/or DataFrame api
- [FEAT] Support panel dashboarding library HOT 7
- construct_update_data function returns no_update value HOT 1
- [FEAT] Support OHLC Traces HOT 2
- [BUG] spikes are removed when clicking on reset axis
- [BUG] Legend does not display when trace has no real data points HOT 4
- [Request] Make dash dependency optional
- [BUG] error proc_macro_span_shrink during pip installation HOT 2
- [FEAT] Support Numpy float 16 HOT 3
- [BUG] Using gunicorn to deploy a dash app with plotly-resampler in Linux HOT 7
- [BUG] nan-handling for `M4` aggregator not yet available
- [BUG] `renderer="png"` - rendering png images in notebooks - does not work HOT 6
- [BUG] Lines become broken when zoomed in HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotly-resampler.