I'm totally new to objects,
I need to push objects to get this structure:
var data = [
{x: 0, y: 91},
{x: 1, y: 90},
{x: 2, y: 89.7},
{x: 3, y: 89.5},
{x: 4, y: 89.2},
{x: 5, y: 88.2},
{x: 6, y: 88.4},
{x: 7, y: 87.9},
{x: 8, y: 87.2},
{x: 9, y: 87.0},
{x: 10, y: 87.2},
];
trying this way
for (var i=0; i<result.rows.length; i++) {
var row = result.rows.item(i);
data.push({x: i, y: row.weight});console.log(data[i]);
}
here is the jsfiddle example, not the whole code with SQLite database, just the part I am not able to manage, what I am trying to do is to feed the chart dynamically, but looks like I am not able to push the 'data' array in the right way (if the problem is there, because the push code looks good).
http://jsfiddle.net/zeroshadow/WDEUz/3/
that's what I get from the console when I push the data in:
Object {x: 1, y: 65}
Object {x: 2, y: 64.9}
Object {x: 3, y: 64.8}
Object {x: 4, y: 64.2}
Object {x: 5, y: 64.3}
Object {x: 6, y: 64.5}
Object {x: 7, y: 64.3}
Object {x: 8, y: 64}
Object {x: 9, y: 63.8}
Object {x: 10, y: 63.1}
looks OK but then the chart does not like it and all is vanished. As I have no knowledge of objects, I thought the array after the push has something wrong, because the data array in its initial state works.
result
? What isresult.rows
? Even though you have included the code, you haven't provided any other useful information that is necessary to solve whatever problem you have. – Felix Kling Mar 1 at 19:48result
orresult.rows
isn't what you think it is, or because of any other problem with code you didn't post. – Felix Kling Mar 1 at 19:55