axisRight() is a D3 axis generator that creates the right-side form of an axis from an associated scale. D3 includes it alongside axisTop(), axisBottom(), and axisLeft() in the d3-axis module. section 4.1.2 section 4.5
Use axisRight() as part of the standard D3 axis workflow:
- Pass the scale responsible for distributing values along the right axis. section 4.1.2 section 4.5
- Apply the generator to a D3 selection with call() so it constructs the axis line, ticks, and labels. section 4.1.2 section 4.5
- Position the containing SVG group using chart margins or a transform; generated axes initially appear at the selection’s origin. section 4.1.2 section 4.5
Right-side scale axis
A right-side axis follows the same pattern as the other generators: create it from the relevant scale, append an SVG group, and call the generator on that selection. A linear temperature scale can supply the values, while the group’s placement reserves the chart’s right margin. section 4.1.2 section 4.5
const maxTemp = d3.max(data, d => d.max_temp_F); const yScale = d3.scaleLinear() .domain([0, maxTemp]) .range([innerHeight, 0]);
Inspect the linear y-scale pattern that supplies values to an axis generator. section 4.1.2
