I have managed to integrate a scatter plot into my Django application following the very helpful steps laid out here. I would now like to do the same for a bar chart but I have not been able to get the data to render on the page. Can someone explain where I am going wrong?
Here is my views.py:
import plotly.offline as opy
import plotly.graph_objs as go
class Graph(TemplateView):
template_name = 'graph.html'
trace = go.Figure(
data=[
go.Bar(
name="Original",
x=data[1,2,3,4],
y=data[1,2,3,4],
offsetgroup=0,
),
],
layout=go.Layout(
title="Bar Chart",
yaxis_title="y axis values"
)
)
bar_div = opy.plot(trace, auto_open=False, output_type='div')
context['bar_div'] = bar_div
return context
Thanks!