際際滷

際際滷Share a Scribd company logo
Chapter 6.
Drawing with Data
Min Jeong Cho
d3.js 螻 of 螻
Bar Chart襦 覲旧牛企慨
覃癌 れ壱襦 蠏谿.
start.html  願鍵
width
height
(x, y)
(0, 0)
x
y
覦 谿 蠏碁Μ蠍  覦 蠍一牛伎  4螳讌
豎  るれ  螳蟆朱 危企慨蠍
1. x譬 語郁鍵
.attr("x", function(d, i) {
return i * 21; // 21 郁鍵
.attr("x", function(d, i) {
return i * (w / dataset.length);
})
豌 覯讌 覦覯
 覯讌 覦覯
1. x譬 語郁鍵
豎  るれ  螳蟆朱 危企慨蠍
(0, 0)
i = 0 i = 1 i = 2

[ 襴 ] return i * (w / dataset.length);
一危 螳 觜襦 螳襦 螳蟆 襷り鍵
2. width(螳襦) 覈 襷り鍵
//Width and height
var w = 500;
var h = 100;
var barPadding = 1; // 伎 l 螻糾
.attr("width", w / dataset.length - barPadding)
一危 螳 觜襦 螳襦 螳蟆 襷り鍵
2. width(螳襦) 覈 襷り鍵
[ 襴 ]
豌 觜
varPadding
一危 螳
螻覓願覓 蠏碁!
3. height(碁) 覈 襷り鍵
.attr("height", function(d) {
return d;
});
.attr("height", function(d) {
return d *  // 螻覓願覓 蠏碁!!
});
螻覓願覓 蠏碁!
3. height(碁) 覈 襷り鍵
る  蟇 螳 泣
[ 襴 ]
SVG り  螳讌 れ
4. y豢 螻り鍵
//y豢
.attr(y, function(d) {
return h - d; // 伎 一危 螳 觜手鍵
})
SVG り  螳讌 れ
4. y豢 螻り鍵
d
d
h
[ 襴 ]
蠏碁  豬 蠏碁 蟾 襷り鍵
5. 蟾 蠍
.attr("fill", function(d) {
return "rgba(0, 0, 0, + (d * 0.05) +);
});
  覯 j鍵 覈
給企 + 伎隈 蠏碁 蟾 襷り鍵
5. 蟾 蠍
http://www.colorpicker.com/
http://www.december.com/html/spec/colorsvg.html
SVG 覈詞蠍  讌讀も.  危 谿語^!!
6. ろ 豺り鍵
 rec襯 危危る  譯 襾濠鍵!
Done!

More Related Content

Drawing with data

  • 1. Chapter 6. Drawing with Data Min Jeong Cho
  • 2. d3.js 螻 of 螻 Bar Chart襦 覲旧牛企慨 覃癌 れ壱襦 蠏谿.
  • 4. width height (x, y) (0, 0) x y 覦 谿 蠏碁Μ蠍 覦 蠍一牛伎 4螳讌
  • 5. 豎 るれ 螳蟆朱 危企慨蠍 1. x譬 語郁鍵 .attr("x", function(d, i) { return i * 21; // 21 郁鍵 .attr("x", function(d, i) { return i * (w / dataset.length); }) 豌 覯讌 覦覯 覯讌 覦覯
  • 6. 1. x譬 語郁鍵 豎 るれ 螳蟆朱 危企慨蠍 (0, 0) i = 0 i = 1 i = 2 [ 襴 ] return i * (w / dataset.length);
  • 7. 一危 螳 觜襦 螳襦 螳蟆 襷り鍵 2. width(螳襦) 覈 襷り鍵 //Width and height var w = 500; var h = 100; var barPadding = 1; // 伎 l 螻糾 .attr("width", w / dataset.length - barPadding)
  • 8. 一危 螳 觜襦 螳襦 螳蟆 襷り鍵 2. width(螳襦) 覈 襷り鍵 [ 襴 ] 豌 觜 varPadding 一危 螳
  • 9. 螻覓願覓 蠏碁! 3. height(碁) 覈 襷り鍵 .attr("height", function(d) { return d; }); .attr("height", function(d) { return d * // 螻覓願覓 蠏碁!! });
  • 10. 螻覓願覓 蠏碁! 3. height(碁) 覈 襷り鍵 る 蟇 螳 泣 [ 襴 ]
  • 11. SVG り 螳讌 れ 4. y豢 螻り鍵 //y豢 .attr(y, function(d) { return h - d; // 伎 一危 螳 觜手鍵 })
  • 12. SVG り 螳讌 れ 4. y豢 螻り鍵 d d h [ 襴 ]
  • 13. 蠏碁 豬 蠏碁 蟾 襷り鍵 5. 蟾 蠍 .attr("fill", function(d) { return "rgba(0, 0, 0, + (d * 0.05) +); }); 覯 j鍵 覈
  • 14. 給企 + 伎隈 蠏碁 蟾 襷り鍵 5. 蟾 蠍 http://www.colorpicker.com/ http://www.december.com/html/spec/colorsvg.html SVG 覈詞蠍 讌讀も. 危 谿語^!!
  • 15. 6. ろ 豺り鍵 rec襯 危危る 譯 襾濠鍵!
  • 16. Done!