Bonjour,
J'ai une question qui me parait simple mais m'as donn� pas mal de fil a retordre (et a d�tordre d'ailleurs)...
Ce code as pour but d'afficher des paths et d'highlighter l'ensemble des paths.
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 for(var i=0;i < pathGlobal.length;i++){ var monde = {}; window['Rset'+i] = rsr.set(); var tmpPath = pathGlobal[i]; for(var j=0;j < tmpPath.length;j++){ monde['path_'+i+'_'+j] = rsr.path(tmpPath[j]).attr(attr); window['Rset'+i].push(monde['path_'+i+'_'+j]); } for (var state in monde) { monde[state].color = Raphael.getColor(); (function (st, state) { var nomSet= eval('Rset'+i); st[0].onmouseover = function () { nomSet.animate({fill: "#FFF"}, 500); nomSet.toFront(); }; st[0].onmouseout = function () { nomSet.animate({fill: "#333",}, 500); nomSet.toFront(); }; })(monde[state], state); } }
La solution ci dessous fonctionne mais le eval('Rset'+i) fais ramer l'affichage de ma carte.
Du coup j'ai tent� de mettre en memoire sur chaques path le nom du path parent (lignes chang�e en gras):
Cependant, le alert me renvois undefined au sujet du this.parentSet...
Code : S�lectionner tout - Visualiser dans une fen�tre � part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 for(var i=0;i < pathGlobal.length;i++){ var monde = {}; window['Rset'+i] = rsr.set(); var tmpPath = pathGlobal[i]; for(var j=0;j < tmpPath.length;j++){ path = rsr.path(tmpPath[j]).attr(attr); path.parentSet = 'Rset'+i; monde['path_'+i+'_'+j] = path; window['Rset'+i].push(path); } for (var state in monde) { monde[state].color = Raphael.getColor(); (function (st) { //st[0].style.cursor = "pointer"; st[0].onmouseover = function () { alert(this.parentSet); nomSet.animate({fill: "#FFF"}, 500); nomSet.toFront(); }; st[0].onmouseout = function () { nomSet.animate({fill: "#333",}, 500); nomSet.toFront(); }; })(monde[state]); } }
Du coup je ne vois pas comment faire pour me passer du eval pour cette fonction.
Je me doute que le probleme provient d'un manque de connaissance de ma part sans trouver laquelle.
Merci d'avance pour toutes les pistes que vous pourrez proposer.
Partager