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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:05:11+00:00 2026-06-18T05:05:11+00:00

I want to pass data to highcharts by getJSON method: <script type=text/javascript> var chart;

  • 0

I want to pass data to highcharts by getJSON method:

<script type="text/javascript">
var chart;
    $(document).ready(function(){
$("#datepicker1").datepicker({showOn: 'button', buttonImage: 'css/base/images   /calendar.gif', buttonImageOnly: true,dateFormat: "yy-mm-dd"});
  });
function draw_chart(){`
   var url="http://localhost/handle_data.php?start=2012-12-30&end=2013-01-04";
    chart=new Highcharts.Chart({});

$.getJSON(url,function(data1){
 var options={
    chart: {
            renderTo: 'container',
    type: 'line'
        },

        xAxis:{
    type: 'datetime'

   },
        yAxis: {
            title: {
                text: 'test'
            }

        }, 
        series:[{
           data:data1.result[0].dayactivity,
           name: "name"
       }]

};
var chart = new Highcharts.Chart(options);
});
}

</script>
</head>

<body>

<div >  
<input type="text" id="datepicker1" name="date1" onchange='draw_chart()' >
</div>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

the value of data1.result[0].dayactivity is:

[[1356796800,0.0],[1356883200,16.1],[1356969600,0.0],[1357056000,0.0],[1357142400,15.0]], 

when i put this value directly to options.series[0].data, it works, but when i pass it throuth getJSON, it does not. The chart is empty. It seems that it executes var chart = new Highcharts.Chart(options); first. How can i solve this? thanks.

  • 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-18T05:05:14+00:00Added an answer on June 18, 2026 at 5:05 am

    You need to move the creation of the Chart within the success callback of $.getJSON(); You only have to instantiate and create the Chart once and that will be within the callback function.

    function draw_chart() {
        var url="http://localhost/handle_data.php?start=2012-12-30&end=2013-01-04";
        $.getJSON(url,
            function(data1){
                /** Declare options after success callback. */
                var options={
                    chart: {
                         renderTo: 'container',
                         type: 'line'
                    },
                    xAxis:{
                         type: 'datetime'
                    },
                    yAxis: {
                         title: { text: 'test'}
                    }, 
                    series:[{
                        data:data1.result[0].dayactivity,
                        name: "name"
                    }]
               };
    
               /** Create a chart instance and pass options. */
               var chart = new Highcharts.Chart(options);
           }
        );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass data to id <script language=javascript src=/foo.aspx?id=1></script> I have this code
var chart; var d = new Array(); function click() { d = document.getElementById('graph:hi').value; alert(d);
In a native function with a jbyteArray argument, I want to pass data back
I want to pass data from second tab to first tab using delegates.But delegate
I want to pass data between a Python and a C# application in Windows
I want to pass data from database to JSF page as a table. I
I have two pages and I want to pass data to each other. How
i have two flex applications and i want to pass the data from one
I have an NSMutableArray of names. I want the pass the data (selected name)
I am writing an android app. I want to pass some data across the

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.