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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:59:55+00:00 2026-05-27T23:59:55+00:00

I’m trying to plot a chart to show time against temperature using highcharts. I

  • 0

I’m trying to plot a chart to show time against temperature using highcharts.

I have three sensors, and data is recorded every 5 minutes (which I believe is 5*60 in JS).

For some reason, it won’t render a scale for the x axis, or any data on the graph. However the barebones of the graph and the y axis scale render fine.

I also get the following error in the console:

Error: Invalid value for <circle> attribute cx="NaN"

If you can spot anything missing or incorrect with my chart code that would be good.

My code is below – I’ve commented in any external references (they’re from a JSON data source, and I’ve checked that it’s all valid data when it comes through).

tempChart = new Highcharts.Chart({
        chart: {
            renderTo:'tempChart', // just a div with id of tempChart
            zoomType:'x',
            type:'line'
        },
        title: {
            text: 'Server Temperature'
        },
        xAxis: {
            type: 'datetime',
            maxZoom: 5*60*1000, // limit zoom to one record (5 minutes)
            title: {
                text: 'Timestamp'
            }
        },
        yAxis: {
            title: {
                text: 'Temperature'
            },
        },
        tooltip: {
            shared: true                    
        },
        series:[{
            type: 'line',
            name: 'Sensor 1',
            pointInterval:5*60*1000,
            pointStart:startDate, // this is a js date object
            data:data.temp1 // this is a javascript array object
        }, {
            type: 'line',
            name: 'Sensor 2',
            pointInterval:5*60*1000,
            pointStart:startDate, // same js date object
            data:data.temp2 // javascript array object
        }, {
            type: 'line',
            name: 'Sensor 3',
            pointInterval:5*60*1000,
            pointStart:startDate, // same
            data:data.temp3 // javascript array object
        }]
    });

Update

I construct the date by using the following function to convert a MySQL date to a JS one (source)

function sql2js(timestamp) {
    var regex=/^([0-9]{2,4})-([0-1][0-9])-([0-3][0-9]) (?:([0-2][0-9]):([0-5][0-9]):([0-5][0-9]))?$/;
    var parts=timestamp.replace(regex,"$1 $2 $3 $4 $5 $6").split(' ');
    return new Date(parts[0],parts[1]-1,parts[2],parts[3],parts[4],parts[5]);
}

So at the beginning of my function to create the chart, I use that function on the MySQL date from my JSON data, like so:

startDate = sql2js(data.startDate);

Just to make sure that the dates were correct, I logged them both:

MySQL date: 2012-01-03 17:05:01
JS date:    Tue Jan 03 2012 17:05:01 GMT+0000 (GMT)
  • 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-05-27T23:59:56+00:00Added an answer on May 27, 2026 at 11:59 pm

    How do you construct your Date object ?

    I’ve played with your example on a JSFiddle, and saw that if I made a bad declaration of the date object (for example, var startDate = new Date()), I got the same error you mentioned.

    But with a proper Date object, all works fine

    EDITED :

    In fact, HighCharts asks for a millisecond UTC date, so you’ll have to do

    var startDate = sql2js('2012-01-03 17:05:01').getUTCMilliseconds();
    

    as updated in the JSFiddle

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

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I am trying to loop through a bunch of documents I have to put
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
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 have just tried to save a simple *.rtf file with some websites and

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.