19 |
20 |
Source: barchart_d3.js
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | /** define our data */
30 | instruments = [{name:"concertina", number: 2},
31 | {name:"piano", number: 5},
32 | {name:"harp", number :25}]
33 |
34 | /** make the viz
35 | - @param scale x multiplier
36 | */
37 | function doit(scale){
38 | d3.select("body")
39 | .selectAll("rect")
40 | .data(instruments)
41 | .attr("width", function(d) { console.log("name " + d.name);return d.number*scale; })
42 | }
43 |
44 | doit(10)
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |