https://data.world/datanerd/cat-vs-dog-popularity-in-u-s/discuss/cat-vs-dog-popularity-in-u-s/4194
- copy code and style from the x axis
- x attribute is -40 (left of the "0" x axis)
- y attribute is height/2 (vertical middle of y axis)
- rotation is -90
- point of rotation is -40, height/2
Example code available at bottom of tutorial
- append group
- append class for chartTitle
- append text
- anchor text in the middle
- set x attribute to the middle
- y attribute is negative value (above top of graphing area, in margin)
Example for JavaScript, HTML, and CSS files available at bottom.
Use Google Fonts
Choose any font.
svg.append("g")
.attr("class", "yTitle")
.append("text")
.text("Number of Dogs")
.attr("text-anchor", "middle")
.attr("x", -40)
.attr("y", height/2)
.attr("transform", "rotate(-90, -40," + height/2 + ")");
svg.append("g")
.attr("class", "chartTitle")
.append("text")
.text("Alaskan Dog Sled Expeditions")
.attr("text-anchor", "middle")
.attr("x", width/2)
.attr("y", -50);
<link href="https://fonts.googleapis.com/css?family=Cabin+Sketch|Finger+Paint|Flavors|Hanalei+Fill" rel="stylesheet">
.xTitle {
font-size: 30;
/* font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif */
font-family: 'Cabin Sketch', cursive;
}
.yTitle {
font-size: 30;
font-family: 'Cabin Sketch', cursive;
}
.chartTitle {
font-size: 50;
font-family: 'Flavors', cursive;
}


