var DemoApp = angular.module('DemoApp', ['dx']);
DemoApp.controller('DemoController', function DemoController($scope) {
var chartDataSource = new DevExpress.data.DataSource({
store: {
type: "odata",
url: "https://js.devexpress.com/Demos/WidgetsGallery/odata/WeatherItems"
},
postProcess: function(results) {
return results[0].DayItems;
},
expand: "DayItems",
filter: ["Id", "=", 1],
paginate: false
});
$scope.chartOptions = {
dataSource: chartDataSource,
title: "Temperature in Barcelona, 2012",
size: {
height: 420
},
series: {
argumentField: "Number",
valueField: "Temperature",
type: "spline"
},
legend: {
visible: false
},
commonPaneSettings: {
border: {
visible: true,
width: 2,
top: false,
right: false
}
},
"export": {
enabled: true
},
tooltip: {
enabled: true,
customizeTooltip: function (arg) {
return {
text: arg.valueText + "°C"
};
}
},
valueAxis: {
valueType: "numeric",
grid: {
opacity: 0.2
},
label: {
customizeText: function() {
return this.valueText + "°C";
}
}
},
argumentAxis: {
type: "discrete",
grid: {
visible: true,
opacity: 0.5
}
},
loadingIndicator: {
enabled: true
}
};
$scope.selectBoxOptions = {
width: 150,
value: 1,
items: months,
valueExpr: "id",
displayExpr: "name",
onValueChanged: function(e) {
chartDataSource.filter(["Id", "=", e.value]);
chartDataSource.load();
}
};
});
<!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.4.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/19.2.4/css/dx.common.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/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/19.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" ng-app="DemoApp" ng-controller="DemoController">
<div id="chart-demo">
<div id="chart" dx-chart="chartOptions"></div>
<div class="action">
<div id="selectbox" dx-select-box="selectBoxOptions"></div>
<div class="label">Choose a month:</div>
</div>
</div>
</div>
</body>
</html>
#selectbox {
float: right;
}
.action {
width: 270px;
margin-top: 20px;
}
.label {
padding-top: 9px;
}
var months = [{
id: 1,
name: "January"
}, {
id: 2,
name: "February"
}, {
id: 3,
name: "March"
}, {
id: 4,
name: "April"
}, {
id: 5,
name: "May"
}, {
id: 6,
name: "June"
}, {
id: 7,
name: "July"
}, {
id: 8,
name: "August"
}, {
id: 9,
name: "September"
}, {
id: 10,
name: "October"
}, {
id: 11,
name: "November"
}, {
id: 12,
name: "December"
}];