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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:24:07+00:00 2026-06-15T02:24:07+00:00

I am trying to parse json data created by a php file to another

  • 0

I am trying to parse json data created by a php file to another script and display its values to a highchart.

My data.php which creates the json data is this:

<?php
header("Content-type: application/json");

$dbhost = "localhost";
$dbuser = "db";
$dbpass = "xxxxx";
$dbname = "db";
$db = mysql_connect($dbhost, $dbuser, $dbpass); 
mysql_select_db($dbname,$db);
$query = "SELECT * FROM monitor_total";

$result = mysql_query($query,$db);

while($row = mysql_fetch_array($result)) {
  $date = $row["date"];
  $count = $row["count"];
  $array[] = array("date" =>$date,"count"=>$count);
}
echo json_encode($array);
?>

the data.php output is:

[{"date":"2012-11-23","count":"582311"},{"date":"2012-11-24","count":"582322"},{"date":"2012-11-22","count":"582121"},{"date":"2012-11-21","count":"581321"},{"date":"2012-11-19","count":"572821"},{"date":"2012-11-20","count":"581321"},{"date":"2012-11-18","count":"582421"},{"date":"2012-11-17","count":"579321"},{"date":"2012-11-16","count":"581321"},{"date":"2012-11-25","count":"558178"}]

inside <script>:

var monitor_graph; // globally available
    monitor_graph = new Highcharts.Chart({
     chart: {
        renderTo: 'graph',
        type: 'spline',
        events: {
            load: requestData
        }
     },
     title: {
        text: 'Registered and total players by date'
     },
     xAxis: {
       categories: []
     },
     yAxis: {
        title: {
           text: 'Players'
        }
     },
     series: [{
        name: 'Total Players',
        data: []
     }]
  });
function requestData() {
$.ajax({
        url: 'data.php',
    success: function(data) {
       $.each(data, function(i,item){

              monitor_graph.series[0].setData(??????????);

       });
     setTimeout(requestData, 1000);
    },
});
}

How i create a serie named total players with ‘item.date’ in x-axis and ‘item.count’ in y-axis???

Please help me!

UPDATE:
i add this inside each:

monitor_graph.xAxis[0].setCategories([item.date]);
monitor_graph.series[0].setData([parseFloat(item.count)]); 

and i now get the 1 point exactly as i need it but with the following error:

Unexpected value NaN parsing y attribute.
  • 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-15T02:24:08+00:00Added an answer on June 15, 2026 at 2:24 am

    you need to modify your success callback to something like this

    var categories=[];
    var seriesData=[];
    $.each(data,function(){
        categories.push(this.date);
        seriesData.push(parseInt(this.count));
    });
    chart.xAxis[0].setCategories(categories);
    chart.series[0].setData(seriesData);
    

    the Series.setData() method expects an array of int/float and not strings and should be called with entire data set and not each point. You were doing this inside the $.each should be done outside this loop. Same goes with categories

    Demo @ jsFiddle

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

Sidebar

Related Questions

I am trying to parse a JSON script from my server which contains a
I'm trying to load and parse json data from an external source into a
I am trying to parse the following JSON string remotely: [{name:Object1,data:[1,2]},{name:Object2,data:[3,4]}] I am doing
I'm trying to parse a json stream in Go. I've created a simplified example:
I am trying to parse the json values from the following stream: {id: tag:search.xxxxx.com,2005:xxxxxxxxxxx}
I;m trying to parse a json string which I receive from web server as
I am trying to parse through a JSON response for customer data (names and
I am trying to parse FB comments JSON, which I get from var url
I was trying to create a application where i parse JSON data and have
So I'm trying to display via a template some data from a JSON request.

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.