2020-02-23 12:49:33 +00:00
|
|
|
module DistPlusChart = {
|
2020-02-22 20:36:22 +00:00
|
|
|
[@react.component]
|
2020-02-23 13:27:52 +00:00
|
|
|
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
2020-02-23 13:14:14 +00:00
|
|
|
open Distributions.DistPlus;
|
2020-02-23 18:59:04 +00:00
|
|
|
// todo: Change to scaledContinuous and scaledDiscrete
|
2020-02-23 12:49:33 +00:00
|
|
|
let discrete = distPlus |> T.toDiscrete;
|
2020-02-22 20:36:22 +00:00
|
|
|
let continuous =
|
2020-02-23 13:14:14 +00:00
|
|
|
distPlus
|
|
|
|
|> T.toContinuous
|
|
|
|
|> E.O.fmap(Distributions.Continuous.getShape);
|
2020-02-23 12:49:33 +00:00
|
|
|
let minX = T.minX(distPlus);
|
|
|
|
let maxX = T.maxX(distPlus);
|
2020-02-23 13:27:52 +00:00
|
|
|
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
2020-02-23 18:34:34 +00:00
|
|
|
<DistributionPlot
|
2020-02-22 20:36:22 +00:00
|
|
|
minX
|
|
|
|
maxX
|
|
|
|
?discrete
|
|
|
|
?continuous
|
|
|
|
color={`hex("333")}
|
|
|
|
onHover
|
|
|
|
timeScale
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-22 23:55:43 +00:00
|
|
|
module IntegralChart = {
|
|
|
|
[@react.component]
|
2020-02-23 13:27:52 +00:00
|
|
|
let make = (~distPlus: DistTypes.distPlus, ~onHover) => {
|
2020-02-23 13:14:14 +00:00
|
|
|
open Distributions.DistPlus;
|
|
|
|
let integral =
|
2020-02-24 22:04:39 +00:00
|
|
|
Distributions.DistPlus.T.toShape(distPlus)
|
|
|
|
|> Distributions.Shape.T.Integral.get(~cache=None);
|
2020-02-22 23:55:43 +00:00
|
|
|
let continuous =
|
|
|
|
integral
|
2020-02-24 22:04:39 +00:00
|
|
|
|> Distributions.Continuous.toLinear
|
2020-02-23 13:14:14 +00:00
|
|
|
|> E.O.fmap(Distributions.Continuous.getShape);
|
2020-02-24 22:04:39 +00:00
|
|
|
let minX = integral |> Distributions.Continuous.T.minX;
|
|
|
|
let maxX = integral |> Distributions.Continuous.T.maxX;
|
2020-02-23 13:27:52 +00:00
|
|
|
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
|
2020-02-23 18:34:34 +00:00
|
|
|
<DistributionPlot
|
2020-02-22 23:55:43 +00:00
|
|
|
minX
|
|
|
|
maxX
|
|
|
|
?continuous
|
|
|
|
color={`hex("333")}
|
|
|
|
timeScale
|
|
|
|
onHover
|
|
|
|
/>;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-02-22 20:36:22 +00:00
|
|
|
[@react.component]
|
2020-02-23 13:27:52 +00:00
|
|
|
let make = (~distPlus: DistTypes.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>
|
2020-02-23 20:50:27 +00:00
|
|
|
<th className="px-4 py-2">
|
|
|
|
{"Discrete Value" |> ReasonReact.string}
|
|
|
|
</th>
|
|
|
|
<th className="px-4 py-2">
|
|
|
|
{"Continuous Value" |> ReasonReact.string}
|
|
|
|
</th>
|
2020-02-22 20:36:22 +00:00
|
|
|
<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>
|
2020-02-23 20:50:27 +00:00
|
|
|
<th className="px-4 py-2 border ">
|
|
|
|
{distPlus
|
|
|
|
|> Distributions.DistPlus.T.xToY(x)
|
|
|
|
|> DistTypes.MixedPoint.toDiscreteValue
|
2020-02-24 16:39:55 +00:00
|
|
|
|> Js.Float.toPrecisionWithPrecision(_, ~digits=7)
|
2020-02-23 20:50:27 +00:00
|
|
|
|> ReasonReact.string}
|
|
|
|
</th>
|
|
|
|
<th className="px-4 py-2 border ">
|
|
|
|
{distPlus
|
|
|
|
|> Distributions.DistPlus.T.xToY(x)
|
|
|
|
|> DistTypes.MixedPoint.toContinuousValue
|
2020-02-24 16:39:55 +00:00
|
|
|
|> Js.Float.toPrecisionWithPrecision(_, ~digits=7)
|
2020-02-23 20:50:27 +00:00
|
|
|
|> ReasonReact.string}
|
|
|
|
</th>
|
2020-02-22 20:36:22 +00:00
|
|
|
<th className="px-4 py-2 border ">
|
2020-02-23 12:49:33 +00:00
|
|
|
{distPlus
|
2020-02-23 13:14:14 +00:00
|
|
|
|> Distributions.DistPlus.T.Integral.xToY(~cache=None, x)
|
2020-02-22 20:36:22 +00:00
|
|
|
|> E.Float.with2DigitsPrecision
|
|
|
|
|> ReasonReact.string}
|
|
|
|
</th>
|
2020-02-24 21:01:29 +00:00
|
|
|
<th className="px-4 py-2 border ">
|
|
|
|
{distPlus
|
|
|
|
|> Distributions.DistPlus.T.Integral.sum(~cache=None)
|
|
|
|
|> E.Float.with2DigitsPrecision
|
|
|
|
|> ReasonReact.string}
|
|
|
|
</th>
|
2020-02-22 20:36:22 +00:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div />
|
|
|
|
</div>;
|
2020-02-24 21:01:29 +00:00
|
|
|
// chart
|
2020-02-22 20:36:22 +00:00
|
|
|
};
|