scale
.d3.axisTop // Ticks on top
d3.axisBottom
d3.axisLeft
d3.axisRight // Ticks on right
scale
as a parameter
var xAxis = d3.axisBottom()
.scale(xScale);
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0," + (h - padding) + ")")
.call(xAxis);
D3’s call()
function takes the incoming selection, as received from the prior link in the chain, and hands that selection off to any function.
.axis path,
.axis line {
stroke: teal;
shape-rendering: crispEdges;
}
.axis text {
font-family: Optima, Futura, sans-serif;
font-weight: bold;
font-size: 14px;
fill: teal;
}
var xAxis = d3.axisBottom()
.scale(xScale)
.ticks(5);
var xAxis = d3.axisBottom()
.scale(xScale)
.tickValues([0, 100, 250, 600]);
var formatAsPercentage = d3.format(".1%");
xAxis.tickFormat(formatAsPercentage);
https://d3js.org/d3.v4.min.js