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.

Copy to CodeSandBox
Apply
Reset
<template> <dx-chart id="chart" :data-source="dataSource" :rotated="true" :bar-group-width="18" title="Population Pyramid For Norway 2016" > <dx-common-series-settings argument-field="age" type="stackedbar" /> <dx-series value-field="male" name="Male" color="#3F7FBF" /> <dx-series value-field="female" name="Female" color="#F87CCC" /> <dx-tooltip :enabled="true" :customize-tooltip="customizeTooltip" /> <dx-value-axis> <dx-label :customize-text="customizeLabel"/> </dx-value-axis> <dx-legend :margin="{left: 50}" vertical-alignment="bottom" horizontal-alignment="center" /> </dx-chart> </template> <script> import DxChart, { DxCommonSeriesSettings, DxValueAxis, DxLabel, DxLegend, DxSeries, DxTooltip } from 'devextreme-vue/chart'; import { dataSource } from './data.js'; export default { components: { DxChart, DxCommonSeriesSettings, DxValueAxis, DxLabel, DxLegend, DxSeries, DxTooltip }, computed: { dataSource() { return dataSource; } }, methods: { customizeTooltip(e) { return { text: Math.abs(e.valueText) }; }, customizeLabel(e) { return `${Math.abs(e.value)}%`; } } }; </script> <style> #chart { height: 549px; width: 820px; margin: 0 auto; } </style>
import Vue from 'vue'; import App from './App.vue'; new Vue({ el: '#app', components: { App }, template: '<App/>' });
<!DOCTYPE html> <html> <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" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.6/css/dx.light.css" /> <script src="https://unpkg.com/core-js@2.4.1/client/shim.min.js"></script> <script src="https://unpkg.com/systemjs@0.21.3/dist/system.js"></script> <script type="text/javascript" src="config.js"></script> <script type="text/javascript"> System.import('./index.js'); </script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="app"> <span v-if="false">Loading...</span> </div> </div> </body> </html>
export 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 } ];
System.config({ transpiler: 'plugin-babel', paths: { 'npm:': 'https://unpkg.com/' }, map: { vue: 'npm:vue@2.6.3/dist/vue.esm.browser.js', 'vue-loader': 'npm:systemjs-vue-browser@latest/index.js', 'devextreme': 'npm:devextreme@19.1', 'devextreme-vue': 'npm:devextreme-vue@19.1', jszip: 'npm:jszip@3.1.3/dist/jszip.min.js', 'quill': 'npm:quill@1.3.6/dist/quill.js', 'devexpress-diagram': 'npm:devexpress-diagram', 'plugin-babel': 'npm:systemjs-plugin-babel@0/plugin-babel.js', 'systemjs-babel-build': 'npm:systemjs-plugin-babel@0/systemjs-babel-browser.js' }, meta: { '*.vue': { loader: 'vue-loader' } }, packages: { 'devextreme-vue': { main: 'index.js' }, 'devextreme': { defaultExtension: 'js' } }, babelOptions: { sourceMaps: false, stage0: true } });