Adds spacer

This commit is contained in:
Roman Galochkin 2020-02-26 15:55:19 +03:00
parent b37d052b4f
commit 746d74da96
2 changed files with 192 additions and 122 deletions

View File

@ -40,6 +40,8 @@ module Styles = {
open Css;
let row =
style([display(`flex), selector("div > div", [flex(`num(1.))])]);
let form = style([backgroundColor(hex("eee")), padding(em(1.))]);
let spacer = style([marginTop(em(3.))]);
};
module FieldFloat = {
@ -70,8 +72,8 @@ let make = () => {
~initialState={
guesstimatorString: "mm(5 to 20, floor(normal(20,2)), [.5, .5])",
domainType: "Complete",
xPoint: "0.0",
excludingProbabilityMass: "",
xPoint: "50.0",
excludingProbabilityMass: "0.3",
unitType: "UnspecifiedDistribution",
zero: MomentRe.momentNow(),
unit: "days",
@ -84,6 +86,65 @@ let make = () => {
reform.submit();
};
let domain =
switch (reform.state.values.domainType) {
| "Complete" => DistTypes.Complete
| "LeftLimited" =>
LeftLimited({
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
})
| "RightLimited" =>
RightLimited({
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
})
| "LeftAndRightLimited" =>
LeftAndRightLimited(
{
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
},
{
xPoint: reform.state.values.xPoint |> float_of_string,
excludingProbabilityMass:
reform.state.values.excludingProbabilityMass |> float_of_string,
},
)
| _ => Js.Exn.raiseError("domain is unknown")
};
let unit =
switch (reform.state.values.unitType) {
| "UnspecifiedDistribution" => DistTypes.UnspecifiedDistribution
| "TimeDistribution" =>
TimeDistribution({
zero: reform.state.values.zero,
unit: reform.state.values.unit |> TimeTypes.TimeUnit.ofString,
})
| _ => Js.Exn.raiseError("unit is unknown")
};
let guesstimatorString = reform.state.values.guesstimatorString;
<div>
<div className=Styles.spacer />
<div>
<div>
{DistPlusIngredients.make(~guesstimatorString, ~domain, ~unit, ())
|> DistPlusIngredients.toDistPlus(
~sampleCount=10000,
~outputXYPoints=2000,
~truncateTo=Some(1000),
)
|> E.O.React.fmapOrNull(distPlus => <DistPlusPlot distPlus />)}
</div>
</div>
<div className=Styles.spacer />
<div className=Styles.form>
<Form.Provider value=reform>
<Antd.Form onSubmit>
<FieldString
@ -196,13 +257,8 @@ let make = () => {
/>
</div>
</div>
<Antd.Form.Item>
{reform.state.formState == Submitting
? "Loading" |> E.ste
: <Antd.Button _type=`primary onClick=onSubmit>
{"Submit" |> E.ste}
</Antd.Button>}
</Antd.Form.Item>
</Antd.Form>
</Form.Provider>;
</Form.Provider>
</div>
</div>;
};

View File

@ -33,6 +33,20 @@ module TimeUnit = {
| `weeks => "weeks"
| `years => "years"
};
let ofString = (timeUnit: string) =>
switch (timeUnit) {
| "days" => `days
| "hours" => `hours
| "milliseconds" => `milliseconds
| "minutes" => `minutes
| "months" => `months
| "quarters" => `quarters
| "seconds" => `seconds
| "weeks" => `weeks
| "years" => `years
| _ => Js.Exn.raiseError("TimeUnit is unknown")
};
};
module TimePoint = {