-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex8.js
63 lines (52 loc) · 1.7 KB
/
index8.js
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
(function(){
const margin = {
top: 10,
right: 20,
bottom: 30,
left: 30
};
const width = 400 - margin.left - margin.right;
const height = 565 - margin.top - margin.bottom;
const svg = d3.select('#chart8')
.append('svg')
.attr('width', width + margin.left + margin.right)
.attr('height', height + margin.top + margin.bottom)
.call(responsivefy)
.append('g')
.attr('transform', `translate(${margin.left}, ${margin.top})`);
const parseTime = d3.timeParse('%Y/%m/%d');
d3.json('./circleData.json', function (err, data) {
if(err){
console.log(err)
}
var xScale = d3.scaleLinear()
.domain([0, 100])
.range([0, width]);
svg.append('g')
.attr('transform', `translate(0, ${height})`)
.call(d3.axisBottom(xScale));
var yScale = d3.scaleLinear()
.domain([0, 100])
.range([height, 0]);
svg.append('g')
.call(d3.axisLeft(yScale));
svg.selectAll('.circle')
.data(data)
.enter()
.append('circle')
.attr('class', 'circle')
.attr('cx', d => xScale(d.x))
.attr('cy', d => yScale(d.y))
.attr('r', d => d.r)
.style('stroke', '#FF9900')
.style('stroke-width', 2)
.style('fill', '#FF9900')
.style('fill-opacity', 0.5);
const t = d3.transition()
.delay(100)
.duration(100);
d3.selectAll('.circle')
.transition(t)
.style('fill', "#FFFF");
});
}())