Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created January 29, 2013 17:51
Show Gist options
  • Select an option

  • Save roundrobin/4666142 to your computer and use it in GitHub Desktop.

Select an option

Save roundrobin/4666142 to your computer and use it in GitHub Desktop.
Tributary inlet
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.svg":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":600,"height":300,"hide":false},"fullscreen":false,"thumbnail":"http://i.imgur.com/8wrnrAS.png"}
trend = 1;
if(trend > 0){
//var mostImproving = sortedData.slice(0, trend);
//var names = _.map(mostImproving,function(d,i){ return d.printableName;});
var names = ["sdfsdf","sdfsdf","sfsdfsdf"]
// console.log("LOG:","names===================",mostImproving,names, trend, pretty_list(names));
var fontColor = "#605e57";
var calloutColor = "red";
var url = "urlasdfdsf";
var text2 = g.append('svg:text')
.attr("fill", fontColor)
.attr("x", 400 /2)
.attr("y", 300)
.attr("font-size", 20)
.attr("font-family", "Times")
.attr("text-anchor", "middle");
text2.append("tspan")
.text("Overall,");
text2.append("tspan")
.text(" a ");
text2.append("tspan")
.text(" positive")
.attr("fill",calloutColor)
.attr("class","textGroup")
.attr("font-weight","bold");
text2.append("tspan")
.text(" week ")
.attr("fill",calloutColor)
.attr("class","textGroup")
.attr("font-weight","bold");
text2.append("tspan")
.text(" for ");
text2.append("tspan")
.text(""+url+"!")
.attr("text-decoration","underline");
text2.append("tspan")
.text(" Your ");
text2.append("tspan")
.text(" biggest ");
text2.append("tspan")
.text("wins ");
text2.append("tspan")
.text(" came");
text2.append("tspan")
.text(" from ");
text2.append("tspan")
.text(" bounce rate")
.attr("fill",calloutColor)
.attr("font-weight","bold");
text2.append("tspan")
.text("Now ");
text2.append("tspan")
.text(" to ");
text2.append("tspan")
.text(" make ");
text2.append("tspan")
.text(" next ");
text2.append("tspan")
.text(" week ");
text2.append("tspan")
.text(" even ");
text2.append("tspan")
.text(" better. ");
text2.append("tspan")
.text("to make next week even better.");
function wrapText(widthBox, heightBox, group, text){
var elements = text.selectAll("tspan");
//console.log("LOG:","elements",elements);
var lengthLine = 0;
var line = 1;
var lineSize = 25;
elements.each(function(d,i){
if(i == 0){
d3.select(this)
.attr("x", tributary.sw /2 )
.attr("dy",line * lineSize);
line += 1;
lengthLine = 0;
}
else if(lengthLine == 0 || lengthLine < widthBox){
lengthLine += this.getComputedTextLength();
}
else
{
d3.select(this)
.attr("x", tributary.sw /2 )
.attr("dy",lineSize);
line += 1;
lengthLine = 0;
}
console.log("LOG:","this", this.getComputedTextLength(), lengthLine, line,d,i);
})
return text;
}
wrapText(100, 300, g, text2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment