Make sure that chart minimum is shown

This commit is contained in:
Ozzie Gooen 2020-02-25 19:55:01 +00:00
parent c30fab22c7
commit ddd0bc0820
9 changed files with 36 additions and 23 deletions

View File

@ -1,6 +1,7 @@
// "mm(floor(uniform(30,35)), normal(50,20), [.25,.5])",
// "mm(floor(normal(28,4)), normal(32,2), uniform(20,24), [.5,.2,.1])",
// "mm(5 to 20, floor(normal(20,2)), [.5, .5])",
let timeDist =
DistPlusIngredients.make(
~guesstimatorString="(floor(10 to 15))",
@ -24,7 +25,8 @@ let distributions = () =>
<h2> {"Single-Discrete" |> ReasonReact.string} </h2>
{setup(
DistPlusIngredients.make(
~guesstimatorString="mm(5 to 20, floor(normal(20,2)), [.5, .5])",
~guesstimatorString=
"uniform(0,1) > 0.036 ? lognormal(6.652, -0.41): 0",
~domain=
RightLimited({xPoint: 50.0, excludingProbabilityMass: 0.3}),
(),

View File

@ -7,7 +7,13 @@ module DistPlusChart = {
distPlus
|> T.toScaledContinuous
|> E.O.fmap(Distributions.Continuous.getShape);
let minX = T.minX(distPlus);
let range = T.xTotalRange(distPlus);
let minX =
switch (T.minX(distPlus), range) {
| (Some(min), Some(range)) => Some(min -. range *. 0.001)
| _ => None
};
let maxX = T.maxX(distPlus);
let timeScale = distPlus.unit |> DistTypes.DistributionUnit.toJson;
<DistributionPlot

View File

@ -40,8 +40,8 @@ function CdfChartReact(props) {
.minX(props.minX)
.onHover(props.onHover)
.marginBottom(props.marginBottom || 15)
.marginLeft(5)
.marginRight(5)
.marginLeft(30)
.marginRight(30)
.marginTop(5)
.showDistributionLines(props.showDistributionLines)
.showDistributionYAxis(props.showDistributionYAxis)

View File

@ -216,8 +216,9 @@ module Mixed = {
Dist({
type t = DistTypes.mixedShape;
type integral = DistTypes.continuousShape;
let minX = ({continuous, discrete}: t) =>
let minX = ({continuous, discrete}: t) => {
min(Continuous.T.minX(continuous), Discrete.T.minX(discrete));
};
let maxX = ({continuous, discrete}: t) =>
max(Continuous.T.maxX(continuous), Discrete.T.maxX(discrete));
let toShape = (t: t): DistTypes.shape => Mixed(t);

View File

@ -63,8 +63,9 @@ module RelativeTimePoint = {
|> MomentRe.Moment.add(~duration=MomentRe.duration(r, timeVector.unit))
};
let _timeToX = (time, timeStart, timeUnit) =>
MomentRe.diff(timeStart, time, timeUnit);
let _timeToX = (time, timeStart, timeUnit) => {
MomentRe.diff(time, timeStart, timeUnit);
};
let toXValue = (timeVector: timeVector, timeInVector: timeInVector) =>
switch (timeInVector) {

View File

@ -17,12 +17,20 @@ let propValue = (t: Prop.Value.t) => {
switch (t) {
| SelectSingle(r) => r |> ReasonReact.string
| ConditionalArray(r) => "Array" |> ReasonReact.string
| DistPlusIngredients(r) =>
| DistPlusIngredients((r: DistTypes.distPlusIngredients)) =>
let newDistribution =
DistPlusIngredients.toDistPlus(~sampleCount=1000, r);
DistPlusIngredients.toDistPlus(
~sampleCount=2000,
~outputXYPoints=2000,
~truncateTo=Some(100),
r,
);
switch (newDistribution) {
| Some(distribution) =>
<div> <DistPlusPlot distPlus=distribution /> </div>
<div>
<DistPlusPlot distPlus=distribution />
{r.guesstimatorString |> ReasonReact.string}
</div>
| None => "Something went wrong" |> ReasonReact.string
};
| FloatCdf(_) => <div />

View File

@ -1,21 +1,16 @@
let guesstimatorString = "normal(40,10)";
let guesstimatorString = "uniform(1, 100)";
let makeI = (currentDateTime: MomentRe.Moment.t) => {
DistPlusIngredients.make(
~guesstimatorString,
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
~domain=RightLimited({xPoint: 300.0, excludingProbabilityMass: 0.3}),
(),
);
};
module Model = {
let make = (currentDateTime: MomentRe.Moment.t) => {
let distPlusIngredients =
DistPlusIngredients.make(
~guesstimatorString,
~unit=TimeDistribution({zero: currentDateTime, unit: `years}),
(),
);
Prop.Value.DistPlusIngredients(distPlusIngredients);
Prop.Value.DistPlusIngredients(makeI(currentDateTime));
};
};

View File

@ -52,8 +52,8 @@ module Internals = {
let stringToMixedShape =
(
~string,
~sampleCount=1000,
~outputXYPoints=1000,
~sampleCount=3000,
~outputXYPoints=3000,
~truncateTo=Some(500),
(),
) =>

View File

@ -13,9 +13,9 @@ const minMaxRatio = (minValue, maxValue) => {
return 'SMALL';
}
const ratio = maxValue / minValue;
if (ratio < 100000) {
if (ratio < 10000) {
return 'SMALL';
} else if (ratio < 10000000) {
} else if (ratio < 1000000) {
return 'MEDIUM';
} else {
return 'LARGE';
@ -46,7 +46,7 @@ const toPdf = (values, outputResolutionCount, min, max) => {
const samples = new Samples(continuousSamples);
const ratioSize$ = ratioSize(samples);
const width = ratioSize$ === 'SMALL' ? 100 : 1;
const width = ratioSize$ === 'SMALL' ? 40 : 1;
const pdf = samples.toPdf({ size: outputResolutionCount, width, min, max });
continuous = pdf;