I'm using flot api to draw charts. Look at this chart type HERE.
In that example they've used values like,
var sin = [], cos = [];
for (var i = 0; i < 14; i += 0.5) {
sin.push([i, Math.sin(i)]);
cos.push([i, Math.cos(i)]);
}
Now the chart was drawn "curved" lines, when i replaced the
sin.push([i, Math.sin(i)]);
cos.push([i, Math.cos(i)]);
with,
sin[i]=[i, Math.sin(i)];
cos[i]=[i, Math.cos(i)];
Then the chart gets drawn using straight lines. I've two questions now.
1) What is the difference between the two types of array assignments?
2) Is this because of difference in array assignments or the API behaviour?
any help greatly appreciated! Thanks.
Edit: Set i to increment by 1 and set different values using push method or default assignment, you'll get the same result.
The i is not Integer. You can use only int in array index.
1) What is the difference between the two types of array assignments? A) None, except the push places next int for index.
2) Is this because of difference in array assignments or the API behaviour? A) Yes with your way the array is invalid, because the 1.5 value for a key is parsed as a string and api can not read the array as it expect.
Try using apis way or using different values for for statement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With