Stacked bar Chart in EJ2 JavaScript control

20 Sep 202424 minutes to read

100% Stacked bar

To render a 100% stacked bar series in your chart, you need to follow a few steps to configure it correctly. Here’s a concise guide on how to do this:

  • 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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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>

The fill property can be used to apply a gradient color to the 100% stacked bar series. By configuring this property with gradient values, you can create a visually appealing effect in which the color transitions smoothly from one shade to another.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 specifies the transparency level of the fill. Adjusting this property allows you to control how opaque or transparent the fill color of the series appears.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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>

Dash array

The dashArray property determines the pattern of dashes and gaps in 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',
        dashArray: '5,5',
        border: { width: 2, color: '#ff4251' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        dashArray: '5,5',
        border: { width: 2, color: '#4C4C4C' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        dashArray: '5,5',
        border: { width: 2, color: '#794F1B' }
      }
    ],
    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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 width and color of the series border.

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' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y1',
        name: 'Orange',
        border: { width: 2, color: '#66BDB7' }
      },
      {
        type: 'StackingBar100',
        dataSource: stackedData,
        xName: 'x',
        yName: 'y2',
        name: 'Wastage',
        border: { width: 2, color: '#794F1B' }
      }
    ],
    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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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. This property transforms the regular 100% stacked bars into cylindrical shapes, enhancing the visual representation of the data.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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. Empty data points are ignored and not plotted on the chart.

Mode

Use the mode property to define how empty or missing data points are handled in the series. The default mode for empty points 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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 customize the fill color of empty points in 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: 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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 width and color of the border 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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 allows you to customize series properties, such as data, fill, and name, before they are rendered on the chart.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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 allows you to customize each data point before it is rendered on the chart.

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/27.1.48/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.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>

See also