Skip to content

Commit

Permalink
Merge pull request #51 from twgardner2/multipleFitrepComparison
Browse files Browse the repository at this point in the history
Multiple fitrep comparison
  • Loading branch information
twgardner2 authored Apr 10, 2023
2 parents 53ce2be + 8e7df51 commit 2548093
Show file tree
Hide file tree
Showing 29 changed files with 6,864 additions and 5,412 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/webpack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
9,639 changes: 5,024 additions & 4,615 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
},
"homepage": "https://github.com/twgardner2/navy_psr#readme",
"dependencies": {
"@karmaniverous/serify-deserify": "^1.2.9",
"@reduxjs/toolkit": "^1.9.1",
"d3": "^7.1.1",
"flatpickr": "^4.6.10"
},
Expand All @@ -40,16 +42,16 @@
"graceful-fs": "^4.2.9",
"html-loader": "^3.1.0",
"mini-css-extract-plugin": "^2.4.5",
"node-sass": "^6.0.1",
"path-browserify": "^1.0.1",
"pdfreader": "^1.2.14",
"postcss-loader": "^6.2.0",
"postcss-preset-env": "^6.7.0",
"process": "^0.11.10",
"sass": "^1.57.1",
"sass-loader": "^12.3.0",
"stream-browserify": "^3.0.0",
"util": "^0.12.4",
"webpack": "^5.64.0",
"webpack-cli": "^4.9.1"
"webpack-cli": "^4.10.0"
}
}
21 changes: 21 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
TODO:
- Axis must stand independent of data.
- Multiple uploads
- Ability to remove an individual from the graph
- Individual data point must be within their own group in the same SVG
- Link table with group (individual data)
- Comparison mode vs individual mode
- Comparison mode by rank
- Comparison mode by time
- Make things hideable/simpler for comparison mode
- Add additional explainer

Constraints, Human factors:
- Do not allow comparison mode for different ranks
- Constrain start date to oldest record
- Show table in Individual mode only -- replace with comparison controls

-- It's probably time to start using redux to manage state



www.navyrecordreview.com

## Installation
Expand Down
6 changes: 4 additions & 2 deletions src/js/data/parsers/table/table-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ export function parse_data_from_table(e, d) {
j[i].childNodes.forEach(function (el) {
if (el.classList.contains("table_field")) {
// Get key and value in cell
var cell_key = el.dataset.key;
var cell_value = el.innerText;
const cell_key = el.dataset.key;

const cell_value=el.getElementsByTagName('input').length ? el.getElementsByTagName('input')[0].value : el.innerText;


// Coerce to correct data type
var schema_entry = tableFields.filter((el) => el.name == cell_key);
Expand Down
48 changes: 48 additions & 0 deletions src/js/data/providers/AbstractProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as lib from '../../lib';
import * as d3 from 'd3';
import { deserify } from "@karmaniverous/serify-deserify";


export class AbstractProvider{

setDatesandTime(){
this.startDate = this.getStartDate();
this.endDate = this.getEndDate();
this.setTimeScale();
}

setTimeScale() {

this.time_scale = d3
.scaleTime()
.domain([this.startDate, this.endDate])
.range([
0,
lib.canvas_width -
lib.y_axis_width -
lib.margin.left -
lib.margin.right,
]);
}

parse(psr){
return deserify(psr)
}

getEarliestDate(dates){

const earliest=dates.reduce((previousDate, currentDate) => {
return currentDate < previousDate ? currentDate : previousDate;
});

return earliest;
}

getLatestDate(dates){
const latest=dates.reduce((previousDate, currentDate) => {
return currentDate > previousDate ? currentDate : previousDate;
});

return latest;
}
}
68 changes: 68 additions & 0 deletions src/js/data/providers/DataLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { updateNewRecord } from "../../stores/records";
import { setActiveRecord } from "../../stores/slices/view-slice";
import { appStore } from "../../stores/app-state";

const { fields } = require('../schema');



export class DataLoader {
constructor(data) {
this.psr=this.format(data);
this.validatePsr();
}

setRecordName(recordName) {
this.recordName=recordName;
}

load(){
if(typeof this.recordName === 'undefined'){
throw 'DataLoader requires a record name before loading';
}

updateNewRecord(this.recordName, this.psr);

appStore.dispatch(setActiveRecord({
activeRecord : this.recordName
})
);
}

format(data) {
return data.map((entry) => {
let type;
for (let k in entry) {
if (!fields[k] || !fields[k].type) {
continue;
}
type = fields[k].type;
if (type === 'number' || type === 'average') {
entry[k] = Number(entry[k]);
} else if (type === 'date' && !(entry[k] instanceof Date)) {
entry[k] = new Date(entry[k]);
} else if (type === 'text') {
entry[k] = entry[k].toString().trim();
}
}
return entry;
});
}

validatePsr() {
this.psr.forEach((entry) => {
Object.keys(fields).forEach((key) => {
if(key === 'sum_group'){
return;
}

if (
typeof entry[key] === 'undefined' &&
!fields[key]['optional']
) {
throw `${key} undefined for entry in parsed data`;
}
});
});
}
}
Loading

0 comments on commit 2548093

Please sign in to comment.