Early start on table and chart for elevation stats

This commit is contained in:
Andreas Kristiansen
2024-08-05 18:13:49 +02:00
parent 6bbbae8374
commit c18be54226
4 changed files with 127 additions and 0 deletions

View File

@@ -688,6 +688,20 @@
return $modes;
}
function azeldata() {
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$sql = "SELECT count(*) qsos, round(COL_ANT_EL) elevation FROM logbook where station_id in (" . implode(',',$logbooks_locations_array) . ") and col_ant_el > 0 group by round(col_ant_el)";
$result = $this->db->query($sql);
return $result->result();
}
}
?>

View File

@@ -133,6 +133,8 @@
<ul class="dropdown-menu header-dropdown">
<li><a class="dropdown-item" href="<?php echo site_url('statistics'); ?>" title="Statistics"><i class="fas fa-chart-area"></i> <?= __("Statistics"); ?></a></li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item" href="<?php echo site_url('statistics/antennaanalytics'); ?>" title="Antenna analytics"><i class="fas fa-chart-area"></i> <?= __("Antenna analytics"); ?></a></li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item" href="<?php echo site_url('statistics/qslstats'); ?>" title="QSL Statistics"><i class="fas fa-chart-area"></i> <?= __("QSL Statistics"); ?></a></li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item" href="<?php echo site_url('gridmap'); ?>" title="Gridmap"><i class="fas fa-globe-europe"></i> <?= __("Gridsquare Map"); ?></a></li>

View File

@@ -0,0 +1,37 @@
<script>
let azdata =
<?php
echo json_encode($azelarray);
?>;
</script>
<div class="container">
<br />
<div class="card">
<div class="card-header">
<?= __("Antenna Analytics"); ?>
</div>
<div class="tables-container mx-2">
<?php
if ($azelarray) {
echo '<table style="width:100%" class="qsotable table-sm table table-bordered table-hover table-striped table-condensed text-center">
<thead>';
echo '<tr>';
echo '<th>'.__("Elevation").'</th>';
echo '<th>'.__("# QSOs").'</th>';
echo '</tr>
</thead>
<tbody>';
foreach ($azelarray as $qso) {
echo '<tr>';
echo '<th>' . $qso->elevation . '</th>';
echo '<th>' . $qso->qsos . '</th>';
echo '</tr>';
}
echo '</tfoot></table>';
}
?>
<canvas id="elevationchart"></canvas>
</div>
</div>
</div>

View File

@@ -0,0 +1,74 @@
makeChart();
function makeChart() {
var labels = [];
var dataQso = [];
$.each(azdata, function () {
labels.push(this.elevation);
dataQso.push(this.qsos);
});
// using this to change color of legend and label according to background color
var color = ifDarkModeThemeReturn('white', 'grey');
var ctx = document.getElementById("elevationchart").getContext('2d');
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: dataQso,
datasets: [{
label: '# QSOs for elevation',
data: dataQso,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 2,
color: color
}]
},
options: {
scales: {
y: {
title: {
display: true,
text: 'Elevation',
font: {
size: 15
},
color: color
},
ticks: {
beginAtZero: true,
color: color
}
},
x: {
title: {
display: true,
text: '# QSOs',
font: {
size: 15
},
color: color
},
ticks: {
color: color
}
}
},
plugins: {
legend: {
labels: {
color: color
}
}
}
}
});
// 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");
}
};