Stacked Bar Chart in JavaScript Charts

100% Stacked Bar

To render a 100% stacked bar series in your chart, follow the steps below:

  • Set the series type: Define the series type as StackingBar100 in your chart configuration. This indicates that the data should be represented as a 100% stacked bar chart, with segments that show the percentage contribution of each part.
var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison'
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Binding data with series

You can bind data to the chart using the dataSource property within the series configuration. This allows you to connect a JSON dataset or remote data to your chart. To display the data correctly, map the fields from the data to the chart series xName and yName properties.

var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison'
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Series customization

The following properties can be used to customize the 100% stacked bar series.

Solid fill

The fill property determines the color applied to the series.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48 },
  { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
  { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
  { x: 2003, y: 1,    y1: 0.09, y2: 0.61 },
  { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
  { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
  { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
  { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
  { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
  { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        fill: '#483D8B'
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        fill: '#556B2F'
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        fill: '#8B0000'
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Gradient fill

The fill property also applies an SVG gradient to a 100% stacked bar series. Define the gradient within an SVG <defs> element using a unique ID, and assign it to the series in the url(#gradientId) format.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48 },
  { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
  { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
  { x: 2003, y: 1, y1: 0.09, y2: 0.61 },
  { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
  { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
  { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
  { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
  { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
  { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        fill: 'url(#gradient1)'
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        fill: 'url(#gradient2)'
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        fill: 'url(#gradient3)'
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <svg style="width:1px; height:1px">
        <defs>
            <linearGradient id="gradient1">
                <stop offset="0%" style="stop-color:coral;stop-opacity:5" />
                <stop offset="50%" style="stop-color:mediumseagreen;stop-opacity:5" />
            </linearGradient>
        </defs>
    </svg>
    <svg style="width:1px; height:1px">
        <defs>
            <linearGradient id="gradient2">
                <stop offset="0%" style="stop-color:darkred;stop-opacity:5" />
                <stop offset="50%" style="stop-color:darkorange;stop-opacity:5" />
            </linearGradient>
        </defs>
    </svg>
    <svg style="width:1px; height:1px">
        <defs>
            <linearGradient id="gradient3">
                <stop offset="0%" style="stop-color:darkmagenta;stop-opacity:5" />
                <stop offset="50%" style="stop-color:darkcyan;stop-opacity:5" />
            </linearGradient>
        </defs>
    </svg>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Opacity

The opacity property controls the transparency of the fill and affects how the series blends with background or overlapping series.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48 },
  { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
  { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
  { x: 2003, y: 1,    y1: 0.09, y2: 0.61 },
  { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
  { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
  { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
  { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
  { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
  { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        opacity: 0.7
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        opacity: 0.7
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        opacity: 0.7
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Border

Use the border property to configure the border width, color, and dash array of the 100% stacked bar series.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48 },
  { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
  { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
  { x: 2003, y: 1,    y1: 0.09, y2: 0.61 },
  { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
  { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
  { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 },
  { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
  { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
  { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        border: { width: 2, color: '#ff4251', dashArray: '5,5' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        border: { width: 2, color: '#66BDB7', dashArray: '5,5' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        border: { width: 2, color: '#794F1B', dashArray: '5,5' }
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

100% Cylindrical stacked bar chart

To render a 100% cylindrical stacked bar chart, set the columnFacet property to Cylinder in the chart series. The only other valid value is Rectangle (the default), which renders rectangular bars.

var cylindricalData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48 }, { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 }, { x: 2003, y: 1, y1: 0.09, y2: 0.61 },
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 }, { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 }, { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar with cylindrical shape
            type: 'StackingBar100', 
            columnFacet: 'Cylinder',
            dataSource: cylindricalData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        },
        {
            type: 'StackingBar100', 
            columnFacet: 'Cylinder',
            dataSource: cylindricalData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        },
        {
            type: 'StackingBar100', 
            columnFacet: 'Cylinder',
            dataSource: cylindricalData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison'
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Empty points

Data points with null or undefined values are considered empty. Configure the emptyPointSettings on the series to control how empty data points are rendered.

Mode

Use the mode property to control handling of empty points. Available modes are Gap, Drop, Zero, and Average. The default mode is Gap.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: null },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: undefined, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: null, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        emptyPointSettings: {
          mode: 'Zero'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        emptyPointSettings: {
          mode: 'Gap'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        emptyPointSettings: {
          mode: 'Average'
        }
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Fill

Use the fill property to set the fill color for empty points.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: null },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: undefined, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: null, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        emptyPointSettings: {
          mode: 'Zero'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        emptyPointSettings: {
          mode: 'Gap'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        emptyPointSettings: {
          mode: 'Average',
          fill: 'red'
        }
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Border

Use the border property to customize the border width and color for empty points.

var stackedData = [
  { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: null },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: undefined, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: null, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart(
  {
    primaryXAxis: {
      title: 'Months'
    },
    primaryYAxis:
    {
      title: 'Percentage (%)',
      labelFormat: '{value}%'
    },
    series: [
      {
        //Series type as 100% stacked bar
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y',
        name: 'Apple',
        emptyPointSettings: {
          mode: 'Zero'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        emptyPointSettings: {
          mode: 'Gap'
        }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        emptyPointSettings: {
          mode: 'Average',
          fill: 'red',
          border: { width: 2, color: 'green' }
        }
      }
    ],
    title: 'Sales Comparison'
  },
  '#element'
);
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Corner radius

The cornerRadius property in the chart series is used to customize the corner radius for 100% stacked bar series. This allows you to create 100% stacked bars with rounded corners. You can customize each corner of the 100% stacked bars using the topLeft, topRight, bottomLeft, and bottomRight properties.

var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {   cornerRadius: { topRight: 10, bottomRight: 10 },
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison',
    pointRender: function (args) {
        if (args.point.series.index % 2 !== 0) {
            args.fill = '#ff6347';
        } 
        else {
            args.fill = '#009cb8';
        }
    }
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Point corner radius

You can customize the corner radius for individual points in the chart series using the pointRender event by setting the cornerRadius property in its event argument.

var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Years'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison',
    pointRender: function (args) {
        if (args.point.index === 1 && args.point.series.index === 2) {
            args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
        }
        if (args.point.index === 4 && args.point.series.index === 2) {
            args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
        }
        if (args.point.index === 6 && args.point.series.index === 2) {
            args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
        }
        if (args.point.index === 8 && args.point.series.index === 2) {
            args.cornerRadius = { topLeft: 0, bottomLeft: 0, topRight: 10, bottomRight: 10 };
        }
    }
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Events

Series render

The seriesRender event enables modification of series properties (for example, data, fill, or name) immediately before rendering. Use this event to adjust series appearance or to dynamically swap data sources.

var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison',
    seriesRender: function (args) {
        if (args.series.index === 0) {
            args.fill = '#ff4251';
        }
        else if (args.series.index === 1) {
            args.fill = '#4C4C4C';
        }
        else if (args.series.index === 2) {
            args.fill = '#794F1B';
        }
    }
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Point render

The pointRender event provides a hook to customize each data point (for example, marker shape, border, or fill) before it is drawn. Use this to apply per-point styling rules or conditional formatting.

var stackedData = [
    { x: 2000, y: 0.61, y1: 0.03, y2: 0.48},
    { x: 2001, y: 0.81, y1: 0.05, y2: 0.53 },
    { x: 2002, y: 0.91, y1: 0.06, y2: 0.57 },
    { x: 2003, y: 1,    y1: 0.09, y2: 0.61 }, 
    { x: 2004, y: 1.19, y1: 0.14, y2: 0.63 },
    { x: 2005, y: 1.47, y1: 0.20, y2: 0.64 },
    { x: 2006, y: 1.74, y1: 0.29, y2: 0.66 }, 
    { x: 2007, y: 1.98, y1: 0.46, y2: 0.76 },
    { x: 2008, y: 1.99, y1: 0.64, y2: 0.77 },
    { x: 2009, y: 1.70, y1: 0.75, y2: 0.55 }
];
var chart = new ej.charts.Chart({
    primaryXAxis: {
        title: 'Months'
    },
    primaryYAxis:
    {
        title: 'Percentage (%)',
        labelFormat: '{value}%'
    },
    series: [
        {
            //Series type as 100% stacked bar
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y',
            name: 'Apple'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y1',
            name: 'Orange'
        }, 
        {
            type: 'StackingBar100',
            dataSource: stackedData, 
            xName: 'x', 
            yName: 'y2',
            name: 'Wastage'
        }
    ],
    title: 'Sales Comparison',
    pointRender: function (args) {
        if (args.point.series.index % 2 !== 0) {
            args.fill = '#ff6347';
        } 
        else {
            args.fill = '#009cb8';
        }
    }
}, '#element');
<!DOCTYPE html>
<html lang="en">

<head>
    <title>EJ2 Animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <link href="index.css" rel="stylesheet">
    <script src="https://cdn.syncfusion.com/ej2/35.2.12/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    <div id="container">
        <div id="element"></div>
    </div>
    <script>
        var ele = document.getElementById('container');
        if (ele) {
            ele.style.visibility = "visible";
        }   
    </script>
    <script src="index.js" type="text/javascript"></script>
</body>

</html>

Troubleshooting

The following list describes common issues you may encounter when working with the 100% Stacked Bar series and how to resolve them.

Chart does not render a 100% stacked bar: Confirm the type property of each series is set to StackingBar100. If type is omitted or set to a different value (for example, StackingBar), the data is drawn as overlapping (non-normalized) segments. In JavaScript, the StackingBarSeries module is loaded through the script bundle; no explicit Chart.Inject(...) call is required.

Cylindrical facet does not appear: columnFacet accepts only Rectangle (the default) and Cylinder. Other values are ignored. Confirm the property is set on each series configuration object and that the chart is rendered with the StackingBar100 series type.

Bands do not normalize to 100%: 100% stacked series render each x-position as 100% of all contributing values. If percentages do not sum to 100, verify that each series shares the same xName and that the input data is non-negative. Negative values are not normalized and will produce inconsistent percentages.

See also