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 7640709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:44:18+00:00 2026-05-31T08:44:18+00:00

I have a controller that generates the following json data: [ { title: Option

  • 0

I have a controller that generates the following json data:

[

    {
        "title": "Option 0",
        "votes": 0
    },
    {
        "title": "Option 1",
        "votes": 1
    },
    {
        "title": "Option 2",
        "votes": 2
    },
    {
        "title": "Option 3",
        "votes": 3
    },
    {
        "title": "Option 4",
        "votes": 4
    },
    {
        "title": "Option 5",
        "votes": 5
    },
    {
        "title": "Option 6",
        "votes": 6
    },
    {
        "title": "Option 7",
        "votes": 7
    },
    {
        "title": "Option 8",
        "votes": 8
    },
    {
        "title": "Option 9",
        "votes": 9
    }

]

I want to make a pie chart from this data using jqplot. I am able to make a chart by following a tutorial but i am not able to show the text labels with the slices. Here is my js code:

jQuery(document).ready(function () {
    urlDataJSON = '/Poll/PollData?pollId=3';

    $.getJSON(urlDataJSON, "", function (data) {
        var dataSlices = [];
        var dataLabels = "";

        $.each(data, function (entryindex, entry) {
            dataSlices.push(entry['votes']);
            dataLabels = dataLabels + entry['title'];
        });
        options = {
            legend: { show: true },
            title: 'Poll Results',
            seriesDefaults: {
                // Make this a pie chart.
                renderer: jQuery.jqplot.PieRenderer,
                rendererOptions: {
                    // Put data labels on the pie slices.
                    // By default, labels show the percentage of the slice.
                    showDataLabels: true
                }
            }
        }
        var plot = $.jqplot('chartdiv', [dataSlices], options);
    });
});              

please tell me how do i show the text associated with pie chart slices. I know i am missing something but again i am a newbie to javascript.

  • 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-05-31T08:44:19+00:00Added an answer on May 31, 2026 at 8:44 am

    Your data structure is incorrect this link takes you to a working example.

    jqPlot example

    I think this will work

    dataSlices.push([entry['title'], entry['votes']]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller that is called with AJAX (sends JSON data), so I
I have a controller with that I want to pass off some data to
I have a controller (Spring-MVC) that generates a PDF report on a get request.
--Summary (shortened)-- I have a controller that loads a profile object from the corresponding
I have a controller method that returns a jSON object and in one calling
I have a bit of data that I want to use to build a
I have the following controller that returns a list of tags when it receives
On ASP.NET MVC 3, assume that we have following controller action: public ActionResult Index()
Following on from this question: ASP.NET MVC Routing with Default Controller I have a
I have a controller that contains a tableView that spawns another controller modally to

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.