From d125664e5768748217052e92741fafca494d8e62 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Mon, 6 Jun 2022 12:25:09 -0700 Subject: [PATCH] Added stdev to table of stats, when needed --- packages/components/src/components/DistributionChart.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/components/src/components/DistributionChart.tsx b/packages/components/src/components/DistributionChart.tsx index 18dd2a3e..276e73d5 100644 --- a/packages/components/src/components/DistributionChart.tsx +++ b/packages/components/src/components/DistributionChart.tsx @@ -153,6 +153,7 @@ type SummaryTableProps = { const SummaryTable: React.FC = ({ distribution }) => { const mean = distribution.mean(); + const stdev = distribution.stdev(); const p5 = distribution.inv(0.05); const p10 = distribution.inv(0.1); const p25 = distribution.inv(0.25); @@ -161,6 +162,9 @@ const SummaryTable: React.FC = ({ distribution }) => { const p90 = distribution.inv(0.9); const p95 = distribution.inv(0.95); + const hasResult = (x: result): boolean => + x.tag === "Ok"; + const unwrapResult = ( x: result ): React.ReactNode => { @@ -180,6 +184,7 @@ const SummaryTable: React.FC = ({ distribution }) => { {"Mean"} + {hasResult(stdev) && {"Stdev"}} {"5%"} {"10%"} {"25%"} @@ -192,6 +197,7 @@ const SummaryTable: React.FC = ({ distribution }) => { {unwrapResult(mean)} + {hasResult(stdev) && {unwrapResult(stdev)}} {unwrapResult(p5)} {unwrapResult(p10)} {unwrapResult(p25)}