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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:33:04+00:00 2026-06-03T14:33:04+00:00

I have to to draw a chart from the following json string: { d:{

  • 0

I have to to draw a chart from the following json string:

{
"d":{
  "results":[
 {
   "_metadata":{
      "uri": "http://www.something.com/hi",
      "type" : "something.preview.hi"
      }, "Period", "1988", "Age": 20, "Size" : 80
 },
   "_metadata":{
       "uri": "http://www.something.com/hi",
       "type" : "something.preview.hi"
      }, "Period", "1989", "Age": 25, "Size" : 90
 } 
   ]  }}

I use jquery.flot.js library to draw the chart. Here is the example to draw the chart and it works fine:

var d1 = [];
for (var i = 0; i < 14; i += 0.5)
    d1.push([i, Math.sin(i)]);
var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];

myChart.setDataArray(d1);
myChart.setDataArray(d2);  

According to example I have converted the json to an array of object:

 var results = $.parseJSON(responseText)["d"]["results"];            
        var sampleData = [];
        for (var i = 0, len = results.length; i < len; i++) {
            var result = results[i];

            sampleData.push({ Perioden: result.Perioden,
                Size: result.Size,
                Age: result.Age}); 
}

 var myData = [];
        for (var i in sampleData) {
            myData.push([sampleData[i].Period, sampleData[i].Age]);
        }

        var myData1 = [];
        for (var i in sampleData) {
            myData1.push([sampleData[i].Period, sampleData[i].Size]);
        }

myChart.setDataArray(myData);
myChart.setDataArray(myData1);

but I get the error that the data format is wrong for the data chart.
Can anyody see what is the different between my code and the example?

  • 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-03T14:33:05+00:00Added an answer on June 3, 2026 at 2:33 pm

    I guess that your json is well formated. but the exemple you are providing is not (trailing “i” after second “uri2 line
    and “,” instead of “:” after “Period”

    second thing, you have Period in your json and Perioden is your js code. check that you are using the same name everywhere

    then you can try to console.log(myData, myData1) to see if you have the expected results

    tell us if it’s enough or if you have another problem

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

Sidebar

Related Questions

I'm using a chart taken from here http://writerbay.wordpress.com/2011/03/12/android-tutorial-displaying-chart-on-android/#comment-54 to draw a graph in android.
Hello I have a Google Visualisation Line chart like this... <script type=text/javascript src=https://www.google.com/jsapi></script> <script
I need to draw a pie chart. I found a nice tutorial here http://mac-objective-c.blogspot.com/2009/04/drawing-pie-charts.html
I have something to draw at runtime. I did drawing in onDraw in MyView
I'm using Google Chart ( http://code.google.com/apis/chart/ ) to produce some graphs for my company.
I have two Lists that both are drag-drop enabled. I also draw a chart
I have, after some help ( MSChart - Forcing a line chart to draw
I have the following code which does nothing but reading some values from a
I have written the following code to set the cursor of a Gtk::Window from
I am using jqPlot javascript library ( http://www.jqplot.com/ ) for graphs and charts in

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.