JavaScript stacked bar chart is a chart with y-values stacked on one another in series order. It shows the relationship among individual values to the total of the points.
You can plot multiple series in a single chart to compare different data sets. Enabling legend and tooltip gives more information about the individual series.
Mark data points with built-in shapes: circles, rectangles, ellipses, vertical lines, horizontal lines, diamonds, triangles, pentagons, crosses, and pluses. In addition to these shapes, use images to make the points more attractive.
Data labels display information about data points. Add a template to display data labels with HTML elements such as images, DIV, and spans for more informative data labels. You can rotate a data label by a given angle.
Use multiple axes to plot different data sets that vary widely from each other.
Group a series with another series separately using a different group name.
Customize spacing between two bars and the width of the bars.
Modernize the UI by applying rounded corners to the stacked bar.
Modernize the UI by displaying value as cylindrical-shaped data points.
Customize the look and feel of the stacked bar chart using built-in APIs.
Easily get started with JavaScript Stacked Bar using a few simple lines of JS code, as demonstrated below. Also explore our JavaScript Stacked Bar Chart Example that shows you how to render and configure the stacked bar chart component.
import { Chart, StackingBarSeries, Category } from '@syncfusion/ej2-charts';
Chart.Inject(Chart, StackingBarSeries, Category);
let chart: Chart = new Chart({
primaryXAxis: {
valueType: 'Category'
},
series:[{
type: 'StackingBar',
dataSource: [
{ x: '2014', y: 111.1 },
{ x: '2015', y: 127.3 },
{ x: '2016', y: 143.4 },
{ x: '2017', y: 159.9 }],
xName: 'x', width: 2,
yName: 'y', name: 'UK'
},
{
type: 'StackingBar',
dataSource: [
{ x: '2014', y: 76.9 },
{ x: '2015', y: 99.5 },
{ x: '2016', y: 121.7 },
{ x: '2017', y: 142.5 }],
xName: 'x', width: 2,
yName: 'y', name: 'Germany',
},
{
type: 'StackingBar',
dataSource: [
{ x: '2014', y: 66.1 },
{ x: '2015', y: 79.3 },
{ x: '2016', y: 91.3 },
{ x: '2017', y: 102.4 }],
xName: 'x', width: 2,
yName: 'y', name: 'France',
},
],
}, '#Chart');
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="container">
<div id="Chart"></div>
</div>
</body>
</html>
Learn the available options to customize JavaScript stacked bar chart.
Stacked Bar Chart API Reference
Explore the JavaScript stacked bar chart APIs.