-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #51 from twgardner2/multipleFitrepComparison
Multiple fitrep comparison
- Loading branch information
Showing
29 changed files
with
6,864 additions
and
5,412 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`; | ||
} | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.