-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (23 loc) · 696 Bytes
/
script.js
File metadata and controls
26 lines (23 loc) · 696 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
// script.js
var chartCircles = function(data) {
var chart = d3.select('#chart');
// Set the chart height and width from data
chart.attr('height', data.height).attr('width', data.width);
// Create some circles using the data
chart.selectAll('circle').data(data.circles)
.enter()
.append('circle')
.attr('cx', function(d) {return d.x})
.attr('cy', function(d) {return d.y})
.attr('r', function(d) {return d.r});
};
var data = {
width: 300, height: 150,
circles: [
{'x': 50, 'y': 30, 'r': 20},
{'x': 70, 'y': 80, 'r': 10},
{'x': 160, 'y': 60, 'r': 10},
{'x': 200, 'y': 100, 'r': 5},
]
};
chartCircles(data);