I am trying to take the users lasso select in django to do something with the data they select.
- The user selects points on plotly graph
- They press a button on the webpage and the selected points are submitted
- The data is processed in python
I currently have the plot on my web page but cannot get the data out. My view is set up like so.
from django.shortcuts import render
from plotly.offline import plot
import plotly.graph_objects as go
import numpy as np
def demo_plot_view(request):
x = [i for i in range(-10, 10)]
y = [np.random.rand()*i for i in range(-5,5)
graphs = [go.Scatter(x=x, y=y, mode='markers')]
layout = {
'title': 'Title of the figure',
'xaxis_title': 'X',
'yaxis_title': 'Y',
'height': 420,
'width': 560,
}
plot_div = plot({'data': graphs, 'layout': layout}, output_type='div')
return render(request, 'my_app/demo-plot.html', context={'plot_div': plot_div})
The demo-plot.html is
<!DOCTYPE HTML>
<html>
<head>
<title>Demo plot</title>
</head>
<body>
{% autoescape off %}
{{ plot_div }}
{% endautoescape %}
</body>
</html>