Your search did not match any results.
Bar Charts

Bi-Directional Bar Chart

Documentation

This demo shows how to create a bi-directional bar chart. This is a rotated stacked bar chart with half of its data source values converted from positive to negative.

Backend API
Copy to CodePen
Apply
Reset
$(() => { $('#chart').dxChart({ title: 'Population Pyramid For Norway 2016', dataSource, rotated: true, barGroupWidth: 18, commonSeriesSettings: { type: 'stackedbar', argumentField: 'age', }, series: [{ valueField: 'male', name: 'Male', color: '#3F7FBF', }, { valueField: 'female', name: 'Female', color: '#F87CCC', }], tooltip: { enabled: true, customizeTooltip() { return { text: Math.abs(this.valueText), }; }, }, valueAxis: { label: { customizeText() { return `${Math.abs(this.value)}%`; }, }, }, legend: { verticalAlignment: 'bottom', horizontalAlignment: 'center', margin: { left: 50 }, }, }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <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="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></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="https://cdn3.devexpress.com/jslib/21.2.3/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/21.2.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/21.2.3/js/dx.all.js"></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"> <div id="chart"></div> </div> </body> </html>
#chart { height: 549px; width: 820px; margin: 0 auto; }
const dataSource = [{ age: '0-4', male: -3.1, female: 2.9, }, { age: '5-9', male: -3.1, female: 3.0, }, { age: '10-14', male: -3.0, female: 2.9, }, { age: '15-19', male: -3.2, female: 3.0, }, { age: '20-24', male: -3.5, female: 3.3, }, { age: '25-29', male: -3.5, female: 3.4, }, { age: '30-34', male: -3.5, female: 3.3, }, { age: '35-39', male: -3.3, female: 3.1, }, { age: '40-44', male: -3.7, female: 3.4, }, { age: '45-49', male: -3.8, female: 3.5, }, { age: '50-54', male: -3.4, female: 3.2, }, { age: '55-59', male: -3.1, female: 3.0, }, { age: '60-64', male: -2.7, female: 2.7, }, { age: '65-69', male: -2.9, female: 2.9, }, { age: '70-74', male: -2, female: 2.1, }, { age: '75-79', male: -1.2, female: 1.4, }, { age: '80-84', male: -0.8, female: 1.2, }, { age: '85-89', male: -0.5, female: 0.8, }, { age: '90-94', male: -0.2, female: 0.5, }, { age: '95+', male: 0, female: 0.1, }];