2022-04-01 00:26:26 +00:00
|
|
|
import React, { FC, useState } from "react"
|
|
|
|
import { SquiggleChart } from "./SquiggleChart"
|
|
|
|
import CodeEditor from "./CodeEditor"
|
2022-03-02 23:22:26 +00:00
|
|
|
import { Form, Input, Card, Row, Col } from "antd"
|
2022-04-01 00:26:26 +00:00
|
|
|
import 'antd/dist/antd.css';
|
2022-03-02 23:22:26 +00:00
|
|
|
|
|
|
|
interface FieldFloatProps {
|
|
|
|
label : string,
|
|
|
|
className? : string,
|
|
|
|
value : number,
|
|
|
|
onChange : (value: number) => void,
|
|
|
|
}
|
|
|
|
|
|
|
|
function FieldFloat(Props: FieldFloatProps) {
|
|
|
|
let [contents, setContents] = useState(Props.value + "");
|
|
|
|
return <Form.Item label={Props.label}>
|
|
|
|
<Input
|
|
|
|
value={contents}
|
|
|
|
className={Props.className ? Props.className : ""}
|
|
|
|
onChange={(e) => setContents(e.target.value)}
|
|
|
|
onBlur={(_) => {
|
|
|
|
let result = parseFloat(contents);
|
|
|
|
if(result != NaN) {
|
|
|
|
Props.onChange(result)
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</Form.Item>
|
|
|
|
}
|
2022-04-01 00:26:26 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
initialSquiggleString : string
|
|
|
|
}
|
|
|
|
|
|
|
|
let SquigglePlayground : FC<Props> = (props) => {
|
|
|
|
let [squiggleString, setSquiggleString] = useState(props.initialSquiggleString)
|
2022-03-02 23:22:26 +00:00
|
|
|
let [sampleCount, setSampleCount] = useState(1000)
|
|
|
|
let [outputXYPoints, setOutputXYPoints] = useState(1000)
|
2022-04-01 02:16:06 +00:00
|
|
|
let [pointDistLength, setPointDistLength] = useState(1000)
|
2022-03-02 23:22:26 +00:00
|
|
|
let [diagramStart, setDiagramStart] = useState(0)
|
|
|
|
let [diagramStop, setDiagramStop] = useState(10)
|
|
|
|
let [diagramCount, setDiagramCount] = useState(20)
|
|
|
|
var demoDist =
|
|
|
|
<SquiggleChart
|
|
|
|
squiggleString={squiggleString}
|
|
|
|
sampleCount={sampleCount}
|
|
|
|
outputXYPoints={outputXYPoints}
|
|
|
|
diagramStart={diagramStart}
|
|
|
|
diagramStop={diagramStop}
|
|
|
|
diagramCount={diagramCount}
|
|
|
|
pointDistLength={pointDistLength}
|
|
|
|
/>
|
|
|
|
return (
|
2022-04-01 00:26:26 +00:00
|
|
|
<Row>
|
|
|
|
<Col span={12}>
|
2022-03-02 23:22:26 +00:00
|
|
|
<Card
|
|
|
|
title="Distribution Form">
|
|
|
|
<Form>
|
2022-04-01 02:16:06 +00:00
|
|
|
<Row gutter={16}>
|
2022-03-02 23:22:26 +00:00
|
|
|
<Col span={24}>
|
2022-04-01 00:26:26 +00:00
|
|
|
<CodeEditor value={squiggleString} onChange={setSquiggleString} oneLine={false}/> </Col>
|
2022-03-02 23:22:26 +00:00
|
|
|
</Row>
|
2022-04-01 02:16:06 +00:00
|
|
|
<Row gutter={16}>
|
2022-03-02 23:22:26 +00:00
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={sampleCount}
|
|
|
|
label="Sample Count"
|
|
|
|
onChange={setSampleCount}
|
|
|
|
/> </Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={outputXYPoints}
|
|
|
|
onChange={setOutputXYPoints}
|
|
|
|
label="Output XY-points" />
|
|
|
|
</Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={pointDistLength}
|
|
|
|
onChange={setPointDistLength}
|
|
|
|
label="Downsample To"
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={diagramStart}
|
|
|
|
onChange={setDiagramStart}
|
|
|
|
label="Diagram Start"
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={diagramStop}
|
|
|
|
onChange={setDiagramStop}
|
|
|
|
label="Diagram Stop"
|
|
|
|
/> </Col>
|
|
|
|
<Col span={12}>
|
|
|
|
<FieldFloat
|
|
|
|
value={diagramCount}
|
|
|
|
onChange={setDiagramCount}
|
|
|
|
label="Diagram Count"
|
|
|
|
/>
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Form>
|
|
|
|
</Card>
|
2022-04-01 00:26:26 +00:00
|
|
|
</Col>
|
|
|
|
<Col span={12} >
|
2022-03-02 23:22:26 +00:00
|
|
|
{demoDist}
|
2022-04-01 00:26:26 +00:00
|
|
|
</Col>
|
|
|
|
</Row>
|
2022-03-02 23:22:26 +00:00
|
|
|
)
|
|
|
|
}
|
2022-04-01 00:26:26 +00:00
|
|
|
export default SquigglePlayground;
|