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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:25:26+00:00 2026-06-13T09:25:26+00:00

I’m trying to get some JSON formatted data from a COSM feed into a

  • 0

I’m trying to get some JSON formatted data from a COSM feed into a simple chart, but am having trouble doing so. I’m not sure if I’m misunderstanding how the series array works (even after reviewing the documentation on it.

This is my code with experiments in it (I eventually want to get the JSON data streamed in through a loop, but for now I just manually tried to push a second data point).

$(document).ready(function(){
            var options = {
                    chart: {
                        renderTo: 'container',
                        type: 'line',
                        marginRight: 130,
                        marginBottom: 25
                    },
                    title: {
                        text: 'Temperature',
                        x: -20 //center
                    },
                    xAxis: {
                        //type: 'datetime',
                    },
                    yAxis: {
                        title: {
                            text: 'Temperature (°C)'
                        },
                        plotLines: [{
                            value: 0,
                            width: 1,
                            color: '#808080'
                        }]
                    },
                    tooltip: {
                        formatter: function() {
                                return '<b>'+ this.series.name +'</b><br/>'+
                                this.x +': '+ this.y +'°C';
                        }
                    },
                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'top',
                        x: -10,
                        y: 100,
                        borderWidth: 0
                    },
                    exporting: {
                        enabled: false
                    },
                    series: [{"name":"Temperature", "data":[]}]
            };
            $.getJSON('http://api.cosm.com/v2/feeds/79903.json?key=dNSiSvXZtR6QBUqbzll4CCgnngGSAKxIQVFSeXBneGpqWT0g', function(data) 
            {
                var xval = data.datastreams[7].at;
                var yval = parseFloat(data.datastreams[7].current_value);
                alert(xval);
                alert(yval);
                var pointChart = new Array(xval, yval);
                options.series[0].data.push(pointChart);
                xval = data.datastreams[2].at;
                yval = parseFloat(data.datastreams[2].current_value);
                pointChart = [xval, yval];
                options.series[0].data.push(pointChart);
                //options.series[0].data.push(data.datastreams[7].at, 25);
                alert(options.series[0].data[0]);
                alert(options.series[0].data[1]);
            });
            var chart = new Highcharts.Chart(options);
        });

JSON looks like this:

{
   "version" : "1.0.0",
   "created" : "2012-10-12T05:01:53.231981Z",
   "status" : "live",
   "location" : {
   },
   "datastreams" : [{
         "max_value" : "100.0",
         "min_value" : "0.0",
         "at" : "2012-10-22T01:28:12.610947Z",
         "id" : "Battery_Level",
         "current_value" : "88"
      }, {
         "max_value" : "30431.0",
         "min_value" : "-26691.0",
         "at" : "2012-10-22T01:22:32.905001Z",
         "id" : "Heading",
         "current_value" : "95"
      }, {
         "max_value" : "64.9304",
         "min_value" : "21.6153",
         "at" : "2012-10-22T01:30:52.656318Z",
         "unit" : {
            "symbol" : "%"
         },
         "id" : "Humidity",
         "current_value" : "55.7556"
      }, {
         "max_value" : "32684.0",
         "min_value" : "0.0",
         "at" : "2012-10-22T01:30:52.656318Z",
         "id" : "Light_Level",
         "current_value" : "37"
      }, {
         "max_value" : "649994.0",
         "min_value" : "-139994.0",
         "at" : "2012-10-18T06:47:56.226880Z",
         "unit" : {
            "symbol" : "µT"
         },
         "id" : "Magnetic_X",
         "current_value" : "-24.90"
      }, {
         "max_value" : "99997.0",
         "min_value" : "-9.9006731e+24",
         "at" : "2012-10-18T06:47:56.226880Z",
         "unit" : {
            "symbol" : "µT"
         },
         "id" : "Magnetic_Y",
         "current_value" : "7.35"
      }, {
         "max_value" : "432.0",
         "min_value" : "-3950.0",
         "at" : "2012-10-18T06:47:56.226880Z",
         "unit" : {
            "symbol" : "µT"
         },
         "id" : "Magnetic_Z",
         "current_value" : "7.10"
      }, {
         "max_value" : "25.59",
         "min_value" : "11.1",
         "at" : "2012-10-22T01:30:52.656318Z",
         "unit" : {
            "symbol" : "°C"
         },
         "id" : "Temperature",
         "current_value" : "22.3800"
   ],
}

As I understand it, Highcharts accepts UTC formatted date/time values for the x-axis? Is the UTC coming in from my JSON feed not valid?

  • 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-13T09:25:27+00:00Added an answer on June 13, 2026 at 9:25 am

    You have to convert your date and time values to a Unix timestamp, then Highcharts will accept it.

    Date.UTC(2010, 0, 1)
    

    Have a look at this tutorial on how to work with date objects in Javascript.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from

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.