Created
December 14, 2020 04:01
-
-
Save Jennyandhuang/e41271b6cffed2f0622b6a877e88ee0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//draw xAxis and xAxis label | |
xAxis = d3.axisBottom() | |
.scale(xScale) | |
d3.select("svg") | |
.append("g") | |
.attr("class", "axis") | |
.attr("transform", "translate(0,620)") | |
.call(xAxis) | |
.append("text") | |
.attr("x", (900+70)/2) //middle of the xAxis | |
.attr("y", "50") // a little bit below xAxis | |
.text("Year") | |
//yAxis and yAxis label | |
yAxis = d3.axisLeft() | |
.scale(yScale) | |
.ticks(10) | |
d3.select('svg') | |
.append("g") | |
.attr("class", "axis") | |
.attr("transform", `translate(${leftMargin},20)`) //use variable in translate | |
.call(yAxis) | |
.append("text") | |
.attr("transform", "rotate(-90)") | |
.attr("x", "-150") | |
.attr("y", "-50") | |
.attr("text-anchor", "end") | |
.text("US Media Ad Spending (Billions)") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment