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
$(function () { var isFirstLevel = true, chartContainer = $("#chart"), chart = chartContainer.dxChart({ dataSource: filterData(""), title: "The Most Populated Countries by Continents", series: { type: "bar" }, legend: { visible: false }, valueAxis: { showZero: false }, onPointClick: function (e) { if (isFirstLevel) { isFirstLevel = false; removePointerCursor(chartContainer); chart.option({ dataSource: filterData(e.target.originalArgument) }); $("#backButton") .dxButton("instance") .option("visible", true); } }, customizePoint: function () { var pointSettings = { color: colors[Number(isFirstLevel)] }; if (!isFirstLevel) { pointSettings.hoverStyle = { hatching: "none" }; } return pointSettings; } }).dxChart("instance"); $("#backButton").dxButton({ text: "Back", icon: "chevronleft", visible: false, onClick: function () { if (!isFirstLevel) { isFirstLevel = true; addPointerCursor(chartContainer); chart.option("dataSource", filterData("")); this.option("visible", false); } } }); addPointerCursor(chartContainer); }); function filterData(name) { return data.filter(function (item) { return item.parentID === name; }); } function addPointerCursor(container) { container.addClass("pointer-on-bars"); } function removePointerCursor(container) { container.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-3.1.0.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.2.4/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.2.4/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.2.4/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/17.2.4/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 class="button-container"> <div id="backButton"></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" } ];