From 513df940c8f900c48982c61ff7dfff7a159a36b7 Mon Sep 17 00:00:00 2001 From: Roman Galochkin Date: Thu, 20 Feb 2020 14:08:51 +0300 Subject: [PATCH] Adds stop conditions --- src/components/charts/CdfChart__Base.re | 2 ++ src/components/charts/CdfChart__Plain.re | 12 ++++++++---- .../charts/GenericDistributionChart.re | 1 + src/components/charts/cdfChartD3.js | 17 ++++++++++++++--- src/components/charts/cdfChartReact.js | 1 + 5 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/components/charts/CdfChart__Base.re b/src/components/charts/CdfChart__Base.re index 96fd0f7c..fdd2d8e4 100644 --- a/src/components/charts/CdfChart__Base.re +++ b/src/components/charts/CdfChart__Base.re @@ -28,6 +28,7 @@ let make = ~discrete=?, ~scale=?, ~showDistributionLines=?, + ~showDistributionYAxis=?, ~showVerticalLine=?, ~timeScale=?, ~verticalLine=?, @@ -47,6 +48,7 @@ let make = ~discrete?, ~scale?, ~showDistributionLines?, + ~showDistributionYAxis?, ~showVerticalLine?, ~timeScale?, ~verticalLine?, diff --git a/src/components/charts/CdfChart__Plain.re b/src/components/charts/CdfChart__Plain.re index 53bdde40..f283b3db 100644 --- a/src/components/charts/CdfChart__Plain.re +++ b/src/components/charts/CdfChart__Plain.re @@ -27,13 +27,16 @@ module Styles = { let make = ( ~color=`hex("111"), - ~primaryDistribution=?, ~discrete=?, ~height=200, ~maxX=?, ~minX=?, ~onHover: float => unit, + ~primaryDistribution=?, ~scale=?, + ~showDistributionLines=false, + ~showDistributionYAxis=false, + ~showVerticalLine=false, ~timeScale=?, ) => {
@@ -42,6 +45,7 @@ let make = ?minX ?scale ?timeScale + discrete={discrete |> E.O.fmap(d => d |> Shape.Discrete.toJs)} height marginBottom=50 marginTop=0 @@ -49,9 +53,9 @@ let make = primaryDistribution={ primaryDistribution |> E.O.fmap(pd => pd |> Shape.XYShape.toJs) } - discrete={discrete |> E.O.fmap(d => d |> Shape.Discrete.toJs)} - showDistributionLines=false - showVerticalLine=false + showDistributionLines + showDistributionYAxis + showVerticalLine />
; }; \ No newline at end of file diff --git a/src/components/charts/GenericDistributionChart.re b/src/components/charts/GenericDistributionChart.re index 5c11cea9..54447ac7 100644 --- a/src/components/charts/GenericDistributionChart.re +++ b/src/components/charts/GenericDistributionChart.re @@ -16,6 +16,7 @@ module Mixed = { color={`hex("333")} timeScale onHover={r => setX(_ => r)} + showDistributionYAxis=true />, [|data|], ); diff --git a/src/components/charts/cdfChartD3.js b/src/components/charts/cdfChartD3.js index 0d3c35ba..13fde107 100644 --- a/src/components/charts/cdfChartD3.js +++ b/src/components/charts/cdfChartD3.js @@ -20,11 +20,15 @@ export class CdfChartD3 { scale: 'linear', timeScale: null, showDistributionLines: true, + showDistributionYAxis: false, areaColors: ['#E1E5EC', '#E1E5EC'], logBase: 10, verticalLine: 110, showVerticalLine: true, - data: null, + data: { + primary: null, + discrete: null, + }, onHover: (e) => { }, }; @@ -103,6 +107,11 @@ export class CdfChartD3 { return this; } + showDistributionYAxis(showDistributionYAxis) { + this.attrs.showDistributionYAxis = showDistributionYAxis; + return this; + } + verticalLine(verticalLine) { this.attrs.verticalLine = verticalLine; return this; @@ -243,8 +252,10 @@ export class CdfChartD3 { .attr('transform', 'translate(0,' + this.calc.chartHeight + ')') .call(xAxis); - this.chart.createObject({ tag: 'g', selector: 'y-axis' }) - .call(yAxis); + if (this.attrs.showDistributionYAxis) { + this.chart.createObject({ tag: 'g', selector: 'y-axis' }) + .call(yAxis); + } // Draw area. this.chart diff --git a/src/components/charts/cdfChartReact.js b/src/components/charts/cdfChartReact.js index 20d41861..0425e400 100644 --- a/src/components/charts/cdfChartReact.js +++ b/src/components/charts/cdfChartReact.js @@ -45,6 +45,7 @@ function CdfChartReact(props) { .marginRight(5) .marginTop(5) .showDistributionLines(props.showDistributionLines) + .showDistributionYAxis(props.showDistributionYAxis) .verticalLine(props.verticalLine) .showVerticalLine(props.showVerticalLine) .container(containerRef.current)