From 6b9b0760b1e0dd322f6d18a1ac015ab95907d141 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Mon, 26 Sep 2022 17:37:39 -0700 Subject: [PATCH] Make numeric chart bucket points less wrong --- web/components/charts/contract/numeric.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/web/components/charts/contract/numeric.tsx b/web/components/charts/contract/numeric.tsx index 7ba7e3e9..d992362f 100644 --- a/web/components/charts/contract/numeric.tsx +++ b/web/components/charts/contract/numeric.tsx @@ -12,10 +12,9 @@ import { useElementWidth } from 'web/hooks/use-element-width' const getNumericChartData = (contract: NumericContract) => { const { totalShares, bucketCount, min, max } = contract + const step = (max - min) / bucketCount const bucketProbs = getDpmOutcomeProbabilities(totalShares) - const xs = range(bucketCount).map( - (i) => min + ((max - min) * i) / bucketCount - ) + const xs = range(bucketCount).map((i) => min + step * (i + 0.5)) const probs = range(bucketCount).map((i) => bucketProbs[`${i}`]) return probs.map((prob, i) => [xs[i], prob] as const) }