Your search did not match any results.
Bar Charts

Stacked Bar

This demo shows the stacked bar series type that visualizes data as columns stacked over each other. You can use this series type to compare values of an individual series with total values aggregated for each argument.

Bind to Data

In this demo, series is bound to data directly. See the Bind Series to Data article for information. The "state" field name is assigned to the argumentField property of the commonSeriesSettings object since the stacked bar chart contains series with the same argument field.

Specify Common Series Settings

To configure settings for all series in the chart, use the commonSeriesSettings object. For example, specify the series type.

Customize Stacked Bar Chart

Use the verticalAlignment and horizontalAlignment properties of the legend object to specify the legend position in the chart. You can specify the text's position relative to the marker in a legend item in the itemTextPosition property.

To configure tooltips in the chart, use the tooltip object. To enable the tooltips, assign true to the enabled property of this object. If you want to customize a specific tooltip, assign a function to the customizeTooltip property. In this demo, the function returns the tooltip's text that shows the series name and point value.
Backend API
Copy to CodePen
const DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', ($scope) => { $scope.chartOptions = { dataSource, commonSeriesSettings: { argumentField: 'state', type: 'stackedBar', }, series: [ { valueField: 'young', name: '0-14' }, { valueField: 'middle', name: '15-64' }, { valueField: 'older', name: '65 and older' }, ], legend: { verticalAlignment: 'bottom', horizontalAlignment: 'center', itemTextPosition: 'top', }, valueAxis: { title: { text: 'millions', }, position: 'right', }, title: 'Male Age Structure', export: { enabled: true, }, tooltip: { enabled: true, location: 'edge', customizeTooltip(arg) { return { text: `${arg.seriesName} years: ${arg.valueText}`, }; }, }, }; });
<!DOCTYPE html> <html xmlns=""> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src=""></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C/script%3E'))</script> <script src=""></script> <script src="data.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container" ng-app="DemoApp" ng-controller="DemoController"> <div id="chart" dx-chart="chartOptions"></div> </div> </body> </html>
#chart { height: 440px; }
const dataSource = [{ state: 'Germany', young: 5.3, middle: 26, older: 8, }, { state: 'Japan', young: 6.45, middle: 30.5, older: 11.22, }, { state: 'Russia', young: 12.56, middle: 45.5, older: 6.5, }, { state: 'USA', young: 32, middle: 87, older: 15, }];