const DemoApp = angular.module('DemoApp', ['dx']);
DemoApp.controller('DemoController', ($scope) => {
$scope.chartOptions = {
rotated: true,
dataSource,
commonSeriesSettings: {
argumentField: 'country',
type: 'bar',
hoverMode: 'allArgumentPoints',
selectionMode: 'allArgumentPoints',
label: {
visible: true,
format: {
type: 'percent',
precision: 1,
},
},
},
valueAxis: {
label: {
format: {
type: 'percent',
precision: 1,
},
},
},
series: [
{ valueField: 'year2007', name: '2007 - 2008' },
{ valueField: 'year2008', name: '2008 - 2009' },
],
title: {
text: 'Economy - Export Change',
},
legend: {
verticalAlignment: 'bottom',
horizontalAlignment: 'center',
},
export: {
enabled: true,
},
onPointClick(e) {
e.target.select();
},
onLegendClick(e) {
const series = e.target;
if (series.isVisible()) {
series.hide();
} else {
series.show();
}
},
};
});
<!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/22.2.6/css/dx.light.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/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/22.2.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>
</body>
</html>
#chart {
height: 440px;
}
const dataSource = [{
country: 'China',
year2007: 0.18265,
year2008: -0.16682,
}, {
country: 'Germany',
year2007: 0.10467,
year2008: -0.20165,
}, {
country: 'United States',
year2007: 0.1232,
year2008: -0.17994,
}, {
country: 'Japan',
year2007: 0.10868,
year2008: -0.25622,
}, {
country: 'France',
year2007: 0.09526,
year2008: -0.23631,
}, {
country: 'Netherlands',
year2007: 0.14402,
year2008: -0.21923,
}];