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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:34:56+00:00 2026-06-08T02:34:56+00:00

I’m trying to create a chart using data from my database calling json, but

  • 0

I’m trying to create a chart using data from my database calling json, but its not showing the results in the chart.
Here’s my code so far:

$(document).ready(function() {
function requestData() {
$.ajax({
        url: 'data.php',
        datatype: 'json',
        success: function(data) {
        alert(data);
        chart.series[0].setData(data[0]);
        },
        cache: false
    });
}
var chart;
chart = new Highcharts.Chart({
    chart: {
            renderTo: 'container',
            type: 'line',
            events: {
               load: requestData
            }
            },
    xAxis: {
  },
  yAxis: {
     title: {
        text: 'Value'
     }
  },

series: [{
         name: 'Random data',
         data: []
            }]
});

});

And here’s my data.php code

$query = "SELECT tiempo,Fp1Ref 
        FROM GraficaEEG limit 10";
$data = mysqli_query($dbc, $query);
$i=0;
while($row = mysqli_fetch_array($data)) {
    $row['tiempo'] = (float) $row['tiempo'];
    $rows[$i]=array($row['tiempo'],(float)$row['Fp1Ref']); 
    $i++;
}
echo json_encode($rows);

The data i receive is this:

[[0,3001],[0.005,4937.22],[0.01,4130.55],[0.015,4213.15],[0.02,4010.61],[0.025,3914.34],[0.03,3785.33],[0.035,3666.13],[0.04,3555.25],[0.045,3447.77]]

So i think is the proper way to pass data for the chart, so i don’t quite get whats wrong, thank you in advance.

  • 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-08T02:34:59+00:00Added an answer on June 8, 2026 at 2:34 am

    I think the problem is that when your requestData() function is fired the chart variable still isn’t fully built and doesn’t know it has the series property.
    To fix this, instead of chart in your requestData() function, reference this (which means the chart object in that context).
    I tried this out in jsfiddle here http://jsfiddle.net/elcabo/p2r6g/.
    Also post the js code below.

    $(function () {
        $(document).ready(function() {
    
            //Function bits
            function requestData(event) {
                var tiemposAlAzar = [[10,20],[20,50]];
                //The 'this' will refer to the chart when fired
                this.series[0].setData(tiemposAlAzar);
            };
    
            var chart;
    
            //Chart bits
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                    type: 'line',
                    events:{
                        load: requestData                           
                    }
                },
                xAxis: {},
                yAxis: {
                    title: {
                    text: 'Value'
                }
            },
            series: [{
                name: 'Random data',
                data: []
            }]
          });
        });
    });​ 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
I'm trying to create an if statement in PHP that prevents a single post
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.