$(() => {
$('#chart').dxChart({
palette: 'soft',
dataSource,
commonSeriesSettings: {
barPadding: 0.5,
argumentField: 'state',
type: 'bar',
},
series: [
{ valueField: 'year1970', name: '1970' },
{ valueField: 'year1980', name: '1980' },
{ valueField: 'year1990', name: '1990' },
{ valueField: 'year2000', name: '2000' },
{ valueField: 'year2008', name: '2008' },
{ valueField: 'year2009', name: '2009' },
],
legend: {
verticalAlignment: 'bottom',
horizontalAlignment: 'center',
},
export: {
enabled: true,
},
title: {
text: 'Oil Production',
subtitle: {
text: '(in millions tonnes)',
},
},
});
});
<!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://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">
<div id="chart"></div>
</div>
</body>
</html>
#chart {
height: 440px;
}
const dataSource = [{
state: 'Saudi Arabia',
year1970: 186.7,
year1980: 480.4,
year1990: 319.6,
year2000: 465,
year2008: 549.7,
year2009: 428.4,
}, {
state: 'USA',
year1970: 557.8,
year1980: 423.2,
year1990: 340.1,
year2000: 282.9,
year2008: 280,
year2009: 298.9,
}, {
state: 'China',
year1970: 32.7,
year1980: 87.7,
year1990: 165.1,
year2000: 126.6,
year2008: 191.3,
year2009: 181.1,
}, {
state: 'Canada',
year1970: 87.5,
year1980: 78.1,
year1990: 69.3,
year2000: 145.7,
year2008: 148.5,
year2009: 182.2,
}, {
state: 'Mexico',
year1970: 24.7,
year1980: 109.2,
year1990: 145.3,
year2000: 148.3,
year2008: 132.1,
year2009: 121.6,
}];