Simple renaming and light cleanup
This commit is contained in:
parent
c3ca1a1a57
commit
a6f5aa7fc0
|
@ -3,23 +3,10 @@ let data: DistributionTypes.xyShape = {
|
||||||
ys: [|0.0, 0.0, 0.1, 0.3, 0.5, 0.2, 0.1|],
|
ys: [|0.0, 0.0, 0.1, 0.3, 0.5, 0.2, 0.1|],
|
||||||
};
|
};
|
||||||
|
|
||||||
let mixedDist =
|
|
||||||
GenericDistribution.make(
|
|
||||||
~generationSource=
|
|
||||||
GuesstimatorString(
|
|
||||||
"mm(floor(uniform(20, 30)), normal(50,10), [.5,.5])",
|
|
||||||
),
|
|
||||||
~probabilityType=Pdf,
|
|
||||||
~domain=Complete,
|
|
||||||
~unit=UnspecifiedDistribution,
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
|
||||||
|
|
||||||
// "mm(floor(uniform(30,35)), normal(50,20), [.25,.5])",
|
// "mm(floor(uniform(30,35)), normal(50,20), [.25,.5])",
|
||||||
let timeDist =
|
let timeDist =
|
||||||
GenericDistribution.make(
|
GenericDistribution.make(
|
||||||
~generationSource=GuesstimatorString("floor(normal(30,2))"),
|
~generationSource=GuesstimatorString("floor(normal(30,3))"),
|
||||||
~probabilityType=Pdf,
|
~probabilityType=Pdf,
|
||||||
~domain=Complete,
|
~domain=Complete,
|
||||||
~unit=TimeDistribution({zero: MomentRe.momentNow(), unit: `days}),
|
~unit=TimeDistribution({zero: MomentRe.momentNow(), unit: `days}),
|
||||||
|
@ -27,16 +14,6 @@ let timeDist =
|
||||||
)
|
)
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
||||||
|
|
||||||
let domainLimitedDist =
|
|
||||||
GenericDistribution.make(
|
|
||||||
~generationSource=GuesstimatorString("mm(3, normal(5,1), [.5,.5])"),
|
|
||||||
~probabilityType=Pdf,
|
|
||||||
~domain=RightLimited({xPoint: 6.0, excludingProbabilityMass: 0.3}),
|
|
||||||
~unit=UnspecifiedDistribution,
|
|
||||||
(),
|
|
||||||
)
|
|
||||||
|> GenericDistribution.renderIfNeeded(~sampleCount=1000);
|
|
||||||
|
|
||||||
let distributions = () =>
|
let distributions = () =>
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -24,7 +24,7 @@ let make =
|
||||||
~maxX=?,
|
~maxX=?,
|
||||||
~minX=?,
|
~minX=?,
|
||||||
~onHover=(f: float) => (),
|
~onHover=(f: float) => (),
|
||||||
~primaryDistribution=?,
|
~continuous=?,
|
||||||
~discrete=?,
|
~discrete=?,
|
||||||
~scale=?,
|
~scale=?,
|
||||||
~showDistributionLines=?,
|
~showDistributionLines=?,
|
||||||
|
@ -44,7 +44,7 @@ let make =
|
||||||
~maxX?,
|
~maxX?,
|
||||||
~minX?,
|
~minX?,
|
||||||
~onHover,
|
~onHover,
|
||||||
~primaryDistribution?,
|
~continuous?,
|
||||||
~discrete?,
|
~discrete?,
|
||||||
~scale?,
|
~scale?,
|
||||||
~showDistributionLines?,
|
~showDistributionLines?,
|
||||||
|
|
|
@ -32,7 +32,7 @@ let make =
|
||||||
~maxX=?,
|
~maxX=?,
|
||||||
~minX=?,
|
~minX=?,
|
||||||
~onHover: float => unit,
|
~onHover: float => unit,
|
||||||
~primaryDistribution=?,
|
~continuous=?,
|
||||||
~scale=?,
|
~scale=?,
|
||||||
~showDistributionLines=false,
|
~showDistributionLines=false,
|
||||||
~showDistributionYAxis=false,
|
~showDistributionYAxis=false,
|
||||||
|
@ -45,14 +45,12 @@ let make =
|
||||||
?minX
|
?minX
|
||||||
?scale
|
?scale
|
||||||
?timeScale
|
?timeScale
|
||||||
discrete={discrete |> E.O.fmap(d => d |> Shape.Discrete.toJs)}
|
discrete={discrete |> E.O.fmap(Shape.Discrete.toJs)}
|
||||||
height
|
height
|
||||||
marginBottom=50
|
marginBottom=50
|
||||||
marginTop=0
|
marginTop=0
|
||||||
onHover
|
onHover
|
||||||
primaryDistribution={
|
continuous={continuous |> E.O.fmap(Shape.XYShape.toJs)}
|
||||||
primaryDistribution |> E.O.fmap(pd => pd |> Shape.XYShape.toJs)
|
|
||||||
}
|
|
||||||
showDistributionLines
|
showDistributionLines
|
||||||
showDistributionYAxis
|
showDistributionYAxis
|
||||||
showVerticalLine
|
showVerticalLine
|
||||||
|
|
|
@ -7,7 +7,7 @@ module Mixed = {
|
||||||
React.useMemo1(
|
React.useMemo1(
|
||||||
() =>
|
() =>
|
||||||
<CdfChart__Plain
|
<CdfChart__Plain
|
||||||
primaryDistribution={data.continuous}
|
continuous={data.continuous}
|
||||||
discrete={data.discrete}
|
discrete={data.discrete}
|
||||||
color={`hex("333")}
|
color={`hex("333")}
|
||||||
timeScale
|
timeScale
|
||||||
|
@ -99,18 +99,15 @@ module Shapee = {
|
||||||
Shape.Any.maxX(shape);
|
Shape.Any.maxX(shape);
|
||||||
};
|
};
|
||||||
<div>
|
<div>
|
||||||
{continuous
|
|
||||||
|> E.O.React.fmapOrNull(continuous =>
|
|
||||||
<CdfChart__Plain
|
<CdfChart__Plain
|
||||||
primaryDistribution=continuous
|
|
||||||
minX
|
minX
|
||||||
maxX
|
maxX
|
||||||
?discrete
|
?discrete
|
||||||
|
?continuous
|
||||||
color={`hex("333")}
|
color={`hex("333")}
|
||||||
onHover
|
onHover
|
||||||
timeScale
|
timeScale
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
{discrete |> E.O.React.fmapOrNull(Shape.Discrete.render)}
|
{discrete |> E.O.React.fmapOrNull(Shape.Discrete.render)}
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,7 @@ export class CdfChartD3 {
|
||||||
verticalLine: 110,
|
verticalLine: 110,
|
||||||
showVerticalLine: true,
|
showVerticalLine: true,
|
||||||
data: {
|
data: {
|
||||||
primary: null,
|
continuous: null,
|
||||||
discrete: null,
|
discrete: null,
|
||||||
},
|
},
|
||||||
onHover: (e) => {
|
onHover: (e) => {
|
||||||
|
@ -165,7 +165,7 @@ export class CdfChartD3 {
|
||||||
'translate(' + this.calc.chartLeftMargin + ',' + this.calc.chartTopMargin + ')',
|
'translate(' + this.calc.chartLeftMargin + ',' + this.calc.chartTopMargin + ')',
|
||||||
);
|
);
|
||||||
|
|
||||||
if(this.hasDate('primary')){
|
if(this.hasDate('continuous')){
|
||||||
const distributionChart = this.addDistributionChart();
|
const distributionChart = this.addDistributionChart();
|
||||||
if(this.hasDate('discrete')) {
|
if(this.hasDate('discrete')) {
|
||||||
this.addLollipopsChart(distributionChart);
|
this.addLollipopsChart(distributionChart);
|
||||||
|
@ -176,13 +176,13 @@ export class CdfChartD3 {
|
||||||
|
|
||||||
addDistributionChart() {
|
addDistributionChart() {
|
||||||
const areaColorRange = d3.scaleOrdinal().range(this.attrs.areaColors);
|
const areaColorRange = d3.scaleOrdinal().range(this.attrs.areaColors);
|
||||||
const dataPoints = [this.getDataPoints('primary')];
|
const dataPoints = [this.getDataPoints('continuous')];
|
||||||
|
|
||||||
// Boundaries.
|
// Boundaries.
|
||||||
const xMin = this.attrs.minX || d3.min(this.attrs.data.primary.xs);
|
const xMin = this.attrs.minX || d3.min(this.attrs.data.continuous.xs) | d3.min(this.attrs.data.discrete.xs);
|
||||||
const xMax = this.attrs.maxX || d3.max(this.attrs.data.primary.xs);
|
const xMax = this.attrs.maxX || d3.max(this.attrs.data.continuous.xs) | d3.max(this.attrs.data.discrete.xs);
|
||||||
const yMin = d3.min(this.attrs.data.primary.ys);
|
const yMin = d3.min(this.attrs.data.continuous.ys);
|
||||||
const yMax = d3.max(this.attrs.data.primary.ys);
|
const yMax = d3.max(this.attrs.data.continuous.ys);
|
||||||
|
|
||||||
// Scales.
|
// Scales.
|
||||||
let xScale = null;
|
let xScale = null;
|
||||||
|
|
|
@ -50,7 +50,7 @@ function CdfChartReact(props) {
|
||||||
.showVerticalLine(props.showVerticalLine)
|
.showVerticalLine(props.showVerticalLine)
|
||||||
.container(containerRef.current)
|
.container(containerRef.current)
|
||||||
.data({
|
.data({
|
||||||
primary: props.primaryDistribution,
|
continuous: props.continuous,
|
||||||
discrete: props.discrete,
|
discrete: props.discrete,
|
||||||
})
|
})
|
||||||
.scale(scale)
|
.scale(scale)
|
||||||
|
|
|
@ -35,7 +35,6 @@ let renderIfNeeded =
|
||||||
| _ => None
|
| _ => None
|
||||||
};
|
};
|
||||||
|
|
||||||
Js.log(newShape);
|
|
||||||
newShape
|
newShape
|
||||||
|> E.O.fmap((shape: DistributionTypes.pointsType) =>
|
|> E.O.fmap((shape: DistributionTypes.pointsType) =>
|
||||||
make(
|
make(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user