damseldeebi
damseldeebi

Reputation: 137

highchart set data to series in xrange chart

I am creating a xrange highchart using this jsfiddle as reference.

How do I pass values to "x","x2","y" values from list?

For normal column/bar chart I would do the following and it works fine.

var percent=[98,100,95]; //data
series: [{
            name: 'Percent',
            data: percent,
        }]

like wise how to pass values to X-range series? I tried the following but didn't work. jsfiddle here

var alphax = [1436824800000, 1436220000000]; //data for x
var alphax2 = [1438207200000, 1438120800000]; //data for x2
var alphay = [1, 0]; //data for y

series:[{
            name: 'Alpha',
            data: [ x= alphax, x2=alphax2, y= alphay ],
        }

how to achieve this?

Upvotes: 0

Views: 514

Answers (1)

Nishith Kant Chaturvedi
Nishith Kant Chaturvedi

Reputation: 4769

you can iterate over the list and push items in x,x2,y.

var alphax = [1436824800000, 1436220000000]; //data for x
var alphax2 = [1438207200000, 1438120800000]; //data for x2
var alphay = [1, 0];
var dataforRange= [];
for(var i=0;i<alphax.length;i++){
dataforRange.push({"x": alphax[i],
            "x2": alphax2[i],
            "y": alphay[i]});
}

See Updated fiddle here

Upvotes: 1

Related Questions