Skip to content

Commit

Permalink
Merge #5.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasondavies committed Nov 26, 2012
2 parents 6103e15 + 4cfddd5 commit 1cecce8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion d3.layout.cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
text = cloudText,
font = cloudFont,
fontSize = cloudFontSize,
fontStyle = cloudFontNormal,
fontWeight = cloudFontNormal,
rotate = cloudRotate,
padding = cloudPadding,
spiral = archimedeanSpiral,
Expand All @@ -25,6 +27,8 @@
return {
text: text.call(this, d, i),
font: font.call(this, d, i),
style: fontStyle.call(this, d, i),
weight: fontWeight.call(this, d, i),
rotate: rotate.call(this, d, i),
size: ~~fontSize.call(this, d, i),
padding: cloudPadding.call(this, d, i)
Expand Down Expand Up @@ -144,6 +148,18 @@
return cloud;
};

cloud.fontStyle = function(x) {
if (!arguments.length) return fontStyle;
fontStyle = d3.functor(x);
return cloud;
};

cloud.fontWeight = function(x) {
if (!arguments.length) return fontWeight;
fontWeight = d3.functor(x);
return cloud;
};

cloud.rotate = function(x) {
if (!arguments.length) return rotate;
rotate = d3.functor(x);
Expand Down Expand Up @@ -185,6 +201,10 @@
return "serif";
}

function cloudFontNormal() {
return "normal";
}

function cloudFontSize(d) {
return Math.sqrt(d.value);
}
Expand All @@ -210,7 +230,7 @@
while (++di < n) {
d = data[di];
c.save();
c.font = ~~((d.size + 1) / ratio) + "px " + d.font;
c.font = d.style + " " + d.weight + " " + ~~((d.size + 1) / ratio) + "px " + d.font;
var w = c.measureText(d.text + "m").width * ratio,
h = d.size << 1;
if (d.rotate) {
Expand Down

0 comments on commit 1cecce8

Please sign in to comment.