我正在尝试创建图表。这是我的HTML代码
<div class="card">
<div class="item item-divider">
Approved and Pending Members
</div>
<div class="item item-text-wrap">
<canvas id="line" class="chart chart-bar" data="memStatData" labels="status" legend="true" series="stats" options="{showTooltips: true}"> </canvas>
</div>
</div>
和我的JS:
$scope.status = ["Approved", "Pending"];
$scope.stats = ["Stats"];
$scope.memStatData = [];
var query = "SELECT sum(members.status='P') as pending, "
+ "sum(members.status='A') as approved FROM members";
$cordovaSQLite.execute(db, query, [])
.then(function(res){
$scope.memStatData = res.rows.item(0);
console.log(JSON.stringify($scope.memStatData));
}, function(err){
$cordovaToast.showShortBottom('Something Went Wrong').then(function(success){}, function(err){});
console.log(err.message);
});
如何在我的图表中显示待处理和已批准的总和?感谢。
答案 0 :(得分:0)
我已经弄清楚了。如果我做得对,请告诉我。但是图表从我的数据库中获取值。
$scope.status = ["Approved", "Pending"];
$scope.stats = ["Stats"];
var query = "SELECT sum(members.status='P') as pending, "
+ "sum(members.status='A') as approved FROM members";
$cordovaSQLite.execute(db, query, [])
.then(function(res){
$scope.memStatData= res.rows.item(0);
var p = $scope.memStatData.pending;
var a = $scope.memStatData.approved;
console.log(p);
console.log(a);
$scope.memStatData = [
[p, a]
];
}, function(err){
// $cordovaToast.showShortBottom('Something Went Wrong').then(function(success){}, function(err){});
console.log(err.message);
});