2020-02-23 12:49:33 +00:00
|
|
|
module DistPlusChart = {
|
2020-02-22 20:36:22 +00:00
|
|
|
[@react.component]
|
2020-02-23 12:49:33 +00:00
|
|
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
|
|
|
open DistFunctor.DistPlus;
|
|
|
|
let discrete = distPlus |> T.toDiscrete;
|
2020-02-22 20:36:22 +00:00
|
|
|
let continuous =
|
2020-02-23 12:49:33 +00:00
|
|
|
distPlus |> T.toContinuous |> E.O.fmap(DistFunctor.Continuous.getShape);
|
|
|
|
let minX = T.minX(distPlus);
|
|
|
|
let maxX = T.maxX(distPlus);
|
|
|
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
2020-02-22 20:36:22 +00:00
|
|
|
<CdfChart__Plain
|
|
|
|
minX
|
|
|
|
maxX
|
|
|
|
?discrete
|
|
|
|
?continuous
|
|
|
|
color={`hex("333")}
|
|
|
|
onHover
|
|
|
|
timeScale
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-22 23:55:43 +00:00
|
|
|
module IntegralChart = {
|
|
|
|
[@react.component]
|
2020-02-23 12:49:33 +00:00
|
|
|
let make = (~distPlus: DistributionTypes.distPlus, ~onHover) => {
|
|
|
|
open DistFunctor.DistPlus;
|
|
|
|
let integral = DistFunctor.DistPlus.T.Integral.get(~cache=None, distPlus);
|
2020-02-22 23:55:43 +00:00
|
|
|
let continuous =
|
|
|
|
integral
|
|
|
|
|> T.toContinuous
|
|
|
|
|> E.O.fmap(DistFunctor.Continuous.toLinear)
|
|
|
|
|> E.O.fmap(DistFunctor.Continuous.getShape);
|
|
|
|
let minX = T.minX(integral);
|
|
|
|
let maxX = T.maxX(integral);
|
2020-02-23 12:49:33 +00:00
|
|
|
let timeScale = distPlus.unit |> DistributionTypes.DistributionUnit.toJson;
|
2020-02-22 23:55:43 +00:00
|
|
|
<CdfChart__Plain
|
|
|
|
minX
|
|
|
|
maxX
|
|
|
|
?continuous
|
|
|
|
color={`hex("333")}
|
|
|
|
timeScale
|
|
|
|
onHover
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-22 20:36:22 +00:00
|
|
|
[@react.component]
|
2020-02-23 12:49:33 +00:00
|
|
|
let make = (~distPlus: DistributionTypes.distPlus) => {
|
2020-02-22 20:36:22 +00:00
|
|
|
let (x, setX) = React.useState(() => 0.);
|
|
|
|
let chart =
|
|
|
|
React.useMemo1(
|
2020-02-23 12:49:33 +00:00
|
|
|
() => {<DistPlusChart distPlus onHover={r => {setX(_ => r)}} />},
|
|
|
|
[|distPlus|],
|
2020-02-22 20:36:22 +00:00
|
|
|
);
|
2020-02-22 23:55:43 +00:00
|
|
|
let chart2 =
|
|
|
|
React.useMemo1(
|
2020-02-23 12:49:33 +00:00
|
|
|
() => {<IntegralChart distPlus onHover={r => {setX(_ => r)}} />},
|
|
|
|
[|distPlus|],
|
2020-02-22 23:55:43 +00:00
|
|
|
);
|
2020-02-22 20:36:22 +00:00
|
|
|
<div>
|
|
|
|
chart
|
2020-02-22 23:55:43 +00:00
|
|
|
chart2
|
2020-02-22 20:36:22 +00:00
|
|
|
<table className="table-auto">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th className="px-4 py-2"> {"X Point" |> ReasonReact.string} </th>
|
|
|
|
<th className="px-4 py-2">
|
|
|
|
{"Y Integral to Point" |> ReasonReact.string}
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th className="px-4 py-2 border ">
|
|
|
|
{x |> E.Float.toString |> ReasonReact.string}
|
|
|
|
</th>
|
|
|
|
<th className="px-4 py-2 border ">
|
2020-02-23 12:49:33 +00:00
|
|
|
{distPlus
|
|
|
|
|> DistFunctor.DistPlus.T.Integral.xToY(~cache=None, x)
|
2020-02-22 20:36:22 +00:00
|
|
|
|> E.Float.with2DigitsPrecision
|
|
|
|
|> ReasonReact.string}
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div />
|
|
|
|
</div>;
|
|
|
|
};
|