[Accumulated Statistics] Fixed when no QSOs found.
这个提交包含在:
父节点
e257ffa109
当前提交
9e4c97e45b
共有 2 个文件被更改,包括 105 次插入 和 93 次删除
|
|
@ -8,6 +8,10 @@ class Accumulate_model extends CI_Model
|
||||||
$CI->load->model('logbooks_model');
|
$CI->load->model('logbooks_model');
|
||||||
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||||
|
|
||||||
|
if (!$logbooks_locations_array) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
$location_list = "'".implode("','",$logbooks_locations_array)."'";
|
||||||
|
|
||||||
switch ($award) {
|
switch ($award) {
|
||||||
|
|
|
||||||
|
|
@ -9,117 +9,125 @@ function accumulatePlot(form) {
|
||||||
var mode = form.mode.value;
|
var mode = form.mode.value;
|
||||||
var period = form.periodradio.value;
|
var period = form.periodradio.value;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url+'index.php/accumulated/get_accumulated_data',
|
url: base_url + 'index.php/accumulated/get_accumulated_data',
|
||||||
type: 'post',
|
type: 'post',
|
||||||
data: {'Band': form.band.value, 'Award': award, 'Mode': mode, 'Period': period},
|
data: { 'Band': form.band.value, 'Award': award, 'Mode': mode, 'Period': period },
|
||||||
success: function(data) {
|
success: function (data) {
|
||||||
// used for switching award text in the table and the chart
|
if (!$.trim(data)) {
|
||||||
switch(award) {
|
$("#accumulateContainer").empty();
|
||||||
case 'dxcc': var awardtext = "DXCC\'s"; break;
|
$("#accumulateContainer").append('<div class="alert alert-danger" role="alert"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Nothing found!</div>');
|
||||||
case 'was': var awardtext = "states";break;
|
$(".ld-ext-right").removeClass('running');
|
||||||
case 'iota': var awardtext = "IOTA\'s";break;
|
$(".ld-ext-right").prop('disabled', false);
|
||||||
case 'waz': var awardtext = "CQ zones"; break;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// used for switching award text in the table and the chart
|
||||||
|
switch (award) {
|
||||||
|
case 'dxcc': var awardtext = "DXCC\'s"; break;
|
||||||
|
case 'was': var awardtext = "states"; break;
|
||||||
|
case 'iota': var awardtext = "IOTA\'s"; break;
|
||||||
|
case 'waz': var awardtext = "CQ zones"; break;
|
||||||
|
}
|
||||||
|
|
||||||
var periodtext = 'Year';
|
var periodtext = 'Year';
|
||||||
if (period == 'month') {
|
if (period == 'month') {
|
||||||
periodtext += ' + month';
|
periodtext += ' + month';
|
||||||
}
|
}
|
||||||
// removing the old chart so that it will not interfere when loading chart again
|
// removing the old chart so that it will not interfere when loading chart again
|
||||||
$("#accumulateContainer").empty();
|
$("#accumulateContainer").empty();
|
||||||
$("#accumulateContainer").append("<canvas id=\"myChartAccumulate\" width=\"400\" height=\"150\"></canvas><div id=\"accumulateTable\"></div>");
|
$("#accumulateContainer").append("<canvas id=\"myChartAccumulate\" width=\"400\" height=\"150\"></canvas><div id=\"accumulateTable\"></div>");
|
||||||
|
|
||||||
// appending table to hold the data
|
// appending table to hold the data
|
||||||
$("#accumulateTable").append('<table style="width:100%" class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' +
|
$("#accumulateTable").append('<table style="width:100%" class="accutable table table-sm table-bordered table-hover table-striped table-condensed text-center"><thead>' +
|
||||||
'<tr>' +
|
'<tr>' +
|
||||||
'<td>#</td>' +
|
'<td>#</td>' +
|
||||||
'<td>' + periodtext + '</td>' +
|
'<td>' + periodtext + '</td>' +
|
||||||
'<td>Accumulated # of ' + awardtext + ' worked </td>'+
|
'<td>Accumulated # of ' + awardtext + ' worked </td>' +
|
||||||
'</tr>' +
|
'</tr>' +
|
||||||
'</thead>' +
|
'</thead>' +
|
||||||
'<tbody></tbody></table>');
|
'<tbody></tbody></table>');
|
||||||
var labels = [];
|
var labels = [];
|
||||||
var dataDxcc = [];
|
var dataDxcc = [];
|
||||||
|
|
||||||
var $myTable = $('.accutable');
|
var $myTable = $('.accutable');
|
||||||
var i = 1;
|
var i = 1;
|
||||||
|
|
||||||
// building the rows in the table
|
// building the rows in the table
|
||||||
var rowElements = data.map(function ( row ) {
|
var rowElements = data.map(function (row) {
|
||||||
|
|
||||||
var $row = $('<tr></tr>');
|
var $row = $('<tr></tr>');
|
||||||
|
|
||||||
var $iterator = $('<td></td>').html(i++);
|
var $iterator = $('<td></td>').html(i++);
|
||||||
var $type = $('<td></td>').html(row.year);
|
var $type = $('<td></td>').html(row.year);
|
||||||
var $content = $('<td></td>').html(row.total);
|
var $content = $('<td></td>').html(row.total);
|
||||||
|
|
||||||
$row.append($iterator, $type, $content);
|
$row.append($iterator, $type, $content);
|
||||||
|
|
||||||
return $row;
|
return $row;
|
||||||
});
|
});
|
||||||
|
|
||||||
// finally inserting the rows
|
// finally inserting the rows
|
||||||
$myTable.append(rowElements);
|
$myTable.append(rowElements);
|
||||||
|
|
||||||
$.each(data, function(){
|
$.each(data, function () {
|
||||||
labels.push(this.year);
|
labels.push(this.year);
|
||||||
dataDxcc.push(this.total);
|
dataDxcc.push(this.total);
|
||||||
});
|
});
|
||||||
|
|
||||||
var ctx = document.getElementById("myChartAccumulate").getContext('2d');
|
var ctx = document.getElementById("myChartAccumulate").getContext('2d');
|
||||||
var myChart = new Chart(ctx, {
|
var myChart = new Chart(ctx, {
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Accumulated number of ' + awardtext + ' worked each ' + period,
|
label: 'Accumulated number of ' + awardtext + ' worked each ' + period,
|
||||||
data: dataDxcc,
|
data: dataDxcc,
|
||||||
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
backgroundColor: 'rgba(54, 162, 235, 0.2)',
|
||||||
borderColor: 'rgba(54, 162, 235, 1)',
|
borderColor: 'rgba(54, 162, 235, 1)',
|
||||||
borderWidth: 2,
|
borderWidth: 2,
|
||||||
}]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
scales: {
|
|
||||||
yAxes: [{
|
|
||||||
ticks: {
|
|
||||||
beginAtZero:true,
|
|
||||||
fontColor: color
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
xAxes: [{
|
|
||||||
ticks: {
|
|
||||||
fontColor: color
|
|
||||||
}
|
|
||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
legend: {
|
options: {
|
||||||
labels: {
|
scales: {
|
||||||
fontColor: color
|
yAxes: [{
|
||||||
|
ticks: {
|
||||||
|
beginAtZero: true,
|
||||||
|
fontColor: color
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
xAxes: [{
|
||||||
|
ticks: {
|
||||||
|
fontColor: color
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
labels: {
|
||||||
|
fontColor: color
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
$(".ld-ext-right").removeClass('running');
|
||||||
|
$(".ld-ext-right").prop('disabled', false);
|
||||||
|
$('.accutable').DataTable({
|
||||||
|
responsive: false,
|
||||||
|
ordering: false,
|
||||||
|
"scrollY": "400px",
|
||||||
|
"scrollCollapse": true,
|
||||||
|
"paging": false,
|
||||||
|
"scrollX": true,
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: [
|
||||||
|
'csv'
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
// using this to change color of csv-button if dark mode is chosen
|
||||||
|
var background = $('body').css("background-color");
|
||||||
|
|
||||||
|
if (background != ('rgb(255, 255, 255)')) {
|
||||||
|
$(".buttons-csv").css("color", "white");
|
||||||
}
|
}
|
||||||
});
|
|
||||||
$(".ld-ext-right").removeClass('running');
|
|
||||||
$(".ld-ext-right").prop('disabled', false);
|
|
||||||
$('.accutable').DataTable({
|
|
||||||
responsive: false,
|
|
||||||
ordering: false,
|
|
||||||
"scrollY": "400px",
|
|
||||||
"scrollCollapse": true,
|
|
||||||
"paging": false,
|
|
||||||
"scrollX": true,
|
|
||||||
dom: 'Bfrtip',
|
|
||||||
buttons: [
|
|
||||||
'csv'
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
// using this to change color of csv-button if dark mode is chosen
|
|
||||||
var background = $('body').css( "background-color");
|
|
||||||
|
|
||||||
if (background != ('rgb(255, 255, 255)')) {
|
|
||||||
$(".buttons-csv").css("color", "white");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用