Friday, December 12, 2025
HomeLanguagesJavascriptD3.js easepoly() Function

D3.js easepoly() Function

The d3.easePoly() function in d3.js is used to give the symmetric polynomial effect to a particular element. This poly easing function is used as a parameter within the d3.ease() function.  

Approach: D3.js transition function will be used for applying different easing effects on a particular element. First of all, create an SVG element and append it to the body of the HTML page, then create a circle and append it to the SVG. Set some attributes of the circle to give it nice color and size and apply the d3.transition function followed by the ease() function and give the d3.easePoly as a parameter to ease function.

Syntax: 

svg.append().attr().ease(d3.easePoly).attr();

Parameter: This function does not accept any parameters.

Return Value: This function does not return anything.

Below given are a few examples of the function given above.

Example 1:




<!DOCTYPE html> 
<html lang="en"
<head
    <meta charset="UTF-8"
    <meta name="viewport" content=" 
     width=device-width, initial-scale=1.0"> 
  
    <script type="text/javascript"
    </script
</head
<body
    <h1 style="color:green">neveropen</h1
    <svg width="500px" height="500px"></svg
      
    <script
        var svg = d3.select("svg") 
        .attr("transform", "translate(0, -50)"); 
  
        svg.append("circle") 
        .attr("cx", 100) 
        .attr("r", 50) 
        .attr("cy", 100) 
        .attr("fill", "green") 
        .transition() 
  
         // Use of d3.easePoly function
         .ease(d3.easePoly) 
         .attr("r", 10) 
         .attr("fill", "red")
         .duration(1500); 
    </script
</body
</html


Output:

Example 2:




<!DOCTYPE html> 
<html lang="en"
<head
    <meta charset="UTF-8"
    <meta name="viewport" content=" 
    width=device-width, initial-scale=1.0"> 
  
    <script type="text/javascript"
    </script
</head
<body
    <h1 style="color:green">neveropen</h1
    <svg width="500px" height="500px"></svg
      
    <script
        var svg = d3.select("svg")  
        svg.append("rect") 
        .attr("x", 50) 
        .attr("width", 10)
        .attr("height", 10)
        .attr("fill", "green") 
        .transition()
          
         // Use of d3.easePoly function
         .ease(d3.easePoly) 
         .attr("width", 100)
         .attr("height", 100)
         .attr("fill", "red")
         .duration(1500); 
    </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
32445 POSTS0 COMMENTS
Milvus
105 POSTS0 COMMENTS
Nango Kala
6813 POSTS0 COMMENTS
Nicole Veronica
11952 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12029 POSTS0 COMMENTS
Shaida Kate Naidoo
6949 POSTS0 COMMENTS
Ted Musemwa
7199 POSTS0 COMMENTS
Thapelo Manthata
6893 POSTS0 COMMENTS
Umr Jansen
6881 POSTS0 COMMENTS