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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:03:53+00:00 2026-06-06T02:03:53+00:00

I have a jqPlot pie chart that I am loading by reading an XML

  • 0

I have a jqPlot pie chart that I am loading by reading an XML file. However, when I load the array for slices dynamically the pie chart does not render right, when I hard code the array it seems to render correctly.

The code I use to get the array is:

function loadSlices(xml)
{
slices = new Array();
$(xml).find("category").each(
    function()
    {
        $(this).find("slice").each(
            function()
            {
                slice = new Array($(this).attr("name"));
                slice.push($(this).attr("size"));
                slices.push(slice);
            }
        );
    }
);
return slices;
 }

The code loading the chart is:

function pieChart(name,xmlurl)
{
$.get(xmlurl,function(xml)
{

    loadSize(name,xml);
    slices= new Array();
    slices.push(loadSlices(xml));
    $("#debug").append("\nSLICES ARR (getting ready to load):");
    debug2dArray(slices);
    //debug2dArray(slices)
    //now load in the pie chart
    var plot1 = $.jqplot(name,[slices],
        {
            seriesDefaults:{
                renderer: $.jqplot.PieRenderer,
                rendererOptions:{
                    showDataLables: true
                },
            }
    });
});//end get AJAX request
 }

When I hard code the slices array as [[["PB&J",2],["Ham",1]]] it works perfectly fine. Any help would be appreciated.

Updates

XML

<chart>
    <size width="450px" height="200px"/>
        <category>
              <slice name="PB&J" size="3" />
              <slice name="Ham"  size="1" />
         </category>
 </chart>

JSFiddles

Static Array

  • 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-06T02:03:55+00:00Added an answer on June 6, 2026 at 2:03 am

    I found the answer. When I was loading it the second time it was rendering the second argument in the embeded arrays as a string so ["PB&J","1"], which jqPlot did not like. So adding a parseInt() around the push for the integer resulted in the correct display. To see a demo of the fix see this jsfiddle.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to make a pie chart using a php file that gets
I have a page that has a jquery chart on it (JQPlot). Unfortunately for
Does anyone have any idea why my chart is not being rendered with Jqplot?
I have a jqplot pie chart with a legend and I would like to
I have a simple JSF line chart that uses PrimeFaces (via jqPlot) library: <p:lineChart
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I made a pie chart using the jqPlot and the pie chart did render,
I have the following codes to render a bar chart and a pie chart.
I have a jqPlot chart which is rendered as in the image below. Iam
Is it possible w/ jqplot to display a line chart that 'overlays' a bar

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.