Thursday, October 9, 2025
HomeLanguagesJavascriptD3.js axis.tickSizeOuter() Function

D3.js axis.tickSizeOuter() Function

The d3.axis.tickSizeOuter() Function in D3.js is used to set the outer tick size to the specified value and returns the axis. The outer tick size controls the length of the square ends of the domain path, offset from the native position of the axis.

Syntax:

axis.tickSizeOuter([size])

Parameters: This function accepts single parameter as mentioned above and described below:

  • size: This parameter is size to set the inner and outer tick size.

Return Value: This function returns the axis.

Below programs illustrate the d3.axis.tickSizeOuter() function in D3.js:

Example 1:

HTML




<!DOCTYPE html> 
<html> 
    
<head> 
    <title> 
        D3.js | D3.axis.tickSizeOuter() Function 
    </title> 
    
    <script type="text/javascript" 
        src="https://d3js.org/d3.v4.min.js"> 
    </script> 
    
    <style> 
        svg text { 
            fill: green; 
            font: 15px sans-serif; 
            text-anchor: center; 
        } 
    </style> 
</head> 
    
<body> 
    <script> 
        var width = 400, height = 400; 
        var svg = d3.select("body") 
            .append("svg") 
            .attr("width", width) 
            .attr("height", height); 
    
        var xscale = d3.scaleLinear() 
            .domain([0, 10]) 
            .range([0, width - 60]); 
    
        var x_axis = d3.axisBottom() 
            .scale(xscale).tickSizeOuter([40]).tickSizeInner([0]);
    
        var xAxisTranslate = height / 2; 
    
        svg.append("g") 
            .attr("transform", "translate(50, " 
                + xAxisTranslate + ")") 
            .call(x_axis)  
    </script> 
</body> 
</html>


Output:

Example 2:

HTML




<!DOCTYPE html> 
<html> 
    
<head> 
    <title> 
        D3.js | D3.axis.tickSizeOuter() Function 
    </title> 
    
    <script type="text/javascript" 
        src="https://d3js.org/d3.v4.min.js"> 
    </script> 
    
    <style> 
        svg text { 
            fill: green; 
            font: 15px sans-serif; 
            text-anchor: end; 
        } 
    </style> 
</head> 
    
<body> 
    <script> 
        var width = 400, height = 400; 
        var svg = d3.select("body") 
            .append("svg") 
            .attr("width", width) 
            .attr("height", height); 
     
        var yscale = d3.scaleLinear() 
            .domain([0, 1]) 
            .range([height - 50, 0]); 
     
        var y_axis = d3.axisRight() 
            .scale(yscale).tickSizeOuter([20]);
     
        svg.append("g") 
            .attr("transform", "translate(100,20)") 
            .call(y_axis)  
    </script> 
</body> 
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32342 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6713 POSTS0 COMMENTS
Nicole Veronica
11876 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11937 POSTS0 COMMENTS
Shaida Kate Naidoo
6833 POSTS0 COMMENTS
Ted Musemwa
7092 POSTS0 COMMENTS
Thapelo Manthata
6786 POSTS0 COMMENTS
Umr Jansen
6789 POSTS0 COMMENTS