I have an array with objects. Now I want to find some of them and give them different parameters. Like, all the objects that are < 1900 should be yellow.
I have already tried to make a funktion with an if- statement. I want to have a function, so later I can use the functionname in the .attr{(...),}
function init() {
paper = Snap("#svgContainer");
for (i = 0; i < data.length; i++) {
data[i].circle = paper.circle(0, 0, 1);
}
function Years() {
for (var i = 0; i < data.length - 0; i++) {
xPos = map(data[i].longitude, (0 - 180), 180, 0, paperWidth);
yPos = paperHeight - map(data[i].latitude, (0 - 90), 90, 0, paperHeight);
function color() {
if (data.year > 0 && < 1000) {
circleColor = "black"
} else if (data.year > 1000 && < 1500) {
circleColor = "red"
} else {
circleColor = "orange"
}
}
data[i].circle.animate({
cx: xPos,
cy: yPos,
fill: color,
r: 5,
}, 50);
};
I may have did something wrong with the function. The console logs "SyntaxError: expected expression, got '<'" or the same with "..., got 'if'"
Aucun commentaire:
Enregistrer un commentaire