Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

D3.js stackOffsetExpand() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The D3.js stackOrderOffsetExpand() method applies a zero baseline and normalizes the values for each point such that the topline is always one.

Syntax:

d3.stackOrderOffsetExpand(series, order);

Parameters: This function accepts two parameters as mentioned above and described below.

  • series: This is the series based on which offset is expanded.
  • order: This is the ordering of the stack.

Return Value: This method returns no value.

Example:

HTML




<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script src=
    </script>
</head>
  
<body>
    <h1 style="text-align: center; color: green;">
        GeeksforGeeks
    </h1>
  
    <script>
        var data = [
        {letter: {a: 1000, b: 2000, c: 3000, d: 4000}},
        {letter: {a: 2000, b: 3000, c: 4000, d: 5000}},
        {letter: {a: 640, b: 960, c: 640, d: 400}},
        {letter: {a: 320, b: 480, c: 640, d: 400}}
        ];
        var stack = d3.stack()
            .keys(["a", "b", "c", "d"])
            .value((d, key) => d.letter[key])
            .order(d3.stackOrderNone)
  
            // Use of d3.stackOrderOffsetExpand() Method
            .offset(d3.stackOffsetExpand);
  
        var series = stack(data);
        console.log(series);
    </script>
</body>
</html>

Output:

My Personal Notes arrow_drop_up
Last Updated : 29 Sep, 2020
Like Article
Save Article
Similar Reads
Related Tutorials