Help on Django + Plotly integration

39 views
Skip to first unread message

Praveen Kumar

unread,
Mar 22, 2023, 10:29:36 AM3/22/23
to Django users
Hi Team,

I need help in implementing Plotly with Django for interactive dashboards.

Please suggest.

Thanks & Regards,
Praveen

Kasper Laudrup

unread,
Mar 22, 2023, 11:08:55 AM3/22/23
to django...@googlegroups.com
On 22/03/2023 15.29, Praveen Kumar wrote:
> Hi Team,
>
> I need help in implementing Plotly with Django for interactive dashboards.
>
> Please suggest.
>

Try following this:

https://googlethatforyou.com?q=plotly%20django

Kind regards,

Kasper Laudrup
OpenPGP_0xE5D9CAC64AAA55EB.asc
OpenPGP_signature

Praveen Kumar

unread,
Mar 23, 2023, 7:47:19 AM3/23/23
to Django users
Hello Kasper,

I have followed following link to get portly chart:


But I'm not getting end result. Please find below the structure that I have made. Please let me know if I'm missing anything.

Screenshot 2023-03-23 154859.png

Kindly suggest.

Thanks & Regards,
Praveen

Ryan Nowakowski

unread,
Mar 23, 2023, 10:50:57 AM3/23/23
to django...@googlegroups.com
Hey Kumar,

"Not getting the end result" is pretty generic. Where are you stuck specifically? Are there any error messages you're seeing? Have you tried the browser's devtools to see if there are any errors there?

- Ryan

Jd Mehra

unread,
Mar 24, 2023, 8:35:45 AM3/24/23
to Django users

Create a view that will generate the Plotly chart. In the view, you can use the Plotly library to create a chart object and return it as an HTML div string. Here is an example view:

from django.shortcuts import render
import plotly.graph_objs as go
import plotly.offline as opy
from django.http import HttpResponse

def my_chart(request):
    trace1 = go.Bar(x=[1, 2, 3], y=[4, 5, 6])
    data = [trace1]
    layout = go.Layout(title='My Chart')
    fig = go.Figure(data=data, layout=layout)
    div = opy.plot(fig, auto_open=False, output_type='div')
    return HttpResponse(div)
Reply all
Reply to author
Forward
0 new messages