Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8274893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:53:13+00:00 2026-06-08T07:53:13+00:00

I am creating pie charts with JSON and Flot. The JS function to create

  • 0

I am creating pie charts with JSON and Flot. The JS function to create the pie chart receives a JSON array from Django in this format:

[1, 3, 2, 5, 4]

If there is no data, the JSON array is:

[0, 0, 0, 0, 0]

I’m trying to adjust the function so that if there is no data, then the pie will not be plotted and some text will appear instead (e.g. “Nothing to show yet”). So far I have tried:

function loadWeekChart(theData) {
    var blankData = [0, 0, 0, 0, 0];
    if ($.data(theData) == $.data(blankData)){
    $('#week-pie-chart').empty().append('Nothing to show yet');
    } else {
        $.plot($("#week-pie-chart"), theData ,
            {
                series: {
                    pie: { 
                        show: true
                    }
                }
            });
     }
}

The JS doesn’t fail, but it neither prints a pie chart (there is no data) nor does it give me the text replacement.

Please can someone show me where I’m going wrong!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:53:15+00:00Added an answer on June 8, 2026 at 7:53 am

    Personaly i would do the following heres the psuedo code…

    set boolean to true
    for each element in the JSON
        compare it with blank data element 
        if they are not equal boolean false
        else continue
    return boolean
    

    Then you will know if there same as that function returns true if they are false if they aren’t.

    Please let me know if you need help coding this. Shouldn’t that hard

    This may also help: Similar Question

    function checkJsons(otherJson,newJson)
    {
        var sameJson = true;
         for (var key in otherJson) {
            if(otherJson[key] != newJson[key]) {sameJson=false;} return sameJson;
         }
    }
    

    That should help, not test though

    A nicer way to do this but harder to read is

    function checkJsons(otherJson,newJson)
    {
      for (var key in otherJson) {if(otherJson[key] != newJson[key]) {return false;}}
      return true;
    }
    
    function pieChartData(theData)
    {
      var blankData = [0, 0, 0, 0, 0];
     if(checkJsons(blankData,theData)){$('#week-pie-chart').empty().append('Nothing to show yet');} else { // do your code here // }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a pie chart in iphone app it gets 4 values from
I'm using fusioncharts free and creating some 3d pie charts like so... <div style=margin:0
I want to create a pie chart in JavaScript. On searching I found the
I am creating a pie chart using PyChart library in Python. Here is my
I'm creating a simple pie chart with three data points. The first and second
I am using achartengine to create a pie chart and I have no trouble
(creating a separate question after comments on this: Javascript redeclared global variable overrides old
Does anybody know, how to make chart like this? I have not found any
Creating extensions got much easier with Vs2010, but this seems not to be the
Creating a site in with FrogCMS and using alot of jquery to create an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.