Your search did not match any results.
Bar Charts

Drill-Down Chart

Documentation

This demo shows a drill-down chart with two views. The start view displays a breakdown of population by continents. When you click a bar, the detailed view reveals most populated countries on the selected continent. Data for this view is provided by applying a filter to the original data.

Copy to CodePen
Apply
Reset
var DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', function DemoController($scope, $element) { $scope.dataSource = filterData(""); $scope.isFirstLevel = true; $scope.chartOptions = { bindingOptions: { dataSource: "dataSource", }, title: "The Most Populated Countries by Continents", series: { type: "bar" }, legend: { visible: false }, valueAxis: { showZero: false }, onPointClick: function (e) { if ($scope.isFirstLevel) { $scope.isFirstLevel = false; removePointerCursor($element); $scope.dataSource = filterData(e.target.originalArgument); } }, customizePoint: function () { var pointSettings = { color: colors[Number($scope.isFirstLevel)] }; if (!$scope.isFirstLevel) { pointSettings.hoverStyle = { hatching: "none" }; } return pointSettings; } }; $scope.buttonOptions = { text: "Back", icon: "chevronleft", bindingOptions: { visible: "!isFirstLevel" }, onClick: function () { if (!$scope.isFirstLevel) { $scope.isFirstLevel = true; addPointerCursor($element); $scope.dataSource = filterData(""); } } }; addPointerCursor($element); }); function filterData(name) { return data.filter(function (item) { return item.parentID === name; }); } function addPointerCursor(element) { element.find("#chart").addClass("pointer-on-bars"); } function removePointerCursor(element) { element.find("#chart").removeClass("pointer-on-bars"); }
<!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.1.0/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/18.1.6/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/18.1.6/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C\/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/18.1.6/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" ng-app="DemoApp" ng-controller="DemoController"> <div id="chart" dx-chart="chartOptions"></div> <div class="button-container"> <div dx-button="buttonOptions"></div> </div> </div> </body> </html>
#chart { height: 440px; width: 100%; } #chart.pointer-on-bars .dxc-series rect { cursor: pointer; } .button-container { text-align: center; height: 40px; position: absolute; top: 7px; left: 0px; }
var colors = ["#6babac", "#e55253"]; var data = [ { arg: "Asia", val: 3007613498, parentID: "" }, { arg: "North America", val: 493603615, parentID: "" }, { arg: "Europe", val: 438575293, parentID: "" }, { arg: "Africa", val: 381331438, parentID: "" }, { arg: "South America", val: 331126555, parentID: "" }, { arg: "Nigeria", val: 181562056, parentID: "Africa" }, { arg: "Egypt", val: 88487396, parentID: "Africa" }, { arg: "Congo", val: 77433744, parentID: "Africa" }, { arg: "Morocco", val: 33848242, parentID: "Africa" }, { arg: "China", val: 1380083000, parentID: "Asia" }, { arg: "India", val: 1306687000, parentID: "Asia" }, { arg: "Pakistan", val: 193885498, parentID: "Asia" }, { arg: "Japan", val: 126958000, parentID: "Asia" }, { arg: "Russia", val: 146804372, parentID: "Europe" }, { arg: "Germany", val: 82175684, parentID: "Europe" }, { arg: "Turkey", val: 79463663, parentID: "Europe" }, { arg: "France", val: 66736000, parentID: "Europe" }, { arg: "United Kingdom", val: 63395574, parentID: "Europe" }, { arg: "United States", val: 325310275, parentID: "North America" }, { arg: "Mexico", val: 121005815, parentID: "North America" }, { arg: "Canada", val: 36048521, parentID: "North America" }, { arg: "Cuba", val: 11239004, parentID: "North America" }, { arg: "Brazil", val: 205737996, parentID: "South America" }, { arg: "Colombia", val: 48400388, parentID: "South America" }, { arg: "Venezuela", val: 30761000, parentID: "South America" }, { arg: "Peru", val: 28220764, parentID: "South America" }, { arg: "Chile", val: 18006407, parentID: "South America" } ];