-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdataArr.html
More file actions
26 lines (23 loc) · 750 Bytes
/
dataArr.html
File metadata and controls
26 lines (23 loc) · 750 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="https://d3js.org/d3.v5.js"></script>
<script>
var colorList = ['red', 'green', 'blue']
var nameList = ['ranck', 'lianxue', 'other']
var ul = d3.select('body').append('ul')
ul.selectAll('li').data(nameList).enter().append('li').attr('style', function (data, index) {
console.dir(index)
return `color: ${colorList[index]}`
}).text( function(data, index) {
return data
})
</script>
</body>
</html>