Initial buttons

This commit is contained in:
Ozzie Gooen 2020-03-03 19:25:06 +00:00
parent 4735b9703c
commit bdeb53a6c4
3 changed files with 43 additions and 21 deletions

View File

@ -1,14 +1,22 @@
type state = { type state = {
log: bool, log: bool,
showStats: bool, showStats: bool,
showParams: bool,
height: int, height: int,
}; };
type action = type action =
| CHANGE_LOG | CHANGE_LOG
| CHANGE_SHOW_STATS | CHANGE_SHOW_STATS
| CHANGE_SHOW_PARAMS
| CHANGE_HEIGHT(int); | CHANGE_HEIGHT(int);
let showAsForm = (distPlus: DistTypes.distPlus) => {
<div>
<Antd.Input value={distPlus.guesstimatorString |> E.O.default("")} />
</div>;
};
let table = (distPlus, x) => { let table = (distPlus, x) => {
<div> <div>
<table className="table-auto text-sm"> <table className="table-auto text-sm">
@ -207,6 +215,8 @@ module IntegralChart = {
}; };
}; };
let button = "bg-gray-300 hover:bg-gray-500 text-grey-darkest text-xs px-4 py-1";
[@react.component] [@react.component]
let make = (~distPlus: DistTypes.distPlus) => { let make = (~distPlus: DistTypes.distPlus) => {
let (x, setX) = React.useState(() => 0.); let (x, setX) = React.useState(() => 0.);
@ -217,8 +227,9 @@ let make = (~distPlus: DistTypes.distPlus) => {
| CHANGE_LOG => {...state, log: !state.log} | CHANGE_LOG => {...state, log: !state.log}
| CHANGE_HEIGHT(height) => {...state, height} | CHANGE_HEIGHT(height) => {...state, height}
| CHANGE_SHOW_STATS => {...state, showStats: !state.showStats} | CHANGE_SHOW_STATS => {...state, showStats: !state.showStats}
| CHANGE_SHOW_PARAMS => {...state, showParams: !state.showParams}
}, },
{log: false, height: 80, showStats: false}, {log: false, height: 80, showStats: false, showParams: false},
); );
let chart = let chart =
React.useMemo2( React.useMemo2(
@ -231,25 +242,36 @@ let make = (~distPlus: DistTypes.distPlus) => {
[|distPlus|], [|distPlus|],
); );
<div> <div>
<div onClick={_ => dispatch(CHANGE_LOG)}>
{(state.log ? "true" : "False") |> ReasonReact.string}
</div>
<div onClick={_ => dispatch(CHANGE_SHOW_STATS)}>
{"Stats" |> ReasonReact.string}
</div>
<div onClick={_ => dispatch(CHANGE_HEIGHT(state.height + 40))}>
{"HightPlus" |> ReasonReact.string}
</div>
<div
onClick={_ =>
dispatch(
CHANGE_HEIGHT(state.height < 81 ? state.height : state.height - 40),
)
}>
{"HightMinus" |> ReasonReact.string}
</div>
chart chart
chart2 chart2
<div className="inline-flex opacity-50 hover:opacity-100">
<button className=button onClick={_ => dispatch(CHANGE_LOG)}>
{(state.log ? "x-Linear" : "x-Log") |> ReasonReact.string}
</button>
<button className=button onClick={_ => dispatch(CHANGE_SHOW_STATS)}>
{"Stats" |> ReasonReact.string}
</button>
<button className=button onClick={_ => dispatch(CHANGE_SHOW_PARAMS)}>
{"Params" |> ReasonReact.string}
</button>
<button
className=button
onClick={_ => dispatch(CHANGE_HEIGHT(state.height + 40))}>
{"Expand" |> ReasonReact.string}
</button>
<button
className=button
onClick={_ =>
dispatch(
CHANGE_HEIGHT(
state.height < 81 ? state.height : state.height - 40,
),
)
}>
{"Compress" |> ReasonReact.string}
</button>
</div>
{state.showParams ? showAsForm(distPlus) : ReasonReact.null}
{state.showStats ? table(distPlus, x) : ReasonReact.null} {state.showStats ? table(distPlus, x) : ReasonReact.null}
</div>; </div>;
// chart // chart

View File

@ -31,7 +31,7 @@ let toDistPlus =
~shape=_, ~shape=_,
~domain=t.domain, ~domain=t.domain,
~unit=t.unit, ~unit=t.unit,
~guesstimatorString=None, ~guesstimatorString=Some(t.guesstimatorString),
(), (),
), ),
) )

View File

@ -20,8 +20,8 @@ let propValue = (t: Prop.Value.t) => {
| DistPlusIngredients((r: DistTypes.distPlusIngredients)) => | DistPlusIngredients((r: DistTypes.distPlusIngredients)) =>
let newDistribution = let newDistribution =
DistPlusIngredients.toDistPlus( DistPlusIngredients.toDistPlus(
~sampleCount=2000, ~sampleCount=1000,
~outputXYPoints=1000, ~outputXYPoints=2000,
~truncateTo=Some(500), ~truncateTo=Some(500),
r, r,
); );