Adds stop conditions

This commit is contained in:
Roman Galochkin 2020-02-20 14:08:51 +03:00
parent 972c9058ef
commit 513df940c8
5 changed files with 26 additions and 7 deletions

View File

@ -28,6 +28,7 @@ let make =
~discrete=?, ~discrete=?,
~scale=?, ~scale=?,
~showDistributionLines=?, ~showDistributionLines=?,
~showDistributionYAxis=?,
~showVerticalLine=?, ~showVerticalLine=?,
~timeScale=?, ~timeScale=?,
~verticalLine=?, ~verticalLine=?,
@ -47,6 +48,7 @@ let make =
~discrete?, ~discrete?,
~scale?, ~scale?,
~showDistributionLines?, ~showDistributionLines?,
~showDistributionYAxis?,
~showVerticalLine?, ~showVerticalLine?,
~timeScale?, ~timeScale?,
~verticalLine?, ~verticalLine?,

View File

@ -27,13 +27,16 @@ module Styles = {
let make = let make =
( (
~color=`hex("111"), ~color=`hex("111"),
~primaryDistribution=?,
~discrete=?, ~discrete=?,
~height=200, ~height=200,
~maxX=?, ~maxX=?,
~minX=?, ~minX=?,
~onHover: float => unit, ~onHover: float => unit,
~primaryDistribution=?,
~scale=?, ~scale=?,
~showDistributionLines=false,
~showDistributionYAxis=false,
~showVerticalLine=false,
~timeScale=?, ~timeScale=?,
) => { ) => {
<div className={Styles.graph(color)}> <div className={Styles.graph(color)}>
@ -42,6 +45,7 @@ let make =
?minX ?minX
?scale ?scale
?timeScale ?timeScale
discrete={discrete |> E.O.fmap(d => d |> Shape.Discrete.toJs)}
height height
marginBottom=50 marginBottom=50
marginTop=0 marginTop=0
@ -49,9 +53,9 @@ let make =
primaryDistribution={ primaryDistribution={
primaryDistribution |> E.O.fmap(pd => pd |> Shape.XYShape.toJs) primaryDistribution |> E.O.fmap(pd => pd |> Shape.XYShape.toJs)
} }
discrete={discrete |> E.O.fmap(d => d |> Shape.Discrete.toJs)} showDistributionLines
showDistributionLines=false showDistributionYAxis
showVerticalLine=false showVerticalLine
/> />
</div>; </div>;
}; };

View File

@ -16,6 +16,7 @@ module Mixed = {
color={`hex("333")} color={`hex("333")}
timeScale timeScale
onHover={r => setX(_ => r)} onHover={r => setX(_ => r)}
showDistributionYAxis=true
/>, />,
[|data|], [|data|],
); );

View File

@ -20,11 +20,15 @@ export class CdfChartD3 {
scale: 'linear', scale: 'linear',
timeScale: null, timeScale: null,
showDistributionLines: true, showDistributionLines: true,
showDistributionYAxis: false,
areaColors: ['#E1E5EC', '#E1E5EC'], areaColors: ['#E1E5EC', '#E1E5EC'],
logBase: 10, logBase: 10,
verticalLine: 110, verticalLine: 110,
showVerticalLine: true, showVerticalLine: true,
data: null, data: {
primary: null,
discrete: null,
},
onHover: (e) => { onHover: (e) => {
}, },
}; };
@ -103,6 +107,11 @@ export class CdfChartD3 {
return this; return this;
} }
showDistributionYAxis(showDistributionYAxis) {
this.attrs.showDistributionYAxis = showDistributionYAxis;
return this;
}
verticalLine(verticalLine) { verticalLine(verticalLine) {
this.attrs.verticalLine = verticalLine; this.attrs.verticalLine = verticalLine;
return this; return this;
@ -243,8 +252,10 @@ export class CdfChartD3 {
.attr('transform', 'translate(0,' + this.calc.chartHeight + ')') .attr('transform', 'translate(0,' + this.calc.chartHeight + ')')
.call(xAxis); .call(xAxis);
if (this.attrs.showDistributionYAxis) {
this.chart.createObject({ tag: 'g', selector: 'y-axis' }) this.chart.createObject({ tag: 'g', selector: 'y-axis' })
.call(yAxis); .call(yAxis);
}
// Draw area. // Draw area.
this.chart this.chart

View File

@ -45,6 +45,7 @@ function CdfChartReact(props) {
.marginRight(5) .marginRight(5)
.marginTop(5) .marginTop(5)
.showDistributionLines(props.showDistributionLines) .showDistributionLines(props.showDistributionLines)
.showDistributionYAxis(props.showDistributionYAxis)
.verticalLine(props.verticalLine) .verticalLine(props.verticalLine)
.showVerticalLine(props.showVerticalLine) .showVerticalLine(props.showVerticalLine)
.container(containerRef.current) .container(containerRef.current)