I want to add labels on a real time flot chart which takes more than one variables. Here is a sample of the code:
//...switch code..
case "3":
dataset = {
"data1": {label : "data1", data : dataArray[0]},
"data2": {label : "data2", data : dataArray[1]},
"data3": {label : "data3", data : dataArray[2]}
};
data = [dataset];
return data;
break;
The code works perfectly if i will not use labels. Example below:
//...switch code..
case "2":
data = [
dataArray[0],
dataArray[1],
];
return data;
break;
What am i doing wrong?
Any kind of example or solution will be perfect!
Assuming that the data
here is then being used in a $.plot
call, it's an incorrect format . You'll end up with an array of a single item, an object with key/value pairs.
What you need is an array of multiple objects:
[
{label : "data1", data : dataArray[0]},
{label : "data1", data : dataArray[1]},
{label : "data1", data : dataArray[2]}
]
Also, ensure that dataArray[0]
, etc.. are in the form of an array of arrays:
[
[x1,y1],
[x2,y2]
]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.