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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:50:04+00:00 2026-06-05T02:50:04+00:00

I cannot seem to get the xAxis in Highcharts to display the date from

  • 0

I cannot seem to get the xAxis in Highcharts to display the date from data loaded via JSON. Also, when I hover over a data point, the label says “Invalid date.”

Here is the PHP code used to generate the data:

function fetchLineChart() {
    $fetchData = $this->db->query("SELECT download, upload, date FROM speed_entries ORDER BY date DESC");

    while ($data = $fetchData->fetch()) {
        $date = date("Y, m, d", strtotime($data['date']));
        $downloadData[] = array('Date.UTC(' . $date . ')', (float)$data['download']);
        $uploadData[] = array('Date.UTC(' . $date . ')', (float)$data['upload']);
    }
    $result = array('download' => $downloadData, 'upload' => $uploadData);
    echo json_encode($result);
}

And here is the jQuery for the chart

$(document).ready(function() {
                var options = {
                    chart: {
                        renderTo: 'lineChart',
                        type: 'line'
                    },
                    title: {
                        text: 'Download / Upload Results'
                    },
                    subtitle: {
                        text: 'Source: Speedtest.net'
                    },
                    yAxis: {
                            title: {
                                    text: 'Speed'
                            },
                            plotLines: [{
                                    value: 0,
                                    width: 1,
                                    color: '#808080'
                            }]
                    },
                    xAxis: {
                        type: 'datetime'
                     },
                    series: [{
                        name: 'Download',
                        lineWidth: 2,
                        marker: {
                            radius: 2
                        },
                        data: []
                    }, {
                        name: 'Upload',
                        data: []
                    }]
                };

                $.getJSON('class.speed.php?mode=lineChart', null, function(json) {
                    var downloads = json.download;
                    var uploads = json.upload;

                    options.series[0].data = downloads;
                    options.series[1].data = uploads;

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

Everything else works, the data lines are displayed correctly. Just cannot figure out how to make the date work.

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-05T02:50:07+00:00Added an answer on June 5, 2026 at 2:50 am

    I might be wrong here but by setting xAxis to ‘datetime’, you are telling Highcharts they you will supply date in form of miliseconds (that is integer) but instead your are passing in a string. Why don’t you generate, as Linger already suggested, miliseconds directly in your php function?

    $miliseconds = strtotime($data['date']) * 1000;
    $downloadData[] = array($miliseconds, (float)$data['download'])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cannot seem to get even vaguely the same data from the Python (Which
I cannot seem to get this date picker working at all. I know it
For some reason I cannot seem to get IE8 to display my jqgrid right
I cannot seem to get a message from drupal_set_message when a user registers on
I cannot seem to get hold of the parent varible from the child template,
I cannot seem to get jdbcmysql to run over ssl. Downloaded gems: jdbc-mysql (5.0.4)
I cannot seem to get the value from a select option that has been
This is soooo weird. I cannot seem to get any output messages from Sys.Debug
I cannot seem to get the quotes around this statement right. No matter what
For some reason I cannot seem to get a ko.computed observable to compute when

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.