Question about javascript objects – Education Career Blog

I’m trying to use a jQuery plugin, the HighCharts, calling the series from a webservice but i don’t know how to use the javascript javascript that i’m filling.

I’ve created the object like this:

chartOjb = new Object();

Then i create two properties:name and data. (i’ve already tested if i’m getting the values properly with alerts(); and everyting is ok).

In HighCharts examples, they fill the series like this:

     series: {
        name: 'Jane',
        data: 1, 0, 4
     }, {
        name: 'John',
        data: 5, 7, 3

I’ve tried to do something like this:

series: chartObj

But that doesn’t work. What would be the proper way to do this?
The example that i’m trying to follow is here:



You are passing a single object, whereas the API wants an array (i gather from your example). So something like:

series: charObj1, chartObj2

should do the trick


The only thing you need to change is to wrap your chartObj in an array.

series: chartObj

changes to

series: chartObj

series needs to be an array of objects to use (one for each series.)


var chartObj = {};
chartObj'name' = 'Jane';
chartObj'data' = 1,0,4;

var otherChartObj = {};
otherChartObj'name' = 'John';
otherChartObj'data' = 5,7,3;

Wrap these objects in an array:

series:chartObj, otherChartObj

Leave a Comment