Skip to content

Commit

Permalink
bug: dis downl no data and comp oor, close #45 #46
Browse files Browse the repository at this point in the history
  • Loading branch information
berntpopp committed Dec 3, 2023
1 parent 0432e7d commit 8b31578
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 11 deletions.
47 changes: 36 additions & 11 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,21 @@
</button>

<!-- Button for downloading the chart as an image -->
<button @click="downloadChart">
<button
:disabled="dataPoints.length === 0"
@click="downloadChart"
>
Download Plot
</button>

<!-- Buttons for saving and loading -->
<button @click="saveDataAsJson">
<button
:disabled="dataPoints.length === 0"
@click="saveDataAsJson"
>
Save
</button>

<!-- invisible file input element -->
<input
ref="fileInput"
Expand All @@ -179,8 +186,12 @@
<button @click="triggerFileInput">
Load
</button>

<!-- Button for downloading data as Excel -->
<button @click="downloadDataAsExcel">
<button
:disabled="dataPoints.length === 0"
@click="downloadDataAsExcel"
>
Download (Excel)
</button>
</div>
Expand Down Expand Up @@ -417,13 +428,24 @@ export default {
return totalLiverVolume.value / CONFIG.NORMALIZATION_FACTOR;
});
// New computed property for formatted normalizedTLV
// Computed property for formatted normalizedTLV
// This is used to display the nTLV with 3 decimal places
// and null if the input is invalid or out-of-range
const formattedNormalizedTLV = computed(() => {
return normalizedTLV.value.toFixed(3); // Rounds to 3 decimal places
if (age.value < CONFIG.AGE_MIN || age.value > CONFIG.AGE_MAX ||
totalLiverVolume.value < CONFIG.TLV_MIN || totalLiverVolume.value > CONFIG.TLV_MAX) {
return null; // Or any appropriate message indicating out-of-range
}
return (totalLiverVolume.value / CONFIG.NORMALIZATION_FACTOR).toFixed(3);
});
// Computed property for progression group based on age and normalizedTLV
const progressionGroup = computed(() => {
// return null if the input is invalid or out-of-range
if (age.value < CONFIG.AGE_MIN || age.value > CONFIG.AGE_MAX ||
totalLiverVolume.value < CONFIG.TLV_MIN || totalLiverVolume.value > CONFIG.TLV_MAX) {
return null; // Or any appropriate message indicating out-of-range
}
// Assuming normalizedTLV and age are available here
// and are reactive properties
const nTLV = normalizedTLV.value;
Expand All @@ -437,13 +459,16 @@ export default {
return 'PG1';
});
// Computed property for liver growth rate (LGR)
const liverGrowthRate = computed(() => {
// Check if age and normalizedTLV are defined and valid
if (age.value && normalizedTLV.value && age.value > 20) {
return 100 * Math.log(normalizedTLV.value) / (age.value - 20);
// return null if the input is invalid or out-of-range
if (age.value < CONFIG.AGE_MIN || age.value > CONFIG.AGE_MAX ||
totalLiverVolume.value < CONFIG.TLV_MIN || totalLiverVolume.value > CONFIG.TLV_MAX) {
return null; // Or any appropriate message indicating out-of-range
}
return null; // Return null if the calculation can't be performed
// Check if age and normalizedTLV are defined and valid
// use the given formula to calculate the liver growth rate
return formulas.calculateLiverGrowthRate(age.value, normalizedTLV.value);
});
// Reactive reference for the data points array
Expand Down
6 changes: 6 additions & 0 deletions src/config/formulasConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,11 @@ export const formulas = {
const age = startAge + i;
return { x: age, y: formulas.calculatePG2Threshold(age) };
}),
calculateLiverGrowthRate: (age, nTLV) => {
if (age > 20) {
return 100 * Math.log(nTLV) / (age - 20);
}
return null;
}
// Add more formulas as needed
};

0 comments on commit 8b31578

Please sign in to comment.