Bonjour,

Comment introduire un retour a la ligne dans un enregistrement d'un array:
j ai essayé avec \n mais ça ne marche pas.
Dans les circles le texte apparait comme ceci "Google \n Analytics"

Merci

Code html : 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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<!DOCTYPE html> <!--on declare au validator le langage utilisé: html5-->
 
<html lang="fr">
 
<body>
 
<div class="container">	
 
<div class="row">
	<br>
	<div class="col-xs-4 col-sm-4 col-md-4 col-lg-12">
		<span  class="acceuil">Notre savoir faire</span>
	</div>
	<svg></svg>
	<br>
</div>
 
<br>
 
<br>
 
</div>
 
<script src="http://d3js.org/d3.v3.js"></script>
<script>
 
// GROUPS:  0 Web | 1: Adobe | 2: hybrid
var data = [
  {"id": 0, "name": "Html", "r": 40 },
  {"id": 0, "name": "PHP", "r": 40 },
  {"id": 0, "name": "Javascript", "r": 40 },
  {"id": 0, "name": "d3.js", "r": 40 },
  {"id": 0, "name": "AJAX", "r": 40 },
  {"id": 0, "name": "Google \n Analytics", "r": 80 },
  {"id": 0, "name": "SVG", "r": 40 },
  {"id": 0, "name": "Bootstrap", "r": 40 },
  {"id": 0, "name": "CSS", "r": 40 },
  {"id": 0, "name": "PHP", "r": 40 },
  {"id": 0, "name": "jQuery", "r": 40 },
  {"id": 0, "name": "MySQL", "r": 40 },
  {"id": 0, "name": "CMS", "r": 40 },
  {"id": 0, "name": "W3C", "r": 40 },
  {"id": 0, "name": "Filezilla", "r": 40 },
 
  {"id": 1, "name": "Illustrator", "r": 40 },
  {"id": 1, "name": "Inkscape", "r": 40 },
  {"id": 1, "name": "Latex", "r": 40 },
 
  {"id": 2, "name": "R Project", "r": 40 },
  {"id": 2, "name": "Sphinx", "r": 40 },  
  {"id": 2, "name": "Question", "r": 40 },
  {"id": 2, "name": "MapInfo", "r": 40 },    
  {"id": 2, "name": "Excel", "r": 40 },
  {"id": 2, "name": "OpenOffice Calc", "r": 70 },
  {"id": 2, "name": "OpenOffice Tab", "r": 70 },
  {"id": 2, "name": "Access", "r": 40 },
];
 
var width = window.innerWidth// affichage fenetre
    height = 400;
 
var fill = d3.scale.category10();
 
var nodes = [], labels = [],
    foci = [{x: 0, y: 300}, {x: 350, y: 300}, {x: 450, y: 300}];
 
var svg = d3.select("svg")
    .attr("width", "100%")
    .attr("height", 500)
    ;
 
var force = d3.layout.force()
    .nodes(nodes)
    .links([])
    .charge(-900)
    .chargeDistance(200)
    .gravity(0.1)
    .friction(0.8)
    .size([width, 450])
    .on("tick", tick);
 
//var node = svg.selectAll("circle");
var node = svg.selectAll("g");
 
var counter = 0;
 
function tick(e) {
  var k = .1 * e.alpha;
 
  // Push nodes toward their designated focus.
  nodes.forEach(function(o, i) {
    o.y += (foci[o.id].y - o.y) * k;
    o.x += (foci[o.id].x - o.x) * k;
  });
 
  node.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
 
}
 
var timer = setInterval(function(){
 
  if (nodes.length > data.length-1) { clearInterval(timer); return;}
 
  var item = data[counter];
  nodes.push({id: item.id, r: item.r, name: item.name});
  force.start();
 
  node = node.data(nodes);
 
  var n = node.enter().append("g")
      .attr("class", "node")
      .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; })
      .style('cursor', 'pointer')
      .on('mousedown', function() {
         var sel = d3.select(this);
         sel.moveToFront();
      })
      .call(force.drag);
 
  n.append("circle")
      .attr("r",  function(d) { return d.r; })
      .style("fill", function(d) { return fill(d.id); })
 
  n.append("text")
      .text(function(d){
          return d.name;
      })
 
      .attr("dy", ".35em")
 
  counter++;
}, 100);
 
 
d3.selection.prototype.moveToFront = function() {
  return this.each(function(){
    this.parentNode.appendChild(this);
  });
};
 
function resize() {
  width = window.innerWidth;
  force.size([width, height]);
  force.start();
}
 
d3.select(window).on('resize', resize);
</script>
 
</body>                                         
 
</html>