Spreading Resistance Profile with ChartJS,

Copy-On-Get and nuget bump (Serilog)
This commit is contained in:
2023-05-16 08:20:35 -07:00
parent 6b409294e4
commit e084fdd58f
53 changed files with 2245 additions and 105 deletions

13
Server/wwwroot/js/chart-3.9.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

20
Server/wwwroot/js/chart-4.3.0.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,4 @@
var _chart = null;
var _CdeId = null;
var _apiUrl = null;
var _BioRadId = null;
@ -232,6 +233,8 @@ function enableHeaderButtonsRunInfo() {
}
function hideDetailsDivRunInfo() {
if (_chart !== null)
_chart.destroy();
$("#DetailsDiv").prop("hidden", true);
$("#DataAttachmentFrame").prop("src", "");
}
@ -245,19 +248,55 @@ function showDetailsDivRunInfo() {
$("#OIExportResult").text('');
}
$("#DataAttachmentFrame").prop("hidden", true);
$("#DataAttachmentDiv").prop("hidden", true);
$("#HeaderAttachmentFrame").prop("hidden", true);
$("#HeaderAttachmentDiv").prop("hidden", true);
if (_toolType != null) {
var visibleFrames = 0;
if (_toolType.DisplayDataAttachment && _toolType.DisplayDataAttachment.length > 0) {
visibleFrames += 1;
$("#DataAttachmentFrame").prop("hidden", false);
if (!_toolType.DataGridAttributes || _toolType.DataGridAttributes.indexOf('div') === -1) {
visibleFrames += 1;
$("#DataAttachmentFrame").prop("hidden", false);
}
else
$("#DataAttachmentDiv").prop("hidden", false);
}
if (_toolType.DisplayHeaderAttachment && _toolType.DisplayHeaderAttachment.length > 0) {
visibleFrames += 1;
$("#HeaderAttachmentFrame").prop("hidden", false);
if (!_toolType.HeaderGridAttributes || _toolType.HeaderGridAttributes.indexOf('div') === -1) {
visibleFrames += 1;
$("#HeaderAttachmentFrame").prop("hidden", false);
}
else
$("#HeaderAttachmentDiv").prop("hidden", false);
}
var frameWidth = (98 / visibleFrames) + "%";
$("#DataAttachmentFrame,#HeaderAttachmentFrame").css('width', frameWidth);
if (_toolType.DataGridAttributes != null) {
var dataGridAttributes = JSON.parse(_toolType.DataGridAttributes);
if (dataGridAttributes.frame) {
for (const property in dataGridAttributes.frame) {
$("#DataAttachmentFrame").css(property, dataGridAttributes.frame[property]);
}
}
if (dataGridAttributes.div) {
for (const property in dataGridAttributes.div) {
$("#DataAttachmentDiv").css(property, dataGridAttributes.div[property]);
}
}
}
if (_toolType.HeaderGridAttributes != null) {
var headerGridAttributes = JSON.parse(_toolType.HeaderGridAttributes);
if (headerGridAttributes.frame) {
for (const property in headerGridAttributes.frame) {
$("#HeaderAttachmentFrame").css(property, headerGridAttributes.frame[property]);
}
}
if (headerGridAttributes.div) {
for (const property in headerGridAttributes.div) {
$("#HeaderAttachmentDiv").css(property, headerGridAttributes.div[property]);
}
}
}
}
}
@ -282,31 +321,265 @@ function cancelHandlerRunInfo(evt, ui) {
return false;
}
function GetMinMax(profilePoints, index) {
var cd;
var depth;
var edited;
var ceilingCD;
var resistivity;
var ceilingEdited;
var maxDepth = 30;
var ceilingResistivity;
var resistivityMin = 99;
var resistivityMax = -99;
var concentrationMin = 99;
var concentrationMax = -99;
var resistanceEditedMin = 99;
var resistanceEditedMax = -99;
for (var i = 0; i < profilePoints.length; i++) {
if (!profilePoints[i].Depth || !profilePoints[i].Edited || !profilePoints[i].Resistivity || !profilePoints[i].CD)
continue;
if (profilePoints[i].Edited.length < 1 || profilePoints[i].Resistivity.length < 1 || profilePoints[i].CD.length < 1)
continue;
depth = parseFloat(profilePoints[i].Depth);
if (depth <= 0 || profilePoints[i].Raw == 0)
continue;
if (index > 0) {
cd = parseFloat(profilePoints[i].CD);
edited = parseFloat(profilePoints[i].Edited);
resistivity = parseFloat(profilePoints[i].Resistivity);
}
else {
cd = Math.log10(parseFloat(profilePoints[i].CD));
edited = Math.log10(parseFloat(profilePoints[i].Edited));
resistivity = Math.log10(parseFloat(profilePoints[i].Resistivity));
}
maxDepth = parseFloat(profilePoints[i].Depth);
if (resistivity < resistivityMin)
resistivityMin = resistivity;
ceilingResistivity = Math.ceil(resistivity);
if (ceilingResistivity > resistivityMax)
resistivityMax = ceilingResistivity;
if (edited < resistanceEditedMin)
resistanceEditedMin = edited;
ceilingEdited = Math.ceil(edited);
if (ceilingEdited > resistanceEditedMax)
resistanceEditedMax = ceilingEdited;
if (cd < concentrationMin)
concentrationMin = cd;
ceilingCD = Math.ceil(cd);
if (ceilingCD > concentrationMax)
concentrationMax = ceilingCD;
}
decades = resistivityMax - resistivityMin;
if (resistanceEditedMax - resistanceEditedMin > decades)
decades = resistanceEditedMax - resistanceEditedMin;
if (concentrationMax - concentrationMin > decades)
decades = concentrationMax - concentrationMin;
return { decades, maxDepth, concentrationMin, concentrationMax, resistanceEditedMin, resistanceEditedMax, resistivityMin, resistivityMax };
}
function setChart(index, ctx, data) {
var cd;
var depth;
var edited;
var resistivity;
var depthCollection = [];
var rawCollection = []; // Black
var resistivityCollection = []; // Green
var concentrationCollection = []; // Blue
var resistanceEditedCollection = []; // Red
var yType = index > 0 ? 'linear' : 'logarithmic';
// var resistivity = [{ x: 10, y: 20 }, { x: 15, y: null }, { x: 20, y: 10 }];
var profilePoints = data.ProfileHeader.ProfilePoints;
var minMax = GetMinMax(profilePoints, index);
for (var i = 0; i < profilePoints.length; i++) {
if (!profilePoints[i].Depth || !profilePoints[i].Edited || !profilePoints[i].Resistivity || !profilePoints[i].CD)
continue;
if (profilePoints[i].Edited.length < 1 || profilePoints[i].Resistivity.length < 1 || profilePoints[i].CD.length < 1)
continue;
depth = parseFloat(profilePoints[i].Depth);
if (depth <= 0 || profilePoints[i].Raw == 0)
continue;
cd = parseFloat(profilePoints[i].CD);
raw = parseFloat(profilePoints[i].Raw);
edited = parseFloat(profilePoints[i].Edited);
resistivity = parseFloat(profilePoints[i].Resistivity);
if (cd === 0 || edited === 0 || resistivity === 0)
continue;
if (edited == 0 || resistivity == 0 || cd == 0)
continue;
depthCollection.push(depth);
if (index > 0) {
rawCollection.push(raw);
concentrationCollection.push(cd);
resistivityCollection.push(resistivity);
resistanceEditedCollection.push(edited);
}
else {
rawCollection.push(Math.log10(raw));
concentrationCollection.push(Math.log10(cd));
resistivityCollection.push(Math.log10(resistivity));
resistanceEditedCollection.push(Math.log10(edited));
}
}
var chartOptions = {
plugins: {
title: {
display: true,
text: yType,
}
},
scales: {
x: {
display: true,
position: 'bottom',
grid: {
display: false,
},
title: {
text: 'Depth (µm)',
display: true,
},
},
raw: {
type: yType,
display: true,
position: 'left',
min: minMax.resistanceEditedMin,
max: minMax.resistanceEditedMax,
grid: {
display: false,
},
title: {
text: 'Resistance (Ω ohm)',
display: true,
},
},
resistanceEdited: {
type: yType,
display: true,
position: 'left',
min: minMax.resistanceEditedMin,
max: minMax.resistanceEditedMax,
grid: {
display: false,
},
title: {
text: 'Resistance Edited (Ω ohm)',
display: true,
},
},
resistivity: {
type: yType,
display: true,
position: 'left',
min: minMax.resistivityMin,
max: minMax.resistivityMax,
grid: {
display: false,
},
title: {
text: 'Resistivity (ρ ohm-cm)',
display: true,
},
},
concentration: {
type: yType,
display: true,
position: 'right',
min: minMax.concentrationMin,
max: minMax.concentrationMax,
grid: {
display: false,
},
title: {
text: 'CD (1/cm³)',
display: true,
},
},
}
};
_chart = new Chart(ctx, {
type: 'line',
data: {
labels: depthCollection,
datasets: [
{
fill: false,
yAxisID: "resistivity",
borderColor: 'rgb(0, 255, 0)',
backgroundColor: 'rgba(0, 255, 0, 1)',
label: 'Resistivity (ρ ohm-cm)',
data: resistivityCollection
}, {
fill: false,
yAxisID: "resistanceEdited",
borderColor: 'rgb(255, 0, 0)',
backgroundColor: 'rgba(255, 0, 0, 1)',
label: 'Resistance Edited (Ω ohm)',
data: resistanceEditedCollection
}, {
fill: false,
yAxisID: "raw",
borderColor: 'rgb(0, 0, 0)',
backgroundColor: 'rgba(0, 0, 0, 1)',
label: 'Resistance (Ω ohm)',
data: rawCollection
}, {
fill: false,
yAxisID: "concentration",
borderColor: 'rgb(0, 0, 255)',
backgroundColor: 'rgba(0, 0, 255, 1)',
label: 'CD (1/cm³)',
data: concentrationCollection
},
]
},
options: chartOptions,
});
}
function detailSelectionChangedRunInfo(evt, ui) {
$("#DataAttachmentFrame").prop("src", "");
if (ui.row.index >= 0) {
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
var toolTypeID = $("#ToolTypeID").text();
var attachmentUrlBase = _apiUrl + '/tooltypes/' + toolTypeID;
var attachmentId = rowData.AttachmentID;
if ((attachmentId == null) || (attachmentId === ''))
return;
if ((_toolType.DisplayDataAttachment == null) || (_toolType.DisplayDataAttachment === ''))
return;
$("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + _toolType.DisplayDataAttachment);
if (_chart !== null)
_chart.destroy();
var toolTypeID = $("#ToolTypeID").text();
var headerAttachmentId = $("#HeaderAttachmentId").text();
var attachmentUrlBase = _apiUrl + '/tooltypes/' + toolTypeID;
if (!headerAttachmentId || headerAttachmentId === '' || !_toolType.DataGridAttributes || _toolType.DataGridAttributes.indexOf('div') === -1) {
$("#DataAttachmentFrame").prop("src", "");
if (ui.row.index >= 0) {
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
var attachmentId = rowData.AttachmentID;
if ((attachmentId == null) || (attachmentId === ''))
return;
$("#DataAttachmentFrame").prop("src", attachmentUrlBase + "/data/files/" + attachmentId + "/" + _toolType.DisplayDataAttachment);
}
}
else {
var ctx = document.getElementById('DataAttachmentCanvas');
$.getJSON(attachmentUrlBase + "/header/files/" + headerAttachmentId + "/" + _toolType.DisplayHeaderAttachment, function (data) {
setChart(ui.row.index, ctx, data);
});
}
}
function loadHeaderAttachmentRunInfo() {
if (_chart !== null)
_chart.destroy();
var toolTypeID = $("#ToolTypeID").text();
$("#DataAttachmentFrame").prop("src", "");
var attachmentId = $("#HeaderAttachmentId").text();
var attachmentUrlBase = _apiUrl + '/tooltypes/' + toolTypeID;
if ((attachmentId == null) || (attachmentId === '') || (_toolType.DisplayHeaderAttachment == null) || (_toolType.DisplayHeaderAttachment === '')) {
$("#HeaderAttachmentFrame").prop("src", "");
} else {
$("#HeaderAttachmentFrame").prop("src", attachmentUrlBase + "/header/files/" + attachmentId + "/" + _toolType.DisplayHeaderAttachment);
if (!_toolType.HeaderGridAttributes || _toolType.HeaderGridAttributes.indexOf('frame') === -1 || _toolType.HeaderGridAttributes.indexOf('controller') === -1)
$("#HeaderAttachmentFrame").prop("src", _apiUrl + '/tooltypes/' + toolTypeID + "/header/files/" + attachmentId + "/" + _toolType.DisplayHeaderAttachment);
else {
var headerGridAttributes = JSON.parse(_toolType.HeaderGridAttributes);
$("#HeaderAttachmentFrame").prop("src", _apiUrl + '/' + headerGridAttributes.frame.controller + '/' + toolTypeID + "/header/files/" + attachmentId + "/" + _toolType.DisplayHeaderAttachment);
}
}
$("#DataAttachmentFrame").prop("src", "");
}
function markAsReviewedRunInfo() {
@ -324,18 +597,53 @@ function markAsReviewedRunInfo() {
});
}
function copySelected(attachmentID, title, data) {
var allText = "";
var headerText = "";
var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow();
if (selectedRow !== null) {
var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index];
for (const property in rowData) {
if (property === "ID" || property === attachmentID || property === title)
continue;
allText = allText + property + '\t';
headerText = headerText + rowData[property] + '\t';
}
}
for (var i = 0; i < data.Results.length; i++) {
if (i === 0) {
for (const property in data.Results[i]) {
if (property === "ID" || property === "InsertDate" || property === attachmentID || property === title)
continue;
allText = allText + property + '\t';
}
allText = allText + '\r';
}
allText = allText + headerText;
for (const property in data.Results[i]) {
if (property === "ID" || property === "InsertDate" || property === attachmentID || property === title)
continue;
allText = allText + data.Results[i][property] + '\t';
}
allText = allText + '\r';
}
copy(allText);
}
function loadDetailsRunInfo() {
showDetailsDivRunInfo();
loadHeaderAttachmentRunInfo();
var gridCreated = $("#DetailsGrid").data("igGrid");
if (gridCreated)
$("#DetailsGrid").igGrid("destroy");
var title = "Title";
var attachmentID = "AttachmentID";
var headerId = $("#HeaderId").text();
var toolTypeID = $("#ToolTypeID").text();
var detailsURL = _apiUrl + "/tooltypes/" + toolTypeID + "/headers/" + headerId + "/data";
var gridColumns = [
{ key: "AttachmentID", dataType: "string", hidden: true },
{ key: "Title", dataType: "string", hidden: true },
{ key: attachmentID, dataType: "string", hidden: true },
{ key: title, dataType: "string", hidden: true },
];
for (var i = 0; i < _toolTypeMetaData.length; i++) {
var f = _toolTypeMetaData[i];
@ -356,23 +664,29 @@ function loadDetailsRunInfo() {
gridColumns.push(col);
}
}
var gridParms = {
autoGenerateColumns: false,
primaryKey: "ID",
features: [
{ name: "Selection", mode: "row", rowSelectionChanging: detailSelectionChangedRunInfo },
{ name: "Resizing" },
{ name: "Sorting", type: "local" }
],
columns: gridColumns,
dataSource: detailsURL,
responseDataKey: "Results",
dataBound: markAsReviewedRunInfo,
};
if ((_toolType != null) && (_toolType.DataGridAttributes != null)) {
jQuery.extend(gridParms, JSON.parse(_toolType.DataGridAttributes));
}
$("#DetailsGrid").igGrid(gridParms);
$.getJSON(detailsURL, function (data) {
var gridParms = {
autoGenerateColumns: false,
primaryKey: "ID",
features: [
{ name: "Selection", mode: "row", rowSelectionChanging: detailSelectionChangedRunInfo },
{ name: "Resizing" },
{ name: "Sorting", type: "local" }
],
columns: gridColumns,
dataSource: data,
dataSourceType: 'json',
responseDataKey: "Results",
dataBound: markAsReviewedRunInfo,
};
if ((_toolType != null) && (_toolType.DataGridAttributes != null)) {
jQuery.extend(gridParms, JSON.parse(_toolType.DataGridAttributes));
}
$("#DetailsGrid").igGrid(gridParms);
if ($("#chkCopyOnGet").is(':checked')) {
copySelected(attachmentID, title, data);
}
});
}
function requestHeaderDataRunInfo() {
@ -396,6 +710,10 @@ function requestHeaderDataRunInfo() {
$("#HeaderAttachmentId").text(_initialHeaderAttachmentId);
_initialHeaderId = -1;
}
if (!_toolType.DataGridAttributes || _toolType.DataGridAttributes.indexOf('pinButton') === -1)
$("#PinButton").hide();
else
$("#PinButton").show();
var headerURL = _apiUrl + "/tooltypes/" + _toolType.ID + "/headers?" + $.param(parms);
var gridColumns = [
{ key: "ID", dataType: "number", hidden: true },
@ -790,12 +1108,14 @@ function initIndex() {
}
function copy(copyText) {
// Select the text field
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
// Copy the text inside the text field
navigator.clipboard.writeText(copyText.value);
if (typeof copyText.select !== "undefined")
copyText.select();
if (typeof copyText.setSelectionRange !== "undefined")
copyText.setSelectionRange(0, 99999); // For mobile devices
if (typeof copyText.value !== "undefined")
navigator.clipboard.writeText(copyText.value);
else
navigator.clipboard.writeText(copyText);
}
function clearWorkMaterial() {
@ -935,4 +1255,7 @@ function runDataSheet(runDataSheetIndex) {
function restartButton(apiUrl) {
clearWorkMaterial();
};
};
// { "frame": { "controller": "SpreadingResistanceProfile", "height": "718px", "width": "698px" } }
// { "div": { "width": "698px", "position": "absolute", "top":"700px", "left": "800px" }, "height": "160px" }