Skip to content

Commit

Permalink
Started to get MAP to play with CEFAS dredge data dump
Browse files Browse the repository at this point in the history
  • Loading branch information
steps39 committed Jul 31, 2024
1 parent 807109f commit 92b14da
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 138 deletions.
13 changes: 8 additions & 5 deletions SedimentDataExplorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ <h1>Sediment Template Data Explorer - v0.20240725</h1>
<button onclick="exportChart()">Export Chart</button>
<button onclick="clearData()">Clear Data</button>
<br>
CEFAS Sediment Data -
CEFAS Sediment Data -
<button onclick="openCEFASSelection()">Select CEFAS Data Sets</button>
<div id="sedDataModal" style="display: none;">
<div id="sedDredgeData" style="display: none;">
</div>
<div id="sedDataModal" style="display: none;">
<h2>Select Data Sets</h2>
<input type="file" id="fileInputDD" multiple onchange="importDredgeData()"> <!-- Allow multiple file selection -->
<input type="text" id="urlInputDD" placeholder="URLs comma-separated" onchange="importDredgeData()">
<!-- Accept comma-separated URLs -->
<label for="fileInputDD">CEFAS dredge data file</label>
<input type="file" id="fileInputDD" onchange="importDredgeData()"> <!-- Could allow multiple file selection -->
<input type="text" id="urlInputDD" placeholder="URL" onchange="importDredgeData()">
<!-- Would accept comma-separated URLs -->
<br>
<input type="text" id="mlApplications" placeholder="MLA ids comma-separated" onchange="closeCEFASSelection()">
<button onclick="closeCEFASSelection()">Finish CEFAS Selection</button>
Expand Down
22 changes: 19 additions & 3 deletions SedimentDataExplorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
instanceSheet[i] = null;
}
dataSheetNames = ['Physical Data','Trace metal data','PAH data','PCB data','BDE data','Organotins data','Organochlorine data'];
dataSheetAbr = {'Physical Data': 'Phys','Trace metal data': 'TM','PAH data': 'PAH','PCB data': 'PCB','BDE data': 'BDE','Organotins data': 'OT','Organochlorine data': 'OC'};
dataSheetNamesCheckboxes = [];
for (let i = 0; i < dataSheetNames.length; i++) {
dataSheetNamesCheckboxes[i] = dataSheetNames[i].replace(/\s/g, '').toLowerCase();
Expand Down Expand Up @@ -1396,7 +1397,11 @@ function filenameDisplay() {
fileDisplayDiv.innerHTML = "";

iconNo = 0;
for (dateSampled in selectedSampleInfo) {
const datesSampled = Object.keys(selectedSampleInfo);
datesSampled.sort();
datesSampled.forEach(dateSampled => {

// for (dateSampled in selectedSampleInfo) {
currentIcon = markerPath + markerPngs[iconNo];
iconNo = (iconNo + 1) % 9;

Expand All @@ -1413,16 +1418,27 @@ function filenameDisplay() {
linkElement.href = fileURL;
// console.log(fileURL);
// console.log(dateSampled);
linkElement.textContent = `File for ${dateSampled}: ${fileURL}`;
positions = Object.keys(selectedSampleInfo[dateSampled].position);
infos = '';
for (dataType in selectedSampleMeasurements[dateSampled]) {
infos += dataSheetAbr[dataType] + ' ';
}
// infos = 'PAH BDE OC OT PCB Phys TM';
textElement1 = document.createTextNode(`${dateSampled} has ${positions.length} samples with ${infos}:`);
textElement2 = document.createTextNode(`File `);
linkElement.textContent = `${fileURL}`;
linkElement.target = "_blank"; // Open link in a new tab/window

// Append the icon before the link
fileDisplayDiv.appendChild(iconElement);
fileDisplayDiv.appendChild(textElement1);
fileDisplayDiv.appendChild(document.createElement("br"));
fileDisplayDiv.appendChild(textElement2);
fileDisplayDiv.appendChild(linkElement);

// Add a line break for better readability
fileDisplayDiv.appendChild(document.createElement("br"));
};
});
fileDisplayDiv.style.display = 'none';
}

Expand Down
4 changes: 3 additions & 1 deletion sdeCharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,9 @@ function displayAnyChart(meas, all, datasets, instanceNo, title, yTitle, showLeg
for (let i = 0; i < chart.scales.x.ticks.length; i++) {
if (x >= left + (right * i) && x <= left + (right * (i + 1))) {
console.log('x label', i);
const regexPattern = /^(\S+): (.+)$/;
// const regexPattern = /^(\S+): (.+)$/;
const regexPattern = /^(.+): (.+)$/;
console.log(all[i]);
const matchResult = all[i].match(regexPattern);
if (matchResult) {
// Extracted parts
Expand Down
Loading

0 comments on commit 92b14da

Please sign in to comment.