You know, I used to think it was awful that life was so unfair. Then I thought, wouldn't it be much worse if life were fair, and all the terrible things that happen to us come because we actually deserve them?
Verwijderd
hoe werkt dit?
1
2
3
4
5
| var output = []; $.each(names,function(index,value) { output[index] = { 'label': names[index], 'data': coords[s][/s][index]}; }); $.plot($("#placeholder"),output); |
[ Voor 3% gewijzigd door Verwijderd op 21-04-2010 18:26 ]
Dragoslav: het volgende werkt namelijk wel:
[code = "javascript"]
$.plot($("#placeholder"),[{Label:names[0],data:coords[0]}, {Label:names[1], data: coords[1]}]);
[/code]
Maargoed dan snap ik nog niet waarom het niet zou moeten werken. Wat bedoel je precies met je bovenstaande oplossing?
Edit:IK heb het al gevonden.. ik was nogal dom bezig. Het had het volgende moeten zijn:
1
2
3
4
5
6
7
| var output = [] for (var i = 0; i < names.length; i++) { output[i] = { 'label': names[i], 'data': coords[i]}; } $.plot($("#graphplaceholder"), output); |
De blokhaken moesten inderdaad weg.. die maken van elk subelement (in het vorige voorbeeld)nog een array.
[ Voor 44% gewijzigd door Guldan op 21-04-2010 21:49 ]
You know, I used to think it was awful that life was so unfair. Then I thought, wouldn't it be much worse if life were fair, and all the terrible things that happen to us come because we actually deserve them?
Mijn glazen bol zegt me dat je 't volgende 'ns moet proberen: array.push()
[ Voor 9% gewijzigd door pieturp op 21-04-2010 21:45 . Reden: verduidelijking ]
... en etcetera en zo
Verwijderd
p.s. gebruik de $.each als je toch al JQeury gebruikt
[ Voor 90% gewijzigd door Verwijderd op 21-04-2010 21:50 ]
You know, I used to think it was awful that life was so unfair. Then I thought, wouldn't it be much worse if life were fair, and all the terrible things that happen to us come because we actually deserve them?