-
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 #10 from seroanalytics/spline
support spline options
- Loading branch information
Showing
22 changed files
with
391 additions
and
62 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
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
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,82 @@ | ||
import React, {useContext} from "react"; | ||
import {ActionType, RootContext, RootDispatchContext} from "../RootContext"; | ||
import Form from "react-bootstrap/Form"; | ||
import {Col, Row} from "react-bootstrap"; | ||
import {between} from "../services/utils"; | ||
|
||
export default function SplineOptions() { | ||
|
||
const state = useContext(RootContext); | ||
const dispatch = useContext(RootDispatchContext); | ||
|
||
const onChangeMethod = (event: any) => { | ||
dispatch({ | ||
type: ActionType.SET_SPLINE_OPTIONS, | ||
payload: {method: event.target.value} | ||
}); | ||
} | ||
|
||
const onChangeSpan = (event: any) => { | ||
dispatch({ | ||
type: ActionType.SET_SPLINE_OPTIONS, | ||
payload: {span: between(event.target.value, 0, 1)} | ||
}); | ||
} | ||
|
||
const onChangeKnots = (event: any) => { | ||
dispatch({ | ||
type: ActionType.SET_SPLINE_OPTIONS, | ||
payload: {k: between(event.target.value, 5, 30)} | ||
}); | ||
} | ||
|
||
const settings = state.datasetSettings[state.selectedDataset].splineSettings; | ||
|
||
return <Form.Group> | ||
<Row className={"mt-2"}> | ||
<Form.Label column sm="6" htmlFor="method"> | ||
Method: | ||
</Form.Label> | ||
<Col sm="6"> | ||
<Form.Select role="listbox" | ||
name="method" | ||
value={settings.method} onChange={onChangeMethod}> | ||
<option>auto</option> | ||
<option>gam</option> | ||
<option>loess</option> | ||
</Form.Select> | ||
</Col> | ||
</Row> | ||
<Row className={"mt-2"}> | ||
<Form.Label column sm="6" htmlFor="span"> | ||
Span: | ||
</Form.Label> | ||
<Col sm="6"> | ||
<Form.Range min={0} max={1} step={0.05} value={settings.span} | ||
onChange={onChangeSpan}/> | ||
<Form.Control type={"number"} | ||
name={"span"} | ||
value={settings.span} | ||
min={0} | ||
max={1} | ||
step={0.05} | ||
onChange={onChangeSpan}/> | ||
</Col> | ||
</Row> | ||
<Row className={"mt-2"}> | ||
<Form.Label column sm="6" htmlFor="k"> | ||
k: | ||
</Form.Label> | ||
<Col sm="6"> | ||
<Form.Range min={5} max={30} step={1} value={settings.k} | ||
onChange={onChangeKnots}/> | ||
<Form.Control type={"number"} | ||
name={"k"} | ||
value={settings.k} | ||
min={5} | ||
max={30} | ||
onChange={onChangeKnots}/> | ||
</Col> | ||
</Row> | ||
</Form.Group> | ||
} |
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,10 @@ | ||
import { useEffect } from "react"; | ||
|
||
export const useDebouncedEffect = (effect: () => void, deps: any[], delay: number) => { | ||
useEffect(() => { | ||
const handler = setTimeout(() => effect(), delay); | ||
|
||
return () => clearTimeout(handler); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [...(deps || []), delay]); | ||
} |
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
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
Oops, something went wrong.