I have asked yet a similar question here
Actually I need to make dynamic this operation, beginning from this example:
$.when(myfun(my_args))
.done(function(res){
var one_x = ["label1_x"], one_d = ["label1"];
var two_x = ["label2_x"], two_d = ["label2"];
res['data'].forEach(function(items,index) {
switch(res['data'][index]['Term']) {
case 'label1':
one_x.push(res['data'][index]['Index']);
one_d.push(res['data'][index]['Value']);
break;
case 'label2':
two_x.push(res['data'][index]['Index']);
two_d.push(res['data'][index]['Value']);
break;
}
});
var mychart = bb.generate({
data: {
type: line();
xs: {
"label1":"one_x",
"label2":"two_x"
},
columns: [
one_x, one_d,
two_x, two_d
],
axis: {
x: {
type: "timeseries",
tick: {
format: "%Y-%m-%d"
}
}
},
});
This comes right from my working code, I would like make this dynamic. I could use arrays to split information but I don't know how to pass arrays to bb object. Any hints?