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