Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Why is Plotly displaying empty space when displaying a graph through django data?

I am trying to print a pie graph using from Django but it is showing an empty space instead of printing the pie chart. I used the instructions from https://plotly.com/javascript/pie-charts/ but I am getting an error. How do I fix it?

views.py

labels = list(account_graph.keys()) # ['Food', 'Gas', 'Friends'] 
data = list(account_graph.values()) # [-6.09, -20.0, -7.0]

return render(request, "finances/account.html", {'labels': labels, 'data': data})

account.html

<div id='expenses'></div>

<script>

      var data = [{
        values: {{data|safe}},
        labels: {{labels|safe}},
        type: 'pie'
      }];

      var layout = {
        height: 400, 
        width: 500
      }

      Plotly.newPlot('expenses', data, layout);
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The problem is that your values are all negative.

Non numeric or negative values are ignored in the pie chart sector calculations (source code), so no slices show up making the graph look empty.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!